Official version of jdt.core v_308 corresponding to 1.1rc3b
diff --git a/org.eclipse.jdt.core/.options b/org.eclipse.jdt.core/.options
index bdf9a49..3785b10 100644
--- a/org.eclipse.jdt.core/.options
+++ b/org.eclipse.jdt.core/.options
@@ -1,38 +1,41 @@
-# Turn on debug tracing for org.eclipse.jdt.core plugin
-org.eclipse.jdt.core/debug=true
-
-# Reports background indexer activity: indexing, saving index file, index queries
-org.eclipse.jdt.core/debug/indexmanager=false
-
-# Reports compiler activity
-org.eclipse.jdt.core/debug/compiler=false
-
-# Reports Java model elements opening/closing
-org.eclipse.jdt.core/debug/javamodel=false
-
-# Reports shared working copy use
-org.eclipse.jdt.core/debug/sharedworkingcopy=false
-
-# Reports classpath variable initialization, and classpath container resolution
-org.eclipse.jdt.core/debug/cpresolution=false
-
-# Reports access to zip and jar files through the Java model
-org.eclipse.jdt.core/debug/zipaccess=false
-
-# Print notified Java element deltas
-org.eclipse.jdt.core/debug/javadelta=false
-
-# Report type hierarchy connections, refreshes and deltas
-org.eclipse.jdt.core/debug/hierarchy=false
-
-# Reports incremental builder activity : nature of build, built state reading, indictment process
-org.eclipse.jdt.core/debug/builder=false
-
-# Reports codeassist completion activity : recovered unit, inferred completions
-org.eclipse.jdt.core/debug/completion=false
-
-# Reports open on selection activity : recovered unit, inferred selection
-org.eclipse.jdt.core/debug/selection=false
-
-# Reports java search activity
-org.eclipse.jdt.core/debug/search=false
\ No newline at end of file
+# Turn on debug tracing for org.eclipse.jdt.core plugin
+org.eclipse.jdt.core/debug=true
+
+# Reports incremental builder activity : nature of build, built state reading, indictment process
+org.eclipse.jdt.core/debug/builder=false
+
+# Reports compiler activity
+org.eclipse.jdt.core/debug/compiler=false
+
+# Reports codeassist completion activity : recovered unit, inferred completions
+org.eclipse.jdt.core/debug/completion=false
+
+# Reports classpath variable initialization, and classpath container resolution
+org.eclipse.jdt.core/debug/cpresolution=false
+
+# Report type hierarchy connections, refreshes and deltas
+org.eclipse.jdt.core/debug/hierarchy=false
+
+# Reports background indexer activity: indexing, saving index file, index queries
+org.eclipse.jdt.core/debug/indexmanager=false
+
+# Print notified Java element deltas
+org.eclipse.jdt.core/debug/javadelta=false
+
+# Reports Java model elements opening/closing
+org.eclipse.jdt.core/debug/javamodel=false
+
+# Reports post actions addition/run
+org.eclipse.jdt.core/debug/postaction=false
+
+# Reports java search activity
+org.eclipse.jdt.core/debug/search=false
+
+# Reports open on selection activity : recovered unit, inferred selection
+org.eclipse.jdt.core/debug/selection=false
+
+# Reports shared working copy use
+org.eclipse.jdt.core/debug/sharedworkingcopy=false
+
+# Reports access to zip and jar files through the Java model
+org.eclipse.jdt.core/debug/zipaccess=false
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java b/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java
index 664ae0a..85ba8f3 100644
--- a/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java
+++ b/org.eclipse.jdt.core/antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java
@@ -1,29 +1,34 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import java.io.File;
+import java.io.PrintWriter;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Javac;
import org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.util.JavaEnvUtils;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.internal.core.Util;
/**
- * Ant compiler adapter for the Eclipse Java compiler. This adapter permits the
+ * Ant 1.5 compiler adapter for the Eclipse Java compiler. This adapter permits the
* Eclipse Java compiler to be used with the <code>javac</code> task in Ant scripts. In order
* to use it, just set the property <code>build.compiler</code> as follows:
* <p>
@@ -37,6 +42,8 @@
*/
public class JDTCompilerAdapter extends DefaultCompilerAdapter {
private static String compilerClass = "org.eclipse.jdt.internal.compiler.batch.Main"; //$NON-NLS-1$
+ String logFileName;
+
/**
* Performs a compile using the JDT batch compiler
*/
@@ -46,14 +53,20 @@
try {
Class c = Class.forName(compilerClass);
- Method compile = c.getMethod("main", new Class[] { String[].class }); //$NON-NLS-1$
- compile.invoke(null, new Object[] { cmd.getArguments()});
+ Constructor batchCompilerConstructor = c.getConstructor(new Class[] { PrintWriter.class, PrintWriter.class, Boolean.TYPE});
+ Object batchCompilerInstance = batchCompilerConstructor.newInstance(new Object[] {new PrintWriter(System.out), new PrintWriter(System.err), new Boolean(true)});
+ Method compile = c.getMethod("compile", new Class[] {String[].class}); //$NON-NLS-1$
+ Object result = compile.invoke(batchCompilerInstance, new Object[] { cmd.getArguments()});
+ final boolean resultValue = ((Boolean) result).booleanValue();
+ if (!resultValue && verbose) {
+ System.out.println(Util.bind("ant.jdtadapter.error.compilationFailed", this.logFileName)); //$NON-NLS-1$
+ }
+ return resultValue;
} catch (ClassNotFoundException cnfe) {
throw new BuildException(Util.bind("ant.jdtadapter.error.missingJDTCompiler")); //$NON-NLS-1$
} catch (Exception ex) {
throw new BuildException(ex);
}
- return true;
}
@@ -65,15 +78,12 @@
*/
cmd.createArgument().setValue("-noExit"); //$NON-NLS-1$
- Path classpath = new Path(project);
-
- /*
- * Eclipse compiler doesn't support bootclasspath dir (-bootclasspath).
- * It is emulated using the classpath. We add bootclasspath at the beginning of
- * the classpath.
- */
+ cmd.createArgument().setValue("-bootclasspath"); //$NON-NLS-1$
if (bootclasspath != null && bootclasspath.size() != 0) {
- classpath.append(bootclasspath);
+ /*
+ * Set the bootclasspath for the Eclipse compiler.
+ */
+ cmd.createArgument().setPath(bootclasspath);
} else {
/*
* No bootclasspath, we will add one throught the JRE_LIB variable
@@ -82,10 +92,12 @@
if (jre_lib == null) {
throw new BuildException(Util.bind("ant.jdtadapter.error.missingJRELIB")); //$NON-NLS-1$
}
- classpath.addExisting(new Path(null, jre_lib.toOSString()));
+ cmd.createArgument().setPath(new Path(null, jre_lib.toOSString()));
}
- /*
+ Path classpath = new Path(project);
+
+ /*
* Eclipse compiler doesn't support -extdirs.
* It is emulated using the classpath. We add extdirs entries after the
* bootclasspath.
@@ -99,30 +111,109 @@
includeJavaRuntime = false;
classpath.append(getCompileClasspath());
+ // For -sourcepath, use the "sourcepath" value if present.
+ // Otherwise default to the "srcdir" value.
+ Path sourcepath = null;
+
+ // retrieve the method getSourcepath() using reflect
+ // This is done to improve the compatibility to ant 1.5
+ Class javacClass = Javac.class;
+ Method getSourcepathMethod = null;
+ try {
+ getSourcepathMethod = javacClass.getMethod("getSourcepath", null); //$NON-NLS-1$
+ } catch(NoSuchMethodException e) {
+ }
+ Path compileSourcepath = null;
+ if (getSourcepathMethod != null) {
+ try {
+ compileSourcepath = (Path) getSourcepathMethod.invoke(attributes, null);
+ } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException e) {
+ }
+ }
+ if (compileSourcepath != null) {
+ sourcepath = compileSourcepath;
+ } else {
+ sourcepath = src;
+ }
+ classpath.append(sourcepath);
/*
* Set the classpath for the Eclipse compiler.
*/
cmd.createArgument().setValue("-classpath"); //$NON-NLS-1$
cmd.createArgument().setPath(classpath);
+ String memoryParameterPrefix = JavaEnvUtils.getJavaVersion().equals(JavaEnvUtils.JAVA_1_1) ? "-J-" : "-J-X";//$NON-NLS-1$//$NON-NLS-2$
+ if (memoryInitialSize != null) {
+ if (!attributes.isForkedJavac()) {
+ attributes.log(Util.bind("ant.jdtadapter.error.ignoringMemoryInitialSize"), Project.MSG_WARN);//$NON-NLS-1$
+ } else {
+ cmd.createArgument().setValue(memoryParameterPrefix
+ + "ms" + memoryInitialSize); //$NON-NLS-1$
+ }
+ }
+
+ if (memoryMaximumSize != null) {
+ if (!attributes.isForkedJavac()) {
+ attributes.log(Util.bind("ant.jdtadapter.error.ignoringMemoryMaximumSize"), Project.MSG_WARN);//$NON-NLS-1$
+ } else {
+ cmd.createArgument().setValue(memoryParameterPrefix
+ + "mx" + memoryMaximumSize); //$NON-NLS-1$
+ }
+ }
+
+ if (debug) {
+ // retrieve the method getSourcepath() using reflect
+ // This is done to improve the compatibility to ant 1.5
+ Method getDebugLevelMethod = null;
+ try {
+ getDebugLevelMethod = javacClass.getMethod("getDebugLevel", null); //$NON-NLS-1$
+ } catch(NoSuchMethodException e) {
+ }
+ String debugLevel = null;
+ if (getDebugLevelMethod != null) {
+ try {
+ debugLevel = (String) getDebugLevelMethod.invoke(attributes, null);
+ } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException e) {
+ }
+ }
+ if (debugLevel != null) {
+ if (debugLevel.length() == 0) {
+ cmd.createArgument().setValue("-g:none"); //$NON-NLS-1$
+ } else {
+ cmd.createArgument().setValue("-g:" + debugLevel); //$NON-NLS-1$
+ }
+ } else {
+ cmd.createArgument().setValue("-g"); //$NON-NLS-1$
+ }
+ } else {
+ cmd.createArgument().setValue("-g:none"); //$NON-NLS-1$
+ }
+
/*
* Handle the nowarn option. If none, then we generate all warnings.
*/
if (attributes.getNowarn()) {
- cmd.createArgument().setValue("-nowarn"); //$NON-NLS-1$
+ if (deprecation) {
+ cmd.createArgument().setValue("-warn:allDeprecation"); //$NON-NLS-1$
+ } else {
+ cmd.createArgument().setValue("-nowarn"); //$NON-NLS-1$
+ }
} else {
- cmd.createArgument().setValue(
- "-warn:constructorName,packageDefaultMethod,maskedCatchBlocks,deprecation"); //$NON-NLS-1$
+ /*
+ * deprecation option.
+ */
+ if (deprecation) {
+ cmd.createArgument().setValue(
+ "-warn:allDeprecation,constructorName,packageDefaultMethod,maskedCatchBlocks,unusedImports,staticReceiver"); //$NON-NLS-1$
+ } else {
+ cmd.createArgument().setValue(
+ "-warn:constructorName,packageDefaultMethod,maskedCatchBlocks,unusedImports,staticReceiver"); //$NON-NLS-1$
+ }
}
/*
- * deprecation option.
- */
- if (deprecation) {
- cmd.createArgument().setValue("-deprecation"); //$NON-NLS-1$
- }
-
- /*
* destDir option.
*/
if (destDir != null) {
@@ -139,13 +230,6 @@
}
/*
- * debug option
- */
- if (debug) {
- cmd.createArgument().setValue("-g"); //$NON-NLS-1$
- }
-
- /*
* verbose option
*/
if (verbose) {
@@ -154,7 +238,8 @@
* extra option allowed by the Eclipse compiler
*/
cmd.createArgument().setValue("-log"); //$NON-NLS-1$
- cmd.createArgument().setValue(destDir.getAbsolutePath() + ".log"); //$NON-NLS-1$
+ logFileName = destDir.getAbsolutePath() + ".log"; //$NON-NLS-1$
+ cmd.createArgument().setValue(logFileName);
}
/*
@@ -165,16 +250,6 @@
}
/*
- * extra option allowed by the Eclipse compiler
- */
- cmd.createArgument().setValue("-time"); //$NON-NLS-1$
-
- /*
- * extra option allowed by the Eclipse compiler
- */
- cmd.createArgument().setValue("-noImportError"); //$NON-NLS-1$
-
- /*
* source option
*/
String source = attributes.getSource();
@@ -182,7 +257,17 @@
cmd.createArgument().setValue("-source"); //$NON-NLS-1$
cmd.createArgument().setValue(source);
}
-
+
+ if (JavaEnvUtils.getJavaVersion().equals(JavaEnvUtils.JAVA_1_4)) {
+ if (target != null && target.equals("1.1")) { //$NON-NLS-1$
+ cmd.createArgument().setValue("-1.3"); //$NON-NLS-1$
+ } else {
+ cmd.createArgument().setValue("-1.4"); //$NON-NLS-1$
+ }
+ } else {
+ cmd.createArgument().setValue("-1.3"); //$NON-NLS-1$
+ }
+
/*
* encoding option
*/
@@ -192,6 +277,11 @@
}
/*
+ * extra option allowed by the Eclipse compiler
+ */
+ cmd.createArgument().setValue("-time"); //$NON-NLS-1$
+
+ /*
* Eclipse compiler doesn't have a -sourcepath option. This is
* handled through the javac task that collects all source files in
* srcdir option.
@@ -228,4 +318,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
index 873eb76..ad2ae6b 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathDirectory.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.batch;
import java.io.File;
@@ -114,4 +114,4 @@
public String toString() {
return "ClasspathDirectory " + path; //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
index ee6bfd6..5009cc4 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJar.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.batch;
import java.io.File;
@@ -35,7 +35,8 @@
this.closeZipFileAtEnd = closeZipFileAtEnd;
}
public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName) {
- if (!isPackage(qualifiedPackageName)) return null; // most common case
+ if (!isPackage(qualifiedPackageName))
+ return null; // most common case
try {
ClassFileReader reader = ClassFileReader.read(zipFile, qualifiedBinaryFileName);
@@ -73,6 +74,6 @@
this.packageCache = null;
}
public String toString() {
- return "Classpath for jar file " + zipFile; //$NON-NLS-1$
+ return "Classpath for jar file " + zipFile.getName(); //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
index a6ac783..e0e8397 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/CompilationUnit.java
@@ -1,18 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.batch;
import java.io.File;
import java.io.IOException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.util.Util;
@@ -56,7 +57,7 @@
return Util.getFileCharContent(new File(new String(fileName)), encoding);
} catch (IOException e) {
}
- return new char[0];
+ return CharOperation.NO_CHAR;
}
public char[] getFileName() {
return fileName;
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileFinder.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileFinder.java
index b39e97c..5ed4025 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileFinder.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileFinder.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.batch;
import java.io.File;
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
index 638f2ea..d263782 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/FileSystem.java
@@ -1,22 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.batch;
import java.io.File;
import java.io.IOException;
import java.util.zip.ZipFile;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class FileSystem implements INameEnvironment {
Classpath[] classpaths;
@@ -166,4 +166,4 @@
}
return false;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
index 47fae90..d4cea8d 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java
@@ -1,21 +1,24 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.batch;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.LineNumberReader;
import java.io.PrintWriter;
+import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -25,6 +28,7 @@
import java.util.ResourceBundle;
import java.util.StringTokenizer;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ClassFile;
@@ -39,14 +43,15 @@
import org.eclipse.jdt.internal.compiler.problem.DefaultProblem;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
+import org.eclipse.jdt.internal.compiler.util.Util;
public class Main implements ProblemSeverities {
public boolean noWarn = false;
public PrintWriter out;
+ public PrintWriter err;
public boolean systemExitWhenFinished = true;
public boolean proceedOnError = false;
@@ -58,7 +63,7 @@
public long lineCount;
public boolean generatePackagesStructure;
- public Hashtable options;
+ public Map options;
public String[] filenames;
public String[] encodings;
public String[] classpaths;
@@ -85,60 +90,13 @@
public boolean proceed = true;
- public Main(PrintWriter writer, boolean systemExitWhenFinished) {
+ public Main(PrintWriter outWriter, PrintWriter errWriter, boolean systemExitWhenFinished) {
- this.out = writer;
+ this.out = outWriter;
+ this.err = errWriter;
this.systemExitWhenFinished = systemExitWhenFinished;
exportedClassFilesCounter = 0;
- options = new Hashtable();
- options.put(
- CompilerOptions.OPTION_LocalVariableAttribute,
- CompilerOptions.DO_NOT_GENERATE);
- options.put(
- CompilerOptions.OPTION_LineNumberAttribute,
- CompilerOptions.DO_NOT_GENERATE);
- options.put(
- CompilerOptions.OPTION_SourceFileAttribute,
- CompilerOptions.DO_NOT_GENERATE);
- options.put(
- CompilerOptions.OPTION_PreserveUnusedLocal,
- CompilerOptions.OPTIMIZE_OUT);
- options.put(
- CompilerOptions.OPTION_ReportUnreachableCode,
- CompilerOptions.ERROR);
- options.put(CompilerOptions.OPTION_ReportInvalidImport, CompilerOptions.ERROR);
- options.put(
- CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod,
- CompilerOptions.WARNING);
- options.put(
- CompilerOptions.OPTION_ReportMethodWithConstructorName,
- CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING);
- options.put(
- CompilerOptions.OPTION_ReportHiddenCatchBlock,
- CompilerOptions.WARNING);
- options.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
- options.put(
- CompilerOptions.OPTION_ReportUnusedParameter,
- CompilerOptions.IGNORE);
- options.put(
- CompilerOptions.OPTION_ReportSyntheticAccessEmulation,
- CompilerOptions.IGNORE);
- options.put(
- CompilerOptions.OPTION_ReportNonExternalizedStringLiteral,
- CompilerOptions.IGNORE);
- options.put(
- CompilerOptions.OPTION_ReportAssertIdentifier,
- CompilerOptions.IGNORE);
- options.put(
- CompilerOptions.OPTION_Compliance,
- CompilerOptions.VERSION_1_3);
- options.put(
- CompilerOptions.OPTION_Source,
- CompilerOptions.VERSION_1_3);
- options.put(
- CompilerOptions.OPTION_TargetPlatform,
- CompilerOptions.VERSION_1_1);
+ this.options = getDefaultOptions();
}
/*
@@ -151,7 +109,7 @@
configure(argv);
if (proceed) {
if (showProgress)
- out.print(Main.bind("progress.compiling")); //$NON-NLS-1$
+ out.println(Main.bind("progress.compiling")); //$NON-NLS-1$
for (int i = 0; i < repetitions; i++) {
globalProblemsCount = 0;
globalErrorsCount = 0;
@@ -186,39 +144,39 @@
}
if (globalProblemsCount > 0) {
if (globalProblemsCount == 1) {
- out.print(Main.bind("compile.oneProblem")); //$NON-NLS-1$
+ err.print(Main.bind("compile.oneProblem")); //$NON-NLS-1$
} else {
- out.print(
+ err.print(
Main.bind("compile.severalProblems", String.valueOf(globalProblemsCount))); //$NON-NLS-1$
}
- out.print(" ("); //$NON-NLS-1$
+ err.print(" ("); //$NON-NLS-1$
if (globalErrorsCount > 0) {
if (globalErrorsCount == 1) {
- out.print(Main.bind("compile.oneError")); //$NON-NLS-1$
+ err.print(Main.bind("compile.oneError")); //$NON-NLS-1$
} else {
- out.print(
+ err.print(
Main.bind("compile.severalErrors", String.valueOf(globalErrorsCount))); //$NON-NLS-1$
}
}
if (globalWarningsCount > 0) {
if (globalErrorsCount > 0) {
- out.print(", "); //$NON-NLS-1$
+ err.print(", "); //$NON-NLS-1$
}
if (globalWarningsCount == 1) {
- out.print(Main.bind("compile.oneWarning")); //$NON-NLS-1$
+ err.print(Main.bind("compile.oneWarning")); //$NON-NLS-1$
} else {
- out.print(
+ err.print(
Main.bind("compile.severalWarnings", String.valueOf(globalWarningsCount))); //$NON-NLS-1$
}
}
- out.println(")"); //$NON-NLS-1$
+ err.println(")"); //$NON-NLS-1$
}
if (exportedClassFilesCounter != 0
&& (this.showProgress || this.timer || this.verbose)) {
if (exportedClassFilesCounter == 1) {
- out.print(Main.bind("compile.oneClassFileGenerated")); //$NON-NLS-1$
+ out.println(Main.bind("compile.oneClassFileGenerated")); //$NON-NLS-1$
} else {
- out.print(
+ out.println(
Main.bind(
"compile.severalClassFilesGenerated", //$NON-NLS-1$
String.valueOf(exportedClassFilesCounter)));
@@ -226,15 +184,16 @@
}
}
if (showProgress)
- System.out.println();
+ out.println();
}
if (systemExitWhenFinished) {
out.flush();
+ err.flush();
System.exit(globalErrorsCount > 0 ? -1 : 0);
}
} catch (InvalidInputException e) {
- out.println(e.getMessage());
- out.println("------------------------"); //$NON-NLS-1$
+ err.println(e.getMessage());
+ err.println("------------------------"); //$NON-NLS-1$
printUsage();
if (systemExitWhenFinished) {
System.exit(-1);
@@ -244,16 +203,18 @@
} catch (Throwable e) { // internal compiler error
if (systemExitWhenFinished) {
out.flush();
+ err.flush();
if (this.log != null) {
- out.close();
+ err.close();
}
System.exit(-1);
}
//e.printStackTrace();
} finally {
out.flush();
+ err.flush();
if (this.log != null) {
- out.close();
+ err.close();
}
}
if (globalErrorsCount == 0){
@@ -268,15 +229,15 @@
*/
public static boolean compile(String commandLine) {
- return compile(commandLine, new PrintWriter(System.out));
+ return compile(commandLine, new PrintWriter(System.out), new PrintWriter(System.err));
}
/*
* Internal IDE API for test harness purpose
*/
- public static boolean compile(String commandLine, PrintWriter writer) {
+ public static boolean compile(String commandLine, PrintWriter outWriter, PrintWriter errWriter) {
- return new Main(writer, false).compile(tokenize(commandLine));
+ return new Main(outWriter, errWriter, false).compile(tokenize(commandLine));
}
public static String[] tokenize(String commandLine) {
@@ -284,7 +245,7 @@
int count = 0;
String[] arguments = new String[10];
StringTokenizer tokenizer = new StringTokenizer(commandLine, " \"", true); //$NON-NLS-1$
- String token = "", lastToken; //$NON-NLS-1$
+ String token = ""; //$NON-NLS-1$
boolean insideQuotes = false;
boolean startNewToken = true;
@@ -294,7 +255,6 @@
// 'xxx "aaa bbb";"ccc" yyy' ---> {"xxx", "aaa bbb;ccc", "yyy" }
// 'xxx/"aaa bbb";"ccc" yyy' ---> {"xxx/aaa bbb;ccc", "yyy" }
while (tokenizer.hasMoreTokens()) {
- lastToken = token;
token = tokenizer.nextToken();
if (token.equals(" ")) { //$NON-NLS-1$
@@ -321,7 +281,10 @@
} else {
if (count == arguments.length)
System.arraycopy(arguments, 0, (arguments = new String[count * 2]), 0, count);
- arguments[count++] = token;
+ String trimmedToken = token.trim();
+ if (trimmedToken.length() != 0) {
+ arguments[count++] = trimmedToken;
+ }
}
}
startNewToken = false;
@@ -336,8 +299,10 @@
*/
public void configure(String[] argv) throws InvalidInputException {
- if ((argv == null) || (argv.length == 0))
- throw new InvalidInputException(Main.bind("configure.noSourceFile")); //$NON-NLS-1$
+ if ((argv == null) || (argv.length == 0)) {
+ printUsage();
+ return;
+ }
final int InsideClasspath = 1;
final int InsideDestinationPath = 2;
final int TargetSetting = 4;
@@ -345,11 +310,12 @@
final int InsideRepetition = 16;
final int InsideSource = 32;
final int InsideDefaultEncoding = 64;
+ final int InsideBootClasspath = 128;
final int Default = 0;
+ String[] bootclasspaths = null;
int DEFAULT_SIZE_CLASSPATH = 4;
- boolean warnOptionInUse = false;
- boolean noWarnOptionInUse = false;
int pathCount = 0;
+ int bootclasspathCount = 0;
int index = -1, filesCount = 0, argCount = argv.length;
int mode = Default;
repetitions = 0;
@@ -357,13 +323,60 @@
boolean printUsageRequired = false;
boolean didSpecifyCompliance = false;
- boolean didSpecifySourceLevel = false;
boolean didSpecifyDefaultEncoding = false;
boolean didSpecifyTarget = false;
String customEncoding = null;
String currentArg = ""; //$NON-NLS-1$
+ // expand the command line if necessary
+ boolean needExpansion = false;
+ loop: for (int i = 0; i < argCount; i++) {
+ if (argv[i].startsWith("@")) { //$NON-NLS-1$
+ needExpansion = true;
+ break loop;
+ }
+ }
+
+ String[] newCommandLineArgs = null;
+ if (needExpansion) {
+ newCommandLineArgs = new String[argCount];
+ index = 0;
+ for (int i = 0; i < argCount; i++) {
+ String[] newArgs = null;
+ String arg = argv[i].trim();
+ if (arg.startsWith("@")) { //$NON-NLS-1$
+ try {
+ LineNumberReader reader = new LineNumberReader(new StringReader(new String(Util.getFileCharContent(new File(arg.substring(1)), null))));
+ StringBuffer buffer = new StringBuffer();
+ String line;
+ while((line = reader.readLine()) != null) {
+ buffer.append(line).append(" "); //$NON-NLS-1$
+ }
+ newArgs = tokenize(buffer.toString());
+ } catch(IOException e) {
+ throw new InvalidInputException(
+ Main.bind("configure.invalidexpansionargumentname", arg)); //$NON-NLS-1$
+ }
+ }
+ if (newArgs != null) {
+ int newCommandLineArgsLength = newCommandLineArgs.length;
+ int newArgsLength = newArgs.length;
+ System.arraycopy(newCommandLineArgs, 0, (newCommandLineArgs = new String[newCommandLineArgsLength + newArgsLength - 1]), 0, index);
+ System.arraycopy(newArgs, 0, newCommandLineArgs, index, newArgsLength);
+ index += newArgsLength;
+ } else {
+ newCommandLineArgs[index++] = arg;
+ }
+ }
+ index = -1;
+ } else {
+ newCommandLineArgs = argv;
+ for (int i = 0; i < argCount; i++) {
+ newCommandLineArgs[i] = newCommandLineArgs[i].trim();
+ }
+ }
+ argCount = newCommandLineArgs.length;
while (++index < argCount) {
if (customEncoding != null) {
@@ -371,7 +384,7 @@
Main.bind("configure.unexpectedCustomEncoding", currentArg, customEncoding)); //$NON-NLS-1$
}
- currentArg = argv[index].trim();
+ currentArg = newCommandLineArgs[index];
customEncoding = null;
if (currentArg.endsWith("]")) { //$NON-NLS-1$
@@ -433,7 +446,6 @@
}
if (currentArg.equals("-source")) { //$NON-NLS-1$
mode = InsideSource;
- didSpecifySourceLevel = true;
continue;
}
if (currentArg.equals("-encoding")) { //$NON-NLS-1$
@@ -470,13 +482,20 @@
}
if (currentArg.equals("-classpath") //$NON-NLS-1$
|| currentArg.equals("-cp")) { //$NON-NLS-1$ //$NON-NLS-2$
- if (pathCount > 0)
- throw new InvalidInputException(
- Main.bind("configure.duplicateClasspath", currentArg)); //$NON-NLS-1$
- classpaths = new String[DEFAULT_SIZE_CLASSPATH];
+ if (pathCount == 0) {
+ classpaths = new String[DEFAULT_SIZE_CLASSPATH];
+ }
mode = InsideClasspath;
continue;
}
+ if (currentArg.equals("-bootclasspath")) {//$NON-NLS-1$
+ if (bootclasspathCount > 0)
+ throw new InvalidInputException(
+ Main.bind("configure.duplicateBootClasspath", currentArg)); //$NON-NLS-1$
+ bootclasspaths = new String[DEFAULT_SIZE_CLASSPATH];
+ mode = InsideBootClasspath;
+ continue;
+ }
if (currentArg.equals("-progress")) { //$NON-NLS-1$
mode = Default;
showProgress = true;
@@ -498,10 +517,6 @@
continue;
}
if ("-deprecation".equals(currentArg)) { //$NON-NLS-1$
- warnOptionInUse = true;
- if (noWarnOptionInUse)
- throw new InvalidInputException(
- Main.bind("configure.duplicateWarningConfiguration")); //$NON-NLS-1$
options.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING);
continue;
}
@@ -578,7 +593,6 @@
} else {
throw new InvalidInputException(
Main.bind("configure.invalidDebugOption", debugOption)); //$NON-NLS-1$
- //$NON-NLS-1$
}
}
continue;
@@ -587,24 +601,36 @@
Main.bind("configure.invalidDebugOption", debugOption)); //$NON-NLS-1$
}
if (currentArg.startsWith("-nowarn")) { //$NON-NLS-1$
- noWarnOptionInUse = true;
- noWarn = true;
- if (warnOptionInUse)
- throw new InvalidInputException(
- Main.bind("configure.duplicateWarningConfiguration")); //$NON-NLS-1$
+ Object[] entries = options.entrySet().toArray();
+ for (int i = 0, max = entries.length; i < max; i++) {
+ Map.Entry entry = (Map.Entry) entries[i];
+ if (!(entry.getKey() instanceof String))
+ continue;
+ if (!(entry.getValue() instanceof String))
+ continue;
+ if (((String) entry.getValue()).equals(CompilerOptions.WARNING)) {
+ options.put((String) entry.getKey(), CompilerOptions.IGNORE);
+ }
+ }
mode = Default;
continue;
}
if (currentArg.startsWith("-warn")) { //$NON-NLS-1$
- warnOptionInUse = true;
- if (noWarnOptionInUse)
- throw new InvalidInputException(
- Main.bind("configure.duplicateWarningConfiguration")); //$NON-NLS-1$
mode = Default;
String warningOption = currentArg;
int length = currentArg.length();
if (length == 10 && warningOption.equals("-warn:none")) { //$NON-NLS-1$
- noWarn = true;
+ Object[] entries = options.entrySet().toArray();
+ for (int i = 0, max = entries.length; i < max; i++) {
+ Map.Entry entry = (Map.Entry) entries[i];
+ if (!(entry.getKey() instanceof String))
+ continue;
+ if (!(entry.getValue() instanceof String))
+ continue;
+ if (((String) entry.getValue()).equals(CompilerOptions.WARNING)) {
+ options.put((String) entry.getKey(), CompilerOptions.IGNORE);
+ }
+ }
continue;
}
if (length < 6)
@@ -644,6 +670,24 @@
options.put(
CompilerOptions.OPTION_ReportUnusedImport,
CompilerOptions.IGNORE);
+ options.put(
+ CompilerOptions.OPTION_ReportStaticAccessReceiver,
+ CompilerOptions.IGNORE);
+ options.put(
+ CompilerOptions.OPTION_ReportNoEffectAssignment,
+ CompilerOptions.IGNORE);
+ options.put(
+ CompilerOptions.OPTION_ReportNoImplicitStringConversion,
+ CompilerOptions.IGNORE);
+ options.put(
+ CompilerOptions.OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
+ CompilerOptions.IGNORE);
+ options.put(
+ CompilerOptions.OPTION_ReportUnusedPrivateMember,
+ CompilerOptions.IGNORE);
+ options.put(
+ CompilerOptions.OPTION_TaskTags,
+ ""); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
@@ -656,7 +700,7 @@
options.put(
CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod,
CompilerOptions.WARNING);
- } else if (token.equals("maskedCatchBlocks")) { //$NON-NLS-1$
+ } else if (token.equals("maskedCatchBlock") || token.equals("maskedCatchBlocks")/*backward compatible*/) { //$NON-NLS-1$ //$NON-NLS-2$
options.put(
CompilerOptions.OPTION_ReportHiddenCatchBlock,
CompilerOptions.WARNING);
@@ -664,18 +708,32 @@
options.put(
CompilerOptions.OPTION_ReportDeprecation,
CompilerOptions.WARNING);
- } else if (token.equals("unusedLocals")) { //$NON-NLS-1$
+ options.put(
+ CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode,
+ CompilerOptions.DISABLED);
+ } else if (token.equals("allDeprecation")) { //$NON-NLS-1$
+ options.put(
+ CompilerOptions.OPTION_ReportDeprecation,
+ CompilerOptions.WARNING);
+ options.put(
+ CompilerOptions.OPTION_ReportDeprecationInDeprecatedCode,
+ CompilerOptions.ENABLED);
+ } else if (token.equals("unusedLocal") || token.equals("unusedLocals")/*backward compatible*/) { //$NON-NLS-1$ //$NON-NLS-2$
options.put(
CompilerOptions.OPTION_ReportUnusedLocal,
CompilerOptions.WARNING);
- } else if (token.equals("unusedArguments")) { //$NON-NLS-1$
+ } else if (token.equals("unusedArgument") || token.equals("unusedArguments")/*backward compatible*/) { //$NON-NLS-1$ //$NON-NLS-2$
options.put(
CompilerOptions.OPTION_ReportUnusedParameter,
CompilerOptions.WARNING);
- } else if (token.equals("unusedImports")) { //$NON-NLS-1$
+ } else if (token.equals("unusedImport") || token.equals("unusedImports")/*backward compatible*/) { //$NON-NLS-1$ //$NON-NLS-2$
options.put(
CompilerOptions.OPTION_ReportUnusedImport,
CompilerOptions.WARNING);
+ } else if (token.equals("unusedPrivate")) { //$NON-NLS-1$
+ options.put(
+ CompilerOptions.OPTION_ReportUnusedPrivateMember,
+ CompilerOptions.WARNING);
} else if (token.equals("syntheticAccess")) { //$NON-NLS-1$
options.put(
CompilerOptions.OPTION_ReportSyntheticAccessEmulation,
@@ -684,6 +742,36 @@
options.put(
CompilerOptions.OPTION_ReportNonExternalizedStringLiteral,
CompilerOptions.WARNING);
+ } else if (token.equals("staticReceiver")) { //$NON-NLS-1$
+ options.put(
+ CompilerOptions.OPTION_ReportStaticAccessReceiver,
+ CompilerOptions.WARNING);
+ } else if (token.equals("noEffectAssign")) { //$NON-NLS-1$
+ options.put(
+ CompilerOptions.OPTION_ReportNoEffectAssignment,
+ CompilerOptions.WARNING);
+ } else if (token.equals("interfaceNonInherited")) { //$NON-NLS-1$
+ options.put(
+ CompilerOptions.OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
+ CompilerOptions.WARNING);
+ } else if (token.equals("noImplicitStringConversion")) {//$NON-NLS-1$
+ options.put(
+ CompilerOptions.OPTION_ReportNoImplicitStringConversion,
+ CompilerOptions.WARNING);
+ } else if (token.startsWith("tasks")) { //$NON-NLS-1$
+ String taskTags = ""; //$NON-NLS-1$
+ int start = token.indexOf('(');
+ int end = token.indexOf(')');
+ if (start >= 0 && end >= 0 && start < end){
+ taskTags = token.substring(start+1, end).trim();
+ taskTags = taskTags.replace('|',',');
+ }
+ if (taskTags.length() == 0){
+ throw new InvalidInputException(Main.bind("configure.invalidTaskTag", token)); //$NON-NLS-1$
+ }
+ options.put(
+ CompilerOptions.OPTION_TaskTags,
+ taskTags);
} else if (token.equals("assertIdentifier")) { //$NON-NLS-1$
options.put(
CompilerOptions.OPTION_ReportAssertIdentifier,
@@ -698,7 +786,6 @@
continue;
}
if (currentArg.equals("-target")) { //$NON-NLS-1$
- didSpecifyTarget = true;
mode = TargetSetting;
continue;
}
@@ -709,6 +796,7 @@
continue;
}
if (mode == TargetSetting) {
+ didSpecifyTarget = true;
if (currentArg.equals("1.1")) { //$NON-NLS-1$
options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_1);
} else if (currentArg.equals("1.2")) { //$NON-NLS-1$
@@ -717,6 +805,10 @@
options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_3);
} else if (currentArg.equals("1.4")) { //$NON-NLS-1$
options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
+ if (didSpecifyCompliance && options.get(CompilerOptions.OPTION_Compliance).equals(CompilerOptions.VERSION_1_3)) {
+ throw new InvalidInputException(Main.bind("configure.incompatibleComplianceForTarget14", (String)options.get(CompilerOptions.OPTION_Compliance))); //$NON-NLS-1$
+ }
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
} else {
throw new InvalidInputException(Main.bind("configure.targetJDK", currentArg)); //$NON-NLS-1$
}
@@ -789,6 +881,23 @@
mode = Default;
continue;
}
+ if (mode == InsideBootClasspath) {
+ StringTokenizer tokenizer = new StringTokenizer(currentArg, File.pathSeparator);
+ while (tokenizer.hasMoreTokens()) {
+ int length;
+ if ((length = bootclasspaths.length) <= bootclasspathCount) {
+ System.arraycopy(
+ bootclasspaths,
+ 0,
+ (bootclasspaths = new String[length * 2]),
+ 0,
+ length);
+ }
+ bootclasspaths[bootclasspathCount++] = tokenizer.nextToken();
+ }
+ mode = Default;
+ continue;
+ }
//default is input directory
currentArg = currentArg.replace('/', File.separatorChar);
if (currentArg.endsWith(File.separator))
@@ -839,20 +948,6 @@
continue;
}
- if (noWarn) {
- // filter options which are related to the assist component
- Object[] entries = options.entrySet().toArray();
- for (int i = 0, max = entries.length; i < max; i++) {
- Map.Entry entry = (Map.Entry) entries[i];
- if (!(entry.getKey() instanceof String))
- continue;
- if (!(entry.getValue() instanceof String))
- continue;
- if (((String) entry.getValue()).equals(CompilerOptions.WARNING)) {
- options.put((String) entry.getKey(), CompilerOptions.IGNORE);
- }
- }
- }
/*
* Standalone options
*/
@@ -877,30 +972,120 @@
0,
filesCount);
if (pathCount == 0) {
- String classProp = System.getProperty("DEFAULT_CLASSPATH"); //$NON-NLS-1$
+ // no user classpath specified.
+ String classProp = System.getProperty("java.class.path"); //$NON-NLS-1$
if ((classProp == null) || (classProp.length() == 0)) {
- out.println(Main.bind("configure.noClasspath")); //$NON-NLS-1$
- classProp = "."; //$NON-NLS-1$
+ err.println(Main.bind("configure.noClasspath")); //$NON-NLS-1$
+ classProp = System.getProperty("user.dir"); //$NON-NLS-1$
}
StringTokenizer tokenizer = new StringTokenizer(classProp, File.pathSeparator);
- classpaths = new String[tokenizer.countTokens()];
+ classpaths = new String[tokenizer.countTokens() + 1];
while (tokenizer.hasMoreTokens()) {
classpaths[pathCount++] = tokenizer.nextToken();
}
+ classpaths[pathCount++] = System.getProperty("user.dir");//$NON-NLS-1$
+ }
+
+ if (bootclasspathCount == 0) {
+ /* no bootclasspath specified
+ * we can try to retrieve the default librairies of the VM used to run
+ * the batch compiler
+ */
+ String javaversion = System.getProperty("java.version");//$NON-NLS-1$
+ if (javaversion != null && javaversion.equalsIgnoreCase("1.1.8")) { //$NON-NLS-1$
+ err.println(Main.bind("configure.requiresJDK1.2orAbove")); //$NON-NLS-1$
+ proceed = false;
+ return;
+ } else {
+ String javaVMName = System.getProperty("java.vm.name");//$NON-NLS-1$
+ if (javaVMName != null && javaVMName.equalsIgnoreCase("J9")) {//$NON-NLS-1$
+ /*
+ * Handle J9 VM settings: Retrieve jclMax by default
+ */
+ String javaHome = System.getProperty("java.home");//$NON-NLS-1$
+ if (javaHome != null) {
+ File javaHomeFile = new File(javaHome);
+ if (javaHomeFile.exists()) {
+ try {
+ javaHomeFile = new File(javaHomeFile.getCanonicalPath());
+ File defaultLibrary = new File(javaHomeFile, "lib" + File.separator + "jclMax" + File.separator + "classes.zip"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ File locales = new File(javaHomeFile, "lib" + File.separator + "jclMax" + File.separator + "locale.zip"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ File charconv = new File(javaHomeFile, "lib" + File.separator + "charconv.zip"); //$NON-NLS-1$//$NON-NLS-2$
+ /* we don't need to check if defaultLibrary exists. This is done later when the user
+ * classpath and the bootclasspath are merged.
+ */
+ bootclasspaths = new String[] {
+ defaultLibrary.getAbsolutePath(),
+ locales.getAbsolutePath(),
+ charconv.getAbsolutePath()};
+ bootclasspathCount = 3;
+ } catch (IOException e) {
+ }
+ }
+ }
+ } else {
+ /*
+ * Handle >= JDK 1.2.2 settings: retrieve rt.jar
+ */
+ String javaHome = System.getProperty("java.home");//$NON-NLS-1$
+ if (javaHome != null) {
+ File javaHomeFile = new File(javaHome);
+ if (javaHomeFile.exists()) {
+ try {
+ javaHomeFile = new File(javaHomeFile.getCanonicalPath());
+ // add all jars in the lib subdirectory
+ File[] systemLibrariesJars = getFilesFrom(new File(javaHomeFile, "lib"), ".jar");//$NON-NLS-1$//$NON-NLS-2$
+ int length = systemLibrariesJars.length;
+ bootclasspaths = new String[length];
+ for (int i = 0; i < length; i++) {
+ /* we don't need to check if this file exists. This is done later when the user
+ * classpath and the bootclasspath are merged.
+ */
+ bootclasspaths[bootclasspathCount++] = systemLibrariesJars[i].getAbsolutePath();
+ }
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+ }
}
- if (classpaths == null)
+ if (classpaths == null) {
classpaths = new String[0];
+ }
+ /*
+ * We put the bootclasspath at the beginning of the classpath entries
+ */
+ String[] newclasspaths = null;
+ if ((pathCount + bootclasspathCount) != classpaths.length) {
+ newclasspaths = new String[pathCount + bootclasspathCount];
+ } else {
+ newclasspaths = classpaths;
+ }
System.arraycopy(
classpaths,
0,
- (classpaths = new String[pathCount]),
- 0,
+ newclasspaths,
+ bootclasspathCount,
pathCount);
+
+ if (bootclasspathCount != 0) {
+ System.arraycopy(
+ bootclasspaths,
+ 0,
+ newclasspaths,
+ 0,
+ bootclasspathCount);
+ }
+ classpaths = newclasspaths;
for (int i = 0, max = classpaths.length; i < max; i++) {
File file = new File(classpaths[i]);
- if (!file.exists()) // signal missing classpath entry file
- out.println(Main.bind("configure.incorrectClasspath", classpaths[i])); //$NON-NLS-1$
+ if (!file.exists()) { // signal missing classpath entry file
+ err.println(Main.bind("configure.incorrectClasspath", classpaths[i])); //$NON-NLS-1$
+ } /* else {
+ out.println(classpaths[i]);
+ }*/
}
if (destinationPath == null) {
generatePackagesStructure = false;
@@ -908,58 +1093,46 @@
destinationPath = null;
}
- if (filenames == null)
- throw new InvalidInputException(Main.bind("configure.noSource")); //$NON-NLS-1$
-
- // check and set compliance/source/target compatibilities
- if (!didSpecifyCompliance){
- if (options.get(CompilerOptions.OPTION_Source).equals(CompilerOptions.VERSION_1_4)){
- options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
- } else {
- options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_3);
- }
+ if (filenames == null) {
+ printUsage();
+ return;
}
- String compliance = (String)options.get(CompilerOptions.OPTION_Compliance);
- if (CompilerOptions.VERSION_1_4.equals(compliance)){
-
- // default 1.4 settings
- if (!didSpecifySourceLevel){
- options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);
- }
- if (!didSpecifyTarget){
- options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
- }
- } else if (CompilerOptions.VERSION_1_3.equals(compliance)){
- // default 1.4 settings
- if (!didSpecifySourceLevel){
- options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_3);
- }
- if (!didSpecifyTarget){
- options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_1);
- }
+ // target must be 1.4 if source is 1.4
+ if (options.get(CompilerOptions.OPTION_Source).equals(CompilerOptions.VERSION_1_4)
+ && !options.get(CompilerOptions.OPTION_TargetPlatform).equals(CompilerOptions.VERSION_1_4)
+ && didSpecifyTarget){
+ throw new InvalidInputException(Main.bind("configure.incompatibleTargetForSource14", (String)options.get(CompilerOptions.OPTION_TargetPlatform))); //$NON-NLS-1$
+ }
+
+ // target cannot be 1.4 if compliance is 1.3
+ if (options.get(CompilerOptions.OPTION_TargetPlatform).equals(CompilerOptions.VERSION_1_4)
+ && !options.get(CompilerOptions.OPTION_Compliance).equals(CompilerOptions.VERSION_1_4)
+ && didSpecifyTarget){
+ throw new InvalidInputException(Main.bind("configure.incompatibleComplianceForTarget14", (String)options.get(CompilerOptions.OPTION_Compliance))); //$NON-NLS-1$
+ }
+
+ // check and set compliance/source/target compatibilities
+ if (options.get(CompilerOptions.OPTION_Source).equals(CompilerOptions.VERSION_1_4)){
+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_4);
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_4);
+ } else if (options.get(CompilerOptions.OPTION_Compliance).equals(CompilerOptions.VERSION_1_4)
+ && options.get(CompilerOptions.OPTION_TargetPlatform).equals(CompilerOptions.VERSION_1_1)) {
+ if (didSpecifyTarget) {
+ throw new InvalidInputException(Main.bind("configure.incompatibleComplianceForTarget11", (String)options.get(CompilerOptions.OPTION_Compliance))); //$NON-NLS-1$
+ } else {
+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_2);
+ }
}
// compliance must be 1.4 if source is 1.4
if (options.get(CompilerOptions.OPTION_Source).equals(CompilerOptions.VERSION_1_4)
&& !options.get(CompilerOptions.OPTION_Compliance).equals(CompilerOptions.VERSION_1_4)){
throw new InvalidInputException(Main.bind("configure.incompatibleComplianceForSource14", (String)options.get(CompilerOptions.OPTION_Compliance))); //$NON-NLS-1$
}
-
- // target must be 1.4 if source is 1.4
- if (options.get(CompilerOptions.OPTION_Source).equals(CompilerOptions.VERSION_1_4)
- && !options.get(CompilerOptions.OPTION_TargetPlatform).equals(CompilerOptions.VERSION_1_4)){
- throw new InvalidInputException(Main.bind("configure.incompatibleTargetForSource14", (String)options.get(CompilerOptions.OPTION_TargetPlatform))); //$NON-NLS-1$
- }
- // target cannot be 1.4 if compliance is 1.3
- if (options.get(CompilerOptions.OPTION_TargetPlatform).equals(CompilerOptions.VERSION_1_4)
- && !options.get(CompilerOptions.OPTION_Compliance).equals(CompilerOptions.VERSION_1_4)){
- throw new InvalidInputException(Main.bind("configure.incompatibleComplianceForTarget14", (String)options.get(CompilerOptions.OPTION_Compliance))); //$NON-NLS-1$
- }
-
if (log != null) {
try {
- out = new PrintWriter(new FileOutputStream(log, false));
+ err = new PrintWriter(new FileOutputStream(log, false));
} catch (IOException e) {
throw new InvalidInputException(Main.bind("configure.cannotOpenLog")); //$NON-NLS-1$
}
@@ -971,6 +1144,89 @@
repetitions = 1;
}
}
+
+ private File[] getFilesFrom(File f, final String extension) {
+ return f.listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ if (name.endsWith(extension)) {
+ return true;
+ }
+ return false;
+ }
+ });
+ }
+
+ public Map getDefaultOptions() {
+ Map defaultOptions = new Hashtable();
+ defaultOptions.put(
+ CompilerOptions.OPTION_LocalVariableAttribute,
+ CompilerOptions.DO_NOT_GENERATE);
+ defaultOptions.put(
+ CompilerOptions.OPTION_LineNumberAttribute,
+ CompilerOptions.GENERATE);
+ defaultOptions.put(
+ CompilerOptions.OPTION_SourceFileAttribute,
+ CompilerOptions.GENERATE);
+ defaultOptions.put(
+ CompilerOptions.OPTION_PreserveUnusedLocal,
+ CompilerOptions.OPTIMIZE_OUT);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportUnreachableCode,
+ CompilerOptions.ERROR);
+ defaultOptions.put(CompilerOptions.OPTION_ReportInvalidImport, CompilerOptions.ERROR);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod,
+ CompilerOptions.WARNING);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportMethodWithConstructorName,
+ CompilerOptions.WARNING);
+ defaultOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.WARNING);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportHiddenCatchBlock,
+ CompilerOptions.WARNING);
+ defaultOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.IGNORE);
+ defaultOptions.put(CompilerOptions.OPTION_ReportUnusedImport, CompilerOptions.WARNING);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportUnusedParameter,
+ CompilerOptions.IGNORE);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportUnusedParameterWhenImplementingAbstract,
+ CompilerOptions.DISABLED);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportUnusedParameterWhenOverridingConcrete,
+ CompilerOptions.DISABLED);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportSyntheticAccessEmulation,
+ CompilerOptions.IGNORE);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportNonExternalizedStringLiteral,
+ CompilerOptions.IGNORE);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportAssertIdentifier,
+ CompilerOptions.IGNORE);
+ defaultOptions.put(
+ CompilerOptions.OPTION_Compliance,
+ CompilerOptions.VERSION_1_3);
+ defaultOptions.put(
+ CompilerOptions.OPTION_Source,
+ CompilerOptions.VERSION_1_3);
+ defaultOptions.put(
+ CompilerOptions.OPTION_TargetPlatform,
+ CompilerOptions.VERSION_1_1);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportNoImplicitStringConversion,
+ CompilerOptions.WARNING);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportStaticAccessReceiver,
+ CompilerOptions.WARNING);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportIncompatibleNonInheritedInterfaceMethod,
+ CompilerOptions.WARNING);
+ defaultOptions.put(
+ CompilerOptions.OPTION_ReportUnusedPrivateMember,
+ CompilerOptions.IGNORE);
+ return defaultOptions;
+ }
public Map getOptions() {
return this.options;
}
@@ -987,20 +1243,20 @@
lineDelta += unitLineCount;
if (showProgress
&& lineDelta > 2000) { // in -log mode, dump a dot every 2000 lines compiled
- System.out.print('.');
+ out.print('.');
lineDelta = 0;
}
}
- if (compilationResult.hasProblems()) {
- IProblem[] problems = compilationResult.getProblems();
+ if (compilationResult.hasProblems() || compilationResult.hasTasks()) {
+ IProblem[] problems = compilationResult.getAllProblems();
int count = problems.length;
int localErrorCount = 0;
for (int i = 0; i < count; i++) {
if (problems[i] != null) {
globalProblemsCount++;
if (localErrorCount == 0)
- out.println("----------"); //$NON-NLS-1$
- out.print(
+ err.println("----------"); //$NON-NLS-1$
+ err.print(
globalProblemsCount
+ ". " //$NON-NLS-1$
+ (problems[i].isError()
@@ -1011,25 +1267,26 @@
} else {
globalWarningsCount++;
}
- out.print(" "); //$NON-NLS-1$
- out.print(
+ err.print(" "); //$NON-NLS-1$
+ err.print(
Main.bind("requestor.in", new String(problems[i].getOriginatingFileName()))); //$NON-NLS-1$
try {
- out.println(
+ err.println(
((DefaultProblem) problems[i]).errorReportSource(
compilationResult.compilationUnit));
- out.println(problems[i].getMessage());
+ err.println(problems[i].getMessage());
} catch (Exception e) {
- out.println(
+ err.println(
Main.bind("requestor.notRetrieveErrorMessage", problems[i].toString())); //$NON-NLS-1$
}
- out.println("----------"); //$NON-NLS-1$
+ err.println("----------"); //$NON-NLS-1$
if (problems[i].isError())
localErrorCount++;
}
};
// exit?
if (systemExitWhenFinished && !proceedOnError && (localErrorCount > 0)) {
+ err.flush();
out.flush();
System.exit(-1);
}
@@ -1104,7 +1361,7 @@
*/
public static void main(String[] argv) {
- new Main(new PrintWriter(System.out), true).compile(argv);
+ new Main(new PrintWriter(System.out), new PrintWriter(System.err), true).compile(argv);
}
// Dump classfiles onto disk for all compilation units that where successfull.
@@ -1132,7 +1389,7 @@
} catch (IOException e) {
String fileName = destinationPath + new String(relativeName);
e.printStackTrace();
- System.out.println(Main.bind("output.noClassFileCreated", fileName)); //$NON-NLS-1$
+ err.println(Main.bind("output.noClassFileCreated", fileName)); //$NON-NLS-1$
}
exportedClassFilesCounter++;
}
@@ -1155,7 +1412,7 @@
} catch (IOException e) {
String fileName = destinationPath + new String(relativeName);
e.printStackTrace();
- System.out.println(Main.bind("output.noClassFileCreated", fileName)); //$NON-NLS-1$
+ err.println(Main.bind("output.noClassFileCreated", fileName)); //$NON-NLS-1$
}
exportedClassFilesCounter++;
}
@@ -1188,13 +1445,19 @@
public void printUsage() {
out.println(Main.bind("misc.usage", Main.bind("compiler.version"))); //$NON-NLS-1$ //$NON-NLS-2$
out.flush();
+ err.flush();
}
/**
* Creates a NLS catalog for the given locale.
*/
public static void relocalize() {
- bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+ try {
+ bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+ } catch(MissingResourceException e) {
+ System.out.println("Missing resource : " + bundleName.replace('.', '/') + ".properties for locale " + Locale.getDefault()); //$NON-NLS-1$//$NON-NLS-2$
+ throw e;
+ }
}
/**
@@ -1285,4 +1548,4 @@
return System.getProperty("user.dir"); //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
index 349b4ef..ed7de3e 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
@@ -1,7 +1,17 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
### JavaBatchCompiler messages.
### compiler version id
-compiler.version = 0.264
+compiler.version = 0.308
### scanning
scanning.start = Collecting source files inside {0}
@@ -22,16 +32,15 @@
compile.severalClassFilesGenerated = {0} .class files generated
### configure
+configure.requiresJDK1.2orAbove = Need to use a JVM >= 1.2
configure.noSourceFile = no source file specified
configure.duplicateLog = duplicate log specification: {0}
configure.duplicateRepeat = duplicate repeat specification: {0}
configure.duplicateCompliance = duplicate compliance setting specification: {0}
configure.source = invalid source option, source is either ''1.3'' or ''1.4'': {0}
-configure.jck = invalid jck option, jck compliance level is either ''1.3'' or ''1.4'': {0}
configure.duplicateOutputPath = duplicate output path specification: {0}
-configure.duplicateClasspath = duplicate classpath specification: {0}
+configure.duplicateBootClasspath = duplicate bootclasspath specification: {0}
configure.invalidDebugOption = invalid debug option: {0}
-configure.duplicateWarningConfiguration = duplicate usage of warning configuration
configure.invalidWarningConfiguration = invalid warning configuration: {0}
configure.invalidWarning = invalid warning: {0}
configure.invalidWarningOption = invalid warning option: {0}
@@ -39,17 +48,19 @@
configure.incompatibleTargetForSource14 = ''1.4'' source mode requires ''-target 1.4'' : {0}
configure.incompatibleComplianceForSource14 = ''1.4'' source mode requires ''-1.4'' compliance mode: {0}
configure.incompatibleComplianceForTarget14 = ''1.4'' target mode requires ''-1.4'' compliance mode: {0}
+configure.incompatibleComplianceForTarget11 = ''1.1'' target mode requires ''-1.3'' compliance mode: {0}
configure.repetition = repetition must be a positive integer: {0}
configure.directoryNotExist = directory does not exist: {0}
configure.IOError = i/o error : unable to retrieve .JAVA files in directory: {0}
configure.version = Eclipse Java Compiler {0}, Copyright IBM Corp 2000-2002. All rights reserved.
configure.noClasspath = no classpath defined, using default directory instead
configure.incorrectClasspath = incorrect classpath: {0}
-configure.noSource = no source file specified
+configure.invalidexpansionargumentname = expansion argument file {0} doesn't exist or cannot be read
configure.cannotOpenLog = cannot open .log file
configure.unexpectedCustomEncoding = unexpected custom encoding specification: {0}[{1}]
configure.unsupportedEncoding = unsupported encoding format: {0}
configure.duplicateDefaultEncoding = duplicate default encoding format specification: {0}
+configure.invalidTaskTag ={0} is an invalid task tag
### requestor
requestor.error = ERROR
@@ -66,43 +77,52 @@
### miscellaneous
misc.usage = Eclipse Java Compiler {0}\n\
- Copyright IBM Corp 2000-2002. All rights reserved.\n\n\
+ Copyright IBM Corp 2000, 2003. All rights reserved.\n\n\
Usage: <options> <source files | directories>\n\n\
where options include:\n\
- -help display this help message\n\
- -version compiler version number\n\
- -classpath <dir 1>;<dir 2>;...;<dir P>\n\
- -d <dir> destination directory (if omitted no package directory structure is created)\n\
+ -help display this help message\n\
+ -version only display compiler version number\n\
+ -classpath <dir 1>;<dir 2>;...;<dir P>\n\
+ -bootclasspath <dir 1>;<dir 2>;...;<dir P>\n\
+ -d <dir> destination directory (if omitted, no directory is created)\n\
\t-d none no classfile is generated\n\
- -target <ver> classfile target setting (1.1 or 1.2, default is 1.1)\n\
- -1.3 set compliance level to 1.3 (default)\n\
- -1.4 set compliance level to 1.4\n\
- -source <ver> assertions toggle (1.3 or 1.4, default is 1.3 in -1.3 mode and 1.4 in -1.4 mode)\n\
- -nowarn no warning (equivalent to ''-warn:none'')\n\
+ -target <ver> set classfile target (1.1 to 1.4, default is ''1.1'')\n\
+ -1.3 use 1.3 compliance level (default)\n\
+ -1.4 use 1.4 compliance level\n\
+ -source <ver> set source level (1.3 or 1.4, default matches compliance level)\n\
+ -nowarn no warning (equivalent to ''-warn:none'')\n\
-warn: <level> set warning level (e.g. ''-warn:unusedLocals,deprecation'')\n\
- \tconstructorName warn method with constructor name\n\
- \tpackageDefaultMethod warn attempt to override package-default method\n\
- \tdeprecation warn usage of deprecated type or member\n\
- \tmaskedCatchBlocks warn hidden catch block\n\
- \tunusedLocals warn on unused local variable (never read)\n\
- \tunusedArguments warn on unused method argument (never read)\n\
- \tunusedImports warn on unused imports\n\
- \tsyntheticAccess warn when performing synthetic access for innerclass\n\
- \tassertIdentifier warn occurrence of ''assert'' used as identifier\n\
- -deprecation equivalent to -warn:deprecation.\n\
- -g[:<level>] debug attributes level\n\
- \t-g all debug info (''-g:lines,vars,source'')\n\
+ \tallDeprecation deprecation (including in deprecated code)\n\
+ \tassertIdentifier ''assert'' used as identifier\n\
+ \tconstructorName method with constructor name \t\t\t\t (default) \n\
+ \tdeprecation deprecation (outside deprecated code) \t\t (default)\n\
+ \tmaskedCatchBlock hidden catch block \t\t\t\t\t\t (default)\n\
+ \tnls string literal lacking non-nls tag //$NON-NLS-<n>$\n\
+ \tpackageDefaultMethod attempt to override package-default method (default)\n\
+ \tunusedArgument unused method argument (never read)\n\
+ \tunusedImport unused import declaration \t\t\t\t\t (default)\n\
+ \tunusedLocal unused local variable (never read)\n\
+ \tunusedPrivate unused private member declaration\n\
+ \tstaticReceiver non-static reference to static member \t\t (default)\n\
+ \tnoEffectAssign assignment without effect \t\t\t\t\t (default)\n\
+ \tsyntheticAccess synthetic access for innerclass\n\
+ \tinterfaceNonInherited interface non-inherited method compatibility (default)\n\
+ \tnoImplicitStringConversion char[] in String concat\t\t\t\t\t (default)\n\
+ \ttasks(<tag1>|...|<tagN>) tasks identified by tags inside comments\n\
+ -deprecation equivalent to ''-warn:deprecation'' (default)\n\
+ -g[:<level>] debug attributes level (default ''-g:lines,source'')\n\
+ \t-g all debug info (''-g:lines,vars,source'')\n\
\t-g:none no debug info\n\
\t-g:[lines,vars,source] selective debug info\n\
- -preserveAllLocals code gen preserve all local variables (for debug purpose)\n\
- -noImportError no errors for unresolved imports\n\
- -encoding specify default source encoding format (custom encoding can also be specifed on\n\
- \t\t\ta per file basis by suffixing each input source file/folder name with '[encoding]')\n\
+ -preserveAllLocals preserve unused local vars for debug purpose (default is optimize out)\n\
+ -noImportError no errors for unresolved imports (default is error)\n\
+ -encoding <enc> specify a different default source encoding format (custom encoding can be specified on\n\
+ \t\t\t\t\ta per file basis by adding suffix ''[<enc>]'' to file/folder names\n\
-log <filename> specify a log file\n\
- -proceedOnError keep compiling when error, dumping class files with problem methods\n\
- -verbose print accessed/processed compilation units \n\
+ -proceedOnError keep compiling when error, dumping class files with problem methods (default is off)\n\
+ -verbose print accessed/processed compilation units\n\
-referenceInfo compute reference info\n\
- -progress show progress (only in -log mode)\n\
- -time display speed information\n\
- -noExit do not call System.exit(n) at end of compilation (n=0 if no error)\n\
- -repeat <n> repeat compilation process <n> times (perf analysis)\n
+ -progress show progress (only in -log mode)\n\
+ -time display speed information \n\
+ -noExit do not call System.exit(n) at end of compilation (n=0 if no error)\n\
+ -repeat <n> repeat compilation process <n> times (perf analysis)\n
diff --git a/org.eclipse.jdt.core/build.properties b/org.eclipse.jdt.core/build.properties
index 2d85280..0016ed5 100644
--- a/org.eclipse.jdt.core/build.properties
+++ b/org.eclipse.jdt.core/build.properties
@@ -1,3 +1,13 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
bin.includes = plugin.xml,\
plugin.properties,\
about.html,\
@@ -20,4 +30,4 @@
source.jdtCompilerAdapter.jar = antadapter/
jars.compile.order=jdtcore.jar,jdtCompilerAdapter.jar
jars.extra.classpath=../org.apache.ant/ant.jar
-src.includes=about.html
\ No newline at end of file
+src.includes=about.html,schema/
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index a4ec10e..9405bd3 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -5,4335 +5,3222 @@
<meta name="Author" content="IBM">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
<title>JDT/Core Release Notes</title>
+
</head>
<body>
-<h1>
+<body text="#000000" bgcolor="#FFFFFF">
+
+
+<table border=0 cellspacing=5 cellpadding=2 width="100%" >
+ <tr>
+ <td align=left width="72%">
+ <font face="Verdana, Arial, Helvetica" size="+3"><b>jdt core - build notes 2.1 stream </font>
+ <br><font face="Arial, Helvetica, sans-serif" size="-2" color="#8080ff">java development tooling core</font></td>
+ </tr>
+ <tr><td> </td></tr>
+ <tr>
+ <td>
+ <font face="Arial, Helvetica, sans-serif" size="-1">
+ Here are the build notes for the Eclipse JDT/Core plug-in project
+ <a href="http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/jdt-core-home/main.html"><b>org.eclipse.jdt.core</b></a>,
+ describing bug resolution and substantial changes in the <a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core"><b>HEAD</b></a> branch.
+ This present document covers all changes since Release 2.0, changes which occurred up to Release 2.0 can be found
+ in <a href="http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.jdt.core/notes/R20_buildnotes_jdt-core.html">build notes R2.0</a>.
+ </font>
+ </td>
+ </tr>
+</table>
+
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build GM5 - 27th June 2002
-<br>Project org.eclipse.jdt.core v_264
+Eclipse SDK 2.1 Build - 20th March 2003
+<br>Project org.eclipse.jdt.core v_308
<h2>
What's new in this drop</h2>
<ul>
-<li>Changed ASCII/binary property for 'about.html' file to ASCII.</li>
-</ul>
+</ul>
<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=35306">35306</a>
+Index update request can be incorrectly handled
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=35263">35263</a>
+Eclipse crashes when opening Hierarchy view for java.lang.Eception
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=35298">35298</a>
+NPE: Internal compiler error
+
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 19th March 2003
+<br>Project org.eclipse.jdt.core v_307 - 2.1 RELEASE CANDIDATE 3
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34040">34040</a>
+It takes a minute to expand a project in Package explorer
<h3>Problem Reports Closed</h3>
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build GM4 - 26th June 2002
-<br>Project org.eclipse.jdt.core v_263
+Eclipse SDK 2.1 Build - 18th March 2003
+<br>Project org.eclipse.jdt.core v_306
<h2>
What's new in this drop</h2>
<ul>
-</ul>
+</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20553">20553</a>
-Doc - Javadocs of 2.0 classes must specify if the class is intended to be instantiated or subclassed by client.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20442">20442</a>
-Doc - Javadoc missing in ICodeSnippetRequestor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20550">20550</a>
-Doc - fields of CorrectionEngine should not be API
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20872">20872</a>
-Doc - the javadoc is not correct for ICodeAssist#codeSelect
-<br>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=35237">35237</a>
+Ant adapter should say where to look for the .log file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=35132">35132</a>
+Need to reindex jar not on classpath not detected
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=35131">35131</a>
+Optimize source attachment query when no source attachment available
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=35128">35128</a>
+Problems with packages named "java"
<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20936">20936</a>
-nullpointer exception in org.eclipse.jdt.internal.core.builder.JavaBuilder
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34214">34214</a>
+createPackageDeclaration on ICompilationUnit
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=35098">35098</a>
+Delete compiled class files when deleting source file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=35087">35087</a>
+NPE while importing plug-ins
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34850">34850</a>
+Need better control over deprecation messages
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34322">34322</a>
+SDK hangs while building on IBM1.3.1SR2
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30418">30418</a>
+Inner classes cause compilation errors with asserts
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34789">34789</a>
+Search for references does not show subclassed methods
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33885">33885</a>
+packages with javax in their name don't import properly
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34992">34992</a>
+TODO as a substring in a comment generates a task
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34708">34708</a>
+unreliable full build/refresh using linked source folders
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=35093">35093</a>
+Not only changes in working copy should refresh type hierarcy.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34851">34851</a>
+Rename Class operation hangs
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020624 - 24th June 2002
-<br>Project org.eclipse.jdt.core v_262
+Eclipse SDK 2.1 Build - 13th March 2003
+<br>Project org.eclipse.jdt.core v_305
<h2>
What's new in this drop</h2>
<ul>
-<li>Updated about.html file.
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34845">34845</a>
+asserts do not need to be NLS'ed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34658">34658</a>
+Save All failed with unhelpful error message.
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34962">34962</a>
+NPE in Scope.getTypeOrPackage
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34802">34802</a>
+instanceof produce InternalCompilerError on MacOSX with JDK1.4.1
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34734">34734</a>
+internal compiler error ArrayIndexOutOfBound w/ 1.4.1 release
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34706">34706</a>
+Internal compiler error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34907">34907</a>
+ArrayIndexOutOfBoundsException after installing Java 1.4.1_01
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34029">34029</a>
+"False-positive" deprecated warning
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34813">34813</a>
+NPE from builder
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 11th March 2003
+<br>Project org.eclipse.jdt.core v_304
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33927">33927</a>
+Leak in Java Editor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33950">33950</a>
+Slow performance when changing code in a much referenced project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34000">34000</a>
+JDK Compliance doesn't match javac generation from an IBM or SUN JDK
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34078">34078</a>
+Hierarchy: 27% of time spent reporting progress
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33998">33998</a>
+unexpected NullPointerException
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34566">34566</a>
+can't get assert to work with mac os x java 1.4.1
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34337">34337</a>
+[RC2] Searches freezes ?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33412">33412</a>
+GB18030: Can't set JRE in a path contains GB18030 characters
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34292">34292</a>
+[RC2] OutOfMemory compiling
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34130">34130</a>
+Debug statements on console
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34301">34301</a>
+Java compiler doesn't dected always unreported exception
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32927">32927</a>
+Exception while playing with type hierarchy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=34059">34059</a>
+When adding a library that is stored in a directory containing a "(" or ")" the classes are *not* reachable for Code Assist.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33900">33900</a>
+NPE setting output directory of a source folder
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 6th March 2003
+<br>Project org.eclipse.jdt.core v_303 - 2.1 RELEASE CANDIDATE 2
+<h2>
+What's new in this drop</h2>
+<ul>
+<li><code>IJavaProject.isOnClasspath(...)</code> no longer throws any exception, but rather consistently return <code>false</code>
+in these circumstances. Indeed, it is difficult for clients to work with predicates that throw exceptions.
+Although this change creates a source incompatibility, the change is binary compatible with 2.0 and within the original
+spirit of the original API contract. Include in 2.1 readme.
</li>
-</ul>
+</ul>
<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33990">33990</a>
+.class file time-stamps out of sync with .java files
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32665">32665</a>
+Closing element trace should hide children
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32634">32634</a>
+Improve readability of compiling progress message
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33949">33949</a>
+DOM: assert statement has wrong length
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33695">33695</a>
+project build path broken
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33475">33475</a>
+Build path seems to be lost every time Eclipse restarts
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33785">33785</a>
+Open on selection fails
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33800">33800</a>
+search: reporting too many method occurrences
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33806">33806</a>
+Code assist failure: assignment of double in for loop hides previous variables
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33754">33754</a>
+IJavaProject.isOnClasspath should answer false for working copies outside the classpath
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33918">33918</a>
+Libraries are not presented in the Package Explorer (I030227)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33843">33843</a>
+Compiler incorrectly generating static method calls
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33625">33625</a>
+Searching for field references with SearchEngine returns some incorrect results
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31610">31610</a>
+IDE does hang-up
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 4th March 2003
+<br>Project org.eclipse.jdt.core v_302a
+<h2>
+What's new in this drop</h2>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33757">33757</a>
+Problem not detected when opening a working copy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33753">33753</a>
+Missing resource messages could be improved
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33748">33748</a>
+Cannot open working copy on .java file in simple project
<h3>Problem Reports Closed</h3>
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020621 - 21st June 2002
-<br>Project org.eclipse.jdt.core v_261
+Eclipse SDK 2.1 Build - 4th March 2003
+<br>Project org.eclipse.jdt.core v_302
<h2>
What's new in this drop</h2>
<ul>
-</ul>
-
-<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20693">20693</a>
-Finding references to variables does not find all occurances
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20011">20011</a>
-Searching for Inner Classes gives bad search results
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20520">20520</a>
-Refactor - expression detection incorrect
-
-<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20643">20643</a>
-Java Projects disappear
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020620 - 20th June 2002
-<br>Project org.eclipse.jdt.core v_260
-<h2>
-What's new in this drop</h2>
-<ul>
-</ul>
-
-<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20532">20532</a>
-Declaration of member binary type not found
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19799">19799</a>
-More problems with importing.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16140">16140</a>
-Non-java project gets .classpath
-
-<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20659">20659</a>
-Compile/rebuild analysis: white space causes large rebuild
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020618 - 18th June 2002
-<br>Project org.eclipse.jdt.core v_259
-<h2>
-What's new in this drop</h2>
-<ul>
-<li>Updated about.html file with reference to CPL 1.0.
+<li>Generalization of working copy deltas: the creation and destruction of any working copy (regular or shared)
+ now fires an <code>ElementChangedEvent</code> as well indicating that the working copy has been
+ <code>ADDED</code> or <code>REMOVED</code>.
+ Until now, only shared working copies were providing such delta notifications.
+ <br>See:
+ <ul>
+ <li><code>IWorkingCopy.getWorkingCopy()</code></li>
+ <li><code>IWorkingCopy.getWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)</code></li>
+ <li><code>IWorkingCopy.destroy()</code></li>
+ </ul>
</li>
-</ul>
+</ul>
<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31799">31799</a>
+Getting squigglies in Java files not on classpath
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31858">31858</a>
+NPE in log
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33371">33371</a>
+Rename method dialog: Error message should quote name
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33686">33686</a>
+Missing extension point schemas
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32981">32981</a>
+Cancel Extract Interface refactoring does not cleanup working copies
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33692">33692</a>
+Cleanup in the batch compiler default options
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33653">33653</a>
+Relevance - should privilege type not needing qualification
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33039">33039</a>
+Quick Fix: IAE n invocation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32588">32588</a>
+Error saving changed source files; all files in project deleted
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33560">33560</a>
+Workspace shows temporary problems also the compiler doesn't
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31765">31765</a>
+private recursive methods not marked as unused
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33231">33231</a>
+Deadlock performing CVS decoration while JRE initializers are invoked
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33571">33571</a>
+SearchEngine.searchAllTypeNames: NPE when passing null as progress monitor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33035">33035</a>
+OutOfMemoryException while searching for references
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33445">33445</a>
+CodeAssist - Relevance is not correct for local class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33462">33462</a>
+NPE during shutdown
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33424">33424</a>
+No completion available in local type constructor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33225">33225</a>
+Override methods... inserts methods incorrectly if class body is as {}
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33207">33207</a>
+Reject output folder that coincidate with source folder if not equal
<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33621">33621</a>
+ICompilationUnit.getElementAt(int) returns strange things when parameter is in a field declaration inside anonymous and local classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33696">33696</a>
+Java source exclusion filter stopped working in RC1
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32250">32250</a>
+Reporting unused private methods could be improved
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33610">33610</a>
+Deltas sent while in operation executed with JavaCore.run
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33573">33573</a>
+NPE in IndexManager on shutdown
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33527">33527</a>
+Inexact match searching in java.math.BigDecimal
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33505">33505</a>
+Compiler fails on allowed inner class code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33461">33461</a>
+NPE upon shutdown
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33466">33466</a>
+NPE on shutdown from IndexManager
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33475">33475</a>
+Build path seems to be lost every time Eclipse restarts
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020617 - 17th June 2002
-<br>Project org.eclipse.jdt.core v_258
+Eclipse SDK 2.1 Build - 27th February 2003
+<br>Project org.eclipse.jdt.core v_301
+<h2>
+What's new in this drop</h2>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=33321">33321</a>
+NPE in IndexManager shutdown
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31764">31764</a>
+CompletionEngine doesn't feed errors to completion requestor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32488">32488</a>
+Request to add/remove source folder to index should not look at active job
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32392">32392</a>
+NPE in SourceMapper
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32701">32701</a>
+Disassembler doesn't show actual modifiers for member types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32919">32919</a>
+Hierarchy views progress bar is useless
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32973">32973</a>
+Codeassist relevance should privilege prefix match over need for qualification
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32629">32629</a>
+DeltaProcessor walking some binary output
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32612">32612</a>
+Saved index file names leaking names?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32376">32376</a>
+Signature.getSimpleName/Qualifier should not create an own char-array
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32628">32628</a>
+Too much time finding out there is no source during search
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32974">32974</a>
+Invalid classpath error on ..classpath edition
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32986">32986</a>
+Stack overflow, infinate recursion in compiler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32607">32607</a>
+Removing outer folder removes nested folder's cus from index
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32937">32937</a>
+Kind not set for empty fine-grained delta
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32909">32909</a>
+compiler error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32690">32690</a>
+Classpath error are not detected after a Check out
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32738">32738</a>
+TVT: Externalized Strings to be removed from .properties file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32957">32957</a>
+StackOverFlowError renaming class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32323">32323</a>
+CVS information on class-Files lost during "rebuild project"
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32563">32563</a>
+IAE in org.eclipse.jdt.core.Signature.toCharArray (M5)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32900">32900</a>
+Java out of memory problem
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25848">25848</a>
+RedHat Linux LANG=en_US.UTF-8 causes some files *NOT* to be compiled
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32579">32579</a>
+abstract protected method can't be overridden
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32545">32545</a>
+Cannot override a method that's accessible in the superclass, but inaccessible in the super-superclass
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32179">32179</a>
+Problems searching for references to selected text
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 21st February 2003
+<br>Project org.eclipse.jdt.core v_300 - 2.1 RELEASE CANDIDATE 1
<h2>
What's new in this drop</h2>
<ul>
-<li>Removed deprecated 2.0 temporary API: <code>IWorkingCopy#findSharedWorkingCopy()</code> which was no longer used anyway. Proper API is taking
-a <code>IBufferFactory</code> in argument.</li>
-</ul>
+<li>In 1.4 compliant mode, the compiler will allow unterminated line comment (i.e. with no trailing line separator), as a consequence
+of the JLS revisal. Thus removed temporary (and unused) 2.1 API :
+<code>ToolFactory.createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean assertMode, boolean recordLineSeparator, <b>boolean strictComment</b>)</code>
+</li>
+</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20427">20427</a>
-J9c needs internal batch compiler methods to be public
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20309">20309</a>
-cannot code resolve on binary method with member type arguments
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20158">20158</a>
-Close and reopen a project does not remove errors
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20325">20325</a>
-CP Variable - should not persist "initialization in progress" value
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20173">20173</a>
-Open type from a jar located inside a closed project.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20135">20135</a>
-2.0 deprecated method
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32342">32342</a>
+The field type Class_A is defined in an inherited type and an enclosing scope
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32476">32476</a>
+Spec now allows line comment to end with EOF
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32339">32339</a>
+Cannot find declaration of SIGNATURE in Java text search
<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20359">20359</a>
-classpath variable ECLIPSE_HOME not initialized on startup
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20261">20261</a>
-cycle in classpath detection seems overzealous
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19826">19826</a>
-livelock during indexing?
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20048">20048</a>
-Minimize recompilation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20053">20053</a>
-interface with same-named method generates compile error
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020612 - 12th June 2002 - FREEZE 3
-<br>Project org.eclipse.jdt.core v_257
+Eclipse SDK 2.1 Build - 20th February 2003
+<br>Project org.eclipse.jdt.core v_299
<h2>
What's new in this drop</h2>
<ul>
-</ul>
-
-<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19537">19537</a>
-Internal error saving file (jzentry == 0)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19917">19917</a>
-Code Assist incorrect for hidden interface fields
-
-<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19916">19916</a>
-Error accessing value from uninitialized localvariable
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19566">19566</a>
-Invalid ClassCastException thrown at runtime
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3306">3306</a>
-Can't compile JDK src
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19851">19851</a>
-IllegalArgumentException in refactor-extract method
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7272">7272</a>
-Open on selection not working in external JARs
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14219">14219</a>
-EOF exception after building in imported plugin with extracted source
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18290">18290</a>
-Incorrect errors reported during reconciling
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020611 - 11th June 2002
-<br>Project org.eclipse.jdt.core v_256
-<h2>
-What's new in this drop</h2>
-<ul>
-<li> Added protection around listener callback invocations (using <code>ISafeRunnable</code>). </li>
-<li> Removed 2 unused deprecated constants on <code>IJavaSearchConstants</code>: READ_REFERENCES and WRITE_REFERENCES.
-They were annoted with intention to discard before 2.0 since were temporarily introduced and deprecated (due to bad naming).
+<li>Added helper method to extract problem marker arguments: <code>CorrectionEngine.getProblemArguments(IMarker problemMarker)</code>
+<li>Added 2 settings to disable classpath enhancements which could affect 2.0 clients.
<pre>
- /**
- * @deprecated - use WRITE_ACCESSES instead (will be discarded before 2.0)
- * @since 2.0
- */
- int WRITE_REFERENCES = WRITE_ACCESSES;
- </pre></li>
-</ul>
+* JAVACORE / Enabling Usage of Classpath Exclusion Patterns
+* When set to "disabled", no entry on a project classpath can be associated with
+* an exclusion pattern.
+* - option id: "org.eclipse.jdt.core.classpath.exclusionPatterns"
+* - possible values: { "enabled", "disabled" }
+* - default: "enabled"
+*
+* JAVACORE / Enabling Usage of Classpath Multiple Output Locations
+* When set to "disabled", no entry on a project classpath can be associated with
+* a specific output location, preventing thus usage of multiple output locations.
+* - option id: "org.eclipse.jdt.core.classpath.multipleOutputLocations"
+* - possible values: { "enabled", "disabled" }
+* - default: "enabled"
+</pre>
+<li>Removed temporary 2.1 API :
+ <ul>
+ <li><code>IPackageFragmentRoot.computeSourceAttachmentRootPath(IPath sourceAttachmentPath)</code>
+ </li>
+ <li><code>IJavaModelMarker.UNBOUND_CONTAINER</code>, use classpath problem marker ID instead (<code>IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND</code>).
+ </li>
+ <li><code>IJavaModelMarker.UNBOUND_VARIABLE</code>, use classpath problem marker ID instead (<code>IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND</code>).
+ </li>
+ </ul>
+</li>
+</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19714">19714</a>
-Eclipse crashes: Drag & Drop
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19794">19794</a>
-Method body change may result in massive recompilation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18983">18983</a>
-Replacing binary project doesn't trigger build
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18953">18953</a>
-Package disapears when disconnected from CVS repopsitory
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19638">19638</a>
-Open Type Hierarchy can start infinite progress monitor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19687">19687</a>
-Preferences not working with import/export
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19512">19512</a>
-ArrayIndexOutOfBound during incremental build
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18922">18922</a>
-Scrapbook does not come back when errors in snippet
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29578">29578</a>
+Issues with migrating shared data
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32040">32040</a>
+Multiple output folders fooling Java builder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32217">32217</a>
+Missing JavaCore in JDT/Core project index
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32338">32338</a>
+Auto generated comments of quickfix method generation for unnamed package class is wrong
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32271">32271</a>
+Type Hierarchy Progress monitor improvements
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32267">32267</a>
+TypeHierarchy. Does not set progress monitor to done when cancelled
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32218">32218</a>
+Inexact matches found when should be exact
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31016">31016</a>
+builder exception found in log
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32225">32225</a>
+incorrect delta after deleting 2 fields
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32219">32219</a>
+JavaModel operations fail with ArrayIndexOutOfBoundsException if array empty
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32182">32182</a>
+NPE performing search
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27994">27994</a>
+Code Assist replace mode inconsistent
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32041">32041</a>
+Multiple output folders fooling Java Model
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32196">32196</a>
+Patch: correctly detect misisng .rsc file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32111">32111</a>
+ArrayIndexOutOfBoundsException during delete of members
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32100">32100</a>
+when superpackage package empty deleting a subpackage deletes superpackage
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31646">31646</a>
+No proposal using code assist in field initializer
<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19808">19808</a>
-core ClassCastException exception in log
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19882">19882</a>
-maybe a cu's single type can be its proimary type too
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19586">19586</a>
-Java project removed from Projects view
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15972">15972</a>
-JAR file from classpath not indexed
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18680">18680</a>
-Classpath Loop
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32227">32227</a>
+Serialization incompatibility with Sun's 1.4 compiler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28426">28426</a>
+Content Assist displays x(String arg0, String arg1) should be x(String str, String delim)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32164">32164</a>
+Serialization methods with private or arbitrary access modifiers should be ignored by "unused private members" compiler check.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32097">32097</a>
+Regression - attached source not found when in a subdirecory of archive
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020606 - 6th June 2002
-<br>Project org.eclipse.jdt.core v_255
+Eclipse SDK 2.1 Build - 18th February 2003
+<br>Project org.eclipse.jdt.core v_298
<h2>
What's new in this drop</h2>
<ul>
-<li>Removed deprecated API on <code>IJavaProject</code>. These were not in 1.0, and shouldn't have been
-introduced (incorrectly resurrected from 0.9).
+<li>Fix for bug <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31997">31997</a>
+ requires the index format to be changed. Indexes will be automatically regenerated upon
+ subsequent search queries (accounting for indexing notification in search progress dialogs).
+</li>
+<li>Unused parameter diagnosis will now ignore parameters in an abstract method,
+a main method, an implementation of an abstract method or a method overriding a
+concrete one. Additional settings got added for enabling the diagnosis of the latter
+two scenarii.
+<pre>
+* COMPILER / Reporting Unused Parameter if Implementing Abstract Method
+* When enabled, the compiler will signal unused parameters in abstract method implementations.
+* The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
+* - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
+* - possible values: { "enabled", "disabled" }
+* - default: "disabled"
+*
+* COMPILER / Reporting Unused Parameter if Overriding Concrete Method
+* When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
+* The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
+* - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
+* - possible values: { "enabled", "disabled" }
+* - default: "disabled"
+</pre>
+</li>
+<li><b>Code completion enhancement:</b>
+ <ul>
+ <li>Relevance of a proposal is higher if the proposal is a variable name and this name contains a prefix.</li>
+ <li>Relevance of a proposal is higher if the proposal is a variable name and this name contains a suffix.</li>
+ </ul>
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32107">32107</a>
+Index signature change isn't honoured any longer
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31997">31997</a>
+Refactoring d.n. work for projects with brackets in name.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31417">31417</a>
+Where has the "Root Path" field gone? [doc]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32000">32000</a>
+IJavaModel.contains() returns true for resources copied into bin folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31947">31947</a>
+NPE on shutdown in BlocksIndexInput.close()
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31985">31985</a>
+NPE searching non-qualified and case insensitive type ref
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28637">28637</a>
+[Preferences] Import Preferences: Console Message: Content is not allowed in Prolog
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31748">31748</a>
+[search] search for reference is broken 2.1 M5
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31990">31990</a>
+Working copy operations should not take workspace lock
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31811">31811</a>
+VerifyError with huge switch statement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5783">5783</a>
+Problem counts are not accumulated
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31652">31652</a>
+NamingConvention.suggestXXNames: Put the most relevant first
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31628">31628</a>
+Redundant import need a warning (matching package declaration)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31867">31867</a>
+No unused import diagnosis on duplicate import
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31495">31495</a>
+Should writeObject/readObject be a compiler warning?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31538">31538</a>
+serialVersionUID being flagged as an "unused" field
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31757">31757</a>
+Folder with invalid pkg name should be non-Java resource
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25204">25204</a>
+Eclipse compiler option: Unused parameters (i.e. never read)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27251">27251</a>
+Compiler preferences: Unused parameters - ignore main
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31383">31383</a>
+Strange rendering of of link resources when link points to Eclipse workspace
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31756">31756</a>
+Code assist: fails inside an array which inside a function call
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31248">31248</a>
+Java Compiler progress monitor tells about probelms found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29790">29790</a>
+OOM Exception in search cause IDE freeze
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32083">32083</a>
+overridden methods that change visibility cause compiler error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=32044">32044</a>
+Pre auto build notification fired when closing or opening a file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31903">31903</a>
+Null pointer exception loading from respository
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31968">31968</a>
+Notifier loose nested levels
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31942">31942</a>
+Bug with Selection Statement switch()
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31916">31916</a>
+M5 Crashing
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31923">31923</a>
+Source folder specific compiler settings
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31917">31917</a>
+Unused private method warning doesn't know about read/writeObject
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8452">8452</a>
+Wrong position in FieldReference
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12797">12797</a>
+Can't add directory pointing to class-files to project classpath
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11023">11023</a>
+Filter code assist choices based on context
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7293">7293</a>
+Scrubbing Output Directory Can Cause Havoc
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6096">6096</a>
+Exception using code assist after package rename
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5043">5043</a>
+Feature Request: source folders in other projects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6488">6488</a>
+Classpath Variables (allow plugins to reserve some)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31809">31809</a>
+Eclipse reports error in task view - but it's no error!
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28319">28319</a>
+Unused parameter should be limited to current method/class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31243">31243</a>
+Warn of unused parameters: Should not warn when method overrides
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28139">28139</a>
+Highlight unused method parameters that are not inherited
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31380">31380</a>
+NPE setting classpath
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 13th February 2003
+<br>Project org.eclipse.jdt.core v_297
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>To help fixing bug <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31135 ">31135</a>,
+ added new flag <code>F_REORDER</code> on <code>IJavaElementDelta</code>. This flag is
+ positioned if a member in a compilation unit has changed its position relatively to its siblings.
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31476">31476</a>
+CU is on build path also it is located in a excluded folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31303">31303</a>
+copy of read-only package doesn't preserve read-only flag
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24045">24045</a>
+Error deleting parent folder of source folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31653">31653</a>
+typos in javadoc of NamingConventions
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30623">30623</a>
+Strange java delta when creating a new class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31446">31446</a>
+Cannot cancel 'Cleaning of output foder'
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30757">30757</a>
+Out of memory exception during hierarchy scoped search
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30485">30485</a>
+ArrayOutOfBoundsException during shutdown
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30609">30609</a>
+Output folder scrubbing
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31497">31497</a>
+Internal compiler error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31591">31591</a>
+abstract method in base class, defined in a subclass results in compile error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31605">31605</a>
+Single line comment on the last line of a file produces a syntax error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31626">31626</a>
+getJavadoc() on TypeDeclaration returning incorrect comment
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 11th February 2003
+<br>Project org.eclipse.jdt.core v_296
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31377">31377</a>
+NullPointerException on binary import
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31441">31441</a>
+Match in jar missing searching for references
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31398">31398</a>
+M5 compilation problems with package abstract methods
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31230">31230</a>
+Code assist on variable names: uses prefix and suffix together
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31440">31440</a>
+Classpath container initializer getDescription should also take a project in argument
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31242">31242</a>
+exception names should use Local Var suffix/prefix, not Method Param
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31168">31168</a>
+Trying to open Java-source file with Java editor fails with I/O Exception.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31261">31261</a>
+Strange behavior when there is more errors than max errors per compilation unit
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31450">31450</a>
+Compiler bug with overriding protected abstract methods, where a parent class has package-private abstract method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31475">31475</a>
+class must implement the inherited abstract method, but cannot override it
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30720">30720</a>
+linked resources and exclusion filters: compiler markers not flushed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31467">31467</a>
+spurious "Incompatible conditional operand types" on ?: when assigning to abstract
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30800">30800</a>
+Search - doesn't find declaration of field with unicode name
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31225">31225</a>
+Source attachment not found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=31148">31148</a>
+freezes when editing a java file and adding while(st.hasMoreTokes())
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30731">30731</a>
+Class move refactoring changes the unlinked projects in the same workplace
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 6th February 2003
+<br>Project org.eclipse.jdt.core v_295 - 2.1 MILESTONE-5 (aka 2.1 RELEASE CANDIDATE 0)
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Added API <code>ClasspathContainerInitializer.getDescription(IPath containerPath)</code> so as to improve readability
+of our messages involving classpath containers (e.g. unbound container classpath problems). Default implementation answers
+the original container path.
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30946">30946</a>
+Deadlock in code parser
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30999">30999</a>
+Hang/Deadlock while inserting brace
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30949">30949</a>
+When compiled from eclipse, unhandled exceptions in try - finally block are not detected.
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 5th February 2003
+<br>Project org.eclipse.jdt.core v_294
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> Classpath problem markers generated for unbound variable or container will have an extra attribute
+(respectively IJavaModelMarker.UNBOUND_VARIABLE or IJavaModelMarker.UNBOUND_CONTAINER) which value is
+the unbound variable or container names. This allows clients to recognize these problems, and contribute
+suitable recovery actions for these.
+</li>
+<li> Project cycles can now be built as soon as the compiler severity for circular
+dependencies is lowered to a warning (see Preferences>Java>Compiler>Other>Circular dependencies>Warning).
+</li>
+<li> Surfaced compiler options for reporting usage of char[] in String concatenations (default is still warning).
+<pre>
+* COMPILER / Reporting Usage of char[] Expressions in String Concatenations
+* When enabled, the compiler will issue an error or a warning whenever a char[] expression
+* is used in String concatenations (e.g. "hello" + new char[]{'w','o','r','l','d'}).
+* - option id: "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
+* - possible values: { "error", "warning", "ignore" }
+* - default: "warning"
+</pre>
+</li>
+<li>Added API <code>IJavaModel.contains()</code> to find out if an <code>IResource</code> is visible in
+ the Java model.
+</li>
+<li> 2.1 API Change in org.eclipse.jdt.core.NamingConventions: deprecated 'suggestSetterName' methods removed.
+ <ul>
+ <li><code>suggestSetterName(IJavaProject,char[],int,char[][])</code>
+ </li>
+ <li><code>suggestSetterName(IJavaProject,String,int,String[])</code>
+ </li>
+ </ul>
+</li>
+<li>Added API for sorting the members of types in a compilation.
<ul>
- <li><code>IJavaProject#getClasspath(...) --> IJavaProject#getRawClasspath(...) </code></li>
- <li><code>IJavaProject#setClasspath(...) --> IJavaProject#setRawClasspath(...) </code></li>
- <li><code>IJavaProject#newProjectEntry(...) --> JavaCore#newProjectEntry(...) </code></li>
- <li><code>IJavaProject#newLibraryEntry(...) --> JavaCore#newLibraryEntry(...) </code></li>
- <li><code>IJavaProject#newSourceEntry(...) --> JavaCore#newSourceEntry(...) </code></li>
+ <li><code>org.eclipse.jdt.core.util.CompilationUnitSorter</code>
+ <pre>
+public static final String RELATIVE_ORDER = "relativeOrder";
+public static void sort(ICompilationUnit compilationUnit,
+ int[] positions,
+ Comparator comparator,
+ int options,
+ IProgressMonitor monitor) throws JavaModelException;
+ </pre>
+ </li>
</ul>
</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30947">30947</a>
+CodeAssist - top level types are not proposed if type is qualified with package
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30907">30907</a>
+Code assist doesn't work in first case statement of a switch statement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30920">30920</a>
+Stack overflow when container resolved to null
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30855">30855</a>
+Wron error message when nesting source folder in class folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30857">30857</a>
+IPackageFragmentRoot: copy removes source folders from classpath
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22756">22756</a>
+Reference search does not respect package fragments scope
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30860">30860</a>
+CodeAssist - Relevance is not correct for member exception
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30856">30856</a>
+1.4 compliant mode should consider abstract method matches
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30825">30825</a>
+Missing REORDERED_IN_CLASSPATH notifications
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26909">26909</a>
+NPE opening type hierarchy for binary type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29832">29832</a>
+Bogus quickfixes after removing/adding core plugins
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30699">30699</a>
+External JAR: no refresh in JavaModel if full build occurred before
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30697">30697</a>
+Classpath marker update could trigger automatic refresh for external JARs
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30805">30805</a>
+Abstract non-visible method diagnosis fooled by intermediate declarations
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14597">14597</a>
+rearrange source code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30417">30417</a>
+ICodeFormatter format method should specify that the positions are sorted from the lowest to the biggest
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30709">30709</a>
+Return value of IPackageFragementRoot.getElementName() has changed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30705">30705</a>
+Simple name should consider member types before toplevel types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30704">30704</a>
+01e0f should be accepted as valid floating point literal
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30511">30511</a>
+IPackageFragmentRoot:move ignores FORCE flag
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30516">30516</a>
+typo in javadoc of IPackageFragmentRoot:isArchive
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30506">30506</a>
+IPackageFragmentRoot:delete does not handle external jars
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20614">20614</a>
+Failure compiling a project with cyclic dependencies
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30227">30227</a>
+compilerAdapter jar should not be include in the repo
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30274">30274</a>
+Need method to figure out if an IResource is visible through the Java Model
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27027">27027</a>
+ClassCastException from codeassist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30503">30503</a>
+IPackageFragmentRoot:move, copy should accept null as sibling
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30496">30496</a>
+CU/classfile name validation shouldn't scan if suffix isn't the proper one
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30471">30471</a>
+AST.parseCompilationUnit(IClassFile, boolean) throws IAE even if class file has source
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30487">30487</a>
+NPE during shutdown in path canonicalization
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26912">26912</a>
+'null == null' fooling blank final analysis
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30280">30280</a>
+NullPointerException at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.resolveType(QualifiedAllocationExpression.java:225)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30393">30393</a>
+Its back: Core Exception [code 380] The resource tree is locked for modifications
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5347">5347</a>
+class files not updated
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9838">9838</a>
+Wrong diagnosis compiling inner classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30600">30600</a>
+incorrect code assist after 'throw new'
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30799">30799</a>
+Core dump with J2SDK 1.4.1_01 in java.util.zip.ZipFile.getNextEntry
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30739">30739</a>
+\u4100 is rejected as an identifier character
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30782">30782</a>
+Can't rename a package to the same name with different case
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30522">30522</a>
+IPackageFragmentRoot: move, copy updateClasspath semantics
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30567">30567</a>
+GB18030: Class name, method name, variable name can not contain GB18030 character in some version of Eclipse for Linux.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30629">30629</a>
+search: no occurrences to type found if type in default package in nested source folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27770">27770</a>
+Rebuild all doesn't follow project dependencies
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24832">24832</a>
+Recurency between projects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27750">27750</a>
+[startup] starting javacore takes 13% of empty worspace startup
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22710">22710</a>
+simple save takes 40 seconds
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30470">30470</a>
+IJavaModelStatus.getMessage not the same as getString
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30465">30465</a>
+PDE binary project import fills log with core exceptions
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28224">28224</a>
+Invalid "Unused Imports" warning when importing inner classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27583">27583</a>
+reconciling allocates megabytes of memory in seconds of typing
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 28th January 2003
+<br>Project org.eclipse.jdt.core v_293
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> By default, JDT/Core will consider a default task tag "TODO" (with normal priority). In the past, default was no task reported.
+<li> Added APIs to save/restore type hierarchies. Note that the client still has to register as a <code>ITypeHierarchyChangedListener</code> once
+restoration has occurred.
+ <ul>
+ <li> <code>ITypeHierarchy.store(OutputStream, IProgressMonitor)</code> for saving a type hierarchy.
+ </li>
+ <li> <code>IType.load(InputStream, IProgressMonitor)</code> for restoring a previously saved hierarchy.
+ </li>
+ </ul>
+</li>
+<li> Added APIs to manipulate package fragment roots:
+ <ul>
+ <li><code>IPackageFragmentRoot.copy(IPath, int, boolean, IClasspathEntry, IProgressMonitor)</code>
+ </li>
+ <li><code>IPackageFragmentRoot.delete(int, boolean, IProgressMonitor)</code>
+ </li>
+ <li><code>IPackageFragmentRoot.move(IPath, int, boolean, IClasspathEntry, IProgressMonitor)</code>
+ </li>
+ </ul>
+ Note that these APIs are very close to the corresponding <code>IResource</code> APIs except that
+ they filter out nested source folders, and that they update the project's classpaths if specified.
+</li>
+<li> Extended compiler optional warning for interface methods incompatible with Object
+non public methods to scenario where thrown exceptions are not compatible (problem ID:
+<code>IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod</code>).
+This problem is optional, and its severity is also controlled by the <code>JavaCore</code>
+preference <code>"org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"</code>.
+</li>
+<li> 2.1 API Change in org.eclipse.jdt.core.NamingConventions: a new boolean parameter 'isBoolean' added. The value of this parameter is <code>true</code> if the field's type is boolean.
+ <ul>
+ <li><code>suggestSetterName(IJavaProject,char[],int,char[][])</code> become <code>suggestSetterName(IJavaProject,char[],int,boolean,char[][])</code>
+ </li>
+ <li><code>suggestSetterName(IJavaProject,String,int,String[])</code> become <code>suggestSetterName(IJavaProject,String,int,boolean,String[])</code>
+ </li>
+ </ul>
+ Previous APIs got deprecated, and will be removed before 2.1.
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22049">22049</a>
+Hierarchy View slow to calculate hierarchy [type hierarchy]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29411">29411</a>
+Projects rebuilt after restart of Eclipse
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30282">30282</a>
+TODO task message shouldn't be multiline
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30102">30102</a>
+NamingConvention: Tests fail
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30113">30113</a>
+Wrong positions in the outliner for a field that follows an initializer
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30224">30224</a>
+No JavaElement delta when renaming non-Java project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30108">30108</a>
+not clear what 'modifiers' in NamingConventions means
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30099">30099</a>
+NamingConvention.suggestArgumentNames: No guess returned
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27291">27291</a>
+[Dialogs] Error dialog looks bad if status message is null
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28666">28666</a>
+Unclear error message for invalid output folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366">29366</a>
+Search reporting invalid inaccurate match
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29864">29864</a>
+Unable to restore working set item - cannot instantiate item: org.eclipse.jdt.ui.PersistableJavaElementFactory
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28044">28044</a>
+weird errors not reported anywhere but in text and overview ruler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30013">30013</a>
+Project compiler setting workspace | project do not persist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29151">29151</a>
+NPE in Surround with try/catch block [refactoring]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29969">29969</a>
+CodeAssist: too much proposals just after 'switch'
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29955">29955</a>
+Should not report incompatible throws clause for interface if Object non public ref method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29894">29894</a>
+Path matching failure (CharOperation)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29761">29761</a>
+Regular expression pattern in exclusion filter is too greedy in M4
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29761">29803</a>
+Source path exclusion filter not relative source folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23134">23134</a>
+Odd behavior from code formatter
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30357">30357</a>
+Incompatibility of serialization with sun jdk
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30370">30370</a>
+Warning "import never used" in spite of use by a javadoc @link
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30209">30209</a>
+JDT compiler bytecode incompatibility with JDK bytecode results in serialization error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27497">27497</a>
+Compile only on class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28263">28263</a>
+Better specification of source folders
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30232">30232</a>
+NullPointerException in compilation unit
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=30160">30160</a>
+CodeAssist - no completion behind jProject
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29862">29862</a>
+GB18030:Could not set a GB18030 character as workbench classpath variable.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29863">29863</a>
+GB18030: Could not create a class variable whose name contains a GB18030 character
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27616">27616</a>
+[Compiler] stack overflow while editing
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23299">23299</a>
+Enhance Code completion
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29239">29239</a>
+Refactoring throws exception if .project or .classpath read-only in 2.1 M4
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 21st January 2003
+<br>Project org.eclipse.jdt.core v_292a
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29872">29872</a>
+ImportOrganizeTest failing due to file missing from index
+
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 21st January 2003
+<br>Project org.eclipse.jdt.core v_292
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> New compiler setting got added to control severity of incompatible interface method with Object non public method.
+This used to be reported incorrectly as an error by our compiler (e.g. <code>interface I { int clone(); }</code>), and
+is now an optional problem (default severity is WARNING). Corresponding problem ID is: <code>IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod</code>.
+<pre>
+* COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
+* When enabled, the compiler will issue an error or a warning whenever an interface
+* defines a method incompatible with a non-inherited Object one.
+* - option id: "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
+* - possible values: { "error", "warning", "ignore" }
+* - default: "warning"
+</pre>
+</li>
+<li> New compiler problems got added to report declarations of unused private members (field/method/type). A JavaCore setting
+got added to control the severity of these new problems (default severity is IGNORE). Note that currently only a valid local usage
+is considered as a true usage (e.g. if a message send targets this method, but cannot see it, then the target method will still be
+reported as unused). Corresponding problem IDs are: <code>IProblem.UnusedPrivateMethod</code>, <code>IProblem.UnusedPrivateField</code>,
+<code>IProblem.UnusedPrivateType</code> and <code>IProblem.UnusedPrivateConstructor</code>.
+<pre>
+* COMPILER / Reporting Unused Private Members
+* When enabled, the compiler will issue an error or a warning whenever a private
+* method or field is declared but never used within the same unit.
+* - option id: "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
+* - possible values: { "error", "warning", "ignore" }
+* - default: "ignore"
+</pre>
+</li>
+<li>CodeAssist now answers keyword completions. Note that there was already an API for these: <code>ICompletionRequestor#acceptKeyword(char[] keywordName, int completionStart, int completionEnd, int relevance)</code>
+which wasn't invoked until now. There is currently no way to distinguish in between a 'synchronized' keyword used as a modifier or as a statement.
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26363">26363</a>
+[ast/dom] type bindings that return null for superclass
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22381">22381</a>
+Show unused fields and variables [refactoring] [search]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19063">19063</a>
+code assist proposals for keywords
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29771">29771</a>
+No reference found to IResource.getLocation when no case sensitive
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28236">28236</a>
+Search for refs to class in hierarchy matches class outside hierarchy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28951">28951</a>
+Source attachment rootpath field missing in UI
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29536">29536</a>
+Check use of IResource.getLocation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29337">29337</a>
+Poor wording in task message "This method overrides deprecated..."
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29601">29601</a>
+TypeHierarchy: Avoid to use 'isInterface' / 'isClass'
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29540">29540</a>
+Search Engine return extra results
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29524">29524</a>
+Search for declaration via patterns adds '"*"
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26260">26260</a>
+task markers: limitting the number of problems per CU limits the number of tasks/markers (in general) per CU
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29306">29306</a>
+Can't get content of CU not on classpath
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3331">3331</a>
+DCR: Code Formatter should offer cast without space (1GI74GZ)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29690">29690</a>
+Locked Resource Tree (JavaModelException)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29585">29585</a>
+Core Exception as resource tree is locked initializing classpath container
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29487">29487</a>
+Internal compiler error: final field set in loop (in constructor)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29546">29546</a>
+Project rebuild cannot write over .class files
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29636">29636</a>
+First anonymous type should be named X$1
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29638">29638</a>
+No field initializations on Object
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27413">27413</a>
+Should we reject that code?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29211">29211</a>
+Should check the visibility of the array type before accessing its length field
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29213">29213</a>
+Should check the visibility of the array type before calling a method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29621">29621</a>
+Wrong Delta When Adding to Filtered Folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29637">29637</a>
+Default debug attributes don't match with javac
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29538">29538</a>
+External jar not indexed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28489">28489</a>
+PackageFragmentRoot.fullExclusionPatternChars() could be optimized for non-source roots
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29298">29298</a>
+Simplify AST creation for an IClassFile (minor)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29374">29374</a>
+Excluded folder on project not returned by Java Model
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27485">27485</a>
+SearchEngine returns wrong java element when searching in an archive that is included by two distinct java projects.
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23300">23300</a>
+Context sensitive Code Completion
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29541">29541</a>
+Scrubbing wipes out entire build directory
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28393">28393</a>
+Duplicate 'missing require project' marker
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25976">25976</a>
+Bug in code formatter: can't be called twice in a row...
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25896">25896</a>
+weird formatting of import declarations
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26426">26426</a>
+Add preference to sort method in the source file.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25875">25875</a>
+import splitting behavior
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23992">23992</a>
+Adding partial compilation for JAVA
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19501">19501</a>
+Found NPE in log
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13029">13029</a>
+"Build" sometimes builds files that have not changed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13008">13008</a>
+Move a Java file, errors remain
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11572">11572</a>
+Cannot refresh a jar file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8720">8720</a>
+include an external directory of classes in Java build path
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3359">3359</a>
+Get rid of source attachment root (1GJON3Q)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28073">28073</a>
+[startup] on startup, jCore loads launching plugins which loads debug plugins
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29652">29652</a>
+Can't attach source to some ZIP files
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29229">29229</a>
+Internal compiler error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28801">28801</a>
+Internal compiler error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18239">18239</a>
+Startup takes too long with java editor open
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28819">28819</a>
+Nullpointer exception when building
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28820">28820</a>
+NullPointerException in compiler in M4
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28953">28953</a>
+internal compiler error: NullPointerException in file with inner class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28954">28954</a>
+Internal compiler error -- assert statements in inner class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28980">28980</a>
+Null-pointer exception on nested class assert
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29267">29267</a>
+NullPointerExc. occured when building project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29088">29088</a>
+Internal compiler error compiling code in M4 edition of eclipse
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29031">29031</a>
+Internal compiler error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5520">5520</a>
+Class files which are source not shown
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3531">3531</a>
+NewClass(Interface)Wizard - shows not-visible types (1G4GNH3)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23033">23033</a>
+[Tasks] Create seperate setting for stopping build on a circular dependency error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28076">28076</a>
+NPE during quick shutdown
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29144">29144</a>
+Missing code implementation in the compiler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29527">29527</a>
+Organize imports fails on included code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29501">29501</a>
+Uninitialized variable warning does not analyze the program thoroughly enough
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29394">29394</a>
+suboptimal handling closing/opening projects in autobuild
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29009">29009</a>
+ClassCircularityError in RequiredPluginsInitializer
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 15th January 2003
+<br>Project org.eclipse.jdt.core v_291a
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29516">29516</a>
+SearchEngine regressions in 20030114
+
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 14th January 2003
+<br>Project org.eclipse.jdt.core v_291
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28545">28545</a>
+JavaProject.exists() returns true if project doesn't have Java nature
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29404">29404</a>
+JavaCore.create(IProject) returns != null for non Java Projects.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28752">28752</a>
+J Search resports non-existent Java element
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22783">22783</a>
+Unexpected null in compiler error message
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29365">29365</a>
+Syntax error inside method body is fooling NLS string detection
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29277">29277</a>
+ToolFactory.createDefaultClassFileReader: Retrieving of classfile location
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29376">29376</a>
+Remove 65k limit on static data
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29176">29176</a>
+[DOM/AST] Statement.get/setLeadingComment should be deleted
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29274">29274</a>
+Surface non-java projects as model non-java resources
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28531">28531</a>
+Classpath Entry: Output folder can not be set to project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28824">28824</a>
+Quick Fix: Type Mismatch -> Cast bug [quick fix]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28599">28599</a>
+validateClasspath rendering of paths
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29079">29079</a>
+Buildpath validation: No check that output folder is inside project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29159">29159</a>
+DeltaProcessor walks removed project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28822">28822</a>
+ClassCastException in ProblemBinding
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28596">28596</a>
+Default output folder cause of validation error even if not used
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28672">28672</a>
+Batch compiler should support argument expansion
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28617">28617</a>
+Qualified super reference cannot be surrounded with parentheses.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27298">27298</a>
+Must return result error could be more accurate
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28869">28869</a>
+Parse error with final local vars without immediate assignment
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28682">28682</a>
+org.eclipse.jdt.core.dom.ForStatement's body position is incorrect
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28622">28622</a>
+Check deprecation should handle unicodes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28559">28559</a>
+@deprecated has to be at the beginning of the comment line
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20844">20844</a>
+Indexing space usage
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26820">26820</a>
+Out of Memory indexing new plugins
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27289">27289</a>
+ClassCircularityError forces ClassNotFoundException's
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27401">27401</a>
+[startup] Review JavaCore.startup()
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28557">28557</a>
+Deprecation is not checked when subclassing a deprecated member type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28615">28615</a>
+Cannot optimize out -0.0 in array initializers
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28750">28750</a>
+Compiler crashes with M4
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27241">27241</a>
+Missing code generation for the qualifier of a static method invocation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3173">3173</a>
+Constant field code generation (1FEWXZW)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28583">28583</a>
+Missing one unit in package view
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28934">28934</a>
+Using assert keyword in methods of nested classes causes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25980">25980</a>
+NullPointerException during Refactor/Move operation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29343">29343</a>
+[M4] Scribbling on missing return statement needs to go on a diet
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29197">29197</a>
+NullPointerException when compiling Class with an assert in a method of an inner class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29082">29082</a>
+Can't access Inner class static field through an instance
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28675">28675</a>
+NPE in indexer
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28908">28908</a>
+ClassCastException in JavaProject.computePackageFragmentRoots
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27430">27430</a>
+Java model hangs onto many ClassFile objects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=29030">29030</a>
+Compiler Bug -- incorrect visibility of protected constructors
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28830">28830</a>
+Flexible projects cannot share output directory
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 17th December 2002 - 2.1 MILESTONE-4
+<br>Project org.eclipse.jdt.core v_290
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Added new JavaCore options
+ <ul>
+ <li>CODEASSIST / Define the Prefixes for Field Name<br>
+ When the prefixes is non empty, completion for field name will begin with
+ one of the proposed prefixes.<br>
+ <ul>
+ <li>option id: "org.eclipse.jdt.core.codeComplete.fieldPrefixes"</li>
+ <li>possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card</li>
+ <li>default: ""</li>
+ </ul>
+ </li>
+ <li>CODEASSIST / Define the Prefixes for Static Field Name<br>
+ When the prefixes is non empty, completion for static field name will begin with
+ one of the proposed prefixes.<br>
+ <ul>
+ <li>option id: "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"</li>
+ <li>possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card</li>
+ <li>default: ""</li>
+ </ul>
+ </li>
+ <li>CODEASSIST / Define the Prefixes for Local Variable Name<br>
+ When the prefixes is non empty, completion for local variable name will begin with
+ one of the proposed prefixes.<br>
+ <ul>
+ <li>option id: "org.eclipse.jdt.core.codeComplete.localPrefixes"</li>
+ <li>possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card</li>
+ <li>default: ""</li>
+ </ul>
+ </li>
+ <li>CODEASSIST / Define the Prefixes for Argument Name<br>
+ When the prefixes is non empty, completion for argument name will begin with
+ one of the proposed prefixes.<br>
+ <ul>
+ <li>option id: "org.eclipse.jdt.core.codeComplete.argumentPrefixes"</li>
+ <li>possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card</li>
+ <li>default: ""</li>
+ </ul>
+ </li>
+ <li>CODEASSIST / Define the Suffixes for Field Name<br>
+ When the suffixes is non empty, completion for field name will end with
+ one of the proposed suffixes.<br>
+ <ul>
+ <li>option id: "org.eclipse.jdt.core.codeComplete.fieldSuffixes"</li>
+ <li>possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card </li>
+ <li>default: ""</li>
+ </ul>
+ </li>
+ <li>ODEASSIST / Define the Suffixes for Static Field Name<br>
+ When the suffixes is non empty, completion for static field name will end with
+ one of the proposed suffixes.<br>
+ <ul>
+ <li>option id: "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"</li>
+ <li>possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card </li>
+ <li>default: ""</li>
+ </ul>
+ </li>
+ <li>CODEASSIST / Define the Suffixes for Local Variable Name<br>
+ When the suffixes is non empty, completion for local variable name will end with
+ one of the proposed suffixes.<br>
+ <ul>
+ <li>option id: "org.eclipse.jdt.core.codeComplete.localSuffixes"</li>
+ <li>possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card </li>
+ <li>default: ""</li>
+ </ul>
+ </li>
+ <li>CODEASSIST / Define the Suffixes for Argument Name<br>
+ When the suffixes is non empty, completion for argument name will end with
+ one of the proposed suffixes.<br>
+ <ul>
+ <li>option id: "org.eclipse.jdt.core.codeComplete.argumentSuffixes"</li>
+ <li>possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card </li>
+ <li>default: ""</li>
+ </ul>
+ </li>
+ </ul>
+</li>
+<li>New API class : org.eclipse.jdt.core.NamingConventions<br>
+This class provides methods for computing Java-specific names.
+<pre>
+package org.eclipse.jdt.core;
+public final class NamingConventions {
+ public static char[] removePrefixAndSuffixForArgumentName(IJavaProject javaProject, char[] argumentName) {...}
+ public static String removePrefixAndSuffixForArgumentName(IJavaProject javaProject, String argumentName) {...}
+ public static char[] removePrefixAndSuffixForFieldName(IJavaProject javaProject, char[] fieldName, int modifiers) {...}
+ public static String removePrefixAndSuffixForFieldName(IJavaProject javaProject, String fieldName, int modifiers) {...}
+ public static char[] removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, char[] localName) {...}
+ public static String removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, String localName) {...}
+ public static char[][] suggestArgumentNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames) {...}
+ public static String[] suggestArgumentNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames) {...}
+ public static char[][] suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames) {...}
+ public static String[] suggestFieldNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, int modifiers, String[] excludedNames) {...}
+ public static char[][] suggestLocalVariableNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames) {...}
+ public static String[] suggestLocalVariableNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames) {...}
+ public static char[] suggestGetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames) {...}
+ public static String suggestGetterName(IJavaProject project, String fieldName, int modifiers, boolean isBoolean, String[] excludedNames) {...}
+ public static char[] suggestSetterName(IJavaProject project, char[] fieldName, int modifiers, char[][] excludedNames) {...}
+ public static String suggestSetterName(IJavaProject project, String fieldName, int modifiers, String[] excludedNames) {...}
+}
+</pre>
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28434">28434</a>
+Open Type broken when workspace has build path problems
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28326">28326</a>
+"Open Type" dialog could not open selected type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28476">28476</a>
+JRE container description wrong
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28447">28447</a>
+Unreadable error message from build class path validation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23210">23210</a>
+Member variable name proposal
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27925">27925</a>
+Openable.hasChildren is slow
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28246">28246</a>
+Class files written to custom output and default output
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27275">27275</a>
+Random craches with corupt jar in library path
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28357">28357</a>
+NPE on importing plugins
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 16th December 2002
+<br>Project org.eclipse.jdt.core v_289
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28316">28316</a>
+Missing references to constructor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28104">28104</a>
+33 Parsers and 35 Scanners created when opening a type hiearchy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28298">28298</a>
+SANITY CHECK error when compiling a specific switch statement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28296">28296</a>
+parser gives cast expression an incorrect length
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28000">28000</a>
+Too many deltas on startup, when resolving cp variables/containers
+
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 13th December 2002
+<br>Project org.eclipse.jdt.core v_288
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28109">28109</a>
+Excluding a source file doesn't remove its Java problems
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28115">28115</a>
+Ubiquitous resource in the JavaModel
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28064">28064</a>
+Stack overflow in java editor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28150">28150</a>
+ClassCastException in completion
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22139">22139</a>
+Array initializer used inline causes syntax error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27941">27941</a>
+ClassCastException in CompletionParser
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27284">27284</a>
+misspelled variable name proposals for array with type name ending in 'y'
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27852">27852</a>
+We should not reject a class named java if it is in the unnamed package
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28208">28208</a>
+IClasspathEntry.getExclusionPattern: String[] would be better
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28114">28114</a>
+Missing type if defined in nested source folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27371">27371</a>
+code assist / auto inserting "()" broken
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28087">28087</a>
+on build, findMarkers called 3 times for each project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27992">27992</a>
+Incremental compile time = complete build time
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28095">28095</a>
+JDTCompilerAdapter references old Main constructor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23231">23231</a>
+[resources] Ability to hide resources from the builders
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 11th December 2002
+<br>Project org.eclipse.jdt.core v_287a
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=28069">28069</a>
+JDTCompilerAdapter and compiler.batch.Main out of sync in I20021210 build
+
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 10th December 2002
+<br>Project org.eclipse.jdt.core v_287
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Added API <code>IJavaProject.isOnClasspath(IResource)</code> that returns whether a given resource is on the
+ classpath of the project and whether it is excluded.
+</li>
+<li>Added mechanism to allow generic container user to request updating definitions held by
+container initializers, onto <code>org.eclipse.jdt.core.ClasspathContainerInitializer</code>:
+
+<pre>
+/**
+ * Returns <code>true</code> if this container initializer can be requested to perform updates
+ * on its own container values. If so, then an update request will be performed using
+ * <code>ClasspathContainerInitializer#requestClasspathContainerUpdate</code>/
+ *
+ * @param containerPath - the path of the container which requires to be updated
+ * @param project - the project for which the container is to be updated
+ * @return boolean - returns <code>true</code> if the container can be updated
+ * @since 2.1
+ */
+public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) {
+ // By default, classpath container initializers do not accept updating containers
+ return false;
+}</pre>
+<pre>
+/**
+ * Request a registered container definition to be updated according to a container suggestion. The container suggestion
+ * only acts as a place-holder to pass along the information to update the matching container definition(s) held by the
+ * container initializer. In particular, it is not expected to store the container suggestion as is, but rather adjust
+ * the actual container definition based on suggested changes.
+ *
+ * IMPORTANT: In reaction to receiving an update request, a container initializer will update the corresponding
+ * container definition (after reconciling changes) at its earliest convenience, using
+ * <code>JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)</code>.
+ * Until it does so, the update will not be reflected in the Java Model.
+ *
+ * In order to anticipate whether the container initializer allows to update its containers, the predicate
+ * <code>JavaCore#canUpdateClasspathContainer</code> should be used.
+ *
+ * @param containerPath - the path of the container which requires to be updated
+ * @param project - the project for which the container is to be updated
+ * @param containerSuggestion - a suggestion to update the corresponding container definition
+ * @throws CoreException when <code>JavaCore#setClasspathContainer</code> would throw any.
+ * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
+ * @see ClasspathContainerInitializer#canUpdateClasspathContainer(IPath, IJavaProject)
+ * @since 2.1
+ */
+public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException {
+ // By default, classpath container initializers do not accept updating containers
+}</pre>
+</li>
+<li>Added helper method to <code>org.eclipse.jdt.core.JavaCore</code> so as to retrieve a registered
+classpath container initializer:
+<pre>/**
+ * Helper method finding the classpath container initializer registered for a given classpath container ID
+ * or <code>null</code> if none was found while iterating over the contributions to extension point to
+ * the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
+ *
+ * A containerID is the first segment of any container path, used to identify the registered container initializer.
+ *
+ * @return ClasspathContainerInitializer - the registered classpath container initializer or <code>null</code> if
+ * none was found.
+ * @since 2.1
+ */
+public static ClasspathContainerInitializer getClasspathContainerInitializer(String containerID)</pre>
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27890">27890</a>
+Batch compiler option -nowarn or -warn:none doesn't remove the warning for conversion from char[] to String
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27670">27670</a>
+ClasspathEntry.rootID allocates a lot of throw-away objects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27595">27595</a>
+Add isOnClasspath(IResource) as API
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27652">27652</a>
+DCR - Need a way to request container initializers to update their container definitions
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27555">27555</a>
+[startup] PackageFragmentRoot - source attached too early (?)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27861">27861</a>
+VerifyError not being caught in jdt core tests
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27914">27914</a>
+Infinite loop setting breakpoint
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27853">27853</a>
+Incorrect invalid unicode
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27840">27840</a>
+Computing non-java resources on a project should not create a NameLookup
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27690">27690</a>
+SourceElementParser doesn't parse local declarations even if it is requested
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5295">5295</a>
+Segmented view misses field comment
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27714">27714</a>
+JavaElement.newNotPresentException
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27735">27735</a>
+CodeAssist - No completion for type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27370">27370</a>
+code assist not working with "new .."
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27658">27658</a>
+Infinite loop when checking cycle
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27683">27683</a>
+Index should be saved right after a project was indexed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27330">27330</a>
+Signeture should reuse Scanner object
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27294">27294</a>
+Performance - getTypeSignature should not rescan element names
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26604">26604</a>
+Forward references unilaterally dissallowed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27532">27532</a>
+Rebuild sometimes introduces invalid errors
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27597">27597</a>
+Ant adapter on a 1.4 JVM sets the target to be 1.4
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27494">27494</a>
+Source folder output folder shown in Package explorer
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27783">27783</a>
+Build output folder should not always be in the project subdirectories
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27600">27600</a>
+NPE while searching
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26602">26602</a>
+Incremental compile/build produces invalid header classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25752">25752</a>
+References list displays nulls for package name parts
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26967">26967</a>
+Upon exit always receive "JVM Terminated message"
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27748">27748</a>
+JUnit import fails
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27660">27660</a>
+Stack overflow causes startup crash
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27236">27236</a>
+search: references to constructors - a subclass constructor reported
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27603">27603</a>
+NPE in AbstractImageBuilder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27448">27448</a>
+using SearchEngine the constructors, inner classes or packages are not found
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 3rd December 2002
+<br>Project org.eclipse.jdt.core v_286
+<h2>
+What's new in this drop</h2>
+<ul>
+<li><b>Code completion enhancement:</b>
+ <ul>
+ <li>Relevance of a proposal is higher if the proposal is after an operator and the type of
+ proposal is compatible with the operator.
+ <br>In the following example <code>var1</code> is more relevant than <code>var2</code>.<pre>
+ public class X {
+ int var1;
+ Object var2;
+ void foo() {
+ int i = 1 + var<cursor>
+ }
+ }</pre>
+ </li>
+ </ul>
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27487">27487</a>
+Builder doesn't handle move to nested source folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27499">27499</a>
+Bogus ClasspathVariableInitializer is found in JavaModel
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22039">22039</a>
+Provide facility to exclude files from compilation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26251">26251</a>
+project compiler settings : some are not set
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25538">25538</a>
+Conflict of classfolder and outputfolder not reported
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27310">27310</a>
+CompilationUnit#lineNumber(..) doc seems flawed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27235">27235</a>
+Bug with assignement with no effect mask
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25928">25928</a>
+Cannot nest entries in Java Build Path - Request for Feature Removal
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26806">26806</a>
+Source build path should allow subdirectories of directories already on path
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27322">27322</a>
+ClassCastException during code assist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27247">27247</a>
+Missing generation for the qualifier in 1.4 mode
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22407">22407</a>
+Can't set Java project build output folder to different project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27250">27250</a>
+Walkback asking for a full rebuild
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27173">27173</a>
+API: add methodInvocation.resolveMethodBinding
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24123">24123</a>
+Support for multiple output dirs
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27151">27151</a>
+NPE searching in hierarchy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24308">24308</a>
+Performance - Optimization of search in hierarchy
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27204">27204</a>
+AST.lineNumber(position) is not working, if the class didn't have a new line at the end of file.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27374">27374</a>
+project specific JRE settings
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27295">27295</a>
+Relevance of member type in type cast should be higher
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27254">27254</a>
+Inexact matches found when search references to UnconditionalFlowContext#maxFieldCount
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26938">26938</a>
+Build Project-command removes all from build-dir
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 26th November 2002
+<br>Project org.eclipse.jdt.core v_285
+<h2>
+What's new in this drop</h2>
+<ul>
+<li><b>Source attachment enhancements:</b>
+ <ul>
+ <li><b>Source folder attachment:</b> The source attachment mechanism got generalized to all binary
+ package fragment root. In the past, only archives did support to carry a source attachment, in the
+ form of a source archive. Now, both binary folder or archive can be associated with sources, which
+ can be either a source archive or a source folder. In particular, mixed modes are supported (binary
+ archive associated to source folder and reciprocally). For more details, see
+ <code>IPackageFragmentRoot.attachSource(IPath, IPath, IProgressMonitor)</code> and
+ <code>JavaCore.newLibraryEntry(...)</code>.
+ </li>
+ <li><b>Automatic root path detection:</b> If null is specified as the root path (see
+ <code>JavaCore.newLibraryEntry(...)</code> and <code>IPackageFragmentRoot.attachSource(...)</code>),
+ then the Java Model will do its best to compute this root path automatically. The underlying algorithm
+ finds the first .java file, parses it, and extract the package declaration to compute the root path.
+ </li>
+ <li><b>Root path detection:</b> The new API
+ <code>IPackageFragmentRoot.computeSourceAttachmentRootPath(IPath sourceAttachmentPath)</code>
+ allows to detect the root path for a given source attachment and package fragment root.
+ </li>
+ </ul>
+</li>
+<li><b>Code completion enhancement:</b>
+ <ul>
+ <li>Relevance of a proposal is lesser if the proposal is in a variable initializer and the proposal is the variable.
+ <br>In the following example <code>var2</code> is less relevant than <code>var1</code>.<pre>
+ public class X {
+ int var1;
+ int var2 = var<cursor>
+ }</pre>
+ </li>
+ <li>Relevance of a proposal is lesser if the proposal is static and the qualified expression is non-static.
+ <br>In the following example <code>var2</code> is more relevant than <code>var1</code>.<pre>
+ public class X {
+ static int var1;
+ int var2;
+ void foo() {
+ this.var<cursor>
+ }
+ }</pre>
+ </li>
+ <li>Relevance of a proposal is higher if the completion is not qualified or is a local variable.
+ <br>In the following example the field <code>var2</code> and the parameter <code>var1</code> are more relevant
+ than field <code>var1</code>.<pre>
+ public class X {
+ int var1;
+ int var2;
+ void foo(int var1) {
+ var<cursor>
+ }
+ }</pre>
+ </li>
+ <li>Relevance of a proposal is higher if the proposal is equals to the current token.
+ <br>In the following example the field <code>var</code> is more relevant than field <code>varPlus</code>.<pre>
+ public class X {
+ int var;
+ int varPlus;
+ void foo() {
+ var<cursor>
+ }
+ }</pre>
+ </li>
+ </ul>
+</li>
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19303">19303</a>
-Open type does not show all type.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14109">14109</a>
-Deadlock between ProblemTreeViewer refresh and reconciler
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19254">19254</a>
-Some local variable completion proposals are missed
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19131">19131</a>
-NPE when removing a project containing missing classfile folder
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19058">19058</a>
-Closing non-java project doesn't remove root from java project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18584">18584</a>
-New 2.0 APIs marked as deprecated should be removed
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18698">18698</a>
-Seeing non-java projects in package view
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18920">18920</a>
-NPE searching for references to a message
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18749">18749</a>
-Missing java doc for IConstantPoolEntry
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18583">18583</a>
-New constants not tagged with @since 2.0
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18708">18708</a>
-DOM AST - IllegalArgumentException organizing imports
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18039">18039</a>
-Opening .class file fails
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18621">18621</a>
-Query all types when project is closed prevents reindexing when project is open
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24916">24916</a>
+quick fix: does not handle additional dimentions sometimes [quick fix]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26903">26903</a>
+VerifyError when casting null to an array type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=27002">27002</a>
+Scanner allocates new ArrayList(10) everytime it's created
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26912">26912</a>
+'null == null' fooling blank final analysis
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26817">26817</a>
+Class File Editor shows words translated which shouldn't be
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26452">26452</a>
+Wrong automatically generated import statements
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26881">26881</a>
+Yoyo in the debugger again
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26753">26753</a>
+Suspicious yoyo behavior when stepping through if condition
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25148">25148</a>
+Can't have different case package names
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26883">26883</a>
+Should report unitialized blank final field
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20932">20932</a>
+Cannot add a source directory as the source of a JAR file.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8719">8719</a>
+DCR - Attac h Java Source: allow un-jarred source tree?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6912">6912</a>
+Attach Source Requires JAR/ZIP
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26255">26255</a>
+project compiler settings : cannot go back to worspace settings
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26841">26841</a>
+Compiler - Does not detect non-visible member type in import
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26784">26784</a>
+problem M3 sourcebuild, linux/gtk - build error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26706">26706</a>
+Cannot create project with comma characters in project path
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26195">26195</a>
+JDT compiler doesn't report recursive constructor invocation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26747">26747</a>
+IllegalArgumentException reading build state
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3243">3243</a>
+SourceAttachment - automatic computation of the package root does not work (1GCMTLP)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26785">26785</a>
+Unreachable empty blocks should be reported in 1.4 compliant mode
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26664">26664</a>
+deprecated interfaces are not allways recognized
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26759">26759</a>
+Cast Compiler Error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26134">26134</a>
+JACKS - VerifyError running invalid code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26253">26253</a>
+task tags: two tags on one line creates one task for first tag
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26677">26677</a>
+Code Assist - expected type must be qualified.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23542">23542</a>
+CodeAssist proposal should offer non-qualified ones first
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25890">25890</a>
+code assist displays static members on non-static expressions
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26025">26025</a>
+Search should not use a file based name environment
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26138">26138</a>
+JACKS - The null literal should not be considered as a constant expression
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26585">26585</a>
+Wrong code generation in conditional expression
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26588">26588</a>
+Code Assist - variable must be less relevant in initialization
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26142">26142</a>
+JACKS: Must reject invalid character after class definition
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26141">26141</a>
+JACKS: Should report unterminated comment
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26129">26129</a>
+JACKS: VerifyError, because opcode jsr_w not used
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25888">25888</a>
+Open on selection fails on private binary inner class contructor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23126">23126</a>
+allow selecting directories when attaching source to jar's
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22145">22145</a>
+Attach source directory in addition to archive file [build path]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26459">26459</a>
+Unused NonVoidMethodRequestor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26122">26122</a>
+JACKS: VerifyError when affecting final local in anonymous class header
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26124">26124</a>
+JACKS - Compile error not reported when break; used in a labeled statement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24934">24934</a>
+Move top level doesn't optimize the imports[refactoring]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25250">25250</a>
+Scrapbook shows wrong error message
<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19271">19271</a>
-IOException when searching for packages
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7916">7916</a>
-Code assist does not find class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19424">19424</a>
-JDT processing deltas for non-java files in non-java projects
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18633">18633</a>
-Build failed: Can not find the class file for org.eclipse.jdt.core.jdom.IDOMInitializer
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18175">18175</a>
-Quickfix false positives for non-public classes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19293">19293</a>
-cancelling compiling does not always cancel
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18539">18539</a>
-unable to run JDBC program, class not found
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3292">3292</a>
-Adding new class takes very long (>20s) (1GEUGFQ)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3333">3333</a>
-JavaCore does not recognize dot notation for inner classes (1GI7GZG)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18507">18507</a>
-overwritting exiting file does not work
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18414">18414</a>
-NLS Tools: Find strings and compiler warning out of synch
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5605">5605</a>
-NPE restarting workspace
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3252">3252</a>
-Code assist list could be narrower in throws completion (1GD074C)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18724">18724</a>
-Code for the static initializer is exceeding the 65535 bytes limit
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3272">3272</a>
-CodeCompletion - should only resolve interfaces (1GE5B8X)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6259">6259</a>
-DCR: IClasspathEntry with JavaDoc location
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10007">10007</a>
-NPE and ClassCastException when renaming class name
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3222">3222</a>
-JM - Reminder - re-enable transient reconciling marker (1GAJ9FQ)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3267">3267</a>
-Deadlock while refreshing form local (1GDTUSD)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5583">5583</a>
-getNonJavaResources does not return .class files for source folders
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16371">16371</a>
-Java Model Exception using code assist
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17626">17626</a>
-Auto-format source removed newline at end of range
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8863">8863</a>
-.classpath gets overwritten if there's an XML error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3335">3335</a>
-Java Element Deltas: Performance issues with deltas from Working Copy (1GIE36J)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3253">3253</a>
-SEVERE: Not all external JARs show up in packages view (1GD0JZO)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=1834">1834</a>
-Cancel build with 10000+ problems takes forever to update (1G2Q9YZ)
-
-<h1>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26580">26580</a>
+java element deltas not sent out?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21837">21837</a>
+Eclipse hangs trying to set a breakpoint
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25406">25406</a>
+Package name change disallowed because of case insensitivity
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26885">26885</a>
+binary representation wrongly flagged as error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26526">26526</a>
+Inner class imports flagged as errors
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26652">26652</a>
+Encountered "case statement must be constant" error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23076">23076</a>
+compilation does not create class files!!!
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24015">24015</a>
+CVS synchronize with outgoing changes only causes Java rebuild
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25478">25478</a>
+Unresolvable import statements Problem Marker malfunctioning
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26658">26658</a>
+No deprecation warning
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26132">26132</a>
+JACKS - Blank final instance must be assigned before the end of constructor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26340">26340</a>
+Using javadoc comments to generate and manage bookmarks.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9020">9020</a>
+More intelligent code assist.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25962">25962</a>
+Output classes is scrubbed due to error in compiling a source.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26166">26166</a>
+compile single file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25684">25684</a>
+SelectionEngine to be made API?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26454">26454</a>
+DCR: IScanner.setSourceReader
+
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020601 - 1st June 2002 - FREEZE 2
-<br>Project org.eclipse.jdt.core v_254
+Eclipse SDK 2.1 Build - 14th November 2002 - 2.1 MILESTONE-3
+<br>Project org.eclipse.jdt.core v_284
<h2>
What's new in this drop</h2>
<ul>
-<li>The resource copy exclusion filter now tolerates whitespaces inside the filter pattern, they will be trimmed
-when used. e.g. " .* , foo/ " is now accepted.</li>
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18446">18446</a>
-JavaCore.getClasspathContainer on not yest created project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18411">18411</a>
-External JAR refresh - caching problem
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18453">18453</a>
-Deleting project doesn't remove pkg fragment root in another project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18331">18331</a>
-Java Model not flushed when upgrading binary projects
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26259">26259</a>
+Errors reported on save which go aways on rebuild
<h3>Problem Reports Closed</h3>
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020531 - 31st May 2002
-<br>Project org.eclipse.jdt.core v_253
+Eclipse SDK 2.1 Build - 13th November 2002
+<br>Project org.eclipse.jdt.core v_283
<h2>
What's new in this drop</h2>
<ul>
-<li>Changing 2.0 API for refreshing external JARs so as to pass in a collection of *elements* to restrain the scope
-of the update (see <code>IJavaModel#refreshExternalArchives(IJavaElement[],IProgressMonitor)</code>. Elements
-can either be package fragment roots, projects or Java model.</li>
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18418">18418</a>
- search: searchDeclarationsOfReferencedTypes reports import declarations
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18287">18287</a>
-<Clinit> change is treated as a structural change by incremental builder
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26128">26128</a>
+packages don't appear in package explorer view
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26044">26044</a>
+Unexpected full builds
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26098">26098</a>
+Wrong line number attribute.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24517">24517</a>
+type view does not notice when jar disappears
<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17766">17766</a>
-Strange error when launching Eclipse from inside Eclipse
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18396">18396</a>
-ant javac target ignores source="1.4" setting inside eclipse
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14187">14187</a>
-error rebuilding project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14607">14607</a>
-Refactor: rename isn't updating references
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16172">16172</a>
-Namelookup slow to retrieve package fragments
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18157">18157</a>
-Internal Error when deleting project
- <br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18259">18259</a>
-changing classpath causes significant recompilation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10394">10394</a>
-symbolic links upset JRE path
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9302">9302</a>
-An unexpected exception has been detected in native code outside the VM
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26063">26063</a>
+MacOS X: Error saving files
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020530 - 30th May 2002
-<br>Project org.eclipse.jdt.core v_252
+Eclipse SDK 2.1 Build - 12th November 2002
+<br>Project org.eclipse.jdt.core v_282b
<h2>
What's new in this drop</h2>
<ul>
-<li>Compiler can now optionally report unused imports. See option named "" on <code>JavaCore#getDefaultOptions</code> comment
-<pre>
- * COMPILER / Reporting Unused Import
- * When enabled, the compiler will issue an error or a warning for unused import
- * reference
- * - option id: "org.eclipse.jdt.core.compiler.problem.unusedImport"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "ignore"
-</pre>
-Note that if import problems (separate settings) are disabled, unused imports will not be reported either.
-This option is also available to the batch compiler ("-warn:unusedImports"). Implementations of <code>IProblemRequestor</code>
-can identify this new problem through its ID <code>IProblem#UnusedImport</code>.
+<li>In case someone deletes the .classpath and no corresponding classpath exists in memory,
+ a default .classpath is not automatically created any longer but a marker is created on the
+ project preventing this project from being built.
+ This covers the following scenarii:
+ <ul>
+ <li>Someone checks in a .project file with the Java nature but doesn't check in the .classpath file.
+ When the project is checked out, a marker is created indicating the .classpath file could not
+ be read.</li>
+ <li>Someone shuts down the workbench, deletes the .classpath and restart the workspace.
+ When attempting to built the project, a marker is created indicating the .classpath file could
+ not be read and the project is not built.</li>
+ <li>The Java nature is added to a project without a .classpath file. A marker is created indicating
+ the .classpath file could not be read.
+ </ul>
</li>
-<li>Added API on IType so as to tell whether a type is anonymous, local or member.</li>
-<li>Changing 2.0 API for refreshing external JARs so as to pass in a collection of projects to restrain the scope
-of the update (see <code>IJavaModel#refreshExternalJARs(IJavaProject[],IProgressMonitor)</code>. </li>
-</ul>
-
-<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17906">17906</a>
-Rename package fails when inner classes are imported
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18255">18255</a>
-NPE during Organize imports.... See test5 in UI tests
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18169">18169</a>
-ast: incorrect length of SingleVariableDeclaration for some array declarations
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18138">18138</a>
-Resolving failure in variable declaration
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18135">18135</a>
-importing plugins resulted in 9MB of errors added to log
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18190">18190</a>
-add a new PackageFragmentRoot does not update the name lookup of dependent projects
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15441">15441</a>
-Important: Problem highlight is out of sync with compiler
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12649">12649</a>
-Missing import after move
-
-<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18042">18042</a>
-AST: Resolving failes with semicolon while loop body
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020529 - 29th May 2002
-<br>Project org.eclipse.jdt.core v_251
-<h2>
-What's new in this drop</h2>
-<ul>
-</ul>
-
-<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18078">18078</a>
-memory leak - destroy a WorkingCopy remove and re-add his buffer
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16187">16187</a>
-Problems occured building seleted resources. MemberTypeBinding
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18029">18029</a>
-disassembled code viewer handles \n incorrectly
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17922">17922</a>
-ClassCastException on rename temp
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18054">18054</a>
-JDT/Core is using the platform encoding instead of the encoding set in the UI
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17923">17923</a>
-Can't find refs to binary fields
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11823">11823</a>
-npe when trying to set source to rt.jar
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17609">17609</a>
-deleting a resource results does not change local history
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16120">16120</a>
-SelectionParser build wrong AST for instanceof statement
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14468">14468</a>
-F3 doesn't work on DefaultExceptionHandler
-
-<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14373">14373</a>
-Number of spaces representing a tab is alway 4
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6169">6169</a>
-Creating the tasks view hangs the UI thread
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18070">18070</a>
-NullPointerException during build
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9173">9173</a>
-Exception about missing org.eclipse.core.boot\.classpath file?
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15602">15602</a>
-OutOfMemoryError
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15311">15311</a>
-Importing external plug-ins from file system fails
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13852">13852</a>
-Cannot generate EJB inheritance deployed code without debug info
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17046">17046</a>
-Inner class reference to Outer class method not recognized
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17953">17953</a>
-NullPointerException when compiling cocoon2
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17930">17930</a>
-Moving secondary types is fooling the java incremental builder
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17873">17873</a>
-Synchronize Comparison does poor job on .classpath files
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16736">16736</a>
-Comment before package statement not associated with it
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12551">12551</a>
-Search finds some but not all method refs
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17254">17254</a>
-Could not find .classpath.
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020527 - 27th May 2002
-<br>Project org.eclipse.jdt.core v_250
-<h2>
-What's new in this drop</h2>
-<ul>
-<li>Added API to retrieve cached flags on type hierarchies (see <code>ITypeHierarchy#getCachedFlags(IType)</code>). Note that these
-flags can help answering both isClass/isInterface queries as well (see <code>Flags.isInterface(int)</code></li>
-<li>Added API to trigger a Java model refresh with respect to external JARs: <code>IJavaModel#refreshExternalJARs</code>. </li>
+<li><b>Selectivity API</b> - Source folders can be associated with filters allowing to exclude
+specified portions of the resource tree rooted at this source entry's path. Exclusion patterns
+are expressed using the Ant file pattern syntax (i.e. **, *, ? wild-cards; where ** can stand for
+one or many folder names).
+ <ul>
+ <li>Added <code>JavaCore.newSourceEntry(IPath path, <b>IPath[] exclusionPatterns</b>)</code>
+ </li>
+ <li>Added <code>IClasspathEntry.getExclusionPatterns()</code>
+ </li>
+ </ul>
+ Full implementation will be available by 2.1 milestone-4.
+</li>
+<li><b>Multiple output folder API</b> - Source folders can be associated with a specific output
+location. The project output location is now corresponding to a default output location.
+ <ul>
+ <li>Added <code>JavaCore.newSourceEntry(IPath path, IPath[] exclusionPatterns, <b>IPath specificOutputLocation</b>)</code>
+ </li>
+ <li>Added <code>IClasspathEntry.getOutputLocation()</code>
+ </li>
+ </ul>
+ Full implementation will be available by 2.1 milestone-4.
+</li>
+<li>The Java builder now iterates over the resource tree, allowing to take advantage of forthcoming
+workspace structure enhancements (in particular: linked folders). As a consequence, the Java builder
+will only consider the resources officially reflected in the resource tree (as opposed to existing
+underlying files not yet reflected when the resource tree is out of sync).
+Note that the build state format has changed to reflect this evolution, as a consequence, if reusing an existing
+workspace, the first build action will have to be a rebuild-all projects, since incrementally it will
+not be able to re-read old build states associated with prerequisite projects (and an incremental build
+cannot tell the build manager a full rebuild is necessary).
+</li>
+<li>An option allows to control whether the Java builder should clean the output folder(s). Since
+options can be specified on a per project basis, each individual project can be toggled for cleaning
+the output folder or not (default is to clean). Also, "scrubbing" output folder got renamed into
+"cleaning" output folder.
<pre>
-/**
- * Triggers an update of the JavaModel with respect to the referenced external JARs.
- * This operation will issue a JavaModel delta describing the discovered changes, in term
- * of Java element package fragment roots added, removed or changed.
- *
- * @param monitor - a progress monitor used to report progress
- * @exception JavaModelException in one of the corresponding situation:
- * - an exception occurs while accessing project resources
- *
- * @see IJavaElementDelta
- * @since 2.0
- */
-void refreshExternalJARs(IProgressMonitor monitor) throws JavaModelException;
+* BUILDER / Cleaning Output Folder(s)
+* Indicate whether the JavaBuilder is allowed to clean the output folders
+* when performing full build operations.
+* - option id: "org.eclipse.jdt.core.builder.cleanOutputFolder"
+* - possible values: { "clean", "ignore" }
+* - default: "clean"
</pre>
-<li>Added flag for notifying a JAR content change during Java delta notification: <code>IJavaElementDelta#F_ARCHIVE_CONTENT_CHANGED</code></li>
+</li>
+<li>Integrated patch from Genady Beriozkin for bug <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25092">25092</a>.
+The compiler will now optionally diagnose assignments having no effect (e.g. x = x).
+Added the following option to control this behavior.
+<pre>
+* COMPILER / Reporting Assignment with no effect
+* When enabled, the compiler will issue an error or a warning whenever an assignment
+* has no effect (e.g 'x = x').
+* - option id: "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
+* - possible values: { "error", "warning", "ignore" }
+* - default: "warning"
+</pre>
+</li>
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17097">17097</a>
-Searching for "*" in java gives a cryptic error message dialog.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15162">15162</a>
-Assertion failure during shutdown
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17145">17145</a>
-NPE while compiling
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17807">17807</a>
-Incremental build problems deleting secondary types
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17564">17564</a>
-Register java file types with the team plugin
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17422">17422</a>
-JDT Compiler Adapter and compatibility with Ant 1.5
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17101">17101</a>
-Assertion failure during shutdown
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17562">17562</a>
-Race condition on startup leads to 2 JavaModel instances
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15395">15395</a>
-AssertionFailedException when creating new Java project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17797">17797</a>
-NullPointerException while building
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17827">17827</a>
-NullPointerException at CompilationResult.computePriority
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16761">16761</a>
-NPE when doing Project -> Rebuild All
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3329">3329</a>
-Specification for IJavaElementDelta needed (1GHVW5M)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16753">16753</a>
-Exception while building
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12159">12159</a>
-Code Format is generating bogus output
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16751">16751</a>
-Renaming a class doesn't update all references
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16789">16789</a>
-Incomplete project element if .classpath file isn't readable
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16279">16279</a>
-compiler creates code that causes verifier error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14113">14113</a>
-Should listen to F_SOURCEATTACHED and F_SOURCEDETACHED java deltas
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15250">15250</a>
-Need a better mapping for the method free return opcode
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16091">16091</a>
-Need way to refresh JAR files
-
-<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16354">16354</a>
-Code Assist has too many items after throws
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16863">16863</a>
-type hierarchy misses types
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14892">14892</a>
-Failed package import leads to OutOfMemory errors at compile time
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17197">17197</a>
-F1 - "Add Jars" to build path locks up eclipse - win2k
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15211">15211</a>
-NPE while searching for a field
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16494">16494</a>
-newSuperTypeHierarchy on binary type returns empty hierarchy
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17127">17127</a>
-IllegalArgumentException in SimpleName.setIdentifier(SimpleName.java:136) in M5
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16857">16857</a>
-Empty folder creation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16209">16209</a>
-Support declared packages that are different from directory location
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6068">6068</a>
-Walkback during plugin import
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12985">12985</a>
-Unexpected full build in incremental mode
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11022">11022</a>
-Unexpected full build
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16436">16436</a>
-CoreException importing org.eclipse.ui.win32
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12520">12520</a>
-JDTCompilerAdapter does not understand -extdirs
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10047">10047</a>
-JDTCompilerAdapter ignores -nowarn and deprecation off.
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020521 - 21st May 2002
-<br>Project org.eclipse.jdt.core v_249 - MILESTONE 6 / FREEZE 1
-<h2>
-What's new in this drop</h2>
-<ul>
-<li>'.classpath' file is now written using platform line delimiters (used to be only using LFs). It is recommanded to convert it to 'text' format
-so as to avoid surfacing delimiter differences in between incompatible platforms. </li>
-<li>The setting allowing for filtering resource copy now also supports folder filtering. Folder names are
-recognized by their '/' suffix, e.g. "META-INF/" specifies filtering out all folder named 'META-INF' (and their contents)</li>
-</ul>
-
-<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3244">3244</a>
-Classpath is not saved using UTF8 (1GCV467)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13878">13878</a>
-Request to support folders for resource copy filters
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16135">16135</a>
-Unexpected errors while reconciling
-
-<h3>Problem Reports Closed</h3>
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020518 - 18th May 2002
-<br>Project org.eclipse.jdt.core v_248
-<h2>
-What's new in this drop</h2>
-<ul><li>Added <code>ToolFactory.createDefaultClassFileReader(IClassFile classfile, int decodingFlag)</code> as an helper method to
- create a classfile reader for classfile elements.</li>
-</ul>
-
-<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16130">16130</a>
-build xerces/plugin.properties slow
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16175">16175</a>
-NPE in IndexManager#checkIndexConsistency
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15563">15563</a>
-CompletionEngine does not report type packages of local variables
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12374">12374</a>
-NPE in ResultCollector
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15977">15977</a>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=26053">26053</a>
+builder out of order in I-20021112
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25859">25859</a>
+Error doing Java Search
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25092">25092</a>
+Detect/Warn on possible user typos
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25894">25894</a>
+Memory leak - Global ThisReference is leaking bindings
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25885">25885</a>
+Code Assist - exact expected type should be more relevant than subtype
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25184">25184</a>
+Operations on cu outside classpath should fail
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25876">25876</a>
+Code Assist - void method are proposed in assignment
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23586">23586</a>
+Creating a new project deletes files in the parent folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25815">25815</a>
+Code Assist does not propose member type.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25820">25820</a>
NPE in Code Assist
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14037">14037</a>
-Internal Error doing java search
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16126">16126</a>
-ArrayIndexOutOfBoundsException during compilation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16132">16132</a>
-Error on Extract Method Refactoring
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16052">16052</a>
-NPE when search reference of a constructor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15945">15945</a>
-Creating new class causes most projects to be recompiled
-
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25811">25811</a>
+Code Assist for variable name suggestion is not perfect.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24010">24010</a>
+IType::resolveType returns null for inner types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25735">25735</a>
+Non-NLS strings are not reported properly when the ending tag is missing
+
<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9244">9244</a>
-Search Generates OutOfMemoryError
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15423">15423</a>
-JRE_LIB source attachment via properties does not work
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15931">15931</a>
-Proposed results to limited/invalid
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16131">16131</a>
-Java search fails to find all references to static final MB_ADDITIONS
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15192">15192</a>
-PackageFragment::copy never overwrites
-
-<h1>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22509">22509</a>
+Unable to start some Java application
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21864">21864</a>
+Associate package hierarchy with top-level source directory
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12957">12957</a>
+Copied resources out of synch
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24276">24276</a>
+javadoc - Imports marked as unused when they are really necessary.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18320">18320</a>
+Compiler Warning/Error/Ignore when Assigning to a Parameter
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25994">25994</a>
+Marker for "static method should be accessed in a static way"
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25995">25995</a>
+Marker for "static method should be accessed in a static way"
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25582">25582</a>
+Cannot specify java source path for resource !
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25665">25665</a>
+AST adds implicit super call (PR 22306 needed on 2.0.2 stream)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25304">25304</a>
+Code assist and parameter assistance.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24783">24783</a>
+method parameter name code completion
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25872">25872</a>
+Eclipse considers the Unicode char '\u000A' an invalid character constant.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25255">25255</a>
+ICompilationUnit::getUnderlyingResource throws an exception
+
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020515 - 15th May 2002
-<br>Project org.eclipse.jdt.core v_247
+Eclipse SDK 2.1 Build - 5th November 2002
+<br>Project org.eclipse.jdt.core v_281
<h2>
What's new in this drop</h2>
<ul>
- <li> New compiler option added to control max number of problems reported on a unit. Default is 100. See <code>JavaCore#getDefaultOptions()</code> </li>
- <pre>
- * COMPILER / Maximum number of problems reported per compilation unit
- * Specify the maximum number of problems reported on each compilation unit.
- * - option id: "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
- * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
- * - default: "100"
- </pre>
- <li>By default, the Java builder is now aborting build process on projects with classpath problems. This option can be disabled through the Java preferences:
- Window>Preferences>Java>Builder></li>
+<li>Code completion enhancement:
+ <ul>
+ <li>Relevance of a proposal is higher if the proposal is in a variable initializer and its type is compatible with the variable type.
+ <br>In the following example <code>var2</code> is more relevant than <code>var1</code>.<pre>
+ public class X {
+ Object var1;
+ int var2;
+ void foo() {
+ int i = var<cursor>
+ }
+ }</pre>
+ </li>
+ <li>Relevance of a proposal is higher if the proposal is on the right hand side of an assignment and its type is compatible with the left hand side type.
+ <br>In the following example <code>var2</code> is more relevant than <code>var1</code>.<pre>
+ public class X {
+ Object var1;
+ int var2;
+ void foo() {
+ int i;
+ i = var<cursor>
+ }
+ }</pre>
+ </li>
+ </ul>
+</li>
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16051">16051</a>
-DOM/AST: wrong position in if statement
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15788">15788</a>
-Walkbacks at startup
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16021">16021</a>
-Infinite loop in JavaCore.isReferencedBy(...)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14467">14467</a>
-Outliner doesn't highlight method
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16017">16017</a>
-JavaBuilder reports build failures on dependencies onto internal JARs
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15568">15568</a>
-Watchpoints, method breakpoints in interesting locations not showing in editor ruler
-
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24626">24626</a>
+codeSelect - does not work in catch clause
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25688">25688</a>
+Non NLS strings improperly reported when the line separator is \r only
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25687">25687</a>
+codeSelect - fails with inner class as method parameter
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25605">25605</a>
+[API] someJavaProject.getRequiredProjectNames(); API should specify that the array is returned in ClassPath order
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25358">25358</a>
+Creating a new Java class - Browse for parent
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25495">25495</a>
+Ant compiler adapter should treat bogus imports as errors
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21957">21957</a>
+'refactor rename' allows subpackage name to start with a space
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25591">25591</a>
+ClassCastException in CompletionEngine
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25539">25539</a>
+Unexpected inaccurate search results
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25578">25578</a>
+Abstract method declaration completion should be more relevant
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25221">25221</a>
+Code assist after new keyword
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25347">25347</a>
+Deprecation-Flag in Ant doesn't work with Eclipse Compiler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25551">25551</a>
+Ant javac adapter always reports build successful even if there are compiler errors
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24939">24939</a>
+Code Assist doesn't find protected constructor for anonymous class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717">3717</a>
+Smoke 114: Progress reporting when switching to different default VM (1GEHXMV)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24565">24565</a>
+CodeAssist proposing twice the same method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25520">25520</a>
+Possible problem in JavaProject#findPackageFragmentRoots(IClasspathEntry)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24518">24518</a>
+Public flag not set for interface method
+
<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16801">16801</a>
-Compiler problem when */ appears in commented String.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12955">12955</a>
-Problem with Type Dialog and HierarchyScopes - build 20020214
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16016">16016</a>
-Opening a project after starting Eclipse misses project indexes (or other internal stuff)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15190">15190</a>
-Java Build errors after save
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16008">16008</a>
-Hang during shutdown
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12392">12392</a>
-Problems to add Project from repository
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15103">15103</a>
-Search results are missing qualification
-
-<h1>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18212">18212</a>
+Java Build Paths no updated correctly when checking out multiple projects
+
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020514 - 14th May 2002
-<br>Project org.eclipse.jdt.core v_246
+Eclipse SDK 2.1 Build - 29th October 2002
+<br>Project org.eclipse.jdt.core v_280
<h2>
What's new in this drop</h2>
<ul>
- <li>Java compiler never record more than 100 markers for compilation problems. All APIs using IProblemRequestor still
- see them all. This change is intended to prevent the task list from being overhelmed with tons of secondary problems. </li>
- <li>Added APIs that allow to create a type hierarchy with a set of working copies that take precendence
- over their original compilation unit:
- <ul>
- <li><code>IType.newSuperTypeHierarchy(IWorkingCopy[], IProgressMonitor)</code></li>
- <li><code>IType.newTypeHierarchy(IWorkingCopy[], IProgressMonitor)</code></li>
- </ul>
- Note that change notification and refreshing is not supported on these hierarchies.
- </li>
+<li>In 1.4 compliant mode, the compiler will report errors for unterminated line comments (i.e. not closed with a line break). For backward compatibility reason,
+the stricter check isn't performed in 1.3 compliant mode. See <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23096">23096</a> for further details.
+Also note that from now on, the trailing line break is part of the line comment source range.
+</li>
+<li>The API setLeadingComment(String) on org.eclipse.jdt.core.dom.Statement class has been updated to reflect the changes made for <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23096">23096</a>.
+This API strictly fits to the JLS. It doesn't use the compliance mode settings. So a line comment needs to be closed with a line break in
+order to be valid.
+See <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25206">25206</a> for further details.</li>
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14051">14051</a>
-The implementation for IType.resolveType(String) is not implemented as noted in the JavaDoc specs
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15322">15322</a>
-need a way to create a type hierarchy that considers working copies
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15142">15142</a>
-CCE in SourceConstructorDeclaration
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15349">15349</a>
-JavaModelException out of Content assist
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15677">15677</a>
-Exception calling sourceType.getFields on working copy of new class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15657">15657</a>
-IDOMMethod.getReturnType returns null for all methods
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15804">15804</a>
-DOM/AST: wrong Length in cascading if/then/else
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15400">15400</a>
-Compiler generates way too many errors
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15857">15857</a>
-Deadlock in the indexer.shutdown()
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15756">15756</a>
-Organizing imports doesn't pick up the right type
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15430">15430</a>
-hang up eclipse
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14965">14965</a>
-Search results in .class files don't select reference
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15690">15690</a>
-Classpath being set in wrong notification lifecycle
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15810">15810</a>
-ClasspathContainer question
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15717">15717</a>
-I cant hold JDK Compiler Compliance level setting.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15448">15448</a>
-i keep loosing preferences
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15113">15113</a>
-extract method: assertion failure
-
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22358">22358</a>
+[api] Would like CharOperation made API
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23207">23207</a>
+Flags.isDeprecated(IMethod.getFlags()) doesn't work
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23984">23984</a>
+validateEdit not called when changing .classpath
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25439">25439</a>
+toString() on IBinding subclasses
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25347">25347</a>
+Deprecation-Flag in Ant doesn't work with Eclipse Compiler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25396">25396</a>
+NPE importing external plug-ins
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25433">25433</a>
+#findPackageFragmentRoots(IClasspathEntry)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25377">25377</a>
+Error location is not correct for empty array initializer
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25174">25174</a>
+Wrong code generation of the eclipse java compiler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25298">25298</a>
+One out of two non-externalized strings reported
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25188">25188</a>
+Debugger won't stop on method first statement breakpoint
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25233">25233</a>
+NPE in CompletionParser.buildMoreCompletionContext
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25206">25206</a>
+DOM/AST: Statement.setLeadingComment specification is inconsistent with the JLS
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25229">25229</a>
+Compiler should not reject innerclass scenario
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25183">25183</a>
+AST: ITypeBinding of interface returns constructor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24833">24833</a>
+TODO: not detected if there is only a comment in .java file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24744">24744</a>
+TODO: Task not found if comment after last closing brace
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23096">23096</a>
+Compiler does not report end of line comment error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24559">24559</a>
+TODO: items disappear when there is a syntax error in a method body
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13907">13907</a>
+Scanner does not report whitespace tokens at end of input
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25185">25185</a>
+ClassFormatError compiling a method with a compilation problem
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25124">25124</a>
+AST: IllegalArgumentException on creation
+
<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8137">8137</a>
-Code assist for anonymous inner type too late
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15761">15761</a>
-Log message after importing plugins fails
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15852">15852</a>
-need set api on IClasspathEntry
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15579">15579</a>
-Incomplete Java Error Message
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13756">13756</a>
-Code Completion + Type Introspection
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3198">3198</a>
-Caller of Signature.toString(String) should be aware that it won't work for '$' separated top-level types (1G4QB2S)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15332">15332</a>
-Problem with "\\" in editor/compiler
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23208">23208</a>
+The javadoc shown by Eclipse is different from what javadoc produces
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25464">25464</a>
+NPE during import plugins
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25170">25170</a>
+opening .java files from outside of classpath is much slower then other files
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23307">23307</a>
+Refactoring and Search are applied only on open files
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20985">20985</a>
+[GM1] REGRESSION: eclipse wants to import class already imported
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24906">24906</a>
+new non-nls strings not noticed on typing
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25378">25378</a>
+Switching from jdk1.3.1 to jdk1.4.1 leaves me without CVS support
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22304">22304</a>
+JavaModel: inner Node Constructor shows syntetic argument
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25373">25373</a>
+options now with 'Map'
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25297">25297</a>
+AST: DCR: Allow subclasses of ASTNode
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20751">20751</a>
+[F3] Discrepency between light bulbs and compiler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25163">25163</a>
+AST DCR: Parameter names in IMethodBinding
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25103">25103</a>
+Formatter indentation
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020507 - 7th May 2002
-<br>Project org.eclipse.jdt.core v_245
+Eclipse SDK 2.1 Build - 23rd October 2002
+<br>Project org.eclipse.jdt.core v_279a
<h2>
What's new in this drop</h2>
<ul>
- <li>Added org.eclipse.jdt.core.dom.Message#Message(String, int, int). This new constructor allows to set the length field. The constructor
- org.eclipse.jdt.core.dom.Message#Message(String, int) still exists and set the length to 0. There is no need to use the new constructor if the length
- is never used.</li>
- <li>Renamed org.eclipse.jdt.core.dom.Message#getSourcePosition() to org.eclipse.jdt.core.dom.Message#getStartPosition(). This
- is more consistent with the DOM/AST API. The old method has been deprecated and will be removed in a close future.</li>
- <li>Added org.eclipse.jdt.core.dom.Message#getLength() allowing to retrieve the length of the node on which
- the message has been reported.</li>
- <li> Added <code>JavaCore#getSharedWorkingCopies(IBufferFactory)</code> allowing to retrieve all registered working
- copies for a given buffer factory. </li>
- <li> JavaBuilder no longer build projects for which prerequisite projects aborted the build process. This considerably
- reduces the number of secondary errors when dealing with workspace setup problems.</li>
- <li> Added <code>IWorkingCopy#reconcile(boolean forceProblemDetection, IProgressMonitor monitor)</code> allowing to force
- problem refresh even if working copy was already consistent.
- <li> Added <code>IClasspathContainer</code> new kind constant <code>K_DEFAULT_SYSTEM</code> to denote system libraries implicitely contributed
- by a runtime. </li>
- <li> Classpath container path can have more than 2 segments. First one is still the container ID, the remaining ones are forming the hints
- passed to the resolution phase (<code>ClasspathContainerInitializer</code> </li>
- <li> Classpath containers can no longer contain variable entries </li>
- <li>JavaCore now persists its options (<code>JavaCore#getOptions</code>) using its plugin property store. Clients no longer need to save them. </li>
- <li>JavaCore now provides constants for all supported option IDs and values.</li>
- <li>JavaCore option added, to allow build to abort in presence of invalid classpath.
- <li>Leveraged new encoding support from Platform/Core. The JavaCore option "org.eclipse.jdt.core.encoding" is now equivalent to <code>ResourcesPlugin.getEncoding()</code>.
- <pre>
- * BUILDER / Abort if Invalid Classpath
- * Allow to toggle the builder to abort if the classpath is invalid
- * - option id: "org.eclipse.jdt.core.builder.invalidClasspath"
- * - possible values: { "abort", "ignore" }
- * - default: "ignore"
- </pre>
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15416">15416</a>
-Classpath container - need to set value even if not referenced
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15418">15418</a>
-Classpath container - may get the init-in-progress value back
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15334">15334</a>
-ast: Message should have length
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15364">15364</a>
-search for references of DebugUIPlugin.setAttributes(...) fails
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15175">15175</a>
-Need API to retrieve all shared working copies for a buffer factory
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15254">15254</a>
-JavaModelManager thinks JavaProject is closed when it is open
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3356">3356</a>
-API - should provide API for running batch compiler (1GJIWDP)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15244">15244</a>
-NPE in JDTCompilerAdapter
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15289">15289</a>
-Why is an incorrect package declaration not reported during reconciling
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13225">13225</a>
-quick fix: shows up only after I save
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15081">15081</a>
-JavaConventions.validateClasspath allows nesting source folders
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15044">15044</a>
-Unable to view some non-java files in external jars
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15177">15177</a>
-Classpath markers not correctly updated
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15168">15168</a>
-circular errors not reported
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13957">13957</a>
-LaunchingPlugin specification of resourceCopyExclusionFilter
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12977">12977</a>
-Adding Java nature to a project does not bring it to like in package view
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15107">15107</a>
-Internal Error organizing imports
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15030">15030</a>
-NPE trying to open or edit source files that reference jbuilder.jar
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14838">14838</a>
-Scrapbook editor: bad handling of // comment
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12543">12543</a>
-Code assist to insert method does not work when there are extra top-level statements
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15061">15061</a>
-IllegalArgumentException in ASTNode.setSourceRange
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15036">15036</a>
-ASTVisitor.preVisit and ASTVisitor.postVisit not called correctly
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3193">3193</a>
-JM - ISourceManipulation.delete send replace-BufferChangedEvent (1FYE8XI)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15091">15091</a>
-Too many cycle markers generated when cycle is detected
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14754">14754</a>
-CodeAssist - Duplicate method declaration proposal inside anonymous type
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15051">15051</a>
-Synthetic access methods are not reported to be synthetic
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3059">3059</a>
-JRE_LIB not appended to buildPath (1GF7TAZ)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15050">15050</a>
-Cleanup Javadoc @exception tags in DOM/AST
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14151">14151</a>
-The code formatter does not respect the "maximum line length" property when the indentation is set to tabulation.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14974">14974</a>
-Bad generated code for '+=' and '-=' operators
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25197">25197</a>
+NPE importing external plugins
<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15719">15719</a>
-Errors during build
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15087">15087</a>
-NPE when methods from the outermost enclosing class is invoked in a anonymous class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13057">13057</a>
-NPE in JavaElementRequestor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11155">11155</a>
-ArrayIndexOutOfBounds exception that caused workbench to freeze
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12921">12921</a>
-Build sometimes builds files that have not changed
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14962">14962</a>
-JDT Search returning improper type
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14929">14929</a>
-External Locations for Output Files
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020430 - 30th April 2002
-<br>Project org.eclipse.jdt.core v_243
+Eclipse SDK 2.1 Build - 22nd October 2002
+<br>Project org.eclipse.jdt.core v_279
<h2>
What's new in this drop</h2>
<ul>
- <li>Priority of the background indexer has been lowered so that
- it doesn't interfer with other threads (e.g. when switching JRE
- the indexing will not start before the switch has completed)
- </li>
- <li>Revised Classpath Container proposal (also see <a href="http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.eclipse.jdt.core/notes/r2.0/classpath%20container/classpathContainer.html">notes</a>):
- <ul>
- <li><code>classpathContainerChanged()</code> got replaced with setter method <code>JavaCore.setClasspathContainer(IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer respectiveContainers) </code></li>
- <li><code>ClasspathContainerResolver</code> got renamed into <code>ClasspathContainerInitializer</code></li>
- <li> Container can no longer contain any <code>CPE_SOURCE</code> entry.
- <li> added container interface <code> IClasspathContainer </code> in order to allow containers to be presented in a UI.
- <ul>
- <li>IClasspathEntry[] getClasspathEntries() </li>
- <li>String getDescription() </li>
- <li>int getKind() </li>
- <li>Path getPath() </li>
- </ul>
- </ul>
- </li>
- <li>If the completion is inside a super type in type declaration header then the relevance grow
- when the type have the correct nature :
- <ul>
- <li> After <code>extends</code> keyword of a class header the relevance grow if the type is a class.
- </li>
- <li> After <code>implements</code> keyword of a class header the relevance grow if the type is an interface.
- </li>
- <li> After <code>extends</code> keyword of an interface header the relevance grow if the type is an interface.
- </li>
- </ul>
- </li>
- <li> If the completion is inside a type in a catch or throws clause the relevance grow when the type is an exception
- (if the name of the type contain <code>exception</code> or <code>error</code>).
- </li>
- <li> If the completion is inside a throw statement the relevance grow when the proposal is an exception.
- </li>
- <li>The background indexer now recovers from internal crash. If this happens,
- a new thread is created and a consistency check is done on all indexes.
- </li>
- <li>An internal buffer factory is now used to create buffers when
- clients don't provide one.
- </li>
- <li>Special handling in the formatter for //$NON-NLS- comments in the source. When a line contains such comments
- it is not formatted anymore. The user will need to manually format it. See <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14387">14387</a> and
- <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=12540">12540</a>.
- </li>
+<li>By default, the compiler will produce warnings for unused imports and non-static references to static members.
+</li>
+<li>Code completion enhancement:
+ <ul>
+ <li>Relevance of a proposal is higher if the proposal is in a return statement and its type is compatible with the return type.
+ <br>In the following example <code>var2</code> is more relevant than <code>var1</code>.<pre>
+ public class X {
+ Object var1;
+ int var2;
+ int foo() {
+ return var<cursor>
+ }
+ }</pre>
+ </li>
+ <li>Relevance of a proposal is higher if the proposal is in a cast statement and its type is in the hierachy of the cast type.
+ <br>In the following example <code>var2</code> is more relevant than <code>var1</code>.<pre>
+ public class X {
+ Object var1;
+ int var2;
+ long foo() {
+ return (int)var<cursor>
+ }
+ }</pre>
+ </li>
+ <li>Relevance of a proposal is higher if the proposal is an argument of a sent message and its type is compatible with the parameter type.
+ <br>In the following example <code>var2</code> is more relevant than <code>var1</code>.<pre>
+ public class X {
+ Object var1;
+ int var2;
+ void foo(int i) {
+ foo(var<cursor>
+ }
+ }</pre>
+ </li>
+ </ul>
+</li>
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14933">14933</a>
-AST: No error message generated for unreachable code
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14921">14921</a>
-No error message from inner type instantiation in static context
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13919">13919</a>
-Declaration for package not found if scope is not project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14852">14852</a>
-Organize Import: missing import
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13531">13531</a>
-Java indexing thread finds "Bonjour, le monde!" too interesting
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14878">14878</a>
-static final char NegThree= (char)-3, -3 == NegThree returns true
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14331">14331</a>
-ICompilationUnit.getElementAt dos not find import decl
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14038">14038</a>
-ClassCastException during JavaReconciling
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14011">14011</a>
-ASTNode.checkNewChild(ASTNode, ASTNode, boolean, Class)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13577">13577</a>
-Problem highlighter is unable to import from Java3D library.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14831">14831</a>
-NPE with hierarchy search of a local variable
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14243">14243</a>
-Applet Viewer Integration
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14140">14140</a>
-ClassCastException when trying to open Java editor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14834">14834</a>
-smalltalk-ish error message
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11651">11651</a>
-Auto-complete shows all Object subclasses after "throws" keyword
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=4970">4970</a>
-Automatic Code Assist needs to be smarter #6
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8651">8651</a>
-Code assist should offer exception instead of any class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14767">14767</a>
-bug in IJavaProject.findType(String, String)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14642">14642</a>
-StringIndexOutOfBoundsException when attempting to view some classes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14558">14558</a>
-Adding binary project doesn't fix classpath problems.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14588">14588</a>
-NullPointerException in Util.equalArraysOrNull
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13492">13492</a>
-Should handle JavaModelExceptions that contains CoreException more gracefully
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12540">12540</a>
-Code formatter should leave comments at end of line
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14387">14387</a>
-Formatter isn't //$NON-NLS-1$ aware
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14313">14313</a>
-DCR: AST in methods with missing return type
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14094">14094</a>
-Indexer: Deadlock on delete project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14594">14594</a>
-"Open type" doesn't find types in project with Java nature added
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14602">14602</a>
-ast: length of variable declaration fragment
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14592">14592</a>
-IType#getTypes and IType#getDeclaringType are not coherent with Hastable
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13868">13868</a>
-Java Model not updated properly
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13234">13234</a>
-Can't open type
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9296">9296</a>
-Hang on open type during indexing
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13916">13916</a>
-api: IScanner - Scanner.linePtr
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14526">14526</a>
-NPE when resolving a SimpleName
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11529">11529</a>
-ast: missing (?) binding on simpleName in VariableDeclaration
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14453">14453</a>
-Remove InfixExpression.Operator.INSTANCEOF operator
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14490">14490</a>
-Possible concurrency hole when saving index before query
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25040">25040</a>
+getPackageFragmentRoots(CP entry) implementation doesn't match spec
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25041">25041</a>
+IJavaElement#getUnderlyingResource - should fail if element doesn't exist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24505">24505</a>
+Refactoring an empty package makes it disappears
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24775">24775</a>
+Wrong delta when replacing binary project with source project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25018">25018</a>
+parseCompilationUnit(..) does not report a compile error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24773">24773</a>
+CompilationUnit.getProblems: not all problems?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24747">24747</a>
+incorrect compile error message
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24974">24974</a>
+Broken link in JDT Plugin-in Developer's Guide
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24691">24691</a>
+Missing interface makes hierarchy incomplete
<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14844">14844</a>
-NPE creating binary projects
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14908">14908</a>
-100% CPU utilization, hang
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14733">14733</a>
-NPE setting marker attributes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13743">13743</a>
-(NPE) Eclipse froze during "open type"
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14074">14074</a>
-Search: Not all refs to TwoPaneElementSelector constructor found
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14889">14889</a>
-bug in IJavaProject.findType(String, String)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12439">12439</a>
-auto completion doesn't consistently work
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14818">14818</a>
-no message for uncaught exception in try block when return in finally
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13810">13810</a>
-ClassCastException in indexer
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13527">13527</a>
-NPE + GP switching JRE
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14096">14096</a>
-IWorkingCopy.findElements should not return null
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13943">13943</a>
-Eclipse crashes when doing a "rebuild all"
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14440">14440</a>
-Possible bug in compiling inner classes
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24213">24213</a>
+[M1] dependency checking too conservative
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24671">24671</a>
+Attaching source to JAR triggers build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=25039">25039</a>
+Non-existing package fragment roots should not be openable
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23311">23311</a>
+Need a way to include external JARs in the indexer
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24956">24956</a>
+Compiler misdiagnoses exception sequence
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24019">24019</a>
+Jar Refresh Problem
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020508-M5patch" - 8th May 2002
-<br>Project org.eclipse.jdt.core v_242b
+Eclipse SDK 2.1 Build - 15th October 2002 - 2.1 MILESTONE-2
+<br>Project org.eclipse.jdt.core v_278
<h2>
What's new in this drop</h2>
<ul>
- <li>Java builder is logging its internal errors </li>
+<li> Added soft dependency on plug-in "org.eclipse.team.core" to account for fileTypes contribution
+</li>
+ <li> JavaCore option added for specifying the task priorities (default is <code>""</code> meaning
+ tasks have normal priority).
+<pre>
+ * COMPILER / Define the Automatic Task Priorities
+ * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
+ * of the task markers issued by the compiler.
+ * If the default is specified, the priority of each task marker is "NORMAL".
+ * - option id: "org.eclipse.jdt.core.compiler.taskPriorities"
+ * - possible values: { "priority[,priority]*" } where priority is one of "HIGH", "NORMAL" or "LOW"
+ * - default: ""
+</pre>
+ </li>
</ul>
+
<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23272">23272</a>
+Plugin dependence problem
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24741">24741</a>
+Search does not find patterned type reference in binary project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23812">23812</a>
+Configurable (TODO) Markers priority in takslist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22840">22840</a>
+Refactor->Move doesn't update Local History
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24685">24685</a>
+Inner package fragments gets deleted - model out of synch
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24498">24498</a>
+Duplicate entries on classpath cause CP marker to no longer refresh
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24630">24630</a>
+NPE in MethodBinding
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24622">24622</a>
+ast: problems with missing ParenthesizedExpression nodes #2
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24529">24529</a>
+compiler must accept empty source files
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24502">24502</a>
+AST: No binding for type accesses to a non-visible type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24511">24511</a>
+AST: Resolve on non-visible import
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24501">24501</a>
+AST: No binding for fields accesses of non-visible fields
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24500">24500</a>
+AST: No binding for field instance access in constructor invocation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24499">24499</a>
+AST: No binding for instance access in constructor invocation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17104">17104</a>
+Compiler does not complain but "Quick Fix" ??? complains
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21893">21893</a>
+IType::isMember works the other way round
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22581">22581</a>
+Ignore unreachable code for unread variables
<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21175">21175</a>
+Incorrectly identified: Catch block is hidden by another one in the same try statement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23523">23523</a>
+Ouliner not updated after catch-up from repository
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24230">24230</a>
+search: does not find a references to constructor in anonymous type creations nodes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24522">24522</a>
+New Class Dialog: No interface method stubs generated for nested class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24567">24567</a>
+problem with hierarchy in working copy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21901">21901</a>
+JavaCore.setClasspathContainer is not generic enough
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24623">24623</a>
+AST: No method body when abstract modifier is existing
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24558">24558</a>
+compiler error, method declaration in interface -> NullPointerException
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24621">24621</a>
+Cannot specified JRE for each project separely ...
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24600">24600</a>
+ECLIPSE_HOME not set
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14194">14194</a>
+Java source files shouldn't show errors when in src dir, but not java resource
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24514">24514</a>
+dependency analyzer is broken
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24400">24400</a>
+Compiler bug or java 'feature' ?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24243">24243</a>
+Heuristic to differ between internal JAR and external JAR.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23769">23769</a>
+java.lang.OutOfMemoryError
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020423 - 23rd April 2002
-<br>Project org.eclipse.jdt.core v_242a
+Eclipse SDK 2.1 Build - 8th October 2002
+<br>Project org.eclipse.jdt.core v_277
<h2>
What's new in this drop</h2>
<ul>
- <li>Java model API additions:
- <ul>
- <li><code>IJavaProject.findType(String)</code></li>
- <li><code>IJavaProject.findType(String, String)</code></li>
- <li><code>IMethod.isMainMethod()</code></li>
- <li><code>IMethod.isSimilar(IMethod)</code></li>
- <li><code>IType.getFullyQualifiedName(char)</code></li>
- <li><code>IType.getTypeQualifiedName(char)</code></li>
- </ul>
- </li>
- <li>API change: <code>IWorkingCopy.findSharedWorkingCopy()</code> is now taking an extra argument: the buffer factory it is associated with. This ensures that
- working copies can only be reused for the same buffer factories.
- </li>
- <li> JavaModelOperations now guarantee the JavaModel is up to date when notifying the Java model change listeners. In particular,
- a builder running after the Java builder will be able to query the Java model with respect to the changes introduced through Java model
- operations (except for index queries). This was never guaranteed in 1.0, but indirectly occurred due to the fact that the previous Java
- builder implementation did force to refresh the Java model while building. </li>
- <li>Classpath Container Enhancement (also see <a href="http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.eclipse.jdt.core/notes/r2.0/classpath%20container/classpathContainer.html">notes</a>):
- <br>Added new type of classpath entry (<code>CPE_CONTAINER</code>), (see proposal here) so as to better encapsulate client defined libraries.
- Typically, VM installs would use classpath containers instead of classpath variables (<code>JRE_LIB</code>) so as to better describe the corresponding
- set of libraries (including extension dirs) to be placed on the build path.
- <p>New APIs added to reflect this addition:
- <ul>
- <li><code>JavaCore.newContainerEntry(IPath containerPath)</code></li>
- <li><code>JavaCore.newContainerEntry(IPath containerPath, boolean isExported)</code></li>
- <li><code>JavaCore.classpathContainerChanged(IPath containerPath, IJavaElement scope) </code></li>
- <li><code>ClasspathContainerResolver </code></li>
- </ul>
- </li>
- <li>DOM/AST:<br>A new type of node has been added to handle properly the instanceof expression. So the new InstanceofExpression node
- replaced the usage of InfixExpression with the operator InfixExpression.Operator.INSTANCEOF. This operator has been
- deprecated and is expected to be removed for the next integration build. See bug <A HREF="http://dev.eclipse.org/bugs/show_bug.cgi?id=14453">14453</a>.</li>
+<li>Search for constructor references now finds implicit constructor calls. Indexes in old workspaces are recomputed when restarted which may result in longer startup times.
+</li>
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13807">13807</a>
-null binding returned for fully qualified array declaration
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14403">14403</a>
-ast: exception on creation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14229">14229</a>
-Failure writing to a read only .project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13905">13905</a>
-changes to read-only .classpath file are not thrown out
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6165">6165</a>
-handle read-only class path file in a graceful way
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14322">14322</a>
-AST/DOM : IVariableBinding.getDeclaringClass() for 'length' field of an array return null
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14343">14343</a>
-ClassFileReader.getEnclosingTypeName() should return null for anonymous types
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12363">12363</a>
-Better integration of the batch compiler with ant javac task option -extdirs
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14217">14217</a>
-DOM/AST: wrong start position for expression statement
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14106">14106</a>
-Declarations in Hierarchy does not find declarations in hierarchy
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13060">13060</a>
-Type hierarchy on region populates Java Model cache for types in the region
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14117">14117</a>
-NPE importing binary projects
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14172">14172</a>
-Builder is setting source resources as derived!
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3266">3266</a>
-Changing kind of classpath entry reports 1 delta (1GDTRTP)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13231">13231</a>
-Quick Fix: wrong proposal
-
-<h3>Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14141">14141</a>
-NullPointerException during search
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13831">13831</a>
-NPE in RegionBasedTypeHierarchy
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12914">12914</a>
-Compiler cannot resolve javax.net
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13964">13964</a>
-Exception on startup
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14198">14198</a>
-AST: CastExpression.getType().resolveBinding() is null
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24449">24449</a>
+AST: Resolve on field access
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24453">24453</a>
+ast: problems with missing ParenthesizedExpression nodes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23112">23112</a>
+search: need a way to search for references to the implicit non-arg constructor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24440">24440</a>
+NPE when complete qualified allocation expression
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24406">24406</a>
+AST: Resolve on method invocation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24376">24376</a>
+Attempt to change resource while tree locked during container initialization
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24346">24346</a>
+Method declaration not found in field initializer
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13939">13939</a>
-DBCS: no error message to invalid character in java source
-<h1>
+DBCS: no error message to DBCS whitespace in java source
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23829">23829</a>
+IType::resolveType incorrectly returns null
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22541">22541</a>
+JDT core test suites should be on dev.eclipse.org
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=2857">2857</a>
+Renaming .java class with errors to .txt leaves errors in Task list (1GK06R3)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24245">24245</a>
+IJavaSearchScope.enclosingProjectsAndJars doc misleading, hard to use
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24140">24140</a>
+Searching for references to a private field within heirarchy seems very slow
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24268">24268</a>
+DOM: NPE in NaiveASTFlattener#visit(SwitchCase node)
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23644">23644</a>
+hierarchy: getAllSuperTypes does not include all superinterfaces?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23593">23593</a>
+search: strange method reference match found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8489">8489</a>
+space instead of tab
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24370">24370</a>
+SerialUID
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24205">24205</a>
+TypeHierarchy omits subtypes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24375">24375</a>
+Casting of primitive final fields to its own type causes VerifyError
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22548">22548</a>
+IndexOutOfBoundsException during jdt indexing
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24347">24347</a>
+AST: Resolve on type name qualifier
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23211">23211</a>
+Bug with search/reference !
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22894">22894</a>
+Improperly formed ICompilationUnit?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24324">24324</a>
+AST: IVariableBinding.getModifiers not same as in source
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23930">23930</a>
+Eclipse crash when a rebuild project !???
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21905">21905</a>
+Class file editor should indicate that .class file is missing debug attributes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21741">21741</a>
+Error while Build and doesn't allow to create ServerProject also
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22376">22376</a>
+Parent of JarEntryFile
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24274">24274</a>
+ArrayIndexOutOfBoundsException from source mapper
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23677">23677</a>
+java.lang.OutOfMemoryError when setting class path
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24233">24233</a>
+Impossible to compile projects - followinf of BUG 22509
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24233">24233</a>
+Installed JRE detection doesnt work correctly
+
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020418 - 18th April 2002
-<br>Project org.eclipse.jdt.core v_241a
+Eclipse SDK 2.1 Build - 1st October 2002
+<br>Project org.eclipse.jdt.core v_276
<h2>
What's new in this drop</h2>
<ul>
- <li>Changing the source attachement of a jar will now correctly fire source
- attachment java deltas. The flags of these deltas are:
- <ul>
- <li><code>IJavaElementDelta.F_SOURCEATTACHED</code> if a source
- has been attached to a jar and no source previously existed.
- </li>
- <li><code>IJavaElementDelta.F_SOURCEDETACHED</code> if a source
- has been detached from a jar and no other source has been attached.
- </li>
- <li><code>IJavaElementDelta.F_SOURCEDETACHED | JavaElementDelta.F_SOURCEATTACHED</code>
- if an attached source has been changed.
- </li>
- </ul>
- </li>
+<li>Registered classpath variable initializers are now taking precedence on values persisted during previous session. This allows
+initializers to rebind their variables when restarting a workspace, and thus fix up their values. </li>
</ul>
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14023">14023</a>
-NPE in build notifier
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14115">14115</a>
-Changing source attachment should not fire a F_REMOVED_FROM_CLASSPATH delta
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14055">14055</a>
-NPE in JavaModelManager.getVariableAsXMLString
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14007">14007</a>
-StringLiteral.setLiteralValue does not do Unicode escaping
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14013">14013</a>
-Compiler should not consider 'this.CONST' as constant expression
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14008">14008</a>
-VariableBinding.getVariableId contains suspicious code
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13989">13989 </a>
-Package view doesn't refresh after JRE switching
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12588">12588</a>
-Good match marked as potential
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13143">13143</a>
-Binary constructor search does not work (ref & decl)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13807">13807</a>
-null binding returned for fully qualified array declaration
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14103">14103</a>
-Too many dependents found when incrementally recompiling
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=4384">4384</a>
-Setting classpath variables does two builds
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3285">3285</a>
-Why does change the source attachment trigger a build (1GEHXW3)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13906">13906</a>
-Compiler did not detect uncaught exception
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14019">14019</a>
-NPE with code assist working in an anonymous inner class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9263">9263</a>
-Code assist can't see other project's class folders
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23594">23594</a>
+code resolve: incorrectly resolving method invocation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21763">21763</a>
+Problem in Java search [search]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22846">22846</a>
+Cannot add in a new classpath entry
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20197">20197</a>
+Classpath Variables pref page does not refresh with latest variables [build path]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24134">24134</a>
+JDTCompilertAdapter doesn't throw BuildException on compile error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24001">24001</a>
+Classpath variable/container initializer should activate
-<h1>
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23656">23656</a>
+hierarchy: type hierarchy on interfaces does not contain Object
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23890">23890</a>
+Changing Package Declarations triggers full project rebuild
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24172">24172</a>
+Strange behavior with wrong package declaration
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24093">24093</a>
+NPE in Java Builder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22445">22445</a>
+Compiler inconsistent with javac when code returns from inside a finally {} block
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24189">24189</a>
+need a way to verify that a string can be a type name
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23925">23925</a>
+Class path vars missing
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24210">24210</a>
+NPE renaming project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24164">24164</a>
+Cannot use a specif rt.jar for a specific Java project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23989">23989</a>
+Build Path page reports cycle even if there is none
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22754">22754</a>
+JRE-Settings independent for each project
+
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020416 - 16th April 2002 - MILESTONE 5
-<br>Project org.eclipse.jdt.core v_240
+Eclipse SDK 2.1 Build - 26th September 2002
+<br>Project org.eclipse.jdt.core v_275
<h2>
What's new in this drop</h2>
<ul>
-<li> Changed the package fragment caching policy so as to accomodate large workspaces. It used to be an overflowing LRU cache of size 1000
-package fragments. It now is a simple table, which is never emptied implicitly any longer. Memory overhead looks negligeable, and it allows to
-deal much better with very large workspaces. Other similar improvements were made on the same front so as to improve JRE switching with such
-workspaces.
+</ul>
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=24083">24083</a>
+NPE accessing JavaProject preferences
+
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 24th September 2002
+<br>Project org.eclipse.jdt.core v_274
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Added new API findDeclaringNode(String) on CompilationUnit. This new method should be used to retrieve ASTNode
+declared in another compilation unit. See javadoc for further details or bug <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23734">23734</a>.
</li>
-<li> ElementChangedEvent got added notion of type (similar to IResourceChangeEvent), so as to better
-allow clients to react to JavaModel changes:
- <ul>
- <li> ElementChangedEvent.POST_CHANGE :
+<li> New APIs added onto IJavaProject to enable project custom options. Project custom options are persisted into a file ".jprefs"
+located inside the project metadata JDT/Core plugin location. Project can be specified custom options, and inherit global ones from JavaCore.
+At this point, it is unclear whether we will attempt to share these custom properties (like .classpath file).
+ <ul>
+ <li>
<pre>
/**
- * Event type constant (bit mask) indicating an after-the-fact
- * report of creations, deletions, and modifications
- * to one or more Java element(s) expressed as a hierarchical
- * java element delta as returned by <code>getDelta</code>.
- *
- * Note: this notification occurs during the corresponding POST_CHANGE
- * resource change notification, and contains a full delta accounting for
- * any JavaModel operation and/or resource change.
- *
- * @see IJavaElementDelta
- * @see IResourceChangeEvent
- * @see #getDelta
- * @since 2.0
+ * Helper method for returning one option value only. Equivalent to <code>(String)this.getOptions(inheritJavaCoreOptions).get(optionName)</code>
+ * Note that it may answer <code>null</code> if this option does not exist, or if there is no custom value for it.
+ * <p>
+ * For a complete description of the configurable options, see <code>JavaCore#getDefaultOptions</code>.
+ * </p>
+ * @param optionName the name of an option
+ * @param inheritJavaCoreOptions - boolean indicating whether JavaCore options should be inherited as well
+ * @return the String value of a given option
+ * @see JavaCore#getDefaultOptions
+ * @since 2.1
*/
- public static final int POST_CHANGE = 1;
-</pre>
- </li>
-
- <li> ElementChangedEvent.PRE_AUTO_BUILD
-<pre>
- /**
- * Event type constant (bit mask) indicating an after-the-fact
- * report of creations, deletions, and modifications
- * to one or more Java element(s) expressed as a hierarchical
- * java element delta as returned by <code>getDelta</code>.
- *
- * Note: this notification occurs during the corresponding PRE_AUTO_BUILD
- * resource change notification. The delta which is notified here only contains
- * information relative to the previous JavaModel operations (i.e. ignores the
- * possible resources which have changed outside Java operations). In
- * particular, it is possible that the JavaModel be inconsistent with respect to
- * resources which got modified outside JavaModel operations (it will only be
- * fully consistent once the POST_CHANGE notification has occured).
- *
- * @see IJavaElementDelta
- * @see IResourceChangeEvent
- * @see #getDelta
- * @since 2.0
- */
- public static final int PRE_AUTO_BUILD = 2;
-</pre>
- </li>
-
- <li> ElementChangedEvent.RECONCILE
-<pre>
- /**
- * Event type constant (bit mask) indicating an after-the-fact
- * report of creations, deletions, and modifications
- * to one or more Java element(s) expressed as a hierarchical
- * java element delta as returned by <code>getDelta</code>.
- *
- * Note: this notification occurs as a result of a working copy reconcile
- * operation.
- *
- * @see IJavaElementDelta
- * @see IResourceChangeEvent
- * @see #getDelta
- * @since 2.0
- */
- public static final int POST_RECONCILE = 4;
-</pre>
- </li>
- </ul>
-</li>
-<li>
- Also added a corresponding API on JavaCore so as to allow registering a listener for a given type of event.
- <pre>
- /**
- * Adds the given listener for changes to Java elements.
- * Has no effect if an identical listener is already registered.
- * After completion of this method, the given listener will be registered for exactly the
- * the specified events. If they were previously registered for other events, they
- * will be deregistered.
- *
- * Once registered, a listener starts receiving notification of changes to
- * java elements in the model. The listener continues to receive
- * notifications until it is replaced or removed.
- *
- * Listeners can listen for several types of event as defined in <code>ElementChangeEvent</code>.
- * Clients are free to register for any number of event types however if they register
- * for more than one, it is their responsibility to ensure they correctly handle the
- * case where the same java element change shows up in multiple notifications.
- * Clients are guaranteed to receive only the events for which they are registered.
- *
- *
- * @param listener the listener
- * @param eventMask the bit-wise OR of all event types of interest to the listener
- * @see IElementChangeListener
- * @see ElementChangeEvent
- * @see #removeElementChangeListener
- * @since 2.0
- */
- public static void addElementChangedListener(IElementChangedListener listener, int eventMask)
- </pre>
-
-</li>
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12353">12353</a>
-DocumentAdapter can never be closed
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9628">9628</a>
-Switching JRE is slow
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11585">11585</a>
-Large # of projects lock essential operations in the Workspace
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13393">13393</a>
-Extremely poor java editor performance in 2002040x
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13233">13233</a>
-IllegalArgumentException on variable declaration in evaluation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13625">13625</a>
-Remove deprecated method from AST/DOM
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13593">13593</a>
-Code Formatter formats synchronized incorrectly.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12921">12921</a>
-Build sometimes builds files that have not changed
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13522">13522</a>
-NPE on anonymous class code assist.
-
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020411 - 11th April 2002
-<br>Project org.eclipse.jdt.core v_239
-<h2>
-What's new in this drop</h2>
-<ul>
-<li>Added a first proposal for .class file reading APIs. This is still experimental and might change slightly.
-See new API in org.eclipse.jdt.core.util.
-<ul>
-<li>ByteCodeVisitorAdapter</li>
-<li>ClassFormatException</li>
-<li>DecodingFlag</li>
-<li>IAttributeNamesConstants</li>
-<li>IBytecodeVisitor</li>
-<li>IClassFileAttribute</li>
-<li>IClassFileDisassembler and ToolFactory#createDefaultClassFileDisassembler</li>
-<li>IClassFileReader</li>
-<li>ICodeAttribute</li>
-<li>IConstantPool</li>
-<li>IConstantPoolConstant</li>
-<li>IConstantPoolEntry</li>
-<li>IConstantValueAttribute</li>
-<li>IExceptionAttribute</li>
-<li>IExceptionTableEntry</li>
-<li>IFieldInfo</li>
-<li>IInnerClassesAttribute</li>
-<li>IInnerClassesAttributeEntry</li>
-<li>ILineNumberAttribute</li>
-<li>ILocalVariableAttribute</li>
-<li>ILocalVariableTableEntry</li>
-<li>IMethodInfo</li>
-<li>IModifierConstants</li>
-<li>IOpcodeMnemonics</li>
-<li>ISourceAttribute</li>
-<li>OpcodeStringValues</li>
-</ul>
-The default implementations are in org.eclipse.jdt.internal.core.util. Any comment is welcome and related bugs
-should be entered in JDT/Core.
-<li>Added char array based APIs on Signature. This APIs avoid creating needless Strings and
- are thus much more performant than their String based equivalent.
- <ul>
- <li><code>createArraySignature(char[], int arrayCount)</code></li>
- <li><code>createCharArrayTypeSignature(char[], boolean)</code></li>
- <li><code>createMethodSignature(char[][], char[]) </code></li>
- <li><code>getArrayCount(char[])</code></li>
- <li><code>getElementType(char[])</code></li>
- <li><code>getParameterCount(char[])</code></li>
- <li><code>getParameterTypes(char[])</code></li>
- <li><code>getQualifier(char[])</code></li>
- <li><code>getReturnType(char[])</code></li>
- <li><code>getSimpleName(char[])</code></li>
- <li><code>getSimpleNames(char[])</code></li>
- <li><code>toCharArray(char[], char[], char[][], boolean, boolean)</code></li>
- <li><code>toCharArray(char[])</code></li>
- <li><code>toQualifiedName(char[][])</code></li>
- </ul>
-</li>
-<li>Removed temporary 2.0 API which were deprecated in previous builds:
- <ul>
- <li><code>IWorkingCopy#getSharedWorkingCopy(IProgressMonitor, IBufferFactory)</code>, use API with extra <code>IProblemRequestor</code></li>
- <li><code>IWorkingCopy#getWorkingCopy(IProgressMonitor, IBufferFactory)</code>, use API with extra <code>IProblemRequestor</code></li>
- <li><code>IWorkingCopy#reconcile(IProblemRequestor)</code>, use API with no <code>IProblemRequestor</code></li>
- </ul>
-</li>
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12762">12762</a>
-Performance - Signature#createTypeSignature should be implemented in term of char[]
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12688">12688</a>
-NPE with code assist
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13408">13408</a>
-Subfolders of build folder are not marked as derived
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13355">13355</a>
-NPE during code completion
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13391">13391</a>
-NPE doing code assist
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13487">13487</a>
-NPE in CompletionEnige
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13395">13395</a>
-loading swt+examples with auto-build on causes deadlock (or takes a very long time)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13063">13063</a>
-NPE in extract method
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13247">13247</a>
-IllegalArgumentException while creating AST
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13386">13386</a>
-'not implemented yet' surfaced on Display in debug
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12617">12617</a>
-code assist: Proposals inside method parameters
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12338">12338</a>
-Unnecessary recompilation when adding packages
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12262">12262</a>
-Compiler Bug with import Statement
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7082">7082</a>
-NPE during build
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020409 - 9th April 2002
-<br>Project org.eclipse.jdt.core v_238a
-<h2>
-What's new in this drop</h2>
-<ul>
-<li>Adding a new empty source folder no longer causes a full build. Only an incremental build is needed now.
-</li>
-<li>Java model API additions:
- <ul>
- <li><code>IJavaElement.getAncestor(int)</code></li>
- <li><code>IJavaElement.getOpenable()</code></li>
- <li><code>IJavaElement.getPath()</code></li>
- <li><code>IJavaElement.getResource()</code></li>
- <li><code>IJavaProject.isOnClasspath(IJavaElement)</code></li>
- <li><code>IPackageFragmentRoot.getRawClasspathEntry()</code></li>
- <li><code>IType.findMethods(IMethod)</code></li>
- <li><code>IWorkingCopy.findElements(IJavaElement)</code></li>
- <li><code>IWorkingCopy.findPrimaryType()</code></li>
- </ul>
-</li>
-<li>ICompletionRequestor API change :
- <ul>
- <li> Added #beginReporting() and #endReporting() API on <code>IProblemRequestor</code>. #beginReporting is always called before restarting error detection. #endReporting is always called at the
- end of detection.
- </li>
- <li> Added API for setting multiple classpath variables at once (<code>JavaCore#setClasspathVariables</code>, this allows to update
- all affected projects exactly once, instead of iterating multiple times on each project (if it references the variable). This can improve performance
- when setting JRE variables.
- </li>
- <li> Added a new parameter <code>relevance</code> to be able to sort proposal by degree of relevance.
- <code>relevance</code> is a positive integer which are used for determine if this proposal is more relevant than another proposal.
- This value can only be used for compare relevance. A proposal is more relevant than another if his relevance
- value is higher.
- <br>
- <br><tt>ICompletionRequestor{</tt>
- <br><tt> void acceptAnonymousType(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptClass(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptError(...);</tt>
- <br><tt> void acceptField(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptInterface(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptKeyword(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptLabel(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptLocalVariable(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptMethod(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptMethodDeclaration(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptModifier(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptPackage(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptType(..., <b>int relevance</b>);</tt>
- <br><tt> void acceptVariableName(..., <b>int relevance</b>);</tt>
- <br><tt>}</tt>
- <br>
- <br>
+ String getOption(String optionName, boolean inheritJavaCoreOptions);
+</pre>
</li>
<li>
- If the completion identifier and proposal are equal and the case match then the proposal relevance grow. Note that this isn't a 1.0 breaking API change, it
- only affects the 2.0 new code assist API (i.e. still backward compatible with 1.0 clients) which hasn't yet reached stability, though it should be close to now.
- </li>
- </ul>
-</li>
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12614">12614</a>
-Initializing JRE variables slow on plug-in activation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12986">12986</a>
-Creating a working copy does not involve the problem requestor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12858">12858</a>
-Compiler Bug : Invalid Byte Code:
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11739">11739</a>
-Dead branches in package/project Hierarchy View
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12873">12873</a>
-CodeAssist : missing proposal of method declaration
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12007">12007</a>
-Source folder ending with .jar considered as JAR archive
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12908">12908</a>
-Build and save attempt fail with NPE and trying it many times crashs Eclipse
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12246">12246</a>
-Packages view shows .class and .java files when JAR has source
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3349">3349</a>
-Need a IJavaElement.getUnderlyingResource that does not do the exists test (1GJ69GP)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12975">12975</a>
-jacks - qualified assignment to final field should be rejected
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12969">12969</a>
-jacks - synchronized (void expression) should be rejected
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12705">12705</a>
-Progress monitor cuts off package name
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12767">12767</a>
-AST MethodBinding question
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9179">9179</a>
-DCR: Need IJavaSearchScope equals or encloses
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12444">12444</a>
-strange types names in ReorderParameters error dialog
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12781">12781</a>
-AST instanceof-InfixExpression: Cant resolve type
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12778">12778</a>
-Typo in comment: InfixExpression.RIGHT_SHIFT_UNSIGNED
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12768">12768</a>
-IScanner doesn't let user state whether line separators are to be recorded
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12651">12651</a>
-NPE out of the CompletionEngine
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12761">12761</a>
-Closing a top level binary type doesn't close the class files of its inner types
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12760">12760</a>
-Type hierarchy missing anonymous binary type if closed
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12674">12674</a>
-Too many problems while reconciling
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12373">12373</a>
-Assert$AssertionFailedException error while reconciling
-
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13059">13059</a>
-incorrect (?) code compiles
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12880">12880</a>
-SQLJ Support
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12603">12603</a>
-Could not delete empty java file
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9600">9600</a>
-Field reference in working copy not found
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12995">12995</a>
-ToolFactory::createScanner - incorrect javadoc
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12933">12933</a>
-"Never used" variable warnings can't detect across scope
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5135">5135</a>
-Open Java editor on IResource.class do an error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12809">12809</a>
-Unimplemented methods should not prevent class from running
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10421">10421</a>
-WSAD hang while setting buildpath
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12590">12590</a>
-Returning the type when local var is selected breaks refactoring
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12710">12710</a>
-Inconsistent behavior for the method IType.createField()
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020402 - 2nd April 2002
-<br>Project org.eclipse.jdt.core v_237
-<h2>
-What's new in this drop</h2>
-<ul>
-<li>Improved specification of <code>IBuffer</code> by saying that:
- <ul>
- <li> Java model operations that manipulate an <code>IBuffer</code> (e.g.
- <code>IType.createMethod(...)</code>) ensures that the same line delimiter
- (i.e. either <code>"\n"</code> or <code>"\r"</code> or <code>"\r\n"</code>) is
- used accross the whole buffer. Thus these operations may change the line delimiter(s)
- included in the string to be append, or replaced.
- However implementors of this interface should be aware that other clients of <code>IBuffer</code>
- might not do such transformations beforehand.</li>
- <li> <code>addBufferChangedListener</code> and <code>removeBufferChangedListener</code>
- have no effect if the buffer is already closed.</li>
- <li> Other operations that manipulate the buffer (like <code>setContent</code>
- might throw a <code>RuntimeException</code> if called after the buffer
- has been closed.</li>
+<pre>
+ /**
+ * Returns the table of the current custom options for this project. Projects remember their custom options,
+ * i.e. only the options different from the the JavaCore global options for the workspace.
+ * A boolean argument allows to directly merge the project options with global ones from <code>JavaCore</code>.
+ * <p>
+ * For a complete description of the configurable options, see <code>JavaCore#getDefaultOptions</code>.
+ * </p>
+ *
+ * @param inheritJavaCoreOptions - boolean indicating whether JavaCore options should be inherited as well
+ * @return table of current settings of all options
+ * (key type: <code>String</code>; value type: <code>String</code>)
+ * @see JavaCore#getDefaultOptions
+ * @since 2.1
+ */
+ Map getOptions(boolean inheritJavaCoreOptions);
+</pre>
+ </li>
+ <li>
+<pre>
+ /**
+ * Sets the project custom options. All and only the options explicitly included in the given table
+ * are remembered; all previous option settings are forgotten, including ones not explicitly
+ * mentioned.
+ * <p>
+ * For a complete description of the configurable options, see <code>JavaCore#getDefaultOptions</code>.
+ * </p>
+ *
+ * @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>),
+ * or <code>null</code> to flush all custom options (clients will automatically get the global JavaCore options).
+ * @see JavaCore#getDefaultOptions
+ * @since 2.1
+ */
+ void setOptions(Map newOptions);
+</pre>
+ </li>
</ul>
</li>
-<li> IScanner API :
- <ul>
- <li> added <code>IScanner#getSource</code> so as to retrieve the scanner original source
- <li> renamed <code>IScanner#setSourceBuffer</code> into <code>IScanner#setSource</code>
- </ul>
-</li>
+ <li>Added <code>JavaCore.run(IWorkspaceRunnable, IProgressMonitor)</code> that allows batching
+ of java model operations. Only one Java element changed event is reported at the end of the batch.
+ For example the following code snippet notifies listeners twice:
+ <pre>
+ ICompilationUnit unit = ...;
+ unit.createType("class B {}", null, false, monitor);
+ unit.getType("A").createField("int i;", null, false, monitor);
+ </pre>
+ To be notified only once, use the following:
+ <pre>
+ JavaCore.run(
+ new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ ICompilationUnit unit = ...;
+ unit.createType("class B {}", null, false, monitor);
+ unit.getType("A").createField("int i;", null, false, monitor);
+ }
+ },
+ monitor);
+ </pre>
+ </li>
</ul>
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23977">23977</a>
+.classpath corruption
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23734">23734</a>
+AST: CompilationUnit.findDeclaringNode only finds bindings from its own ast
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23979">23979</a>
+Build Path page reports cycle even if there is none
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20881">20881</a>
+"organize imports" does not find an import statement "add import" does. [code manipulation]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7091">7091</a>
+turn off the debug info on a project by project basis
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19663">19663</a>
+Java|Compiler|Other|Filtered resources needs to be project/team specific
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14062">14062</a>
+JDK Compliance against a project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22289">22289</a>
+To have file encoding by project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7395">7395</a>
+Set the compiler options per project instead of per workspace
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23894">23894</a>
+Extra (TODO) Markers : There is no todo task when there is no error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23162">23162</a>
+DOM: clients should be able to control if bindings are available even if AST is modified
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23901">23901</a>
+CCE in DefaultBindingResolver
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23597">23597</a>
+cannot resolve a call to a protected superclass method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23573">23573</a>
+AST: clone & source locations
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12454">12454</a>
-AST/DOM: IllegalArgumentException generated by bad source
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12431">12431</a>
-Unclear compiler error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12416">12416</a>
-Separate caching of project and pkg fragment root from caching of openables
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12457">12457</a>
-Need to synchronize JobManager.discardJobs(...)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12445">12445</a>
-Compiler Failure on reference to abstract interface method
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12417">12417</a>
-api: IScanner, ITerminalSymbols - no way to get some tokens
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12419">12419</a>
-Weird secondary error in constructor reconciliation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12419">12419</a>
-api: IScanner - missing (?) getSourceBuffer
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12380">12380</a>
-AST/DOM: resolveTypeBinding() on the second operand of a instanceof expression return null
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9790">9790</a>
-Add constructors from superclass inserts in wrong place
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12387">12387</a>
-Out Of Memory error importing file
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3423">3423</a>
-Need IConstants (1GKM51O)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11583">11583</a>
-Infinite loop in OverflowingLRUCache
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12346">12346</a>
-Leaking closed buffers
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11431">11431</a>
-Stepping from one case statement's break ends up in next case
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12326">12326</a>
-Bad line number information returned from CompilationUnit with no trailing newline
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3313">3313</a>
-Severe - Performance - Java Model redundancies (1GFKTUN)
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22618">22618</a>
+incorrect warning about unread vars
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3239">3239</a>
+CodeFormatter: need to be able to set linedelimiter used (1GC0LFK)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22979">22979</a>
+using IScanner inside comments
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23550">23550</a>
+Micro-java, embedded java
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23833">23833</a>
+Java source attachment does not work
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23402">23402</a>
+Cancel on compile has no effect
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23635">23635</a>
+Compilation Errors Inconsistent
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21520">21520</a>
+'Errors during build: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding' error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22148">22148</a>
+Qlfd. vs. unqlfd. Name from IField.getTypeSignature
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21475">21475</a>
+No source for classes without debug information [general issue]
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12470">12470</a>
-0214 - Walkback during encapsulate method
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9179">9179</a>
-DCR: Need IJavaSearchScope equals or encloses
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10307">10307</a>
-Code assist failed to search whole class path
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7079">7079</a>
-Code formatting fails with java.lang.Error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3255">3255</a>
-Reminder - re-enable transient marker generation during code-assist (1GDCXLB)
-
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020426 - 26th April 2002
-<br>Project org.eclipse.jdt.core v_236
+Eclipse SDK 2.1 Build - 19th September 2002 - 2.1 MILESTONE-1
+<br>Project org.eclipse.jdt.core v_273a
<h2>
What's new in this drop</h2>
<ul>
-<li> Reconciling with errors provide type errors in addition to syntax ones. This is still experimental,
- and can be disabled by unchecking the editor preference for transient problems.
-</li>
-<li>Performance improvement of index queries with the <code>WaitUntilReady</code> policy.
- The background indexer now takes all the CPU when another thread is waiting for it to
- finish indexing.
- User will notice this improvement when doing a search or opening a type and there are
- still files to index.
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23558">23558</a>
+Extremly slow startup
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23788">23788</a>
+Java compiler doesn't properly flag invalid protected access (for javac 1.4 compatibility)
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 16th September 2002
+<br>Project org.eclipse.jdt.core v_273
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>The source lookup for .class files inside jar files has been improved. Before it worked only if the .class files
+had a source file attribute. This was too limiting in case of the usage of a library which has not been compiled in
+debug mode. Now in case there is no such source file attribute, an heuristic is used to create the proper entry. We
+assume that a class named A in a package p has been compiled from a class A.java in a folder p. For .class files
+that correspond to member or local classes the source mapping is using the top level class name in which the class is defined.
+The only limitiation that still exists is that it is not possible to retrieve the source for secondary types (types
+that are defined in a file which doesn't have the same name). See bug <A HREF="http://dev.eclipse.org/bugs/show_bug.cgi?id=21475">21475</a>
+for further details.</li>
+</ul>
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21475">21475</a>
+Attaching Source-Code to a library which is not compiled with debug info
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23466">23466</a>
+Compiler violates JLS 8.3.2
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21022">21022</a>
+warning on imports while typing and warning on unused imports is on
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23329">23329</a>
+search: incorrect range for type references in brackets
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23284">23284</a>
+AST: SingleVariableDeclaration needs extra dimensions?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23464">23464</a>
+ast: (Super)ConstructorInvocation should be wrapped in ExpressionStatement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22560">22560</a>
+"Add return type" correction could be smarter [quick fix]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23492">23492</a>
+[DOM/AST] lazy init should not count as a modification
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23292">23292</a>
+Must restart Eclipse after debug of source in .zip is updated
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22306">22306</a>
+AST: Constructor contains syntetic SuperConstructorCall
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22832">22832</a>
+select does not work when caret is at the begining of an identifier
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23242">23242</a>
+Bad line number info when multiple statements on same line
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23362">23362</a>
+DOM: incorrect length for InfixExpression.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23357">23357</a>
+Build not triggered on build path change
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21954">21954</a>
+compile / debug VM mismatch
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23558">23558</a>
+Extremly slow startup
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21952">21952</a>
+Circular Dependencies Message - Error vs. Warning Message
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23375">23375</a>
+cycle detection algorithm is O(pow(n - 1, n - 1))
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22900">22900</a>
+import of a.b.C fails if package a exists
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 10th September 2002
+<br>Project org.eclipse.jdt.core v_272
+<h2>
+What's new in this drop</h2>
+<ul>
+ <li>JavaCore option added for the error level (warning or error) of incomplete classpath or projects involved
+ in a cycle.
+ <pre>
+* JAVACORE / Reporting Incomplete Classpath
+* An entry on the classpath doesn't exist or is not visible (e.g. a referenced project is closed).
+* - option id: "org.eclipse.jdt.core.incompleteClasspath"
+* - possible values: { "error", "warning"}
+* - default: "error"
+*
+* JAVACORE / Reporting Classpath Cycle
+* A project is involved in a cycle.
+* - option id: "org.eclipse.jdt.core.circularClasspath"
+* - possible values: { "error", "warning" }
+* - default: "error"
+ </pre>
+ </li>
+<li>New option -bootclasspath is added for the batch compiler. This option allows you to override the location of bootstrap
+class files. If omitted, the batch compiler will retrieve the libraries used by its JVM. So there is no more need to specify the
+rt.jar file using the -classpath option. The batch compiler also retrieves the contents of the property "java.class.path" if no
+-classpath option is specified.
</li>
-<li>Scanner API
- <ul>
- <li>defined scanner API (see <code>org.eclipse.jdt.core.compiler.IScanner</code>). </li>
- <li>added tool factory API (see <code>org.eclipse.jdt.core.ToolFactory#createScanner</code>), allowing to obtain
- a scanner (implementing <code>IScanner</code> API). </li>
- </ul>
+<li> Deprecation warning inside deprecated code are now ignored by default. A new JavaCore option
+allows to report them all.
+<pre>
+* COMPILER / Reporting Deprecation Inside Deprecated Code
+* When enabled, the compiler will signal use of deprecated API inside deprecated code.
+* The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
+* - option id: "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
+* - possible values: { "enabled", "disabled" }
+* - default: "disabled"
+</pre>
</li>
-<li> Code formatter API
- <ul>
- <li>defined code formatter API (see <code>org.eclipse.jdt.core.ICodeFormatter</code>). </li>
- <li>added tool factory API (see <code>org.eclipse.jdt.core.ToolFactory#createCodeFormatter</code>), allowing to obtain
- a code formatter (implementing <code>ICodeFormatter</code> API). Note that an extension point was also added
- to allow client code to contribute a code formatter implementation. The code formatter extension point is named
- <code>org.eclipse.jdt.core.codeFormatter</code>, also see associate comment in plugin.xml.</li>
- <li>added tool factory API (see <code>org.eclipse.jdt.core.ToolFactory#createDefaultCodeFormatter</code>), allowing to obtain
- a default code formatter (implementing <code>ICodeFormatter</code> API). </li>
- </ul>
+<li> Compiler can now optionally collect tasks from the source code. Occurrences of
+a given task tag are looked for inside any type of comments, and reported as custom task markers
+(<code>"org.eclipse.jdt.core.task"</code>).
+ <ul>
+ <li> New problem ID got created: <code>org.eclipse.jdt.core.compiler.IProblem#Task</code>. Note that
+ clients of <code>IProblemRequestor</code> will get detected tasks as warnings with this new ID, they
+ can be filtered out if needed.
+ </li>
+ <li> JavaCore option added for specifying the task tag values (default is <code>""</code> meaning no
+ task is detected).
+<pre>
+* COMPILER / Define the Automatic Task Tags
+* When the tag is non empty, the compiler will issue a task marker whenever it encounters
+* one of the corresponding tag inside any comment in Java source code.
+* Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
+* - option id: "org.eclipse.jdt.core.taskTags"
+* - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
+* - default: ""
+</pre>
+ </li>
+ </ul>
</li>
-<li> Working Copy API : instead of passing a problem requestor (<code>org.eclipse.jdt.core.IProblemRequestor</code>) to working copy #reconcile(...)
-operation. The problem requestor is passed along at creation time.
- <ul>
- <li>added IWorkingCopy.getWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)</li>
- <li>added IWorkingCopy.getSharedWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)</li>
- </ul>
- Previous API taking <code>IBufferFactory</code> got deprecated, they will be removed in a subsequent build.
-</li>
-<li>Some internal classes got deprecated (as client code relies on them), since being surfaced:
- <ul>
- <li> <code>org.eclipse.jdt.internal.core.parser.InvalidInputException</code> <br>==> <code>org.eclipse.jdt.core.compiler.InvalidInputException</code> </li>
- <li> <code>org.eclipse.jdt.internal.core.parser.TerminalSymbols</code> <br>==> <code>org.eclipse.jdt.core.compiler.ITerminalSymbols</code> </li>
- </ul>
- They will be removed in a subsequent build.
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3353">3353</a>
-API - Should provide api for formatting source (1GJIWCF)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3179">3179</a>
-Compiler - LF cannot run classes that miss implementations of an interface (1FNFVY8)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12199">12199</a>
-Generated classfiles should be tagged as derived resources
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11640">11640</a>
-Bug in the code formatter
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10544">10544</a>
-Internal error creating long package name
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12140">12140</a>
-typo in IPackageFragmentRoot::createPackageFragment javadoc
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11422">11422</a>
-Attaching source when using variables to point to jars very unintuitive
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12000">12000</a>
-Main.compile does not close log file
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6558">6558</a>
-Missing class path entries should be displayed as an error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3354">3354</a>
-API - should provide api for Scanning (1GJIWCT)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7496">7496</a>
-Interface shows as class under content assist
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11475">11475</a>
-Code resolve reports types in security package
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10899">10899</a>
-Can't open on selection for member type in binary class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12013">12013</a>
-JavaCore.getClasspathVariable fails on empty variables
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11845">11845</a>
-Internal Compiler Error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11922">11922</a>
-is this code reachable or not?
-
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12119">12119</a>
-Eclipse build slow on network
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7881">7881</a>
-IType.move() clobbers editing buffer of destination element
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10703">10703</a>
-ast: no API to figure out the source range of 'super' keywords
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10983">10983</a>
-NullPointerException in JavaBuilder during Save
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3355">3355</a>
-API - should provide API for source element parsing (1GJIWD8)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10955">10955</a>
-DCR - search: too limiting api of IJavaSearchScope
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8819">8819</a>
-Self hosting tool doesn't update search index
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11497">11497</a>
-Renaming project failed with Java Model Exception: Java Model Status [Name collision.]
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12059">12059</a>
-api: JavaCore::getOptions should return Map, not Hashtable
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12044">12044</a>
-Search for field reference broken
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11905">11905</a>
-DCR - provide scanning API
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020321 - 21st March 2002 - MILESTONE 4
-<br>Project org.eclipse.jdt.core v_235a
-<h2>
-What's new in this drop</h2>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12014">12014</a>
-No delta when adding package where src=bin and src!=proj
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11755">11755</a>
-resource copy filter and duplicated resource error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11640">11640</a>
-Bug in the code formatter
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11860">11860</a>
-Cannot move a compilation unit
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11627">11627</a>
-Refactoring: CCE in Pullup method
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11735">11735</a>
-NPE selecting F3 in editor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11854">11854</a>
-NPE on save
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11805">11805</a>
-build output filter is ignored
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11568">11568</a>
-Code resolve does not work for changed constructor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11656">11656</a>
-Please add a ICompletionRequestorAdapter
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9271">9271</a>
-NPE inspecting "null" in the expressions view
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11638">11638</a>
-ast: CompilationUnit::findDeclaringNode fails
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11272">11272</a>
-slow context assist on method/field-rich classes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11340">11340</a>
-open on selection does not work for binary types
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11654">11654</a>
-NPE during build
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11659">11659</a>
-ast: CompilationUnit::findDeclaringNode fails #2
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11086">11086</a>
-ClassFileCompilationUnit should implement IClassFile
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020319 - 19th March 2002
-<br>Project org.eclipse.jdt.core v_234
-<h2>
-What's new in this drop</h2>
-<ul>
-<li> New API on IType for complete snippet in current type context. Code complete is performed against
- source (if available) or against type structure
-<br> <tt>void codeComplete(</tt>
-<br><tt> char[] snippet,</tt>
-<br><tt> int insertion,</tt>
-<br><tt> int position,</tt>
-<br><tt> char[][] localVariableTypeNames,</tt>
-<br><tt> char[][] localVariableNames,</tt>
-<br><tt> int[] localVariableModifiers,</tt>
-<br><tt> boolean isStatic,</tt>
-<br><tt> ICompletionRequestor requestor) throws JavaModelException;</tt>
-<br>
+<li> Creating a working copy on a non-existing ICompilationUnit is now allowed.
+ Such a working copy will have its contents initialized to an empty string.
+ Commiting this working copy creates the underlying compilation unit.
</li>
-</ul>
+</ul>
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23257">23257</a>
+IInitializer::getNameRange returns incorrect result
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23318">23318</a>
+Resolution of Circular Dep. preference/error message filtering
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23113">23113</a>
+Request to enrich messages provided by AST with errors defined in IProblem
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22154">22154</a>
+Proposed method for org.eclipse.jdt.core.dom.ITypeBinding
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23181">23181</a>
+IScanner returns incorrect whitespaces
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23259">23259</a>
+AST: SwitchCase wrong length
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23117">23117</a>
+DOM: no error message for method with wrong return type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20215">20215</a>
+Batch compiler ignores the CLASSPATH env variable
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23054">23054</a>
+DOM - TypeDeclaration.getJavadoc() can find incorrect javadoc
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22054">22054</a>
+Can't extract local variable from super send [refactoring]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22161">22161</a>
+AST: Innerclass name: Positions wrong
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22526">22526</a>
+Warning given when implementing deprecated methods
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23050">23050</a>
+DOM - IVariableBinding.getModifiers() doesn't give final modifier for local variables
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22939">22939</a>
+ast: incorrect range for a name in brackets
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22458">22458</a>
+Refactoring a package does not move the package's directory
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6976">6976</a>
+Auto collect tasks from code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23052">23052</a>
+DOM - CCE calling resolveBinding on an on-demand import from a type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22635">22635</a>
+recompile doesn't happen
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23118">23118</a>
+AST: BreakStatement & ContinueStatement: wrong length
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23048">23048</a>
+DOM - lazy initialization of empty loop bodies causes binding resolution to fail
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22203">22203</a>
+More dependencies increase GUI waiting time [build path]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11529">11529</a>
+ast: missing (?) binding on simpleName in VariableDeclaration
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8921">8921</a>
+DCR - Need a way to create a working copy ignoring existing files
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22673">22673</a>
+VerifyError in char cast of static final char referenced through instance
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23075">23075</a>
+Wrong compiling of inner classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23077">23077</a>
+search: does not find type references in some imports
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22942">22942</a>
+JavaProject.exists returns true when it should not
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22517">22517</a>
+Cannot create type X in project Test if d:\test\X.java exists
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18684">18684</a>
+Organize Imports doesn't work on external Jars
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22946">22946</a>
+search: NPE
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22637">22637</a>
+AST: Typos in Javadoc Assignment.Operator
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17210">17210</a>
+No match found when query contains '?'
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21420">21420</a>
+Changing .classpath doesn't update JDT
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21485">21485</a>
+NPE when doing a reference search to a package
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22428">22428</a>
+Compiler 1.4 - should report visibility issue for shadowed protected method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22418">22418</a>
+Should not complain about package for empty units
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22102">22102</a>
+Not all implementors found for IPartListener
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20631">20631</a>
+Declaration of local binary type not found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20435">20435</a>
+NPE when searching java method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22334">22334</a>
+Compiler generates corrupt classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22361">22361</a>
+Error in javadoc for JavaCore.getResolvedClasspathEntry
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21749">21749</a>
+Exported libraries and source folders
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10318">10318</a>
-Feature Request: new Code Assist API required
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22830">22830</a>
+Subtle visibility problem: class declaration resolved improperly
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23264">23264</a>
+ast: incorrect node hierarchy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23116">23116</a>
+DCR: ModifierNode
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=23055">23055</a>
+DOM - SuperMethodInvocation.resolveTypeBinding() returns null
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21843">21843</a>
+Qualifier in "Type Hierarchy" View
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21158">21158</a>
+Deadlock on startup
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22883">22883</a>
+IJavaProject::find(String) returns null for non-primary top-level types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22123">22123</a>
+Inability to put a classpath var pointing to a dir inside the project which is one dir up from output dir
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12496">12496</a>
+Creating a type hierarchy should not populate java model cache
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22453">22453</a>
+Compiler Problem
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22149">22149</a>
+jdk compiles but eclipse does not
-<h3>
-Problem Reports Closed</h3>
-
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020318 - 18th March 2002
-<br>Project org.eclipse.jdt.core v_233
+Eclipse SDK 2.0 Build - 1st August 2002
+<br>Project org.eclipse.jdt.core v_270
<h2>
What's new in this drop</h2>
<ul>
-<li> Added option to trace java search activity.
- To enable it, see the following line in the org.eclipse.jdt.core/.options file:
- <code>org.eclipse.jdt.core/debug/search=true</code>
+</ul>
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22093">22093</a>
+VerifyError due to duplicate access method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21916">21916</a>
+VariableDeclarationExpression
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21911">21911</a>
+NPE in the compiler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7517">7517</a>
+No control of formatting fo do {} while blocks
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=22078">22078</a>
+Incorrect error message
+
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.1 Build - 30th July 2002
+<br>Project org.eclipse.jdt.core v_269
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Add a new API getRawTokenSource() on org.eclipse.jdt.core.compiler.IScanner. It should be used if the user doesn't
+want the Unicode characters to be processed, otherwise use getCurrentTokenSource().</li>
+</ul>
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21912">21912</a>
+Compiler probleme: continue statement with label identifier
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21358">21358</a>
+DOM/AST: setLeadingComment and setJavadocComment doesn't support Unicode
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21828">21828</a>
+Possible problem in DoStatement#accept0(...)
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3458">3458</a>
+Resource folders containing source (1G4CKG9)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21627">21627</a>
+Compiled class error on iSeries
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21723">21723</a>
+Getting java.lang.OutOfMemoryError
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16176">16176</a>
+References to private fields could be optimized
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21109">21109</a>
+Have option for compiler warning on use of static field/method through reference
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3357">3357</a>
+DCR - Add compiler option (1GJJQAD)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21879">21879</a>
+Search could be optimized based on visibility
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21868">21868</a>
+No return statement for code with infinite loop
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20820">20820</a>
+Squiggly line is at a bad place for missing return statement
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK 2.0 Build - 23rd July 2002
+<br>Project org.eclipse.jdt.core v_268
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Added optional compiler problem for signalling non-static invocations of static field/methods
+(see <code>JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER()</code>)
</li>
-<li>Added API <code>CorrectionEngine#computeCorrections(IProblem, ICompilationUnit, ICorrectionRequestor)</code>, allowing.
-to compute replacement corrections for IProblem(s) detected while reconciling.</li>
-<li>Added API <code>ISourceReference#exists()</code>, allowing.
-to check existency before invoking <code>ISourceReference</code> behavior. All implementations did already provide
-an <code>exists()</code> method since they also are implementing <code>IJavaElement</code>.</li>
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11524">11524</a>
-api: IWorkingCopy:: getWorkingCopy() javadoc
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11511">11511</a>
-Compiler 1.4 fooled by extra interface methods
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11389">11389</a>
-Unused parameters not showing up as compiler warnings
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11410">11410</a>
-Exception in Java Builder when debug options turned off
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11285">11285</a>
-Potential NPE in CopyResourceElementsOperation.processPackageFragmentResource
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11440">11440</a>
-npe in rename temp
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11468">11468</a>
-NPE deleting project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11435">11435</a>
-compiler bug: overwriting implicitely abstract method in anonymous inner class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11250">11250</a>
-NPE in log after importing plugins
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11271">11271</a>
-Unable to delete a binary project in Java perspective
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11210">11210</a>
-ResourceDeltas are lost when merging deltas
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11371">11380</a>
-ast: missing binding for ConditionalExpression
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11371">11371</a>
-DOM/AST: node missing for super constructor call
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6243">6243</a>
-an ISourceReference API issue
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11296">11296</a>
-NPE during build
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3438">3438</a>
-OpenOnSelection - should be able to locate missing method by guessing (1GL186P)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11406">11406</a>
-ActionPerformed() method in AbstractAction not found
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3221">3221</a>
-JM - Deadlock while saving in Editor (1GAJ67W)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11201">11201</a>
-ClassCastException during build process
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020314 - 14th March 2002
-<br>Project org.eclipse.jdt.core v_232
-<h2>
-What's new in this drop</h2>
-<ul>
-<li>Added API <code>IDOMFactory.createInterface()</code> and <code>IDOMFactory.createClass()</code>.
-See <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10980">10980</a> for details.</li>
-</ul>
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11355">11355</a>
-OpenOnSelection unable to perform in single-type import
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9232">9232</a>
-ICompilationUnit.delete() fails
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11176">11176</a>
-Organize imports misses org.eclipse.core.resources
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3224">3224</a>
-Tests - Re-enable reconciler tests (1GAKXZM)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10980">10980</a>
-JDT / factory for new interfaces would be nice
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10996">10996</a>
-createCompilationUnit doesn't behave as described in the documentation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11125">11125</a>
-DOM/AST: API request <br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11277">11277</a>
-Difference in between outliner content and unit content
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10833">10833</a>
-Open type doesn't propose all type after a checkout
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11067">11067</a>
-Adding useful toString() method for each new DOM/AST nodes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9933">9933</a>
-Format does not handle synchronized keyword correctly
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8675">8675</a>
-DCR - Code correction could suggest new element creation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11341">11341</a>
-incorrect outline (i see only imports)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11217">11217</a>
-is double "; " on a return statement an error?
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10031">10031</a>
-SEF ClassCastException
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020312 - 12th March 2002
-<br>Project org.eclipse.jdt.core v_231
-<h2>
-What's new in this drop</h2>
-<ul>
-<li> Performance improvement:
- <ul>
- <li> Search doesn't populate the Java Model any longer. Thus the memory
- used by a search operation can be reclaimed at the end. </li>
- <li> Access to zip and jar files has been improved, which should result
- in better performance on a slow network. </li>
- </ul>
- </li>
-<li> Added flag <code>IJavaElementDelta.F_FINE_GRAINED</code> that indicates
- that a fine-grained delta was computed for a given delta.
- Clients can use this flag to find out if a compilation unit
- that have a <code>F_CONTENT</code> change should assume that there are
- no finer grained changes (<code>F_FINE_GRAINED</code> is set) or if
- finer grained changes were not considered (<code>F_FINE_GRAINED</code>
- is not set).
- </li>
-<li> Surfacing IProblem (<code>org.eclipse.jdt.core.compiler.IProblem</code>)
- <br>This allows some Java API to report failures in a lighter way than generating markers. Marker based API have been
- deprecated (note that due to some deadlock in client code, some of these API did not even produce markers, e.g. reconciling). In addition to
- surfacing problem descriptions, IProblem exposes all the IDs for the Java problem markers (attribute "id" on markers of type "org.eclipse.jdt.core.problem")</li>
-<li> Changed error reporting method for <code>ICompletionRequestor</code> to surface IProblems instead of IMarkers.</li>
-</ul>
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11191">11191</a>
-Strange anonymous types in outline structure
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11151">11151</a>
-ast: IllegalArgumentException on AST creation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10538">10538</a>
-Possible memory leak?
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10616">10616</a>
-StringIndexOutOfBoundsException opening type selection dialog
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11152">11152</a>
-Code Select - does not work with empty selection
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11129">11129</a>
-DOM/AST: Call resolveTypeBinding() on a CastExpression object throws a NullPoitnerException
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3256">3256</a>
-SearchableEnvironment - converts char[] to String, which affects performance
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10984">10984</a>
-DOM/AST: CU with syntax errors
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11106">11106</a>
-DOM/AST: do statement doesn't contain trailing semicolon
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11104">11104</a>
-DOM/AST: NumberLiteral contains leading and trailing comments
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10213">10213</a>
-SearchEngine.createJavaSearchScope((IJavaElement[]) does not work for binary elements
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9240">9240</a>
-Search finds deleted classes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11011">11011</a>
-incorrect 'variable never used' warning
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11025">11025</a>
-extract method: incorrectly disallowed on some boolean expressions
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10697">10697</a>
-Performance - Binary model should not cache the classfile bytes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11037">11037</a>
-DOM/AST: IllegalArgumentException when creatin AST
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10635">10635</a>
-Override methods not showing missing methods
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7930">7930</a>
-Code Assist - No completion in switch statement
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10979">10979</a>
-JDOM/add superinterface format problem
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10986">10986</a>
-DOM/AST: NPE when trying to resolve a binding
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10580">10580</a>
-type hierarchy incorrect for nested types
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10935">10935</a>
-DOM/AST: wrong length of variable declaration fragment
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6111">6111</a>
-Missing completion
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10898">10898</a>
-DOM/AST: NullPointerException
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3261">3261</a>
-Search - Memory peak during search (1GEN17L)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6667">6667</a>
-Search: OutOfMemoryError searching wildcarded field ref
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10874">10874</a>
-DOM/AST: ClassInstanceCreation contains trailing comment
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10881">10881</a>
-DOM/AST: SwitchCase.isDefault always returns false
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10865">10865</a>
-DOM/AST; AST.resolveWellKnownType("void") returns null
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10861">10861</a>
-DOM/AST: TypeLiteral.resolveTypeBinding doesn't return class Class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10819">10819</a>
-Incomplete task description after build with incomplete classpath
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10468">10468</a>
-DOM/AST: TypeDeclaration#isLocalTypeDeclaration doesn't consider anonymous types
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10499">10499</a>
-DOM/AST: need a way to access the IMethodBinding of a ClassInstanceCreation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10496">10496</a>
-DOM/AST: need for a node that holds the body statements of a ClassInstanceCreation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10781">10781</a>
-ast: incorrect position and length for AnonymousClassDeclaration
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10843">10843</a>
-DOM/AST: wrong structure for for statements
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10663">10663</a>
-ast: exception in AST converter
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10759">10759</a>
-ast: incorrect length of SimpleName (subsubnode of ArrayType)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10500">10500</a>
-Shouldn't ignore inherited method with wrong argument types
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10627">10627</a>
-Rebuild Deletes non-Class Resources
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3233">3233</a>
-JM - CreateElementInCuOperation should not save working copy (1GBEKAW)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3445">3445</a>
-search: type hierarchy scope incorrect (1GLC8VS)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10954">10954</a>
-IMember::getFlags semantics on interface members
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3195">3195</a>
-Unnecessary proposals in Open on selection whith syntax error (1G0EIBB)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10933">10933</a>
-DOM/AST: position of AnonymousTypeDeclaration is [-1,0]
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10815">10815</a>
-Error message for "incomplete path" lacks details
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10913">10913</a>
-DOM/AST: resolveBinding() for static field access
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10698">10698</a>
-DOM/AST: exception when creating AST
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=4946">4946</a>
-Cross-project builder efficiency issues
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3213">3213</a>
-No compile error for bad interface (1G7G6M1)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10667">10667</a>
-NPE in self encapsulate field
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10389">10389</a>
-Editing non-Java files causes a recompile
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10313">10313</a>
-Can not create Java project from existing source (1000+ Java files)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10794">10794</a>
-NPE from search during refactor, pull up method
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10699">10699</a>
-ast: nothing in anonymous inner classes is created
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020305 - 5th March 2002
-<br>Project org.eclipse.jdt.core v_230
-<h2>
-What's new in this drop</h2>
-<ul>
-<li> Added API <code>IClassFile.getWorkingCopy(IProgressMonitor, IBufferFactory)</code>
- for consistence with <code>IWorkingCopy</code>.
- The returned working copy is just a wrapper on the class file's buffer.
- Thus only the <code>getBuffer()</code> operation is valid on this working
- copy.
+<li>Compilation problem descriptions are now shortened (qualified type arguments
+are dequalified in the problem message, problem arguments are left fully qualified).
</li>
-<li> Added the notion of shared working copies. This allows clients to always
- get the same <code>IWorkingCopy</code> instance when asking for a working copy.
- See <code>IWorkingCopy.getSharedWorkingCopy(IProgressMonitor, IBufferFactory)</code>,
- <code>IWorkingCopy.findSharedWorkingCopy()</code>
- and <code>IWorkingCopy.destroy()</code> for more detail.
-</li>
-<li> Added option to trace use of shared working copies.
- To enable it, see the following line in the org.eclipse.jdt.core/.options file:
- <code>org.eclipse.jdt.core/debug/sharedworkingcopy=true</code>
-</li>
-<li> Added extension point to jdtcore so as to allow client plugins to register classpath variable initializers.
- Extension point is "org.eclipse.jdt.core.classpathVariableInitializer".
- (also see <a href="http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.eclipse.jdt.core/notes/r2.0/variable%20init/uninit-classpath-vars.html">design notes</a>)
- Note that each classpath variable, if unbound, will trigger its registered initializer exactly once per session. If unsuccessful, it will stay unbound.
+</ul>
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20402">20402</a>
+Error Description too long, should not list full class name
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21778">21778</a>
+ClassFileReader fails on Gnome Twain class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21787">21787</a>
+Provide compiler warning of using static method via non-static style.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21768">21768</a>
+ast: incorrect length of SimpleName in MethodDeclaration
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21757">21757</a>
+ast: incorrect range for Name in TypeDeclaration
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21754">21754</a>
+typo in IType::getSuperInterfaceNames javadoc
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21672">21672</a>
+Wrong location for the last 'return' bytecode command
-</li>
-<li> Added option to trace classpath variable initializations.
- To enable it, see the following line in the org.eclipse.jdt.core/.options file:
- <code>org.eclipse.jdt.core/debug/cpvariable=true</code>
-</li>
-<li>Added option to trace access to zip and jar files from the Java model.
- To enable it, see the following line in the org.eclipse.jdt.core/.options file:
- <code>org.eclipse.jdt.core/debug/zipaccess=true</code>
-</li>
-<li>Resurrect some code for backport 1.0 internal functionality
- <ul>
- <li> org.eclipse.jdt.internal.compiler.ConfigurableOption (all the class).
- <li> org.eclipse.jdt.internal.formatter.CodeFormatter (some methods) :
- <ul>
- <li> public CodeFormatter(ConfigurableOption[] settings)
- <li> private static Map convertConfigurableOptions(ConfigurableOption[] settings)
- <li> public static ConfigurableOption[] getDefaultOptions(Locale locale)
- <li> public static String format(String sourceString, int initialIndentationLevel, ConfigurableOption[] options)
- </ul>
- <li> org.eclipse.jdt.internal.formatter.Options.properties (all the file)
- </ul>
-</li>
-</ul>
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3303">3303</a>
-Many errors when adding projects from repository in a fresh install (1GF5PU7)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5285">5285</a>
-Compile errors on load when Java Perspective not open
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7085">7085</a>
-Build errors when adding the JUnit example project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10700">10700</a>
-ast: resolveBinding returns null on parameter reference
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10676">10676</a>
-StringLiteral.resolveTypeBinding() return null
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10679">10679</a>
-ClassCastException when calling resolveTypeBinding() with an error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10634">10634</a>
-Problem with compiling some java classes; class not visible
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10340">10340</a>
-NPE when selecting multiple methods to "Pull up"
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10662">10662</a>
-Casting to Buffer makes it impossible for clients to implement IBuffer
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10592">10592</a>
-ast: NPE in SingleVariableDeclaration::resolveBinding
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9583">9583</a>
-DOM : Self encapsulate field: NPE
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10570">10570</a>
-ast: CatchClause has incorrect startingPoint
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10587">10587</a>
-ast: missing node for a variable binding
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9588">9588</a>
-Invalid delta when replacing jar and proj=src=bin
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10495">10495</a>
-typo in ASTNode::MALFORMED javadoc
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10472">10472</a>
-CodeAssist - No completion between dot and number
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3323">3323</a>
-OpenOnSelection - no selection inside CodeFormatterPreferencePage.fTextListener initializer (1GGND3S)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10466">10466</a>
-"Cannot reference a field before it is defined" - compiler bug?
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10386">10386</a>
-NPE in MatchLocator.lookupType
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10378">10378</a>
-perf problem with external JARs
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9593">9593</a>
-SelectionEngine give more results than expected
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9969">9969</a>
-CodeFormatter: Bug when formatting try/catch Block
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3231">3231</a>
-1.4 - target is now 1.2 (1GHW0DF)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9998">9998</a>
-Performance - Better pruning meaningless AST nodes upon completion
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10240">10240</a>
-JDTCompilerAdapter doesn't understand "deprecation" from Ant
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10274">10274</a>
-DOM/AST: wrong implementation of TypeDeclaration.getFields
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10241">10241</a>
-Remaining references to com.ibm
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10753">10753</a>
-Compiler barfs on c:\ubizen with invalid unicode
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10749">10749</a>
-Bug is code formatter
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10701">10701</a>
-Undefined method when compiling using JDK 1.4
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10674">10674</a>
-AST API request : method binding for ClassInstanceCreation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10583">10583</a>
-Can not save any java file
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10275">10275</a>
-Search: reference to class not found
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3437">3437</a>
-Code Assist fails when method has unknown return type (1GL12EG)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9579">9579</a>
-Search: declaration in hierarchy - wrong matches
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10460">10460</a>
-The Compiler can not resolve package level class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10244">10244</a>
-DOM/AST: MethodInvocation should have resolveBinding() method
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9157">9157</a>
-My existing .class files are deleted!
-
-<h1>
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020226 - 26th February 2002
-<br>Project org.eclipse.jdt.core v_229
+Eclipse SDK 2.1 Build - 22nd July 2002
+<br>Project org.eclipse.jdt.core v_267
<h2>
What's new in this drop</h2>
<ul>
-<li>Java tooling now performs normally inside method bodies whose signature could not
-be resolved.
-</li>
-<li> Specified that when an <code>IBuffer</code> is created through an
- <code>IBufferFactory</code>, its content is set with the original
- element's content.
-</ul>
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10110">10110</a>
-Project not build since it was inconsistent
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9642">9642</a>
-Search - missing inaccurate type matches
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9992">9992</a>
-Member class declaration not found
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10221">10221</a>
-No variable name suggestion on array type
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10166">10166</a>
-Interface hides Object methods
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7934">7934</a>
-Builder always rebuilds when workbench restarted
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7456">7456</a>
-Error message with overloaded methods is confusing
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10152">10152</a>
-Computing hierarchy of IResource is slow
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8809">8809</a>
-Code assist with class folders does not work
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9763">9763</a>
-Code assist failure due to error in method signature:1GRVN5R
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9985">9985</a>
-Built in compiler will sometimes not allow Object method calls on Interfaces
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10008">10008</a>
-Internal compiler error when compiling switch statement
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9912">9912</a>
-Batch compiler doesn't put binaries in the right folder when -d is missing
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6059">6059</a>
-NPE in JavaModelStatus
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9351">9351</a>
-Copying a compilation unit onto itself destroys compilation unit
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9813">9813</a>
-VerifyError with Inner Class having private constructor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9492">9492</a>
-Walkback while searching
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9837">9837</a>
-Inconsistent behavior when compiling from source or using binaries for constant expressions
+</ul>
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6951">6951</a>
-DCR - Builder should ignore filtered out resources
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5809">5809</a>
-Duplicate class names in separate package imports cause compile error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9888">9888</a>
-JAR exorter problems with META-INF in projects with no source folder
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10104">10104</a>
-Calculated serialVersionID's are incompatible with Sun's JDK
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21606">21606</a>
+ImageBuilder deletes & adds rather than overwriting
-<h1>
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21282">21282</a>
+IType.getFullyQualifiedName() problems
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21182">21182</a>
+unimplemented method error after implementing in super
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21682">21682</a>
+marking a method deprecated doesn't eleminate deprecated warning
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21556">21556</a>
+"Missing code implementation in the compiler"
+
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020214 - 14th February 2002 - MILESTONE 3
-<br>Project org.eclipse.jdt.core v_228
-<h2>
-What's new in this drop</h2>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9479">9479</a>
-exception on package creation (discouraged name)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5999">5999</a>
-IType.resolveType returns multiple matches also the type is unambigious
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7485">7485</a>
-IType resolve fails
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9785">9785</a>
-Problem in IType.resolveType()
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9239">9239</a>
-search for method declaration - strange behavior
-
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5647">5647</a>
-Search results differ when using outliner context menu vs. dialog
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5239">5239</a>
-outliner gets out of synch
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5029">5029</a>
-Internal Error saving java file
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9586">9586</a>
-Java 1.4 feature assert does not throw any exception
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9504">9504</a>
-1GRU1L3:Search reference works only in outline view and not in editor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9476">9476</a>
-ArrayIndexOutOfBounds in JavaBuilder
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3262">3262</a>
-Strange output file deletion (1GDS2IX)
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020212 - 12th February 200
-<br>Project org.eclipse.jdt.core v_227
+Eclipse SDK 2.0 Build - 15th July 2002
+<br>Project org.eclipse.jdt.core v_266
<h2>
What's new in this drop</h2>
<ul>
-<li>Resource copy filters : A new setting allows to specify exclusion filters for resource being copied to the output folder..
- <ul>
- <li>option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilters"
- <li>possible values: { "<name>[,<name>]* } where <name> is a file name pattern (only * wild-cards allowed)
- <li>default: ""
- </ul>
-</li>
-<li>Encoding support : Batch compiler can be specified the source encoding format using '-encoding myEncoding' command line option.
-In case of necessity, each individual file specified on the command line can be associated with a custom encoding
-by suffixing its name with '[myEncoding]' (if applied to a folder, then all files in it will be sharing the custom
-encoding). When no encoding is specified, then the platform default is used (as before). Similarily, a JavaCore option got added to
-control the default encoding (no support yet for per file custom encoding).
- <ul>
- <li>option id: "org.eclipse.jdt.core.encoding"
- <li>possible values: { "" for platform default, or any of the supported encoding name }.
- <li>default: ""
- </ul>
-</li>
-<li> Fix for <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9183">9183</a> required to increment the index signature
-version so as to trigger automatic reindexing on workspace startup (and thus add somme type references that were previously
-missing from the binary index files). Subsequent startups will not reindex any further (only if inconsistency is detected,
-e.g. signature version is different).
-</li>
-<li> The <code>IBufferFactory</code> used when creating an <code>IWorkingCopy</code>
-(see <code>ICompilationUnit.getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory)</code>)
-is now remembered and will be reused if the working copy is closed then reopen.
-</li>
-<li>Old Java builder implementation got removed</li>
-<li>Project dependency cycle detection reenabled</li>
-<li> Open on selection no longer need a non-empty selection to perform (when empty it will use the token
-in which the selection start position is located).
-<li>Improved progress reporting while searching all types in the workspace.</li>
-</ul>
+</ul>
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9452">9452</a>
-IllegalArgumentException when creating an AST for TestCase.java
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7390">7390</a>
-Editing and saving read-only .java source file may cause lost of data
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7926">7926</a>
-Code Assist - No completion for class instance creation after inner class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7636">7636</a>
-Can't do code assist after field with local class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8369">8369</a>
-Code assist stops to work after anonymous class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9398">9398</a>
-Compiler error with double array
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9395">9395</a>
-ClassCastException during build
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9185">9185</a>
-Severe shutdown performance problem
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6167">6167</a>
-Indexer not stoped on exit
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7362">7362</a>
-Override Methods doesn't handle unicodes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7295">7295</a>
-Indendation in generated getters/setters of inner classes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6678">6678</a>
-Incorrect output after Add Unimplemented Method
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8758">8758</a>
-null pointer exception in eclipse core while compiling Java code
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6236">6236</a>
-Renamed file is not excluded from project build
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8696">8696</a>
-Code assist doesn't work in initializer of anonymous inner class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6064">6064</a>
-Open on selection shouldn't require selection.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9223">9223</a>
-CodeAssist failure in inner type from class file.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6847">6847</a>
-DCR - Filtering output to build directory
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9309">9309</a>
-DOM/AST: NPE when trying to resolve a binding
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9308">9308</a>
-DOM/AST: two equal hash table accesses
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9101">9101</a>
-Parse error while typing in Java editor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9031">9031</a>
-NPE in AbstractMethodDeclaration.compilationResult during search
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9084">9084</a>
-NPE in parser during build
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9008">9008</a>
-Code assist on method declaration gives wrong throw exception
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8878">8878</a>
-Code assist provides arbitrary, invalid choice after a space
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9198">9128</a>
-NegativeArraySizeException starting workbench
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9035">9035</a>
-I got an NPE
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9183">9183</a>
-BinaryIndexer doesn't index all type references
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3321">3321</a>
-Adding missing source folder doesn't remove warning (1GGCC4P)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3219">3219</a>
-JM - 'Cycle detected' should not be a marker attribute (1G8VTSA)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9169">9169</a>
-Wrong code generation for comparison of string constants
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8685">8685</a>
-Exception while deleting a method
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=4021">4021</a>
-jdt: Java elements and resources: error in source code (1GG87S9)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7878">7878</a>
-On Package creation: No warning for unconventional names
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9041">9041</a>
-search: cannot create a sub-cu scope
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9088">9088</a>
-Unreachable catch block when error in referenced class's fields
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3299">3299</a>
-Autobuild produces errors when renaming source folders
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9009">9009</a>
-ClassCastException creating an invalid method
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21580">21580</a>
+VerifyError in 1.4 compliant mode
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21557">21557</a>
+VM bug prevents valid Java code to be executed on VM < 1.3.1
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3190">3190</a>
-JM - use of "open" in java model inconsistent with core (1FW2EYQ)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3268">3268</a>
-create(IProject) strange for normal projects (1GDVTER)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8527">8527</a>
-Delete inner class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3037">3037</a>
-Core error compiling a java class (1GEJK8Q)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9386">9386</a>
-cannot import jar files into project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7976">7976</a>
-JDT misses the new Java files created by PDE
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5713">5713</a>
-NPE when searching for references in a JAR
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9177">9177</a>
-Builder treats build errors as JavaErrors
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8040">8040</a>
-java source with $ in reference won't compile
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5036">5036</a>
-assertion fails on build
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8498">8498</a>
-deprecated methods are not displayed in the task console
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3371">3371</a>
-Assertion failed exception during build (1GK183O)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3419">3419</a>
-asserion failed in build (1GKB9CH)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7895">7895</a>
-Wierd state: Project not built because inconsistent.
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7830">7830</a>
-Deleting more than one method consecutively from the hierarchy view causes unexpected corruption of othe methods
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9190">9190</a>
-Removing a library from classpath gives not a remove delta
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9104">9104</a>
-copy package progress dialog has missing string
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5706">5706</a>
-Cannot add two folders w/ same name but diff projects to build path of Java project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9103">9103</a>
-Search reports no references to SWT.Help
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6418">6418</a>
-Scrapbook: "Unexpected End Of File" expected
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3191">3191</a>
-JM - non-existing external jars will not come to life when created (1FWI5C4)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8980">8980</a>
-Unpredictable error catching on overridden methods with less visibility
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9024">9024</a>
-Do not find reference to an interface in JAR
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9040">9040</a>
-DOM/AST: why is the left hand side of an assignment an expression
+<h3>Problem Reports Closed</h3>
-<h1>
+<p><hr><h1>
Eclipse Platform Build Notes <br>
Java Development Tooling Core</h1>
-Eclipse SDK Build 20020205 - 5th February 2002
-<br>Project org.eclipse.jdt.core v_226
+Eclipse SDK 2.1 Build - 12th July 2002
+<br>Project org.eclipse.jdt.core v_265
<h2>
What's new in this drop</h2>
<ul>
-<li> The JavaModel no longer notifies changes for generated classfiles in the output folder, these
-were never supposed to be signaled. </li>
-</ul>
+<li>Changed ASCII/binary property for entire project.</li>
+</ul>
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3448">3448</a>
-No error for package and type collision in default package
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9016">9016</a>
-DOM/AST: Problems with array.length access
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9014">9014</a>
-DOM/AST: NullPointerException when resolving System.err.println
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9018">9018</a>
-DOM/AST: why does the key of a variable binding include the type
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5355">5355</a>
-search: NPE in searchDeclarationsOfReferencedTypes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8928">8928</a>
-Unable to find references or declarations of methods that use static inner classes in the signature
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3291">3291</a>
-Exception adding .class file to folder in package view (1GEUF3I)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8900">8900</a>
-Search causing internal error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8812">8812</a>
-Changing export state not propagated
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8856">8856</a>
-DOM AST: positions and bindings missing on QualifiedName
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3446">3446</a>
-type hierarchy: incorrect behavior wrt working copies (1GLDHOA)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3210">3210</a>
-Search - method declarations within TypeHierarchy gives no matches (1G54BMR)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8145">8145</a>
-TypeDeclaration sourceEnd contains trailing comment
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8832">8832</a>
-Sanity check error (internal error) when unused variables inside initializers
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8078">8078</a>
-Missing resource in copy CU dialog
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8764">8764</a>
-NPE while closing projects
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8359">8359</a>
-Index out of date when replacing a JAR
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8773">8773</a>
-VerifyError : A .class file exported from VAJ does not run in JDK 1.2.2 (1GPPET0)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8697">8697</a>
-2 compiler bugs: the operator unkown operator is undefined and defined in an inherited type and an enclosing scope
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8706">8706</a>
-Compile error when compiling an anonymous class which extends java.awt.Frame
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8709">8709</a>
-Error compiling JDK1.4 classes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8340">8340</a>
-inaccurate error message when dependent project is closed
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3344">3344</a>
-JavaElementDelta reports changed class files (1GIV8IK)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8384">8384</a>
-Unexpected compile errors when abstract method missing return type
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8789">8789</a>
-Compiler incorrectly reports that abstract method has a body
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21230">21230</a>
+Rebuilding project fails with ContextStackOverflow (CompilationResult.quickPrioritize)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21203">21203</a>
+Compile time NullPointerException in catch blocks
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21447">21447</a>
+Wrong method invoked at runtime
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21482">21482</a>
+Error in generated byte code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21480">21480</a>
+Bytecode disassembler doesn't handle #invokespecial correctly
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20725">20725</a>
+JavaBuilder.toString can throw NPE
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20865">20865</a>
+nullPointerException being thrown by Class Type.resolveBinding()
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21116">21116</a>
+Can't compile because eclipse says that the method is not visible
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7987">7987</a>
-Field reference search should do lookup in 1.4 mode
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8863">8863</a>
-.classpath gets overwritten if there's an XML error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7162">7162</a>
-Java Model Exceptions in log from TypeHierarchyLifeCycle
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8699">8699</a>
-Compiler error message incomplete: Syntax error on token ''
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3324">3324</a>
-Bad compiler error (1GHF25P)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3441">3441</a>
-Internal error renaming a class (1GL2XCW)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7841">7841</a>
-Overriden methods inserted past the end of source
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020129 - 29th January 2002
-<br>Project org.eclipse.jdt.core v_225
-<h2>
-What's new in this drop</h2>
-<ul>
-<li> Java compiler is JCK 1.4 compliant. When toggled in 1.4 mode (batch: -1.4 -source 1.4), the Java compiler is fully JCK 1.4 compliant
-as of JCK 1.4 2001-10-01 update. When in 1.3 mode (default), it is JCK 1.3a compliant.
-</li>
-<li> By default, when toggled into 1.4 mode, the batch compiler will enable assertion support (e.g. -source 1.4). It can still manually
-be toggled for 1.3 source level compatibility (-source 1.3).
-</li>
-<li> Added constructor <code>SearchEngine(IWorkingCopy[])</code>
- which takes a list of working copies that will take precedence
- over their original compilation units in the subsequent search
- operations on this search engine.
- <br>
- Note that this functionality is still under development and some
- parts may not work as expected. Feedback is welcome.
-</li>
-<li> New feature to achieve problems corrections : org.eclipse.jdt.core.CorrectionEngine.
- Correction results are answered through a requestor (org.eclipse.jdt.core.ICorrectionRequestor).
-</li>
-<li> JavaCore will no longer add indirectly prereq'ed project amongst project references.
-</li>
-<li> New JDOM AST API available (also see <a href="http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.eclipse.jdt.core/notes/r2.0/dom%20ast/ast.html?rev=1.1&content-type=text/html">design
-note</a>). This API has not yet reached full stability, and feedback is very welcome.
-</li>
-</ul>
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21049">21049</a>
+Save (Build / Compile?) performance
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20961">20961</a>
+Can't get complete classpath for project.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=21428">21428</a>
+DOM/AST: AST class unnecessarily plug-in dependent?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20059">20059</a>
+project.isOnClassPath(project) result random
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8641">8641</a>
-Can't find references in hierarchy in binary projects
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8659">8659</a>
-Unexpected changes in project references (.vcm-meta)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8358">8358</a>
-Search: doesn't find reference although there are
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6799">6799</a>
-Duplicate type collisions
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8414">8414</a>
-Incorrect "unused variable" warning?
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8484">8484</a>
-Internal error searching for write access to a variable
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8536">8536</a>
-Bug on "Open type hierarchy"
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8575">8575</a>
-Variable name code completion should handle arrays
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8530">8530</a>
-Internal error using assertions (1.4 feature)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8531">8531</a>
-VerifyError in code containing assertions
-
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7509">7509</a>
-1GQ6DUC: WSWB:WIN2000 - Ctrl-space Code Completion does not work
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8060">8060</a>
-Hierarchy only shows Object when opening type in binary project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3408">3408</a>
-JCK 1.4 - NAME - qualified AmbiguousName and an ExpressionName (1GK7M9B)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8584">8584</a>
-Invalid syntax error generated by compiler
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020124 - 24th January 2002 - MILESTONE 2
-<br>Project org.eclipse.jdt.core v_224
-<h2>
-What's new in this drop</h2>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11354">11354</a>
-Unable to edit Java code
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8016">8016</a>
-getter/setter outliner reconciling broken
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8352">8352</a>
-No hierarchy when using HierachyType
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8042">8042</a>
-ClassCastException hovering in java editor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8216">8216</a>
-Incomplete super type hierarchy for binaries
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8125">8125</a>
-'Could not uniquely map the type name' message opening type
-
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7221">7221</a>
-IllegalArgumentException renaming package
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5341">5341</a>
-Error message shouldn't expose exception class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8038">8038</a>
-Null Pointer Exception Adding Unimplemented
-
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020123 - 23rd January 2002
-<br>Project org.eclipse.jdt.core v_223
-<h2>
-What's new in this drop</h2>
-<ul>
-<li>Added workaround for <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7764">7764</a>
-UI Dead Lock - IDE frozen
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3200">3200</a>
-JavaBuilder - Build progress message could be shortened
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8087">8087</a>
-NPE when hierarchy verbose on and hierarchy on a region
-
-<h3>
-Problem Reports Closed</h3>
-
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020122 - 22nd January 2002
-<br>Project org.eclipse.jdt.core v_222
-<h2>
-What's new in this drop</h2>
-<ul>
-<li> The selection engine now only selects identifier between selection start and selection end.
-Previous behaviour was to select identifier between selection start and identifier end.
-(e.g. if you select <b>File</b> in <b>File</b>Input, now the selection engine select the class File and not FileInput)
-<li> Fix for <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6839">6839</a> required to increment the index signature
-version so as to trigger automatic reindexing on workspace startup (and thus get rid of undesired anonymous type entries
-in the index files). Subsequent startups will not reindex any further (only if inconsistency is detected, e.g. signature version
-is different).
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7993">7993</a>
-NPE when creating type hierarchy
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3417">3417</a>
-JCK 1.4 - BINC - the new method is a static (respectively instance) method. (1GK7WCP)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3416">3416</a>
-JCK 1.4 - BINC - the new method is less accessible than the old one (1GK7VXD)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3415">3415</a>
-JCK 1.4 - BINC - the new field is a static (respectively instance) field (1GK7VSN)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3414">3414</a>
-JCK 1.4 - BINC - the new field is less accessible than the old one (1GK7VMD)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3413">3413</a>
-JCK 1.4 - BINC - detection of an IncompatibleClassChangeError (1GK7VCA)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3412">3412</a>
-JCK 1.4 - BINC - Invoke overriding class methods (1GK7UGQ)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3410">3410</a>
-JCK 1.4 - BINC - Adding a String field that has the same name as a String field of a superclass (1GK7MHO)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7920">7920</a>
-JavaProject.canonicalizedPath
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7597">7597</a>
-PackageFragmentRoot which are archives loose associated resource
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7827">7827</a>
-null returned from getOriginal(IJavaElement workingCopyElement) for IMPORT_CONTAINER
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7144">7144</a>
-Hierarchy incorrect when using binary projects
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3411">3411</a>
-JCK 1.4 - BINC - Overriding instance and class methods (1GK7U6C)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3418">3418</a>
-JCK 1.4 - EXPR - a NullPointerException is raised in run time (1GK7WHA) <br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7441">7441</a>
-Open a type is extremely slow
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7616">7616</a>
-Unnecessary indexing when project is opened
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3229">3229</a>
-OpenOnSelection - strange behaviour of code resolve (1GAVL08)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6953">6953</a>
-No code assist proposals for interface constructor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7583">7583</a>
-DOMNode#getChild(String) needs to handle children with null names
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7584">7584</a>
-Comments on IDOMMethod#getReturnType()
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3247">3247</a>
-SelectionEngine moves selection to enclosing token (1GCSD8D)
-
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7956">7956</a>
-No reference found to BlockScope.analysisIndex
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3283">3283</a>
-OpenOnSelection - Code resolve doesn't work in some situations (1GEI5QT)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5453">5453</a>
-DCR: Code Assist for anonymous types
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7617">7617</a>
-NPE in Builder with duplicated type names
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6466">6466</a>
-Code Formatter
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020115 - 15th January 2002
-<br>Project org.eclipse.jdt.core v_221
-<h2>
-What's new in this drop</h2>
-<ul>
-<li> The compiler will now follow JLS 8.6 with respect to anonymous class
-constructors (i.e. allow them to throw any exceptions).
-<li> The compiler now enforces that interface methods be compatible with Object ones.
-<li> The batch compiler will no longer create package directory structure anymore when the command line
-argument '-d' <tt><destination></tt> is omitted (compliant with standard batch compilers).
-<li> A type hierarchy that misses a super type is not rooted at Object any longer,
- but the subtype (of the missing type) will be a root (this is the behavior of
- VA/Java and VAME.)
-<li> Adding a type that was missing from a hierarchy will update the hierarchy correctly.
-<li> New API on ICompletionRequestor for suggest anonymous type declaration:</li>
-<br> <tt>void acceptAnonymousType(</tt>
-<br><tt> char[] superTypePackageName,</tt>
-<br><tt> char[] superTypeName,</tt>
-<br><tt> char[][] parameterPackageNames,</tt>
-<br><tt> char[][] parameterNames,</tt>
-<br><tt> char[][] parameterNames,</tt>
-<br><tt> char[] completionName,</tt>
-<br><tt> int modifiers,</tt>
-<br><tt> int completionStart,</tt>
-<br><tt> int completionEnd);</tt>
-<br>
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7625">7625</a>
-No typehierarchy in working copy
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7595">7595</a>
-New builder performs intempestive full build on method body changes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7528">7528</a>
-IlegalArgumentException in path canonicalisation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7034">7034</a>
-code assist performance problem in scrapbook
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7119">7119</a>
-Content Assist does not complete some code
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7000">7000</a>
-Switch and Try statement doesn't include trailing }
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6932">6932</a>
-Increment statement in for loop contains trailing comments
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6342">6342</a>
-Code assist on Intreface-'Constructors' incomplete
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7344">7344</a>
-Search - write acces give wrong result
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7455">7455</a>
-Build problems when instance variable name matches constructor parameter name and assignment to this.name in try block
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6839">6839</a>
-AllTypesSearchEngine returns anonymous classes
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7445">7445</a>
-char/string concat bug
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3192">3192</a>
-Invalid type hierarchy when missing type(s) in hierarchy (1GF5RN4)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3304">3304</a>
-Hierarchy not updated when changing classpath (1GF5QSW)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7422">7422</a>
-Missing project references on some imported Java projects
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5067">5067</a>
-CodeAssist - no variable name suggestion for base type
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7363">7363</a>
-Rebuild Project action is not compiling all Java source files
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7325">7325</a>
-Build collisions should be non-fatal?
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7324">7324</a>
-Ambiguous multiple problem descriptions when collision of build files
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3385">3385</a>
-JCK 1.4 - INTF - illegal method declaration for interface (1GK2AWS)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3318">3318</a>
-JDOM - IDomNode redefines clone() with different signature (1GFVU2V)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6101">6101</a>
-Unexpected error in inner class
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7333">7333</a>
-typo in type name: ResetSateForCodeGenerationVisitor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7354">7354</a>
-Compatibility with javac when no output directory is specified
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6473">6473</a>
-JavaConventions should use IWorkspace validate methods
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7129">7129</a>
-Problems with replacing a project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3386">3386</a>
-JCK 1.4 - EXCP - checked exception in variable initializer of anonymous class (1GK7B5L)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3367">3367</a>
-JCK 1.4 - ICLS - An instance initializer in an anonymous class may throw any exception (1GK7LYF)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7184">7184</a>
-Built in compiler does not allow anonymous class initializers to throw exceptions
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6504">6504</a>
-Type hierarchy: Subtypes in jar of another project not found
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3334">3334</a>
-Types hierarchy view does not show all subclasses. (1GI901Q)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6866">6866</a>
-Code-Assist (ctrl+space) to slow with jre-src
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7071">7071</a>
-ArrayStoreException getting hoverhelp in Java editor
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7165">7165</a>
-erroneous warning of unused variables
-
-<h3>
-Problem Reports Closed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3217">3217</a>
-JM - deleting default package (1G8417Z)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7375">7375</a>
-new classes with funny names don't appear in package view
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7302">7302</a>
-Need visibility in search results
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7305">7305</a>
-interface methods are marked abstract
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7290">7290</a>
-Project size limitation
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6232">6232</a>
-Build problems: Internal error: null when compiling JDK source code
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7380">7380</a>
-Wrong scope for traverse methods
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7137">7137</a>
-Invalid type not flagged by compiler
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6924">6924</a>
-ArrayIndexOutOfBoundsException when setting the build path.
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20020108 - 8th January 2002
-<br>Project org.eclipse.jdt.core v_220a
-<h2>
-What's new in this drop</h2>
-<ul>
-<li>
-Added new compiler option to toggle compliance level (can be either
-"1.3" or "1.4" - 1.3 being the default), and it will affect the behavior
-of the compiler with respect to JLS 8.1.5 (inherited member shadows enclosing
-one). Option is located on <tt>JavaCore#getOptions()</tt> and named <tt>"org.eclipse.jdt.core.compiler.compliance"</tt>
-Accordingly, the batch compiler accepts an extra command line argument
-"-1.3" or "-1.4" (1.3 compliance being the default).</li>
-</ul>
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3330">3330</a>
-JCK 1.4 - illegal simple name imports (1GHW0G1)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7070">7070</a>
-moved classes lost!
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6785">6785</a>
-NPE in IType.resolve
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6779">6779</a>
-searchDeclarationsOfReferencedTyped - missing exception types
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7035">7035</a>
-New builder - builder does not close all JARs
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7033">7033</a>
-Stale packages view after moving compilation units
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6927">6927</a>
-Static inner class won't compile (doesn't match JDK behavior)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7030">7030</a>
-IllegalArgumentException renaming project
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7029">7029</a>
-Renaming a Java project doesn't refresh the packages view
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7027">7027</a>
-project gone after renaming in the navigator
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7026">7026</a>
-walkback on rename project - could not reproduce
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6889">6889</a>
-No typehierarchy for inner types
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3343">3343</a>
-Missing java.lang.Object should produce a more prominent compiler error
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6948">6948</a>
-New builder - builder does not reuse opened JARs
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3314">3314</a>
-Resources not appearing in Java perspective or Jar export wizard (1GFL0QT)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6890">6890</a>
-META-INF hidden
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6993">6993</a>
-JavaModel inconsistencies with units outside classpath
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3360">3360</a>
-Code assist does not work in inner classes (1GJOVT6)
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6893">6893</a>
-LocalTypeDeclaration includes preceeding comment even if there are statements in between
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3372">3372</a>
-Markers for build path not updated on (re-) build
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5413">5413</a>
-incorrect class source range
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6429">6429</a>
-declaration source start incorrect on local variable
-<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6433">6433</a>
-declaration source start incorrect on local variable #2
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3235">3235</a>
-PackageFragmentRoot existency check need to be revisited (1GCUNO7)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6865">6865</a>
-open on selection in BuildNotifier only finds contents of rt.jar
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6037">6037</a>
-JarPackageFragmentRoot.getUnderlyingResource() always returns null
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6750">6750</a>
-Batch compiler - Classpath handling is too strict
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3409">3409</a>
-JCK 1.4 - STMT - null literal in throw statement (1GK7MEQ)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4915">4915</a>
-JCK 1.4 - need a major compiler switch for 1.3 / 1.4 mode
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6678">6678</a>
-Incorrect output after Add Unimplemented Method
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3361">3361</a>
-JCK 1.4 - ICLS - field from outer class and inherited public field in nested class (1GK7LAA)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3350">3350</a>
-JCK 1.4 - ICLS - static class from outer and class from superclass in top-level nested class (1GK7DVJ)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3351">3351</a>
-JCK 1.4 - ICLS - static class from outer and protected static class from superclass in nested class (1GK7DZV)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3352">3352</a>
-JCK 1.4 - ICLS - static class from outer and public static class from superclass in nested class (1GK7EB9)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3362">3362</a>
-JCK 1.4 - ICLS - field from outer class and inherited field in nested class (1GK7LCX)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3363">3363</a>
-JCK 1.4 - ICLS - An inherited variable that shadows a name from an enclosing non-package scope (1GK7LHR)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3364">3364</a>
-JCK 1.4 - ICLS - An inherited method that shadows a name from an enclosing non-package scope (1GK7LKV)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3365">3365</a>
-JCK 1.4 - ICLS - An inherited class that shadows a name from an enclosing non-package scope (1GK7LTA)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3366">3366</a>
-JCK 1.4 - ICLS - An inherited interface that shadows a name from an enclosing non-package scope (1GK7LW2)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3375">3375</a>
-JCK 1.4 - ICLS - class from outer and protected class from superclass in top-level nested class (1GK7FLC)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3376">3376</a>
-JCK 1.4 - ICLS - class from outer and public class from superclass in top-level nested class (1GK7FOT)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3377">3377</a>
-JCK 1.4 - ICLS - class from outer and class from superclass in top-level nested class (1GK7FTA)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3378">3378</a>
-JCK 1.4 - ICLS - class from outer and protected static class from superclass in nested class (1GK7FX7)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3379">3379</a>
-JCK 1.4 - ICLS - class from outer and public static class from superclass in nested class (1GK7G2A)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3380">3380</a>
-JCK 1.4 - ICLS - class from outer and static class from superclass in nested class (1GK7G5A)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3381">3381</a>
-JCK 1.4 - ICLS - class from outer and protected class from superclass in nested class (1GK7G8E)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3382">3382</a>
-JCK 1.4 - ICLS - class from outer and public class from superclass in nested class (1GK7GC1)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3383">3383</a>
-JCK 1.4 - ICLS - class from outer and class from superclass in nested class (1GK7GQA)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3384">3384</a>
-JCK 1.4 - ICLS - static class from outer and public static class from superclass in top-level nested class. (1GK7CTV)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3387">3387</a>
-JCK 1.4 - ICLS - static field from outer class and inherited public field in top-level nested class (1GK7H0B)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3388">3388</a>
-JCK 1.4 - ICLS - static class from outer and protected static class from superclass in top-level nested class (1GK7BGP)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3389">3389</a>
-JCK 1.4 - ICLS - static class from outer and static class from superclass in top-level nested class (1GK7D2P)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3390">3390</a>
-JCK 1.4 - ICLS - static class from outer and protected class from superclass in top-level nested class (1GK7D7Q)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3391">3391</a>
-JCK 1.4 - ICLS - static class from outer and public class from superclass in top-level nested class (1GK7DBD)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3392">3392</a>
-JCK 1.4 - ICLS - static class from outer and static class from superclass in nested class (1GK7ERE)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3393">3393</a>
-JCK 1.4 - ICLS - static class from outer and protected class from superclass in nested class (1GK7EVB)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3394">3394</a>
-JCK 1.4 - ICLS - static class from outer and public class from superclass in nested class (1GK7EZB)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3395">3395</a>
-JCK 1.4 - ICLS - static class from outer and class from superclass in nested class (1GK7F4S)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3396">3396</a>
-JCK 1.4 - ICLS - class from outer and protected static class from superclass in top-level nested class (1GK7F8L)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3397">3397</a>
-JCK 1.4 - ICLS - class from outer and public static class from superclass in top-level nested class (1GK7FCN)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3398">3398</a>
-JCK 1.4 - ICLS - class from outer and static class from superclass in top-level nested class (1GK7FHB)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3399">3399</a>
-JCK 1.4 - ICLS - static field from outer class and inherited field in top-level nested class (1GK7H2Z)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3400">3400</a>
-JCK 1.4 - ICLS - static field from outer class and inherited protected field in top-level nested class (1GK7GW6)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3401">3401</a>
-JCK 1.4 - ICLS - field from outer class and inherited field in top-level nested class (1GK7HEF)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3402">3402</a>
-JCK 1.4 - ICLS - static field from outer class and inherited protected field in nested class (1GK7HH1)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3403">3403</a>
-JCK 1.4 - ICLS - field from outer class and inherited protected field in top-level nested class (1GK7H5X)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3404">3404</a>
-JCK 1.4 - ICLS - field from outer class and inherited public field in top-level nested class (1GK7HBJ)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3405">3405</a>
-JCK 1.4 - ICLS - static field from outer class and inherited public field in nested class (1GK7HKE)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3406">3406</a>
-JCK 1.4 - ICLS - static field from outer class and inherited field in nested class (1GK7HMN)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3407">3407</a>
-JCK 1.4 - ICLS - field from outer class and inherited protected field in nested class (1GK7L79)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6061">6061</a>
-unreachable code/unused temp ?
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6443">6443</a>
-Incremental java builder doesn't handle folder create/delete nicely
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5317">5317</a>
-Reparenting class should refresh hierarchy
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6740">6740</a>
-Problems with deleting project
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6491">6491</a>
-Non-java resource folder doesn't appear under pkg fragment root
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3245">3245</a>
-sub folders with dot not visible in packages view (1GCOH17)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6806">6806</a>
-NullPointerException moving enpty cu out of default package
-
-<h3>
-Problem Reports Closed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=7065">7065</a>
-NPE when saving a Java source
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6956">6956</a>
-incorrect compiler error reported on extract method
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=7072">7072</a>
-Protected member in superclass not visible in subclass
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=7066">7066</a>
-Subclass can't see protected inner class of superclass
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3284">3284</a>
-Project doesn't always rebuild after changing the Java build path
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6957">6957</a>
-CCE in AnonymousLocalTypeDeclaration::traverse
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6958">6958</a>
-NPE in DeltaProcessor
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6900">6900</a>
-Rebuild project fails with error "1000
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4382">4382</a>
-NullPointerException in JavaBuilder
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3199">3199</a>
-Missing classpath variables
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6848">6848</a>
-Index out of range exception with New builder
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4913">4913</a>
-null argument in IncrementalImageBuilder.getBuilderType
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6760">6760</a>
-package names truncated in compilation dialog
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3295">3295</a>
-Errors from missing reference to a jar do not go away
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3450">3450</a>
-Bug in JavaSearchScope (1GLE1GC)
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20011218 - 18th December 2001 - MILESTONE 1
-<br>Project org.eclipse.jdt.core v_219a
-<h2>
-What's new in this drop</h2>
-
-<h3>
-Problem Reports Fixed</h3>
-
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6117">6117</a>
-CodeFormatter - impossible to set indentation level and position mapping w/o deprecated methods
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6719">6719</a>
-LocalTypeDeclaration::traverse
-
-<h3>
-Problem Reports Closed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5432">5432</a>
-compiler syntax error is incorrect
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20011211 - 11th December 2001
-<br>Project org.eclipse.jdt.core v_218
-<h2>
-What's new in this drop</h2>
-
-<ul>
-<li> Java element deltas are batched. If the java model operation modifies
- a resource, then the java element deltas are merged and fired during
- the resource delta processing. If the java model operation doesn't
- modify any resource (e.g. IWorkingCopy.reconcile()), then the java
- element delta is fired right away.
-</ul>
-<h3>
-Problem Reports Fixed</h3>
-
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3215">3215</a>
-JM - Creating a new class sends out many notifications (1GD2GT0)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6695">6695</a>
-Changing Java preference in build 20011206 throws a NullPointerException in org.eclipse.jdt.internal.core.DeltaProcessor.initializeRoots
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6761">6761</a>
-NullPointerException during replace
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3290">3290</a>
-JavaBuilder - Old class files remain after change of output location
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3188">3188</a>
-JavaBuilder - Deleting source doesn't delete binary folders (1FVPTTK)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3185">3185</a>
-JavaBuilder - Errors don't disappear
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3189">3189</a>
-JavaBuilder - Missing libraries results in insufficient dependency info
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3204">3204</a>
-ImageBuilder should show error count in the progress
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3227">3227</a>
-JCL dev - Builder did not refresh problems in exception hierarchy
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3228">3228</a>
-Discarding rt.jar from build path triggers too many recompilation
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3232">3232</a>
-Incremental builder unable to handle efficiently missing rt.jar scenario
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3234">3234</a>
-Incremental builder does not notice addition of java.lang.Object inside same project
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3241">3241</a>
-Build doesn't honor cancel
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3260">3260</a>
-NPE when doing incremental project build
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3278">3278</a>
-JavaBuilder - Problem Count rarely updated
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3287">3287</a>
-Built state does not remember old pkg fragment roots
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3301">3301</a>
-Incremental build doesn't detect disappearance of field
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3305">3305</a>
-Incremental build doesn't detect abstract method to implements
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3311">3311</a>
-performance: task list still does not scale at all
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3312">3312</a>
-Internal errors in image builder due to duplicate package fragment
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3317">3317</a>
-Fullbuild after startup
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3322">3322</a>
-NullPointerException during build in StateImpl.getSourceElementEntries
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3326">3326</a>
-Incremental build doesn't work if bin deleted
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3370">3370</a>
-Incremental compiler is compiling project when it should not
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3422">3422</a>
-NPE in Java builder during catchup
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3429">3429</a>
-Incremental compilation bug on namespace change in private local class
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3444">3444</a>
-Build problems: Marker set on Folder?
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5007">5007</a>
-Project classpath references do not follow class folders
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5109">5109</a>
-Adding project doesn't fix build errors
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5320">5320</a>
-NPE during catchup
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5641">5641</a>
-NPE on rebuild when replacing internal jar
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6538">6538</a>
-searchDeclarationsOf* incorrect
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6690">6690</a>
-CodeAssist finds types outside the classpath
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6687">6687</a>
-Wrong JavaModel refresh after drag and drop outside folder with dot in name
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6693">6693</a>
-AbstractImageBuilder.compile throws an ArrayIndexOutOfBoundsException on line 166 in build 20011206
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6670">6670</a>
-Code Assist: Cannot resolve in method body
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6674">6674</a>
-Cannot add unimplemented methods
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6629">6629</a>
-Open On Selection does not work on Linux
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5542">5542</a>
-Too many deltas are fired on each JavaModel operation
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3269">3269</a>
-Updating the Java packages view on project creation (1GDW0U9)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3202">3202</a>
-DCR - JM - Merge Java Element Deltas with Resource Deltas (1G2B60Z)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6621">6621</a>
-NPE in Delta Processor
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3368">3368</a>
-JCK 1.4 - INTF - The field of protected interface is used in other package (1GK7M25)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6596">6596</a>
-Java compiler can generate invalid bytecode
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6586">6586</a>
-NullPointerException when resource modification done before java model is open
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6542">6542</a>
-extract method: incorrect error message
-
-<h3>
-Problem Reports Closed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6645">6645</a>
-Build/Rebuild does not recompile code
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6669">6669</a>
-Search doesn't find reference to a field that is only used in an initialization
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5385">5385</a>
-search: name searchDeclarationsOfSentMessages is not good
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3183">3183</a>
-JM - Builders and nested operations using Java model can get inconsistent results (1FUBV90)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3250">3250</a>
-JavaProject.retrieveResource picks first removed child delta (1GCV7PQ)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6378">6378</a>
-ClassCastException in inner class emulation
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6677">6677</a>
-\u in comment gives Invalid unicode error
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20011206 - 06th December 2001
-<br>Project org.eclipse.jdt.core v_217
-<h2>
-What's new in this drop</h2>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6564">6564</a>
-New builder - Incremental recompilation detected package problems incorrectly
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6563">6563</a>
-Package view does not refresh ok when adding both package and unit at once
-
-<h3>
-Problem Reports Closed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3242">3242</a>
-TypeRef.getType does not work for inner types (1GCFUNT)
-
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20011204 - 4th December 2001
-<br>Project org.eclipse.jdt.core v_216c
-<h2>
-What's new in this drop</h2>
-<ul>
-<li> New incremental builder implementation enabled by default (can reenable the
-old implementation by changing the builder extension in the plugin.xml)
-<li> Delta processing improvement:
- <ul>
- <li> No longer creates unnecessary Java elements when traversing the resource delta.
- <li> Handles changes in binary folder libraries.
- <li> Projects that share libraries are notified individually.
- <li> Doesn't notify empty deltas any longer.
- </ul>
-<li> Source folder resource copying no longer perfom any copies as soon as
-one source folder coincidates with the output location.
-<li> Open on selection is more fault-tolerant: will now try to locate a
-selected method for which argument types are incorrect.
-<li> Compiler no longer rejects correct code with respect to access to protected
-members defined in enclosing types (was only accepting a subset of correct scenarii).
-</ul>
-<h3>
-Problem Reports Fixed</h3>
-
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6528">6528</a>:
-InvocationTargetException trying to search
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6494">6494</a>:
-New builder: Invalid error found (The declared package does not match the expected package)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6461">6461</a>:
-NewBuilder - doesn't detect incorrectly located compilation units
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6456">6456</a>:
-Invalid error when compiling access to protected member inside innerclass
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3358">3358</a>:
-Performance: indexer doing too much work? (1GJLDN7)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5471">5471</a>:
-CodeFormatter mapped positions broken for multi-line comments
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6431">6431</a>:
-ArrayIndexOutOfBoundsException in the SourceIndexer requestor
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6422">6422</a>:
-Resource copy should not occur as soon as one source folder overlap the
-binary output
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6416">6416</a>:
-Code resolve doesn't work on message send when parameters are not correct
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5705">5705</a>:
-Wrong positions for ClassCastLiteral
-<h3>
-Problem Reports Closed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6423">6423</a>:
-Search - does not find declarations of method "to*String"
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3246">3246</a>:
-CodeCompletion - No completion on member access on anonymous class (1GD3OGA)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5454">5454</a>:
-Code Assist adds qualified code inside inner classes
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5837">5837</a>:
-ArrayIndexOutOfBoundsException in index merging
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20011127 - 27th November 2001
-<br>Project org.eclipse.jdt.core v_215a
-<h2>
-What's new in this drop</h2>
-
-<ul>
-<li>
-Better highlighting of multi-line message sending</li>
-
-<li>
-Code assist only qualifies implicit members when necessary</li>
-
-<li>
-New API for setting both classpath and output location at the same time
-(allowing to avoid classpath validation failures in case there is no way
-to change both independantly):</li>
-
-<br><tt>IJavaProject.setRawClasspath(IClasspathEntry[] newClasspath, IPath
-newOutputLocation, IProgressMonitor monitor)</tt></ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6339">6339</a> Assertion
-failed in SourceType
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5618">5618</a>
-Uncaught CompletionNodeFound exception doing code assist
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6294">6294</a>
-Exception during setting the classpath
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6302">6302</a>
-AssertionFailure in open on selection
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6094">6094</a>
-Search - does not find references to JavaProject.setProject(...)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3320">3320</a>"
-Search - Match through super type not found if in different project (1GGAOFT)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6158">6158</a>"
-Search - Prefix and postfix expression not found as write reference
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4974">4974</a>:
-Set classpath / output location should be one operation
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6176">6176</a>:
-Eclipse tools index out of bounds
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6160">6160</a>:
-Index out of bounds in update references
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6151">6151</a>:
-ArrayIndexOutOfBoundsException in ObjectSet
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5943">5943</a>:
-internal error in setting buildpath (name collsion)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5471">5471</a>:
-CodeFormatter mapped positions broken for multi-line comments
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5907">5907</a>:
-Indexer errors when disk full
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5884">5884</a>:
-Code assist should only fully qualify if needed
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5514">5514</a>:
-Select a declaration does not work in unsaved working copies
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5414">5414</a>:
-ArrayIndexOutOfBoundsException in Signature
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5384">5384</a>:
-search engine: behavior different than expected
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6104">6104</a>:
-Unoptimal debugger highlight for multi-line message expression
-<h3>
-Problem Reports Closed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6210">6210</a>: Creation
-failed error when creating a source folder
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3425">3425</a>:
-JavaCore.create(String handle) looses information (1GLA0QG)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6127">6127</a>:
-Reference by local class not found when searching for interface refs
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4990">4990</a>:
-Error starting Eclipse
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3471">3471</a>:
-Leading '/' in src page of Java wizard is misleading (1G842TH)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3619">3619</a>:
-inconsistent search for method declarations (1GCZZS1)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5557">5557</a>:
-Incorrect hierarchy shown (not rooted at Object)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6100">6100</a>:
-Bug in ObjectSet.Enumeration.nextElement
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20011120 - 20th November 2001
-<br>Project org.eclipse.jdt.core v_213
-<h2>
-What's new in this drop</h2>
-
-<ul>
-<li>
-CodeAssist no longer find synthetic completions.</li>
-
-<li>
-Reduced startup time of Java perspective</li>
-
-<li>
-CodeAssist option added to force full qualification of implicit field/method
-references (see JavaCore option: "org.eclipse.jdt.core.codeComplete.forceImplicitQualification").</li>
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5982">5982</a>: content
-assist displays accessors
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5955">5955</a>:
-NPE in LookupEnvironment
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5923">5923</a>:
-Search for "length" field refs finds [].length
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5916">5916</a>:
-Search - too many matches for refs to NameLookup.findPackageFragmentRoot
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5957">5957</a>:
-Internal error in RecoveredMethod.add
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5972">5972</a>:
-Incremental builder (new) recompiling dependents of Parser for no apparent
-reason
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5940">5940</a>:
-Instance initializer in anon inner class generates errors
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5913">5913</a>:
-Performance - creating tons of classfile elements at startup
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5862">5862</a>:
-search : too many matches on search with OrPattern
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6070">6070</a>:
-New Builder: Builder order problem
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5852">5852</a>:
-Project references not updated according to buildpath
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5471">5471</a>:
-CodeFormatter mapped positions broken for multi-line comments
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5563">5563</a>:
-Write reference on declaration not reported
-<h3>
-Problem Reports Closed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3257">3257</a>: IMethod.getParameterNames
-for ClassFiles should use names from source (1GDGN3G)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3245">3245</a>:
-sub folders with dot not visible in packages view (1GCOH17)
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20011113 - 13th November 2001
-<br>Project org.eclipse.jdt.core v_211b
-<h2>
-What's new in this drop</h2>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5821">5821</a>: Refactor
-Rename renames local variable instead of member in case of name clash
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5003>5003</a>: Review JavaBuilder cancelation handling <br><a href=" http://dev.eclipse.org/bugs/show_bug.cgi?id="5790">5790</a>:
-IJavaProject.hasBuildState() fails with new builder
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5794">5794</a>:
-Polymorphic search doesn't work in dependent projects
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5781">5781</a>:
-NPE using new image builder
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5834">5834</a>:
-Incremental build recompiled unrelated project
-<h3>
-Problem Reports Closed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5215">5215</a>: search:
-missing field reference
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20011112 - 12th November 2001
-<br>Project org.eclipse.jdt.core v_210_01
-<h2>
-What's new in this drop</h2>
-
-<ul>
-<li>
-Project references are maintained by the JavaCore, in parallel with build
-path.</li>
-
-<li>
-Resurrected deprecated APIs from 0.9 which were discarded previously.</li>
-
-<li>
-ICodeCompletion reverted to 1.0 version, and got deprecated. Use ICompletionRequestor
-instead.</li>
-
-<li>
-Cross-project incremental recompilation in presence of structural changes
-in produced binaries.</li>
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5362">5362</a>: Deeper
-than necessary JavaElementDelta when package added
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5525">5525</a>:
-ICodeCompletionRequestor isn't 1.0 compatible
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5616">5616</a>:
-NPE when compiling invalid code defining a array of strings
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5217">5217</a>:
-java search scope: missing enclosing project
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5527">5527</a>:
-Unexpected inaccurate matches for #close() declarations
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5522">5522</a>:
-Type hierarchy - missing subtypes of JavaElement
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5508">5508</a>:
-JDT cannot support periods in the folders above the package name
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5541">5541</a>:
-No refresh when adding a compilation unit inside a dot named source folder
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5532">5532</a>:
-Incremental compile missed a return type change
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5515">5515</a>:
-AbortCompilation during polymorphic search
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5275">5275</a>:
-Cross-project recompilation Defect 186249 - OTI PR# 1GLEYT1
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5267">5267</a>:
-Dependent Projects not compiled when project is saved
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5425">5425</a>:
-Exception on CodeAssist
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3194">3194</a>:
-DCR - JM - Buffer contents is duplicated (1G03HCP)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5430">5430</a>:
-Must resurrect 0.9 deprecated APIs
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4923">4923</a>:
-IJavaProject.getPackageFragmentRoots returns roots from other projects
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3308">3308</a>:
-Projects not build in correct order after load (1GF60TN)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3435">3435</a>:
-keeping the project references and required project in synch (1GL0L34)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5203">5203</a>:
-Project indexing does not restrain to source files on the classpath
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3293">3293</a>:
-search does not work in inner class (1GEUQHJ)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3249">3249</a>:
-Error message is confusing: using token instead of identifier (1GCTDYM)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5214">5214</a>:
-TVT: Apostrophe shows up multiple times in Java error messages in some
-translations (italian)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5263">5263</a>:
-TVT: Compiler error messages are hard for translators to understand
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3251">3251</a>:
-Types not included in code assist list for import (1GD06W9)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5277">5277</a>:
-Code assist on assert method do an AbortException
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5070">5070</a>:
-search: missing interface method reference
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5069">5069</a>:
-search: method reference in super missing
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5068">5068</a>:
-search: missing method reference
-<h3>
-Problem Reports Closed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5526">5526</a>: NullPointerException
-searching declarations of #close()
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5498">5498</a>:
-Java Compile - code does not compile correctly in JDT, but does with javac
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5493">5493</a>:
-Adding project references doesn't update the classpath
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5426">5426</a>:
-CodeAssist returns empty completion
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=1690">1690</a>:
-Local variables not always displayed when in scope (1GJ8PX4)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4368">4368</a>:
-Wrong match in Java Search
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3238">3238</a>:
-CodeAssist - no completion if cursor at string beginning (1GI3BYO)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3271">3271</a>:
-Unable to delete attached internal source jar (1GDX215)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3209">3209</a>:
-DCR - JM -Invalid references to IPath.getDevice() potentially breaking
-on Linux (1G4U1R7)
-<br>
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20011025 - 25th October 2001
-<br>Project org.eclipse.jdt.core v_206
-<h2>
-What's new in this drop</h2>
-
-<ul>
-<li>
-JavaModel is no longer performing smart classpath updates when Java package
-fragment roots are either moved or removed.</li>
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3568">3568</a>: no
-hoverhelp over constructor referrences (1GAJ0KP)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5218">5218</a>:
-AccSuper is not set properly
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5200">5200</a>:
-SetClasspathOperation must close root only when root is removed
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3449">3449</a>:
-CodeAssist - two type with same name must be qualified (1GLDN3Z)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4973">4973</a>:
-Rename package removes first letter of import statements
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3279">3279</a>:
-Severe - JM - Source found, even though sourcepath is false (1GELAVB)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3434">3434</a>:
-Deleting a project from the ws removes it from the buildpath! (1GKZNBS)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5021">5021</a>:
-Refactoring trashed my code
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5136">5136</a>:
-ArrayIndexOutOfBoundsException when a field declaration is an anonymous
-class
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3440">3440</a>:
-Classfile comparator should be able to ignore order (1GL2I7E)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3439">3439</a>:
-Classfile comparator should be able to ignore synthetics (1GL2I3N)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3442">3442</a>:
-NPE in SourceElementParser (1GL496I)
-<h3>
-Problem Reports Closed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3369">3369</a>: Classpath
-gets out of sync (1GJU853)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3281">3281</a>:
-change java project binary output create new package (1GEHK07)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3298">3298</a>:
-Incorrect compile error on valid case statement (1GEYWET)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3562">3562</a>:
-Outliner bug for initializers (1G93CS3)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3447">3447</a>:
-search: could automatically narrow down scope (1GLDJVN)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3288">3288</a>:
-CodeAssist - Code assist doesn't work in some methods (1GELEBH)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5073">5073</a>:
-delete does not work on default package
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3443">3443</a>:
-Unused argument/variable warnings shown twice (1GL4OW7)
-<br>
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20011018 - 18th October 2001
-<br>Project org.eclipse.jdt.core v_205
-<h2>
-What's new in this drop</h2>
-
-<ul>
-<li>
-CodeAssist provides variable name suggestions.</li>
-
-<br> (breaking) API Changes on <tt>ICompletionRequestor</tt>
-<br> <b>+</b> <u>Added</u> API for suggest variable name:
-<br> <tt>void acceptVariableName(</tt>
-<br><tt> char[] typePackageName,</tt>
-<br><tt> char[] typeName,</tt>
-<br><tt> char[] name,</tt>
-<br><tt> char[] completionName,</tt>
-<br><tt> int completionStart,</tt>
-<br><tt> int completionEnd);</tt>
-<br>
-<li>
-Helper method for computing a resolved and expanded path (all exports from
-prerequisites) which was introduced in 204, got <u>removed</u>. This is
-not an API change, it never made it out officially.</li>
-
-<br> <b>-</b> <tt>IJavaProject.getExpandedClasspath(boolean)</tt>
-<p><tt>SearchEngine.createJavaSearchScope(IResource[])</tt> has been deprecated.
-Use <tt>SearchEngine.createJavaSearchScope(IJavaElement[])</tt> instead.
-The rational is that <tt>createJavaSearchScope(IResource[])</tt> was not
-well defined for projects, and it could not define a search scope for java
-elements that didn't have a corresponding resource (e.g. external jars).
-This deprecated API's behavior has also reverted to the 1.0 state for backward
-compatibility. The specification of <tt>createJavaSearchScope(IJavaElement[])</tt>
-is as follows:
-<ul>
-<li>
-If an element is an <tt>IJavaProject</tt>, then the project's source folders,
-its jars (external and internal) and its references projects (with their
-source folders and jars, recursively) will be included.</li>
-
-<li>
-If an element is an <tt>IPackageFragmentRoot</tt>, then only the package
-fragments of this package fragment root will be included.</li>
-
-<li>
-If an element is an <tt>IPackageFragment</tt>, then only the compilation
-unit and class files of this package fragment will be included. Subpackages
-will NOT be included.</li>
-</ul>
-</ul>
-
-<h3>
-Problem Reports Fixed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5065">5065</a>: NullPointerException
-in Code Assist
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4921">4921</a>:
-Serach does not find types in internal jar
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4917">4917</a>:
-Latest build fails updating TypeHierarchy
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3296">3296</a>:
-CodeAssist - should filter out duplicates if any (1GEWDL7)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3325">3325</a>:
-Too much codeassist match on interface (1GH0GV1)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3424">3424</a>:
-DCR: code assist support for variable name suggestions (1GKM6OQ)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3282">3282</a>:
-JCK 1.4 - DASG - assigned variable before catch block after return statement
-(1GK2AHX)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3452">3452</a>:
-NPE doing Display from Binary (1GLEG5K)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3374">3374</a>:
-SearchPatter.createPattern(...) doesn't work with unicodes (1GJYBRY)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3309">3309</a>:
-DCR - JM - could ICompilationUnit::getType throw JME? (1GF9AL9)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3310">3310</a>:
-Smoke 124: Compile errors introduced with rename refactoring (1GFBK2G)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3436">3436</a>:
-NPW in TypeHierarchy (1GL0L8D)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4919">4919</a>:
-Cannot duplicate local variable in finally block
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4943">4943</a>:
-Verification error
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4385">4385</a>:
-QualifiedAllocationExpression.sourceEnd incorrect if type is an AnonymousLocalTypeDeclaration
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3230">3230</a>:
-Search - Too many type references for query ending with * (1GAZVGI)
-<h3>
-Problem Reports Closed</h3>
-<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3174">3174</a>: Open-on-selection
-doesn't work on MouseAdapter (1GF69TH)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3337">3337</a>:
-Open on selection failed with double message (1GIFA80)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3207">3207</a>:
-JM - Smart save when empty CU (1G4EVHM)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=1672">1672</a>:
-Cannot evaluate classes in a sealed jar (1GHU6YK)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3220">3220</a>:
-Formatter tests refer to hardcoded path on disk (1G9R5G4)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3258">3258</a>:
-exception doing import assist (1GDIJ9D)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3240">3240</a>:
-need to find method declarations in anonymous inner types (1GCBPRI)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3254">3254</a>:
-Indexer - Should nest index source retrieval in IWorkspaceRunnable (1GD7J6F)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3225">3225</a>:
-IJavaProject.findPackageFragment strange semantic (1GAOLWQ)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3218">3218</a>:
-No interface to polymorphically acess ICompilationUnit (1G8D2ZP)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3205">3205</a>:
-Problems with IJavaModel.findPackageFragment (1G456DO)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3197">3197</a>:
-DCR - OpenOnSelection - Code resolve doesn't work on declarations (1G0UX9V)
-<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3177">3177</a>:
-64kb method should be a configurable problem (1FJHGVF)
-<br>
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 20011011 - October 11th, 2001
-<br>Project org.eclipse.jdt.core v_204
-<h2>
-What's new in this drop</h2>
-
-<ul>
-<li>
-Classpath entries (except for source folders) can be tagged as exported
-upon creation. When exported, an entry is contributed to dependent projects
-along with its output location.</li>
-
-<li>
-Added APIs:</li>
-
-<br> Testing status of a given entry
-<br> + IClasspathEntry.isExported()</ul>
- Creating
-entries with export flag
-<br>
-+ JavaCore.newProjectEntry(IPath, boolean)
-<br>
-+ JavaCore.newLibraryEntry(IPath, IPath, IPath, boolean)
-<br>
-+ JavaCore.newVariableEntry(IPath, boolean)
-<p> Helper
-method computing a resolved and expanded path (all exports from prerequisites)
-<br>
-+ IJavaProject.getExpandedClasspath(boolean)
-<ul>
-<li>
-CodeAssist inserts qualification on field/method references in case of
-ambiguities.</li>
-
-<li>
-CodeAssist provides parameter names on method completions.</li>
-
-<br> API Changes on ICompletionRequestor
-<br> + Added API for answering method declaration completions:
-<br> void acceptMethodDeclaration(
-<br> char[] declaringTypePackageName,
-<br> char[] declaringTypeName,
-<br> char[] selector,
-<br> char[][] parameterPackageNames,
-<br> char[][] parameterTypeNames,
-<br> char[][] parameterNames,
-<br> char[] returnTypePackageName,
-<br> char[] returnTypeName,
-<br> char[] completionName,
-<br> int modifiers,
-<br> int completionStart,
-<br> int completionEnd);
-<br> + Added parameterNames to normal method results
-API:
-<br> void acceptMethod(
-<br> char[] declaringTypePackageName,
-<br> char[] declaringTypeName,
-<br> char[] selector,
-<br> char[][] parameterPackageNames,
-<br> char[][] parameterTypeNames,
-<br> char[][] parameterNames,<<<<<<<<<<<<<<<<
-ADDED
-<br> char[] returnTypePackageName,
-<br> char[] returnTypeName,
-<br> char[] completionName,
-<br> int modifiers,
-<br> int completionStart,
-<br> int completionEnd);
-<br>
-<li>
-CodeAssist optionally performs visibility checks (see JavaCore option:
-"org.eclipse.jdt.core.codeComplete.visibilityCheck").</li>
-
-<li>
-Search for field read and field write references. Two new constants have
-been added</li>
-
-<br> on IJavaSearchConstants to be used when creating
-a field reference search pattern:
-<br> - READ_REFERENCES: the search results contain *only*
-read access to a field.
-<br> - WRITE_REFERENCES: the search results contain *only*
-write access to a field.
-<br> Note that if REFERENCES is used, then search results
-contain both read and write
-<br> accesss to a field.
-<li>
-OpenOnSelection can now locate selected declarations which have a corresponding</li>
-
-<br> Java element (i.e. no local declaration is found),
-and is more tolerant of
-<br> incorrect code.</ul>
-
-<h2>
-Problem Reports Fixed</h2>
- 3430 usability: parameter hints (1GKYXK5)
-<br> 3431 Unreachable code in JCore
-(1GL2V6K)
-<br> 3175 JCK1.3a - ICLS - Comparing
-current instance against enclosing instance inside of anonymous class.
-(1GLDSBS)
-<br> 1GLBOJZ: ITPJCORE:WIN2000 - UnaryExpression doesn't store
-expression type in bit mask
-<br> 1GDS7IP: ITPJCORE:WIN2000 - VerifyError related to a local
-index computation
-<br> 1GLABQ7: ITPJCORE:WIN2000 - JavaCore.create(String) throws an
-unexpected exception
-<br> 1GL0PGV: ITPJCORE:WINNT - Batch compiler leaving JARs open
-<br> 5268 ITPJCORE:ALL - VerifyError when running app (1GL4QKI)
-<br> 1GLBP65: ITPJCORE:WIN2000 - search: type refs - incorrect match
-<br> 1GKXCOM: ITPJCORE:WIN2000 - ClassCastException during inner
-class emulation
-<br> 1GD07GK: ITPJUI:WIN98 - Code assist should qualify methods if
-needed.
-<br> 1GL1HF8: ITPJCORE:WIN2000 - Missing implementation in the compiler
-compiling invalid code
-<br> 1GL13OT: ITPJCORE:ALL - INameLookup should be removed
-<br> 1GL1I9F: ITPJCORE:WIN2000 - Wrong source mapping for binary
-methods with parameters with identical simple names
-<br> 1G4CIP0: ITPJUI:WIN - Source for binaries doesn't work for anonymous
-inner classes
-<br> 1GD79XM: ITPJCORE:WINNT - Search - search for field references
-- not all found
-<br> 1GLA60W: ITPJCORE:WINNT - CodeAssist - should not propose declarations
-of method already locally implemented
-<br> 1GLAEZB: ITPJCORE:WINNT - CodeAssist does not disambiguate method
-references
-<br> 1GL4F3J: ITPJCORE:WINNT - Completion on declaration should also
-provide thrown exceptions
-<br> 1GL11J6: ITPJCORE:WIN2000 - search: missing field references
-(nested types)
-<br> 1GL12XE: ITPJCORE:WIN2000 - search: missing field references
-in inner class
-<br> 1GL0X82: ITPJCORE:ALL - ClassCastException setting args on class
-file
-<br> 1GKAQJS: ITPJCORE:WIN2000 - search: incorrect results for nested
-types
-<br> 1GKZ8VZ: ITPJCORE:WINNT - Search - did not find references to
-member constructor
-<br> 1GKYS7Y: ITPJCORE:WINNT - Main not found
-<br> 1GELSDQ: ITPJUI:WINNT - JDOM: IType.createMethod does not insert
-nicely for inner types
-<br> 1GF67VL: ITPJUI:WIN98 - DCR - CodeCompletion - Code-assist for
-listener methods
-<br> 1GFK8YT: ITPJUI:ALL - Rename CU A.B.java to AB.java fails (NPE)
-<br> 1GD06J6: ITPJUI:WIN98 - Code assist should qualify fields if
-needed.
-<br> 1FZWGMG: ITPCOM:WIN98 - DCR - CodeAssist - code assist should
-provide method signature completions
-<br> 1GHVOQE: ITPJCORE:WINNT - Ambiguous completion in CodeAssist
-<br> 1G8DEAB: ITPJUI:WINNT - DCR: code assist super methods when
-defining method
-<br> 1GGNNDZ: ITPJCORE:WINNT - OpenOnSelection - non visible target
-is equivalent to no target
-<br> 1GE14NN: ITPJUI:WINNT - Unable to find/search for .class files
-<br> 1GJYFUO: ITPDUI:ALL - Evaluation hangs, evaluation thread is
-suspended
-<br> 1FWG453: ITPJCORE:WIN98 - OpenOnSelection - fails for default
-constructors
-<br> 1GDQD37: ITPJUI:WIN2000 - OpenOnSelection - Open on selection
-failure
-<br> 1GGZ2R7: ITPJUI:WIN2000 - Search for method refs failed
-<br> 1GKNXX6: ITPJCORE:WINNT - OpenOnSelection - no selection if
-targeting member type in default package
-<br> 1GE34EE: ITPJUI:WIN2000 - OpenOnSelection - initial selection
-wrong
-<br> 1GKEG73: ITPJCORE:WIN2000 - search (136): missing field declaration
-<br> 1GKB9YH: ITPJCORE:WIN2000 - search for field refs - incorrect
-results
-<br> 1GJL6EJ: ITPJCORE:WINNT - JavaConventions.validateClasspath:
-Compares against variable name
-<br> 1GDQEAS: ITPJUI:ALL - Indexer - delete unused indexes on Java
-core plug-in shutdown
-<br> 1GKM4M9: ITPJCORE:WINNT - DCR: code select should work on declarations
-<br> 1G2NZVT: ITPJUI:WIN2000 - DCR - OpenOnSelection - Code resolve
-doesn't work for declarations
-<h3>
-Problem Reports Closed</h3>
- 3223 Search from editor's context
-menu doesn't work (1GAJCD8)
-<br> 3433 search: missing field occurrecnces (1GKZ8J6)
-<br> 3176 JCK1.3a - STMT - Single declaration
-in try block (1GLDSH9)
-<br> 1GL0MN9: ITPJCORE:WIN2000 - search: not consistent results for
-nested types
-<br> 1GL9UMH: ITPJCORE:WIN2000 - search: missing type occurrences
-<br> 1GKYXK5: ITPJUI:WIN2000 - usability: parameter hints
-<br> 1GEV78E: ITPJUI:WIN2000 - Code assist: private superclass methods
-show up, but others don't
-<br> 1GDKKTS: ITPJUI:WINNT - CodeCompletion - import assist shows
-invisible types
-<br> 1G7317O: ITPJCORE:WIN2000 - DCR - CodeAssist - code assist shows
-invisible members
-<br> 1GKK930: ITPJCORE:WINNT - No code assist for Inner type
-<br> 1GIIDGX: ITPJUI:WINNT - open on type: does not work on some
-types
-<br> 1GKOFO6: ITPJCORE:WINNT - Internal error searching for class
-references
-<br> 1GK96A0: ITPJCORE:WINNT - NPE during search operation
-<br> 1GK9B5Q: ITPJCORE:WINNT - Class reference search broken
-<br> 1GBOFK5: ITPJUI:ALL - "References to" on methods in jars
-<br> 1GKECWC: ITPJCORE:WINNT - Organize Imports fails: Typerefs not
-complete
-<br> 1GKCH3N: ITPJCORE:WIN2000 - search: method refs - super call
-not found
-<br> 1GKB475: ITPJCORE:WINNT - StringIndexOutOfBoundsException on
-searchfor methods
-<br> 1GJL6V0: ITPJCORE:WINNT - JavaConventions.validateClasspath:
-IStatus usage
-<br> 1GKM1MU: ITPJCORE:WINNT - Classpath validation: Overlapping
-accepted
-<br> 1GJL7RS: ITPJCORE:WINNT - JavaConventions.validateClasspath:
-nested sourcefolders
-<br> 1GK9NB0: ITPJCORE:WIN2000 - Another core dump - sorry
-<br> 1GJYG33: ITPJUI:WIN2000 - Core dump in run time workbench in
-Search
-<br> 1GK9S59: ITPJUI:WIN2000 - Internal error when synchronizing
-<br> 1GL2TZY: ITPJUI:WIN2000 - Code Completion should only show visible
-items
-<br> 1GKRLZ4: ITPJCORE:WIN2000 - Compiler overzealous with commas
-<br> 1GF98R4: ITPJUI:WINNT - JM - why is a file A.B.java seen as
-a compilation unit?
-<br> 1G98XR7: ITPJCORE:WIN2000 - Feature Request for JavaDoc CodeAssist
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Eclipse SDK Build 0.202 - Spetember 27th, 2001
-<br>Project org.eclipse.jdt.core v_202
-<h2>
-What's new in this drop</h2>
-
-<ul>
-<li>
-New AST node for empty statements (org.eclipse.jdt.internal.compiler.ast.EmptyStatement)</li>
-
-<br> i.e. 2 more APIs on the AST visitor. Note: this was not
-an official API
-<li>
-ISourceElementRequestor notifies enter/exit initializers instead of just
-acceptInitializer. Note: this was not an official API</li>
-
-<li>
-Search in inner-classes now works. Indexes are recomputed automatically
-on start-up.</li>
-
-<li>
- Removed CodeAssist option for hungry mode (org.eclipse.jdt.core.codeComplete.entireWordReplacement)</li>
-
-<br> Client code can decide whether using inferred end position
-(hungry behavior) or original cursor location (insert behavior)
-<br> based on the keystroke (enter/insert?).
-<li>
- org.eclipse.jdt.core.search.IJavaSearchResultCollector now clearly
-states that</li>
-
-<br> the order of the search result is unspecified.</ul>
-
-<h2>
-Problem reports fixed</h2>
- 1GK2A45: ITPJCORE:WIN2000 - JCK 1.4 - possibly assigned variable
-after assignment expression when true
-<br> 1GK29Q8: ITPJCORE:WIN2000 - JCK 1.4 - possibly assigned value
-of a final instance variable after a constant boolean expression when false
-<br> 1G52F7P: ITPJCORE:WINNT - Search - finds bogus references to
-class
-<br> 1G4TNX1: ITPJCORE:WINNT - Search - No search anonymous results
-in inner classes
-<br> 1GHW0AZ: ITPJCORE:WINNT - JCK 1.4 - unreachable empty statements
-<br> 1GK2BLM: ITPJCORE:WIN2000 - JCK 1.4 - definitely assigned value
-after the boolean operator ? : when true
-<br> 1GKB28A: ITPJCORE:WIN2000 - Compiler accepts incorrect code
-<br> 1FL4T1Q: LFCOM:WINNT - JCK 1.4 - VerifyError due to an illegal
-jump
-<br> 1GK2B6D: ITPJCORE:WIN2000 - JCK 1.4 - definitely assigned value
-before the second operand of the boolean operator &&
-<br> 1GK2AOF: ITPJCORE:WIN2000 - JCK 1.4 - assigned variable before
-finally block after return statement
-<br> 1GK6WD3: ITPJCORE:WIN2000 - search:no fully qualified references
-are found
-<br> 1GK7231: ITPJCORE:WIN2000 - typos in comments
-<br> 1GK77HA: ITPJCORE:WINNT - Search - missing base type references
-<br> 1GJY2XN: ITPJUI:WIN2000 - rename type: error when with reference
-<br> 1GK1I2J: ITPJCORE:WIN2000 - Broken SourceEnd in ForStatement
-and WhileStatement
-<br> 1GK1HWY: ITPJCORE:WIN2000 - Broken sourceEnd in for Assignment
-and CompoundAssignment
-<br> 1GIIBC3: ITPJCORE:WINNT - search for method references - missing
-matches
-<br> 1GGNOTF: ITPJCORE:WINNT - Search doesn't find method referenced
-in anonymous inner class
-<br> 1GK1GJE: ITPJCORE:ALL - Search - StringOutBoundsException when
-searching references in JAR
-<h3>
-Problem Reports Closed</h3>
- 1GJY3KG: ITPJUI:WIN2000 - NPE in jdt.internal.core.ClassFileInfo
-<br> 1GK90H4: ITPJCORE:WIN2000 - search: missing package reference
-<br> 1GK8TXE: ITPJCORE:WIN2000 - search: missing field reference
-<br> 1GK7K17: ITPJCORE:WIN2000 - search: missing type reference
-<br> 1GKCJIL: ITPJCORE:WIN2000 - build exception in 135
-<br> 1GK6WP9: ITPJCORE:WIN2000 - seach: missing type reference
-<br> 1GJZSBE: ITPJCORE:WINNT - ArrayIndexOutOfBoundsException during
-rebuild
-<br> 1GK7E6S: ITPJCORE:WIN2000 - search: StringIndexOufOfBound
-<br> 1GIT857: ITPJCORE:WIN2000 - Performance - Ctrl+S triggers five
-parser runs
-<br> 1GEHCYL: ITPUI:WINNT - Minor: Colon at wrong place in build
-dialog
-<br> 1FLUBRR: JRIDE:WINNT - Problems: instantiating inner classes
-<br> 1FLUOJI: JRIDE:WINNT - Problems: vague error message with illegal
-constructor invocation
-<br> 1FLZUG5: JRIDE:WINNT - Problems: invalid expression as statement
-is not reported
-<br> 1FLZV4M: JRIDE:WINNT - Problems: invalid hexa literal number
-not reported
-<br> 1FLZYES: JRIDE:WINNT - Problems: the interface cannot define
-an initializer is not reported
-<br> 1FQVTI1: LFCOM:WINNT - Compiler - No implicit conversion should
-not generate aconstnull
-<br> 1FUZYXT: ITPJCORE:WINNT - JM - Source for Binaries issue
-<br> 1FX0LZ0: ITPCOM:ALL - Request for comments preceeding imports
-& package decls
-<br> 1FW8ENP: ITPJUI:WIN98 - JDOM - Deleting import statements from
-Outline obliterates intervening comments
-<br> 1G4PWC7: ITPJCORE:WINNT - Search - No matches with class files
-<br> 1G83ZKL: ITPJUI:WINNT - Compiler - unclear error message for
-a reserved word used as an identifier
-<br> 1GF5W1S: ITPJUI:WIN2000 - ClassCastException in LookupEnvironment
-<br> 1GKF01S: ITPJCORE:WINNT - Severe: internal error during search
-<br> 1GDVFRX: ITPJUI:WIN2000 - CodeCompletion - eats the following
-word
-<br> 1GF67JM: ITPJUI:WIN98 - CodeCompletion - Code-assist consumes
-next token
-<br> 1GCSHAC: ITPJCORE:Inconsistent codeassist behavior
-<br> 1GCNBTL: ITPJCORE:ALL - DCR - JM - Provide a way to read JavaCore
-default options from the plugin.xml file
-<br> 1GAJBOU: ITPJUI:WINNT - Code Assist shows matches after ()
-<br> 1FW8NV6: ITPJCORE:ALL - DCR - JM - Need API for compiler options
-<h1>
-Eclipse Platform Build Notes <br>
-Java Development Tooling Core</h1>
-Build 0.200 - September 13th, 2001
-<br>Project org.eclipse.jdt.core v_200
-<h2>
-What is new in this drop</h2>
-
-<ul>
-<li>
-JCK1.3a compliant.</li>
-
-<li>
-Added 2 new APIs on JavaConventions for classpath validation.</li>
-
-<ul>
-<li>
-IJavaModelStatus validateClasspath(IJavaProject project, IClasspathEntry[]
-classpath, IPath outputLocation)</li>
-
-<li>
-IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry
-entry, boolean checkSourceAttachment)</li>
-</ul>
-
-<li>
-Ant Eclipse compiler task added (org.eclipse.jdt.core.ant.Jdtcom)</li>
-
-<li>
-Assertions support enabled: by default the compiler is 1.3 compliant, but
-it can optionally be turned into source 1.4 mode cf. JavaCore options.</li>
-
-<li>
-More options are surfaced on JavaCore. See JavaCore.getDefaultOptions()
-for description.</li>
-
-<ul>
-<li>
-...internal...ConfigurableOption has disappeared.</li>
-
-<li>
-Evaluation in binaries is functional</li>
-</ul>
-
-<li>
-Search for references now finds results in binaries. Indexes in old workspaces
-are recomputed when restarted which may result in longer startup times.</li>
-</ul>
+<p><hr>
+For earlier build notes, also see <a href="http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.jdt.core/notes/R20_buildnotes_jdt-core.html">build notes up to Release 2.0</a>.
-<h2>
-Problem Reports Fixed</h2>
-1GEKKUO: ITPJCORE:ALL - JM - Util.readContentsAsBytes(InputStream) doesn't
-allow for size hint
-<br>1GBRPSJ: ITPJCORE:Options - should surface the code formatter options
-on JavaCore
-<br>1GJU3YV: ITPJCORE:ALL - ArrayIndexOutOfBoundsException in scanner
-<br>1GJL1R5: ITPJCORE:ALL - NPE in ClassFile.getSourceRange
-<br>1GH49XR: ITPJUI:WIN2000 - Organize Imports inserts bogus import
-<br>1GJU3O8: ITPJCORE:WINNT - type hierarchy: NPE
-<br>1GJIYKP: ITPJCORE:WINNT - type hierarchy - contains unrelated types
-<br>1GITFQR: IVJIDT:WIN2000 - Wrong byte code generation, Inconsistent
-stack height 1 != 0 error
-<br>1GIHUQP: ITPJCORE:WINNT - search for static field should be more accurate
-<br>1GIT66X: ITPJCORE:WINNT - ClassCastException when calling CodeAssist
-<br>1GJA0WG: ITPJCORE:WINNT - AbortCompilationUnit when doing a Search
-<br>1GH49HW: ITPJUI:WINNT - Search functionality is misleading when viewing
-source from jar
-<br>1GFXPE5: ITPJUI:ALL - Search for method references broken
-<br>1GFM3X3: ITPJUI:WINNT - Wrong code formatter default for keeping else
-on same line
-<br>1GHSM7B: ITPJUI:ALL - formatting of anonymous classes
-<br>1GGPVHN: ITPJUI:WIN2000 - Not getting hover Javadoc for ISelection
-<br>1GE2LO2: ITPJCORE:WIN2000 - SourceStart and SourceEnd of synchronized
-statement
-<br>1GIUTIZ: ITPJCORE:WIN2000 - AST: case statement doesn't cover case
-keyword
-<br>1GITCCY: ITPJCORE:WIN2000 - AST: strange LocalDeclaration.declarationSourceEnd
-<br>1GIRQFW: ITPJCORE:WIN2000 - AST: wrong source end if subnode is of
-type AnnonymousTypeDeclaration
-<br>1GIRHRP: ITPJCORE:WIN2000 - AST: wrong sourceStart and sourceEnd in
-SynchronizedStatement
-<br>1GHUAUO: ITPJCORE:ALL - Renaming an element in a working copy corrupts
-the working copy
-<br>1GHUAM1: ITPJCORE:ALL - NPE when renaming an element in a working copy
-<br>1GHDA2V: ITPJCORE:WINNT - ClassCastException when doing a search
-<br>1GFY02B: ITPJUI:ALL - Delete a method and saving introduces extra lines
-<br>1GFOFMD: ITPJUI:WIN2000 - New class should have space between package
-and class decls
-<br>1GI3R1I: ITPJCORE:WIN2000 - Compilation error evaluating super expression
-in debugger
-<br>1GII07V: ITPJCORE:WIN2000 - CompilationUnitDeclaration.traverse doesn't
-call visitor.endVisit
-<br>1GIR345: ITPJCORE:ALL - Indexer: NegativeArraySizeException
-<br>1GIRC23: ITPJCORE:ALL - CodeFormatter brace on new line problem
-<br>1GIT8SA: ITPJCORE:WIN2000 - AST: wrong sourceEnd if action is Block
-<br>1GIUQVL: ITPJCORE:WINNT - IClassPathEntry: java doc incorrect
-<br>1GIVGMH: ITPJUI:ALL - EC: Javadoc hoverhelp incorrectly uses first
-of multiple comments
-<br>1GIYKSR: ITPJCORE:WIN2000 - Ast: FieldDeclaration.traverse implemeted
-differently
-<br>1GI3ND5: ITPJCORE:WINNT - Potential optimization during IB problem
-generation
-<br>1GFBVZH: ITPUI:WIN2000 - ArrayIndexOutOfBoundsException: Java editor
-<br>1GI509E: ITPJCORE:WINNT - IJavaProject.getNonJavaResources returns
-java and class files
-<br>1GI2WAW: ITPJCORE:WINNT - Too many results for default package
-<br>1GHQZ9H: ITPJUI:ALL - Walkback doing a search
-<br>1GGYT3S: ITPJCORE:WINNT - javaconventions::validatePackageName and
-default package
-<br>1GF9856: ITPJCORE:WINNT - JM - JavaConventions::validateCompilationUnitName
-<br>1GF822P: ITPJCORE:WIN2000 - NegativeArraySizeException in Parser
-<br>1GI6T4Y: ITPJCORE:WINNT - NPE in JavaModeManager retrieving workspace
-options
-<br>1GE4ILR: ITPJCORE:ALL - Eval - Evaluation in Binary Project fails
-<br>1GI3LLC: ITPJCORE:ALL - Incorrect formatting for the new keyword
-<br>1GHU6O5: ITPJCORE:WINNT - RMIC test fail
-<br>1GHH6O7: ITPJCORE:ALL - Need to tune the exception analysis for AssertStatement
-<br>1GHUW7T: ITPJCORE:WIN2000 - Build Problem
-<br>1GI3IG9: ITPJCORE:ALL - internal compiler error involving bogus method/field
-declaration
-<br>1GHU4PK: ITPJCORE:WINNT - NoSuchMethodError when running program
-<br>1GHONAX: ITPJCORE:WIN2000 - Compiler uses different name lookup for
-refactoring
-<br>1GEJYAJ: ITPJCORE:WIN2000 - Compiler - Binding of QualifiedNameReference
-is null
-<br>1GHFHWR: ITPJCORE:ALL - Assertions: CodeAssist and Selection need to
-be updated
-<br>1GHFHXG: ITPJCORE:ALL - Assertions: Add optional warning on assert
-identifier
-<br>1GCZ9VM: ITPJCORE:WIN2000 - DCR - Compiler - Batch compiler should
-be API
-<br>1GHO6QR: ITPJCORE:WINNT - Code Assist - no method completion when return
-type is secondary one
-<br>1GH0AU7: ITPJCORE:ALL - Eval - VerifyError in scrapbook page
-<br>1GH2R62: ITPJCORE:WIN2000 - Typo in progress message
-<br>1GGYL32: ITPJCORE:ALL - Default supertypes are not visible when qualified
-<br>1GDFJK0: IVJIDT:WIN2000 - Using 'synchronized' produces invalid exception
-table values in class, causes "Illegal exception table range" exception,
-VAJ 3.5+
-<br>1GGAK6G: ITPJCORE:ALL - Incorrect javadoc comment in JavaElement
-<br>1GF9L3K: ITPDUI:ALL - Eval - Private array resolution failure
-<br>1GF8KHX: ITPJUI:ALL - Invalid project build path should be warning,
-not error
-<br>1GF7JIH: ITPJCORE:ALL - Exception when removing network drive
-<br>1GEYBL9: ITPJUI:WINNT - Adding source folders on CP is very confusing
-<br>1GEJAOT: ITPJUI:WINNT - JRE Source attachment set to path to does not
-exist
-<br>1GEHZNB: ITPJUI:WINNT - smoke 114: formatter inserts extra tab in first
-line
-<br>1GCZZT4: ITPJCORE:Fault-tolerance - missing constructor invocation
-could still answer the allocated type
-<br>1GAU96P: ITPJCORE:WINNT - DCR - JM - JavaProject should provide a class
-path validation method
-<br>1G7A1TL: ITPJCORE:WINNT - DCR - JM - Rules for classpath not specified
-<br>1FVVWZT: ITPJCORE:ALL - JM - IBinaryType should implement getSourceFileName()
<br>
</body>
</html>
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
index 7cf1210..a85bd9c 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
@@ -1,38 +1,45 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist;
-import java.util.*;
+import java.util.Locale;
+import java.util.Map;
-import org.eclipse.jdt.core.compiler.InvalidInputException;
-import org.eclipse.jdt.internal.compiler.*;
-import org.eclipse.jdt.internal.compiler.env.*;
-
-import org.eclipse.jdt.internal.codeassist.impl.*;
import org.eclipse.jdt.core.ICompletionRequestor;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.codeassist.complete.*;
+import org.eclipse.jdt.internal.codeassist.complete.*;
+import org.eclipse.jdt.internal.codeassist.impl.AssistParser;
+import org.eclipse.jdt.internal.codeassist.impl.Engine;
+import org.eclipse.jdt.internal.codeassist.impl.Keywords;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.env.*;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.parser.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
+import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
+import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
+import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
+import org.eclipse.jdt.internal.compiler.util.ObjectVector;
+import org.eclipse.jdt.internal.core.*;
import org.eclipse.jdt.internal.core.BasicCompilationUnit;
import org.eclipse.jdt.internal.core.TypeConverter;
-import org.eclipse.jdt.internal.compiler.impl.*;
/**
* This class is the entry point for source completions.
@@ -41,19 +48,32 @@
*/
public final class CompletionEngine
extends Engine
- implements ISearchRequestor, TypeConstants , ITerminalSymbols , RelevanceConstants {
+ implements ISearchRequestor, TypeConstants , TerminalTokens , RelevanceConstants {
public static boolean DEBUG = false;
private final static char[] ERROR_PATTERN = "*error*".toCharArray(); //$NON-NLS-1$
private final static char[] EXCEPTION_PATTERN = "*exception*".toCharArray(); //$NON-NLS-1$
private final static char[] SEMICOLON = new char[] { ';' };
- TypeBinding[] expectedTypes;
+
+ private final static int SUPERTYPE = 1;
+ private final static int SUBTYPE = 2;
+
+ private final static int FIELD = 0;
+ private final static int LOCAL = 1;
+ private final static int ARGUMENT = 2;
+
+ int expectedTypesPtr = -1;
+ TypeBinding[] expectedTypes = new TypeBinding[1];
+ int expectedTypesFilter;
+ int uninterestingBindingsPtr = -1;
+ Binding[] uninterestingBindings = new Binding[1];
boolean assistNodeIsClass;
boolean assistNodeIsException;
boolean assistNodeIsInterface;
+ IJavaProject javaProject;
CompletionParser parser;
ICompletionRequestor requestor;
ProblemReporter problemReporter;
@@ -61,6 +81,8 @@
char[] token;
boolean resolvingImports = false;
boolean insideQualifiedReference = false;
+ boolean noProposal = true;
+ IProblem problem = null;
int startPosition, actualCompletionPosition, endPosition, offset;
HashtableOfObject knownPkgs = new HashtableOfObject(10);
HashtableOfObject knownTypes = new HashtableOfObject(10);
@@ -136,9 +158,11 @@
public CompletionEngine(
ISearchableNameEnvironment nameEnvironment,
ICompletionRequestor requestor,
- Map settings) {
+ Map settings,
+ IJavaProject javaProject) {
super(settings);
+ this.javaProject = javaProject;
this.requestor = requestor;
this.nameEnvironment = nameEnvironment;
@@ -146,18 +170,53 @@
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
this.compilerOptions,
new DefaultProblemFactory(Locale.getDefault()) {
- public void record(IProblem problem, CompilationResult unitResult, ReferenceContext referenceContext) {
- if (problem.isError() && (problem.getID() & IProblem.Syntax) != 0) {
- CompletionEngine.this.requestor.acceptError(problem);
+ int lastErrorStart;
+
+ public IProblem createProblem(
+ char[] originatingFileName,
+ int problemId,
+ String[] problemArguments,
+ String[] messageArguments,
+ int severity,
+ int startPosition,
+ int endPosition,
+ int lineNumber) {
+
+ IProblem problem = super.createProblem(
+ originatingFileName,
+ problemId,
+ problemArguments,
+ messageArguments,
+ severity,
+ startPosition,
+ endPosition,
+ lineNumber);
+
+ if(actualCompletionPosition > startPosition
+ && lastErrorStart < startPosition
+ && problem.isError()
+ && (problem.getID() & IProblem.Syntax) == 0) {
+
+ CompletionEngine.this.problem = problem;
+ lastErrorStart = startPosition;
}
+
+ return problem;
}
+
});
this.parser =
- new CompletionParser(problemReporter, this.compilerOptions.assertMode);
+ new CompletionParser(problemReporter, this.compilerOptions.sourceLevel >= CompilerOptions.JDK1_4);
this.lookupEnvironment =
new LookupEnvironment(this, this.compilerOptions, problemReporter, nameEnvironment);
this.nameScanner =
- new Scanner(false, false, false, this.compilerOptions.assertMode);
+ new Scanner(
+ false /*comment*/,
+ false /*whitespace*/,
+ false /*nls*/,
+ this.compilerOptions.sourceLevel >= CompilerOptions.JDK1_4 /*assert*/,
+ null /*taskTags*/,
+ null/*taskPriorities*/);
}
/**
@@ -177,7 +236,9 @@
this.knownTypes.put(completionName, this);
- int relevance = R_DEFAULT;
+ boolean isQualified = true;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
if (resolvingImports) {
completionName = CharOperation.concat(completionName, SEMICOLON);
relevance += computeRelevanceForCaseMatching(token, fullyQualifiedName);
@@ -185,18 +246,21 @@
if (!insideQualifiedReference) {
if (mustQualifyType(packageName, className)) {
if (packageName == null || packageName.length == 0)
- if (unitScope != null && unitScope.fPackage.compoundName != NoCharChar)
+ if (unitScope != null && unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
return; // ignore types from the default package from outside it
} else {
completionName = className;
+ isQualified = false;
}
}
relevance += computeRelevanceForCaseMatching(token, className);
relevance += computeRelevanceForExpectingType(packageName, className);
relevance += computeRelevanceForClass();
relevance += computeRelevanceForException(className);
+ relevance += computeRelevanceForQualification(isQualified);
}
+ noProposal = false;
requestor.acceptClass(
packageName,
className,
@@ -227,7 +291,9 @@
this.knownTypes.put(completionName, this);
- int relevance = R_DEFAULT;
+ boolean isQualified = true;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
if (resolvingImports) {
completionName = CharOperation.concat(completionName, new char[] { ';' });
relevance += computeRelevanceForCaseMatching(token, fullyQualifiedName);
@@ -235,17 +301,20 @@
if (!insideQualifiedReference) {
if (mustQualifyType(packageName, interfaceName)) {
if (packageName == null || packageName.length == 0)
- if (unitScope != null && unitScope.fPackage.compoundName != NoCharChar)
+ if (unitScope != null && unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
return; // ignore types from the default package from outside it
} else {
completionName = interfaceName;
+ isQualified = false;
}
}
relevance += computeRelevanceForCaseMatching(token, interfaceName);
relevance += computeRelevanceForExpectingType(packageName, interfaceName);
relevance += computeRelevanceForInterface();
+ relevance += computeRelevanceForQualification(isQualified);
}
+ noProposal = false;
requestor.acceptInterface(
packageName,
interfaceName,
@@ -269,9 +338,11 @@
this.knownPkgs.put(packageName, this);
- int relevance = R_DEFAULT;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
relevance += computeRelevanceForCaseMatching(token, packageName);
+ noProposal = false;
requestor.acceptPackage(
packageName,
resolvingImports
@@ -299,7 +370,9 @@
this.knownTypes.put(completionName, this);
- int relevance = R_DEFAULT;
+ boolean isQualified = true;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
if (resolvingImports) {
completionName = CharOperation.concat(completionName, new char[] { ';' });
relevance += computeRelevanceForCaseMatching(token, fullyQualifiedName);
@@ -307,16 +380,19 @@
if (!insideQualifiedReference) {
if (mustQualifyType(packageName, typeName)) {
if (packageName == null || packageName.length == 0)
- if (unitScope != null && unitScope.fPackage.compoundName != NoCharChar)
+ if (unitScope != null && unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
return; // ignore types from the default package from outside it
} else {
completionName = typeName;
+ isQualified = false;
}
}
relevance += computeRelevanceForCaseMatching(token, typeName);
relevance += computeRelevanceForExpectingType(packageName, typeName);
+ relevance += computeRelevanceForQualification(isQualified);
}
+ noProposal = false;
requestor.acceptType(
packageName,
typeName,
@@ -326,23 +402,24 @@
relevance);
}
- private void complete(AstNode astNode, Binding qualifiedBinding, Scope scope) {
+ private void complete(AstNode astNode, AstNode astNodeParent, Binding qualifiedBinding, Scope scope) {
setSourceRange(astNode.sourceStart, astNode.sourceEnd);
- if(parser.assistNodeParent != null) {
- computeExpectedTypes(parser.assistNodeParent, scope);
+ computeUninterestingBindings(astNodeParent, scope);
+ if(astNodeParent != null) {
+ computeExpectedTypes(astNodeParent, scope);
}
-
- // defaults... some nodes will change these
+
if (astNode instanceof CompletionOnFieldType) {
CompletionOnFieldType field = (CompletionOnFieldType) astNode;
CompletionOnSingleTypeReference type = (CompletionOnSingleTypeReference) field.type;
token = type.token;
setSourceRange(type.sourceStart, type.sourceEnd);
- // findKeywords(token, modifiers, scope); // could be the start of a field, method or member type
+
findTypesAndPackages(token, scope);
+ findKeywordsForMember(token, field.modifiers);
if(!field.isLocalVariable && field.modifiers == CompilerModifiers.AccDefault) {
findMethods(token,null,scope.enclosingSourceType(),scope,new ObjectVector(),false,false,true,null,null,false);
@@ -355,15 +432,16 @@
token = type.token;
setSourceRange(type.sourceStart, type.sourceEnd);
findTypesAndPackages(token, scope);
-
+ findKeywordsForMember(token, method.modifiers);
+
if(method.modifiers == CompilerModifiers.AccDefault) {
findMethods(token,null,scope.enclosingSourceType(),scope,new ObjectVector(),false,false,true,null,null,false);
}
} else {
if (astNode instanceof CompletionOnSingleNameReference) {
-
- token = ((CompletionOnSingleNameReference) astNode).token;
+ CompletionOnSingleNameReference singleNameReference = (CompletionOnSingleNameReference) astNode;
+ token = singleNameReference.token;
findVariablesAndMethods(
token,
scope,
@@ -371,7 +449,16 @@
scope);
// can be the start of a qualified type name
findTypesAndPackages(token, scope);
-
+ findKeywords(token, singleNameReference.possibleKeywords);
+ if(singleNameReference.canBeExplicitConstructor){
+ if(CharOperation.prefixEquals(token, Keywords.THIS, false)) {
+ ReferenceBinding ref = scope.enclosingSourceType();
+ findExplicitConstructors(Keywords.THIS, ref, (MethodScope)scope, singleNameReference);
+ } else if(CharOperation.prefixEquals(token, Keywords.SUPER, false)) {
+ ReferenceBinding ref = scope.enclosingSourceType();
+ findExplicitConstructors(Keywords.SUPER, ref.superclass(), (MethodScope)scope, singleNameReference);
+ }
+ }
} else {
if (astNode instanceof CompletionOnSingleTypeReference) {
@@ -420,6 +507,12 @@
findMemberTypes(token, receiverType, scope, scope.enclosingSourceType());
findClassField(token, (TypeBinding) qualifiedBinding, scope);
+
+ MethodScope methodScope = null;
+ if((scope instanceof MethodScope && !((MethodScope)scope).isStatic)
+ || ((methodScope = scope.enclosingMethodScope()) != null && !methodScope.isStatic)) {
+ findKeywords(token, new char[][]{Keywords.THIS});
+ }
findFields(
token,
@@ -494,13 +587,15 @@
} else {
if (astNode instanceof CompletionOnMemberAccess) {
-
+ insideQualifiedReference = true;
CompletionOnMemberAccess access = (CompletionOnMemberAccess) astNode;
long completionPosition = access.nameSourcePosition;
setSourceRange((int) (completionPosition >>> 32), (int) completionPosition);
token = access.token;
-
+
+ findKeywords(token, new char[][]{Keywords.NEW});
+
findFieldsAndMethods(
token,
(TypeBinding) qualifiedBinding,
@@ -512,7 +607,8 @@
} else {
if (astNode instanceof CompletionOnMessageSend) {
-
+ setSourceRange(astNode.sourceStart, astNode.sourceEnd, false);
+
CompletionOnMessageSend messageSend = (CompletionOnMessageSend) astNode;
TypeBinding[] argTypes =
computeTypes(messageSend.arguments, (BlockScope) scope);
@@ -539,7 +635,8 @@
} else {
if (astNode instanceof CompletionOnExplicitConstructorCall) {
-
+ setSourceRange(astNode.sourceStart, astNode.sourceEnd, false);
+
CompletionOnExplicitConstructorCall constructorCall =
(CompletionOnExplicitConstructorCall) astNode;
TypeBinding[] argTypes =
@@ -554,7 +651,8 @@
} else {
if (astNode instanceof CompletionOnQualifiedAllocationExpression) {
-
+ setSourceRange(astNode.sourceStart, astNode.sourceEnd, false);
+
CompletionOnQualifiedAllocationExpression allocExpression =
(CompletionOnQualifiedAllocationExpression) astNode;
TypeBinding[] argTypes =
@@ -602,7 +700,7 @@
token = method.selector;
- findVariableNames(token, method.returnType, excludeNames);
+ findVariableNames(token, method.returnType, excludeNames, FIELD, method.modifiers);
} else {
if (astNode instanceof CompletionOnFieldName) {
CompletionOnFieldName field = (CompletionOnFieldName) astNode;
@@ -615,7 +713,7 @@
token = field.realName;
- findVariableNames(field.realName, field.type, excludeNames);
+ findVariableNames(field.realName, field.type, excludeNames, FIELD, field.modifiers);
} else {
if (astNode instanceof CompletionOnLocalName ||
astNode instanceof CompletionOnArgumentName){
@@ -633,10 +731,17 @@
if(variable instanceof CompletionOnLocalName){
token = ((CompletionOnLocalName) variable).realName;
+ findVariableNames(token, variable.type, excludeNames, LOCAL, variable.modifiers);
} else {
- token = ((CompletionOnArgumentName) variable).realName;
+ CompletionOnArgumentName arg = (CompletionOnArgumentName) variable;
+ token = arg.realName;
+ findVariableNames(token, variable.type, excludeNames, arg.isCatchArgument ? LOCAL : ARGUMENT, variable.modifiers);
}
- findVariableNames(token, variable.type, excludeNames);
+ } else {
+ if(astNode instanceof CompletionOnKeyword) {
+ CompletionOnKeyword keyword = (CompletionOnKeyword)astNode;
+ findKeywords(keyword.getToken(), keyword.getPossibleKeywords());
+ }
}
}
}
@@ -654,8 +759,7 @@
}
public void complete(IType type, char[] snippet, int position, char[][] localVariableTypeNames, char[][] localVariableNames, int[] localVariableModifiers, boolean isStatic){
- TypeConverter converter = new TypeConverter();
-
+
IType topLevelType = type;
while(topLevelType.getDeclaringType() != null) {
topLevelType = topLevelType.getDeclaringType();
@@ -666,7 +770,7 @@
CompilationUnitDeclaration compilationUnit = new CompilationUnitDeclaration(problemReporter, compilationResult, 0);
try {
- TypeDeclaration typeDeclaration = converter.buildTypeDeclaration(type, compilationUnit, compilationResult, problemReporter);
+ TypeDeclaration typeDeclaration = TypeConverter.buildTypeDeclaration(type, compilationUnit, compilationResult);
if(typeDeclaration != null) {
// build AST from snippet
@@ -697,10 +801,13 @@
// completionNodeFound = true;
if (e.astNode != null) {
// if null then we found a problem in the completion node
- complete(e.astNode, e.qualifiedBinding, e.scope);
+ complete(e.astNode, parser.assistNodeParent, e.qualifiedBinding, e.scope);
}
}
}
+ if(noProposal && problem != null) {
+ requestor.acceptError(problem);
+ }
}
} catch(JavaModelException e) {
// Do nothing
@@ -726,7 +833,7 @@
char[] fakeSource = CharOperation.concat(prefix.toString().toCharArray(), snippet, "}}".toCharArray());//$NON-NLS-1$
offset = prefix.length();
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
+ String encoding = this.compilerOptions.defaultEncoding;
BasicCompilationUnit fakeUnit = new BasicCompilationUnit(
fakeSource,
null,
@@ -784,6 +891,9 @@
// scan the package & import statements first
if (parsedUnit.currentPackage instanceof CompletionOnPackageReference) {
findPackages((CompletionOnPackageReference) parsedUnit.currentPackage);
+ if(noProposal && problem != null) {
+ requestor.acceptError(problem);
+ }
return;
}
@@ -793,6 +903,17 @@
ImportReference importReference = imports[i];
if (importReference instanceof CompletionOnImportReference) {
findImports((CompletionOnImportReference) importReference);
+ if(noProposal && problem != null) {
+ requestor.acceptError(problem);
+ }
+ return;
+ } else if(importReference instanceof CompletionOnKeyword) {
+ setSourceRange(importReference.sourceStart, importReference.sourceEnd);
+ CompletionOnKeyword keyword = (CompletionOnKeyword)importReference;
+ findKeywords(keyword.getToken(), keyword.getPossibleKeywords());
+ if(noProposal && problem != null) {
+ requestor.acceptError(problem);
+ }
return;
}
}
@@ -819,14 +940,20 @@
if(DEBUG) {
System.out.print("COMPLETION - Completion node : "); //$NON-NLS-1$
System.out.println(e.astNode.toString());
+ if(parser.assistNodeParent != null) {
+ System.out.print("COMPLETION - Parent Node : "); //$NON-NLS-1$
+ System.out.println(parser.assistNodeParent);
+ }
}
// if null then we found a problem in the completion node
- complete(e.astNode, e.qualifiedBinding, e.scope);
+ complete(e.astNode, parser.assistNodeParent, e.qualifiedBinding, e.scope);
}
}
}
}
-
+ if(noProposal && problem != null) {
+ requestor.acceptError(problem);
+ }
/* Ignore package, import, class & interface keywords for now...
if (!completionNodeFound) {
if (parsedUnit == null || parsedUnit.types == null) {
@@ -855,7 +982,7 @@
int argsLength = arguments.length;
TypeBinding[] argTypes = new TypeBinding[argsLength];
for (int a = argsLength; --a >= 0;)
- argTypes[a] = arguments[a].resolveType(scope);
+ argTypes[a] = arguments[a].resolvedType;
return argTypes;
}
@@ -866,24 +993,27 @@
InvocationSite invocationSite) {
if (currentType.isInterface()) {
- char[] completion = TypeConstants.NoChar;
+ char[] completion = CharOperation.NO_CHAR;
// nothing to insert - do not want to replace the existing selector & arguments
if (source == null
|| source.length <= endPosition
|| source[endPosition] != ')')
completion = new char[] { ')' };
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
+ noProposal = false;
requestor.acceptAnonymousType(
currentType.qualifiedPackageName(),
currentType.qualifiedSourceName(),
- TypeConstants.NoCharChar,
- TypeConstants.NoCharChar,
- TypeConstants.NoCharChar,
+ CharOperation.NO_CHAR_CHAR,
+ CharOperation.NO_CHAR_CHAR,
+ CharOperation.NO_CHAR_CHAR,
completion,
IConstants.AccPublic,
endPosition - offset,
endPosition - offset,
- R_DEFAULT);
+ relevance);
} else {
findConstructors(
currentType,
@@ -902,16 +1032,18 @@
if (token.length <= classField.length
&& CharOperation.prefixEquals(token, classField, false /* ignore case */
)) {
- int relevance = R_DEFAULT;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
relevance += computeRelevanceForCaseMatching(token, classField);
relevance += computeRelevanceForExpectingType(scope.getJavaLangClass());
-
+
+ noProposal = false;
requestor.acceptField(
- NoChar,
- NoChar,
+ CharOperation.NO_CHAR,
+ CharOperation.NO_CHAR,
classField,
- NoChar,
- NoChar,
+ CharOperation.NO_CHAR,
+ CharOperation.NO_CHAR,
classField,
CompilerModifiers.AccStatic | CompilerModifiers.AccPublic,
startPosition - offset,
@@ -920,6 +1052,70 @@
}
}
+ private void findExplicitConstructors(
+ char[] name,
+ ReferenceBinding currentType,
+ MethodScope scope,
+ InvocationSite invocationSite) {
+
+ ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration)scope.referenceContext;
+ MethodBinding enclosingConstructor = constructorDeclaration.binding;
+
+ // No visibility checks can be performed without the scope & invocationSite
+ MethodBinding[] methods = currentType.availableMethods();
+ if(methods != null) {
+ next : for (int f = methods.length; --f >= 0;) {
+ MethodBinding constructor = methods[f];
+ if (constructor != enclosingConstructor && constructor.isConstructor()) {
+
+ if (constructor.isSynthetic()) continue next;
+
+ if (options.checkVisibility
+ && !constructor.canBeSeenBy(invocationSite, scope)) continue next;
+
+ TypeBinding[] parameters = constructor.parameters;
+ int paramLength = parameters.length;
+
+ char[][] parameterPackageNames = new char[paramLength][];
+ char[][] parameterTypeNames = new char[paramLength][];
+ for (int i = 0; i < paramLength; i++) {
+ TypeBinding type = parameters[i];
+ parameterPackageNames[i] = type.qualifiedPackageName();
+ parameterTypeNames[i] = type.qualifiedSourceName();
+ }
+ char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames);
+
+ char[] completion = CharOperation.NO_CHAR;
+ if (source != null
+ && source.length > endPosition
+ && source[endPosition] == '(')
+ completion = name;
+ else
+ completion = CharOperation.concat(name, new char[] { '(', ')' });
+
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
+ relevance += computeRelevanceForCaseMatching(token, name);
+
+ noProposal = false;
+ requestor.acceptMethod(
+ currentType.qualifiedPackageName(),
+ currentType.qualifiedSourceName(),
+ name,
+ parameterPackageNames,
+ parameterTypeNames,
+ parameterNames,
+ CharOperation.NO_CHAR,
+ CharOperation.NO_CHAR,
+ completion,
+ constructor.modifiers,
+ startPosition - offset,
+ endPosition - offset,
+ relevance);
+ }
+ }
+ }
+ }
private void findConstructors(
ReferenceBinding currentType,
TypeBinding[] argTypes,
@@ -938,7 +1134,10 @@
if (constructor.isSynthetic()) continue next;
if (options.checkVisibility
- && !constructor.canBeSeenBy(invocationSite, scope)) continue next;
+ && !constructor.canBeSeenBy(invocationSite, scope)) {
+ if(!forAnonymousType || !constructor.isProtected())
+ continue next;
+ }
TypeBinding[] parameters = constructor.parameters;
int paramLength = parameters.length;
@@ -946,7 +1145,7 @@
continue next;
for (int a = minArgLength; --a >= 0;)
if (argTypes[a] != null) // can be null if it could not be resolved properly
- if (!scope.areTypesCompatible(argTypes[a], constructor.parameters[a]))
+ if (!argTypes[a].isCompatibleWith(constructor.parameters[a]))
continue next;
char[][] parameterPackageNames = new char[paramLength][];
@@ -958,7 +1157,7 @@
}
char[][] parameterNames = findMethodParameterNames(constructor,parameterTypeNames);
- char[] completion = TypeConstants.NoChar;
+ char[] completion = CharOperation.NO_CHAR;
// nothing to insert - do not want to replace the existing selector & arguments
if (source == null
|| source.length <= endPosition
@@ -966,6 +1165,10 @@
completion = new char[] { ')' };
if(forAnonymousType){
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
+
+ noProposal = false;
requestor.acceptAnonymousType(
currentType.qualifiedPackageName(),
currentType.qualifiedSourceName(),
@@ -976,8 +1179,12 @@
constructor.modifiers,
endPosition - offset,
endPosition - offset,
- R_DEFAULT);
+ relevance);
} else {
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
+
+ noProposal = false;
requestor.acceptMethod(
currentType.qualifiedPackageName(),
currentType.qualifiedSourceName(),
@@ -985,13 +1192,13 @@
parameterPackageNames,
parameterTypeNames,
parameterNames,
- TypeConstants.NoChar,
- TypeConstants.NoChar,
+ CharOperation.NO_CHAR,
+ CharOperation.NO_CHAR,
completion,
constructor.modifiers,
endPosition - offset,
endPosition - offset,
- R_DEFAULT);
+ relevance);
}
}
}
@@ -1040,9 +1247,12 @@
if (CharOperation.equals(field.name, otherField.name, true)) {
if (field.declaringClass.isSuperclassOf(otherField.declaringClass))
continue next;
- if (otherField.declaringClass.isInterface())
+ if (otherField.declaringClass.isInterface()) {
+ if (field.declaringClass == scope.getJavaLangObject())
+ continue next;
if (field.declaringClass.implementsInterface(otherField.declaringClass, true))
continue next;
+ }
if (field.declaringClass.isInterface())
if (otherField.declaringClass.implementsInterface(field.declaringClass, true))
continue next;
@@ -1072,10 +1282,14 @@
completion = CharOperation.concat(prefix,completion,'.');
}
- int relevance = R_DEFAULT;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal(field);
relevance += computeRelevanceForCaseMatching(fieldName, field.name);
relevance += computeRelevanceForExpectingType(field.type);
+ relevance += computeRelevanceForStatic(onlyStaticFields, field.isStatic());
+ relevance += computeRelevanceForQualification(prefixRequired);
+ noProposal = false;
requestor
.acceptField(
field.declaringClass.qualifiedPackageName(),
@@ -1210,16 +1424,18 @@
&& CharOperation.prefixEquals(token, lengthField, false /* ignore case */
)) {
- int relevance = R_DEFAULT;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
relevance += computeRelevanceForCaseMatching(token,lengthField);
relevance += computeRelevanceForExpectingType(BaseTypes.IntBinding);
+ noProposal = false;
requestor.acceptField(
- NoChar,
- NoChar,
+ CharOperation.NO_CHAR,
+ CharOperation.NO_CHAR,
lengthField,
- NoChar,
- NoChar,
+ CharOperation.NO_CHAR,
+ CharOperation.NO_CHAR,
lengthField,
CompilerModifiers.AccPublic,
startPosition - offset,
@@ -1279,20 +1495,113 @@
// what about onDemand types? Ignore them since it does not happen!
// import p1.p2.A.*;
- private void findKeywords(char[] keyword, char[][] choices, Scope scope) {
-
+ private void findKeywords(char[] keyword, char[][] choices) {
+ if(choices == null || choices.length == 0) return;
+
int length = keyword.length;
if (length > 0)
for (int i = 0; i < choices.length; i++)
if (length <= choices[i].length
&& CharOperation.prefixEquals(keyword, choices[i], false /* ignore case */
)){
- int relevance = R_DEFAULT;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
relevance += computeRelevanceForCaseMatching(keyword, choices[i]);
+ noProposal = false;
requestor.acceptKeyword(choices[i], startPosition - offset, endPosition - offset,relevance);
}
}
+
+ private void findKeywordsForMember(char[] token, int modifiers) {
+ char[][] keywords = new char[Keywords.COUNT][];
+ int count = 0;
+
+ // visibility
+ if((modifiers & CompilerModifiers.AccPrivate) == 0
+ && (modifiers & CompilerModifiers.AccProtected) == 0
+ && (modifiers & CompilerModifiers.AccPublic) == 0) {
+ keywords[count++] = Keywords.PROTECTED;
+ keywords[count++] = Keywords.PUBLIC;
+ if((modifiers & CompilerModifiers.AccAbstract) == 0) {
+ keywords[count++] = Keywords.PRIVATE;
+ }
+ }
+
+ if((modifiers & CompilerModifiers.AccAbstract) == 0) {
+ // abtract
+ if((modifiers & ~(CompilerModifiers.AccVisibilityMASK | CompilerModifiers.AccStatic)) == 0) {
+ keywords[count++] = Keywords.ABSTARCT;
+ }
+
+ // final
+ if((modifiers & CompilerModifiers.AccFinal) == 0) {
+ keywords[count++] = Keywords.FINAL;
+ }
+
+ // static
+ if((modifiers & CompilerModifiers.AccStatic) == 0) {
+ keywords[count++] = Keywords.STATIC;
+ }
+
+ boolean canBeField = true;
+ boolean canBeMethod = true;
+ boolean canBeType = true;
+ if((modifiers & CompilerModifiers.AccNative) != 0
+ || (modifiers & CompilerModifiers.AccStrictfp) != 0
+ || (modifiers & CompilerModifiers.AccSynchronized) != 0) {
+ canBeField = false;
+ canBeType = false;
+ }
+
+ if((modifiers & CompilerModifiers.AccTransient) != 0
+ || (modifiers & CompilerModifiers.AccVolatile) != 0) {
+ canBeMethod = false;
+ canBeType = false;
+ }
+
+ if(canBeField) {
+ // transient
+ if((modifiers & CompilerModifiers.AccTransient) == 0) {
+ keywords[count++] = Keywords.TRANSIENT;
+ }
+
+ // volatile
+ if((modifiers & CompilerModifiers.AccVolatile) == 0) {
+ keywords[count++] = Keywords.VOLATILE;
+ }
+ }
+
+ if(canBeMethod) {
+ // native
+ if((modifiers & CompilerModifiers.AccNative) == 0) {
+ keywords[count++] = Keywords.NATIVE;
+ }
+
+ // strictfp
+ if((modifiers & CompilerModifiers.AccStrictfp) == 0) {
+ keywords[count++] = Keywords.STRICTFP;
+ }
+
+ // synchronized
+ if((modifiers & CompilerModifiers.AccSynchronized) == 0) {
+ keywords[count++] = Keywords.SYNCHRONIZED;
+ }
+ }
+
+ if(canBeType) {
+ keywords[count++] = Keywords.CLASS;
+ keywords[count++] = Keywords.INTERFACE;
+ }
+ } else {
+ // class
+ keywords[count++] = Keywords.CLASS;
+ keywords[count++] = Keywords.INTERFACE;
+ }
+ System.arraycopy(keywords, 0, keywords = new char[count][], 0, count);
+
+ findKeywords(token, keywords);
+ }
// Helper method for findMemberTypes(char[], ReferenceBinding, Scope)
private void findMemberTypes(
@@ -1346,12 +1655,16 @@
typesFound.add(memberType);
- int relevance = R_DEFAULT;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
relevance += computeRelevanceForCaseMatching(typeName, memberType.sourceName);
relevance += computeRelevanceForExpectingType(memberType);
if (memberType.isClass()) {
relevance += computeRelevanceForClass();
+ relevance += computeRelevanceForException(memberType.sourceName);
+
+ noProposal = false;
requestor.acceptClass(
memberType.qualifiedPackageName(),
memberType.qualifiedSourceName(),
@@ -1363,6 +1676,8 @@
} else {
relevance += computeRelevanceForInterface();
+
+ noProposal = false;
requestor.acceptInterface(
memberType.qualifiedPackageName(),
memberType.qualifiedSourceName(),
@@ -1641,7 +1956,8 @@
if (method.isConstructor()) continue next;
- // if (noVoidReturnType && method.returnType == BaseTypes.VoidBinding) continue next;
+ if (expectedTypesPtr > -1 && method.returnType == BaseTypes.VoidBinding) continue next;
+
if (onlyStaticMethods && !method.isStatic()) continue next;
if (options.checkVisibility
@@ -1667,7 +1983,7 @@
for (int a = minArgLength; --a >= 0;){
if (argTypes[a] != null){ // can be null if it could not be resolved properly
- if (!scope.areTypesCompatible(argTypes[a], method.parameters[a])) {
+ if (!argTypes[a].isCompatibleWith(method.parameters[a])) {
continue next;
}
}
@@ -1688,11 +2004,15 @@
if (method.declaringClass.isSuperclassOf(otherMethod.declaringClass))
continue next;
- if (otherMethod.declaringClass.isInterface())
+ if (otherMethod.declaringClass.isInterface()) {
+ if(method.declaringClass == scope.getJavaLangObject())
+ continue next;
+
if (method
.declaringClass
.implementsInterface(otherMethod.declaringClass, true))
continue next;
+ }
if (method.declaringClass.isInterface())
if(otherMethod
@@ -1715,7 +2035,7 @@
}
char[][] parameterNames = findMethodParameterNames(method,parameterTypeNames);
- char[] completion = TypeConstants.NoChar;
+ char[] completion = CharOperation.NO_CHAR;
int previousStartPosition = startPosition;
@@ -1740,10 +2060,14 @@
completion = CharOperation.concat(prefix,completion,'.');
}
- int relevance = R_DEFAULT;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
relevance += computeRelevanceForCaseMatching(methodName, method.selector);
relevance += computeRelevanceForExpectingType(method.returnType);
-
+ relevance += computeRelevanceForStatic(onlyStaticMethods, method.isStatic());
+ relevance += computeRelevanceForQualification(prefixRequired);
+
+ noProposal = false;
requestor.acceptMethod(
method.declaringClass.qualifiedPackageName(),
method.declaringClass.qualifiedSourceName(),
@@ -1762,11 +2086,15 @@
}
}
- private int computeRelevanceForCaseMatching(char[] token, char[] proposalName){
+ int computeRelevanceForCaseMatching(char[] token, char[] proposalName){
if (CharOperation.prefixEquals(token, proposalName, true /* do not ignore case */)) {
- return R_CASE;
+ if(CharOperation.equals(token, proposalName, true /* do not ignore case */)) {
+ return R_CASE + R_EXACT_NAME;
+ } else {
+ return R_CASE;
+ }
} else {
- return R_DEFAULT;
+ return 0;
}
}
private int computeRelevanceForClass(){
@@ -1779,7 +2107,19 @@
if(assistNodeIsInterface) {
return R_INTERFACE;
}
- return R_DEFAULT;
+ return 0;
+ }
+ private int computeRelevanceForQualification(boolean prefixRequired) {
+ if(!prefixRequired) {
+ return R_UNQUALIFIED;
+ }
+ return 0;
+ }
+ private int computeRelevanceForStatic(boolean onlyStatic, boolean isStatic) {
+ if(insideQualifiedReference && !onlyStatic && !isStatic) {
+ return R_NON_STATIC;
+ }
+ return 0;
}
private int computeRelevanceForException(char[] proposalName){
@@ -1788,30 +2128,58 @@
CharOperation.match(ERROR_PATTERN, proposalName, false))) {
return R_EXCEPTION;
}
- return R_DEFAULT;
+ return 0;
}
private int computeRelevanceForExpectingType(TypeBinding proposalType){
if(expectedTypes != null && proposalType != null) {
- for (int i = 0; i < expectedTypes.length; i++) {
- if(Scope.areTypesCompatible(proposalType, expectedTypes[i])) {
+ for (int i = 0; i <= expectedTypesPtr; i++) {
+ if(CharOperation.equals(expectedTypes[i].qualifiedPackageName(), proposalType.qualifiedPackageName()) &&
+ CharOperation.equals(expectedTypes[i].qualifiedSourceName(), proposalType.qualifiedSourceName())) {
+ return R_EXACT_EXPECTED_TYPE;
+ }
+ if((expectedTypesFilter & SUBTYPE) != 0
+ && proposalType.isCompatibleWith(expectedTypes[i])) {
+ return R_EXPECTED_TYPE;
+ }
+ if((expectedTypesFilter & SUPERTYPE) != 0
+ && expectedTypes[i].isCompatibleWith(proposalType)) {
return R_EXPECTED_TYPE;
}
}
}
- return R_DEFAULT;
+ return 0;
}
private int computeRelevanceForExpectingType(char[] packageName, char[] typeName){
if(expectedTypes != null) {
- for (int i = 0; i < expectedTypes.length; i++) {
+ for (int i = 0; i <= expectedTypesPtr; i++) {
if(CharOperation.equals(expectedTypes[i].qualifiedPackageName(), packageName) &&
CharOperation.equals(expectedTypes[i].qualifiedSourceName(), typeName)) {
- return R_EXPECTED_TYPE;
+ return R_EXACT_EXPECTED_TYPE;
}
}
}
- return R_DEFAULT;
+ return 0;
}
-
+ int computeRelevanceForInterestingProposal(){
+ return computeRelevanceForInterestingProposal(null);
+ }
+ private int computeRelevanceForInterestingProposal(Binding binding){
+ if(uninterestingBindings != null) {
+ for (int i = 0; i <= uninterestingBindingsPtr; i++) {
+ if(uninterestingBindings[i] == binding) {
+ return 0;
+ }
+ }
+ }
+ return R_INTERESTING;
+ }
+ private void computeUninterestingBindings(AstNode parent, Scope scope){
+ if(parent instanceof LocalDeclaration) {
+ addUninterestingBindings(((LocalDeclaration)parent).binding);
+ } else if (parent instanceof FieldDeclaration) {
+ addUninterestingBindings(((FieldDeclaration)parent).binding);
+ }
+ }
// Helper method for findMethods(char[], MethodBinding[], Scope, ObjectVector, boolean, boolean, boolean, TypeBinding)
private void findLocalMethodDeclarations(
char[] methodName,
@@ -1946,9 +2314,12 @@
}
}
- int relevance = R_DEFAULT;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
relevance += computeRelevanceForCaseMatching(methodName, method.selector);
+ if(method.isAbstract()) relevance += R_ABSTRACT_METHOD;
+ noProposal = false;
requestor.acceptMethodDeclaration(
method.declaringClass.qualifiedPackageName(),
method.declaringClass.qualifiedSourceName(),
@@ -2101,7 +2472,7 @@
int length = parameterTypeNames.length;
if (length == 0){
- return TypeConstants.NoCharChar;
+ return CharOperation.NO_CHAR_CHAR;
}
// look into the corresponding unit if it is available
if (bindingType instanceof SourceTypeBinding){
@@ -2181,11 +2552,15 @@
))
continue next;
- int relevance = R_DEFAULT;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
relevance += computeRelevanceForCaseMatching(typeName, localType.sourceName);
relevance += computeRelevanceForExpectingType(localType);
+ relevance += computeRelevanceForException(localType.sourceName);
relevance += computeRelevanceForClass();
+ relevance += computeRelevanceForQualification(false);
+ noProposal = false;
requestor.acceptClass(
localType.qualifiedPackageName(),
localType.sourceName,
@@ -2241,12 +2616,17 @@
if (!CharOperation.prefixEquals(token, sourceType.sourceName, false)) continue;
- int relevance = R_DEFAULT;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
relevance += computeRelevanceForCaseMatching(token, sourceType.sourceName);
relevance += computeRelevanceForExpectingType(sourceType);
+ relevance += computeRelevanceForQualification(false);
if (sourceType.isClass()){
relevance += computeRelevanceForClass();
+ relevance += computeRelevanceForException(sourceType.sourceName);
+
+ noProposal = false;
requestor.acceptClass(
sourceType.qualifiedPackageName(),
sourceType.sourceName(),
@@ -2257,6 +2637,8 @@
relevance);
} else {
relevance += computeRelevanceForInterface();
+
+ noProposal = false;
requestor.acceptInterface(
sourceType.qualifiedPackageName(),
sourceType.sourceName(),
@@ -2268,13 +2650,71 @@
}
}
}
-
- if (token.length == 0)
- return;
-
- findKeywords(token, baseTypes, scope);
- nameEnvironment.findTypes(token, this);
- nameEnvironment.findPackages(token, this);
+
+ if (token.length == 0) {
+ if(expectedTypesPtr > -1) {
+ next : for (int i = 0; i <= expectedTypesPtr; i++) {
+ if(expectedTypes[i] instanceof ReferenceBinding) {
+ ReferenceBinding refBinding = (ReferenceBinding)expectedTypes[i];
+ boolean inSameUnit = unitScope.isDefinedInSameUnit(refBinding);
+
+ // top level types of the current unit are already proposed.
+ if(!inSameUnit || (inSameUnit && refBinding.isMemberType())) {
+ char[] packageName = refBinding.qualifiedPackageName();
+ char[] typeName = refBinding.sourceName();
+ char[] completionName = typeName;
+
+ boolean isQualified = false;
+ if (!insideQualifiedReference && !refBinding.isMemberType()) {
+ if (mustQualifyType(packageName, typeName)) {
+ if (packageName == null || packageName.length == 0)
+ if (unitScope != null && unitScope.fPackage.compoundName != CharOperation.NO_CHAR_CHAR)
+ continue next; // ignore types from the default package from outside it
+ completionName = CharOperation.concat(packageName, typeName, '.');
+ isQualified = true;
+ }
+ }
+
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
+ relevance += computeRelevanceForCaseMatching(token, typeName);
+ relevance += computeRelevanceForExpectingType(refBinding);
+ relevance += computeRelevanceForQualification(isQualified);
+
+ if(refBinding.isClass()) {
+ relevance += computeRelevanceForClass();
+
+ noProposal = false;
+ requestor.acceptClass(
+ packageName,
+ typeName,
+ completionName,
+ refBinding.modifiers,
+ startPosition - offset,
+ endPosition - offset,
+ relevance);
+ } else if (refBinding.isInterface()) {
+ relevance += computeRelevanceForInterface();
+
+ noProposal = false;
+ requestor.acceptInterface(
+ packageName,
+ typeName,
+ completionName,
+ refBinding.modifiers,
+ startPosition - offset,
+ endPosition - offset,
+ relevance);
+ }
+ }
+ }
+ }
+ }
+ } else {
+ findKeywords(token, baseTypes);
+ nameEnvironment.findTypes(token, this);
+ nameEnvironment.findPackages(token, this);
+ }
}
private void findTypesAndSubpackages(
@@ -2294,6 +2734,54 @@
length);
qualifiedName[length] = '.';
}
+
+ if (unitScope != null) {
+ int typeLength = qualifiedName.length;
+ SourceTypeBinding[] types = unitScope.topLevelTypes;
+
+ for (int i = 0, length = types.length; i < length; i++) {
+ SourceTypeBinding sourceType = types[i];
+
+ char[] qualifiedSourceTypeName = CharOperation.concatWith(sourceType.compoundName, '.');
+
+ if (typeLength > qualifiedSourceTypeName.length) continue;
+ if (!CharOperation.prefixEquals(qualifiedName, qualifiedSourceTypeName, false)) continue;
+
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
+ relevance += computeRelevanceForCaseMatching(qualifiedName, qualifiedSourceTypeName);
+ relevance += computeRelevanceForExpectingType(sourceType);
+ relevance += computeRelevanceForQualification(false);
+
+ if (sourceType.isClass()){
+ relevance += computeRelevanceForClass();
+ relevance += computeRelevanceForException(sourceType.sourceName);
+
+ noProposal = false;
+ requestor.acceptClass(
+ sourceType.qualifiedPackageName(),
+ sourceType.sourceName(),
+ sourceType.sourceName(),
+ sourceType.modifiers,
+ startPosition - offset,
+ endPosition - offset,
+ relevance);
+ } else {
+ relevance += computeRelevanceForInterface();
+
+ noProposal = false;
+ requestor.acceptInterface(
+ sourceType.qualifiedPackageName(),
+ sourceType.sourceName(),
+ sourceType.sourceName(),
+ sourceType.modifiers,
+ startPosition - offset,
+ endPosition - offset,
+ relevance);
+ }
+ }
+ }
+
nameEnvironment.findTypes(qualifiedName, this);
nameEnvironment.findPackages(qualifiedName, this);
}
@@ -2356,14 +2844,17 @@
}
localsFound.add(local);
- int relevance = R_DEFAULT;
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal(local);
relevance += computeRelevanceForCaseMatching(token, local.name);
relevance += computeRelevanceForExpectingType(local.type);
+ relevance += computeRelevanceForQualification(false);
+ noProposal = false;
requestor.acceptLocalVariable(
local.name,
local.type == null
- ? NoChar
+ ? CharOperation.NO_CHAR
: local.type.qualifiedPackageName(),
local.type == null
? local.declaration.type.toString().toCharArray()
@@ -2428,115 +2919,121 @@
currentScope = currentScope.parent;
}
}
-
- // Helper method for private void findVariableNames(char[] name, TypeReference type )
- private void findVariableName(char[] token, char[] qualifiedPackageName, char[] qualifiedSourceName, char[] sourceName, char[][] excludeNames, int dim){
- if(sourceName == null || sourceName.length == 0)
- return;
-
- char[] name = null;
+ // Helper method for private void findVariableNames(char[] name, TypeReference type )
+ private void findVariableName(
+ char[] token,
+ char[] qualifiedPackageName,
+ char[] qualifiedSourceName,
+ char[] sourceName,
+ char[][] excludeNames,
+ int dim,
+ int kind,
+ int modifiers){
- // compute variable name for base type
- try{
- nameScanner.setSource(sourceName);
- switch (nameScanner.getNextToken()) {
- case TokenNameint :
- case TokenNamebyte :
- case TokenNameshort :
- case TokenNamechar :
- case TokenNamelong :
- case TokenNamefloat :
- case TokenNamedouble :
- case TokenNameboolean :
- if(token != null && token.length != 0)
- return;
- name = computeBaseNames(sourceName[0], excludeNames);
- break;
- }
- if(name != null) {
- int relevance = R_DEFAULT;
- relevance += computeRelevanceForCaseMatching(token, name);
-
+ if(sourceName == null || sourceName.length == 0)
+ return;
+
+ // compute variable name for non base type
+ final char[] displayName;
+ if (dim > 0){
+ int l = qualifiedSourceName.length;
+ displayName = new char[l+(2*dim)];
+ System.arraycopy(qualifiedSourceName, 0, displayName, 0, l);
+ for(int i = 0; i < dim; i++){
+ displayName[l+(i*2)] = '[';
+ displayName[l+(i*2)+1] = ']';
+ }
+ } else {
+ displayName = qualifiedSourceName;
+ }
+
+ final char[] t = token;
+ final char[] q = qualifiedPackageName;
+ INamingRequestor namingRequestor = new INamingRequestor() {
+ public void acceptNameWithPrefixAndSuffix(char[] name, boolean isFirstPrefix, boolean isFirstSuffix) {
+ accept( name,
+ (isFirstPrefix ? R_NAME_FIRST_PREFIX : R_NAME_PREFIX) + (isFirstSuffix ? R_NAME_FIRST_SUFFIX : R_NAME_SUFFIX));
+ }
+
+ public void acceptNameWithPrefix(char[] name, boolean isFirstPrefix) {
+ accept(name, isFirstPrefix ? R_NAME_FIRST_PREFIX : R_NAME_PREFIX);
+ }
+
+ public void acceptNameWithSuffix(char[] name, boolean isFirstSuffix) {
+ accept(name, isFirstSuffix ? R_NAME_FIRST_SUFFIX : R_NAME_SUFFIX);
+ }
+
+ public void acceptNameWithoutPrefixAndSuffix(char[] name) {
+ accept(name, 0);
+ }
+ void accept(char[] name, int prefixAndSuffixRelevance){
+ if (CharOperation.prefixEquals(t, name, false)) {
+ int relevance = computeBaseRelevance();
+ relevance += computeRelevanceForInterestingProposal();
+ relevance += computeRelevanceForCaseMatching(t, name);
+ relevance += prefixAndSuffixRelevance;
+
// accept result
+ noProposal = false;
requestor.acceptVariableName(
- qualifiedPackageName,
- qualifiedSourceName,
+ q,
+ displayName,
name,
name,
startPosition - offset,
endPosition - offset,
relevance);
- return;
}
- } catch(InvalidInputException e){
}
-
- // compute variable name for non base type
- char[][] names = computeNames(sourceName, dim > 0);
- char[] displayName;
- if (dim > 0){
- int l = qualifiedSourceName.length;
- displayName = new char[l+(2*dim)];
- System.arraycopy(qualifiedSourceName, 0, displayName, 0, l);
- for(int i = 0; i < dim; i++){
- displayName[l+(i*2)] = '[';
- displayName[l+(i*2)+1] = ']';
- }
- } else {
- displayName = qualifiedSourceName;
- }
- next : for(int i = 0 ; i < names.length ; i++){
- name = names[i];
-
- if (!CharOperation.prefixEquals(token, name, false))
- continue next;
-
- // completion must be an identifier (not a keyword, ...).
- try{
- nameScanner.setSource(name);
- if(nameScanner.getNextToken() != TokenNameIdentifier)
- continue next;
- } catch(InvalidInputException e){
- continue next;
- }
-
- int count = 2;
- char[] originalName = name;
- for(int j = 0 ; j < excludeNames.length ; j++){
- if(CharOperation.equals(name, excludeNames[j], false)) {
- name = CharOperation.concat(originalName, String.valueOf(count++).toCharArray());
- j = 0;
- }
- }
-
- int relevance = R_DEFAULT;
- relevance += computeRelevanceForCaseMatching(token, name);
-
- // accept result
- requestor.acceptVariableName(
+ };
+
+ switch (kind) {
+ case FIELD :
+ InternalNamingConventions.suggestFieldNames(
+ javaProject,
qualifiedPackageName,
- displayName,
- name,
- name,
- startPosition - offset,
- endPosition - offset,
- relevance);
- }
+ qualifiedSourceName,
+ dim,
+ modifiers,
+ excludeNames,
+ namingRequestor);
+ break;
+ case LOCAL :
+ InternalNamingConventions.suggestLocalVariableNames(
+ javaProject,
+ qualifiedPackageName,
+ qualifiedSourceName,
+ dim,
+ excludeNames,
+ namingRequestor);
+ break;
+ case ARGUMENT :
+ InternalNamingConventions.suggestArgumentNames(
+ javaProject,
+ qualifiedPackageName,
+ qualifiedSourceName,
+ dim,
+ excludeNames,
+ namingRequestor);
+ break;
+ }
}
- private void findVariableNames(char[] name, TypeReference type , char[][] excludeNames){
+ private void findVariableNames(char[] name, TypeReference type , char[][] excludeNames, int kind, int modifiers){
if(type != null &&
- type.binding != null &&
- type.binding.problemId() == Binding.NoError){
- TypeBinding tb = type.binding;
+ type.resolvedType != null &&
+ type.resolvedType.problemId() == Binding.NoError){
+ TypeBinding tb = type.resolvedType;
findVariableName(
name,
tb.leafComponentType().qualifiedPackageName(),
tb.leafComponentType().qualifiedSourceName(),
tb.leafComponentType().sourceName(),
excludeNames,
- type.dimensions());
+ type.dimensions(),
+ kind,
+ modifiers);
}/* else {
char[][] typeName = type.getTypeName();
findVariableName(
@@ -2560,101 +3057,336 @@
this.knownPkgs = new HashtableOfObject(10);
this.knownTypes = new HashtableOfObject(10);
}
-
- private void setSourceRange(int start, int end) {
-
- this.startPosition = start;
- this.endPosition = end + 1;
- }
- private char[] computeBaseNames(char firstName, char[][] excludeNames){
- char[] name = new char[]{firstName};
-
- for(int i = 0 ; i < excludeNames.length ; i++){
- if(CharOperation.equals(name, excludeNames[i], false)) {
- name[0]++;
- if(name[0] > 'z')
- name[0] = 'a';
- if(name[0] == firstName)
- return null;
- i = 0;
- }
+ private void setSourceRange(int start, int end) {
+ this.setSourceRange(start, end, true);
+ }
+
+ private void setSourceRange(int start, int end, boolean emptyTokenAdjstment) {
+ this.startPosition = start;
+ if(emptyTokenAdjstment) {
+ int endOfEmptyToken = ((CompletionScanner)parser.scanner).endOfEmptyToken;
+ this.endPosition = endOfEmptyToken > end ? endOfEmptyToken + 1 : end + 1;
+ } else {
+ this.endPosition = end + 1;
}
-
- return name;
+ }
+ int computeBaseRelevance(){
+ return R_DEFAULT;
}
private void computeExpectedTypes(AstNode parent, Scope scope){
- int expectedTypeCount = 0;
- expectedTypes = new TypeBinding[1];
+ // default filter
+ expectedTypesFilter = SUBTYPE;
+
+ // find types from parent
if(parent instanceof AbstractVariableDeclaration) {
- TypeBinding binding = ((AbstractVariableDeclaration)parent).type.binding;
+ AbstractVariableDeclaration variable = (AbstractVariableDeclaration)parent;
+ TypeBinding binding = variable.type.resolvedType;
if(binding != null) {
- expectedTypes[expectedTypeCount++] = binding;
+ if(!(variable.initialization instanceof ArrayInitializer)) {
+ addExpectedType(binding);
+ }
}
} else if(parent instanceof Assignment) {
- TypeBinding binding = ((Assignment)parent).lhsType;
+ TypeBinding binding = ((Assignment)parent).resolvedType;
if(binding != null) {
- expectedTypes[expectedTypeCount++] = binding;
+ addExpectedType(binding);
}
} else if(parent instanceof ReturnStatement) {
- MethodBinding methodBinding = ((AbstractMethodDeclaration) scope.methodScope().referenceContext).binding;
- TypeBinding binding = methodBinding == null ? null : methodBinding.returnType;
- if(binding != null) {
- expectedTypes[expectedTypeCount++] = binding;
+ if(scope.methodScope().referenceContext instanceof AbstractMethodDeclaration) {
+ MethodBinding methodBinding = ((AbstractMethodDeclaration) scope.methodScope().referenceContext).binding;
+ TypeBinding binding = methodBinding == null ? null : methodBinding.returnType;
+ if(binding != null) {
+ addExpectedType(binding);
+ }
}
+ } else if(parent instanceof CastExpression) {
+ Expression e = ((CastExpression)parent).type;
+ TypeBinding binding = e.resolvedType;
+ if(binding != null){
+ addExpectedType(binding);
+ expectedTypesFilter = SUBTYPE | SUPERTYPE;
+ }
+ } else if(parent instanceof MessageSend) {
+ MessageSend messageSend = (MessageSend) parent;
+
+ if(messageSend.receiverType instanceof ReferenceBinding) {
+ ReferenceBinding binding = (ReferenceBinding)messageSend.receiverType;
+ boolean isStatic = messageSend.receiver.isTypeReference();
+
+ while(binding != null) {
+ computeExpectedTypesForMessageSend(
+ binding,
+ messageSend.selector,
+ messageSend.arguments,
+ (ReferenceBinding)messageSend.receiverType,
+ scope,
+ messageSend,
+ isStatic);
+ computeExpectedTypesForMessageSendForInterface(
+ binding,
+ messageSend.selector,
+ messageSend.arguments,
+ (ReferenceBinding)messageSend.receiverType,
+ scope,
+ messageSend,
+ isStatic);
+ binding = binding.superclass();
+ }
+ }
+ } else if(parent instanceof AllocationExpression) {
+ AllocationExpression allocationExpression = (AllocationExpression) parent;
+
+ ReferenceBinding binding = (ReferenceBinding)allocationExpression.type.resolvedType;
+
+ if(binding != null) {
+ computeExpectedTypesForAllocationExpression(
+ binding,
+ allocationExpression.arguments,
+ scope,
+ allocationExpression);
+ }
+ } else if(parent instanceof OperatorExpression) {
+ int operator = (parent.bits & AstNode.OperatorMASK) >> AstNode.OperatorSHIFT;
+ if(parent instanceof ConditionalExpression) {
+ // for future use
+ } else if(parent instanceof InstanceOfExpression) {
+ InstanceOfExpression e = (InstanceOfExpression) parent;
+ TypeBinding binding = e.expression.resolvedType;
+ if(binding != null){
+ addExpectedType(binding);
+ expectedTypesFilter = SUBTYPE | SUPERTYPE;
+ }
+ } else if(parent instanceof BinaryExpression) {
+ switch(operator) {
+ case OperatorIds.PLUS :
+ addExpectedType(BaseTypes.ShortBinding);
+ addExpectedType(BaseTypes.IntBinding);
+ addExpectedType(BaseTypes.LongBinding);
+ addExpectedType(BaseTypes.FloatBinding);
+ addExpectedType(BaseTypes.DoubleBinding);
+ addExpectedType(BaseTypes.CharBinding);
+ addExpectedType(BaseTypes.ByteBinding);
+ addExpectedType(scope.getJavaLangString());
+ break;
+ case OperatorIds.AND_AND :
+ case OperatorIds.OR_OR :
+ case OperatorIds.XOR :
+ addExpectedType(BaseTypes.BooleanBinding);
+ break;
+ default :
+ addExpectedType(BaseTypes.ShortBinding);
+ addExpectedType(BaseTypes.IntBinding);
+ addExpectedType(BaseTypes.LongBinding);
+ addExpectedType(BaseTypes.FloatBinding);
+ addExpectedType(BaseTypes.DoubleBinding);
+ addExpectedType(BaseTypes.CharBinding);
+ addExpectedType(BaseTypes.ByteBinding);
+ break;
+ }
+ } else if(parent instanceof UnaryExpression) {
+ switch(operator) {
+ case OperatorIds.NOT :
+ addExpectedType(BaseTypes.BooleanBinding);
+ break;
+ case OperatorIds.TWIDDLE :
+ addExpectedType(BaseTypes.ShortBinding);
+ addExpectedType(BaseTypes.IntBinding);
+ addExpectedType(BaseTypes.LongBinding);
+ addExpectedType(BaseTypes.CharBinding);
+ addExpectedType(BaseTypes.ByteBinding);
+ break;
+ case OperatorIds.PLUS :
+ case OperatorIds.MINUS :
+ case OperatorIds.PLUS_PLUS :
+ case OperatorIds.MINUS_MINUS :
+ addExpectedType(BaseTypes.ShortBinding);
+ addExpectedType(BaseTypes.IntBinding);
+ addExpectedType(BaseTypes.LongBinding);
+ addExpectedType(BaseTypes.FloatBinding);
+ addExpectedType(BaseTypes.DoubleBinding);
+ addExpectedType(BaseTypes.CharBinding);
+ addExpectedType(BaseTypes.ByteBinding);
+ break;
+ }
+ }
+ } else if(parent instanceof ArrayReference) {
+ addExpectedType(BaseTypes.ShortBinding);
+ addExpectedType(BaseTypes.IntBinding);
+ addExpectedType(BaseTypes.LongBinding);
}
- System.arraycopy(expectedTypes, 0, expectedTypes = new TypeBinding[expectedTypeCount], 0, expectedTypeCount);
+ if(expectedTypesPtr + 1 != expectedTypes.length) {
+ System.arraycopy(expectedTypes, 0, expectedTypes = new TypeBinding[expectedTypesPtr + 1], 0, expectedTypesPtr + 1);
+ }
}
- private char[][] computeNames(char[] sourceName, boolean forArray){
- char[][] names = new char[5][];
- int nameCount = 0;
- boolean previousIsUpperCase = false;
- for(int i = sourceName.length - 1 ; i >= 0 ; i--){
- boolean isUpperCase = Character.isUpperCase(sourceName[i]);
- if(isUpperCase && !previousIsUpperCase){
- char[] name = CharOperation.subarray(sourceName,i,sourceName.length);
- if(name.length > 1){
- if(nameCount == names.length) {
- System.arraycopy(names, 0, names = new char[nameCount * 2][], 0, nameCount);
- }
- name[0] = Character.toLowerCase(name[0]);
-
- if(forArray) {
- int length = name.length;
- if (name[length-1] == 's'){
- System.arraycopy(name, 0, name = new char[length + 2], 0, length);
- name[length] = 'e';
- name[length+1] = 's';
- } else {
- System.arraycopy(name, 0, name = new char[length + 1], 0, length);
- name[length] = 's';
+
+ private void computeExpectedTypesForAllocationExpression(
+ ReferenceBinding binding,
+ Expression[] arguments,
+ Scope scope,
+ InvocationSite invocationSite) {
+
+ MethodBinding[] methods = binding.availableMethods();
+ nextMethod : for (int i = 0; i < methods.length; i++) {
+ MethodBinding method = methods[i];
+
+ if (!method.isConstructor()) continue nextMethod;
+
+ if (method.isSynthetic()) continue nextMethod;
+
+ if (options.checkVisibility && !method.canBeSeenBy(invocationSite, scope)) continue nextMethod;
+
+ TypeBinding[] parameters = method.parameters;
+ if(parameters.length < arguments.length)
+ continue nextMethod;
+
+ int length = arguments.length - 1;
+
+ for (int j = 0; j < length; j++) {
+ Expression argument = arguments[j];
+ TypeBinding argType = argument.resolvedType;
+ if(argType != null && !argType.isCompatibleWith(parameters[j]))
+ continue nextMethod;
+ }
+
+ TypeBinding expectedType = method.parameters[arguments.length - 1];
+ if(expectedType != null) {
+ addExpectedType(expectedType);
+ }
+ }
+ }
+
+ private void computeExpectedTypesForMessageSendForInterface(
+ ReferenceBinding binding,
+ char[] selector,
+ Expression[] arguments,
+ ReferenceBinding receiverType,
+ Scope scope,
+ InvocationSite invocationSite,
+ boolean isStatic) {
+
+ ReferenceBinding[] itsInterfaces = binding.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ ReferenceBinding[][] interfacesToVisit = new ReferenceBinding[5][];
+ int lastPosition = 0;
+ interfacesToVisit[lastPosition] = itsInterfaces;
+
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+
+ for (int j = 0, length = interfaces.length; j < length; j++) {
+ ReferenceBinding currentType = interfaces[j];
+
+ if ((currentType.tagBits & TagBits.InterfaceVisited) == 0) {
+ // if interface as not already been visited
+ currentType.tagBits |= TagBits.InterfaceVisited;
+
+ computeExpectedTypesForMessageSend(
+ currentType,
+ selector,
+ arguments,
+ receiverType,
+ scope,
+ invocationSite,
+ isStatic);
+
+ itsInterfaces = currentType.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(
+ interfacesToVisit,
+ 0,
+ interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
+ 0,
+ lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
}
- }
- names[nameCount++] = name;
+ }
}
}
- previousIsUpperCase = isUpperCase;
- }
- if(nameCount == 0){
- char[] name = CharOperation.toLowerCase(sourceName);
- if(forArray) {
- int length = name.length;
- if (name[length-1] == 's'){
- System.arraycopy(name, 0, name = new char[length + 2], 0, length);
- name[length] = 'e';
- name[length+1] = 's';
- } else {
- System.arraycopy(name, 0, name = new char[length + 1], 0, length);
- name[length] = 's';
- }
- }
- names[nameCount++] = name;
+ // bit reinitialization
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+
+ for (int j = 0, length = interfaces.length; j < length; j++){
+ interfaces[j].tagBits &= ~TagBits.InterfaceVisited;
+ }
+ }
}
- System.arraycopy(names, 0, names = new char[nameCount][], 0, nameCount);
- return names;
+ }
+
+ private void computeExpectedTypesForMessageSend(
+ ReferenceBinding binding,
+ char[] selector,
+ Expression[] arguments,
+ ReferenceBinding receiverType,
+ Scope scope,
+ InvocationSite invocationSite,
+ boolean isStatic) {
+
+ MethodBinding[] methods = binding.availableMethods();
+ nextMethod : for (int i = 0; i < methods.length; i++) {
+ MethodBinding method = methods[i];
+
+ if (method.isSynthetic()) continue nextMethod;
+
+ if (method.isDefaultAbstract()) continue nextMethod;
+
+ if (method.isConstructor()) continue nextMethod;
+
+ if (isStatic && !method.isStatic()) continue nextMethod;
+
+ if (options.checkVisibility && !method.canBeSeenBy(receiverType, invocationSite, scope)) continue nextMethod;
+
+ if(!CharOperation.equals(method.selector, selector)) continue nextMethod;
+
+ TypeBinding[] parameters = method.parameters;
+ if(parameters.length < arguments.length)
+ continue nextMethod;
+
+ int length = arguments.length - 1;
+
+ for (int j = 0; j < length; j++) {
+ Expression argument = arguments[j];
+ TypeBinding argType = argument.resolvedType;
+ if(argType != null && !argType.isCompatibleWith(parameters[j]))
+ continue nextMethod;
+ }
+
+ TypeBinding expectedType = method.parameters[arguments.length - 1];
+ if(expectedType != null) {
+ addExpectedType(expectedType);
+ }
+ }
+ }
+ private void addExpectedType(TypeBinding type){
+ if(type == null || !type.isValidBinding()) return;
+
+ try {
+ this.expectedTypes[++this.expectedTypesPtr] = type;
+ } catch (IndexOutOfBoundsException e) {
+ int oldLength = this.expectedTypes.length;
+ TypeBinding oldTypes[] = this.expectedTypes;
+ this.expectedTypes = new TypeBinding[oldLength * 2];
+ System.arraycopy(oldTypes, 0, this.expectedTypes, 0, oldLength);
+ this.expectedTypes[this.expectedTypesPtr] = type;
+ }
+ }
+ private void addUninterestingBindings(Binding binding){
+ if(binding == null) return;
+ try {
+ this.uninterestingBindings[++this.uninterestingBindingsPtr] = binding;
+ } catch (IndexOutOfBoundsException e) {
+ int oldLength = this.uninterestingBindings.length;
+ Binding oldBindings[] = this.uninterestingBindings;
+ this.uninterestingBindings = new Binding[oldLength * 2];
+ System.arraycopy(oldBindings, 0, this.uninterestingBindings, 0, oldLength);
+ this.uninterestingBindings[this.uninterestingBindingsPtr] = binding;
+ }
}
private char[] computePrefix(SourceTypeBinding declarationType, SourceTypeBinding invocationType, boolean isStatic){
@@ -2686,17 +3418,4 @@
return completion.toString().toCharArray();
}
-
- private boolean isEnclosed(ReferenceBinding possibleEnclosingType, ReferenceBinding type){
- if(type.isNestedType()){
- ReferenceBinding enclosing = type.enclosingType();
- while(enclosing != null ){
- if(possibleEnclosingType == enclosing)
- return true;
- enclosing = enclosing.enclosingType();
- }
- }
- return false;
- }
-
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java
index 8a14285..30562df 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist;
/**
@@ -57,4 +57,4 @@
* The default package is represented by an empty array.
*/
public void acceptType(char[] packageName, char[] typeName);
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchableNameEnvironment.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchableNameEnvironment.java
index f7c1f44..27e911c 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchableNameEnvironment.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISearchableNameEnvironment.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
@@ -45,4 +45,4 @@
* types are found relative to their enclosing type.
*/
void findTypes(char[] prefix, ISearchRequestor requestor);
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java
index b003dae..45ad83b 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/ISelectionRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist;
import org.eclipse.jdt.core.compiler.IProblem;
@@ -142,4 +142,4 @@
* The default package is represented by an empty array.
*/
void acceptPackage(char[] packageName);
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/RelevanceConstants.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/RelevanceConstants.java
index fa5e18e..38de531 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/RelevanceConstants.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/RelevanceConstants.java
@@ -1,21 +1,33 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist;
public interface RelevanceConstants {
int R_DEFAULT = 0;
+ int R_INTERESTING = 5;
int R_CASE = 10;
+ int R_EXACT_NAME = 4;
int R_EXPECTED_TYPE = 20;
+ int R_EXACT_EXPECTED_TYPE = 30;
int R_INTERFACE = 20;
int R_CLASS = 20;
int R_EXCEPTION = 20;
+ int R_ABSTRACT_METHOD = 20;
+ int R_NON_STATIC = 10;
+ int R_UNQUALIFIED = 3;
+ int R_NAME_FIRST_PREFIX = 6;
+ int R_NAME_PREFIX = 5;
+ int R_NAME_FIRST_SUFFIX = 4;
+ int R_NAME_SUFFIX = 3;
+
+
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
index 69d1ede..85c34b3 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
@@ -1,20 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist;
import java.util.*;
import org.eclipse.jdt.core.compiler.*;
-import org.eclipse.jdt.core.compiler.InvalidInputException;
-import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.codeassist.impl.*;
import org.eclipse.jdt.internal.codeassist.select.*;
import org.eclipse.jdt.internal.compiler.*;
@@ -23,7 +21,6 @@
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
import org.eclipse.jdt.internal.compiler.impl.*;
/**
@@ -53,6 +50,9 @@
private char[][][] acceptedInterfaces;
int acceptedClassesCount;
int acceptedInterfacesCount;
+
+ boolean noProposal = true;
+ IProblem problem = null;
/**
* The SelectionEngine is responsible for computing the selected object.
@@ -86,12 +86,37 @@
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
this.compilerOptions,
new DefaultProblemFactory(Locale.getDefault())) {
- public void record(IProblem problem, CompilationResult unitResult, ReferenceContext referenceContext) {
- unitResult.record(problem, referenceContext);
- SelectionEngine.this.requestor.acceptError(problem);
+
+ public IProblem createProblem(
+ char[] fileName,
+ int problemId,
+ String[] problemArguments,
+ String[] messageArguments,
+ int severity,
+ int problemStartPosition,
+ int problemEndPosition,
+ int lineNumber,
+ ReferenceContext referenceContext,
+ CompilationResult unitResult) {
+ IProblem problem = super.createProblem(
+ fileName,
+ problemId,
+ problemArguments,
+ messageArguments,
+ severity,
+ problemStartPosition,
+ problemEndPosition,
+ lineNumber,
+ referenceContext,
+ unitResult);
+ if(SelectionEngine.this.problem == null && problem.isError() && (problem.getID() & IProblem.Syntax) == 0) {
+ SelectionEngine.this.problem = problem;
+ }
+
+ return problem;
}
};
- this.parser = new SelectionParser(problemReporter, this.compilerOptions.assertMode);
+ this.parser = new SelectionParser(problemReporter, this.compilerOptions.sourceLevel >= CompilerOptions.JDK1_4);
this.lookupEnvironment =
new LookupEnvironment(this, this.compilerOptions, problemReporter, nameEnvironment);
}
@@ -132,6 +157,7 @@
acceptedClasses[acceptedClassesCount++] = acceptedClass;
} else {
+ noProposal = false;
requestor.acceptClass(
packageName,
className,
@@ -178,6 +204,7 @@
acceptedInterfaces[acceptedInterfacesCount++] = acceptedInterface;
} else {
+ noProposal = false;
requestor.acceptInterface(
packageName,
interfaceName,
@@ -202,6 +229,7 @@
if(acceptedClasses != null){
acceptedAnswer = true;
for (int i = 0; i < acceptedClassesCount; i++) {
+ noProposal = false;
requestor.acceptClass(
acceptedClasses[i][0],
acceptedClasses[i][1],
@@ -213,6 +241,7 @@
if(acceptedInterfaces != null){
acceptedAnswer = true;
for (int i = 0; i < acceptedInterfacesCount; i++) {
+ noProposal = false;
requestor.acceptInterface(
acceptedInterfaces[i][0],
acceptedInterfaces[i][1],
@@ -258,7 +287,7 @@
int nextCharacterPosition = selectionStart;
char currentCharacter = ' ';
try {
- while(currentPosition > 0 || currentCharacter == '\r' || currentCharacter == '\n'){
+ while(currentPosition > 0){
if(source[currentPosition] == '\\' && source[currentPosition+1] == 'u') {
int pos = currentPosition + 2;
@@ -289,29 +318,28 @@
}
currentPosition--;
}
- }
- catch (ArrayIndexOutOfBoundsException e) {
+ } catch (ArrayIndexOutOfBoundsException e) {
return false;
}
// compute start and end of the last token
- scanner.resetTo(nextCharacterPosition, selectionEnd);
+ scanner.resetTo(nextCharacterPosition, selectionEnd + 1);
do {
try {
token = scanner.getNextToken();
} catch (InvalidInputException e) {
return false;
}
- if((token == ITerminalSymbols.TokenNamethis ||
- token == ITerminalSymbols.TokenNamesuper ||
- token == ITerminalSymbols.TokenNameIdentifier) &&
+ if((token == TerminalTokens.TokenNamethis ||
+ token == TerminalTokens.TokenNamesuper ||
+ token == TerminalTokens.TokenNameIdentifier) &&
scanner.startPosition <= selectionStart &&
selectionStart <= scanner.currentPosition) {
lastIdentifierStart = scanner.startPosition;
lastIdentifierEnd = scanner.currentPosition - 1;
lastIdentifier = scanner.getCurrentTokenSource();
}
- } while (token != ITerminalSymbols.TokenNameEOF);
+ } while (token != TerminalTokens.TokenNameEOF);
} else {
scanner.resetTo(selectionStart, selectionEnd);
@@ -324,9 +352,9 @@
return false;
}
switch (token) {
- case ITerminalSymbols.TokenNamethis :
- case ITerminalSymbols.TokenNamesuper :
- case ITerminalSymbols.TokenNameIdentifier :
+ case TerminalTokens.TokenNamethis :
+ case TerminalTokens.TokenNamesuper :
+ case TerminalTokens.TokenNameIdentifier :
if (!expectingIdentifier)
return false;
lastIdentifier = scanner.getCurrentTokenSource();
@@ -341,20 +369,20 @@
identCount++;
expectingIdentifier = false;
break;
- case ITerminalSymbols.TokenNameDOT :
+ case TerminalTokens.TokenNameDOT :
if (expectingIdentifier)
return false;
entireSelection.append('.');
expectingIdentifier = true;
break;
- case ITerminalSymbols.TokenNameEOF :
+ case TerminalTokens.TokenNameEOF :
if (expectingIdentifier)
return false;
break;
default :
return false;
}
- } while (token != ITerminalSymbols.TokenNameEOF);
+ } while (token != TerminalTokens.TokenNameEOF);
}
if (lastIdentifierStart > 0) {
actualSelectionStart = lastIdentifierStart;
@@ -417,6 +445,7 @@
if (parsedUnit.currentPackage instanceof SelectionOnPackageReference) {
char[][] tokens =
((SelectionOnPackageReference) parsedUnit.currentPackage).tokens;
+ noProposal = false;
requestor.acceptPackage(CharOperation.concatWith(tokens, '.'));
return;
}
@@ -426,6 +455,7 @@
ImportReference importReference = imports[i];
if (importReference instanceof SelectionOnImportReference) {
char[][] tokens = ((SelectionOnImportReference) importReference).tokens;
+ noProposal = false;
requestor.acceptPackage(CharOperation.concatWith(tokens, '.'));
nameEnvironment.findTypes(CharOperation.concatWith(tokens, '.'), this);
// accept qualified types only if no unqualified type was accepted
@@ -439,6 +469,9 @@
}
}
}
+ if(noProposal && problem != null) {
+ requestor.acceptError(problem);
+ }
return;
}
}
@@ -479,6 +512,9 @@
acceptQualifiedTypes();
}
}
+ if(noProposal && problem != null) {
+ requestor.acceptError(problem);
+ }
} catch (IndexOutOfBoundsException e) { // work-around internal failure - 1GEMF6D
} catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object
} finally {
@@ -494,6 +530,7 @@
return;
}
if (typeBinding.isInterface()) {
+ noProposal = false;
requestor.acceptInterface(
typeBinding.qualifiedPackageName(),
typeBinding.qualifiedSourceName(),
@@ -505,12 +542,13 @@
return;
}
ReferenceBinding original = (ReferenceBinding) problemBinding.original;
-
+ noProposal = false;
requestor.acceptClass(
original.qualifiedPackageName(),
original.qualifiedSourceName(),
false);
} else {
+ noProposal = false;
requestor.acceptClass(
typeBinding.qualifiedPackageName(),
typeBinding.qualifiedSourceName(),
@@ -528,6 +566,7 @@
parameterPackageNames[i] = parameterTypes[i].qualifiedPackageName();
parameterTypeNames[i] = parameterTypes[i].qualifiedSourceName();
}
+ noProposal = false;
requestor.acceptMethod(
methodBinding.declaringClass.qualifiedPackageName(),
methodBinding.declaringClass.qualifiedSourceName(),
@@ -542,6 +581,7 @@
if (binding instanceof FieldBinding) {
FieldBinding fieldBinding = (FieldBinding) binding;
if (fieldBinding.declaringClass != null) { // arraylength
+ noProposal = false;
requestor.acceptField(
fieldBinding.declaringClass.qualifiedPackageName(),
fieldBinding.declaringClass.qualifiedSourceName(),
@@ -559,6 +599,7 @@
} else
if (binding instanceof PackageBinding) {
PackageBinding packageBinding = (PackageBinding) binding;
+ noProposal = false;
requestor.acceptPackage(packageBinding.readableName());
acceptedAnswer = true;
} else
@@ -578,10 +619,13 @@
* a type name which is to be resolved in the context of a compilation unit.
* NOTE: the type name is supposed to be correctly reduced (no whitespaces, no unicodes left)
*
+ * @param topLevelTypes org.eclipse.jdt.internal.compiler.env.ISourceType[]
+ * a source form of the top level types of the compilation unit in which code assist is invoked.
+
* @param searchInEnvironment
* if <code>true</code> and no selection could be found in context then search type in environment.
*/
- public void selectType(ISourceType sourceType, char[] typeName, boolean searchInEnvironment) {
+ public void selectType(ISourceType sourceType, char[] typeName, ISourceType[] topLevelTypes, boolean searchInEnvironment) {
try {
acceptedAnswer = false;
@@ -595,13 +639,13 @@
// compute parse tree for this most outer type
CompilationResult result = new CompilationResult(outerType.getFileName(), 1, 1, this.compilerOptions.maxProblemsPerUnit);
CompilationUnitDeclaration parsedUnit =
- SourceTypeConverter
- .buildCompilationUnit(
- new ISourceType[] { outerType },
- false,
- // don't need field and methods
- true, // by default get member types
- this.parser.problemReporter(), result);
+ SourceTypeConverter.buildCompilationUnit(
+ topLevelTypes,
+ false, // no need for field and methods
+ true, // need member types
+ false, // no need for field initialization
+ this.parser.problemReporter(),
+ result);
if (parsedUnit != null && parsedUnit.types != null) {
if(DEBUG) {
@@ -633,8 +677,7 @@
field.type = new SelectionOnSingleTypeReference(typeName, -1);
// position not used
} else {
- qualifiedSelection = typeName;
- char[][] previousIdentifiers = CharOperation.splitOn('.', typeName, 0, dot - 1);
+ char[][] previousIdentifiers = CharOperation.splitOn('.', typeName, 0, dot);
char[] selectionIdentifier =
CharOperation.subarray(typeName, dot + 1, typeName.length);
this.selectedIdentifier = selectionIdentifier;
@@ -683,9 +726,11 @@
}
}
}
+ if(noProposal && problem != null) {
+ requestor.acceptError(problem);
+ }
} catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object
} finally {
- qualifiedSelection = null;
reset();
}
}
@@ -735,4 +780,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java
new file mode 100644
index 0000000..6538fa4
--- /dev/null
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeDetector.java
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.codeassist.complete;
+
+import org.eclipse.jdt.internal.compiler.*;
+import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.lookup.*;
+
+/**
+ * Detect the presence of a node in expression
+ */
+public class CompletionNodeDetector extends AbstractSyntaxTreeVisitorAdapter {
+ private AstNode searchedNode;
+ private AstNode parent;
+ private boolean result;
+
+ public CompletionNodeDetector(AstNode searchedNode, AstNode visitedAst){
+ this.searchedNode = searchedNode;
+ this.result = false;
+
+ if(searchedNode != null && visitedAst != null) {
+ visitedAst.traverse(this, null);
+ }
+ }
+
+ public boolean containsCompletionNode() {
+ return result;
+ }
+
+ public AstNode getCompletionNodeParent() {
+ return parent;
+ }
+ public void endVisit(AllocationExpression allocationExpression, BlockScope scope) {
+ endVisit(allocationExpression);
+ }
+ public void endVisit(AND_AND_Expression and_and_Expression, BlockScope scope) {
+ endVisit(and_and_Expression);
+ }
+ public void endVisit(ArrayAllocationExpression arrayAllocationExpression, BlockScope scope) {
+ endVisit(arrayAllocationExpression);
+ }
+ public void endVisit(ArrayInitializer arrayInitializer, BlockScope scope) {
+ endVisit(arrayInitializer);
+ }
+ public void endVisit(ArrayQualifiedTypeReference arrayQualifiedTypeReference, BlockScope scope) {
+ endVisit(arrayQualifiedTypeReference);
+ }
+ public void endVisit(ArrayQualifiedTypeReference arrayQualifiedTypeReference, ClassScope scope) {
+ endVisit(arrayQualifiedTypeReference);
+ }
+ public void endVisit(ArrayReference arrayReference, BlockScope scope) {
+ endVisit(arrayReference);
+ }
+ public void endVisit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
+ endVisit(arrayTypeReference);
+ }
+ public void endVisit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
+ endVisit(arrayTypeReference);
+ }
+ public void endVisit(Assignment assignment, BlockScope scope) {
+ endVisit(assignment);
+ }
+ public void endVisit(BinaryExpression binaryExpression, BlockScope scope) {
+ endVisit(binaryExpression);
+ }
+ public void endVisit(CastExpression castExpression, BlockScope scope) {
+ endVisit(castExpression);
+ }
+ public void endVisit(CompoundAssignment compoundAssignment, BlockScope scope) {
+ endVisit(compoundAssignment);
+ }
+ public void endVisit(ConditionalExpression conditionalExpression, BlockScope scope) {
+ endVisit(conditionalExpression);
+ }
+ public void endVisit(EqualExpression equalExpression, BlockScope scope) {
+ endVisit(equalExpression);
+ }
+ public void endVisit(ExplicitConstructorCall explicitConstructor, BlockScope scope) {
+ endVisit(explicitConstructor);
+ }
+ public void endVisit(FieldReference fieldReference, BlockScope scope) {
+ endVisit(fieldReference);
+ }
+ public void endVisit(InstanceOfExpression instanceOfExpression, BlockScope scope) {
+ endVisit(instanceOfExpression);
+ }
+ public void endVisit(MessageSend messageSend, BlockScope scope) {
+ endVisit(messageSend);
+ }
+ public void endVisit(OR_OR_Expression or_or_Expression, BlockScope scope) {
+ endVisit(or_or_Expression);
+ }
+ public void endVisit(PostfixExpression postfixExpression, BlockScope scope) {
+ endVisit(postfixExpression);
+ }
+ public void endVisit(PrefixExpression prefixExpression, BlockScope scope) {
+ endVisit(prefixExpression);
+ }
+ public void endVisit(QualifiedAllocationExpression qualifiedAllocationExpression, BlockScope scope) {
+ endVisit(qualifiedAllocationExpression);
+ }
+ public void endVisit(QualifiedNameReference qualifiedNameReference, BlockScope scope) {
+ endVisit(qualifiedNameReference);
+ }
+ public void endVisit(QualifiedSuperReference qualifiedSuperReference, BlockScope scope) {
+ endVisit(qualifiedSuperReference);
+ }
+ public void endVisit(QualifiedThisReference qualifiedThisReference, BlockScope scope) {
+ endVisit(qualifiedThisReference);
+ }
+ public void endVisit(QualifiedTypeReference qualifiedTypeReference, BlockScope scope) {
+ endVisit(qualifiedTypeReference);
+ }
+ public void endVisit(QualifiedTypeReference qualifiedTypeReference, ClassScope scope) {
+ endVisit(qualifiedTypeReference);
+ }
+ public void endVisit(SingleNameReference singleNameReference, BlockScope scope) {
+ endVisit(singleNameReference);
+ }
+ public void endVisit(SingleTypeReference singleTypeReference, BlockScope scope) {
+ endVisit(singleTypeReference);
+ }
+ public void endVisit(SingleTypeReference singleTypeReference, ClassScope scope) {
+ endVisit(singleTypeReference);
+ }
+ public void endVisit(SuperReference superReference, BlockScope scope) {
+ endVisit(superReference);
+ }
+ public void endVisit(ThisReference thisReference, BlockScope scope) {
+ endVisit(thisReference);
+ }
+ public void endVisit(UnaryExpression unaryExpression, BlockScope scope) {
+ endVisit(unaryExpression);
+ }
+ public boolean visit(AllocationExpression allocationExpression, BlockScope scope) {
+ return this.visit(allocationExpression);
+ }
+ public boolean visit(AND_AND_Expression and_and_Expression, BlockScope scope) {
+ return this.visit(and_and_Expression);
+ }
+ public boolean visit(ArrayAllocationExpression arrayAllocationExpression, BlockScope scope) {
+ return this.visit(arrayAllocationExpression);
+ }
+ public boolean visit(ArrayInitializer arrayInitializer, BlockScope scope) {
+ return this.visit(arrayInitializer);
+ }
+ public boolean visit(ArrayQualifiedTypeReference arrayQualifiedTypeReference, BlockScope scope) {
+ return this.visit(arrayQualifiedTypeReference);
+ }
+ public boolean visit(ArrayQualifiedTypeReference arrayQualifiedTypeReference, ClassScope scope) {
+ return this.visit(arrayQualifiedTypeReference);
+ }
+ public boolean visit(ArrayReference arrayReference, BlockScope scope) {
+ return this.visit(arrayReference);
+ }
+ public boolean visit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
+ return this.visit(arrayTypeReference);
+ }
+ public boolean visit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
+ return this.visit(arrayTypeReference);
+ }
+ public boolean visit(Assignment assignment, BlockScope scope) {
+ return this.visit(assignment);
+ }
+ public boolean visit(BinaryExpression binaryExpression, BlockScope scope) {
+ return this.visit(binaryExpression);
+ }
+ public boolean visit(CastExpression castExpression, BlockScope scope) {
+ return this.visit(castExpression);
+ }
+ public boolean visit(CompoundAssignment compoundAssignment, BlockScope scope) {
+ return this.visit(compoundAssignment);
+ }
+ public boolean visit(ConditionalExpression conditionalExpression, BlockScope scope) {
+ return this.visit(conditionalExpression);
+ }
+ public boolean visit(EqualExpression equalExpression, BlockScope scope) {
+ return this.visit(equalExpression);
+ }
+ public boolean visit(ExplicitConstructorCall explicitConstructor, BlockScope scope) {
+ return this.visit(explicitConstructor);
+ }
+ public boolean visit(FieldReference fieldReference, BlockScope scope) {
+ return this.visit(fieldReference);
+ }
+ public boolean visit(InstanceOfExpression instanceOfExpression, BlockScope scope) {
+ return this.visit(instanceOfExpression);
+ }
+ public boolean visit(MessageSend messageSend, BlockScope scope) {
+ return this.visit(messageSend);
+ }
+ public boolean visit(OR_OR_Expression or_or_Expression, BlockScope scope) {
+ return this.visit(or_or_Expression);
+ }
+ public boolean visit(PostfixExpression postfixExpression, BlockScope scope) {
+ return this.visit(postfixExpression);
+ }
+ public boolean visit(PrefixExpression prefixExpression, BlockScope scope) {
+ return this.visit(prefixExpression);
+ }
+ public boolean visit(QualifiedAllocationExpression qualifiedAllocationExpression, BlockScope scope) {
+ return this.visit(qualifiedAllocationExpression);
+ }
+ public boolean visit(QualifiedNameReference qualifiedNameReference, BlockScope scope) {
+ return this.visit(qualifiedNameReference);
+ }
+ public boolean visit(QualifiedSuperReference qualifiedSuperReference, BlockScope scope) {
+ return this.visit(qualifiedSuperReference);
+ }
+ public boolean visit(QualifiedThisReference qualifiedThisReference, BlockScope scope) {
+ return this.visit(qualifiedThisReference);
+ }
+ public boolean visit(QualifiedTypeReference qualifiedTypeReference, BlockScope scope) {
+ return this.visit(qualifiedTypeReference);
+ }
+ public boolean visit(QualifiedTypeReference qualifiedTypeReference, ClassScope scope) {
+ return this.visit(qualifiedTypeReference);
+ }
+ public boolean visit(SingleNameReference singleNameReference, BlockScope scope) {
+ return this.visit(singleNameReference);
+ }
+ public boolean visit(SingleTypeReference singleTypeReference, BlockScope scope) {
+ return this.visit(singleTypeReference);
+ }
+ public boolean visit(SingleTypeReference singleTypeReference, ClassScope scope) {
+ return this.visit(singleTypeReference);
+ }
+ public boolean visit(SuperReference superReference, BlockScope scope) {
+ return this.visit(superReference);
+ }
+ public boolean visit(ThisReference thisReference, BlockScope scope) {
+ return this.visit(thisReference);
+ }
+ public boolean visit(UnaryExpression unaryExpression, BlockScope scope) {
+ return this.visit(unaryExpression);
+ }
+
+ private void endVisit(AstNode astNode) {
+ if(result && parent == null && astNode != searchedNode) {
+ if(!(astNode instanceof AllocationExpression && ((AllocationExpression) astNode).type == searchedNode)
+ && !(astNode instanceof ConditionalExpression && ((ConditionalExpression) astNode).valueIfTrue == searchedNode)
+ && !(astNode instanceof ConditionalExpression && ((ConditionalExpression) astNode).valueIfFalse == searchedNode)) {
+ parent = astNode;
+ }
+ }
+ }
+ private boolean visit(AstNode astNode) {
+ if(astNode == searchedNode) {
+ result = true;
+ }
+ return !result;
+ }
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeFound.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeFound.java
index 87fc2a7..651a625 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeFound.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionNodeFound.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnArgumentName.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnArgumentName.java
index 0c8364d..5ccacad 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnArgumentName.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnArgumentName.java
@@ -1,26 +1,27 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class CompletionOnArgumentName extends Argument {
private static final char[] FAKENAMESUFFIX = " ".toCharArray(); //$NON-NLS-1$
public char[] realName;
+ public boolean isCatchArgument = false;
public CompletionOnArgumentName(char[] name , long posNom , TypeReference tr , int modifiers){
super(CharOperation.concat(name, FAKENAMESUFFIX), posNom, tr, modifiers);
this.realName = name;
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassLiteralAccess.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassLiteralAccess.java
index 13387a1..e798863 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassLiteralAccess.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassLiteralAccess.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassReference.java
index 41c9120..b7b9a00 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnClassReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
public class CompletionOnClassReference extends CompletionOnSingleTypeReference {
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExceptionReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExceptionReference.java
index f33b116..62ce069 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExceptionReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExceptionReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExplicitConstructorCall.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExplicitConstructorCall.java
index 9125831..89b5048 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExplicitConstructorCall.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnExplicitConstructorCall.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
@@ -41,6 +41,12 @@
}
public void resolve(BlockScope scope) {
ReferenceBinding receiverType = scope.enclosingSourceType();
+
+ if (arguments != null) {
+ int argsLength = arguments.length;
+ for (int a = argsLength; --a >= 0;)
+ arguments[a].resolveType(scope);
+ }
if (accessMode != This && receiverType != null) {
if (receiverType.isHierarchyInconsistent())
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnFieldName.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnFieldName.java
index 9b0c4dc..6b2a24e 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnFieldName.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnFieldName.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class CompletionOnFieldName extends FieldDeclaration {
private static final char[] FAKENAMESUFFIX = " ".toCharArray(); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnFieldType.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnFieldType.java
index 969cc0d..be4ed62 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnFieldType.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnFieldType.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
@@ -31,6 +31,7 @@
* before the cursor.
*/
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
@@ -42,7 +43,7 @@
this.sourceStart = type.sourceStart;
this.sourceEnd = type.sourceEnd;
this.type = type;
- this.name = NoChar;
+ this.name = CharOperation.NO_CHAR;
this.isLocalVariable = isLocalVariable;
}
public TypeBinding getTypeBinding(Scope scope) {
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnImportReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnImportReference.java
index 0e64220..cabdfe9 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnImportReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnImportReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnInterfaceReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnInterfaceReference.java
index 5f7d43f..1f03c17 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnInterfaceReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnInterfaceReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
public class CompletionOnInterfaceReference extends CompletionOnSingleTypeReference {
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword.java
new file mode 100644
index 0000000..4eaa384
--- /dev/null
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.codeassist.complete;
+
+public interface CompletionOnKeyword {
+ char[] getToken();
+ char[][] getPossibleKeywords();
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword1.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword1.java
new file mode 100644
index 0000000..fc58f0f
--- /dev/null
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword1.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.codeassist.complete;
+
+import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
+import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+
+public class CompletionOnKeyword1 extends SingleTypeReference implements CompletionOnKeyword {
+ private char[][] possibleKeywords;
+ public CompletionOnKeyword1(char[] token, long pos, char[] possibleKeyword) {
+ this(token, pos, new char[][]{possibleKeyword});
+ }
+ public CompletionOnKeyword1(char[] token, long pos, char[][] possibleKeywords) {
+ super(token, pos);
+ this.possibleKeywords = possibleKeywords;
+ }
+ public char[] getToken() {
+ return token;
+ }
+ public char[][] getPossibleKeywords() {
+ return possibleKeywords;
+ }
+ public void aboutToResolve(Scope scope) {
+ getTypeBinding(scope);
+ }
+ public TypeBinding getTypeBinding(Scope scope) {
+ throw new CompletionNodeFound(this, scope);
+ }
+ public String toStringExpression(int tab){
+ return "<CompleteOnKeyword:"+new String(token)+">"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword2.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword2.java
new file mode 100644
index 0000000..6fa6cb7
--- /dev/null
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword2.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.codeassist.complete;
+
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
+
+public class CompletionOnKeyword2 extends ImportReference implements CompletionOnKeyword {
+ private char[] token;
+ private long pos;
+ private char[][] possibleKeywords;
+ public CompletionOnKeyword2(char[] token, long pos, char[][] possibleKeywords) {
+ super(new char[][]{token}, new long[]{pos}, false);
+ this.token = token;
+ this.pos = pos;
+ this.possibleKeywords = possibleKeywords;
+ }
+ public char[] getToken() {
+ return token;
+ }
+ public char[][] getPossibleKeywords() {
+ return possibleKeywords;
+ }
+ public String toString(int tab, boolean withOnDemand) {
+ return "<CompleteOnKeyword:" + new String(token) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword3.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword3.java
new file mode 100644
index 0000000..a0fa00b
--- /dev/null
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword3.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.codeassist.complete;
+
+import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+
+public class CompletionOnKeyword3 extends SingleNameReference implements CompletionOnKeyword{
+ private char[] token;
+ private long pos;
+ private char[][] possibleKeywords;
+ public CompletionOnKeyword3(char[] token, long pos, char[] possibleKeyword) {
+ this(token, pos, new char[][]{possibleKeyword});
+ }
+ public CompletionOnKeyword3(char[] token, long pos, char[][] possibleKeywords) {
+ super(token, pos);
+ this.token = token;
+ this.pos = pos;
+ this.possibleKeywords = possibleKeywords;
+ }
+ public char[] getToken() {
+ return token;
+ }
+ public char[][] getPossibleKeywords() {
+ return possibleKeywords;
+ }
+ public TypeBinding resolveType(BlockScope scope) {
+ throw new CompletionNodeFound(this, scope);
+ }
+ public String toStringExpression() {
+ return "<CompleteOnKeyword:" + new String(token) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnLocalName.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnLocalName.java
index 07f1185..ecf1d40 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnLocalName.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnLocalName.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class CompletionOnLocalName extends LocalDeclaration {
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMemberAccess.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMemberAccess.java
index 99b14e9..2e8f6fa 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMemberAccess.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMemberAccess.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
@@ -55,4 +55,4 @@
return "<CompleteOnMemberAccess:" //$NON-NLS-1$
+ super.toStringExpression() + ">"; //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSend.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSend.java
index 59d4e56..cff6067 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSend.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSend.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
@@ -38,7 +38,13 @@
public class CompletionOnMessageSend extends MessageSend {
public TypeBinding resolveType(BlockScope scope) {
- if (receiver == ThisReference.ThisImplicit)
+ if (arguments != null) {
+ int argsLength = arguments.length;
+ for (int a = argsLength; --a >= 0;)
+ arguments[a].resolveType(scope);
+ }
+
+ if (receiver.isImplicitThis())
throw new CompletionNodeFound(this, null, scope);
TypeBinding receiverType = receiver.resolveType(scope);
@@ -53,7 +59,7 @@
public String toStringExpression() {
String s = "<CompleteOnMessageSend:"; //$NON-NLS-1$
- if (receiver != ThisReference.ThisImplicit)
+ if (!receiver.isImplicitThis())
s = s + receiver.toStringExpression() + "."; //$NON-NLS-1$
s = s + new String(selector) + "("; //$NON-NLS-1$
if (arguments != null) {
@@ -67,4 +73,4 @@
s = s + ")>"; //$NON-NLS-1$
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMethodName.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMethodName.java
index dafcf9d..25c0fd6 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMethodName.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMethodName.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
import org.eclipse.jdt.internal.compiler.CompilationResult;
@@ -58,4 +58,4 @@
s += ">"; //$NON-NLS-1$
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMethodReturnType.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMethodReturnType.java
index 1d09e9e..206726d 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMethodReturnType.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMethodReturnType.java
@@ -1,19 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
-import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
public class CompletionOnMethodReturnType extends MethodDeclaration {
public CompletionOnMethodReturnType(TypeReference returnType, CompilationResult compilationResult){
@@ -23,12 +22,12 @@
this.sourceEnd = returnType.sourceEnd;
}
- public void resolveStatements(ClassScope upperScope) {
- throw new CompletionNodeFound(this, upperScope);
+ public void resolveStatements() {
+ throw new CompletionNodeFound(this, this.scope);
}
public String toString(int tab) {
return returnType.toString(tab);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnPackageReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnPackageReference.java
index 016a2a9..1edde4f 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnPackageReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnPackageReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedAllocationExpression.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedAllocationExpression.java
index 72eb755..30ebd68 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedAllocationExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
@@ -39,25 +39,29 @@
public class CompletionOnQualifiedAllocationExpression extends QualifiedAllocationExpression {
public TypeBinding resolveType(BlockScope scope) {
- TypeBinding typeBinding = null;
+ if (arguments != null) {
+ int argsLength = arguments.length;
+ for (int a = argsLength; --a >= 0;)
+ arguments[a].resolveType(scope);
+ }
+
if (enclosingInstance != null) {
TypeBinding enclosingType = enclosingInstance.resolveType(scope);
- if (!(enclosingType instanceof ReferenceBinding)) {
- scope.problemReporter().illegalPrimitiveOrArrayTypeForEnclosingInstance(enclosingType, enclosingInstance);
+ if (enclosingType == null || !(enclosingType instanceof ReferenceBinding)) {
throw new CompletionNodeFound();
}
- typeBinding = ((SingleTypeReference) type).resolveTypeEnclosing(scope, (ReferenceBinding) enclosingType);
- if (!(typeBinding instanceof ReferenceBinding))
+ this.resolvedType = ((SingleTypeReference) type).resolveTypeEnclosing(scope, (ReferenceBinding) enclosingType);
+ if (!(this.resolvedType instanceof ReferenceBinding))
throw new CompletionNodeFound(); // no need to continue if its an array or base type
- if (typeBinding.isInterface()) // handle the anonymous class definition case
- typeBinding = scope.getJavaLangObject();
+ if (this.resolvedType.isInterface()) // handle the anonymous class definition case
+ this.resolvedType = scope.getJavaLangObject();
} else {
- typeBinding = type.resolveType(scope);
- if (!(typeBinding instanceof ReferenceBinding))
+ this.resolvedType = type.resolveType(scope);
+ if (!(this.resolvedType instanceof ReferenceBinding))
throw new CompletionNodeFound(); // no need to continue if its an array or base type
}
- throw new CompletionNodeFound(this, typeBinding, scope);
+ throw new CompletionNodeFound(this, this.resolvedType, scope);
}
public String toStringExpression(int tab) {
return
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedClassReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedClassReference.java
index 763238e..298b06f 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedClassReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedClassReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
public class CompletionOnQualifiedClassReference extends CompletionOnQualifiedTypeReference {
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedExceptionReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedExceptionReference.java
index bb82b29..f13341b 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedExceptionReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedExceptionReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedInterfaceReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedInterfaceReference.java
index e786dc7..f4f3870 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedInterfaceReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedInterfaceReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
public class CompletionOnQualifiedInterfaceReference extends CompletionOnQualifiedTypeReference {
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java
index 77e345a..257da1e 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedNameReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java
index 6d4b4d8..78469c3 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnQualifiedTypeReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleNameReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleNameReference.java
index effaa36..7c7b9d7 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleNameReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleNameReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
@@ -35,8 +35,15 @@
import org.eclipse.jdt.internal.compiler.lookup.*;
public class CompletionOnSingleNameReference extends SingleNameReference {
+public char[][] possibleKeywords;
+public boolean canBeExplicitConstructor;
public CompletionOnSingleNameReference(char[] source, long pos) {
+ this(source, pos, null, false);
+}
+public CompletionOnSingleNameReference(char[] source, long pos, char[][] possibleKeywords, boolean canBeExplicitConstructor) {
super(source, pos);
+ this.possibleKeywords = possibleKeywords;
+ this.canBeExplicitConstructor = canBeExplicitConstructor;
}
public TypeBinding resolveType(BlockScope scope) {
throw new CompletionNodeFound(this, scope);
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java
index 28ee0d2..1891e70 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnSingleTypeReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
@@ -60,4 +60,7 @@
return "<CompleteOnType:" + new String(token) + ">" ; //$NON-NLS-2$ //$NON-NLS-1$
}
+public String toStringExpression(){
+ return this.toStringExpression(0);
+}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
index 2b2a20c..a90e13d 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
@@ -25,37 +25,65 @@
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.problem.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.codeassist.impl.*;
public class CompletionParser extends AssistParser {
+ // OWNER
+ protected static final int COMPLETION_PARSER = 1024;
+ protected static final int COMPLETION_OR_ASSIST_PARSER = ASSIST_PARSER + COMPLETION_PARSER;
+
+ // KIND : all values known by CompletionParser are between 1025 and 1549
+ protected static final int K_BLOCK_DELIMITER = COMPLETION_PARSER + 1; // whether we are inside a block
+ protected static final int K_SELECTOR_INVOCATION_TYPE = COMPLETION_PARSER + 2; // whether we are inside a message send
+ protected static final int K_SELECTOR_QUALIFIER = COMPLETION_PARSER + 3; // whether we are inside a message send
+ protected static final int K_BETWEEN_CATCH_AND_RIGHT_PAREN = COMPLETION_PARSER + 4; // whether we are between the keyword 'catch' and the following ')'
+ protected static final int K_NEXT_TYPEREF_IS_CLASS = COMPLETION_PARSER + 5; // whether the next type reference is a class
+ protected static final int K_NEXT_TYPEREF_IS_INTERFACE = COMPLETION_PARSER + 6; // whether the next type reference is an interface
+ protected static final int K_NEXT_TYPEREF_IS_EXCEPTION = COMPLETION_PARSER + 7; // whether the next type reference is an exception
+ protected static final int K_BETWEEN_NEW_AND_LEFT_BRACKET = COMPLETION_PARSER + 8; // whether we are between the keyword 'new' and the following left braket, ie. '[', '(' or '{'
+ protected static final int K_INSIDE_THROW_STATEMENT = COMPLETION_PARSER + 9; // whether we are between the keyword 'throw' and the end of a throw statement
+ protected static final int K_INSIDE_RETURN_STATEMENT = COMPLETION_PARSER + 10; // whether we are between the keyword 'return' and the end of a return statement
+ protected static final int K_CAST_STATEMENT = COMPLETION_PARSER + 11; // whether we are between ')' and the end of a cast statement
+ protected static final int K_LOCAL_INITIALIZER_DELIMITER = COMPLETION_PARSER + 12;
+ protected static final int K_ARRAY_INITIALIZER = COMPLETION_PARSER + 13;
+ protected static final int K_ARRAY_CREATION = COMPLETION_PARSER + 14;
+ protected static final int K_UNARY_OPERATOR = COMPLETION_PARSER + 15;
+ protected static final int K_BINARY_OPERATOR = COMPLETION_PARSER + 16;
+ protected static final int K_ASSISGNMENT_OPERATOR = COMPLETION_PARSER + 17;
+ protected static final int K_CONDITIONAL_OPERATOR = COMPLETION_PARSER + 18;
+ protected static final int K_BETWEEN_IF_AND_RIGHT_PAREN = COMPLETION_PARSER + 19;
+ protected static final int K_BETWEEN_WHILE_AND_RIGHT_PAREN = COMPLETION_PARSER + 20;
+ protected static final int K_BETWEEN_FOR_AND_RIGHT_PAREN = COMPLETION_PARSER + 21;
+ protected static final int K_BETWEEN_SWITCH_AND_RIGHT_PAREN = COMPLETION_PARSER + 22;
+ protected static final int K_BETWEEN_SYNCHRONIZED_AND_RIGHT_PAREN = COMPLETION_PARSER + 23;
+ protected static final int K_INSIDE_ASSERT_STATEMENT = COMPLETION_PARSER + 24;
+ protected static final int K_SWITCH_LABEL= COMPLETION_PARSER + 25;
+ protected static final int K_BETWEEN_CASE_AND_COLON = COMPLETION_PARSER + 26;
+ protected static final int K_BETWEEN_DEFAULT_AND_COLON = COMPLETION_PARSER + 27;
+ protected static final int K_BETWEEN_LEFT_AND_RIGHT_BRACKET = COMPLETION_PARSER + 28;
+
/* public fields */
public int cursorLocation;
- public char[][] labels; // the visible labels up to the cursor location
public AstNode assistNodeParent; // the parent node of assist node
/* the following fields are internal flags */
- boolean betweenNewAndLeftBraket; // whether we are between the keyword 'new' and the following left braket, ie. '[', '(' or '{'
- boolean betweenCatchAndRightParen; // whether we are between the keyword 'catch' and the following ')'
- boolean completionBehindDot; // true when completion identifier immediately follows a dot
+ // block kind
+ static final int IF = 1;
+ static final int TRY = 2;
+ static final int CATCH = 3;
+ static final int WHILE = 4;
+ static final int SWITCH = 5;
+ static final int FOR = 6;
+ static final int DO = 7;
+ static final int SYNCHRONIZED = 8;
+ static final int METHOD = 9;
- boolean nextTypeReferenceIsClass;
- boolean nextTypeReferenceIsException;
- boolean nextTypeReferenceIsInterface;
+ // label kind
+ static final int DEFAULT = 1;
- int bracketDepth;
- int throwBracketDepth;
-
- // the stacks of types and qualifiers for invocations (ie. method invocations, allocation expressions and
- // explicit constructor invocations). They use the same stack pointer as the selector stack (ie. invocationPtr)
- // the invocation type stack contains one of the invocation type constants below
- // the qualifier stack contains pointers to the expression stack or -1 if there is no qualifier
- // (a qualifier is the expression that qualifies a 'new', a 'super' constructor or a 'this' constructor
- // or it is the receiver of a message send)
- int[] invocationTypeStack = new int[StackIncrement];
- int[] qualifierStack = new int[StackIncrement];
-
// invocation type constants
static final int EXPLICIT_RECEIVER = 0;
static final int NO_RECEIVER = -1;
@@ -63,6 +91,9 @@
static final int NAME_RECEIVER = -3;
static final int ALLOCATION = -4;
static final int QUALIFIED_ALLOCATION = -5;
+
+ static final int QUESTION = 1;
+ static final int COLON = 2;
// the type of the current invocation (one of the invocation type constants)
int invocationType;
@@ -70,23 +101,20 @@
// a pointer in the expression stack to the qualifier of a invocation
int qualifier;
- // a stack of label counters
- // a new counter is pushed on the stack each time when a method (or a constructor) is entered,
- // it is poped when the method (or constructor) is exited,
- // it is incremented when a new label is defined
- int labelCounterPtr;
- int[] labelCounterStack = new int[StackIncrement];
-
- // a stack of invocationPtr: contains the first invocationPtr of a block
- // the current invocationPtr+1 is pushed when a block is entered
- // it is poped when a block is exited
- int blockInvocationPtr;
- int[] blockInvocationStack = new int[StackIncrement];
-
// last modifiers info
int lastModifiers = AccDefault;
int lastModifiersStart = -1;
+ // depth of '(', '{' and '[]'
+ int bracketDepth;
+
+ // show if the current token can be an explicit constructor
+ int canBeExplicitConstructor = NO;
+ static final int NO = 0;
+ static final int NEXTTOKEN = 1;
+ static final int YES = 2;
+
+
public CompletionParser(ProblemReporter problemReporter, boolean assertMode) {
super(problemReporter, assertMode);
}
@@ -94,10 +122,18 @@
return ((CompletionScanner)scanner).completionIdentifier;
}
protected void attachOrphanCompletionNode(){
+ if(assistNode == null) return;
+
if (this.isOrphanCompletionNode) {
AstNode orphan = this.assistNode;
this.isOrphanCompletionNode = false;
+ if (currentElement instanceof RecoveredUnit){
+ if (orphan instanceof ImportReference){
+ currentElement.add((ImportReference)orphan, 0);
+ }
+ }
+
/* if in context of a type, then persists the identifier into a fake field return type */
if (currentElement instanceof RecoveredType){
RecoveredType recoveredType = (RecoveredType)currentElement;
@@ -152,34 +188,324 @@
}
// the following code applies only in methods, constructors or initializers
- if ((!this.inMethodStack[this.inMethodPtr] && !this.inFieldInitializationStack[this.inFieldInitializationPtr])) {
+ if ((!isInsideMethod() && !isInsideFieldInitialization())) {
return;
}
// push top expression on ast stack if it contains the completion node
Expression expression;
- if (this.expressionPtr > -1 && containsCompletionNode(expression = this.expressionStack[this.expressionPtr])) {
- /* check for completion at the beginning of method body
- behind an invalid signature
- */
- RecoveredMethod method = currentElement.enclosingMethod();
- if (method != null){
- AbstractMethodDeclaration methodDecl = method.methodDeclaration;
- if ((methodDecl.bodyStart == methodDecl.sourceEnd+1) // was missing opening brace
- && (scanner.getLineNumber(expression.sourceStart) == scanner.getLineNumber(methodDecl.sourceEnd))){
- return;
+ if (this.expressionPtr > -1) {
+ expression = this.expressionStack[this.expressionPtr];
+ CompletionNodeDetector detector = new CompletionNodeDetector(assistNode, expression);
+ if(detector.containsCompletionNode()) {
+ /* check for completion at the beginning of method body
+ behind an invalid signature
+ */
+ RecoveredMethod method = currentElement.enclosingMethod();
+ if (method != null){
+ AbstractMethodDeclaration methodDecl = method.methodDeclaration;
+ if ((methodDecl.bodyStart == methodDecl.sourceEnd+1) // was missing opening brace
+ && (scanner.getLineNumber(expression.sourceStart) == scanner.getLineNumber(methodDecl.sourceEnd))){
+ return;
+ }
}
- }
- if (expression instanceof AllocationExpression) {
- // keep the context if it is an allocation expression
- Statement statement = (Statement)wrapWithExplicitConstructorCallIfNeeded(expression);
- currentElement = currentElement.add(statement, 0);
- } else {
- Statement statement = (Statement)wrapWithExplicitConstructorCallIfNeeded(this.assistNode);
- currentElement = currentElement.add(statement, 0);
+ if(expression == assistNode
+ || (expression instanceof AllocationExpression
+ && ((AllocationExpression)expression).type == assistNode)){
+ buildMoreCompletionContext(expression);
+ } else {
+ assistNodeParent = detector.getCompletionNodeParent();
+ if(assistNodeParent != null) {
+ currentElement = currentElement.add((Statement)assistNodeParent, 0);
+ } else {
+ currentElement = currentElement.add(expression, 0);
+ }
+ }
}
}
}
+private void buildMoreCompletionContext(Expression expression) {
+ Statement statement = expression;
+ int kind = topKnownElementKind(COMPLETION_OR_ASSIST_PARSER);
+ if(kind != 0) {
+ int info = topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER);
+ nextElement : switch (kind) {
+ case K_SELECTOR_QUALIFIER :
+ int selector = topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER, 2);
+ if(selector == THIS_CONSTRUCTOR || selector == SUPER_CONSTRUCTOR) {
+ ExplicitConstructorCall call = new ExplicitConstructorCall(
+ (selector == THIS_CONSTRUCTOR) ?
+ ExplicitConstructorCall.This :
+ ExplicitConstructorCall.Super
+ );
+ call.arguments = new Expression[] {expression};
+ call.sourceStart = expression.sourceStart;
+ call.sourceEnd = expression.sourceEnd;
+ assistNodeParent = call;
+ } else {
+ int invocationType = topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER,1);
+ int qualifierExprPtr = info;
+
+ // find arguments
+ int length = expressionLengthStack[expressionLengthPtr];
+
+ // search previous arguments if missing
+ if(expressionLengthPtr > 0 && length == 1) {
+ int start = (int) (identifierPositionStack[selector] >>> 32);
+ if(this.expressionStack[expressionPtr-1] != null && this.expressionStack[expressionPtr-1].sourceStart > start) {
+ length += expressionLengthStack[expressionLengthPtr-1];;
+ }
+
+ }
+
+ Expression[] arguments = null;
+ if (length != 0) {
+ arguments = new Expression[length];
+ expressionPtr -= length;
+ System.arraycopy(expressionStack, expressionPtr + 1, arguments, 0, length-1);
+ arguments[length-1] = expression;
+ };
+
+ if(invocationType != ALLOCATION && invocationType != QUALIFIED_ALLOCATION) {
+ MessageSend messageSend = new MessageSend();
+ messageSend.selector = identifierStack[selector];
+ messageSend.arguments = arguments;
+
+ // find receiver
+ switch (invocationType) {
+ case NO_RECEIVER:
+ messageSend.receiver = ThisReference.implicitThis();
+ break;
+ case NAME_RECEIVER:
+ // remove special flags for primitive types
+ while (this.identifierLengthPtr >= 0 && this.identifierLengthStack[this.identifierLengthPtr] < 0) {
+ this.identifierLengthPtr--;
+ }
+
+ // remove selector
+ this.identifierPtr--;
+ this.identifierLengthStack[this.identifierLengthPtr]--;
+ // consume the receiver
+ messageSend.receiver = this.getUnspecifiedReference();
+ break;
+ case SUPER_RECEIVER:
+ messageSend.receiver = new SuperReference(0, 0);
+ break;
+ case EXPLICIT_RECEIVER:
+ messageSend.receiver = this.expressionStack[qualifierExprPtr];
+ break;
+ default :
+ messageSend.receiver = ThisReference.implicitThis();
+ break;
+ }
+ assistNodeParent = messageSend;
+ } else {
+ if(invocationType == ALLOCATION) {
+ AllocationExpression allocationExpr = new AllocationExpression();
+ allocationExpr.arguments = arguments;
+ allocationExpr.type = getTypeReference(0);
+ assistNodeParent = allocationExpr;
+ } else {
+ QualifiedAllocationExpression allocationExpr = new QualifiedAllocationExpression();
+ allocationExpr.enclosingInstance = this.expressionStack[qualifierExprPtr];
+ allocationExpr.arguments = arguments;
+ allocationExpr.type = getTypeReference(0);
+ assistNodeParent = allocationExpr;
+ }
+ }
+ }
+ break nextElement;
+ case K_INSIDE_RETURN_STATEMENT :
+ if(info == bracketDepth) {
+ ReturnStatement returnStatement = new ReturnStatement(expression, expression.sourceStart, expression.sourceEnd);
+ assistNodeParent = returnStatement;
+ }
+ break nextElement;
+ case K_CAST_STATEMENT :
+ Expression castType;
+ if(this.expressionPtr > 0
+ && ((castType = this.expressionStack[this.expressionPtr-1]) instanceof TypeReference
+ || castType instanceof NameReference)) {
+ CastExpression cast = new CastExpression(expression, getTypeReference(castType));
+ cast.sourceStart = castType.sourceStart;
+ cast.sourceEnd= expression.sourceEnd;
+ assistNodeParent = cast;
+ }
+ break nextElement;
+ case K_UNARY_OPERATOR :
+ if(expressionPtr > -1) {
+ Expression operatorExpression = null;
+ switch (info) {
+ case PLUS_PLUS :
+ operatorExpression = new PrefixExpression(expression,IntLiteral.One, PLUS, expression.sourceStart);
+ break;
+ case MINUS_MINUS :
+ operatorExpression = new PrefixExpression(expression,IntLiteral.One, MINUS, expression.sourceStart);
+ break;
+ default :
+ operatorExpression = new UnaryExpression(expression, info);
+ break;
+ }
+ if(operatorExpression != null) {
+ assistNodeParent = operatorExpression;
+ }
+ }
+ break nextElement;
+ case K_BINARY_OPERATOR :
+ if(expressionPtr > 0) {
+ Expression operatorExpression = null;
+ switch (info) {
+ case AND_AND :
+ operatorExpression = new AND_AND_Expression(this.expressionStack[expressionPtr-1], expression, info);
+ break;
+ case OR_OR :
+ operatorExpression = new OR_OR_Expression(this.expressionStack[expressionPtr-1], expression, info);
+ break;
+ case EQUAL_EQUAL :
+ case NOT_EQUAL :
+ operatorExpression = new EqualExpression(this.expressionStack[expressionPtr-1], expression, info);
+ break;
+ case INSTANCEOF :
+ // should never occur
+ break;
+ default :
+ operatorExpression = new BinaryExpression(this.expressionStack[expressionPtr-1], expression, info);
+ break;
+ }
+ if(operatorExpression != null) {
+ assistNodeParent = operatorExpression;
+ }
+ }
+ break nextElement;
+ case K_ARRAY_INITIALIZER :
+ ArrayInitializer arrayInitializer = new ArrayInitializer();
+ arrayInitializer.expressions = new Expression[]{expression};
+ expressionPtr -= expressionLengthStack[expressionLengthPtr--];
+
+ if(expressionLengthPtr > -1
+ && expressionPtr > -1
+ && this.expressionStack[expressionPtr] != null
+ && this.expressionStack[expressionPtr].sourceStart > info) {
+ expressionLengthPtr--;
+ }
+
+ lastCheckPoint = scanner.currentPosition;
+
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER, 1) == K_ARRAY_CREATION) {
+ ArrayAllocationExpression allocationExpression = new ArrayAllocationExpression();
+ allocationExpression.type = getTypeReference(0);
+ int length = expressionLengthStack[expressionLengthPtr];
+ allocationExpression.dimensions = new Expression[length];
+
+ allocationExpression.initializer = arrayInitializer;
+ assistNodeParent = allocationExpression;
+ } else if(currentElement instanceof RecoveredField) {
+ RecoveredField recoveredField = (RecoveredField) currentElement;
+ if(recoveredField.fieldDeclaration.type.dimensions() == 0) {
+ Block block = new Block(0);
+ block.sourceStart = info;
+ currentElement = currentElement.add(block, 1);
+ } else {
+ statement = arrayInitializer;
+ }
+ } else if(currentElement instanceof RecoveredLocalVariable) {
+ RecoveredLocalVariable recoveredLocalVariable = (RecoveredLocalVariable) currentElement;
+ if(recoveredLocalVariable.localDeclaration.type.dimensions() == 0) {
+ Block block = new Block(0);
+ block.sourceStart = info;
+ currentElement = currentElement.add(block, 1);
+ } else {
+ statement = arrayInitializer;
+ }
+ } else {
+ statement = arrayInitializer;
+ }
+ break nextElement;
+ case K_ARRAY_CREATION :
+ ArrayAllocationExpression allocationExpression = new ArrayAllocationExpression();
+ allocationExpression.type = getTypeReference(0);
+ allocationExpression.dimensions = new Expression[]{expression};
+
+ assistNodeParent = allocationExpression;
+ break nextElement;
+ case K_ASSISGNMENT_OPERATOR :
+ if(expressionPtr > 0 && expressionStack[expressionPtr - 1] != null) {
+ Assignment assignment;
+ if(info == EQUAL) {
+ assignment = new Assignment(
+ expressionStack[expressionPtr - 1],
+ expression,
+ expression.sourceEnd
+ );
+ } else {
+ assignment = new CompoundAssignment(
+ expressionStack[expressionPtr - 1],
+ expression,
+ info,
+ expression.sourceEnd
+ );
+ }
+ assistNodeParent = assignment;
+ }
+ break nextElement;
+ case K_CONDITIONAL_OPERATOR :
+ if(info == QUESTION) {
+ if(expressionPtr > 0) {
+ expressionPtr--;
+ expressionLengthPtr--;
+ expressionStack[expressionPtr] = expressionStack[expressionPtr+1];
+ popElement(K_CONDITIONAL_OPERATOR);
+ buildMoreCompletionContext(expression);
+ return;
+ }
+ } else {
+ if(expressionPtr > 1) {
+ expressionPtr = expressionPtr - 2;
+ expressionLengthPtr = expressionLengthPtr - 2;
+ expressionStack[expressionPtr] = expressionStack[expressionPtr+2];
+ popElement(K_CONDITIONAL_OPERATOR);
+ buildMoreCompletionContext(expression);
+ return;
+ }
+ }
+ break nextElement;
+ case K_BETWEEN_LEFT_AND_RIGHT_BRACKET :
+ ArrayReference arrayReference;
+ if(identifierPtr < 0 && expressionPtr > 0 && expressionStack[expressionPtr] == expression) {
+ arrayReference =
+ new ArrayReference(
+ expressionStack[expressionPtr-1],
+ expression);
+ } else {
+ arrayReference =
+ new ArrayReference(
+ getUnspecifiedReferenceOptimized(),
+ expression);
+ }
+ assistNodeParent = arrayReference;
+ break;
+
+ }
+ }
+ if(assistNodeParent != null) {
+ currentElement = currentElement.add((Statement)assistNodeParent, 0);
+ } else {
+ if(currentElement instanceof RecoveredField
+ && ((RecoveredField) currentElement).fieldDeclaration.initialization == null) {
+
+ assistNodeParent = ((RecoveredField) currentElement).fieldDeclaration;
+ currentElement = currentElement.add(statement, 0);
+ } else if(currentElement instanceof RecoveredLocalVariable
+ && ((RecoveredLocalVariable) currentElement).localDeclaration.initialization == null) {
+
+ assistNodeParent = ((RecoveredLocalVariable) currentElement).localDeclaration;
+ currentElement = currentElement.add(statement, 0);
+ } else {
+ currentElement = currentElement.add(expression, 0);
+ }
+ }
+}
+
public int bodyEnd(AbstractMethodDeclaration method){
return cursorLocation;
}
@@ -191,10 +517,12 @@
* Returns whether we found a completion node.
*/
private boolean checkCatchClause() {
- if (this.betweenCatchAndRightParen && this.identifierPtr > -1) {
+ if ((topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_CATCH_AND_RIGHT_PAREN) && this.identifierPtr > -1) {
// NB: if the cursor is on the variable, then it has been reduced (so identifierPtr is -1),
// thus this can only be a completion on the type of the catch clause
+ pushOnElementStack(K_NEXT_TYPEREF_IS_EXCEPTION);
this.assistNode = getTypeReference(0);
+ popElement(K_NEXT_TYPEREF_IS_EXCEPTION);
this.lastCheckPoint = this.assistNode.sourceEnd + 1;
this.isOrphanCompletionNode = true;
return true;
@@ -206,14 +534,18 @@
* Returns whether we found a completion node.
*/
private boolean checkClassInstanceCreation() {
- if (this.betweenNewAndLeftBraket) {
+ if (topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_NEW_AND_LEFT_BRACKET) {
// completion on type inside an allocation expression
- if(this.throwBracketDepth != -1 && this.throwBracketDepth == this.bracketDepth) {
- this.nextTypeReferenceIsException = true;
+ TypeReference type;
+ if (topKnownElementKind(COMPLETION_OR_ASSIST_PARSER, 1) == K_INSIDE_THROW_STATEMENT
+ && topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER, 1) == this.bracketDepth) {
+ pushOnElementStack(K_NEXT_TYPEREF_IS_EXCEPTION);
+ type = getTypeReference(0);
+ popElement(K_NEXT_TYPEREF_IS_EXCEPTION);
+ } else {
+ type = getTypeReference(0);
}
- TypeReference type = getTypeReference(0);
- this.nextTypeReferenceIsException = false;
this.assistNode = type;
this.lastCheckPoint = type.sourceEnd + 1;
if (this.invocationType == ALLOCATION) {
@@ -234,6 +566,7 @@
this.expressionStack[this.qualifier] = allocExpr; // attach it now (it replaces the qualifier expression)
this.isOrphanCompletionNode = false;
}
+ popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET);
return true;
}
return false;
@@ -296,6 +629,89 @@
}
return false;
}
+private boolean checkKeyword() {
+ if (currentElement instanceof RecoveredUnit) {
+ RecoveredUnit unit = (RecoveredUnit) currentElement;
+ int index = -1;
+ if ((index = this.indexOfAssistIdentifier()) > -1) {
+ char[] ident = identifierStack[index];
+ long pos = identifierPositionStack[index];
+
+ char[][] keywords = new char[Keywords.COUNT][];
+ int count = 0;
+ if(unit.typeCount == 0
+ && lastModifiers == AccDefault
+ && CharOperation.prefixEquals(identifierStack[index], Keywords.IMPORT)) {
+ keywords[count++] = Keywords.IMPORT;
+ }
+ if(unit.typeCount == 0
+ && unit.importCount == 0
+ && lastModifiers == AccDefault
+ && compilationUnit.currentPackage == null
+ && CharOperation.prefixEquals(identifierStack[index], Keywords.PACKAGE)) {
+ keywords[count++] = Keywords.PACKAGE;
+ }
+ if((lastModifiers & AccPublic) == 0
+ && CharOperation.prefixEquals(identifierStack[index], Keywords.PUBLIC)) {
+ boolean hasNoPublicType = true;
+ for (int i = 0; i < unit.typeCount; i++) {
+ if((unit.types[i].typeDeclaration.modifiers & AccPublic) != 0) {
+ hasNoPublicType = false;
+ }
+ }
+ if(hasNoPublicType) {
+ keywords[count++] = Keywords.PUBLIC;
+ }
+ }
+ if((lastModifiers & AccAbstract) == 0
+ && (lastModifiers & AccFinal) == 0
+ && CharOperation.prefixEquals(identifierStack[index], Keywords.ABSTARCT)) {
+ keywords[count++] = Keywords.ABSTARCT;
+ }
+ if((lastModifiers & AccAbstract) == 0
+ && (lastModifiers & AccFinal) == 0
+ && CharOperation.prefixEquals(identifierStack[index], Keywords.FINAL)) {
+ keywords[count++] = Keywords.FINAL;
+ }
+ if(CharOperation.prefixEquals(identifierStack[index], Keywords.CLASS)) {
+ keywords[count++] = Keywords.CLASS;
+ }
+ if((lastModifiers & AccFinal) == 0
+ && CharOperation.prefixEquals(identifierStack[index], Keywords.INTERFACE)) {
+ keywords[count++] = Keywords.INTERFACE;
+ }
+ if(count != 0) {
+ System.arraycopy(keywords, 0, keywords = new char[count][], 0, count);
+
+ this.assistNode = new CompletionOnKeyword2(ident, pos, keywords);
+ this.lastCheckPoint = assistNode.sourceEnd + 1;
+ this.isOrphanCompletionNode = true;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+private boolean checkInstanceofKeyword() {
+ if(isInsideMethod()) {
+ int kind = topKnownElementKind(COMPLETION_OR_ASSIST_PARSER);
+ int index;
+ if(kind != K_BLOCK_DELIMITER
+ && (index = indexOfAssistIdentifier()) > -1
+ && expressionPtr > -1
+ && expressionLengthStack[expressionPtr] == 1
+ && CharOperation.prefixEquals(identifierStack[index], Keywords.INSTANCEOF)) {
+ this.assistNode = new CompletionOnKeyword3(
+ identifierStack[index],
+ identifierPositionStack[index],
+ Keywords.INSTANCEOF);
+ this.lastCheckPoint = assistNode.sourceEnd + 1;
+ this.isOrphanCompletionNode = true;
+ return true;
+ }
+ }
+ return false;
+}
/**
* Checks if the completion is inside a method invocation or a constructor invocation.
* Returns whether we found a completion node.
@@ -306,8 +722,7 @@
null;
boolean isEmptyNameCompletion = false;
boolean isEmptyAssistIdentifier = false;
- int startInvocationPtr = this.blockInvocationPtr >= 0 ? this.blockInvocationStack[this.blockInvocationPtr] : 0;
- if (this.invocationPtr >= startInvocationPtr
+ if (topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_SELECTOR_QUALIFIER
&& ((isEmptyNameCompletion = topExpression == this.assistNode && this.isEmptyNameCompletion()) // eg. it is something like "this.fred([cursor]" but it is not something like "this.fred(1 + [cursor]"
|| (isEmptyAssistIdentifier = this.indexOfAssistIdentifier() >= 0 && this.identifierStack[this.identifierPtr].length == 0))) { // eg. it is something like "this.fred(1 [cursor]"
@@ -321,8 +736,8 @@
}
// find receiver and qualifier
- int invocationType = this.invocationTypeStack[this.invocationPtr];
- int qualifierExprPtr = this.qualifierStack[this.invocationPtr];
+ int invocationType = topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER, 1);
+ int qualifierExprPtr = topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER);
// find arguments
int numArgs = this.expressionPtr - qualifierExprPtr;
@@ -349,7 +764,7 @@
switch (invocationType) {
case NO_RECEIVER:
// implicit this
- messageSend.receiver = ThisReference.ThisImplicit;
+ messageSend.receiver = ThisReference.implicitThis();
break;
case NAME_RECEIVER:
// remove special flags for primitive types
@@ -364,14 +779,14 @@
messageSend.receiver = this.getUnspecifiedReference();
break;
case SUPER_RECEIVER:
- messageSend.receiver = SuperReference.Super;
+ messageSend.receiver = new SuperReference(0, 0);
break;
case EXPLICIT_RECEIVER:
messageSend.receiver = this.expressionStack[qualifierExprPtr];
}
// set selector
- int selectorPtr = this.selectorStack[this.invocationPtr];
+ int selectorPtr = topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER, 2);
messageSend.selector = this.identifierStack[selectorPtr];
// remove selector
if (this.identifierLengthPtr >=0 && this.identifierLengthStack[this.identifierLengthPtr] == 1) {
@@ -389,7 +804,7 @@
this.isOrphanCompletionNode = true;
return true;
} else {
- int selectorPtr = this.selectorStack[this.invocationPtr];
+ int selectorPtr = topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER, 2);
if (selectorPtr == THIS_CONSTRUCTOR || selectorPtr == SUPER_CONSTRUCTOR) {
// creates an explicit constructor call
CompletionOnExplicitConstructorCall call = new CompletionOnExplicitConstructorCall(
@@ -526,13 +941,15 @@
* resulting parsed structure.
*/
public void completionIdentifierCheck(){
+ //if (assistNode != null) return;
+ if (checkKeyword()) return;
if (checkRecoveredType()) return;
if (checkRecoveredMethod()) return;
// if not in a method in non diet mode and if not inside a field initializer, only record references attached to types
- if (!(this.inMethodStack[this.inMethodPtr] && !this.diet)
- && !insideFieldInitialization()) return;
+ if (!(isInsideMethod() && !this.diet)
+ && !isIndirectlyInsideFieldInitialization()) return;
/*
In some cases, the completion identifier may not have yet been consumed,
@@ -566,50 +983,160 @@
if (checkCatchClause()) return;
if (checkMemberAccess()) return;
if (checkClassLiteralAccess()) return;
-
+ if (checkInstanceofKeyword()) return;
+
// if the completion was not on an empty name, it can still be inside an invocation (eg. this.fred("abc"[cursor])
// (NB: Put this check before checkNameCompletion() because the selector of the invocation can be on the identifier stack)
if (checkInvocation()) return;
if (checkNameCompletion()) return;
} finally {
- storeLabelsIfNeeded();
+ }
+}
+protected void consumeArrayCreationExpressionWithInitializer() {
+ super.consumeArrayCreationExpressionWithInitializer();
+ popElement(K_ARRAY_CREATION);
+}
+protected void consumeArrayCreationExpressionWithoutInitializer() {
+ super.consumeArrayCreationExpressionWithoutInitializer();
+ popElement(K_ARRAY_CREATION);
+}
+protected void consumeAssignment() {
+ popElement(K_ASSISGNMENT_OPERATOR);
+ super.consumeAssignment();
+}
+protected void consumeAssignmentOperator(int pos) {
+ super.consumeAssignmentOperator(pos);
+ pushOnElementStack(K_ASSISGNMENT_OPERATOR, pos);
+}
+protected void consumeBinaryExpression(int op) {
+ super.consumeBinaryExpression(op);
+ popElement(K_BINARY_OPERATOR);
+
+ if(expressionStack[expressionPtr] instanceof BinaryExpression) {
+ BinaryExpression exp = (BinaryExpression) expressionStack[expressionPtr];
+ if(assistNode != null && exp.right == assistNode) {
+ assistNodeParent = exp;
+ }
}
}
protected void consumeCaseLabel() {
- Expression caseExpression = this.expressionStack[this.expressionPtr];
- if (caseExpression instanceof SingleNameReference || caseExpression instanceof QualifiedNameReference) {
- // label counter was wrongly incremented in consumeToken
- if (this.labelCounterPtr >= 0) this.labelCounterStack[this.labelCounterPtr]--;
- }
super.consumeCaseLabel();
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) != K_SWITCH_LABEL) {
+ pushOnElementStack(K_SWITCH_LABEL);
+ }
+}
+protected void consumeCastExpression() {
+ popElement(K_CAST_STATEMENT);
+
+ Expression exp, cast, castType;
+ expressionPtr--;
+ expressionLengthPtr--;
+ expressionStack[expressionPtr] = cast = new CastExpression(exp = expressionStack[expressionPtr+1], castType = expressionStack[expressionPtr]);
+ cast.sourceStart = castType.sourceStart - 1;
+ cast.sourceEnd = exp.sourceEnd;
+}
+protected void consumeCastExpressionLL1() {
+ popElement(K_CAST_STATEMENT);
+ super.consumeCastExpressionLL1();
+}
+protected void consumeClassBodyDeclaration() {
+ popElement(K_BLOCK_DELIMITER);
+ super.consumeClassBodyDeclaration();
+}
+protected void consumeClassBodyopt() {
+ popElement(K_SELECTOR_QUALIFIER);
+ popElement(K_SELECTOR_INVOCATION_TYPE);
+ super.consumeClassBodyopt();
+}
+protected void consumeClassHeaderName() {
+ super.consumeClassHeaderName();
+
+ if (currentElement != null
+ && currentToken == TokenNameIdentifier
+ && this.cursorLocation+1 >= scanner.startPosition
+ && this.cursorLocation < scanner.currentPosition){
+ this.pushIdentifier();
+
+ int index = -1;
+ /* check if current awaiting identifier is the completion identifier */
+ if ((index = this.indexOfAssistIdentifier()) > -1) {
+
+ RecoveredType recoveredType = (RecoveredType)currentElement;
+ /* filter out cases where scanner is still inside type header */
+ if (!recoveredType.foundOpeningBrace) {
+ char[][] keywords = new char[Keywords.COUNT][];
+ int count = 0;
+
+ TypeDeclaration type = recoveredType.typeDeclaration;
+ if(type.superInterfaces == null) {
+ if(type.superclass == null) {;
+ keywords[count++] = Keywords.EXTENDS;
+ }
+ keywords[count++] = Keywords.IMPLEMENTS;
+ }
+
+ System.arraycopy(keywords, 0, keywords = new char[count][], 0, count);
+
+ if(count > 0) {
+ type.superclass = new CompletionOnKeyword1(
+ identifierStack[index],
+ identifierPositionStack[index],
+ keywords);
+ this.assistNode = type.superclass;
+ this.lastCheckPoint = type.superclass.sourceEnd + 1;
+ }
+ }
+ }
+ }
}
protected void consumeClassHeaderExtends() {
- this.nextTypeReferenceIsClass = true;
+ pushOnElementStack(K_NEXT_TYPEREF_IS_CLASS);
super.consumeClassHeaderExtends();
- this.nextTypeReferenceIsClass = false;
+ popElement(K_NEXT_TYPEREF_IS_CLASS);
+
+ if (currentElement != null
+ && currentToken == TokenNameIdentifier
+ && this.cursorLocation+1 >= scanner.startPosition
+ && this.cursorLocation < scanner.currentPosition){
+ this.pushIdentifier();
+
+ int index = -1;
+ /* check if current awaiting identifier is the completion identifier */
+ if ((index = this.indexOfAssistIdentifier()) > -1) {
+
+ RecoveredType recoveredType = (RecoveredType)currentElement;
+ /* filter out cases where scanner is still inside type header */
+ if (!recoveredType.foundOpeningBrace) {
+ TypeDeclaration type = recoveredType.typeDeclaration;
+ if(type.superInterfaces == null) {
+ type.superclass = new CompletionOnKeyword1(
+ identifierStack[index],
+ identifierPositionStack[index],
+ Keywords.IMPLEMENTS);
+ this.assistNode = type.superclass;
+ this.lastCheckPoint = type.superclass.sourceEnd + 1;
+ }
+ }
+ }
+ }
}
protected void consumeClassTypeElt() {
- this.nextTypeReferenceIsException = true;
+ pushOnElementStack(K_NEXT_TYPEREF_IS_EXCEPTION);
super.consumeClassTypeElt();
- this.nextTypeReferenceIsException = false;
+ popElement(K_NEXT_TYPEREF_IS_EXCEPTION);
}
protected void consumeConditionalExpression(int op) {
- Expression valueIfTrue = this.expressionStack[this.expressionPtr - 1];
- if (valueIfTrue instanceof SingleNameReference || valueIfTrue instanceof QualifiedNameReference) {
- // label counter was wrongly incremented in consumeToken
- if (this.labelCounterPtr >= 0) this.labelCounterStack[this.labelCounterPtr]--;
- }
+ popElement(K_CONDITIONAL_OPERATOR);
super.consumeConditionalExpression(op);
}
protected void consumeConstructorBody() {
+ popElement(K_BLOCK_DELIMITER);
super.consumeConstructorBody();
- this.labelCounterPtr--;
- if (this.blockInvocationPtr >= 0) this.blockInvocationPtr--;
}
protected void consumeConstructorHeader() {
super.consumeConstructorHeader();
- pushBlockInvocationPtr();
+ pushOnElementStack(K_BLOCK_DELIMITER);
}
protected void consumeConstructorHeaderName() {
@@ -625,6 +1152,18 @@
}
this.restartRecovery = true;
}
+protected void consumeDefaultLabel() {
+ super.consumeDefaultLabel();
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_SWITCH_LABEL) {
+ popElement(K_SWITCH_LABEL);
+ }
+ pushOnElementStack(K_SWITCH_LABEL, DEFAULT);
+}
+protected void consumeEnterAnonymousClassBody() {
+ popElement(K_SELECTOR_QUALIFIER);
+ popElement(K_SELECTOR_INVOCATION_TYPE);
+ super.consumeEnterAnonymousClassBody();
+}
protected void consumeEnterVariable() {
identifierPtr--;
identifierLengthPtr--;
@@ -640,32 +1179,69 @@
} else {
restartRecovery = true;
+// private boolean checkKeyword() {
+// if (currentElement instanceof RecoveredUnit) {
+// RecoveredUnit unit = (RecoveredUnit) currentElement;
+// int index = -1;
+// if ((index = this.indexOfAssistIdentifier()) > -1) {
+// if(unit.typeCount == 0
+// && CharOperation.prefixEquals(identifierStack[index], Keywords.IMPORT)) {
+// CompletionOnKeyword2 completionOnImportKeyword = new CompletionOnKeyword2(Keywords.IMPORT, identifierPositionStack[index]);
+// this.assistNode = completionOnImportKeyword;
+// this.lastCheckPoint = completionOnImportKeyword.sourceEnd + 1;
+// this.isOrphanCompletionNode = true;
+// return true;
+// } else if(unit.typeCount == 0
+// && unit.importCount == 0
+// && CharOperation.prefixEquals(identifierStack[index], Keywords.PACKAGE)) {
+// CompletionOnKeyword2 completionOnImportKeyword = new CompletionOnKeyword2(Keywords.PACKAGE, identifierPositionStack[index]);
+// this.assistNode = completionOnImportKeyword;
+// this.lastCheckPoint = completionOnImportKeyword.sourceEnd + 1;
+// this.isOrphanCompletionNode = true;
+// return true;
+// }
+// }
+// }
+// return false;
+// }
+
// recovery
if (currentElement != null) {
- int nameSourceStart = (int)(identifierPositionStack[identifierPtr] >>> 32);
- intPtr--;
-
- TypeReference type = getTypeReference(intStack[intPtr--]);
- intPtr--;
-
- if (!(currentElement instanceof RecoveredType)
- && (currentToken == TokenNameDOT
- || (scanner.getLineNumber(type.sourceStart)
- != scanner.getLineNumber(nameSourceStart)))){
- lastCheckPoint = nameSourceStart;
- restartRecovery = true;
- return;
+ if(!checkKeyword() && !(currentElement instanceof RecoveredUnit && ((RecoveredUnit)currentElement).typeCount == 0)) {
+ int nameSourceStart = (int)(identifierPositionStack[identifierPtr] >>> 32);
+ intPtr--;
+
+ TypeReference type = getTypeReference(intStack[intPtr--]);
+ intPtr--;
+
+ if (!(currentElement instanceof RecoveredType)
+ && (currentToken == TokenNameDOT
+ || (scanner.getLineNumber(type.sourceStart)
+ != scanner.getLineNumber(nameSourceStart)))){
+ lastCheckPoint = nameSourceStart;
+ restartRecovery = true;
+ return;
+ }
+
+ FieldDeclaration completionFieldDecl = new CompletionOnFieldType(type, false);
+ completionFieldDecl.modifiers = intStack[intPtr--];
+ assistNode = completionFieldDecl;
+ lastCheckPoint = type.sourceEnd + 1;
+ currentElement = currentElement.add(completionFieldDecl, 0);
+ lastIgnoredToken = -1;
}
-
- FieldDeclaration completionFieldDecl = new CompletionOnFieldType(type, false);
- completionFieldDecl.modifiers = intStack[intPtr--];
- assistNode = completionFieldDecl;
- lastCheckPoint = type.sourceEnd + 1;
- currentElement = currentElement.add(completionFieldDecl, 0);
- lastIgnoredToken = -1;
}
}
}
+protected void consumeEqualityExpression(int op) {
+ super.consumeEqualityExpression(op);
+ popElement(K_BINARY_OPERATOR);
+
+ BinaryExpression exp = (BinaryExpression) expressionStack[expressionPtr];
+ if(assistNode != null && exp.right == assistNode) {
+ assistNodeParent = exp;
+ }
+}
protected void consumeExitVariableWithInitialization() {
super.consumeExitVariableWithInitialization();
@@ -674,9 +1250,15 @@
if (cursorLocation + 1 < variable.initialization.sourceStart ||
cursorLocation > variable.initialization.sourceEnd) {
variable.initialization = null;
+ } else if (assistNode != null && assistNode == variable.initialization) {
+ assistNodeParent = variable;
}
}
-
+protected void consumeExplicitConstructorInvocation(int flag, int recFlag) {
+ popElement(K_SELECTOR_QUALIFIER);
+ popElement(K_SELECTOR_INVOCATION_TYPE);
+ super.consumeExplicitConstructorInvocation(flag, recFlag);
+}
/*
* Copy of code from superclass with the following change:
* If the cursor location is on the field access, then create a
@@ -695,7 +1277,12 @@
this.pushCompletionOnMemberAccessOnExpressionStack(isSuperAccess);
}
}
-
+protected void consumeForceNoDiet() {
+ super.consumeForceNoDiet();
+ if (isInsideMethod()) {
+ pushOnElementStack(K_LOCAL_INITIALIZER_DELIMITER);
+ }
+}
protected void consumeFormalParameter() {
if (this.indexOfAssistIdentifier() < 0) {
super.consumeFormalParameter();
@@ -706,12 +1293,14 @@
long namePositions = identifierPositionStack[identifierPtr--];
TypeReference type = getTypeReference(intStack[intPtr--] + intStack[intPtr--]);
intPtr -= 2;
- Argument arg =
+ CompletionOnArgumentName arg =
new CompletionOnArgumentName(
name,
namePositions,
type,
intStack[intPtr + 1] & ~AccDeprecated); // modifiers
+
+ arg.isCatchArgument = topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_CATCH_AND_RIGHT_PAREN;
pushOnAstStack(arg);
assistNode = arg;
@@ -723,10 +1312,77 @@
listLength++;
}
}
+protected void consumeInsideCastExpression() {
+ int end = intStack[intPtr--];
+ Expression castType = getTypeReference(intStack[intPtr--]);
+ castType.sourceEnd = end - 1;
+ castType.sourceStart = intStack[intPtr--] + 1;
+ pushOnExpressionStack(castType);
+
+ pushOnElementStack(K_CAST_STATEMENT);
+}
+protected void consumeInsideCastExpressionLL1() {
+ super.consumeInsideCastExpressionLL1();
+ pushOnElementStack(K_CAST_STATEMENT);
+}
+protected void consumeInstanceOfExpression(int op) {
+ super.consumeInstanceOfExpression(op);
+ popElement(K_BINARY_OPERATOR);
+
+ InstanceOfExpression exp = (InstanceOfExpression) expressionStack[expressionPtr];
+ if(assistNode != null && exp.type == assistNode) {
+ assistNodeParent = exp;
+ }
+}
+protected void consumeInterfaceHeaderName() {
+ super.consumeInterfaceHeaderName();
+
+ if (currentElement != null
+ && currentToken == TokenNameIdentifier
+ && this.cursorLocation+1 >= scanner.startPosition
+ && this.cursorLocation < scanner.currentPosition){
+ this.pushIdentifier();
+
+ int index = -1;
+ /* check if current awaiting identifier is the completion identifier */
+ if ((index = this.indexOfAssistIdentifier()) > -1) {
+
+ RecoveredType recoveredType = (RecoveredType)currentElement;
+ /* filter out cases where scanner is still inside type header */
+ if (!recoveredType.foundOpeningBrace) {
+ TypeDeclaration type = recoveredType.typeDeclaration;
+ if(type.superInterfaces == null) {
+ CompletionOnKeyword1 completionOnKeyword = new CompletionOnKeyword1(
+ identifierStack[index],
+ identifierPositionStack[index],
+ Keywords.EXTENDS);
+ type.superInterfaces = new TypeReference[]{completionOnKeyword};
+ this.assistNode = completionOnKeyword;
+ this.lastCheckPoint = completionOnKeyword.sourceEnd + 1;
+ }
+ }
+ }
+ }
+}
protected void consumeInterfaceType() {
- this.nextTypeReferenceIsInterface = true;
+ pushOnElementStack(K_NEXT_TYPEREF_IS_INTERFACE);
super.consumeInterfaceType();
- this.nextTypeReferenceIsInterface = false;
+ popElement(K_NEXT_TYPEREF_IS_INTERFACE);
+}
+protected void consumeMethodInvocationName() {
+ popElement(K_SELECTOR_QUALIFIER);
+ popElement(K_SELECTOR_INVOCATION_TYPE);
+ super.consumeMethodInvocationName();
+}
+protected void consumeMethodInvocationPrimary() {
+ popElement(K_SELECTOR_QUALIFIER);
+ popElement(K_SELECTOR_INVOCATION_TYPE);
+ super.consumeMethodInvocationPrimary();
+}
+protected void consumeMethodInvocationSuper() {
+ popElement(K_SELECTOR_QUALIFIER);
+ popElement(K_SELECTOR_INVOCATION_TYPE);
+ super.consumeMethodInvocationSuper();
}
protected void consumeMethodHeaderName() {
if(this.indexOfAssistIdentifier() < 0) {
@@ -812,17 +1468,77 @@
}
}
}
+protected void consumeMethodHeaderParameters() {
+ super.consumeMethodHeaderParameters();
+
+ if (currentElement != null
+ && currentToken == TokenNameIdentifier
+ && this.cursorLocation+1 >= scanner.startPosition
+ && this.cursorLocation < scanner.currentPosition){
+ this.pushIdentifier();
+
+ int index = -1;
+ /* check if current awaiting identifier is the completion identifier */
+ if ((index = this.indexOfAssistIdentifier()) > -1) {
+ RecoveredMethod recoveredMethod = (RecoveredMethod)currentElement;
+ /* filter out cases where scanner is still inside type header */
+ if (!recoveredMethod.foundOpeningBrace) {
+ AbstractMethodDeclaration method = recoveredMethod.methodDeclaration;
+ if(method.thrownExceptions == null
+ && CharOperation.prefixEquals(identifierStack[index], Keywords.THROWS)) {
+ CompletionOnKeyword1 completionOnKeyword = new CompletionOnKeyword1(
+ identifierStack[index],
+ identifierPositionStack[index],
+ Keywords.THROWS);
+ method.thrownExceptions = new TypeReference[]{completionOnKeyword};
+ recoveredMethod.foundOpeningBrace = true;
+ this.assistNode = completionOnKeyword;
+ this.lastCheckPoint = completionOnKeyword.sourceEnd + 1;
+ }
+ }
+ }
+ }
+}
+protected void consumeMethodHeaderExtendedDims() {
+ super.consumeMethodHeaderExtendedDims();
+
+ if (currentElement != null
+ && currentToken == TokenNameIdentifier
+ && this.cursorLocation+1 >= scanner.startPosition
+ && this.cursorLocation < scanner.currentPosition){
+ this.pushIdentifier();
+
+ int index = -1;
+ /* check if current awaiting identifier is the completion identifier */
+ if ((index = this.indexOfAssistIdentifier()) > -1) {
-protected void consumeMethodBody() {
- super.consumeMethodBody();
- this.labelCounterPtr--;
- if (this.blockInvocationPtr >= 0) this.blockInvocationPtr--;
+ RecoveredMethod recoveredMethod = (RecoveredMethod)currentElement;
+ /* filter out cases where scanner is still inside type header */
+ if (!recoveredMethod.foundOpeningBrace) {
+ AbstractMethodDeclaration method = recoveredMethod.methodDeclaration;
+ if(method.thrownExceptions == null) {
+ CompletionOnKeyword1 completionOnKeyword = new CompletionOnKeyword1(
+ identifierStack[index],
+ identifierPositionStack[index],
+ Keywords.THROWS);
+ method.thrownExceptions = new TypeReference[]{completionOnKeyword};
+ recoveredMethod.foundOpeningBrace = true;
+ this.assistNode = completionOnKeyword;
+ this.lastCheckPoint = completionOnKeyword.sourceEnd + 1;
+ }
+ }
+ }
+ }
}
+protected void consumeMethodBody() {
+ popElement(K_BLOCK_DELIMITER);
+ super.consumeMethodBody();
+}
protected void consumeMethodHeader() {
super.consumeMethodHeader();
- pushBlockInvocationPtr();
+ pushOnElementStack(K_BLOCK_DELIMITER);
}
protected void consumeModifiers() {
super.consumeModifiers();
@@ -830,17 +1546,73 @@
this.lastModifiersStart = intStack[intPtr];
this.lastModifiers = intStack[intPtr-1];
}
+protected void consumeRestoreDiet() {
+ super.consumeRestoreDiet();
+ if (isInsideMethod()) {
+ popElement(K_LOCAL_INITIALIZER_DELIMITER);
+ }
+}
+protected void consumeStatementSwitch() {
+ super.consumeStatementSwitch();
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_SWITCH_LABEL) {
+ popElement(K_SWITCH_LABEL);
+ }
+}
protected void consumeNestedMethod() {
super.consumeNestedMethod();
- this.pushNewLabelCounter();
+ if(!(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BLOCK_DELIMITER)) pushOnElementStack(K_BLOCK_DELIMITER);
}
-protected void consumeStatementLabel() {
- super.consumeStatementLabel();
- if (this.labelCounterPtr >= 0) this.labelCounterStack[this.labelCounterPtr]--;
+protected void consumePushPosition() {
+ super.consumePushPosition();
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BINARY_OPERATOR) {
+ int info = topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER);
+ popElement(K_BINARY_OPERATOR);
+ pushOnElementStack(K_UNARY_OPERATOR, info);
+ }
}
protected void consumeToken(int token) {
+ if(isFirst) {
+ super.consumeToken(token);
+ return;
+ }
+ if(canBeExplicitConstructor == NEXTTOKEN) {
+ canBeExplicitConstructor = YES;
+ } else {
+ canBeExplicitConstructor = NO;
+ }
+
int previous = this.previousToken;
int previousIdentifierPtr = this.previousIdentifierPtr;
+
+ if (isInsideMethod() || isInsideFieldInitialization()) {
+ switch(token) {
+ case TokenNameLPAREN:
+ popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET);
+ break;
+ case TokenNameLBRACE:
+ popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET);
+ break;
+ case TokenNameLBRACKET:
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_NEW_AND_LEFT_BRACKET) {
+ popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET);
+ pushOnElementStack(K_ARRAY_CREATION);
+ }
+ break;
+ case TokenNameRBRACE:
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BLOCK_DELIMITER) {
+ popElement(K_BLOCK_DELIMITER);
+ } else {
+ popElement(K_ARRAY_INITIALIZER);
+ }
+ break;
+ case TokenNameRBRACKET:
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_LEFT_AND_RIGHT_BRACKET) {
+ popElement(K_BETWEEN_LEFT_AND_RIGHT_BRACKET);
+ }
+ break;
+
+ }
+ }
super.consumeToken(token);
// if in field initializer (directly or not), on the completion identifier and not in recovery mode yet
@@ -849,12 +1621,12 @@
if (token == TokenNameIdentifier
&& this.identifierStack[this.identifierPtr] == assistIdentifier()
&& this.currentElement == null
- && this.insideFieldInitialization()) {
+ && this.isIndirectlyInsideFieldInitialization()) {
this.scanner.eofPosition = cursorLocation < Integer.MAX_VALUE ? cursorLocation+1 : cursorLocation;
}
// if in a method or if in a field initializer
- if (this.inMethodStack[this.inMethodPtr] || this.inFieldInitializationStack[this.inFieldInitializationPtr]) {
+ if (isInsideMethod() || isInsideFieldInitialization()) {
switch (token) {
case TokenNameDOT:
switch (previous) {
@@ -865,7 +1637,7 @@
this.invocationType = SUPER_RECEIVER;
break;
case TokenNameIdentifier: // eg. bar[.]fred()
- if (!this.betweenNewAndLeftBraket) { // eg. not new z.y[.]X()
+ if (topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) != K_BETWEEN_NEW_AND_LEFT_BRACKET) {
if (this.identifierPtr != previousIdentifierPtr) { // if identifier has been consumed, eg. this.x[.]fred()
this.invocationType = EXPLICIT_RECEIVER;
} else {
@@ -877,10 +1649,6 @@
break;
case TokenNameIdentifier:
if (previous == TokenNameDOT) { // eg. foo().[fred]()
- // if current identifier is the empty completion one
- if (identifierStack[identifierPtr] == CompletionScanner.EmptyCompletionIdentifier){
- this.completionBehindDot = true;
- }
if (this.invocationType != SUPER_RECEIVER // eg. not super.[fred]()
&& this.invocationType != NAME_RECEIVER // eg. not bar.[fred]()
&& this.invocationType != ALLOCATION // eg. not new foo.[Bar]()
@@ -892,7 +1660,7 @@
}
break;
case TokenNamenew:
- this.betweenNewAndLeftBraket = true;
+ pushOnElementStack(K_BETWEEN_NEW_AND_LEFT_BRACKET);
this.qualifier = this.expressionPtr; // NB: even if there is no qualification, set it to the expression ptr so that the number of arguments are correctly computed
if (previous == TokenNameDOT) { // eg. fred().[new] X()
this.invocationType = QUALIFIED_ALLOCATION;
@@ -913,119 +1681,289 @@
}
break;
case TokenNamecatch:
- this.betweenCatchAndRightParen = true;
+ pushOnElementStack(K_BETWEEN_CATCH_AND_RIGHT_PAREN);
break;
case TokenNameLPAREN:
- this.betweenNewAndLeftBraket = false;
- this.bracketDepth++;
if (this.invocationType == NO_RECEIVER || this.invocationType == NAME_RECEIVER) {
this.qualifier = this.expressionPtr; // remenber the last expression so that arguments are correctly computed
}
switch (previous) {
case TokenNameIdentifier: // eg. fred[(]) or foo.fred[(])
- this.pushOnInvocationStacks(this.invocationType, this.qualifier);
+ if (topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_SELECTOR) {
+ this.pushOnElementStack(K_SELECTOR_INVOCATION_TYPE, this.invocationType);
+ this.pushOnElementStack(K_SELECTOR_QUALIFIER, this.qualifier);
+ }
this.invocationType = NO_RECEIVER;
break;
case TokenNamethis: // explicit constructor invocation, eg. this[(]1, 2)
- this.pushOnInvocationStacks(
- (this.invocationType == QUALIFIED_ALLOCATION) ? QUALIFIED_ALLOCATION : ALLOCATION,
- this.qualifier);
+ if (topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_SELECTOR) {
+ this.pushOnElementStack(K_SELECTOR_INVOCATION_TYPE, (this.invocationType == QUALIFIED_ALLOCATION) ? QUALIFIED_ALLOCATION : ALLOCATION);
+ this.pushOnElementStack(K_SELECTOR_QUALIFIER, this.qualifier);
+ }
this.invocationType = NO_RECEIVER;
break;
case TokenNamesuper: // explicit constructor invocation, eg. super[(]1, 2)
- this.pushOnInvocationStacks(
- (this.invocationType == QUALIFIED_ALLOCATION) ? QUALIFIED_ALLOCATION : ALLOCATION,
- this.qualifier);
+ if (topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_SELECTOR) {
+ this.pushOnElementStack(K_SELECTOR_INVOCATION_TYPE, (this.invocationType == QUALIFIED_ALLOCATION) ? QUALIFIED_ALLOCATION : ALLOCATION);
+ this.pushOnElementStack(K_SELECTOR_QUALIFIER, this.qualifier);
+ }
this.invocationType = NO_RECEIVER;
break;
}
break;
case TokenNameLBRACE:
- this.betweenNewAndLeftBraket = false;
this.bracketDepth++;
- this.pushBlockInvocationPtr();
+ int kind;
+ if((kind = topKnownElementKind(COMPLETION_OR_ASSIST_PARSER)) == K_FIELD_INITIALIZER_DELIMITER
+ || kind == K_LOCAL_INITIALIZER_DELIMITER
+ || kind == K_ARRAY_CREATION) {
+ pushOnElementStack(K_ARRAY_INITIALIZER, endPosition);
+ } else {
+ switch(previous) {
+ case TokenNameRPAREN :
+ switch(previousKind) {
+ case K_BETWEEN_IF_AND_RIGHT_PAREN :
+ pushOnElementStack(K_BLOCK_DELIMITER, IF);
+ break;
+ case K_BETWEEN_CATCH_AND_RIGHT_PAREN :
+ pushOnElementStack(K_BLOCK_DELIMITER, CATCH);
+ break;
+ case K_BETWEEN_WHILE_AND_RIGHT_PAREN :
+ pushOnElementStack(K_BLOCK_DELIMITER, WHILE);
+ break;
+ case K_BETWEEN_SWITCH_AND_RIGHT_PAREN :
+ pushOnElementStack(K_BLOCK_DELIMITER, SWITCH);
+ break;
+ case K_BETWEEN_FOR_AND_RIGHT_PAREN :
+ pushOnElementStack(K_BLOCK_DELIMITER, FOR);
+ break;
+ case K_BETWEEN_SYNCHRONIZED_AND_RIGHT_PAREN :
+ pushOnElementStack(K_BLOCK_DELIMITER, SYNCHRONIZED);
+ break;
+ default :
+ pushOnElementStack(K_BLOCK_DELIMITER);
+ break;
+ }
+ break;
+ case TokenNametry :
+ pushOnElementStack(K_BLOCK_DELIMITER, TRY);
+ break;
+ case TokenNamedo:
+ pushOnElementStack(K_BLOCK_DELIMITER, DO);
+ break;
+ default :
+ pushOnElementStack(K_BLOCK_DELIMITER);
+ break;
+ }
+ }
break;
case TokenNameLBRACKET:
- this.betweenNewAndLeftBraket = false;
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) != K_ARRAY_CREATION) {
+ pushOnElementStack(K_BETWEEN_LEFT_AND_RIGHT_BRACKET);
+ }
this.bracketDepth++;
break;
case TokenNameRBRACE:
this.bracketDepth--;
- if (this.blockInvocationPtr >= 0) this.blockInvocationPtr--;
break;
case TokenNameRBRACKET:
this.bracketDepth--;
break;
case TokenNameRPAREN:
- this.betweenCatchAndRightParen = false;
- this.bracketDepth--;
- break;
- case TokenNameCOLON:
- if (previous == TokenNameIdentifier) {
- if (this.labelCounterPtr >= 0) this.labelCounterStack[this.labelCounterPtr]++;
+ switch(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER)) {
+ case K_BETWEEN_CATCH_AND_RIGHT_PAREN :
+ popElement(K_BETWEEN_CATCH_AND_RIGHT_PAREN);
+ break;
+ case K_BETWEEN_IF_AND_RIGHT_PAREN :
+ if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == bracketDepth) {
+ popElement(K_BETWEEN_IF_AND_RIGHT_PAREN);
+ }
+ break;
+ case K_BETWEEN_WHILE_AND_RIGHT_PAREN :
+ if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == bracketDepth) {
+ popElement(K_BETWEEN_WHILE_AND_RIGHT_PAREN);
+ }
+ break;
+ case K_BETWEEN_FOR_AND_RIGHT_PAREN :
+ if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == bracketDepth) {
+ popElement(K_BETWEEN_FOR_AND_RIGHT_PAREN);
+ }
+ break;
+ case K_BETWEEN_SWITCH_AND_RIGHT_PAREN :
+ if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == bracketDepth) {
+ popElement(K_BETWEEN_SWITCH_AND_RIGHT_PAREN);
+ }
+ break;
+ case K_BETWEEN_SYNCHRONIZED_AND_RIGHT_PAREN :
+ if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == bracketDepth) {
+ popElement(K_BETWEEN_SYNCHRONIZED_AND_RIGHT_PAREN);
+ }
+ break;
}
break;
case TokenNamethrow:
- this.throwBracketDepth= bracketDepth;
+ pushOnElementStack(K_INSIDE_THROW_STATEMENT, bracketDepth);
+ break;
+ case TokenNameSEMICOLON:
+ switch(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER)) {
+ case K_INSIDE_THROW_STATEMENT :
+ if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == this.bracketDepth) {
+ popElement(K_INSIDE_THROW_STATEMENT);
+ }
+ break;
+ case K_INSIDE_RETURN_STATEMENT :
+ if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == this.bracketDepth) {
+ popElement(K_INSIDE_RETURN_STATEMENT);
+ }
+ break;
+ case K_INSIDE_ASSERT_STATEMENT :
+ if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == this.bracketDepth) {
+ popElement(K_INSIDE_ASSERT_STATEMENT);
+ }
+ break;
+ }
+ break;
+ case TokenNamereturn:
+ pushOnElementStack(K_INSIDE_RETURN_STATEMENT, this.bracketDepth);
+ break;
+ case TokenNameMULTIPLY:
+ pushOnElementStack(K_BINARY_OPERATOR, MULTIPLY);
+ break;
+ case TokenNameDIVIDE:
+ pushOnElementStack(K_BINARY_OPERATOR, DIVIDE);
+ break;
+ case TokenNameREMAINDER:
+ pushOnElementStack(K_BINARY_OPERATOR, REMAINDER);
+ break;
+ case TokenNamePLUS:
+ pushOnElementStack(K_BINARY_OPERATOR, PLUS);
+ break;
+ case TokenNameMINUS:
+ pushOnElementStack(K_BINARY_OPERATOR, MINUS);
+ break;
+ case TokenNameLEFT_SHIFT:
+ pushOnElementStack(K_BINARY_OPERATOR, LEFT_SHIFT);
+ break;
+ case TokenNameRIGHT_SHIFT:
+ pushOnElementStack(K_BINARY_OPERATOR, RIGHT_SHIFT);
+ break;
+ case TokenNameUNSIGNED_RIGHT_SHIFT:
+ pushOnElementStack(K_BINARY_OPERATOR, UNSIGNED_RIGHT_SHIFT);
+ break;
+ case TokenNameLESS:
+ pushOnElementStack(K_BINARY_OPERATOR, LESS);
+ break;
+ case TokenNameGREATER:
+ pushOnElementStack(K_BINARY_OPERATOR, GREATER);
+ break;
+ case TokenNameLESS_EQUAL:
+ pushOnElementStack(K_BINARY_OPERATOR, LESS_EQUAL);
+ break;
+ case TokenNameGREATER_EQUAL:
+ pushOnElementStack(K_BINARY_OPERATOR, GREATER_EQUAL);
+ break;
+ case TokenNameAND:
+ pushOnElementStack(K_BINARY_OPERATOR, AND);
+ break;
+ case TokenNameXOR:
+ pushOnElementStack(K_BINARY_OPERATOR, XOR);
+ break;
+ case TokenNameOR:
+ pushOnElementStack(K_BINARY_OPERATOR, OR);
+ break;
+ case TokenNameAND_AND:
+ pushOnElementStack(K_BINARY_OPERATOR, AND_AND);
+ break;
+ case TokenNameOR_OR:
+ pushOnElementStack(K_BINARY_OPERATOR, OR_OR);
+ break;
+ case TokenNamePLUS_PLUS:
+ pushOnElementStack(K_UNARY_OPERATOR, PLUS_PLUS);
+ break;
+ case TokenNameMINUS_MINUS:
+ pushOnElementStack(K_UNARY_OPERATOR, MINUS_MINUS);
+ break;
+ case TokenNameTWIDDLE:
+ pushOnElementStack(K_UNARY_OPERATOR, TWIDDLE);
+ break;
+ case TokenNameNOT:
+ pushOnElementStack(K_UNARY_OPERATOR, NOT);
+ break;
+ case TokenNameEQUAL_EQUAL:
+ pushOnElementStack(K_BINARY_OPERATOR, EQUAL_EQUAL);
+ break;
+ case TokenNameNOT_EQUAL:
+ pushOnElementStack(K_BINARY_OPERATOR, NOT_EQUAL);
+ break;
+ case TokenNameinstanceof:
+ pushOnElementStack(K_BINARY_OPERATOR, INSTANCEOF);
+ break;
+ case TokenNameQUESTION:
+ pushOnElementStack(K_CONDITIONAL_OPERATOR, QUESTION);
+ break;
+ case TokenNameCOLON:
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_CONDITIONAL_OPERATOR
+ && topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == QUESTION) {
+ popElement(K_CONDITIONAL_OPERATOR);
+ pushOnElementStack(K_CONDITIONAL_OPERATOR, COLON);
+ } else {
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BETWEEN_CASE_AND_COLON) {
+ popElement(K_BETWEEN_CASE_AND_COLON);
+ } else {
+ popElement(K_BETWEEN_DEFAULT_AND_COLON);
+ }
+ }
+ break;
+ case TokenNameif:
+ pushOnElementStack(K_BETWEEN_IF_AND_RIGHT_PAREN, bracketDepth);
+ break;
+ case TokenNamewhile:
+ pushOnElementStack(K_BETWEEN_WHILE_AND_RIGHT_PAREN, bracketDepth);
+ break;
+ case TokenNamefor:
+ pushOnElementStack(K_BETWEEN_FOR_AND_RIGHT_PAREN, bracketDepth);
+ break;
+ case TokenNameswitch:
+ pushOnElementStack(K_BETWEEN_SWITCH_AND_RIGHT_PAREN, bracketDepth);
+ break;
+ case TokenNamesynchronized:
+ pushOnElementStack(K_BETWEEN_SYNCHRONIZED_AND_RIGHT_PAREN, bracketDepth);
+ break;
+ case TokenNameassert:
+ pushOnElementStack(K_INSIDE_ASSERT_STATEMENT, this.bracketDepth);
+ break;
+ case TokenNamecase :
+ pushOnElementStack(K_BETWEEN_CASE_AND_COLON);
+ break;
+ case TokenNamedefault :
+ pushOnElementStack(K_BETWEEN_DEFAULT_AND_COLON);
break;
}
}
}
-/**
- * Return whether the given ast node contains the completion node.
- */
-private boolean containsCompletionNode(AstNode ast) {
- if (this.assistNode == null || ast instanceof Literal) {
- return false;
- }
- if (this.assistNode == ast) {
- return true;
- }
- if (ast instanceof Reference || ast instanceof TypeReference) {
- return ast == this.assistNode;
- }
- if (ast instanceof Assignment) {
- Assignment assign = (Assignment)ast;
- return containsCompletionNode(assign.lhs) || containsCompletionNode(assign.expression);
- }
- if (ast instanceof UnaryExpression) {
- UnaryExpression unary = (UnaryExpression)ast;
- return containsCompletionNode(unary.expression);
- }
- if (ast instanceof BinaryExpression) {
- BinaryExpression binary = (BinaryExpression)ast;
- return containsCompletionNode(binary.left) || containsCompletionNode(binary.right);
- }
- if (ast instanceof InstanceOfExpression) {
- InstanceOfExpression instanceOfExpr = (InstanceOfExpression)ast;
- return containsCompletionNode(instanceOfExpr.expression) || containsCompletionNode(instanceOfExpr.type);
- }
- if (ast instanceof ConditionalExpression) {
- ConditionalExpression conditional = (ConditionalExpression)ast;
- return containsCompletionNode(conditional.condition) || containsCompletionNode(conditional.valueIfTrue) || containsCompletionNode(conditional.valueIfFalse);
- }
- if (ast instanceof AllocationExpression) {
- AllocationExpression alloc = (AllocationExpression)ast;
- return containsCompletionNode(alloc.type);
- }
- if (ast instanceof CastExpression) {
- CastExpression cast = (CastExpression)ast;
- return containsCompletionNode(cast.expression) || containsCompletionNode(cast.type);
- }
- if (ast instanceof ExplicitConstructorCall) {
- ExplicitConstructorCall call = (ExplicitConstructorCall)ast;
- Expression[] arguments = call.arguments;
- if (arguments != null) {
- for (int i = 0; i < arguments.length; i++) {
- if (containsCompletionNode(arguments[i])) {
- return true;
- }
- }
- return false;
+protected void consumeUnaryExpression(int op) {
+ super.consumeUnaryExpression(op);
+ popElement(K_UNARY_OPERATOR);
+
+ if(expressionStack[expressionPtr] instanceof UnaryExpression) {
+ UnaryExpression exp = (UnaryExpression) expressionStack[expressionPtr];
+ if(assistNode != null && exp.expression == assistNode) {
+ assistNodeParent = exp;
}
}
- return false;
}
+protected void consumeUnaryExpression(int op, boolean post) {
+ super.consumeUnaryExpression(op, post);
+ popElement(K_UNARY_OPERATOR);
+
+ if(expressionStack[expressionPtr] instanceof UnaryExpression) {
+ UnaryExpression exp = (UnaryExpression) expressionStack[expressionPtr];
+ if(assistNode != null && exp.expression == assistNode) {
+ assistNodeParent = exp;
+ }
+ }
+}
+
public ImportReference createAssistImportReference(char[][] tokens, long[] positions){
return new CompletionOnImportReference(tokens, positions);
}
@@ -1039,37 +1977,110 @@
positions);
}
public TypeReference createQualifiedAssistTypeReference(char[][] previousIdentifiers, char[] name, long[] positions){
- return this.betweenCatchAndRightParen || this.nextTypeReferenceIsException // check for exception scenario
- ? new CompletionOnQualifiedExceptionReference(
- previousIdentifiers,
- name,
- positions)
- : this.nextTypeReferenceIsInterface
- ? new CompletionOnQualifiedInterfaceReference(
- previousIdentifiers,
- name,
- positions)
- : this.nextTypeReferenceIsClass
- ? new CompletionOnQualifiedClassReference(
- previousIdentifiers,
- name,
- positions)
- : new CompletionOnQualifiedTypeReference(
- previousIdentifiers,
- name,
- positions);
+ switch (topKnownElementKind(COMPLETION_OR_ASSIST_PARSER)) {
+ case K_NEXT_TYPEREF_IS_EXCEPTION :
+ return new CompletionOnQualifiedExceptionReference(previousIdentifiers, name, positions);
+ case K_NEXT_TYPEREF_IS_CLASS :
+ return new CompletionOnQualifiedClassReference(previousIdentifiers, name, positions);
+ case K_NEXT_TYPEREF_IS_INTERFACE :
+ return new CompletionOnQualifiedInterfaceReference(previousIdentifiers, name, positions);
+ default :
+ return new CompletionOnQualifiedTypeReference(previousIdentifiers, name, positions);
+ }
}
public NameReference createSingleAssistNameReference(char[] name, long position) {
- return new CompletionOnSingleNameReference(name, position);
+ int kind = topKnownElementKind(COMPLETION_OR_ASSIST_PARSER);
+ if(!isInsideMethod()) {
+ return new CompletionOnSingleNameReference(name, position);
+ } else {
+ boolean canBeExplicitConstructorCall = false;
+ if(kind == K_BLOCK_DELIMITER
+ && previousKind == K_BLOCK_DELIMITER
+ && previousInfo == DO) {
+ return new CompletionOnKeyword3(name, position, Keywords.WHILE);
+ } else if(kind == K_BLOCK_DELIMITER
+ && previousKind == K_BLOCK_DELIMITER
+ && previousInfo == TRY) {
+ return new CompletionOnKeyword3(name, position, new char[][]{Keywords.CATCH, Keywords.FINALLY});
+ } else if(kind == K_BLOCK_DELIMITER
+ && topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == SWITCH) {
+ return new CompletionOnKeyword3(name, position, new char[][]{Keywords.CASE, Keywords.DEFAULT});
+ } else {
+ char[][] keywords = new char[Keywords.COUNT][];
+ int count = 0;
+
+ if((lastModifiers & AccStatic) == 0) {
+ keywords[count++]= Keywords.SUPER;
+ keywords[count++]= Keywords.THIS;
+ }
+ keywords[count++]= Keywords.NEW;
+
+ if(kind == K_BLOCK_DELIMITER) {
+ if(canBeExplicitConstructor == YES) {
+ canBeExplicitConstructorCall = true;
+ }
+
+ keywords[count++]= Keywords.ASSERT;
+ keywords[count++]= Keywords.DO;
+ keywords[count++]= Keywords.FOR;
+ keywords[count++]= Keywords.IF;
+ keywords[count++]= Keywords.RETURN;
+ keywords[count++]= Keywords.SWITCH;
+ keywords[count++]= Keywords.SYNCHRONIZED;
+ keywords[count++]= Keywords.THROW;
+ keywords[count++]= Keywords.TRY;
+ keywords[count++]= Keywords.WHILE;
+
+ keywords[count++]= Keywords.FINAL;
+ keywords[count++]= Keywords.CLASS;
+
+ if(previousKind == K_BLOCK_DELIMITER) {
+ switch (previousInfo) {
+ case IF :
+ keywords[count++]= Keywords.ELSE;
+ break;
+ case CATCH :
+ keywords[count++]= Keywords.CATCH;
+ keywords[count++]= Keywords.FINALLY;
+ break;
+ }
+ }
+ if(isInsideLoop()) {
+ keywords[count++]= Keywords.CONTINUE;
+ }
+ if(isInsideBreakable()) {
+ keywords[count++]= Keywords.BREAK;
+ }
+ } else if(kind != K_BETWEEN_CASE_AND_COLON && kind != K_BETWEEN_DEFAULT_AND_COLON) {
+ keywords[count++]= Keywords.TRUE;
+ keywords[count++]= Keywords.FALSE;
+ keywords[count++]= Keywords.NULL;
+
+ if(kind == K_SWITCH_LABEL) {
+ if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) != DEFAULT) {
+ keywords[count++]= Keywords.DEFAULT;
+ }
+ keywords[count++]= Keywords.BREAK;
+ keywords[count++]= Keywords.CASE;
+ }
+ }
+ System.arraycopy(keywords, 0 , keywords = new char[count][], 0, count);
+
+ return new CompletionOnSingleNameReference(name, position, keywords, canBeExplicitConstructorCall);
+ }
+ }
}
public TypeReference createSingleAssistTypeReference(char[] name, long position) {
- return this.betweenCatchAndRightParen || this.nextTypeReferenceIsException // check for exception scenario
- ? new CompletionOnExceptionReference(name, position)
- : this.nextTypeReferenceIsInterface
- ? new CompletionOnInterfaceReference(name, position)
- : this.nextTypeReferenceIsClass
- ? new CompletionOnClassReference(name, position)
- : new CompletionOnSingleTypeReference(name, position);
+ switch (topKnownElementKind(COMPLETION_OR_ASSIST_PARSER)) {
+ case K_NEXT_TYPEREF_IS_EXCEPTION :
+ return new CompletionOnExceptionReference(name, position) ;
+ case K_NEXT_TYPEREF_IS_CLASS :
+ return new CompletionOnClassReference(name, position);
+ case K_NEXT_TYPEREF_IS_INTERFACE :
+ return new CompletionOnInterfaceReference(name, position);
+ default :
+ return new CompletionOnSingleTypeReference(name, position);
+ }
}
public CompilationUnitDeclaration dietParse(ICompilationUnit sourceUnit, CompilationResult compilationResult, int cursorLocation) {
@@ -1086,6 +2097,7 @@
super.flushAssistState();
this.isOrphanCompletionNode = false;
+ assistNodeParent = null;
CompletionScanner completionScanner = (CompletionScanner)this.scanner;
completionScanner.completedIdentifierStart = 0;
completionScanner.completedIdentifierEnd = -1;
@@ -1097,20 +2109,9 @@
}
return super.getUnspecifiedReferenceOptimized();
}
-/**
- * Return whether the given ast node has information interresting for code completion.
- */
-private boolean hasCompletionInformation(AstNode ast) {
- return (
- ast instanceof AbstractMethodDeclaration ||
- ast instanceof AbstractVariableDeclaration ||
- ast instanceof LabeledStatement ||
- ast instanceof TypeDeclaration);
-}
public void initialize() {
super.initialize();
this.initializeForBlockStatements();
- this.labelCounterPtr = -1;
}
/*
* Initializes the state of the parser that is about to go for BlockStatements.
@@ -1118,14 +2119,13 @@
private void initializeForBlockStatements() {
this.previousToken = -1;
this.previousIdentifierPtr = -1;
- this.completionBehindDot = false;
- this.betweenNewAndLeftBraket = false;
- this.betweenCatchAndRightParen = false;
this.bracketDepth = 0;
- this.throwBracketDepth = -1;
this.invocationType = NO_RECEIVER;
this.qualifier = -1;
- this.blockInvocationPtr = -1;
+ popUntilElement(K_SWITCH_LABEL);
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) != K_SWITCH_LABEL) {
+ this.popUntilElement(K_BLOCK_DELIMITER);
+ }
}
public void initializeScanner(){
this.scanner = new CompletionScanner(this.assertMode);
@@ -1149,6 +2149,82 @@
this.assistNode instanceof CompletionOnSingleNameReference &&
(((CompletionOnSingleNameReference)this.assistNode).token.length == 0);
}
+protected boolean isIndirectlyInsideBlock(){
+ int i = elementPtr;
+ while(i > -1) {
+ if(elementKindStack[i] == K_BLOCK_DELIMITER)
+ return true;
+ i--;
+ }
+ return false;
+}
+
+protected boolean isInsideBlock(){
+ int i = elementPtr;
+ while(i > -1) {
+ switch (elementKindStack[i]) {
+ case K_TYPE_DELIMITER : return false;
+ case K_METHOD_DELIMITER : return false;
+ case K_FIELD_INITIALIZER_DELIMITER : return false;
+ case K_BLOCK_DELIMITER : return true;
+ }
+ i--;
+ }
+ return false;
+}
+protected boolean isInsideBreakable(){
+ int i = elementPtr;
+ while(i > -1) {
+ switch (elementKindStack[i]) {
+ case K_TYPE_DELIMITER : return false;
+ case K_METHOD_DELIMITER : return false;
+ case K_FIELD_INITIALIZER_DELIMITER : return false;
+ case K_SWITCH_LABEL : return true;
+ case K_BLOCK_DELIMITER :
+ switch(elementInfoStack[i]) {
+ case FOR :
+ case DO :
+ case WHILE :
+ return true;
+ }
+ }
+ i--;
+ }
+ return false;
+}
+protected boolean isInsideLoop(){
+ int i = elementPtr;
+ while(i > -1) {
+ switch (elementKindStack[i]) {
+ case K_TYPE_DELIMITER : return false;
+ case K_METHOD_DELIMITER : return false;
+ case K_FIELD_INITIALIZER_DELIMITER : return false;
+ case K_BLOCK_DELIMITER :
+ switch(elementInfoStack[i]) {
+ case FOR :
+ case DO :
+ case WHILE :
+ return true;
+ }
+ }
+ i--;
+ }
+ return false;
+}
+protected boolean isInsideReturn(){
+ int i = elementPtr;
+ while(i > -1) {
+ switch (elementKindStack[i]) {
+ case K_TYPE_DELIMITER : return false;
+ case K_METHOD_DELIMITER : return false;
+ case K_FIELD_INITIALIZER_DELIMITER : return false;
+ case K_BLOCK_DELIMITER : return false;
+ case K_INSIDE_RETURN_STATEMENT : return true;
+ }
+ i--;
+ }
+ return false;
+}
public CompilationUnitDeclaration parse(ICompilationUnit sourceUnit, CompilationResult compilationResult, int cursorLocation) {
this.cursorLocation = cursorLocation;
@@ -1157,24 +2233,22 @@
completionScanner.cursorLocation = cursorLocation;
return this.parse(sourceUnit, compilationResult);
}
+public void parseBlockStatements(
+ ConstructorDeclaration cd,
+ CompilationUnitDeclaration unit) {
+ canBeExplicitConstructor = 1;
+ super.parseBlockStatements(cd, unit);
+}
/*
* Prepares the state of the parser to go for BlockStatements.
*/
protected void prepareForBlockStatements() {
- super.prepareForBlockStatements();
+ this.nestedMethod[this.nestedType = 0] = 1;
+ this.variablesCounter[this.nestedType] = 0;
+ this.realBlockStack[this.realBlockPtr = 1] = 0;
+
this.initializeForBlockStatements();
}
-protected void pushBlockInvocationPtr() {
- try {
- this.blockInvocationStack[++this.blockInvocationPtr] = this.invocationPtr+1;
- } catch (IndexOutOfBoundsException e) {
- int oldStackLength = this.blockInvocationStack.length;
- int[] oldStack = this.blockInvocationStack;
- this.blockInvocationStack = new int[oldStackLength + StackIncrement];
- System.arraycopy(oldStack, 0, this.blockInvocationStack, 0, oldStackLength);
- this.blockInvocationStack[this.blockInvocationPtr] = this.invocationPtr+1;
- }
-}
/**
* Creates a completion on member access node and push it
* on the expression stack.
@@ -1197,38 +2271,6 @@
expressionStack[expressionPtr] = fr;
}
}
-protected void pushNewLabelCounter() {
- try {
- this.labelCounterStack[++this.labelCounterPtr] = 0;
- } catch (IndexOutOfBoundsException e) {
- int oldStackLength = this.labelCounterStack.length;
- int[] oldStack = this.labelCounterStack;
- this.labelCounterStack = new int[oldStackLength + StackIncrement];
- System.arraycopy(oldStack, 0, this.labelCounterStack, 0, oldStackLength);
- this.labelCounterStack[this.labelCounterPtr] = 0;
- }
-}
-/**
- * Pushes the given invocation type (one of the invocation type constants) on the invocation type stack,
- * and the given qualifier (an expression pointer to the expression stack) on the qualifier stack.
- */
-protected void pushOnInvocationStacks(int invocationType, int qualifierExprPtr) {
- // NB: invocationPtr has already been incremented by a call to pushOnSelectorStack()
- try {
- this.invocationTypeStack[this.invocationPtr] = invocationType;
- this.qualifierStack[this.invocationPtr] = qualifierExprPtr;
- } catch (IndexOutOfBoundsException e) {
- int oldStackLength = this.invocationTypeStack.length;
- int oldInvocationTypeStack[] = this.invocationTypeStack;
- int oldQualifierStack[] = this.qualifierStack;
- this.invocationTypeStack = new int[oldStackLength + StackIncrement];
- this.qualifierStack = new int[oldStackLength + StackIncrement];
- System.arraycopy(oldInvocationTypeStack, 0, this.invocationTypeStack, 0, oldStackLength);
- System.arraycopy(oldQualifierStack, 0, this.qualifierStack, 0, oldStackLength);
- this.invocationTypeStack[this.invocationPtr] = invocationType;
- this.qualifierStack[this.invocationPtr] = qualifierExprPtr;
- }
-}
public void recordCompletionOnReference(){
if (currentElement instanceof RecoveredType){
@@ -1245,6 +2287,48 @@
if (!diet) return; // only record references attached to types
}
+public void recoveryExitFromVariable() {
+ if(currentElement != null && currentElement instanceof RecoveredLocalVariable) {
+ RecoveredElement oldElement = currentElement;
+ super.recoveryExitFromVariable();
+ if(oldElement != currentElement) {
+ popElement(K_LOCAL_INITIALIZER_DELIMITER);
+ }
+ } else {
+ super.recoveryExitFromVariable();
+ }
+}
+public void recoveryTokenCheck() {
+ RecoveredElement oldElement = currentElement;
+ switch (currentToken) {
+ case TokenNameRBRACE :
+ super.recoveryTokenCheck();
+ if(currentElement != oldElement && oldElement instanceof RecoveredBlock) {
+ popElement(K_BLOCK_DELIMITER);
+ }
+ break;
+ case TokenNamecase :
+ super.recoveryTokenCheck();
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BLOCK_DELIMITER
+ && topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == SWITCH) {
+ pushOnElementStack(K_SWITCH_LABEL);
+ }
+ break;
+ case TokenNamedefault :
+ super.recoveryTokenCheck();
+ if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_BLOCK_DELIMITER
+ && topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == SWITCH) {
+ pushOnElementStack(K_SWITCH_LABEL, DEFAULT);
+ } else if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_SWITCH_LABEL) {
+ popElement(K_SWITCH_LABEL);
+ pushOnElementStack(K_SWITCH_LABEL, DEFAULT);
+ }
+ break;
+ default :
+ super.recoveryTokenCheck();
+ break;
+ }
+}
protected void reportSyntaxError(int act, int currentKind, int stateStackTop) {
/* Intercept error state on EOF inside method bodies, due to
@@ -1283,7 +2367,7 @@
the end of the method body or compilation unit */
if ((scanner.eofPosition == cursorLocation+1)
&& (!(referenceContext instanceof CompilationUnitDeclaration)
- || insideFieldInitialization())) {
+ || isIndirectlyInsideFieldInitialization())) {
/* disabled since does not handle possible field/message refs, i.e. Obj[ASSIST HERE]ect.registerNatives()
// consume extra tokens which were part of the qualified reference
@@ -1309,8 +2393,12 @@
}
*/
/* restart in diet mode for finding sibling constructs */
- if (currentElement.enclosingType() != null){
- lastCheckPoint = this.assistNode.sourceEnd+1;
+ if (currentElement instanceof RecoveredType
+ || currentElement.enclosingType() != null){
+
+ if(lastCheckPoint <= this.assistNode.sourceEnd) {
+ lastCheckPoint = this.assistNode.sourceEnd+1;
+ }
int end = currentElement.topElement().sourceEnd();
scanner.eofPosition = end < Integer.MAX_VALUE ? end + 1 : end;
} else {
@@ -1324,18 +2412,21 @@
public void setAssistIdentifier(char[] assistIdent){
((CompletionScanner)scanner).completionIdentifier = assistIdent;
}
-/**
- * Stores the labels left on the identifier stack if they have not been stored yet.
- */
-private void storeLabelsIfNeeded() {
-// int counter = this.labelCounterPtr >= 0 ? this.labelCounterStack[this.labelCounterPtr] : 0;
-// if (this.labels == null && this.identifierPtr >= 0) {
-// this.labels = new char[counter][];
-// System.arraycopy(this.identifierStack, this.identifierPtr - counter + 1, this.labels, 0, counter);
-// }
-// this.identifierPtr -= counter;
-// this.identifierLengthPtr -= counter; // labels have not been concatenated yet
+public String toString() {
+ String s = ""; //$NON-NLS-1$
+ s = s + "elementKindStack : int[] = {"; //$NON-NLS-1$
+ for (int i = 0; i <= elementPtr; i++) {
+ s = s + String.valueOf(elementKindStack[i]) + ","; //$NON-NLS-1$ //$NON-NLS-2$
+ };
+ s = s + "}\n"; //$NON-NLS-1$
+ s = s + "elementInfoStack : int[] = {"; //$NON-NLS-1$
+ for (int i = 0; i <= elementPtr; i++) {
+ s = s + String.valueOf(elementInfoStack[i]) + ","; //$NON-NLS-1$ //$NON-NLS-2$
+ };
+ s = s + "}\n"; //$NON-NLS-1$
+ return s + super.toString();
}
+
/*
* Update recovery state based on current parser/scanner state
*/
@@ -1359,6 +2450,8 @@
got activated once.
*/
this.recoveryTokenCheck();
+
+ this.recoveryExitFromVariable();
}
protected LocalDeclaration createLocalDeclaration(Expression initialization, char[] name, int sourceStart, int sourceEnd) {
@@ -1373,7 +2466,7 @@
}
protected FieldDeclaration createFieldDeclaration(Expression initialization, char[] name, int sourceStart, int sourceEnd) {
- if (this.indexOfAssistIdentifier() < 0) {
+ if (this.indexOfAssistIdentifier() < 0 || (currentElement instanceof RecoveredUnit && ((RecoveredUnit)currentElement).typeCount == 0)) {
return super.createFieldDeclaration(initialization, name, sourceStart, sourceEnd);
} else {
CompletionOnFieldName field = new CompletionOnFieldName(initialization, name, sourceStart, sourceEnd);
@@ -1382,5 +2475,4 @@
return field;
}
}
-
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java
index 5916e7d..85cb5af 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionScanner.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/*
@@ -20,6 +20,7 @@
* 0 means completion behind the first character
* n means completion behind the n-th character
*/
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
@@ -27,6 +28,7 @@
public char[] completionIdentifier;
public int cursorLocation;
+ public int endOfEmptyToken = -1;
/* Source positions of the completedIdentifier
* if inside actual identifier, end goes to the actual identifier
@@ -37,7 +39,13 @@
public static final char[] EmptyCompletionIdentifier = {};
public CompletionScanner(boolean assertMode) {
- super(false, false, false, assertMode);
+ super(
+ false /*comment*/,
+ false /*whitespace*/,
+ false /*nls*/,
+ assertMode /*assert*/,
+ null /*taskTags*/,
+ null/*taskPriorities*/);
}
/*
* Truncate the current identifier if it is containing the cursor location. Since completion is performed
@@ -173,7 +181,7 @@
&& ((currentCharacter == '\r') || (currentCharacter == '\n')))
pushLineSeparator();
isWhiteSpace =
- (currentCharacter == ' ') || Character.isWhitespace(currentCharacter);
+ (currentCharacter == ' ') || CharOperation.isWhitespace(currentCharacter);
}
/* completion requesting strictly inside blanks */
if ((whiteStart != currentPosition)
@@ -197,6 +205,11 @@
/* might be completing at eof (e.g. behind a dot) */
if (completionIdentifier == null &&
startPosition == cursorLocation + 1){
+ // compute end of empty identifier.
+ // if the empty identifier is at the start of a next token the end of
+ // empty identifier is the end of the next token (eg. "<empty token>next").
+ while(getNextCharAsJavaIdentifierPart()) {}
+ endOfEmptyToken = currentPosition - 1;
currentPosition = startPosition; // for being detected as empty free identifier
return TokenNameIdentifier;
}
@@ -542,9 +555,11 @@
currentPosition--; // reset one character behind
return TokenNameCOMMENT_LINE;
}
- } catch (IndexOutOfBoundsException e) { //an eof will them be generated
+ } catch (IndexOutOfBoundsException e) {
+ recordComment(false);
+ if (this.taskTags != null) checkTaskTag(this.startPosition, this.currentPosition-1);
if (tokenizeComments) {
- currentPosition--; // reset one character behind
+ this.currentPosition--; // reset one character behind
return TokenNameCOMMENT_LINE;
}
}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/InvalidCursorLocation.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/InvalidCursorLocation.java
index d624eca..fb1f60f 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/InvalidCursorLocation.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/InvalidCursorLocation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.complete;
/**
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistOptions.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistOptions.java
index 70d7ab0..83615b0 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistOptions.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistOptions.java
@@ -1,17 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.impl;
+import java.util.Iterator;
import java.util.Map;
+import org.eclipse.jdt.core.compiler.CharOperation;
+
public class AssistOptions {
/**
* Option IDs
@@ -20,11 +23,35 @@
"org.eclipse.jdt.core.codeComplete.visibilityCheck"; //$NON-NLS-1$
public static final String OPTION_ForceImplicitQualification =
"org.eclipse.jdt.core.codeComplete.forceImplicitQualification"; //$NON-NLS-1$
+ public static final String OPTION_FieldPrefixes =
+ "org.eclipse.jdt.core.codeComplete.fieldPrefixes"; //$NON-NLS-1$
+ public static final String OPTION_StaticFieldPrefixes =
+ "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
+ public static final String OPTION_LocalPrefixes =
+ "org.eclipse.jdt.core.codeComplete.localPrefixes"; //$NON-NLS-1$
+ public static final String OPTION_ArgumentPrefixes =
+ "org.eclipse.jdt.core.codeComplete.argumentPrefixes"; //$NON-NLS-1$
+ public static final String OPTION_FieldSuffixes =
+ "org.eclipse.jdt.core.codeComplete.fieldSuffixes"; //$NON-NLS-1$
+ public static final String OPTION_StaticFieldSuffixes =
+ "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
+ public static final String OPTION_LocalSuffixes =
+ "org.eclipse.jdt.core.codeComplete.localSuffixes"; //$NON-NLS-1$
+ public static final String OPTION_ArgumentSuffixes =
+ "org.eclipse.jdt.core.codeComplete.argumentSuffixes"; //$NON-NLS-1$
public static final String ENABLED = "enabled"; //$NON-NLS-1$
public static final String DISABLED = "disabled"; //$NON-NLS-1$
public boolean checkVisibility = false;
public boolean forceImplicitQualification = false;
+ public char[][] fieldPrefixes = null;
+ public char[][] staticFieldPrefixes = null;
+ public char[][] localPrefixes = null;
+ public char[][] argumentPrefixes = null;
+ public char[][] fieldSuffixes = null;
+ public char[][] staticFieldSuffixes = null;
+ public char[][] localSuffixes = null;
+ public char[][] argumentSuffixes = null;
/**
* Initializing the assist options with default settings
@@ -40,9 +67,9 @@
return;
// filter options which are related to the assist component
- Object[] entries = settings.entrySet().toArray();
- for (int i = 0, max = entries.length; i < max; i++) {
- Map.Entry entry = (Map.Entry) entries[i];
+ Iterator entries = settings.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry)entries.next();
if (!(entry.getKey() instanceof String))
continue;
if (!(entry.getValue() instanceof String))
@@ -66,7 +93,63 @@
this.forceImplicitQualification = false;
}
continue;
- }
+ } else if(optionID.equals(OPTION_FieldPrefixes)){
+ if (optionValue.length() == 0) {
+ this.fieldPrefixes = null;
+ } else {
+ this.fieldPrefixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray());
+ }
+ continue;
+ } else if(optionID.equals(OPTION_StaticFieldPrefixes)){
+ if (optionValue.length() == 0) {
+ this.staticFieldPrefixes = null;
+ } else {
+ this.staticFieldPrefixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray());
+ }
+ continue;
+ } else if(optionID.equals(OPTION_LocalPrefixes)){
+ if (optionValue.length() == 0) {
+ this.localPrefixes = null;
+ } else {
+ this.localPrefixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray());
+ }
+ continue;
+ } else if(optionID.equals(OPTION_ArgumentPrefixes)){
+ if (optionValue.length() == 0) {
+ this.argumentPrefixes = null;
+ } else {
+ this.argumentPrefixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray());
+ }
+ continue;
+ } else if(optionID.equals(OPTION_FieldSuffixes)){
+ if (optionValue.length() == 0) {
+ this.fieldSuffixes = null;
+ } else {
+ this.fieldSuffixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray());
+ }
+ continue;
+ } else if(optionID.equals(OPTION_StaticFieldSuffixes)){
+ if (optionValue.length() == 0) {
+ this.staticFieldSuffixes = null;
+ } else {
+ this.staticFieldSuffixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray());
+ }
+ continue;
+ } else if(optionID.equals(OPTION_LocalSuffixes)){
+ if (optionValue.length() == 0) {
+ this.localSuffixes = null;
+ } else {
+ this.localSuffixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray());
+ }
+ continue;
+ } else if(optionID.equals(OPTION_ArgumentSuffixes)){
+ if (optionValue.length() == 0) {
+ this.argumentSuffixes = null;
+ } else {
+ this.argumentSuffixes = CharOperation.splitAndTrimOn(',', optionValue.toCharArray());
+ }
+ continue;
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
index 978cb86..99a1287 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.impl;
/*
@@ -37,12 +37,10 @@
import org.eclipse.jdt.internal.compiler.parser.RecoveredInitializer;
import org.eclipse.jdt.internal.compiler.parser.RecoveredMethod;
import org.eclipse.jdt.internal.compiler.parser.RecoveredType;
-import org.eclipse.jdt.internal.compiler.parser.RecoveredUnit;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
public abstract class AssistParser extends Parser {
-
public AstNode assistNode;
public boolean isOrphanCompletionNode;
@@ -55,31 +53,29 @@
// the index in the identifier stack of the previous identifier
protected int previousIdentifierPtr;
- // the stacks of selectors for invocations (ie. method invocations, allocation expressions and
- // explicit constructor invocations)
- // the selector stack contains pointers to the identifier stack or one of the selector constants below
- protected int invocationPtr;
- protected int[] selectorStack = new int[StackIncrement];
-
+ // element stack
+ protected static final int ElementStackIncrement = 100;
+ protected int elementPtr;
+ protected int[] elementKindStack = new int[ElementStackIncrement];
+ protected int[] elementInfoStack = new int[ElementStackIncrement];
+ protected int previousKind;
+ protected int previousInfo;
+
+ // OWNER
+ protected static final int ASSIST_PARSER = 512;
+
+ // KIND : all values known by AssistParser are between 513 and 1023
+ protected static final int K_SELECTOR = ASSIST_PARSER + 1; // whether we are inside a message send
+ protected static final int K_TYPE_DELIMITER = ASSIST_PARSER + 2; // whether we are inside a type declaration
+ protected static final int K_METHOD_DELIMITER = ASSIST_PARSER + 3; // whether we are inside a method declaration
+ protected static final int K_FIELD_INITIALIZER_DELIMITER = ASSIST_PARSER + 4; // whether we are inside a field initializer
+
// selector constants
protected static final int THIS_CONSTRUCTOR = -1;
protected static final int SUPER_CONSTRUCTOR = -2;
+
+ protected boolean isFirst = false;
- // whether the parser is in a field initializer
- // (false is pushed each time a new type is entered,
- // it is changed to true when the initializer is entered,
- // it is changed back to false when the initializer is exited,
- // and it is poped when the type is exited)
- protected int inFieldInitializationPtr;
- protected boolean[] inFieldInitializationStack = new boolean[StackIncrement];
-
- // whether the parser is in a method, constructor or initializer
- // (false is pushed each time a new type is entered,
- // it is changed to true when the method is entered,
- // it is changed back to false when the method is exited,
- // and it is poped when the type is exited)
- protected int inMethodPtr;
- protected boolean[] inMethodStack = new boolean[StackIncrement];
public AssistParser(ProblemReporter problemReporter, boolean assertMode) {
super(problemReporter, true, assertMode);
}
@@ -95,12 +91,11 @@
* Recovery state is inferred from the current state of the parser (reduced node stack).
*/
public RecoveredElement buildInitialRecoveryState(){
-
/* recovery in unit structure */
if (referenceContext instanceof CompilationUnitDeclaration){
RecoveredElement element = super.buildInitialRecoveryState();
flushAssistState();
- initInMethodAndInFieldInitializationStack(element);
+ flushElementStack();
return element;
}
@@ -117,7 +112,8 @@
TypeDeclaration type = (TypeDeclaration) referenceContext;
for (int i = 0; i < type.fields.length; i++){
FieldDeclaration field = type.fields[i];
- if (!field.isField()
+ if (field != null
+ && !field.isField()
&& field.declarationSourceStart <= scanner.initialPosition
&& scanner.initialPosition <= field.declarationSourceEnd
&& scanner.eofPosition <= field.declarationSourceEnd+1){
@@ -238,75 +234,60 @@
}
}
- initInMethodAndInFieldInitializationStack(element);
return element;
}
-protected void consumeClassBodyDeclarationsopt() {
- super.consumeClassBodyDeclarationsopt();
- this.inFieldInitializationPtr--;
- this.inMethodPtr--;
+protected void consumeClassBodyDeclaration() {
+ popElement(K_METHOD_DELIMITER);
+ super.consumeClassBodyDeclaration();
}
protected void consumeClassBodyopt() {
super.consumeClassBodyopt();
- this.invocationPtr--; // NB: This can be decremented below -1 only if in diet mode and not in field initializer
+ popElement(K_SELECTOR);
}
protected void consumeClassHeader() {
super.consumeClassHeader();
- this.pushNotInInitializer();
- this.pushNotInMethod();
+ pushOnElementStack(K_TYPE_DELIMITER);
}
protected void consumeConstructorBody() {
super.consumeConstructorBody();
- this.inMethodStack[this.inMethodPtr] = false;
+ popElement(K_METHOD_DELIMITER);
}
protected void consumeConstructorHeader() {
super.consumeConstructorHeader();
- this.inMethodStack[this.inMethodPtr] = true;
-}
-protected void consumeEmptyClassBodyDeclarationsopt() {
- super.consumeEmptyClassBodyDeclarationsopt();
- this.inFieldInitializationPtr--;
- this.inMethodPtr--;
+ pushOnElementStack(K_METHOD_DELIMITER);
}
protected void consumeEnterAnonymousClassBody() {
super.consumeEnterAnonymousClassBody();
- this.invocationPtr--; // NB: This can be decremented below -1 only if in diet mode and not in field initializer
- this.pushNotInInitializer();
- this.pushNotInMethod();
+ popElement(K_SELECTOR);
+ pushOnElementStack(K_TYPE_DELIMITER);
}
protected void consumeExplicitConstructorInvocation(int flag, int recFlag) {
super.consumeExplicitConstructorInvocation(flag, recFlag);
- this.invocationPtr--; // NB: This can be decremented below -1 only if in diet mode and not in field initializer
+ popElement(K_SELECTOR);
}
protected void consumeForceNoDiet() {
super.consumeForceNoDiet();
// if we are not in a method (ie. we are not in a local variable initializer)
// then we are entering a field initializer
- if (!this.inMethodStack[this.inMethodPtr]) {
- this.inFieldInitializationStack[this.inFieldInitializationPtr] = true;
+ if (!isInsideMethod()) {
+ pushOnElementStack(K_FIELD_INITIALIZER_DELIMITER);
}
}
protected void consumeInterfaceHeader() {
super.consumeInterfaceHeader();
- this.pushNotInInitializer();
- this.pushNotInMethod();
-}
-protected void consumeInterfaceMemberDeclarationsopt() {
- super.consumeInterfaceMemberDeclarationsopt();
- this.inFieldInitializationPtr--;
- this.inMethodPtr--;
+ pushOnElementStack(K_TYPE_DELIMITER);
}
protected void consumeMethodBody() {
super.consumeMethodBody();
- this.inMethodStack[this.inMethodPtr] = false;
+ popElement(K_METHOD_DELIMITER);
}
protected void consumeMethodHeader() {
super.consumeMethodHeader();
- this.inMethodStack[this.inMethodPtr] = true;
+ pushOnElementStack(K_METHOD_DELIMITER);
}
protected void consumeMethodInvocationName() {
super.consumeMethodInvocationName();
- this.invocationPtr--; // NB: This can be decremented below -1 only if in diet mode and not in field initializer
+ popElement(K_SELECTOR);
MessageSend messageSend = (MessageSend)expressionStack[expressionPtr];
if (messageSend == assistNode){
this.lastCheckPoint = messageSend.sourceEnd + 1;
@@ -314,7 +295,7 @@
}
protected void consumeMethodInvocationPrimary() {
super.consumeMethodInvocationPrimary();
- this.invocationPtr--; // NB: This can be decremented below -1 only if in diet mode and not in field initializer
+ popElement(K_SELECTOR);
MessageSend messageSend = (MessageSend)expressionStack[expressionPtr];
if (messageSend == assistNode){
this.lastCheckPoint = messageSend.sourceEnd + 1;
@@ -322,7 +303,7 @@
}
protected void consumeMethodInvocationSuper() {
super.consumeMethodInvocationSuper();
- this.invocationPtr--; // NB: This can be decremented below -1 only if in diet mode and not in field initializer
+ popElement(K_SELECTOR);
MessageSend messageSend = (MessageSend)expressionStack[expressionPtr];
if (messageSend == assistNode){
this.lastCheckPoint = messageSend.sourceEnd + 1;
@@ -330,7 +311,7 @@
}
protected void consumeNestedMethod() {
super.consumeNestedMethod();
- this.inMethodStack[this.inMethodPtr] = true;
+ if(!isInsideMethod()) pushOnElementStack(K_METHOD_DELIMITER);
}
protected void consumeOpenBlock() {
// OpenBlock ::= $empty
@@ -399,8 +380,8 @@
super.consumeRestoreDiet();
// if we are not in a method (ie. we were not in a local variable initializer)
// then we are exiting a field initializer
- if (!this.inMethodStack[this.inMethodPtr]) {
- this.inFieldInitializationStack[this.inFieldInitializationPtr] = false;
+ if (!isInsideMethod()) {
+ popElement(K_FIELD_INITIALIZER_DELIMITER);
}
}
protected void consumeSingleTypeImportDeclarationName() {
@@ -456,26 +437,43 @@
}
protected void consumeStaticInitializer() {
super.consumeStaticInitializer();
- this.inMethodStack[this.inMethodPtr] = false;
+ popElement(K_METHOD_DELIMITER);
}
protected void consumeStaticOnly() {
super.consumeStaticOnly();
- this.inMethodStack[this.inMethodPtr] = true;
+ pushOnElementStack(K_METHOD_DELIMITER);
}
protected void consumeToken(int token) {
super.consumeToken(token);
+
+ if(isFirst) {
+ isFirst = false;
+ return;
+ }
// register message send selector only if inside a method or if looking at a field initializer
// and if the current token is an open parenthesis
- if ((this.inMethodStack[this.inMethodPtr] || this.inFieldInitializationStack[this.inFieldInitializationPtr]) && token == TokenNameLPAREN) {
- switch (this.previousToken) {
- case TokenNameIdentifier:
- this.pushOnSelectorStack(this.identifierPtr);
+ if (isInsideMethod() || isInsideFieldInitialization()) {
+ switch (token) {
+ case TokenNameLPAREN :
+ switch (this.previousToken) {
+ case TokenNameIdentifier:
+ this.pushOnElementStack(K_SELECTOR, this.identifierPtr);
+ break;
+ case TokenNamethis: // explicit constructor invocation, eg. this(1, 2)
+ this.pushOnElementStack(K_SELECTOR, THIS_CONSTRUCTOR);
+ break;
+ case TokenNamesuper: // explicit constructor invocation, eg. super(1, 2)
+ this.pushOnElementStack(K_SELECTOR, SUPER_CONSTRUCTOR);
+ break;
+ }
break;
- case TokenNamethis: // explicit constructor invocation, eg. this(1, 2)
- this.pushOnSelectorStack(THIS_CONSTRUCTOR);
- break;
- case TokenNamesuper: // explicit constructor invocation, eg. super(1, 2)
- this.pushOnSelectorStack(SUPER_CONSTRUCTOR);
+ }
+ } else {
+ switch (token) {
+ case TokenNameRBRACE :
+ if(topKnownElementKind(ASSIST_PARSER) == K_TYPE_DELIMITER) {
+ popElement(K_TYPE_DELIMITER);
+ }
break;
}
}
@@ -550,6 +548,11 @@
this.isOrphanCompletionNode = false;
this.setAssistIdentifier(null);
}
+protected void flushElementStack() {
+ this.elementPtr = -1;
+ this.previousKind = 0;
+ this.previousInfo = 0;
+}
/*
* Build specific type reference nodes in case the cursor is located inside the type reference
*/
@@ -644,12 +647,28 @@
firstToken = TokenNameTWIDDLE;
scanner.recordLineSeparator = false;
+
+ isFirst = true;
}
public void goForConstructorBlockStatementsopt() {
//tells the scanner to go for constructor block statements opt parsing
firstToken = TokenNameNOT;
scanner.recordLineSeparator = false;
+
+ isFirst = true;
+}
+public void goForHeaders(){
+ super.goForHeaders();
+ isFirst = true;
+}
+public void goForCompilationUnit(){
+ super.goForCompilationUnit();
+ isFirst = true;
+}
+public void goForBlockStatementsOrMethodHeaders() {
+ super.goForBlockStatementsOrMethodHeaders();
+ isFirst = true;
}
/*
* Retrieve a partial subset of a qualified name reference up to the completion point.
@@ -700,64 +719,82 @@
public void initialize() {
super.initialize();
this.flushAssistState();
- this.invocationPtr = -1;
- this.inMethodStack[this.inMethodPtr = 0] = false;
- this.inFieldInitializationStack[this.inFieldInitializationPtr = 0] = false;
+ this.flushElementStack();
this.previousIdentifierPtr = -1;
}
+
public abstract void initializeScanner();
-
-protected void initInMethodAndInFieldInitializationStack(RecoveredElement currentElement) {
-
- int length = currentElement.depth() + 1;
- int ptr = length;
- boolean[] methodStack = new boolean[length];
- boolean[] fieldInitializationStack = new boolean[length];
- boolean inMethod = false;
- boolean inFieldInitializer = false;
-
- RecoveredElement element = currentElement;
- while(element != null){
- if(element instanceof RecoveredMethod ||
- element instanceof RecoveredInitializer) {
- if(element.parent == null) {
- methodStack[--ptr] = true;
- fieldInitializationStack[ptr] = false;
- }
- inMethod = true;
- } else if(element instanceof RecoveredField){
- inFieldInitializer = element.sourceEnd() == 0;
- } else if(element instanceof RecoveredType){
- methodStack[--ptr] = inMethod;
- fieldInitializationStack[ptr] = inFieldInitializer;
-
- inMethod = false;
- inFieldInitializer = false;
- } else if(element instanceof RecoveredUnit) {
- methodStack[--ptr] = false;
- fieldInitializationStack[ptr] = false;
- }
- element = element.parent;
- }
-
- inMethodPtr = length - ptr - 1;
- inFieldInitializationPtr = inMethodPtr;
- System.arraycopy(methodStack, ptr, inMethodStack, 0, inMethodPtr + 1);
- System.arraycopy(fieldInitializationStack, ptr, inFieldInitializationStack, 0, inFieldInitializationPtr + 1);
-
-}
-
-/**
- * Returns whether we are directly or indirectly inside a field initializer.
- */
-protected boolean insideFieldInitialization() {
- for (int i = this.inFieldInitializationPtr; i >= 0; i--) {
- if (this.inFieldInitializationStack[i]) {
+protected boolean isIndirectlyInsideFieldInitialization(){
+ int i = elementPtr;
+ while(i > -1) {
+ if(elementKindStack[i] == K_FIELD_INITIALIZER_DELIMITER)
return true;
- }
+ i--;
}
return false;
}
+protected boolean isIndirectlyInsideMethod(){
+ int i = elementPtr;
+ while(i > -1) {
+ if(elementKindStack[i] == K_METHOD_DELIMITER)
+ return true;
+ i--;
+ }
+ return false;
+}
+protected boolean isIndirectlyInsideType(){
+ int i = elementPtr;
+ while(i > -1) {
+ if(elementKindStack[i] == K_TYPE_DELIMITER)
+ return true;
+ i--;
+ }
+ return false;
+}
+protected boolean isInsideFieldInitialization(){
+ int i = elementPtr;
+ while(i > -1) {
+ switch (elementKindStack[i]) {
+ case K_TYPE_DELIMITER : return false;
+ case K_METHOD_DELIMITER : return false;
+ case K_FIELD_INITIALIZER_DELIMITER : return true;
+ }
+ i--;
+ }
+ return false;
+}
+protected boolean isInsideMethod(){
+ int i = elementPtr;
+ while(i > -1) {
+ switch (elementKindStack[i]) {
+ case K_TYPE_DELIMITER : return false;
+ case K_METHOD_DELIMITER : return true;
+ case K_FIELD_INITIALIZER_DELIMITER : return false;
+ }
+ i--;
+ }
+ return false;
+}
+protected boolean isInsideType(){
+ int i = elementPtr;
+ while(i > -1) {
+ switch (elementKindStack[i]) {
+ case K_TYPE_DELIMITER : return true;
+ case K_METHOD_DELIMITER : return false;
+ case K_FIELD_INITIALIZER_DELIMITER : return false;
+ }
+ i--;
+ }
+ return false;
+}
+protected int lastIndexOfElement(int kind) {
+ int i = elementPtr;
+ while(i > -1) {
+ if(elementKindStack[i] == kind) return i;
+ i--;
+ }
+ return -1;
+}
/**
* Parse the block statements inside the given method declaration and try to complete at the
* cursor location.
@@ -857,6 +894,32 @@
nestedMethod[nestedType]--;
}
}
+protected void popElement(int kind){
+ if(elementPtr < 0 || elementKindStack[elementPtr] != kind) return;
+
+ previousKind = elementKindStack[elementPtr];
+ previousInfo = elementInfoStack[elementPtr];
+
+ switch (kind) {
+ default :
+ elementPtr--;
+ break;
+ }
+}
+protected void popUntilElement(int kind){
+ if(elementPtr < 0) return;
+ int i = elementPtr;
+ while (i >= 0 && elementKindStack[i] != kind) {
+ i--;
+ }
+ if(i >= 0) {
+ if(i < elementPtr) {
+ previousKind = elementKindStack[i+1];
+ previousInfo = elementInfoStack[i+1];
+ }
+ elementPtr = i;
+ }
+}
/*
* Prepares the state of the parser to go for BlockStatements.
*/
@@ -864,47 +927,98 @@
this.nestedMethod[this.nestedType = 0] = 1;
this.variablesCounter[this.nestedType] = 0;
this.realBlockStack[this.realBlockPtr = 1] = 0;
- this.invocationPtr = -1;
-}
-/*
- * Pushes 'false' on the inInitializerStack.
- */
-protected void pushNotInInitializer() {
- try {
- this.inFieldInitializationStack[++this.inFieldInitializationPtr] = false;
- } catch (IndexOutOfBoundsException e) {
- //except in test's cases, it should never raise
- int oldStackLength = this.inFieldInitializationStack.length;
- System.arraycopy(this.inFieldInitializationStack , 0, (this.inFieldInitializationStack = new boolean[oldStackLength + StackIncrement]), 0, oldStackLength);
- this.inFieldInitializationStack[this.inFieldInitializationPtr] = false;
+
+ // initialize element stack
+ int fieldInitializerIndex = lastIndexOfElement(K_FIELD_INITIALIZER_DELIMITER);
+ int methodIndex = lastIndexOfElement(K_METHOD_DELIMITER);
+ if(methodIndex == fieldInitializerIndex) {
+ // there is no method and no field initializer
+ flushElementStack();
+ } else if(methodIndex > fieldInitializerIndex) {
+ popUntilElement(K_METHOD_DELIMITER);
+ } else {
+ popUntilElement(K_FIELD_INITIALIZER_DELIMITER);
}
}
/*
- * Pushes 'false' on the inMethodStack.
+ * Prepares the state of the parser to go for Headers.
*/
-protected void pushNotInMethod() {
+protected void prepareForHeaders() {
+ nestedMethod[nestedType = 0] = 0;
+ variablesCounter[nestedType] = 0;
+ realBlockStack[realBlockPtr = 0] = 0;
+
+ popUntilElement(K_TYPE_DELIMITER);
+}
+protected void pushOnElementStack(int kind){
+ this.pushOnElementStack(kind, 0);
+}
+protected void pushOnElementStack(int kind, int info){
+ if (this.elementPtr < -1) return;
+
+ this.previousKind = 0;
+ this.previousInfo = 0;
+
try {
- this.inMethodStack[++this.inMethodPtr] = false;
+ this.elementPtr++;
+ this.elementKindStack[this.elementPtr] = kind;
+ this.elementInfoStack[this.elementPtr] = info;
} catch (IndexOutOfBoundsException e) {
- //except in test's cases, it should never raise
- int oldStackLength = this.inMethodStack.length;
- System.arraycopy(this.inMethodStack , 0, (this.inMethodStack = new boolean[oldStackLength + StackIncrement]), 0, oldStackLength);
- this.inMethodStack[this.inMethodPtr] = false;
+ int oldStackLength = this.elementKindStack.length;
+ int oldElementStack[] = this.elementKindStack;
+ int oldElementInfoStack[] = this.elementInfoStack;
+ this.elementKindStack = new int[oldStackLength + StackIncrement];
+ this.elementInfoStack = new int[oldStackLength + StackIncrement];
+ System.arraycopy(oldElementStack, 0, this.elementKindStack, 0, oldStackLength);
+ System.arraycopy(oldElementInfoStack, 0, this.elementInfoStack, 0, oldStackLength);
+ this.elementKindStack[this.elementPtr] = kind;
+ this.elementInfoStack[this.elementPtr] = info;
}
}
-/**
- * Pushes the given the given selector (an identifier pointer to the identifier stack) on the selector stack.
- */
-protected void pushOnSelectorStack(int selectorIdPtr) {
- if (this.invocationPtr < -1) return;
- try {
- this.selectorStack[++this.invocationPtr] = selectorIdPtr;
- } catch (IndexOutOfBoundsException e) {
- int oldStackLength = this.selectorStack.length;
- int oldSelectorStack[] = this.selectorStack;
- this.selectorStack = new int[oldStackLength + StackIncrement];
- System.arraycopy(oldSelectorStack, 0, this.selectorStack, 0, oldStackLength);
- this.selectorStack[this.invocationPtr] = selectorIdPtr;
+public void recoveryExitFromVariable() {
+ if(currentElement != null && currentElement instanceof RecoveredField
+ && !(currentElement instanceof RecoveredInitializer)) {
+ RecoveredElement oldElement = currentElement;
+ super.recoveryExitFromVariable();
+ if(oldElement != currentElement) {
+ popElement(K_FIELD_INITIALIZER_DELIMITER);
+ }
+ } else {
+ super.recoveryExitFromVariable();
+ }
+}
+public void recoveryTokenCheck() {
+ RecoveredElement oldElement = currentElement;
+ switch (currentToken) {
+ case TokenNameLBRACE :
+ super.recoveryTokenCheck();
+ if(currentElement instanceof RecoveredInitializer) {
+ if(oldElement instanceof RecoveredField) {
+ popUntilElement(K_FIELD_INITIALIZER_DELIMITER);
+ popElement(K_FIELD_INITIALIZER_DELIMITER);
+ }
+ if(currentElement != oldElement
+ && topKnownElementKind(ASSIST_PARSER) != K_METHOD_DELIMITER) {
+ pushOnElementStack(K_METHOD_DELIMITER);
+ }
+ }
+ break;
+ case TokenNameRBRACE :
+ super.recoveryTokenCheck();
+ if(currentElement != oldElement) {
+ if(oldElement instanceof RecoveredInitializer
+ || oldElement instanceof RecoveredMethod) {
+ popUntilElement(K_METHOD_DELIMITER);
+ popElement(K_METHOD_DELIMITER);
+ } else if(oldElement instanceof RecoveredType) {
+ popUntilElement(K_TYPE_DELIMITER);
+ popElement(K_TYPE_DELIMITER);
+ }
+ }
+ break;
+ default :
+ super.recoveryTokenCheck();
+ break;
}
}
public void reset(){
@@ -912,14 +1026,6 @@
}
/*
* Reset context so as to resume to regular parse loop
- */
-protected void resetStacks() {
- super.resetStacks();
- this.inFieldInitializationStack[this.inFieldInitializationPtr = 0] = false;
- this.inMethodStack[this.inMethodPtr = 0] = false;
-}
-/*
- * Reset context so as to resume to regular parse loop
* If unable to reset for resuming, answers false.
*
* Move checkpoint location, reset internal stacks and
@@ -944,22 +1050,17 @@
/* attempt to move checkpoint location */
if (!this.moveRecoveryCheckpoint()) return false;
- initInMethodAndInFieldInitializationStack(currentElement);
-
// only look for headers
if (referenceContext instanceof CompilationUnitDeclaration
|| this.assistNode != null){
-
- if(inMethodStack[inMethodPtr] &&
- insideFieldInitialization() &&
+ if(isInsideMethod() &&
+ isIndirectlyInsideFieldInitialization() &&
this.assistNode == null
){
this.prepareForBlockStatements();
goForBlockStatementsOrMethodHeaders();
} else {
- nestedMethod[nestedType = 0] = 0;
- variablesCounter[nestedType] = 0;
- realBlockStack[realBlockPtr = 0] = 0;
+ this.prepareForHeaders();
goForHeaders();
diet = true; // passed this point, will not consider method bodies
}
@@ -969,9 +1070,7 @@
|| referenceContext instanceof TypeDeclaration){
if (currentElement instanceof RecoveredType){
- nestedMethod[nestedType = 0] = 0;
- variablesCounter[nestedType] = 0;
- realBlockStack[realBlockPtr = 0] = 0;
+ this.prepareForHeaders();
goForHeaders();
} else {
this.prepareForBlockStatements();
@@ -983,6 +1082,34 @@
return false;
}
public abstract void setAssistIdentifier(char[] assistIdent);
+protected int topKnownElementInfo(int owner) {
+ return topKnownElementInfo(owner, 0);
+}
+protected int topKnownElementInfo(int owner, int offSet) {
+ int i = elementPtr;
+ while(i > -1) {
+ if((elementKindStack[i] & owner) != 0) {
+ if(offSet <= 0) return elementInfoStack[i];
+ offSet--;
+ }
+ i--;
+ }
+ return 0;
+}
+protected int topKnownElementKind(int owner) {
+ return topKnownElementKind(owner, 0);
+}
+protected int topKnownElementKind(int owner, int offSet) {
+ int i = elementPtr;
+ while(i > -1) {
+ if((elementKindStack[i] & owner) != 0) {
+ if(offSet <= 0) return elementKindStack[i];
+ offSet--;
+ }
+ i--;
+ }
+ return 0;
+}
/**
* If the given ast node is inside an explicit constructor call
* then wrap it with a fake constructor call.
@@ -990,8 +1117,8 @@
*/
protected AstNode wrapWithExplicitConstructorCallIfNeeded(AstNode ast) {
int selector;
- if (ast != null && this.invocationPtr >= 0 && ast instanceof Expression &&
- (((selector = this.selectorStack[this.invocationPtr]) == THIS_CONSTRUCTOR) ||
+ if (ast != null && topKnownElementKind(ASSIST_PARSER) == K_SELECTOR && ast instanceof Expression &&
+ (((selector = topKnownElementInfo(ASSIST_PARSER)) == THIS_CONSTRUCTOR) ||
(selector == SUPER_CONSTRUCTOR))) {
ExplicitConstructorCall call = new ExplicitConstructorCall(
(selector == THIS_CONSTRUCTOR) ?
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java
index a00e5d2..c33a748 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java
Binary files differ
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java
new file mode 100644
index 0000000..97a94be
--- /dev/null
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.codeassist.impl;
+
+public interface Keywords {
+ int COUNT = 41;
+
+ char[] ABSTARCT = "abstract".toCharArray(); //$NON-NLS-1$
+ char[] ASSERT = "assert".toCharArray(); //$NON-NLS-1$
+ char[] BREAK = "break".toCharArray(); //$NON-NLS-1$
+ char[] CASE = "case".toCharArray(); //$NON-NLS-1$
+ char[] CATCH = "catch".toCharArray(); //$NON-NLS-1$
+ char[] CLASS = "class".toCharArray(); //$NON-NLS-1$
+ char[] CONTINUE = "continue".toCharArray(); //$NON-NLS-1$
+ char[] DEFAULT = "default".toCharArray(); //$NON-NLS-1$
+ char[] DO = "do".toCharArray(); //$NON-NLS-1$
+ char[] ELSE = "else".toCharArray(); //$NON-NLS-1$
+ char[] EXTENDS = "extends".toCharArray(); //$NON-NLS-1$
+ char[] FINAL = "final".toCharArray(); //$NON-NLS-1$
+ char[] FINALLY = "finally".toCharArray(); //$NON-NLS-1$
+ char[] FOR = "for".toCharArray(); //$NON-NLS-1$
+ char[] IF = "if".toCharArray(); //$NON-NLS-1$
+ char[] IMPLEMENTS = "implements".toCharArray(); //$NON-NLS-1$
+ char[] IMPORT = "import".toCharArray(); //$NON-NLS-1$
+ char[] INSTANCEOF = "instanceof".toCharArray(); //$NON-NLS-1$
+ char[] INTERFACE = "interface".toCharArray(); //$NON-NLS-1$
+ char[] NATIVE = "native".toCharArray(); //$NON-NLS-1$
+ char[] NEW = "new".toCharArray(); //$NON-NLS-1$
+ char[] PACKAGE = "package".toCharArray(); //$NON-NLS-1$
+ char[] PRIVATE = "private".toCharArray(); //$NON-NLS-1$
+ char[] PROTECTED = "protected".toCharArray(); //$NON-NLS-1$
+ char[] PUBLIC = "public".toCharArray(); //$NON-NLS-1$
+ char[] RETURN = "return".toCharArray(); //$NON-NLS-1$
+ char[] STATIC = "static".toCharArray(); //$NON-NLS-1$
+ char[] STRICTFP = "strictfp".toCharArray(); //$NON-NLS-1$
+ char[] SUPER = "super".toCharArray(); //$NON-NLS-1$
+ char[] SWITCH = "switch".toCharArray(); //$NON-NLS-1$
+ char[] SYNCHRONIZED = "synchronized".toCharArray(); //$NON-NLS-1$
+ char[] THIS = "this".toCharArray(); //$NON-NLS-1$
+ char[] THROW = "throw".toCharArray(); //$NON-NLS-1$
+ char[] THROWS = "throws".toCharArray(); //$NON-NLS-1$
+ char[] TRANSIENT = "transient".toCharArray(); //$NON-NLS-1$
+ char[] TRY = "try".toCharArray(); //$NON-NLS-1$
+ char[] VOLATILE = "volatile".toCharArray(); //$NON-NLS-1$
+ char[] WHILE = "while".toCharArray(); //$NON-NLS-1$
+ char[] TRUE = "true".toCharArray(); //$NON-NLS-1$
+ char[] FALSE = "false".toCharArray(); //$NON-NLS-1$
+ char[] NULL = "null".toCharArray(); //$NON-NLS-1$
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionNodeFound.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionNodeFound.java
index 331dcc5..5a5d96a 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionNodeFound.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionNodeFound.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
import org.eclipse.jdt.internal.compiler.lookup.*;
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnArgumentName.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnArgumentName.java
index c79ff57..3f75e96 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnArgumentName.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnArgumentName.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
import org.eclipse.jdt.internal.compiler.ast.Argument;
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java
index 643388b..ffe252f 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnExplicitConstructorCall.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java
index d554df7..aecc5fd 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldType.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldType.java
index 370af3b..cb76584 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldType.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnFieldType.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
@@ -19,7 +20,7 @@
this.sourceStart = type.sourceStart;
this.sourceEnd = type.sourceEnd;
this.type = type;
- this.name = NoChar;
+ this.name = CharOperation.NO_CHAR;
}
public String toString(int tab) {
return type.toString(tab);
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java
index 5f6ad26..3c99952 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnImportReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnLocalName.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnLocalName.java
index 5204d49..fbb137a 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnLocalName.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnLocalName.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
import org.eclipse.jdt.internal.compiler.ast.Expression;
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java
index d0d8811..eb73dc2 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnMessageSend.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
@@ -30,14 +30,67 @@
*/
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
-import org.eclipse.jdt.internal.compiler.ast.ThisReference;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TagBits;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class SelectionOnMessageSend extends MessageSend {
+ /*
+ * Cannot answer default abstract match, iterate in superinterfaces of declaring class
+ * for a better match (default abstract match came from scope lookups).
+ */
+ private MethodBinding findNonDefaultAbstractMethod(MethodBinding binding) {
+
+ ReferenceBinding[] itsInterfaces = binding.declaringClass.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+ ReferenceBinding[][] interfacesToVisit = new ReferenceBinding[5][];
+ int lastPosition = 0;
+ interfacesToVisit[lastPosition] = itsInterfaces;
+
+ for (int i = 0; i <= lastPosition; i++) {
+ ReferenceBinding[] interfaces = interfacesToVisit[i];
+
+ for (int j = 0, length = interfaces.length; j < length; j++) {
+ ReferenceBinding currentType = interfaces[j];
+
+ if ((currentType.tagBits & TagBits.InterfaceVisited) == 0) {
+ // if interface as not already been visited
+ currentType.tagBits |= TagBits.InterfaceVisited;
+
+ MethodBinding[] methods = currentType.getMethods(binding.selector);;
+ if(methods != null) {
+ for (int k = 0; k < methods.length; k++) {
+ if(binding.areParametersEqual(methods[k])) {
+ return methods[k];
+ }
+ }
+ }
+
+ itsInterfaces = currentType.superInterfaces();
+ if (itsInterfaces != NoSuperInterfaces) {
+
+ if (++lastPosition == interfacesToVisit.length)
+ System.arraycopy(
+ interfacesToVisit,
+ 0,
+ interfacesToVisit = new ReferenceBinding[lastPosition * 2][],
+ 0,
+ lastPosition);
+ interfacesToVisit[lastPosition] = itsInterfaces;
+ }
+ }
+ }
+ }
+ }
+ return binding;
+ }
+
public TypeBinding resolveType(BlockScope scope) {
+
super.resolveType(scope);
// tolerate some error cases
@@ -49,13 +102,18 @@
|| binding.problemId() == ProblemReasons.NonStaticReferenceInStaticContext)) {
throw new SelectionNodeFound();
} else {
- throw new SelectionNodeFound(binding);
+ if(binding.isDefaultAbstract()) {
+ throw new SelectionNodeFound(findNonDefaultAbstractMethod(binding)); // 23594
+ } else {
+ throw new SelectionNodeFound(binding);
+ }
}
}
-
+
public String toStringExpression() {
+
String s = "<SelectOnMessageSend:"; //$NON-NLS-1$
- if (receiver != ThisReference.ThisImplicit)
+ if (!receiver.isImplicitThis())
s = s + receiver.toStringExpression() + "."; //$NON-NLS-1$
s = s + new String(selector) + "("; //$NON-NLS-1$
if (arguments != null) {
@@ -69,4 +127,4 @@
s = s + ")>"; //$NON-NLS-1$
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java
index 029b528..a7c3587 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java
index e782421..c0dcb4f 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedAllocationExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java
index 6a3e135..6212773 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedNameReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
@@ -31,6 +31,7 @@
*
*/
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
@@ -38,7 +39,6 @@
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class SelectionOnQualifiedNameReference extends QualifiedNameReference {
public long[] sourcePositions; // positions of each token, the last one being the positions of the completion identifier
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java
index aed9fe1..eb1cb41 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedSuperReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java
index 244e906..79bee2a 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnQualifiedTypeReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
@@ -22,12 +22,12 @@
*
*/
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
import org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class SelectionOnQualifiedTypeReference extends QualifiedTypeReference {
public SelectionOnQualifiedTypeReference(char[][] previousIdentifiers, char[] selectionIdentifier, long[] positions) {
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java
index 10998bb..e2c89c5 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleNameReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java
index 9e955ab..a42533a 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSingleTypeReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
@@ -51,12 +51,12 @@
super.resolveTypeEnclosing(scope, enclosingType);
// tolerate some error cases
- if (binding == null ||
- !(binding.isValidBinding() ||
- binding.problemId() == ProblemReasons.NotVisible))
+ if (this.resolvedType == null ||
+ !(this.resolvedType.isValidBinding() ||
+ this.resolvedType.problemId() == ProblemReasons.NotVisible))
throw new SelectionNodeFound();
else
- throw new SelectionNodeFound(binding);
+ throw new SelectionNodeFound(this.resolvedType);
}
public String toStringExpression(int tab){
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java
index 6dbe135..37cb3d1 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnSuperReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
index 1b31b52..3b6abbd 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
@@ -23,13 +23,13 @@
import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.env.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.codeassist.impl.*;
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class SelectionParser extends AssistParser {
@@ -143,12 +143,27 @@
super.classInstanceCreation(alwaysQualified);
}
}
+protected void consumeArrayCreationExpressionWithoutInitializer() {
+ // ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
+ // ArrayCreationWithoutArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
-protected void consumeArrayCreationExpression() {
- // ArrayCreationExpression ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializeropt
- // ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializeropt
+ super.consumeArrayCreationExpressionWithoutInitializer();
- super.consumeArrayCreationExpression();
+ ArrayAllocationExpression alloc = (ArrayAllocationExpression)expressionStack[expressionPtr];
+ if (alloc.type == assistNode){
+ if (!diet){
+ this.restartRecovery = true; // force to restart in recovery mode
+ this.lastIgnoredToken = -1;
+ }
+ this.isOrphanCompletionNode = true;
+ }
+}
+
+protected void consumeArrayCreationExpressionWithInitializer() {
+ // ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
+ // ArrayCreationWithArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializer
+
+ super.consumeArrayCreationExpressionWithInitializer();
ArrayAllocationExpression alloc = (ArrayAllocationExpression)expressionStack[expressionPtr];
if (alloc.type == assistNode){
@@ -171,7 +186,7 @@
new AnonymousLocalTypeDeclaration(this.compilationUnit.compilationResult);
alloc =
anonymousType.allocation = new SelectionOnQualifiedAllocationExpression(anonymousType);
- markCurrentMethodWithLocalType();
+ markEnclosingMemberWithLocalType();
pushOnAstStack(anonymousType);
alloc.sourceEnd = rParenPos; //the position has been stored explicitly
@@ -201,16 +216,18 @@
this.lastCheckPoint = alloc.sourceEnd + 1;
if (!diet){
this.restartRecovery = true; // force to restart in recovery mode
- this.lastIgnoredToken = -1;
+ this.lastIgnoredToken = -1;
+ currentToken = 0; // opening brace already taken into account
+ hasReportedError = true;
}
- this.isOrphanCompletionNode = true;
-
- anonymousType.bodyStart = scanner.currentPosition;
+
+ anonymousType.bodyStart = scanner.currentPosition;
listLength = 0; // will be updated when reading super-interfaces
// recovery
- if (currentElement != null){
+ if (currentElement != null){
lastCheckPoint = anonymousType.bodyStart;
- currentElement = currentElement.add(anonymousType, 0); // the recoveryTokenCheck will deal with the open brace
+ currentElement = currentElement.add(anonymousType, 0);
+ currentToken = 0; // opening brace already taken into account
lastIgnoredToken = -1;
}
}
@@ -277,6 +294,14 @@
protected void consumeFormalParameter() {
if (this.indexOfAssistIdentifier() < 0) {
super.consumeFormalParameter();
+ if((!diet || dietInt != 0) && astPtr > -1) {
+ Argument argument = (Argument) astStack[astPtr];
+ if(argument.type == assistNode) {
+ isOrphanCompletionNode = true;
+ this.restartRecovery = true; // force to restart in recovery mode
+ this.lastIgnoredToken = -1;
+ }
+ }
} else {
identifierLengthPtr--;
@@ -544,7 +569,7 @@
this.lastIgnoredToken = -1;
}
this.isOrphanCompletionNode = true;
- return new SingleNameReference(new char[0], 0); // dummy reference
+ return new SingleNameReference(CharOperation.NO_CHAR, 0); // dummy reference
}
NameReference nameReference;
/* retrieve identifiers subset and whole positions, the completion node positions
@@ -677,6 +702,12 @@
this.selectionIdentifierCheck();
this.attachOrphanCompletionNode();
+ // if an assist node has been found and a recovered element exists,
+ // mark enclosing blocks as to be preserved
+ if (this.assistNode != null && this.currentElement != null) {
+ currentElement.preserveEnclosingBlocks();
+ }
+
/* check and update recovered state based on current token,
this action is also performed when shifting token after recovery
got activated once.
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java
index 737f87e..aab9afd 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionScanner.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.codeassist.select;
/*
@@ -30,7 +30,7 @@
*/
public SelectionScanner(boolean assertMode) {
- super(false, false, false, assertMode);
+ super(false /*comment*/, false /*whitespace*/, false /*nls*/, assertMode /*assert*/, null /*taskTags*/, null/*taskPriorities*/);
}
public char[] getCurrentIdentifierSource() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CharOperation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CharOperation.java
new file mode 100644
index 0000000..915f387
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/CharOperation.java
@@ -0,0 +1,2572 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.compiler;
+
+/**
+ * This class is a collection of helper methods to manipulate char arrays.
+ *
+ * @since 2.1
+ */
+public final class CharOperation {
+
+ /**
+ * Constant for an empty char array
+ */
+ public static final char[] NO_CHAR = new char[0];
+
+ /**
+ * Constant for an empty char array with two dimensions.
+ */
+ public static final char[][] NO_CHAR_CHAR = new char[0][];
+
+ /**
+ * Answers a new array with appending the suffix character at the end of the array.
+ * <br>
+ * <br>
+ * For example:<br>
+ * <ol>
+ * <li><pre>
+ * array = { 'a', 'b' }
+ * suffix = 'c'
+ * => result = { 'a', 'b' , 'c' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = null
+ * suffix = 'c'
+ * => result = { 'c' }
+ * </pre></li>
+ * </ol>
+ *
+ * @param array the array that is concanated with the suffix character
+ * @param suffix the suffix character
+ * @return the new array
+ */
+ public static final char[] append(char[] array, char suffix) {
+ if (array == null)
+ return new char[] { suffix };
+ int length = array.length;
+ System.arraycopy(array, 0, array = new char[length + 1], 0, length);
+ array[length] = suffix;
+ return array;
+ }
+ /**
+ * Append the given subarray to the target array starting at the given index in the target array.
+ * The start of the subarray is inclusive, the end is exclusive.
+ * Answers a new target array if it needs to grow, otherwise answers the same target array.
+ * <br>
+ * For example:<br>
+ * <ol>
+ * <li><pre>
+ * target = { 'a', 'b', '0' }
+ * index = 2
+ * array = { 'c', 'd' }
+ * start = 0
+ * end = 1
+ * => result = { 'a', 'b' , 'c' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * target = { 'a', 'b' }
+ * index = 2
+ * array = { 'c', 'd' }
+ * start = 0
+ * end = 1
+ * => result = { 'a', 'b' , 'c', '0', '0' , '0' } (new array)
+ * </pre></li>
+ * <li><pre>
+ * target = { 'a', 'b', 'c' }
+ * index = 1
+ * array = { 'c', 'd', 'e', 'f' }
+ * start = 1
+ * end = 4
+ * => result = { 'a', 'd' , 'e', 'f', '0', '0', '0', '0' } (new array)
+ * </pre></li>
+ * </ol>
+ *
+ * @param target the given target
+ * @param index the given index
+ * @param array the given array
+ * @param start the given start index
+ * @param end the given end index
+ *
+ * @return the new array
+ * @throws NullPointerException if the target array is null
+ */
+ public static final char[] append(char[] target, int index, char[] array, int start, int end) {
+ int targetLength = target.length;
+ int subLength = end-start;
+ int newTargetLength = subLength+index;
+ if (newTargetLength > targetLength) {
+ System.arraycopy(target, 0, target = new char[newTargetLength*2], 0, index);
+ }
+ System.arraycopy(array, start, target, index, subLength);
+ return target;
+ }
+
+ /**
+ * Answers the concatenation of the two arrays. It answers null if the two arrays are null.
+ * If the first array is null, then the second array is returned.
+ * If the second array is null, then the first array is returned.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = null
+ * => result = null
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { ' a' } }
+ * second = null
+ * => result = { { ' a' } }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = null
+ * second = { { ' a' } }
+ * => result = { { ' a' } }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { ' b' } }
+ * second = { { ' a' } }
+ * => result = { { ' b' }, { ' a' } }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array to concatenate
+ * @param second the second array to concatenate
+ * @return the concatenation of the two arrays, or null if the two arrays are null.
+ */
+ public static final char[][] arrayConcat(char[][] first, char[][] second) {
+ if (first == null)
+ return second;
+ if (second == null)
+ return first;
+
+ int length1 = first.length;
+ int length2 = second.length;
+ char[][] result = new char[length1 + length2][];
+ System.arraycopy(first, 0, result, 0, length1);
+ System.arraycopy(second, 0, result, length1, length2);
+ return result;
+ }
+
+ /**
+ * Answers a new array adding the second array at the end of first array.
+ * It answers null if the first and second are null.
+ * If the first array is null, then a new array char[][] is created with second.
+ * If the second array is null, then the first array is returned.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = { 'a' }
+ * => result = { { ' a' } }
+ * </pre>
+ * <li><pre>
+ * first = { { ' a' } }
+ * second = null
+ * => result = { { ' a' } }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { ' a' } }
+ * second = { ' b' }
+ * => result = { { ' a' } , { ' b' } }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array to concatenate
+ * @param second the array to add at the end of the first array
+ * @return a new array adding the second array at the end of first array, or null if the two arrays are null.
+ */
+ public static final char[][] arrayConcat(char[][] first, char[] second) {
+ if (second == null)
+ return first;
+ if (first == null)
+ return new char[][] { second };
+
+ int length = first.length;
+ char[][] result = new char[length + 1][];
+ System.arraycopy(first, 0, result, 0, length);
+ result[length] = second;
+ return result;
+ }
+
+ /**
+ * Compare the contents of the two arrays array and prefix and answers:
+ * <ul>
+ * <li>zero if the array starts with the prefix contents</li>
+ * <li>the difference between the first two characters that are not equal </li>
+ * <li>one if array length is lower than the prefix length and that the prefix starts with the
+ * array contents.</li>
+ * </ul>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * array = null
+ * prefix = null
+ * => result = NullPointerException
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'a', 'b', 'c', 'd', 'e' }
+ * prefix = { 'a', 'b', 'c'}
+ * => result = 0
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'a', 'b', 'c', 'd', 'e' }
+ * prefix = { 'a', 'B', 'c'}
+ * => result = 32
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'd', 'b', 'c', 'd', 'e' }
+ * prefix = { 'a', 'b', 'c'}
+ * => result = 3
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'a', 'b', 'c', 'd', 'e' }
+ * prefix = { 'd', 'b', 'c'}
+ * => result = -3
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'a', 'a', 'c', 'd', 'e' }
+ * prefix = { 'a', 'e', 'c'}
+ * => result = -4
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param array the given array
+ * @param prefix the given prefix
+ * @return the result of the comparison
+ * @exception NullPointerException if either array or prefix is null
+ */
+ public static final int compareWith(char[] array, char[] prefix) {
+ int arrayLength = array.length;
+ int prefixLength = prefix.length;
+ int min = Math.min(arrayLength, prefixLength);
+ int i = 0;
+ while (min-- != 0) {
+ char c1 = array[i];
+ char c2 = prefix[i++];
+ if (c1 != c2)
+ return c1 - c2;
+ }
+ if (prefixLength == i)
+ return 0;
+ return 1;
+ }
+
+ /**
+ * Answers the concatenation of the two arrays. It answers null if the two arrays are null.
+ * If the first array is null, then the second array is returned.
+ * If the second array is null, then the first array is returned.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = { 'a' }
+ * => result = { ' a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { ' a' }
+ * second = null
+ * => result = { ' a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { ' a' }
+ * second = { ' b' }
+ * => result = { ' a' , ' b' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array to concatenate
+ * @param second the second array to concatenate
+ * @return the concatenation of the two arrays, or null if the two arrays are null.
+ */
+ public static final char[] concat(char[] first, char[] second) {
+ if (first == null)
+ return second;
+ if (second == null)
+ return first;
+
+ int length1 = first.length;
+ int length2 = second.length;
+ char[] result = new char[length1 + length2];
+ System.arraycopy(first, 0, result, 0, length1);
+ System.arraycopy(second, 0, result, length1, length2);
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the three arrays. It answers null if the three arrays are null.
+ * If first is null, it answers the concatenation of second and third.
+ * If second is null, it answers the concatenation of first and third.
+ * If third is null, it answers the concatenation of first and second.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = { 'a' }
+ * third = { 'b' }
+ * => result = { ' a', 'b' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { 'a' }
+ * second = null
+ * third = { 'b' }
+ * => result = { ' a', 'b' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { 'a' }
+ * second = { 'b' }
+ * third = null
+ * => result = { ' a', 'b' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = null
+ * second = null
+ * third = null
+ * => result = null
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { 'a' }
+ * second = { 'b' }
+ * third = { 'c' }
+ * => result = { 'a', 'b', 'c' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array to concatenate
+ * @param second the second array to concatenate
+ * @param third the third array to concatenate
+ *
+ * @return the concatenation of the three arrays, or null if the three arrays are null.
+ */
+ public static final char[] concat(
+ char[] first,
+ char[] second,
+ char[] third) {
+ if (first == null)
+ return concat(second, third);
+ if (second == null)
+ return concat(first, third);
+ if (third == null)
+ return concat(first, second);
+
+ int length1 = first.length;
+ int length2 = second.length;
+ int length3 = third.length;
+ char[] result = new char[length1 + length2 + length3];
+ System.arraycopy(first, 0, result, 0, length1);
+ System.arraycopy(second, 0, result, length1, length2);
+ System.arraycopy(third, 0, result, length1 + length2, length3);
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the two arrays inserting the separator character between the two arrays.
+ * It answers null if the two arrays are null.
+ * If the first array is null, then the second array is returned.
+ * If the second array is null, then the first array is returned.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = { 'a' }
+ * separator = '/'
+ * => result = { ' a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { ' a' }
+ * second = null
+ * separator = '/'
+ * => result = { ' a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { ' a' }
+ * second = { ' b' }
+ * separator = '/'
+ * => result = { ' a' , '/', 'b' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array to concatenate
+ * @param second the second array to concatenate
+ * @param separator the character to insert
+ * @return the concatenation of the two arrays inserting the separator character
+ * between the two arrays , or null if the two arrays are null.
+ */
+ public static final char[] concat(
+ char[] first,
+ char[] second,
+ char separator) {
+ if (first == null)
+ return second;
+ if (second == null)
+ return first;
+
+ int length1 = first.length;
+ if (length1 == 0)
+ return second;
+ int length2 = second.length;
+ if (length2 == 0)
+ return first;
+
+ char[] result = new char[length1 + length2 + 1];
+ System.arraycopy(first, 0, result, 0, length1);
+ result[length1] = separator;
+ System.arraycopy(second, 0, result, length1 + 1, length2);
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the three arrays inserting the sep1 character between the
+ * two arrays and sep2 between the last two.
+ * It answers null if the three arrays are null.
+ * If the first array is null, then it answers the concatenation of second and third inserting
+ * the sep2 character between them.
+ * If the second array is null, then the first array is returned.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = { 'a' }
+ * separator = '/'
+ * => result = { ' a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { ' a' }
+ * second = null
+ * separator = '/'
+ * => result = { ' a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { ' a' }
+ * second = { ' b' }
+ * separator = '/'
+ * => result = { ' a' , '/', 'b' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array to concatenate
+ * @param second the second array to concatenate
+ * @param separator the character to insert
+ * @return the concatenation of the two arrays inserting the separator character
+ * between the two arrays , or null if the two arrays are null.
+ */
+ public static final char[] concat(
+ char[] first,
+ char sep1,
+ char[] second,
+ char sep2,
+ char[] third) {
+ if (first == null)
+ return concat(second, third, sep2);
+ if (second == null)
+ return concat(first, third, sep1);
+ if (third == null)
+ return concat(first, second, sep1);
+
+ int length1 = first.length;
+ int length2 = second.length;
+ int length3 = third.length;
+ char[] result = new char[length1 + length2 + length3 + 2];
+ System.arraycopy(first, 0, result, 0, length1);
+ result[length1] = sep1;
+ System.arraycopy(second, 0, result, length1 + 1, length2);
+ result[length1 + length2 + 1] = sep2;
+ System.arraycopy(third, 0, result, length1 + length2 + 2, length3);
+ return result;
+ }
+
+ /**
+ * Answers a new array with prepending the prefix character and appending the suffix
+ * character at the end of the array. If array is null, it answers a new array containing the
+ * prefix and the suffix characters.
+ * <br>
+ * <br>
+ * For example:<br>
+ * <ol>
+ * <li><pre>
+ * prefix = 'a'
+ * array = { 'b' }
+ * suffix = 'c'
+ * => result = { 'a', 'b' , 'c' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * prefix = 'a'
+ * array = null
+ * suffix = 'c'
+ * => result = { 'a', 'c' }
+ * </pre></li>
+ * </ol>
+ *
+ * @param prefix the prefix character
+ * @param array the array that is concanated with the prefix and suffix characters
+ * @param suffix the suffix character
+ * @return the new array
+ */
+ public static final char[] concat(char prefix, char[] array, char suffix) {
+ if (array == null)
+ return new char[] { prefix, suffix };
+
+ int length = array.length;
+ char[] result = new char[length + 2];
+ result[0] = prefix;
+ System.arraycopy(array, 0, result, 1, length);
+ result[length + 1] = suffix;
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the given array parts using the given separator between each
+ * part and appending the given name at the end.
+ * <br>
+ * <br>
+ * For example:<br>
+ * <ol>
+ * <li><pre>
+ * name = { 'c' }
+ * array = { { 'a' }, { 'b' } }
+ * separator = '.'
+ * => result = { 'a', '.', 'b' , '.', 'c' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * name = null
+ * array = { { 'a' }, { 'b' } }
+ * separator = '.'
+ * => result = { 'a', '.', 'b' }
+ * </pre></li>
+ * <li><pre>
+ * name = { ' c' }
+ * array = null
+ * separator = '.'
+ * => result = { 'c' }
+ * </pre></li>
+ * </ol>
+ *
+ * @param name the given name
+ * @param array the given array
+ * @param separator the given separator
+ * @return the concatenation of the given array parts using the given separator between each
+ * part and appending the given name at the end
+ */
+ public static final char[] concatWith(
+ char[] name,
+ char[][] array,
+ char separator) {
+ int nameLength = name == null ? 0 : name.length;
+ if (nameLength == 0)
+ return concatWith(array, separator);
+
+ int length = array == null ? 0 : array.length;
+ if (length == 0)
+ return name;
+
+ int size = nameLength;
+ int index = length;
+ while (--index >= 0)
+ if (array[index].length > 0)
+ size += array[index].length + 1;
+ char[] result = new char[size];
+ index = size;
+ for (int i = length - 1; i >= 0; i--) {
+ int subLength = array[i].length;
+ if (subLength > 0) {
+ index -= subLength;
+ System.arraycopy(array[i], 0, result, index, subLength);
+ result[--index] = separator;
+ }
+ }
+ System.arraycopy(name, 0, result, 0, nameLength);
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the given array parts using the given separator between each
+ * part and appending the given name at the end.
+ * <br>
+ * <br>
+ * For example:<br>
+ * <ol>
+ * <li><pre>
+ * name = { 'c' }
+ * array = { { 'a' }, { 'b' } }
+ * separator = '.'
+ * => result = { 'a', '.', 'b' , '.', 'c' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * name = null
+ * array = { { 'a' }, { 'b' } }
+ * separator = '.'
+ * => result = { 'a', '.', 'b' }
+ * </pre></li>
+ * <li><pre>
+ * name = { ' c' }
+ * array = null
+ * separator = '.'
+ * => result = { 'c' }
+ * </pre></li>
+ * </ol>
+ *
+ * @param array the given array
+ * @param name the given name
+ * @param separator the given separator
+ * @return the concatenation of the given array parts using the given separator between each
+ * part and appending the given name at the end
+ */
+ public static final char[] concatWith(
+ char[][] array,
+ char[] name,
+ char separator) {
+ int nameLength = name == null ? 0 : name.length;
+ if (nameLength == 0)
+ return concatWith(array, separator);
+
+ int length = array == null ? 0 : array.length;
+ if (length == 0)
+ return name;
+
+ int size = nameLength;
+ int index = length;
+ while (--index >= 0)
+ if (array[index].length > 0)
+ size += array[index].length + 1;
+ char[] result = new char[size];
+ index = 0;
+ for (int i = 0; i < length; i++) {
+ int subLength = array[i].length;
+ if (subLength > 0) {
+ System.arraycopy(array[i], 0, result, index, subLength);
+ index += subLength;
+ result[index++] = separator;
+ }
+ }
+ System.arraycopy(name, 0, result, index, nameLength);
+ return result;
+ }
+
+ /**
+ * Answers the concatenation of the given array parts using the given separator between each part.
+ * <br>
+ * <br>
+ * For example:<br>
+ * <ol>
+ * <li><pre>
+ * array = { { 'a' }, { 'b' } }
+ * separator = '.'
+ * => result = { 'a', '.', 'b' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = null
+ * separator = '.'
+ * => result = { }
+ * </pre></li>
+ * </ol>
+ *
+ * @param array the given array
+ * @param separator the given separator
+ * @return the concatenation of the given array parts using the given separator between each part
+ */
+ public static final char[] concatWith(char[][] array, char separator) {
+ int length = array == null ? 0 : array.length;
+ if (length == 0)
+ return CharOperation.NO_CHAR;
+
+ int size = length - 1;
+ int index = length;
+ while (--index >= 0) {
+ if (array[index].length == 0)
+ size--;
+ else
+ size += array[index].length;
+ }
+ if (size <= 0)
+ return CharOperation.NO_CHAR;
+ char[] result = new char[size];
+ index = length;
+ while (--index >= 0) {
+ length = array[index].length;
+ if (length > 0) {
+ System.arraycopy(
+ array[index],
+ 0,
+ result,
+ (size -= length),
+ length);
+ if (--size >= 0)
+ result[size] = separator;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Answers true if the array contains an occurrence of character, false otherwise.
+ *
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * character = 'c'
+ * array = { { ' a' }, { ' b' } }
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * character = 'a'
+ * array = { { ' a' }, { ' b' } }
+ * result => true
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param character the character to search
+ * @param array the array in which the search is done
+ * @exception NullPointerException if array is null.
+ *
+ * @return true if the array contains an occurrence of character, false otherwise.
+ */
+ public static final boolean contains(char character, char[][] array) {
+ for (int i = array.length; --i >= 0;) {
+ char[] subarray = array[i];
+ for (int j = subarray.length; --j >= 0;)
+ if (subarray[j] == character)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Answers true if the array contains an occurrence of character, false otherwise.
+ *
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * character = 'c'
+ * array = { ' b' }
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * character = 'a'
+ * array = { ' a' , ' b' }
+ * result => true
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param character the character to search
+ * @param array the array in which the search is done
+ * @exception NullPointerException if array is null.
+ *
+ * @return true if the array contains an occurrence of character, false otherwise.
+ */
+ public static final boolean contains(char character, char[] array) {
+ for (int i = array.length; --i >= 0;)
+ if (array[i] == character)
+ return true;
+ return false;
+ }
+
+ /**
+ * Answers a deep copy of the toCopy array.
+ *
+ * @param toCopy the array to copy
+ * @return a deep copy of the toCopy array.
+ */
+ public static final char[][] deepCopy(char[][] toCopy) {
+ int toCopyLength = toCopy.length;
+ char[][] result = new char[toCopyLength][];
+ for (int i = 0; i < toCopyLength; i++) {
+ char[] toElement = toCopy[i];
+ int toElementLength = toElement.length;
+ char[] resultElement = new char[toElementLength];
+ System.arraycopy(toElement, 0, resultElement, 0, toElementLength);
+ result[i] = resultElement;
+ }
+ return result;
+ }
+
+ /**
+ * Return true if array ends with the sequence of characters contained in toBeFound,
+ * otherwise false.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * array = { 'a', 'b', 'c', 'd' }
+ * toBeFound = { 'b', 'c' }
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'a', 'b', 'c' }
+ * toBeFound = { 'b', 'c' }
+ * result => true
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param array the array to check
+ * @param toBeFound the array to find
+ * @exception NullPointerException if array is null or toBeFound is null
+ * @return true if array ends with the sequence of characters contained in toBeFound,
+ * otherwise false.
+ */
+ public static final boolean endsWith(char[] array, char[] toBeFound) {
+ int i = toBeFound.length;
+ int j = array.length - i;
+
+ if (j < 0)
+ return false;
+ while (--i >= 0)
+ if (toBeFound[i] != array[i + j])
+ return false;
+ return true;
+ }
+
+ /**
+ * Answers true if the two arrays are identical character by character, otherwise false.
+ * The equality is case sensitive.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = null
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { } }
+ * second = null
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { 'a' } }
+ * second = { { 'a' } }
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { 'A' } }
+ * second = { { 'a' } }
+ * result => false
+ * </pre>
+ * </li>
+ * </ol>
+ * @param first the first array
+ * @param second the second array
+ * @return true if the two arrays are identical character by character, otherwise false
+ */
+ public static final boolean equals(char[][] first, char[][] second) {
+ if (first == second)
+ return true;
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
+
+ for (int i = first.length; --i >= 0;)
+ if (!equals(first[i], second[i]))
+ return false;
+ return true;
+ }
+
+ /**
+ * If isCaseSensite is true, answers true if the two arrays are identical character
+ * by character, otherwise false.
+ * If it is false, answers true if the two arrays are identical character by
+ * character without checking the case, otherwise false.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = null
+ * isCaseSensitive = true
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { } }
+ * second = null
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { 'A' } }
+ * second = { { 'a' } }
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { { 'A' } }
+ * second = { { 'a' } }
+ * isCaseSensitive = false
+ * result => true
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array
+ * @param second the second array
+ * @param isCaseSensitive check whether or not the equality should be case sensitive
+ * @return true if the two arrays are identical character by character according to the value
+ * of isCaseSensitive, otherwise false
+ */
+ public static final boolean equals(
+ char[][] first,
+ char[][] second,
+ boolean isCaseSensitive) {
+
+ if (isCaseSensitive) {
+ return equals(first, second);
+ }
+ if (first == second)
+ return true;
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
+
+ for (int i = first.length; --i >= 0;)
+ if (!equals(first[i], second[i], false))
+ return false;
+ return true;
+ }
+
+ /**
+ * Answers true if the two arrays are identical character by character, otherwise false.
+ * The equality is case sensitive.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = null
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { }
+ * second = null
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { 'a' }
+ * second = { 'a' }
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { 'a' }
+ * second = { 'A' }
+ * result => false
+ * </pre>
+ * </li>
+ * </ol>
+ * @param first the first array
+ * @param second the second array
+ * @return true if the two arrays are identical character by character, otherwise false
+ */
+ public static final boolean equals(char[] first, char[] second) {
+ if (first == second)
+ return true;
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
+
+ for (int i = first.length; --i >= 0;)
+ if (first[i] != second[i])
+ return false;
+ return true;
+ }
+
+ /**
+ * If isCaseSensite is true, answers true if the two arrays are identical character
+ * by character, otherwise false.
+ * If it is false, answers true if the two arrays are identical character by
+ * character without checking the case, otherwise false.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * first = null
+ * second = null
+ * isCaseSensitive = true
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { }
+ * second = null
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { 'A' }
+ * second = { 'a' }
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * first = { 'A' }
+ * second = { 'a' }
+ * isCaseSensitive = false
+ * result => true
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param first the first array
+ * @param second the second array
+ * @param isCaseSensitive check whether or not the equality should be case sensitive
+ * @return true if the two arrays are identical character by character according to the value
+ * of isCaseSensitive, otherwise false
+ */
+ public static final boolean equals(
+ char[] first,
+ char[] second,
+ boolean isCaseSensitive) {
+
+ if (isCaseSensitive) {
+ return equals(first, second);
+ }
+ if (first == second)
+ return true;
+ if (first == null || second == null)
+ return false;
+ if (first.length != second.length)
+ return false;
+
+ for (int i = first.length; --i >= 0;)
+ if (Character.toLowerCase(first[i])
+ != Character.toLowerCase(second[i]))
+ return false;
+ return true;
+ }
+ /**
+ * If isCaseSensite is true, the equality is case sensitive, otherwise it is case insensitive.
+ *
+ * Answers true if the name contains the fragment at the starting index startIndex, otherwise false.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * fragment = { 'b', 'c' , 'd' }
+ * name = { 'a', 'b', 'c' , 'd' }
+ * startIndex = 1
+ * isCaseSensitive = true
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * fragment = { 'b', 'c' , 'd' }
+ * name = { 'a', 'b', 'C' , 'd' }
+ * startIndex = 1
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * fragment = { 'b', 'c' , 'd' }
+ * name = { 'a', 'b', 'C' , 'd' }
+ * startIndex = 0
+ * isCaseSensitive = false
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * fragment = { 'b', 'c' , 'd' }
+ * name = { 'a', 'b'}
+ * startIndex = 0
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param fragment the fragment to check
+ * @param second the array to check
+ * @param startIndex the starting index
+ * @param isCaseSensitive check whether or not the equality should be case sensitive
+ * @return true if the name contains the fragment at the starting index startIndex according to the
+ * value of isCaseSensitive, otherwise false.
+ * @exception NullPointerException if fragment or name is null.
+ */
+ public static final boolean fragmentEquals(
+ char[] fragment,
+ char[] name,
+ int startIndex,
+ boolean isCaseSensitive) {
+
+ int max = fragment.length;
+ if (name.length < max + startIndex)
+ return false;
+ if (isCaseSensitive) {
+ for (int i = max;
+ --i >= 0;
+ ) // assumes the prefix is not larger than the name
+ if (fragment[i] != name[i + startIndex])
+ return false;
+ return true;
+ }
+ for (int i = max;
+ --i >= 0;
+ ) // assumes the prefix is not larger than the name
+ if (Character.toLowerCase(fragment[i])
+ != Character.toLowerCase(name[i + startIndex]))
+ return false;
+ return true;
+ }
+
+ /**
+ * Answers a hashcode for the array
+ *
+ * @param array the array for which a hashcode is required
+ * @return the hashcode
+ * @exception NullPointerException if array is null
+ */
+ public static final int hashCode(char[] array) {
+ int hash = 0;
+ int offset = 0;
+ int length = array.length;
+ if (length < 16) {
+ for (int i = length; i > 0; i--)
+ hash = (hash * 37) + array[offset++];
+ } else {
+ // only sample some characters
+ int skip = length / 8;
+ for (int i = length; i > 0; i -= skip, offset += skip)
+ hash = (hash * 39) + array[offset];
+ }
+ return hash & 0x7FFFFFFF;
+ }
+ /**
+ * Answers true if c is a whitespace according to the JLS (\u000a, \u000c, \u000d, \u0009), otherwise false.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * c = ' '
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * c = '\u3000'
+ * result => false
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param c the character to check
+ * @return true if c is a whitespace according to the JLS, otherwise false.
+ */
+ public static boolean isWhitespace(char c) {
+ switch (c) {
+ case 10 : /* \ u000a: LINE FEED */
+ case 12 : /* \ u000c: FORM FEED */
+ case 13 : /* \ u000d: CARRIAGE RETURN */
+ case 32 : /* \ u0020: SPACE */
+ case 9 : /* \ u0009: HORIZONTAL TABULATION */
+ return true;
+ default :
+ return false;
+ }
+ }
+
+ /**
+ * Answers the first index in the array for which the corresponding character is
+ * equal to toBeFound. Answers -1 if no occurrence of this character is found.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * toBeFound = 'c'
+ * array = { ' a', 'b', 'c', 'd' }
+ * result => 2
+ * </pre>
+ * </li>
+ * <li><pre>
+ * toBeFound = 'e'
+ * array = { ' a', 'b', 'c', 'd' }
+ * result => -1
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param toBeFound the character to search
+ * @param array the array to be searched
+ * @return the first index in the array for which the corresponding character is
+ * equal to toBeFound, -1 otherwise
+ * @exception NullPointerException if array is null
+ */
+ public static final int indexOf(char toBeFound, char[] array) {
+ for (int i = 0; i < array.length; i++)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+ }
+
+ /**
+ * Answers the first index in the array for which the corresponding character is
+ * equal to toBeFound starting the search at index start.
+ * Answers -1 if no occurrence of this character is found.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * toBeFound = 'c'
+ * array = { ' a', 'b', 'c', 'd' }
+ * start = 2
+ * result => 2
+ * </pre>
+ * </li>
+ * <li><pre>
+ * toBeFound = 'c'
+ * array = { ' a', 'b', 'c', 'd' }
+ * start = 3
+ * result => -1
+ * </pre>
+ * </li>
+ * <li><pre>
+ * toBeFound = 'e'
+ * array = { ' a', 'b', 'c', 'd' }
+ * start = 1
+ * result => -1
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param toBeFound the character to search
+ * @param array the array to be searched
+ * @param start the starting index
+ * @return the first index in the array for which the corresponding character is
+ * equal to toBeFound, -1 otherwise
+ * @exception NullPointerException if array is null
+ * @exception ArrayIndexOutOfBoundsException if start is lower than 0
+ */
+ public static final int indexOf(char toBeFound, char[] array, int start) {
+ for (int i = start; i < array.length; i++)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+ }
+
+ /**
+ * Answers the last index in the array for which the corresponding character is
+ * equal to toBeFound starting from the end of the array.
+ * Answers -1 if no occurrence of this character is found.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * toBeFound = 'c'
+ * array = { ' a', 'b', 'c', 'd' , 'c', 'e' }
+ * result => 4
+ * </pre>
+ * </li>
+ * <li><pre>
+ * toBeFound = 'e'
+ * array = { ' a', 'b', 'c', 'd' }
+ * result => -1
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param toBeFound the character to search
+ * @param array the array to be searched
+ * @return the last index in the array for which the corresponding character is
+ * equal to toBeFound starting from the end of the array, -1 otherwise
+ * @exception NullPointerException if array is null
+ */
+ public static final int lastIndexOf(char toBeFound, char[] array) {
+ for (int i = array.length; --i >= 0;)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+ }
+
+ /**
+ * Answers the last index in the array for which the corresponding character is
+ * equal to toBeFound stopping at the index startIndex.
+ * Answers -1 if no occurrence of this character is found.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * toBeFound = 'c'
+ * array = { ' a', 'b', 'c', 'd' }
+ * startIndex = 2
+ * result => 2
+ * </pre>
+ * </li>
+ * <li><pre>
+ * toBeFound = 'c'
+ * array = { ' a', 'b', 'c', 'd', 'e' }
+ * startIndex = 3
+ * result => -1
+ * </pre>
+ * </li>
+ * <li><pre>
+ * toBeFound = 'e'
+ * array = { ' a', 'b', 'c', 'd' }
+ * startIndex = 0
+ * result => -1
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param toBeFound the character to search
+ * @param array the array to be searched
+ * @param startIndex the stopping index
+ * @return the last index in the array for which the corresponding character is
+ * equal to toBeFound stopping at the index startIndex, -1 otherwise
+ * @exception NullPointerException if array is null
+ * @exception ArrayIndexOutOfBoundsException if startIndex is lower than 0
+ */
+ public static final int lastIndexOf(
+ char toBeFound,
+ char[] array,
+ int startIndex) {
+ for (int i = array.length; --i >= startIndex;)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+ }
+
+ /**
+ * Answers the last index in the array for which the corresponding character is
+ * equal to toBeFound starting from endIndex to startIndex.
+ * Answers -1 if no occurrence of this character is found.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * toBeFound = 'c'
+ * array = { ' a', 'b', 'c', 'd' }
+ * startIndex = 2
+ * endIndex = 2
+ * result => 2
+ * </pre>
+ * </li>
+ * <li><pre>
+ * toBeFound = 'c'
+ * array = { ' a', 'b', 'c', 'd', 'e' }
+ * startIndex = 3
+ * endIndex = 4
+ * result => -1
+ * </pre>
+ * </li>
+ * <li><pre>
+ * toBeFound = 'e'
+ * array = { ' a', 'b', 'c', 'd' }
+ * startIndex = 0
+ * endIndex = 3
+ * result => -1
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param toBeFound the character to search
+ * @param array the array to be searched
+ * @param startIndex the stopping index
+ * @param endIndex the starting index
+ * @return the last index in the array for which the corresponding character is
+ * equal to toBeFound starting from endIndex to startIndex, -1 otherwise
+ * @exception NullPointerException if array is null
+ * @exception ArrayIndexOutOfBoundsException if endIndex is greater or equals to array length or starting is lower than 0
+ */
+ public static final int lastIndexOf(
+ char toBeFound,
+ char[] array,
+ int startIndex,
+ int endIndex) {
+ for (int i = endIndex; --i >= startIndex;)
+ if (toBeFound == array[i])
+ return i;
+ return -1;
+ }
+
+ /**
+ * Answers the last portion of a name given a separator.
+ * <br>
+ * <br>
+ * For example,
+ * <pre>
+ * lastSegment("java.lang.Object".toCharArray(),'.') --> Object
+ * </pre>
+ *
+ * @param array the array
+ * @param separator the given separator
+ * @return the last portion of a name given a separator
+ * @exception NullPointerException if array is null
+ */
+ final static public char[] lastSegment(char[] array, char separator) {
+ int pos = lastIndexOf(separator, array);
+ if (pos < 0)
+ return array;
+ return subarray(array, pos + 1, array.length);
+ }
+
+ /**
+ * Answers true if the pattern matches the given name, false otherwise. This char[] pattern matching
+ * accepts wild-cards '*' and '?'.
+ *
+ * When not case sensitive, the pattern is assumed to already be lowercased, the
+ * name will be lowercased character per character as comparing.
+ * If name is null, the answer is false.
+ * If pattern is null, the answer is true if name is not null.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * pattern = { '?', 'b', '*' }
+ * name = { 'a', 'b', 'c' , 'd' }
+ * isCaseSensitive = true
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * pattern = { '?', 'b', '?' }
+ * name = { 'a', 'b', 'c' , 'd' }
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * <li><pre>
+ * pattern = { 'b', '*' }
+ * name = { 'a', 'b', 'c' , 'd' }
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param pattern the given pattern
+ * @param name the given name
+ * @param isCaseSensitive flag to know whether or not the matching should be case sensitive
+ * @return true if the pattern matches the given name, false otherwise
+ */
+ public static final boolean match(
+ char[] pattern,
+ char[] name,
+ boolean isCaseSensitive) {
+
+ if (name == null)
+ return false; // null name cannot match
+ if (pattern == null)
+ return true; // null pattern is equivalent to '*'
+
+ return match(
+ pattern,
+ 0,
+ pattern.length,
+ name,
+ 0,
+ name.length,
+ isCaseSensitive);
+ }
+
+ /**
+ * Answers true if the a sub-pattern matches the subpart of the given name, false otherwise.
+ * char[] pattern matching, accepting wild-cards '*' and '?'. Can match only subset of name/pattern.
+ * end positions are non-inclusive.
+ * The subpattern is defined by the patternStart and pattternEnd positions.
+ * When not case sensitive, the pattern is assumed to already be lowercased, the
+ * name will be lowercased character per character as comparing.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * pattern = { '?', 'b', '*' }
+ * patternStart = 1
+ * patternEnd = 3
+ * name = { 'a', 'b', 'c' , 'd' }
+ * nameStart = 1
+ * nameEnd = 4
+ * isCaseSensitive = true
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * pattern = { '?', 'b', '*' }
+ * patternStart = 1
+ * patternEnd = 2
+ * name = { 'a', 'b', 'c' , 'd' }
+ * nameStart = 1
+ * nameEnd = 2
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param pattern the given pattern
+ * @param patternStart the given pattern start
+ * @param patternEnd the given pattern end
+ * @param name the given name
+ * @param nameStart the given name start
+ * @param nameEnd the given name end
+ * @param isCaseSensitive flag to know if the matching should be case sensitive
+ * @return true if the a sub-pattern matches the subpart of the given name, false otherwise
+ */
+ public static final boolean match(
+ char[] pattern,
+ int patternStart,
+ int patternEnd,
+ char[] name,
+ int nameStart,
+ int nameEnd,
+ boolean isCaseSensitive) {
+
+ if (name == null)
+ return false; // null name cannot match
+ if (pattern == null)
+ return true; // null pattern is equivalent to '*'
+ int iPattern = patternStart;
+ int iName = nameStart;
+
+ if (patternEnd < 0)
+ patternEnd = pattern.length;
+ if (nameEnd < 0)
+ nameEnd = name.length;
+
+ /* check first segment */
+ char patternChar = 0;
+ while ((iPattern < patternEnd)
+ && (patternChar = pattern[iPattern]) != '*') {
+ if (iName == nameEnd)
+ return false;
+ if (patternChar
+ != (isCaseSensitive
+ ? name[iName]
+ : Character.toLowerCase(name[iName]))
+ && patternChar != '?') {
+ return false;
+ }
+ iName++;
+ iPattern++;
+ }
+ /* check sequence of star+segment */
+ int segmentStart;
+ if (patternChar == '*') {
+ segmentStart = ++iPattern; // skip star
+ } else {
+ segmentStart = 0; // force iName check
+ }
+ int prefixStart = iName;
+ checkSegment : while (iName < nameEnd) {
+ if (iPattern == patternEnd) {
+ iPattern = segmentStart; // mismatch - restart current segment
+ iName = ++prefixStart;
+ continue checkSegment;
+ }
+ /* segment is ending */
+ if ((patternChar = pattern[iPattern]) == '*') {
+ segmentStart = ++iPattern; // skip start
+ if (segmentStart == patternEnd) {
+ return true;
+ }
+ prefixStart = iName;
+ continue checkSegment;
+ }
+ /* check current name character */
+ if ((isCaseSensitive ? name[iName] : Character.toLowerCase(name[iName]))
+ != patternChar
+ && patternChar != '?') {
+ iPattern = segmentStart; // mismatch - restart current segment
+ iName = ++prefixStart;
+ continue checkSegment;
+ }
+ iName++;
+ iPattern++;
+ }
+
+ return (segmentStart == patternEnd)
+ || (iName == nameEnd && iPattern == patternEnd)
+ || (iPattern == patternEnd - 1 && pattern[iPattern] == '*');
+ }
+
+ /**
+ * Answers true if the pattern matches the filepath using the pathSepatator, false otherwise.
+ *
+ * Path char[] pattern matching, accepting wild-cards '**', '*' and '?' (using Ant directory tasks
+ * conventions, also see "http://jakarta.apache.org/ant/manual/dirtasks.html#defaultexcludes").
+ * Path pattern matching is enhancing regular pattern matching in supporting extra rule where '**' represent
+ * any folder combination.
+ * Special rules:
+ * - foo\ is equivalent to foo\**
+ * - *.java is equivalent to **\*.java
+ * When not case sensitive, the pattern is assumed to already be lowercased, the
+ * name will be lowercased character per character as comparing.
+ *
+ * @param pattern the given pattern
+ * @param filepath the given path
+ * @param isCaseSensitive to find out whether or not the matching should be case sensitive
+ * @param pathSeparator the given path separator
+ * @return true if the pattern matches the filepath using the pathSepatator, false otherwise
+ */
+ public static final boolean pathMatch(
+ char[] pattern,
+ char[] filepath,
+ boolean isCaseSensitive,
+ char pathSeparator) {
+
+ if (filepath == null)
+ return false; // null name cannot match
+ if (pattern == null)
+ return true; // null pattern is equivalent to '*'
+
+ // special case: pattern foo is equivalent to **\foo (not absolute)
+ boolean freeLeadingDoubleStar;
+
+ // offsets inside pattern
+ int pSegmentStart, pLength = pattern.length;
+
+ if (freeLeadingDoubleStar = pattern[0] != pathSeparator){
+ pSegmentStart = 0;
+ } else {
+ pSegmentStart = 1;
+ }
+ int pSegmentEnd = CharOperation.indexOf(pathSeparator, pattern, pSegmentStart+1);
+ if (pSegmentEnd < 0) pSegmentEnd = pLength;
+
+ // special case: pattern foo\ is equivalent to foo\**
+ boolean freeTrailingDoubleStar = pattern[pLength - 1] == pathSeparator;
+
+ // offsets inside filepath
+ int fSegmentStart, fLength = filepath.length;
+ if (filepath[0] != pathSeparator){
+ fSegmentStart = 0;
+ } else {
+ fSegmentStart = 1;
+ }
+ if (fSegmentStart != pSegmentStart) {
+ return false; // both must start with a separator or none.
+ }
+ int fSegmentEnd = CharOperation.indexOf(pathSeparator, filepath, fSegmentStart+1);
+ if (fSegmentEnd < 0) fSegmentEnd = fLength;
+
+ // first segments
+ while (pSegmentStart < pLength
+ && !freeLeadingDoubleStar
+ && !(pSegmentEnd == pLength && freeTrailingDoubleStar
+ || (pSegmentEnd == pSegmentStart + 2
+ && pattern[pSegmentStart] == '*'
+ && pattern[pSegmentStart + 1] == '*'))) {
+
+ if (fSegmentStart >= fLength)
+ return false;
+ if (!CharOperation
+ .match(
+ pattern,
+ pSegmentStart,
+ pSegmentEnd,
+ filepath,
+ fSegmentStart,
+ fSegmentEnd,
+ isCaseSensitive)) {
+ return false;
+ }
+
+ // jump to next segment
+ pSegmentEnd =
+ CharOperation.indexOf(
+ pathSeparator,
+ pattern,
+ pSegmentStart = pSegmentEnd + 1);
+ // skip separator
+ if (pSegmentEnd < 0)
+ pSegmentEnd = pLength;
+
+ fSegmentEnd =
+ CharOperation.indexOf(
+ pathSeparator,
+ filepath,
+ fSegmentStart = fSegmentEnd + 1);
+ // skip separator
+ if (fSegmentEnd < 0) fSegmentEnd = fLength;
+ }
+
+ /* check sequence of doubleStar+segment */
+ int pSegmentRestart;
+ if ((pSegmentStart >= pLength && freeTrailingDoubleStar)
+ || (pSegmentEnd == pSegmentStart + 2
+ && pattern[pSegmentStart] == '*'
+ && pattern[pSegmentStart + 1] == '*')) {
+ pSegmentEnd =
+ CharOperation.indexOf(
+ pathSeparator,
+ pattern,
+ pSegmentStart = pSegmentEnd + 1);
+ // skip separator
+ if (pSegmentEnd < 0) pSegmentEnd = pLength;
+ pSegmentRestart = pSegmentStart;
+ } else {
+ if (pSegmentStart >= pLength) return fSegmentStart >= fLength; // true if filepath is done too.
+ pSegmentRestart = 0; // force fSegmentStart check
+ }
+ int fSegmentRestart = fSegmentStart;
+ checkSegment : while (fSegmentStart < fLength) {
+
+ if (pSegmentStart >= pLength) {
+ if (freeTrailingDoubleStar) return true;
+ // mismatch - restart current path segment
+ pSegmentEnd =
+ CharOperation.indexOf(pathSeparator, pattern, pSegmentStart = pSegmentRestart);
+ if (pSegmentEnd < 0) pSegmentEnd = pLength;
+
+ fSegmentRestart =
+ CharOperation.indexOf(pathSeparator, filepath, fSegmentRestart + 1);
+ // skip separator
+ if (fSegmentRestart < 0) {
+ fSegmentRestart = fLength;
+ } else {
+ fSegmentRestart++;
+ }
+ fSegmentEnd =
+ CharOperation.indexOf(pathSeparator, filepath, fSegmentStart = fSegmentRestart);
+ if (fSegmentEnd < 0) fSegmentEnd = fLength;
+ continue checkSegment;
+ }
+
+ /* path segment is ending */
+ if (pSegmentEnd == pSegmentStart + 2
+ && pattern[pSegmentStart] == '*'
+ && pattern[pSegmentStart + 1] == '*') {
+ pSegmentEnd =
+ CharOperation.indexOf(pathSeparator, pattern, pSegmentStart = pSegmentEnd + 1);
+ // skip separator
+ if (pSegmentEnd < 0) pSegmentEnd = pLength;
+ pSegmentRestart = pSegmentStart;
+ fSegmentRestart = fSegmentStart;
+ if (pSegmentStart >= pLength) return true;
+ continue checkSegment;
+ }
+ /* chech current path segment */
+ if (!CharOperation.match(
+ pattern,
+ pSegmentStart,
+ pSegmentEnd,
+ filepath,
+ fSegmentStart,
+ fSegmentEnd,
+ isCaseSensitive)) {
+ // mismatch - restart current path segment
+ pSegmentEnd =
+ CharOperation.indexOf(pathSeparator, pattern, pSegmentStart = pSegmentRestart);
+ if (pSegmentEnd < 0) pSegmentEnd = pLength;
+
+ fSegmentRestart =
+ CharOperation.indexOf(pathSeparator, filepath, fSegmentRestart + 1);
+ // skip separator
+ if (fSegmentRestart < 0) {
+ fSegmentRestart = fLength;
+ } else {
+ fSegmentRestart++;
+ }
+ fSegmentEnd =
+ CharOperation.indexOf(pathSeparator, filepath, fSegmentStart = fSegmentRestart);
+ if (fSegmentEnd < 0) fSegmentEnd = fLength;
+ continue checkSegment;
+ }
+ // jump to next segment
+ pSegmentEnd =
+ CharOperation.indexOf(
+ pathSeparator,
+ pattern,
+ pSegmentStart = pSegmentEnd + 1);
+ // skip separator
+ if (pSegmentEnd < 0)
+ pSegmentEnd = pLength;
+
+ fSegmentEnd =
+ CharOperation.indexOf(
+ pathSeparator,
+ filepath,
+ fSegmentStart = fSegmentEnd + 1);
+ // skip separator
+ if (fSegmentEnd < 0)
+ fSegmentEnd = fLength;
+ }
+
+ return (pSegmentRestart >= pSegmentEnd)
+ || (fSegmentStart >= fLength && pSegmentStart >= pLength)
+ || (pSegmentStart == pLength - 2
+ && pattern[pSegmentStart] == '*'
+ && pattern[pSegmentStart + 1] == '*')
+ || (pSegmentStart == pLength && freeTrailingDoubleStar);
+ }
+
+ /**
+ * Answers the number of occurrences of the given character in the given array, 0 if any.
+ *
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * toBeFound = 'b'
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * result => 3
+ * </pre>
+ * </li>
+ * <li><pre>
+ * toBeFound = 'c'
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * result => 0
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param toBeFound the given character
+ * @param array the given array
+ * @return the number of occurrences of the given character in the given array, 0 if any
+ * @exception NullPointerException if array is null
+ */
+ public static final int occurencesOf(char toBeFound, char[] array) {
+ int count = 0;
+ for (int i = 0; i < array.length; i++)
+ if (toBeFound == array[i])
+ count++;
+ return count;
+ }
+
+ /**
+ * Answers the number of occurrences of the given character in the given array starting
+ * at the given index, 0 if any.
+ *
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * toBeFound = 'b'
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * start = 2
+ * result => 2
+ * </pre>
+ * </li>
+ * <li><pre>
+ * toBeFound = 'c'
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * start = 0
+ * result => 0
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param toBeFound the given character
+ * @param array the given array
+ * @return the number of occurrences of the given character in the given array, 0 if any
+ * @exception NullPointerException if array is null
+ * @exception ArrayIndexOutOfBoundsException if start is lower than 0
+ */
+ public static final int occurencesOf(
+ char toBeFound,
+ char[] array,
+ int start) {
+ int count = 0;
+ for (int i = start; i < array.length; i++)
+ if (toBeFound == array[i])
+ count++;
+ return count;
+ }
+
+ /**
+ * Answers true if the given name starts with the given prefix, false otherwise.
+ * The comparison is case sensitive.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * prefix = { 'a' , 'b' }
+ * name = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * prefix = { 'a' , 'c' }
+ * name = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * result => false
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param prefix the given prefix
+ * @param name the given name
+ * @return true if the given name starts with the given prefix, false otherwise
+ * @exception NullPointerException if the given name is null or if the given prefix is null
+ */
+ public static final boolean prefixEquals(char[] prefix, char[] name) {
+
+ int max = prefix.length;
+ if (name.length < max)
+ return false;
+ for (int i = max;
+ --i >= 0;
+ ) // assumes the prefix is not larger than the name
+ if (prefix[i] != name[i])
+ return false;
+ return true;
+ }
+
+ /**
+ * Answers true if the given name starts with the given prefix, false otherwise.
+ * isCaseSensitive is used to find out whether or not the comparison should be case sensitive.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * prefix = { 'a' , 'B' }
+ * name = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * isCaseSensitive = false
+ * result => true
+ * </pre>
+ * </li>
+ * <li><pre>
+ * prefix = { 'a' , 'B' }
+ * name = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * isCaseSensitive = true
+ * result => false
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param prefix the given prefix
+ * @param name the given name
+ * @param isCaseSensitive to find out whether or not the comparison should be case sensitive
+ * @return true if the given name starts with the given prefix, false otherwise
+ * @exception NullPointerException if the given name is null or if the given prefix is null
+ */
+ public static final boolean prefixEquals(
+ char[] prefix,
+ char[] name,
+ boolean isCaseSensitive) {
+
+ int max = prefix.length;
+ if (name.length < max)
+ return false;
+ if (isCaseSensitive) {
+ for (int i = max;
+ --i >= 0;
+ ) // assumes the prefix is not larger than the name
+ if (prefix[i] != name[i])
+ return false;
+ return true;
+ }
+
+ for (int i = max;
+ --i >= 0;
+ ) // assumes the prefix is not larger than the name
+ if (Character.toLowerCase(prefix[i])
+ != Character.toLowerCase(name[i]))
+ return false;
+ return true;
+ }
+
+ /**
+ * Replace all occurrence of the character to be replaced with the remplacement character in the
+ * given array.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * toBeReplaced = 'b'
+ * replacementChar = 'a'
+ * result => No returned value, but array is now equals to { 'a' , 'a', 'a', 'a', 'a', 'a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * toBeReplaced = 'c'
+ * replacementChar = 'a'
+ * result => No returned value, but array is now equals to { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param array the given array
+ * @param toBeReplaced the character to be replaced
+ * @param replacementChar the replacement character
+ * @exception NullPointerException if the given array is null
+ */
+ public static final void replace(
+ char[] array,
+ char toBeReplaced,
+ char replacementChar) {
+ if (toBeReplaced != replacementChar) {
+ for (int i = 0, max = array.length; i < max; i++) {
+ if (array[i] == toBeReplaced)
+ array[i] = replacementChar;
+ }
+ }
+ }
+
+ /**
+ * Answers a new array of characters with substitutions. No side-effect is operated on the original
+ * array, in case no substitution happened, then the result is the same as the
+ * original one.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * toBeReplaced = { 'b' }
+ * replacementChar = { 'a', 'a' }
+ * result => { 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * toBeReplaced = { 'c' }
+ * replacementChar = { 'a' }
+ * result => { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param the given array
+ * @param toBeReplaced characters to be replaced
+ * @param the replacement characters
+ * @return a new array of characters with substitutions or the given array if none
+ * @exception NullPointerException if the given array is null
+ */
+ public static final char[] replace(
+ char[] array,
+ char[] toBeReplaced,
+ char[] replacementChars) {
+
+ int max = array.length;
+ int replacedLength = toBeReplaced.length;
+ int replacementLength = replacementChars.length;
+
+ int[] starts = new int[5];
+ int occurrenceCount = 0;
+
+ if (!equals(toBeReplaced, replacementChars)) {
+
+ next : for (int i = 0; i < max; i++) {
+ int j = 0;
+ while (j < replacedLength) {
+ if (i + j == max)
+ continue next;
+ if (array[i + j] != toBeReplaced[j++])
+ continue next;
+ }
+ if (occurrenceCount == starts.length) {
+ System.arraycopy(
+ starts,
+ 0,
+ starts = new int[occurrenceCount * 2],
+ 0,
+ occurrenceCount);
+ }
+ starts[occurrenceCount++] = i;
+ }
+ }
+ if (occurrenceCount == 0)
+ return array;
+ char[] result =
+ new char[max
+ + occurrenceCount * (replacementLength - replacedLength)];
+ int inStart = 0, outStart = 0;
+ for (int i = 0; i < occurrenceCount; i++) {
+ int offset = starts[i] - inStart;
+ System.arraycopy(array, inStart, result, outStart, offset);
+ inStart += offset;
+ outStart += offset;
+ System.arraycopy(
+ replacementChars,
+ 0,
+ result,
+ outStart,
+ replacementLength);
+ inStart += replacedLength;
+ outStart += replacementLength;
+ }
+ System.arraycopy(array, inStart, result, outStart, max - inStart);
+ return result;
+ }
+
+ /**
+ * Return a new array which is the split of the given array using the given divider and triming each subarray to remove
+ * whitespaces equals to ' '.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * divider = 'b'
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * result => { { 'a' }, { }, { 'a' }, { 'a' } }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * divider = 'c'
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * result => { { 'a', 'b', 'b', 'a', 'b', 'a' } }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * divider = 'b'
+ * array = { 'a' , ' ', 'b', 'b', 'a', 'b', 'a' }
+ * result => { { 'a' }, { }, { 'a' }, { 'a' } }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * divider = 'c'
+ * array = { ' ', ' ', 'a' , 'b', 'b', 'a', 'b', 'a', ' ' }
+ * result => { { 'a', 'b', 'b', 'a', 'b', 'a' } }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param divider the given divider
+ * @param array the given array
+ * @return a new array which is the split of the given array using the given divider and triming each subarray to remove
+ * whitespaces equals to ' '
+ */
+ public static final char[][] splitAndTrimOn(char divider, char[] array) {
+ int length = array == null ? 0 : array.length;
+ if (length == 0)
+ return NO_CHAR_CHAR;
+
+ int wordCount = 1;
+ for (int i = 0; i < length; i++)
+ if (array[i] == divider)
+ wordCount++;
+ char[][] split = new char[wordCount][];
+ int last = 0, currentWord = 0;
+ for (int i = 0; i < length; i++) {
+ if (array[i] == divider) {
+ int start = last, end = i - 1;
+ while (start < i && array[start] == ' ')
+ start++;
+ while (end > start && array[end] == ' ')
+ end--;
+ split[currentWord] = new char[end - start + 1];
+ System.arraycopy(
+ array,
+ start,
+ split[currentWord++],
+ 0,
+ end - start + 1);
+ last = i + 1;
+ }
+ }
+ int start = last, end = length - 1;
+ while (start < length && array[start] == ' ')
+ start++;
+ while (end > start && array[end] == ' ')
+ end--;
+ split[currentWord] = new char[end - start + 1];
+ System.arraycopy(
+ array,
+ start,
+ split[currentWord++],
+ 0,
+ end - start + 1);
+ return split;
+ }
+
+ /**
+ * Return a new array which is the split of the given array using the given divider.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * divider = 'b'
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * result => { { 'a' }, { }, { 'a' }, { 'a' } }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * divider = 'c'
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * result => { { 'a', 'b', 'b', 'a', 'b', 'a' } }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * divider = 'c'
+ * array = { ' ', ' ', 'a' , 'b', 'b', 'a', 'b', 'a', ' ' }
+ * result => { { ' ', 'a', 'b', 'b', 'a', 'b', 'a', ' ' } }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param divider the given divider
+ * @param array the given array
+ * @return a new array which is the split of the given array using the given divider
+ */
+ public static final char[][] splitOn(char divider, char[] array) {
+ int length = array == null ? 0 : array.length;
+ if (length == 0)
+ return NO_CHAR_CHAR;
+
+ int wordCount = 1;
+ for (int i = 0; i < length; i++)
+ if (array[i] == divider)
+ wordCount++;
+ char[][] split = new char[wordCount][];
+ int last = 0, currentWord = 0;
+ for (int i = 0; i < length; i++) {
+ if (array[i] == divider) {
+ split[currentWord] = new char[i - last];
+ System.arraycopy(
+ array,
+ last,
+ split[currentWord++],
+ 0,
+ i - last);
+ last = i + 1;
+ }
+ }
+ split[currentWord] = new char[length - last];
+ System.arraycopy(array, last, split[currentWord], 0, length - last);
+ return split;
+ }
+
+ /**
+ * Return a new array which is the split of the given array using the given divider. The given end
+ * is exclusive and the given start is inclusive.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * divider = 'b'
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' }
+ * start = 2
+ * end = 5
+ * result => { { }, { }, { 'a' } }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param divider the given divider
+ * @param array the given array
+ * @param start the given starting index
+ * @param end the given ending index
+ * @return a new array which is the split of the given array using the given divider
+ * @exception ArrayIndexOutOfBoundsException if start is lower than 0 or end is greater than the array length
+ */
+ public static final char[][] splitOn(
+ char divider,
+ char[] array,
+ int start,
+ int end) {
+ int length = array == null ? 0 : array.length;
+ if (length == 0 || start > end)
+ return NO_CHAR_CHAR;
+
+ int wordCount = 1;
+ for (int i = start; i < end; i++)
+ if (array[i] == divider)
+ wordCount++;
+ char[][] split = new char[wordCount][];
+ int last = start, currentWord = 0;
+ for (int i = start; i < end; i++) {
+ if (array[i] == divider) {
+ split[currentWord] = new char[i - last];
+ System.arraycopy(
+ array,
+ last,
+ split[currentWord++],
+ 0,
+ i - last);
+ last = i + 1;
+ }
+ }
+ split[currentWord] = new char[end - last];
+ System.arraycopy(array, last, split[currentWord], 0, end - last);
+ return split;
+ }
+
+ /**
+ * Answers a new array which is a copy of the given array starting at the given start and
+ * ending at the given end. The given start is inclusive and the given end is exclusive.
+ * Answers null if start is greater than end, if start is lower than 0 or if end is greater
+ * than the length of the given array. If end equals -1, it is converted to the array length.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * array = { { 'a' } , { 'b' } }
+ * start = 0
+ * end = 1
+ * result => { { 'a' } }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { { 'a' } , { 'b' } }
+ * start = 0
+ * end = -1
+ * result => { { 'a' }, { 'b' } }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param array the given array
+ * @param start the given starting index
+ * @param end the given ending index
+ * @return a new array which is a copy of the given array starting at the given start and
+ * ending at the given end
+ * @exception NullPointerException if the given array is null
+ */
+ public static final char[][] subarray(char[][] array, int start, int end) {
+ if (end == -1)
+ end = array.length;
+ if (start > end)
+ return null;
+ if (start < 0)
+ return null;
+ if (end > array.length)
+ return null;
+
+ char[][] result = new char[end - start][];
+ System.arraycopy(array, start, result, 0, end - start);
+ return result;
+ }
+
+ /**
+ * Answers a new array which is a copy of the given array starting at the given start and
+ * ending at the given end. The given start is inclusive and the given end is exclusive.
+ * Answers null if start is greater than end, if start is lower than 0 or if end is greater
+ * than the length of the given array. If end equals -1, it is converted to the array length.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * array = { 'a' , 'b' }
+ * start = 0
+ * end = 1
+ * result => { 'a' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'a', 'b' }
+ * start = 0
+ * end = -1
+ * result => { 'a' , 'b' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param array the given array
+ * @param start the given starting index
+ * @param end the given ending index
+ * @return a new array which is a copy of the given array starting at the given start and
+ * ending at the given end
+ * @exception NullPointerException if the given array is null
+ */
+ public static final char[] subarray(char[] array, int start, int end) {
+ if (end == -1)
+ end = array.length;
+ if (start > end)
+ return null;
+ if (start < 0)
+ return null;
+ if (end > array.length)
+ return null;
+
+ char[] result = new char[end - start];
+ System.arraycopy(array, start, result, 0, end - start);
+ return result;
+ }
+ /**
+ * Answers the result of a char[] conversion to lowercase. Answers null if the given chars array is null.
+ * <br>
+ * NOTE: If no conversion was necessary, then answers back the argument one.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * chars = { 'a' , 'b' }
+ * result => { 'a' , 'b' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'A', 'b' }
+ * result => { 'a' , 'b' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param chars the chars to convert
+ * @return the result of a char[] conversion to lowercase
+ */
+ final static public char[] toLowerCase(char[] chars) {
+ if (chars == null)
+ return null;
+ int length = chars.length;
+ char[] lowerChars = null;
+ for (int i = 0; i < length; i++) {
+ char c = chars[i];
+ char lc = Character.toLowerCase(c);
+ if ((c != lc) || (lowerChars != null)) {
+ if (lowerChars == null) {
+ System.arraycopy(
+ chars,
+ 0,
+ lowerChars = new char[length],
+ 0,
+ i);
+ }
+ lowerChars[i] = lc;
+ }
+ }
+ return lowerChars == null ? chars : lowerChars;
+ }
+
+ /**
+ * Answers a new array removing leading and trailing spaces (' '). Answers the given array if there is no
+ * space characters to remove.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * chars = { ' ', 'a' , 'b', ' ', ' ' }
+ * result => { 'a' , 'b' }
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { 'A', 'b' }
+ * result => { 'A' , 'b' }
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param chars the given array
+ * @return a new array removing leading and trailing spaces (' ')
+ */
+ final static public char[] trim(char[] chars) {
+
+ if (chars == null)
+ return null;
+
+ int start = 0, length = chars.length, end = length - 1;
+ while (start < length && chars[start] == ' ') {
+ start++;
+ }
+ while (end > start && chars[end] == ' ') {
+ end--;
+ }
+ if (start != 0 || end != length - 1) {
+ return subarray(chars, start, end + 1);
+ }
+ return chars;
+ }
+
+ /**
+ * Answers a string which is the concatenation of the given array using the '.' as a separator.
+ * <br>
+ * <br>
+ * For example:
+ * <ol>
+ * <li><pre>
+ * array = { { 'a' } , { 'b' } }
+ * result => "a.b"
+ * </pre>
+ * </li>
+ * <li><pre>
+ * array = { { ' ', 'a' } , { 'b' } }
+ * result => " a.b"
+ * </pre>
+ * </li>
+ * </ol>
+ *
+ * @param chars the given array
+ * @return a string which is the concatenation of the given array using the '.' as a separator
+ */
+ final static public String toString(char[][] array) {
+ char[] result = concatWith(array, '.');
+ return new String(result);
+ }
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
index 6820c2a..8fb308e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
@@ -1,14 +1,37 @@
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v0.5
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v05.html
-
-Contributors:
- IBM Corporation - initial API and implementation
-**********************************************************************/
-
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * IBM Corporation - added the following constants
+ * NonStaticAccessToStaticField
+ * NonStaticAccessToStaticMethod
+ * Task
+ * ExpressionShouldBeAVariable
+ * AssignmentHasNoEffect
+ * IBM Corporation - added the following constants
+ * TooManySyntheticArgumentSlots
+ * TooManyArrayDimensions
+ * TooManyBytesForStringConstant
+ * TooManyMethods
+ * TooManyFields
+ * NonBlankFinalLocalAssignment
+ * ObjectCannotHaveSuperTypes
+ * MissingSemiColon
+ * InvalidParenthesizedExpression
+ * EnclosingInstanceInConstructorCall
+ * BytecodeExceeds64KLimitForConstructor
+ * IncompatibleReturnTypeForNonInheritedInterfaceMethod
+ * UnusedPrivateMethod
+ * UnusedPrivateConstructor
+ * UnusedPrivateType
+ * UnusedPrivateField
+ * IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod
+ *******************************************************************************/
package org.eclipse.jdt.core.compiler;
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
@@ -162,7 +185,9 @@
int AmbiguousType = TypeRelated + 4;
int UsingDeprecatedType = TypeRelated + 5;
int InternalTypeNameProvided = TypeRelated + 6;
-
+ /** @since 2.1 */
+ int UnusedPrivateType = Internal + TypeRelated + 7;
+
int IncompatibleTypesInEqualityOperator = TypeRelated + 15;
int IncompatibleTypesInConditionalOperator = TypeRelated + 16;
int TypeMismatch = TypeRelated + 17;
@@ -178,6 +203,8 @@
int OuterLocalMustBeFinal = Internal + 25;
int CannotDefineInterfaceInLocalType = Internal + 26;
int IllegalPrimitiveOrArrayTypeForEnclosingInstance = TypeRelated + 27;
+ /** @since 2.1 */
+ int EnclosingInstanceInConstructorCall = Internal + 28;
int AnonymousClassCannotExtendFinalClass = TypeRelated + 29;
// variables
@@ -189,8 +216,10 @@
// local variables
int RedefinedLocal = Internal + 55;
int RedefinedArgument = Internal + 56;
- int DuplicateFinalLocalInitialization = Internal + 57;
// final local variables
+ int DuplicateFinalLocalInitialization = Internal + 57;
+ /** @since 2.1 */
+ int NonBlankFinalLocalAssignment = Internal + 58;
int FinalOuterLocalAssignment = Internal + 60;
int LocalVariableIsNeverUsed = Internal + 61;
int ArgumentIsNeverUsed = Internal + 62;
@@ -198,6 +227,12 @@
int BytecodeExceeds64KLimitForClinit = Internal + 64;
int TooManyArgumentSlots = Internal + 65;
int TooManyLocalVariableSlots = Internal + 66;
+ /** @since 2.1 */
+ int TooManySyntheticArgumentSlots = Internal + 67;
+ /** @since 2.1 */
+ int TooManyArrayDimensions = Internal + 68;
+ /** @since 2.1 */
+ int BytecodeExceeds64KLimitForConstructor = Internal + 69;
// fields
int UndefinedField = FieldRelated + 70;
@@ -206,7 +241,11 @@
int UsingDeprecatedField = FieldRelated + 73;
int NonStaticFieldFromStaticInvocation = FieldRelated + 74;
int ReferenceToForwardField = FieldRelated + Internal + 75;
-
+ /** @since 2.1 */
+ int NonStaticAccessToStaticField = Internal + FieldRelated + 76;
+ /** @since 2.1 */
+ int UnusedPrivateField = Internal + FieldRelated + 77;
+
// blank final fields
int FinalFieldAssignment = FieldRelated + 80;
int UninitializedBlankFinalField = FieldRelated + 81;
@@ -229,12 +268,18 @@
int NoMessageSendOnBaseType = MethodRelated + 114;
int ParameterMismatch = MethodRelated + 115;
int NoMessageSendOnArrayType = MethodRelated + 116;
-
+ /** @since 2.1 */
+ int NonStaticAccessToStaticMethod = Internal + MethodRelated + 117;
+ /** @since 2.1 */
+ int UnusedPrivateMethod = Internal + MethodRelated + 118;
+
// constructors
int UndefinedConstructor = ConstructorRelated + 130;
int NotVisibleConstructor = ConstructorRelated + 131;
int AmbiguousConstructor = ConstructorRelated + 132;
int UsingDeprecatedConstructor = ConstructorRelated + 133;
+ /** @since 2.1 */
+ int UnusedPrivateConstructor = Internal + MethodRelated + 134;
// explicit constructor calls
int InstanceFieldDuringConstructorInvocation = ConstructorRelated + 135;
int InstanceMethodDuringConstructorInvocation = ConstructorRelated + 136;
@@ -290,7 +335,10 @@
int InvalidNullToSynchronized = Internal + 176;
// throw
int CannotThrowNull = Internal + 177;
-
+ // assignment
+ /** @since 2.1 */
+ int AssignmentHasNoEffect = Internal + 178;
+
// inner emulation
int NeedToEmulateFieldReadAccess = FieldRelated + 190;
int NeedToEmulateFieldWriteAccess = FieldRelated + 191;
@@ -320,6 +368,12 @@
int UnmatchedBracket = Syntax + Internal + 220;
int NoFieldOnBaseType = FieldRelated + 221;
int InvalidExpressionAsStatement = Syntax + Internal + 222;
+ /** @since 2.1 */
+ int ExpressionShouldBeAVariable = Syntax + Internal + 223;
+ /** @since 2.1 */
+ int MissingSemiColon = Syntax + Internal + 224;
+ /** @since 2.1 */
+ int InvalidParenthesizedExpression = Syntax + Internal + 225;
// scanner errors
int EndOfSource = Syntax + Internal + 250;
@@ -364,6 +418,8 @@
int MustSpecifyPackage = 326;
int HierarchyHasProblems = TypeRelated + 327;
int PackageIsNotExpectedPackage = 328;
+ /** @since 2.1 */
+ int ObjectCannotHaveSuperTypes = 329;
// int InvalidSuperclassBase = TypeRelated + 329; // reserved to 334 included
int SuperclassNotFound = TypeRelated + 329 + ProblemReasons.NotFound; // TypeRelated + 330
@@ -464,7 +520,11 @@
int OverridingNonVisibleMethod = MethodRelated + 410;
int AbstractMethodCannotBeOverridden = MethodRelated + 411;
int OverridingDeprecatedMethod = MethodRelated + 412;
-
+ /** @since 2.1 */
+ int IncompatibleReturnTypeForNonInheritedInterfaceMethod = MethodRelated + 413;
+ /** @since 2.1 */
+ int IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod = MethodRelated + 414;
+
// code snippet support
int CodeSnippetMissingClass = Internal + 420;
int CodeSnippetMissingMethod = Internal + 421;
@@ -473,8 +533,20 @@
//constant pool
int TooManyConstantsInConstantPool = Internal + 430;
-
+ /** @since 2.1 */
+ int TooManyBytesForStringConstant = Internal + 431;
+
+ // static constraints
+ /** @since 2.1 */
+ int TooManyFields = Internal + 432;
+ /** @since 2.1 */
+ int TooManyMethods = Internal + 433;
+
// 1.4 features
// assertion warning
int UseAssertAsAnIdentifier = Internal + 440;
+
+ // detected task
+ /** @since 2.1 */
+ int Task = Internal + 450;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/InvalidInputException.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/InvalidInputException.java
index 46fed58..64930a5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/InvalidInputException.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/InvalidInputException.java
@@ -1,13 +1,13 @@
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v0.5
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v05.html
-
-Contributors:
- IBM Corporation - initial API and implementation
-**********************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.jdt.core.compiler;
@@ -17,16 +17,16 @@
public class InvalidInputException extends Exception {
/**
- * InvalidInputException constructor comment.
+ * Creates a new exception with no detail message.
*/
public InvalidInputException() {
super();
}
/**
- * InvalidInputException constructor comment.
- * @param s java.lang.String
+ * Creates a new exception with the given detail message.
+ * @param message the detail message
*/
- public InvalidInputException(String s) {
- super(s);
+ public InvalidInputException(String message) {
+ super(message);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/AbstractSyntaxTreeVisitorAdapter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/AbstractSyntaxTreeVisitorAdapter.java
index 00bbc48..80be5f6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/AbstractSyntaxTreeVisitorAdapter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/AbstractSyntaxTreeVisitorAdapter.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
import org.eclipse.jdt.core.compiler.*;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
index 51e4566..56aa11c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java
@@ -1,25 +1,28 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
import java.io.*;
-import java.util.*;
+import java.util.StringTokenizer;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.codegen.*;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.impl.StringConstant;
import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
+import org.eclipse.jdt.internal.compiler.util.Util;
/**
* Represents a class file wrapper on bytes, it is aware of its actual
@@ -62,7 +65,6 @@
public static final int INITIAL_HEADER_SIZE = 1000;
public static final int INCREMENT_SIZE = 1000;
public static final int INNER_CLASSES_SIZE = 5;
- protected HashtableOfType nameUsage;
public CodeStream codeStream;
protected int problemLine; // used to create line number attributes for problem methods
@@ -148,15 +150,7 @@
this.enclosingClassFile = enclosingClassFile;
// innerclasses get their names computed at code gen time
- if (aType.isLocalType()) {
- ((LocalTypeBinding) aType).constantPoolName(
- computeConstantPoolName((LocalTypeBinding) aType));
- ReferenceBinding[] memberTypes = aType.memberTypes();
- for (int i = 0, max = memberTypes.length; i < max; i++) {
- ((LocalTypeBinding) memberTypes[i]).constantPoolName(
- computeConstantPoolName((LocalTypeBinding) memberTypes[i]));
- }
- }
+
contents = new byte[INITIAL_CONTENTS_SIZE];
// now we continue to generate the bytes inside the contents array
contents[contentsOffset++] = (byte) (accessFlags >> 8);
@@ -442,8 +436,7 @@
int fieldAttributeOffset = contentsOffset;
contentsOffset += 2;
// 4.7.2 only static constant fields get a ConstantAttribute
- if (fieldBinding.constant != Constant.NotAConstant
- && fieldBinding.constant.typeID() != T_null) {
+ if (fieldBinding.constant != Constant.NotAConstant){
// Now we generate the constant attribute corresponding to the fieldBinding
int constantValueNameIndex =
constantPool.literalIndex(AttributeNamesConstants.ConstantValueName);
@@ -561,6 +554,9 @@
+ (syntheticFields == null ? 0 : syntheticFields.length);
// write the number of fields
+ if (fieldCount > 0xFFFF) {
+ referenceBinding.scope.problemReporter().tooManyFields(referenceBinding.scope.referenceType());
+ }
contents[contentsOffset++] = (byte) (fieldCount >> 8);
contents[contentsOffset++] = (byte) fieldCount;
@@ -874,20 +870,21 @@
switch (accessMethodBinding.accessType) {
case SyntheticAccessMethodBinding.FieldReadAccess :
// generate a method info to emulate an reading access to
- // a private field
+ // a non-accessible field
addSyntheticFieldReadAccessMethod(syntheticAccessMethods[i]);
break;
case SyntheticAccessMethodBinding.FieldWriteAccess :
// generate a method info to emulate an writing access to
- // a private field
+ // a non-accessible field
addSyntheticFieldWriteAccessMethod(syntheticAccessMethods[i]);
break;
case SyntheticAccessMethodBinding.MethodAccess :
- // generate a method info to emulate an access to a private method
+ case SyntheticAccessMethodBinding.SuperMethodAccess :
+ // generate a method info to emulate an access to a non-accessible method / super-method
addSyntheticMethodAccessMethod(syntheticAccessMethods[i]);
break;
case SyntheticAccessMethodBinding.ConstructorAccess :
- // generate a method info to emulate an access to a private method
+ // generate a method info to emulate an access to a non-accessible constructor
addSyntheticConstructorAccessMethod(syntheticAccessMethods[i]);
}
}
@@ -1459,7 +1456,8 @@
0,
contentsLength);
}
- localContentsOffset += 2; // the startPC for this is always 0
+ localContents[localContentsOffset++] = 0; // the startPC for this is always 0
+ localContents[localContentsOffset++] = 0;
localContents[localContentsOffset++] = (byte) (code_length >> 8);
localContents[localContentsOffset++] = (byte) code_length;
nameIndex = constantPool.literalIndex(QualifiedNamesConstants.This);
@@ -1470,7 +1468,8 @@
codeStream.methodDeclaration.binding.declaringClass.signature());
localContents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
localContents[localContentsOffset++] = (byte) descriptorIndex;
- localContentsOffset += 2; // the resolved position for this is always 0
+ localContents[localContentsOffset++] = 0;// the resolved position for this is always 0
+ localContents[localContentsOffset++] = 0;
}
for (int i = 0; i < codeStream.allLocalsCounter; i++) {
LocalVariableBinding localVariable = codeStream.locals[i];
@@ -1621,7 +1620,8 @@
localContents[localContentsOffset++] = (byte) handlerPC;
if (exceptionHandler.exceptionType == null) {
// any exception handler
- localContentsOffset += 2;
+ localContents[localContentsOffset++] = 0;
+ localContents[localContentsOffset++] = 0;
} else {
int nameIndex;
if (exceptionHandler.exceptionType == TypeBinding.NullBinding) {
@@ -1865,6 +1865,14 @@
// first we handle the linenumber attribute
if (codeStream.generateLineNumberAttributes) {
+ if (localContentsOffset + 20 >= (contentsLength = localContents.length)) {
+ System.arraycopy(
+ contents,
+ 0,
+ (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
+ 0,
+ contentsLength);
+ }
/* Create and add the line number attribute (used for debugging)
* Build the pairs of:
* (bytecodePC lineNumber)
@@ -1997,6 +2005,14 @@
localContentsOffset += 2; // first we handle the linenumber attribute
if (codeStream.generateLineNumberAttributes) {
+ if (localContentsOffset + 20 >= (contentsLength = localContents.length)) {
+ System.arraycopy(
+ contents,
+ 0,
+ (localContents = contents = new byte[contentsLength + INCREMENT_SIZE]),
+ 0,
+ contentsLength);
+ }
/* Create and add the line number attribute (used for debugging)
* Build the pairs of:
* (bytecodePC lineNumber)
@@ -2076,7 +2092,7 @@
ReferenceBinding declaringClass = binding.declaringClass;
if (declaringClass.isNestedType()) {
NestedTypeBinding methodDeclaringClass = (NestedTypeBinding) declaringClass;
- argSize = methodDeclaringClass.syntheticArgumentsOffset;
+ argSize = methodDeclaringClass.enclosingInstancesSlotSize;
SyntheticArgumentBinding[] syntheticArguments;
if ((syntheticArguments = methodDeclaringClass.syntheticEnclosingInstances())
!= null) {
@@ -2228,7 +2244,8 @@
}
// there is no exception table, so we need to offset by 2 the current offset and move
// on the attribute generation
- localContentsOffset += 2;
+ contents[localContentsOffset++] = 0;
+ contents[localContentsOffset++] = 0;
// debug attributes
int codeAttributeAttributeOffset = localContentsOffset;
int attributeNumber = 0;
@@ -2365,67 +2382,6 @@
contents[methodAttributeOffset] = (byte) attributeNumber;
}
- /*
- * INTERNAL USE-ONLY
- * Innerclasses get their name computed as they are generated, since some may not
- * be actually outputed if sitting inside unreachable code.
- *
- * @param localType org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding
- */
- public char[] computeConstantPoolName(LocalTypeBinding localType) {
- if (localType.constantPoolName() != null) {
- return localType.constantPoolName();
- }
- // delegates to the outermost enclosing classfile, since it is the only one with a global vision of its innertypes.
- if (enclosingClassFile != null) {
- return this.outerMostEnclosingClassFile().computeConstantPoolName(localType);
- }
- if (nameUsage == null)
- nameUsage = new HashtableOfType();
-
- // ensure there is not already such a local type name defined by the user
- int index = 0;
- char[] candidateName;
- while(true) {
- if (localType.isMemberType()){
- if (index == 0){
- candidateName = CharOperation.concat(
- localType.enclosingType().constantPoolName(),
- localType.sourceName,
- '$');
- } else {
- // in case of collision, then member name gets extra $1 inserted
- // e.g. class X { { class L{} new X(){ class L{} } } }
- candidateName = CharOperation.concat(
- localType.enclosingType().constantPoolName(),
- '$',
- String.valueOf(index).toCharArray(),
- '$',
- localType.sourceName);
- }
- } else if (localType.isAnonymousType()){
- candidateName = CharOperation.concat(
- referenceBinding.constantPoolName(),
- String.valueOf(index+1).toCharArray(),
- '$');
- } else {
- candidateName = CharOperation.concat(
- referenceBinding.constantPoolName(),
- '$',
- String.valueOf(index+1).toCharArray(),
- '$',
- localType.sourceName);
- }
- if (nameUsage.get(candidateName) != null) {
- index ++;
- } else {
- nameUsage.put(candidateName, localType);
- break;
- }
- }
- return candidateName;
- }
-
/**
* INTERNAL USE-ONLY
* Request the creation of a ClassFile compatible representation of a problematic type
@@ -2439,6 +2395,8 @@
SourceTypeBinding typeBinding = typeDeclaration.binding;
ClassFile classFile = new ClassFile(typeBinding, null, true);
+ // TODO: (olivier) handle cases where a field cannot be generated (name too long)
+ // TODO: (olivier) handle too many methods
// inner attributes
if (typeBinding.isMemberType())
classFile.recordEnclosingTypeAttributes(typeBinding);
@@ -2448,7 +2406,7 @@
if ((fields != null) && (fields != NoFields)) {
for (int i = 0, max = fields.length; i < max; i++) {
if (fields[i].constant == null) {
- FieldReference.getConstantFor(fields[i], false, null, null, 0);
+ FieldReference.getConstantFor(fields[i], null, false, null);
}
}
classFile.addFieldInfos();
@@ -2464,7 +2422,7 @@
AbstractMethodDeclaration[] methodDeclarations = typeDeclaration.methods;
int maxMethodDecl = methodDeclarations == null ? 0 : methodDeclarations.length;
int problemsLength;
- IProblem[] problems = unitResult.getProblems();
+ IProblem[] problems = unitResult.getErrors();
if (problems == null) {
problems = new IProblem[0];
}
@@ -2956,4 +2914,4 @@
output.close();
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java
index 10e9d52..3bcbacd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/CompilationResult.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
/**
@@ -41,11 +41,12 @@
public class CompilationResult {
public IProblem problems[];
+ public IProblem tasks[];
public int problemCount;
+ public int taskCount;
public ICompilationUnit compilationUnit;
private Map problemsMap;
private Map firstErrorsMap;
- private HashSet duplicateProblems;
private int maxProblemPerUnit;
public char[][][] qualifiedReferences;
public char[][] simpleNameReferences;
@@ -56,237 +57,371 @@
public boolean hasBeenAccepted = false;
public char[] fileName;
-public CompilationResult(
- char[] fileName,
- int unitIndex,
- int totalUnitsKnown,
- int maxProblemPerUnit){
-
- this.fileName = fileName;
- this.unitIndex = unitIndex;
- this.totalUnitsKnown = totalUnitsKnown;
- this.maxProblemPerUnit = maxProblemPerUnit;
-
-}
-
-public CompilationResult(
- ICompilationUnit compilationUnit,
- int unitIndex,
- int totalUnitsKnown,
- int maxProblemPerUnit){
-
- this.fileName = compilationUnit.getFileName();
- this.compilationUnit = compilationUnit;
- this.unitIndex = unitIndex;
- this.totalUnitsKnown = totalUnitsKnown;
- this.maxProblemPerUnit = maxProblemPerUnit;
-
-}
-private int computePriority(IProblem problem){
-
- final int P_STATIC = 1000;
- final int P_OUTSIDE_METHOD = 4000;
- final int P_FIRST_ERROR = 2000;
- final int P_ERROR = 10000;
+ public CompilationResult(
+ char[] fileName,
+ int unitIndex,
+ int totalUnitsKnown,
+ int maxProblemPerUnit){
- int priority = 1000 - problem.getSourceLineNumber(); // early problems first
- if (priority < 0) priority = 0;
- if (problem.isError()){
- priority += P_ERROR;
+ this.fileName = fileName;
+ this.unitIndex = unitIndex;
+ this.totalUnitsKnown = totalUnitsKnown;
+ this.maxProblemPerUnit = maxProblemPerUnit;
}
- ReferenceContext context = problemsMap == null ? null : (ReferenceContext) problemsMap.get(problem);
- if (context != null){
- if (context instanceof AbstractMethodDeclaration){
- AbstractMethodDeclaration method = (AbstractMethodDeclaration) context;
- if (method.isStatic()) {
- priority += P_STATIC;
+
+ public CompilationResult(
+ ICompilationUnit compilationUnit,
+ int unitIndex,
+ int totalUnitsKnown,
+ int maxProblemPerUnit){
+
+ this.fileName = compilationUnit.getFileName();
+ this.compilationUnit = compilationUnit;
+ this.unitIndex = unitIndex;
+ this.totalUnitsKnown = totalUnitsKnown;
+ this.maxProblemPerUnit = maxProblemPerUnit;
+ }
+
+ private int computePriority(IProblem problem){
+
+ final int P_STATIC = 1000;
+ final int P_OUTSIDE_METHOD = 4000;
+ final int P_FIRST_ERROR = 2000;
+ final int P_ERROR = 10000;
+
+ int priority = 1000 - problem.getSourceLineNumber(); // early problems first
+ if (priority < 0) priority = 0;
+ if (problem.isError()){
+ priority += P_ERROR;
+ }
+ ReferenceContext context = problemsMap == null ? null : (ReferenceContext) problemsMap.get(problem);
+ if (context != null){
+ if (context instanceof AbstractMethodDeclaration){
+ AbstractMethodDeclaration method = (AbstractMethodDeclaration) context;
+ if (method.isStatic()) {
+ priority += P_STATIC;
+ }
+ } else {
+ priority += P_OUTSIDE_METHOD;
}
} else {
- priority += P_OUTSIDE_METHOD;
+ priority += P_OUTSIDE_METHOD;
}
- } else {
- priority += P_OUTSIDE_METHOD;
+ if (firstErrorsMap.containsKey(problem)){
+ priority += P_FIRST_ERROR;
+ }
+ return priority;
}
- if (firstErrorsMap.containsKey(problem)){
- priority += P_FIRST_ERROR;
- }
- return priority;
-}
-public ClassFile[] getClassFiles() {
- Enumeration enum = compiledTypes.elements();
- ClassFile[] classFiles = new ClassFile[compiledTypes.size()];
- int index = 0;
- while (enum.hasMoreElements()){
- classFiles[index++] = (ClassFile)enum.nextElement();
- }
- return classFiles;
-}
-/**
- * Answer the initial compilation unit corresponding to the present compilation result
- */
-public ICompilationUnit getCompilationUnit(){
- return compilationUnit;
-}
-/**
- * Answer the initial file name
- */
-public char[] getFileName(){
- return fileName;
-}
-/**
- * Answer the problems (errors and warnings) encountered during compilation.
- *
- * This is not a compiler internal API - it has side-effects !
- * It is intended to be used only once all problems have been detected,
- * and makes sure the problems slot as the exact size of the number of
- * problems.
- */
-public IProblem[] getProblems() {
+
- // Re-adjust the size of the problems if necessary.
- if (problems != null) {
-
- if (this.problemCount != problems.length) {
- System.arraycopy(problems, 0, (problems = new IProblem[problemCount]), 0, problemCount);
+ public IProblem[] getAllProblems() {
+ IProblem[] problems = this.getProblems();
+ int problemCount = problems != null ? problems.length : 0;
+ IProblem[] tasks = this.getTasks();
+ int taskCount = tasks != null ? tasks.length : 0;
+ if (taskCount == 0) {
+ return problems;
+ }
+ if (problemCount == 0) {
+ return tasks;
}
- if (this.maxProblemPerUnit > 0 && this.problemCount > this.maxProblemPerUnit){
- quickPrioritize(problems, 0, problemCount - 1);
- this.problemCount = this.maxProblemPerUnit;
- System.arraycopy(problems, 0, (problems = new IProblem[problemCount]), 0, problemCount);
+ int totalNumberOfProblem = problemCount + taskCount;
+ IProblem[] allProblems = new IProblem[totalNumberOfProblem];
+ int allProblemIndex = 0;
+ int taskIndex = 0;
+ int problemIndex = 0;
+ while (taskIndex + problemIndex < totalNumberOfProblem) {
+ IProblem nextTask = null;
+ IProblem nextProblem = null;
+ if (taskIndex < taskCount) {
+ nextTask = tasks[taskIndex];
+ }
+ if (problemIndex < problemCount) {
+ nextProblem = problems[problemIndex];
+ }
+ // select the next problem
+ IProblem currentProblem = null;
+ if (nextProblem != null) {
+ if (nextTask != null) {
+ if (nextProblem.getSourceStart() < nextTask.getSourceStart()) {
+ currentProblem = nextProblem;
+ problemIndex++;
+ } else {
+ currentProblem = nextTask;
+ taskIndex++;
+ }
+ } else {
+ currentProblem = nextProblem;
+ problemIndex++;
+ }
+ } else {
+ if (nextTask != null) {
+ currentProblem = nextTask;
+ taskIndex++;
+ }
+ }
+ allProblems[allProblemIndex++] = currentProblem;
}
-
- // Sort problems per source positions.
- quicksort(problems, 0, problems.length-1);
+ return allProblems;
}
- return problems;
-}
-
-public boolean hasErrors() {
- if (problems != null)
- for (int i = 0; i < problemCount; i++) {
- if (problems[i].isError())
- return true;
+
+ public ClassFile[] getClassFiles() {
+ Enumeration enum = compiledTypes.elements();
+ ClassFile[] classFiles = new ClassFile[compiledTypes.size()];
+ int index = 0;
+ while (enum.hasMoreElements()){
+ classFiles[index++] = (ClassFile)enum.nextElement();
}
- return false;
-}
-public boolean hasProblems() {
- return problemCount != 0;
-}
-public boolean hasWarnings() {
- if (problems != null)
- for (int i = 0; i < problemCount; i++) {
- if (problems[i].isWarning())
- return true;
- }
- return false;
-}
-
-private static void quicksort(IProblem arr[], int left, int right) {
- int i, last, pos;
-
- if (left >= right) {
- /* do nothing if array contains fewer than two */
- return;
- /* two elements */
+ return classFiles;
}
- swap(arr, left, (left + right) / 2);
- last = left;
- pos = arr[left].getSourceStart();
+ /**
+ * Answer the initial compilation unit corresponding to the present compilation result
+ */
+ public ICompilationUnit getCompilationUnit(){
+ return compilationUnit;
+ }
- for (i = left + 1; i <= right; i++) {
- if (arr[i].getSourceStart() < pos) {
- swap(arr, ++last, i);
+ /**
+ * Answer the initial file name
+ */
+ public char[] getFileName(){
+ return fileName;
+ }
+
+ /**
+ * Answer the errors encountered during compilation.
+ */
+ public IProblem[] getErrors() {
+
+ IProblem[] problems = getProblems();
+ int errorCount = 0;
+ for (int i = 0; i < this.problemCount; i++) {
+ if (problems[i].isError()) errorCount++;
}
- }
-
- swap(arr, left, last);
- quicksort(arr, left, last - 1);
- quicksort(arr, last + 1, right);
-}
-
-private void quickPrioritize(IProblem arr[], int left, int right) {
- int i, last, prio;
-
- if (left >= right) {
- /* do nothing if array contains fewer than two */
- return;
- /* two elements */
- }
-
- swap(arr, left, (left + right) / 2);
- last = left;
- prio = computePriority(arr[left]);
-
- for (i = left + 1; i <= right; i++) {
- if (computePriority(arr[i]) > prio) {
- swap(arr, ++last, i);
+ if (errorCount == this.problemCount) return problems;
+ IProblem[] errors = new IProblem[errorCount];
+ int index = 0;
+ for (int i = 0; i < this.problemCount; i++) {
+ if (problems[i].isError()) errors[index++] = problems[i];
}
+ return errors;
+ }
+
+ /**
+ * Answer the problems (errors and warnings) encountered during compilation.
+ *
+ * This is not a compiler internal API - it has side-effects !
+ * It is intended to be used only once all problems have been detected,
+ * and makes sure the problems slot as the exact size of the number of
+ * problems.
+ */
+ public IProblem[] getProblems() {
+
+ // Re-adjust the size of the problems if necessary.
+ if (problems != null) {
+
+ if (this.problemCount != problems.length) {
+ System.arraycopy(problems, 0, (problems = new IProblem[problemCount]), 0, problemCount);
+ }
+
+ if (this.maxProblemPerUnit > 0 && this.problemCount > this.maxProblemPerUnit){
+ quickPrioritize(problems, 0, problemCount - 1);
+ this.problemCount = this.maxProblemPerUnit;
+ System.arraycopy(problems, 0, (problems = new IProblem[problemCount]), 0, problemCount);
+ }
+
+ // Sort problems per source positions.
+ quickSort(problems, 0, problems.length-1);
+ }
+ return problems;
}
- swap(arr, left, last);
- quickPrioritize(arr, left, last - 1);
- quickPrioritize(arr, last + 1, right);
-}
+ /**
+ * Answer the tasks (TO-DO, ...) encountered during compilation.
+ *
+ * This is not a compiler internal API - it has side-effects !
+ * It is intended to be used only once all problems have been detected,
+ * and makes sure the problems slot as the exact size of the number of
+ * problems.
+ */
+ public IProblem[] getTasks() {
+
+ // Re-adjust the size of the tasks if necessary.
+ if (this.tasks != null) {
+
+ if (this.taskCount != this.tasks.length) {
+ System.arraycopy(this.tasks, 0, (this.tasks = new IProblem[this.taskCount]), 0, this.taskCount);
+ }
+ quickSort(tasks, 0, tasks.length-1);
+ }
+ return this.tasks;
+ }
+
+ public boolean hasErrors() {
-/**
- * For now, remember the compiled type using its compound name.
- */
-public void record(char[] typeName, ClassFile classFile) {
- compiledTypes.put(typeName, classFile);
-}
-public void record(IProblem newProblem, ReferenceContext referenceContext) {
- if (problemCount == 0) {
- problems = new IProblem[5];
- } else {
- if (problemCount == problems.length)
+ if (problems != null)
+ for (int i = 0; i < problemCount; i++) {
+ if (problems[i].isError())
+ return true;
+ }
+ return false;
+ }
+
+ public boolean hasProblems() {
+
+ return problemCount != 0;
+ }
+
+ public boolean hasSyntaxError(){
+
+ if (problems != null)
+ for (int i = 0; i < problemCount; i++) {
+ IProblem problem = problems[i];
+ if ((problem.getID() & IProblem.Syntax) != 0 && problem.isError())
+ return true;
+ }
+ return false;
+ }
+
+ public boolean hasTasks() {
+ return this.taskCount != 0;
+ }
+
+ public boolean hasWarnings() {
+
+ if (problems != null)
+ for (int i = 0; i < problemCount; i++) {
+ if (problems[i].isWarning())
+ return true;
+ }
+ return false;
+ }
+
+ private static void quickSort(IProblem[] list, int left, int right) {
+
+ if (left >= right) return;
+
+ // sort the problems by their source start position... starting with 0
+ int original_left = left;
+ int original_right = right;
+ int mid = list[(left + right) / 2].getSourceStart();
+ do {
+ while (list[left].getSourceStart() < mid)
+ left++;
+ while (mid < list[right].getSourceStart())
+ right--;
+ if (left <= right) {
+ IProblem tmp = list[left];
+ list[left] = list[right];
+ list[right] = tmp;
+ left++;
+ right--;
+ }
+ } while (left <= right);
+ if (original_left < right)
+ quickSort(list, original_left, right);
+ if (left < original_right)
+ quickSort(list, left, original_right);
+ }
+
+ private void quickPrioritize(IProblem[] list, int left, int right) {
+
+ if (left >= right) return;
+
+ // sort the problems by their priority... starting with the highest priority
+ int original_left = left;
+ int original_right = right;
+ int mid = computePriority(list[(left + right) / 2]);
+ do {
+ while (computePriority(list[right]) < mid)
+ right--;
+ while (mid < computePriority(list[left]))
+ left++;
+ if (left <= right) {
+ IProblem tmp = list[left];
+ list[left] = list[right];
+ list[right] = tmp;
+ left++;
+ right--;
+ }
+ } while (left <= right);
+ if (original_left < right)
+ quickPrioritize(list, original_left, right);
+ if (left < original_right)
+ quickPrioritize(list, left, original_right);
+ }
+
+ /**
+ * For now, remember the compiled type using its compound name.
+ */
+ public void record(char[] typeName, ClassFile classFile) {
+
+ compiledTypes.put(typeName, classFile);
+ }
+
+ public void record(IProblem newProblem, ReferenceContext referenceContext) {
+
+ if (newProblem.getID() == IProblem.Task) {
+ recordTask(newProblem);
+ return;
+ }
+ if (problemCount == 0) {
+ problems = new IProblem[5];
+ } else if (problemCount == problems.length) {
System.arraycopy(problems, 0, (problems = new IProblem[problemCount * 2]), 0, problemCount);
- };
- problems[problemCount++] = newProblem;
- if (referenceContext != null){
- if (problemsMap == null) problemsMap = new Hashtable(5);
- if (firstErrorsMap == null) firstErrorsMap = new Hashtable(5);
- if (newProblem.isError() && !referenceContext.hasErrors()) firstErrorsMap.put(newProblem, newProblem);
- problemsMap.put(newProblem, referenceContext);
+ }
+ problems[problemCount++] = newProblem;
+ if (referenceContext != null){
+ if (problemsMap == null) problemsMap = new Hashtable(5);
+ if (firstErrorsMap == null) firstErrorsMap = new Hashtable(5);
+ if (newProblem.isError() && !referenceContext.hasErrors()) firstErrorsMap.put(newProblem, newProblem);
+ problemsMap.put(newProblem, referenceContext);
+ }
}
-}
-private static void swap(IProblem arr[], int i, int j) {
- IProblem tmp;
- tmp = arr[i];
- arr[i] = arr[j];
- arr[j] = tmp;
-}
-CompilationResult tagAsAccepted(){
- this.hasBeenAccepted = true;
- this.problemsMap = null; // flush
- return this;
-}
-public String toString(){
- StringBuffer buffer = new StringBuffer();
- if (this.fileName != null){
- buffer.append("Filename : ").append(this.fileName).append('\n'); //$NON-NLS-1$
- }
- if (this.compiledTypes != null){
- buffer.append("COMPILED type(s) \n"); //$NON-NLS-1$
- Enumeration typeNames = this.compiledTypes.keys();
- while (typeNames.hasMoreElements()) {
- char[] typeName = (char[]) typeNames.nextElement();
- buffer.append("\t - ").append(typeName).append('\n'); //$NON-NLS-1$
-
+ private void recordTask(IProblem newProblem) {
+ if (this.taskCount == 0) {
+ this.tasks = new IProblem[5];
+ } else if (this.taskCount == this.tasks.length) {
+ System.arraycopy(this.tasks, 0, (this.tasks = new IProblem[this.taskCount * 2]), 0, this.taskCount);
}
- } else {
- buffer.append("No COMPILED type\n"); //$NON-NLS-1$
+ this.tasks[this.taskCount++] = newProblem;
}
- if (problems != null){
- buffer.append(this.problemCount).append(" PROBLEM(s) detected \n"); //$NON-NLS-1$//$NON-NLS-2$
- for (int i = 0; i < this.problemCount; i++){
- buffer.append("\t - ").append(this.problems[i]).append('\n'); //$NON-NLS-1$
+
+ public CompilationResult tagAsAccepted(){
+
+ this.hasBeenAccepted = true;
+ this.problemsMap = null; // flush
+ return this;
+ }
+
+ public String toString(){
+
+ StringBuffer buffer = new StringBuffer();
+ if (this.fileName != null){
+ buffer.append("Filename : ").append(this.fileName).append('\n'); //$NON-NLS-1$
}
- } else {
- buffer.append("No PROBLEM\n"); //$NON-NLS-1$
- }
- return buffer.toString();
-}
+ if (this.compiledTypes != null){
+ buffer.append("COMPILED type(s) \n"); //$NON-NLS-1$
+ Enumeration typeNames = this.compiledTypes.keys();
+ while (typeNames.hasMoreElements()) {
+ char[] typeName = (char[]) typeNames.nextElement();
+ buffer.append("\t - ").append(typeName).append('\n'); //$NON-NLS-1$
+
+ }
+ } else {
+ buffer.append("No COMPILED type\n"); //$NON-NLS-1$
+ }
+ if (problems != null){
+ buffer.append(this.problemCount).append(" PROBLEM(s) detected \n"); //$NON-NLS-1$//$NON-NLS-2$
+ for (int i = 0; i < this.problemCount; i++){
+ buffer.append("\t - ").append(this.problems[i]).append('\n'); //$NON-NLS-1$
+ }
+ } else {
+ buffer.append("No PROBLEM\n"); //$NON-NLS-1$
+ }
+ return buffer.toString();
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
index b92e132..607a993 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/Compiler.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
import org.eclipse.jdt.core.compiler.*;
@@ -24,14 +24,14 @@
public class Compiler implements ITypeRequestor, ProblemSeverities {
public Parser parser;
- ICompilerRequestor requestor;
+ public ICompilerRequestor requestor;
public CompilerOptions options;
public ProblemReporter problemReporter;
// management of unit to be processed
//public CompilationUnitResult currentCompilationUnitResult;
- CompilationUnitDeclaration[] unitsToProcess;
- int totalUnits; // (totalUnits-1) gives the last unit in unitToProcess
+ public CompilationUnitDeclaration[] unitsToProcess;
+ public int totalUnits; // (totalUnits-1) gives the last unit in unitToProcess
// name lookup
public LookupEnvironment lookupEnvironment;
@@ -113,7 +113,7 @@
new Parser(
problemReporter,
this.options.parseLiteralExpressionsAsConstants,
- this.options.assertMode);
+ options.sourceLevel >= CompilerOptions.JDK1_4);
}
/**
@@ -184,7 +184,7 @@
new Parser(
problemReporter,
parseLiteralExpressionsAsConstants,
- this.options.assertMode);
+ this.options.sourceLevel >= CompilerOptions.JDK1_4);
}
/**
@@ -212,12 +212,13 @@
}
if (options.verbose) {
+ String count = String.valueOf(totalUnits + 1);
System.out.println(
Util.bind(
"compilation.request" , //$NON-NLS-1$
new String[] {
- String.valueOf(totalUnits + 1),
- String.valueOf(totalUnits + 1),
+ count,
+ count,
new String(sourceUnit.getFileName())}));
}
@@ -416,16 +417,19 @@
internalException.printStackTrace(writer);
StringBuffer buffer = stringWriter.getBuffer();
+ String[] pbArguments = new String[] {
+ Util.bind("compilation.internalError" ) //$NON-NLS-1$
+ + "\n" //$NON-NLS-1$
+ + buffer.toString()};
+
result
.record(
problemReporter
.createProblem(
result.getFileName(),
IProblem.Unclassified,
- new String[] {
- Util.bind("compilation.internalError" ) //$NON-NLS-1$
- + "\n" //$NON-NLS-1$
- + buffer.toString()},
+ pbArguments,
+ pbArguments,
Error, // severity
0, // source start
0, // source end
@@ -477,6 +481,7 @@
result.getFileName(),
abortException.problemId,
abortException.problemArguments,
+ abortException.messageArguments,
Error, // severity
0, // source start
0, // source end
@@ -517,7 +522,7 @@
/**
* Process a compilation unit already parsed and build.
*/
- private void process(CompilationUnitDeclaration unit, int i) {
+ public void process(CompilationUnitDeclaration unit, int i) {
getMethodBodies(unit, i);
@@ -553,9 +558,14 @@
}
/**
- * Internal API used to resolve a compilation unit minimally for code assist engine
+ * Internal API used to resolve a given compilation unit. Can run a subset of the compilation process
*/
- public CompilationUnitDeclaration resolve(ICompilationUnit sourceUnit) {
+ public CompilationUnitDeclaration resolve(
+ ICompilationUnit sourceUnit,
+ boolean verifyMethods,
+ boolean analyzeCode,
+ boolean generateCode) {
+
CompilationUnitDeclaration unit = null;
try {
// build and record parsed units
@@ -567,8 +577,19 @@
if (unit.scope != null) {
// fault in fields & methods
unit.scope.faultInTypes();
+ if (unit.scope != null && verifyMethods) {
+ // http://dev.eclipse.org/bugs/show_bug.cgi?id=23117
+ // verify inherited methods
+ unit.scope.verifyMethods(lookupEnvironment.methodVerifier());
+ }
// type checking
- unit.resolve();
+ unit.resolve();
+
+ // flow analysis
+ if (analyzeCode) unit.analyseCode();
+
+ // code generation
+ if (generateCode) unit.generateCode();
}
unitsToProcess[0] = null; // release reference to processed unit declaration
requestor.acceptResult(unit.compilationResult.tagAsAccepted());
@@ -592,4 +613,4 @@
// this.reset();
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ConfigurableOption.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ConfigurableOption.java
index c0a74d2..c806ed4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ConfigurableOption.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ConfigurableOption.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
/**
@@ -54,7 +54,7 @@
ResourceBundle resource = null;
try {
String location = componentName.substring(0, componentName.lastIndexOf('.'));
- resource = ResourceBundle.getBundle(location + ".Options", loc); //$NON-NLS-1$
+ resource = ResourceBundle.getBundle(location + ".options", loc); //$NON-NLS-1$
} catch (MissingResourceException e) {
category = "Missing ressources entries for" + componentName + " options"; //$NON-NLS-1$ //$NON-NLS-2$
name = "Missing ressources entries for"+ componentName + " options"; //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java
index 2500281..6029257 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
public class DefaultErrorHandlingPolicies {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DocumentElementParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DocumentElementParser.java
index d57fb91..24b6163 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DocumentElementParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DocumentElementParser.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
/*
@@ -32,7 +32,6 @@
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
public class DocumentElementParser extends Parser {
IDocumentElementRequestor requestor;
@@ -64,7 +63,7 @@
}
},
false,
- options.assertMode);
+ options.sourceLevel >= CompilerOptions.JDK1_4);
this.requestor = requestor;
intArrayStack = new int[30][];
this.options = options;
@@ -90,47 +89,34 @@
pushOnIntArrayStack(this.getJavaDocPositions());
boolean deprecated = false;
int lastAnnotationIndex = -1;
+ int commentPtr = scanner.commentPtr;
//since jdk1.2 look only in the last java doc comment...
- found : {
- if ((lastAnnotationIndex = scanner.commentPtr) >= 0) { //look for @deprecated
- scanner.commentPtr = -1;
- // reset the comment stack, since not necessary after having checked
- int commentSourceStart = scanner.commentStarts[lastAnnotationIndex];
- // javadoc only (non javadoc comment have negative end positions.)
- int commentSourceEnd = scanner.commentStops[lastAnnotationIndex] - 1;
- //stop is one over
- char[] comment = scanner.source;
-
- for (int i = commentSourceStart + 3; i < commentSourceEnd - 10; i++) {
- if ((comment[i] == '@')
- && (comment[i + 1] == 'd')
- && (comment[i + 2] == 'e')
- && (comment[i + 3] == 'p')
- && (comment[i + 4] == 'r')
- && (comment[i + 5] == 'e')
- && (comment[i + 6] == 'c')
- && (comment[i + 7] == 'a')
- && (comment[i + 8] == 't')
- && (comment[i + 9] == 'e')
- && (comment[i + 10] == 'd')) {
- // ensure the tag is properly ended: either followed by a space, line end or asterisk.
- int nextPos = i + 11;
- deprecated =
- (comment[nextPos] == ' ')
- || (comment[nextPos] == '\n')
- || (comment[nextPos] == '\r')
- || (comment[nextPos] == '*');
- break found;
- }
- }
+ nextComment : for (lastAnnotationIndex = scanner.commentPtr; lastAnnotationIndex >= 0; lastAnnotationIndex--){
+ //look for @deprecated into the first javadoc comment preceeding the declaration
+ int commentSourceStart = scanner.commentStarts[lastAnnotationIndex];
+ // javadoc only (non javadoc comment have negative end positions.)
+ if (modifiersSourceStart != -1 && modifiersSourceStart < commentSourceStart) {
+ continue nextComment;
}
+ if (scanner.commentStops[lastAnnotationIndex] < 0) {
+ continue nextComment;
+ }
+ int commentSourceEnd = scanner.commentStops[lastAnnotationIndex] - 1; //stop is one over
+ char[] comment = scanner.source;
+
+ deprecated =
+ checkDeprecation(
+ commentSourceStart,
+ commentSourceEnd,
+ comment);
+ break nextComment;
}
if (deprecated) {
checkAndSetModifiers(AccDeprecated);
}
// modify the modifier source start to point at the first comment
- if (lastAnnotationIndex >= 0) {
+ if (commentPtr >= 0) {
declarationSourceStart = scanner.commentStarts[0];
}
}
@@ -249,7 +235,7 @@
} else {
// Record that the block has a declaration for local types
typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult);
- markCurrentMethodWithLocalType();
+ markEnclosingMemberWithLocalType();
blockReal();
}
@@ -652,7 +638,7 @@
} else {
// Record that the block has a declaration for local types
typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult);
- markCurrentMethodWithLocalType();
+ markEnclosingMemberWithLocalType();
blockReal();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IAbstractSyntaxTreeVisitor.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IAbstractSyntaxTreeVisitor.java
index ca1b50b..d70291c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IAbstractSyntaxTreeVisitor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IAbstractSyntaxTreeVisitor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
import org.eclipse.jdt.core.compiler.*;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ICompilerRequestor.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ICompilerRequestor.java
index 402644b..b879c21 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ICompilerRequestor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ICompilerRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IDebugRequestor.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IDebugRequestor.java
index 4a9ab68..7db699a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IDebugRequestor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IDebugRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
public interface IDebugRequestor {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IDocumentElementRequestor.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IDocumentElementRequestor.java
index c2fdc01..b9cd201 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IDocumentElementRequestor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IDocumentElementRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
import org.eclipse.jdt.core.compiler.IProblem;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IErrorHandlingPolicy.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IErrorHandlingPolicy.java
index db96d2d..d5e0459 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IErrorHandlingPolicy.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IErrorHandlingPolicy.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
/*
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IProblemFactory.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IProblemFactory.java
index 8f381fe..d5e36bd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IProblemFactory.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IProblemFactory.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
import java.util.Locale;
@@ -28,7 +28,8 @@
IProblem createProblem(
char[] originatingFileName,
int problemId,
- String[] arguments,
+ String[] problemArguments,
+ String[] messageArguments, // shorter versions of the problemArguments
int severity,
int startPosition,
int endPosition,
@@ -36,5 +37,5 @@
Locale getLocale();
- String getLocalizedMessage(int problemId, String[] problemArguments);
-}
\ No newline at end of file
+ String getLocalizedMessage(int problemId, String[] messageArguments);
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java
index ed3a5ea..01d4c02 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
import org.eclipse.jdt.core.compiler.IProblem;
@@ -123,16 +123,10 @@
void exitCompilationUnit(int declarationEnd);
void exitConstructor(int declarationEnd);
/*
- * - No initialization source for now -
- * initializationSource denotes the source of the expression used for initializing
- * the field if any (if no source, then it is null).
- *
- * Note: the initializationSource will be used in case we do need to type check
- * against source models, and thus the only interesting use for it is field
- * constant propagation. Therefore, the initializationSource will only be non
- * null for final fields (so as to minimize char[] allocations).
+ * initializationStart denotes the source start of the expression used for initializing
+ * the field if any (-1 if no initialization).
*/
-void exitField(/*char[] initializationSource, */int declarationEnd);
+void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd);
void exitInitializer(int declarationEnd);
void exitInterface(int declarationEnd);
void exitMethod(int declarationEnd);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java
index 1b6ae62..ad174a0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
/**
@@ -36,24 +36,23 @@
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
public class SourceElementParser extends Parser {
ISourceElementRequestor requestor;
- private int fieldCount;
- private int localIntPtr;
- private int lastFieldEndPosition;
- private ISourceType sourceType;
- private boolean reportReferenceInfo;
- private char[][] typeNames;
- private char[][] superTypeNames;
- private int nestedTypeIndex;
- private static final char[] JAVA_LANG_OBJECT = "java.lang.Object".toCharArray(); //$NON-NLS-1$
- private NameReference[] unknownRefs;
- private int unknownRefsCounter;
- private LocalDeclarationVisitor localDeclarationVisitor = null;
- private CompilerOptions options;
+ int fieldCount;
+ int localIntPtr;
+ int lastFieldEndPosition;
+ ISourceType sourceType;
+ boolean reportReferenceInfo;
+ char[][] typeNames;
+ char[][] superTypeNames;
+ int nestedTypeIndex;
+ static final char[] JAVA_LANG_OBJECT = "java.lang.Object".toCharArray(); //$NON-NLS-1$
+ NameReference[] unknownRefs;
+ int unknownRefsCounter;
+ LocalDeclarationVisitor localDeclarationVisitor = null;
+ CompilerOptions options;
/**
* An ast visitor that visits local type declarations.
@@ -92,7 +91,7 @@
}
},
true,
- options.assertMode);
+ options.sourceLevel >= CompilerOptions.JDK1_4);
this.requestor = requestor;
typeNames = new char[4][];
superTypeNames = new char[4][];
@@ -203,6 +202,7 @@
protected void consumeExitVariableWithoutInitialization() {
// ExitVariableWithoutInitialization ::= $empty
// do nothing by default
+ super.consumeExitVariableWithoutInitialization();
if (isLocalDeclaration() || ((currentToken != TokenNameCOMMA) && (currentToken != TokenNameSEMICOLON)))
return;
((SourceFieldDeclaration) astStack[astPtr]).fieldEndPosition = scanner.currentPosition - 1;
@@ -757,10 +757,12 @@
selectorSourceEnd =
((SourceMethodDeclaration) methodDeclaration).selectorSourceEnd;
}
- if (isInRange){
+ if (isInRange) {
+ int modifiers = methodDeclaration.modifiers;
+ boolean deprecated = (modifiers & AccDeprecated) != 0; // remember deprecation so as to not lose it below
requestor.enterMethod(
methodDeclaration.declarationSourceStart,
- methodDeclaration.modifiers & AccJustFlag,
+ deprecated ? (modifiers & AccJustFlag) | AccDeprecated : modifiers & AccJustFlag,
returnTypeName(((MethodDeclaration) methodDeclaration).returnType),
methodDeclaration.selector,
methodDeclaration.sourceStart,
@@ -795,9 +797,11 @@
}
}
if (isInRange) {
+ int modifiers = fieldDeclaration.modifiers;
+ boolean deprecated = (modifiers & AccDeprecated) != 0; // remember deprecation so as to not lose it below
requestor.enterField(
fieldDeclaration.declarationSourceStart,
- fieldDeclaration.modifiers & AccJustFlag,
+ deprecated ? (modifiers & AccJustFlag) | AccDeprecated : modifiers & AccJustFlag,
returnTypeName(fieldDeclaration.type),
fieldDeclaration.name,
fieldDeclaration.sourceStart,
@@ -805,7 +809,21 @@
}
this.visitIfNeeded(fieldDeclaration);
if (isInRange){
- requestor.exitField(fieldEndPosition);
+ requestor.exitField(
+ // filter out initializations that are not a constant (simple check)
+ (fieldDeclaration.initialization == null
+ || fieldDeclaration.initialization instanceof ArrayInitializer
+ || fieldDeclaration.initialization instanceof AllocationExpression
+ || fieldDeclaration.initialization instanceof ArrayAllocationExpression
+ || fieldDeclaration.initialization instanceof Assignment
+ || fieldDeclaration.initialization instanceof ClassLiteralAccess
+ || fieldDeclaration.initialization instanceof MessageSend
+ || fieldDeclaration.initialization instanceof ArrayReference
+ || fieldDeclaration.initialization instanceof ThisReference) ?
+ -1 :
+ fieldDeclaration.initialization.sourceStart,
+ fieldEndPosition,
+ fieldDeclaration.declarationSourceEnd);
}
} else {
@@ -880,9 +898,11 @@
}
if (isInterface) {
if (isInRange){
+ int modifiers = typeDeclaration.modifiers;
+ boolean deprecated = (modifiers & AccDeprecated) != 0; // remember deprecation so as to not lose it below
requestor.enterInterface(
typeDeclaration.declarationSourceStart,
- typeDeclaration.modifiers & AccJustFlag,
+ deprecated ? (modifiers & AccJustFlag) | AccDeprecated : modifiers & AccJustFlag,
typeDeclaration.name,
typeDeclaration.sourceStart,
typeDeclaration.sourceEnd,
@@ -996,11 +1016,15 @@
unknownRefs = new NameReference[10];
unknownRefsCounter = 0;
}
+
try {
diet = true;
CompilationResult compilationUnitResult = new CompilationResult(unit, 0, 0, this.options.maxProblemsPerUnit);
CompilationUnitDeclaration parsedUnit = parse(unit, compilationUnitResult, start, end);
- if (needReferenceInfo){
+ if (scanner.recordLineSeparator) {
+ requestor.acceptLineSeparatorPositions(scanner.getLineEnds());
+ }
+ if (this.localDeclarationVisitor != null || needReferenceInfo){
diet = false;
this.getMethodBodies(parsedUnit);
}
@@ -1008,9 +1032,6 @@
notifySourceElementRequestor(parsedUnit);
} catch (AbortCompilation e) {
} finally {
- if (scanner.recordLineSeparator) {
- requestor.acceptLineSeparatorPositions(scanner.getLineEnds());
- }
diet = old;
}
}
@@ -1022,19 +1043,18 @@
unknownRefs = new NameReference[10];
unknownRefsCounter = 0;
}
-
+
try {
-/* diet = !needReferenceInfo;
- reportReferenceInfo = needReferenceInfo;
- CompilationResult compilationUnitResult = new CompilationResult(unit, 0, 0);
- parse(unit, compilationUnitResult);
-*/ diet = true;
+ diet = true;
reportReferenceInfo = needReferenceInfo;
CompilationResult compilationUnitResult = new CompilationResult(unit, 0, 0, this.options.maxProblemsPerUnit);
CompilationUnitDeclaration parsedUnit = parse(unit, compilationUnitResult);
+ if (scanner.recordLineSeparator) {
+ requestor.acceptLineSeparatorPositions(scanner.getLineEnds());
+ }
int initialStart = this.scanner.initialPosition;
int initialEnd = this.scanner.eofPosition;
- if (needReferenceInfo){
+ if (this.localDeclarationVisitor != null || needReferenceInfo){
diet = false;
this.getMethodBodies(parsedUnit);
}
@@ -1042,9 +1062,6 @@
notifySourceElementRequestor(parsedUnit);
} catch (AbortCompilation e) {
} finally {
- if (scanner.recordLineSeparator) {
- requestor.acceptLineSeparatorPositions(scanner.getLineEnds());
- }
diet = old;
}
}
@@ -1068,8 +1085,9 @@
CompilationUnitDeclaration unit =
SourceTypeConverter.buildCompilationUnit(
new ISourceType[]{sourceType},
- false,
- false,
+ false, // no need for field and methods
+ false, // no need for member types
+ false, // no need for field initialization
problemReporter(),
compilationUnitResult);
if ((unit == null) || (unit.types == null) || (unit.types.length != 1))
@@ -1119,6 +1137,8 @@
/* scanner initialization */
scanner.setSource(contents);
scanner.recordLineSeparator = false;
+ scanner.taskTags = null;
+ scanner.taskPriorities = null;
scanner.resetTo(start, end);
/* unit creation */
@@ -1199,63 +1219,6 @@
}
this.unknownRefs[this.unknownRefsCounter++] = nameRef;
}
-private TypeReference typeReference(
- int dim,
- int localIdentifierPtr,
- int localIdentifierLengthPtr) {
- /* build a Reference on a variable that may be qualified or not
- * This variable is a type reference and dim will be its dimensions.
- * We don't have any side effect on the stacks' pointers.
- */
-
- int length;
- TypeReference ref;
- if ((length = identifierLengthStack[localIdentifierLengthPtr]) == 1) {
- // single variable reference
- if (dim == 0) {
- ref =
- new SingleTypeReference(
- identifierStack[localIdentifierPtr],
- identifierPositionStack[localIdentifierPtr--]);
- } else {
- ref =
- new ArrayTypeReference(
- identifierStack[localIdentifierPtr],
- dim,
- identifierPositionStack[localIdentifierPtr--]);
- ref.sourceEnd = endPosition;
- }
- } else {
- if (length < 0) { //flag for precompiled type reference on base types
- ref = TypeReference.baseTypeReference(-length, dim);
- ref.sourceStart = intStack[localIntPtr--];
- if (dim == 0) {
- ref.sourceEnd = intStack[localIntPtr--];
- } else {
- localIntPtr--;
- ref.sourceEnd = endPosition;
- }
- } else { //Qualified variable reference
- char[][] tokens = new char[length][];
- localIdentifierPtr -= length;
- long[] positions = new long[length];
- System.arraycopy(identifierStack, localIdentifierPtr + 1, tokens, 0, length);
- System.arraycopy(
- identifierPositionStack,
- localIdentifierPtr + 1,
- positions,
- 0,
- length);
- if (dim == 0) {
- ref = new QualifiedTypeReference(tokens, positions);
- } else {
- ref = new ArrayQualifiedTypeReference(tokens, dim, positions);
- ref.sourceEnd = endPosition;
- }
- }
- };
- return ref;
-}
private void visitIfNeeded(AbstractMethodDeclaration method) {
if (this.localDeclarationVisitor != null
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementRequestorAdapter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementRequestorAdapter.java
index aa78a8a..aeeed19 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementRequestorAdapter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementRequestorAdapter.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler;
import org.eclipse.jdt.core.compiler.IProblem;
@@ -198,7 +198,7 @@
/*
* @see ISourceElementRequestor#exitField(int)
*/
- public void exitField(int declarationEnd) {
+ public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
}
/*
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java
index f1fc826..d018e1e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -31,33 +31,41 @@
FlowContext flowContext,
FlowInfo flowInfo) {
- Constant opConstant = left.conditionalConstant();
- if (opConstant != NotAConstant) {
- if (opConstant.booleanValue() == true) {
- // TRUE && anything
- // need to be careful of scenario:
- // (x && y) && !z, if passing the left info to the right, it would be swapped by the !
- FlowInfo mergedInfo = left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits();
- mergedInfo = right.analyseCode(currentScope, flowContext, mergedInfo);
- mergedInitStateIndex =
- currentScope.methodScope().recordInitializationStates(mergedInfo);
- return mergedInfo;
- }
+ Constant cst = this.left.optimizedBooleanConstant();
+ boolean isLeftOptimizedTrue = cst != NotAConstant && cst.booleanValue() == true;
+ boolean isLeftOptimizedFalse = cst != NotAConstant && cst.booleanValue() == false;
+
+ if (isLeftOptimizedTrue) {
+ // TRUE && anything
+ // need to be careful of scenario:
+ // (x && y) && !z, if passing the left info to the right, it would be swapped by the !
+ FlowInfo mergedInfo = left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits();
+ mergedInfo = right.analyseCode(currentScope, flowContext, mergedInfo);
+ mergedInitStateIndex =
+ currentScope.methodScope().recordInitializationStates(mergedInfo);
+ return mergedInfo;
}
+
FlowInfo leftInfo = left.analyseCode(currentScope, flowContext, flowInfo);
// need to be careful of scenario:
// (x && y) && !z, if passing the left info to the right, it would be swapped by the !
FlowInfo rightInfo = leftInfo.initsWhenTrue().unconditionalInits().copy();
- if (opConstant != NotAConstant && opConstant.booleanValue() == false) rightInfo.markAsFakeReachable(true);
-
rightInitStateIndex =
currentScope.methodScope().recordInitializationStates(rightInfo);
+
+ int previousMode = rightInfo.reachMode();
+ if (isLeftOptimizedFalse){
+ rightInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
rightInfo = right.analyseCode(currentScope, flowContext, rightInfo);
- FlowInfo mergedInfo =
+ FlowInfo trueMergedInfo = rightInfo.initsWhenTrue().copy();
+ rightInfo.setReachMode(previousMode); // reset after trueMergedInfo got extracted
+
+ FlowInfo mergedInfo =
FlowInfo.conditional(
- rightInfo.initsWhenTrue().copy(),
+ trueMergedInfo,
leftInfo.initsWhenFalse().copy().unconditionalInits().mergedWith(
- rightInfo.initsWhenFalse().copy().unconditionalInits()));
+ rightInfo.initsWhenFalse().copy().unconditionalInits()));
mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(mergedInfo);
return mergedInfo;
@@ -110,7 +118,8 @@
if (valueRequired) {
codeStream.generateImplicitConversion(implicitConversion);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
}
/**
@@ -123,13 +132,13 @@
Label trueLabel,
Label falseLabel,
boolean valueRequired) {
- if ((constant != Constant.NotAConstant) && (constant.typeID() == T_boolean)) {
+
+ if (constant != Constant.NotAConstant) {
super.generateOptimizedBoolean(currentScope, codeStream, trueLabel, falseLabel, valueRequired);
return;
}
- int pc = codeStream.position;
Constant condConst;
- if ((condConst = left.conditionalConstant()) != NotAConstant) {
+ if ((condConst = left.optimizedBooleanConstant()) != NotAConstant) {
if (condConst.booleanValue() == true) {
// <something equivalent to true> && x
left.generateOptimizedBoolean(
@@ -169,8 +178,9 @@
}
}
}
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
if (mergedInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(
currentScope,
@@ -178,7 +188,7 @@
}
return;
}
- if ((condConst = right.conditionalConstant()) != NotAConstant) {
+ if ((condConst = right.optimizedBooleanConstant()) != NotAConstant) {
if (condConst.booleanValue() == true) {
// x && <something equivalent to true>
if ((bits & OnlyValueRequiredMASK) != 0) {
@@ -202,15 +212,17 @@
false);
} else {
// x && <something equivalent to false>
+ Label internalTrueLabel = new Label(codeStream);
left.generateOptimizedBoolean(
currentScope,
codeStream,
- trueLabel,
- falseLabel,
+ internalTrueLabel, // will be false in the end
+ null,
false);
if (rightInitStateIndex != -1) {
codeStream.addDefinitelyAssignedVariables(currentScope, rightInitStateIndex);
}
+ internalTrueLabel.place();
right.generateOptimizedBoolean(
currentScope,
codeStream,
@@ -227,8 +239,9 @@
}
}
}
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
if (mergedInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(
currentScope,
@@ -275,7 +288,6 @@
// no implicit fall through TRUE/FALSE --> should never occur
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
if (mergedInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(
currentScope,
@@ -294,4 +306,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
index 14ce0b4..e69c864 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractMethodDeclaration.java
@@ -1,20 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.internal.compiler.*;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext;
import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.codegen.*;
-import org.eclipse.jdt.internal.compiler.flow.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.*;
import org.eclipse.jdt.internal.compiler.parser.*;
@@ -38,7 +39,7 @@
public MethodBinding binding;
public boolean ignoreFurtherInvestigation = false;
public boolean needFreeReturn = false;
-
+
public int bodyStart;
public int bodyEnd = -1;
public CompilationResult compilationResult;
@@ -71,61 +72,9 @@
}
}
- public void analyseCode(
- ClassScope currentScope,
- FlowContext flowContext,
- FlowInfo flowInfo) {
+ public abstract void analyseCode(ClassScope scope, InitializationFlowContext initializationContext, FlowInfo info);
- // starting of the code analysis for methods
- if (ignoreFurtherInvestigation)
- return;
- try {
- if (binding == null)
- return;
- // may be in a non necessary <clinit> for innerclass with static final constant fields
- if (binding.isAbstract() || binding.isNative())
- return;
-
- ExceptionHandlingFlowContext methodContext =
- new ExceptionHandlingFlowContext(
- flowContext,
- this,
- binding.thrownExceptions,
- scope,
- FlowInfo.DeadEnd);
-
- // propagate to statements
- if (statements != null) {
- for (int i = 0, count = statements.length; i < count; i++) {
- Statement stat;
- if (!flowInfo.complainIfUnreachable((stat = statements[i]), scope)) {
- flowInfo = stat.analyseCode(scope, methodContext, flowInfo);
- }
- }
- }
- // check for missing returning path
- TypeBinding returnType = binding.returnType;
- if ((returnType == VoidBinding) || isAbstract()) {
- needFreeReturn =
- !((flowInfo == FlowInfo.DeadEnd) || flowInfo.isFakeReachable());
- } else {
- if (flowInfo != FlowInfo.DeadEnd) {
- // special test for empty methods that should return something
- if ((statements == null) && (returnType != VoidBinding)) {
- scope.problemReporter().shouldReturn(returnType, this);
- } else {
- scope.problemReporter().shouldReturn(
- returnType,
- statements[statements.length - 1]);
- }
- }
- }
- } catch (AbortMethod e) {
- this.ignoreFurtherInvestigation = true;
- }
- }
-
- /**
+ /**
* Bind and add argument's binding into the scope of the method
*/
public void bindArguments() {
@@ -150,9 +99,34 @@
if (this.thrownExceptions != null
&& this.binding != null
&& this.binding.thrownExceptions != null) {
+ int thrownExceptionLength = this.thrownExceptions.length;
int length = this.binding.thrownExceptions.length;
- for (int i = 0; i < length; i++) {
- this.thrownExceptions[i].binding = this.binding.thrownExceptions[i];
+ if (length == thrownExceptionLength) {
+ for (int i = 0; i < length; i++) {
+ this.thrownExceptions[i].resolvedType = this.binding.thrownExceptions[i];
+ }
+ } else {
+ int bindingIndex = 0;
+ for (int i = 0; i < thrownExceptionLength && bindingIndex < length; i++) {
+ TypeReference thrownException = this.thrownExceptions[i];
+ ReferenceBinding thrownExceptionBinding = this.binding.thrownExceptions[bindingIndex];
+ char[][] bindingCompoundName = thrownExceptionBinding.compoundName;
+ if (thrownException instanceof SingleTypeReference) {
+ // single type reference
+ int lengthName = bindingCompoundName.length;
+ char[] thrownExceptionTypeName = thrownException.getTypeName()[0];
+ if (CharOperation.equals(thrownExceptionTypeName, bindingCompoundName[lengthName - 1])) {
+ thrownException.resolvedType = thrownExceptionBinding;
+ bindingIndex++;
+ }
+ } else {
+ // qualified type reference
+ if (CharOperation.equals(thrownException.getTypeName(), bindingCompoundName)) {
+ thrownException.resolvedType = thrownExceptionBinding;
+ bindingIndex++;
+ }
+ }
+ }
}
}
}
@@ -198,7 +172,7 @@
} catch (AbortMethod e2) {
int problemsLength;
IProblem[] problems =
- scope.referenceCompilationUnit().compilationResult.getProblems();
+ scope.referenceCompilationUnit().compilationResult.getAllProblems();
IProblem[] problemsCopy = new IProblem[problemsLength = problems.length];
System.arraycopy(problems, 0, problemsCopy, 0, problemsLength);
classFile.addProblemMethod(this, binding, problemsCopy, problemResetPC);
@@ -207,7 +181,7 @@
// produce a problem method accounting for this fatal error
int problemsLength;
IProblem[] problems =
- scope.referenceCompilationUnit().compilationResult.getProblems();
+ scope.referenceCompilationUnit().compilationResult.getAllProblems();
IProblem[] problemsCopy = new IProblem[problemsLength = problems.length];
System.arraycopy(problems, 0, problemsCopy, 0, problemsLength);
classFile.addProblemMethod(this, binding, problemsCopy, problemResetPC);
@@ -226,7 +200,7 @@
CodeStream codeStream = classFile.codeStream;
codeStream.reset(this, classFile);
// initialize local positions
- scope.computeLocalVariablePositions(binding.isStatic() ? 0 : 1, codeStream);
+ this.scope.computeLocalVariablePositions(binding.isStatic() ? 0 : 1, codeStream);
// arguments initialization for local variable debug attributes
if (arguments != null) {
@@ -240,14 +214,16 @@
for (int i = 0, max = statements.length; i < max; i++)
statements[i].generateCode(scope, codeStream);
}
- if (needFreeReturn) {
+ if (this.needFreeReturn) {
codeStream.return_();
}
// local variable attributes
codeStream.exitUserScope(scope);
- codeStream.recordPositionsFrom(0, this.bodyEnd);
+ codeStream.recordPositionsFrom(0, this.declarationSourceEnd);
classFile.completeCodeAttribute(codeAttributeOffset);
attributeNumber++;
+ } else {
+ checkArgumentsSize();
}
classFile.completeMethodInfo(methodAttributeOffset, attributeNumber);
@@ -257,6 +233,22 @@
}
}
+ private void checkArgumentsSize() {
+ TypeBinding[] parameters = binding.parameters;
+ int size = 1; // an abstact method or a native method cannot be static
+ for (int i = 0, max = parameters.length; i < max; i++) {
+ TypeBinding parameter = parameters[i];
+ if (parameter == LongBinding || parameter == DoubleBinding) {
+ size += 2;
+ } else {
+ size++;
+ }
+ if (size > 0xFF) {
+ scope.problemReporter().noMoreAvailableSpaceForArgument(scope.locals[i], scope.locals[i].declaration);
+ }
+ }
+ }
+
public boolean hasErrors() {
return this.ignoreFurtherInvestigation;
}
@@ -318,13 +310,13 @@
try {
bindArguments();
bindThrownExceptions();
- resolveStatements(upperScope);
+ resolveStatements();
} catch (AbortMethod e) { // ========= abort on fatal error =============
this.ignoreFurtherInvestigation = true;
}
}
- public void resolveStatements(ClassScope upperScope) {
+ public void resolveStatements() {
if (statements != null) {
int i = 0, length = statements.length;
@@ -395,4 +387,4 @@
IAbstractSyntaxTreeVisitor visitor,
ClassScope classScope) {
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java
index 451acfc..65cddf5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AbstractVariableDeclaration.java
@@ -1,15 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+
public abstract class AbstractVariableDeclaration extends Statement {
public int modifiers;
@@ -21,10 +25,17 @@
public int declarationSourceStart;
public int declarationSourceEnd;
public int modifiersSourceStart;
- public AbstractVariableDeclaration() {
- }
- public abstract String name();
+ public AbstractVariableDeclaration() {}
+
+ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
+ return flowInfo;
+ }
+
+ public abstract String name();
+
+ public void resolve(BlockScope scope) {}
+
public String toString(int tab) {
String s = tabString(tab);
@@ -36,4 +47,4 @@
s += " = " + initialization.toStringExpression(tab); //$NON-NLS-1$
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
index 4516cbb..14b9884 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -26,7 +26,6 @@
MethodBinding syntheticAccessor;
public AllocationExpression() {
- super();
}
public FlowInfo analyseCode(
@@ -34,7 +33,8 @@
FlowContext flowContext,
FlowInfo flowInfo) {
- // must verify that exceptions potentially thrown by this expression are caught in the method
+ // check captured variables are initialized in current context (26134)
+ checkCapturedLocalInitializationIfNecessary(this.binding.declaringClass, currentScope, flowInfo);
// process arguments
if (arguments != null) {
@@ -47,7 +47,7 @@
}
// record some dependency information for exception types
ReferenceBinding[] thrownExceptions;
- if (((thrownExceptions = binding.thrownExceptions).length) != 0) {
+ if (((thrownExceptions = this.binding.thrownExceptions).length) != 0) {
// check exception handling
flowContext.checkExceptionHandlers(
thrownExceptions,
@@ -57,9 +57,30 @@
}
manageEnclosingInstanceAccessIfNecessary(currentScope);
manageSyntheticAccessIfNecessary(currentScope);
+
return flowInfo;
}
+ public void checkCapturedLocalInitializationIfNecessary(ReferenceBinding checkedType, BlockScope currentScope, FlowInfo flowInfo) {
+
+ if (checkedType.isLocalType()
+ && !checkedType.isAnonymousType()
+ && !currentScope.isDefinedInType(checkedType)) { // only check external allocations
+ NestedTypeBinding nestedType = (NestedTypeBinding) checkedType;
+ SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables();
+ if (syntheticArguments != null)
+ for (int i = 0, count = syntheticArguments.length; i < count; i++){
+ SyntheticArgumentBinding syntheticArgument = syntheticArguments[i];
+ LocalVariableBinding targetLocal;
+ if ((targetLocal = syntheticArgument.actualOuterLocalVariable) == null) continue;
+ if (targetLocal.declaration != null && !flowInfo.isDefinitelyAssigned(targetLocal)){
+ currentScope.problemReporter().uninitializedLocalVariable(targetLocal, this);
+ }
+ }
+
+ }
+ }
+
public Expression enclosingInstance() {
return null;
}
@@ -79,9 +100,9 @@
// better highlight for allocation: display the type individually
codeStream.recordPositionsFrom(pc, type.sourceStart);
- // handling innerclass instance allocation
+ // handling innerclass instance allocation - enclosing instance arguments
if (allocatedType.isNestedType()) {
- codeStream.generateSyntheticArgumentValues(
+ codeStream.generateSyntheticEnclosingInstanceValues(
currentScope,
allocatedType,
enclosingInstance(),
@@ -93,6 +114,13 @@
arguments[i].generateCode(currentScope, codeStream, true);
}
}
+ // handling innerclass instance allocation - outer local arguments
+ if (allocatedType.isNestedType()) {
+ codeStream.generateSyntheticOuterArgumentValues(
+ currentScope,
+ allocatedType,
+ this);
+ }
// invoke constructor
if (syntheticAccessor == null) {
codeStream.invokespecial(binding);
@@ -135,14 +163,11 @@
&& currentScope.enclosingSourceType().isLocalType()) {
if (allocatedType.isLocalType()) {
- ((LocalTypeBinding) allocatedType).addInnerEmulationDependent(
- currentScope,
- false,
- false);
+ ((LocalTypeBinding) allocatedType).addInnerEmulationDependent(currentScope, false);
// request cascade of accesses
} else {
// locally propagate, since we already now the desired shape for sure
- currentScope.propagateInnerEmulation(allocatedType, false, false);
+ currentScope.propagateInnerEmulation(allocatedType, false);
// request cascade of accesses
}
}
@@ -161,7 +186,7 @@
// constructor will not be dumped as private, no emulation required thus
} else {
syntheticAccessor =
- ((SourceTypeBinding) binding.declaringClass).addSyntheticMethod(binding);
+ ((SourceTypeBinding) binding.declaringClass).addSyntheticMethod(binding, isSuperAccess());
currentScope.problemReporter().needToEmulateMethodAccess(binding, this);
}
}
@@ -171,7 +196,7 @@
// Propagate the type checking to the arguments, and check if the constructor is defined.
constant = NotAConstant;
- TypeBinding typeBinding = type.resolveType(scope);
+ this.resolvedType = type.resolveType(scope);
// will check for null after args are resolved
// buffering the arguments' types
@@ -184,22 +209,22 @@
if ((argumentTypes[i] = arguments[i].resolveType(scope)) == null)
argHasError = true;
if (argHasError)
- return typeBinding;
+ return this.resolvedType;
}
- if (typeBinding == null)
+ if (this.resolvedType == null)
return null;
- if (!typeBinding.canBeInstantiated()) {
- scope.problemReporter().cannotInstantiate(type, typeBinding);
- return typeBinding;
+ if (!this.resolvedType.canBeInstantiated()) {
+ scope.problemReporter().cannotInstantiate(type, this.resolvedType);
+ return this.resolvedType;
}
- ReferenceBinding allocatedType = (ReferenceBinding) typeBinding;
+ ReferenceBinding allocatedType = (ReferenceBinding) this.resolvedType;
if (!(binding = scope.getConstructor(allocatedType, argumentTypes, this))
.isValidBinding()) {
if (binding.declaringClass == null)
binding.declaringClass = allocatedType;
scope.problemReporter().invalidConstructor(this, binding);
- return typeBinding;
+ return this.resolvedType;
}
if (isMethodUseDeprecated(binding, scope))
scope.problemReporter().deprecatedMethod(binding, this);
@@ -253,4 +278,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnonymousLocalTypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnonymousLocalTypeDeclaration.java
index b38ba89..4b05879 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnonymousLocalTypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AnonymousLocalTypeDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.CompilationResult;
@@ -27,7 +27,7 @@
}
// use a default name in order to th name lookup
- // to operate juat like a regular type (which has a name)
+ // to operate just like a regular type (which has a name)
//without checking systematically if the naem is null ....
public MethodBinding createsInternalConstructorWithBinding(MethodBinding inheritedConstructorBinding) {
@@ -52,8 +52,7 @@
}
//the super call inside the constructor
- cd.constructorCall =
- new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper);
+ cd.constructorCall = SuperReference.implicitSuperConstructorCall();
cd.constructorCall.sourceStart = sourceStart;
cd.constructorCall.sourceEnd = sourceEnd;
@@ -87,7 +86,7 @@
inheritedConstructorBinding.thrownExceptions, //exceptions
binding); //declaringClass
- cd.scope = new MethodScope(scope, this, true);
+ cd.scope = new MethodScope(scope, cd, true);
cd.bindArguments();
cd.constructorCall.resolve(cd.scope);
@@ -111,6 +110,10 @@
}
public void resolve(BlockScope scope) {
+ if (binding != null) {
+ // remember local types binding for innerclass emulation propagation
+ scope.referenceCompilationUnit().record((LocalTypeBinding)binding);
+ }
// scope and binding are provided in updateBindingSuperclass
resolve();
updateMaxFieldCount();
@@ -167,4 +170,4 @@
} catch (AbortType e) {
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
index a043362..f1a03b2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -18,6 +18,7 @@
public Argument(char[] name, long posNom, TypeReference tr, int modifiers) {
super(null, name, (int) (posNom >>> 32), (int) posNom);
+ this.declarationSourceEnd = (int) posNom;
this.modifiers = modifiers;
type = tr;
this.bits |= IsLocalDeclarationReachableMASK;
@@ -26,7 +27,7 @@
public void bind(MethodScope scope, TypeBinding typeBinding, boolean used) {
if (this.type != null)
- this.type.binding = typeBinding;
+ this.type.resolvedType = typeBinding;
// record the resolved type into the type reference
int modifierFlag = this.modifiers;
if ((this.binding = scope.duplicateName(this.name)) != null) {
@@ -40,7 +41,7 @@
if (typeBinding != null && isTypeUseDeprecated(typeBinding, scope))
scope.problemReporter().deprecatedType(typeBinding, this.type);
this.binding.declaration = this;
- this.binding.used = used;
+ this.binding.useFlag = used ? LocalVariableBinding.USED : LocalVariableBinding.UNUSED;
}
}
@@ -89,4 +90,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
index a1e958a..f4429a3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayAllocationExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -25,8 +25,6 @@
public Expression[] dimensions;
public ArrayInitializer initializer;
- public ArrayBinding arrayTb;
-
/**
* ArrayAllocationExpression constructor comment.
*/
@@ -60,7 +58,6 @@
boolean valueRequired) {
int pc = codeStream.position;
- ArrayBinding arrayBinding;
if (initializer != null) {
initializer.generateCode(currentScope, codeStream, valueRequired);
@@ -75,13 +72,12 @@
}
// Generate a sequence of bytecodes corresponding to an array allocation
- if ((arrayTb.isArrayType())
- && ((arrayBinding = (ArrayBinding) arrayTb).dimensions == 1)) {
+ if (this.resolvedType.dimensions() == 1) {
// Mono-dimensional array
- codeStream.newArray(currentScope, arrayBinding);
+ codeStream.newArray(currentScope, (ArrayBinding)this.resolvedType);
} else {
// Multi-dimensional array
- codeStream.multianewarray(arrayTb, nonNullDimensionsLength);
+ codeStream.multianewarray(this.resolvedType, nonNullDimensionsLength);
}
if (valueRequired) {
@@ -100,58 +96,60 @@
// only at the -end- like new int [4][][]. The parser allows new int[][4][]
// so this must be checked here......(this comes from a reduction to LL1 grammar)
- TypeBinding referenceTb = type.resolveType(scope);
+ TypeBinding referenceType = type.resolveType(scope);
+
// will check for null after dimensions are checked
constant = Constant.NotAConstant;
- if (referenceTb == VoidBinding) {
+ if (referenceType == VoidBinding) {
scope.problemReporter().cannotAllocateVoidArray(this);
- referenceTb = null; // will return below
+ referenceType = null;
}
// check the validity of the dimension syntax (and test for all null dimensions)
- int lengthDim = -1;
+ int explicitDimIndex = -1;
for (int i = dimensions.length; --i >= 0;) {
if (dimensions[i] != null) {
- if (lengthDim == -1)
- lengthDim = i;
- } else if (
- lengthDim != -1) {
+ if (explicitDimIndex < 0) explicitDimIndex = i;
+ } else if (explicitDimIndex> 0) {
// should not have an empty dimension before an non-empty one
scope.problemReporter().incorrectLocationForEmptyDimension(this, i);
- return null;
}
}
- if (referenceTb == null)
- return null;
- // lengthDim == -1 says if all dimensions are nulled
+ // explicitDimIndex < 0 says if all dimensions are nulled
// when an initializer is given, no dimension must be specified
if (initializer == null) {
- if (lengthDim == -1) {
+ if (explicitDimIndex < 0) {
scope.problemReporter().mustDefineDimensionsOrInitializer(this);
- return null;
}
- } else if (lengthDim != -1) {
+ } else if (explicitDimIndex >= 0) {
scope.problemReporter().cannotDefineDimensionsAndInitializer(this);
- return null;
}
// dimensions resolution
- for (int i = 0; i <= lengthDim; i++) {
- TypeBinding dimTb = dimensions[i].resolveTypeExpecting(scope, IntBinding);
- if (dimTb == null)
- return null;
- dimensions[i].implicitWidening(IntBinding, dimTb);
+ for (int i = 0; i <= explicitDimIndex; i++) {
+ if (dimensions[i] != null) {
+ TypeBinding dimensionType = dimensions[i].resolveTypeExpecting(scope, IntBinding);
+ if (dimensionType != null) {
+ dimensions[i].implicitWidening(IntBinding, dimensionType);
+ }
+ }
}
// building the array binding
- arrayTb = scope.createArray(referenceTb, dimensions.length);
+ if (referenceType != null) {
+ if (dimensions.length > 255) {
+ scope.problemReporter().tooManyDimensions(this);
+ }
+ this.resolvedType = scope.createArray(referenceType, dimensions.length);
- // check the initializer
- if (initializer != null)
- if ((initializer.resolveTypeExpecting(scope, arrayTb)) != null)
- initializer.binding = arrayTb;
- return arrayTb;
+ // check the initializer
+ if (initializer != null) {
+ if ((initializer.resolveTypeExpecting(scope, this.resolvedType)) != null)
+ initializer.binding = (ArrayBinding)this.resolvedType;
+ }
+ }
+ return this.resolvedType;
}
public String toStringExpression() {
@@ -182,4 +180,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
index 00e3a26..7c51b58 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java
@@ -1,17 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.flow.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
@@ -55,10 +54,18 @@
case T_short :
case T_byte :
case T_char :
- case T_float :
case T_long :
+ if (expr.constant.longValue() != 0) {
+ codeStream.dup();
+ codeStream.generateInlinedValue(i);
+ expr.generateCode(currentScope, codeStream, true);
+ codeStream.arrayAtPut(elementsTypeID, false);
+ }
+ break;
+ case T_float :
case T_double :
- if (expr.constant.doubleValue() != 0) {
+ double constantValue = expr.constant.doubleValue();
+ if (constantValue == -0.0 || constantValue != 0) {
codeStream.dup();
codeStream.generateInlinedValue(i);
expr.generateCode(currentScope, codeStream, true);
@@ -74,7 +81,7 @@
}
break;
default :
- if (expr.constant != NullConstant.Default) {
+ if (!(expr instanceof NullLiteral)) {
codeStream.dup();
codeStream.generateInlinedValue(i);
expr.generateCode(currentScope, codeStream, true);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
index 58f90e2..254e44e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayQualifiedTypeReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -27,8 +27,11 @@
return dimensions;
}
public TypeBinding getTypeBinding(Scope scope) {
- if (binding != null)
- return binding;
+ if (this.resolvedType != null)
+ return this.resolvedType;
+ if (dimensions > 255) {
+ scope.problemReporter().tooManyDimensions(this);
+ }
return scope.createArray(scope.getType(tokens), dimensions);
}
public String toStringExpression(int tab){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java
index 96b54fe..677fe96 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -21,8 +21,6 @@
public Expression receiver;
public Expression position;
- public TypeBinding arrayElementBinding;
-
public ArrayReference(Expression rec, Expression pos) {
this.receiver = rec;
this.position = pos;
@@ -69,7 +67,7 @@
receiver.generateCode(currentScope, codeStream, true);
position.generateCode(currentScope, codeStream, true);
assignment.expression.generateCode(currentScope, codeStream, true);
- codeStream.arrayAtPut(arrayElementBinding.id, valueRequired);
+ codeStream.arrayAtPut(this.resolvedType.id, valueRequired);
if (valueRequired) {
codeStream.generateImplicitConversion(assignment.implicitConversion);
}
@@ -86,13 +84,13 @@
int pc = codeStream.position;
receiver.generateCode(currentScope, codeStream, true);
position.generateCode(currentScope, codeStream, true);
- codeStream.arrayAt(arrayElementBinding.id);
+ codeStream.arrayAt(this.resolvedType.id);
// Generating code for the potential runtime type checking
if (valueRequired) {
codeStream.generateImplicitConversion(implicitConversion);
} else {
- if (arrayElementBinding == LongBinding
- || arrayElementBinding == DoubleBinding) {
+ if (this.resolvedType == LongBinding
+ || this.resolvedType == DoubleBinding) {
codeStream.pop2();
} else {
codeStream.pop();
@@ -112,7 +110,7 @@
receiver.generateCode(currentScope, codeStream, true);
position.generateCode(currentScope, codeStream, true);
codeStream.dup2();
- codeStream.arrayAt(arrayElementBinding.id);
+ codeStream.arrayAt(this.resolvedType.id);
int operationTypeID;
if ((operationTypeID = implicitConversion >> 4) == T_String) {
codeStream.generateStringAppend(currentScope, null, expression);
@@ -130,7 +128,7 @@
// cast the value back to the array reference type
codeStream.generateImplicitConversion(assignmentImplicitConversion);
}
- codeStream.arrayAtPut(arrayElementBinding.id, valueRequired);
+ codeStream.arrayAtPut(this.resolvedType.id, valueRequired);
}
public void generatePostIncrement(
@@ -142,10 +140,10 @@
receiver.generateCode(currentScope, codeStream, true);
position.generateCode(currentScope, codeStream, true);
codeStream.dup2();
- codeStream.arrayAt(arrayElementBinding.id);
+ codeStream.arrayAt(this.resolvedType.id);
if (valueRequired) {
- if ((arrayElementBinding == LongBinding)
- || (arrayElementBinding == DoubleBinding)) {
+ if ((this.resolvedType == LongBinding)
+ || (this.resolvedType == DoubleBinding)) {
codeStream.dup2_x2();
} else {
codeStream.dup_x2();
@@ -154,27 +152,28 @@
codeStream.generateConstant(
postIncrement.expression.constant,
implicitConversion);
- codeStream.sendOperator(postIncrement.operator, arrayElementBinding.id);
+ codeStream.sendOperator(postIncrement.operator, this.resolvedType.id);
codeStream.generateImplicitConversion(
postIncrement.assignmentImplicitConversion);
- codeStream.arrayAtPut(arrayElementBinding.id, false);
+ codeStream.arrayAtPut(this.resolvedType.id, false);
}
public TypeBinding resolveType(BlockScope scope) {
constant = Constant.NotAConstant;
- TypeBinding arrayTb = receiver.resolveType(scope);
- if (arrayTb == null)
- return null;
- if (!arrayTb.isArrayType()) {
- scope.problemReporter().referenceMustBeArrayTypeAt(arrayTb, this);
- return null;
+ TypeBinding arrayType = receiver.resolveType(scope);
+ if (arrayType != null) {
+ if (arrayType.isArrayType()) {
+ this.resolvedType = ((ArrayBinding) arrayType).elementsType(scope);
+ } else {
+ scope.problemReporter().referenceMustBeArrayTypeAt(arrayType, this);
+ }
}
- TypeBinding positionTb = position.resolveTypeExpecting(scope, IntBinding);
- if (positionTb == null)
- return null;
- position.implicitWidening(IntBinding, positionTb);
- return arrayElementBinding = ((ArrayBinding) arrayTb).elementsType(scope);
+ TypeBinding positionType = position.resolveTypeExpecting(scope, IntBinding);
+ if (positionType != null) {
+ position.implicitWidening(IntBinding, positionType);
+ }
+ return this.resolvedType;
}
public String toStringExpression() {
@@ -191,4 +190,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
index 91c6f76..413d713 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayTypeReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -32,12 +32,15 @@
return dimensions;
}
public TypeBinding getTypeBinding(Scope scope) {
- if (binding != null)
- return binding;
+ if (this.resolvedType != null)
+ return this.resolvedType;
+ if (dimensions > 255) {
+ scope.problemReporter().tooManyDimensions(this);
+ }
return scope.createArray(scope.getType(token), dimensions);
+
}
public String toStringExpression(int tab){
- /* slow speed */
String s = super.toStringExpression(tab) ;
if (dimensions == 1 ) return s + "[]" ; //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
index 5a5a51e..65ebf9a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
@@ -1,18 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -47,36 +47,38 @@
FlowContext flowContext,
FlowInfo flowInfo) {
- Constant constant = assertExpression.constant;
- if (constant != NotAConstant && constant.booleanValue() == true) {
- return flowInfo;
- }
-
preAssertInitStateIndex = currentScope.methodScope().recordInitializationStates(flowInfo);
+
+ Constant cst = this.assertExpression.optimizedBooleanConstant();
+ boolean isOptimizedTrueAssertion = cst != NotAConstant && cst.booleanValue() == true;
+ boolean isOptimizedFalseAssertion = cst != NotAConstant && cst.booleanValue() == false;
+
FlowInfo assertInfo = flowInfo.copy();
-
+ if (isOptimizedTrueAssertion) {
+ assertInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
+ assertInfo = assertExpression.analyseCode(currentScope, flowContext, assertInfo).unconditionalInits();
+
if (exceptionArgument != null) {
- assertInfo = exceptionArgument.analyseCode(
- currentScope,
- flowContext,
- assertExpression.analyseCode(currentScope, flowContext, assertInfo).unconditionalInits())
- .unconditionalInits();
- } else {
- assertInfo = assertExpression.analyseCode(currentScope, flowContext, assertInfo).unconditionalInits();
+ // only gets evaluated when escaping - results are not taken into account
+ FlowInfo exceptionInfo = exceptionArgument.analyseCode(currentScope, flowContext, assertInfo.copy());
+
+ if (!isOptimizedTrueAssertion){
+ flowContext.checkExceptionHandlers(
+ currentScope.getJavaLangAssertionError(),
+ this,
+ exceptionInfo,
+ currentScope);
+ }
}
- // assertion might throw AssertionError (unchecked), which can have consequences in term of
- // definitely assigned variables (depending on caught exception in the context)
- // DISABLED - AssertionError is unchecked, try statements are already protected against these.
- //flowContext.checkExceptionHandlers(currentScope.getJavaLangAssertionError(), this, assertInfo, currentScope);
-
- // only retain potential initializations
- flowInfo.addPotentialInitializationsFrom(assertInfo.unconditionalInits());
-
// add the assert support in the clinit
manageSyntheticAccessIfNecessary(currentScope);
-
- return flowInfo;
+ if (isOptimizedFalseAssertion) {
+ return flowInfo; // if assertions are enabled, the following code will be unreachable
+ } else {
+ return flowInfo.mergedWith(assertInfo.unconditionalInits());
+ }
}
public void generateCode(BlockScope currentScope, CodeStream codeStream) {
@@ -139,13 +141,19 @@
public void manageSyntheticAccessIfNecessary(BlockScope currentScope) {
- // need assertion flag: $assertionsDisabled on outer most source type
- ClassScope outerMostClassScope = currentScope.outerMostClassScope();
- SourceTypeBinding sourceTypeBinding = outerMostClassScope.enclosingSourceType();
- this.assertionSyntheticFieldBinding = sourceTypeBinding.addSyntheticField(this, currentScope);
+ // need assertion flag: $assertionsDisabled on outer most source clas
+ // (in case of static member of interface, will use the outermost static member - bug 22334)
+ SourceTypeBinding outerMostClass = currentScope.enclosingSourceType();
+ while (outerMostClass.isLocalType()){
+ ReferenceBinding enclosing = outerMostClass.enclosingType();
+ if (enclosing == null || enclosing.isInterface()) break;
+ outerMostClass = (SourceTypeBinding) enclosing;
+ }
+
+ this.assertionSyntheticFieldBinding = outerMostClass.addSyntheticField(this, currentScope);
// find <clinit> and enable assertion support
- TypeDeclaration typeDeclaration = outerMostClassScope.referenceType();
+ TypeDeclaration typeDeclaration = outerMostClass.scope.referenceType();
AbstractMethodDeclaration[] methods = typeDeclaration.methods;
for (int i = 0, max = methods.length; i < max; i++) {
AbstractMethodDeclaration method = methods[i];
@@ -159,7 +167,7 @@
public String toString(int tab) {
StringBuffer buffer = new StringBuffer(tabString(tab));
- buffer.append("assert"); //$NON-NLS-1$
+ buffer.append("assert "); //$NON-NLS-1$
buffer.append(this.assertExpression);
if (this.exceptionArgument != null) {
buffer.append(":"); //$NON-NLS-1$
@@ -169,4 +177,4 @@
return buffer.toString();
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
index bbfc9a1..8bdbbda 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
@@ -1,13 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ * Genady Beriozkin - added support for reporting assignment with no effect
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -17,15 +18,16 @@
public class Assignment extends Expression {
- public Reference lhs;
+ public Expression lhs;
public Expression expression;
- public TypeBinding lhsType;
-
+
public Assignment(Expression lhs, Expression expression, int sourceEnd) {
//lhs is always a reference by construction ,
//but is build as an expression ==> the checkcast cannot fail
- this.lhs = (Reference) lhs;
+ this.lhs = lhs;
+ lhs.bits |= IsStrictlyAssignedMASK; // tag lhs as assigned
+
this.expression = expression;
this.sourceStart = lhs.sourceStart;
@@ -40,11 +42,20 @@
// a field reference, a blank final field reference, a field of an enclosing instance or
// just a local variable.
- return lhs
+ return ((Reference) lhs)
.analyseAssignment(currentScope, flowContext, flowInfo, this, false)
.unconditionalInits();
}
+ void checkAssignmentEffect(BlockScope scope) {
+
+ Binding left = getDirectBinding(this.lhs);
+ if (left != null && left == getDirectBinding(this.expression)) {
+ scope.problemReporter().assignmentHasNoEffect(this, left.shortReadableName());
+ this.bits |= IsAssignmentWithNoEffectMASK; // record assignment has no effect
+ }
+ }
+
public void generateCode(
BlockScope currentScope,
CodeStream codeStream,
@@ -55,34 +66,57 @@
// just a local variable.
int pc = codeStream.position;
- lhs.generateAssignment(currentScope, codeStream, this, valueRequired);
- // variable may have been optimized out
- // the lhs is responsible to perform the implicitConversion generation for the assignment since optimized for unused local assignment.
+ if ((this.bits & IsAssignmentWithNoEffectMASK) != 0) {
+ if (valueRequired) {
+ this.expression.generateCode(currentScope, codeStream, true);
+ }
+ } else {
+ ((Reference) lhs).generateAssignment(currentScope, codeStream, this, valueRequired);
+ // variable may have been optimized out
+ // the lhs is responsible to perform the implicitConversion generation for the assignment since optimized for unused local assignment.
+ }
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
+ Binding getDirectBinding(Expression someExpression) {
+ if (someExpression instanceof SingleNameReference) {
+ return ((SingleNameReference)someExpression).binding;
+ } else if (someExpression instanceof FieldReference) {
+ FieldReference fieldRef = (FieldReference)someExpression;
+ if (fieldRef.receiver.isThis() && !(fieldRef.receiver instanceof QualifiedThisReference)) {
+ return fieldRef.binding;
+ }
+ }
+ return null;
+ }
+
public TypeBinding resolveType(BlockScope scope) {
// due to syntax lhs may be only a NameReference, a FieldReference or an ArrayReference
constant = NotAConstant;
- this.lhsType = lhs.resolveType(scope);
- TypeBinding expressionTb = expression.resolveType(scope);
- if (this.lhsType == null || expressionTb == null)
+ if (!(this.lhs instanceof Reference)) {
+ scope.problemReporter().expressionShouldBeAVariable(this.lhs);
+ }
+ this.resolvedType = lhs.resolveType(scope); // expressionType contains the assignment type (lhs Type)
+ TypeBinding rhsType = expression.resolveType(scope);
+ if (this.resolvedType == null || rhsType == null) {
return null;
-
+ }
+ checkAssignmentEffect(scope);
+
// Compile-time conversion of base-types : implicit narrowing integer into byte/short/character
// may require to widen the rhs expression at runtime
- if ((expression.isConstantValueOfTypeAssignableToType(expressionTb, this.lhsType)
- || (this.lhsType.isBaseType() && BaseTypeBinding.isWidening(this.lhsType.id, expressionTb.id)))
- || (scope.areTypesCompatible(expressionTb, this.lhsType))) {
- expression.implicitWidening(this.lhsType, expressionTb);
- return this.lhsType;
+ if ((expression.isConstantValueOfTypeAssignableToType(rhsType, this.resolvedType)
+ || (this.resolvedType.isBaseType() && BaseTypeBinding.isWidening(this.resolvedType.id, rhsType.id)))
+ || rhsType.isCompatibleWith(this.resolvedType)) {
+ expression.implicitWidening(this.resolvedType, rhsType);
+ return this.resolvedType;
}
scope.problemReporter().typeMismatchErrorActualTypeExpectedType(
expression,
- expressionTb,
- this.lhsType);
- return null;
+ rhsType,
+ this.resolvedType);
+ return this.resolvedType;
}
public String toString(int tab) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AstNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AstNode.java
index c7eb82a..76a45e3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AstNode.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AstNode.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.impl.*;
@@ -21,76 +21,82 @@
//some global provision for the hierarchy
public final static Constant NotAConstant = Constant.NotAConstant;
- // storage for internal flags (32 bits)
- public int bits = IsReachableMASK; // reachable by default
+ // storage for internal flags (32 bits) BIT USAGE
+ public final static int Bit1 = 0x1; // return type (operators) | name reference kind (name ref) | add assertion (type decl)
+ public final static int Bit2 = 0x2; // return type (operators) | name reference kind (name ref) | has local type (type, method, field decl)
+ public final static int Bit3 = 0x4; // return type (operators) | name reference kind (name ref) | implicit this (this ref)
+ public final static int Bit4 = 0x8; // return type (operators) | first assignment to local (local decl)
+ public final static int Bit5 = 0x10; // value for return (binary expression) |
+ public final static int Bit6 = 0x20; // depth (name ref, msg) | only value required (binary expression)
+ public final static int Bit7 = 0x40; // depth (name ref, msg) | operator (operators)
+ public final static int Bit8 = 0x80; // depth (name ref, msg) | operator (operators)
+ public final static int Bit9 = 0x100; // depth (name ref, msg) | operator (operators)
+ public final static int Bit10= 0x200; // depth (name ref, msg) | operator (operators)
+ public final static int Bit11 = 0x400; // depth (name ref, msg) | operator (operators)
+ public final static int Bit12 = 0x800; // depth (name ref, msg) | operator (operators)
+ public final static int Bit13 = 0x1000; // depth (name ref, msg)
+ public final static int Bit14 = 0x2000; // assigned (reference lhs)
+ public final static int Bit15 = 0x4000;
+ public final static int Bit16 = 0x8000;
+ public final static int Bit17 = 0x10000;
+ public final static int Bit18 = 0x20000;
+ public final static int Bit19 = 0x40000;
+ public final static int Bit20 = 0x80000;
+ public final static int Bit21 = 0x100000;
+ public final static int Bit22 = 0x200000; // parenthesis count (expression)
+ public final static int Bit23 = 0x400000; // parenthesis count (expression)
+ public final static int Bit24 = 0x800000; // parenthesis count (expression)
+ public final static int Bit25 = 0x1000000; // parenthesis count (expression)
+ public final static int Bit26 = 0x2000000; // parenthesis count (expression)
+ public final static int Bit27 = 0x4000000; // parenthesis count (expression)
+ public final static int Bit28 = 0x8000000; // parenthesis count (expression)
+ public final static int Bit29 = 0x10000000; // parenthesis count (expression)
+ public final static int Bit30 = 0x20000000; // assignment with no effect (assignment)
+ public final static int Bit31 = 0x40000000; // local declaration reachable (local decl)
+ public final static int Bit32 = 0x80000000; // reachable (statement)
- // for operators only
- // Reach . . . . . . . . . . . . . . . . . O O O O O O V VrR R R R
- public static final int ReturnTypeIDMASK = 15; // 4 lower bits for operators
- public static final int ValueForReturnMASK = 16; // for binary expressions
- public static final int OnlyValueRequiredMASK = 32; // for binary expressions
- public static final int OperatorSHIFT = 6;
- public static final int OperatorMASK = 63 << OperatorSHIFT;
+ public int bits = IsReachableMASK; // reachable by default
- // for name references only
- // Reach . . . . . . . . . . . . . . . . D D D D D D D D VrF R R R
- public static final int RestrictiveFlagMASK = 7;
- // 3 lower bits for name references
- public static final int FirstAssignmentToLocalMASK = 8;
+ // for operators
+ public static final int ReturnTypeIDMASK = Bit1|Bit2|Bit3|Bit4;
+ public static final int OperatorSHIFT = 6; // Bit7 -> Bit12
+ public static final int OperatorMASK = Bit7|Bit8|Bit9|Bit10|Bit11|Bit12; // 6 bits for operator ID
+
+ // for binary expressions
+ public static final int ValueForReturnMASK = Bit5;
+ public static final int OnlyValueRequiredMASK = Bit6;
+
+ // for name references
+ public static final int RestrictiveFlagMASK = Bit1|Bit2|Bit3;
+ public static final int FirstAssignmentToLocalMASK = Bit4;
+
+ // for this reference
+ public static final int IsImplicitThisMask = Bit3;
+
// for single name references
- public static final int DepthSHIFT = 5;
- public static final int DepthMASK = 0xFF << DepthSHIFT;
- // 8 bits for actual depth value (max. 255)
+ public static final int DepthSHIFT = 5; // Bit6 -> Bit13
+ public static final int DepthMASK = Bit6|Bit7|Bit8|Bit9|Bit10|Bit11|Bit12|Bit13; // 8 bits for actual depth value (max. 255)
- // for statements only
- public static final int IsReachableMASK = 0x80000000; // highest bit
- public static final int IsLocalDeclarationReachableMASK = 0x40000000; // below highest bit
+ // for statements
+ public static final int IsReachableMASK = Bit32;
+ public static final int IsLocalDeclarationReachableMASK = Bit31;
- // for type declaration only
- public static final int AddAssertionMASK = 1; // lowest bit
+ // for type declaration
+ public static final int AddAssertionMASK = Bit1;
- // for type, method and field declarations only
- public static final int HasLocalTypeMASK = 2;
- // cannot conflict with AddAssertionMASK
+ // for type, method and field declarations
+ public static final int HasLocalTypeMASK = Bit2; // cannot conflict with AddAssertionMASK
- /*
- public final static int BitMask1= 0x1; // decimal 1
- public final static int BitMask2= 0x2; // decimal 2
- public final static int BitMask3= 0x4; // decimal 4
- public final static int BitMask4= 0x8; // decimal 8
- public final static int BitMask5= 0x10; // decimal 16
- public final static int BitMask6= 0x20; // decimal 32
- public final static int BitMask7= 0x40; // decimal 64
- public final static int BitMask8= 0x80; // decimal 128
- public final static int BitMask9= 0x100; // decimal 256
- public final static int BitMask10= 0x200; // decimal 512
- public final static int BitMask11= 0x400; // decimal 1024
- public final static int BitMask12= 0x800; // decimal 2048
- public final static int BitMask13= 0x1000; // decimal 4096
- public final static int BitMask14= 0x2000; // decimal 8192
- public final static int BitMask15= 0x4000; // decimal 16384
- public final static int BitMask16= 0x8000; // decimal 32768
- public final static int BitMask17= 0x10000; // decimal 65536
- public final static int BitMask18= 0x20000; // decimal 131072
- public final static int BitMask19= 0x40000; // decimal 262144
- public final static int BitMask20= 0x80000; // decimal 524288
- public final static int BitMask21= 0x100000; // decimal 1048576
- public final static int BitMask22= 0x200000; // decimal 2097152
- public final static int BitMask23= 0x400000; // decimal 4194304
- public final static int BitMask24= 0x800000; // decimal 8388608
- public final static int BitMask25= 0x1000000; // decimal 16777216
- public final static int BitMask26= 0x2000000; // decimal 33554432
- public final static int BitMask27= 0x4000000; // decimal 67108864
- public final static int BitMask28= 0x8000000; // decimal 134217728
- public final static int BitMask29= 0x10000000; // decimal 268435456
- public final static int BitMask30= 0x20000000; // decimal 536870912
- public final static int BitMask31= 0x40000000; // decimal 1073741824
- public final static int BitMask32= 0x80000000; // decimal 2147483648
- */
+ // for expression
+ public static final int ParenthesizedSHIFT = 21; // Bit22 -> Bit29
+ public static final int ParenthesizedMASK = Bit22|Bit23|Bit24|Bit25|Bit26|Bit27|Bit28|Bit29; // 8 bits for parenthesis count value (max. 255)
- /**
- * AstNode constructor comment.
- */
+ // for assignment
+ public static final int IsAssignmentWithNoEffectMASK = Bit30;
+
+ // for references on lhs of assignment (set only for true assignments, as opposed to compound ones)
+ public static final int IsStrictlyAssignedMASK = Bit14;
+
public AstNode() {
super();
@@ -109,16 +115,44 @@
*/
public final boolean isFieldUseDeprecated(FieldBinding field, Scope scope) {
- return field.isViewedAsDeprecated()
- && !scope.isDefinedInSameUnit(field.declaringClass);
+ if (field.isPrivate() && !scope.isDefinedInField(field)) {
+ // ignore cases where field is used from within inside itself
+ field.modifiers |= AccPrivateUsed;
+ }
+
+ if (!field.isViewedAsDeprecated()) return false;
+
+ // inside same unit - no report
+ if (scope.isDefinedInSameUnit(field.declaringClass)) return false;
+
+ // if context is deprecated, may avoid reporting
+ if (!scope.environment().options.reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false;
+ return true;
}
+ public boolean isImplicitThis() {
+
+ return false;
+ }
+
/* Answer true if the method use is considered deprecated.
* An access in the same compilation unit is allowed.
*/
public final boolean isMethodUseDeprecated(MethodBinding method, Scope scope) {
- return method.isViewedAsDeprecated()
- && !scope.isDefinedInSameUnit(method.declaringClass);
+
+ if (method.isPrivate() && !scope.isDefinedInMethod(method)) {
+ // ignore cases where method is used from within inside itself (e.g. direct recursions)
+ method.modifiers |= AccPrivateUsed;
+ }
+
+ if (!method.isViewedAsDeprecated()) return false;
+
+ // inside same unit - no report
+ if (scope.isDefinedInSameUnit(method.declaringClass)) return false;
+
+ // if context is deprecated, may avoid reporting
+ if (!scope.environment().options.reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false;
+ return true;
}
public boolean isSuper() {
@@ -142,7 +176,20 @@
return false;
ReferenceBinding refType = (ReferenceBinding) type;
- return refType.isViewedAsDeprecated() && !scope.isDefinedInSameUnit(refType);
+
+ if (refType.isPrivate() && !scope.isDefinedInType(refType)) {
+ // ignore cases where type is used from within inside itself
+ refType.modifiers |= AccPrivateUsed;
+ }
+
+ if (!refType.isViewedAsDeprecated()) return false;
+
+ // inside same unit - no report
+ if (scope.isDefinedInSameUnit(refType)) return false;
+
+ // if context is deprecated, may avoid reporting
+ if (!scope.environment().options.reportDeprecationInsideDeprecatedCode && scope.isInsideDeprecatedCode()) return false;
+ return true;
}
public static String modifiersString(int modifiers) {
@@ -205,4 +252,4 @@
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
index 2e38d82..c047dfb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BinaryExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -46,34 +46,34 @@
public void computeConstant(BlockScope scope, int leftId, int rightId) {
//compute the constant when valid
- if ((left.constant != Constant.NotAConstant)
- && (right.constant != Constant.NotAConstant)) {
+ if ((this.left.constant != Constant.NotAConstant)
+ && (this.right.constant != Constant.NotAConstant)) {
try {
- constant =
+ this.constant =
Constant.computeConstantOperation(
- left.constant,
+ this.left.constant,
leftId,
- (bits & OperatorMASK) >> OperatorSHIFT,
- right.constant,
+ (this.bits & OperatorMASK) >> OperatorSHIFT,
+ this.right.constant,
rightId);
} catch (ArithmeticException e) {
- constant = Constant.NotAConstant;
+ this.constant = Constant.NotAConstant;
// 1.2 no longer throws an exception at compile-time
//scope.problemReporter().compileTimeConstantThrowsArithmeticException(this);
}
} else {
- constant = Constant.NotAConstant;
+ this.constant = Constant.NotAConstant;
//add some work for the boolean operators & |
- optimizedBooleanConstant(
+ this.optimizedBooleanConstant(
leftId,
- (bits & OperatorMASK) >> OperatorSHIFT,
+ (this.bits & OperatorMASK) >> OperatorSHIFT,
rightId);
}
}
- public Constant conditionalConstant() {
+ public Constant optimizedBooleanConstant() {
- return optimizedBooleanConstant == null ? constant : optimizedBooleanConstant;
+ return this.optimizedBooleanConstant == null ? this.constant : this.optimizedBooleanConstant;
}
/**
@@ -699,7 +699,6 @@
Label falseLabel,
boolean valueRequired) {
- int pc = codeStream.position;
int promotedTypeID = left.implicitConversion >> 4;
// both sides got promoted in the same way
if (promotedTypeID == T_int) {
@@ -721,7 +720,8 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
// x > 0
@@ -742,7 +742,8 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
}
@@ -769,7 +770,8 @@
codeStream.dcmpl();
codeStream.ifgt(trueLabel);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
} else {
@@ -791,7 +793,8 @@
codeStream.dcmpl();
codeStream.ifle(falseLabel);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
} else {
// no implicit fall through TRUE/FALSE --> should never occur
@@ -810,7 +813,6 @@
Label falseLabel,
boolean valueRequired) {
- int pc = codeStream.position;
int promotedTypeID = left.implicitConversion >> 4;
// both sides got promoted in the same way
if (promotedTypeID == T_int) {
@@ -832,7 +834,8 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
// x >= 0
@@ -853,7 +856,8 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
}
@@ -880,7 +884,8 @@
codeStream.dcmpl();
codeStream.ifge(trueLabel);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
} else {
@@ -902,7 +907,8 @@
codeStream.dcmpl();
codeStream.iflt(falseLabel);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
} else {
// no implicit fall through TRUE/FALSE --> should never occur
@@ -921,7 +927,6 @@
Label falseLabel,
boolean valueRequired) {
- int pc = codeStream.position;
int promotedTypeID = left.implicitConversion >> 4;
// both sides got promoted in the same way
if (promotedTypeID == T_int) {
@@ -943,7 +948,7 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
// x < 0
@@ -964,7 +969,7 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
}
@@ -991,7 +996,7 @@
codeStream.dcmpg();
codeStream.iflt(trueLabel);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
} else {
@@ -1013,7 +1018,7 @@
codeStream.dcmpg();
codeStream.ifge(falseLabel);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
} else {
// no implicit fall through TRUE/FALSE --> should never occur
@@ -1032,7 +1037,6 @@
Label falseLabel,
boolean valueRequired) {
- int pc = codeStream.position;
int promotedTypeID = left.implicitConversion >> 4;
// both sides got promoted in the same way
if (promotedTypeID == T_int) {
@@ -1054,7 +1058,8 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
// x <= 0
@@ -1075,7 +1080,8 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
}
@@ -1102,7 +1108,8 @@
codeStream.dcmpg();
codeStream.ifle(trueLabel);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
}
} else {
@@ -1124,7 +1131,8 @@
codeStream.dcmpg();
codeStream.ifgt(falseLabel);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
return;
} else {
// no implicit fall through TRUE/FALSE --> should never occur
@@ -1143,10 +1151,9 @@
Label falseLabel,
boolean valueRequired) {
- int pc = codeStream.position;
Constant condConst;
if ((left.implicitConversion & 0xF) == T_boolean) {
- if ((condConst = left.conditionalConstant()) != NotAConstant) {
+ if ((condConst = left.optimizedBooleanConstant()) != NotAConstant) {
if (condConst.booleanValue() == true) {
// <something equivalent to true> & x
left.generateOptimizedBoolean(
@@ -1189,11 +1196,12 @@
}
}
}
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
- if ((condConst = right.conditionalConstant()) != NotAConstant) {
+ if ((condConst = right.optimizedBooleanConstant()) != NotAConstant) {
if (condConst.booleanValue() == true) {
// x & <something equivalent to true>
if ((bits & OnlyValueRequiredMASK) != 0) {
@@ -1236,8 +1244,9 @@
}
}
}
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
}
@@ -1262,7 +1271,8 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
}
/**
@@ -1275,10 +1285,9 @@
Label falseLabel,
boolean valueRequired) {
- int pc = codeStream.position;
Constant condConst;
if ((left.implicitConversion & 0xF) == T_boolean) {
- if ((condConst = left.conditionalConstant()) != NotAConstant) {
+ if ((condConst = left.optimizedBooleanConstant()) != NotAConstant) {
if (condConst.booleanValue() == true) {
// <something equivalent to true> | x
left.generateOptimizedBoolean(
@@ -1302,6 +1311,8 @@
}
}
}
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
} else {
// <something equivalent to false> | x
left.generateOptimizedBoolean(
@@ -1321,10 +1332,9 @@
valueRequired);
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
- if ((condConst = right.conditionalConstant()) != NotAConstant) {
+ if ((condConst = right.optimizedBooleanConstant()) != NotAConstant) {
if (condConst.booleanValue() == true) {
// x | <something equivalent to true>
left.generateOptimizedBoolean(
@@ -1348,6 +1358,8 @@
}
}
}
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
} else {
// x | <something equivalent to false>
if ((bits & OnlyValueRequiredMASK) != 0) {
@@ -1367,7 +1379,6 @@
falseLabel,
false);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
}
@@ -1392,7 +1403,8 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
}
/**
@@ -1405,10 +1417,9 @@
Label falseLabel,
boolean valueRequired) {
- int pc = codeStream.position;
Constant condConst;
if ((left.implicitConversion & 0xF) == T_boolean) {
- if ((condConst = left.conditionalConstant()) != NotAConstant) {
+ if ((condConst = left.optimizedBooleanConstant()) != NotAConstant) {
if (condConst.booleanValue() == true) {
// <something equivalent to true> ^ x
left.generateOptimizedBoolean(
@@ -1442,10 +1453,9 @@
valueRequired);
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
- if ((condConst = right.conditionalConstant()) != NotAConstant) {
+ if ((condConst = right.optimizedBooleanConstant()) != NotAConstant) {
if (condConst.booleanValue() == true) {
// x ^ <something equivalent to true>
left.generateOptimizedBoolean(
@@ -1479,7 +1489,6 @@
falseLabel,
false);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
}
@@ -1504,7 +1513,8 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
}
public void generateOptimizedStringBuffer(
@@ -1591,19 +1601,19 @@
return;
case AND_AND :
Constant cst;
- if ((cst = left.conditionalConstant()) != NotAConstant) {
+ if ((cst = left.optimizedBooleanConstant()) != NotAConstant) {
if (cst.booleanValue() == false) { // left is equivalent to false
optimizedBooleanConstant = cst; // constant(false)
return;
} else { //left is equivalent to true
- if ((cst = right.conditionalConstant()) != NotAConstant) {
+ if ((cst = right.optimizedBooleanConstant()) != NotAConstant) {
optimizedBooleanConstant = cst;
// the conditional result is equivalent to the right conditional value
}
return;
}
}
- if ((cst = right.conditionalConstant()) != NotAConstant) {
+ if ((cst = right.optimizedBooleanConstant()) != NotAConstant) {
if (cst.booleanValue() == false) { // right is equivalent to false
optimizedBooleanConstant = cst; // constant(false)
}
@@ -1613,18 +1623,18 @@
if ((leftId != T_boolean) || (rightId != T_boolean))
return;
case OR_OR :
- if ((cst = left.conditionalConstant()) != NotAConstant) {
+ if ((cst = left.optimizedBooleanConstant()) != NotAConstant) {
if (cst.booleanValue() == true) { // left is equivalent to true
optimizedBooleanConstant = cst; // constant(true)
return;
} else { //left is equivalent to false
- if ((cst = right.conditionalConstant()) != NotAConstant) {
+ if ((cst = right.optimizedBooleanConstant()) != NotAConstant) {
optimizedBooleanConstant = cst;
}
return;
}
}
- if ((cst = right.conditionalConstant()) != NotAConstant) {
+ if ((cst = right.optimizedBooleanConstant()) != NotAConstant) {
if (cst.booleanValue() == true) { // right is equivalent to true
optimizedBooleanConstant = cst; // constant(true)
}
@@ -1686,28 +1696,28 @@
switch (result & 0xF) { // record the current ReturnTypeID
// only switch on possible result type.....
case T_boolean :
- this.typeBinding = BooleanBinding;
+ this.resolvedType = BooleanBinding;
break;
case T_byte :
- this.typeBinding = ByteBinding;
+ this.resolvedType = ByteBinding;
break;
case T_char :
- this.typeBinding = CharBinding;
+ this.resolvedType = CharBinding;
break;
case T_double :
- this.typeBinding = DoubleBinding;
+ this.resolvedType = DoubleBinding;
break;
case T_float :
- this.typeBinding = FloatBinding;
+ this.resolvedType = FloatBinding;
break;
case T_int :
- this.typeBinding = IntBinding;
+ this.resolvedType = IntBinding;
break;
case T_long :
- this.typeBinding = LongBinding;
+ this.resolvedType = LongBinding;
break;
case T_String :
- this.typeBinding = scope.getJavaLangString();
+ this.resolvedType = scope.getJavaLangString();
break;
default : //error........
constant = Constant.NotAConstant;
@@ -1717,7 +1727,7 @@
// compute the constant when valid
computeConstant(scope, leftId, rightId);
- return this.typeBinding;
+ return this.resolvedType;
}
public String toStringExpressionNoParenthesis() {
@@ -1735,4 +1745,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Block.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Block.java
index af50ef2..dd8316a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Block.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Block.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -33,12 +33,14 @@
FlowInfo flowInfo) {
// empty block
- if (statements == null)
- return flowInfo;
+ if (statements == null) return flowInfo;
+ boolean didAlreadyComplain = false;
for (int i = 0, max = statements.length; i < max; i++) {
Statement stat;
- if (!flowInfo.complainIfUnreachable((stat = statements[i]), scope)) {
+ if (!flowInfo.complainIfUnreachable(stat = statements[i], scope, didAlreadyComplain)) {
flowInfo = stat.analyseCode(scope, flowContext, flowInfo);
+ } else {
+ didAlreadyComplain = true;
}
}
return flowInfo;
@@ -157,4 +159,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java
index 0f954fb..8466836 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.codegen.*;
@@ -61,6 +61,12 @@
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
public void resetStateForCodeGeneration() {
- this.targetLabel.resetStateForCodeGeneration();
+ if (this.targetLabel != null) {
+ this.targetLabel.resetStateForCodeGeneration();
+ }
}
+
+public void resolve(BlockScope scope) {
+}
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Break.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Break.java
index 36f4195..8c685db 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Break.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Break.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -29,70 +29,61 @@
// to each of the traversed try statements, so that execution will terminate properly.
// lookup the label, this should answer the returnContext
- FlowContext targetContext;
- if (label == null) {
- targetContext = flowContext.getTargetContextForDefaultBreak();
- } else {
- targetContext = flowContext.getTargetContextForBreakLabel(label);
- }
+ FlowContext targetContext = (label == null)
+ ? flowContext.getTargetContextForDefaultBreak()
+ : flowContext.getTargetContextForBreakLabel(label);
+
if (targetContext == null) {
if (label == null) {
currentScope.problemReporter().invalidBreak(this);
} else {
- currentScope.problemReporter().undefinedLabel(this); // need to improve
+ currentScope.problemReporter().undefinedLabel(this);
}
- } else {
- targetLabel = targetContext.breakLabel();
- targetContext.recordBreakFrom(flowInfo);
- FlowContext traversedContext = flowContext;
- int subIndex = 0, maxSub = 5;
- subroutines = new AstNode[maxSub];
- while (true) {
- AstNode sub;
- if ((sub = traversedContext.subRoutine()) != null) {
- if (subIndex == maxSub) {
- System.arraycopy(
- subroutines,
- 0,
- (subroutines = new AstNode[maxSub *= 2]),
- 0,
- subIndex);
- // grow
- }
- subroutines[subIndex++] = sub;
- if (sub.cannotReturn()) {
- break;
- }
- }
- // remember the initialization at this
- // point for dealing with blank final variables.
- traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
-
- if (traversedContext == targetContext) {
- break;
- } else {
- traversedContext = traversedContext.parent;
- }
- }
- // resize subroutines
- if (subIndex != maxSub) {
- System.arraycopy(
- subroutines,
- 0,
- (subroutines = new AstNode[subIndex]),
- 0,
- subIndex);
- }
+ return flowInfo; // pretend it did not break since no actual target
}
- return FlowInfo.DeadEnd;
+
+ targetLabel = targetContext.breakLabel();
+ FlowContext traversedContext = flowContext;
+ int subIndex = 0, maxSub = 5;
+ subroutines = new AstNode[maxSub];
+
+ do {
+ AstNode sub;
+ if ((sub = traversedContext.subRoutine()) != null) {
+ if (subIndex == maxSub) {
+ System.arraycopy(subroutines, 0, (subroutines = new AstNode[maxSub*=2]), 0, subIndex); // grow
+ }
+ subroutines[subIndex++] = sub;
+ if (sub.cannotReturn()) {
+ break;
+ }
+ }
+ traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
+
+ AstNode node;
+ if ((node = traversedContext.associatedNode) instanceof TryStatement) {
+ TryStatement tryStatement = (TryStatement) node;
+ flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
+ } else if (traversedContext == targetContext) {
+ // only record break info once accumulated through subroutines, and only against target context
+ targetContext.recordBreakFrom(flowInfo);
+ break;
+ }
+ } while ((traversedContext = traversedContext.parent) != null);
+
+ // resize subroutines
+ if (subIndex != maxSub) {
+ System.arraycopy(subroutines, 0, (subroutines = new AstNode[subIndex]), 0, subIndex);
+ }
+ return FlowInfo.DEAD_END;
}
public String toString(int tab) {
String s = tabString(tab);
- s = s + "break "; //$NON-NLS-1$
+ s += "break "; //$NON-NLS-1$
if (label != null)
- s = s + new String(label);
+ s += new String(label);
return s;
}
@@ -103,4 +94,4 @@
visitor.visit(this, blockscope);
visitor.endVisit(this, blockscope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java
index 3f63633..a571c54 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -52,30 +52,30 @@
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
+ /**
+ * No-op : should use resolveCase(...) instead.
+ */
public void resolve(BlockScope scope) {
-
- // error....use resolveCase....
- throw new NullPointerException();
}
public Constant resolveCase(
BlockScope scope,
- TypeBinding testTb,
+ TypeBinding switchType,
SwitchStatement switchStatement) {
// add into the collection of cases of the associated switch statement
switchStatement.cases[switchStatement.caseCount++] = this;
- TypeBinding caseTb = constantExpression.resolveType(scope);
- if (caseTb == null || testTb == null)
+ TypeBinding caseType = constantExpression.resolveType(scope);
+ if (caseType == null || switchType == null)
return null;
- if (constantExpression.isConstantValueOfTypeAssignableToType(caseTb, testTb))
+ if (constantExpression.isConstantValueOfTypeAssignableToType(caseType, switchType))
return constantExpression.constant;
- if (scope.areTypesCompatible(caseTb, testTb))
+ if (caseType.isCompatibleWith(switchType))
return constantExpression.constant;
scope.problemReporter().typeMismatchErrorActualTypeExpectedType(
constantExpression,
- caseTb,
- testTb);
+ caseType,
+ switchType);
return null;
}
@@ -95,4 +95,4 @@
}
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
index ba70696..2ad3c74 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CastExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -21,7 +21,6 @@
public Expression expression;
public Expression type;
public boolean needRuntimeCheckcast;
- public TypeBinding castTb;
//expression.implicitConversion holds the cast for baseType casting
public CastExpression(Expression e, Expression t) {
@@ -56,10 +55,10 @@
public final void areTypesCastCompatible(
BlockScope scope,
- TypeBinding castTb,
- TypeBinding expressionTb) {
+ TypeBinding castType,
+ TypeBinding expressionType) {
- // see specifications p.68
+ // see specifications 5.5
// handle errors and process constant when needed
// if either one of the type is null ==>
@@ -67,134 +66,143 @@
// we then do not report an obvious-cascade-error.
needRuntimeCheckcast = false;
- if (castTb == null || expressionTb == null)
- return;
- if (castTb.isBaseType()) {
- if (expressionTb.isBaseType()) {
- if (expressionTb == castTb) {
+ if (castType == null || expressionType == null) return;
+
+ // identity conversion cannot be performed upfront, due to side-effects
+ // like constant propagation
+
+ if (castType.isBaseType()) {
+ if (expressionType.isBaseType()) {
+ if (expressionType == castType) {
+ expression.implicitWidening(castType, expressionType);
constant = expression.constant; //use the same constant
return;
}
- if (scope.areTypesCompatible(expressionTb, castTb)
- || BaseTypeBinding.isNarrowing(castTb.id, expressionTb.id)) {
- expression.implicitConversion = (castTb.id << 4) + expressionTb.id;
+ if (expressionType.isCompatibleWith(castType)
+ || BaseTypeBinding.isNarrowing(castType.id, expressionType.id)) {
+ expression.implicitConversion = (castType.id << 4) + expressionType.id;
if (expression.constant != Constant.NotAConstant)
constant = expression.constant.castTo(expression.implicitConversion);
return;
}
}
- scope.problemReporter().typeCastError(this, castTb, expressionTb);
+ scope.problemReporter().typeCastError(this, castType, expressionType);
return;
}
//-----------cast to something which is NOT a base type--------------------------
- if (expressionTb == NullBinding)
+ if (expressionType == NullBinding) {
+ // if (castType.isArrayType()){ // 26903 - need checkcast when casting null to array type
+ // needRuntimeCheckcast = true;
+ // }
return; //null is compatible with every thing
-
- if (expressionTb.isBaseType()) {
- scope.problemReporter().typeCastError(this, castTb, expressionTb);
+ }
+ if (expressionType.isBaseType()) {
+ scope.problemReporter().typeCastError(this, castType, expressionType);
return;
}
- if (expressionTb.isArrayType()) {
- if (castTb.isArrayType()) {
- //------- (castTb.isArray) expressionTb.isArray -----------
- TypeBinding expressionEltTb = ((ArrayBinding) expressionTb).elementsType(scope);
- if (expressionEltTb.isBaseType()) {
+ if (expressionType.isArrayType()) {
+ if (castType == expressionType) return; // identity conversion
+
+ if (castType.isArrayType()) {
+ //------- (castType.isArray) expressionType.isArray -----------
+ TypeBinding exprElementType = ((ArrayBinding) expressionType).elementsType(scope);
+ if (exprElementType.isBaseType()) {
// <---stop the recursion-------
- if (((ArrayBinding) castTb).elementsType(scope) == expressionEltTb)
+ if (((ArrayBinding) castType).elementsType(scope) == exprElementType)
needRuntimeCheckcast = true;
else
- scope.problemReporter().typeCastError(this, castTb, expressionTb);
+ scope.problemReporter().typeCastError(this, castType, expressionType);
return;
}
// recursively on the elements...
areTypesCastCompatible(
scope,
- ((ArrayBinding) castTb).elementsType(scope),
- expressionEltTb);
+ ((ArrayBinding) castType).elementsType(scope),
+ exprElementType);
return;
} else if (
- castTb.isClass()) {
- //------(castTb.isClass) expressionTb.isArray ---------------
- if (scope.isJavaLangObject(castTb))
+ castType.isClass()) {
+ //------(castType.isClass) expressionType.isArray ---------------
+ if (scope.isJavaLangObject(castType))
return;
- } else { //------- (castTb.isInterface) expressionTb.isArray -----------
- if (scope.isJavaLangCloneable(castTb) || scope.isJavaIoSerializable(castTb)) {
+ } else { //------- (castType.isInterface) expressionType.isArray -----------
+ if (scope.isJavaLangCloneable(castType) || scope.isJavaIoSerializable(castType)) {
needRuntimeCheckcast = true;
return;
}
}
- scope.problemReporter().typeCastError(this, castTb, expressionTb);
+ scope.problemReporter().typeCastError(this, castType, expressionType);
return;
}
- if (expressionTb.isClass()) {
- if (castTb.isArrayType()) {
- // ---- (castTb.isArray) expressionTb.isClass -------
- if (scope.isJavaLangObject(expressionTb)) { // potential runtime error
+ if (expressionType.isClass()) {
+ if (castType.isArrayType()) {
+ // ---- (castType.isArray) expressionType.isClass -------
+ if (scope.isJavaLangObject(expressionType)) { // potential runtime error
needRuntimeCheckcast = true;
return;
}
- } else if (
- castTb.isClass()) { // ----- (castTb.isClass) expressionTb.isClass ------
- if (scope.areTypesCompatible(expressionTb, castTb)) // no runtime error
+ } else if (castType.isClass()) { // ----- (castType.isClass) expressionType.isClass ------
+ if (expressionType.isCompatibleWith(castType)){ // no runtime error
+ if (castType.id == T_String) constant = expression.constant; // (String) cst is still a constant
return;
- if (scope.areTypesCompatible(castTb, expressionTb)) {
+ }
+ if (castType.isCompatibleWith(expressionType)) {
// potential runtime error
needRuntimeCheckcast = true;
return;
}
- } else { // ----- (castTb.isInterface) expressionTb.isClass -------
- if (((ReferenceBinding) expressionTb).isFinal()) {
- // no subclass for expressionTb, thus compile-time check is valid
- if (scope.areTypesCompatible(expressionTb, castTb))
+ } else { // ----- (castType.isInterface) expressionType.isClass -------
+ if (((ReferenceBinding) expressionType).isFinal()) {
+ // no subclass for expressionType, thus compile-time check is valid
+ if (expressionType.isCompatibleWith(castType))
return;
} else { // a subclass may implement the interface ==> no check at compile time
needRuntimeCheckcast = true;
return;
}
}
- scope.problemReporter().typeCastError(this, castTb, expressionTb);
+ scope.problemReporter().typeCastError(this, castType, expressionType);
return;
}
- // if (expressionTb.isInterface()) { cannot be anything else
- if (castTb.isArrayType()) {
- // ----- (castTb.isArray) expressionTb.isInterface ------
- if (scope.isJavaLangCloneable(expressionTb)
- || scope.isJavaIoSerializable(expressionTb)) // potential runtime error
+ // if (expressionType.isInterface()) { cannot be anything else
+ if (castType.isArrayType()) {
+ // ----- (castType.isArray) expressionType.isInterface ------
+ if (scope.isJavaLangCloneable(expressionType)
+ || scope.isJavaIoSerializable(expressionType)) // potential runtime error
needRuntimeCheckcast = true;
else
- scope.problemReporter().typeCastError(this, castTb, expressionTb);
+ scope.problemReporter().typeCastError(this, castType, expressionType);
return;
- } else if (
- castTb.isClass()) { // ----- (castTb.isClass) expressionTb.isInterface --------
- if (scope.isJavaLangObject(castTb)) // no runtime error
+ } else if (castType.isClass()) { // ----- (castType.isClass) expressionType.isInterface --------
+ if (scope.isJavaLangObject(castType)) // no runtime error
return;
- if (((ReferenceBinding) castTb).isFinal()) {
- // no subclass for castTb, thus compile-time check is valid
- if (!scope.areTypesCompatible(castTb, expressionTb)) {
+ if (((ReferenceBinding) castType).isFinal()) {
+ // no subclass for castType, thus compile-time check is valid
+ if (!castType.isCompatibleWith(expressionType)) {
// potential runtime error
- scope.problemReporter().typeCastError(this, castTb, expressionTb);
+ scope.problemReporter().typeCastError(this, castType, expressionType);
return;
}
}
- } else { // ----- (castTb.isInterface) expressionTb.isInterface -------
- if (castTb != expressionTb
- && (Scope.compareTypes(castTb, expressionTb) == NotRelated)) {
- MethodBinding[] castTbMethods = ((ReferenceBinding) castTb).methods();
- MethodBinding[] expressionTbMethods =
- ((ReferenceBinding) expressionTb).methods();
- int exprMethodsLength = expressionTbMethods.length;
- for (int i = 0, castMethodsLength = castTbMethods.length;
- i < castMethodsLength;
- i++)
- for (int j = 0; j < exprMethodsLength; j++)
- if (castTbMethods[i].returnType != expressionTbMethods[j].returnType)
- if (castTbMethods[i].selector == expressionTbMethods[j].selector)
- if (castTbMethods[i].areParametersEqual(expressionTbMethods[j]))
- scope.problemReporter().typeCastError(this, castTb, expressionTb);
+ } else { // ----- (castType.isInterface) expressionType.isInterface -------
+ if (castType == expressionType) return; // identity conversion
+ if (Scope.compareTypes(castType, expressionType) == NotRelated) {
+ MethodBinding[] castTypeMethods = ((ReferenceBinding) castType).methods();
+ MethodBinding[] expressionTypeMethods =
+ ((ReferenceBinding) expressionType).methods();
+ int exprMethodsLength = expressionTypeMethods.length;
+ for (int i = 0, castMethodsLength = castTypeMethods.length; i < castMethodsLength; i++)
+ for (int j = 0; j < exprMethodsLength; j++) {
+ if ((castTypeMethods[i].returnType != expressionTypeMethods[j].returnType)
+ && (castTypeMethods[i].selector == expressionTypeMethods[j].selector)
+ && castTypeMethods[i].areParametersEqual(expressionTypeMethods[j])) {
+ scope.problemReporter().typeCastError(this, castType, expressionType);
+ }
+ }
}
}
needRuntimeCheckcast = true;
@@ -219,7 +227,7 @@
|| needRuntimeCheckcast) { // Added for: 1F1W9IG: IVJCOM:WINNT - Compiler omits casting check
codeStream.generateConstant(constant, implicitConversion);
if (needRuntimeCheckcast) {
- codeStream.checkcast(castTb);
+ codeStream.checkcast(this.resolvedType);
if (!valueRequired)
codeStream.pop();
}
@@ -232,7 +240,7 @@
codeStream,
valueRequired || needRuntimeCheckcast);
if (needRuntimeCheckcast) {
- codeStream.checkcast(castTb);
+ codeStream.checkcast(this.resolvedType);
if (!valueRequired)
codeStream.pop();
} else {
@@ -242,6 +250,14 @@
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
+ public Expression innermostCastedExpression(){
+ Expression current = this.expression;
+ while (current instanceof CastExpression) {
+ current = ((CastExpression) current).expression;
+ }
+ return current;
+ }
+
public TypeBinding resolveType(BlockScope scope) {
// compute a new constant if the cast is effective
@@ -251,16 +267,16 @@
constant = Constant.NotAConstant;
implicitConversion = T_undefined;
- TypeBinding expressionTb = expression.resolveType(scope);
- if (expressionTb == null)
- return null;
-
if ((type instanceof TypeReference) || (type instanceof NameReference)) {
- if ((castTb = type.resolveType(scope)) == null)
- return null;
- areTypesCastCompatible(scope, castTb, expressionTb);
- return castTb;
- } else { // expression as a cast !!!!!!!!
+ this.resolvedType = type.resolveType(scope);
+ TypeBinding castedExpressionType = expression.resolveType(scope);
+ if (this.resolvedType != null && castedExpressionType != null) {
+ areTypesCastCompatible(scope, this.resolvedType, castedExpressionType);
+ }
+ return this.resolvedType;
+ } else { // expression as a cast !!!!!!!!
+ TypeBinding castedExpressionType = expression.resolveType(scope);
+ if (castedExpressionType == null) return null;
scope.problemReporter().invalidTypeReference(type);
return null;
}
@@ -282,4 +298,4 @@
}
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CharLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CharLiteral.java
index ee43693..6572aa3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CharLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CharLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java
index 2a40037..10428c9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ClassLiteralAccess.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -58,7 +58,7 @@
// in interface case, no caching occurs, since cannot make a cache field for interface
if (valueRequired)
- codeStream.generateClassLiteralAccessForType(type.binding, syntheticField);
+ codeStream.generateClassLiteralAccessForType(type.resolvedType, syntheticField);
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
@@ -74,7 +74,7 @@
return null;
}
- return scope.getJavaLangClass();
+ return this.resolvedType = scope.getJavaLangClass();
}
public String toStringExpression() {
@@ -93,4 +93,4 @@
}
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java
index 1e0f868..be32a5f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -45,11 +45,10 @@
this,
NoExceptions,
scope,
- FlowInfo.DeadEnd);
+ FlowInfo.DEAD_END);
// check for missing returning path
- needFreeReturn =
- !((flowInfo == FlowInfo.DeadEnd) || flowInfo.isFakeReachable());
+ this.needFreeReturn = flowInfo.isReachable();
// check missing blank final field initializations
flowInfo = flowInfo.mergedWith(staticInitializerFlowContext.initsOnReturn);
@@ -147,10 +146,8 @@
TypeDeclaration declaringType = classScope.referenceContext;
// initialize local positions - including initializer scope.
- scope.computeLocalVariablePositions(0, codeStream); // should not be necessary
MethodScope staticInitializerScope = declaringType.staticInitializerScope;
staticInitializerScope.computeLocalVariablePositions(0, codeStream);
- // offset by the argument size
// 1.4 feature
// This has to be done before any other initialization
@@ -188,7 +185,7 @@
// reset the constant pool to its state before the clinit
constantPool.resetForClinit(constantPoolIndex, constantPoolOffset);
} else {
- if (needFreeReturn) {
+ if (this.needFreeReturn) {
int oldPosition = codeStream.position;
codeStream.return_();
codeStream.updateLocalVariablesAttribute(oldPosition);
@@ -252,4 +249,4 @@
sourceType.addSyntheticField(sourceType, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
index b7cf5ac..7b7bfa3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
@@ -1,20 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
public class CompilationUnitDeclaration
extends AstNode
@@ -31,7 +31,9 @@
public ProblemReporter problemReporter;
public CompilationResult compilationResult;
- private LocalTypeBinding[] allLocalTypes;
+ private LocalTypeBinding[] localTypes;
+ int localTypeCount = 0;
+
public boolean isPropagatingInnerClassEmulation;
public CompilationUnitDeclaration(
@@ -89,19 +91,36 @@
* to compiler structures.
*/
public void cleanUp() {
-
+ if (this.types != null) {
+ for (int i = 0, max = this.types.length; i < max; i++) {
+ cleanUp(this.types[i]);
+ }
+ for (int i = 0, max = this.localTypeCount; i < max; i++) {
+ // null out the type's scope backpointers
+ localTypes[i].scope = null; // local members are already in the list
+ }
+ }
ClassFile[] classFiles = compilationResult.getClassFiles();
for (int i = 0, max = classFiles.length; i < max; i++) {
// clear the classFile back pointer to the bindings
ClassFile classFile = classFiles[i];
- // null out the type's scope backpointers
- ((SourceTypeBinding) classFile.referenceBinding).scope = null;
// null out the classfile backpointer to a type binding
classFile.referenceBinding = null;
classFile.codeStream = null; // codeStream holds onto ast and scopes
classFile.innerClassesBindings = null;
}
}
+ private void cleanUp(TypeDeclaration type) {
+ if (type.memberTypes != null) {
+ for (int i = 0, max = type.memberTypes.length; i < max; i++){
+ cleanUp(type.memberTypes[i]);
+ }
+ }
+ if (type.binding != null) {
+ // null out the type's scope backpointers
+ type.binding.scope = null;
+ }
+ }
public void checkUnusedImports(){
@@ -200,9 +219,12 @@
public void propagateInnerEmulationForAllLocalTypes() {
isPropagatingInnerClassEmulation = true;
- if (allLocalTypes != null) {
- for (int i = 0, max = allLocalTypes.length; i < max; i++) {
- allLocalTypes[i].updateInnerEmulationDependents();
+ for (int i = 0, max = this.localTypeCount; i < max; i++) {
+
+ LocalTypeBinding localType = localTypes[i];
+ // only propagate for reachable local types
+ if ((localType.scope.referenceType().bits & IsReachableMASK) != 0) {
+ localType.updateInnerEmulationDependents();
}
}
}
@@ -213,18 +235,12 @@
*/
public void record(LocalTypeBinding localType) {
- if (allLocalTypes == null) {
- allLocalTypes = new LocalTypeBinding[] { localType };
- } else {
- int length = allLocalTypes.length;
- System.arraycopy(
- allLocalTypes,
- 0,
- (allLocalTypes = new LocalTypeBinding[length + 1]),
- 0,
- length);
- allLocalTypes[length] = localType;
+ if (this.localTypeCount == 0) {
+ this.localTypes = new LocalTypeBinding[5];
+ } else if (this.localTypeCount == this.localTypes.length) {
+ System.arraycopy(this.localTypes, 0, (this.localTypes = new LocalTypeBinding[this.localTypeCount * 2]), 0, this.localTypeCount);
}
+ this.localTypes[this.localTypeCount++] = localType;
}
public void resolve() {
@@ -235,7 +251,7 @@
types[i].resolve(scope);
}
}
- checkUnusedImports();
+ if (!this.compilationResult.hasSyntaxError()) checkUnusedImports();
} catch (AbortCompilationUnit e) {
this.ignoreFurtherInvestigation = true;
return;
@@ -272,19 +288,24 @@
return;
try {
if (visitor.visit(this, scope)) {
+ if (currentPackage != null) {
+ currentPackage.traverse(visitor, scope);
+ }
if (imports != null) {
int importLength = imports.length;
- for (int i = 0; i < importLength; i++)
+ for (int i = 0; i < importLength; i++) {
imports[i].traverse(visitor, scope);
+ }
}
if (types != null) {
int typesLength = types.length;
- for (int i = 0; i < typesLength; i++)
+ for (int i = 0; i < typesLength; i++) {
types[i].traverse(visitor, scope);
+ }
}
}
visitor.endVisit(this, scope);
} catch (AbortCompilationUnit e) {
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
index 597e5f3..5dfd3c3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -27,6 +27,7 @@
//but is build as an expression ==> the checkcast cannot fail
super(lhs, expression, sourceEnd);
+ lhs.bits &= ~IsStrictlyAssignedMASK; // tag lhs as NON assigned - it is also a read access
this.operator = operator ;
}
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
@@ -34,7 +35,7 @@
// a field reference, a blank final field reference, a field of an enclosing instance or
// just a local variable.
- return lhs.analyseAssignment(currentScope, flowContext, flowInfo, this, true).unconditionalInits();
+ return ((Reference) lhs).analyseAssignment(currentScope, flowContext, flowInfo, this, true).unconditionalInits();
}
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
@@ -43,7 +44,7 @@
// just a local variable.
int pc = codeStream.position;
- lhs.generateCompoundAssignment(currentScope, codeStream, expression, operator, assignmentImplicitConversion, valueRequired);
+ ((Reference) lhs).generateCompoundAssignment(currentScope, codeStream, expression, operator, assignmentImplicitConversion, valueRequired);
if (valueRequired) {
codeStream.generateImplicitConversion(implicitConversion);
}
@@ -78,6 +79,9 @@
}
public TypeBinding resolveType(BlockScope scope) {
constant = NotAConstant;
+ if (!(this.lhs instanceof Reference)) {
+ scope.problemReporter().expressionShouldBeAVariable(this.lhs);
+ }
TypeBinding lhsType = lhs.resolveType(scope);
TypeBinding expressionType = expression.resolveType(scope);
if (lhsType == null || expressionType == null)
@@ -122,7 +126,7 @@
lhs.implicitConversion = result >>> 12;
expression.implicitConversion = (result >>> 4) & 0x000FF;
assignmentImplicitConversion = (lhsId << 4) + (result & 0x0000F);
- return lhsType;
+ return this.resolvedType = lhsType;
}
public boolean restrainUsageToNumericTypes(){
return false ;}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
index 659a880..c7edf5e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -19,11 +19,15 @@
public class ConditionalExpression extends OperatorExpression {
public Expression condition, valueIfTrue, valueIfFalse;
+ public Constant optimizedBooleanConstant;
+ public Constant optimizedIfTrueConstant;
+ public Constant optimizedIfFalseConstant;
+
private int returnTypeSlotSize = 1;
// for local variables table attributes
- int thenInitStateIndex = -1;
- int elseInitStateIndex = -1;
+ int trueInitStateIndex = -1;
+ int falseInitStateIndex = -1;
int mergedInitStateIndex = -1;
public ConditionalExpression(
@@ -42,74 +46,66 @@
FlowContext flowContext,
FlowInfo flowInfo) {
- Constant conditionConstant = condition.conditionalConstant();
+ Constant cst = this.condition.optimizedBooleanConstant();
+ boolean isConditionOptimizedTrue = cst != NotAConstant && cst.booleanValue() == true;
+ boolean isConditionOptimizedFalse = cst != NotAConstant && cst.booleanValue() == false;
- flowInfo = condition.analyseCode(currentScope, flowContext, flowInfo, conditionConstant == NotAConstant);
-
- if (conditionConstant != NotAConstant) {
- if (conditionConstant.booleanValue() == true) {
- // TRUE ? left : right
- FlowInfo resultInfo =
- valueIfTrue.analyseCode(currentScope, flowContext, flowInfo.initsWhenTrue().unconditionalInits());
- // analyse valueIfFalse, but do not take into account any of its infos
- valueIfFalse.analyseCode(
- currentScope,
- flowContext,
- flowInfo.initsWhenFalse().copy().unconditionalInits().markAsFakeReachable(true));
- mergedInitStateIndex =
- currentScope.methodScope().recordInitializationStates(resultInfo);
- return resultInfo;
- } else {
- // FALSE ? left : right
- // analyse valueIfTrue, but do not take into account any of its infos
- valueIfTrue.analyseCode(
- currentScope,
- flowContext,
- flowInfo.initsWhenTrue().copy().unconditionalInits().markAsFakeReachable(true));
- FlowInfo mergeInfo =
- valueIfFalse.analyseCode(currentScope, flowContext, flowInfo.initsWhenFalse().unconditionalInits());
- mergedInitStateIndex =
- currentScope.methodScope().recordInitializationStates(mergeInfo);
- return mergeInfo;
- }
+ int mode = flowInfo.reachMode();
+ flowInfo = condition.analyseCode(currentScope, flowContext, flowInfo, cst == NotAConstant);
+
+ // process the if-true part
+ FlowInfo trueFlowInfo = flowInfo.initsWhenTrue().copy();
+ if (isConditionOptimizedFalse) {
+ trueFlowInfo.setReachMode(FlowInfo.UNREACHABLE);
}
+ trueInitStateIndex = currentScope.methodScope().recordInitializationStates(trueFlowInfo);
+ trueFlowInfo = valueIfTrue.analyseCode(currentScope, flowContext, trueFlowInfo);
- // store a copy of the merged info, so as to compute the local variable attributes afterwards
- FlowInfo trueInfo = flowInfo.initsWhenTrue();
- thenInitStateIndex =
- currentScope.methodScope().recordInitializationStates(trueInfo);
- FlowInfo falseInfo = flowInfo.initsWhenFalse();
- elseInitStateIndex =
- currentScope.methodScope().recordInitializationStates(falseInfo);
+ // process the if-false part
+ FlowInfo falseFlowInfo = flowInfo.initsWhenFalse().copy();
+ if (isConditionOptimizedTrue) {
+ falseFlowInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
+ falseInitStateIndex = currentScope.methodScope().recordInitializationStates(falseFlowInfo);
+ falseFlowInfo = valueIfFalse.analyseCode(currentScope, flowContext, falseFlowInfo);
- // propagate analysis
- trueInfo = valueIfTrue.analyseCode(currentScope, flowContext, trueInfo.copy());
- falseInfo =
- valueIfFalse.analyseCode(currentScope, flowContext, falseInfo.copy());
+ // merge if-true & if-false initializations
+ FlowInfo mergedInfo;
+ if (isConditionOptimizedTrue){
+ mergedInfo = trueFlowInfo.addPotentialInitializationsFrom(falseFlowInfo);
+ } else if (isConditionOptimizedFalse) {
+ mergedInfo = falseFlowInfo.addPotentialInitializationsFrom(trueFlowInfo);
+ } else {
+ // merge using a conditional info - 1GK2BLM
+ // if ((t && (v = t)) ? t : t && (v = f)) r = v; -- ok
+ cst = this.optimizedIfTrueConstant;
+ boolean isValueIfTrueOptimizedTrue = cst != null && cst != NotAConstant && cst.booleanValue() == true;
+ boolean isValueIfTrueOptimizedFalse = cst != null && cst != NotAConstant && cst.booleanValue() == false;
+
+ cst = this.optimizedIfFalseConstant;
+ boolean isValueIfFalseOptimizedTrue = cst != null && cst != NotAConstant && cst.booleanValue() == true;
+ boolean isValueIfFalseOptimizedFalse = cst != null && cst != NotAConstant && cst.booleanValue() == false;
- // merge back using a conditional info - 1GK2BLM
- // if ((t && (v = t)) ? t : t && (v = f)) r = v; -- ok
- FlowInfo mergedInfo =
- FlowInfo.conditional(
- trueInfo.initsWhenTrue().copy().unconditionalInits().mergedWith( // must copy, since could be shared with trueInfo.initsWhenFalse()...
- falseInfo.initsWhenTrue().copy().unconditionalInits()),
- trueInfo.initsWhenFalse().unconditionalInits().mergedWith(
- falseInfo.initsWhenFalse().unconditionalInits()));
- /*
- FlowInfo mergedInfo = valueIfTrue.analyseCode(
- currentScope,
- flowContext,
- flowInfo.initsWhenTrue().copy()).
- unconditionalInits().
- mergedWith(
- valueIfFalse.analyseCode(
- currentScope,
- flowContext,
- flowInfo.initsWhenFalse().copy()).
- unconditionalInits());
- */
+ UnconditionalFlowInfo trueInfoWhenTrue = trueFlowInfo.initsWhenTrue().copy().unconditionalInits();
+ if (isValueIfTrueOptimizedFalse) trueInfoWhenTrue.setReachMode(FlowInfo.UNREACHABLE);
+
+ UnconditionalFlowInfo falseInfoWhenTrue = falseFlowInfo.initsWhenTrue().copy().unconditionalInits();
+ if (isValueIfFalseOptimizedFalse) falseInfoWhenTrue.setReachMode(FlowInfo.UNREACHABLE);
+
+ UnconditionalFlowInfo trueInfoWhenFalse = trueFlowInfo.initsWhenFalse().copy().unconditionalInits();
+ if (isValueIfTrueOptimizedTrue) trueInfoWhenFalse.setReachMode(FlowInfo.UNREACHABLE);
+
+ UnconditionalFlowInfo falseInfoWhenFalse = falseFlowInfo.initsWhenFalse().copy().unconditionalInits();
+ if (isValueIfFalseOptimizedTrue) falseInfoWhenFalse.setReachMode(FlowInfo.UNREACHABLE);
+
+ mergedInfo =
+ FlowInfo.conditional(
+ trueInfoWhenTrue.mergedWith(falseInfoWhenTrue),
+ trueInfoWhenFalse.mergedWith(falseInfoWhenFalse));
+ }
mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(mergedInfo);
+ mergedInfo.setReachMode(mode);
return mergedInfo;
}
@@ -134,7 +130,7 @@
return;
}
Constant cst = condition.constant;
- Constant condCst = condition.conditionalConstant();
+ Constant condCst = condition.optimizedBooleanConstant();
boolean needTruePart =
!(((cst != NotAConstant) && (cst.booleanValue() == false))
|| ((condCst != NotAConstant) && (condCst.booleanValue() == false)));
@@ -152,11 +148,11 @@
(falseLabel = new Label(codeStream)),
needConditionValue);
- if (thenInitStateIndex != -1) {
+ if (trueInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(
currentScope,
- thenInitStateIndex);
- codeStream.addDefinitelyAssignedVariables(currentScope, thenInitStateIndex);
+ trueInitStateIndex);
+ codeStream.addDefinitelyAssignedVariables(currentScope, trueInitStateIndex);
}
// Then code generation
if (needTruePart) {
@@ -174,11 +170,11 @@
}
if (needFalsePart) {
falseLabel.place();
- if (elseInitStateIndex != -1) {
+ if (falseInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(
currentScope,
- elseInitStateIndex);
- codeStream.addDefinitelyAssignedVariables(currentScope, elseInitStateIndex);
+ falseInitStateIndex);
+ codeStream.addDefinitelyAssignedVariables(currentScope, falseInitStateIndex);
}
valueIfFalse.generateCode(currentScope, codeStream, valueRequired);
// End of if statement
@@ -211,9 +207,8 @@
super.generateOptimizedBoolean(currentScope, codeStream, trueLabel, falseLabel, valueRequired);
return;
}
- int pc = codeStream.position;
Constant cst = condition.constant;
- Constant condCst = condition.conditionalConstant();
+ Constant condCst = condition.optimizedBooleanConstant();
boolean needTruePart =
!(((cst != NotAConstant) && (cst.booleanValue() == false))
|| ((condCst != NotAConstant) && (condCst.booleanValue() == false)));
@@ -232,11 +227,11 @@
internalFalseLabel = new Label(codeStream),
needConditionValue);
- if (thenInitStateIndex != -1) {
+ if (trueInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(
currentScope,
- thenInitStateIndex);
- codeStream.addDefinitelyAssignedVariables(currentScope, thenInitStateIndex);
+ trueInitStateIndex);
+ codeStream.addDefinitelyAssignedVariables(currentScope, trueInitStateIndex);
}
// Then code generation
if (needTruePart) {
@@ -247,19 +242,17 @@
int position = codeStream.position;
codeStream.goto_(endifLabel);
codeStream.updateLastRecordedEndPC(position);
- // Tune codestream stack size
- //if (valueRequired) {
- // codeStream.decrStackSize(returnTypeSlotSize);
- //}
+ // No need to decrement codestream stack size
+ // since valueIfTrue was already consumed by branch bytecode
}
}
if (needFalsePart) {
internalFalseLabel.place();
- if (elseInitStateIndex != -1) {
+ if (falseInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(
currentScope,
- elseInitStateIndex);
- codeStream.addDefinitelyAssignedVariables(currentScope, elseInitStateIndex);
+ falseInitStateIndex);
+ codeStream.addDefinitelyAssignedVariables(currentScope, falseInitStateIndex);
}
valueIfFalse.generateOptimizedBoolean(currentScope, codeStream, trueLabel, falseLabel, valueRequired);
@@ -273,9 +266,14 @@
mergedInitStateIndex);
}
// no implicit conversion for boolean values
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ codeStream.updateLastRecordedEndPC(codeStream.position);
}
+ public Constant optimizedBooleanConstant() {
+
+ return this.optimizedBooleanConstant == null ? this.constant : this.optimizedBooleanConstant;
+ }
+
public TypeBinding resolveType(BlockScope scope) {
// specs p.368
constant = NotAConstant;
@@ -286,15 +284,13 @@
return null;
// Propagate the constant value from the valueIfTrue and valueIFFalse expression if it is possible
- if (condition.constant != NotAConstant
- && valueIfTrue.constant != NotAConstant
- && valueIfFalse.constant != NotAConstant) {
+ Constant condConstant, trueConstant, falseConstant;
+ if ((condConstant = condition.constant) != NotAConstant
+ && (trueConstant = valueIfTrue.constant) != NotAConstant
+ && (falseConstant = valueIfFalse.constant) != NotAConstant) {
// all terms are constant expression so we can propagate the constant
// from valueIFTrue or valueIfFalse to teh receiver constant
- constant =
- (condition.constant.booleanValue())
- ? valueIfTrue.constant
- : valueIfFalse.constant;
+ constant = condConstant.booleanValue() ? trueConstant : falseConstant;
}
if (valueIfTrueType == valueIfFalseType) { // harmed the implicit conversion
valueIfTrue.implicitWidening(valueIfTrueType, valueIfTrueType);
@@ -302,8 +298,20 @@
if (valueIfTrueType == LongBinding || valueIfTrueType == DoubleBinding) {
returnTypeSlotSize = 2;
}
- this.typeBinding = valueIfTrueType;
- return valueIfTrueType;
+
+ if (valueIfTrueType == BooleanBinding) {
+ this.optimizedIfTrueConstant = valueIfTrue.optimizedBooleanConstant();
+ this.optimizedIfFalseConstant = valueIfFalse.optimizedBooleanConstant();
+
+ // Propagate the optimized boolean constant if possible
+ if ((condConstant = condition.optimizedBooleanConstant()) != NotAConstant) {
+
+ this.optimizedBooleanConstant = condConstant.booleanValue()
+ ? optimizedIfTrueConstant
+ : optimizedIfFalseConstant;
+ }
+ }
+ return this.resolvedType = valueIfTrueType;
}
// Determine the return type depending on argument types
// Numeric types
@@ -313,7 +321,7 @@
|| (valueIfTrueType == ShortBinding && valueIfFalseType == ByteBinding)) {
valueIfTrue.implicitWidening(ShortBinding, valueIfTrueType);
valueIfFalse.implicitWidening(ShortBinding, valueIfFalseType);
- this.typeBinding = ShortBinding;
+ this.resolvedType = ShortBinding;
return ShortBinding;
}
// <Byte|Short|Char> x constant(Int) ---> <Byte|Short|Char> and reciprocally
@@ -322,7 +330,7 @@
&& valueIfFalse.isConstantValueOfTypeAssignableToType(valueIfFalseType, valueIfTrueType))) {
valueIfTrue.implicitWidening(valueIfTrueType, valueIfTrueType);
valueIfFalse.implicitWidening(valueIfTrueType, valueIfFalseType);
- this.typeBinding = valueIfTrueType;
+ this.resolvedType = valueIfTrueType;
return valueIfTrueType;
}
if ((valueIfFalseType == ByteBinding
@@ -332,7 +340,7 @@
&& valueIfTrue.isConstantValueOfTypeAssignableToType(valueIfTrueType, valueIfFalseType))) {
valueIfTrue.implicitWidening(valueIfFalseType, valueIfTrueType);
valueIfFalse.implicitWidening(valueIfFalseType, valueIfFalseType);
- this.typeBinding = valueIfFalseType;
+ this.resolvedType = valueIfFalseType;
return valueIfFalseType;
}
// Manual binary numeric promotion
@@ -341,7 +349,7 @@
&& BaseTypeBinding.isNarrowing(valueIfFalseType.id, T_int)) {
valueIfTrue.implicitWidening(IntBinding, valueIfTrueType);
valueIfFalse.implicitWidening(IntBinding, valueIfFalseType);
- this.typeBinding = IntBinding;
+ this.resolvedType = IntBinding;
return IntBinding;
}
// long
@@ -350,7 +358,7 @@
valueIfTrue.implicitWidening(LongBinding, valueIfTrueType);
valueIfFalse.implicitWidening(LongBinding, valueIfFalseType);
returnTypeSlotSize = 2;
- this.typeBinding = LongBinding;
+ this.resolvedType = LongBinding;
return LongBinding;
}
// float
@@ -358,14 +366,14 @@
&& BaseTypeBinding.isNarrowing(valueIfFalseType.id, T_float)) {
valueIfTrue.implicitWidening(FloatBinding, valueIfTrueType);
valueIfFalse.implicitWidening(FloatBinding, valueIfFalseType);
- this.typeBinding = FloatBinding;
+ this.resolvedType = FloatBinding;
return FloatBinding;
}
// double
valueIfTrue.implicitWidening(DoubleBinding, valueIfTrueType);
valueIfFalse.implicitWidening(DoubleBinding, valueIfFalseType);
returnTypeSlotSize = 2;
- this.typeBinding = DoubleBinding;
+ this.resolvedType = DoubleBinding;
return DoubleBinding;
}
// Type references (null null is already tested)
@@ -377,16 +385,16 @@
valueIfFalseType);
return null;
}
- if (scope.areTypesCompatible(valueIfFalseType, valueIfTrueType)) {
+ if (valueIfFalseType.isCompatibleWith(valueIfTrueType)) {
valueIfTrue.implicitWidening(valueIfTrueType, valueIfTrueType);
valueIfFalse.implicitWidening(valueIfTrueType, valueIfFalseType);
- this.typeBinding = valueIfTrueType;
+ this.resolvedType = valueIfTrueType;
return valueIfTrueType;
}
- if (scope.areTypesCompatible(valueIfTrueType, valueIfFalseType)) {
+ if (valueIfTrueType.isCompatibleWith(valueIfFalseType)) {
valueIfTrue.implicitWidening(valueIfFalseType, valueIfTrueType);
valueIfFalse.implicitWidening(valueIfFalseType, valueIfFalseType);
- this.typeBinding = valueIfFalseType;
+ this.resolvedType = valueIfFalseType;
return valueIfFalseType;
}
scope.problemReporter().conditionalArgumentsIncompatibleTypes(
@@ -410,4 +418,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
index 6a36595..373f023 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import java.util.ArrayList;
@@ -16,10 +16,10 @@
import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
public class ConstructorDeclaration extends AbstractMethodDeclaration {
@@ -27,9 +27,6 @@
public final static char[] ConstantPoolName = "<init>".toCharArray(); //$NON-NLS-1$
public boolean isDefaultConstructor = false;
- public int referenceCount = 0;
- // count how many times this constructor is referenced from other local constructors
-
public ConstructorDeclaration(CompilationResult compilationResult){
super(compilationResult);
}
@@ -41,6 +38,18 @@
if (ignoreFurtherInvestigation)
return;
+
+ if (this.binding != null && this.binding.isPrivate() && !this.binding.isPrivateUsed()) {
+ if (!classScope.referenceCompilationUnit().compilationResult.hasSyntaxError()) {
+ scope.problemReporter().unusedPrivateConstructor(this);
+ }
+ }
+
+ // check constructor recursion, once all constructor got resolved
+ if (isRecursive(null /*lazy initialized visited list*/)) {
+ this.scope.problemReporter().recursiveConstructorInvocation(this.constructorCall);
+ }
+
try {
ExceptionHandlingFlowContext constructorContext =
new ExceptionHandlingFlowContext(
@@ -48,7 +57,7 @@
this,
binding.thrownExceptions,
scope,
- FlowInfo.DeadEnd);
+ FlowInfo.DEAD_END);
initializerFlowContext.checkInitializerExceptions(
scope,
constructorContext,
@@ -84,21 +93,23 @@
}
// propagate to statements
if (statements != null) {
+ boolean didAlreadyComplain = false;
for (int i = 0, count = statements.length; i < count; i++) {
Statement stat;
- if (!flowInfo.complainIfUnreachable((stat = statements[i]), scope)) {
+ if (!flowInfo.complainIfUnreachable(stat = statements[i], scope, didAlreadyComplain)) {
flowInfo = stat.analyseCode(scope, constructorContext, flowInfo);
+ } else {
+ didAlreadyComplain = true;
}
}
}
// check for missing returning path
- needFreeReturn =
- !((flowInfo == FlowInfo.DeadEnd) || flowInfo.isFakeReachable());
+ this.needFreeReturn = flowInfo.isReachable();
// check missing blank final field initializations
if ((constructorCall != null)
&& (constructorCall.accessMode != ExplicitConstructorCall.This)) {
- flowInfo = flowInfo.mergedWith(initializerFlowContext.initsOnReturn);
+ flowInfo = flowInfo.mergedWith(constructorContext.initsOnReturn);
FieldBinding[] fields = binding.declaringClass.fields();
for (int i = 0, count = fields.length; i < count; i++) {
FieldBinding field;
@@ -123,6 +134,7 @@
* @param classFile org.eclipse.jdt.internal.compiler.codegen.ClassFile
*/
public void generateCode(ClassScope classScope, ClassFile classFile) {
+
int problemResetPC = 0;
if (ignoreFurtherInvestigation) {
if (this.binding == null)
@@ -153,7 +165,7 @@
} catch (AbortMethod e2) {
int problemsLength;
IProblem[] problems =
- scope.referenceCompilationUnit().compilationResult.getProblems();
+ scope.referenceCompilationUnit().compilationResult.getAllProblems();
IProblem[] problemsCopy = new IProblem[problemsLength = problems.length];
System.arraycopy(problems, 0, problemsCopy, 0, problemsLength);
classFile.addProblemConstructor(this, binding, problemsCopy, problemResetPC);
@@ -161,7 +173,7 @@
} else {
int problemsLength;
IProblem[] problems =
- scope.referenceCompilationUnit().compilationResult.getProblems();
+ scope.referenceCompilationUnit().compilationResult.getAllProblems();
IProblem[] problemsCopy = new IProblem[problemsLength = problems.length];
System.arraycopy(problems, 0, problemsCopy, 0, problemsLength);
classFile.addProblemConstructor(this, binding, problemsCopy, problemResetPC);
@@ -169,25 +181,65 @@
}
}
+ public void generateSyntheticFieldInitializationsIfNecessary(
+ MethodScope scope,
+ CodeStream codeStream,
+ ReferenceBinding declaringClass) {
+
+ if (!declaringClass.isNestedType()) return;
+
+ NestedTypeBinding nestedType = (NestedTypeBinding) declaringClass;
+
+ SyntheticArgumentBinding[] syntheticArgs = nestedType.syntheticEnclosingInstances();
+ for (int i = 0, max = syntheticArgs == null ? 0 : syntheticArgs.length; i < max; i++) {
+ SyntheticArgumentBinding syntheticArg;
+ if ((syntheticArg = syntheticArgs[i]).matchingField != null) {
+ codeStream.aload_0();
+ codeStream.load(syntheticArg);
+ codeStream.putfield(syntheticArg.matchingField);
+ }
+ }
+ syntheticArgs = nestedType.syntheticOuterLocalVariables();
+ for (int i = 0, max = syntheticArgs == null ? 0 : syntheticArgs.length; i < max; i++) {
+ SyntheticArgumentBinding syntheticArg;
+ if ((syntheticArg = syntheticArgs[i]).matchingField != null) {
+ codeStream.aload_0();
+ codeStream.load(syntheticArg);
+ codeStream.putfield(syntheticArg.matchingField);
+ }
+ }
+ }
+
private void internalGenerateCode(ClassScope classScope, ClassFile classFile) {
+
classFile.generateMethodInfoHeader(binding);
int methodAttributeOffset = classFile.contentsOffset;
int attributeNumber = classFile.generateMethodInfoAttribute(binding);
if ((!binding.isNative()) && (!binding.isAbstract())) {
+
TypeDeclaration declaringType = classScope.referenceContext;
int codeAttributeOffset = classFile.contentsOffset;
classFile.generateCodeAttributeHeader();
CodeStream codeStream = classFile.codeStream;
codeStream.reset(this, classFile);
+
// initialize local positions - including initializer scope.
ReferenceBinding declaringClass = binding.declaringClass;
- int argSize = 0;
- scope.computeLocalVariablePositions(// consider synthetic arguments if any
- argSize =
- declaringClass.isNestedType()
- ? ((NestedTypeBinding) declaringClass).syntheticArgumentsOffset
- : 1,
- codeStream);
+
+ int argSlotSize = 1; // this==aload0
+
+ if (declaringClass.isNestedType()){
+ NestedTypeBinding nestedType = (NestedTypeBinding) declaringClass;
+ this.scope.extraSyntheticArguments = nestedType.syntheticOuterLocalVariables();
+ scope.computeLocalVariablePositions(// consider synthetic arguments if any
+ nestedType.enclosingInstancesSlotSize + 1,
+ codeStream);
+ argSlotSize += nestedType.enclosingInstancesSlotSize;
+ argSlotSize += nestedType.outerLocalVariablesSlotSize;
+ } else {
+ scope.computeLocalVariablePositions(1, codeStream);
+ }
+
if (arguments != null) {
for (int i = 0, max = arguments.length; i < max; i++) {
// arguments initialization for local variable debug attributes
@@ -196,47 +248,32 @@
argBinding.recordInitializationStartPC(0);
TypeBinding argType;
if ((argType = argBinding.type) == LongBinding || (argType == DoubleBinding)) {
- argSize += 2;
+ argSlotSize += 2;
} else {
- argSize++;
+ argSlotSize++;
}
}
}
+
MethodScope initializerScope = declaringType.initializerScope;
- initializerScope.computeLocalVariablePositions(argSize, codeStream);
- // offset by the argument size (since not linked to method scope)
+ initializerScope.computeLocalVariablePositions(argSlotSize, codeStream); // offset by the argument size (since not linked to method scope)
+ boolean needFieldInitializations = constructorCall == null || constructorCall.accessMode != ExplicitConstructorCall.This;
+
+ // post 1.4 source level, synthetic initializations occur prior to explicit constructor call
+ boolean preInitSyntheticFields = scope.environment().options.targetJDK >= CompilerOptions.JDK1_4;
+
+ if (needFieldInitializations && preInitSyntheticFields){
+ generateSyntheticFieldInitializationsIfNecessary(scope, codeStream, declaringClass);
+ }
// generate constructor call
if (constructorCall != null) {
constructorCall.generateCode(scope, codeStream);
}
// generate field initialization - only if not invoking another constructor call of the same class
- if ((constructorCall != null)
- && (constructorCall.accessMode != ExplicitConstructorCall.This)) {
- // generate synthetic fields initialization
- if (declaringClass.isNestedType()) {
- NestedTypeBinding nestedType = (NestedTypeBinding) declaringClass;
- SyntheticArgumentBinding[] syntheticArgs =
- nestedType.syntheticEnclosingInstances();
- for (int i = 0, max = syntheticArgs == null ? 0 : syntheticArgs.length;
- i < max;
- i++) {
- if (syntheticArgs[i].matchingField != null) {
- codeStream.aload_0();
- codeStream.load(syntheticArgs[i]);
- codeStream.putfield(syntheticArgs[i].matchingField);
- }
- }
- syntheticArgs = nestedType.syntheticOuterLocalVariables();
- for (int i = 0, max = syntheticArgs == null ? 0 : syntheticArgs.length;
- i < max;
- i++) {
- if (syntheticArgs[i].matchingField != null) {
- codeStream.aload_0();
- codeStream.load(syntheticArgs[i]);
- codeStream.putfield(syntheticArgs[i].matchingField);
- }
- }
+ if (needFieldInitializations) {
+ if (!preInitSyntheticFields){
+ generateSyntheticFieldInitializationsIfNecessary(scope, codeStream, declaringClass);
}
// generate user field initialization
if (declaringType.fields != null) {
@@ -254,7 +291,7 @@
statements[i].generateCode(scope, codeStream);
}
}
- if (needFreeReturn) {
+ if (this.needFreeReturn) {
codeStream.return_();
}
// local variable attributes
@@ -286,14 +323,43 @@
return true;
}
+ /**
+ * Returns true if the constructor is directly involved in a cycle.
+ * Given most constructors aren't, we only allocate the visited list
+ * lazily.
+ */
+ public boolean isRecursive(ArrayList visited) {
+
+ if (this.binding == null
+ || this.constructorCall == null
+ || this.constructorCall.binding == null
+ || this.constructorCall.isSuperAccess()
+ || !this.constructorCall.binding.isValidBinding()) {
+ return false;
+ }
+
+ ConstructorDeclaration targetConstructor =
+ ((ConstructorDeclaration)this.scope.referenceType().declarationOf(constructorCall.binding));
+ if (this == targetConstructor) return true; // direct case
+
+ if (visited == null) { // lazy allocation
+ visited = new ArrayList(1);
+ } else {
+ int index = visited.indexOf(this);
+ if (index >= 0) return index == 0; // only blame if directly part of the cycle
+ }
+ visited.add(this);
+
+ return targetConstructor.isRecursive(visited);
+ }
+
public void parseStatements(Parser parser, CompilationUnitDeclaration unit) {
//fill up the constructor body with its statements
if (ignoreFurtherInvestigation)
return;
if (isDefaultConstructor){
- constructorCall =
- new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper);
+ constructorCall = SuperReference.implicitSuperConstructorCall();
constructorCall.sourceStart = sourceStart;
constructorCall.sourceEnd = sourceEnd;
return;
@@ -306,45 +372,28 @@
* Type checking for constructor, just another method, except for special check
* for recursive constructor invocations.
*/
- public void resolveStatements(ClassScope upperScope) {
-/*
- // checking for recursive constructor call (protection)
- if (!ignoreFurtherInvestigation && constructorCall == null){
- constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper);
- constructorCall.sourceStart = sourceStart;
- constructorCall.sourceEnd = sourceEnd;
- }
-*/
+ public void resolveStatements() {
+
if (!CharOperation.equals(scope.enclosingSourceType().sourceName, selector)){
scope.problemReporter().missingReturnType(this);
}
// if null ==> an error has occurs at parsing time ....
- if (constructorCall != null) {
+ if (this.constructorCall != null) {
// e.g. using super() in java.lang.Object
- if (binding != null
- && binding.declaringClass.id == T_Object
- && constructorCall.accessMode != ExplicitConstructorCall.This) {
- if (constructorCall.accessMode == ExplicitConstructorCall.Super) {
- scope.problemReporter().cannotUseSuperInJavaLangObject(constructorCall);
+ if (this.binding != null
+ && this.binding.declaringClass.id == T_Object
+ && this.constructorCall.accessMode != ExplicitConstructorCall.This) {
+ if (this.constructorCall.accessMode == ExplicitConstructorCall.Super) {
+ scope.problemReporter().cannotUseSuperInJavaLangObject(this.constructorCall);
}
- constructorCall = null;
+ this.constructorCall = null;
} else {
- constructorCall.resolve(scope);
+ this.constructorCall.resolve(this.scope);
}
}
- super.resolveStatements(upperScope);
-
- // indirect reference: increment target constructor reference count
- if (constructorCall != null){
- if (constructorCall.binding != null
- && !constructorCall.isSuperAccess()
- && constructorCall.binding.isValidBinding()) {
- ((ConstructorDeclaration)
- (upperScope.referenceContext.declarationOf(constructorCall.binding))).referenceCount++;
- }
- }
+ super.resolveStatements();
}
public String toStringStatements(int tab) {
@@ -391,4 +440,4 @@
}
visitor.endVisit(this, classScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Continue.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Continue.java
index fe5e82c..7c827e1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Continue.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Continue.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -30,74 +30,65 @@
// to each of the traversed try statements, so that execution will terminate properly.
// lookup the label, this should answer the returnContext
- FlowContext targetContext;
- if (label == null) {
- targetContext = flowContext.getTargetContextForDefaultContinue();
- } else {
- targetContext = flowContext.getTargetContextForContinueLabel(label);
- }
+ FlowContext targetContext = (label == null)
+ ? flowContext.getTargetContextForDefaultContinue()
+ : flowContext.getTargetContextForContinueLabel(label);
+
if (targetContext == null) {
if (label == null) {
currentScope.problemReporter().invalidContinue(this);
} else {
- currentScope.problemReporter().undefinedLabel(this); // need to improve
+ currentScope.problemReporter().undefinedLabel(this);
}
- } else {
- if (targetContext == FlowContext.NotContinuableContext) {
- currentScope.problemReporter().invalidContinue(this);
- return FlowInfo.DeadEnd;
- }
- targetLabel = targetContext.continueLabel();
- targetContext.recordContinueFrom(flowInfo);
- FlowContext traversedContext = flowContext;
- int subIndex = 0, maxSub = 5;
- subroutines = new AstNode[maxSub];
- while (true) {
- AstNode sub;
- if ((sub = traversedContext.subRoutine()) != null) {
- if (subIndex == maxSub) {
- System.arraycopy(
- subroutines,
- 0,
- (subroutines = new AstNode[maxSub *= 2]),
- 0,
- subIndex);
- // grow
- }
- subroutines[subIndex++] = sub;
- if (sub.cannotReturn()) {
- break;
- }
- }
- // remember the initialization at this
- // point for dealing with blank final variables.
- traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
+ return flowInfo; // pretend it did not continue since no actual target
+ }
- if (traversedContext == targetContext) {
+ if (targetContext == FlowContext.NotContinuableContext) {
+ currentScope.problemReporter().invalidContinue(this);
+ return flowInfo; // pretend it did not continue since no actual target
+ }
+ targetLabel = targetContext.continueLabel();
+ FlowContext traversedContext = flowContext;
+ int subIndex = 0, maxSub = 5;
+ subroutines = new AstNode[maxSub];
+
+ do {
+ AstNode sub;
+ if ((sub = traversedContext.subRoutine()) != null) {
+ if (subIndex == maxSub) {
+ System.arraycopy(subroutines, 0, (subroutines = new AstNode[maxSub*=2]), 0, subIndex); // grow
+ }
+ subroutines[subIndex++] = sub;
+ if (sub.cannotReturn()) {
break;
- } else {
- traversedContext = traversedContext.parent;
}
}
- // resize subroutines
- if (subIndex != maxSub) {
- System.arraycopy(
- subroutines,
- 0,
- (subroutines = new AstNode[subIndex]),
- 0,
- subIndex);
+ traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
+
+ AstNode node;
+ if ((node = traversedContext.associatedNode) instanceof TryStatement) {
+ TryStatement tryStatement = (TryStatement) node;
+ flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
+ } else if (traversedContext == targetContext) {
+ // only record continue info once accumulated through subroutines, and only against target context
+ targetContext.recordContinueFrom(flowInfo);
+ break;
}
+ } while ((traversedContext = traversedContext.parent) != null);
+
+ // resize subroutines
+ if (subIndex != maxSub) {
+ System.arraycopy(subroutines, 0, (subroutines = new AstNode[subIndex]), 0, subIndex);
}
- return FlowInfo.DeadEnd;
+ return FlowInfo.DEAD_END;
}
public String toString(int tab) {
String s = tabString(tab);
- s = s + "continue "; //$NON-NLS-1$
+ s += "continue "; //$NON-NLS-1$
if (label != null)
- s = s + new String(label);
+ s += new String(label);
return s;
}
@@ -108,4 +99,4 @@
visitor.visit(this, blockScope);
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java
index 3179eab..250e327 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -52,6 +52,12 @@
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
+ /**
+ * No-op : should use resolveCase(...) instead.
+ */
+ public void resolve(BlockScope scope) {
+ }
+
public Constant resolveCase(
BlockScope scope,
TypeBinding testType,
@@ -81,4 +87,4 @@
visitor.visit(this, blockScope);
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
index b9b2fcb..e9e4ec6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -49,63 +49,54 @@
continueLabel,
currentScope);
- Constant conditionConstant = condition.constant;
- Constant conditionalConstant = condition.conditionalConstant();
- boolean isFalseCondition =
- ((conditionConstant != NotAConstant)
- && (conditionConstant.booleanValue() == false))
- || ((conditionalConstant != NotAConstant)
- && (conditionalConstant.booleanValue() == false));
+ Constant cst = condition.constant;
+ boolean isConditionTrue = cst != NotAConstant && cst.booleanValue() == true;
+ cst = condition.optimizedBooleanConstant();
+ boolean isConditionOptimizedTrue = cst != NotAConstant && cst.booleanValue() == true;
+ boolean isConditionOptimizedFalse = cst != NotAConstant && cst.booleanValue() == false;
+ int previousMode = flowInfo.reachMode();
+
if ((action != null) && !action.isEmptyBlock()) {
- flowInfo = action.analyseCode(currentScope, loopingContext, flowInfo.copy());
+ flowInfo = action.analyseCode(currentScope, loopingContext, flowInfo);
// code generation can be optimized when no need to continue in the loop
- if ((flowInfo == FlowInfo.DeadEnd) || flowInfo.isFakeReachable()) {
- if ((loopingContext.initsOnContinue == FlowInfo.DeadEnd)
- || loopingContext.initsOnContinue.isFakeReachable()) {
- continueLabel = null;
- } else {
- flowInfo = loopingContext.initsOnContinue; // for condition
- if (isFalseCondition) {
- // continueLabel = null; - cannot nil the label since may be targeted already by 'continue' statements
- } else {
- loopingContext.complainOnFinalAssignmentsInLoop(currentScope, flowInfo);
- }
- }
- } else {
- if (isFalseCondition) {
- // continueLabel = null; - cannot nil the label since may be targeted already by 'continue' statements
- } else {
- loopingContext.complainOnFinalAssignmentsInLoop(currentScope, flowInfo);
- }
+ if (!flowInfo.isReachable() && !loopingContext.initsOnContinue.isReachable()) {
+ continueLabel = null;
}
}
- LoopingFlowContext condLoopContext;
+ /* Reset reach mode, to address following scenario.
+ * final blank;
+ * do { if (true) break; else blank = 0; } while(false);
+ * blank = 1; // may be initialized already
+ */
+ flowInfo.setReachMode(previousMode);
+
flowInfo =
condition.analyseCode(
currentScope,
- (condLoopContext =
- new LoopingFlowContext(flowContext, this, null, null, currentScope)),
+ loopingContext,
(action == null
? flowInfo
: (flowInfo.mergedWith(loopingContext.initsOnContinue))));
- condLoopContext.complainOnFinalAssignmentsInLoop(currentScope, flowInfo);
+ if (!isConditionOptimizedFalse && continueLabel != null) {
+ loopingContext.complainOnFinalAssignmentsInLoop(currentScope, flowInfo);
+ }
// infinite loop
FlowInfo mergedInfo;
- if ((condition.constant != NotAConstant)
- && (condition.constant.booleanValue() == true)) {
+ if (isConditionTrue) {
mergedInfo = loopingContext.initsOnBreak;
- mergedInitStateIndex =
- currentScope.methodScope().recordInitializationStates(mergedInfo);
- return mergedInfo;
+ if (!mergedInfo.isReachable()) mergedInfo.addPotentialInitializationsFrom(flowInfo.initsWhenFalse());
+ } else {
+ // end of loop: either condition false or break
+ mergedInfo =
+ flowInfo.initsWhenFalse().unconditionalInits().mergedWith(
+ loopingContext.initsOnBreak);
+ if (isConditionOptimizedTrue && !loopingContext.initsOnBreak.isReachable()) {
+ mergedInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
}
-
- // end of loop: either condition false or break
- mergedInfo =
- flowInfo.initsWhenFalse().unconditionalInits().mergedWith(
- loopingContext.initsOnBreak);
mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(mergedInfo);
return mergedInfo;
@@ -157,9 +148,12 @@
}
public void resetStateForCodeGeneration() {
-
- this.breakLabel.resetStateForCodeGeneration();
- this.continueLabel.resetStateForCodeGeneration();
+ if (this.breakLabel != null) {
+ this.breakLabel.resetStateForCodeGeneration();
+ }
+ if (this.continueLabel != null) {
+ this.continueLabel.resetStateForCodeGeneration();
+ }
}
public void resolve(BlockScope scope) {
@@ -195,4 +189,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoubleLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoubleLiteral.java
index a3430f2..24228cf 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoubleLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DoubleLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -30,7 +30,7 @@
if (computedValue.doubleValue() > Double.MAX_VALUE) return ; //may be Infinity
if (computedValue.doubleValue() < Double.MIN_VALUE)
- { //only a true 0 can be made of zeros :-)
+ { //only a true 0 can be made of zeros
//2.00000000000000000e-324 is illegal ....
label :
for (int i=0;i<source.length;i++)
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EmptyStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EmptyStatement.java
index 84c9fc7..c7b7cac 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EmptyStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EmptyStatement.java
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java
index 3442476..9fe0aad 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -68,32 +68,33 @@
left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits()).asNegatedCondition().unconditionalInits();
}
}
-public final boolean areTypesCastCompatible(BlockScope scope, TypeBinding castTb, TypeBinding expressionTb) {
- //see specifications p.68
+public final boolean areTypesCastCompatible(BlockScope scope, TypeBinding castType, TypeBinding expressionType) {
+ //see specifications 5.5
//A more complete version of this method is provided on
//CastExpression (it deals with constant and need runtime checkcast)
+ if (castType == expressionType) return true;
//========ARRAY===============
- if (expressionTb.isArrayType()) {
- if (castTb.isArrayType()) { //------- (castTb.isArray) expressionTb.isArray -----------
- TypeBinding expressionEltTb = ((ArrayBinding) expressionTb).elementsType(scope);
- if (expressionEltTb.isBaseType())
+ if (expressionType.isArrayType()) {
+ if (castType.isArrayType()) { //------- (castTb.isArray) expressionTb.isArray -----------
+ TypeBinding expressionEltType = ((ArrayBinding) expressionType).elementsType(scope);
+ if (expressionEltType.isBaseType())
// <---stop the recursion-------
- return ((ArrayBinding) castTb).elementsType(scope) == expressionEltTb;
+ return ((ArrayBinding) castType).elementsType(scope) == expressionEltType;
//recursivly on the elts...
- return areTypesCastCompatible(scope, ((ArrayBinding) castTb).elementsType(scope), expressionEltTb);
+ return areTypesCastCompatible(scope, ((ArrayBinding) castType).elementsType(scope), expressionEltType);
}
- if (castTb.isBaseType()) {
+ if (castType.isBaseType()) {
return false;
}
- if (castTb.isClass()) { //------(castTb.isClass) expressionTb.isArray ---------------
- if (scope.isJavaLangObject(castTb))
+ if (castType.isClass()) { //------(castTb.isClass) expressionTb.isArray ---------------
+ if (scope.isJavaLangObject(castType))
return true;
return false;
}
- if (castTb.isInterface()) { //------- (castTb.isInterface) expressionTb.isArray -----------
- if (scope.isJavaLangCloneable(castTb) || scope.isJavaIoSerializable(castTb)) {
+ if (castType.isInterface()) { //------- (castTb.isInterface) expressionTb.isArray -----------
+ if (scope.isJavaLangCloneable(castType) || scope.isJavaIoSerializable(castType)) {
return true;
}
return false;
@@ -103,39 +104,39 @@
}
//------------(castType) null--------------
- if (expressionTb == NullBinding) {
- return !castTb.isBaseType();
+ if (expressionType == NullBinding) {
+ return !castType.isBaseType();
}
//========BASETYPE==============
- if (expressionTb.isBaseType()) {
+ if (expressionType.isBaseType()) {
return false;
}
//========REFERENCE TYPE===================
- if (expressionTb.isClass()) {
- if (castTb.isArrayType()) { // ---- (castTb.isArray) expressionTb.isClass -------
- if (scope.isJavaLangObject(expressionTb))
+ if (expressionType.isClass()) {
+ if (castType.isArrayType()) { // ---- (castTb.isArray) expressionTb.isClass -------
+ if (scope.isJavaLangObject(expressionType))
return true;
}
- if (castTb.isBaseType()) {
+ if (castType.isBaseType()) {
return false;
}
- if (castTb.isClass()) { // ----- (castTb.isClass) expressionTb.isClass ------
- if (scope.areTypesCompatible(expressionTb, castTb))
+ if (castType.isClass()) { // ----- (castTb.isClass) expressionTb.isClass ------
+ if (expressionType.isCompatibleWith(castType))
return true;
else {
- if (scope.areTypesCompatible(castTb, expressionTb)) {
+ if (castType.isCompatibleWith(expressionType)) {
return true;
}
return false;
}
}
- if (castTb.isInterface()) { // ----- (castTb.isInterface) expressionTb.isClass -------
- if (((ReferenceBinding) expressionTb).isFinal()) { //no subclass for expressionTb, thus compile-time check is valid
- if (scope.areTypesCompatible(expressionTb, castTb))
+ if (castType.isInterface()) { // ----- (castTb.isInterface) expressionTb.isClass -------
+ if (((ReferenceBinding) expressionType).isFinal()) { //no subclass for expressionTb, thus compile-time check is valid
+ if (expressionType.isCompatibleWith(castType))
return true;
return false;
} else {
@@ -145,34 +146,34 @@
return false;
}
- if (expressionTb.isInterface()) {
- if (castTb.isArrayType()) { // ----- (castTb.isArray) expressionTb.isInterface ------
- if (scope.isJavaLangCloneable(expressionTb) || scope.isJavaIoSerializable(expressionTb))
+ if (expressionType.isInterface()) {
+ if (castType.isArrayType()) { // ----- (castTb.isArray) expressionTb.isInterface ------
+ if (scope.isJavaLangCloneable(expressionType) || scope.isJavaIoSerializable(expressionType))
//potential runtime error
{
return true;
}
return false;
}
- if (castTb.isBaseType()) {
+ if (castType.isBaseType()) {
return false;
}
- if (castTb.isClass()) { // ----- (castTb.isClass) expressionTb.isInterface --------
- if (scope.isJavaLangObject(castTb))
+ if (castType.isClass()) { // ----- (castTb.isClass) expressionTb.isInterface --------
+ if (scope.isJavaLangObject(castType))
return true;
- if (((ReferenceBinding) castTb).isFinal()) { //no subclass for castTb, thus compile-time check is valid
- if (scope.areTypesCompatible(castTb, expressionTb)) {
+ if (((ReferenceBinding) castType).isFinal()) { //no subclass for castTb, thus compile-time check is valid
+ if (castType.isCompatibleWith(expressionType)) {
return true;
}
return false;
}
return true;
}
- if (castTb.isInterface()) { // ----- (castTb.isInterface) expressionTb.isInterface -------
- if (castTb != expressionTb && (Scope.compareTypes(castTb, expressionTb) == NotRelated)) {
- MethodBinding[] castTbMethods = ((ReferenceBinding) castTb).methods();
+ if (castType.isInterface()) { // ----- (castTb.isInterface) expressionTb.isInterface -------
+ if (Scope.compareTypes(castType, expressionType) == NotRelated) {
+ MethodBinding[] castTbMethods = ((ReferenceBinding) castType).methods();
int castTbMethodsLength = castTbMethods.length;
- MethodBinding[] expressionTbMethods = ((ReferenceBinding) expressionTb).methods();
+ MethodBinding[] expressionTbMethods = ((ReferenceBinding) expressionType).methods();
int expressionTbMethodsLength = expressionTbMethods.length;
for (int i = 0; i < castTbMethodsLength; i++) {
for (int j = 0; j < expressionTbMethodsLength; j++) {
@@ -194,19 +195,20 @@
return false;
}
-public final void computeConstant(TypeBinding leftTb, TypeBinding rightTb) {
- if ((left.constant != NotAConstant) && (right.constant != NotAConstant)) {
- constant =
+public final void computeConstant(TypeBinding leftType, TypeBinding rightType) {
+ if ((this.left.constant != NotAConstant) && (this.right.constant != NotAConstant)) {
+ this.constant =
Constant.computeConstantOperationEQUAL_EQUAL(
left.constant,
- leftTb.id,
+ leftType.id,
EQUAL_EQUAL,
right.constant,
- rightTb.id);
- if (((bits & OperatorMASK) >> OperatorSHIFT) == NOT_EQUAL)
+ rightType.id);
+ if (((this.bits & OperatorMASK) >> OperatorSHIFT) == NOT_EQUAL)
constant = Constant.fromValue(!constant.booleanValue());
} else {
- constant = NotAConstant;
+ this.constant = NotAConstant;
+ // no optimization for null == null
}
}
/**
@@ -260,11 +262,11 @@
* Optimized operations are: == and !=
*/
public void generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStream, Label trueLabel, Label falseLabel, boolean valueRequired) {
- if ((constant != Constant.NotAConstant) && (constant.typeID() == T_boolean)) {
+
+ if (constant != Constant.NotAConstant) {
super.generateOptimizedBoolean(currentScope, codeStream, trueLabel, falseLabel, valueRequired);
return;
}
- int pc = codeStream.position;
if (((bits & OperatorMASK) >> OperatorSHIFT) == EQUAL_EQUAL) {
if ((left.implicitConversion & 0xF) /*compile-time*/ == T_boolean) {
generateOptimizedBooleanEqual(currentScope, codeStream, trueLabel, falseLabel, valueRequired);
@@ -278,7 +280,6 @@
generateOptimizedNonBooleanEqual(currentScope, codeStream, falseLabel, trueLabel, valueRequired);
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
}
/**
* Boolean generation for == with boolean operands
@@ -286,18 +287,16 @@
* Note this code does not optimize conditional constants !!!!
*/
public void generateOptimizedBooleanEqual(BlockScope currentScope, CodeStream codeStream, Label trueLabel, Label falseLabel, boolean valueRequired) {
- int pc = codeStream.position;
+
// optimized cases: true == x, false == x
if (left.constant != NotAConstant) {
boolean inline = left.constant.booleanValue();
right.generateOptimizedBoolean(currentScope, codeStream, (inline ? trueLabel : falseLabel), (inline ? falseLabel : trueLabel), valueRequired);
- codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
} // optimized cases: x == true, x == false
if (right.constant != NotAConstant) {
boolean inline = right.constant.booleanValue();
left.generateOptimizedBoolean(currentScope, codeStream, (inline ? trueLabel : falseLabel), (inline ? falseLabel : trueLabel), valueRequired);
- codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
// default case
@@ -318,37 +317,18 @@
}
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
}
/**
* Boolean generation for == with non-boolean operands
*
*/
public void generateOptimizedNonBooleanEqual(BlockScope currentScope, CodeStream codeStream, Label trueLabel, Label falseLabel, boolean valueRequired) {
+
int pc = codeStream.position;
Constant inline;
if ((inline = right.constant) != NotAConstant) {
- // optimized case: x == null
- if (right.constant == NullConstant.Default) {
- left.generateCode(currentScope, codeStream, valueRequired);
- if (valueRequired) {
- if (falseLabel == null) {
- if (trueLabel != null) {
- // implicit falling through the FALSE case
- codeStream.ifnull(trueLabel);
- }
- } else {
- // implicit falling through the TRUE case
- if (trueLabel == null) {
- codeStream.ifnonnull(falseLabel);
- } else {
- // no implicit fall through TRUE/FALSE --> should never occur
- }
- }
- }
- codeStream.recordPositionsFrom(pc, this.sourceStart);
- return;
- }
// optimized case: x == 0
if (((left.implicitConversion >> 4) == T_int) && (inline.intValue() == 0)) {
left.generateCode(currentScope, codeStream, valueRequired);
@@ -372,27 +352,6 @@
}
}
if ((inline = left.constant) != NotAConstant) {
- // optimized case: null == x
- if (left.constant == NullConstant.Default) {
- right.generateCode(currentScope, codeStream, valueRequired);
- if (valueRequired) {
- if (falseLabel == null) {
- if (trueLabel != null) {
- // implicit falling through the FALSE case
- codeStream.ifnull(trueLabel);
- }
- } else {
- // implicit falling through the TRUE case
- if (trueLabel == null) {
- codeStream.ifnonnull(falseLabel);
- } else {
- // no implicit fall through TRUE/FALSE --> should never occur
- }
- }
- }
- codeStream.recordPositionsFrom(pc, this.sourceStart);
- return;
- }
// optimized case: 0 == x
if (((left.implicitConversion >> 4) == T_int)
&& (inline.intValue() == 0)) {
@@ -416,6 +375,60 @@
return;
}
}
+ // null cases
+ // optimized case: x == null
+ if (right instanceof NullLiteral) {
+ if (left instanceof NullLiteral) {
+ // null == null
+ if (valueRequired) {
+ if (falseLabel == null) {
+ // implicit falling through the FALSE case
+ if (trueLabel != null) {
+ codeStream.goto_(trueLabel);
+ }
+ }
+ }
+ } else {
+ left.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired) {
+ if (falseLabel == null) {
+ if (trueLabel != null) {
+ // implicit falling through the FALSE case
+ codeStream.ifnull(trueLabel);
+ }
+ } else {
+ // implicit falling through the TRUE case
+ if (trueLabel == null) {
+ codeStream.ifnonnull(falseLabel);
+ } else {
+ // no implicit fall through TRUE/FALSE --> should never occur
+ }
+ }
+ }
+ }
+ codeStream.recordPositionsFrom(pc, this.sourceStart);
+ return;
+ } else if (left instanceof NullLiteral) { // optimized case: null == x
+ right.generateCode(currentScope, codeStream, valueRequired);
+ if (valueRequired) {
+ if (falseLabel == null) {
+ if (trueLabel != null) {
+ // implicit falling through the FALSE case
+ codeStream.ifnull(trueLabel);
+ }
+ } else {
+ // implicit falling through the TRUE case
+ if (trueLabel == null) {
+ codeStream.ifnonnull(falseLabel);
+ } else {
+ // no implicit fall through TRUE/FALSE --> should never occur
+ }
+ }
+ }
+ codeStream.recordPositionsFrom(pc, this.sourceStart);
+ return;
+ }
+
// default case
left.generateCode(currentScope, codeStream, valueRequired);
right.generateCode(currentScope, codeStream, valueRequired);
@@ -477,50 +490,50 @@
}
public TypeBinding resolveType(BlockScope scope) {
// always return BooleanBinding
- TypeBinding leftTb = left.resolveType(scope);
- TypeBinding rightTb = right.resolveType(scope);
- if (leftTb == null || rightTb == null){
+ TypeBinding leftType = left.resolveType(scope);
+ TypeBinding rightType = right.resolveType(scope);
+ if (leftType == null || rightType == null){
constant = NotAConstant;
return null;
}
// both base type
- if (leftTb.isBaseType() && rightTb.isBaseType()) {
+ if (leftType.isBaseType() && rightType.isBaseType()) {
// the code is an int
// (cast) left == (cast) rigth --> result
// 0000 0000 0000 0000 0000
// <<16 <<12 <<8 <<4 <<0
- int result = ResolveTypeTables[EQUAL_EQUAL][ (leftTb.id << 4) + rightTb.id];
+ int result = ResolveTypeTables[EQUAL_EQUAL][ (leftType.id << 4) + rightType.id];
left.implicitConversion = result >>> 12;
right.implicitConversion = (result >>> 4) & 0x000FF;
bits |= result & 0xF;
if ((result & 0x0000F) == T_undefined) {
constant = Constant.NotAConstant;
- scope.problemReporter().invalidOperator(this, leftTb, rightTb);
+ scope.problemReporter().invalidOperator(this, leftType, rightType);
return null;
}
- computeConstant(leftTb, rightTb);
- this.typeBinding = BooleanBinding;
+ computeConstant(leftType, rightType);
+ this.resolvedType = BooleanBinding;
return BooleanBinding;
}
// Object references
// spec 15.20.3
- if (areTypesCastCompatible(scope, rightTb, leftTb) || areTypesCastCompatible(scope, leftTb, rightTb)) {
+ if (areTypesCastCompatible(scope, rightType, leftType) || areTypesCastCompatible(scope, leftType, rightType)) {
// (special case for String)
- if ((rightTb.id == T_String) && (leftTb.id == T_String))
- computeConstant(leftTb, rightTb);
+ if ((rightType.id == T_String) && (leftType.id == T_String))
+ computeConstant(leftType, rightType);
else
constant = NotAConstant;
- if (rightTb.id == T_String)
+ if (rightType.id == T_String)
right.implicitConversion = String2String;
- if (leftTb.id == T_String)
+ if (leftType.id == T_String)
left.implicitConversion = String2String;
- this.typeBinding = BooleanBinding;
+ this.resolvedType = BooleanBinding;
return BooleanBinding;
}
constant = NotAConstant;
- scope.problemReporter().notCompatibleTypesError(this, leftTb, rightTb);
+ scope.problemReporter().notCompatibleTypesError(this, leftType, rightType);
return null;
}
public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
index 55dc75b..e9dca4c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -102,9 +102,10 @@
codeStream.aload_0();
// handling innerclass constructor invocation
- ReferenceBinding targetType;
- if ((targetType = binding.declaringClass).isNestedType()) {
- codeStream.generateSyntheticArgumentValues(
+ ReferenceBinding targetType = binding.declaringClass;
+ // handling innerclass instance allocation - enclosing instance arguments
+ if (targetType.isNestedType()) {
+ codeStream.generateSyntheticEnclosingInstanceValues(
currentScope,
targetType,
discardEnclosingInstance ? null : qualification,
@@ -116,6 +117,13 @@
arguments[i].generateCode(currentScope, codeStream, true);
}
}
+ // handling innerclass instance allocation - outer local arguments
+ if (targetType.isNestedType()) {
+ codeStream.generateSyntheticOuterArgumentValues(
+ currentScope,
+ targetType,
+ this);
+ }
if (syntheticAccessor != null) {
// synthetic accessor got some extra arguments appended to its signature, which need values
for (int i = 0,
@@ -165,16 +173,10 @@
&& currentScope.enclosingSourceType().isLocalType()) {
if (superType.isLocalType()) {
- ((LocalTypeBinding) superType).addInnerEmulationDependent(
- currentScope,
- qualification != null,
- true);
- // request direct access
+ ((LocalTypeBinding) superType).addInnerEmulationDependent(currentScope, qualification != null);
} else {
// locally propagate, since we already now the desired shape for sure
- currentScope.propagateInnerEmulation(superType, qualification != null, true);
- // request direct access
-
+ currentScope.propagateInnerEmulation(superType, qualification != null);
}
}
}
@@ -192,7 +194,7 @@
// constructor will not be dumped as private, no emulation required thus
} else {
syntheticAccessor =
- ((SourceTypeBinding) binding.declaringClass).addSyntheticMethod(binding);
+ ((SourceTypeBinding) binding.declaringClass).addSyntheticMethod(binding, isSuperAccess());
currentScope.problemReporter().needToEmulateMethodAccess(binding, this);
}
}
@@ -257,6 +259,9 @@
for (int i = 0; i < length; i++)
arguments[i].implicitWidening(paramTypes[i], argTypes[i]);
}
+ if (binding.isPrivate()) {
+ binding.modifiers |= AccPrivateUsed;
+ }
} else {
if (binding.declaringClass == null)
binding.declaringClass = receiverType;
@@ -313,4 +318,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
index 6a233e8..3357d28 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.impl.*;
@@ -25,25 +25,34 @@
//Expression is a subclass of Statement. See the message isValidJavaStatement()
public int implicitConversion;
-
+ public TypeBinding resolvedType;
+
public Constant constant;
public Expression() {
super();
}
- public FlowInfo analyseCode(
- BlockScope currentScope,
- FlowContext flowContext,
- FlowInfo flowInfo,
- boolean valueRequired) {
+ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
+
+ return flowInfo;
+ }
+
+ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, boolean valueRequired) {
return analyseCode(currentScope, flowContext, flowInfo);
}
- public Constant conditionalConstant() {
+ /**
+ * Constant usable for bytecode pattern optimizations, but cannot be inlined
+ * since it is not strictly equivalent to the definition of constant expressions.
+ * In particular, some side-effects may be required to occur (only the end value
+ * is known).
+ * Constant is known to be of boolean type
+ */
+ public Constant optimizedBooleanConstant() {
- return constant;
+ return this.constant;
}
public static final boolean isConstantValueRepresentable(
@@ -335,7 +344,7 @@
}
codeStream.newStringBuffer();
codeStream.dup();
- if ((typeID == T_String) || (typeID == T_null)) {
+ if (typeID == T_String || typeID == T_null) {
if (constant != NotAConstant) {
codeStream.ldc(constant.stringValue());
} else {
@@ -357,15 +366,15 @@
if (runtimeTimeType == null || compileTimeType == null)
return;
- if (compileTimeType.id == T_null) {
- // this case is possible only for constant null
- // The type of runtime is a reference type
- // The code gen use the constant id thus any value
- // for the runtime id (akak the <<4) could be used.
- // T_Object is used as some general T_reference
- implicitConversion = (T_Object << 4) + T_null;
- return;
- }
+// if (compileTimeType.id == T_null) {
+// // this case is possible only for constant null
+// // The type of runtime is a reference type
+// // The code gen use the constant id thus any value
+// // for the runtime id (akak the <<4) could be used.
+// // T_Object is used as some general T_reference
+// implicitConversion = (T_Object << 4) + T_null;
+// return;
+// }
switch (runtimeTimeType.id) {
case T_byte :
@@ -433,16 +442,17 @@
public TypeBinding resolveTypeExpecting(
BlockScope scope,
- TypeBinding expectedTb) {
+ TypeBinding expectedType) {
- TypeBinding thisTb = this.resolveType(scope);
- if (thisTb == null)
- return null;
- if (!scope.areTypesCompatible(thisTb, expectedTb)) {
- scope.problemReporter().typeMismatchError(thisTb, expectedTb, this);
+ TypeBinding expressionType = this.resolveType(scope);
+ if (expressionType == null) return null;
+ if (expressionType == expectedType) return expressionType;
+
+ if (!expressionType.isCompatibleWith(expectedType)) {
+ scope.problemReporter().typeMismatchError(expressionType, expectedType, this);
return null;
}
- return thisTb;
+ return expressionType;
}
public String toString(int tab) {
@@ -481,4 +491,4 @@
return this;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExtendedStringLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExtendedStringLiteral.java
index 1560504..e79212d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExtendedStringLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExtendedStringLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -15,8 +15,6 @@
public class ExtendedStringLiteral extends StringLiteral {
- private static final int INIT_SIZE = 30;
-
/**
* Build a string+char literal
*/
@@ -79,4 +77,4 @@
visitor.visit(this, scope);
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java
index d9aa624..f805141 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FalseLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
index a8fa506..75276ea 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -55,6 +55,11 @@
FlowContext flowContext,
FlowInfo flowInfo) {
+ if (this.binding != null && this.binding.isPrivate() && !this.binding.isPrivateUsed()) {
+ if (!initializationScope.referenceCompilationUnit().compilationResult.hasSyntaxError()) {
+ initializationScope.problemReporter().unusedPrivateField(this);
+ }
+ }
// cannot define static non-constant field inside nested class
if (binding != null
&& binding.isValidBinding()
@@ -74,9 +79,6 @@
.analyseCode(initializationScope, flowContext, flowInfo)
.unconditionalInits();
flowInfo.markAsDefinitelyAssigned(binding);
- } else {
- flowInfo.markAsDefinitelyNotAssigned(binding);
- // clear the bit in case it was already set (from enclosing info)
}
return flowInfo;
}
@@ -150,7 +152,7 @@
if (isTypeUseDeprecated(this.binding.type, initializationScope))
initializationScope.problemReporter().deprecatedType(this.binding.type, this.type);
- this.type.binding = this.binding.type; // update binding for type reference
+ this.type.resolvedType = this.binding.type; // update binding for type reference
// the resolution of the initialization hasn't been done
if (this.initialization == null) {
@@ -168,7 +170,7 @@
if (initialization instanceof ArrayInitializer) {
- if ((initializationTypeBinding = this.initialization.resolveTypeExpecting(initializationScope, typeBinding)) != null) {
+ if ((initializationTypeBinding = this.initialization.resolveTypeExpecting(initializationScope, typeBinding)) != null) {
((ArrayInitializer) this.initialization).binding = (ArrayBinding) initializationTypeBinding;
this.initialization.implicitWidening(typeBinding, initializationTypeBinding);
}
@@ -179,7 +181,7 @@
this.initialization.implicitWidening(typeBinding, initializationTypeBinding);
- } else if (initializationScope.areTypesCompatible(initializationTypeBinding, typeBinding)) {
+ } else if (initializationTypeBinding.isCompatibleWith(typeBinding)) {
this.initialization.implicitWidening(typeBinding, initializationTypeBinding);
} else {
@@ -211,4 +213,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
index 727751f..f0a949b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -45,7 +45,7 @@
// compound assignment extra work
if (isCompound) { // check the variable part is initialized if blank final
- if (binding.isFinal()
+ if (binding.isBlankFinal()
&& receiver.isThis()
&& currentScope.allowBlankFinalFieldAssignment(binding)
&& (!flowInfo.isDefinitelyAssigned(binding))) {
@@ -54,6 +54,10 @@
}
manageSyntheticReadAccessIfNecessary(currentScope);
}
+ flowInfo =
+ receiver
+ .analyseCode(currentScope, flowContext, flowInfo, !binding.isStatic())
+ .unconditionalInits();
if (assignment.expression != null) {
flowInfo =
assignment
@@ -61,27 +65,27 @@
.analyseCode(currentScope, flowContext, flowInfo)
.unconditionalInits();
}
- flowInfo =
- receiver
- .analyseCode(currentScope, flowContext, flowInfo, !binding.isStatic())
- .unconditionalInits();
manageSyntheticWriteAccessIfNecessary(currentScope);
// check if assigning a final field
if (binding.isFinal()) {
// in a context where it can be assigned?
- if (receiver.isThis()
+ if (binding.isBlankFinal()
+ && !isCompound
+ && receiver.isThis()
&& !(receiver instanceof QualifiedThisReference)
+ && ((receiver.bits & ParenthesizedMASK) == 0) // (this).x is forbidden
&& currentScope.allowBlankFinalFieldAssignment(binding)) {
if (flowInfo.isPotentiallyAssigned(binding)) {
currentScope.problemReporter().duplicateInitializationOfBlankFinalField(
binding,
this);
+ } else {
+ flowContext.recordSettingFinal(binding, this);
}
flowInfo.markAsDefinitelyAssigned(binding);
- flowContext.recordSettingFinal(binding, this);
} else {
- // assigning a final field outside an initializer or constructor
+ // assigning a final field outside an initializer or constructor or wrong reference
currentScope.problemReporter().cannotAssignToFinalField(binding, this);
}
}
@@ -154,10 +158,7 @@
}
} else {
boolean isStatic = this.codegenBinding.isStatic();
- receiver.generateCode(
- currentScope,
- codeStream,
- valueRequired && (!isStatic) && (this.codegenBinding.constant == NotAConstant));
+ receiver.generateCode(currentScope, codeStream, !isStatic);
if (valueRequired) {
if (this.codegenBinding.constant == NotAConstant) {
if (this.codegenBinding.declaringClass == null) { // array length
@@ -175,8 +176,17 @@
}
codeStream.generateImplicitConversion(implicitConversion);
} else {
+ if (!isStatic) {
+ codeStream.invokeObjectGetClass(); // perform null check
+ codeStream.pop();
+ }
codeStream.generateConstant(this.codegenBinding.constant, implicitConversion);
}
+ } else {
+ if (!isStatic){
+ codeStream.invokeObjectGetClass(); // perform null check
+ codeStream.pop();
+ }
}
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
@@ -286,10 +296,9 @@
public static final Constant getConstantFor(
FieldBinding binding,
- boolean implicitReceiver,
Reference reference,
- Scope referenceScope,
- int indexInQualification) {
+ boolean isImplicit,
+ Scope referenceScope) {
//propagation of the constant.
@@ -311,12 +320,8 @@
return binding.constant = NotAConstant;
}
if (binding.constant != null) {
- if (indexInQualification == 0) {
- return binding.constant;
- }
- //see previous comment for the (sould-always-be) valid cast
- QualifiedNameReference qualifiedReference = (QualifiedNameReference) reference;
- if (indexInQualification == (qualifiedReference.indexOfFirstFieldBinding - 1)) {
+ if (isImplicit || (reference instanceof QualifiedNameReference
+ && binding == ((QualifiedNameReference)reference).binding)) {
return binding.constant;
}
return NotAConstant;
@@ -331,47 +336,15 @@
TypeDeclaration typeDecl = typeBinding.scope.referenceContext;
FieldDeclaration fieldDecl = typeDecl.declarationOf(binding);
- //what scope to use (depend on the staticness of the field binding)
- MethodScope fieldScope =
- binding.isStatic()
+ fieldDecl.resolve(binding.isStatic() //side effect on binding
? typeDecl.staticInitializerScope
- : typeDecl.initializerScope;
+ : typeDecl.initializerScope);
- if (implicitReceiver) { //Determine if the ref is legal in the current class of the field
- //i.e. not a forward reference .... (they are allowed when the receiver is explicit ! ... Please don't ask me why !...yet another java mystery...)
- if (fieldScope.fieldDeclarationIndex == MethodScope.NotInFieldDecl) {
- // no field is currently being analysed in typeDecl
- fieldDecl.resolve(fieldScope); //side effect on binding :-) ...
- return binding.constant;
- }
- //We are re-entering the same class fields analysing
- if ((reference != null)
- && (binding.declaringClass == referenceScope.enclosingSourceType()) // only complain for access inside same type
- && (binding.id > fieldScope.fieldDeclarationIndex)) {
- //forward reference. The declaration remains unresolved.
- referenceScope.problemReporter().forwardReference(reference, indexInQualification, typeBinding);
- return NotAConstant;
- }
- fieldDecl.resolve(fieldScope); //side effect on binding :-) ...
+ if (isImplicit || (reference instanceof QualifiedNameReference
+ && binding == ((QualifiedNameReference)reference).binding)) {
return binding.constant;
}
- //the field reference is explicity. It has to be a "simple" like field reference to get the
- //constant propagation. For example in Packahe.Type.field1.field2 , field1 may have its
- //constant having a propagation where field2 is always not propagating its
- if (indexInQualification == 0) {
- fieldDecl.resolve(fieldScope); //side effect on binding :-) ...
- return binding.constant;
- }
- // Side-effect on the field binding may not be propagated out for the qualified reference
- // unless it occurs in first place of the name sequence
- fieldDecl.resolve(fieldScope); //side effect on binding :-) ...
- //see previous comment for the cast that should always be valid
- QualifiedNameReference qualifiedReference = (QualifiedNameReference) reference;
- if (indexInQualification == (qualifiedReference.indexOfFirstFieldBinding - 1)) {
- return binding.constant;
- } else {
- return NotAConstant;
- }
+ return NotAConstant;
}
public boolean isSuperAccess() {
@@ -425,12 +398,12 @@
}
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, field's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
if (binding.declaringClass != this.receiverType
&& !this.receiverType.isArrayType()
&& binding.declaringClass != null // array.length
&& binding.constant == NotAConstant
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
&& binding.declaringClass.id != T_Object)
//no change for Object fields (in case there was)
|| !binding.declaringClass.canBeSeenBy(currentScope))) {
@@ -482,12 +455,12 @@
}
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, field's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
if (binding.declaringClass != this.receiverType
&& !this.receiverType.isArrayType()
&& binding.declaringClass != null // array.length
&& binding.constant == NotAConstant
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
&& binding.declaringClass.id != T_Object)
//no change for Object fields (in case there was)
|| !binding.declaringClass.canBeSeenBy(currentScope))) {
@@ -522,18 +495,21 @@
if (isFieldUseDeprecated(binding, scope))
scope.problemReporter().deprecatedField(binding, this);
- // check for this.x in static is done in the resolution of the receiver
- constant =
- FieldReference.getConstantFor(
- binding,
- receiver == ThisReference.ThisImplicit,
- this,
- scope,
- 0);
- if (receiver != ThisReference.ThisImplicit)
+ boolean isImplicitThisRcv = receiver.isImplicitThis();
+ constant = FieldReference.getConstantFor(binding, this, isImplicitThisRcv, scope);
+ if (!isImplicitThisRcv) {
constant = NotAConstant;
-
- return binding.type;
+ }
+ if (binding.isStatic()) {
+ // static field accessed through receiver? legal but unoptimal (optional warning)
+ if (!(isImplicitThisRcv
+ || receiver.isSuper()
+ || (receiver instanceof NameReference
+ && (((NameReference) receiver).bits & BindingIds.TYPE) != 0))) {
+ scope.problemReporter().unnecessaryReceiverForStaticField(this, binding);
+ }
+ }
+ return this.resolvedType = binding.type;
}
public void setActualReceiverType(ReferenceBinding receiverType) {
@@ -565,4 +541,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FloatLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FloatLiteral.java
index d7fb60f..fcae6d1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FloatLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FloatLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
index 583c44d..52f01fd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
@@ -1,18 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.flow.*;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.*;
public class ForStatement extends Statement {
@@ -70,15 +72,18 @@
preCondInitStateIndex =
currentScope.methodScope().recordInitializationStates(flowInfo);
- boolean conditionIsInlinedToTrue =
- condition == null || (condition.constant != NotAConstant && condition.constant.booleanValue() == true);
- boolean conditionIsInlinedToFalse =
- ! conditionIsInlinedToTrue && (condition.constant != NotAConstant && condition.constant.booleanValue() == false);
+ Constant cst = this.condition == null ? null : this.condition.constant;
+ boolean isConditionTrue = cst == null || (cst != NotAConstant && cst.booleanValue() == true);
+ boolean isConditionFalse = cst != null && (cst != NotAConstant && cst.booleanValue() == false);
+
+ cst = this.condition == null ? null : this.condition.optimizedBooleanConstant();
+ boolean isConditionOptimizedTrue = cst == null || (cst != NotAConstant && cst.booleanValue() == true);
+ boolean isConditionOptimizedFalse = cst != null && (cst != NotAConstant && cst.booleanValue() == false);
// process the condition
LoopingFlowContext condLoopContext = null;
if (condition != null) {
- if (!conditionIsInlinedToTrue) {
+ if (!isConditionTrue) {
flowInfo =
condition.analyseCode(
scope,
@@ -91,13 +96,14 @@
// process the action
LoopingFlowContext loopingContext;
FlowInfo actionInfo;
- if ((action == null) || action.isEmptyBlock()) {
+ if (action == null
+ || (action.isEmptyBlock() && currentScope.environment().options.complianceLevel <= CompilerOptions.JDK1_3)) {
if (condLoopContext != null)
condLoopContext.complainOnFinalAssignmentsInLoop(scope, flowInfo);
- if (conditionIsInlinedToTrue) {
- return FlowInfo.DeadEnd;
+ if (isConditionTrue) {
+ return FlowInfo.DEAD_END;
} else {
- if (conditionIsInlinedToFalse){
+ if (isConditionFalse){
continueLabel = null; // for(;false;p());
}
actionInfo = flowInfo.initsWhenTrue().copy();
@@ -111,17 +117,20 @@
condIfTrueInitStateIndex =
currentScope.methodScope().recordInitializationStates(initsWhenTrue);
- actionInfo = conditionIsInlinedToFalse
- ? FlowInfo.DeadEnd // unreachable when condition inlined to false
- : initsWhenTrue.copy();
- if (!actionInfo.complainIfUnreachable(action, scope)) {
+ if (isConditionFalse) {
+ actionInfo = FlowInfo.DEAD_END;
+ } else {
+ actionInfo = initsWhenTrue.copy();
+ if (isConditionOptimizedFalse){
+ actionInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
+ }
+ if (!actionInfo.complainIfUnreachable(action, scope, false)) {
actionInfo = action.analyseCode(scope, loopingContext, actionInfo);
}
// code generation can be optimized when no need to continue in the loop
- if (((actionInfo == FlowInfo.DeadEnd) || actionInfo.isFakeReachable())
- && ((loopingContext.initsOnContinue == FlowInfo.DeadEnd)
- || loopingContext.initsOnContinue.isFakeReachable())) {
+ if (!actionInfo.isReachable() && !loopingContext.initsOnContinue.isReachable()) {
continueLabel = null;
} else {
if (condLoopContext != null)
@@ -138,12 +147,12 @@
int i = 0, count = increments.length;
while (i < count)
actionInfo = increments[i++].analyseCode(scope, loopContext, actionInfo);
- loopContext.complainOnFinalAssignmentsInLoop(scope, flowInfo);
+ loopContext.complainOnFinalAssignmentsInLoop(scope, actionInfo);
}
// infinite loop
FlowInfo mergedInfo;
- if (conditionIsInlinedToTrue) {
+ if (isConditionOptimizedTrue) {
mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(
mergedInfo = loopingContext.initsOnBreak);
@@ -154,6 +163,9 @@
mergedInfo =
flowInfo.initsWhenFalse().unconditionalInits().mergedWith(
loopingContext.initsOnBreak.unconditionalInits());
+ if (isConditionOptimizedTrue && continueLabel == null){
+ mergedInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(mergedInfo);
return mergedInfo;
@@ -248,9 +260,12 @@
}
public void resetStateForCodeGeneration() {
-
- this.breakLabel.resetStateForCodeGeneration();
- this.continueLabel.resetStateForCodeGeneration();
+ if (this.breakLabel != null) {
+ this.breakLabel.resetStateForCodeGeneration();
+ }
+ if (this.continueLabel != null) {
+ this.continueLabel.resetStateForCodeGeneration();
+ }
}
public void resolve(BlockScope upperScope) {
@@ -333,4 +348,4 @@
}
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
index cd19c74..859548e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -63,86 +63,84 @@
FlowContext flowContext,
FlowInfo flowInfo) {
- FlowInfo thenFlowInfo, elseFlowInfo;
-
// process the condition
flowInfo = condition.analyseCode(currentScope, flowContext, flowInfo);
+ Constant cst = this.condition.optimizedBooleanConstant();
+ boolean isConditionOptimizedTrue = cst != NotAConstant && cst.booleanValue() == true;
+ boolean isConditionOptimizedFalse = cst != NotAConstant && cst.booleanValue() == false;
+
// process the THEN part
- if (thenStatement == null) {
- thenFlowInfo = flowInfo.initsWhenTrue();
- } else {
- Constant cst;
- thenFlowInfo =
- ((((cst = condition.constant) != NotAConstant)
- && (cst.booleanValue() == false))
- || (((cst = condition.conditionalConstant()) != NotAConstant)
- && (cst.booleanValue() == false)))
- ? (flowInfo.initsWhenTrue().copy().markAsFakeReachable(true))
- : flowInfo.initsWhenTrue().copy();
+ FlowInfo thenFlowInfo = flowInfo.initsWhenTrue().copy();
+ if (isConditionOptimizedFalse) {
+ thenFlowInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
+ if (this.thenStatement != null) {
// Save info for code gen
thenInitStateIndex =
currentScope.methodScope().recordInitializationStates(thenFlowInfo);
- if (!thenFlowInfo.complainIfUnreachable(thenStatement, currentScope)) {
+ if (!thenFlowInfo.complainIfUnreachable(thenStatement, currentScope, false)) {
thenFlowInfo =
thenStatement.analyseCode(currentScope, flowContext, thenFlowInfo);
}
};
// optimizing the jump around the ELSE part
- thenExit = (thenFlowInfo == FlowInfo.DeadEnd) || thenFlowInfo.isFakeReachable();
+ this.thenExit = !thenFlowInfo.isReachable();
// process the ELSE part
- if (elseStatement == null) {
- elseFlowInfo = flowInfo.initsWhenFalse();
- } else {
- Constant cst;
- elseFlowInfo =
- ((((cst = condition.constant) != NotAConstant) && (cst.booleanValue() == true))
- || (((cst = condition.conditionalConstant()) != NotAConstant)
- && (cst.booleanValue() == true)))
- ? (flowInfo.initsWhenFalse().copy().markAsFakeReachable(true))
- : flowInfo.initsWhenFalse().copy();
+ FlowInfo elseFlowInfo = flowInfo.initsWhenFalse().copy();
+ if (isConditionOptimizedTrue) {
+ elseFlowInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
+ if (this.elseStatement != null) {
// Save info for code gen
elseInitStateIndex =
currentScope.methodScope().recordInitializationStates(elseFlowInfo);
- if (!elseFlowInfo.complainIfUnreachable(elseStatement, currentScope)) {
+ if (!elseFlowInfo.complainIfUnreachable(elseStatement, currentScope, false)) {
elseFlowInfo =
elseStatement.analyseCode(currentScope, flowContext, elseFlowInfo);
}
}
+ boolean elseExit = !elseFlowInfo.isReachable();
+
// merge THEN & ELSE initializations
FlowInfo mergedInfo;
- if ((condition.constant != NotAConstant)
- && (condition.constant.booleanValue() == true)) {
- // IF (TRUE)
- if (thenExit) {
- mergedInfo = elseFlowInfo.markAsFakeReachable(true);
- mergedInitStateIndex =
- currentScope.methodScope().recordInitializationStates(mergedInfo);
- return mergedInfo;
+// if (isConditionOptimizedTrue){
+// if (!this.thenExit) {
+// mergedInfo = thenFlowInfo;
+// } else {
+// mergedInfo = elseFlowInfo.setReachMode(FlowInfo.UNREACHABLE);
+// }
+//
+// } else if (isConditionOptimizedFalse) {
+// if (!elseExit) {
+// mergedInfo = elseFlowInfo;
+// } else {
+// mergedInfo = thenFlowInfo.setReachMode(FlowInfo.UNREACHABLE);
+// }
+//
+// } else {
+// mergedInfo = thenFlowInfo.mergedWith(elseFlowInfo.unconditionalInits());
+// }
+ if (isConditionOptimizedTrue){
+ if (!this.thenExit) {
+ mergedInfo = thenFlowInfo.addPotentialInitializationsFrom(elseFlowInfo);
} else {
- mergedInitStateIndex =
- currentScope.methodScope().recordInitializationStates(thenFlowInfo);
- return thenFlowInfo;
+ mergedInfo = elseFlowInfo.setReachMode(FlowInfo.UNREACHABLE);
}
+
+ } else if (isConditionOptimizedFalse) {
+ if (!elseExit) {
+ mergedInfo = elseFlowInfo.addPotentialInitializationsFrom(thenFlowInfo);
+ } else {
+ mergedInfo = thenFlowInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
+
} else {
- // IF (FALSE)
- if ((condition.constant != NotAConstant)
- && (condition.constant.booleanValue() == false)) {
- if (elseFlowInfo.isDeadEnd()) {
- mergedInfo = thenFlowInfo.markAsFakeReachable(true);
- mergedInitStateIndex =
- currentScope.methodScope().recordInitializationStates(mergedInfo);
- return mergedInfo;
- } else {
- mergedInitStateIndex =
- currentScope.methodScope().recordInitializationStates(elseFlowInfo);
- return elseFlowInfo;
- }
- }
+ mergedInfo = thenFlowInfo.mergedWith(elseFlowInfo.unconditionalInits());
}
- mergedInfo = thenFlowInfo.mergedWith(elseFlowInfo.unconditionalInits());
+
mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(mergedInfo);
return mergedInfo;
@@ -156,32 +154,28 @@
*/
public void generateCode(BlockScope currentScope, CodeStream codeStream) {
- if ((bits & IsReachableMASK) == 0) {
+ if ((this.bits & IsReachableMASK) == 0) {
return;
}
int pc = codeStream.position;
Label endifLabel = new Label(codeStream);
// optimizing the then/else part code gen
- Constant cst, condCst;
- boolean hasThenPart =
- !((((cst = condition.constant) != NotAConstant)
- && (cst.booleanValue() == false))
- || (thenStatement == null)
- || (thenStatement.isEmptyBlock())
- || (((condCst = condition.conditionalConstant()) != NotAConstant)
- && (condCst.booleanValue() == false)));
+ Constant cst;
+ boolean hasThenPart =
+ !(((cst = this.condition.optimizedBooleanConstant()) != NotAConstant
+ && cst.booleanValue() == false)
+ || this.thenStatement == null
+ || this.thenStatement.isEmptyBlock());
boolean hasElsePart =
- !(((cst != NotAConstant) && (cst.booleanValue() == true))
- || (elseStatement == null)
- || (elseStatement.isEmptyBlock())
- || (((condCst = condition.conditionalConstant()) != NotAConstant)
- && (condCst.booleanValue() == true)));
+ !((cst != NotAConstant && cst.booleanValue() == true)
+ || this.elseStatement == null
+ || this.elseStatement.isEmptyBlock());
if (hasThenPart) {
Label falseLabel;
// generate boolean condition
- condition.generateOptimizedBoolean(
+ this.condition.generateOptimizedBoolean(
currentScope,
codeStream,
null,
@@ -195,10 +189,10 @@
codeStream.addDefinitelyAssignedVariables(currentScope, thenInitStateIndex);
}
// generate then statement
- thenStatement.generateCode(currentScope, codeStream);
+ this.thenStatement.generateCode(currentScope, codeStream);
// jump around the else statement
if (hasElsePart && !thenExit) {
- thenStatement.branchChainTo(endifLabel);
+ this.thenStatement.branchChainTo(endifLabel);
int position = codeStream.position;
codeStream.goto_(endifLabel);
codeStream.updateLastRecordedEndPC(position);
@@ -208,7 +202,7 @@
} else {
if (hasElsePart) {
// generate boolean condition
- condition.generateOptimizedBoolean(
+ this.condition.generateOptimizedBoolean(
currentScope,
codeStream,
endifLabel,
@@ -216,7 +210,7 @@
true);
} else {
// generate condition side-effects
- condition.generateCode(currentScope, codeStream, false);
+ this.condition.generateCode(currentScope, codeStream, false);
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
}
@@ -229,7 +223,7 @@
elseInitStateIndex);
codeStream.addDefinitelyAssignedVariables(currentScope, elseInitStateIndex);
}
- elseStatement.generateCode(currentScope, codeStream);
+ this.elseStatement.generateCode(currentScope, codeStream);
}
endifLabel.place();
// May loose some local variable initializations : affecting the local variable attributes
@@ -275,4 +269,4 @@
}
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ImportReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ImportReference.java
index e4cc0a8..47aa3e1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ImportReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ImportReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java
index 3d66060..c949513 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Initializer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -25,7 +25,7 @@
this.block = block;
this.modifiers = modifiers;
- declarationSourceStart = sourceStart = block.sourceStart;
+ declarationSourceStart = sourceStart = bodyStart = block.sourceStart;
}
public FlowInfo analyseCode(
@@ -111,6 +111,6 @@
if (visitor.visit(this, scope)) {
block.traverse(visitor, scope);
}
- visitor.visit(this, scope);
+ visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InnerTypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InnerTypeDeclaration.java
index 67309c7..12e1543 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InnerTypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InnerTypeDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
index 9bab805..3cdd78f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -44,13 +44,15 @@
public final boolean areTypesCastCompatible(
BlockScope scope,
- TypeBinding castTb,
- TypeBinding expressionTb) {
+ TypeBinding castType,
+ TypeBinding expressionType) {
// see specifications p.68
//A more cpmplete version of this method is provided on
//CastExpression (it deals with constant and need runtime checkcast)
+ if (castType == expressionType) return true;
+
//by grammatical construction, the first test is ALWAYS false
//if (castTb.isBaseType())
//{ if (expressionTb.isBaseType())
@@ -71,33 +73,32 @@
//else
{ //-------------checkcast to something which is NOT a basetype----------------------------------
- if (NullBinding == expressionTb)
- //null is compatible with every thing ....
- {
+ //null is compatible with every thing ....
+ if (NullBinding == expressionType) {
return true;
}
- if (expressionTb.isArrayType()) {
- if (castTb.isArrayType()) {
+ if (expressionType.isArrayType()) {
+ if (castType.isArrayType()) {
//------- (castTb.isArray) expressionTb.isArray -----------
- TypeBinding expressionEltTb = ((ArrayBinding) expressionTb).elementsType(scope);
+ TypeBinding expressionEltTb = ((ArrayBinding) expressionType).elementsType(scope);
if (expressionEltTb.isBaseType())
// <---stop the recursion-------
- return ((ArrayBinding) castTb).elementsType(scope) == expressionEltTb;
+ return ((ArrayBinding) castType).elementsType(scope) == expressionEltTb;
//recursivly on the elts...
return areTypesCastCompatible(
scope,
- ((ArrayBinding) castTb).elementsType(scope),
+ ((ArrayBinding) castType).elementsType(scope),
expressionEltTb);
}
- if (castTb.isClass()) {
+ if (castType.isClass()) {
//------(castTb.isClass) expressionTb.isArray ---------------
- if (scope.isJavaLangObject(castTb))
+ if (scope.isJavaLangObject(castType))
return true;
return false;
}
- if (castTb.isInterface()) {
+ if (castType.isInterface()) {
//------- (castTb.isInterface) expressionTb.isArray -----------
- if (scope.isJavaLangCloneable(castTb) || scope.isJavaIoSerializable(castTb)) {
+ if (scope.isJavaLangCloneable(castType) || scope.isJavaIoSerializable(castType)) {
return true;
}
return false;
@@ -105,33 +106,33 @@
return false;
}
- if (expressionTb.isBaseType()) {
+ if (expressionType.isBaseType()) {
return false;
}
- if (expressionTb.isClass()) {
- if (castTb.isArrayType()) {
+ if (expressionType.isClass()) {
+ if (castType.isArrayType()) {
// ---- (castTb.isArray) expressionTb.isClass -------
- if (scope.isJavaLangObject(expressionTb)) {
+ if (scope.isJavaLangObject(expressionType)) {
return true;
} else {
return false;
}
}
- if (castTb.isClass()) { // ----- (castTb.isClass) expressionTb.isClass ------
- if (scope.areTypesCompatible(expressionTb, castTb))
+ if (castType.isClass()) { // ----- (castTb.isClass) expressionTb.isClass ------
+ if (expressionType.isCompatibleWith(castType))
return true;
else {
- if (scope.areTypesCompatible(castTb, expressionTb)) {
+ if (castType.isCompatibleWith(expressionType)) {
return true;
}
return false;
}
}
- if (castTb.isInterface()) {
+ if (castType.isInterface()) {
// ----- (castTb.isInterface) expressionTb.isClass -------
- if (((ReferenceBinding) expressionTb).isFinal()) {
+ if (((ReferenceBinding) expressionType).isFinal()) {
//no subclass for expressionTb, thus compile-time check is valid
- if (scope.areTypesCompatible(expressionTb, castTb))
+ if (expressionType.isCompatibleWith(castType))
return true;
return false;
} else {
@@ -141,38 +142,37 @@
return false;
}
- if (expressionTb.isInterface()) {
- if (castTb.isArrayType()) {
+ if (expressionType.isInterface()) {
+ if (castType.isArrayType()) {
// ----- (castTb.isArray) expressionTb.isInterface ------
- if (scope.isJavaLangCloneable(expressionTb)
- || scope.isJavaIoSerializable(expressionTb))
+ if (scope.isJavaLangCloneable(expressionType)
+ || scope.isJavaIoSerializable(expressionType))
//potential runtime error
{
return true;
}
return false;
}
- if (castTb.isClass()) {
+ if (castType.isClass()) {
// ----- (castTb.isClass) expressionTb.isInterface --------
- if (scope.isJavaLangObject(castTb))
+ if (scope.isJavaLangObject(castType))
return true;
- if (((ReferenceBinding) castTb).isFinal()) {
+ if (((ReferenceBinding) castType).isFinal()) {
//no subclass for castTb, thus compile-time check is valid
- if (scope.areTypesCompatible(castTb, expressionTb)) {
+ if (castType.isCompatibleWith(expressionType)) {
return true;
}
return false;
}
return true;
}
- if (castTb.isInterface()) {
+ if (castType.isInterface()) {
// ----- (castTb.isInterface) expressionTb.isInterface -------
- if (castTb != expressionTb
- && (Scope.compareTypes(castTb, expressionTb) == NotRelated)) {
- MethodBinding[] castTbMethods = ((ReferenceBinding) castTb).methods();
+ if ((Scope.compareTypes(castType, expressionType) == NotRelated)) {
+ MethodBinding[] castTbMethods = ((ReferenceBinding) castType).methods();
int castTbMethodsLength = castTbMethods.length;
MethodBinding[] expressionTbMethods =
- ((ReferenceBinding) expressionTb).methods();
+ ((ReferenceBinding) expressionType).methods();
int expressionTbMethodsLength = expressionTbMethods.length;
for (int i = 0; i < castTbMethodsLength; i++) {
for (int j = 0; j < expressionTbMethodsLength; j++) {
@@ -209,7 +209,7 @@
int pc = codeStream.position;
expression.generateCode(currentScope, codeStream, true);
- codeStream.instance_of(type.binding);
+ codeStream.instance_of(type.resolvedType);
if (!valueRequired)
codeStream.pop();
codeStream.recordPositionsFrom(pc, this.sourceStart);
@@ -218,16 +218,16 @@
public TypeBinding resolveType(BlockScope scope) {
constant = NotAConstant;
- TypeBinding expressionTb = expression.resolveType(scope);
- TypeBinding checkTb = type.resolveType(scope);
- if (expressionTb == null || checkTb == null)
+ TypeBinding expressionType = expression.resolveType(scope);
+ TypeBinding checkType = type.resolveType(scope);
+ if (expressionType == null || checkType == null)
return null;
- if (!areTypesCastCompatible(scope, checkTb, expressionTb)) {
- scope.problemReporter().notCompatibleTypesError(this, expressionTb, checkTb);
+ if (!areTypesCastCompatible(scope, checkType, expressionType)) {
+ scope.problemReporter().notCompatibleTypesError(this, expressionType, checkType);
return null;
}
- this.typeBinding = BooleanBinding;
+ this.resolvedType = BooleanBinding;
return BooleanBinding;
}
@@ -245,4 +245,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteral.java
index 965e101..035d067 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -129,6 +129,7 @@
if (constant == FORMAT_ERROR) {
constant = NotAConstant;
scope.problemReporter().constantOutOfFormat(this);
+ this.resolvedType = null;
return null;
}
return tb;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteralMinValue.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteralMinValue.java
index cd9211e..0314d6f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteralMinValue.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IntLiteralMinValue.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.impl.*;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
index 5378a69..f0ce979 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -67,7 +67,8 @@
public AstNode concreteStatement() {
- return statement.concreteStatement();
+ // return statement.concreteStatement(); // for supporting nested labels: a:b:c: someStatement (see 21912)
+ return statement;
}
/**
@@ -120,7 +121,8 @@
}
public void resetStateForCodeGeneration() {
-
- this.targetLabel.resetStateForCodeGeneration();
+ if (this.targetLabel != null) {
+ this.targetLabel.resetStateForCodeGeneration();
+ }
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Literal.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Literal.java
index 129fa9c..404b52b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Literal.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Literal.java
@@ -1,25 +1,31 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
public abstract class Literal extends Expression {
-
public Literal(int s,int e) {
sourceStart = s ;
sourceEnd= e;
}
+
+public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
+ return flowInfo;
+}
+
public abstract void computeConstant() ;
//ON ERROR constant STAYS NULL
public abstract TypeBinding literalType(BlockScope scope);
@@ -32,7 +38,8 @@
constant = Constant.NotAConstant;
return null;
}
- return literalType(scope);
+ this.resolvedType = literalType(scope);
+ return this.resolvedType;
}
public abstract char[] source() ;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
index 7e731fe..daed2c3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -32,10 +32,10 @@
this.sourceEnd = sourceEnd;
if (initialization != null) {
this.declarationSourceEnd = initialization.sourceEnd;
+ this.declarationEnd = initialization.sourceEnd;
} else {
- this.declarationSourceEnd = sourceEnd;
+ this.declarationEnd = sourceEnd;
}
- this.declarationEnd = this.declarationSourceEnd;
}
public FlowInfo analyseCode(
@@ -44,30 +44,36 @@
FlowInfo flowInfo) {
// record variable initialization if any
- if (!flowInfo.isDeadEnd() && !flowInfo.isFakeReachable()) {
+ if (flowInfo.isReachable()) {
bits |= IsLocalDeclarationReachableMASK; // only set if actually reached
}
- if (initialization == null)
+ if (initialization == null)
return flowInfo;
+
flowInfo =
initialization
.analyseCode(currentScope, flowContext, flowInfo)
.unconditionalInits();
+
+ // final int i = (i = 0);
+ // no need to complain since (i = 0) part will get the blame
+ //if (binding.isFinal() && flowInfo.isPotentiallyAssigned(binding)) {
+ // currentScope.problemReporter().duplicateInitializationOfFinalLocal(binding, this);
+ //}
+
flowInfo.markAsDefinitelyAssigned(binding);
return flowInfo;
}
public void checkModifiers() {
- //only potential valid modifier is <<final>>
- if (((modifiers & AccJustFlag) | AccFinal) != AccFinal)
+ //only potential valid modifier is <<final>>
+ if (((modifiers & AccJustFlag) & ~AccFinal) != 0)
//AccModifierProblem -> other (non-visibility problem)
//AccAlternateModifierProblem -> duplicate modifier
//AccModifierProblem | AccAlternateModifierProblem -> visibility problem"
- // -x-1 returns the bitInvert
- modifiers =
- (modifiers & (-AccAlternateModifierProblem - 1)) | AccModifierProblem;
+ modifiers = (modifiers & ~AccAlternateModifierProblem) | AccModifierProblem;
}
/**
@@ -76,15 +82,17 @@
*/
public void generateCode(BlockScope currentScope, CodeStream codeStream) {
+ // even if not reachable, variable must be added to visible if allocated (28298)
+ if (binding.resolvedPosition != -1) {
+ codeStream.addVisibleLocalVariable(binding);
+ }
if ((bits & IsReachableMASK) == 0) {
return;
}
int pc = codeStream.position;
Constant inlinedValue;
+
// something to initialize?
- if (binding.resolvedPosition != -1) {
- codeStream.addVisibleLocalVariable(binding);
- }
if (initialization != null) {
// initialize to constant value?
if ((inlinedValue = initialization.constant) != NotAConstant) {
@@ -102,6 +110,13 @@
initialization.generateCode(currentScope, codeStream, true);
// if binding unused generate then discard the value
if (binding.resolvedPosition != -1) {
+ // 26903, need extra cast to store null in array local var
+ if (binding.type.isArrayType()
+ && (initialization.resolvedType == NullBinding // arrayLoc = null
+ || ((initialization instanceof CastExpression) // arrayLoc = (type[])null
+ && (((CastExpression)initialization).innermostCastedExpression().resolvedType == NullBinding)))){
+ codeStream.checkcast(binding.type);
+ }
codeStream.store(binding, false);
if (binding.initializationCount == 0) {
/* Variable may have been initialized during the code initializing it
@@ -151,6 +166,9 @@
// the name already exists... may carry on with the first binding...
scope.problemReporter().redefineLocal(this);
} else {
+ if ((modifiers & AccFinal)!= 0 && this.initialization == null) {
+ modifiers |= AccBlankFinal;
+ }
binding = new LocalVariableBinding(this, tb, modifiers, false);
scope.addLocalVariable(binding);
binding.constant = NotAConstant;
@@ -177,7 +195,7 @@
if (initTb != null) {
if (initialization.isConstantValueOfTypeAssignableToType(initTb, tb)
|| (tb.isBaseType() && BaseTypeBinding.isWidening(tb.id, initTb.id))
- || scope.areTypesCompatible(initTb, tb))
+ || initTb.isCompatibleWith(tb))
initialization.implicitWidening(tb, initTb);
else
scope.problemReporter().typeMismatchError(initTb, tb, this);
@@ -203,4 +221,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalTypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalTypeDeclaration.java
index 2193cd7..7f10c6b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalTypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalTypeDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java
index 307f73c..7a06225 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -129,6 +129,7 @@
if (constant == FORMAT_ERROR) {
constant = NotAConstant;
scope.problemReporter().constantOutOfFormat(this);
+ this.resolvedType = null;
return null;
}
return tb;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteralMinValue.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteralMinValue.java
index 8122d62..57236c1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteralMinValue.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteralMinValue.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.impl.*;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MagicLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MagicLiteral.java
index e9024df..fb75e63 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MagicLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MagicLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
public abstract class MagicLiteral extends Literal {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MemberTypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MemberTypeDeclaration.java
index 1d7313b..2c87c26 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MemberTypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MemberTypeDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
index b8c880a..3e7cff4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -45,8 +45,6 @@
// must verify that exceptions potentially thrown by this expression are caught in the method
flowContext.checkExceptionHandlers(thrownExceptions, this, flowInfo, currentScope);
}
- // if invoking through an enclosing instance, then must perform the field generation -- only if reachable
- manageEnclosingInstanceAccessIfNecessary(currentScope);
manageSyntheticAccessIfNecessary(currentScope);
return flowInfo;
}
@@ -64,15 +62,11 @@
// generate receiver/enclosing instance access
boolean isStatic = codegenBinding.isStatic();
// outer access ?
- if (!isStatic && ((bits & DepthMASK) != 0) && (receiver == ThisReference.ThisImplicit)){
+ if (!isStatic && ((bits & DepthMASK) != 0) && receiver.isImplicitThis()){
// outer method can be reached through emulation if implicit access
- Object[] path = currentScope.getExactEmulationPath(currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT));
- if (path == null) {
- // emulation was not possible (should not happen per construction)
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(path, this, currentScope);
- }
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] path = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
+ codeStream.generateOuterAccess(path, this, targetType, currentScope);
} else {
receiver.generateCode(currentScope, codeStream, !isStatic);
}
@@ -125,17 +119,6 @@
public boolean isTypeAccess() {
return receiver != null && receiver.isTypeReference();
}
-public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope) {
- if (((bits & DepthMASK) != 0) && !binding.isStatic() && (receiver == ThisReference.ThisImplicit)) {
- ReferenceBinding compatibleType = currentScope.enclosingSourceType();
- // the declaringClass of the target binding must be compatible with the enclosing
- // type at <depth> levels outside
- for (int i = 0, depth = (bits & DepthMASK) >> DepthSHIFT; i < depth; i++) {
- compatibleType = compatibleType.enclosingType();
- }
- currentScope.emulateOuterAccess((SourceTypeBinding) compatibleType, false); // request cascade of accesses
- }
-}
public void manageSyntheticAccessIfNecessary(BlockScope currentScope){
if (binding.isPrivate()){
@@ -143,7 +126,7 @@
// depth is set for both implicit and explicit access (see MethodBinding#canBeSeenBy)
if (currentScope.enclosingSourceType() != binding.declaringClass){
- syntheticAccessor = ((SourceTypeBinding)binding.declaringClass).addSyntheticMethod(binding);
+ syntheticAccessor = ((SourceTypeBinding)binding.declaringClass).addSyntheticMethod(binding, isSuperAccess());
currentScope.problemReporter().needToEmulateMethodAccess(binding, this);
return;
}
@@ -152,7 +135,7 @@
// qualified super need emulation always
SourceTypeBinding destinationType = (SourceTypeBinding)(((QualifiedSuperReference)receiver).currentCompatibleType);
- syntheticAccessor = destinationType.addSyntheticMethod(binding);
+ syntheticAccessor = destinationType.addSyntheticMethod(binding, isSuperAccess());
currentScope.problemReporter().needToEmulateMethodAccess(binding, this);
return;
@@ -164,19 +147,19 @@
!= (enclosingSourceType = currentScope.enclosingSourceType()).getPackage()){
SourceTypeBinding currentCompatibleType = (SourceTypeBinding)enclosingSourceType.enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
- syntheticAccessor = currentCompatibleType.addSyntheticMethod(binding);
+ syntheticAccessor = currentCompatibleType.addSyntheticMethod(binding, isSuperAccess());
currentScope.problemReporter().needToEmulateMethodAccess(binding, this);
return;
}
}
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, method's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, method's declaring class is touched if any different from receiver type
// and not from Object or implicit static method call.
if (binding.declaringClass != this.qualifyingType
&& !this.qualifyingType.isArrayType()
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
- && (receiver != ThisReference.ThisImplicit || !binding.isStatic())
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
+ && (!receiver.isImplicitThis() || !binding.isStatic())
&& binding.declaringClass.id != T_Object) // no change for Object methods
|| !binding.declaringClass.canBeSeenBy(currentScope))) {
@@ -203,7 +186,6 @@
}
}
if (argHasError){
- MethodBinding closestMethod = null;
if(receiverType instanceof ReferenceBinding) {
// record any selector match, for clients who may still need hint about possible method match
this.codegenBinding = this.binding = scope.findMethod((ReferenceBinding)receiverType, selector, new TypeBinding[]{}, this);
@@ -221,32 +203,39 @@
}
this.codegenBinding = this.binding =
- receiver == ThisReference.ThisImplicit
+ receiver.isImplicitThis()
? scope.getImplicitMethod(selector, argumentTypes, this)
: scope.getMethod(this.receiverType, selector, argumentTypes, this);
if (!binding.isValidBinding()) {
if (binding.declaringClass == null) {
if (this.receiverType instanceof ReferenceBinding) {
binding.declaringClass = (ReferenceBinding) this.receiverType;
- } else { // really bad error ....
+ } else {
scope.problemReporter().errorNoMethodFor(this, this.receiverType, argumentTypes);
return null;
}
}
scope.problemReporter().invalidMethod(this, binding);
// record the closest match, for clients who may still need hint about possible method match
- if (binding.problemId() == ProblemReasons.NotFound){
- this.codegenBinding = this.binding = ((ProblemMethodBinding)binding).closestMatch;
+ if (binding instanceof ProblemMethodBinding){
+ MethodBinding closestMatch = ((ProblemMethodBinding)binding).closestMatch;
+ if (closestMatch != null) this.codegenBinding = this.binding = closestMatch;
}
- return null;
+ return binding == null ? null : binding.returnType;
}
if (!binding.isStatic()) {
// the "receiver" must not be a type, i.e. a NameReference that the TC has bound to a Type
- if (receiver instanceof NameReference) {
- if ((((NameReference) receiver).bits & BindingIds.TYPE) != 0) {
- scope.problemReporter().mustUseAStaticMethod(this, binding);
- return null;
- }
+ if (receiver instanceof NameReference
+ && (((NameReference) receiver).bits & BindingIds.TYPE) != 0) {
+ scope.problemReporter().mustUseAStaticMethod(this, binding);
+ }
+ } else {
+ // static message invoked through receiver? legal but unoptimal (optional warning).
+ if (!(receiver.isImplicitThis()
+ || receiver.isSuper()
+ || (receiver instanceof NameReference
+ && (((NameReference) receiver).bits & BindingIds.TYPE) != 0))) {
+ scope.problemReporter().unnecessaryReceiverForStaticMethod(this, binding);
}
}
if (arguments != null)
@@ -257,14 +246,13 @@
if (binding.isAbstract()) {
if (receiver.isSuper()) {
scope.problemReporter().cannotDireclyInvokeAbstractMethod(this, binding);
- return null;
}
// abstract private methods cannot occur nor abstract static............
}
if (isMethodUseDeprecated(binding, scope))
scope.problemReporter().deprecatedMethod(binding, this);
- return binding.returnType;
+ return this.resolvedType = binding.returnType;
}
public void setActualReceiverType(ReferenceBinding receiverType) {
this.qualifyingType = receiverType;
@@ -282,7 +270,7 @@
public String toStringExpression(){
String s = ""; //$NON-NLS-1$
- if (receiver != ThisReference.ThisImplicit)
+ if (!receiver.isImplicitThis())
s = s + receiver.toStringExpression()+"."; //$NON-NLS-1$
s = s + new String(selector) + "(" ; //$NON-NLS-1$
if (arguments != null)
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
index bee41a0..d63da92 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java
@@ -1,20 +1,24 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
+import org.eclipse.jdt.internal.compiler.flow.ExceptionHandlingFlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
+import org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.*;
-import org.eclipse.jdt.internal.compiler.util.*;
+import org.eclipse.jdt.internal.compiler.problem.AbortMethod;
public class MethodDeclaration extends AbstractMethodDeclaration {
@@ -27,6 +31,61 @@
super(compilationResult);
}
+ public void analyseCode(
+ ClassScope classScope,
+ InitializationFlowContext initializationContext,
+ FlowInfo flowInfo) {
+
+ // starting of the code analysis for methods
+ if (ignoreFurtherInvestigation)
+ return;
+ try {
+ if (binding == null)
+ return;
+
+ if (this.binding.isPrivate() && !this.binding.isPrivateUsed()) {
+ if (!classScope.referenceCompilationUnit().compilationResult.hasSyntaxError()) {
+ scope.problemReporter().unusedPrivateMethod(this);
+ }
+ }
+
+ // may be in a non necessary <clinit> for innerclass with static final constant fields
+ if (binding.isAbstract() || binding.isNative())
+ return;
+
+ ExceptionHandlingFlowContext methodContext =
+ new ExceptionHandlingFlowContext(
+ initializationContext,
+ this,
+ binding.thrownExceptions,
+ scope,
+ FlowInfo.DEAD_END);
+
+ // propagate to statements
+ if (statements != null) {
+ boolean didAlreadyComplain = false;
+ for (int i = 0, count = statements.length; i < count; i++) {
+ Statement stat;
+ if (!flowInfo.complainIfUnreachable((stat = statements[i]), scope, didAlreadyComplain)) {
+ flowInfo = stat.analyseCode(scope, methodContext, flowInfo);
+ } else {
+ didAlreadyComplain = true;
+ }
+ }
+ }
+ // check for missing returning path
+ TypeBinding returnType = binding.returnType;
+ if ((returnType == VoidBinding) || isAbstract()) {
+ this.needFreeReturn = flowInfo.isReachable();
+ } else {
+ if (flowInfo != FlowInfo.DEAD_END) {
+ scope.problemReporter().shouldReturn(returnType, this);
+ }
+ }
+ } catch (AbortMethod e) {
+ this.ignoreFurtherInvestigation = true;
+ }
+ }
public void parseStatements(Parser parser, CompilationUnitDeclaration unit) {
@@ -36,11 +95,11 @@
parser.parse(this, unit);
}
- public void resolveStatements(ClassScope upperScope) {
+ public void resolveStatements() {
// ========= abort on fatal error =============
if (this.returnType != null && this.binding != null) {
- this.returnType.binding = this.binding.returnType;
+ this.returnType.resolvedType = this.binding.returnType;
// record the return type binding
}
// look if the name of the method is correct
@@ -65,7 +124,7 @@
scope.problemReporter().methodNeedingNoBody(this);
}
}
- super.resolveStatements(upperScope);
+ super.resolveStatements();
}
public String returnTypeToString(int tab) {
@@ -100,4 +159,4 @@
}
visitor.endVisit(this, classScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java
index 6fcc25e..9dde5b3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NameReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.lookup.*;
@@ -16,7 +16,8 @@
public Binding binding, codegenBinding; //may be aTypeBinding-aFieldBinding-aLocalVariableBinding
- public TypeBinding receiverType, actualReceiverType;
+ public TypeBinding receiverType; // raw receiver type
+ public TypeBinding actualReceiverType; // modified receiver type - actual one according to namelookup
//the error printing
//some name reference are build as name reference but
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullLiteral.java
index 274c9cb..027e12a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NullLiteral.java
@@ -1,52 +1,59 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
-import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
public class NullLiteral extends MagicLiteral {
- static final char[] source = {'n' , 'u' , 'l' , 'l'};
-public NullLiteral(int s , int e) {
- super(s,e);
-}
-public void computeConstant() {
- constant = Constant.fromValue(null);}
-/**
- * Code generation for the null literal
- *
- * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
- * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
- * @param valueRequired boolean
- */
-public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
- int pc = codeStream.position;
- if (valueRequired)
- codeStream.aconst_null();
- codeStream.recordPositionsFrom(pc, this.sourceStart);
-}
-public TypeBinding literalType(BlockScope scope) {
- return NullBinding;
-}
-/**
- *
- */
-public char[] source() {
- return source;
-}
-public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
- visitor.visit(this, scope);
- visitor.endVisit(this, scope);
-}
+ static final char[] source = {'n' , 'u' , 'l' , 'l'};
+
+ public NullLiteral(int s , int e) {
+
+ super(s,e);
+ }
+
+ public void computeConstant() {
+
+ constant = NotAConstant;
+ }
+
+ /**
+ * Code generation for the null literal
+ *
+ * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
+ * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
+ * @param valueRequired boolean
+ */
+ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
+ int pc = codeStream.position;
+ if (valueRequired)
+ codeStream.aconst_null();
+ codeStream.recordPositionsFrom(pc, this.sourceStart);
+ }
+ public TypeBinding literalType(BlockScope scope) {
+ return NullBinding;
+ }
+
+ /**
+ *
+ */
+ public char[] source() {
+ return source;
+ }
+
+ public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
+ visitor.visit(this, scope);
+ visitor.endVisit(this, scope);
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NumberLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NumberLiteral.java
index f9309cb..ed2d4bf 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NumberLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/NumberLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
public abstract class NumberLiteral extends Literal {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java
index 5f6d4e4..9c0f771 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -31,35 +31,42 @@
FlowContext flowContext,
FlowInfo flowInfo) {
- Constant opConstant = left.conditionalConstant();
- if (opConstant != NotAConstant) {
- if (opConstant.booleanValue() == false) {
- // FALSE || anything
- // need to be careful of scenario:
- // (x || y) || !z, if passing the left info to the right, it would be swapped by the !
- FlowInfo mergedInfo = left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits();
- mergedInfo = right.analyseCode(currentScope, flowContext, mergedInfo);
- mergedInitStateIndex =
- currentScope.methodScope().recordInitializationStates(mergedInfo);
- return mergedInfo;
- }
+ Constant cst = this.left.optimizedBooleanConstant();
+ boolean isLeftOptimizedTrue = cst != NotAConstant && cst.booleanValue() == true;
+ boolean isLeftOptimizedFalse = cst != NotAConstant && cst.booleanValue() == false;
+
+ if (isLeftOptimizedFalse) {
+ // FALSE || anything
+ // need to be careful of scenario:
+ // (x || y) || !z, if passing the left info to the right, it would be swapped by the !
+ FlowInfo mergedInfo = left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits();
+ mergedInfo = right.analyseCode(currentScope, flowContext, mergedInfo);
+ mergedInitStateIndex =
+ currentScope.methodScope().recordInitializationStates(mergedInfo);
+ return mergedInfo;
}
- FlowInfo leftInfo, rightInfo;
- leftInfo = left.analyseCode(currentScope, flowContext, flowInfo);
+
+ FlowInfo leftInfo = left.analyseCode(currentScope, flowContext, flowInfo);
// need to be careful of scenario:
// (x || y) || !z, if passing the left info to the right, it would be swapped by the !
- rightInfo = leftInfo.initsWhenFalse().unconditionalInits().copy();
- if (opConstant != NotAConstant && opConstant.booleanValue() == true) rightInfo.markAsFakeReachable(true);
-
+ FlowInfo rightInfo = leftInfo.initsWhenFalse().unconditionalInits().copy();
rightInitStateIndex =
currentScope.methodScope().recordInitializationStates(rightInfo);
+
+ int previousMode = rightInfo.reachMode();
+ if (isLeftOptimizedTrue){
+ rightInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
rightInfo = right.analyseCode(currentScope, flowContext, rightInfo);
+ FlowInfo falseMergedInfo = rightInfo.initsWhenFalse().copy();
+ rightInfo.setReachMode(previousMode); // reset after falseMergedInfo got extracted
+
FlowInfo mergedInfo = FlowInfo.conditional(
// merging two true initInfos for such a negative case: if ((t && (b = t)) || f) r = b; // b may not have been initialized
leftInfo.initsWhenTrue().copy().unconditionalInits().mergedWith(
rightInfo.initsWhenTrue().copy().unconditionalInits()),
- rightInfo.initsWhenFalse().copy());
+ falseMergedInfo);
mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(mergedInfo);
return mergedInfo;
@@ -127,13 +134,12 @@
Label trueLabel,
Label falseLabel,
boolean valueRequired) {
- if ((constant != Constant.NotAConstant) && (constant.typeID() == T_boolean)) {
+ if (constant != Constant.NotAConstant) {
super.generateOptimizedBoolean(currentScope, codeStream, trueLabel, falseLabel, valueRequired);
return;
}
- int pc = codeStream.position;
Constant condConst;
- if ((condConst = left.conditionalConstant()) != NotAConstant) {
+ if ((condConst = left.optimizedBooleanConstant()) != NotAConstant) {
if (condConst.booleanValue() == true) {
// <something equivalent to true> || x
left.generateOptimizedBoolean(
@@ -151,6 +157,8 @@
}
}
}
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
} else {
// <something equivalent to false> || x
left.generateOptimizedBoolean(
@@ -173,7 +181,6 @@
valueRequired);
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
if (mergedInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(
currentScope,
@@ -181,18 +188,20 @@
}
return;
}
- if ((condConst = right.conditionalConstant()) != NotAConstant) {
+ if ((condConst = right.optimizedBooleanConstant()) != NotAConstant) {
if (condConst.booleanValue() == true) {
// x || <something equivalent to true>
+ Label internalFalseLabel = new Label(codeStream);
left.generateOptimizedBoolean(
currentScope,
codeStream,
- trueLabel,
- falseLabel,
+ null,
+ internalFalseLabel, // will be true in the end
false);
if (rightInitStateIndex != -1) {
codeStream.addDefinitelyAssignedVariables(currentScope, rightInitStateIndex);
}
+ internalFalseLabel.place();
right.generateOptimizedBoolean(
currentScope,
codeStream,
@@ -208,6 +217,8 @@
}
}
}
+ // reposition the endPC
+ codeStream.updateLastRecordedEndPC(codeStream.position);
} else {
// x || <something equivalent to false>
if ((bits & OnlyValueRequiredMASK) != 0) {
@@ -230,7 +241,6 @@
falseLabel,
false);
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
if (mergedInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(
currentScope,
@@ -274,7 +284,6 @@
// no implicit fall through TRUE/FALSE --> should never occur
}
}
- codeStream.recordPositionsFrom(pc, this.sourceStart);
if (mergedInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(
currentScope,
@@ -293,4 +302,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorExpression.java
index 2f7912d..c98285a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorExpression.java
@@ -1,21 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-
public abstract class OperatorExpression extends Expression implements OperatorIds {
public static int[][] ResolveTypeTables = new int[NumberOfTables][];
- public TypeBinding typeBinding;
+
static {classInitialize();}
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorIds.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorIds.java
index e895005..35662db 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorIds.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OperatorIds.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
public interface OperatorIds {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
index c3fa291..99fbeb8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -40,7 +40,7 @@
// just a local variable.
int pc = codeStream.position;
- lhs.generatePostIncrement(currentScope, codeStream, this, valueRequired);
+ ((Reference) lhs).generatePostIncrement(currentScope, codeStream, this, valueRequired);
if (valueRequired) {
codeStream.generateImplicitConversion(implicitConversion);
}
@@ -74,4 +74,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
index dba1f21..e94e9ac 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -57,4 +57,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
index 2505d33..c641a0c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -15,12 +15,16 @@
import org.eclipse.jdt.internal.compiler.flow.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
+/**
+ * Variation on allocation, where can be specified an enclosing instance and an anonymous type
+ */
public class QualifiedAllocationExpression extends AllocationExpression {
//qualification may be on both side
public Expression enclosingInstance;
public AnonymousLocalTypeDeclaration anonymousType;
-
+ public ReferenceBinding superTypeBinding;
+
public QualifiedAllocationExpression() {
}
@@ -33,12 +37,17 @@
FlowContext flowContext,
FlowInfo flowInfo) {
- // variation on allocation, where can be specified an enclosing instance and an anonymous type
-
// analyse the enclosing instance
if (enclosingInstance != null) {
flowInfo = enclosingInstance.analyseCode(currentScope, flowContext, flowInfo);
}
+
+ // check captured variables are initialized in current context (26134)
+ checkCapturedLocalInitializationIfNecessary(
+ this.superTypeBinding == null ? this.binding.declaringClass : this.superTypeBinding,
+ currentScope,
+ flowInfo);
+
// process arguments
if (arguments != null) {
for (int i = 0, count = arguments.length; i < count; i++) {
@@ -78,12 +87,6 @@
int pc = codeStream.position;
ReferenceBinding allocatedType = binding.declaringClass;
- if (allocatedType.isLocalType()) {
- LocalTypeBinding localType = (LocalTypeBinding) allocatedType;
- localType.constantPoolName(
- codeStream.classFile.outerMostEnclosingClassFile().computeConstantPoolName(
- localType));
- }
codeStream.new_(allocatedType);
if (valueRequired) {
codeStream.dup();
@@ -91,10 +94,9 @@
// better highlight for allocation: display the type individually
codeStream.recordPositionsFrom(pc, type.sourceStart);
- // handling innerclass instance allocation
+ // handling innerclass instance allocation - enclosing instance arguments
if (allocatedType.isNestedType()) {
- // make sure its name is computed before arguments, since may be necessary for argument emulation
- codeStream.generateSyntheticArgumentValues(
+ codeStream.generateSyntheticEnclosingInstanceValues(
currentScope,
allocatedType,
enclosingInstance(),
@@ -106,6 +108,14 @@
arguments[i].generateCode(currentScope, codeStream, true);
}
}
+ // handling innerclass instance allocation - outer local arguments
+ if (allocatedType.isNestedType()) {
+ codeStream.generateSyntheticOuterArgumentValues(
+ currentScope,
+ allocatedType,
+ this);
+ }
+
// invoke constructor
if (syntheticAccessor == null) {
codeStream.invokespecial(binding);
@@ -120,6 +130,7 @@
codeStream.invokespecial(syntheticAccessor);
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
+
if (anonymousType != null) {
anonymousType.generateCode(currentScope, codeStream);
}
@@ -147,30 +158,22 @@
&& currentScope.enclosingSourceType().isLocalType()) {
if (allocatedType.isLocalType()) {
- ((LocalTypeBinding) allocatedType).addInnerEmulationDependent(
- currentScope,
- enclosingInstance != null,
- false);
- // request cascade of accesses
+ ((LocalTypeBinding) allocatedType).addInnerEmulationDependent(currentScope, enclosingInstance != null);
} else {
// locally propagate, since we already now the desired shape for sure
- currentScope.propagateInnerEmulation(
- allocatedType,
- enclosingInstance != null,
- false);
- // request cascade of accesses
+ currentScope.propagateInnerEmulation(allocatedType, enclosingInstance != null);
}
}
}
public TypeBinding resolveType(BlockScope scope) {
- if (anonymousType == null && enclosingInstance == null)
+ // added for code assist...cannot occur with 'normal' code
+ if (anonymousType == null && enclosingInstance == null) {
return super.resolveType(scope);
- // added for code assist... is not possible with 'normal' code
+ }
// Propagate the type checking to the arguments, and checks if the constructor is defined.
-
// ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
// ClassInstanceCreationExpression ::= Name '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
// ==> by construction, when there is an enclosing instance the typename may NOT be qualified
@@ -178,119 +181,118 @@
// sometime a SingleTypeReference and sometime a QualifedTypeReference
constant = NotAConstant;
- TypeBinding enclosingInstTb = null;
- TypeBinding recType;
- if (anonymousType == null) {
- //----------------no anonymous class------------------------
- if ((enclosingInstTb = enclosingInstance.resolveType(scope)) == null)
- return null;
- if (enclosingInstTb.isBaseType() | enclosingInstTb.isArrayType()) {
+ TypeBinding enclosingInstanceType = null;
+ TypeBinding receiverType = null;
+ boolean hasError = false;
+ if (anonymousType == null) { //----------------no anonymous class------------------------
+ if ((enclosingInstanceType = enclosingInstance.resolveType(scope)) == null){
+ hasError = true;
+ } else if (enclosingInstanceType.isBaseType() || enclosingInstanceType.isArrayType()) {
scope.problemReporter().illegalPrimitiveOrArrayTypeForEnclosingInstance(
- enclosingInstTb,
+ enclosingInstanceType,
enclosingInstance);
- return null;
+ hasError = true;
+ } else if ((this.resolvedType = receiverType = ((SingleTypeReference) type).resolveTypeEnclosing(
+ scope,
+ (ReferenceBinding) enclosingInstanceType)) == null) {
+ hasError = true;
}
- recType =
- ((SingleTypeReference) type).resolveTypeEnclosing(
- scope,
- (ReferenceBinding) enclosingInstTb);
// will check for null after args are resolved
TypeBinding[] argumentTypes = NoParameters;
if (arguments != null) {
- boolean argHasError = false;
int length = arguments.length;
argumentTypes = new TypeBinding[length];
for (int i = 0; i < length; i++)
- if ((argumentTypes[i] = arguments[i].resolveType(scope)) == null)
- argHasError = true;
- if (argHasError)
- return recType;
+ if ((argumentTypes[i] = arguments[i].resolveType(scope)) == null){
+ hasError = true;
+ }
}
- if (recType == null)
- return null;
- if (!recType.canBeInstantiated()) {
- scope.problemReporter().cannotInstantiate(type, recType);
- return recType;
+ // limit of fault-tolerance
+ if (hasError) return receiverType;
+
+ if (!receiverType.canBeInstantiated()) {
+ scope.problemReporter().cannotInstantiate(type, receiverType);
+ return receiverType;
}
- if ((binding =
- scope.getConstructor((ReferenceBinding) recType, argumentTypes, this))
- .isValidBinding()) {
+ if ((this.binding = scope.getConstructor((ReferenceBinding) receiverType, argumentTypes, this))
+ .isValidBinding()) {
if (isMethodUseDeprecated(binding, scope))
- scope.problemReporter().deprecatedMethod(binding, this);
+ scope.problemReporter().deprecatedMethod(this.binding, this);
if (arguments != null)
for (int i = 0; i < arguments.length; i++)
- arguments[i].implicitWidening(binding.parameters[i], argumentTypes[i]);
+ arguments[i].implicitWidening(this.binding.parameters[i], argumentTypes[i]);
} else {
- if (binding.declaringClass == null)
- binding.declaringClass = (ReferenceBinding) recType;
- scope.problemReporter().invalidConstructor(this, binding);
- return recType;
+ if (this.binding.declaringClass == null)
+ this.binding.declaringClass = (ReferenceBinding) receiverType;
+ scope.problemReporter().invalidConstructor(this, this.binding);
+ return receiverType;
}
// The enclosing instance must be compatible with the innermost enclosing type
- ReferenceBinding expectedType = binding.declaringClass.enclosingType();
- if (scope.areTypesCompatible(enclosingInstTb, expectedType))
- return recType;
+ ReferenceBinding expectedType = this.binding.declaringClass.enclosingType();
+ if (enclosingInstanceType.isCompatibleWith(expectedType))
+ return receiverType;
scope.problemReporter().typeMismatchErrorActualTypeExpectedType(
- enclosingInstance,
- enclosingInstTb,
+ this.enclosingInstance,
+ enclosingInstanceType,
expectedType);
- return recType;
+ return receiverType;
}
//--------------there is an anonymous type declaration-----------------
- if (enclosingInstance != null) {
- if ((enclosingInstTb = enclosingInstance.resolveType(scope)) == null)
- return null;
- if (enclosingInstTb.isBaseType() | enclosingInstTb.isArrayType()) {
+ if (this.enclosingInstance != null) {
+ if ((enclosingInstanceType = this.enclosingInstance.resolveType(scope)) == null) {
+ hasError = true;
+ } else if (enclosingInstanceType.isBaseType() || enclosingInstanceType.isArrayType()) {
scope.problemReporter().illegalPrimitiveOrArrayTypeForEnclosingInstance(
- enclosingInstTb,
- enclosingInstance);
- return null;
+ enclosingInstanceType,
+ this.enclosingInstance);
+ hasError = true;
+ } else {
+ receiverType = ((SingleTypeReference) type).resolveTypeEnclosing(
+ scope,
+ (ReferenceBinding) enclosingInstanceType);
}
+ } else {
+ receiverType = type.resolveType(scope);
}
- // due to syntax-construction, recType is a ReferenceBinding
- recType =
- (enclosingInstance == null)
- ? type.resolveType(scope)
- : ((SingleTypeReference) type).resolveTypeEnclosing(
- scope,
- (ReferenceBinding) enclosingInstTb);
- if (recType == null)
- return null;
- if (((ReferenceBinding) recType).isFinal()) {
- scope.problemReporter().anonymousClassCannotExtendFinalClass(type, recType);
- return null;
+ if (receiverType == null) {
+ hasError = true;
+ } else if (((ReferenceBinding) receiverType).isFinal()) {
+ scope.problemReporter().anonymousClassCannotExtendFinalClass(type, receiverType);
+ hasError = true;
}
TypeBinding[] argumentTypes = NoParameters;
if (arguments != null) {
int length = arguments.length;
argumentTypes = new TypeBinding[length];
for (int i = 0; i < length; i++)
- if ((argumentTypes[i] = arguments[i].resolveType(scope)) == null)
- return null;
+ if ((argumentTypes[i] = arguments[i].resolveType(scope)) == null) {
+ hasError = true;
+ }
+ }
+ // limit of fault-tolerance
+ if (hasError) {
+ return receiverType;
}
// an anonymous class inherits from java.lang.Object when declared "after" an interface
- ReferenceBinding superBinding =
- recType.isInterface() ? scope.getJavaLangObject() : (ReferenceBinding) recType;
+ this.superTypeBinding =
+ receiverType.isInterface() ? scope.getJavaLangObject() : (ReferenceBinding) receiverType;
MethodBinding inheritedBinding =
- scope.getConstructor(superBinding, argumentTypes, this);
+ scope.getConstructor(this.superTypeBinding, argumentTypes, this);
if (!inheritedBinding.isValidBinding()) {
if (inheritedBinding.declaringClass == null)
- inheritedBinding.declaringClass = superBinding;
+ inheritedBinding.declaringClass = this.superTypeBinding;
scope.problemReporter().invalidConstructor(this, inheritedBinding);
return null;
}
if (enclosingInstance != null) {
- if (!scope
- .areTypesCompatible(
- enclosingInstTb,
- inheritedBinding.declaringClass.enclosingType())) {
+ if (!enclosingInstanceType.isCompatibleWith(inheritedBinding.declaringClass.enclosingType())) {
scope.problemReporter().typeMismatchErrorActualTypeExpectedType(
enclosingInstance,
- enclosingInstTb,
+ enclosingInstanceType,
inheritedBinding.declaringClass.enclosingType());
return null;
}
@@ -303,18 +305,22 @@
arguments[i].implicitWidening(inheritedBinding.parameters[i], argumentTypes[i]);
// Update the anonymous inner class : superclass, interface
- scope.addAnonymousType(anonymousType, (ReferenceBinding) recType);
+ scope.addAnonymousType(anonymousType, (ReferenceBinding) receiverType);
anonymousType.resolve(scope);
binding = anonymousType.createsInternalConstructorWithBinding(inheritedBinding);
return anonymousType.binding; // 1.2 change
}
+
+ public String toStringExpression() {
+ return this.toStringExpression(0);
+ }
public String toStringExpression(int tab) {
String s = ""; //$NON-NLS-1$
if (enclosingInstance != null)
s += enclosingInstance.toString() + "."; //$NON-NLS-1$
- s += super.toStringExpression(tab);
+ s += super.toStringExpression();
if (anonymousType != null) {
s += anonymousType.toString(tab);
} //allows to restart just after the } one line under ....
@@ -337,4 +343,4 @@
}
visitor.endVisit(this, scope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
index 1e0e55e..d5e4271 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -41,77 +41,64 @@
Assignment assignment,
boolean isCompound) {
- if (assignment.expression != null) {
- flowInfo =
- assignment
- .expression
- .analyseCode(currentScope, flowContext, flowInfo)
- .unconditionalInits();
- }
// determine the rank until which we now we do not need any actual value for the field access
int otherBindingsCount = otherBindings == null ? 0 : otherBindings.length;
- int indexOfFirstValueRequired = otherBindingsCount;
- while (indexOfFirstValueRequired > 0) {
- FieldBinding otherBinding = otherBindings[indexOfFirstValueRequired - 1];
- if (otherBinding.isStatic())
- break; // no longer need any value before this point
- indexOfFirstValueRequired--;
- }
- FieldBinding lastFieldBinding = null;
- if ((bits & FIELD) != 0) {
- // reading from a field
- // check if final blank field
- if ((lastFieldBinding = (FieldBinding) binding).isFinal()
- && currentScope.allowBlankFinalFieldAssignment(lastFieldBinding)) {
- if (!flowInfo.isDefinitelyAssigned(lastFieldBinding)) {
- currentScope.problemReporter().uninitializedBlankFinalField(
- lastFieldBinding,
- this);
+ boolean needValue = otherBindingsCount == 0 || !this.otherBindings[0].isStatic();
+ switch (bits & RestrictiveFlagMASK) {
+ case FIELD : // reading a field
+ lastFieldBinding = (FieldBinding) binding;
+ if (needValue) {
+ manageSyntheticReadAccessIfNecessary(currentScope, lastFieldBinding, this.actualReceiverType, 0);
+ } // check if final blank field
+ if (lastFieldBinding.isBlankFinal()
+ && this.otherBindings != null // the last field binding is only assigned
+ && currentScope.allowBlankFinalFieldAssignment(lastFieldBinding)) {
+ if (!flowInfo.isDefinitelyAssigned(lastFieldBinding)) {
+ currentScope.problemReporter().uninitializedBlankFinalField(
+ lastFieldBinding,
+ this);
+ }
}
- }
- } else {
- if ((bits & LOCAL) != 0) {
+ break;
+ case LOCAL :
// first binding is a local variable
LocalVariableBinding localBinding;
if (!flowInfo
.isDefinitelyAssigned(localBinding = (LocalVariableBinding) binding)) {
currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
}
- if (!flowInfo.isFakeReachable())
- localBinding.used = true;
- }
+ if (flowInfo.isReachable()) {
+ localBinding.useFlag = LocalVariableBinding.USED;
+ } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
+ localBinding.useFlag = LocalVariableBinding.FAKE_USED;
+ }
}
- if (indexOfFirstValueRequired == 0) {
+
+ if (needValue) {
manageEnclosingInstanceAccessIfNecessary(currentScope);
// only for first binding
}
// all intermediate field accesses are read accesses
if (otherBindings != null) {
- int start = indexOfFirstValueRequired == 0 ? 0 : indexOfFirstValueRequired - 1;
- for (int i = start; i < otherBindingsCount; i++) {
- if (lastFieldBinding != null) { // could be null if first was a local variable
- TypeBinding lastReceiverType;
- switch(i){
- case 0 :
- lastReceiverType = this.actualReceiverType;
- break;
- case 1 :
- lastReceiverType = ((VariableBinding)binding).type;
- break;
- default :
- lastReceiverType = otherBindings[i-1].type;
- }
+ for (int i = 0; i < otherBindingsCount-1; i++) {
+ lastFieldBinding = otherBindings[i];
+ needValue = !otherBindings[i+1].isStatic();
+ if (needValue) {
manageSyntheticReadAccessIfNecessary(
currentScope,
lastFieldBinding,
- lastReceiverType,
- i);
+ i == 0
+ ? ((VariableBinding)binding).type
+ : otherBindings[i-1].type,
+ i + 1);
}
- lastFieldBinding = otherBindings[i];
}
+ lastFieldBinding = otherBindings[otherBindingsCount-1];
}
+
if (isCompound) {
if (binding == lastFieldBinding
+ && lastFieldBinding.isBlankFinal()
&& currentScope.allowBlankFinalFieldAssignment(lastFieldBinding)
&& (!flowInfo.isDefinitelyAssigned(lastFieldBinding))) {
currentScope.problemReporter().uninitializedBlankFinalField(
@@ -134,25 +121,33 @@
? 0
: otherBindingsCount);
}
+
+ if (assignment.expression != null) {
+ flowInfo =
+ assignment
+ .expression
+ .analyseCode(currentScope, flowContext, flowInfo)
+ .unconditionalInits();
+ }
+
// the last field access is a write access
if (lastFieldBinding.isFinal()) {
// in a context where it can be assigned?
- if (currentScope.allowBlankFinalFieldAssignment(lastFieldBinding)) {
+ if (lastFieldBinding.isBlankFinal()
+ && !isCompound
+ && currentScope.allowBlankFinalFieldAssignment(lastFieldBinding)
+ && indexOfFirstFieldBinding == 1) {
if (flowInfo.isPotentiallyAssigned(lastFieldBinding)) {
- if (indexOfFirstFieldBinding == 1) {
- // was an implicit reference to the first field binding
- currentScope.problemReporter().duplicateInitializationOfBlankFinalField(
- lastFieldBinding,
- this);
- } else {
- currentScope.problemReporter().cannotAssignToFinalField(lastFieldBinding, this);
- // attempting to assign a non implicit reference
- }
+ currentScope.problemReporter().duplicateInitializationOfBlankFinalField(lastFieldBinding, this);
+ } else {
+ flowContext.recordSettingFinal(lastFieldBinding, this);
}
flowInfo.markAsDefinitelyAssigned(lastFieldBinding);
- flowContext.recordSettingFinal(lastFieldBinding, this);
} else {
currentScope.problemReporter().cannotAssignToFinalField(lastFieldBinding, this);
+ if (currentScope.allowBlankFinalFieldAssignment(lastFieldBinding)) { // pretend it got assigned
+ flowInfo.markAsDefinitelyAssigned(lastFieldBinding);
+ }
}
}
// equivalent to valuesRequired[maxOtherBindings]
@@ -168,6 +163,7 @@
return flowInfo;
}
+
public FlowInfo analyseCode(
BlockScope currentScope,
FlowContext flowContext,
@@ -184,26 +180,16 @@
// determine the rank until which we now we do not need any actual value for the field access
int otherBindingsCount = otherBindings == null ? 0 : otherBindings.length;
- int indexOfFirstValueRequired;
- if (valueRequired) {
- indexOfFirstValueRequired = otherBindingsCount;
- while (indexOfFirstValueRequired > 0) {
- FieldBinding otherBinding = otherBindings[indexOfFirstValueRequired - 1];
- if (otherBinding.isStatic())
- break; // no longer need any value before this point
- indexOfFirstValueRequired--;
- }
- } else {
- indexOfFirstValueRequired = otherBindingsCount + 1;
- }
+
+ boolean needValue = otherBindingsCount == 0 ? valueRequired : !this.otherBindings[0].isStatic();
switch (bits & RestrictiveFlagMASK) {
case FIELD : // reading a field
- if (indexOfFirstValueRequired == 0) {
+ if (needValue) {
manageSyntheticReadAccessIfNecessary(currentScope, (FieldBinding) binding, this.actualReceiverType, 0);
}
// check if reading a final blank field
FieldBinding fieldBinding;
- if ((fieldBinding = (FieldBinding) binding).isFinal()
+ if ((fieldBinding = (FieldBinding) binding).isBlankFinal()
&& (indexOfFirstFieldBinding == 1)
// was an implicit reference to the first field binding
&& currentScope.allowBlankFinalFieldAssignment(fieldBinding)
@@ -217,23 +203,28 @@
.isDefinitelyAssigned(localBinding = (LocalVariableBinding) binding)) {
currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
}
- if (!flowInfo.isFakeReachable())
- localBinding.used = true;
+ if (flowInfo.isReachable()) {
+ localBinding.useFlag = LocalVariableBinding.USED;
+ } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
+ localBinding.useFlag = LocalVariableBinding.FAKE_USED;
+ }
}
- if (indexOfFirstValueRequired == 0) {
+ if (needValue) {
manageEnclosingInstanceAccessIfNecessary(currentScope);
// only for first binding
}
if (otherBindings != null) {
- int start = indexOfFirstValueRequired == 0 ? 0 : indexOfFirstValueRequired - 1;
- for (int i = start; i < otherBindingsCount; i++) {
- manageSyntheticReadAccessIfNecessary(
- currentScope,
- otherBindings[i],
- i == 0
- ? ((VariableBinding)binding).type
- : otherBindings[i-1].type,
- i + 1);
+ for (int i = 0; i < otherBindingsCount; i++) {
+ needValue = i < otherBindingsCount-1 ? !otherBindings[i+1].isStatic() : valueRequired;
+ if (needValue) {
+ manageSyntheticReadAccessIfNecessary(
+ currentScope,
+ otherBindings[i],
+ i == 0
+ ? ((VariableBinding)binding).type
+ : otherBindings[i-1].type,
+ i + 1);
+ }
}
}
return flowInfo;
@@ -246,7 +237,7 @@
FieldBinding fieldBinding = (FieldBinding) binding;
MethodScope methodScope = scope.methodScope();
if (methodScope.enclosingSourceType() == fieldBinding.declaringClass
- && methodScope.fieldDeclarationIndex != methodScope.NotInFieldDecl
+ && methodScope.fieldDeclarationIndex != MethodScope.NotInFieldDecl
&& fieldBinding.id >= methodScope.fieldDeclarationIndex) {
if ((!fieldBinding.isStatic() || methodScope.isStatic)
&& this.indexOfFirstFieldBinding == 1)
@@ -262,7 +253,7 @@
Assignment assignment,
boolean valueRequired) {
- generateReadSequence(currentScope, codeStream, true);
+ generateReadSequence(currentScope, codeStream);
assignment.expression.generateCode(currentScope, codeStream, true);
fieldStore(codeStream, lastFieldBinding, syntheticWriteAccessor, valueRequired);
// equivalent to valuesRequired[maxOtherBindings]
@@ -274,19 +265,24 @@
BlockScope currentScope,
CodeStream codeStream,
boolean valueRequired) {
+
int pc = codeStream.position;
if (constant != NotAConstant) {
if (valueRequired) {
codeStream.generateConstant(constant, implicitConversion);
}
} else {
- generateReadSequence(currentScope, codeStream, valueRequired);
+ generateReadSequence(currentScope, codeStream);
if (valueRequired) {
if (lastFieldBinding.declaringClass == null) { // array length
codeStream.arraylength();
codeStream.generateImplicitConversion(implicitConversion);
} else {
if (lastFieldBinding.constant != NotAConstant) {
+ if (!lastFieldBinding.isStatic()){
+ codeStream.invokeObjectGetClass();
+ codeStream.pop();
+ }
// inline the last field constant
codeStream.generateConstant(lastFieldBinding.constant, implicitConversion);
} else {
@@ -306,6 +302,12 @@
codeStream.generateImplicitConversion(implicitConversion);
}
}
+ } else {
+ if (lastFieldBinding != null && !lastFieldBinding.isStatic()){
+ codeStream.invokeObjectGetClass(); // perform null check
+ codeStream.pop();
+ }
+
}
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
@@ -318,7 +320,7 @@
int assignmentImplicitConversion,
boolean valueRequired) {
- generateReadSequence(currentScope, codeStream, true);
+ generateReadSequence(currentScope, codeStream);
SyntheticAccessMethodBinding accessor =
syntheticReadAccessors == null
? null
@@ -365,7 +367,7 @@
CodeStream codeStream,
CompoundAssignment postIncrement,
boolean valueRequired) {
- generateReadSequence(currentScope, codeStream, true);
+ generateReadSequence(currentScope, codeStream);
SyntheticAccessMethodBinding accessor =
syntheticReadAccessors == null
? null
@@ -416,93 +418,82 @@
*/
public void generateReadSequence(
BlockScope currentScope,
- CodeStream codeStream,
- boolean valueRequired) {
+ CodeStream codeStream) {
+
// determine the rank until which we now we do not need any actual value for the field access
int otherBindingsCount = this.otherCodegenBindings == null ? 0 : otherCodegenBindings.length;
- int indexOfFirstValueRequired;
- if (valueRequired) {
- indexOfFirstValueRequired = otherBindingsCount;
- while (indexOfFirstValueRequired > 0) {
- FieldBinding otherBinding = this.otherCodegenBindings[indexOfFirstValueRequired - 1];
- if (otherBinding.isStatic() || otherBinding.constant != NotAConstant)
- break; // no longer need any value before this point
- indexOfFirstValueRequired--;
- }
- } else {
- indexOfFirstValueRequired = otherBindingsCount + 1;
- }
- if (indexOfFirstValueRequired == 0) {
- switch (bits & RestrictiveFlagMASK) {
- case FIELD :
- lastFieldBinding = (FieldBinding) this.codegenBinding;
- // if first field is actually constant, we can inline it
- if (lastFieldBinding.constant != NotAConstant) {
- codeStream.generateConstant(lastFieldBinding.constant, 0);
- // no implicit conversion
- lastFieldBinding = null; // will not generate it again
- break;
- }
- if (!lastFieldBinding.isStatic()) {
- if ((bits & DepthMASK) != 0) {
- Object[] emulationPath =
- currentScope.getExactEmulationPath(
- currentScope.enclosingSourceType().enclosingTypeAt(
- (bits & DepthMASK) >> DepthSHIFT));
- if (emulationPath == null) {
- // internal error, per construction we should have found it
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(emulationPath, this, currentScope);
- }
- } else {
- generateReceiver(codeStream);
- }
- }
+
+ boolean needValue = otherBindingsCount == 0 || !this.otherBindings[0].isStatic();
+ switch (bits & RestrictiveFlagMASK) {
+ case FIELD :
+ lastFieldBinding = (FieldBinding) this.codegenBinding;
+ // if first field is actually constant, we can inline it
+ if (lastFieldBinding.constant != NotAConstant) {
break;
- case LOCAL : // reading the first local variable
- lastFieldBinding = null;
- LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding;
- // regular local variable read
- if (localBinding.constant != NotAConstant) {
- codeStream.generateConstant(localBinding.constant, 0);
- // no implicit conversion
+ }
+ if (needValue && !lastFieldBinding.isStatic()) {
+ if ((bits & DepthMASK) != 0) {
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
+ codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
} else {
- // outer local?
- if ((bits & DepthMASK) != 0) {
- // outer local can be reached either through a synthetic arg or a synthetic field
- VariableBinding[] path = currentScope.getEmulationPath(localBinding);
- if (path == null) {
- // emulation was not possible (should not happen per construction)
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(path, this, currentScope);
- }
- } else {
- codeStream.load(localBinding);
- }
+ generateReceiver(codeStream);
}
- }
- } else {
- lastFieldBinding = null;
+ }
+ break;
+ case LOCAL : // reading the first local variable
+ if (!needValue) break; // no value needed
+ lastFieldBinding = null;
+ LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding;
+ // regular local variable read
+ if (localBinding.constant != NotAConstant) {
+ codeStream.generateConstant(localBinding.constant, 0);
+ // no implicit conversion
+ } else {
+ // outer local?
+ if ((bits & DepthMASK) != 0) {
+ // outer local can be reached either through a synthetic arg or a synthetic field
+ VariableBinding[] path = currentScope.getEmulationPath(localBinding);
+ codeStream.generateOuterAccess(path, this, localBinding, currentScope);
+ } else {
+ codeStream.load(localBinding);
+ }
+ }
}
+
// all intermediate field accesses are read accesses
// only the last field binding is a write access
if (this.otherCodegenBindings != null) {
- int start = indexOfFirstValueRequired == 0 ? 0 : indexOfFirstValueRequired - 1;
- for (int i = start; i < otherBindingsCount; i++) {
+ for (int i = 0; i < otherBindingsCount; i++) {
+ FieldBinding nextField = this.otherCodegenBindings[i];
if (lastFieldBinding != null) {
- MethodBinding accessor =
- syntheticReadAccessors == null ? null : syntheticReadAccessors[i];
- if (accessor == null)
- if (lastFieldBinding.isStatic())
- codeStream.getstatic(lastFieldBinding);
- else
- codeStream.getfield(lastFieldBinding);
- else
- codeStream.invokestatic(accessor);
+ needValue = !nextField.isStatic();
+ if (needValue) {
+ MethodBinding accessor =
+ syntheticReadAccessors == null ? null : syntheticReadAccessors[i];
+ if (accessor == null) {
+ if (lastFieldBinding.constant != NotAConstant) {
+ if (this.lastFieldBinding != this.codegenBinding && !this.lastFieldBinding.isStatic()) {
+ codeStream.invokeObjectGetClass(); // perform null check
+ codeStream.pop();
+ }
+ codeStream.generateConstant(lastFieldBinding.constant, 0);
+ } else if (lastFieldBinding.isStatic()) {
+ codeStream.getstatic(lastFieldBinding);
+ } else {
+ codeStream.getfield(lastFieldBinding);
+ }
+ } else {
+ codeStream.invokestatic(accessor);
+ }
+ } else {
+ if (this.codegenBinding != this.lastFieldBinding && !this.lastFieldBinding.isStatic()){
+ codeStream.invokeObjectGetClass(); // perform null check
+ codeStream.pop();
+ }
+ }
}
- lastFieldBinding = otherCodegenBindings[i];
+ this.lastFieldBinding = nextField;
}
}
}
@@ -536,8 +527,7 @@
int index = indexOfFirstFieldBinding;
int length = tokens.length;
if (index == length) { // restrictiveFlag == FIELD
- constant =
- FieldReference.getConstantFor((FieldBinding) binding, false, this, scope, index - 1);
+ this.constant = FieldReference.getConstantFor((FieldBinding) binding, this, false, scope);
return type;
}
// allocation of the fieldBindings array and its respective constants
@@ -546,9 +536,9 @@
otherDepths = new int[otherBindingsLength];
// fill the first constant (the one of the binding)
- constant =
+ this.constant =
((bits & FIELD) != 0)
- ? FieldReference.getConstantFor((FieldBinding) binding, false, this, scope, index - 1)
+ ? FieldReference.getConstantFor((FieldBinding) binding, this, false, scope)
: ((VariableBinding) binding).constant;
// save first depth, since will be updated by visibility checks of other bindings
int firstDepth = (bits & DepthMASK) >> DepthSHIFT;
@@ -566,14 +556,20 @@
if (field.isValidBinding()) {
if (isFieldUseDeprecated(field, scope))
scope.problemReporter().deprecatedField(field, this);
- Constant someConstant =
- FieldReference.getConstantFor(field, false, this, scope, place);
+ Constant someConstant = FieldReference.getConstantFor(field, this, false, scope);
// constant propagation can only be performed as long as the previous one is a constant too.
- if (constant != NotAConstant) {
- constant = someConstant;
+ if (this.constant != NotAConstant) {
+ this.constant = someConstant;
}
+
type = field.type;
index++;
+
+ if (field.isStatic()) {
+ // static field accessed through receiver? legal but unoptimal (optional warning)
+ scope.problemReporter().unnecessaryReceiverForStaticField(this, field);
+ }
+
} else {
constant = NotAConstant; //don't fill other constants slots...
scope.problemReporter().invalidField(this, field, index, type);
@@ -589,23 +585,8 @@
if (((bits & DepthMASK) == 0) || (constant != NotAConstant)) {
return;
}
- switch (bits & RestrictiveFlagMASK) {
- case FIELD :
- FieldBinding fieldBinding;
- if ((fieldBinding = (FieldBinding) binding).isStatic()
- || (fieldBinding.constant != NotAConstant))
- return;
- ReferenceBinding compatibleType = currentScope.enclosingSourceType();
- // the declaringClass of the target binding must be compatible with the enclosing
- // type at <depth> levels outside
- for (int i = 0, depth = (bits & DepthMASK) >> DepthSHIFT; i < depth; i++) {
- compatibleType = compatibleType.enclosingType();
- }
- currentScope.emulateOuterAccess(compatibleType, false);
- // request cascade of accesses
- break;
- case LOCAL :
- currentScope.emulateOuterAccess((LocalVariableBinding) binding);
+ if ((bits & RestrictiveFlagMASK) == LOCAL) {
+ currentScope.emulateOuterAccess((LocalVariableBinding) binding);
}
}
public void manageSyntheticReadAccessIfNecessary(
@@ -650,12 +631,12 @@
}
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, field's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
if (fieldBinding.declaringClass != lastReceiverType
&& !lastReceiverType.isArrayType()
&& fieldBinding.declaringClass != null
&& fieldBinding.constant == NotAConstant
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
&& (index > 0 || indexOfFirstFieldBinding > 1 || !fieldBinding.isStatic())
&& fieldBinding.declaringClass.id != T_Object)
|| !fieldBinding.declaringClass.canBeSeenBy(currentScope))){
@@ -696,12 +677,12 @@
}
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, field's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
if (fieldBinding.declaringClass != lastReceiverType
&& !lastReceiverType.isArrayType()
&& fieldBinding.declaringClass != null
&& fieldBinding.constant == NotAConstant
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
&& (fieldBinding != binding || indexOfFirstFieldBinding > 1 || !fieldBinding.isStatic())
&& fieldBinding.declaringClass.id != T_Object)
|| !fieldBinding.declaringClass.canBeSeenBy(currentScope))){
@@ -748,14 +729,14 @@
this);
bits &= ~RestrictiveFlagMASK; // clear bits
bits |= LOCAL;
- return getOtherFieldBindings(scope);
+ return this.resolvedType = getOtherFieldBindings(scope);
}
if (binding instanceof FieldBinding) {
// check for forward references
FieldBinding fieldBinding = (FieldBinding) binding;
MethodScope methodScope = scope.methodScope();
if (methodScope.enclosingSourceType() == fieldBinding.declaringClass
- && methodScope.fieldDeclarationIndex != methodScope.NotInFieldDecl
+ && methodScope.fieldDeclarationIndex != MethodScope.NotInFieldDecl
&& fieldBinding.id >= methodScope.fieldDeclarationIndex) {
if ((!fieldBinding.isStatic() || methodScope.isStatic)
&& this.indexOfFirstFieldBinding == 1)
@@ -763,20 +744,27 @@
}
bits &= ~RestrictiveFlagMASK; // clear bits
bits |= FIELD;
- return getOtherFieldBindings(scope);
+
+ // check for deprecated receiver type
+ // deprecation check for receiver type if not first token
+ if (indexOfFirstFieldBinding > 1) {
+ if (isTypeUseDeprecated(this.actualReceiverType, scope))
+ scope.problemReporter().deprecatedType(this.actualReceiverType, this);
+ }
+
+ return this.resolvedType = getOtherFieldBindings(scope);
}
// thus it was a type
bits &= ~RestrictiveFlagMASK; // clear bits
bits |= TYPE;
case TYPE : //=============only type ==============
- //deprecated test
if (isTypeUseDeprecated((TypeBinding) binding, scope))
scope.problemReporter().deprecatedType((TypeBinding) binding, this);
- return (TypeBinding) binding;
+ return this.resolvedType = (TypeBinding) binding;
}
}
//========error cases===============
- return this.reportError(scope);
+ return this.resolvedType = this.reportError(scope);
}
public void setFieldIndex(int index) {
this.indexOfFirstFieldBinding = index;
@@ -798,4 +786,4 @@
public String unboundReferenceErrorName() {
return new String(tokens[0]);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java
index f7fb377..d35b82d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -31,6 +31,10 @@
public TypeBinding resolveType(BlockScope scope) {
+ if ((this.bits & ParenthesizedMASK) != 0) {
+ scope.problemReporter().invalidParenthesizedExpression(this);
+ return null;
+ }
super.resolveType(scope);
if (currentCompatibleType == null)
return null; // error case
@@ -39,7 +43,7 @@
scope.problemReporter().cannotUseSuperInJavaLangObject(this);
return null;
}
- return currentCompatibleType.superclass();
+ return this.resolvedType = currentCompatibleType.superclass();
}
public String toStringExpression() {
@@ -56,4 +60,4 @@
}
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
index 6a27f07..86d38dd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -19,11 +19,10 @@
public TypeReference qualification;
ReferenceBinding currentCompatibleType;
-
- public QualifiedThisReference(TypeReference name, int pos, int sourceEnd) {
-
+
+ public QualifiedThisReference(TypeReference name, int sourceStart, int sourceEnd) {
+ super(sourceStart, sourceEnd);
qualification = name;
- this.sourceEnd = sourceEnd;
this.sourceStart = name.sourceStart;
}
@@ -32,7 +31,6 @@
FlowContext flowContext,
FlowInfo flowInfo) {
- manageEnclosingInstanceAccessIfNecessary(currentScope);
return flowInfo;
}
@@ -42,32 +40,9 @@
FlowInfo flowInfo,
boolean valueRequired) {
- if (valueRequired) {
- manageEnclosingInstanceAccessIfNecessary(currentScope);
- }
return flowInfo;
}
- protected boolean checkAccess(
- MethodScope methodScope,
- TypeBinding targetType) {
-
- // this/super cannot be used in constructor call
- if (methodScope.isConstructorCall) {
- methodScope.problemReporter().fieldsOrThisBeforeConstructorInvocation(this);
- return false;
- }
-
- // static may not refer to this/super
- if (methodScope.isStatic) {
- methodScope.problemReporter().incorrectEnclosingInstanceReference(
- this,
- targetType);
- return false;
- }
- return true;
- }
-
/**
* Code generation for QualifiedThisReference
*
@@ -84,13 +59,8 @@
if (valueRequired) {
if ((bits & DepthMASK) != 0) {
Object[] emulationPath =
- currentScope.getExactEmulationPath(currentCompatibleType);
- if (emulationPath == null) {
- // internal error, per construction we should have found it
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(emulationPath, this, currentScope);
- }
+ currentScope.getEmulationPath(this.currentCompatibleType, true /*only exact match*/, false/*consider enclosing arg*/);
+ codeStream.generateOuterAccess(emulationPath, this, this.currentCompatibleType, currentScope);
} else {
// nothing particular after all
codeStream.aload_0();
@@ -99,64 +69,34 @@
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
- void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope) {
-
- currentScope.emulateOuterAccess(
- (SourceTypeBinding) currentCompatibleType,
- false);
- // request cascade of accesses
- }
-
public TypeBinding resolveType(BlockScope scope) {
constant = NotAConstant;
- TypeBinding qualificationTb = qualification.resolveType(scope);
- if (qualificationTb == null)
- return null;
+ this.resolvedType = qualification.resolveType(scope);
+ if (this.resolvedType == null) return null;
// the qualification MUST exactly match some enclosing type name
// Its possible to qualify 'this' by the name of the current class
int depth = 0;
- currentCompatibleType = scope.referenceType().binding;
- while (currentCompatibleType != null
- && currentCompatibleType != qualificationTb) {
+ this.currentCompatibleType = scope.referenceType().binding;
+ while (this.currentCompatibleType != null
+ && this.currentCompatibleType != this.resolvedType) {
depth++;
- currentCompatibleType =
- currentCompatibleType.isStatic() ? null : currentCompatibleType.enclosingType();
+ this.currentCompatibleType = this.currentCompatibleType.isStatic() ? null : this.currentCompatibleType.enclosingType();
}
bits &= ~DepthMASK; // flush previous depth if any
bits |= (depth & 0xFF) << DepthSHIFT; // encoded depth into 8 bits
- if (currentCompatibleType == null) {
- scope.problemReporter().incorrectEnclosingInstanceReference(
- this,
- qualificationTb);
- return null;
+ if (this.currentCompatibleType == null) {
+ scope.problemReporter().noSuchEnclosingInstance(this.resolvedType, this, false);
+ return this.resolvedType;
}
// Ensure one cannot write code like: B() { super(B.this); }
if (depth == 0) {
- if (!checkAccess(scope.methodScope(), qualificationTb))
- return null;
- } else {
- // Could also be targeting an enclosing instance inside a super constructor invocation
- // class X {
- // public X(int i) {
- // this(new Object() { Object obj = X.this; });
- // }
- // }
-
- MethodScope methodScope = scope.methodScope();
- while (methodScope != null) {
- if (methodScope.enclosingSourceType() == currentCompatibleType) {
- if (!this.checkAccess(methodScope, qualificationTb))
- return null;
- break;
- }
- methodScope = methodScope.parent.methodScope();
- }
- }
- return qualificationTb;
+ checkAccess(scope.methodScope());
+ } // if depth>0, path emulation will diagnose bad scenarii
+ return this.resolvedType;
}
public String toStringExpression() {
@@ -173,4 +113,4 @@
}
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
index 2df8f81..3244db7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -22,9 +22,9 @@
sourceStart = (int) (sourcePositions[0]>>>32) ;
sourceEnd = (int)(sourcePositions[sourcePositions.length-1] & 0x00000000FFFFFFFFL ) ;
}
-public QualifiedTypeReference(char[][] sources , TypeBinding tb , long[] poss) {
+public QualifiedTypeReference(char[][] sources , TypeBinding type , long[] poss) {
this(sources,poss);
- binding = tb;
+ this.resolvedType = type;
}
public TypeReference copyDims(int dim){
//return a type reference copy of me with some dimensions
@@ -33,8 +33,8 @@
return new ArrayQualifiedTypeReference(tokens,null,dim,sourcePositions) ;
}
public TypeBinding getTypeBinding(Scope scope) {
- if (binding != null)
- return binding;
+ if (this.resolvedType != null)
+ return this.resolvedType;
return scope.getType(tokens);
}
public char[][] getTypeName(){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java
index 0929d8f..33652ba 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java
@@ -1,20 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.flow.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.Util;
public abstract class Reference extends Expression {
/**
@@ -23,9 +21,8 @@
public Reference() {
super();
}
-public FlowInfo analyseAssignment(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, Assignment assignment, boolean isCompound) {
- throw new ShouldNotImplement(Util.bind("ast.variableShouldProvide")); //$NON-NLS-1$
-}
+public abstract FlowInfo analyseAssignment(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, Assignment assignment, boolean isCompound);
+
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
return flowInfo;
}
@@ -64,13 +61,10 @@
}
}
}
-public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) {
- throw new ShouldNotImplement(Util.bind("ast.compoundPreShouldProvide")); //$NON-NLS-1$
-}
-public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
- throw new ShouldNotImplement(Util.bind("ast.compoundVariableShouldProvide")); //$NON-NLS-1$
-}
-public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
- throw new ShouldNotImplement(Util.bind("ast.postIncrShouldProvide")); //$NON-NLS-1$
-}
+public abstract void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired);
+
+public abstract void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired);
+
+public abstract void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired);
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
index da9dbc4..cb47c2c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -41,7 +41,7 @@
int subIndex = 0, maxSub = 5;
boolean saveValueNeeded = false;
boolean hasValueToSave = expression != null && expression.constant == NotAConstant;
- while (true) {
+ do {
AstNode sub;
if ((sub = traversedContext.subRoutine()) != null) {
if (this.subroutines == null){
@@ -56,33 +56,28 @@
break;
}
}
- AstNode node;
+ traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
+ AstNode node;
if ((node = traversedContext.associatedNode) instanceof SynchronizedStatement) {
isSynchronized = true;
- } else if (node instanceof TryStatement && hasValueToSave) {
+ } else if (node instanceof TryStatement) {
+ TryStatement tryStatement = (TryStatement) node;
+ flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits
+ if (hasValueToSave) {
if (this.saveValueVariable == null){ // closest subroutine secret variable is used
- prepareSaveValueLocation((TryStatement)node);
+ prepareSaveValueLocation(tryStatement);
}
saveValueNeeded = true;
+ }
} else if (traversedContext instanceof InitializationFlowContext) {
currentScope.problemReporter().cannotReturnInInitializer(this);
- return FlowInfo.DeadEnd;
+ return FlowInfo.DEAD_END;
}
-
- // remember the initialization at this
- // point for dealing with blank final variables.
- traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
-
- FlowContext parentContext;
- if ((parentContext = traversedContext.parent) == null) { // top-context
- break;
- } else {
- traversedContext = parentContext;
- }
- }
+ } while ((traversedContext = traversedContext.parent) != null);
+
// resize subroutines
if ((subroutines != null) && (subIndex != maxSub)) {
System.arraycopy(subroutines, 0, (subroutines = new AstNode[subIndex]), 0, subIndex);
@@ -91,7 +86,7 @@
// secret local variable for return value (note that this can only occur in a real method)
if (saveValueNeeded) {
if (this.saveValueVariable != null) {
- this.saveValueVariable.used = true;
+ this.saveValueVariable.useFlag = LocalVariableBinding.USED;
}
} else {
this.saveValueVariable = null;
@@ -99,7 +94,7 @@
this.expression.bits |= ValueForReturnMASK;
}
}
- return FlowInfo.DeadEnd;
+ return FlowInfo.DEAD_END;
}
/**
@@ -118,7 +113,7 @@
// generate the expression
if ((expression != null) && (expression.constant == NotAConstant)) {
expression.generateCode(currentScope, codeStream, needValue()); // no value needed if non-returning subroutine
- generateStoreSaveValueIfNecessary(currentScope, codeStream);
+ generateStoreSaveValueIfNecessary(codeStream);
}
// generation of code responsible for invoking the finally blocks in sequence
@@ -144,10 +139,10 @@
if ((expression != null) && (expression.constant != NotAConstant)) {
codeStream.generateConstant(expression.constant, expression.implicitConversion);
- generateStoreSaveValueIfNecessary(currentScope, codeStream);
+ generateStoreSaveValueIfNecessary(codeStream);
}
// output the suitable return bytecode or wrap the value inside a descriptor for doits
- this.generateReturnBytecode(currentScope, codeStream);
+ this.generateReturnBytecode(codeStream);
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
@@ -155,7 +150,7 @@
* Dump the suitable return bytecode for a return statement
*
*/
-public void generateReturnBytecode(BlockScope currentScope, CodeStream codeStream) {
+public void generateReturnBytecode(CodeStream codeStream) {
if (expression == null) {
codeStream.return_();
@@ -179,8 +174,7 @@
}
}
}
-public void generateStoreSaveValueIfNecessary(BlockScope currentScope, CodeStream codeStream){
-
+public void generateStoreSaveValueIfNecessary(CodeStream codeStream){
if (saveValueVariable != null) codeStream.store(saveValueVariable, false);
}
public boolean needValue(){
@@ -223,7 +217,7 @@
scope.problemReporter().attemptToReturnVoidValue(this);
return;
}
- if (methodType != null && scope.areTypesCompatible(expressionType, methodType)) {
+ if (methodType != null && expressionType.isCompatibleWith(methodType)) {
expression.implicitWidening(methodType, expressionType);
return;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
index 3ebfff2..d3f56db 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -36,10 +36,10 @@
switch (bits & RestrictiveFlagMASK) {
case FIELD : // reading a field
FieldBinding fieldBinding;
- if ((fieldBinding = (FieldBinding) binding).isFinal() && currentScope.allowBlankFinalFieldAssignment(fieldBinding)) {
+ if ((fieldBinding = (FieldBinding) binding).isBlankFinal()
+ && currentScope.allowBlankFinalFieldAssignment(fieldBinding)) {
if (!flowInfo.isDefinitelyAssigned(fieldBinding)) {
currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
- // we could improve error msg here telling "cannot use compound assignment on final blank field"
}
}
manageSyntheticReadAccessIfNecessary(currentScope);
@@ -51,7 +51,11 @@
currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
// we could improve error msg here telling "cannot use compound assignment on final local variable"
}
- if (!flowInfo.isFakeReachable()) localBinding.used = true;
+ if (flowInfo.isReachable()) {
+ localBinding.useFlag = LocalVariableBinding.USED;
+ } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
+ localBinding.useFlag = LocalVariableBinding.FAKE_USED;
+ }
}
}
if (assignment.expression != null) {
@@ -65,12 +69,13 @@
FieldBinding fieldBinding;
if ((fieldBinding = (FieldBinding) binding).isFinal()) {
// inside a context where allowed
- if (currentScope.allowBlankFinalFieldAssignment(fieldBinding)) {
+ if (!isCompound && fieldBinding.isBlankFinal() && currentScope.allowBlankFinalFieldAssignment(fieldBinding)) {
if (flowInfo.isPotentiallyAssigned(fieldBinding)) {
currentScope.problemReporter().duplicateInitializationOfBlankFinalField(fieldBinding, this);
+ } else {
+ flowContext.recordSettingFinal(fieldBinding, this);
}
flowInfo.markAsDefinitelyAssigned(fieldBinding);
- flowContext.recordSettingFinal(fieldBinding, this);
} else {
currentScope.problemReporter().cannotAssignToFinalField(fieldBinding, this);
}
@@ -85,10 +90,13 @@
}
if (localBinding.isFinal()) {
if ((bits & DepthMASK) == 0) {
- if (flowInfo.isPotentiallyAssigned(localBinding)) {
+ if (isCompound || !localBinding.isBlankFinal()){
+ currentScope.problemReporter().cannotAssignToFinalLocal(localBinding, this);
+ } else if (flowInfo.isPotentiallyAssigned(localBinding)) {
currentScope.problemReporter().duplicateInitializationOfFinalLocal(localBinding, this);
+ } else {
+ flowContext.recordSettingFinal(localBinding, this);
}
- flowContext.recordSettingFinal(localBinding, this);
} else {
currentScope.problemReporter().cannotAssignToFinalOuterLocal(localBinding, this);
}
@@ -110,7 +118,8 @@
}
// check if reading a final blank field
FieldBinding fieldBinding;
- if ((fieldBinding = (FieldBinding) binding).isFinal() && currentScope.allowBlankFinalFieldAssignment(fieldBinding)) {
+ if ((fieldBinding = (FieldBinding) binding).isBlankFinal()
+ && currentScope.allowBlankFinalFieldAssignment(fieldBinding)) {
if (!flowInfo.isDefinitelyAssigned(fieldBinding)) {
currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
}
@@ -121,7 +130,11 @@
if (!flowInfo.isDefinitelyAssigned(localBinding = (LocalVariableBinding) binding)) {
currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
}
- if (!flowInfo.isFakeReachable()) localBinding.used = true;
+ if (flowInfo.isReachable()) {
+ localBinding.useFlag = LocalVariableBinding.USED;
+ } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
+ localBinding.useFlag = LocalVariableBinding.FAKE_USED;
+ }
}
if (valueRequired) {
manageEnclosingInstanceAccessIfNecessary(currentScope);
@@ -137,42 +150,20 @@
if (!((FieldBinding) binding).isStatic()) {
// must check for the static status....
if (scope.methodScope().isStatic) {
- scope.problemReporter().staticFieldAccessToNonStaticVariable(
- this,
- fieldBinding);
+ scope.problemReporter().staticFieldAccessToNonStaticVariable(this, fieldBinding);
constant = NotAConstant;
- return null;
+ return fieldBinding.type;
}
}
- constant = FieldReference.getConstantFor(fieldBinding, true, this, scope, 0);
+ constant = FieldReference.getConstantFor(fieldBinding, this, true, scope);
+
if (isFieldUseDeprecated(fieldBinding, scope))
scope.problemReporter().deprecatedField(fieldBinding, this);
- //===============================================
- //cycle are forbidden ONLY within the same class...why ?????? (poor javac....)
- //Cycle can be done using cross class ref but not direct into a same class reference ????
- //class A { static int k = B.k+1;}
- //class B { static int k = A.k+2;}
- //The k-cycle in this example is valid.
-
- //class C { static int k = k + 1 ;}
- //here it is forbidden ! ????
- //but the next one is valid !!!
- //class C { static int k = C.k + 1;}
-
- //notice that the next one is also valid ?!?!
- //class A { static int k = foo().k+1 ; static A foo(){return new A();}}
-
- //for all these reasons, the next piece of code is only here and not
- //commun for all FieldRef and QualifiedNameRef....(i.e. in the getField(..) API.....
-
- //instance field may refer to forward static field, like in
- //int i = staticI;
- //static int staticI = 2 ;
-
MethodScope ms = scope.methodScope();
- if (ms.enclosingSourceType() == fieldBinding.declaringClass
- && ms.fieldDeclarationIndex != ms.NotInFieldDecl
+ if ((this.bits & IsStrictlyAssignedMASK) == 0
+ && ms.enclosingSourceType() == fieldBinding.declaringClass
+ && ms.fieldDeclarationIndex != MethodScope.NotInFieldDecl
&& fieldBinding.id >= ms.fieldDeclarationIndex) {
//if the field is static and ms is not .... then it is valid
if (!fieldBinding.isStatic() || ms.isStatic)
@@ -211,13 +202,9 @@
FieldBinding fieldBinding;
if (!(fieldBinding = (FieldBinding) this.codegenBinding).isStatic()) { // need a receiver?
if ((bits & DepthMASK) != 0) {
- Object[] emulationPath = currentScope.getExactEmulationPath(currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT));
- if (emulationPath == null) {
- // internal error, per construction we should have found it
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(emulationPath, this, currentScope);
- }
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
+ codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
} else {
this.generateReceiver(codeStream);
}
@@ -254,6 +241,14 @@
}
return;
}
+ // 26903, need extra cast to store null in array local var
+ if (localBinding.type.isArrayType()
+ && (assignment.expression.resolvedType == NullBinding // arrayLoc = null
+ || ((assignment.expression instanceof CastExpression) // arrayLoc = (type[])null
+ && (((CastExpression)assignment.expression).innermostCastedExpression().resolvedType == NullBinding)))){
+ codeStream.checkcast(localBinding.type);
+ }
+
// normal local assignment (since cannot store in outer local which are final locations)
codeStream.store(localBinding, valueRequired);
if ((bits & FirstAssignmentToLocalMASK) != 0) { // for local variable debug attributes
@@ -280,13 +275,9 @@
boolean isStatic;
if (!(isStatic = fieldBinding.isStatic())) {
if ((bits & DepthMASK) != 0) {
- Object[] emulationPath = currentScope.getExactEmulationPath(currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT));
- if (emulationPath == null) {
- // internal error, per construction we should have found it
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(emulationPath, this, currentScope);
- }
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
+ codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
} else {
generateReceiver(codeStream);
}
@@ -314,12 +305,7 @@
if ((bits & DepthMASK) != 0) {
// outer local can be reached either through a synthetic arg or a synthetic field
VariableBinding[] path = currentScope.getEmulationPath(localBinding);
- if (path == null) {
- // emulation was not possible (should not happen per construction)
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(path, this, currentScope);
- }
+ codeStream.generateOuterAccess(path, this, localBinding, currentScope);
} else {
// regular local variable read
codeStream.load(localBinding);
@@ -363,13 +349,9 @@
}
} else {
if ((bits & DepthMASK) != 0) {
- Object[] emulationPath = currentScope.getExactEmulationPath(currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT));
- if (emulationPath == null) {
- // internal error, per construction we should have found it
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(emulationPath, this, currentScope);
- }
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
+ codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
} else {
codeStream.aload_0();
}
@@ -468,13 +450,9 @@
}
} else {
if ((bits & DepthMASK) != 0) {
- Object[] emulationPath = currentScope.getExactEmulationPath(currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT));
- if (emulationPath == null) {
- // internal error, per construction we should have found it
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(emulationPath, this, currentScope);
- }
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
+ codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
} else {
codeStream.aload_0();
}
@@ -542,20 +520,8 @@
//If inlinable field, forget the access emulation, the code gen will directly target it
if (((bits & DepthMASK) == 0) || (constant != NotAConstant)) return;
- switch (bits & RestrictiveFlagMASK) {
- case FIELD :
- FieldBinding fieldBinding;
- if ((fieldBinding = (FieldBinding)binding).isStatic() || (fieldBinding.constant != NotAConstant)) return;
- ReferenceBinding compatibleType = currentScope.enclosingSourceType();
- // the declaringClass of the target binding must be compatible with the enclosing
- // type at <depth> levels outside
- for (int i = 0, depth = (bits & DepthMASK) >> DepthSHIFT; i < depth; i++) {
- compatibleType = compatibleType.enclosingType();
- }
- currentScope.emulateOuterAccess(compatibleType, false); // request cascade of accesses
- break;
- case LOCAL :
- currentScope.emulateOuterAccess((LocalVariableBinding) binding);
+ if ((bits & RestrictiveFlagMASK) == LOCAL) {
+ currentScope.emulateOuterAccess((LocalVariableBinding) binding);
}
}
public void manageSyntheticReadAccessIfNecessary(BlockScope currentScope) {
@@ -582,13 +548,13 @@
}
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, field's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
// and not from Object or implicit static field access.
if (fieldBinding.declaringClass != this.actualReceiverType
&& !this.actualReceiverType.isArrayType()
&& fieldBinding.declaringClass != null
&& fieldBinding.constant == NotAConstant
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
&& !fieldBinding.isStatic()
&& fieldBinding.declaringClass.id != T_Object) // no change for Object fields (if there was any)
|| !fieldBinding.declaringClass.canBeSeenBy(currentScope))){
@@ -616,13 +582,13 @@
}
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, field's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
// and not from Object or implicit static field access.
if (fieldBinding.declaringClass != this.actualReceiverType
&& !this.actualReceiverType.isArrayType()
&& fieldBinding.declaringClass != null
&& fieldBinding.constant == NotAConstant
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
&& !fieldBinding.isStatic()
&& fieldBinding.declaringClass.id != T_Object) // no change for Object fields (if there was any)
|| !fieldBinding.declaringClass.canBeSeenBy(currentScope))){
@@ -652,17 +618,22 @@
case VARIABLE : // =========only variable============
case VARIABLE | TYPE : //====both variable and type============
if (binding instanceof VariableBinding) {
- VariableBinding vb = (VariableBinding) binding;
+ VariableBinding variable = (VariableBinding) binding;
if (binding instanceof LocalVariableBinding) {
bits &= ~RestrictiveFlagMASK; // clear bits
bits |= LOCAL;
- constant = vb.constant;
- if ((!vb.isFinal()) && ((bits & DepthMASK) != 0))
- scope.problemReporter().cannotReferToNonFinalOuterLocal((LocalVariableBinding)vb, this);
- return vb.type;
+ if ((this.bits & IsStrictlyAssignedMASK) == 0) {
+ constant = variable.constant;
+ } else {
+ constant = NotAConstant;
+ }
+ if ((!variable.isFinal()) && ((bits & DepthMASK) != 0)) {
+ scope.problemReporter().cannotReferToNonFinalOuterLocal((LocalVariableBinding)variable, this);
+ }
+ return this.resolvedType = variable.type;
}
// a field
- return checkFieldAccess(scope);
+ return this.resolvedType = checkFieldAccess(scope);
}
// thus it was a type
@@ -673,12 +644,12 @@
//deprecated test
if (isTypeUseDeprecated((TypeBinding) binding, scope))
scope.problemReporter().deprecatedType((TypeBinding) binding, this);
- return (TypeBinding) binding;
+ return this.resolvedType = (TypeBinding) binding;
}
}
// error scenarii
- return this.reportError(scope);
+ return this.resolvedType = this.reportError(scope);
}
public String toStringExpression(){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java
index 7130c0c..e907566 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleTypeReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -23,9 +23,9 @@
sourceEnd = (int) (pos & 0x00000000FFFFFFFFL) ;
}
-public SingleTypeReference(char[] source ,TypeBinding tb, long pos) {
+public SingleTypeReference(char[] source ,TypeBinding type, long pos) {
this(source, pos) ;
- binding = tb ;
+ this.resolvedType = type ;
}
public TypeReference copyDims(int dim){
//return a type reference copy of me with some dimensions
@@ -34,8 +34,8 @@
return new ArrayTypeReference(token,null,dim,(((long)sourceStart)<<32)+sourceEnd) ;
}
public TypeBinding getTypeBinding(Scope scope) {
- if (binding != null)
- return binding;
+ if (this.resolvedType != null)
+ return this.resolvedType;
return scope.getType(token);
}
public char [][] getTypeName() {
@@ -49,7 +49,7 @@
}
if (isTypeUseDeprecated(memberTb, scope))
scope.problemReporter().deprecatedType(memberTb, this);
- return binding = memberTb;
+ return this.resolvedType = memberTb;
}
public String toStringExpression(int tab){
return new String(token) ;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
index 463e0d9..bdacc05 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Statement.java
@@ -1,21 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.compiler.codegen.*;
import org.eclipse.jdt.internal.compiler.flow.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.Util;
public abstract class Statement extends AstNode {
@@ -26,16 +24,9 @@
super();
}
- public FlowInfo analyseCode(
- BlockScope currentScope,
- FlowContext flowContext,
- FlowInfo flowInfo) {
- return flowInfo;
- }
+ public abstract FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo);
- public void generateCode(BlockScope currentScope, CodeStream codeStream) {
- throw new ShouldNotImplement(Util.bind("ast.missingStatement")); //$NON-NLS-1$
- }
+ public abstract void generateCode(BlockScope currentScope, CodeStream codeStream);
public boolean isEmptyBlock() {
return false;
@@ -56,13 +47,9 @@
return true;
}
- public void resolve(BlockScope scope) {
- }
+ public abstract void resolve(BlockScope scope);
- public Constant resolveCase(
- BlockScope scope,
- TypeBinding testType,
- SwitchStatement switchStatement) {
+ public Constant resolveCase(BlockScope scope, TypeBinding testType, SwitchStatement switchStatement) {
// statement within a switch that are not case are treated as normal statement....
resolve(scope);
@@ -78,4 +65,4 @@
*/
public void branchChainTo(Label label) {
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/StringLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/StringLiteral.java
index 8838c58..656c7f4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/StringLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/StringLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -17,89 +17,98 @@
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class StringLiteral extends Literal {
+
char[] source;
-public StringLiteral(char[] token, int s, int e) {
- this(s,e);
- source = token;
-}
-public StringLiteral(int s, int e) {
- super(s,e);
-}
-public void computeConstant() {
+ public StringLiteral(char[] token, int s, int e) {
- constant = Constant.fromValue(String.valueOf(source));}
-public ExtendedStringLiteral extendWith(CharLiteral lit){
- //add the lit source to mine, just as if it was mine
-
- return new ExtendedStringLiteral(this,lit);
-}
-public ExtendedStringLiteral extendWith(StringLiteral lit){
- //add the lit source to mine, just as if it was mine
-
- return new ExtendedStringLiteral(this,lit);
-}
-/**
- * Code generation for string literal
- *
- * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
- * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
- * @param valueRequired boolean
- */
-public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
- int pc = codeStream.position;
- if (valueRequired)
- codeStream.ldc(constant.stringValue());
- codeStream.recordPositionsFrom(pc, this.sourceStart);
-}
-public TypeBinding literalType(BlockScope scope) {
- return scope.getJavaLangString();
-}
-/**
- * source method comment.
- */
-public char[] source() {
- return source;
-}
-public String toStringExpression() {
-
- // handle some special char.....
- StringBuffer result = new StringBuffer("\""); //$NON-NLS-1$
- for (int i = 0; i < source.length; i++) {
- switch (source[i]) {
- case '\b' :
- result.append("\\b"); //$NON-NLS-1$
- break;
- case '\t' :
- result.append("\\t"); //$NON-NLS-1$
- break;
- case '\n' :
- result.append("\\n"); //$NON-NLS-1$
- break;
- case '\f' :
- result.append("\\f"); //$NON-NLS-1$
- break;
- case '\r' :
- result.append("\\r"); //$NON-NLS-1$
- break;
- case '\"' :
- result.append("\\\""); //$NON-NLS-1$
- break;
- case '\'' :
- result.append("\\'"); //$NON-NLS-1$
- break;
- case '\\' : //take care not to display the escape as a potential real char
- result.append("\\\\"); //$NON-NLS-1$
- break;
- default :
- result.append(source[i]);
- }
+ this(s,e);
+ source = token;
}
- result.append("\""); //$NON-NLS-1$
- return result.toString();
-}
-public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
- visitor.visit(this, scope);
- visitor.endVisit(this, scope);
-}
+
+ public StringLiteral(int s, int e) {
+
+ super(s,e);
+ }
+
+ public void computeConstant() {
+
+ constant = Constant.fromValue(String.valueOf(source));
+ }
+
+ public ExtendedStringLiteral extendWith(CharLiteral lit){
+
+ //add the lit source to mine, just as if it was mine
+ return new ExtendedStringLiteral(this,lit);
+ }
+
+ public ExtendedStringLiteral extendWith(StringLiteral lit){
+
+ //add the lit source to mine, just as if it was mine
+ return new ExtendedStringLiteral(this,lit);
+ }
+
+ /**
+ * Code generation for string literal
+ */
+ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
+
+ int pc = codeStream.position;
+ if (valueRequired)
+ codeStream.ldc(constant.stringValue());
+ codeStream.recordPositionsFrom(pc, this.sourceStart);
+ }
+
+ public TypeBinding literalType(BlockScope scope) {
+
+ return scope.getJavaLangString();
+ }
+
+ public char[] source() {
+
+ return source;
+ }
+
+ public String toStringExpression() {
+
+ // handle some special char.....
+ StringBuffer result = new StringBuffer("\""); //$NON-NLS-1$
+ for (int i = 0; i < source.length; i++) {
+ switch (source[i]) {
+ case '\b' :
+ result.append("\\b"); //$NON-NLS-1$
+ break;
+ case '\t' :
+ result.append("\\t"); //$NON-NLS-1$
+ break;
+ case '\n' :
+ result.append("\\n"); //$NON-NLS-1$
+ break;
+ case '\f' :
+ result.append("\\f"); //$NON-NLS-1$
+ break;
+ case '\r' :
+ result.append("\\r"); //$NON-NLS-1$
+ break;
+ case '\"' :
+ result.append("\\\""); //$NON-NLS-1$
+ break;
+ case '\'' :
+ result.append("\\'"); //$NON-NLS-1$
+ break;
+ case '\\' : //take care not to display the escape as a potential real char
+ result.append("\\\\"); //$NON-NLS-1$
+ break;
+ default :
+ result.append(source[i]);
+ }
+ }
+ result.append("\""); //$NON-NLS-1$
+ return result.toString();
+ }
+
+ public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
+ visitor.visit(this, scope);
+ visitor.endVisit(this, scope);
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SuperReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SuperReference.java
index 08509d3..2111e62 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SuperReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SuperReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -16,22 +16,17 @@
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class SuperReference extends ThisReference {
- public static final SuperReference Super = new SuperReference();
-/**
- * SuperReference constructor comment.
- */
-public SuperReference() {
- super();
-}
-public SuperReference(int pos, int sourceEnd) {
- super();
- sourceStart = pos;
- this.sourceEnd = sourceEnd;
+public SuperReference(int sourceStart, int sourceEnd) {
+ super(sourceStart, sourceEnd);
}
public static ExplicitConstructorCall implicitSuperConstructorCall() {
return new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper);
}
+public boolean isImplicitThis() {
+
+ return false;
+}
public boolean isSuper() {
return true;
@@ -49,7 +44,7 @@
scope.problemReporter().cannotUseSuperInJavaLangObject(this);
return null;
}
- return enclosingTb.superclass;
+ return this.resolvedType = enclosingTb.superclass;
}
public String toStringExpression(){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
index a5832cc..a8fa167 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -45,25 +45,27 @@
// analyse the block by considering specially the case/default statements (need to bind them
// to the entry point)
- FlowInfo caseInits = FlowInfo.DeadEnd;
+ FlowInfo caseInits = FlowInfo.DEAD_END;
// in case of statements before the first case
preSwitchInitStateIndex =
currentScope.methodScope().recordInitializationStates(flowInfo);
int caseIndex = 0;
if (statements != null) {
+ boolean didAlreadyComplain = false;
for (int i = 0, max = statements.length; i < max; i++) {
Statement statement = statements[i];
- if ((caseIndex < caseCount)
- && (statement == cases[caseIndex])) { // statements[i] is a case or a default case
+ if ((caseIndex < caseCount) && (statement == cases[caseIndex])) { // statement is a case
caseIndex++;
caseInits = caseInits.mergedWith(flowInfo.copy().unconditionalInits());
- } else {
- if (statement == defaultCase) {
- caseInits = caseInits.mergedWith(flowInfo.copy().unconditionalInits());
- }
+ didAlreadyComplain = false; // reset complaint
+ } else if (statement == defaultCase) { // statement is the default case
+ caseInits = caseInits.mergedWith(flowInfo.copy().unconditionalInits());
+ didAlreadyComplain = false; // reset complaint
}
- if (!caseInits.complainIfUnreachable(statement, scope)) {
+ if (!caseInits.complainIfUnreachable(statement, scope, didAlreadyComplain)) {
caseInits = statement.analyseCode(scope, switchContext, caseInits);
+ } else {
+ didAlreadyComplain = true;
}
}
}
@@ -126,23 +128,32 @@
// generate expression testes
testExpression.generateCode(currentScope, codeStream, needSwitch);
- // generate the appropriate switch table
+ // generate the appropriate switch table/lookup bytecode
if (needSwitch) {
int max = localKeysCopy[caseCount - 1];
int min = localKeysCopy[0];
if ((long) (caseCount * 2.5) > ((long) max - (long) min)) {
- codeStream.tableswitch(
- defaultLabel,
- min,
- max,
- constants,
- sortedIndexes,
- caseLabels);
+
+ // work-around 1.3 VM bug, if max>0x7FFF0000, must use lookup bytecode
+ // see http://dev.eclipse.org/bugs/show_bug.cgi?id=21557
+ if (max > 0x7FFF0000 && currentScope.environment().options.complianceLevel < CompilerOptions.JDK1_4) {
+ codeStream.lookupswitch(defaultLabel, constants, sortedIndexes, caseLabels);
+
+ } else {
+ codeStream.tableswitch(
+ defaultLabel,
+ min,
+ max,
+ constants,
+ sortedIndexes,
+ caseLabels);
+ }
} else {
codeStream.lookupswitch(defaultLabel, constants, sortedIndexes, caseLabels);
}
codeStream.updateLastRecordedEndPC(codeStream.position);
}
+
// generate the switch block statements
int caseIndex = 0;
if (statements != null) {
@@ -188,8 +199,9 @@
public void resetStateForCodeGeneration() {
-
- this.breakLabel.resetStateForCodeGeneration();
+ if (this.breakLabel != null) {
+ this.breakLabel.resetStateForCodeGeneration();
+ }
}
public void resolve(BlockScope upperScope) {
@@ -198,9 +210,8 @@
if (testType == null)
return;
testExpression.implicitWidening(testType, testType);
- if (!(testExpression
- .isConstantValueOfTypeAssignableToType(testType, IntBinding))) {
- if (!upperScope.areTypesCompatible(testType, IntBinding)) {
+ if (!(testExpression.isConstantValueOfTypeAssignableToType(testType, IntBinding))) {
+ if (!testType.isCompatibleWith(IntBinding)) {
upperScope.problemReporter().incorrectSwitchType(testExpression, testType);
return;
}
@@ -220,7 +231,7 @@
int key = cst.intValue();
for (int j = 0; j < counter; j++) {
if (casesValues[j] == key) {
- scope.problemReporter().duplicateCase((Case) statements[i], cst);
+ scope.problemReporter().duplicateCase((Case) statements[i], cst); //TODO: (philippe) could improve diagnosis to indicate colliding case
}
}
casesValues[counter++] = key;
@@ -309,4 +320,4 @@
label.appendForwardReferencesFrom(this.breakLabel);
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java
index 2c77024..ac2f5a3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SynchronizedStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -43,7 +43,7 @@
FlowInfo flowInfo) {
// mark the synthetic variable as being used
- synchroVariable.used = true;
+ synchroVariable.useFlag = LocalVariableBinding.USED;
// simple propagation to subnodes
flowInfo =
@@ -53,9 +53,8 @@
expression.analyseCode(scope, flowContext, flowInfo));
// optimizing code gen
- if ((flowInfo == FlowInfo.DeadEnd) || flowInfo.isFakeReachable()) {
- blockExit = true;
- }
+ this.blockExit = !flowInfo.isReachable();
+
return flowInfo;
}
@@ -167,4 +166,4 @@
}
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java
index 69858cd..ea71f99 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThisReference.java
@@ -1,72 +1,119 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
import org.eclipse.jdt.internal.compiler.codegen.*;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.lookup.*;
public class ThisReference extends Reference {
+
+ public static ThisReference implicitThis(){
+
+ ThisReference implicitThis = new ThisReference(0, 0);
+ implicitThis.bits |= IsImplicitThisMask;
+ return implicitThis;
+ }
+
+ public ThisReference(int sourceStart, int sourceEnd) {
- public static final ThisReference ThisImplicit = new ThisReference();
-
-/**
- * ThisReference constructor comment.
- */
-public ThisReference() {
- super();
-}
-public ThisReference(int s, int sourceEnd) {
- this();
- this.sourceStart = s ;
- this.sourceEnd = sourceEnd;
-}
-protected boolean checkAccess(MethodScope methodScope) {
- // this/super cannot be used in constructor call
- if (methodScope.isConstructorCall) {
- methodScope.problemReporter().fieldsOrThisBeforeConstructorInvocation(this);
- return false;
+ this.sourceStart = sourceStart;
+ this.sourceEnd = sourceEnd;
}
- // static may not refer to this/super
- if (methodScope.isStatic) {
- methodScope.problemReporter().errorThisSuperInStatic(this);
- return false;
- }
- return true;
-}
-public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
- int pc = codeStream.position;
- if (valueRequired)
- codeStream.aload_0();
- codeStream.recordPositionsFrom(pc, this.sourceStart);
-}
-public boolean isThis() {
-
- return true ;
-}
-public TypeBinding resolveType(BlockScope scope) {
- // implicit this
- constant = NotAConstant;
- if (this != ThisImplicit && !checkAccess(scope.methodScope()))
- return null;
- return scope.enclosingSourceType();
-}
-public String toStringExpression(){
+ /*
+ * @see Reference#analyseAssignment(...)
+ */
+ public FlowInfo analyseAssignment(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, Assignment assignment, boolean isCompound) {
- if (this == ThisImplicit) return "" ; //$NON-NLS-1$
- return "this"; //$NON-NLS-1$
-}
-public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
- visitor.visit(this, blockScope);
- visitor.endVisit(this, blockScope);
-}
+ return flowInfo; // this cannot be assigned
+ }
+
+ public boolean checkAccess(MethodScope methodScope) {
+
+ // this/super cannot be used in constructor call
+ if (methodScope.isConstructorCall) {
+ methodScope.problemReporter().fieldsOrThisBeforeConstructorInvocation(this);
+ return false;
+ }
+
+ // static may not refer to this/super
+ if (methodScope.isStatic) {
+ methodScope.problemReporter().errorThisSuperInStatic(this);
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * @see Reference#generateAssignment(...)
+ */
+ public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) {
+
+ // this cannot be assigned
+ }
+
+ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
+
+ int pc = codeStream.position;
+ if (valueRequired)
+ codeStream.aload_0();
+ if ((this.bits & IsImplicitThisMask) == 0) codeStream.recordPositionsFrom(pc, this.sourceStart);
+ }
+
+ /*
+ * @see Reference#generateCompoundAssignment(...)
+ */
+ public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
+
+ // this cannot be assigned
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.compiler.ast.Reference#generatePostIncrement()
+ */
+ public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
+
+ // this cannot be assigned
+ }
+
+ public boolean isImplicitThis() {
+
+ return (this.bits & IsImplicitThisMask) != 0;
+ }
+
+ public boolean isThis() {
+
+ return true ;
+ }
+
+ public TypeBinding resolveType(BlockScope scope) {
+
+ constant = NotAConstant;
+ if (!this.isImplicitThis() && !checkAccess(scope.methodScope()))
+ return null;
+ return this.resolvedType = scope.enclosingSourceType();
+ }
+
+ public String toStringExpression(){
+
+ if (this.isImplicitThis()) return "" ; //$NON-NLS-1$
+ return "this"; //$NON-NLS-1$
+ }
+
+ public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
+
+ visitor.visit(this, blockScope);
+ visitor.endVisit(this, blockScope);
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java
index ac28041..d938232 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -33,7 +33,7 @@
exception.analyseCode(currentScope, flowContext, flowInfo);
// need to check that exception thrown is actually caught somewhere
flowContext.checkExceptionHandlers(exceptionType, this, flowInfo, currentScope);
- return FlowInfo.DeadEnd;
+ return FlowInfo.DEAD_END;
}
/**
@@ -76,4 +76,4 @@
exception.traverse(visitor, blockScope);
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java
index c863aea..9960bac 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TrueLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
index de58da7..ed49960 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -24,6 +24,8 @@
BlockScope scope;
public boolean subRoutineCannotReturn = true;
+ public UnconditionalFlowInfo subRoutineInits;
+
// should rename into subRoutineComplete to be set to false by default
ReferenceBinding[] caughtExceptionTypes;
@@ -60,10 +62,10 @@
currentScope.methodScope().recordInitializationStates(flowInfo);
if (anyExceptionVariable != null) {
- anyExceptionVariable.used = true;
+ anyExceptionVariable.useFlag = LocalVariableBinding.USED;
}
if (returnAddressVariable != null) {
- returnAddressVariable.used = true;
+ returnAddressVariable.useFlag = LocalVariableBinding.USED;
}
InsideSubRoutineFlowContext insideSubContext;
FinallyFlowContext finallyContext;
@@ -76,16 +78,17 @@
} else {
// analyse finally block first
insideSubContext = new InsideSubRoutineFlowContext(flowContext, this);
- subInfo =
+ subInfo =
finallyBlock
.analyseCode(
currentScope,
finallyContext = new FinallyFlowContext(flowContext, finallyBlock),
flowInfo.copy())
.unconditionalInits();
- if (!((subInfo == FlowInfo.DeadEnd) || subInfo.isFakeReachable())) {
+ if (subInfo.isReachable()) {
subRoutineCannotReturn = false;
}
+ this.subRoutineInits = subInfo;
}
// process the try block in a context handling the local exceptions.
ExceptionHandlingFlowContext handlingContext =
@@ -102,7 +105,7 @@
tryBlockExit = false;
} else {
tryInfo = tryBlock.analyseCode(currentScope, handlingContext, flowInfo.copy());
- tryBlockExit = (tryInfo == FlowInfo.DeadEnd) || tryInfo.isFakeReachable();
+ tryBlockExit = !tryInfo.isReachable();
}
// check unreachable catch blocks
@@ -114,7 +117,6 @@
catchExits = new boolean[catchCount = catchBlocks.length];
for (int i = 0; i < catchCount; i++) {
// keep track of the inits that could potentially have led to this exception handler (for final assignments diagnosis)
- ///*
FlowInfo catchInfo =
flowInfo
.copy()
@@ -133,16 +135,17 @@
"(uncheckedExceptionTypes notNil and: [uncheckedExceptionTypes at: index])
ifTrue: [catchInits addPotentialInitializationsFrom: tryInits]."
*/
+ // TODO: should only tag as unreachable if the catchblock cannot be reached
+ //??? if (!handlingContext.initsOnException(caughtExceptionTypes[i]).isReachable()){
if (tryBlock.statements == null) {
- catchInfo.markAsFakeReachable(true);
+ catchInfo.setReachMode(FlowInfo.UNREACHABLE);
}
catchInfo =
catchBlocks[i].analyseCode(
currentScope,
insideSubContext == null ? flowContext : insideSubContext,
catchInfo);
- catchExits[i] =
- ((catchInfo == FlowInfo.DeadEnd) || catchInfo.isFakeReachable());
+ catchExits[i] = !catchInfo.isReachable();
tryInfo = tryInfo.mergedWith(catchInfo.unconditionalInits());
}
}
@@ -152,11 +155,15 @@
return tryInfo;
}
+
// we also need to check potential multiple assignments of final variables inside the finally block
// need to include potential inits from returns inside the try/catch parts - 1GK2AOF
- tryInfo.addPotentialInitializationsFrom(insideSubContext.initsOnReturn);
- finallyContext.complainOnRedundantFinalAssignments(tryInfo, currentScope);
- if (subInfo == FlowInfo.DeadEnd) {
+ finallyContext.complainOnRedundantFinalAssignments(
+ tryInfo.isReachable()
+ ? (tryInfo.addPotentialInitializationsFrom(insideSubContext.initsOnReturn))
+ : insideSubContext.initsOnReturn,
+ currentScope);
+ if (subInfo == FlowInfo.DEAD_END) {
mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(subInfo);
return subInfo;
@@ -246,8 +253,7 @@
if (tryBlockHasSomeCode) {
for (int i = 0; i < maxCatches; i++) {
boolean preserveCurrentHandler =
- (preserveExceptionHandler[i
- / ExceptionHandlingFlowContext.BitCacheSize]
+ (preserveExceptionHandler[i / ExceptionHandlingFlowContext.BitCacheSize]
& (1 << (i % ExceptionHandlingFlowContext.BitCacheSize)))
!= 0;
if (preserveCurrentHandler) {
@@ -265,8 +271,7 @@
} else {
for (int i = 0; i < maxCatches; i++) {
boolean preserveCurrentHandler =
- (preserveExceptionHandler[i
- / ExceptionHandlingFlowContext.BitCacheSize]
+ (preserveExceptionHandler[i / ExceptionHandlingFlowContext.BitCacheSize]
& (1 << (i % ExceptionHandlingFlowContext.BitCacheSize)))
!= 0;
if (preserveCurrentHandler) {
@@ -387,6 +392,12 @@
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
+ public void resetStateForCodeGeneration() {
+ if (this.subRoutineStartLabel != null) {
+ this.subRoutineStartLabel.resetStateForCodeGeneration();
+ }
+ }
+
public void resolve(BlockScope upperScope) {
// special scope for secret locals optimization.
@@ -403,7 +414,7 @@
// provision for returning and forcing the finally block to run
MethodScope methodScope = scope.methodScope();
- // the type does not matter as long as its not a normal base type
+ // the type does not matter as long as it is not a base type
this.returnAddressVariable =
new LocalVariableBinding(SecretReturnName, upperScope.getJavaLangObject(), AccDefault, false);
finallyScope.addLocalVariable(returnAddressVariable);
@@ -460,9 +471,9 @@
for (int i = 0; i < length; i++) {
caughtExceptionTypes[i] = (ReferenceBinding) argumentTypes[i];
for (int j = 0; j < i; j++) {
- if (scope.areTypesCompatible(caughtExceptionTypes[i], argumentTypes[j])) {
+ if (caughtExceptionTypes[i].isCompatibleWith(argumentTypes[j])) {
scope.problemReporter().wrongSequenceOfExceptionTypesError(this, i, j);
- return;
+ // cannot return - since may still proceed if unreachable code is ignored (21203)
}
}
}
@@ -522,4 +533,4 @@
}
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
index 4cdb509..198a8c5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.impl.*;
@@ -18,7 +19,6 @@
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.*;
import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
public class TypeDeclaration
extends Statement
@@ -123,64 +123,14 @@
if (ignoreFurtherInvestigation)
return flowInfo;
try {
- // remember local types binding for innerclass emulation propagation
- currentScope.referenceCompilationUnit().record((LocalTypeBinding) binding);
-
- InitializationFlowContext initializerContext =
- new InitializationFlowContext(null, this, initializerScope);
- // propagate down the max field count
- updateMaxFieldCount();
- FlowInfo fieldInfo = flowInfo.copy();
- // so as not to propagate changes outside this type
- if (fields != null) {
- for (int i = 0, count = fields.length; i < count; i++) {
- fieldInfo =
- fields[i].analyseCode(initializerScope, initializerContext, fieldInfo);
- if (fieldInfo == FlowInfo.DeadEnd) {
- // in case the initializer is not reachable, use a reinitialized flowInfo and enter a fake reachable
- // branch, since the previous initializer already got the blame.
- initializerScope.problemReporter().initializerMustCompleteNormally(fields[i]);
- fieldInfo = FlowInfo.initial(maxFieldCount).markAsFakeReachable(true);
- }
- }
- }
- if (memberTypes != null) {
- for (int i = 0, count = memberTypes.length; i < count; i++) {
- memberTypes[i].analyseCode(scope, flowContext, fieldInfo.copy());
- }
- }
- if (methods != null) {
- int recursionBalance = 0; // check constructor recursions
- for (int i = 0, count = methods.length; i < count; i++) {
- AbstractMethodDeclaration method = methods[i];
- if (method.ignoreFurtherInvestigation)
- continue;
- if (method.isConstructor()) { // constructor
- ConstructorDeclaration constructor = (ConstructorDeclaration) method;
- constructor.analyseCode(scope, initializerContext, fieldInfo.copy());
- // compute the recursive invocation balance:
- // how many thisReferences vs. superReferences to constructors
- int refCount;
- if ((refCount = constructor.referenceCount) > 0) {
- if ((constructor.constructorCall == null)
- || constructor.constructorCall.isSuperAccess()
- || !constructor.constructorCall.binding.isValidBinding()) {
- recursionBalance -= refCount;
- constructor.referenceCount = -1;
- // for error reporting propagation
- } else {
- recursionBalance += refCount;
- }
- }
- } else { // regular method
- method.analyseCode(scope, null, flowInfo.copy());
- }
- }
- if (recursionBalance > 0) {
- // there is one or more cycle(s) amongst constructor invocations
- scope.problemReporter().recursiveConstructorInvocation(this);
- }
- }
+ bits |= IsReachableMASK;
+ LocalTypeBinding localType = (LocalTypeBinding) binding;
+
+ localType.setConstantPoolName(currentScope.compilationUnitScope().computeConstantPoolName(localType));
+ manageEnclosingInstanceAccessIfNecessary(currentScope);
+
+ updateMaxFieldCount(); // propagate down the max field count
+ internalAnalyseCode(flowContext, flowInfo);
} catch (AbortType e) {
this.ignoreFurtherInvestigation = true;
}
@@ -191,90 +141,17 @@
* Flow analysis for a member innertype
*
*/
- public void analyseCode(ClassScope classScope1) {
+ public void analyseCode(ClassScope enclosingClassScope) {
if (ignoreFurtherInvestigation)
return;
try {
// propagate down the max field count
updateMaxFieldCount();
- FlowInfo flowInfo = FlowInfo.initial(maxFieldCount); // start fresh init info
- InitializationFlowContext initializerContext =
- new InitializationFlowContext(null, this, initializerScope);
- InitializationFlowContext staticInitializerContext =
- new InitializationFlowContext(null, this, staticInitializerScope);
- FlowInfo nonStaticFieldInfo = flowInfo.copy(),
- staticFieldInfo = flowInfo.copy();
- if (fields != null) {
- for (int i = 0, count = fields.length; i < count; i++) {
- if (fields[i].isStatic()) {
- staticFieldInfo =
- fields[i].analyseCode(
- staticInitializerScope,
- staticInitializerContext,
- staticFieldInfo);
- // in case the initializer is not reachable, use a reinitialized flowInfo and enter a fake reachable
- // branch, since the previous initializer already got the blame.
- if (staticFieldInfo == FlowInfo.DeadEnd) {
- staticInitializerScope.problemReporter().initializerMustCompleteNormally(
- fields[i]);
- staticFieldInfo = FlowInfo.initial(maxFieldCount).markAsFakeReachable(true);
- }
- } else {
- nonStaticFieldInfo =
- fields[i].analyseCode(initializerScope, initializerContext, nonStaticFieldInfo);
- // in case the initializer is not reachable, use a reinitialized flowInfo and enter a fake reachable
- // branch, since the previous initializer already got the blame.
- if (nonStaticFieldInfo == FlowInfo.DeadEnd) {
- initializerScope.problemReporter().initializerMustCompleteNormally(fields[i]);
- nonStaticFieldInfo = FlowInfo.initial(maxFieldCount).markAsFakeReachable(true);
- }
- }
- }
- }
- if (memberTypes != null) {
- for (int i = 0, count = memberTypes.length; i < count; i++) {
- memberTypes[i].analyseCode(scope);
- }
- }
- if (methods != null) {
- int recursionBalance = 0; // check constructor recursions
- for (int i = 0, count = methods.length; i < count; i++) {
- AbstractMethodDeclaration method = methods[i];
- if (method.ignoreFurtherInvestigation)
- continue;
- if (method.isInitializationMethod()) {
- if (method.isStatic()) { // <clinit>
- ((Clinit) method).analyseCode(scope, staticInitializerContext, staticFieldInfo);
- } else { // constructor
- ConstructorDeclaration constructor = (ConstructorDeclaration) method;
- constructor.analyseCode(scope, initializerContext, nonStaticFieldInfo.copy());
- // compute the recursive invocation balance:
- // how many thisReferences vs. superReferences to constructors
- int refCount;
- if ((refCount = constructor.referenceCount) > 0) {
- if ((constructor.constructorCall == null)
- || constructor.constructorCall.isSuperAccess()
- || !constructor.constructorCall.binding.isValidBinding()) {
- recursionBalance -= refCount;
- constructor.referenceCount = -1; // for error reporting propagation
- } else {
- recursionBalance += refCount;
- }
- }
- }
- } else { // regular method
- method.analyseCode(scope, null, FlowInfo.initial(maxFieldCount));
- }
- }
- if (recursionBalance > 0) {
- // there is one or more cycle(s) amongst constructor invocations
- scope.problemReporter().recursiveConstructorInvocation(this);
- }
- }
+ internalAnalyseCode(null, FlowInfo.initial(maxFieldCount));
} catch (AbortType e) {
this.ignoreFurtherInvestigation = true;
- };
+ }
}
/**
@@ -289,77 +166,17 @@
if (ignoreFurtherInvestigation)
return;
try {
- // remember local types binding for innerclass emulation propagation
- currentScope.referenceCompilationUnit().record((LocalTypeBinding) binding);
+ bits |= IsReachableMASK;
+ LocalTypeBinding localType = (LocalTypeBinding) binding;
- /* force to emulation of access to direct enclosing instance: only for local members.
- * By using the initializer scope, we actually only request an argument emulation, the
- * field is not added until actually used. However we will force allocations to be qualified
- * with an enclosing instance.
- */
- initializerScope.emulateOuterAccess(
- (SourceTypeBinding) binding.enclosingType(),
- false);
-
- InitializationFlowContext initializerContext =
- new InitializationFlowContext(null, this, initializerScope);
- // propagate down the max field count
- updateMaxFieldCount();
- FlowInfo fieldInfo = flowInfo.copy();
- // so as not to propagate changes outside this type
- if (fields != null) {
- for (int i = 0, count = fields.length; i < count; i++) {
- if (!fields[i].isStatic()) {
- fieldInfo =
- fields[i].analyseCode(initializerScope, initializerContext, fieldInfo);
- if (fieldInfo == FlowInfo.DeadEnd) {
- // in case the initializer is not reachable, use a reinitialized flowInfo and enter a fake reachable
- // branch, since the previous initializer already got the blame.
- initializerScope.problemReporter().initializerMustCompleteNormally(fields[i]);
- fieldInfo = FlowInfo.initial(maxFieldCount).markAsFakeReachable(true);
- }
- }
- }
- }
- if (memberTypes != null) {
- for (int i = 0, count = memberTypes.length; i < count; i++) {
- memberTypes[i].analyseCode(scope, flowContext, fieldInfo.copy());
- }
- }
- if (methods != null) {
- int recursionBalance = 0; // check constructor recursions
- for (int i = 0, count = methods.length; i < count; i++) {
- AbstractMethodDeclaration method = methods[i];
- if (method.ignoreFurtherInvestigation)
- continue;
- if (method.isConstructor()) { // constructor
- ConstructorDeclaration constructor = (ConstructorDeclaration) method;
- constructor.analyseCode(scope, initializerContext, fieldInfo.copy());
- // compute the recursive invocation balance:
- // how many thisReferences vs. superReferences to constructors
- int refCount;
- if ((refCount = constructor.referenceCount) > 0) {
- if ((constructor.constructorCall == null)
- || constructor.constructorCall.isSuperAccess()
- || !constructor.constructorCall.binding.isValidBinding()) {
- recursionBalance -= refCount;
- constructor.referenceCount = -1; // for error reporting propagation
- } else {
- recursionBalance += refCount;
- }
- }
- } else { // regular method
- method.analyseCode(scope, null, flowInfo.copy());
- }
- }
- if (recursionBalance > 0) {
- // there is one or more cycle(s) amongst constructor invocations
- scope.problemReporter().recursiveConstructorInvocation(this);
- }
- }
+ localType.setConstantPoolName(currentScope.compilationUnitScope().computeConstantPoolName(localType));
+ manageEnclosingInstanceAccessIfNecessary(currentScope);
+
+ updateMaxFieldCount(); // propagate down the max field count
+ internalAnalyseCode(flowContext, flowInfo);
} catch (AbortType e) {
this.ignoreFurtherInvestigation = true;
- };
+ }
}
/**
@@ -371,83 +188,10 @@
if (ignoreFurtherInvestigation)
return;
try {
- FlowInfo flowInfo = FlowInfo.initial(maxFieldCount); // start fresh init info
- InitializationFlowContext initializerContext =
- new InitializationFlowContext(null, this, initializerScope);
- InitializationFlowContext staticInitializerContext =
- new InitializationFlowContext(null, this, staticInitializerScope);
- FlowInfo nonStaticFieldInfo = flowInfo.copy(),
- staticFieldInfo = flowInfo.copy();
- if (fields != null) {
- for (int i = 0, count = fields.length; i < count; i++) {
- if (fields[i].isStatic()) {
- staticFieldInfo =
- fields[i].analyseCode(
- staticInitializerScope,
- staticInitializerContext,
- staticFieldInfo);
- // in case the initializer is not reachable, use a reinitialized flowInfo and enter a fake reachable
- // branch, since the previous initializer already got the blame.
- if (staticFieldInfo == FlowInfo.DeadEnd) {
- staticInitializerScope.problemReporter().initializerMustCompleteNormally(
- fields[i]);
- staticFieldInfo = FlowInfo.initial(maxFieldCount).markAsFakeReachable(true);
- }
- } else {
- nonStaticFieldInfo =
- fields[i].analyseCode(initializerScope, initializerContext, nonStaticFieldInfo);
- // in case the initializer is not reachable, use a reinitialized flowInfo and enter a fake reachable
- // branch, since the previous initializer already got the blame.
- if (nonStaticFieldInfo == FlowInfo.DeadEnd) {
- initializerScope.problemReporter().initializerMustCompleteNormally(fields[i]);
- nonStaticFieldInfo = FlowInfo.initial(maxFieldCount).markAsFakeReachable(true);
- }
- }
- }
- }
- if (memberTypes != null) {
- for (int i = 0, count = memberTypes.length; i < count; i++) {
- memberTypes[i].analyseCode(scope);
- }
- }
- if (methods != null) {
- int recursionBalance = 0; // check constructor recursions
- for (int i = 0, count = methods.length; i < count; i++) {
- AbstractMethodDeclaration method = methods[i];
- if (method.ignoreFurtherInvestigation)
- continue;
- if (method.isInitializationMethod()) {
- if (method.isStatic()) { // <clinit>
- ((Clinit) method).analyseCode(scope, staticInitializerContext, staticFieldInfo);
- } else { // constructor
- ConstructorDeclaration constructor = (ConstructorDeclaration) method;
- constructor.analyseCode(scope, initializerContext, nonStaticFieldInfo.copy());
- // compute the recursive invocation balance:
- // how many thisReferences vs. superReferences to constructors
- int refCount;
- if ((refCount = constructor.referenceCount) > 0) {
- if ((constructor.constructorCall == null)
- || constructor.constructorCall.isSuperAccess()
- || !constructor.constructorCall.binding.isValidBinding()) {
- recursionBalance -= refCount;
- constructor.referenceCount = -1; // for error reporting propagation
- } else {
- recursionBalance += refCount;
- }
- }
- }
- } else { // regular method
- method.analyseCode(scope, null, FlowInfo.initial(maxFieldCount));
- }
- }
- if (recursionBalance > 0) {
- // there is one or more cycle(s) amongst constructor invocations
- scope.problemReporter().recursiveConstructorInvocation(this);
- }
- }
+ internalAnalyseCode(null, FlowInfo.initial(maxFieldCount));
} catch (AbortType e) {
this.ignoreFurtherInvestigation = true;
- };
+ }
}
/*
@@ -532,8 +276,7 @@
//the super call inside the constructor
if (needExplicitConstructorCall) {
- constructor.constructorCall =
- new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper);
+ constructor.constructorCall = SuperReference.implicitSuperConstructorCall();
constructor.constructorCall.sourceStart = sourceStart;
constructor.constructorCall.sourceEnd = sourceEnd;
}
@@ -771,12 +514,9 @@
*/
public void generateCode(BlockScope blockScope, CodeStream codeStream) {
- if (hasBeenGenerated)
- return;
+ if (hasBeenGenerated) return;
int pc = codeStream.position;
- if (binding != null) {
- ((NestedTypeBinding) binding).computeSyntheticArgumentsOffset();
- }
+ if (binding != null) ((NestedTypeBinding) binding).computeSyntheticArgumentSlotSizes();
generateCode(codeStream.classFile);
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
@@ -786,9 +526,8 @@
*/
public void generateCode(ClassScope classScope, ClassFile enclosingClassFile) {
- if (hasBeenGenerated)
- return;
- ((NestedTypeBinding) binding).computeSyntheticArgumentsOffset();
+ if (hasBeenGenerated) return;
+ if (binding != null) ((NestedTypeBinding) binding).computeSyntheticArgumentSlotSizes();
generateCode(enclosingClassFile);
}
@@ -800,15 +539,146 @@
generateCode((ClassFile) null);
}
+ public boolean hasErrors() {
+ return this.ignoreFurtherInvestigation;
+ }
+
+ /**
+ * Common flow analysis for all types
+ *
+ */
+ public void internalAnalyseCode(FlowContext flowContext, FlowInfo flowInfo) {
+
+ if (this.binding.isPrivate() && !this.binding.isPrivateUsed()) {
+ if (!scope.referenceCompilationUnit().compilationResult.hasSyntaxError()) {
+ scope.problemReporter().unusedPrivateType(this);
+ }
+ }
+
+ ReferenceBinding[] defaultHandledExceptions = new ReferenceBinding[] { scope.getJavaLangThrowable()}; // tolerate any kind of exception
+ InitializationFlowContext initializerContext = new InitializationFlowContext(null, this, initializerScope);
+ InitializationFlowContext staticInitializerContext = new InitializationFlowContext(null, this, staticInitializerScope);
+ FlowInfo nonStaticFieldInfo = flowInfo.copy().unconditionalInits().discardFieldInitializations();
+ FlowInfo staticFieldInfo = flowInfo.copy().unconditionalInits().discardFieldInitializations();
+ if (fields != null) {
+ for (int i = 0, count = fields.length; i < count; i++) {
+ FieldDeclaration field = fields[i];
+ if (field.isStatic()) {
+ /*if (field.isField()){
+ staticInitializerContext.handledExceptions = NoExceptions; // no exception is allowed jls8.3.2
+ } else {*/
+ staticInitializerContext.handledExceptions = defaultHandledExceptions; // tolerate them all, and record them
+ /*}*/
+ staticFieldInfo =
+ field.analyseCode(
+ staticInitializerScope,
+ staticInitializerContext,
+ staticFieldInfo);
+ // in case the initializer is not reachable, use a reinitialized flowInfo and enter a fake reachable
+ // branch, since the previous initializer already got the blame.
+ if (staticFieldInfo == FlowInfo.DEAD_END) {
+ staticInitializerScope.problemReporter().initializerMustCompleteNormally(field);
+ staticFieldInfo = FlowInfo.initial(maxFieldCount).setReachMode(FlowInfo.UNREACHABLE);
+ }
+ } else {
+ /*if (field.isField()){
+ initializerContext.handledExceptions = NoExceptions; // no exception is allowed jls8.3.2
+ } else {*/
+ initializerContext.handledExceptions = defaultHandledExceptions; // tolerate them all, and record them
+ /*}*/
+ nonStaticFieldInfo =
+ field.analyseCode(initializerScope, initializerContext, nonStaticFieldInfo);
+ // in case the initializer is not reachable, use a reinitialized flowInfo and enter a fake reachable
+ // branch, since the previous initializer already got the blame.
+ if (nonStaticFieldInfo == FlowInfo.DEAD_END) {
+ initializerScope.problemReporter().initializerMustCompleteNormally(field);
+ nonStaticFieldInfo = FlowInfo.initial(maxFieldCount).setReachMode(FlowInfo.UNREACHABLE);
+ }
+ }
+ }
+ }
+ if (memberTypes != null) {
+ for (int i = 0, count = memberTypes.length; i < count; i++) {
+ if (flowContext != null){ // local type
+ memberTypes[i].analyseCode(scope, flowContext, nonStaticFieldInfo.copy());
+ } else {
+ memberTypes[i].analyseCode(scope);
+ }
+ }
+ }
+ if (methods != null) {
+ UnconditionalFlowInfo outerInfo = flowInfo.copy().unconditionalInits().discardFieldInitializations();
+ FlowInfo constructorInfo = nonStaticFieldInfo.unconditionalInits().discardNonFieldInitializations().addInitializationsFrom(outerInfo);
+ for (int i = 0, count = methods.length; i < count; i++) {
+ AbstractMethodDeclaration method = methods[i];
+ if (method.ignoreFurtherInvestigation)
+ continue;
+ if (method.isInitializationMethod()) {
+ if (method.isStatic()) { // <clinit>
+ method.analyseCode(
+ scope,
+ staticInitializerContext,
+ staticFieldInfo.unconditionalInits().discardNonFieldInitializations().addInitializationsFrom(outerInfo));
+ } else { // constructor
+ method.analyseCode(scope, initializerContext, constructorInfo.copy());
+ }
+ } else { // regular method
+ method.analyseCode(scope, null, flowInfo.copy());
+ }
+ }
+ }
+ }
+
public boolean isInterface() {
return (modifiers & AccInterface) != 0;
}
- public boolean hasErrors() {
- return this.ignoreFurtherInvestigation;
- }
+ /*
+ * Access emulation for a local type
+ * force to emulation of access to direct enclosing instance.
+ * By using the initializer scope, we actually only request an argument emulation, the
+ * field is not added until actually used. However we will force allocations to be qualified
+ * with an enclosing instance.
+ * 15.9.2
+ */
+ public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope) {
+ NestedTypeBinding nestedType = (NestedTypeBinding) binding;
+
+ MethodScope methodScope = currentScope.methodScope();
+ if (!methodScope.isStatic && !methodScope.isConstructorCall){
+
+ nestedType.addSyntheticArgumentAndField(binding.enclosingType());
+ }
+ // add superclass enclosing instance arg for anonymous types (if necessary)
+ if (binding.isAnonymousType()) {
+ ReferenceBinding superclass = binding.superclass;
+ if (superclass.enclosingType() != null && !superclass.isStatic()) {
+ if (!binding.superclass.isLocalType()
+ || ((NestedTypeBinding)binding.superclass).getSyntheticField(superclass.enclosingType(), true) != null){
+
+ nestedType.addSyntheticArgument(superclass.enclosingType());
+ }
+ }
+ }
+ }
+
+ /*
+ * Access emulation for a local member type
+ * force to emulation of access to direct enclosing instance.
+ * By using the initializer scope, we actually only request an argument emulation, the
+ * field is not added until actually used. However we will force allocations to be qualified
+ * with an enclosing instance.
+ *
+ * Local member cannot be static.
+ */
+ public void manageEnclosingInstanceAccessIfNecessary(ClassScope currentScope) {
+
+ NestedTypeBinding nestedType = (NestedTypeBinding) binding;
+ nestedType.addSyntheticArgumentAndField(binding.enclosingType());
+ }
+
/**
* A <clinit> will be requested as soon as static fields or assertions are present. It will be eliminated during
* classfile creation if no bytecode was actually produced based on some optimizations/compiler settings.
@@ -843,19 +713,22 @@
//members
if (memberTypes != null) {
- for (int i = memberTypes.length; --i >= 0;)
+ int length = memberTypes.length;
+ for (int i = 0; i < length; i++)
memberTypes[i].parseMethod(parser, unit);
}
//methods
if (methods != null) {
- for (int i = methods.length; --i >= 0;)
+ int length = methods.length;
+ for (int i = 0; i < length; i++)
methods[i].parseStatements(parser, unit);
}
//initializers
if (fields != null) {
- for (int i = fields.length; --i >= 0;) {
+ int length = fields.length;
+ for (int i = 0; i < length; i++) {
if (fields[i] instanceof Initializer) {
((Initializer) fields[i]).parseStatements(parser, this, unit);
}
@@ -877,10 +750,10 @@
scope.problemReporter().deprecatedType(binding.superclass, superclass);
if (superInterfaces != null)
for (int i = superInterfaces.length; --i >= 0;)
- if (superInterfaces[i].binding != null)
- if (isTypeUseDeprecated(superInterfaces[i].binding, scope))
+ if (superInterfaces[i].resolvedType != null)
+ if (isTypeUseDeprecated(superInterfaces[i].resolvedType, scope))
scope.problemReporter().deprecatedType(
- superInterfaces[i].binding,
+ superInterfaces[i].resolvedType,
superInterfaces[i]);
maxFieldCount = 0;
int lastFieldID = -1;
@@ -889,6 +762,8 @@
FieldDeclaration field = fields[i];
if (field.isField()) {
if (field.binding == null) {
+ // still discover secondary errors
+ if (field.initialization != null) field.initialization.resolve(field.isStatic() ? staticInitializerScope : initializerScope);
ignoreFurtherInvestigation = true;
continue;
}
@@ -900,12 +775,22 @@
field.resolve(field.isStatic() ? staticInitializerScope : initializerScope);
}
}
- if (memberTypes != null)
- for (int i = 0, count = memberTypes.length; i < count; i++)
+ if (memberTypes != null) {
+ for (int i = 0, count = memberTypes.length; i < count; i++) {
memberTypes[i].resolve(scope);
- if (methods != null)
- for (int i = 0, count = methods.length; i < count; i++)
+ }
+ }
+ int missingAbstractMethodslength = this.missingAbstractMethods == null ? 0 : this.missingAbstractMethods.length;
+ int methodsLength = this.methods == null ? 0 : methods.length;
+ if ((methodsLength + missingAbstractMethodslength) > 0xFFFF) {
+ scope.problemReporter().tooManyMethods(this);
+ }
+
+ if (methods != null) {
+ for (int i = 0, count = methods.length; i < count; i++) {
methods[i].resolve(scope);
+ }
+ }
} catch (AbortType e) {
this.ignoreFurtherInvestigation = true;
return;
@@ -920,6 +805,9 @@
// and TC....
if (binding != null) {
+ // remember local types binding for innerclass emulation propagation
+ blockScope.referenceCompilationUnit().record((LocalTypeBinding)binding);
+
// binding is not set if the receiver could not be created
resolve();
updateMaxFieldCount();
@@ -930,6 +818,10 @@
// member scopes are already created
// request the construction of a binding if local member type
+ if (binding != null && binding instanceof LocalTypeBinding) {
+ // remember local types binding for innerclass emulation propagation
+ upperScope.referenceCompilationUnit().record((LocalTypeBinding)binding);
+ }
resolve();
updateMaxFieldCount();
}
@@ -1041,6 +933,7 @@
methods[i].traverse(visitor, scope);
}
}
+ visitor.endVisit(this, unitScope);
} catch (AbortType e) {
}
}
@@ -1066,4 +959,4 @@
maxFieldCount = outerMostType.maxFieldCount; // down
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
index cf799a6..8916982 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java
@@ -1,25 +1,31 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
+import org.eclipse.jdt.internal.compiler.flow.FlowContext;
+import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.lookup.*;
public abstract class TypeReference extends Expression {
- public TypeBinding binding;
+
public TypeReference() {
super () ;
}
-// allows us to trap completion & selection nodes
+public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
+ return flowInfo;
+}
+
+// allows us to trap completion & selection nodes
public void aboutToResolve(Scope scope) {}
/*
* Answer a base type reference (can be an array of base type).
@@ -84,19 +90,19 @@
public TypeBinding resolveType(BlockScope scope) {
// handle the error here
constant = NotAConstant;
- if (binding != null) { // is a shared type reference which was already resolved
- if (!binding.isValidBinding())
+ if (this.resolvedType != null) { // is a shared type reference which was already resolved
+ if (!this.resolvedType.isValidBinding())
return null; // already reported error
} else {
- binding = getTypeBinding(scope);
- if (!binding.isValidBinding()) {
- scope.problemReporter().invalidType(this, binding);
+ this.resolvedType = getTypeBinding(scope);
+ if (!this.resolvedType.isValidBinding()) {
+ scope.problemReporter().invalidType(this, this.resolvedType);
return null;
}
- if (isTypeUseDeprecated(binding, scope))
- scope.problemReporter().deprecatedType(binding, this);
+ if (isTypeUseDeprecated(this.resolvedType, scope))
+ scope.problemReporter().deprecatedType(this.resolvedType, this);
}
- return binding;
+ return this.resolvedType;
}
public abstract void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope classScope);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
index 408a832..ade8fd3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/UnaryExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -30,17 +30,21 @@
BlockScope currentScope,
FlowContext flowContext,
FlowInfo flowInfo) {
+
if (((bits & OperatorMASK) >> OperatorSHIFT) == NOT) {
- return expression
+ return this.expression
.analyseCode(currentScope, flowContext, flowInfo)
.asNegatedCondition();
} else {
- return expression.analyseCode(currentScope, flowContext, flowInfo);
+ return this.expression.analyseCode(currentScope, flowContext, flowInfo);
}
}
- public Constant conditionalConstant() {
- return optimizedBooleanConstant == null ? constant : optimizedBooleanConstant;
+ public Constant optimizedBooleanConstant() {
+
+ return this.optimizedBooleanConstant == null
+ ? this.constant
+ : this.optimizedBooleanConstant;
}
/**
@@ -54,23 +58,24 @@
BlockScope currentScope,
CodeStream codeStream,
boolean valueRequired) {
+
int pc = codeStream.position;
Label falseLabel, endifLabel;
- if (constant != Constant.NotAConstant) {
+ if (this.constant != Constant.NotAConstant) {
// inlined value
if (valueRequired) {
- codeStream.generateConstant(constant, implicitConversion);
+ codeStream.generateConstant(this.constant, this.implicitConversion);
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
return;
}
switch ((bits & OperatorMASK) >> OperatorSHIFT) {
case NOT :
- switch (expression.implicitConversion >> 4) /* runtime type */ {
+ switch (this.expression.implicitConversion >> 4) /* runtime type */ {
case T_boolean :
// ! <boolean>
// Generate code for the condition
- expression.generateOptimizedBoolean(
+ this.expression.generateOptimizedBoolean(
currentScope,
codeStream,
null,
@@ -92,18 +97,18 @@
}
break;
case TWIDDLE :
- switch (expression.implicitConversion >> 4 /* runtime */
+ switch (this.expression.implicitConversion >> 4 /* runtime */
) {
case T_int :
// ~int
- expression.generateCode(currentScope, codeStream, valueRequired);
+ this.expression.generateCode(currentScope, codeStream, valueRequired);
if (valueRequired) {
codeStream.iconst_m1();
codeStream.ixor();
}
break;
case T_long :
- expression.generateCode(currentScope, codeStream, valueRequired);
+ this.expression.generateCode(currentScope, codeStream, valueRequired);
if (valueRequired) {
codeStream.ldc2_w(-1L);
codeStream.lxor();
@@ -112,28 +117,26 @@
break;
case MINUS :
// - <num>
- if (constant != NotAConstant) {
+ if (this.constant != NotAConstant) {
if (valueRequired) {
- switch (expression.implicitConversion >> 4 /* runtime */
- ) {
+ switch (this.expression.implicitConversion >> 4){ /* runtime */
case T_int :
- codeStream.generateInlinedValue(constant.intValue() * -1);
+ codeStream.generateInlinedValue(this.constant.intValue() * -1);
break;
case T_float :
- codeStream.generateInlinedValue(constant.floatValue() * -1.0f);
+ codeStream.generateInlinedValue(this.constant.floatValue() * -1.0f);
break;
case T_long :
- codeStream.generateInlinedValue(constant.longValue() * -1L);
+ codeStream.generateInlinedValue(this.constant.longValue() * -1L);
break;
case T_double :
- codeStream.generateInlinedValue(constant.doubleValue() * -1.0);
+ codeStream.generateInlinedValue(this.constant.doubleValue() * -1.0);
}
}
} else {
- expression.generateCode(currentScope, codeStream, valueRequired);
+ this.expression.generateCode(currentScope, codeStream, valueRequired);
if (valueRequired) {
- switch (expression.implicitConversion >> 4 /* runtime type */
- ) {
+ switch (expression.implicitConversion >> 4){ /* runtime type */
case T_int :
codeStream.ineg();
break;
@@ -150,10 +153,10 @@
}
break;
case PLUS :
- expression.generateCode(currentScope, codeStream, valueRequired);
+ this.expression.generateCode(currentScope, codeStream, valueRequired);
}
if (valueRequired) {
- codeStream.generateImplicitConversion(implicitConversion);
+ codeStream.generateImplicitConversion(this.implicitConversion);
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
@@ -169,7 +172,7 @@
Label falseLabel,
boolean valueRequired) {
- if ((constant != Constant.NotAConstant) && (constant.typeID() == T_boolean)) {
+ if ((this.constant != Constant.NotAConstant) && (this.constant.typeID() == T_boolean)) {
super.generateOptimizedBoolean(
currentScope,
codeStream,
@@ -178,8 +181,8 @@
valueRequired);
return;
}
- if (((bits & OperatorMASK) >> OperatorSHIFT) == NOT) {
- expression.generateOptimizedBoolean(
+ if (((this.bits & OperatorMASK) >> OperatorSHIFT) == NOT) {
+ this.expression.generateOptimizedBoolean(
currentScope,
codeStream,
falseLabel,
@@ -196,15 +199,16 @@
}
public TypeBinding resolveType(BlockScope scope) {
- TypeBinding expressionTb = expression.resolveType(scope);
- if (expressionTb == null) {
- constant = NotAConstant;
+
+ TypeBinding expressionType = this.expression.resolveType(scope);
+ if (expressionType == null) {
+ this.constant = NotAConstant;
return null;
}
- int expressionId = expressionTb.id;
+ int expressionId = expressionType.id;
if (expressionId > 15) {
- constant = NotAConstant;
- scope.problemReporter().invalidOperator(this, expressionTb);
+ this.constant = NotAConstant;
+ scope.problemReporter().invalidOperator(this, expressionType);
return null;
}
@@ -225,64 +229,66 @@
// 0000 0000 0000 0000 0000
// <<16 <<12 <<8 <<4 <<0
int result = ResolveTypeTables[tableId][(expressionId << 4) + expressionId];
- expression.implicitConversion = result >>> 12;
- bits |= result & 0xF;
+ this.expression.implicitConversion = result >>> 12;
+ this.bits |= result & 0xF;
switch (result & 0xF) { // only switch on possible result type.....
case T_boolean :
- this.typeBinding = BooleanBinding;
+ this.resolvedType = BooleanBinding;
break;
case T_byte :
- this.typeBinding = ByteBinding;
+ this.resolvedType = ByteBinding;
break;
case T_char :
- this.typeBinding = CharBinding;
+ this.resolvedType = CharBinding;
break;
case T_double :
- this.typeBinding = DoubleBinding;
+ this.resolvedType = DoubleBinding;
break;
case T_float :
- this.typeBinding = FloatBinding;
+ this.resolvedType = FloatBinding;
break;
case T_int :
- this.typeBinding = IntBinding;
+ this.resolvedType = IntBinding;
break;
case T_long :
- this.typeBinding = LongBinding;
+ this.resolvedType = LongBinding;
break;
default : //error........
- constant = Constant.NotAConstant;
+ this.constant = Constant.NotAConstant;
if (expressionId != T_undefined)
- scope.problemReporter().invalidOperator(this, expressionTb);
+ scope.problemReporter().invalidOperator(this, expressionType);
return null;
}
// compute the constant when valid
- if (expression.constant != Constant.NotAConstant) {
- constant =
+ if (this.expression.constant != Constant.NotAConstant) {
+ this.constant =
Constant.computeConstantOperation(
- expression.constant,
+ this.expression.constant,
expressionId,
(bits & OperatorMASK) >> OperatorSHIFT);
} else {
- constant = Constant.NotAConstant;
+ this.constant = Constant.NotAConstant;
if (((bits & OperatorMASK) >> OperatorSHIFT) == NOT) {
- Constant cst = expression.conditionalConstant();
- if (cst.typeID() == T_boolean)
- optimizedBooleanConstant = Constant.fromValue(!cst.booleanValue());
+ Constant cst = expression.optimizedBooleanConstant();
+ if (cst != Constant.NotAConstant)
+ this.optimizedBooleanConstant = Constant.fromValue(!cst.booleanValue());
}
}
- return this.typeBinding;
+ return this.resolvedType;
}
public String toStringExpressionNoParenthesis() {
- return operatorToString() + " " + expression.toStringExpression(); //$NON-NLS-1$
+
+ return operatorToString() + " " + this.expression.toStringExpression(); //$NON-NLS-1$
}
public void traverse(
IAbstractSyntaxTreeVisitor visitor,
BlockScope blockScope) {
+
if (visitor.visit(this, blockScope)) {
- expression.traverse(visitor, blockScope);
+ this.expression.traverse(visitor, blockScope);
}
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
index cf43117..4ab98e7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -39,26 +39,38 @@
FlowInfo flowInfo) {
breakLabel = new Label();
- continueLabel = new Label();
+ continueLabel = new Label();
+ Constant cst = this.condition.constant;
+ boolean isConditionTrue = cst != NotAConstant && cst.booleanValue() == true;
+ boolean isConditionFalse = cst != NotAConstant && cst.booleanValue() == false;
+
+ cst = this.condition.optimizedBooleanConstant();
+ boolean isConditionOptimizedTrue = cst != NotAConstant && cst.booleanValue() == true;
+ boolean isConditionOptimizedFalse = cst != NotAConstant && cst.booleanValue() == false;
+
preCondInitStateIndex =
currentScope.methodScope().recordInitializationStates(flowInfo);
LoopingFlowContext condLoopContext;
FlowInfo postCondInfo =
- condition.analyseCode(
+ this.condition.analyseCode(
currentScope,
(condLoopContext =
new LoopingFlowContext(flowContext, this, null, null, currentScope)),
flowInfo);
LoopingFlowContext loopingContext;
- if ((action == null) || action.isEmptyBlock()) {
+ FlowInfo actionInfo;
+ if (action == null
+ || (action.isEmptyBlock() && currentScope.environment().options.complianceLevel <= CompilerOptions.JDK1_3)) {
condLoopContext.complainOnFinalAssignmentsInLoop(currentScope, postCondInfo);
- if ((condition.constant != NotAConstant)
- && (condition.constant.booleanValue() == true)) {
- return FlowInfo.DeadEnd;
+ if (isConditionTrue) {
+ return FlowInfo.DEAD_END;
} else {
FlowInfo mergedInfo = postCondInfo.initsWhenFalse().unconditionalInits();
+ if (isConditionOptimizedTrue){
+ mergedInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(mergedInfo);
return mergedInfo;
@@ -73,27 +85,29 @@
breakLabel,
continueLabel,
currentScope);
- FlowInfo actionInfo =
- ((condition.constant != Constant.NotAConstant)
- && (condition.constant.booleanValue() == false))
- ? FlowInfo.DeadEnd
- : postCondInfo.initsWhenTrue().copy();
+ if (isConditionFalse) {
+ actionInfo = FlowInfo.DEAD_END;
+ } else {
+ actionInfo = postCondInfo.initsWhenTrue().copy();
+ if (isConditionOptimizedFalse){
+ actionInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
+ }
// for computing local var attributes
condIfTrueInitStateIndex =
currentScope.methodScope().recordInitializationStates(
postCondInfo.initsWhenTrue());
- if (!actionInfo.complainIfUnreachable(action, currentScope)) {
+ if (!actionInfo.complainIfUnreachable(action, currentScope, false)) {
actionInfo = action.analyseCode(currentScope, loopingContext, actionInfo);
}
// code generation can be optimized when no need to continue in the loop
- if (((actionInfo == FlowInfo.DeadEnd) || actionInfo.isFakeReachable())
- && ((loopingContext.initsOnContinue == FlowInfo.DeadEnd)
- || loopingContext.initsOnContinue.isFakeReachable())) {
+ if (!actionInfo.isReachable() && !loopingContext.initsOnContinue.isReachable()) {
continueLabel = null;
} else {
+ // TODO: (philippe) should simplify in one Loop context
condLoopContext.complainOnFinalAssignmentsInLoop(currentScope, postCondInfo);
loopingContext.complainOnFinalAssignmentsInLoop(currentScope, actionInfo);
}
@@ -101,8 +115,7 @@
// infinite loop
FlowInfo mergedInfo;
- if ((condition.constant != Constant.NotAConstant)
- && (condition.constant.booleanValue() == true)) {
+ if (isConditionOptimizedTrue) {
mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(
mergedInfo = loopingContext.initsOnBreak);
@@ -113,6 +126,9 @@
mergedInfo =
postCondInfo.initsWhenFalse().unconditionalInits().mergedWith(
loopingContext.initsOnBreak);
+ if (isConditionOptimizedTrue && continueLabel == null){
+ mergedInfo.setReachMode(FlowInfo.UNREACHABLE);
+ }
mergedInitStateIndex =
currentScope.methodScope().recordInitializationStates(mergedInfo);
return mergedInfo;
@@ -196,9 +212,12 @@
}
public void resetStateForCodeGeneration() {
-
- this.breakLabel.resetStateForCodeGeneration();
- this.continueLabel.resetStateForCodeGeneration();
+ if (this.breakLabel != null) {
+ this.breakLabel.resetStateForCodeGeneration();
+ }
+ if (this.continueLabel != null) {
+ this.continueLabel.resetStateForCodeGeneration();
+ }
}
public void resolve(BlockScope scope) {
@@ -233,4 +252,4 @@
}
visitor.endVisit(this, blockScope);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
index cbac1f3..0052909 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.classfmt;
import org.eclipse.jdt.internal.compiler.env.*;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
index f6b6c22..5116df9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
@@ -1,24 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.classfmt;
-import org.eclipse.jdt.internal.compiler.codegen.*;
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.codegen.AttributeNamesConstants;
import org.eclipse.jdt.internal.compiler.env.*;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.impl.NullConstant;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.util.*;
-
-import java.io.*;
-import java.util.Arrays;
+import org.eclipse.jdt.internal.compiler.util.Util;
public class ClassFileReader extends ClassFileStruct implements AttributeNamesConstants, IBinaryType {
private int constantPoolCount;
@@ -373,7 +374,11 @@
*/
public int getModifiers() {
if (this.innerInfo != null) {
- return this.innerInfo.getModifiers();
+ if ((this.accessFlags & AccDeprecated) != 0) {
+ return this.innerInfo.getModifiers() | AccDeprecated;
+ } else {
+ return this.innerInfo.getModifiers();
+ }
}
return this.accessFlags;
}
@@ -709,8 +714,6 @@
return currentConstant.booleanValue() != otherConstant.booleanValue();
case TypeIds.T_String :
return !currentConstant.stringValue().equals(otherConstant.stringValue());
- case TypeIds.T_null :
- return otherConstant != NullConstant.Default;
}
}
return false;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java
index 9f1ef51..329e6ff 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileStruct.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.classfmt;
abstract public class ClassFileStruct implements ClassFileConstants {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFormatException.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFormatException.java
index b0bb51e..ad63ee5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFormatException.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFormatException.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.classfmt;
public class ClassFormatException extends Exception {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java
index d04dd07..af19cbd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/FieldInfo.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.classfmt;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.codegen.AttributeNamesConstants;
import org.eclipse.jdt.internal.compiler.env.IBinaryField;
import org.eclipse.jdt.internal.compiler.impl.BooleanConstant;
@@ -23,7 +24,6 @@
import org.eclipse.jdt.internal.compiler.impl.ShortConstant;
import org.eclipse.jdt.internal.compiler.impl.StringConstant;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class FieldInfo extends ClassFileStruct implements AttributeNamesConstants, IBinaryField, Comparable, TypeIds {
private Constant constant;
@@ -33,7 +33,6 @@
private int accessFlags;
private char[] name;
private char[] signature;
- private int attributesCount;
private int attributeBytes;
private Object wrappedConstantValue;
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java
index 23f807a..d1245c9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/InnerClassInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.classfmt;
import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
index 60e0fa9..f04bc9f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
@@ -1,18 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.classfmt;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.codegen.AttributeNamesConstants;
import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class MethodInfo extends ClassFileStruct implements IBinaryMethod, AttributeNamesConstants, Comparable {
private char[][] exceptionNames;
@@ -22,10 +22,8 @@
private int accessFlags;
private char[] name;
private char[] signature;
- private int attributesCount;
private int attributeBytes;
- static private final char[][] noException = new char[0][0];
- private int decodeIndex;
+ static private final char[][] noException = CharOperation.NO_CHAR_CHAR;
/**
* @param classFileBytes byte[]
* @param offsets int[]
@@ -235,4 +233,4 @@
this.constantPoolOffsets = null;
super.reset();
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java
index 7b6db1f..8bda895 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
public interface AttributeNamesConstants {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CaseLabel.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CaseLabel.java
index be7b92b..69a0d51 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CaseLabel.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CaseLabel.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
public class CaseLabel extends Label {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CharArrayCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CharArrayCache.java
index 77e9acd..77fdd1f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CharArrayCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CharArrayCache.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
public class CharArrayCache {
// to avoid using Enumerations, walk the individual tables skipping nulls
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
index f6dc3f0..159c518 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
import org.eclipse.jdt.internal.compiler.*;
@@ -1484,14 +1484,8 @@
case T_double :
generateInlinedValue(constant.doubleValue());
break;
- case T_String :
- this.ldc(constant.stringValue());
- break;
- default : //reference object (constant can be from T_null or T_String)
- if (constant.typeID() == T_String)
- ldc(constant.stringValue());
- else
- aconst_null();
+ default : //String or Object
+ ldc(constant.stringValue());
}
}
/**
@@ -1773,21 +1767,28 @@
else
this.iconst_0();
}
-public void generateOuterAccess(Object[] mappingSequence, AstNode invocationSite, Scope scope) {
- if (mappingSequence == null)
- return;
- if (mappingSequence == BlockScope.EmulationPathToImplicitThis) {
- if (scope.methodScope().isConstructorCall){
- scope.problemReporter().errorThisSuperInStatic(invocationSite);
+public void generateOuterAccess(Object[] mappingSequence, AstNode invocationSite, Binding target, Scope scope) {
+ if (mappingSequence == null) {
+ if (target instanceof LocalVariableBinding) {
+ scope.problemReporter().needImplementation(); //TODO: (philippe) should improve local emulation failure reporting
+ } else {
+ scope.problemReporter().noSuchEnclosingInstance((ReferenceBinding)target, invocationSite, false);
}
- this.aload_0();
return;
}
- if (mappingSequence[0] instanceof FieldBinding) {
+ if (mappingSequence == BlockScope.NoEnclosingInstanceInConstructorCall) {
+ scope.problemReporter().noSuchEnclosingInstance((ReferenceBinding)target, invocationSite, true);
+ return;
+ } else if (mappingSequence == BlockScope.NoEnclosingInstanceInStaticContext) {
+ scope.problemReporter().noSuchEnclosingInstance((ReferenceBinding)target, invocationSite, false);
+ return;
+ }
+
+ if (mappingSequence == BlockScope.EmulationPathToImplicitThis) {
+ this.aload_0();
+ return;
+ } else if (mappingSequence[0] instanceof FieldBinding) {
FieldBinding fieldBinding = (FieldBinding) mappingSequence[0];
- if (scope.methodScope().isConstructorCall){
- scope.problemReporter().errorThisSuperInStatic(invocationSite);
- }
this.aload_0();
this.getfield(fieldBinding);
} else {
@@ -1802,6 +1803,7 @@
}
}
}
+
/**
* The equivalent code performs a string conversion:
*
@@ -1832,72 +1834,70 @@
this.invokeStringBufferToString();
}
/**
- * Code responsible to generate the suitable code to supply values for the synthetic arguments of
- * a constructor invocation of a nested type.
+ * Code responsible to generate the suitable code to supply values for the synthetic enclosing
+ * instance arguments of a constructor invocation of a nested type.
*/
-public void generateSyntheticArgumentValues(BlockScope currentScope, ReferenceBinding targetType, Expression enclosingInstance, AstNode invocationSite) {
+public void generateSyntheticEnclosingInstanceValues(BlockScope currentScope, ReferenceBinding targetType, Expression enclosingInstance, AstNode invocationSite) {
+
+ // supplying enclosing instance for the anonymous type's superclass
+ ReferenceBinding checkedTargetType = targetType.isAnonymousType() ? targetType.superclass() : targetType;
+ boolean hasExtraEnclosingInstance = enclosingInstance != null;
+ if (hasExtraEnclosingInstance
+ && (!checkedTargetType.isNestedType() || checkedTargetType.isStatic())) {
+ currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, checkedTargetType);
+ return;
+ }
// perform some emulation work in case there is some and we are inside a local type only
ReferenceBinding[] syntheticArgumentTypes;
-
- // generate the enclosing instance first
if ((syntheticArgumentTypes = targetType.syntheticEnclosingInstanceTypes()) != null) {
- ReferenceBinding targetEnclosingType = targetType.isAnonymousType() ?
- targetType.superclass().enclosingType() // supplying enclosing instance for the anonymous type's superclass
- : targetType.enclosingType();
-
+ ReferenceBinding targetEnclosingType = checkedTargetType.enclosingType();
+ boolean needEnclosingInstanceNullCheck = currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4;
+
for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) {
ReferenceBinding syntheticArgType = syntheticArgumentTypes[i];
- if (enclosingInstance != null && i == 0) {
- if (syntheticArgType != targetEnclosingType) {
- currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, targetType);
- }
- //if (currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4){
+ if (hasExtraEnclosingInstance && syntheticArgType == targetEnclosingType) {
+ hasExtraEnclosingInstance = false;
enclosingInstance.generateCode(currentScope, this, true);
- if (syntheticArgType == targetEnclosingType){
- this.dup();
- }
- this.invokeObjectGetClass(); // causes null check for all explicit enclosing instances
- this.pop();
- //} else {
- // enclosingInstance.generateCode(currentScope, this, syntheticArgType == targetEnclosingType);
- //}
- } else {
- Object[] emulationPath = currentScope.getCompatibleEmulationPath(syntheticArgType);
- if (emulationPath == null) {
- currentScope.problemReporter().missingEnclosingInstanceSpecification(syntheticArgType, invocationSite);
- } else {
- this.generateOuterAccess(emulationPath, invocationSite, currentScope);
+ if (needEnclosingInstanceNullCheck){
+ dup();
+ invokeObjectGetClass(); // will perform null check
+ pop();
}
+
+ } else {
+ Object[] emulationPath = currentScope.getEmulationPath(
+ syntheticArgType,
+ false /*not only exact match (i.e. allow compatible)*/,
+ targetType.isAnonymousType());
+ this.generateOuterAccess(emulationPath, invocationSite, syntheticArgType, currentScope);
}
}
- } else { // we may still have an enclosing instance to consider
- if (enclosingInstance != null) {
- currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, targetType);
- //if (currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4){
- enclosingInstance.generateCode(currentScope, this, true);
- this.invokeObjectGetClass(); // causes null check for all explicit enclosing instances
- this.pop();
- //} else {
- // enclosingInstance.generateCode(currentScope, this, false); // do not want the value
- //}
+ if (hasExtraEnclosingInstance){
+ currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, checkedTargetType);
}
}
+}
+
+/**
+ * Code responsible to generate the suitable code to supply values for the synthetic outer local
+ * variable arguments of a constructor invocation of a nested type.
+ * (bug 26122) - synthetic values for outer locals must be passed after user arguments, e.g. new X(i = 1){}
+ */
+public void generateSyntheticOuterArgumentValues(BlockScope currentScope, ReferenceBinding targetType, AstNode invocationSite) {
+
// generate the synthetic outer arguments then
SyntheticArgumentBinding syntheticArguments[];
if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) {
for (int i = 0, max = syntheticArguments.length; i < max; i++) {
- VariableBinding[] emulationPath = currentScope.getEmulationPath(syntheticArguments[i].actualOuterLocalVariable);
- if (emulationPath == null) {
- // could not emulate a path to a given outer local variable (internal error)
- currentScope.problemReporter().needImplementation();
- } else {
- this.generateOuterAccess(emulationPath, invocationSite, currentScope);
- }
+ LocalVariableBinding targetVariable = syntheticArguments[i].actualOuterLocalVariable;
+ VariableBinding[] emulationPath = currentScope.getEmulationPath(targetVariable);
+ this.generateOuterAccess(emulationPath, invocationSite, targetVariable, currentScope);
}
}
}
+
/**
* @param parameters org.eclipse.jdt.internal.compiler.lookup.TypeBinding[]
* @param constructorBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding
@@ -1922,7 +1922,18 @@
else
resolvedPosition++;
}
- syntheticArguments = nestedType.syntheticOuterLocalVariables();
+ }
+ for (int i = 0; i < length; i++) {
+ load(parameters[i], resolvedPosition);
+ if ((parameters[i] == DoubleBinding) || (parameters[i] == LongBinding))
+ resolvedPosition += 2;
+ else
+ resolvedPosition++;
+ }
+
+ if (constructorBinding.declaringClass.isNestedType()) {
+ NestedTypeBinding nestedType = (NestedTypeBinding) constructorBinding.declaringClass;
+ SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables();
for (int i = 0; i < (syntheticArguments == null ? 0 : syntheticArguments.length); i++) {
TypeBinding type;
load((type = syntheticArguments[i].type), resolvedPosition);
@@ -1932,13 +1943,6 @@
resolvedPosition++;
}
}
- for (int i = 0; i < length; i++) {
- load(parameters[i], resolvedPosition);
- if ((parameters[i] == DoubleBinding) || (parameters[i] == LongBinding))
- resolvedPosition += 2;
- else
- resolvedPosition++;
- }
this.invokespecial(constructorBinding);
this.return_();
}
@@ -2009,7 +2013,7 @@
if (methodBinding.isConstructor()
|| methodBinding.isPrivate()
// qualified super "X.super.foo()" targets methods from superclass
- || (methodBinding.declaringClass != methodDeclaration.binding.declaringClass)){
+ || accessBinding.accessType == SyntheticAccessMethodBinding.SuperMethodAccess){
this.invokespecial(methodBinding);
} else {
if (methodBinding.declaringClass.isInterface()){
@@ -3014,8 +3018,12 @@
writeUnsignedByte(argCount);
// Generate a 0 into the byte array. Like the array is already fill with 0, we just need to increment
// the number of bytes.
- position++;
- classFileOffset++;
+ try {
+ position++;
+ bCodeStream[classFileOffset++] = 0;
+ } catch (IndexOutOfBoundsException e) {
+ resizeByteArray((byte)0);
+ }
if (((id = methodBinding.returnType.id) == T_double) || (id == T_long))
stackDepth += (2 - argCount);
else
@@ -3504,6 +3512,10 @@
}
}
final public void jsr(Label lbl) {
+ if (this.wideMode) {
+ this.jsr_w(lbl);
+ return;
+ }
countLabels = 0;
try {
position++;
@@ -4018,6 +4030,9 @@
case 3 :
this.iload_3();
break;
+ //case -1 :
+ // internal failure: trying to load variable not supposed to be generated
+ // break;
default :
this.iload(resolvedPosition);
}
@@ -4296,8 +4311,12 @@
resizeByteArray(OPC_lookupswitch);
}
for (int i = (3 - (pos % 4)); i > 0; i--) {
- position++; // Padding
- classFileOffset++;
+ try {
+ position++;
+ bCodeStream[classFileOffset++] = 0;
+ } catch (IndexOutOfBoundsException e) {
+ resizeByteArray((byte)0);
+ }
}
defaultLabel.branch();
writeSignedWord(length);
@@ -4808,12 +4827,19 @@
if (insertionIndex != -1) {
// widen the existing entry
// we have to figure out if we need to move the last entry at another location to keep a sorted table
- if ((pcToSourceMapSize > 4) && (pcToSourceMap[pcToSourceMapSize - 4] > startPC)) {
- System.arraycopy(pcToSourceMap, insertionIndex, pcToSourceMap, insertionIndex + 2, pcToSourceMapSize - 2 - insertionIndex);
- pcToSourceMap[insertionIndex++] = startPC;
- pcToSourceMap[insertionIndex] = newLine;
- } else {
- pcToSourceMap[pcToSourceMapSize - 2] = startPC;
+ /* First we need to check if at the insertion position there is not an existing entry
+ * that includes the one we want to insert. This is the case if pcToSourceMap[insertionIndex - 1] == newLine.
+ * In this case we don't want to change the table. If not, we want to insert a new entry. Prior to insertion
+ * we want to check if it is worth doing an arraycopy. If not we simply update the recorded pc.
+ */
+ if (!((insertionIndex > 1) && (pcToSourceMap[insertionIndex - 1] == newLine))) {
+ if ((pcToSourceMapSize > 4) && (pcToSourceMap[pcToSourceMapSize - 4] > startPC)) {
+ System.arraycopy(pcToSourceMap, insertionIndex, pcToSourceMap, insertionIndex + 2, pcToSourceMapSize - 2 - insertionIndex);
+ pcToSourceMap[insertionIndex++] = startPC;
+ pcToSourceMap[insertionIndex] = newLine;
+ } else {
+ pcToSourceMap[pcToSourceMapSize - 2] = startPC;
+ }
}
}
}
@@ -5134,115 +5160,118 @@
sort(tab, lo, hi0, result);
}
}
+
public final void store(LocalVariableBinding localBinding, boolean valueRequired) {
- TypeBinding type = localBinding.type;
int position = localBinding.resolvedPosition;
// Using dedicated int bytecode
- if ((type == IntBinding) || (type == CharBinding) || (type == ByteBinding) || (type == ShortBinding) || (type == BooleanBinding)) {
- if (valueRequired)
- this.dup();
- switch (position) {
- case 0 :
- this.istore_0();
- break;
- case 1 :
- this.istore_1();
- break;
- case 2 :
- this.istore_2();
- break;
- case 3 :
- this.istore_3();
- break;
- default :
- this.istore(position);
- }
- return;
- }
- // Using dedicated float bytecode
- if (type == FloatBinding) {
- if (valueRequired)
- this.dup();
- switch (position) {
- case 0 :
- this.fstore_0();
- break;
- case 1 :
- this.fstore_1();
- break;
- case 2 :
- this.fstore_2();
- break;
- case 3 :
- this.fstore_3();
- break;
- default :
- this.fstore(position);
- }
- return;
- }
- // Using dedicated long bytecode
- if (type == LongBinding) {
- if (valueRequired)
- this.dup2();
- switch (position) {
- case 0 :
- this.lstore_0();
- break;
- case 1 :
- this.lstore_1();
- break;
- case 2 :
- this.lstore_2();
- break;
- case 3 :
- this.lstore_3();
- break;
- default :
- this.lstore(position);
- }
- return;
- }
- // Using dedicated double bytecode
- if (type == DoubleBinding) {
- if (valueRequired)
- this.dup2();
- switch (position) {
- case 0 :
- this.dstore_0();
- break;
- case 1 :
- this.dstore_1();
- break;
- case 2 :
- this.dstore_2();
- break;
- case 3 :
- this.dstore_3();
- break;
- default :
- this.dstore(position);
- }
- return;
- }
- // Reference object
- if (valueRequired)
- this.dup();
- switch (position) {
- case 0 :
- this.astore_0();
+ switch(localBinding.type.id) {
+ case TypeIds.T_int :
+ case TypeIds.T_char :
+ case TypeIds.T_byte :
+ case TypeIds.T_short :
+ case TypeIds.T_boolean :
+ if (valueRequired)
+ this.dup();
+ switch (position) {
+ case 0 :
+ this.istore_0();
+ break;
+ case 1 :
+ this.istore_1();
+ break;
+ case 2 :
+ this.istore_2();
+ break;
+ case 3 :
+ this.istore_3();
+ break;
+ //case -1 :
+ // internal failure: trying to store into variable not supposed to be generated
+ // break;
+ default :
+ this.istore(position);
+ }
break;
- case 1 :
- this.astore_1();
+ case TypeIds.T_float :
+ if (valueRequired)
+ this.dup();
+ switch (position) {
+ case 0 :
+ this.fstore_0();
+ break;
+ case 1 :
+ this.fstore_1();
+ break;
+ case 2 :
+ this.fstore_2();
+ break;
+ case 3 :
+ this.fstore_3();
+ break;
+ default :
+ this.fstore(position);
+ }
break;
- case 2 :
- this.astore_2();
+ case TypeIds.T_double :
+ if (valueRequired)
+ this.dup2();
+ switch (position) {
+ case 0 :
+ this.dstore_0();
+ break;
+ case 1 :
+ this.dstore_1();
+ break;
+ case 2 :
+ this.dstore_2();
+ break;
+ case 3 :
+ this.dstore_3();
+ break;
+ default :
+ this.dstore(position);
+ }
break;
- case 3 :
- this.astore_3();
+ case TypeIds.T_long :
+ if (valueRequired)
+ this.dup2();
+ switch (position) {
+ case 0 :
+ this.lstore_0();
+ break;
+ case 1 :
+ this.lstore_1();
+ break;
+ case 2 :
+ this.lstore_2();
+ break;
+ case 3 :
+ this.lstore_3();
+ break;
+ default :
+ this.lstore(position);
+ }
break;
- default :
- this.astore(position);
+ default:
+ // Reference object
+ if (valueRequired)
+ this.dup();
+ switch (position) {
+ case 0 :
+ this.astore_0();
+ break;
+ case 1 :
+ this.astore_1();
+ break;
+ case 2 :
+ this.astore_2();
+ break;
+ case 3 :
+ this.astore_3();
+ break;
+ default :
+ this.astore(position);
+ }
}
}
public final void store(TypeBinding type, int position) {
@@ -5413,8 +5442,12 @@
resizeByteArray(OPC_tableswitch);
}
for (int i = (3 - (pos % 4)); i > 0; i--) {
- position++; // Padding
- classFileOffset++;
+ try {
+ position++;
+ bCodeStream[classFileOffset++] = 0;
+ } catch (IndexOutOfBoundsException e) {
+ resizeByteArray((byte)0);
+ }
}
defaultLabel.branch();
writeSignedWord(low);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java
index f23b361..d1d30fc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ConstantPool.java
@@ -1,20 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.util.*;
/**
* This type is used to store all the constant pool entries.
@@ -701,7 +701,7 @@
}
if (length >= 65535) {
currentOffset = savedCurrentOffset - 1;
- return -1;
+ this.classFile.referenceBinding.scope.problemReporter().noMoreAvailableSpaceForConstant(this.classFile.referenceBinding.scope.referenceType());
}
index = UTF8Cache.put(utf8Constant, currentIndex);
if (index > 0xFFFF){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/DoubleCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/DoubleCache.java
index bd7c5bf..467358c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/DoubleCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/DoubleCache.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
public class DoubleCache {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ExceptionLabel.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ExceptionLabel.java
index 33c844e..b120831 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ExceptionLabel.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ExceptionLabel.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FieldNameAndTypeCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FieldNameAndTypeCache.java
index 9037c24..1e06933 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FieldNameAndTypeCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FieldNameAndTypeCache.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class FieldNameAndTypeCache {
public FieldBinding keyTable[];
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FloatCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FloatCache.java
index e51f838..c83b5d1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FloatCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/FloatCache.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
public class FloatCache {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/IntegerCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/IntegerCache.java
index feafe93..51ba5e6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/IntegerCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/IntegerCache.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
public class IntegerCache {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
index 20dee8c..dff500a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Label.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
@@ -64,8 +64,15 @@
// Leave two bytes free to generate the jump afterwards
codeStream.position += 2;
codeStream.classFileOffset += 2;
- } else { //Position is set. Write it!
- codeStream.writeSignedShort((short) (position - codeStream.position + 1));
+ } else {
+ /*
+ * Position is set. Write it if it is not a wide branch.
+ */
+ int offset = position - codeStream.position + 1;
+ if (Math.abs(offset) > 0x7FFF && !this.codeStream.wideMode) {
+ throw new AbortMethod(CodeStream.RESTART_IN_WIDE_MODE);
+ }
+ codeStream.writeSignedShort((short) offset);
}
}
/*
@@ -174,7 +181,7 @@
}
for (int i = 0; i < forwardReferenceCount; i++) {
int offset = position - forwardReferences[i] + 1;
- if (offset > 0x7FFF && !this.codeStream.wideMode) {
+ if (Math.abs(offset) > 0x7FFF && !this.codeStream.wideMode) {
throw new AbortMethod(CodeStream.RESTART_IN_WIDE_MODE);
}
if (this.codeStream.wideMode) {
@@ -205,7 +212,7 @@
for (int j = 0; j < label.forwardReferenceCount; j++) {
int forwardPosition = label.forwardReferences[j];
int offset = position - forwardPosition + 1;
- if (offset > 0x7FFF && !this.codeStream.wideMode) {
+ if (Math.abs(offset) > 0x7FFF && !this.codeStream.wideMode) {
throw new AbortMethod(CodeStream.RESTART_IN_WIDE_MODE);
}
if (this.codeStream.wideMode) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/LongCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/LongCache.java
index 624446d..e32817a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/LongCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/LongCache.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
public class LongCache {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/MethodNameAndTypeCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/MethodNameAndTypeCache.java
index 21f5879..0fc65fc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/MethodNameAndTypeCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/MethodNameAndTypeCache.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class MethodNameAndTypeCache {
public MethodBinding keyTable[];
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ObjectCache.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ObjectCache.java
index 3e7fd8d..38d4318 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ObjectCache.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ObjectCache.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
public class ObjectCache {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Opcodes.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Opcodes.java
index 2c2b572..a00fe75 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Opcodes.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/Opcodes.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
public interface Opcodes {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/QualifiedNamesConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/QualifiedNamesConstants.java
index aaa0aba..304ebda 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/QualifiedNamesConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/QualifiedNamesConstants.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
public interface QualifiedNamesConstants {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ResetStateForCodeGenerationVisitor.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ResetStateForCodeGenerationVisitor.java
index 7cce4ca..66c0de4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ResetStateForCodeGenerationVisitor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/ResetStateForCodeGenerationVisitor.java
@@ -1,16 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.codegen;
import org.eclipse.jdt.internal.compiler.AbstractSyntaxTreeVisitorAdapter;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.ast.BranchStatement;
import org.eclipse.jdt.internal.compiler.ast.DoStatement;
import org.eclipse.jdt.internal.compiler.ast.ForStatement;
@@ -51,6 +52,10 @@
branchStatement.resetStateForCodeGeneration();
return true;
}
-
+
+ public boolean visit(TryStatement tryStatement, BlockScope scope) {
+ tryStatement.resetStateForCodeGeneration();
+ return true;
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryField.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryField.java
index 483173b..68cd659 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryField.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryField.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
import org.eclipse.jdt.internal.compiler.impl.Constant;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryMethod.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryMethod.java
index 2718955..22e3586 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryMethod.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryMethod.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
// clinit methods (synthetics too?) can be returned from IBinaryType>>getMethods()
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryNestedType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryNestedType.java
index a1d06da..63ed7e0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryNestedType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryNestedType.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
public interface IBinaryNestedType {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java
index 4b1bdaa..b796483 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IBinaryType.java
@@ -1,18 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
+import org.eclipse.jdt.core.compiler.CharOperation;
+
public interface IBinaryType extends IGenericType {
- char[][] NoInterface = new char[0][];
+ char[][] NoInterface = CharOperation.NO_CHAR_CHAR;
IBinaryNestedType[] NoNestedType = new IBinaryNestedType[0];
IBinaryField[] NoField = new IBinaryField[0];
IBinaryMethod[] NoMethod = new IBinaryMethod[0];
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ICompilationUnit.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ICompilationUnit.java
index d4a3b1c..70006b0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ICompilationUnit.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ICompilationUnit.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IConstants.java
index 501c4d1..7eb36a4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IConstants.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IDependent.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IDependent.java
index ea771b1..b456c83 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IDependent.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IDependent.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericField.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericField.java
index 4fec9e0..9b365bf 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericField.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericField.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
public interface IGenericField {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericMethod.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericMethod.java
index 8f277a7..b9d5cbc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericMethod.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericMethod.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
public interface IGenericMethod {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericType.java
index 4d03a31..81eca2f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/IGenericType.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
public interface IGenericType extends IDependent {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironment.java
index 2cc1cde..663914b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/INameEnvironment.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceField.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceField.java
index 67d84b2..e70ea27 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceField.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceField.java
@@ -1,42 +1,47 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
public interface ISourceField extends IGenericField {
/**
* Answer the source end position of the field's declaration.
*/
-
int getDeclarationSourceEnd();
+
/**
* Answer the source start position of the field's declaration.
*/
-
int getDeclarationSourceStart();
+
+/**
+ * Answer the initialization source for this constant field.
+ * Answer null if the field is not a constant or if it has no initialization.
+ */
+char[] getInitializationSource();
+
/**
* Answer the source end position of the field's name.
*/
-
int getNameSourceEnd();
+
/**
* Answer the source start position of the field's name.
*/
-
int getNameSourceStart();
+
/**
* Answer the type name of the field.
*
* The name is a simple name or a qualified, dot separated name.
* For example, Hashtable or java.util.Hashtable.
*/
-
char[] getTypeName();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceMethod.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceMethod.java
index 9b8415f..0a34e22 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceMethod.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceMethod.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
public interface ISourceMethod extends IGenericMethod {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceType.java
index 039029e..95c2e14 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceType.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
public interface ISourceType extends IGenericType {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
index f0db12c..308cdf2 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/NameEnvironmentAnswer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.env;
public class NameEnvironmentAnswer {
@@ -76,4 +76,4 @@
public boolean isSourceType() {
return sourceTypes != null;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java
index fd2988c..db85090 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.flow;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
@@ -18,110 +18,161 @@
*
*/
public class ConditionalFlowInfo extends FlowInfo {
+
public FlowInfo initsWhenTrue;
public FlowInfo initsWhenFalse;
-ConditionalFlowInfo(FlowInfo initsWhenTrue, FlowInfo initsWhenFalse){
- this.initsWhenTrue = initsWhenTrue;
- this.initsWhenFalse = initsWhenFalse;
-}
-public UnconditionalFlowInfo addInitializationsFrom(UnconditionalFlowInfo otherInits) {
- return unconditionalInits().addInitializationsFrom(otherInits);
-}
-public UnconditionalFlowInfo addPotentialInitializationsFrom(UnconditionalFlowInfo otherInits) {
- return unconditionalInits().addPotentialInitializationsFrom(otherInits);
-}
-public FlowInfo asNegatedCondition() {
- FlowInfo extra = initsWhenTrue;
- initsWhenTrue = initsWhenFalse;
- initsWhenFalse = extra;
- return this;
-}
-public FlowInfo copy() {
- return new ConditionalFlowInfo(initsWhenTrue.copy(), initsWhenFalse.copy());
-}
-public FlowInfo initsWhenFalse() {
- return initsWhenFalse;
-}
-public FlowInfo initsWhenTrue() {
- return initsWhenTrue;
-}
-/**
- * Check status of definite assignment for a field.
- */
-public boolean isDefinitelyAssigned(FieldBinding field) {
- return initsWhenTrue.isDefinitelyAssigned(field)
- && initsWhenFalse.isDefinitelyAssigned(field);
-}
-/**
- * Check status of definite assignment for a local variable.
- */
-public boolean isDefinitelyAssigned(LocalVariableBinding local) {
- return initsWhenTrue.isDefinitelyAssigned(local)
- && initsWhenFalse.isDefinitelyAssigned(local);
+ ConditionalFlowInfo(FlowInfo initsWhenTrue, FlowInfo initsWhenFalse){
+
+ this.initsWhenTrue = initsWhenTrue;
+ this.initsWhenFalse = initsWhenFalse;
+ }
-}
-public boolean isFakeReachable(){
- return unconditionalInits().isFakeReachable();
- //should maybe directly be: false
-}
-/**
- * Check status of potential assignment for a field.
- */
-public boolean isPotentiallyAssigned(FieldBinding field) {
- return initsWhenTrue.isPotentiallyAssigned(field)
- || initsWhenFalse.isPotentiallyAssigned(field);
+ public FlowInfo addInitializationsFrom(FlowInfo otherInits) {
+
+ this.initsWhenTrue.addInitializationsFrom(otherInits);
+ this.initsWhenFalse.addInitializationsFrom(otherInits);
+ return this;
+ }
-}
-/**
- * Check status of potential assignment for a local variable.
- */
-public boolean isPotentiallyAssigned(LocalVariableBinding local) {
- return initsWhenTrue.isPotentiallyAssigned(local)
- || initsWhenFalse.isPotentiallyAssigned(local);
+ public FlowInfo addPotentialInitializationsFrom(FlowInfo otherInits) {
+
+ this.initsWhenTrue.addPotentialInitializationsFrom(otherInits);
+ this.initsWhenFalse.addPotentialInitializationsFrom(otherInits);
+ return this;
+ }
-}
-/**
- * Record a field got definitely assigned.
- */
-public void markAsDefinitelyAssigned(FieldBinding field) {
- initsWhenTrue.markAsDefinitelyAssigned(field);
- initsWhenFalse.markAsDefinitelyAssigned(field);
-}
-/**
- * Record a field got definitely assigned.
- */
-public void markAsDefinitelyAssigned(LocalVariableBinding local) {
- initsWhenTrue.markAsDefinitelyAssigned(local);
- initsWhenFalse.markAsDefinitelyAssigned(local);
-}
-/**
- * Clear the initialization info for a field
- */
-public void markAsDefinitelyNotAssigned(FieldBinding field) {
- initsWhenTrue.markAsDefinitelyNotAssigned(field);
- initsWhenFalse.markAsDefinitelyNotAssigned(field);
-}
-/**
- * Clear the initialization info for a local variable
- */
-public void markAsDefinitelyNotAssigned(LocalVariableBinding local) {
- initsWhenTrue.markAsDefinitelyNotAssigned(local);
- initsWhenFalse.markAsDefinitelyNotAssigned(local);
-}
-public FlowInfo markAsFakeReachable(boolean isFakeReachable) {
- initsWhenTrue.markAsFakeReachable(isFakeReachable);
- initsWhenFalse.markAsFakeReachable(isFakeReachable);
- return this;
-}
-public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits) {
- return unconditionalInits().mergedWith(otherInits);
-}
-public String toString() {
- return "FlowInfo<true: " + initsWhenTrue.toString() + ", false: " + initsWhenFalse.toString() + ">"; //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$
-}
-public UnconditionalFlowInfo unconditionalInits() {
- return initsWhenTrue.unconditionalInits().copy()
- .mergedWith(initsWhenFalse.unconditionalInits());
-}
+ public FlowInfo asNegatedCondition() {
+
+ FlowInfo extra = initsWhenTrue;
+ initsWhenTrue = initsWhenFalse;
+ initsWhenFalse = extra;
+ return this;
+ }
+
+ public FlowInfo copy() {
+
+ return new ConditionalFlowInfo(initsWhenTrue.copy(), initsWhenFalse.copy());
+ }
+
+ public FlowInfo initsWhenFalse() {
+
+ return initsWhenFalse;
+ }
+
+ public FlowInfo initsWhenTrue() {
+
+ return initsWhenTrue;
+ }
+
+ /**
+ * Check status of definite assignment for a field.
+ */
+ public boolean isDefinitelyAssigned(FieldBinding field) {
+
+ return initsWhenTrue.isDefinitelyAssigned(field)
+ && initsWhenFalse.isDefinitelyAssigned(field);
+ }
+
+ /**
+ * Check status of definite assignment for a local variable.
+ */
+ public boolean isDefinitelyAssigned(LocalVariableBinding local) {
+
+ return initsWhenTrue.isDefinitelyAssigned(local)
+ && initsWhenFalse.isDefinitelyAssigned(local);
+ }
+
+ public int reachMode(){
+ return unconditionalInits().reachMode();
+ }
+
+ public boolean isReachable(){
+
+ return unconditionalInits().isReachable();
+ //should maybe directly be: false
+ }
+
+ /**
+ * Check status of potential assignment for a field.
+ */
+ public boolean isPotentiallyAssigned(FieldBinding field) {
+
+ return initsWhenTrue.isPotentiallyAssigned(field)
+ || initsWhenFalse.isPotentiallyAssigned(field);
+ }
+
+ /**
+ * Check status of potential assignment for a local variable.
+ */
+ public boolean isPotentiallyAssigned(LocalVariableBinding local) {
+
+ return initsWhenTrue.isPotentiallyAssigned(local)
+ || initsWhenFalse.isPotentiallyAssigned(local);
+ }
+
+ /**
+ * Record a field got definitely assigned.
+ */
+ public void markAsDefinitelyAssigned(FieldBinding field) {
+
+ initsWhenTrue.markAsDefinitelyAssigned(field);
+ initsWhenFalse.markAsDefinitelyAssigned(field);
+ }
+
+ /**
+ * Record a field got definitely assigned.
+ */
+ public void markAsDefinitelyAssigned(LocalVariableBinding local) {
+
+ initsWhenTrue.markAsDefinitelyAssigned(local);
+ initsWhenFalse.markAsDefinitelyAssigned(local);
+ }
+
+ /**
+ * Clear the initialization info for a field
+ */
+ public void markAsDefinitelyNotAssigned(FieldBinding field) {
+
+ initsWhenTrue.markAsDefinitelyNotAssigned(field);
+ initsWhenFalse.markAsDefinitelyNotAssigned(field);
+ }
+
+ /**
+ * Clear the initialization info for a local variable
+ */
+ public void markAsDefinitelyNotAssigned(LocalVariableBinding local) {
+
+ initsWhenTrue.markAsDefinitelyNotAssigned(local);
+ initsWhenFalse.markAsDefinitelyNotAssigned(local);
+ }
+
+ public FlowInfo setReachMode(int reachMode) {
+
+ initsWhenTrue.setReachMode(reachMode);
+ initsWhenFalse.setReachMode(reachMode);
+ return this;
+ }
+
+ /**
+ * Converts conditional receiver into inconditional one, updated in the following way: <ul>
+ * <li> intersection of definitely assigned variables,
+ * <li> union of potentially assigned variables.
+ * </ul>
+ */
+ public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits) {
+
+ return unconditionalInits().mergedWith(otherInits);
+ }
+
+ public String toString() {
+
+ return "FlowInfo<true: " + initsWhenTrue.toString() + ", false: " + initsWhenFalse.toString() + ">"; //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$
+ }
+
+ public UnconditionalFlowInfo unconditionalInits() {
+
+ return initsWhenTrue.unconditionalInits().copy()
+ .mergedWith(initsWhenFalse.unconditionalInits());
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java
index 0cccf9d..8e3baf0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.flow;
import java.util.ArrayList;
@@ -26,7 +26,7 @@
*/
public class ExceptionHandlingFlowContext extends FlowContext {
- ReferenceBinding[] handledExceptions;
+ public ReferenceBinding[] handledExceptions;
public final static int BitCacheSize = 32; // 32 bits per int
int[] isReached;
@@ -63,11 +63,11 @@
isReached[cacheIndex] |= bitMask;
this.initsOnExceptions[i] = flowInfo.copy().unconditionalInits();
} else {
- this.initsOnExceptions[i] = FlowInfo.DeadEnd;
+ this.initsOnExceptions[i] = FlowInfo.DEAD_END;
}
}
System.arraycopy(this.isReached, 0, this.isNeeded, 0, cacheSize);
- this.initsOnReturn = FlowInfo.DeadEnd;
+ this.initsOnReturn = FlowInfo.DEAD_END;
}
public void complainIfUnusedExceptionHandlers(
@@ -114,6 +114,7 @@
}
buffer.append('-').append(initsOnExceptions[i].toString()).append(']');
}
+ buffer.append("[initsOnReturn -").append(initsOnReturn.toString()).append(']'); //$NON-NLS-1$
return buffer.toString();
}
@@ -121,11 +122,15 @@
int index;
if ((index = indexes.get(exceptionType)) < 0) {
- return FlowInfo.DeadEnd;
+ return FlowInfo.DEAD_END;
}
return initsOnExceptions[index];
}
+ public UnconditionalFlowInfo initsOnReturn(){
+ return this.initsOnReturn;
+ }
+
public void recordHandlingException(
ReferenceBinding exceptionType,
UnconditionalFlowInfo flowInfo,
@@ -141,16 +146,21 @@
this.isNeeded[cacheIndex] |= bitMask;
}
this.isReached[cacheIndex] |= bitMask;
+
initsOnExceptions[index] =
- initsOnExceptions[index] == FlowInfo.DeadEnd
+ initsOnExceptions[index] == FlowInfo.DEAD_END
? flowInfo.copy().unconditionalInits()
: initsOnExceptions[index].mergedWith(flowInfo);
}
- public void recordReturnFrom(UnconditionalFlowInfo flowInfo) {
-
- // record initializations which were performed at the return point
- initsOnReturn = initsOnReturn.mergedWith(flowInfo);
+ public void recordReturnFrom(FlowInfo flowInfo) {
+
+ if (!flowInfo.isReachable()) return;
+ if (initsOnReturn == FlowInfo.DEAD_END) {
+ initsOnReturn = flowInfo.copy().unconditionalInits();
+ } else {
+ initsOnReturn.mergedWith(flowInfo.unconditionalInits());
+ }
}
/*
@@ -184,4 +194,4 @@
this.extendedExceptions.add(newException);
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java
index 8d64760..a09fa55 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java
@@ -1,20 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.flow;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
-import org.eclipse.jdt.internal.compiler.ast.NameReference;
import org.eclipse.jdt.internal.compiler.ast.Reference;
-import org.eclipse.jdt.internal.compiler.lookup.BindingIds;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
@@ -25,6 +24,7 @@
public class FinallyFlowContext extends FlowContext {
Reference finalAssignments[];
+ VariableBinding finalVariables[];
int assignCount;
public FinallyFlowContext(FlowContext parent, AstNode associatedNode) {
@@ -40,33 +40,46 @@
FlowInfo flowInfo,
BlockScope scope) {
for (int i = 0; i < assignCount; i++) {
- Reference ref;
- if (((ref = finalAssignments[i]).bits & BindingIds.FIELD) != 0) {
+ VariableBinding variable = finalVariables[i];
+ if (variable == null) continue;
+
+ boolean complained = false; // remember if have complained on this final assignment
+ if (variable instanceof FieldBinding) {
// final field
- if (flowInfo.isPotentiallyAssigned(ref.fieldBinding())) {
- scope.problemReporter().duplicateInitializationOfBlankFinalField(ref.fieldBinding(), ref);
+ if (flowInfo.isPotentiallyAssigned((FieldBinding)variable)) {
+ complained = true;
+ scope.problemReporter().duplicateInitializationOfBlankFinalField((FieldBinding)variable, finalAssignments[i]);
}
} else {
// final local variable
- if (flowInfo
- .isPotentiallyAssigned((LocalVariableBinding) ((NameReference) ref).binding)) {
+ if (flowInfo.isPotentiallyAssigned((LocalVariableBinding) variable)) {
+ complained = true;
scope.problemReporter().duplicateInitializationOfFinalLocal(
- (LocalVariableBinding) ((NameReference) ref).binding,
- (NameReference) ref);
+ (LocalVariableBinding) variable,
+ finalAssignments[i]);
}
}
// any reference reported at this level is removed from the parent context
// where it could also be reported again
- FlowContext currentContext = parent;
- while (currentContext != null) {
- if (currentContext.isSubRoutine()) {
- currentContext.removeFinalAssignmentIfAny(ref);
+ if (complained) {
+ FlowContext currentContext = parent;
+ while (currentContext != null) {
+ //if (currentContext.isSubRoutine()) {
+ currentContext.removeFinalAssignmentIfAny(finalAssignments[i]);
+ //}
+ currentContext = currentContext.parent;
}
- currentContext = currentContext.parent;
}
}
}
+ public String individualToString() {
+
+ StringBuffer buffer = new StringBuffer("Finally flow context"); //$NON-NLS-1$
+ buffer.append("[finalAssignments count -").append(assignCount).append(']'); //$NON-NLS-1$
+ return buffer.toString();
+ }
+
public boolean isSubRoutine() {
return true;
}
@@ -76,6 +89,7 @@
Reference finalAssignment) {
if (assignCount == 0) {
finalAssignments = new Reference[5];
+ finalVariables = new VariableBinding[5];
} else {
if (assignCount == finalAssignments.length)
System.arraycopy(
@@ -84,8 +98,25 @@
(finalAssignments = new Reference[assignCount * 2]),
0,
assignCount);
+ System.arraycopy(
+ finalVariables,
+ 0,
+ (finalVariables = new VariableBinding[assignCount * 2]),
+ 0,
+ assignCount);
};
- finalAssignments[assignCount++] = finalAssignment;
+ finalAssignments[assignCount] = finalAssignment;
+ finalVariables[assignCount++] = binding;
return true;
}
-}
\ No newline at end of file
+
+ void removeFinalAssignmentIfAny(Reference reference) {
+ for (int i = 0; i < assignCount; i++) {
+ if (finalAssignments[i] == reference) {
+ finalAssignments[i] = null;
+ finalVariables[i] = null;
+ return;
+ }
+ }
+ }
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
index f26c5eb..bea317f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java
@@ -1,18 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.flow;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.Reference;
+import org.eclipse.jdt.internal.compiler.ast.TryStatement;
import org.eclipse.jdt.internal.compiler.codegen.Label;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
@@ -20,25 +22,26 @@
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* Reflects the context of code analysis, keeping track of enclosing
* try statements, exception handlers, etc...
*/
public class FlowContext implements TypeConstants {
+
public AstNode associatedNode;
public FlowContext parent;
- public final static FlowContext NotContinuableContext =
- new FlowContext(null, null);
+ public final static FlowContext NotContinuableContext = new FlowContext(null, null);
public FlowContext(FlowContext parent, AstNode associatedNode) {
+
this.parent = parent;
this.associatedNode = associatedNode;
}
public Label breakLabel() {
+
return null;
}
@@ -68,6 +71,7 @@
0,
raisedCount);
FlowContext traversedContext = this;
+
while (traversedContext != null) {
AstNode sub;
if (((sub = traversedContext.subRoutine()) != null) && sub.cannotReturn()) {
@@ -75,8 +79,8 @@
// exceptions will actually never get sent...
return;
}
- // filter exceptions that are locally caught from the most enclosing
- // try statement to the outer ones.
+ // filter exceptions that are locally caught from the innermost enclosing
+ // try statement to the outermost ones.
if (traversedContext instanceof ExceptionHandlingFlowContext) {
ExceptionHandlingFlowContext exceptionContext =
(ExceptionHandlingFlowContext) traversedContext;
@@ -129,9 +133,8 @@
for (int i = 0; i < raisedCount; i++) {
TypeBinding raisedException;
if ((raisedException = raisedExceptions[i]) != null) {
- if (scope
- .areTypesCompatible(raisedException, scope.getJavaLangRuntimeException())
- || scope.areTypesCompatible(raisedException, scope.getJavaLangError())) {
+ if (raisedException.isCompatibleWith(scope.getJavaLangRuntimeException())
+ || raisedException.isCompatibleWith(scope.getJavaLangError())) {
remainingCount--;
raisedExceptions[i] = null;
}
@@ -157,12 +160,21 @@
}
if (remainingCount == 0)
return;
+
+ traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
+ if (traversedContext.associatedNode instanceof TryStatement){
+ flowInfo = flowInfo.copy().addInitializationsFrom(((TryStatement) traversedContext.associatedNode).subRoutineInits);
+ }
traversedContext = traversedContext.parent;
}
// if reaches this point, then there are some remaining unhandled exception types.
- for (int i = 0; i < raisedCount; i++) {
+ nextReport: for (int i = 0; i < raisedCount; i++) {
TypeBinding exception;
if ((exception = raisedExceptions[i]) != null) {
+ // only one complaint if same exception declared to be thrown more than once
+ for (int j = 0; j < i; j++) {
+ if (raisedExceptions[j] == exception) continue nextReport; // already reported
+ }
scope.problemReporter().unhandledException(exception, location);
}
}
@@ -187,8 +199,9 @@
// exceptions will actually never get sent...
return;
}
- // filter exceptions that are locally caught from the most enclosing
- // try statement to the outer ones.
+
+ // filter exceptions that are locally caught from the innermost enclosing
+ // try statement to the outermost ones.
if (traversedContext instanceof ExceptionHandlingFlowContext) {
ExceptionHandlingFlowContext exceptionContext =
(ExceptionHandlingFlowContext) traversedContext;
@@ -225,9 +238,8 @@
}
// method treatment for unchecked exceptions
if (exceptionContext.isMethodContext) {
- if (scope
- .areTypesCompatible(raisedException, scope.getJavaLangRuntimeException())
- || scope.areTypesCompatible(raisedException, scope.getJavaLangError()))
+ if (raisedException.isCompatibleWith(scope.getJavaLangRuntimeException())
+ || raisedException.isCompatibleWith(scope.getJavaLangError()))
return;
// anonymous constructors are allowed to throw any exceptions (their thrown exceptions
@@ -243,6 +255,11 @@
break; // not handled anywhere, thus jump to error handling
}
}
+
+ traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
+ if (traversedContext.associatedNode instanceof TryStatement){
+ flowInfo = flowInfo.copy().addInitializationsFrom(((TryStatement) traversedContext.associatedNode).subRoutineInits);
+ }
traversedContext = traversedContext.parent;
}
// if reaches this point, then there are some remaining unhandled exception types.
@@ -250,6 +267,7 @@
}
public Label continueLabel() {
+
return null;
}
@@ -257,6 +275,7 @@
* lookup through break labels
*/
public FlowContext getTargetContextForBreakLabel(char[] labelName) {
+
FlowContext current = this, lastNonReturningSubRoutine = null;
while (current != null) {
if (current.isNonReturningContext()) {
@@ -281,9 +300,11 @@
* lookup through continue labels
*/
public FlowContext getTargetContextForContinueLabel(char[] labelName) {
- FlowContext current = this,
- lastContinuable = null,
- lastNonReturningSubRoutine = null;
+
+ FlowContext current = this;
+ FlowContext lastContinuable = null;
+ FlowContext lastNonReturningSubRoutine = null;
+
while (current != null) {
if (current.isNonReturningContext()) {
lastNonReturningSubRoutine = current;
@@ -292,12 +313,14 @@
lastContinuable = current;
}
}
+
char[] currentLabelName;
- if (((currentLabelName = current.labelName()) != null)
- && CharOperation.equals(currentLabelName, labelName)) {
+ if ((currentLabelName = current.labelName()) != null && CharOperation.equals(currentLabelName, labelName)) {
+
+ // matching label found
if ((lastContinuable != null)
- && (current.associatedNode.concreteStatement()
- == lastContinuable.associatedNode)) {
+ && (current.associatedNode.concreteStatement() == lastContinuable.associatedNode)) {
+
if (lastNonReturningSubRoutine == null) {
return lastContinuable;
} else {
@@ -318,12 +341,13 @@
* lookup a default break through breakable locations
*/
public FlowContext getTargetContextForDefaultBreak() {
+
FlowContext current = this, lastNonReturningSubRoutine = null;
while (current != null) {
if (current.isNonReturningContext()) {
lastNonReturningSubRoutine = current;
}
- if (current.isBreakable()) {
+ if (current.isBreakable() && current.labelName() == null) {
if (lastNonReturningSubRoutine == null) {
return current;
} else {
@@ -340,6 +364,7 @@
* lookup a default continue amongst continuable locations
*/
public FlowContext getTargetContextForDefaultContinue() {
+
FlowContext current = this, lastNonReturningSubRoutine = null;
while (current != null) {
if (current.isNonReturningContext()) {
@@ -359,30 +384,42 @@
}
public String individualToString() {
+
return "Flow context"; //$NON-NLS-1$
}
public FlowInfo initsOnBreak() {
- return FlowInfo.DeadEnd;
+
+ return FlowInfo.DEAD_END;
+ }
+
+ public UnconditionalFlowInfo initsOnReturn() {
+
+ return FlowInfo.DEAD_END;
}
public boolean isBreakable() {
+
return false;
}
public boolean isContinuable() {
+
return false;
}
public boolean isNonReturningContext() {
+
return false;
}
public boolean isSubRoutine() {
+
return false;
}
public char[] labelName() {
+
return null;
}
@@ -395,15 +432,17 @@
boolean recordFinalAssignment(
VariableBinding variable,
Reference finalReference) {
+
return true; // keep going
}
- public void recordReturnFrom(UnconditionalFlowInfo flowInfo) {
+ public void recordReturnFrom(FlowInfo flowInfo) {
}
public void recordSettingFinal(
VariableBinding variable,
Reference finalReference) {
+
// for initialization inside looping statement that effectively loops
FlowContext context = this;
while (context != null) {
@@ -418,10 +457,12 @@
}
public AstNode subRoutine() {
+
return null;
}
public String toString() {
+
StringBuffer buffer = new StringBuffer();
FlowContext current = this;
int parentsCount = 0;
@@ -446,4 +487,4 @@
buffer.append(individualToString()).append('\n');
return buffer.toString();
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java
index bccdabc..231b8c8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.flow;
import org.eclipse.jdt.internal.compiler.ast.Statement;
@@ -16,72 +16,112 @@
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
public abstract class FlowInfo {
- public static final UnconditionalFlowInfo DeadEnd = new UnconditionalFlowInfo(); // Represents a dead branch status of initialization
-abstract public UnconditionalFlowInfo addInitializationsFrom(UnconditionalFlowInfo otherInits);
-abstract public UnconditionalFlowInfo addPotentialInitializationsFrom(UnconditionalFlowInfo otherInits);
-public FlowInfo asNegatedCondition() {
- return this;
-}
-public boolean complainIfUnreachable(Statement statement, BlockScope scope) {
- // Report an error if necessary
- return false;
-}
-public static FlowInfo conditional(FlowInfo initsWhenTrue, FlowInfo initsWhenFalse){
- // if (initsWhenTrue.equals(initsWhenFalse)) return initsWhenTrue; -- could optimize if #equals is defined
- return new ConditionalFlowInfo(initsWhenTrue, initsWhenFalse);
-}
-abstract public FlowInfo copy();
-public static UnconditionalFlowInfo initial(int maxFieldCount) {
- UnconditionalFlowInfo info = new UnconditionalFlowInfo();
- info.maxFieldCount = maxFieldCount;
- return info;
-}
-abstract public FlowInfo initsWhenFalse();
-abstract public FlowInfo initsWhenTrue();
-final public boolean isDeadEnd() {
- return this == DeadEnd;
-}
-/**
- * Check status of definite assignment for a field.
- */
- abstract public boolean isDefinitelyAssigned(FieldBinding field);
-/**
- * Check status of definite assignment for a local.
- */
-public abstract boolean isDefinitelyAssigned(LocalVariableBinding local);
-abstract public boolean isFakeReachable();
-/**
- * Check status of potential assignment for a field.
- */
- abstract public boolean isPotentiallyAssigned(FieldBinding field);
-/**
- * Check status of potential assignment for a local variable.
- */
- abstract public boolean isPotentiallyAssigned(LocalVariableBinding field);
-/**
- * Record a field got definitely assigned.
- */
-abstract public void markAsDefinitelyAssigned(FieldBinding field);
-/**
- * Record a local got definitely assigned.
- */
-abstract public void markAsDefinitelyAssigned(LocalVariableBinding local);
-/**
- * Clear the initialization info for a field
- */
-abstract public void markAsDefinitelyNotAssigned(FieldBinding field);
-/**
- * Clear the initialization info for a local variable
- */
-abstract public void markAsDefinitelyNotAssigned(LocalVariableBinding local);
-abstract public FlowInfo markAsFakeReachable(boolean isFakeReachable);
-abstract public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits);
-public String toString(){
- if (this == DeadEnd){
- return "FlowInfo.DeadEnd"; //$NON-NLS-1$
+ public final static int REACHABLE = 0;
+ public final static int UNREACHABLE = 1;
+
+ public static final UnconditionalFlowInfo DEAD_END; // Represents a dead branch status of initialization
+ static {
+ DEAD_END = new UnconditionalFlowInfo();
+ DEAD_END.reachMode = UNREACHABLE;
}
- return super.toString();
-}
-abstract public UnconditionalFlowInfo unconditionalInits();
+ abstract public FlowInfo addInitializationsFrom(FlowInfo otherInits);
+
+ abstract public FlowInfo addPotentialInitializationsFrom(FlowInfo otherInits);
+
+ public FlowInfo asNegatedCondition() {
+
+ return this;
+ }
+
+ public boolean complainIfUnreachable(Statement statement, BlockScope scope, boolean didAlreadyComplain) {
+
+ // Report an error if necessary
+ return false;
+ }
+
+ public static FlowInfo conditional(FlowInfo initsWhenTrue, FlowInfo initsWhenFalse){
+
+ // if (initsWhenTrue.equals(initsWhenFalse)) return initsWhenTrue; -- could optimize if #equals is defined
+ return new ConditionalFlowInfo(initsWhenTrue, initsWhenFalse);
+ }
+
+ abstract public FlowInfo copy();
+
+ public static UnconditionalFlowInfo initial(int maxFieldCount) {
+ UnconditionalFlowInfo info = new UnconditionalFlowInfo();
+ info.maxFieldCount = maxFieldCount;
+ return info;
+ }
+
+ abstract public FlowInfo initsWhenFalse();
+
+ abstract public FlowInfo initsWhenTrue();
+
+ /**
+ * Check status of definite assignment for a field.
+ */
+ abstract public boolean isDefinitelyAssigned(FieldBinding field);
+
+ /**
+ * Check status of definite assignment for a local.
+ */
+ public abstract boolean isDefinitelyAssigned(LocalVariableBinding local);
+
+ //abstract public int reachMode();
+
+ /**
+ * Check status of potential assignment for a field.
+ */
+ abstract public boolean isPotentiallyAssigned(FieldBinding field);
+
+ /**
+ * Check status of potential assignment for a local variable.
+ */
+
+ abstract public boolean isPotentiallyAssigned(LocalVariableBinding field);
+
+ abstract public boolean isReachable();
+
+ /**
+ * Record a field got definitely assigned.
+ */
+ abstract public void markAsDefinitelyAssigned(FieldBinding field);
+
+ /**
+ * Record a local got definitely assigned.
+ */
+ abstract public void markAsDefinitelyAssigned(LocalVariableBinding local);
+
+ /**
+ * Clear the initialization info for a field
+ */
+ abstract public void markAsDefinitelyNotAssigned(FieldBinding field);
+
+ /**
+ * Clear the initialization info for a local variable
+ */
+ abstract public void markAsDefinitelyNotAssigned(LocalVariableBinding local);
+
+ abstract public int reachMode();
+
+ abstract public FlowInfo setReachMode(int reachMode);
+
+ /**
+ * Returns the receiver updated in the following way: <ul>
+ * <li> intersection of definitely assigned variables,
+ * <li> union of potentially assigned variables.
+ * </ul>
+ */
+ abstract public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits);
+
+ public String toString(){
+
+ if (this == DEAD_END){
+ return "FlowInfo.DEAD_END"; //$NON-NLS-1$
+ }
+ return super.toString();
+ }
+
+ abstract public UnconditionalFlowInfo unconditionalInits();
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java
index 8ce26f9..6de6a69 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.flow;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
@@ -25,7 +25,7 @@
public TypeBinding[] thrownExceptions = new TypeBinding[5];
public AstNode[] exceptionThrowers = new AstNode[5];
public FlowInfo[] exceptionThrowerFlowInfos = new FlowInfo[5];
-
+
public InitializationFlowContext(
FlowContext parent,
AstNode associatedNode,
@@ -33,9 +33,9 @@
super(
parent,
associatedNode,
- new ReferenceBinding[] { scope.getJavaLangThrowable()},
- // tolerate any kind of exception, but record them
- scope, FlowInfo.DeadEnd);
+ NoExceptions, // no exception allowed by default
+ scope,
+ FlowInfo.DEAD_END);
}
public void checkInitializerExceptions(
@@ -51,6 +51,16 @@
}
}
+ public String individualToString() {
+
+ StringBuffer buffer = new StringBuffer("Initialization flow context"); //$NON-NLS-1$
+ for (int i = 0; i < exceptionCount; i++) {
+ buffer.append('[').append(thrownExceptions[i].readableName());
+ buffer.append('-').append(exceptionThrowerFlowInfos[i].toString()).append(']');
+ }
+ return buffer.toString();
+ }
+
public void recordHandlingException(
ReferenceBinding exceptionType,
UnconditionalFlowInfo flowInfo,
@@ -58,6 +68,7 @@
AstNode invocationSite,
boolean wasMasked) {
+ // even if unreachable code, need to perform unhandled exception diagnosis
int size = thrownExceptions.length;
if (exceptionCount == size) {
System.arraycopy(
@@ -83,4 +94,4 @@
exceptionThrowers[exceptionCount] = invocationSite;
exceptionThrowerFlowInfos[exceptionCount++] = flowInfo.copy();
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InsideSubRoutineFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InsideSubRoutineFlowContext.java
index 14ec0b3..bba42e1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InsideSubRoutineFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InsideSubRoutineFlowContext.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.flow;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
@@ -24,9 +24,20 @@
FlowContext parent,
AstNode associatedNode) {
super(parent, associatedNode);
- this.initsOnReturn = FlowInfo.DeadEnd;
+ this.initsOnReturn = FlowInfo.DEAD_END;
}
-
+
+ public String individualToString() {
+
+ StringBuffer buffer = new StringBuffer("Inside SubRoutine flow context"); //$NON-NLS-1$
+ buffer.append("[initsOnReturn -").append(initsOnReturn.toString()).append(']'); //$NON-NLS-1$
+ return buffer.toString();
+ }
+
+ public UnconditionalFlowInfo initsOnReturn(){
+ return this.initsOnReturn;
+ }
+
public boolean isNonReturningContext() {
return associatedNode.cannotReturn();
}
@@ -35,8 +46,13 @@
return associatedNode;
}
- public void recordReturnFrom(UnconditionalFlowInfo flowInfo) {
- // record initializations which were performed at the return point
- initsOnReturn = initsOnReturn.mergedWith(flowInfo);
+ public void recordReturnFrom(FlowInfo flowInfo) {
+
+ if (!flowInfo.isReachable()) return;
+ if (initsOnReturn == FlowInfo.DEAD_END) {
+ initsOnReturn = flowInfo.copy().unconditionalInits();
+ } else {
+ initsOnReturn.mergedWith(flowInfo.unconditionalInits());
+ }
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LabelFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LabelFlowContext.java
index b5129bb..9f5c81c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LabelFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LabelFlowContext.java
@@ -1,38 +1,42 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.flow;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.codegen.Label;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* Reflects the context of code analysis, keeping track of enclosing
* try statements, exception handlers, etc...
*/
public class LabelFlowContext extends SwitchFlowContext {
+
public char[] labelName;
+
public LabelFlowContext(
FlowContext parent,
AstNode associatedNode,
char[] labelName,
Label breakLabel,
BlockScope scope) {
+
super(parent, associatedNode, breakLabel);
this.labelName = labelName;
checkLabelValidity(scope);
}
void checkLabelValidity(BlockScope scope) {
+
// check if label was already defined above
FlowContext current = parent;
while (current != null) {
@@ -46,10 +50,12 @@
}
public String individualToString() {
+
return "Label flow context [label:" + String.valueOf(labelName) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
}
public char[] labelName() {
+
return labelName;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java
index a4b2b37..f47888a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java
@@ -1,17 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.flow;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
-import org.eclipse.jdt.internal.compiler.ast.NameReference;
import org.eclipse.jdt.internal.compiler.ast.Reference;
import org.eclipse.jdt.internal.compiler.codegen.Label;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
@@ -25,12 +24,14 @@
* try statements, exception handlers, etc...
*/
public class LoopingFlowContext extends SwitchFlowContext {
+
public Label continueLabel;
- public UnconditionalFlowInfo initsOnContinue = FlowInfo.DeadEnd;
+ public UnconditionalFlowInfo initsOnContinue = FlowInfo.DEAD_END;
Reference finalAssignments[];
VariableBinding finalVariables[];
int assignCount = 0;
Scope associatedScope;
+
public LoopingFlowContext(
FlowContext parent,
AstNode associatedNode,
@@ -46,31 +47,31 @@
BlockScope scope,
FlowInfo flowInfo) {
for (int i = 0; i < assignCount; i++) {
- VariableBinding variable;
- if ((variable = finalVariables[i]) != null) {
- boolean complained; // remember if have complained on this final assignment
- if (variable instanceof FieldBinding) {
- if (complained = flowInfo.isPotentiallyAssigned((FieldBinding) variable)) {
- scope.problemReporter().duplicateInitializationOfBlankFinalField(
- (FieldBinding) variable,
- (NameReference) finalAssignments[i]);
- }
- } else {
- if (complained =
- flowInfo.isPotentiallyAssigned((LocalVariableBinding) variable)) {
- scope.problemReporter().duplicateInitializationOfFinalLocal(
- (LocalVariableBinding) variable,
- (NameReference) finalAssignments[i]);
- }
+ VariableBinding variable = finalVariables[i];
+ if (variable == null) continue;
+ boolean complained = false; // remember if have complained on this final assignment
+ if (variable instanceof FieldBinding) {
+ if (flowInfo.isPotentiallyAssigned((FieldBinding) variable)) {
+ complained = true;
+ scope.problemReporter().duplicateInitializationOfBlankFinalField(
+ (FieldBinding) variable,
+ finalAssignments[i]);
}
- // any reference reported at this level is removed from the parent context where it
- // could also be reported again
- if (complained) {
- FlowContext context = parent;
- while (context != null) {
- context.removeFinalAssignmentIfAny(finalAssignments[i]);
- context = context.parent;
- }
+ } else {
+ if (flowInfo.isPotentiallyAssigned((LocalVariableBinding) variable)) {
+ complained = true;
+ scope.problemReporter().duplicateInitializationOfFinalLocal(
+ (LocalVariableBinding) variable,
+ finalAssignments[i]);
+ }
+ }
+ // any reference reported at this level is removed from the parent context where it
+ // could also be reported again
+ if (complained) {
+ FlowContext context = parent;
+ while (context != null) {
+ context.removeFinalAssignmentIfAny(finalAssignments[i]);
+ context = context.parent;
}
}
}
@@ -81,7 +82,10 @@
}
public String individualToString() {
- return "Looping flow context"; //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer("Looping flow context"); //$NON-NLS-1$
+ buffer.append("[initsOnBreak -").append(initsOnBreak.toString()).append(']'); //$NON-NLS-1$
+ buffer.append("[initsOnContinue -").append(initsOnContinue.toString()).append(']'); //$NON-NLS-1$
+ return buffer.toString();
}
public boolean isContinuable() {
@@ -89,16 +93,15 @@
}
public boolean isContinuedTo() {
- return initsOnContinue != FlowInfo.DeadEnd;
+ return initsOnContinue != FlowInfo.DEAD_END;
}
public void recordContinueFrom(FlowInfo flowInfo) {
- if (initsOnContinue == FlowInfo.DeadEnd) {
+
+ if (!flowInfo.isReachable()) return;
+ if (initsOnContinue == FlowInfo.DEAD_END) {
initsOnContinue = flowInfo.copy().unconditionalInits();
} else {
- // ignore if not really reachable (1FKEKRP)
- if (flowInfo.isFakeReachable())
- return;
initsOnContinue.mergedWith(flowInfo.unconditionalInits());
};
}
@@ -146,4 +149,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java
index 59e187b..08b632b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.flow;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
@@ -19,7 +19,7 @@
*/
public class SwitchFlowContext extends FlowContext {
public Label breakLabel;
- public UnconditionalFlowInfo initsOnBreak = FlowInfo.DeadEnd;
+ public UnconditionalFlowInfo initsOnBreak = FlowInfo.DEAD_END;
public SwitchFlowContext(
FlowContext parent,
@@ -34,7 +34,9 @@
}
public String individualToString() {
- return "Switch flow context"; //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer("Switch flow context"); //$NON-NLS-1$
+ buffer.append("[initsOnBreak -").append(initsOnBreak.toString()).append(']'); //$NON-NLS-1$
+ return buffer.toString();
}
public boolean isBreakable() {
@@ -42,13 +44,11 @@
}
public void recordBreakFrom(FlowInfo flowInfo) {
- if (initsOnBreak == FlowInfo.DeadEnd) {
+
+ if (initsOnBreak == FlowInfo.DEAD_END) {
initsOnBreak = flowInfo.copy().unconditionalInits();
} else {
- // ignore if not really reachable (1FKEKRP)
- if (flowInfo.isFakeReachable())
- return;
initsOnBreak.mergedWith(flowInfo.unconditionalInits());
};
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java
index 7916c97..6784d35 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java
@@ -1,17 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.flow;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.Statement;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
@@ -23,417 +24,554 @@
* No caching of pre-allocated instances.
*/
public class UnconditionalFlowInfo extends FlowInfo {
+
+
public long definiteInits;
- long potentialInits;
+ public long potentialInits;
public long extraDefiniteInits[];
- long extraPotentialInits[];
- public boolean isFakeReachable;
+ public long extraPotentialInits[];
+
+ public int reachMode = REACHABLE; // by default
+
public int maxFieldCount;
// Constants
public static final int BitCacheSize = 64; // 64 bits in a long.
-UnconditionalFlowInfo() {
-}
-public UnconditionalFlowInfo addInitializationsFrom(UnconditionalFlowInfo otherInits) {
+
+ UnconditionalFlowInfo() {
+ }
// unions of both sets of initialization - used for try/finally
- if (this == DeadEnd)
- return this;
- if (otherInits == DeadEnd)
- return this;
-
- // union of definitely assigned variables,
- definiteInits |= otherInits.definiteInits;
- // union of potentially set ones
- potentialInits |= otherInits.potentialInits;
+ public FlowInfo addInitializationsFrom(FlowInfo inits) {
- // treating extra storage
- if (extraDefiniteInits != null) {
- if (otherInits.extraDefiniteInits != null) {
- // both sides have extra storage
- int i = 0, length, otherLength;
- if ((length = extraDefiniteInits.length) < (otherLength = otherInits.extraDefiniteInits.length)) {
- // current storage is shorter -> grow current (could maybe reuse otherInits extra storage?)
- System.arraycopy(extraDefiniteInits, 0, (extraDefiniteInits = new long[otherLength]), 0, length);
- System.arraycopy(extraPotentialInits, 0, (extraPotentialInits = new long[otherLength]), 0, length);
- while (i < length) {
- extraDefiniteInits[i] |= otherInits.extraDefiniteInits[i];
- extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
- }
- while (i < otherLength) {
- extraPotentialInits[i] = otherInits.extraPotentialInits[i++];
- }
- } else {
- // current storage is longer
- while (i < otherLength) {
- extraDefiniteInits[i] |= otherInits.extraDefiniteInits[i];
- extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
- }
- while (i < length)
- extraDefiniteInits[i++] = 0;
- }
- } else {
- // no extra storage on otherInits
- }
- } else
- if (otherInits.extraDefiniteInits != null) {
- // no storage here, but other has extra storage.
- int otherLength;
- System.arraycopy(otherInits.extraDefiniteInits, 0, (extraDefiniteInits = new long[otherLength = otherInits.extraDefiniteInits.length]), 0, otherLength);
- System.arraycopy(otherInits.extraPotentialInits, 0, (extraPotentialInits = new long[otherLength]), 0, otherLength);
- }
- return this;
-}
-public UnconditionalFlowInfo addPotentialInitializationsFrom(UnconditionalFlowInfo otherInits) {
+ if (this == DEAD_END)
+ return this;
- // unions of both sets of initialization - used for try/finally
- if (this == DeadEnd){
- return this;
- }
- if (otherInits == DeadEnd){
- return this;
- }
- // union of potentially set ones
- potentialInits |= otherInits.potentialInits;
-
- // treating extra storage
- if (extraDefiniteInits != null) {
- if (otherInits.extraDefiniteInits != null) {
- // both sides have extra storage
- int i = 0, length, otherLength;
- if ((length = extraDefiniteInits.length) < (otherLength = otherInits.extraDefiniteInits.length)) {
- // current storage is shorter -> grow current (could maybe reuse otherInits extra storage?)
- System.arraycopy(extraDefiniteInits, 0, (extraDefiniteInits = new long[otherLength]), 0, length);
- System.arraycopy(extraPotentialInits, 0, (extraPotentialInits = new long[otherLength]), 0, length);
- while (i < length) {
- extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
- }
- while (i < otherLength) {
- extraPotentialInits[i] = otherInits.extraPotentialInits[i++];
- }
- } else {
- // current storage is longer
- while (i < otherLength) {
- extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
- }
- }
- }
- } else
- if (otherInits.extraDefiniteInits != null) {
- // no storage here, but other has extra storage.
- int otherLength;
- extraDefiniteInits = new long[otherLength = otherInits.extraDefiniteInits.length];
- System.arraycopy(otherInits.extraPotentialInits, 0, (extraPotentialInits = new long[otherLength]), 0, otherLength);
- }
- return this;
-}
-public boolean complainIfUnreachable(Statement statement, BlockScope scope) {
- // Report an error if necessary
-
- boolean isDeadEnd;
- if ((isDeadEnd = (this == DeadEnd)) || isFakeReachable) {
- statement.bits &= ~AstNode.IsReachableMASK;
- /* EXTRA REFERENCE RECORDING
- statement.recordUnreachableReferences(scope.referenceType()); // scopes cannot have an enclosingMethod slot since there are class scopes
- */
- if (isDeadEnd)
- scope.problemReporter().unreachableCode(statement);
- return isDeadEnd;
- }
- return false;
-}
-/**
- * Answers a copy of the current instance
- */
-public FlowInfo copy() {
- // do not clone the DeadEnd
- if (this == DeadEnd)
- return this;
-
- // look for an unused preallocated object
- UnconditionalFlowInfo copy = new UnconditionalFlowInfo();
-
- // copy slots
- copy.definiteInits = definiteInits;
- copy.potentialInits = potentialInits;
- copy.isFakeReachable = isFakeReachable;
- copy.maxFieldCount = maxFieldCount;
+ UnconditionalFlowInfo otherInits = inits.unconditionalInits();
+ if (otherInits == DEAD_END)
+ return this;
+
+ // union of definitely assigned variables,
+ definiteInits |= otherInits.definiteInits;
+ // union of potentially set ones
+ potentialInits |= otherInits.potentialInits;
- if (extraDefiniteInits != null) {
- int length;
- System.arraycopy(extraDefiniteInits, 0, (copy.extraDefiniteInits = new long[ (length = extraDefiniteInits.length)]), 0, length);
- System.arraycopy(extraPotentialInits, 0, (copy.extraPotentialInits = new long[length]), 0, length);
- };
- return copy;
-}
-public FlowInfo initsWhenFalse() {
- return this;
-}
-public FlowInfo initsWhenTrue() {
- return this;
-}
-/**
- * Check status of definite assignment at a given position.
- * It deals with the dual representation of the InitializationInfo2:
- * bits for the first 64 entries, then an array of booleans.
- */
-final private boolean isDefinitelyAssigned(int position) {
- // Dependant of CodeStream.isDefinitelyAssigned(..)
- // id is zero-based
- if (position < BitCacheSize) {
- return (definiteInits & (1L << position)) != 0; // use bits
- }
- // use extra vector
- if (extraDefiniteInits == null)
- return false; // if vector not yet allocated, then not initialized
- int vectorIndex;
- if ((vectorIndex = (position / BitCacheSize) - 1) >= extraDefiniteInits.length)
- return false; // if not enough room in vector, then not initialized
- return ((extraDefiniteInits[vectorIndex]) & (1L << (position % BitCacheSize))) != 0;
-}
-/**
- * Check status of definite assignment for a field.
- */
-final public boolean isDefinitelyAssigned(FieldBinding field) {
- // Dependant of CodeStream.isDefinitelyAssigned(..)
- // We do not want to complain in unreachable code
- if ((this == DeadEnd) || (this.isFakeReachable))
- return true;
- return isDefinitelyAssigned(field.id);
-}
-/**
- * Check status of definite assignment for a local.
- */
-final public boolean isDefinitelyAssigned(LocalVariableBinding local) {
- // Dependant of CodeStream.isDefinitelyAssigned(..)
- // We do not want to complain in unreachable code
- if ((this == DeadEnd) || (this.isFakeReachable))
- return true;
- if (local.isArgument) {
- return true;
- }
- return isDefinitelyAssigned(local.id + maxFieldCount);
-}
-public boolean isFakeReachable() {
- return isFakeReachable;
-}
-/**
- * Check status of potential assignment at a given position.
- * It deals with the dual representation of the InitializationInfo3:
- * bits for the first 64 entries, then an array of booleans.
- */
-final private boolean isPotentiallyAssigned(int position) {
- // id is zero-based
- if (position < BitCacheSize) {
- // use bits
- return (potentialInits & (1L << position)) != 0;
- }
- // use extra vector
- if (extraPotentialInits == null)
- return false; // if vector not yet allocated, then not initialized
- int vectorIndex;
- if ((vectorIndex = (position / BitCacheSize) - 1) >= extraPotentialInits.length)
- return false; // if not enough room in vector, then not initialized
- return ((extraPotentialInits[vectorIndex]) & (1L << (position % BitCacheSize))) != 0;
-}
-/**
- * Check status of definite assignment for a field.
- */
-final public boolean isPotentiallyAssigned(FieldBinding field) {
- // We do not want to complain in unreachable code
- if ((this == DeadEnd) || (this.isFakeReachable))
- return false;
- return isPotentiallyAssigned(field.id);
-}
-/**
- * Check status of potential assignment for a local.
- */
-final public boolean isPotentiallyAssigned(LocalVariableBinding local) {
- // We do not want to complain in unreachable code
- if ((this == DeadEnd) || (this.isFakeReachable))
- return false;
- if (local.isArgument) {
- return true;
- }
- return isPotentiallyAssigned(local.id + maxFieldCount);
-}
-/**
- * Record a definite assignment at a given position.
- * It deals with the dual representation of the InitializationInfo2:
- * bits for the first 64 entries, then an array of booleans.
- */
-final private void markAsDefinitelyAssigned(int position) {
- if (this != DeadEnd) {
-
- // position is zero-based
- if (position < BitCacheSize) {
- // use bits
- long mask;
- definiteInits |= (mask = 1L << position);
- potentialInits |= mask;
- } else {
- // use extra vector
- int vectorIndex = (position / BitCacheSize) - 1;
- if (extraDefiniteInits == null) {
- int length;
- extraDefiniteInits = new long[length = vectorIndex + 1];
- extraPotentialInits = new long[length];
- } else {
- int oldLength; // might need to grow the arrays
- if (vectorIndex >= (oldLength = extraDefiniteInits.length)) {
- System.arraycopy(extraDefiniteInits, 0, (extraDefiniteInits = new long[vectorIndex + 1]), 0, oldLength);
- System.arraycopy(extraPotentialInits, 0, (extraPotentialInits = new long[vectorIndex + 1]), 0, oldLength);
+ // treating extra storage
+ if (extraDefiniteInits != null) {
+ if (otherInits.extraDefiniteInits != null) {
+ // both sides have extra storage
+ int i = 0, length, otherLength;
+ if ((length = extraDefiniteInits.length) < (otherLength = otherInits.extraDefiniteInits.length)) {
+ // current storage is shorter -> grow current (could maybe reuse otherInits extra storage?)
+ System.arraycopy(extraDefiniteInits, 0, (extraDefiniteInits = new long[otherLength]), 0, length);
+ System.arraycopy(extraPotentialInits, 0, (extraPotentialInits = new long[otherLength]), 0, length);
+ while (i < length) {
+ extraDefiniteInits[i] |= otherInits.extraDefiniteInits[i];
+ extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
+ }
+ while (i < otherLength) {
+ extraPotentialInits[i] = otherInits.extraPotentialInits[i++];
+ }
+ } else {
+ // current storage is longer
+ while (i < otherLength) {
+ extraDefiniteInits[i] |= otherInits.extraDefiniteInits[i];
+ extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
+ }
+ while (i < length)
+ extraDefiniteInits[i++] = 0;
}
- }
- long mask;
- extraDefiniteInits[vectorIndex] |= (mask = 1L << (position % BitCacheSize));
- extraPotentialInits[vectorIndex] |= mask;
- }
- }
-}
-/**
- * Record a field got definitely assigned.
- */
-public void markAsDefinitelyAssigned(FieldBinding field) {
- if (this != DeadEnd)
- markAsDefinitelyAssigned(field.id);
-}
-/**
- * Record a local got definitely assigned.
- */
-public void markAsDefinitelyAssigned(LocalVariableBinding local) {
- if (this != DeadEnd)
- markAsDefinitelyAssigned(local.id + maxFieldCount);
-}
-/**
- * Clear initialization information at a given position.
- * It deals with the dual representation of the InitializationInfo2:
- * bits for the first 64 entries, then an array of booleans.
- */
-final private void markAsDefinitelyNotAssigned(int position) {
- if (this != DeadEnd) {
-
- // position is zero-based
- if (position < BitCacheSize) {
- // use bits
- long mask;
- definiteInits &= ~(mask = 1L << position);
- potentialInits &= ~mask;
- } else {
- // use extra vector
- int vectorIndex = (position / BitCacheSize) - 1;
- if (extraDefiniteInits == null) {
- return; // nothing to do, it was not yet set
} else {
- // might need to grow the arrays
- if (vectorIndex >= extraDefiniteInits.length) {
- return; // nothing to do, it was not yet set
- }
+ // no extra storage on otherInits
}
- long mask;
- extraDefiniteInits[vectorIndex] &= ~(mask = 1L << (position % BitCacheSize));
- extraPotentialInits[vectorIndex] &= ~mask;
- }
- }
-}
-/**
- * Clear the initialization info for a field
- */
-public void markAsDefinitelyNotAssigned(FieldBinding field) {
- if (this != DeadEnd)
- markAsDefinitelyNotAssigned(field.id);
-}
-/**
- * Clear the initialization info for a local variable
- */
-
-public void markAsDefinitelyNotAssigned(LocalVariableBinding local) {
- if (this != DeadEnd)
- markAsDefinitelyNotAssigned(local.id + maxFieldCount);
-}
-public FlowInfo markAsFakeReachable(boolean isFakeReachable) {
- this.isFakeReachable = isFakeReachable;
- return this;
-}
-public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits) {
- // updates the receiver with:
- // - intersection of definitely assigned variables,
- // - union of potentially set ones
-
- if (this == DeadEnd)
- return otherInits;
- if (otherInits == DeadEnd)
+ } else
+ if (otherInits.extraDefiniteInits != null) {
+ // no storage here, but other has extra storage.
+ int otherLength;
+ System.arraycopy(otherInits.extraDefiniteInits, 0, (extraDefiniteInits = new long[otherLength = otherInits.extraDefiniteInits.length]), 0, otherLength);
+ System.arraycopy(otherInits.extraPotentialInits, 0, (extraPotentialInits = new long[otherLength]), 0, otherLength);
+ }
return this;
+ }
- // if one branch is not fake reachable, then the merged one is reachable
- if (!otherInits.isFakeReachable())
- markAsFakeReachable(false);
+ // unions of both sets of initialization - used for try/finally
+ public FlowInfo addPotentialInitializationsFrom(FlowInfo inits) {
+
+ if (this == DEAD_END){
+ return this;
+ }
- // intersection of definitely assigned variables,
- definiteInits &= otherInits.definiteInits;
- // union of potentially set ones
- potentialInits |= otherInits.potentialInits;
-
- // treating extra storage
- if (extraDefiniteInits != null) {
- if (otherInits.extraDefiniteInits != null) {
- // both sides have extra storage
- int i = 0, length, otherLength;
- if ((length = extraDefiniteInits.length) < (otherLength = otherInits.extraDefiniteInits.length)) {
- // current storage is shorter -> grow current (could maybe reuse otherInits extra storage?)
- System.arraycopy(extraDefiniteInits, 0, (extraDefiniteInits = new long[otherLength]), 0, length);
- System.arraycopy(extraPotentialInits, 0, (extraPotentialInits = new long[otherLength]), 0, length);
- while (i < length) {
- extraDefiniteInits[i] &= otherInits.extraDefiniteInits[i];
- extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
+ UnconditionalFlowInfo otherInits = inits.unconditionalInits();
+ if (otherInits == DEAD_END){
+ return this;
+ }
+ // union of potentially set ones
+ potentialInits |= otherInits.potentialInits;
+
+ // treating extra storage
+ if (extraDefiniteInits != null) {
+ if (otherInits.extraDefiniteInits != null) {
+ // both sides have extra storage
+ int i = 0, length, otherLength;
+ if ((length = extraDefiniteInits.length) < (otherLength = otherInits.extraDefiniteInits.length)) {
+ // current storage is shorter -> grow current (could maybe reuse otherInits extra storage?)
+ System.arraycopy(extraDefiniteInits, 0, (extraDefiniteInits = new long[otherLength]), 0, length);
+ System.arraycopy(extraPotentialInits, 0, (extraPotentialInits = new long[otherLength]), 0, length);
+ while (i < length) {
+ extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
+ }
+ while (i < otherLength) {
+ extraPotentialInits[i] = otherInits.extraPotentialInits[i++];
+ }
+ } else {
+ // current storage is longer
+ while (i < otherLength) {
+ extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
+ }
}
- while (i < otherLength) {
- extraPotentialInits[i] = otherInits.extraPotentialInits[i++];
+ }
+ } else
+ if (otherInits.extraDefiniteInits != null) {
+ // no storage here, but other has extra storage.
+ int otherLength;
+ extraDefiniteInits = new long[otherLength = otherInits.extraDefiniteInits.length];
+ System.arraycopy(otherInits.extraPotentialInits, 0, (extraPotentialInits = new long[otherLength]), 0, otherLength);
+ }
+ return this;
+ }
+
+ // Report an error if necessary
+ public boolean complainIfUnreachable(Statement statement, BlockScope scope, boolean didAlreadyComplain) {
+
+ if ((this.reachMode & UNREACHABLE) != 0) {
+ statement.bits &= ~AstNode.IsReachableMASK;
+ boolean reported = this == DEAD_END;
+ if (!didAlreadyComplain && reported) {
+ scope.problemReporter().unreachableCode(statement);
+ }
+ return reported; // keep going for fake reachable
+ }
+ return false;
+ }
+
+ /**
+ * Answers a copy of the current instance
+ */
+ public FlowInfo copy() {
+
+ // do not clone the DeadEnd
+ if (this == DEAD_END)
+ return this;
+
+ // look for an unused preallocated object
+ UnconditionalFlowInfo copy = new UnconditionalFlowInfo();
+
+ // copy slots
+ copy.definiteInits = this.definiteInits;
+ copy.potentialInits = this.potentialInits;
+ copy.reachMode = this.reachMode;
+ copy.maxFieldCount = this.maxFieldCount;
+
+ if (this.extraDefiniteInits != null) {
+ int length;
+ System.arraycopy(this.extraDefiniteInits, 0, (copy.extraDefiniteInits = new long[ (length = extraDefiniteInits.length)]), 0, length);
+ System.arraycopy(this.extraPotentialInits, 0, (copy.extraPotentialInits = new long[length]), 0, length);
+ };
+ return copy;
+ }
+
+ public UnconditionalFlowInfo discardFieldInitializations(){
+
+ int limit = this.maxFieldCount;
+
+ if (limit < BitCacheSize) {
+ long mask = (1L << limit)-1;
+ this.definiteInits &= ~mask;
+ this.potentialInits &= ~mask;
+ return this;
+ }
+
+ this.definiteInits = 0;
+ this.potentialInits = 0;
+
+ // use extra vector
+ if (extraDefiniteInits == null) {
+ return this; // if vector not yet allocated, then not initialized
+ }
+ int vectorIndex, length = this.extraDefiniteInits.length;
+ if ((vectorIndex = (limit / BitCacheSize) - 1) >= length) {
+ return this; // not enough room yet
+ }
+ for (int i = 0; i < vectorIndex; i++) {
+ this.extraDefiniteInits[i] = 0L;
+ this.extraPotentialInits[i] = 0L;
+ }
+ long mask = (1L << (limit % BitCacheSize))-1;
+ this.extraDefiniteInits[vectorIndex] &= ~mask;
+ this.extraPotentialInits[vectorIndex] &= ~mask;
+ return this;
+ }
+
+ public UnconditionalFlowInfo discardNonFieldInitializations(){
+
+ int limit = this.maxFieldCount;
+
+ if (limit < BitCacheSize) {
+ long mask = (1L << limit)-1;
+ this.definiteInits &= mask;
+ this.potentialInits &= mask;
+ return this;
+ }
+ // use extra vector
+ if (extraDefiniteInits == null) {
+ return this; // if vector not yet allocated, then not initialized
+ }
+ int vectorIndex, length = this.extraDefiniteInits.length;
+ if ((vectorIndex = (limit / BitCacheSize) - 1) >= length) {
+ return this; // not enough room yet
+ }
+ long mask = (1L << (limit % BitCacheSize))-1;
+ this.extraDefiniteInits[vectorIndex] &= mask;
+ this.extraPotentialInits[vectorIndex] &= mask;
+ for (int i = vectorIndex+1; i < length; i++) {
+ this.extraDefiniteInits[i] = 0L;
+ this.extraPotentialInits[i] = 0L;
+ }
+ return this;
+ }
+
+ public FlowInfo initsWhenFalse() {
+
+ return this;
+ }
+
+ public FlowInfo initsWhenTrue() {
+
+ return this;
+ }
+
+ /**
+ * Check status of definite assignment at a given position.
+ * It deals with the dual representation of the InitializationInfo2:
+ * bits for the first 64 entries, then an array of booleans.
+ */
+ final private boolean isDefinitelyAssigned(int position) {
+
+ // Dependant of CodeStream.isDefinitelyAssigned(..)
+ // id is zero-based
+ if (position < BitCacheSize) {
+ return (definiteInits & (1L << position)) != 0; // use bits
+ }
+ // use extra vector
+ if (extraDefiniteInits == null)
+ return false; // if vector not yet allocated, then not initialized
+ int vectorIndex;
+ if ((vectorIndex = (position / BitCacheSize) - 1) >= extraDefiniteInits.length)
+ return false; // if not enough room in vector, then not initialized
+ return ((extraDefiniteInits[vectorIndex]) & (1L << (position % BitCacheSize))) != 0;
+ }
+
+ /**
+ * Check status of definite assignment for a field.
+ */
+ final public boolean isDefinitelyAssigned(FieldBinding field) {
+
+ // Dependant of CodeStream.isDefinitelyAssigned(..)
+ // We do not want to complain in unreachable code
+ if ((this.reachMode & UNREACHABLE) != 0)
+ return true;
+ return isDefinitelyAssigned(field.id);
+ }
+
+ /**
+ * Check status of definite assignment for a local.
+ */
+ final public boolean isDefinitelyAssigned(LocalVariableBinding local) {
+
+ // Dependant of CodeStream.isDefinitelyAssigned(..)
+ // We do not want to complain in unreachable code
+ if ((this.reachMode & UNREACHABLE) != 0)
+ return true;
+ if (local.isArgument) {
+ return true;
+ }
+ // final constants are inlined, and thus considered as always initialized
+ if (local.constant != Constant.NotAConstant) {
+ return true;
+ }
+ return isDefinitelyAssigned(local.id + maxFieldCount);
+ }
+
+ public boolean isReachable() {
+
+ return this.reachMode == REACHABLE;
+ }
+
+ /**
+ * Check status of potential assignment at a given position.
+ * It deals with the dual representation of the InitializationInfo3:
+ * bits for the first 64 entries, then an array of booleans.
+ */
+ final private boolean isPotentiallyAssigned(int position) {
+
+ // id is zero-based
+ if (position < BitCacheSize) {
+ // use bits
+ return (potentialInits & (1L << position)) != 0;
+ }
+ // use extra vector
+ if (extraPotentialInits == null)
+ return false; // if vector not yet allocated, then not initialized
+ int vectorIndex;
+ if ((vectorIndex = (position / BitCacheSize) - 1) >= extraPotentialInits.length)
+ return false; // if not enough room in vector, then not initialized
+ return ((extraPotentialInits[vectorIndex]) & (1L << (position % BitCacheSize))) != 0;
+ }
+
+ /**
+ * Check status of definite assignment for a field.
+ */
+ final public boolean isPotentiallyAssigned(FieldBinding field) {
+
+ return isPotentiallyAssigned(field.id);
+ }
+
+ /**
+ * Check status of potential assignment for a local.
+ */
+ final public boolean isPotentiallyAssigned(LocalVariableBinding local) {
+
+ if (local.isArgument) {
+ return true;
+ }
+ // final constants are inlined, and thus considered as always initialized
+ if (local.constant != Constant.NotAConstant) {
+ return true;
+ }
+ return isPotentiallyAssigned(local.id + maxFieldCount);
+ }
+
+ /**
+ * Record a definite assignment at a given position.
+ * It deals with the dual representation of the InitializationInfo2:
+ * bits for the first 64 entries, then an array of booleans.
+ */
+ final private void markAsDefinitelyAssigned(int position) {
+
+ if (this != DEAD_END) {
+
+ // position is zero-based
+ if (position < BitCacheSize) {
+ // use bits
+ long mask;
+ definiteInits |= (mask = 1L << position);
+ potentialInits |= mask;
+ } else {
+ // use extra vector
+ int vectorIndex = (position / BitCacheSize) - 1;
+ if (extraDefiniteInits == null) {
+ int length;
+ extraDefiniteInits = new long[length = vectorIndex + 1];
+ extraPotentialInits = new long[length];
+ } else {
+ int oldLength; // might need to grow the arrays
+ if (vectorIndex >= (oldLength = extraDefiniteInits.length)) {
+ System.arraycopy(extraDefiniteInits, 0, (extraDefiniteInits = new long[vectorIndex + 1]), 0, oldLength);
+ System.arraycopy(extraPotentialInits, 0, (extraPotentialInits = new long[vectorIndex + 1]), 0, oldLength);
+ }
+ }
+ long mask;
+ extraDefiniteInits[vectorIndex] |= (mask = 1L << (position % BitCacheSize));
+ extraPotentialInits[vectorIndex] |= mask;
+ }
+ }
+ }
+
+ /**
+ * Record a field got definitely assigned.
+ */
+ public void markAsDefinitelyAssigned(FieldBinding field) {
+ if (this != DEAD_END)
+ markAsDefinitelyAssigned(field.id);
+ }
+
+ /**
+ * Record a local got definitely assigned.
+ */
+ public void markAsDefinitelyAssigned(LocalVariableBinding local) {
+ if (this != DEAD_END)
+ markAsDefinitelyAssigned(local.id + maxFieldCount);
+ }
+
+ /**
+ * Clear initialization information at a given position.
+ * It deals with the dual representation of the InitializationInfo2:
+ * bits for the first 64 entries, then an array of booleans.
+ */
+ final private void markAsDefinitelyNotAssigned(int position) {
+ if (this != DEAD_END) {
+
+ // position is zero-based
+ if (position < BitCacheSize) {
+ // use bits
+ long mask;
+ definiteInits &= ~(mask = 1L << position);
+ potentialInits &= ~mask;
+ } else {
+ // use extra vector
+ int vectorIndex = (position / BitCacheSize) - 1;
+ if (extraDefiniteInits == null) {
+ return; // nothing to do, it was not yet set
+ } else {
+ // might need to grow the arrays
+ if (vectorIndex >= extraDefiniteInits.length) {
+ return; // nothing to do, it was not yet set
+ }
+ }
+ long mask;
+ extraDefiniteInits[vectorIndex] &= ~(mask = 1L << (position % BitCacheSize));
+ extraPotentialInits[vectorIndex] &= ~mask;
+ }
+ }
+ }
+
+ /**
+ * Clear the initialization info for a field
+ */
+ public void markAsDefinitelyNotAssigned(FieldBinding field) {
+
+ if (this != DEAD_END)
+ markAsDefinitelyNotAssigned(field.id);
+ }
+
+ /**
+ * Clear the initialization info for a local variable
+ */
+
+ public void markAsDefinitelyNotAssigned(LocalVariableBinding local) {
+
+ if (this != DEAD_END)
+ markAsDefinitelyNotAssigned(local.id + maxFieldCount);
+ }
+
+ /**
+ * Returns the receiver updated in the following way: <ul>
+ * <li> intersection of definitely assigned variables,
+ * <li> union of potentially assigned variables.
+ * </ul>
+ */
+ public UnconditionalFlowInfo mergedWith(UnconditionalFlowInfo otherInits) {
+
+ if (this == DEAD_END) return otherInits;
+ if (otherInits == DEAD_END) return this;
+
+ if ((this.reachMode & UNREACHABLE) != (otherInits.reachMode & UNREACHABLE)){
+ if ((this.reachMode & UNREACHABLE) != 0){
+ return otherInits;
+ } else {
+ return this;
+ }
+ }
+
+ // if one branch is not fake reachable, then the merged one is reachable
+ this.reachMode &= otherInits.reachMode;
+
+ // intersection of definitely assigned variables,
+ this.definiteInits &= otherInits.definiteInits;
+ // union of potentially set ones
+ this.potentialInits |= otherInits.potentialInits;
+
+ // treating extra storage
+ if (this.extraDefiniteInits != null) {
+ if (otherInits.extraDefiniteInits != null) {
+ // both sides have extra storage
+ int i = 0, length, otherLength;
+ if ((length = this.extraDefiniteInits.length) < (otherLength = otherInits.extraDefiniteInits.length)) {
+ // current storage is shorter -> grow current (could maybe reuse otherInits extra storage?)
+ System.arraycopy(this.extraDefiniteInits, 0, (this.extraDefiniteInits = new long[otherLength]), 0, length);
+ System.arraycopy(this.extraPotentialInits, 0, (this.extraPotentialInits = new long[otherLength]), 0, length);
+ while (i < length) {
+ this.extraDefiniteInits[i] &= otherInits.extraDefiniteInits[i];
+ this.extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
+ }
+ while (i < otherLength) {
+ this.extraPotentialInits[i] = otherInits.extraPotentialInits[i++];
+ }
+ } else {
+ // current storage is longer
+ while (i < otherLength) {
+ this.extraDefiniteInits[i] &= otherInits.extraDefiniteInits[i];
+ this.extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
+ }
+ while (i < length)
+ this.extraDefiniteInits[i++] = 0;
}
} else {
- // current storage is longer
- while (i < otherLength) {
- extraDefiniteInits[i] &= otherInits.extraDefiniteInits[i];
- extraPotentialInits[i] |= otherInits.extraPotentialInits[i++];
- }
+ // no extra storage on otherInits
+ int i = 0, length = this.extraDefiniteInits.length;
while (i < length)
- extraDefiniteInits[i++] = 0;
+ this.extraDefiniteInits[i++] = 0;
}
- } else {
- // no extra storage on otherInits
- int i = 0, length = extraDefiniteInits.length;
- while (i < length)
- extraDefiniteInits[i++] = 0;
- }
- } else
- if (otherInits.extraDefiniteInits != null) {
- // no storage here, but other has extra storage.
- int otherLength;
- extraDefiniteInits = new long[otherLength = otherInits.extraDefiniteInits.length];
- System.arraycopy(otherInits.extraPotentialInits, 0, (extraPotentialInits = new long[otherLength]), 0, otherLength);
- }
- return this;
-}
-/*
- * Answer the total number of fields in enclosing types of a given type
- */
-static int numberOfEnclosingFields(ReferenceBinding type){
- int count = 0;
- type = type.enclosingType();
- while(type != null) {
- count += type.fieldCount();
+ } else
+ if (otherInits.extraDefiniteInits != null) {
+ // no storage here, but other has extra storage.
+ int otherLength;
+ this.extraDefiniteInits = new long[otherLength = otherInits.extraDefiniteInits.length];
+ System.arraycopy(otherInits.extraPotentialInits, 0, (this.extraPotentialInits = new long[otherLength]), 0, otherLength);
+ }
+ return this;
+ }
+
+ /*
+ * Answer the total number of fields in enclosing types of a given type
+ */
+ static int numberOfEnclosingFields(ReferenceBinding type){
+
+ int count = 0;
type = type.enclosingType();
+ while(type != null) {
+ count += type.fieldCount();
+ type = type.enclosingType();
+ }
+ return count;
}
- return count;
-}
-public String toString(){
- if (this == DeadEnd){
- return "FlowInfo.DeadEnd"; //$NON-NLS-1$
+
+ public int reachMode(){
+ return this.reachMode;
}
- return "FlowInfo<def: "+ definiteInits +", pot: " + potentialInits + ">"; //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$
-}
-public UnconditionalFlowInfo unconditionalInits() {
- // also see conditional inits, where it requests them to merge
- return this;
-}
+
+ public FlowInfo setReachMode(int reachMode) {
+
+ if (this == DEAD_END) return this; // cannot modify DEAD_END
+
+ // reset optional inits when becoming unreachable
+ if ((this.reachMode & UNREACHABLE) == 0 && (reachMode & UNREACHABLE) != 0) {
+ this.potentialInits = 0;
+ if (this.extraPotentialInits != null){
+ for (int i = 0, length = this.extraPotentialInits.length; i < length; i++){
+ this.extraPotentialInits[i] = 0;
+ }
+ }
+ }
+ this.reachMode = reachMode;
+
+ return this;
+ }
+
+ public String toString(){
+
+ if (this == DEAD_END){
+ return "FlowInfo.DEAD_END"; //$NON-NLS-1$
+ }
+ return "FlowInfo<def: "+ this.definiteInits //$NON-NLS-1$
+ +", pot: " + this.potentialInits //$NON-NLS-1$
+ + ", reachable:" + ((this.reachMode & UNREACHABLE) == 0) //$NON-NLS-1$
+ +">"; //$NON-NLS-1$
+ }
+
+ public UnconditionalFlowInfo unconditionalInits() {
+
+ // also see conditional inits, where it requests them to merge
+ return this;
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java
index 5eeb639..6412e0a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
public class BooleanConstant extends Constant {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java
index 94f52fe..223f6ad 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
public class ByteConstant extends Constant {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java
index 85ee12c..fdbdb93 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
public class CharConstant extends Constant {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
index c306cf8..4e3089d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
@@ -1,20 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
+import java.util.Iterator;
import java.util.Map;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
@@ -34,18 +36,29 @@
public static final String OPTION_ReportMethodWithConstructorName = "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
public static final String OPTION_ReportOverridingPackageDefaultMethod = "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
public static final String OPTION_ReportDeprecation = "org.eclipse.jdt.core.compiler.problem.deprecation"; //$NON-NLS-1$
+ public static final String OPTION_ReportDeprecationInDeprecatedCode = "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
public static final String OPTION_ReportHiddenCatchBlock = "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
public static final String OPTION_ReportUnusedLocal = "org.eclipse.jdt.core.compiler.problem.unusedLocal"; //$NON-NLS-1$
public static final String OPTION_ReportUnusedParameter = "org.eclipse.jdt.core.compiler.problem.unusedParameter"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnusedParameterWhenImplementingAbstract = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnusedParameterWhenOverridingConcrete = "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
public static final String OPTION_ReportUnusedImport = "org.eclipse.jdt.core.compiler.problem.unusedImport"; //$NON-NLS-1$
public static final String OPTION_ReportSyntheticAccessEmulation = "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
+ public static final String OPTION_ReportNoEffectAssignment = "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"; //$NON-NLS-1$
public static final String OPTION_ReportNonExternalizedStringLiteral = "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
+ public static final String OPTION_ReportIncompatibleNonInheritedInterfaceMethod = "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
+ public static final String OPTION_ReportUnusedPrivateMember = "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
+ public static final String OPTION_ReportNoImplicitStringConversion = "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
public static final String OPTION_Source = "org.eclipse.jdt.core.compiler.source"; //$NON-NLS-1$
public static final String OPTION_TargetPlatform = "org.eclipse.jdt.core.compiler.codegen.targetPlatform"; //$NON-NLS-1$
public static final String OPTION_ReportAssertIdentifier = "org.eclipse.jdt.core.compiler.problem.assertIdentifier"; //$NON-NLS-1$
public static final String OPTION_Compliance = "org.eclipse.jdt.core.compiler.compliance"; //$NON-NLS-1$
public static final String OPTION_Encoding = "org.eclipse.jdt.core.encoding"; //$NON-NLS-1$
public static final String OPTION_MaxProblemPerUnit = "org.eclipse.jdt.core.compiler.maxProblemPerUnit"; //$NON-NLS-1$
+ public static final String OPTION_ReportStaticAccessReceiver = "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
+ public static final String OPTION_TaskTags = "org.eclipse.jdt.core.compiler.taskTags"; //$NON-NLS-1$
+ public static final String OPTION_TaskPriorities = "org.eclipse.jdt.core.compiler.taskPriorities"; //$NON-NLS-1$
+
/* should surface ??? */
public static final String OPTION_PrivateConstructorAccess = "org.eclipse.jdt.core.compiler.codegen.constructorAccessEmulation"; //$NON-NLS-1$
@@ -64,6 +77,8 @@
public static final String ERROR = "error"; //$NON-NLS-1$
public static final String WARNING = "warning"; //$NON-NLS-1$
public static final String IGNORE = "ignore"; //$NON-NLS-1$
+ public static final String ENABLED = "enabled"; //$NON-NLS-1$
+ public static final String DISABLED = "disabled"; //$NON-NLS-1$
/**
* Bit mask for configurable problems (error/warning threshold)
@@ -81,13 +96,25 @@
public static final int NonExternalizedString = 0x100000;
public static final int AssertUsedAsAnIdentifier = 0x200000;
public static final int UnusedImport = 0x400000;
-
+ public static final int StaticAccessReceiver = 0x800000;
+ public static final int Task = 0x1000000;
+ public static final int NoEffectAssignment = 0x2000000;
+ public static final int IncompatibleNonInheritedInterfaceMethod = 0x4000000;
+ public static final int UnusedPrivateMember = 0x8000000;
+
// Default severity level for handlers
- public int errorThreshold = UnreachableCode | ImportProblem;
+ public int errorThreshold =
+ UnreachableCode
+ | ImportProblem;
+
public int warningThreshold =
- MethodWithConstructorName | OverriddenPackageDefaultMethod
- | UsingDeprecatedAPI | MaskedCatchBlock
- | AssertUsedAsAnIdentifier | NoImplicitStringConversion;
+ MethodWithConstructorName
+ | OverriddenPackageDefaultMethod
+ | UsingDeprecatedAPI
+ | MaskedCatchBlock
+ | AssertUsedAsAnIdentifier
+ | NoImplicitStringConversion
+ | IncompatibleNonInheritedInterfaceMethod;
// Debug attributes
public static final int Source = 1; // SourceFileAttribute
@@ -97,7 +124,6 @@
// By default only lines and source attributes are generated.
public int produceDebugAttributes = Lines | Source;
-
// JDK 1.1, 1.2, 1.3 or 1.4
public static final int JDK1_1 = 0;
public static final int JDK1_2 = 1;
@@ -110,8 +136,8 @@
// toggle private access emulation for 1.2 (constr. accessor has extra arg on constructor) or 1.3 (make private constructor default access when access needed)
public boolean isPrivateConstructorAccessChangingVisibility = false; // by default, follows 1.2
- // 1.4 feature
- public boolean assertMode = false; //1.3 behavior by default
+ // 1.4 feature (assertions are available in source 1.4 mode only)
+ public int sourceLevel = JDK1_3; //1.3 behavior by default
// source encoding format
public String defaultEncoding = null; // will use the platform default encoding
@@ -134,6 +160,19 @@
// max problems per compilation unit
public int maxProblemsPerUnit = 100; // no more than 100 problems per default
+ // tags used to recognize tasks in comments
+ public char[][] taskTags = null;
+
+ // priorities of tasks in comments
+ public char[][] taskPriorites = null;
+
+ // deprecation report
+ public boolean reportDeprecationInsideDeprecatedCode = false;
+
+ // unused parameters report
+ public boolean reportUnusedParameterWhenImplementingAbstract = false;
+ public boolean reportUnusedParameterWhenOverridingConcrete = false;
+
/**
* Initializing the compiler options with defaults
*/
@@ -148,9 +187,9 @@
if (settings == null) return;
// filter options which are related to the compiler component
- Object[] entries = settings.entrySet().toArray();
- for (int i = 0, max = entries.length; i < max; i++){
- Map.Entry entry = (Map.Entry)entries[i];
+ Iterator entries = settings.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry)entries.next();
if (!(entry.getKey() instanceof String)) continue;
if (!(entry.getValue() instanceof String)) continue;
String optionID = (String) entry.getKey();
@@ -301,6 +340,15 @@
}
continue;
}
+ // Report deprecation inside deprecated code
+ if(optionID.equals(OPTION_ReportDeprecationInDeprecatedCode)){
+ if (optionValue.equals(ENABLED)) {
+ this.reportDeprecationInsideDeprecatedCode = true;
+ } else if (optionValue.equals(DISABLED)) {
+ this.reportDeprecationInsideDeprecatedCode = false;
+ }
+ continue;
+ }
// Report hidden catch block
if(optionID.equals(OPTION_ReportHiddenCatchBlock)){
if (optionValue.equals(ERROR)) {
@@ -328,7 +376,21 @@
this.warningThreshold &= ~UnusedLocalVariable;
}
continue;
- }
+ }
+ // Report no implicit String conversion
+ if (optionID.equals(OPTION_ReportNoImplicitStringConversion)) {
+ if (optionValue.equals(ERROR)) {
+ this.errorThreshold |= NoImplicitStringConversion;
+ this.warningThreshold &= ~NoImplicitStringConversion;
+ } else if (optionValue.equals(WARNING)) {
+ this.errorThreshold &= ~NoImplicitStringConversion;
+ this.warningThreshold |= NoImplicitStringConversion;
+ } else if (optionValue.equals(IGNORE)) {
+ this.errorThreshold &= ~NoImplicitStringConversion;
+ this.warningThreshold &= ~NoImplicitStringConversion;
+ }
+ continue;
+ }
// Report unused parameter
if(optionID.equals(OPTION_ReportUnusedParameter)){
if (optionValue.equals(ERROR)) {
@@ -343,7 +405,25 @@
}
continue;
}
- // Report unused parameter
+ // Report unused parameter when implementing abstract method
+ if(optionID.equals(OPTION_ReportUnusedParameterWhenImplementingAbstract)){
+ if (optionValue.equals(ENABLED)) {
+ this.reportUnusedParameterWhenImplementingAbstract = true;
+ } else if (optionValue.equals(DISABLED)) {
+ this.reportUnusedParameterWhenImplementingAbstract = false;
+ }
+ continue;
+ }
+ // Report unused parameter when implementing abstract method
+ if(optionID.equals(OPTION_ReportUnusedParameterWhenOverridingConcrete)){
+ if (optionValue.equals(ENABLED)) {
+ this.reportUnusedParameterWhenOverridingConcrete = true;
+ } else if (optionValue.equals(DISABLED)) {
+ this.reportUnusedParameterWhenOverridingConcrete = false;
+ }
+ continue;
+ }
+ // Report unused import
if(optionID.equals(OPTION_ReportUnusedImport)){
if (optionValue.equals(ERROR)) {
this.errorThreshold |= UnusedImport;
@@ -402,9 +482,9 @@
// Set the source compatibility mode (assertions)
if(optionID.equals(OPTION_Source)){
if (optionValue.equals(VERSION_1_3)) {
- this.assertMode = false;
+ this.sourceLevel = JDK1_3;
} else if (optionValue.equals(VERSION_1_4)) {
- this.assertMode = true;
+ this.sourceLevel = JDK1_4;
}
continue;
}
@@ -430,17 +510,86 @@
}
continue;
}
+ // Report unnecessary receiver for static access
+ if(optionID.equals(OPTION_ReportStaticAccessReceiver)){
+ if (optionValue.equals(ERROR)) {
+ this.errorThreshold |= StaticAccessReceiver;
+ this.warningThreshold &= ~StaticAccessReceiver;
+ } else if (optionValue.equals(WARNING)) {
+ this.errorThreshold &= ~StaticAccessReceiver;
+ this.warningThreshold |= StaticAccessReceiver;
+ } else if (optionValue.equals(IGNORE)) {
+ this.errorThreshold &= ~StaticAccessReceiver;
+ this.warningThreshold &= ~StaticAccessReceiver;
+ }
+ continue;
+ }
+ // Report interface method incompatible with non-inherited Object method
+ if(optionID.equals(OPTION_ReportIncompatibleNonInheritedInterfaceMethod)){
+ if (optionValue.equals(ERROR)) {
+ this.errorThreshold |= IncompatibleNonInheritedInterfaceMethod;
+ this.warningThreshold &= ~IncompatibleNonInheritedInterfaceMethod;
+ } else if (optionValue.equals(WARNING)) {
+ this.errorThreshold &= ~IncompatibleNonInheritedInterfaceMethod;
+ this.warningThreshold |= IncompatibleNonInheritedInterfaceMethod;
+ } else if (optionValue.equals(IGNORE)) {
+ this.errorThreshold &= ~IncompatibleNonInheritedInterfaceMethod;
+ this.warningThreshold &= ~IncompatibleNonInheritedInterfaceMethod;
+ }
+ continue;
+ }
+ // Report unused private members
+ if(optionID.equals(OPTION_ReportUnusedPrivateMember)){
+ if (optionValue.equals(ERROR)) {
+ this.errorThreshold |= UnusedPrivateMember;
+ this.warningThreshold &= ~UnusedPrivateMember;
+ } else if (optionValue.equals(WARNING)) {
+ this.errorThreshold &= ~UnusedPrivateMember;
+ this.warningThreshold |= UnusedPrivateMember;
+ } else if (optionValue.equals(IGNORE)) {
+ this.errorThreshold &= ~UnusedPrivateMember;
+ this.warningThreshold &= ~UnusedPrivateMember;
+ }
+ continue;
+ }
+ // Report task
+ if(optionID.equals(OPTION_TaskTags)){
+ if (optionValue.length() == 0) {
+ this.taskTags = null;
+ } else {
+ this.taskTags = CharOperation.splitAndTrimOn(',', optionValue.toCharArray());
+ }
+ continue;
+ }
+ // Report no-op assignments
+ if(optionID.equals(OPTION_ReportNoEffectAssignment)){
+ if (optionValue.equals(ERROR)) {
+ this.errorThreshold |= NoEffectAssignment;
+ this.warningThreshold &= ~NoEffectAssignment;
+ } else if (optionValue.equals(WARNING)) {
+ this.errorThreshold &= ~NoEffectAssignment;
+ this.warningThreshold |= NoEffectAssignment;
+ } else if (optionValue.equals(IGNORE)) {
+ this.errorThreshold &= ~NoEffectAssignment;
+ this.warningThreshold &= ~NoEffectAssignment;
+ }
+ continue;
+ }
+ if(optionID.equals(OPTION_TaskPriorities)){
+ if (optionValue.length() == 0) {
+ this.taskPriorites = null;
+ } else {
+ this.taskPriorites = CharOperation.splitAndTrimOn(',', optionValue.toCharArray());
+ }
+ continue;
+ }
}
}
- public int getTargetJDK() {
- return this.targetJDK;
- }
-
- public int getNonExternalizedStringLiteralSeverity() {
- if((warningThreshold & NonExternalizedString) != 0)
+ public int getSeverity(int irritant) {
+ if((warningThreshold & irritant) != 0)
return Warning;
- if((errorThreshold & NonExternalizedString) != 0)
+ if((errorThreshold & irritant) != 0)
return Error;
return Ignore;
}
@@ -567,7 +716,15 @@
buf.append("\n-synthetic access emulation: IGNORE"); //$NON-NLS-1$
}
}
- if ((errorThreshold & NonExternalizedString) != 0){
+ if ((errorThreshold & NoEffectAssignment) != 0){
+ buf.append("\n-assignment with no effect: ERROR"); //$NON-NLS-1$
+ } else {
+ if ((warningThreshold & NoEffectAssignment) != 0){
+ buf.append("\n-assignment with no effect: WARNING"); //$NON-NLS-1$
+ } else {
+ buf.append("\n-assignment with no effect: IGNORE"); //$NON-NLS-1$
+ }
+ } if ((errorThreshold & NonExternalizedString) != 0){
buf.append("\n-non externalized string: ERROR"); //$NON-NLS-1$
} else {
if ((warningThreshold & NonExternalizedString) != 0){
@@ -576,6 +733,33 @@
buf.append("\n-non externalized string: IGNORE"); //$NON-NLS-1$
}
}
+ if ((errorThreshold & StaticAccessReceiver) != 0){
+ buf.append("\n-static access receiver: ERROR"); //$NON-NLS-1$
+ } else {
+ if ((warningThreshold & StaticAccessReceiver) != 0){
+ buf.append("\n-static access receiver: WARNING"); //$NON-NLS-1$
+ } else {
+ buf.append("\n-static access receiver: IGNORE"); //$NON-NLS-1$
+ }
+ }
+ if ((errorThreshold & IncompatibleNonInheritedInterfaceMethod) != 0){
+ buf.append("\n-incompatible non inherited interface method: ERROR"); //$NON-NLS-1$
+ } else {
+ if ((warningThreshold & IncompatibleNonInheritedInterfaceMethod) != 0){
+ buf.append("\n-incompatible non inherited interface method: WARNING"); //$NON-NLS-1$
+ } else {
+ buf.append("\n-incompatible non inherited interface method: IGNORE"); //$NON-NLS-1$
+ }
+ }
+ if ((errorThreshold & UnusedPrivateMember) != 0){
+ buf.append("\n-unused private member: ERROR"); //$NON-NLS-1$
+ } else {
+ if ((warningThreshold & UnusedPrivateMember) != 0){
+ buf.append("\n-unused private member: WARNING"); //$NON-NLS-1$
+ } else {
+ buf.append("\n-unused private member: IGNORE"); //$NON-NLS-1$
+ }
+ }
switch(targetJDK){
case JDK1_1 :
buf.append("\n-target JDK: 1.1"); //$NON-NLS-1$
@@ -614,6 +798,11 @@
buf.append("\n-parse literal expressions as constants : " + (parseLiteralExpressionsAsConstants ? "ON" : "OFF")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
buf.append("\n-runtime exception name for compile error : " + runtimeExceptionNameForCompileError); //$NON-NLS-1$
buf.append("\n-encoding : " + (defaultEncoding == null ? "<default>" : defaultEncoding)); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("\n-task tags: " + (this.taskTags == null ? "" : new String(CharOperation.concatWith(this.taskTags,',')))); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("\n-task priorities : " + (this.taskPriorites == null ? "" : new String(CharOperation.concatWith(this.taskPriorites,',')))); //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("\n-report deprecation inside deprecated code : " + (reportDeprecationInsideDeprecatedCode ? "ENABLED" : "DISABLED")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n-report unused parameter when implementing abstract method : " + (reportUnusedParameterWhenImplementingAbstract ? "ENABLED" : "DISABLED")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ buf.append("\n-report unused parameter when overriding concrete method : " + (reportUnusedParameterWhenOverridingConcrete ? "ENABLED" : "DISABLED")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return buf.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
index 65886b3..c946b78 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
import org.eclipse.jdt.internal.compiler.ast.OperatorIds;
@@ -16,1477 +16,1596 @@
import org.eclipse.jdt.internal.compiler.util.Util;
public abstract class Constant implements TypeIds, OperatorIds {
+
public static final Constant NotAConstant = new DoubleConstant(Double.NaN);
public static final IntConstant Zero = new IntConstant(0);
public static final IntConstant Two = new IntConstant(2);
public static final IntConstant One = new IntConstant(1);
-public boolean booleanValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"boolean")); //$NON-NLS-1$ //$NON-NLS-2$
-}
-public byte byteValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"byte")); //$NON-NLS-1$ //$NON-NLS-2$
-}
-public final Constant castTo(int conversionToTargetType){
- //the cast is an int of the form
- // (castId<<4)+typeId (in order to follow the
- //user written style (cast)expression ....
- //This method assumes that the TC is done (correctly :-)
-
- if (this == NotAConstant) return NotAConstant ;
- switch(conversionToTargetType){
- case T_undefined : return this;
-// case (T_undefined<<4)+T_undefined : return NotAConstant ;
-// case (T_undefined<<4)+T_byte : return NotAConstant ;
-// case (T_undefined<<4)+T_long : return NotAConstant ;
-// case (T_undefined<<4)+T_short : return NotAConstant ;
-// case (T_undefined<<4)+T_void : return NotAConstant ;
-// case (T_undefined<<4)+T_String : return NotAConstant ;
-// case (T_undefined<<4)+T_Object : return NotAConstant ;
-// case (T_undefined<<4)+T_double : return NotAConstant ;
-// case (T_undefined<<4)+T_float : return NotAConstant ;
-// case (T_undefined<<4)+T_boolean : return NotAConstant ;
-// case (T_undefined<<4)+T_char : return NotAConstant ;
-// case (T_undefined<<4)+T_int : return NotAConstant ;
-// case (T_undefined<<4)+T_null : return NotAConstant ;
-// case (T_byte<<4)+T_undefined : return NotAConstant ;
- case (T_byte<<4)+T_byte : return this ;
- case (T_byte<<4)+T_long : return Constant.fromValue((byte)this.longValue()) ;
- case (T_byte<<4)+T_short : return Constant.fromValue((byte)this.shortValue());
-// case (T_byte<<4)+T_void : return NotAConstant ;
-// case (T_byte<<4)+T_String : return NotAConstant ;
-// case (T_byte<<4)+T_Object : return NotAConstant ;
- case (T_byte<<4)+T_double : return Constant.fromValue((byte)this.doubleValue());
- case (T_byte<<4)+T_float : return Constant.fromValue((byte)this.floatValue());
-// case (T_byte<<4)+T_boolean : return NotAConstant ;
- case (T_byte<<4)+T_char : return Constant.fromValue((byte)this.charValue());
- case (T_byte<<4)+T_int : return Constant.fromValue((byte)this.intValue());
-// case (T_byte<<4)+T_null : return NotAConstant ;
+ public boolean booleanValue() {
-// case (T_long<<4)+T_undefined : return NotAConstant ;
- case (T_long<<4)+T_byte : return Constant.fromValue((long)this.byteValue());
- case (T_long<<4)+T_long : return this ;
- case (T_long<<4)+T_short : return Constant.fromValue((long)this.shortValue());
-// case (T_long<<4)+T_void : return NotAConstant ;
-// case (T_long<<4)+T_String : return NotAConstant ;
-// case (T_long<<4)+T_Object : return NotAConstant ;
- case (T_long<<4)+T_double : return Constant.fromValue((long)this.doubleValue());
- case (T_long<<4)+T_float : return Constant.fromValue((long)this.floatValue());
-// case (T_long<<4)+T_boolean : return NotAConstant ;
- case (T_long<<4)+T_char : return Constant.fromValue((long)this.charValue());
- case (T_long<<4)+T_int : return Constant.fromValue((long)this.intValue());
-// case (T_long<<4)+T_null : return NotAConstant ;
-
-// case (T_short<<4)+T_undefined : return NotAConstant ;
- case (T_short<<4)+T_byte : return Constant.fromValue((short)this.byteValue());
- case (T_short<<4)+T_long : return Constant.fromValue((short)this.longValue());
- case (T_short<<4)+T_short : return this ;
-// case (T_short<<4)+T_void : return NotAConstant ;
-// case (T_short<<4)+T_String : return NotAConstant ;
-// case (T_short<<4)+T_Object : return NotAConstant ;
- case (T_short<<4)+T_double : return Constant.fromValue((short)this.doubleValue()) ;
- case (T_short<<4)+T_float : return Constant.fromValue((short)this.floatValue()) ;
-// case (T_short<<4)+T_boolean : return NotAConstant ;
- case (T_short<<4)+T_char : return Constant.fromValue((short)this.charValue()) ;
- case (T_short<<4)+T_int : return Constant.fromValue((short)this.intValue()) ;
-// case (T_short<<4)+T_null : return NotAConstant ;
-
-// case (T_void<<4)+T_undefined : return NotAConstant ;
-// case (T_void<<4)+T_byte : return NotAConstant ;
-// case (T_void<<4)+T_long : return NotAConstant ;
-// case (T_void<<4)+T_short : return NotAConstant ;
-// case (T_void<<4)+T_void : return NotAConstant ;
-// case (T_void<<4)+T_String : return NotAConstant ;
-// case (T_void<<4)+T_Object : return NotAConstant ;
-// case (T_void<<4)+T_double : return NotAConstant ;
-// case (T_void<<4)+T_float : return NotAConstant ;
-// case (T_void<<4)+T_boolean : return NotAConstant ;
-// case (T_void<<4)+T_char : return NotAConstant ;
-// case (T_void<<4)+T_int : return NotAConstant ;
-// case (T_void<<4)+T_null : return NotAConstant ;
-
-// case (T_String<<4)+T_undefined : return NotAConstant ;
-// case (T_String<<4)+T_byte : return NotAConstant ;
-// case (T_String<<4)+T_long : return NotAConstant ;
-// case (T_String<<4)+T_short : return NotAConstant ;
-// case (T_String<<4)+T_void : return NotAConstant ;
- case (T_String<<4)+T_String : return this ;
-// case (T_String<<4)+T_Object : return NotAConstant ;
-// case (T_String<<4)+T_double : return NotAConstant ;
-// case (T_String<<4)+T_float : return NotAConstant ;
-// case (T_String<<4)+T_boolean : return NotAConstant ;
-// case (T_String<<4)+T_char : return NotAConstant ;
-// case (T_String<<4)+T_int : return NotAConstant ;
-// case (T_String<<4)+T_null : return NotAConstant ;
-
-// case (T_Object<<4)+T_undefined : return NotAConstant ;
-// case (T_Object<<4)+T_byte : return NotAConstant ;
-// case (T_Object<<4)+T_long : return NotAConstant ;
-// case (T_Object<<4)+T_short : return NotAConstant ;
-// case (T_Object<<4)+T_void : return NotAConstant ;
-// case (T_Object<<4)+T_String : return NotAConstant ;
-// case (T_Object<<4)+T_Object : return NotAConstant ;
-// case (T_Object<<4)+T_double : return NotAConstant ;
-// case (T_Object<<4)+T_float : return NotAConstant ;
-// case (T_Object<<4)+T_boolean : return NotAConstant ;
-// case (T_Object<<4)+T_char : return NotAConstant ;
-// case (T_Object<<4)+T_int : return NotAConstant ;
- case (T_Object<<4)+T_null : return this ;
-
-// case (T_double<<4)+T_undefined : return NotAConstant ;
- case (T_double<<4)+T_byte : return Constant.fromValue((double)this.byteValue()) ;
- case (T_double<<4)+T_long : return Constant.fromValue((double)this.longValue()) ;
- case (T_double<<4)+T_short : return Constant.fromValue((double)this.shortValue()) ;
-// case (T_double<<4)+T_void : return NotAConstant ;
-// case (T_double<<4)+T_String : return NotAConstant ;
-// case (T_double<<4)+T_Object : return NotAConstant ;
- case (T_double<<4)+T_double : return this ;
- case (T_double<<4)+T_float : return Constant.fromValue((double)this.floatValue()) ;
-// case (T_double<<4)+T_boolean : return NotAConstant ;
- case (T_double<<4)+T_char : return Constant.fromValue((double)this.charValue()) ;
- case (T_double<<4)+T_int : return Constant.fromValue((double)this.intValue());
-// case (T_double<<4)+T_null : return NotAConstant ;
-
-// case (T_float<<4)+T_undefined : return NotAConstant ;
- case (T_float<<4)+T_byte : return Constant.fromValue((float)this.byteValue()) ;
- case (T_float<<4)+T_long : return Constant.fromValue((float)this.longValue()) ;
- case (T_float<<4)+T_short : return Constant.fromValue((float)this.shortValue()) ;
-// case (T_float<<4)+T_void : return NotAConstant ;
-// case (T_float<<4)+T_String : return NotAConstant ;
-// case (T_float<<4)+T_Object : return NotAConstant ;
- case (T_float<<4)+T_double : return Constant.fromValue((float)this.doubleValue()) ;
- case (T_float<<4)+T_float : return this ;
-// case (T_float<<4)+T_boolean : return NotAConstant ;
- case (T_float<<4)+T_char : return Constant.fromValue((float)this.charValue()) ;
- case (T_float<<4)+T_int : return Constant.fromValue((float)this.intValue()) ;
-// case (T_float<<4)+T_null : return NotAConstant ;
-
-// case (T_boolean<<4)+T_undefined : return NotAConstant ;
-// case (T_boolean<<4)+T_byte : return NotAConstant ;
-// case (T_boolean<<4)+T_long : return NotAConstant ;
-// case (T_boolean<<4)+T_short : return NotAConstant ;
-// case (T_boolean<<4)+T_void : return NotAConstant ;
-// case (T_boolean<<4)+T_String : return NotAConstant ;
-// case (T_boolean<<4)+T_Object : return NotAConstant ;
-// case (T_boolean<<4)+T_double : return NotAConstant ;
-// case (T_boolean<<4)+T_float : return NotAConstant ;
- case (T_boolean<<4)+T_boolean : return this ;
-// case (T_boolean<<4)+T_char : return NotAConstant ;
-// case (T_boolean<<4)+T_int : return NotAConstant ;
-// case (T_boolean<<4)+T_null : return NotAConstant ;
-
-// case (T_char<<4)+T_undefined : return NotAConstant ;
- case (T_char<<4)+T_byte : return Constant.fromValue((char)this.byteValue()) ;
- case (T_char<<4)+T_long : return Constant.fromValue((char)this.longValue()) ;
- case (T_char<<4)+T_short : return Constant.fromValue((char)this.shortValue()) ;
-// case (T_char<<4)+T_void : return NotAConstant ;
-// case (T_char<<4)+T_String : return NotAConstant ;
-// case (T_char<<4)+T_Object : return NotAConstant ;
- case (T_char<<4)+T_double : return Constant.fromValue((char)this.doubleValue()) ;
- case (T_char<<4)+T_float : return Constant.fromValue((char)this.floatValue()) ;
-// case (T_char<<4)+T_boolean : return NotAConstant ;
- case (T_char<<4)+T_char : return this ;
- case (T_char<<4)+T_int : return Constant.fromValue((char)this.intValue()) ;
-// case (T_char<<4)+T_null : return NotAConstant ;
-
-// case (T_int<<4)+T_undefined : return NotAConstant ;
- case (T_int<<4)+T_byte : return Constant.fromValue((int)this.byteValue()) ;
- case (T_int<<4)+T_long : return Constant.fromValue((int)this.longValue()) ;
- case (T_int<<4)+T_short : return Constant.fromValue((int)this.shortValue()) ;
-// case (T_int<<4)+T_void : return NotAConstant ;
-// case (T_int<<4)+T_String : return NotAConstant ;
-// case (T_int<<4)+T_Object : return NotAConstant ;
- case (T_int<<4)+T_double : return Constant.fromValue((int)this.doubleValue()) ;
- case (T_int<<4)+T_float : return Constant.fromValue((int)this.floatValue()) ;
-// case (T_int<<4)+T_boolean : return NotAConstant ;
- case (T_int<<4)+T_char : return Constant.fromValue((int)this.charValue()) ;
- case (T_int<<4)+T_int : return this ;
-// case (T_int<<4)+T_null : return NotAConstant ;
-
-// case (T_null<<4)+T_undefined : return NotAConstant ;
-// case (T_null<<4)+T_byte : return NotAConstant ;
-// case (T_null<<4)+T_long : return NotAConstant ;
-// case (T_null<<4)+T_short : return NotAConstant ;
-// case (T_null<<4)+T_void : return NotAConstant ;
-// case (T_null<<4)+T_String : return NotAConstant ;
-// case (T_null<<4)+T_Object : return NotAConstant ;
-// case (T_null<<4)+T_double : return NotAConstant ;
-// case (T_null<<4)+T_float : return NotAConstant ;
-// case (T_null<<4)+T_boolean : return NotAConstant ;
-// case (T_null<<4)+T_char : return NotAConstant ;
-// case (T_null<<4)+T_int : return NotAConstant ;
- case (T_null<<4)+T_null : return this ;
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"boolean")); //$NON-NLS-1$ //$NON-NLS-2$
}
+ public byte byteValue() {
+
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"byte")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public final Constant castTo(int conversionToTargetType){
+ //the cast is an int of the form
+ // (castId<<4)+typeId (in order to follow the
+ //user written style (cast)expression ....
-
- return NotAConstant ;
-}
-public char charValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"char")); //$NON-NLS-1$ //$NON-NLS-2$
-}
-public static final Constant computeConstantOperation(Constant cst, int id, int operator) {
- //this method assumes that the TC has been done .
- //the result should be availbale with not runtime error
-
- switch (operator) {
- case NOT :
- return Constant.fromValue(!cst.booleanValue());
- case PLUS : return cst ;
- case MINUS : //the two special -9223372036854775808L and -2147483648 are inlined at parseTime
- switch (id){
- case T_float : float f ;
- if ( (f= cst.floatValue()) == 0.0f)
- { //positive and negative 0....
- if (Float.floatToIntBits(f) == 0)
- return Constant.fromValue(-0.0f);
- else
- return Constant.fromValue(0.0f);}
- break; //default case
- case T_double : double d ;
- if ( (d= cst.doubleValue()) == 0.0d)
- { //positive and negative 0....
- if (Double.doubleToLongBits(d) == 0)
- return Constant.fromValue(-0.0d);
- else
- return Constant.fromValue(0.0d);}
- break; //default case
- }
- return computeConstantOperationMINUS(Zero,T_int,operator,cst,id);
- case TWIDDLE:
- switch (id){
- case T_char : return Constant.fromValue(~ cst.charValue()) ;
- case T_byte: return Constant.fromValue(~ cst.byteValue()) ;
- case T_short: return Constant.fromValue(~ cst.shortValue()) ;
- case T_int: return Constant.fromValue(~ cst.intValue()) ;
- case T_long: return Constant.fromValue(~ cst.longValue()) ;
- default : return NotAConstant;} //should not occur.....(conservative code)
- default : return NotAConstant ;}} //should not occur....(conservative code)
-public static final Constant computeConstantOperation(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done . So (except for divide by zero)
- //the result should be availbale with not runtime error
-
- switch (operator) {
- case AND : return computeConstantOperationAND (left,leftId,operator,right,rightId) ;
- case AND_AND : return computeConstantOperationAND_AND (left,leftId,operator,right,rightId) ;
- case DIVIDE : return computeConstantOperationDIVIDE (left,leftId,operator,right,rightId) ;
- case GREATER : return computeConstantOperationGREATER (left,leftId,operator,right,rightId) ;
- case GREATER_EQUAL : return computeConstantOperationGREATER_EQUAL(left,leftId,operator,right,rightId) ;
- case LEFT_SHIFT : return computeConstantOperationLEFT_SHIFT (left,leftId,operator,right,rightId) ;
- case LESS : return computeConstantOperationLESS (left,leftId,operator,right,rightId) ;
- case LESS_EQUAL : return computeConstantOperationLESS_EQUAL (left,leftId,operator,right,rightId) ;
- case MINUS : return computeConstantOperationMINUS (left,leftId,operator,right,rightId) ;
- case MULTIPLY : return computeConstantOperationMULTIPLY (left,leftId,operator,right,rightId) ;
- case OR : return computeConstantOperationOR (left,leftId,operator,right,rightId) ;
- case OR_OR : return computeConstantOperationOR_OR (left,leftId,operator,right,rightId) ;
- case PLUS : return computeConstantOperationPLUS (left,leftId,operator,right,rightId) ;
- case REMAINDER : return computeConstantOperationREMAINDER (left,leftId,operator,right,rightId) ;
- case RIGHT_SHIFT: return computeConstantOperationRIGHT_SHIFT(left,leftId,operator,right,rightId) ;
- case UNSIGNED_RIGHT_SHIFT: return computeConstantOperationUNSIGNED_RIGHT_SHIFT(left,leftId,operator,right,rightId) ;
- case XOR : return computeConstantOperationXOR (left,leftId,operator,right,rightId) ;
-
- default : return NotAConstant ;}} //should not occurs....(conservative code)
-public static final Constant computeConstantOperationAND(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
+ if (this == NotAConstant) return NotAConstant;
+ switch(conversionToTargetType){
+ case T_undefined : return this;
+ // TARGET TYPE <- FROM TYPE
+ // case (T_undefined<<4)+T_undefined : return NotAConstant;
+ // case (T_undefined<<4)+T_byte : return NotAConstant;
+ // case (T_undefined<<4)+T_long : return NotAConstant;
+ // case (T_undefined<<4)+T_short : return NotAConstant;
+ // case (T_undefined<<4)+T_void : return NotAConstant;
+ // case (T_undefined<<4)+T_String : return NotAConstant;
+ // case (T_undefined<<4)+T_Object : return NotAConstant;
+ // case (T_undefined<<4)+T_double : return NotAConstant;
+ // case (T_undefined<<4)+T_float : return NotAConstant;
+ // case (T_undefined<<4)+T_boolean : return NotAConstant;
+ // case (T_undefined<<4)+T_char : return NotAConstant;
+ // case (T_undefined<<4)+T_int : return NotAConstant;
+
+ // case (T_byte<<4)+T_undefined : return NotAConstant;
+ case (T_byte<<4)+T_byte : return this;
+ case (T_byte<<4)+T_long : return Constant.fromValue((byte)this.longValue());
+ case (T_byte<<4)+T_short : return Constant.fromValue((byte)this.shortValue());
+ // case (T_byte<<4)+T_void : return NotAConstant;
+ // case (T_byte<<4)+T_String : return NotAConstant;
+ // case (T_byte<<4)+T_Object : return NotAConstant;
+ case (T_byte<<4)+T_double : return Constant.fromValue((byte)this.doubleValue());
+ case (T_byte<<4)+T_float : return Constant.fromValue((byte)this.floatValue());
+ // case (T_byte<<4)+T_boolean : return NotAConstant;
+ case (T_byte<<4)+T_char : return Constant.fromValue((byte)this.charValue());
+ case (T_byte<<4)+T_int : return Constant.fromValue((byte)this.intValue());
- switch (leftId){
- case T_boolean : return Constant.fromValue(left.booleanValue() & right.booleanValue()) ;
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() & right.charValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() & right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() & right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() & right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() & right.longValue()) ;}
- break ;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() & right.charValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() & right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() & right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() & right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() & right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() & right.charValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() & right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() & right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() & right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() & right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() & right.charValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() & right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() & right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() & right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() & right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() & right.charValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() & right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() & right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() & right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() & right.longValue()) ;}
-
+ // case (T_long<<4)+T_undefined : return NotAConstant;
+ case (T_long<<4)+T_byte : return Constant.fromValue((long)this.byteValue());
+ case (T_long<<4)+T_long : return this;
+ case (T_long<<4)+T_short : return Constant.fromValue((long)this.shortValue());
+ // case (T_long<<4)+T_void : return NotAConstant;
+ // case (T_long<<4)+T_String : return NotAConstant;
+ // case (T_long<<4)+T_Object : return NotAConstant;
+ case (T_long<<4)+T_double : return Constant.fromValue((long)this.doubleValue());
+ case (T_long<<4)+T_float : return Constant.fromValue((long)this.floatValue());
+ // case (T_long<<4)+T_boolean : return NotAConstant;
+ case (T_long<<4)+T_char : return Constant.fromValue((long)this.charValue());
+ case (T_long<<4)+T_int : return Constant.fromValue((long)this.intValue());
+
+ // case (T_short<<4)+T_undefined : return NotAConstant;
+ case (T_short<<4)+T_byte : return Constant.fromValue((short)this.byteValue());
+ case (T_short<<4)+T_long : return Constant.fromValue((short)this.longValue());
+ case (T_short<<4)+T_short : return this;
+ // case (T_short<<4)+T_void : return NotAConstant;
+ // case (T_short<<4)+T_String : return NotAConstant;
+ // case (T_short<<4)+T_Object : return NotAConstant;
+ case (T_short<<4)+T_double : return Constant.fromValue((short)this.doubleValue());
+ case (T_short<<4)+T_float : return Constant.fromValue((short)this.floatValue());
+ // case (T_short<<4)+T_boolean : return NotAConstant;
+ case (T_short<<4)+T_char : return Constant.fromValue((short)this.charValue());
+ case (T_short<<4)+T_int : return Constant.fromValue((short)this.intValue());
+
+ // case (T_void<<4)+T_undefined : return NotAConstant;
+ // case (T_void<<4)+T_byte : return NotAConstant;
+ // case (T_void<<4)+T_long : return NotAConstant;
+ // case (T_void<<4)+T_short : return NotAConstant;
+ // case (T_void<<4)+T_void : return NotAConstant;
+ // case (T_void<<4)+T_String : return NotAConstant;
+ // case (T_void<<4)+T_Object : return NotAConstant;
+ // case (T_void<<4)+T_double : return NotAConstant;
+ // case (T_void<<4)+T_float : return NotAConstant;
+ // case (T_void<<4)+T_boolean : return NotAConstant;
+ // case (T_void<<4)+T_char : return NotAConstant;
+ // case (T_void<<4)+T_int : return NotAConstant;
+
+ // case (T_String<<4)+T_undefined : return NotAConstant;
+ // case (T_String<<4)+T_byte : return NotAConstant;
+ // case (T_String<<4)+T_long : return NotAConstant;
+ // case (T_String<<4)+T_short : return NotAConstant;
+ // case (T_String<<4)+T_void : return NotAConstant;
+ case (T_String<<4)+T_String : return this;
+ // case (T_String<<4)+T_Object : return NotAConstant;
+ // case (T_String<<4)+T_double : return NotAConstant;
+ // case (T_String<<4)+T_float : return NotAConstant;
+ // case (T_String<<4)+T_boolean : return NotAConstant;
+ // case (T_String<<4)+T_char : return NotAConstant;
+ // case (T_String<<4)+T_int : return NotAConstant;
+
+ // case (T_Object<<4)+T_undefined : return NotAConstant;
+ // case (T_Object<<4)+T_byte : return NotAConstant;
+ // case (T_Object<<4)+T_long : return NotAConstant;
+ // case (T_Object<<4)+T_short : return NotAConstant;
+ // case (T_Object<<4)+T_void : return NotAConstant;
+ // case (T_Object<<4)+T_String : return NotAConstant;
+ // case (T_Object<<4)+T_Object : return NotAConstant;
+ // case (T_Object<<4)+T_double : return NotAConstant;
+ // case (T_Object<<4)+T_float : return NotAConstant;
+ // case (T_Object<<4)+T_boolean : return NotAConstant;
+ // case (T_Object<<4)+T_char : return NotAConstant;
+ // case (T_Object<<4)+T_int : return NotAConstant;
+
+ // case (T_double<<4)+T_undefined : return NotAConstant;
+ case (T_double<<4)+T_byte : return Constant.fromValue((double)this.byteValue());
+ case (T_double<<4)+T_long : return Constant.fromValue((double)this.longValue());
+ case (T_double<<4)+T_short : return Constant.fromValue((double)this.shortValue());
+ // case (T_double<<4)+T_void : return NotAConstant;
+ // case (T_double<<4)+T_String : return NotAConstant;
+ // case (T_double<<4)+T_Object : return NotAConstant;
+ case (T_double<<4)+T_double : return this;
+ case (T_double<<4)+T_float : return Constant.fromValue((double)this.floatValue());
+ // case (T_double<<4)+T_boolean : return NotAConstant;
+ case (T_double<<4)+T_char : return Constant.fromValue((double)this.charValue());
+ case (T_double<<4)+T_int : return Constant.fromValue((double)this.intValue());
+
+ // case (T_float<<4)+T_undefined : return NotAConstant;
+ case (T_float<<4)+T_byte : return Constant.fromValue((float)this.byteValue());
+ case (T_float<<4)+T_long : return Constant.fromValue((float)this.longValue());
+ case (T_float<<4)+T_short : return Constant.fromValue((float)this.shortValue());
+ // case (T_float<<4)+T_void : return NotAConstant;
+ // case (T_float<<4)+T_String : return NotAConstant;
+ // case (T_float<<4)+T_Object : return NotAConstant;
+ case (T_float<<4)+T_double : return Constant.fromValue((float)this.doubleValue());
+ case (T_float<<4)+T_float : return this;
+ // case (T_float<<4)+T_boolean : return NotAConstant;
+ case (T_float<<4)+T_char : return Constant.fromValue((float)this.charValue());
+ case (T_float<<4)+T_int : return Constant.fromValue((float)this.intValue());
+
+ // case (T_boolean<<4)+T_undefined : return NotAConstant;
+ // case (T_boolean<<4)+T_byte : return NotAConstant;
+ // case (T_boolean<<4)+T_long : return NotAConstant;
+ // case (T_boolean<<4)+T_short : return NotAConstant;
+ // case (T_boolean<<4)+T_void : return NotAConstant;
+ // case (T_boolean<<4)+T_String : return NotAConstant;
+ // case (T_boolean<<4)+T_Object : return NotAConstant;
+ // case (T_boolean<<4)+T_double : return NotAConstant;
+ // case (T_boolean<<4)+T_float : return NotAConstant;
+ case (T_boolean<<4)+T_boolean : return this;
+ // case (T_boolean<<4)+T_char : return NotAConstant;
+ // case (T_boolean<<4)+T_int : return NotAConstant;
+
+ // case (T_char<<4)+T_undefined : return NotAConstant;
+ case (T_char<<4)+T_byte : return Constant.fromValue((char)this.byteValue());
+ case (T_char<<4)+T_long : return Constant.fromValue((char)this.longValue());
+ case (T_char<<4)+T_short : return Constant.fromValue((char)this.shortValue());
+ // case (T_char<<4)+T_void : return NotAConstant;
+ // case (T_char<<4)+T_String : return NotAConstant;
+ // case (T_char<<4)+T_Object : return NotAConstant;
+ case (T_char<<4)+T_double : return Constant.fromValue((char)this.doubleValue());
+ case (T_char<<4)+T_float : return Constant.fromValue((char)this.floatValue());
+ // case (T_char<<4)+T_boolean : return NotAConstant;
+ case (T_char<<4)+T_char : return this;
+ case (T_char<<4)+T_int : return Constant.fromValue((char)this.intValue());
+
+ // case (T_int<<4)+T_undefined : return NotAConstant;
+ case (T_int<<4)+T_byte : return Constant.fromValue((int)this.byteValue());
+ case (T_int<<4)+T_long : return Constant.fromValue((int)this.longValue());
+ case (T_int<<4)+T_short : return Constant.fromValue((int)this.shortValue());
+ // case (T_int<<4)+T_void : return NotAConstant;
+ // case (T_int<<4)+T_String : return NotAConstant;
+ // case (T_int<<4)+T_Object : return NotAConstant;
+ case (T_int<<4)+T_double : return Constant.fromValue((int)this.doubleValue());
+ case (T_int<<4)+T_float : return Constant.fromValue((int)this.floatValue());
+ // case (T_int<<4)+T_boolean : return NotAConstant;
+ case (T_int<<4)+T_char : return Constant.fromValue((int)this.charValue());
+ case (T_int<<4)+T_int : return this;
+
}
+ return NotAConstant;
+ }
+
+ public char charValue() {
+
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"char")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static final Constant computeConstantOperation(Constant cst, int id, int operator) {
- return NotAConstant ;} // should not get here
-public static final Constant computeConstantOperationAND_AND(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- return Constant.fromValue(left.booleanValue() && right.booleanValue()) ;}
-public static final Constant computeConstantOperationDIVIDE(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
- // the /0 must be handled outside this method (error reporting)
-
- switch (leftId){
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() / right.charValue()) ;
- case T_float: return Constant.fromValue(left.charValue() / right.floatValue()) ;
- case T_double: return Constant.fromValue(left.charValue() / right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() / right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() / right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() / right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() / right.longValue()) ;}
- break;
- case T_float :
- switch (rightId){
- case T_char : return Constant.fromValue(left.floatValue() / right.charValue()) ;
- case T_float: return Constant.fromValue(left.floatValue() / right.floatValue()) ;
- case T_double: return Constant.fromValue(left.floatValue() / right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.floatValue() / right.byteValue()) ;
- case T_short: return Constant.fromValue(left.floatValue() / right.shortValue()) ;
- case T_int: return Constant.fromValue(left.floatValue() / right.intValue()) ;
- case T_long: return Constant.fromValue(left.floatValue() / right.longValue()) ;}
- break;
- case T_double :
- switch (rightId){
- case T_char : return Constant.fromValue(left.doubleValue() / right.charValue()) ;
- case T_float: return Constant.fromValue(left.doubleValue() / right.floatValue()) ;
- case T_double: return Constant.fromValue(left.doubleValue() / right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.doubleValue() / right.byteValue()) ;
- case T_short: return Constant.fromValue(left.doubleValue() / right.shortValue()) ;
- case T_int: return Constant.fromValue(left.doubleValue() / right.intValue()) ;
- case T_long: return Constant.fromValue(left.doubleValue() / right.longValue()) ;}
- break;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() / right.charValue()) ;
- case T_float: return Constant.fromValue(left.byteValue() / right.floatValue()) ;
- case T_double: return Constant.fromValue(left.byteValue() / right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() / right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() / right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() / right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() / right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() / right.charValue()) ;
- case T_float: return Constant.fromValue(left.shortValue() / right.floatValue()) ;
- case T_double: return Constant.fromValue(left.shortValue() / right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() / right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() / right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() / right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() / right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() / right.charValue()) ;
- case T_float: return Constant.fromValue(left.intValue() / right.floatValue()) ;
- case T_double: return Constant.fromValue(left.intValue() / right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() / right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() / right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() / right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() / right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() / right.charValue()) ;
- case T_float: return Constant.fromValue(left.longValue() / right.floatValue()) ;
- case T_double: return Constant.fromValue(left.longValue() / right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() / right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() / right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() / right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() / right.longValue()) ;}
-
+ switch (operator) {
+ case NOT :
+ return Constant.fromValue(!cst.booleanValue());
+ case PLUS : return cst;
+ case MINUS : //the two special -9223372036854775808L and -2147483648 are inlined at parseTime
+ switch (id){
+ case T_float : float f;
+ if ( (f= cst.floatValue()) == 0.0f)
+ { //positive and negative 0....
+ if (Float.floatToIntBits(f) == 0)
+ return Constant.fromValue(-0.0f);
+ else
+ return Constant.fromValue(0.0f);}
+ break; //default case
+ case T_double : double d;
+ if ( (d= cst.doubleValue()) == 0.0d)
+ { //positive and negative 0....
+ if (Double.doubleToLongBits(d) == 0)
+ return Constant.fromValue(-0.0d);
+ else
+ return Constant.fromValue(0.0d);}
+ break; //default case
+ }
+ return computeConstantOperationMINUS(Zero,T_int,operator,cst,id);
+ case TWIDDLE:
+ switch (id){
+ case T_char : return Constant.fromValue(~ cst.charValue());
+ case T_byte: return Constant.fromValue(~ cst.byteValue());
+ case T_short: return Constant.fromValue(~ cst.shortValue());
+ case T_int: return Constant.fromValue(~ cst.intValue());
+ case T_long: return Constant.fromValue(~ cst.longValue());
+ default : return NotAConstant;
+ }
+ default : return NotAConstant;
}
-
+ }
- return NotAConstant ;} //should not get here
-public static final Constant computeConstantOperationEQUAL_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
+ public static final Constant computeConstantOperation(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (operator) {
+ case AND : return computeConstantOperationAND (left,leftId,operator,right,rightId);
+ case AND_AND : return computeConstantOperationAND_AND (left,leftId,operator,right,rightId);
+ case DIVIDE : return computeConstantOperationDIVIDE (left,leftId,operator,right,rightId);
+ case GREATER : return computeConstantOperationGREATER (left,leftId,operator,right,rightId);
+ case GREATER_EQUAL : return computeConstantOperationGREATER_EQUAL(left,leftId,operator,right,rightId);
+ case LEFT_SHIFT : return computeConstantOperationLEFT_SHIFT (left,leftId,operator,right,rightId);
+ case LESS : return computeConstantOperationLESS (left,leftId,operator,right,rightId);
+ case LESS_EQUAL : return computeConstantOperationLESS_EQUAL (left,leftId,operator,right,rightId);
+ case MINUS : return computeConstantOperationMINUS (left,leftId,operator,right,rightId);
+ case MULTIPLY : return computeConstantOperationMULTIPLY (left,leftId,operator,right,rightId);
+ case OR : return computeConstantOperationOR (left,leftId,operator,right,rightId);
+ case OR_OR : return computeConstantOperationOR_OR (left,leftId,operator,right,rightId);
+ case PLUS : return computeConstantOperationPLUS (left,leftId,operator,right,rightId);
+ case REMAINDER : return computeConstantOperationREMAINDER (left,leftId,operator,right,rightId);
+ case RIGHT_SHIFT: return computeConstantOperationRIGHT_SHIFT(left,leftId,operator,right,rightId);
+ case UNSIGNED_RIGHT_SHIFT: return computeConstantOperationUNSIGNED_RIGHT_SHIFT(left,leftId,operator,right,rightId);
+ case XOR : return computeConstantOperationXOR (left,leftId,operator,right,rightId);
- switch (leftId){
- case T_boolean :
- if (rightId == T_boolean) {
- return Constant.fromValue(left.booleanValue() == right.booleanValue()) ;
- }
- break ;
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() == right.charValue()) ;
- case T_float: return Constant.fromValue(left.charValue() == right.floatValue()) ;
- case T_double: return Constant.fromValue(left.charValue() == right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() == right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() == right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() == right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() == right.longValue()) ;}
- break;
- case T_float :
- switch (rightId){
- case T_char : return Constant.fromValue(left.floatValue() == right.charValue()) ;
- case T_float: return Constant.fromValue(left.floatValue() == right.floatValue()) ;
- case T_double: return Constant.fromValue(left.floatValue() == right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.floatValue() == right.byteValue()) ;
- case T_short: return Constant.fromValue(left.floatValue() == right.shortValue()) ;
- case T_int: return Constant.fromValue(left.floatValue() == right.intValue()) ;
- case T_long: return Constant.fromValue(left.floatValue() == right.longValue()) ;}
- break;
- case T_double :
- switch (rightId){
- case T_char : return Constant.fromValue(left.doubleValue() == right.charValue()) ;
- case T_float: return Constant.fromValue(left.doubleValue() == right.floatValue()) ;
- case T_double: return Constant.fromValue(left.doubleValue() == right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.doubleValue() == right.byteValue()) ;
- case T_short: return Constant.fromValue(left.doubleValue() == right.shortValue()) ;
- case T_int: return Constant.fromValue(left.doubleValue() == right.intValue()) ;
- case T_long: return Constant.fromValue(left.doubleValue() == right.longValue()) ;}
- break;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() == right.charValue()) ;
- case T_float: return Constant.fromValue(left.byteValue() == right.floatValue()) ;
- case T_double: return Constant.fromValue(left.byteValue() == right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() == right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() == right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() == right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() == right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() == right.charValue()) ;
- case T_float: return Constant.fromValue(left.shortValue() == right.floatValue()) ;
- case T_double: return Constant.fromValue(left.shortValue() == right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() == right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() == right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() == right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() == right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() == right.charValue()) ;
- case T_float: return Constant.fromValue(left.intValue() == right.floatValue()) ;
- case T_double: return Constant.fromValue(left.intValue() == right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() == right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() == right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() == right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() == right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() == right.charValue()) ;
- case T_float: return Constant.fromValue(left.longValue() == right.floatValue()) ;
- case T_double: return Constant.fromValue(left.longValue() == right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() == right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() == right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() == right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() == right.longValue()) ;}
- break;
- case T_String :
- if (rightId == T_String) {
- //String are intermed in th compiler==>thus if two string constant
- //get to be compared, it is an equal on the vale which is done
- return Constant.fromValue(((StringConstant)left).compileTimeEqual((StringConstant)right)) ;
- }
- break;
- case T_null :
- if (rightId == T_String) {
- return Constant.fromValue(false);
- } else {
- if (rightId == T_null) {
- return Constant.fromValue(true) ;
+ default : return NotAConstant;
+ }
+ }
+
+ public static final Constant computeConstantOperationAND(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_boolean : return Constant.fromValue(left.booleanValue() & right.booleanValue());
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() & right.charValue());
+ case T_byte: return Constant.fromValue(left.charValue() & right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() & right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() & right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() & right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() & right.charValue());
+ case T_byte: return Constant.fromValue(left.byteValue() & right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() & right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() & right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() & right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() & right.charValue());
+ case T_byte: return Constant.fromValue(left.shortValue() & right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() & right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() & right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() & right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() & right.charValue());
+ case T_byte: return Constant.fromValue(left.intValue() & right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() & right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() & right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() & right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() & right.charValue());
+ case T_byte: return Constant.fromValue(left.longValue() & right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() & right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() & right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() & right.longValue());
}
}
- }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationAND_AND(Constant left, int leftId, int operator, Constant right, int rightId) {
- return Constant.fromValue(false) ;}
-public static final Constant computeConstantOperationGREATER(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() > right.charValue()) ;
- case T_float: return Constant.fromValue(left.charValue() > right.floatValue()) ;
- case T_double: return Constant.fromValue(left.charValue() > right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() > right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() > right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() > right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() > right.longValue()) ;}
- break;
- case T_float :
- switch (rightId){
- case T_char : return Constant.fromValue(left.floatValue() > right.charValue()) ;
- case T_float: return Constant.fromValue(left.floatValue() > right.floatValue()) ;
- case T_double: return Constant.fromValue(left.floatValue() > right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.floatValue() > right.byteValue()) ;
- case T_short: return Constant.fromValue(left.floatValue() > right.shortValue()) ;
- case T_int: return Constant.fromValue(left.floatValue() > right.intValue()) ;
- case T_long: return Constant.fromValue(left.floatValue() > right.longValue()) ;}
- break;
- case T_double :
- switch (rightId){
- case T_char : return Constant.fromValue(left.doubleValue() > right.charValue()) ;
- case T_float: return Constant.fromValue(left.doubleValue() > right.floatValue()) ;
- case T_double: return Constant.fromValue(left.doubleValue() > right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.doubleValue() > right.byteValue()) ;
- case T_short: return Constant.fromValue(left.doubleValue() > right.shortValue()) ;
- case T_int: return Constant.fromValue(left.doubleValue() > right.intValue()) ;
- case T_long: return Constant.fromValue(left.doubleValue() > right.longValue()) ;}
- break;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() > right.charValue()) ;
- case T_float: return Constant.fromValue(left.byteValue() > right.floatValue()) ;
- case T_double: return Constant.fromValue(left.byteValue() > right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() > right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() > right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() > right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() > right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() > right.charValue()) ;
- case T_float: return Constant.fromValue(left.shortValue() > right.floatValue()) ;
- case T_double: return Constant.fromValue(left.shortValue() > right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() > right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() > right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() > right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() > right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() > right.charValue()) ;
- case T_float: return Constant.fromValue(left.intValue() > right.floatValue()) ;
- case T_double: return Constant.fromValue(left.intValue() > right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() > right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() > right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() > right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() > right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() > right.charValue()) ;
- case T_float: return Constant.fromValue(left.longValue() > right.floatValue()) ;
- case T_double: return Constant.fromValue(left.longValue() > right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() > right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() > right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() > right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() > right.longValue()) ;}
-
- }
-
- return NotAConstant ;} //should not get here
-public static final Constant computeConstantOperationGREATER_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() >= right.charValue()) ;
- case T_float: return Constant.fromValue(left.charValue() >= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.charValue() >= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() >= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() >= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() >= right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() >= right.longValue()) ;}
- break;
- case T_float :
- switch (rightId){
- case T_char : return Constant.fromValue(left.floatValue() >= right.charValue()) ;
- case T_float: return Constant.fromValue(left.floatValue() >= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.floatValue() >= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.floatValue() >= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.floatValue() >= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.floatValue() >= right.intValue()) ;
- case T_long: return Constant.fromValue(left.floatValue() >= right.longValue()) ;}
- break;
- case T_double :
- switch (rightId){
- case T_char : return Constant.fromValue(left.doubleValue() >= right.charValue()) ;
- case T_float: return Constant.fromValue(left.doubleValue() >= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.doubleValue() >= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.doubleValue() >= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.doubleValue() >= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.doubleValue() >= right.intValue()) ;
- case T_long: return Constant.fromValue(left.doubleValue() >= right.longValue()) ;}
- break;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() >= right.charValue()) ;
- case T_float: return Constant.fromValue(left.byteValue() >= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.byteValue() >= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() >= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() >= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() >= right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() >= right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() >= right.charValue()) ;
- case T_float: return Constant.fromValue(left.shortValue() >= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.shortValue() >= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() >= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() >= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() >= right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() >= right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() >= right.charValue()) ;
- case T_float: return Constant.fromValue(left.intValue() >= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.intValue() >= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() >= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() >= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() >= right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() >= right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() >= right.charValue()) ;
- case T_float: return Constant.fromValue(left.longValue() >= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.longValue() >= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() >= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() >= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() >= right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() >= right.longValue()) ;}
-
- }
-
- return NotAConstant ;} //should not get here
-public static final Constant computeConstantOperationLEFT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() << right.charValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() << right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() << right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() << right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() << right.longValue()) ;}
- break ;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() << right.charValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() << right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() << right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() << right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() << right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() << right.charValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() << right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() << right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() << right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() << right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() << right.charValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() << right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() << right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() << right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() << right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() << right.charValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() << right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() << right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() << right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() << right.longValue()) ;}
-
- }
-
-
- return NotAConstant ;} // should not get here
-public static final Constant computeConstantOperationLESS(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() < right.charValue()) ;
- case T_float: return Constant.fromValue(left.charValue() < right.floatValue()) ;
- case T_double: return Constant.fromValue(left.charValue() < right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() < right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() < right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() < right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() < right.longValue()) ;}
- break;
- case T_float :
- switch (rightId){
- case T_char : return Constant.fromValue(left.floatValue() < right.charValue()) ;
- case T_float: return Constant.fromValue(left.floatValue() < right.floatValue()) ;
- case T_double: return Constant.fromValue(left.floatValue() < right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.floatValue() < right.byteValue()) ;
- case T_short: return Constant.fromValue(left.floatValue() < right.shortValue()) ;
- case T_int: return Constant.fromValue(left.floatValue() < right.intValue()) ;
- case T_long: return Constant.fromValue(left.floatValue() < right.longValue()) ;}
- break;
- case T_double :
- switch (rightId){
- case T_char : return Constant.fromValue(left.doubleValue() < right.charValue()) ;
- case T_float: return Constant.fromValue(left.doubleValue() < right.floatValue()) ;
- case T_double: return Constant.fromValue(left.doubleValue() < right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.doubleValue() < right.byteValue()) ;
- case T_short: return Constant.fromValue(left.doubleValue() < right.shortValue()) ;
- case T_int: return Constant.fromValue(left.doubleValue() < right.intValue()) ;
- case T_long: return Constant.fromValue(left.doubleValue() < right.longValue()) ;}
- break;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() < right.charValue()) ;
- case T_float: return Constant.fromValue(left.byteValue() < right.floatValue()) ;
- case T_double: return Constant.fromValue(left.byteValue() < right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() < right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() < right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() < right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() < right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() < right.charValue()) ;
- case T_float: return Constant.fromValue(left.shortValue() < right.floatValue()) ;
- case T_double: return Constant.fromValue(left.shortValue() < right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() < right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() < right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() < right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() < right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() < right.charValue()) ;
- case T_float: return Constant.fromValue(left.intValue() < right.floatValue()) ;
- case T_double: return Constant.fromValue(left.intValue() < right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() < right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() < right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() < right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() < right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() < right.charValue()) ;
- case T_float: return Constant.fromValue(left.longValue() < right.floatValue()) ;
- case T_double: return Constant.fromValue(left.longValue() < right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() < right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() < right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() < right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() < right.longValue()) ;}
-
- }
-
- return NotAConstant ;} //should not get here
-public static final Constant computeConstantOperationLESS_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() <= right.charValue()) ;
- case T_float: return Constant.fromValue(left.charValue() <= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.charValue() <= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() <= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() <= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() <= right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() <= right.longValue()) ;}
- break;
- case T_float :
- switch (rightId){
- case T_char : return Constant.fromValue(left.floatValue() <= right.charValue()) ;
- case T_float: return Constant.fromValue(left.floatValue() <= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.floatValue() <= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.floatValue() <= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.floatValue() <= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.floatValue() <= right.intValue()) ;
- case T_long: return Constant.fromValue(left.floatValue() <= right.longValue()) ;}
- break;
- case T_double :
- switch (rightId){
- case T_char : return Constant.fromValue(left.doubleValue() <= right.charValue()) ;
- case T_float: return Constant.fromValue(left.doubleValue() <= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.doubleValue() <= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.doubleValue() <= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.doubleValue() <= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.doubleValue() <= right.intValue()) ;
- case T_long: return Constant.fromValue(left.doubleValue() <= right.longValue()) ;}
- break;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() <= right.charValue()) ;
- case T_float: return Constant.fromValue(left.byteValue() <= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.byteValue() <= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() <= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() <= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() <= right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() <= right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() <= right.charValue()) ;
- case T_float: return Constant.fromValue(left.shortValue() <= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.shortValue() <= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() <= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() <= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() <= right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() <= right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() <= right.charValue()) ;
- case T_float: return Constant.fromValue(left.intValue() <= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.intValue() <= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() <= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() <= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() <= right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() <= right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() <= right.charValue()) ;
- case T_float: return Constant.fromValue(left.longValue() <= right.floatValue()) ;
- case T_double: return Constant.fromValue(left.longValue() <= right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() <= right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() <= right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() <= right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() <= right.longValue()) ;}
-
- }
-
- return NotAConstant ;} //should not get here
-public static final Constant computeConstantOperationMINUS(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() - right.charValue()) ;
- case T_float: return Constant.fromValue(left.charValue() - right.floatValue()) ;
- case T_double: return Constant.fromValue(left.charValue() - right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() - right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() - right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() - right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() - right.longValue()) ;}
- break;
- case T_float :
- switch (rightId){
- case T_char : return Constant.fromValue(left.floatValue() - right.charValue()) ;
- case T_float: return Constant.fromValue(left.floatValue() - right.floatValue()) ;
- case T_double: return Constant.fromValue(left.floatValue() - right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.floatValue() - right.byteValue()) ;
- case T_short: return Constant.fromValue(left.floatValue() - right.shortValue()) ;
- case T_int: return Constant.fromValue(left.floatValue() - right.intValue()) ;
- case T_long: return Constant.fromValue(left.floatValue() - right.longValue()) ;}
- break;
- case T_double :
- switch (rightId){
- case T_char : return Constant.fromValue(left.doubleValue() - right.charValue()) ;
- case T_float: return Constant.fromValue(left.doubleValue() - right.floatValue()) ;
- case T_double: return Constant.fromValue(left.doubleValue() - right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.doubleValue() - right.byteValue()) ;
- case T_short: return Constant.fromValue(left.doubleValue() - right.shortValue()) ;
- case T_int: return Constant.fromValue(left.doubleValue() - right.intValue()) ;
- case T_long: return Constant.fromValue(left.doubleValue() - right.longValue()) ;}
- break;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() - right.charValue()) ;
- case T_float: return Constant.fromValue(left.byteValue() - right.floatValue()) ;
- case T_double: return Constant.fromValue(left.byteValue() - right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() - right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() - right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() - right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() - right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() - right.charValue()) ;
- case T_float: return Constant.fromValue(left.shortValue() - right.floatValue()) ;
- case T_double: return Constant.fromValue(left.shortValue() - right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() - right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() - right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() - right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() - right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() - right.charValue()) ;
- case T_float: return Constant.fromValue(left.intValue() - right.floatValue()) ;
- case T_double: return Constant.fromValue(left.intValue() - right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() - right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() - right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() - right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() - right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() - right.charValue()) ;
- case T_float: return Constant.fromValue(left.longValue() - right.floatValue()) ;
- case T_double: return Constant.fromValue(left.longValue() - right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() - right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() - right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() - right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() - right.longValue()) ;}
-
- }
-
- return NotAConstant ;} //should not get here
-public static final Constant computeConstantOperationMULTIPLY(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() * right.charValue()) ;
- case T_float: return Constant.fromValue(left.charValue() * right.floatValue()) ;
- case T_double: return Constant.fromValue(left.charValue() * right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() * right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() * right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() * right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() * right.longValue()) ;}
- break;
- case T_float :
- switch (rightId){
- case T_char : return Constant.fromValue(left.floatValue() * right.charValue()) ;
- case T_float: return Constant.fromValue(left.floatValue() * right.floatValue()) ;
- case T_double: return Constant.fromValue(left.floatValue() * right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.floatValue() * right.byteValue()) ;
- case T_short: return Constant.fromValue(left.floatValue() * right.shortValue()) ;
- case T_int: return Constant.fromValue(left.floatValue() * right.intValue()) ;
- case T_long: return Constant.fromValue(left.floatValue() * right.longValue()) ;}
- break;
- case T_double :
- switch (rightId){
- case T_char : return Constant.fromValue(left.doubleValue() * right.charValue()) ;
- case T_float: return Constant.fromValue(left.doubleValue() * right.floatValue()) ;
- case T_double: return Constant.fromValue(left.doubleValue() * right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.doubleValue() * right.byteValue()) ;
- case T_short: return Constant.fromValue(left.doubleValue() * right.shortValue()) ;
- case T_int: return Constant.fromValue(left.doubleValue() * right.intValue()) ;
- case T_long: return Constant.fromValue(left.doubleValue() * right.longValue()) ;}
- break;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() * right.charValue()) ;
- case T_float: return Constant.fromValue(left.byteValue() * right.floatValue()) ;
- case T_double: return Constant.fromValue(left.byteValue() * right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() * right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() * right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() * right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() * right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() * right.charValue()) ;
- case T_float: return Constant.fromValue(left.shortValue() * right.floatValue()) ;
- case T_double: return Constant.fromValue(left.shortValue() * right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() * right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() * right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() * right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() * right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() * right.charValue()) ;
- case T_float: return Constant.fromValue(left.intValue() * right.floatValue()) ;
- case T_double: return Constant.fromValue(left.intValue() * right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() * right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() * right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() * right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() * right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() * right.charValue()) ;
- case T_float: return Constant.fromValue(left.longValue() * right.floatValue()) ;
- case T_double: return Constant.fromValue(left.longValue() * right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() * right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() * right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() * right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() * right.longValue()) ;}
-
- }
-
-
- return NotAConstant ;} //should not get here
-public static final Constant computeConstantOperationOR(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_boolean : return Constant.fromValue(left.booleanValue() | right.booleanValue()) ;
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() | right.charValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() | right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() | right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() | right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() | right.longValue()) ;}
- break;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() | right.charValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() | right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() | right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() | right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() | right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() | right.charValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() | right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() | right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() | right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() | right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() | right.charValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() | right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() | right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() | right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() | right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() | right.charValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() | right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() | right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() | right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() | right.longValue()) ;}
-
- }
-
-
- return NotAConstant ;} // should not get here
-public static final Constant computeConstantOperationOR_OR(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- return Constant.fromValue(left.booleanValue() || right.booleanValue()) ;}
-public static final Constant computeConstantOperationPLUS(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_Object :
- if (rightId == T_String) {
- return Constant.fromValue(left.stringValue() + right.stringValue());
- }
- case T_boolean :
- if (rightId == T_String) {
- return Constant.fromValue(left.stringValue() + right.stringValue());
- }
- break ;
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() + right.charValue()) ;
- case T_float: return Constant.fromValue(left.charValue() + right.floatValue()) ;
- case T_double: return Constant.fromValue(left.charValue() + right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() + right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() + right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() + right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() + right.longValue()) ;
- case T_String: return Constant.fromValue(left.stringValue() + right.stringValue()) ;}
- break;
- case T_float :
- switch (rightId){
- case T_char : return Constant.fromValue(left.floatValue() + right.charValue()) ;
- case T_float: return Constant.fromValue(left.floatValue() + right.floatValue()) ;
- case T_double: return Constant.fromValue(left.floatValue() + right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.floatValue() + right.byteValue()) ;
- case T_short: return Constant.fromValue(left.floatValue() + right.shortValue()) ;
- case T_int: return Constant.fromValue(left.floatValue() + right.intValue()) ;
- case T_long: return Constant.fromValue(left.floatValue() + right.longValue()) ;
- case T_String: return Constant.fromValue(left.stringValue() + right.stringValue()) ; }
- break;
- case T_double :
- switch (rightId){
- case T_char : return Constant.fromValue(left.doubleValue() + right.charValue()) ;
- case T_float: return Constant.fromValue(left.doubleValue() + right.floatValue()) ;
- case T_double: return Constant.fromValue(left.doubleValue() + right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.doubleValue() + right.byteValue()) ;
- case T_short: return Constant.fromValue(left.doubleValue() + right.shortValue()) ;
- case T_int: return Constant.fromValue(left.doubleValue() + right.intValue()) ;
- case T_long: return Constant.fromValue(left.doubleValue() + right.longValue()) ;
- case T_String: return Constant.fromValue(left.stringValue() + right.stringValue()) ;}
- break;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() + right.charValue()) ;
- case T_float: return Constant.fromValue(left.byteValue() + right.floatValue()) ;
- case T_double: return Constant.fromValue(left.byteValue() + right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() + right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() + right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() + right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() + right.longValue()) ;
- case T_String: return Constant.fromValue(left.stringValue() + right.stringValue()) ; }
-
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() + right.charValue()) ;
- case T_float: return Constant.fromValue(left.shortValue() + right.floatValue()) ;
- case T_double: return Constant.fromValue(left.shortValue() + right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() + right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() + right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() + right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() + right.longValue()) ;
- case T_String: return Constant.fromValue(left.stringValue() + right.stringValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() + right.charValue()) ;
- case T_float: return Constant.fromValue(left.intValue() + right.floatValue()) ;
- case T_double: return Constant.fromValue(left.intValue() + right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() + right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() + right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() + right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() + right.longValue()) ;
- case T_String: return Constant.fromValue(left.stringValue() + right.stringValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() + right.charValue()) ;
- case T_float: return Constant.fromValue(left.longValue() + right.floatValue()) ;
- case T_double: return Constant.fromValue(left.longValue() + right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() + right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() + right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() + right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() + right.longValue()) ;
- case T_String: return Constant.fromValue(left.stringValue() + right.stringValue()) ; }
- break;
- case T_String :
- switch (rightId){
- case T_char : return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_float: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_double: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_byte: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_short: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_int: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_long: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_String: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_null: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_boolean: return Constant.fromValue(left.stringValue() + right.stringValue()) ;}
- break;
- case T_null :
- switch (rightId){
- case T_char : return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_float: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_double: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_byte: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_short: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_int: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_long: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_String: return Constant.fromValue(left.stringValue() + right.stringValue()) ;
- case T_null: return Constant.fromValue(left.stringValue() + right.stringValue()) ; }
-
- }
-
- return NotAConstant ;} //should not get here
-public static final Constant computeConstantOperationREMAINDER(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() % right.charValue()) ;
- case T_float: return Constant.fromValue(left.charValue() % right.floatValue()) ;
- case T_double: return Constant.fromValue(left.charValue() % right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() % right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() % right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() % right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() % right.longValue()) ;}
- break;
- case T_float :
- switch (rightId){
- case T_char : return Constant.fromValue(left.floatValue() % right.charValue()) ;
- case T_float: return Constant.fromValue(left.floatValue() % right.floatValue()) ;
- case T_double: return Constant.fromValue(left.floatValue() % right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.floatValue() % right.byteValue()) ;
- case T_short: return Constant.fromValue(left.floatValue() % right.shortValue()) ;
- case T_int: return Constant.fromValue(left.floatValue() % right.intValue()) ;
- case T_long: return Constant.fromValue(left.floatValue() % right.longValue()) ;}
- break;
- case T_double :
- switch (rightId){
- case T_char : return Constant.fromValue(left.doubleValue() % right.charValue()) ;
- case T_float: return Constant.fromValue(left.doubleValue() % right.floatValue()) ;
- case T_double: return Constant.fromValue(left.doubleValue() % right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.doubleValue() % right.byteValue()) ;
- case T_short: return Constant.fromValue(left.doubleValue() % right.shortValue()) ;
- case T_int: return Constant.fromValue(left.doubleValue() % right.intValue()) ;
- case T_long: return Constant.fromValue(left.doubleValue() % right.longValue()) ;}
- break;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() % right.charValue()) ;
- case T_float: return Constant.fromValue(left.byteValue() % right.floatValue()) ;
- case T_double: return Constant.fromValue(left.byteValue() % right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() % right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() % right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() % right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() % right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() % right.charValue()) ;
- case T_float: return Constant.fromValue(left.shortValue() % right.floatValue()) ;
- case T_double: return Constant.fromValue(left.shortValue() % right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() % right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() % right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() % right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() % right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() % right.charValue()) ;
- case T_float: return Constant.fromValue(left.intValue() % right.floatValue()) ;
- case T_double: return Constant.fromValue(left.intValue() % right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() % right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() % right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() % right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() % right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() % right.charValue()) ;
- case T_float: return Constant.fromValue(left.longValue() % right.floatValue()) ;
- case T_double: return Constant.fromValue(left.longValue() % right.doubleValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() % right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() % right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() % right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() % right.longValue()) ;}
-
- }
-
- return NotAConstant ;} //should not get here
-public static final Constant computeConstantOperationRIGHT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() >> right.charValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() >> right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() >> right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() >> right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() >> right.longValue()) ;}
- break ;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() >> right.charValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() >> right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() >> right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() >> right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() >> right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() >> right.charValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() >> right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() >> right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() >> right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() >> right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() >> right.charValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() >> right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() >> right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() >> right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() >> right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() >> right.charValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() >> right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() >> right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() >> right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() >> right.longValue()) ;}
-
- }
-
-
- return NotAConstant ;} // should not get here
-public static final Constant computeConstantOperationUNSIGNED_RIGHT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() >>> right.charValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() >>> right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() >>> right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() >>> right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() >>> right.longValue()) ;}
- break ;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() >>> right.charValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() >>> right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() >>> right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() >>> right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() >>> right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() >>> right.charValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() >>> right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() >>> right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() >>> right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() >>> right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() >>> right.charValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() >>> right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() >>> right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() >>> right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() >>> right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() >>> right.charValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() >>> right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() >>> right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() >>> right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() >>> right.longValue()) ;}
-
- }
-
-
- return NotAConstant ;} // should not get here
-public static final Constant computeConstantOperationXOR(Constant left, int leftId, int operator, Constant right, int rightId) {
- //this method assumes that the TC has been done .
-
- switch (leftId){
- case T_boolean : return Constant.fromValue(left.booleanValue() ^ right.booleanValue()) ;
- case T_char :
- switch (rightId){
- case T_char : return Constant.fromValue(left.charValue() ^ right.charValue()) ;
- case T_byte: return Constant.fromValue(left.charValue() ^ right.byteValue()) ;
- case T_short: return Constant.fromValue(left.charValue() ^ right.shortValue()) ;
- case T_int: return Constant.fromValue(left.charValue() ^ right.intValue()) ;
- case T_long: return Constant.fromValue(left.charValue() ^ right.longValue()) ;}
- break ;
- case T_byte :
- switch (rightId){
- case T_char : return Constant.fromValue(left.byteValue() ^ right.charValue()) ;
- case T_byte: return Constant.fromValue(left.byteValue() ^ right.byteValue()) ;
- case T_short: return Constant.fromValue(left.byteValue() ^ right.shortValue()) ;
- case T_int: return Constant.fromValue(left.byteValue() ^ right.intValue()) ;
- case T_long: return Constant.fromValue(left.byteValue() ^ right.longValue()) ;}
- break;
- case T_short :
- switch (rightId){
- case T_char : return Constant.fromValue(left.shortValue() ^ right.charValue()) ;
- case T_byte: return Constant.fromValue(left.shortValue() ^ right.byteValue()) ;
- case T_short: return Constant.fromValue(left.shortValue() ^ right.shortValue()) ;
- case T_int: return Constant.fromValue(left.shortValue() ^ right.intValue()) ;
- case T_long: return Constant.fromValue(left.shortValue() ^ right.longValue()) ;}
- break;
- case T_int :
- switch (rightId){
- case T_char : return Constant.fromValue(left.intValue() ^ right.charValue()) ;
- case T_byte: return Constant.fromValue(left.intValue() ^ right.byteValue()) ;
- case T_short: return Constant.fromValue(left.intValue() ^ right.shortValue()) ;
- case T_int: return Constant.fromValue(left.intValue() ^ right.intValue()) ;
- case T_long: return Constant.fromValue(left.intValue() ^ right.longValue()) ;}
- break;
- case T_long :
- switch (rightId){
- case T_char : return Constant.fromValue(left.longValue() ^ right.charValue()) ;
- case T_byte: return Constant.fromValue(left.longValue() ^ right.byteValue()) ;
- case T_short: return Constant.fromValue(left.longValue() ^ right.shortValue()) ;
- case T_int: return Constant.fromValue(left.longValue() ^ right.intValue()) ;
- case T_long: return Constant.fromValue(left.longValue() ^ right.longValue()) ;}
-
- }
-
-
- return NotAConstant ;} // should not get here
-public double doubleValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"double")); //$NON-NLS-2$ //$NON-NLS-1$
-}
-public float floatValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"float")); //$NON-NLS-2$ //$NON-NLS-1$
-}
-public static Constant fromValue(byte value) {
- return new ByteConstant(value);
-}
-public static Constant fromValue(char value) {
- return new CharConstant(value);
-}
-public static Constant fromValue(double value) {
- return new DoubleConstant(value);
-}
-public static Constant fromValue(float value) {
- return new FloatConstant(value);
-}
-public static Constant fromValue(int value) {
- return new IntConstant(value);
-}
-public static Constant fromValue(long value) {
- return new LongConstant(value);
-}
-public static Constant fromValue(String value) {
- if (value == null) return NullConstant.Default;
- return new StringConstant(value);
-}
-public static Constant fromValue(short value) {
- return new ShortConstant(value);
-}
-public static Constant fromValue(boolean value) {
- return new BooleanConstant(value);
-}
-public int intValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"int")); //$NON-NLS-2$ //$NON-NLS-1$
-}
-public long longValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"long")); //$NON-NLS-2$ //$NON-NLS-1$
-}
-public short shortValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo",typeName(),"short")); //$NON-NLS-2$ //$NON-NLS-1$
-}
-/** Deprecated
-*/
-public String stringValue() {
- throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo",typeName(),"String")); //$NON-NLS-1$ //$NON-NLS-2$
-}
-public String toString(){
-
- if (this == NotAConstant) return "(Constant) NotAConstant" ; //$NON-NLS-1$
- return super.toString(); }
-public abstract int typeID();
-public String typeName() {
- switch (typeID()) {
- case T_int : return "int"; //$NON-NLS-1$
- case T_byte : return "byte"; //$NON-NLS-1$
- case T_short : return "short"; //$NON-NLS-1$
- case T_char : return "char"; //$NON-NLS-1$
- case T_float : return "float"; //$NON-NLS-1$
- case T_double : return "double"; //$NON-NLS-1$
- case T_boolean : return "boolean"; //$NON-NLS-1$
- case T_long : return "long";//$NON-NLS-1$
- case T_String : return "java.lang.String"; //$NON-NLS-1$
- case T_null : return "null"; //$NON-NLS-1$
- default: return "unknown"; //$NON-NLS-1$
+ return Constant.fromValue(left.booleanValue() && right.booleanValue());
}
-}
+
+ public static final Constant computeConstantOperationDIVIDE(Constant left, int leftId, int operator, Constant right, int rightId) {
+ // division by zero must be handled outside this method (error reporting)
+
+ switch (leftId){
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() / right.charValue());
+ case T_float: return Constant.fromValue(left.charValue() / right.floatValue());
+ case T_double: return Constant.fromValue(left.charValue() / right.doubleValue());
+ case T_byte: return Constant.fromValue(left.charValue() / right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() / right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() / right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() / right.longValue());
+ }
+ break;
+ case T_float :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.floatValue() / right.charValue());
+ case T_float: return Constant.fromValue(left.floatValue() / right.floatValue());
+ case T_double: return Constant.fromValue(left.floatValue() / right.doubleValue());
+ case T_byte: return Constant.fromValue(left.floatValue() / right.byteValue());
+ case T_short: return Constant.fromValue(left.floatValue() / right.shortValue());
+ case T_int: return Constant.fromValue(left.floatValue() / right.intValue());
+ case T_long: return Constant.fromValue(left.floatValue() / right.longValue());
+ }
+ break;
+ case T_double :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.doubleValue() / right.charValue());
+ case T_float: return Constant.fromValue(left.doubleValue() / right.floatValue());
+ case T_double: return Constant.fromValue(left.doubleValue() / right.doubleValue());
+ case T_byte: return Constant.fromValue(left.doubleValue() / right.byteValue());
+ case T_short: return Constant.fromValue(left.doubleValue() / right.shortValue());
+ case T_int: return Constant.fromValue(left.doubleValue() / right.intValue());
+ case T_long: return Constant.fromValue(left.doubleValue() / right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() / right.charValue());
+ case T_float: return Constant.fromValue(left.byteValue() / right.floatValue());
+ case T_double: return Constant.fromValue(left.byteValue() / right.doubleValue());
+ case T_byte: return Constant.fromValue(left.byteValue() / right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() / right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() / right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() / right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() / right.charValue());
+ case T_float: return Constant.fromValue(left.shortValue() / right.floatValue());
+ case T_double: return Constant.fromValue(left.shortValue() / right.doubleValue());
+ case T_byte: return Constant.fromValue(left.shortValue() / right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() / right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() / right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() / right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() / right.charValue());
+ case T_float: return Constant.fromValue(left.intValue() / right.floatValue());
+ case T_double: return Constant.fromValue(left.intValue() / right.doubleValue());
+ case T_byte: return Constant.fromValue(left.intValue() / right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() / right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() / right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() / right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() / right.charValue());
+ case T_float: return Constant.fromValue(left.longValue() / right.floatValue());
+ case T_double: return Constant.fromValue(left.longValue() / right.doubleValue());
+ case T_byte: return Constant.fromValue(left.longValue() / right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() / right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() / right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() / right.longValue());
+ }
+
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationEQUAL_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_boolean :
+ if (rightId == T_boolean) {
+ return Constant.fromValue(left.booleanValue() == right.booleanValue());
+ }
+ break;
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() == right.charValue());
+ case T_float: return Constant.fromValue(left.charValue() == right.floatValue());
+ case T_double: return Constant.fromValue(left.charValue() == right.doubleValue());
+ case T_byte: return Constant.fromValue(left.charValue() == right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() == right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() == right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() == right.longValue());}
+ break;
+ case T_float :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.floatValue() == right.charValue());
+ case T_float: return Constant.fromValue(left.floatValue() == right.floatValue());
+ case T_double: return Constant.fromValue(left.floatValue() == right.doubleValue());
+ case T_byte: return Constant.fromValue(left.floatValue() == right.byteValue());
+ case T_short: return Constant.fromValue(left.floatValue() == right.shortValue());
+ case T_int: return Constant.fromValue(left.floatValue() == right.intValue());
+ case T_long: return Constant.fromValue(left.floatValue() == right.longValue());
+ }
+ break;
+ case T_double :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.doubleValue() == right.charValue());
+ case T_float: return Constant.fromValue(left.doubleValue() == right.floatValue());
+ case T_double: return Constant.fromValue(left.doubleValue() == right.doubleValue());
+ case T_byte: return Constant.fromValue(left.doubleValue() == right.byteValue());
+ case T_short: return Constant.fromValue(left.doubleValue() == right.shortValue());
+ case T_int: return Constant.fromValue(left.doubleValue() == right.intValue());
+ case T_long: return Constant.fromValue(left.doubleValue() == right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() == right.charValue());
+ case T_float: return Constant.fromValue(left.byteValue() == right.floatValue());
+ case T_double: return Constant.fromValue(left.byteValue() == right.doubleValue());
+ case T_byte: return Constant.fromValue(left.byteValue() == right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() == right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() == right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() == right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() == right.charValue());
+ case T_float: return Constant.fromValue(left.shortValue() == right.floatValue());
+ case T_double: return Constant.fromValue(left.shortValue() == right.doubleValue());
+ case T_byte: return Constant.fromValue(left.shortValue() == right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() == right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() == right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() == right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() == right.charValue());
+ case T_float: return Constant.fromValue(left.intValue() == right.floatValue());
+ case T_double: return Constant.fromValue(left.intValue() == right.doubleValue());
+ case T_byte: return Constant.fromValue(left.intValue() == right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() == right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() == right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() == right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() == right.charValue());
+ case T_float: return Constant.fromValue(left.longValue() == right.floatValue());
+ case T_double: return Constant.fromValue(left.longValue() == right.doubleValue());
+ case T_byte: return Constant.fromValue(left.longValue() == right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() == right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() == right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() == right.longValue());
+ }
+ break;
+ case T_String :
+ if (rightId == T_String) {
+ //String are interned in th compiler==>thus if two string constant
+ //get to be compared, it is an equal on the vale which is done
+ return Constant.fromValue(((StringConstant)left).compileTimeEqual((StringConstant)right));
+ }
+ break;
+ case T_null :
+ if (rightId == T_String) {
+ return Constant.fromValue(false);
+ } else {
+ if (rightId == T_null) {
+ return Constant.fromValue(true);
+ }
+ }
+ }
+
+ return Constant.fromValue(false);
+ }
+
+ public static final Constant computeConstantOperationGREATER(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() > right.charValue());
+ case T_float: return Constant.fromValue(left.charValue() > right.floatValue());
+ case T_double: return Constant.fromValue(left.charValue() > right.doubleValue());
+ case T_byte: return Constant.fromValue(left.charValue() > right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() > right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() > right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() > right.longValue());
+ }
+ break;
+ case T_float :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.floatValue() > right.charValue());
+ case T_float: return Constant.fromValue(left.floatValue() > right.floatValue());
+ case T_double: return Constant.fromValue(left.floatValue() > right.doubleValue());
+ case T_byte: return Constant.fromValue(left.floatValue() > right.byteValue());
+ case T_short: return Constant.fromValue(left.floatValue() > right.shortValue());
+ case T_int: return Constant.fromValue(left.floatValue() > right.intValue());
+ case T_long: return Constant.fromValue(left.floatValue() > right.longValue());
+ }
+ break;
+ case T_double :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.doubleValue() > right.charValue());
+ case T_float: return Constant.fromValue(left.doubleValue() > right.floatValue());
+ case T_double: return Constant.fromValue(left.doubleValue() > right.doubleValue());
+ case T_byte: return Constant.fromValue(left.doubleValue() > right.byteValue());
+ case T_short: return Constant.fromValue(left.doubleValue() > right.shortValue());
+ case T_int: return Constant.fromValue(left.doubleValue() > right.intValue());
+ case T_long: return Constant.fromValue(left.doubleValue() > right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() > right.charValue());
+ case T_float: return Constant.fromValue(left.byteValue() > right.floatValue());
+ case T_double: return Constant.fromValue(left.byteValue() > right.doubleValue());
+ case T_byte: return Constant.fromValue(left.byteValue() > right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() > right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() > right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() > right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() > right.charValue());
+ case T_float: return Constant.fromValue(left.shortValue() > right.floatValue());
+ case T_double: return Constant.fromValue(left.shortValue() > right.doubleValue());
+ case T_byte: return Constant.fromValue(left.shortValue() > right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() > right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() > right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() > right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() > right.charValue());
+ case T_float: return Constant.fromValue(left.intValue() > right.floatValue());
+ case T_double: return Constant.fromValue(left.intValue() > right.doubleValue());
+ case T_byte: return Constant.fromValue(left.intValue() > right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() > right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() > right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() > right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() > right.charValue());
+ case T_float: return Constant.fromValue(left.longValue() > right.floatValue());
+ case T_double: return Constant.fromValue(left.longValue() > right.doubleValue());
+ case T_byte: return Constant.fromValue(left.longValue() > right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() > right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() > right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() > right.longValue());
+ }
+
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationGREATER_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() >= right.charValue());
+ case T_float: return Constant.fromValue(left.charValue() >= right.floatValue());
+ case T_double: return Constant.fromValue(left.charValue() >= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.charValue() >= right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() >= right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() >= right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() >= right.longValue());
+ }
+ break;
+ case T_float :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.floatValue() >= right.charValue());
+ case T_float: return Constant.fromValue(left.floatValue() >= right.floatValue());
+ case T_double: return Constant.fromValue(left.floatValue() >= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.floatValue() >= right.byteValue());
+ case T_short: return Constant.fromValue(left.floatValue() >= right.shortValue());
+ case T_int: return Constant.fromValue(left.floatValue() >= right.intValue());
+ case T_long: return Constant.fromValue(left.floatValue() >= right.longValue());
+ }
+ break;
+ case T_double :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.doubleValue() >= right.charValue());
+ case T_float: return Constant.fromValue(left.doubleValue() >= right.floatValue());
+ case T_double: return Constant.fromValue(left.doubleValue() >= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.doubleValue() >= right.byteValue());
+ case T_short: return Constant.fromValue(left.doubleValue() >= right.shortValue());
+ case T_int: return Constant.fromValue(left.doubleValue() >= right.intValue());
+ case T_long: return Constant.fromValue(left.doubleValue() >= right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() >= right.charValue());
+ case T_float: return Constant.fromValue(left.byteValue() >= right.floatValue());
+ case T_double: return Constant.fromValue(left.byteValue() >= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.byteValue() >= right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() >= right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() >= right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() >= right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() >= right.charValue());
+ case T_float: return Constant.fromValue(left.shortValue() >= right.floatValue());
+ case T_double: return Constant.fromValue(left.shortValue() >= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.shortValue() >= right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() >= right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() >= right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() >= right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() >= right.charValue());
+ case T_float: return Constant.fromValue(left.intValue() >= right.floatValue());
+ case T_double: return Constant.fromValue(left.intValue() >= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.intValue() >= right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() >= right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() >= right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() >= right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() >= right.charValue());
+ case T_float: return Constant.fromValue(left.longValue() >= right.floatValue());
+ case T_double: return Constant.fromValue(left.longValue() >= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.longValue() >= right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() >= right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() >= right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() >= right.longValue());
+ }
+
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationLEFT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() << right.charValue());
+ case T_byte: return Constant.fromValue(left.charValue() << right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() << right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() << right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() << right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() << right.charValue());
+ case T_byte: return Constant.fromValue(left.byteValue() << right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() << right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() << right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() << right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() << right.charValue());
+ case T_byte: return Constant.fromValue(left.shortValue() << right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() << right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() << right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() << right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() << right.charValue());
+ case T_byte: return Constant.fromValue(left.intValue() << right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() << right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() << right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() << right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() << right.charValue());
+ case T_byte: return Constant.fromValue(left.longValue() << right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() << right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() << right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() << right.longValue());
+ }
+
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationLESS(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() < right.charValue());
+ case T_float: return Constant.fromValue(left.charValue() < right.floatValue());
+ case T_double: return Constant.fromValue(left.charValue() < right.doubleValue());
+ case T_byte: return Constant.fromValue(left.charValue() < right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() < right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() < right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() < right.longValue());
+ }
+ break;
+ case T_float :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.floatValue() < right.charValue());
+ case T_float: return Constant.fromValue(left.floatValue() < right.floatValue());
+ case T_double: return Constant.fromValue(left.floatValue() < right.doubleValue());
+ case T_byte: return Constant.fromValue(left.floatValue() < right.byteValue());
+ case T_short: return Constant.fromValue(left.floatValue() < right.shortValue());
+ case T_int: return Constant.fromValue(left.floatValue() < right.intValue());
+ case T_long: return Constant.fromValue(left.floatValue() < right.longValue());
+ }
+ break;
+ case T_double :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.doubleValue() < right.charValue());
+ case T_float: return Constant.fromValue(left.doubleValue() < right.floatValue());
+ case T_double: return Constant.fromValue(left.doubleValue() < right.doubleValue());
+ case T_byte: return Constant.fromValue(left.doubleValue() < right.byteValue());
+ case T_short: return Constant.fromValue(left.doubleValue() < right.shortValue());
+ case T_int: return Constant.fromValue(left.doubleValue() < right.intValue());
+ case T_long: return Constant.fromValue(left.doubleValue() < right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() < right.charValue());
+ case T_float: return Constant.fromValue(left.byteValue() < right.floatValue());
+ case T_double: return Constant.fromValue(left.byteValue() < right.doubleValue());
+ case T_byte: return Constant.fromValue(left.byteValue() < right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() < right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() < right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() < right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() < right.charValue());
+ case T_float: return Constant.fromValue(left.shortValue() < right.floatValue());
+ case T_double: return Constant.fromValue(left.shortValue() < right.doubleValue());
+ case T_byte: return Constant.fromValue(left.shortValue() < right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() < right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() < right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() < right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() < right.charValue());
+ case T_float: return Constant.fromValue(left.intValue() < right.floatValue());
+ case T_double: return Constant.fromValue(left.intValue() < right.doubleValue());
+ case T_byte: return Constant.fromValue(left.intValue() < right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() < right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() < right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() < right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() < right.charValue());
+ case T_float: return Constant.fromValue(left.longValue() < right.floatValue());
+ case T_double: return Constant.fromValue(left.longValue() < right.doubleValue());
+ case T_byte: return Constant.fromValue(left.longValue() < right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() < right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() < right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() < right.longValue());
+ }
+
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationLESS_EQUAL(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() <= right.charValue());
+ case T_float: return Constant.fromValue(left.charValue() <= right.floatValue());
+ case T_double: return Constant.fromValue(left.charValue() <= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.charValue() <= right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() <= right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() <= right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() <= right.longValue());
+ }
+ break;
+ case T_float :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.floatValue() <= right.charValue());
+ case T_float: return Constant.fromValue(left.floatValue() <= right.floatValue());
+ case T_double: return Constant.fromValue(left.floatValue() <= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.floatValue() <= right.byteValue());
+ case T_short: return Constant.fromValue(left.floatValue() <= right.shortValue());
+ case T_int: return Constant.fromValue(left.floatValue() <= right.intValue());
+ case T_long: return Constant.fromValue(left.floatValue() <= right.longValue());
+ }
+ break;
+ case T_double :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.doubleValue() <= right.charValue());
+ case T_float: return Constant.fromValue(left.doubleValue() <= right.floatValue());
+ case T_double: return Constant.fromValue(left.doubleValue() <= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.doubleValue() <= right.byteValue());
+ case T_short: return Constant.fromValue(left.doubleValue() <= right.shortValue());
+ case T_int: return Constant.fromValue(left.doubleValue() <= right.intValue());
+ case T_long: return Constant.fromValue(left.doubleValue() <= right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() <= right.charValue());
+ case T_float: return Constant.fromValue(left.byteValue() <= right.floatValue());
+ case T_double: return Constant.fromValue(left.byteValue() <= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.byteValue() <= right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() <= right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() <= right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() <= right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() <= right.charValue());
+ case T_float: return Constant.fromValue(left.shortValue() <= right.floatValue());
+ case T_double: return Constant.fromValue(left.shortValue() <= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.shortValue() <= right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() <= right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() <= right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() <= right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() <= right.charValue());
+ case T_float: return Constant.fromValue(left.intValue() <= right.floatValue());
+ case T_double: return Constant.fromValue(left.intValue() <= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.intValue() <= right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() <= right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() <= right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() <= right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() <= right.charValue());
+ case T_float: return Constant.fromValue(left.longValue() <= right.floatValue());
+ case T_double: return Constant.fromValue(left.longValue() <= right.doubleValue());
+ case T_byte: return Constant.fromValue(left.longValue() <= right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() <= right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() <= right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() <= right.longValue());
+ }
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationMINUS(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() - right.charValue());
+ case T_float: return Constant.fromValue(left.charValue() - right.floatValue());
+ case T_double: return Constant.fromValue(left.charValue() - right.doubleValue());
+ case T_byte: return Constant.fromValue(left.charValue() - right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() - right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() - right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() - right.longValue());
+ }
+ break;
+ case T_float :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.floatValue() - right.charValue());
+ case T_float: return Constant.fromValue(left.floatValue() - right.floatValue());
+ case T_double: return Constant.fromValue(left.floatValue() - right.doubleValue());
+ case T_byte: return Constant.fromValue(left.floatValue() - right.byteValue());
+ case T_short: return Constant.fromValue(left.floatValue() - right.shortValue());
+ case T_int: return Constant.fromValue(left.floatValue() - right.intValue());
+ case T_long: return Constant.fromValue(left.floatValue() - right.longValue());
+ }
+ break;
+ case T_double :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.doubleValue() - right.charValue());
+ case T_float: return Constant.fromValue(left.doubleValue() - right.floatValue());
+ case T_double: return Constant.fromValue(left.doubleValue() - right.doubleValue());
+ case T_byte: return Constant.fromValue(left.doubleValue() - right.byteValue());
+ case T_short: return Constant.fromValue(left.doubleValue() - right.shortValue());
+ case T_int: return Constant.fromValue(left.doubleValue() - right.intValue());
+ case T_long: return Constant.fromValue(left.doubleValue() - right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() - right.charValue());
+ case T_float: return Constant.fromValue(left.byteValue() - right.floatValue());
+ case T_double: return Constant.fromValue(left.byteValue() - right.doubleValue());
+ case T_byte: return Constant.fromValue(left.byteValue() - right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() - right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() - right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() - right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() - right.charValue());
+ case T_float: return Constant.fromValue(left.shortValue() - right.floatValue());
+ case T_double: return Constant.fromValue(left.shortValue() - right.doubleValue());
+ case T_byte: return Constant.fromValue(left.shortValue() - right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() - right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() - right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() - right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() - right.charValue());
+ case T_float: return Constant.fromValue(left.intValue() - right.floatValue());
+ case T_double: return Constant.fromValue(left.intValue() - right.doubleValue());
+ case T_byte: return Constant.fromValue(left.intValue() - right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() - right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() - right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() - right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() - right.charValue());
+ case T_float: return Constant.fromValue(left.longValue() - right.floatValue());
+ case T_double: return Constant.fromValue(left.longValue() - right.doubleValue());
+ case T_byte: return Constant.fromValue(left.longValue() - right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() - right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() - right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() - right.longValue());
+ }
+
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationMULTIPLY(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() * right.charValue());
+ case T_float: return Constant.fromValue(left.charValue() * right.floatValue());
+ case T_double: return Constant.fromValue(left.charValue() * right.doubleValue());
+ case T_byte: return Constant.fromValue(left.charValue() * right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() * right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() * right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() * right.longValue());
+ }
+ break;
+ case T_float :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.floatValue() * right.charValue());
+ case T_float: return Constant.fromValue(left.floatValue() * right.floatValue());
+ case T_double: return Constant.fromValue(left.floatValue() * right.doubleValue());
+ case T_byte: return Constant.fromValue(left.floatValue() * right.byteValue());
+ case T_short: return Constant.fromValue(left.floatValue() * right.shortValue());
+ case T_int: return Constant.fromValue(left.floatValue() * right.intValue());
+ case T_long: return Constant.fromValue(left.floatValue() * right.longValue());
+ }
+ break;
+ case T_double :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.doubleValue() * right.charValue());
+ case T_float: return Constant.fromValue(left.doubleValue() * right.floatValue());
+ case T_double: return Constant.fromValue(left.doubleValue() * right.doubleValue());
+ case T_byte: return Constant.fromValue(left.doubleValue() * right.byteValue());
+ case T_short: return Constant.fromValue(left.doubleValue() * right.shortValue());
+ case T_int: return Constant.fromValue(left.doubleValue() * right.intValue());
+ case T_long: return Constant.fromValue(left.doubleValue() * right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() * right.charValue());
+ case T_float: return Constant.fromValue(left.byteValue() * right.floatValue());
+ case T_double: return Constant.fromValue(left.byteValue() * right.doubleValue());
+ case T_byte: return Constant.fromValue(left.byteValue() * right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() * right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() * right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() * right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() * right.charValue());
+ case T_float: return Constant.fromValue(left.shortValue() * right.floatValue());
+ case T_double: return Constant.fromValue(left.shortValue() * right.doubleValue());
+ case T_byte: return Constant.fromValue(left.shortValue() * right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() * right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() * right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() * right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() * right.charValue());
+ case T_float: return Constant.fromValue(left.intValue() * right.floatValue());
+ case T_double: return Constant.fromValue(left.intValue() * right.doubleValue());
+ case T_byte: return Constant.fromValue(left.intValue() * right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() * right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() * right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() * right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() * right.charValue());
+ case T_float: return Constant.fromValue(left.longValue() * right.floatValue());
+ case T_double: return Constant.fromValue(left.longValue() * right.doubleValue());
+ case T_byte: return Constant.fromValue(left.longValue() * right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() * right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() * right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() * right.longValue());
+ }
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationOR(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_boolean : return Constant.fromValue(left.booleanValue() | right.booleanValue());
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() | right.charValue());
+ case T_byte: return Constant.fromValue(left.charValue() | right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() | right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() | right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() | right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() | right.charValue());
+ case T_byte: return Constant.fromValue(left.byteValue() | right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() | right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() | right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() | right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() | right.charValue());
+ case T_byte: return Constant.fromValue(left.shortValue() | right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() | right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() | right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() | right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() | right.charValue());
+ case T_byte: return Constant.fromValue(left.intValue() | right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() | right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() | right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() | right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() | right.charValue());
+ case T_byte: return Constant.fromValue(left.longValue() | right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() | right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() | right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() | right.longValue());
+ }
+
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationOR_OR(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ return Constant.fromValue(left.booleanValue() || right.booleanValue());
+ }
+
+ public static final Constant computeConstantOperationPLUS(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_Object :
+ if (rightId == T_String) {
+ return Constant.fromValue(left.stringValue() + right.stringValue());
+ }
+ case T_boolean :
+ if (rightId == T_String) {
+ return Constant.fromValue(left.stringValue() + right.stringValue());
+ }
+ break;
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() + right.charValue());
+ case T_float: return Constant.fromValue(left.charValue() + right.floatValue());
+ case T_double: return Constant.fromValue(left.charValue() + right.doubleValue());
+ case T_byte: return Constant.fromValue(left.charValue() + right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() + right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() + right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() + right.longValue());
+ case T_String: return Constant.fromValue(left.stringValue() + right.stringValue());
+ }
+ break;
+ case T_float :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.floatValue() + right.charValue());
+ case T_float: return Constant.fromValue(left.floatValue() + right.floatValue());
+ case T_double: return Constant.fromValue(left.floatValue() + right.doubleValue());
+ case T_byte: return Constant.fromValue(left.floatValue() + right.byteValue());
+ case T_short: return Constant.fromValue(left.floatValue() + right.shortValue());
+ case T_int: return Constant.fromValue(left.floatValue() + right.intValue());
+ case T_long: return Constant.fromValue(left.floatValue() + right.longValue());
+ case T_String: return Constant.fromValue(left.stringValue() + right.stringValue());
+ }
+ break;
+ case T_double :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.doubleValue() + right.charValue());
+ case T_float: return Constant.fromValue(left.doubleValue() + right.floatValue());
+ case T_double: return Constant.fromValue(left.doubleValue() + right.doubleValue());
+ case T_byte: return Constant.fromValue(left.doubleValue() + right.byteValue());
+ case T_short: return Constant.fromValue(left.doubleValue() + right.shortValue());
+ case T_int: return Constant.fromValue(left.doubleValue() + right.intValue());
+ case T_long: return Constant.fromValue(left.doubleValue() + right.longValue());
+ case T_String: return Constant.fromValue(left.stringValue() + right.stringValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() + right.charValue());
+ case T_float: return Constant.fromValue(left.byteValue() + right.floatValue());
+ case T_double: return Constant.fromValue(left.byteValue() + right.doubleValue());
+ case T_byte: return Constant.fromValue(left.byteValue() + right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() + right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() + right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() + right.longValue());
+ case T_String: return Constant.fromValue(left.stringValue() + right.stringValue());
+ }
+
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() + right.charValue());
+ case T_float: return Constant.fromValue(left.shortValue() + right.floatValue());
+ case T_double: return Constant.fromValue(left.shortValue() + right.doubleValue());
+ case T_byte: return Constant.fromValue(left.shortValue() + right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() + right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() + right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() + right.longValue());
+ case T_String: return Constant.fromValue(left.stringValue() + right.stringValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() + right.charValue());
+ case T_float: return Constant.fromValue(left.intValue() + right.floatValue());
+ case T_double: return Constant.fromValue(left.intValue() + right.doubleValue());
+ case T_byte: return Constant.fromValue(left.intValue() + right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() + right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() + right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() + right.longValue());
+ case T_String: return Constant.fromValue(left.stringValue() + right.stringValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() + right.charValue());
+ case T_float: return Constant.fromValue(left.longValue() + right.floatValue());
+ case T_double: return Constant.fromValue(left.longValue() + right.doubleValue());
+ case T_byte: return Constant.fromValue(left.longValue() + right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() + right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() + right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() + right.longValue());
+ case T_String: return Constant.fromValue(left.stringValue() + right.stringValue());
+ }
+ break;
+ case T_String :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_float: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_double: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_byte: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_short: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_int: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_long: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_String: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_boolean: return Constant.fromValue(left.stringValue() + right.stringValue());
+ }
+ break;
+ case T_null :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_float: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_double: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_byte: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_short: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_int: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_long: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_String: return Constant.fromValue(left.stringValue() + right.stringValue());
+ }
+
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationREMAINDER(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() % right.charValue());
+ case T_float: return Constant.fromValue(left.charValue() % right.floatValue());
+ case T_double: return Constant.fromValue(left.charValue() % right.doubleValue());
+ case T_byte: return Constant.fromValue(left.charValue() % right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() % right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() % right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() % right.longValue());
+ }
+ break;
+ case T_float :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.floatValue() % right.charValue());
+ case T_float: return Constant.fromValue(left.floatValue() % right.floatValue());
+ case T_double: return Constant.fromValue(left.floatValue() % right.doubleValue());
+ case T_byte: return Constant.fromValue(left.floatValue() % right.byteValue());
+ case T_short: return Constant.fromValue(left.floatValue() % right.shortValue());
+ case T_int: return Constant.fromValue(left.floatValue() % right.intValue());
+ case T_long: return Constant.fromValue(left.floatValue() % right.longValue());
+ }
+ break;
+ case T_double :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.doubleValue() % right.charValue());
+ case T_float: return Constant.fromValue(left.doubleValue() % right.floatValue());
+ case T_double: return Constant.fromValue(left.doubleValue() % right.doubleValue());
+ case T_byte: return Constant.fromValue(left.doubleValue() % right.byteValue());
+ case T_short: return Constant.fromValue(left.doubleValue() % right.shortValue());
+ case T_int: return Constant.fromValue(left.doubleValue() % right.intValue());
+ case T_long: return Constant.fromValue(left.doubleValue() % right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() % right.charValue());
+ case T_float: return Constant.fromValue(left.byteValue() % right.floatValue());
+ case T_double: return Constant.fromValue(left.byteValue() % right.doubleValue());
+ case T_byte: return Constant.fromValue(left.byteValue() % right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() % right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() % right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() % right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() % right.charValue());
+ case T_float: return Constant.fromValue(left.shortValue() % right.floatValue());
+ case T_double: return Constant.fromValue(left.shortValue() % right.doubleValue());
+ case T_byte: return Constant.fromValue(left.shortValue() % right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() % right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() % right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() % right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() % right.charValue());
+ case T_float: return Constant.fromValue(left.intValue() % right.floatValue());
+ case T_double: return Constant.fromValue(left.intValue() % right.doubleValue());
+ case T_byte: return Constant.fromValue(left.intValue() % right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() % right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() % right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() % right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() % right.charValue());
+ case T_float: return Constant.fromValue(left.longValue() % right.floatValue());
+ case T_double: return Constant.fromValue(left.longValue() % right.doubleValue());
+ case T_byte: return Constant.fromValue(left.longValue() % right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() % right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() % right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() % right.longValue());
+ }
+
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationRIGHT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() >> right.charValue());
+ case T_byte: return Constant.fromValue(left.charValue() >> right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() >> right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() >> right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() >> right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() >> right.charValue());
+ case T_byte: return Constant.fromValue(left.byteValue() >> right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() >> right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() >> right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() >> right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() >> right.charValue());
+ case T_byte: return Constant.fromValue(left.shortValue() >> right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() >> right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() >> right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() >> right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() >> right.charValue());
+ case T_byte: return Constant.fromValue(left.intValue() >> right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() >> right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() >> right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() >> right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() >> right.charValue());
+ case T_byte: return Constant.fromValue(left.longValue() >> right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() >> right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() >> right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() >> right.longValue());
+ }
+
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationUNSIGNED_RIGHT_SHIFT(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() >>> right.charValue());
+ case T_byte: return Constant.fromValue(left.charValue() >>> right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() >>> right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() >>> right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() >>> right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() >>> right.charValue());
+ case T_byte: return Constant.fromValue(left.byteValue() >>> right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() >>> right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() >>> right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() >>> right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() >>> right.charValue());
+ case T_byte: return Constant.fromValue(left.shortValue() >>> right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() >>> right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() >>> right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() >>> right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() >>> right.charValue());
+ case T_byte: return Constant.fromValue(left.intValue() >>> right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() >>> right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() >>> right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() >>> right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() >>> right.charValue());
+ case T_byte: return Constant.fromValue(left.longValue() >>> right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() >>> right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() >>> right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() >>> right.longValue());
+ }
+
+ }
+
+ return NotAConstant;
+ }
+
+ public static final Constant computeConstantOperationXOR(Constant left, int leftId, int operator, Constant right, int rightId) {
+
+ switch (leftId){
+ case T_boolean : return Constant.fromValue(left.booleanValue() ^ right.booleanValue());
+ case T_char :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.charValue() ^ right.charValue());
+ case T_byte: return Constant.fromValue(left.charValue() ^ right.byteValue());
+ case T_short: return Constant.fromValue(left.charValue() ^ right.shortValue());
+ case T_int: return Constant.fromValue(left.charValue() ^ right.intValue());
+ case T_long: return Constant.fromValue(left.charValue() ^ right.longValue());
+ }
+ break;
+ case T_byte :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.byteValue() ^ right.charValue());
+ case T_byte: return Constant.fromValue(left.byteValue() ^ right.byteValue());
+ case T_short: return Constant.fromValue(left.byteValue() ^ right.shortValue());
+ case T_int: return Constant.fromValue(left.byteValue() ^ right.intValue());
+ case T_long: return Constant.fromValue(left.byteValue() ^ right.longValue());
+ }
+ break;
+ case T_short :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.shortValue() ^ right.charValue());
+ case T_byte: return Constant.fromValue(left.shortValue() ^ right.byteValue());
+ case T_short: return Constant.fromValue(left.shortValue() ^ right.shortValue());
+ case T_int: return Constant.fromValue(left.shortValue() ^ right.intValue());
+ case T_long: return Constant.fromValue(left.shortValue() ^ right.longValue());
+ }
+ break;
+ case T_int :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.intValue() ^ right.charValue());
+ case T_byte: return Constant.fromValue(left.intValue() ^ right.byteValue());
+ case T_short: return Constant.fromValue(left.intValue() ^ right.shortValue());
+ case T_int: return Constant.fromValue(left.intValue() ^ right.intValue());
+ case T_long: return Constant.fromValue(left.intValue() ^ right.longValue());
+ }
+ break;
+ case T_long :
+ switch (rightId){
+ case T_char : return Constant.fromValue(left.longValue() ^ right.charValue());
+ case T_byte: return Constant.fromValue(left.longValue() ^ right.byteValue());
+ case T_short: return Constant.fromValue(left.longValue() ^ right.shortValue());
+ case T_int: return Constant.fromValue(left.longValue() ^ right.intValue());
+ case T_long: return Constant.fromValue(left.longValue() ^ right.longValue());
+ }
+ }
+
+ return NotAConstant;
+ }
+
+ public double doubleValue() {
+
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"double")); //$NON-NLS-2$ //$NON-NLS-1$
+ }
+
+ public float floatValue() {
+
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"float")); //$NON-NLS-2$ //$NON-NLS-1$
+ }
+
+ public static Constant fromValue(byte value) {
+
+ return new ByteConstant(value);
+ }
+
+ public static Constant fromValue(char value) {
+
+ return new CharConstant(value);
+ }
+
+ public static Constant fromValue(double value) {
+
+ return new DoubleConstant(value);
+ }
+
+ public static Constant fromValue(float value) {
+
+ return new FloatConstant(value);
+ }
+
+ public static Constant fromValue(int value) {
+
+ return new IntConstant(value);
+ }
+
+ public static Constant fromValue(long value) {
+
+ return new LongConstant(value);
+ }
+
+ public static Constant fromValue(String value) {
+
+ return new StringConstant(value);
+ }
+
+ public static Constant fromValue(short value) {
+
+ return new ShortConstant(value);
+ }
+
+ public static Constant fromValue(boolean value) {
+
+ return new BooleanConstant(value);
+ }
+
+ public int intValue() {
+
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"int")); //$NON-NLS-2$ //$NON-NLS-1$
+ }
+
+ public long longValue() {
+
+ throw new ShouldNotImplement(Util.bind("constant.cannotCastedInto",typeName(),"long")); //$NON-NLS-2$ //$NON-NLS-1$
+ }
+
+ public short shortValue() {
+
+ throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo",typeName(),"short")); //$NON-NLS-2$ //$NON-NLS-1$
+ }
+
+ public String stringValue() {
+
+ throw new ShouldNotImplement(Util.bind("constant.cannotConvertedTo",typeName(),"String")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public String toString(){
+
+ if (this == NotAConstant) return "(Constant) NotAConstant"; //$NON-NLS-1$
+ return super.toString(); }
+
+ public abstract int typeID();
+
+ public String typeName() {
+ switch (typeID()) {
+ case T_int : return "int"; //$NON-NLS-1$
+ case T_byte : return "byte"; //$NON-NLS-1$
+ case T_short : return "short"; //$NON-NLS-1$
+ case T_char : return "char"; //$NON-NLS-1$
+ case T_float : return "float"; //$NON-NLS-1$
+ case T_double : return "double"; //$NON-NLS-1$
+ case T_boolean : return "boolean"; //$NON-NLS-1$
+ case T_long : return "long";//$NON-NLS-1$
+ case T_String : return "java.lang.String"; //$NON-NLS-1$
+ case T_null : return "null"; //$NON-NLS-1$
+ default: return "unknown"; //$NON-NLS-1$
+ }
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java
index 684fe96..d18ca7f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
public class DoubleConstant extends Constant {
@@ -47,8 +47,7 @@
}
public String stringValue() {
- //spec 15.17.11
- String s = new Double(value).toString();
+ String s = Double.toString(value);
if (s == null)
return "null"; //$NON-NLS-1$
else
@@ -64,4 +63,4 @@
public int typeID() {
return T_double;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java
index 031447d..013ae9d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
public class FloatConstant extends Constant {
@@ -47,8 +47,7 @@
}
public String stringValue() {
- //spec 15.17.11
- String s = new Float(value).toString();
+ String s = Float.toString(value);
if (s == null)
return "null"; //$NON-NLS-1$
else
@@ -62,4 +61,4 @@
public int typeID() {
return T_float;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ITypeRequestor.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ITypeRequestor.java
index ced3157..c2d3439 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ITypeRequestor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ITypeRequestor.java
@@ -1,20 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.env.ISourceType;
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-
+
public interface ITypeRequestor {
/**
@@ -34,4 +34,4 @@
* requested type.
*/
void accept(ISourceType[] sourceType, PackageBinding packageBinding);
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java
index 0f1f846..48ec7dd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
public class IntConstant extends Constant {
@@ -62,4 +62,4 @@
public int typeID() {
return T_int;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java
index bdede47..4465487 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
public class LongConstant extends Constant {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/NullConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/NullConstant.java
deleted file mode 100644
index 2c8f6ba..0000000
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/NullConstant.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.internal.compiler.impl;
-
-public class NullConstant extends Constant {
- public static final NullConstant Default = new NullConstant();
-
- final static String NullString = new StringBuffer(4).append((String)null).toString();
-private NullConstant() {
-}
-public String stringValue() {
-
- return NullString;
-}
-public String toString(){
-
- return "(null)" + null ; } //$NON-NLS-1$
-public int typeID() {
- return T_null;
-}
-}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java
index 8d8ae1a..d5d04a3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ReferenceContext.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
/*
* Implementors are valid compilation contexts from which we can
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java
index cef6901..a2c5f83 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
public class ShortConstant extends Constant {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/StringConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/StringConstant.java
index 3ebc60a..850ea69 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/StringConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/StringConstant.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
public class StringConstant extends Constant {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
index 15e36ed..8e293ab 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ArrayBinding.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.impl.Constant;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public final class ArrayBinding extends TypeBinding {
// creation and initialization of the length field
@@ -47,6 +47,10 @@
brackets.append("[]"); //$NON-NLS-1$
return leafComponentType.debugName() + brackets.toString();
}
+public int dimensions() {
+ return this.dimensions;
+}
+
/* Answer an array whose dimension size is one less than the receiver.
*
* When the receiver's dimension size is one then answer the leaf component type.
@@ -64,7 +68,7 @@
/* Answer true if the receiver type can be assigned to the argument type (right)
*/
-boolean isCompatibleWith(TypeBinding right) {
+public boolean isCompatibleWith(TypeBinding right) {
if (this == right)
return true;
@@ -129,6 +133,14 @@
}
return CharOperation.concat(leafComponentType.readableName(), brackets);
}
+public char[] shortReadableName(){
+ char[] brackets = new char[dimensions * 2];
+ for (int i = dimensions * 2 - 1; i >= 0; i -= 2) {
+ brackets[i] = ']';
+ brackets[i - 1] = '[';
+ }
+ return CharOperation.concat(leafComponentType.shortReadableName(), brackets);
+}
public char[] sourceName() {
char[] brackets = new char[dimensions * 2];
for (int i = dimensions * 2 - 1; i >= 0; i -= 2) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java
index a9f6f78..1c2cd15 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypeBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public final class BaseTypeBinding extends TypeBinding {
@@ -31,7 +31,7 @@
/* Answer true if the receiver type can be assigned to the argument type (right)
*/
-final boolean isCompatibleWith(TypeBinding right) {
+public final boolean isCompatibleWith(TypeBinding right) {
if (this == right)
return true;
if (!right.isBaseType())
@@ -146,6 +146,9 @@
public char[] readableName() {
return simpleName;
}
+public char[] shortReadableName(){
+ return simpleName;
+}
public char[] sourceName() {
return simpleName;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypes.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypes.java
index e734c5b..f56d688 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypes.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BaseTypes.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public interface BaseTypes {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
index d7bab4f..0395d61 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java
@@ -1,22 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.env.IBinaryField;
import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/*
Not all fields defined by this type are initialized when it is created.
@@ -220,17 +220,28 @@
this);
return binding;
}
+/**
+ * Create method bindings for binary type, filtering out <clinit> and synthetics
+ */
private void createMethods(IBinaryMethod[] iMethods) {
- int total = 0;
- int clinitIndex = -1;
+ int total = 0, initialTotal = 0, iClinit = -1;
+ int[] toSkip = null;
if (iMethods != null) {
- total = iMethods.length;
+ total = initialTotal = iMethods.length;
for (int i = total; --i >= 0;) {
- char[] methodName = iMethods[i].getSelector();
- if (methodName[0] == '<' && methodName.length == 8) { // Can only match <clinit>
+ IBinaryMethod method = iMethods[i];
+ if ((method.getModifiers() & AccSynthetic) != 0) {
+ // discard synthetics methods
+ if (toSkip == null) toSkip = new int[iMethods.length];
+ toSkip[i] = -1;
total--;
- clinitIndex = i;
- break;
+ } else if (iClinit == -1) {
+ char[] methodName = method.getSelector();
+ if (methodName.length == 8 && methodName[0] == '<') {
+ // discard <clinit>
+ iClinit = i;
+ total--;
+ }
}
}
}
@@ -240,10 +251,14 @@
}
this.methods = new MethodBinding[total];
- int next = 0;
- for (int i = 0, length = iMethods.length; i < length; i++)
- if (i != clinitIndex)
- this.methods[next++] = createMethod(iMethods[i]);
+ if (total == initialTotal) {
+ for (int i = 0; i < initialTotal; i++)
+ this.methods[i] = createMethod(iMethods[i]);
+ } else {
+ for (int i = 0, index = 0; i < initialTotal; i++)
+ if (iClinit != i && (toSkip == null || toSkip[i] != -1))
+ this.methods[index++] = createMethod(iMethods[i]);
+ }
modifiers |= AccUnresolved; // until methods() is sent
}
/* Answer the receiver's enclosing type... null if the receiver is a top level type.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java
index 39fdc26..9b3c6c9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java
@@ -1,41 +1,45 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public abstract class Binding implements BindingIds, CompilerModifiers, ProblemReasons {
-/* API
-* Answer the receiver's binding type from Binding.BindingID.
-*
-* Note: Do NOT expect this to be used very often... only in switch statements with
-* more than 2 possible choices.
-*/
+ /* API
+ * Answer the receiver's binding type from Binding.BindingID.
+ *
+ * Note: Do NOT expect this to be used very often... only in switch statements with
+ * more than 2 possible choices.
+ */
+ public abstract int bindingType();
+ /* API
+ * Answer true if the receiver is not a problem binding
+ */
+
+ public final boolean isValidBinding() {
+ return problemId() == NoError;
+ }
+ /* API
+ * Answer the problem id associated with the receiver.
+ * NoError if the receiver is a valid binding.
+ */
+
+ public int problemId() {
+ return NoError;
+ }
+ /* Answer a printable representation of the receiver.
+ */
+ public abstract char[] readableName();
-public abstract int bindingType();
-/* API
-* Answer true if the receiver is not a problem binding
-*/
-
-public final boolean isValidBinding() {
- return problemId() == NoError;
-}
-/* API
-* Answer the problem id associated with the receiver.
-* NoError if the receiver is a valid binding.
-*/
-
-public int problemId() {
- return NoError;
-}
-/* Answer a printable representation of the receiver.
-*/
-
-public abstract char[] readableName();
+ /* Shorter printable representation of the receiver (no qualified type)
+ */
+ public char[] shortReadableName(){
+ return readableName();
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BindingIds.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BindingIds.java
index 32a8144..b69b12a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BindingIds.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BindingIds.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public interface BindingIds {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
index b3be0a2..21d0448 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
@@ -19,7 +20,6 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class BlockScope extends Scope {
@@ -30,10 +30,13 @@
public int offset; // for variable allocation throughout scopes
public int maxOffset; // for variable allocation throughout scopes
- // finally scopes must be shifted behind respective try scope
+ // finally scopes must be shifted behind respective try&catch scope(s) so as to avoid
+ // collisions of secret variables (return address, save value).
public BlockScope[] shiftScopes;
public final static VariableBinding[] EmulationPathToImplicitThis = {};
+ public final static VariableBinding[] NoEnclosingInstanceInConstructorCall = {};
+ public final static VariableBinding[] NoEnclosingInstanceInStaticContext = {};
public Scope[] subscopes = new Scope[1]; // need access from code assist
public int scopeIndex = 0; // need access from code assist
@@ -100,8 +103,8 @@
} while ((scope = scope.parent) instanceof BlockScope);
ClassScope localTypeScope = new ClassScope(this, localType);
- localTypeScope.buildLocalTypeBinding(enclosingSourceType());
addSubscope(localTypeScope);
+ localTypeScope.buildLocalTypeBinding(enclosingSourceType());
}
/* Insert a local variable into a given scope, updating its position
@@ -151,9 +154,8 @@
if (methodScope.isStatic != binding.isStatic())
return false;
return methodScope.isInsideInitializer() // inside initializer
- || ((AbstractMethodDeclaration) methodScope.referenceContext)
- .isInitializationMethod();
- // inside constructor or clinit
+ || ((AbstractMethodDeclaration) methodScope.referenceContext)
+ .isInitializationMethod(); // inside constructor or clinit
}
String basicToString(int tab) {
String newLine = "\n"; //$NON-NLS-1$
@@ -187,27 +189,20 @@
/* Compute variable positions in scopes given an initial position offset
* ignoring unused local variables.
*
- * Special treatment to have Try secret return address variables located at non
- * colliding positions. Return addresses are not allocated initially, but gathered
- * and allocated behind all other variables.
+ * No argument is expected here (ilocal is the first non-argument local of the outermost scope)
+ * Arguments are managed by the MethodScope method
*/
- public void computeLocalVariablePositions(
- int initOffset,
- CodeStream codeStream) {
+ void computeLocalVariablePositions(int ilocal, int initOffset, CodeStream codeStream) {
this.offset = initOffset;
this.maxOffset = initOffset;
// local variable init
- int ilocal = 0, maxLocals = 0, localsLength = locals.length;
- while ((maxLocals < localsLength) && (locals[maxLocals] != null))
- maxLocals++;
- boolean hasMoreVariables = maxLocals > 0;
+ int maxLocals = this.localIndex;
+ boolean hasMoreVariables = ilocal < maxLocals;
// scope init
- int iscope = 0, maxScopes = 0, subscopesLength = subscopes.length;
- while ((maxScopes < subscopesLength) && (subscopes[maxScopes] != null))
- maxScopes++;
+ int iscope = 0, maxScopes = this.scopeIndex;
boolean hasMoreScopes = maxScopes > 0;
// iterate scopes and variables in parallel
@@ -218,60 +213,55 @@
if (subscopes[iscope] instanceof BlockScope) {
BlockScope subscope = (BlockScope) subscopes[iscope];
int subOffset = subscope.shiftScopes == null ? this.offset : subscope.maxShiftedOffset();
- subscope.computeLocalVariablePositions(subOffset, codeStream);
+ subscope.computeLocalVariablePositions(0, subOffset, codeStream);
if (subscope.maxOffset > this.maxOffset)
this.maxOffset = subscope.maxOffset;
}
hasMoreScopes = ++iscope < maxScopes;
} else {
+
// consider variable first
- LocalVariableBinding local = locals[ilocal];
-
+ LocalVariableBinding local = locals[ilocal]; // if no local at all, will be locals[ilocal]==null
+
// check if variable is actually used, and may force it to be preserved
- boolean generatesLocal =
- (local.used && (local.constant == Constant.NotAConstant)) || local.isArgument;
- if (!local.used
+ boolean generateCurrentLocalVar = (local.useFlag == LocalVariableBinding.USED && (local.constant == Constant.NotAConstant));
+
+ // do not report fake used variable
+ if (local.useFlag == LocalVariableBinding.UNUSED
&& (local.declaration != null) // unused (and non secret) local
&& ((local.declaration.bits & AstNode.IsLocalDeclarationReachableMASK) != 0)) { // declaration is reachable
- if (local.isArgument) // method argument
- this.problemReporter().unusedArgument(local.declaration);
- else if (!(local.declaration instanceof Argument)) // do not report unused catch arguments
+
+ if (!(local.declaration instanceof Argument)) // do not report unused catch arguments
this.problemReporter().unusedLocalVariable(local.declaration);
}
- if (!generatesLocal) {
- if (local.declaration != null
- && environment().options.preserveAllLocalVariables) {
- generatesLocal = true; // force it to be preserved in the generated code
- local.used = true;
+
+ // could be optimized out, but does need to preserve unread variables ?
+ if (!generateCurrentLocalVar) {
+ if (local.declaration != null && environment().options.preserveAllLocalVariables) {
+ generateCurrentLocalVar = true; // force it to be preserved in the generated code
+ local.useFlag = LocalVariableBinding.USED;
}
}
- if (generatesLocal) {
+
+ // allocate variable
+ if (generateCurrentLocalVar) {
if (local.declaration != null) {
- codeStream.record(local);
- // record user local variables for attribute generation
+ codeStream.record(local); // record user-defined local variables for attribute generation
}
- // allocate variable position
+ // assign variable position
local.resolvedPosition = this.offset;
- // check for too many arguments/local variables
- if (local.isArgument) {
- if (this.offset > 0xFF) { // no more than 255 words of arguments
- this.problemReporter().noMoreAvailableSpaceForArgument(local, local.declaration);
- }
- } else {
- if (this.offset > 0xFFFF) { // no more than 65535 words of locals
- this.problemReporter().noMoreAvailableSpaceForLocal(
- local, local.declaration == null ? (AstNode)this.methodScope().referenceContext : local.declaration);
- }
- }
-
- // increment offset
if ((local.type == LongBinding) || (local.type == DoubleBinding)) {
this.offset += 2;
} else {
this.offset++;
}
+ if (this.offset > 0xFFFF) { // no more than 65535 words of locals
+ this.problemReporter().noMoreAvailableSpaceForLocal(
+ local,
+ local.declaration == null ? (AstNode)this.methodScope().referenceContext : local.declaration);
+ }
} else {
local.resolvedPosition = -1; // not generated
}
@@ -322,57 +312,6 @@
}
}
- /*
- * Record the suitable binding denoting a synthetic field or constructor argument,
- * mapping to a given actual enclosing instance type in the scope context.
- * Skip it if the enclosingType is actually the current scope's enclosing type.
- */
-
- public void emulateOuterAccess(
- ReferenceBinding targetEnclosingType,
- boolean useDirectReference) {
-
- ReferenceBinding currentType = enclosingSourceType();
- if (currentType.isNestedType()
- && currentType != targetEnclosingType){
- /*&& !targetEnclosingType.isSuperclassOf(currentType)*/
-
- if (useDirectReference) {
- // the target enclosing type is not in scope, we directly refer it
- // must also add a synthetic field if we're not inside a constructor
- NestedTypeBinding currentNestedType = (NestedTypeBinding) currentType;
- if (methodScope().isInsideInitializerOrConstructor())
- currentNestedType.addSyntheticArgument(targetEnclosingType);
- else
- currentNestedType.addSyntheticArgumentAndField(targetEnclosingType);
-
- } else { // indirect reference sequence
- int depth = 0;
-
- // saturate all the way up until reaching compatible enclosing type
- while (currentType.isLocalType()){
- NestedTypeBinding currentNestedType = (NestedTypeBinding) currentType;
- currentType = currentNestedType.enclosingType;
-
- if (depth == 0){
- if (methodScope().isInsideInitializerOrConstructor()) {
- // must also add a synthetic field if we're not inside a constructor
- currentNestedType.addSyntheticArgument(currentType);
- } else {
- currentNestedType.addSyntheticArgumentAndField(currentType);
- }
- } else if (currentNestedType == targetEnclosingType
- || targetEnclosingType.isSuperclassOf(currentNestedType)) {
- break;
- } else {
- currentNestedType.addSyntheticArgumentAndField(currentType);
- }
- depth++;
- }
- }
- }
- }
-
/* Note that it must never produce a direct access to the targetEnclosingType,
* but instead a field sequence (this$2.this$1.this$0) so as to handle such a test case:
*
@@ -824,86 +763,6 @@
else
return new ProblemBinding(name, enclosingSourceType(), NotFound);
}
-
- /*
- * This retrieves the argument that maps to an enclosing instance of the suitable type,
- * if not found then answers nil -- do not create one
- *
- * #implicitThis : the implicit this will be ok
- * #((arg) this$n) : available as a constructor arg
- * #((arg) this$n access$m... access$p) : available as as a constructor arg + a sequence of synthetic accessors to synthetic fields
- * #((fieldDescr) this$n access#m... access$p) : available as a first synthetic field + a sequence of synthetic accessors to synthetic fields
- * nil : not found
- *
- */
- public Object[] getCompatibleEmulationPath(ReferenceBinding targetEnclosingType) {
-
- MethodScope currentMethodScope = this.methodScope();
- SourceTypeBinding sourceType = currentMethodScope.enclosingSourceType();
-
- // identity check
- if (!currentMethodScope.isStatic
- && !currentMethodScope.isConstructorCall
- && (sourceType == targetEnclosingType
- || targetEnclosingType.isSuperclassOf(sourceType))) {
- return EmulationPathToImplicitThis; // implicit this is good enough
- }
- if (!sourceType.isNestedType()
- || sourceType.isStatic()) { // no emulation from within non-inner types
- return null;
- }
- boolean insideConstructor =
- currentMethodScope.isInsideInitializerOrConstructor();
- // use synthetic constructor arguments if possible
- if (insideConstructor) {
- SyntheticArgumentBinding syntheticArg;
- if ((syntheticArg = ((NestedTypeBinding) sourceType).getSyntheticArgument(targetEnclosingType, this, false)) != null) {
- return new Object[] { syntheticArg };
- }
- }
-
- // use a direct synthetic field then
- if (!currentMethodScope.isStatic) {
- FieldBinding syntheticField;
- if ((syntheticField = sourceType.getSyntheticField(targetEnclosingType, this, false)) != null) {
- return new Object[] { syntheticField };
- }
- // could be reached through a sequence of enclosing instance link (nested members)
- Object[] path = new Object[2]; // probably at least 2 of them
- ReferenceBinding currentType = sourceType.enclosingType();
- if (insideConstructor) {
- path[0] = ((NestedTypeBinding) sourceType).getSyntheticArgument((SourceTypeBinding) currentType, this, false);
- } else {
- path[0] =
- sourceType.getSyntheticField((SourceTypeBinding) currentType, this, false);
- }
- if (path[0] != null) { // keep accumulating
- int count = 1;
- ReferenceBinding currentEnclosingType;
- while ((currentEnclosingType = currentType.enclosingType()) != null) {
- //done?
- if (currentType == targetEnclosingType
- || targetEnclosingType.isSuperclassOf(currentType))
- break;
- syntheticField = ((NestedTypeBinding) currentType).getSyntheticField((SourceTypeBinding) currentEnclosingType, this, false);
- if (syntheticField == null)
- break;
- // append inside the path
- if (count == path.length) {
- System.arraycopy(path, 0, (path = new Object[count + 1]), 0, count);
- }
- // private access emulation is necessary since synthetic field is private
- path[count++] = ((SourceTypeBinding) syntheticField.declaringClass).addSyntheticMethod(syntheticField, true);
- currentType = currentEnclosingType;
- }
- if (currentType == targetEnclosingType
- || targetEnclosingType.isSuperclassOf(currentType)) {
- return path;
- }
- }
- }
- return null;
- }
/* API
*
@@ -922,18 +781,18 @@
compilationUnitScope().recordTypeReference(receiverType);
compilationUnitScope().recordTypeReferences(argumentTypes);
MethodBinding methodBinding = receiverType.getExactConstructor(argumentTypes);
- if (methodBinding != null)
+ if (methodBinding != null) {
if (methodBinding.canBeSeenBy(invocationSite, this))
return methodBinding;
-
+ }
MethodBinding[] methods =
receiverType.getMethods(ConstructorDeclaration.ConstantPoolName);
- if (methods == NoMethods)
+ if (methods == NoMethods) {
return new ProblemMethodBinding(
ConstructorDeclaration.ConstantPoolName,
argumentTypes,
NotFound);
-
+ }
MethodBinding[] compatible = new MethodBinding[methods.length];
int compatibleIndex = 0;
for (int i = 0, length = methods.length; i < length; i++)
@@ -957,8 +816,9 @@
return visible[0];
if (visibleIndex == 0)
return new ProblemMethodBinding(
+ compatible[0],
ConstructorDeclaration.ConstantPoolName,
- argumentTypes,
+ compatible[0].parameters,
NotVisible);
return mostSpecificClassMethodBinding(visible, visibleIndex);
}
@@ -967,9 +827,9 @@
* This retrieves the argument that maps to an enclosing instance of the suitable type,
* if not found then answers nil -- do not create one
*
- * #implicitThis : the implicit this will be ok
- * #((arg) this$n) : available as a constructor arg
- * #((arg) this$n ... this$p) : available as as a constructor arg + a sequence of fields
+ * #implicitThis : the implicit this will be ok
+ * #((arg) this$n) : available as a constructor arg
+ * #((arg) this$n ... this$p) : available as as a constructor arg + a sequence of fields
* #((fieldDescr) this$n ... this$p) : available as a sequence of fields
* nil : not found
*
@@ -1012,80 +872,108 @@
* This retrieves the argument that maps to an enclosing instance of the suitable type,
* if not found then answers nil -- do not create one
*
- * #implicitThis : the implicit this will be ok
+ * #implicitThis : the implicit this will be ok
* #((arg) this$n) : available as a constructor arg
* #((arg) this$n access$m... access$p) : available as as a constructor arg + a sequence of synthetic accessors to synthetic fields
* #((fieldDescr) this$n access#m... access$p) : available as a first synthetic field + a sequence of synthetic accessors to synthetic fields
- * nil : not found
- *
- * EXACT MATCH VERSION - no type compatibility is performed
+ * nil : not found
+ * jls 15.9.2
*/
- public Object[] getExactEmulationPath(ReferenceBinding targetEnclosingType) {
-
+ public Object[] getEmulationPath(
+ ReferenceBinding targetEnclosingType,
+ boolean onlyExactMatch,
+ boolean ignoreEnclosingArgInConstructorCall) {
+ //TODO: (philippe) investigate why exactly test76 fails if ignoreEnclosingArgInConstructorCall is always false
MethodScope currentMethodScope = this.methodScope();
SourceTypeBinding sourceType = currentMethodScope.enclosingSourceType();
// identity check
if (!currentMethodScope.isStatic
- && !currentMethodScope.isConstructorCall
- && (sourceType == targetEnclosingType)) {
+ && (!currentMethodScope.isConstructorCall || ignoreEnclosingArgInConstructorCall)
+ && (sourceType == targetEnclosingType
+ || (!onlyExactMatch && targetEnclosingType.isSuperclassOf(sourceType)))) {
+ if (currentMethodScope.isConstructorCall) {
+ return NoEnclosingInstanceInConstructorCall;
+ }
+ if (currentMethodScope.isStatic){
+ return NoEnclosingInstanceInStaticContext;
+ }
return EmulationPathToImplicitThis; // implicit this is good enough
}
- if (!sourceType.isNestedType()
- || sourceType.isStatic()) { // no emulation from within non-inner types
+ if (!sourceType.isNestedType() || sourceType.isStatic()) { // no emulation from within non-inner types
+ if (currentMethodScope.isConstructorCall) {
+ return NoEnclosingInstanceInConstructorCall;
+ }
+ if (currentMethodScope.isStatic){
+ return NoEnclosingInstanceInStaticContext;
+ }
return null;
}
-
- boolean insideConstructor =
- currentMethodScope.isInsideInitializerOrConstructor();
+ boolean insideConstructor = currentMethodScope.isInsideInitializerOrConstructor();
// use synthetic constructor arguments if possible
if (insideConstructor) {
SyntheticArgumentBinding syntheticArg;
- if ((syntheticArg = ((NestedTypeBinding) sourceType).getSyntheticArgument(targetEnclosingType, this, true)) != null) {
+ if ((syntheticArg = ((NestedTypeBinding) sourceType).getSyntheticArgument(targetEnclosingType, onlyExactMatch)) != null) {
return new Object[] { syntheticArg };
}
}
+
// use a direct synthetic field then
- if (!currentMethodScope.isStatic) {
- FieldBinding syntheticField;
- if ((syntheticField = sourceType.getSyntheticField(targetEnclosingType, this, true)) != null) {
- return new Object[] { syntheticField };
+ if (currentMethodScope.isStatic) {
+ return NoEnclosingInstanceInStaticContext;
+ }
+ FieldBinding syntheticField = sourceType.getSyntheticField(targetEnclosingType, onlyExactMatch);
+ if (syntheticField != null) {
+ if (currentMethodScope.isConstructorCall){
+ return NoEnclosingInstanceInConstructorCall;
}
- // could be reached through a sequence of enclosing instance link (nested members)
- Object[] path = new Object[2]; // probably at least 2 of them
- ReferenceBinding currentType = sourceType.enclosingType();
- if (insideConstructor) {
- path[0] =
- ((NestedTypeBinding) sourceType).getSyntheticArgument((SourceTypeBinding) currentType, this, true);
- } else {
- path[0] =
- sourceType.getSyntheticField((SourceTypeBinding) currentType, this, true);
+ return new Object[] { syntheticField };
+ }
+ // could be reached through a sequence of enclosing instance link (nested members)
+ Object[] path = new Object[2]; // probably at least 2 of them
+ ReferenceBinding currentType = sourceType.enclosingType();
+ if (insideConstructor) {
+ path[0] = ((NestedTypeBinding) sourceType).getSyntheticArgument((SourceTypeBinding) currentType, onlyExactMatch);
+ } else {
+ if (currentMethodScope.isConstructorCall){
+ return NoEnclosingInstanceInConstructorCall;
}
- if (path[0] != null) { // keep accumulating
- int count = 1;
- ReferenceBinding currentEnclosingType;
- while ((currentEnclosingType = currentType.enclosingType()) != null) {
- //done?
- if (currentType == targetEnclosingType)
- break;
- syntheticField =
- ((NestedTypeBinding) currentType).getSyntheticField(
- (SourceTypeBinding) currentEnclosingType,
- this,
- true);
- if (syntheticField == null)
- break;
- // append inside the path
- if (count == path.length) {
- System.arraycopy(path, 0, (path = new Object[count + 1]), 0, count);
+ path[0] = sourceType.getSyntheticField((SourceTypeBinding) currentType, onlyExactMatch);
+ }
+ if (path[0] != null) { // keep accumulating
+
+ int count = 1;
+ ReferenceBinding currentEnclosingType;
+ while ((currentEnclosingType = currentType.enclosingType()) != null) {
+
+ //done?
+ if (currentType == targetEnclosingType
+ || (!onlyExactMatch && targetEnclosingType.isSuperclassOf(currentType))) break;
+
+ if (currentMethodScope != null) {
+ currentMethodScope = currentMethodScope.enclosingMethodScope();
+ if (currentMethodScope != null && currentMethodScope.isConstructorCall){
+ return NoEnclosingInstanceInConstructorCall;
}
- // private access emulation is necessary since synthetic field is private
- path[count++] = ((SourceTypeBinding) syntheticField.declaringClass).addSyntheticMethod(syntheticField, true);
- currentType = currentEnclosingType;
+ if (currentMethodScope != null && currentMethodScope.isStatic){
+ return NoEnclosingInstanceInStaticContext;
+ }
}
- if (currentType == targetEnclosingType) {
- return path;
+
+ syntheticField = ((NestedTypeBinding) currentType).getSyntheticField((SourceTypeBinding) currentEnclosingType, onlyExactMatch);
+ if (syntheticField == null) break;
+
+ // append inside the path
+ if (count == path.length) {
+ System.arraycopy(path, 0, (path = new Object[count + 1]), 0, count);
}
+ // private access emulation is necessary since synthetic field is private
+ path[count++] = ((SourceTypeBinding) syntheticField.declaringClass).addSyntheticMethod(syntheticField, true);
+ currentType = currentEnclosingType;
+ }
+ if (currentType == targetEnclosingType
+ || (!onlyExactMatch && targetEnclosingType.isSuperclassOf(currentType))) {
+ return path;
}
}
return null;
@@ -1202,15 +1090,15 @@
return new ProblemMethodBinding(methodBinding, selector, argumentTypes, NotFound);
}
// make the user qualify the method, likely wants the first inherited method (javac generates an ambiguous error instead)
- fuzzyProblem = new ProblemMethodBinding(selector, argumentTypes, InheritedNameHidesEnclosingName);
+ fuzzyProblem = new ProblemMethodBinding(selector, methodBinding.parameters, InheritedNameHidesEnclosingName);
} else if (!methodBinding.canBeSeenBy(receiverType, invocationSite, classScope)) {
// using <classScope> instead of <this> for visibility check does grant all access to innerclass
fuzzyProblem =
new ProblemMethodBinding(
+ methodBinding,
selector,
- argumentTypes,
- methodBinding.declaringClass,
+ methodBinding.parameters,
NotVisible);
}
}
@@ -1327,8 +1215,7 @@
ReferenceBinding currentType = (ReferenceBinding) receiverType;
if (!currentType.canBeSeenBy(this))
- return new ProblemMethodBinding(selector, argumentTypes, NotVisible);
- // *** Need a new problem id - TypeNotVisible?
+ return new ProblemMethodBinding(selector, argumentTypes, ReceiverTypeNotVisible);
// retrieve an exact visible match (if possible)
MethodBinding methodBinding =
@@ -1350,9 +1237,9 @@
NotFound);
if (!methodBinding.canBeSeenBy(currentType, invocationSite, this))
return new ProblemMethodBinding(
+ methodBinding,
selector,
- argumentTypes,
- methodBinding.declaringClass,
+ methodBinding.parameters,
NotVisible);
}
return methodBinding;
@@ -1384,25 +1271,10 @@
* Code responsible to request some more emulation work inside the invocation type, so as to supply
* correct synthetic arguments to any allocation of the target type.
*/
- public void propagateInnerEmulation(
- ReferenceBinding targetType,
- boolean isEnclosingInstanceSupplied,
- boolean useDirectReference) {
+ public void propagateInnerEmulation(ReferenceBinding targetType, boolean isEnclosingInstanceSupplied) {
- // perform some emulation work in case there is some and we are inside a local type only
- // propage emulation of the enclosing instances
- ReferenceBinding[] syntheticArgumentTypes;
- if ((syntheticArgumentTypes = targetType.syntheticEnclosingInstanceTypes())
- != null) {
- for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) {
- ReferenceBinding syntheticArgType = syntheticArgumentTypes[i];
- // need to filter out the one that could match a supplied enclosing instance
- if (!(isEnclosingInstanceSupplied
- && (syntheticArgType == targetType.enclosingType()))) {
- this.emulateOuterAccess(syntheticArgType, useDirectReference);
- }
- }
- }
+ // no need to propagate enclosing instances, they got eagerly allocated already.
+
SyntheticArgumentBinding[] syntheticArguments;
if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) {
for (int i = 0, max = syntheticArguments.length; i < max; i++) {
@@ -1442,4 +1314,4 @@
s += ((BlockScope) subscopes[i]).toString(tab + 1) + "\n"; //$NON-NLS-1$
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index cd268ee..665d35e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Clinit;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
@@ -17,7 +18,6 @@
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
public class ClassScope extends Scope {
@@ -469,6 +469,9 @@
fieldBinding.declaringClass,
fieldDecl);
+ if (fieldDecl.initialization == null && (modifiers & AccFinal) != 0) {
+ modifiers |= AccBlankFinal;
+ }
fieldBinding.modifiers = modifiers;
}
@@ -565,12 +568,16 @@
*/
private boolean connectSuperclass() {
SourceTypeBinding sourceType = referenceContext.binding;
+ if (isJavaLangObject(sourceType)) { // handle the case of redefining java.lang.Object up front
+ sourceType.superclass = null;
+ sourceType.superInterfaces = NoSuperInterfaces;
+ if (referenceContext.superclass != null || referenceContext.superInterfaces != null)
+ problemReporter().objectCannotHaveSuperTypes(sourceType);
+ return true; // do not propagate Object's hierarchy problems down to every subtype
+ }
if (referenceContext.superclass == null) {
- if (isJavaLangObject(sourceType))
- return true;
sourceType.superclass = getJavaLangObject();
return !detectCycle(sourceType, sourceType.superclass, null);
- // ensure Object is initialized if it comes from a source file
}
ReferenceBinding superclass = findSupertype(referenceContext.superclass);
if (superclass != null) { // is null if a cycle was detected cycle
@@ -580,25 +587,17 @@
problemReporter().superclassMustBeAClass(sourceType, referenceContext.superclass, superclass);
} else if (superclass.isFinal()) {
problemReporter().classExtendFinalClass(sourceType, referenceContext.superclass, superclass);
- } else if (isJavaLangObject(sourceType)) {
- // can only happen if Object extends another type... will never happen unless we're testing for it.
- sourceType.tagBits |= HierarchyHasProblems;
- sourceType.superclass = null;
- return true;
} else {
// only want to reach here when no errors are reported
- referenceContext.superclass.binding = superclass;
+ referenceContext.superclass.resolvedType = superclass;
sourceType.superclass = superclass;
return true;
}
}
sourceType.tagBits |= HierarchyHasProblems;
- if (!isJavaLangObject(sourceType)) {
- sourceType.superclass = getJavaLangObject();
- if ((sourceType.superclass.tagBits & BeginHierarchyCheck) == 0)
- detectCycle(sourceType, sourceType.superclass, null);
- // ensure Object is initialized if it comes from a source file
- }
+ sourceType.superclass = getJavaLangObject();
+ if ((sourceType.superclass.tagBits & BeginHierarchyCheck) == 0)
+ detectCycle(sourceType, sourceType.superclass, null);
return false; // reported some error against the source type
}
@@ -617,6 +616,8 @@
sourceType.superInterfaces = NoSuperInterfaces;
if (referenceContext.superInterfaces == null)
return true;
+ if (isJavaLangObject(sourceType)) // already handled the case of redefining java.lang.Object
+ return true;
boolean noProblems = true;
int length = referenceContext.superInterfaces.length;
@@ -651,7 +652,8 @@
noProblems = false;
continue nextInterface;
}
- referenceContext.superInterfaces[i].binding = superInterface;
+
+ referenceContext.superInterfaces[i].resolvedType = superInterface;
// only want to reach here when no errors are reported
interfaceBindings[count++] = superInterface;
}
@@ -871,4 +873,4 @@
else
return "--- Class Scope ---\n\n Binding not initialized" ; //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
index 7a58220..7b66433 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
@@ -1,27 +1,28 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.CompoundNameVector;
import org.eclipse.jdt.internal.compiler.util.HashtableOfType;
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
import org.eclipse.jdt.internal.compiler.util.SimpleNameVector;
public class CompilationUnitScope extends Scope {
+
public LookupEnvironment environment;
public CompilationUnitDeclaration referenceContext;
public char[][] currentPackageName;
@@ -33,13 +34,15 @@
private CompoundNameVector qualifiedReferences;
private SimpleNameVector simpleNameReferences;
private ObjectVector referencedTypes;
+
+ HashtableOfType constantPoolNameUsage;
public CompilationUnitScope(CompilationUnitDeclaration unit, LookupEnvironment environment) {
super(COMPILATION_UNIT_SCOPE, null);
this.environment = environment;
this.referenceContext = unit;
unit.scope = this;
- this.currentPackageName = unit.currentPackage == null ? NoCharChar : unit.currentPackage.tokens;
+ this.currentPackageName = unit.currentPackage == null ? CharOperation.NO_CHAR_CHAR : unit.currentPackage.tokens;
if (environment.options.produceReferenceInfo) {
this.qualifiedReferences = new CompoundNameVector();
@@ -59,12 +62,19 @@
topLevelTypes = new SourceTypeBinding[0]; // want it initialized if the package cannot be resolved
if (referenceContext.compilationResult.compilationUnit != null) {
char[][] expectedPackageName = referenceContext.compilationResult.compilationUnit.getPackageName();
- if (expectedPackageName != null && !CharOperation.equals(currentPackageName, expectedPackageName)) {
- problemReporter().packageIsNotExpectedPackage(referenceContext);
- currentPackageName = expectedPackageName.length == 0 ? NoCharChar : expectedPackageName;
+ if (expectedPackageName != null
+ && !CharOperation.equals(currentPackageName, expectedPackageName)) {
+
+ // only report if the unit isn't structurally empty
+ if (referenceContext.currentPackage != null
+ || referenceContext.types != null
+ || referenceContext.imports != null) {
+ problemReporter().packageIsNotExpectedPackage(referenceContext);
+ }
+ currentPackageName = expectedPackageName.length == 0 ? CharOperation.NO_CHAR_CHAR : expectedPackageName;
}
}
- if (currentPackageName == NoCharChar) {
+ if (currentPackageName == CharOperation.NO_CHAR_CHAR) {
if ((fPackage = environment.defaultPackage) == null) {
problemReporter().mustSpecifyPackage(referenceContext);
return;
@@ -92,10 +102,7 @@
problemReporter().duplicateTypes(referenceContext, typeDecl);
continue nextType;
}
- boolean packageExists = currentPackageName == NoCharChar
- ? environment.getTopLevelPackage(typeDecl.name) != null
- : (fPackage.getPackage(typeDecl.name)) != null;
- if (packageExists) {
+ if (fPackage != environment.defaultPackage && fPackage.getPackage(typeDecl.name) != null) {
// if a package exists, it must be a valid package - cannot be a NotFound problem package
problemReporter().typeCollidesWithPackage(referenceContext, typeDecl);
continue nextType;
@@ -111,7 +118,10 @@
}
ClassScope child = new ClassScope(this, typeDecl);
- topLevelTypes[count++] = child.buildType(null, fPackage);
+ SourceTypeBinding type = child.buildType(null, fPackage);
+ if(type != null) {
+ topLevelTypes[count++] = type;
+ }
}
// shrink topLevelTypes... only happens if an error was reported
@@ -178,6 +188,65 @@
System.arraycopy(resolvedImports, 0, resolvedImports = new ImportBinding[index], 0, index);
imports = resolvedImports;
}
+/*
+ * INTERNAL USE-ONLY
+ * Innerclasses get their name computed as they are generated, since some may not
+ * be actually outputed if sitting inside unreachable code.
+ */
+public char[] computeConstantPoolName(LocalTypeBinding localType) {
+ if (localType.constantPoolName() != null) {
+ return localType.constantPoolName();
+ }
+ // delegates to the outermost enclosing classfile, since it is the only one with a global vision of its innertypes.
+
+ if (constantPoolNameUsage == null)
+ constantPoolNameUsage = new HashtableOfType();
+
+ ReferenceBinding outerMostEnclosingType = localType.scope.outerMostClassScope().enclosingSourceType();
+
+ // ensure there is not already such a local type name defined by the user
+ int index = 0;
+ char[] candidateName;
+ while(true) {
+ if (localType.isMemberType()){
+ if (index == 0){
+ candidateName = CharOperation.concat(
+ localType.enclosingType().constantPoolName(),
+ localType.sourceName,
+ '$');
+ } else {
+ // in case of collision, then member name gets extra $1 inserted
+ // e.g. class X { { class L{} new X(){ class L{} } } }
+ candidateName = CharOperation.concat(
+ localType.enclosingType().constantPoolName(),
+ '$',
+ String.valueOf(index).toCharArray(),
+ '$',
+ localType.sourceName);
+ }
+ } else if (localType.isAnonymousType()){
+ candidateName = CharOperation.concat(
+ outerMostEnclosingType.constantPoolName(),
+ String.valueOf(index+1).toCharArray(),
+ '$');
+ } else {
+ candidateName = CharOperation.concat(
+ outerMostEnclosingType.constantPoolName(),
+ '$',
+ String.valueOf(index+1).toCharArray(),
+ '$',
+ localType.sourceName);
+ }
+ if (constantPoolNameUsage.get(candidateName) != null) {
+ index ++;
+ } else {
+ constantPoolNameUsage.put(candidateName, localType);
+ break;
+ }
+ }
+ return candidateName;
+}
+
void connectTypeHierarchy() {
for (int i = 0, length = topLevelTypes.length; i < length; i++)
topLevelTypes[i].scope.connectTypeHierarchy();
@@ -219,10 +288,12 @@
for (int j = 0; j < index; j++)
if (resolvedImports[j].onDemand == importReference.onDemand)
if (CharOperation.equals(compoundName, resolvedImports[j].compoundName)) {
+ problemReporter().unusedImport(importReference); // since skipped, must be reported now
continue nextImport;
}
if (importReference.onDemand == true)
if (CharOperation.equals(compoundName, currentPackageName)) {
+ problemReporter().unusedImport(importReference); // since skipped, must be reported now
continue nextImport;
}
if (importReference.onDemand) {
@@ -242,6 +313,12 @@
problemReporter().cannotImportPackage(importReference);
continue nextImport;
}
+ if (typeBinding instanceof ReferenceBinding) {
+ ReferenceBinding referenceBinding = (ReferenceBinding) typeBinding;
+ if (importReference.isTypeUseDeprecated(referenceBinding, this)) {
+ problemReporter().deprecatedType((TypeBinding) typeBinding, importReference);
+ }
+ }
ReferenceBinding existingType = typesBySimpleNames.get(compoundName[compoundName.length - 1]);
if (existingType != null) {
// duplicate test above should have caught this case, but make sure
@@ -315,11 +392,15 @@
}
for (; i < length; i++) {
+ if (!type.canBeSeenBy(fPackage)) {
+ return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, i), type, NotVisible);
+ }
// does not look for inherited member types on purpose
- if ((type = type.getMemberType(compoundName[i])) == null)
+ if ((type = type.getMemberType(compoundName[i])) == null) {
return new ProblemReferenceBinding(
CharOperation.subarray(compoundName, 0, i + 1),
NotFound);
+ }
}
if (!type.canBeSeenBy(fPackage))
return new ProblemReferenceBinding(compoundName, type, NotVisible);
@@ -505,4 +586,4 @@
for (int i = 0, length = topLevelTypes.length; i < length; i++)
topLevelTypes[i].verifyMethods(verifier);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilerModifiers.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilerModifiers.java
index 4408f09..73e7658 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilerModifiers.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilerModifiers.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -16,17 +16,23 @@
// those constants are depending upon ClassFileConstants (relying that classfiles only use the 16 lower bits)
final int AccDefault = 0;
final int AccJustFlag = 0xFFFF;
- final int AccCatchesExceptions = 0x10000;
- final int AccThrowsExceptions = 0x20000;
- final int AccProblem = 0x40000;
- final int AccFromClassFile = 0x80000;
- final int AccIsConstantValue = 0x80000;
- final int AccDefaultAbstract = 0x80000;
- final int AccDeprecatedImplicitly = 0x200000; // ie. is deprecated itself or contained by a deprecated type
- final int AccAlternateModifierProblem = 0x400000;
- final int AccModifierProblem = 0x800000;
- final int AccSemicolonBody = 0x1000000;
- final int AccUnresolved = 0x2000000;
- final int AccClearPrivateModifier = 0x4000000; // might be requested during private access emulation
+ final int AccCatchesExceptions = 0x10000; // bit17
+ final int AccThrowsExceptions = 0x20000; // bit18 - also IConstants.AccSynthetic
+ final int AccProblem = 0x40000; // bit19
+ final int AccFromClassFile = 0x80000; // bit20
+ final int AccIsConstantValue = 0x80000; // bit20
+ final int AccDefaultAbstract = 0x80000; // bit20
+ // bit21 - IConstants.AccDeprecated
+ final int AccDeprecatedImplicitly = 0x200000; // bit22 ie. is deprecated itself or contained by a deprecated type
+ final int AccAlternateModifierProblem = 0x400000; // bit23
+ final int AccModifierProblem = 0x800000; // bit24
+ final int AccSemicolonBody = 0x1000000; // bit25
+ final int AccUnresolved = 0x2000000; // bit26
+ final int AccClearPrivateModifier = 0x4000000; // bit27 might be requested during private access emulation
+ final int AccBlankFinal = 0x4000000; // bit27 for blank final variables
+ final int AccPrivateUsed = 0x8000000; // bit28 used to diagnose unused private members
final int AccVisibilityMASK = AccPublic | AccProtected | AccPrivate;
+
+ final int AccOverriding = 0x10000000; // bit29 to record fact a method overrides another one
+ final int AccImplementing = 0x20000000; // bit30 to record fact a method implements another one (i.e. is concrete and overrides an abstract one)
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java
index 6db7b79..a2f5e06 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
@@ -138,6 +138,7 @@
public final int getAccessFlags() {
return modifiers & AccJustFlag;
}
+
/* Answer true if the receiver has default visibility
*/
@@ -156,6 +157,12 @@
public final boolean isPrivate() {
return (modifiers & AccPrivate) != 0;
}
+/* Answer true if the receiver has private visibility and is used locally
+*/
+
+public final boolean isPrivateUsed() {
+ return (modifiers & AccPrivateUsed) != 0;
+}
/* Answer true if the receiver has protected visibility
*/
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImportBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImportBinding.java
index e221988..bad794d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImportBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ImportBinding.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class ImportBinding extends Binding {
public char[][] compoundName;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InnerEmulationDependency.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InnerEmulationDependency.java
index 6c0d362..dc345cd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InnerEmulationDependency.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InnerEmulationDependency.java
@@ -1,23 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public class InnerEmulationDependency{
+
public BlockScope scope;
public boolean wasEnclosingInstanceSupplied;
- public boolean useDirectAccess;
-public InnerEmulationDependency(BlockScope scope, boolean wasEnclosingInstanceSupplied, boolean useDirectAccess) {
- this.scope = scope;
- this.wasEnclosingInstanceSupplied = wasEnclosingInstanceSupplied;
- this.useDirectAccess = useDirectAccess;
-}
+ public InnerEmulationDependency(BlockScope scope, boolean wasEnclosingInstanceSupplied) {
+ this.scope = scope;
+ this.wasEnclosingInstanceSupplied = wasEnclosingInstanceSupplied;
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
index 95a5330..9549fac 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public interface InvocationSite {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java
index 2d3940a..be127bf 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java
@@ -1,23 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.Util;
public final class LocalTypeBinding extends NestedTypeBinding {
final static char[] LocalTypePrefix = { '$', 'L', 'o', 'c', 'a', 'l', '$' };
private InnerEmulationDependency[] dependents;
+ ArrayBinding[] localArrayBindings; // used to cache array bindings of various dimensions for this local type
+
public LocalTypeBinding(ClassScope scope, SourceTypeBinding enclosingType) {
super(
new char[][] {CharOperation.concat(LocalTypePrefix, scope.referenceContext.name)},
@@ -34,7 +36,7 @@
* all its dependents so as to update them (see updateInnerEmulationDependents()).
*/
-public void addInnerEmulationDependent(BlockScope scope, boolean wasEnclosingInstanceSupplied, boolean useDirectAccess) {
+public void addInnerEmulationDependent(BlockScope scope, boolean wasEnclosingInstanceSupplied) {
int index;
if (dependents == null) {
index = 0;
@@ -46,7 +48,7 @@
return; // already stored
System.arraycopy(dependents, 0, (dependents = new InnerEmulationDependency[index + 1]), 0, index);
}
- dependents[index] = new InnerEmulationDependency(scope, wasEnclosingInstanceSupplied, useDirectAccess);
+ dependents[index] = new InnerEmulationDependency(scope, wasEnclosingInstanceSupplied);
// System.out.println("Adding dependency: "+ new String(scope.enclosingType().readableName()) + " --> " + new String(this.readableName()));
}
/* Answer the receiver's constant pool name.
@@ -57,9 +59,24 @@
public char[] constantPoolName() /* java/lang/Object */ {
return constantPoolName;
}
-public void constantPoolName(char[] computedConstantPoolName) /* java/lang/Object */ {
- this.constantPoolName = computedConstantPoolName;
+
+ArrayBinding createArrayType(int dimensionCount) {
+ if (localArrayBindings == null) {
+ localArrayBindings = new ArrayBinding[] {new ArrayBinding(this, dimensionCount)};
+ return localArrayBindings[0];
+ }
+
+ // find the cached array binding for this dimensionCount (if any)
+ int length = localArrayBindings.length;
+ for (int i = 0; i < length; i++)
+ if (localArrayBindings[i].dimensions == dimensionCount)
+ return localArrayBindings[i];
+
+ // no matching array
+ System.arraycopy(localArrayBindings, 0, localArrayBindings = new ArrayBinding[length + 1], 0, length);
+ return localArrayBindings[length] = new ArrayBinding(this, dimensionCount);
}
+
public char[] readableName() {
if (isAnonymousType()) {
if (superInterfaces == NoSuperInterfaces)
@@ -72,15 +89,38 @@
return sourceName;
}
}
-// Record that the type is a local member type
+public char[] shortReadableName() {
+ if (isAnonymousType()) {
+ if (superInterfaces == NoSuperInterfaces)
+ return ("<"+Util.bind("binding.subclass",new String(superclass.shortReadableName())) + ">").toCharArray(); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
+ else
+ return ("<"+Util.bind("binding.implementation",new String(superInterfaces[0].shortReadableName())) + ">").toCharArray(); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
+ } else if (isMemberType()) {
+ return CharOperation.concat(enclosingType().shortReadableName(), sourceName, '.');
+ } else {
+ return sourceName;
+ }
+}
+
+// Record that the type is a local member type
public void setAsMemberType() {
tagBits |= MemberTypeMask;
}
+
+public void setConstantPoolName(char[] computedConstantPoolName) /* java/lang/Object */ {
+ this.constantPoolName = computedConstantPoolName;
+}
+
public char[] sourceName() {
- if (isAnonymousType())
- return readableName();
- else
+ if (isAnonymousType()) {
+ //return readableName();
+ if (superInterfaces == NoSuperInterfaces)
+ return ("<"+Util.bind("binding.subclass",new String(superclass.sourceName())) + ">").toCharArray(); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
+ else
+ return ("<"+Util.bind("binding.implementation",new String(superInterfaces[0].sourceName())) + ">").toCharArray(); //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-1$
+
+ } else
return sourceName;
}
public String toString() {
@@ -99,7 +139,7 @@
for (int i = 0; i < dependents.length; i++) {
InnerEmulationDependency dependency = dependents[i];
// System.out.println("Updating " + new String(this.readableName()) + " --> " + new String(dependency.scope.enclosingType().readableName()));
- dependency.scope.propagateInnerEmulation(this, dependency.wasEnclosingInstanceSupplied, dependency.useDirectAccess);
+ dependency.scope.propagateInnerEmulation(this, dependency.wasEnclosingInstanceSupplied);
}
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java
index dae9c94..65c2465 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java
@@ -1,91 +1,112 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.impl.Constant;
public class LocalVariableBinding extends VariableBinding {
- public boolean isArgument;
+ public boolean isArgument;
public int resolvedPosition; // for code generation (position in method context)
- public boolean used; // for flow analysis
+
+ public static final int UNUSED = 0;
+ public static final int USED = 1;
+ public static final int FAKE_USED = 2;
+ public int useFlag; // for flow analysis (default is UNUSED)
+
public BlockScope declaringScope; // back-pointer to its declaring scope
public LocalDeclaration declaration; // for source-positions
public int[] initializationPCs;
public int initializationCount = 0;
-// for synthetic local variables
-public LocalVariableBinding(char[] name, TypeBinding type, int modifiers, boolean isArgument) {
- this.name = name;
- this.type = type;
- this.modifiers = modifiers;
- if (this.isArgument = isArgument)
- this.constant = Constant.NotAConstant;
-}
+ // for synthetic local variables
+ public LocalVariableBinding(char[] name, TypeBinding type, int modifiers, boolean isArgument) {
-// regular local variable or argument
-public LocalVariableBinding(LocalDeclaration declaration, TypeBinding type, int modifiers, boolean isArgument) {
- this(declaration.name, type, modifiers, isArgument);
- this.declaration = declaration;
-}
-/* API
-* Answer the receiver's binding type from Binding.BindingID.
-*/
-
-public final int bindingType() {
- return LOCAL;
-}
-// Answer whether the variable binding is a secret variable added for code gen purposes
-
-public boolean isSecret() {
- return declaration == null && !isArgument;
-}
-public void recordInitializationEndPC(int pc) {
- if (initializationPCs[((initializationCount - 1) << 1) + 1] == -1)
- initializationPCs[((initializationCount - 1) << 1) + 1] = pc;
-}
-public void recordInitializationStartPC(int pc) {
- if (initializationPCs == null)
- return;
- // optimize cases where reopening a contiguous interval
- if ((initializationCount > 0) && (initializationPCs[ ((initializationCount - 1) << 1) + 1] == pc)) {
- initializationPCs[ ((initializationCount - 1) << 1) + 1] = -1; // reuse previous interval (its range will be augmented)
- } else {
- int index = initializationCount << 1;
- if (index == initializationPCs.length) {
- System.arraycopy(initializationPCs, 0, (initializationPCs = new int[initializationCount << 2]), 0, index);
- }
- initializationPCs[index] = pc;
- initializationPCs[index + 1] = -1;
- initializationCount++;
+ this.name = name;
+ this.type = type;
+ this.modifiers = modifiers;
+ if (this.isArgument = isArgument)
+ this.constant = Constant.NotAConstant;
}
-}
-public String toString() {
- String s = super.toString();
- if (!used)
- s += "[pos: unused]"; //$NON-NLS-1$
- else
- s += "[pos: " + String.valueOf(resolvedPosition) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
- s += "[id:" + String.valueOf(id) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
- if (initializationCount > 0) {
- s += "[pc: "; //$NON-NLS-1$
- for (int i = 0; i < initializationCount; i++) {
- if (i > 0)
- s += ", "; //$NON-NLS-1$
- s += String.valueOf(initializationPCs[i << 1]) + "-" + ((initializationPCs[(i << 1) + 1] == -1) ? "?" : String.valueOf(initializationPCs[(i<< 1) + 1])); //$NON-NLS-2$ //$NON-NLS-1$
- }
- s += "]"; //$NON-NLS-1$
+
+ // regular local variable or argument
+ public LocalVariableBinding(LocalDeclaration declaration, TypeBinding type, int modifiers, boolean isArgument) {
+
+ this(declaration.name, type, modifiers, isArgument);
+ this.declaration = declaration;
}
- return s;
-}
+
+ /* API
+ * Answer the receiver's binding type from Binding.BindingID.
+ */
+ public final int bindingType() {
+
+ return LOCAL;
+ }
+
+ // Answer whether the variable binding is a secret variable added for code gen purposes
+ public boolean isSecret() {
+
+ return declaration == null && !isArgument;
+ }
+
+ public void recordInitializationEndPC(int pc) {
+
+ if (initializationPCs[((initializationCount - 1) << 1) + 1] == -1)
+ initializationPCs[((initializationCount - 1) << 1) + 1] = pc;
+ }
+
+ public void recordInitializationStartPC(int pc) {
+
+ if (initializationPCs == null) return;
+ // optimize cases where reopening a contiguous interval
+ if ((initializationCount > 0) && (initializationPCs[ ((initializationCount - 1) << 1) + 1] == pc)) {
+ initializationPCs[ ((initializationCount - 1) << 1) + 1] = -1; // reuse previous interval (its range will be augmented)
+ } else {
+ int index = initializationCount << 1;
+ if (index == initializationPCs.length) {
+ System.arraycopy(initializationPCs, 0, (initializationPCs = new int[initializationCount << 2]), 0, index);
+ }
+ initializationPCs[index] = pc;
+ initializationPCs[index + 1] = -1;
+ initializationCount++;
+ }
+ }
+
+ public String toString() {
+
+ String s = super.toString();
+ switch (useFlag){
+ case USED:
+ s += "[pos: " + String.valueOf(resolvedPosition) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
+ break;
+ case UNUSED:
+ s += "[pos: unused]"; //$NON-NLS-1$
+ break;
+ case FAKE_USED:
+ s += "[pos: fake_used]"; //$NON-NLS-1$
+ break;
+ }
+ s += "[id:" + String.valueOf(id) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
+ if (initializationCount > 0) {
+ s += "[pc: "; //$NON-NLS-1$
+ for (int i = 0; i < initializationCount; i++) {
+ if (i > 0)
+ s += ", "; //$NON-NLS-1$
+ s += String.valueOf(initializationPCs[i << 1]) + "-" + ((initializationPCs[(i << 1) + 1] == -1) ? "?" : String.valueOf(initializationPCs[(i<< 1) + 1])); //$NON-NLS-2$ //$NON-NLS-1$
+ }
+ s += "]"; //$NON-NLS-1$
+ }
+ return s;
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
index b720b9b..1afbe3b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
@@ -17,7 +18,6 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.ITypeRequestor;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.HashtableOfPackage;
import org.eclipse.jdt.internal.compiler.util.Util;
@@ -29,8 +29,8 @@
PackageBinding defaultPackage;
ImportBinding[] defaultImports;
HashtableOfPackage knownPackages;
- static final ProblemPackageBinding theNotFoundPackage = new ProblemPackageBinding(new char[0], NotFound);
- static final ProblemReferenceBinding theNotFoundType = new ProblemReferenceBinding(new char[0], NotFound);
+ static final ProblemPackageBinding TheNotFoundPackage = new ProblemPackageBinding(CharOperation.NO_CHAR, NotFound);
+ static final ProblemReferenceBinding TheNotFoundType = new ProblemReferenceBinding(CharOperation.NO_CHAR, NotFound);
private INameEnvironment nameEnvironment;
private MethodVerifier verifier;
@@ -228,14 +228,14 @@
return defaultPackage;
PackageBinding packageBinding = getPackage0(constantPoolName[0]);
- if (packageBinding == null || packageBinding == theNotFoundPackage) {
+ if (packageBinding == null || packageBinding == TheNotFoundPackage) {
packageBinding = new PackageBinding(constantPoolName[0], this);
knownPackages.put(constantPoolName[0], packageBinding);
}
for (int i = 1, length = constantPoolName.length - 1; i < length; i++) {
PackageBinding parent = packageBinding;
- if ((packageBinding = parent.getPackage0(constantPoolName[i])) == null || packageBinding == theNotFoundPackage) {
+ if ((packageBinding = parent.getPackage0(constantPoolName[i])) == null || packageBinding == TheNotFoundPackage) {
packageBinding = new PackageBinding(CharOperation.subarray(constantPoolName, 0, i + 1), parent, this);
parent.addPackage(packageBinding);
}
@@ -246,6 +246,9 @@
*/
ArrayBinding createArrayType(TypeBinding type, int dimensionCount) {
+ if (type instanceof LocalTypeBinding) // cache local type arrays with the local type itself
+ return ((LocalTypeBinding) type).createArrayType(dimensionCount);
+
// find the array binding cache for this dimension
int dimIndex = dimensionCount - 1;
int length = uniqueArrayBindings.length;
@@ -306,7 +309,7 @@
PackageBinding createPackage(char[][] compoundName) {
PackageBinding packageBinding = getPackage0(compoundName[0]);
- if (packageBinding == null || packageBinding == theNotFoundPackage) {
+ if (packageBinding == null || packageBinding == TheNotFoundPackage) {
packageBinding = new PackageBinding(compoundName[0], this);
knownPackages.put(compoundName[0], packageBinding);
}
@@ -317,11 +320,11 @@
// otherwise when the source type was defined, the correct error would have been reported
// unless its an unresolved type which is referenced from an inconsistent class file
ReferenceBinding type = packageBinding.getType0(compoundName[i]);
- if (type != null && type != theNotFoundType && !(type instanceof UnresolvedReferenceBinding))
+ if (type != null && type != TheNotFoundType && !(type instanceof UnresolvedReferenceBinding))
return null;
PackageBinding parent = packageBinding;
- if ((packageBinding = parent.getPackage0(compoundName[i])) == null || packageBinding == theNotFoundPackage) {
+ if ((packageBinding = parent.getPackage0(compoundName[i])) == null || packageBinding == TheNotFoundPackage) {
// if the package is unknown, check to see if a type exists which would collide with the new package
// catches the case of a package statement of: package java.lang.Object;
// since the package can be added after a set of source files have already been compiled, we need
@@ -351,11 +354,11 @@
}
PackageBinding packageBinding = getPackage0(compoundName[0]);
- if (packageBinding == null || packageBinding == theNotFoundPackage)
+ if (packageBinding == null || packageBinding == TheNotFoundPackage)
return null;
for (int i = 1, packageLength = compoundName.length - 1; i < packageLength; i++)
- if ((packageBinding = packageBinding.getPackage0(compoundName[i])) == null || packageBinding == theNotFoundPackage)
+ if ((packageBinding = packageBinding.getPackage0(compoundName[i])) == null || packageBinding == TheNotFoundPackage)
return null;
return packageBinding.getType0(compoundName[compoundName.length - 1]);
}
@@ -378,7 +381,7 @@
PackageBinding getTopLevelPackage(char[] name) {
PackageBinding packageBinding = getPackage0(name);
if (packageBinding != null) {
- if (packageBinding == theNotFoundPackage)
+ if (packageBinding == TheNotFoundPackage)
return null;
else
return packageBinding;
@@ -389,7 +392,7 @@
return packageBinding;
}
- knownPackages.put(name, theNotFoundPackage); // saves asking the oracle next time
+ knownPackages.put(name, TheNotFoundPackage); // saves asking the oracle next time
return null;
}
/* Answer the type corresponding to the compoundName.
@@ -406,20 +409,20 @@
if ((referenceBinding = defaultPackage.getType0(compoundName[0])) == null) {
PackageBinding packageBinding = getPackage0(compoundName[0]);
- if (packageBinding != null && packageBinding != theNotFoundPackage)
+ if (packageBinding != null && packageBinding != TheNotFoundPackage)
return null; // collides with a known package... should not call this method in such a case
referenceBinding = askForType(defaultPackage, compoundName[0]);
}
} else {
PackageBinding packageBinding = getPackage0(compoundName[0]);
- if (packageBinding == theNotFoundPackage)
+ if (packageBinding == TheNotFoundPackage)
return null;
if (packageBinding != null) {
for (int i = 1, packageLength = compoundName.length - 1; i < packageLength; i++) {
if ((packageBinding = packageBinding.getPackage0(compoundName[i])) == null)
break;
- if (packageBinding == theNotFoundPackage)
+ if (packageBinding == TheNotFoundPackage)
return null;
}
}
@@ -430,7 +433,7 @@
referenceBinding = askForType(packageBinding, compoundName[compoundName.length - 1]);
}
- if (referenceBinding == null || referenceBinding == theNotFoundType)
+ if (referenceBinding == null || referenceBinding == TheNotFoundType)
return null;
if (referenceBinding instanceof UnresolvedReferenceBinding)
referenceBinding = ((UnresolvedReferenceBinding) referenceBinding).resolve(this);
@@ -452,7 +455,7 @@
ReferenceBinding getTypeFromConstantPoolName(char[] signature, int start, int end) {
if (end == -1)
- end = signature.length - 1;
+ end = signature.length;
char[][] compoundName = CharOperation.splitOn('/', signature, start, end);
ReferenceBinding binding = getCachedType(compoundName);
@@ -460,7 +463,7 @@
PackageBinding packageBinding = computePackageFrom(compoundName);
binding = new UnresolvedReferenceBinding(compoundName, packageBinding);
packageBinding.addType(binding);
- } else if (binding == theNotFoundType) {
+ } else if (binding == TheNotFoundType) {
problemReporter.isClassPathCorrect(compoundName, null);
return null; // will not get here since the above error aborts the compilation
}
@@ -519,7 +522,7 @@
throw new Error(Util.bind("error.undefinedBaseType",String.valueOf(signature[start]))); //$NON-NLS-1$
}
} else {
- binding = getTypeFromConstantPoolName(signature, start + 1, end - 1);
+ binding = getTypeFromConstantPoolName(signature, start + 1, end);
}
if (dimension == 0)
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MemberTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MemberTypeBinding.java
index f7d2222..ebb6029 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MemberTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MemberTypeBinding.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
public final class MemberTypeBinding extends NestedTypeBinding {
public MemberTypeBinding(char[][] compoundName, ClassScope scope, SourceTypeBinding enclosingType) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java
index d11e456..fc2b75b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
@@ -22,6 +23,7 @@
public ReferenceBinding declaringClass;
char[] signature;
+
protected MethodBinding() {
}
public MethodBinding(int modifiers, char[] selector, TypeBinding returnType, TypeBinding[] args, ReferenceBinding[] exceptions, ReferenceBinding declaringClass) {
@@ -204,120 +206,156 @@
} while ((type = type.superclass()) != null);
return false;
}
+
/* Answer the receiver's constant pool name.
*
* <init> for constructors
* <clinit> for clinit methods
* or the source name of the method
*/
-
public final char[] constantPoolName() {
return selector;
}
public final int getAccessFlags() {
return modifiers & AccJustFlag;
}
+
/* Answer true if the receiver is an abstract method
*/
-
public final boolean isAbstract() {
return (modifiers & AccAbstract) != 0;
}
+
/* Answer true if the receiver is a constructor
*/
-
public final boolean isConstructor() {
return selector == ConstructorDeclaration.ConstantPoolName;
}
protected boolean isConstructorRelated() {
return isConstructor();
}
+
/* Answer true if the receiver has default visibility
*/
-
public final boolean isDefault() {
return !isPublic() && !isProtected() && !isPrivate();
}
+
/* Answer true if the receiver is a system generated default abstract method
*/
-
public final boolean isDefaultAbstract() {
return (modifiers & AccDefaultAbstract) != 0;
}
+
/* Answer true if the receiver is a deprecated method
*/
-
public final boolean isDeprecated() {
return (modifiers & AccDeprecated) != 0;
}
+
/* Answer true if the receiver is final and cannot be overridden
*/
-
public final boolean isFinal() {
return (modifiers & AccFinal) != 0;
}
+
+/* Answer true if the receiver is implementing another method
+ * i.e. is overriding and is concrete and overriden is abstract
+ * Only set for source methods
+*/
+public final boolean isImplementing() {
+ return (modifiers & AccImplementing) != 0;
+}
+
/* Answer true if the receiver is a native method
*/
-
public final boolean isNative() {
return (modifiers & AccNative) != 0;
}
+
+/* Answer true if the receiver is overriding another method
+ * Only set for source methods
+*/
+public final boolean isOverriding() {
+ return (modifiers & AccOverriding) != 0;
+}
+/*
+ * Answer true if the receiver is a "public static void main(String[])" method
+ */
+public final boolean isMain() {
+ if (this.selector.length == 4 && CharOperation.equals(this.selector, MAIN)
+ && ((this.modifiers & (AccPublic | AccStatic)) != 0)
+ && VoidBinding == this.returnType
+ && this.parameters.length == 1) {
+ TypeBinding paramType = this.parameters[0];
+ if (paramType.dimensions() == 1 && paramType.leafComponentType().id == TypeIds.T_JavaLangString) {
+ return true;
+ }
+ }
+ return false;
+}
/* Answer true if the receiver has private visibility
*/
-
public final boolean isPrivate() {
return (modifiers & AccPrivate) != 0;
}
+
+/* Answer true if the receiver has private visibility and is used locally
+*/
+public final boolean isPrivateUsed() {
+ return (modifiers & AccPrivateUsed) != 0;
+}
+
/* Answer true if the receiver has protected visibility
*/
-
public final boolean isProtected() {
return (modifiers & AccProtected) != 0;
}
+
/* Answer true if the receiver has public visibility
*/
-
public final boolean isPublic() {
return (modifiers & AccPublic) != 0;
}
+
/* Answer true if the receiver got requested to clear the private modifier
* during private access emulation.
*/
-
public final boolean isRequiredToClearPrivateModifier() {
return (modifiers & AccClearPrivateModifier) != 0;
}
+
/* Answer true if the receiver is a static method
*/
-
public final boolean isStatic() {
return (modifiers & AccStatic) != 0;
}
+
/* Answer true if all float operations must adher to IEEE 754 float/double rules
*/
-
public final boolean isStrictfp() {
return (modifiers & AccStrictfp) != 0;
}
+
/* Answer true if the receiver is a synchronized method
*/
-
public final boolean isSynchronized() {
return (modifiers & AccSynchronized) != 0;
}
+
/* Answer true if the receiver has public visibility
*/
-
public final boolean isSynthetic() {
return (modifiers & AccSynthetic) != 0;
}
+
/* Answer true if the receiver's declaring type is deprecated (or any of its enclosing types)
*/
-
public final boolean isViewedAsDeprecated() {
return (modifiers & AccDeprecated) != 0 ||
(modifiers & AccDeprecatedImplicitly) != 0;
}
+
public char[] readableName() /* foo(int, Thread) */ {
StringBuffer buffer = new StringBuffer(parameters.length + 1 * 20);
if (isConstructor())
@@ -335,37 +373,78 @@
buffer.append(')');
return buffer.toString().toCharArray();
}
+
+/**
+ * @see org.eclipse.jdt.internal.compiler.lookup.Binding#shortReadableName()
+ */
+public char[] shortReadableName() {
+ StringBuffer buffer = new StringBuffer(parameters.length + 1 * 20);
+ if (isConstructor())
+ buffer.append(declaringClass.shortReadableName());
+ else
+ buffer.append(selector);
+ buffer.append('(');
+ if (parameters != NoParameters) {
+ for (int i = 0, length = parameters.length; i < length; i++) {
+ if (i > 0)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append(parameters[i].shortReadableName());
+ }
+ }
+ buffer.append(')');
+ return buffer.toString().toCharArray();
+}
+
protected final void selector(char[] selector) {
this.selector = selector;
this.signature = null;
}
+
/* Answer the receiver's signature.
*
* NOTE: This method should only be used during/after code gen.
* The signature is cached so if the signature of the return type or any parameter
* type changes, the cached state is invalid.
*/
-
public final char[] signature() /* (ILjava/lang/Thread;)Ljava/lang/Object; */ {
if (signature != null)
return signature;
StringBuffer buffer = new StringBuffer(parameters.length + 1 * 20);
buffer.append('(');
- if (isConstructorRelated() && declaringClass.isNestedType()) {
+
+ TypeBinding[] targetParameters = this.parameters;
+ boolean considerSynthetics = isConstructorRelated() && declaringClass.isNestedType();
+ if (considerSynthetics) {
+
// take into account the synthetic argument type signatures as well
ReferenceBinding[] syntheticArgumentTypes = declaringClass.syntheticEnclosingInstanceTypes();
int count = syntheticArgumentTypes == null ? 0 : syntheticArgumentTypes.length;
- for (int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++) {
buffer.append(syntheticArgumentTypes[i].signature());
- SyntheticArgumentBinding[] syntheticArguments = declaringClass.syntheticOuterLocalVariables();
- count = syntheticArguments == null ? 0 : syntheticArguments.length;
- for (int i = 0; i < count; i++)
- buffer.append(syntheticArguments[i].type.signature());
+ }
+
+ if (this instanceof SyntheticAccessMethodBinding) {
+ targetParameters = ((SyntheticAccessMethodBinding)this).targetMethod.parameters;
+ }
}
- if (parameters != NoParameters)
- for (int i = 0, length = parameters.length; i < length; i++)
+
+ if (targetParameters != NoParameters) {
+ for (int i = 0; i < targetParameters.length; i++) {
+ buffer.append(targetParameters[i].signature());
+ }
+ }
+ if (considerSynthetics) {
+ SyntheticArgumentBinding[] syntheticOuterArguments = declaringClass.syntheticOuterLocalVariables();
+ int count = syntheticOuterArguments == null ? 0 : syntheticOuterArguments.length;
+ for (int i = 0; i < count; i++) {
+ buffer.append(syntheticOuterArguments[i].type.signature());
+ }
+ // move the extra padding arguments of the synthetic constructor invocation to the end
+ for (int i = targetParameters.length, extraLength = parameters.length; i < extraLength; i++) {
buffer.append(parameters[i].signature());
+ }
+ }
buffer.append(')');
buffer.append(returnType.signature());
return signature = buffer.toString().toCharArray();
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java
index 92ba68f..f8bf377 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java
@@ -1,22 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.flow.UnconditionalFlowInfo;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
@@ -28,17 +31,15 @@
public class MethodScope extends BlockScope {
public ReferenceContext referenceContext;
- public boolean needToCompactLocalVariables;
public boolean isStatic; // method modifier or initializer one
- //fields used in the TC process (no real meaning)
+ //fields used during name resolution
public static final int NotInFieldDecl = -1; //must be a negative value
- public boolean isConstructorCall = false; //modified on the fly by the TC
- public int fieldDeclarationIndex = NotInFieldDecl;
- //modified on the fly by the TC
+ public boolean isConstructorCall = false;
+ public int fieldDeclarationIndex = NotInFieldDecl;
+ // flow analysis
public int analysisIndex; // for setting flow-analysis id
-
public boolean isPropagatingInnerClassEmulation;
// for local variables table attributes
@@ -46,10 +47,10 @@
public long[] definiteInits = new long[4];
public long[][] extraDefiniteInits = new long[4][];
- public MethodScope(
- ClassScope parent,
- ReferenceContext context,
- boolean isStatic) {
+ // inner-emulation
+ public SyntheticArgumentBinding[] extraSyntheticArguments;
+
+ public MethodScope(ClassScope parent, ReferenceContext context, boolean isStatic) {
super(METHOD_SCOPE, parent);
locals = new LocalVariableBinding[5];
@@ -213,6 +214,78 @@
methodBinding.modifiers = modifiers;
}
+ /* Compute variable positions in scopes given an initial position offset
+ * ignoring unused local variables.
+ *
+ * Deal with arguments here, locals and subscopes are processed in BlockScope method
+ */
+ public void computeLocalVariablePositions(int initOffset, CodeStream codeStream) {
+
+ boolean isReportingUnusedArgument = false;
+
+ if (referenceContext instanceof AbstractMethodDeclaration) {
+ AbstractMethodDeclaration methodDecl = (AbstractMethodDeclaration)referenceContext;
+ MethodBinding method = methodDecl.binding;
+ CompilerOptions options = compilationUnitScope().environment.options;
+ if (!(method.isAbstract()
+ || (method.isImplementing() && !options.reportUnusedParameterWhenImplementingAbstract)
+ || (method.isOverriding() && !method.isImplementing() && !options.reportUnusedParameterWhenOverridingConcrete)
+ || method.isMain())) {
+ isReportingUnusedArgument = true;
+ }
+ }
+ this.offset = initOffset;
+ this.maxOffset = initOffset;
+
+ // manage arguments
+ int ilocal = 0, maxLocals = this.localIndex;
+ while (ilocal < maxLocals) {
+ LocalVariableBinding local = locals[ilocal];
+ if (local == null || !local.isArgument) break; // done with arguments
+
+ // do not report fake used variable
+ if (isReportingUnusedArgument
+ && local.useFlag == LocalVariableBinding.UNUSED
+ && ((local.declaration.bits & AstNode.IsLocalDeclarationReachableMASK) != 0)) { // declaration is reachable
+ this.problemReporter().unusedArgument(local.declaration);
+ }
+
+ // record user-defined argument for attribute generation
+ codeStream.record(local);
+
+ // assign variable position
+ local.resolvedPosition = this.offset;
+
+ if ((local.type == LongBinding) || (local.type == DoubleBinding)) {
+ this.offset += 2;
+ } else {
+ this.offset++;
+ }
+ // check for too many arguments/local variables
+ if (this.offset > 0xFF) { // no more than 255 words of arguments
+ this.problemReporter().noMoreAvailableSpaceForArgument(local, local.declaration);
+ }
+ ilocal++;
+ }
+
+ // sneak in extra argument before other local variables
+ if (extraSyntheticArguments != null) {
+ for (int iarg = 0, maxArguments = extraSyntheticArguments.length; iarg < maxArguments; iarg++){
+ SyntheticArgumentBinding argument = extraSyntheticArguments[iarg];
+ argument.resolvedPosition = this.offset;
+ if ((argument.type == LongBinding) || (argument.type == DoubleBinding)){
+ this.offset += 2;
+ } else {
+ this.offset++;
+ }
+ if (this.offset > 0xFF) { // no more than 255 words of arguments
+ this.problemReporter().noMoreAvailableSpaceForArgument(argument, (AstNode)this.referenceContext);
+ }
+ }
+ }
+ this.computeLocalVariablePositions(ilocal, this.offset, codeStream);
+ }
+
/* Error management:
* keep null for all the errors that prevent the method to be created
* otherwise return a correct method binding (but without the element
@@ -315,9 +388,8 @@
public final int recordInitializationStates(FlowInfo flowInfo) {
- if ((flowInfo == FlowInfo.DeadEnd) || (flowInfo.isFakeReachable())) {
- return -1;
- }
+ if (!flowInfo.isReachable()) return -1;
+
UnconditionalFlowInfo unconditionalFlowInfo = flowInfo.unconditionalInits();
long[] extraInits = unconditionalFlowInfo.extraDefiniteInits;
long inits = unconditionalFlowInfo.definiteInits;
@@ -394,7 +466,8 @@
s += newLine + "startIndex = " + startIndex; //$NON-NLS-1$
s += newLine + "isConstructorCall = " + isConstructorCall; //$NON-NLS-1$
s += newLine + "fieldDeclarationIndex = " + fieldDeclarationIndex; //$NON-NLS-1$
+ s += newLine + "referenceContext = " + referenceContext; //$NON-NLS-1$
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java
index 5657b84..9035629 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
public final class MethodVerifier implements TagBits, TypeConstants {
@@ -22,6 +22,7 @@
HashtableOfObject currentMethods;
ReferenceBinding runtimeException;
ReferenceBinding errorException;
+ LookupEnvironment environment;
/*
Binding creation is responsible for reporting all problems with types:
- all modifier problems (duplicates & multiple visibility modifiers + incompatible combinations - abstract/final)
@@ -38,215 +39,25 @@
- shadowing an enclosing type's source name
- defining a static class or interface inside a non-static nested class
- defining an interface as a local type (local types can only be classes)
-
-verifyTypeStructure
-
- | hasHierarchyProblem superclass current names interfaces interfacesByIndentity duplicateExists invalidType |
-
- (type basicModifiers anyMask: AccModifierProblem | AccAlternateModifierProblem) ifTrue: [
- self reportModifierProblemsOnType: type].
-
- type controller isJavaDefaultPackage ifFalse: [
- (nameEnvironment class doesPackageExistNamed: type javaQualifiedName) ifTrue: [
- problemSummary
- reportVerificationProblem: #CollidesWithPackage
- args: (Array with: type javaQualifiedName)
- severity: nil
- forType: type]].
-
- hasHierarchyProblem := false.
-
- type isJavaClass
- ifTrue: [
- (superclass := self superclassFor: type) ~~ nil ifTrue: [
- superclass isBuilderClass ifTrue: [
- superclass := superclass newClass].
- superclass isJavaMissing
- ifTrue: [
- hasHierarchyProblem := true.
- type javaSuperclassIsMissing ifTrue: [
- problemSummary
- reportVerificationProblem: #MissingSuperclass
- args: (Array with: superclass javaQualifiedName with: superclass unmatchedDescriptor)
- severity: nil
- forType: type].
- type javaSuperclassCreatesCycle ifTrue: [
- problemSummary
- reportVerificationProblem: #CyclicSuperclass
- args: (Array with: superclass javaQualifiedName)
- severity: nil
- forType: type].
- type javaSuperclassIsInterface ifTrue: [
- problemSummary
- reportVerificationProblem: #ClassCannotExtendAnInterface
- args: (Array with: superclass javaQualifiedName)
- severity: nil
- forType: type]]
- ifFalse: [
- "NOTE: If type is a Java class and its superclass is
- a valid descriptor then it should NEVER be an interface."
-
- superclass isJavaFinal ifTrue: [
- problemSummary
- reportVerificationProblem: #ClassCannotExtendFinalClass
- args: nil
- severity: nil
- forType: type]]]]
- ifFalse: [
- type isJavaLocalType ifTrue: [
- problemSummary
- reportVerificationProblem: #CannotDefineLocalInterface
- args: nil
- severity: nil
- forType: type]].
-
- type isJavaNestedType ifTrue: [
- (current := type) sourceName notEmpty ifTrue: [
- names := Set new.
- [(current := current enclosingType) ~~ nil] whileTrue: [
- names add: current sourceName].
-
- (names includes: type sourceName) ifTrue: [
- problemSummary
- reportVerificationProblem: #NestedTypeCannotShadowTypeName
- args: nil
- severity: nil
- forType: type]].
-
- (type enclosingType isJavaNestedType and: [type enclosingType isJavaClass]) ifTrue: [
- type enclosingType isJavaStatic ifFalse: [
- type isJavaClass
- ifTrue: [
- type isJavaStatic ifTrue: [
- problemSummary
- reportVerificationProblem: #StaticClassCannotExistInNestedClass
- args: nil
- severity: nil
- forType: type]]
- ifFalse: [
- problemSummary
- reportVerificationProblem: #InterfaceCannotExistInNestedClass
- args: nil
- severity: nil
- forType: type]]]].
-
- (interfaces := newClass superinterfaces) notEmpty ifTrue: [
- interfacesByIndentity := interfaces asSet.
- duplicateExists := interfaces size ~~ interfacesByIndentity size.
-
- interfacesByIndentity do: [:interface |
- duplicateExists ifTrue: [
- (interfaces occurrencesOf: interface) > 1 ifTrue: [
- problemSummary
- reportVerificationProblem: #InterfaceIsSpecifiedMoreThanOnce
- args: (Array with: interface javaQualifiedName)
- severity: nil
- forType: type]].
-
- interface isJavaMissing ifTrue: [
- hasHierarchyProblem := true.
- interface basicClass == JavaInterfaceIsClass basicClass
- ifTrue: [
- problemSummary
- reportVerificationProblem: #UsingClassWhereInterfaceIsRequired
- args: (Array with: interface javaQualifiedName)
- severity: nil
- forType: type]
- ifFalse: [
- interface basicClass == JavaMissingInterface basicClass
- ifTrue: [
- problemSummary
- reportVerificationProblem: #MissingInterface
- args: (Array with: interface javaQualifiedName with: interface unmatchedDescriptor)
- severity: nil
- forType: type]
- ifFalse: [
- problemSummary
- reportVerificationProblem: #CyclicSuperinterface
- args: (Array with: interface javaQualifiedName)
- severity: nil
- forType: type]]]]].
-
- hasHierarchyProblem ifFalse: [
- "Search up the type's hierarchy for
- 1. missing superclass,
- 2. superclass cycle, or
- 3. superclass is interface."
- (invalidType := newClass findFirstInvalidSupertypeSkipping: EsIdentitySet new) ~~ nil ifTrue: [
- problemSummary
- reportVerificationProblem: #HasHierarchyProblem
- args: (Array with: invalidType javaReadableName)
- severity: nil
- forType: type]]
-
-reportModifierProblemsOnType: aType
-
- (type basicModifiers anyMask: AccAlternateModifierProblem) ifTrue: [
- (type basicModifiers anyMask: AccModifierProblem)
- ifTrue: [
- ^problemSummary
- reportVerificationProblem: #OnlyOneVisibilityModifierAllowed
- args: nil
- severity: nil
- forType: aType]
- ifFalse: [
- ^problemSummary
- reportVerificationProblem: #DuplicateModifier
- args: nil
- severity: nil
- forType: aType]].
-
- type isJavaInterface ifTrue: [
- ^problemSummary
- reportVerificationProblem: #IllegalModifierForInterface
- args: nil
- severity: nil
- forType: aType].
-
- (type basicModifiers allMask: AccAbstract | AccFinal) ifTrue: [
- ^problemSummary
- reportVerificationProblem: #IllegalModifierCombinationAbstractFinal
- args: nil
- severity: nil
- forType: aType].
-
- ^problemSummary
- reportVerificationProblem: #IllegalModifierForClass
- args: nil
- severity: nil
- forType: aType
-
-void reportModifierProblems() {
- if (this.type.isAbstract() && this.type.isFinal())
- this.problemReporter.illegalModifierCombinationAbstractFinal(this.type);
-
- // Should be able to detect all 3 problems NOT just 1
- if ((type.modifiers() & Modifiers.AccAlternateModifierProblem) == 0) {
- if (this.type.isInterface())
- this.problemReporter.illegalModifierForInterface(this.type);
- else
- this.problemReporter.illegalModifier(this.type);
- } else {
- if ((type.modifiers() & Modifiers.AccModifierProblem) != 0)
- this.problemReporter.onlyOneVisibilityModifierAllowed(this.type);
- else
- this.problemReporter.duplicateModifier(this.type);
- }
-}
*/
public MethodVerifier(LookupEnvironment environment) {
- this.type = null; // Initialized with the public method verify(SourceTypeBinding)
+ this.type = null; // Initialized with the public method verify(SourceTypeBinding)
this.inheritedMethods = null;
this.currentMethods = null;
this.runtimeException = null;
this.errorException = null;
+ this.environment = environment;
}
private void checkAgainstInheritedMethods(MethodBinding currentMethod, MethodBinding[] methods, int length) {
+ currentMethod.modifiers |= CompilerModifiers.AccOverriding;
for (int i = length; --i >= 0;) {
MethodBinding inheritedMethod = methods[i];
+ if (!currentMethod.isAbstract() && inheritedMethod.isAbstract())
+ currentMethod.modifiers |= CompilerModifiers.AccImplementing;
+
if (currentMethod.returnType != inheritedMethod.returnType) {
this.problemReporter(currentMethod).incompatibleReturnType(currentMethod, inheritedMethod);
- } else if (currentMethod.isStatic() != inheritedMethod.isStatic()) { // Cannot override a static method or hide an instance method
+ } else if (currentMethod.isStatic() != inheritedMethod.isStatic()) { // Cannot override a static method or hide an instance method
this.problemReporter(currentMethod).staticAndInstanceConflict(currentMethod, inheritedMethod);
} else {
if (currentMethod.thrownExceptions != NoExceptions)
@@ -256,7 +67,7 @@
if (!this.isAsVisible(currentMethod, inheritedMethod))
this.problemReporter(currentMethod).visibilityConflict(currentMethod, inheritedMethod);
if (inheritedMethod.isViewedAsDeprecated())
- if (!currentMethod.isViewedAsDeprecated())
+ if (!currentMethod.isViewedAsDeprecated() || environment.options.reportDeprecationInsideDeprecatedCode)
this.problemReporter(currentMethod).overridesDeprecatedMethod(currentMethod, inheritedMethod);
}
}
@@ -267,7 +78,6 @@
Assumes all exceptions are valid and throwable.
Unchecked exceptions (compatible with runtime & error) are ignored (see the spec on pg. 203).
*/
-
private void checkExceptions(MethodBinding newMethod, MethodBinding inheritedMethod) {
ReferenceBinding[] newExceptions = newMethod.thrownExceptions;
ReferenceBinding[] inheritedExceptions = inheritedMethod.thrownExceptions;
@@ -283,33 +93,33 @@
private void checkInheritedMethods(MethodBinding[] methods, int length) {
TypeBinding returnType = methods[0].returnType;
int index = length;
- while ((--index > 0) && (returnType == methods[index].returnType));
- if (index > 0) { // All inherited methods do NOT have the same vmSignature
+ while (--index > 0 && returnType == methods[index].returnType);
+ if (index > 0) { // All inherited methods do NOT have the same vmSignature
this.problemReporter().inheritedMethodsHaveIncompatibleReturnTypes(this.type, methods, length);
return;
}
MethodBinding concreteMethod = null;
- if (!type.isInterface()){ // ignore concrete methods for interfaces
- for (int i = length; --i >= 0;) // Remember that only one of the methods can be non-abstract
+ if (!type.isInterface()) { // ignore concrete methods for interfaces
+ for (int i = length; --i >= 0;) { // Remember that only one of the methods can be non-abstract
if (!methods[i].isAbstract()) {
concreteMethod = methods[i];
break;
}
+ }
}
if (concreteMethod == null) {
if (this.type.isClass() && !this.type.isAbstract()) {
for (int i = length; --i >= 0;)
- if (!mustImplementAbstractMethod(methods[i]))
- return; // in this case, we have already reported problem against the concrete superclass
+ if (!mustImplementAbstractMethod(methods[i])) return; // have already reported problem against the concrete superclass
- TypeDeclaration typeDeclaration = this.type.scope.referenceContext;
- if (typeDeclaration != null) {
- MethodDeclaration missingAbstractMethod = typeDeclaration.addMissingAbstractMethodFor(methods[0]);
- missingAbstractMethod.scope.problemReporter().abstractMethodMustBeImplemented(this.type, methods[0]);
- } else {
- this.problemReporter().abstractMethodMustBeImplemented(this.type, methods[0]);
- }
+ TypeDeclaration typeDeclaration = this.type.scope.referenceContext;
+ if (typeDeclaration != null) {
+ MethodDeclaration missingAbstractMethod = typeDeclaration.addMissingAbstractMethodFor(methods[0]);
+ missingAbstractMethod.scope.problemReporter().abstractMethodMustBeImplemented(this.type, methods[0]);
+ } else {
+ this.problemReporter().abstractMethodMustBeImplemented(this.type, methods[0]);
+ }
}
return;
}
@@ -349,8 +159,7 @@
else
complain about missing implementation only if type is NOT an interface or abstract
*/
-
-private void checkMethods() {
+private void checkMethods() {
boolean mustImplementAbstractMethods = this.type.isClass() && !this.type.isAbstract();
char[][] methodSelectors = this.inheritedMethods.keyTable;
for (int s = methodSelectors.length; --s >= 0;) {
@@ -387,22 +196,42 @@
}
if (index > 0) {
this.checkInheritedMethods(matchingInherited, index + 1); // pass in the length of matching
- } else {
- if (mustImplementAbstractMethods && index == 0 && matchingInherited[0].isAbstract())
- if (mustImplementAbstractMethod(matchingInherited[0])) {
- TypeDeclaration typeDeclaration = this.type.scope.referenceContext;
- if (typeDeclaration != null) {
- MethodDeclaration missingAbstractMethod = typeDeclaration.addMissingAbstractMethodFor(matchingInherited[0]);
- missingAbstractMethod.scope.problemReporter().abstractMethodMustBeImplemented(this.type, matchingInherited[0]);
- } else {
- this.problemReporter().abstractMethodMustBeImplemented(this.type, matchingInherited[0]);
- }
+ } else if (mustImplementAbstractMethods && index == 0 && matchingInherited[0].isAbstract()) {
+ if (mustImplementAbstractMethod(matchingInherited[0])) {
+ TypeDeclaration typeDeclaration = this.type.scope.referenceContext;
+ if (typeDeclaration != null) {
+ MethodDeclaration missingAbstractMethod = typeDeclaration.addMissingAbstractMethodFor(matchingInherited[0]);
+ missingAbstractMethod.scope.problemReporter().abstractMethodMustBeImplemented(this.type, matchingInherited[0]);
+ } else {
+ this.problemReporter().abstractMethodMustBeImplemented(this.type, matchingInherited[0]);
}
+ }
}
}
}
}
}
+private void checkPackagePrivateAbstractMethod(MethodBinding abstractMethod) {
+ ReferenceBinding superType = this.type.superclass();
+ char[] selector = abstractMethod.selector;
+ do {
+ if (!superType.isValidBinding()) return;
+ if (!superType.isAbstract()) return; // closer non abstract super type will be flagged instead
+
+ MethodBinding[] methods = superType.getMethods(selector);
+ nextMethod : for (int m = methods.length; --m >= 0;) {
+ MethodBinding method = methods[m];
+ if (method.returnType != abstractMethod.returnType || !method.areParametersEqual(abstractMethod))
+ continue nextMethod;
+ if (method.isPrivate() || method.isConstructor() || method.isDefaultAbstract())
+ continue nextMethod;
+ if (superType.fPackage == abstractMethod.declaringClass.fPackage) return; // found concrete implementation of abstract method in same package
+ }
+ } while ((superType = superType.superclass()) != abstractMethod.declaringClass);
+
+ // non visible abstract methods cannot be overridden so the type must be defined abstract
+ this.problemReporter().abstractMethodCannotBeOverridden(this.type, abstractMethod);
+}
/*
Binding creation is responsible for reporting:
- all modifier problems (duplicates & multiple visibility modifiers + incompatible combinations)
@@ -421,12 +250,9 @@
int lastPosition = 0;
interfacesToVisit[lastPosition] = type.superInterfaces();
- ReferenceBinding superType;
- if (this.type.isClass()) {
- superType = this.type.superclass();
- } else { // check interface methods against Object
- superType = this.type.scope.getJavaLangObject();
- }
+ ReferenceBinding superType = this.type.isClass()
+ ? this.type.superclass()
+ : this.type.scope.getJavaLangObject(); // check interface methods against Object
MethodBinding[] nonVisibleDefaultMethods = null;
int nonVisibleCount = 0;
@@ -444,19 +270,23 @@
MethodBinding method = methods[m];
if (!(method.isPrivate() || method.isConstructor() || method.isDefaultAbstract())) { // look at all methods which are NOT private or constructors or default abstract
MethodBinding[] existingMethods = (MethodBinding[]) this.inheritedMethods.get(method.selector);
- if (existingMethods != null)
- for (int i = 0, length = existingMethods.length; i < length; i++)
- if (method.returnType == existingMethods[i].returnType)
- if (method.areParametersEqual(existingMethods[i]))
- continue nextMethod;
+ if (existingMethods != null) {
+ for (int i = 0, length = existingMethods.length; i < length; i++) {
+ if (method.returnType == existingMethods[i].returnType && method.areParametersEqual(existingMethods[i])) {
+ if (method.isDefault() && method.isAbstract() && method.declaringClass.fPackage != type.fPackage)
+ checkPackagePrivateAbstractMethod(method);
+ continue nextMethod;
+ }
+ }
+ }
if (nonVisibleDefaultMethods != null)
for (int i = 0; i < nonVisibleCount; i++)
- if (method.returnType == nonVisibleDefaultMethods[i].returnType)
- if (CharOperation.equals(method.selector, nonVisibleDefaultMethods[i].selector))
- if (method.areParametersEqual(nonVisibleDefaultMethods[i]))
- continue nextMethod;
+ if (method.returnType == nonVisibleDefaultMethods[i].returnType
+ && CharOperation.equals(method.selector, nonVisibleDefaultMethods[i].selector)
+ && method.areParametersEqual(nonVisibleDefaultMethods[i]))
+ continue nextMethod;
- if (!(method.isDefault() && (method.declaringClass.fPackage != type.fPackage))) { // ignore methods which have default visibility and are NOT defined in another package
+ if (!(method.isDefault() && method.declaringClass.fPackage != type.fPackage)) { // ignore methods which have default visibility and are NOT defined in another package
if (existingMethods == null)
existingMethods = new MethodBinding[1];
else
@@ -478,11 +308,9 @@
MethodBinding[] current = (MethodBinding[]) this.currentMethods.get(method.selector);
if (current != null) { // non visible methods cannot be overridden so a warning is issued
foundMatch : for (int i = 0, length = current.length; i < length; i++) {
- if (method.returnType == current[i].returnType) {
- if (method.areParametersEqual(current[i])) {
- this.problemReporter().overridesPackageDefaultMethod(current[i], method);
- break foundMatch;
- }
+ if (method.returnType == current[i].returnType && method.areParametersEqual(current[i])) {
+ this.problemReporter().overridesPackageDefaultMethod(current[i], method);
+ break foundMatch;
}
}
}
@@ -531,50 +359,6 @@
interfaces[j].tagBits &= ~InterfaceVisited;
}
}
-/*
-computeInheritedMethodMembers
-
- "8.4.6.4"
- "Compute all of the members for the type that are inherited from its supertypes.
- This includes:
- All of the methods implemented in the supertype hierarchy that are not overridden.
- PROBLEM: Currently we do not remove overridden methods in the interface hierarchy.
- This could cause a non-existent exception error to be detected."
-
- | supertype allSuperinterfaces methodsSeen interfacesSeen |
- inheritedMethodMembers := LookupTable new: 50.
- allSuperinterfaces := OrderedCollection new.
-
- type isJavaClass ifTrue: [
- supertype := type.
- methodsSeen := EsIdentitySet new: 20.
- [(supertype := self superclassFor: supertype) == nil] whileFalse: [
- (supertype isBuilderClass or: [supertype isValidDescriptor]) ifTrue: [
- allSuperinterfaces addAll: (self superinterfacesFor: supertype).
- supertype javaUserDefinedMethodsDo: [:method |
- (method isJavaPrivate or: [method isJavaConstructor]) ifFalse: [
- (method isJavaDefault and: [method declaringClass package symbol ~= type package symbol]) ifFalse: [
- (methodsSeen includes: method selector) ifFalse: [
- methodsSeen add: method selector.
- (inheritedMethodMembers
- at: (self methodSignatureFor: method selector)
- ifAbsentPut: [OrderedCollection new: 3])
- add: method]]]]]]].
-
- allSuperinterfaces addAll: (self superinterfacesFor: type).
- interfacesSeen := EsIdentitySet new: allSuperinterfaces size * 2.
- [allSuperinterfaces notEmpty] whileTrue: [
- supertype := allSuperinterfaces removeFirst.
- (interfacesSeen includes: supertype) ifFalse: [
- interfacesSeen add: supertype.
- (supertype isBuilderClass or: [supertype isValidDescriptor]) ifTrue: [
- allSuperinterfaces addAll: (self superinterfacesFor: supertype).
- supertype javaUserDefinedMethodsDo: [:method | "Interface methods are all abstract public."
- (inheritedMethodMembers
- at: (self methodSignatureFor: method selector)
- ifAbsentPut: [OrderedCollection new: 3])
- add: method]]]]
-*/
private void computeMethods() {
MethodBinding[] methods = type.methods();
int size = methods.length;
@@ -624,8 +408,11 @@
while (superclass.isAbstract() && superclass != declaringClass)
superclass = superclass.superclass(); // find the first concrete superclass or the abstract declaringClass
} else {
- if (this.type.implementsInterface(declaringClass, false))
- return !this.type.isAbstract();
+ if (this.type.implementsInterface(declaringClass, false)) {
+ if (this.type.isAbstract()) return false; // leave it for the subclasses
+ if (!superclass.implementsInterface(declaringClass, true)) // only if a superclass does not also implement the interface
+ return true;
+ }
while (superclass.isAbstract() && !superclass.implementsInterface(declaringClass, false))
superclass = superclass.superclass(); // find the first concrete superclass or the superclass which implements the interface
}
@@ -651,229 +438,13 @@
this.computeInheritedMethods();
this.checkMethods();
}
-private void zzFieldProblems() {
-}
-/*
-Binding creation is responsible for reporting all problems with fields:
- - all modifier problems (duplicates & multiple visibility modifiers + incompatible combinations - final/volatile)
- - plus invalid modifiers given the context (the verifier did not do this before)
- - include initializers in the modifier checks even though bindings are not created
- - collisions... 2 fields with same name
- - interfaces cannot define initializers
- - nested types cannot define static fields
- - with the type of the field:
- - void is not a valid type (or for an array)
- - an ambiguous, invisible or missing type
-
-verifyFields
-
- | toSearch |
- (toSearch := newClass fields) notEmpty ifTrue: [
- newClass fromJavaClassFile
- ifTrue: [
- toSearch do: [:field |
- field isJavaInitializer ifFalse: [
- self verifyFieldType: field]]]
- ifFalse: [
- toSearch do: [:field |
- field isJavaInitializer
- ifTrue: [self verifyFieldInitializer: field]
- ifFalse: [self verifyField: field]]]]
-
-verifyFieldInitializer: field
-
- type isJavaInterface
- ifTrue: [
- problemSummary
- reportVerificationProblem: #InterfacesCannotHaveInitializers
- args: #()
- severity: nil
- forField: field]
- ifFalse: [
- field isJavaStatic
- ifTrue: [
- field modifiers == AccStatic ifFalse: [
- problemSummary
- reportVerificationProblem: #IllegalModifierForStaticInitializer
- args: #()
- severity: nil
- forField: field]]
- ifFalse: [
- field modifiers == 0 ifFalse: [
- problemSummary
- reportVerificationProblem: #IllegalModifierForInitializer
- args: #()
- severity: nil
- forField: field]]]
-
-verifyField: field
-
- (field basicModifiers anyMask: AccAlternateModifierProblem | AccModifierProblem) ifTrue: [
- self reportModifierProblemsOnField: field].
-
- field isJavaStatic ifTrue: [
- type isJavaStatic ifFalse: [
- (type isJavaNestedType and: [type isJavaClass]) ifTrue: [
- problemSummary
- reportVerificationProblem: #NestedClassCannotHaveStaticField
- args: #()
- severity: nil
- forField: field]]].
-
- self verifyFieldType: field
-
-verifyFieldType: field
-
- | descriptor fieldType |
- "8.3 (Class) 9.3 (Interface)"
- "Optimize the base type case"
- field typeIsBaseType
- ifTrue: [
- field typeName = 'V' ifTrue: [ "$NON-NLS$"
- problemSummary
- reportVerificationProblem: #IllegalTypeForField
- args: (Array with: JavaVoid)
- severity: nil
- forField: field]]
- ifFalse: [
- descriptor := field asDescriptorIn: nameEnvironment.
- (fieldType := descriptor type) isValidDescriptor
- ifTrue: [
- (fieldType isArrayType and: [fieldType leafComponentType isVoidType]) ifTrue: [
- problemSummary
- reportVerificationProblem: #InvalidArrayType
- args: (Array with: fieldType javaReadableName)
- severity: nil
- forField: field]]
- ifFalse: [
- problemSummary
- reportVerificationProblem: #UnboundTypeForField
- args: (Array with: fieldType javaReadableName with: fieldType leafComponentType)
- severity: nil
- forField: field]].
-
-reportModifierProblemsOnField: field
-
- (field basicModifiers anyMask: AccAlternateModifierProblem) ifTrue: [
- (field basicModifiers anyMask: AccModifierProblem)
- ifTrue: [
- ^problemSummary
- reportVerificationProblem: #OnlyOneVisibilityModifierAllowed
- args: #()
- severity: ErrorInfo::ConflictingModifier
- forField: field]
- ifFalse: [
- ^problemSummary
- reportVerificationProblem: #DuplicateModifier
- args: #()
- severity: ErrorInfo::ConflictingModifier
- forField: field]].
-
- type isJavaInterface ifTrue: [
- ^problemSummary
- reportVerificationProblem: #IllegalModifierForInterfaceField
- args: #()
- severity: nil
- forField: field].
-
- (field basicModifiers allMask: AccFinal | AccVolatile) ifTrue: [
- ^problemSummary
- reportVerificationProblem: #IllegalModifierCombinationFinalVolatile
- args: #()
- severity: nil
- forField: field].
-
- ^problemSummary
- reportVerificationProblem: #IllegalModifierForField
- args: #()
- severity: nil
- forField: field
-
-void reportModifierProblems(FieldBinding field) {
- if (field.isFinal() && field.isVolatile())
- this.problemReporter.illegalModifierCombinationFinalVolatile(field);
-
- // Should be able to detect all 3 problems NOT just 1
- if ((type.modifiers() & Modifiers.AccAlternateModifierProblem) == 0) {
- if (this.type.isInterface())
- this.problemReporter.illegalModifierForInterfaceField(field);
- else
- this.problemReporter.illegalModifier(field);
- } else {
- if ((field.modifiers & Modifiers.AccModifierProblem) != 0)
- this.problemReporter.onlyOneVisibilityModifierAllowed(field);
- else
- this.problemReporter.duplicateModifier(field);
- }
-}
-*/
-private void zzImportProblems() {
-}
-/*
-Binding creation is responsible for reporting all problems with imports:
- - on demand imports which refer to missing packages
- - with single type imports:
- - resolves to an ambiguous, invisible or missing type
- - conflicts with the type's source name
- - has the same simple name as another import
-
-Note: VAJ ignored duplicate imports (only one was kept)
-
-verifyImports
-
- | importsBySimpleName nameEnvClass imports cl first |
- importsBySimpleName := LookupTable new.
- nameEnvClass := nameEnvironment class.
-
- "7.5.2"
- type imports do: [:import |
- import isOnDemand
- ifTrue: [
- (nameEnvClass doesPackageExistNamed: import javaPackageName) ifFalse: [
- (nameEnvClass findJavaClassNamedFrom: import javaPackageName) == nil ifTrue: [
- problemSummary
- reportVerificationProblem: #OnDemandImportRefersToMissingPackage
- args: (Array with: import asString)
- severity: ErrorInfo::ImportVerification
- forType: type]]]
- ifFalse: [
- (imports := importsBySimpleName at: import javaSimpleName ifAbsent: []) == nil
- ifTrue: [
- importsBySimpleName at: import javaSimpleName put: (Array with: import)]
- ifFalse: [
- (imports includes: import) ifFalse: [
- importsBySimpleName at: import javaSimpleName put: imports, (Array with: import)]].
-
- "Ignore any imports which are simple names - we will treat these as no-ops."
-
- import javaPackageName notEmpty ifTrue: [
- cl := nameEnvClass findJavaClassNamedFrom: import asString.
-
- (cl ~~ nil and: [cl isJavaPublic or: [cl controller symbol == type controller symbol]]) ifFalse: [
- problemSummary
- reportVerificationProblem: #SingleTypeImportRefersToInvisibleType
- args: (Array with: import asString)
- severity: ErrorInfo::ImportVerification
- forType: type]]]].
-
- importsBySimpleName notEmpty ifTrue: [
- importsBySimpleName keysAndValuesDo: [:simpleName :matching |
- matching size == 1
- ifTrue: [
- simpleName = type sourceName ifTrue: [
- matching first javaReadableName = type javaReadableName ifFalse: [
- problemSummary
- reportVerificationProblem: #SingleTypeImportConflictsWithType
- args: #()
- severity: nil
- forType: type]]]
- ifFalse: [
- problemSummary
- reportVerificationProblem: #SingleTypeImportsHaveSameSimpleName
- args: (Array with: simpleName)
- severity: nil
- forType: type]]]
-*/
-private void zzTypeProblems() {
+public String toString() {
+ StringBuffer buffer = new StringBuffer(10);
+ buffer.append("MethodVerifier for type: "); //$NON-NLS-1$
+ buffer.append(type.readableName());
+ buffer.append('\n');
+ buffer.append("\t-inherited methods: "); //$NON-NLS-1$
+ buffer.append(this.inheritedMethods);
+ return buffer.toString();
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java
index b5d71c3..5327917 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/NestedTypeBinding.java
@@ -1,202 +1,219 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public class NestedTypeBinding extends SourceTypeBinding {
+
public SourceTypeBinding enclosingType;
public SyntheticArgumentBinding[] enclosingInstances;
public SyntheticArgumentBinding[] outerLocalVariables;
- public int syntheticArgumentsOffset; // amount of slots used by synthetic constructor arguments
-public NestedTypeBinding(char[][] typeName, ClassScope scope, SourceTypeBinding enclosingType) {
- super(typeName, enclosingType.fPackage, scope);
- this.tagBits |= IsNestedType;
- this.enclosingType = enclosingType;
-}
-/* Add a new synthetic argument for <actualOuterLocalVariable>.
-* Answer the new argument or the existing argument if one already existed.
-*/
-
-public SyntheticArgumentBinding addSyntheticArgument(LocalVariableBinding actualOuterLocalVariable) {
- SyntheticArgumentBinding synthLocal = null;
-
- if (outerLocalVariables == null) {
- synthLocal = new SyntheticArgumentBinding(actualOuterLocalVariable);
- outerLocalVariables = new SyntheticArgumentBinding[] {synthLocal};
- } else {
- int size = outerLocalVariables.length;
- int newArgIndex = size;
- for (int i = size; --i >= 0;) { // must search backwards
- if (outerLocalVariables[i].actualOuterLocalVariable == actualOuterLocalVariable)
- return outerLocalVariables[i]; // already exists
- if (outerLocalVariables[i].id > actualOuterLocalVariable.id)
- newArgIndex = i;
- }
- SyntheticArgumentBinding[] synthLocals = new SyntheticArgumentBinding[size + 1];
- System.arraycopy(outerLocalVariables, 0, synthLocals, 0, newArgIndex);
- synthLocals[newArgIndex] = synthLocal = new SyntheticArgumentBinding(actualOuterLocalVariable);
- System.arraycopy(outerLocalVariables, newArgIndex, synthLocals, newArgIndex + 1, size - newArgIndex);
- outerLocalVariables = synthLocals;
- }
- //System.out.println("Adding synth arg for local var: " + new String(actualOuterLocalVariable.name) + " to: " + new String(this.readableName()));
- if (scope.referenceCompilationUnit().isPropagatingInnerClassEmulation)
- this.updateInnerEmulationDependents();
- return synthLocal;
-}
-/* Add a new synthetic argument for <enclosingType>.
-* Answer the new argument or the existing argument if one already existed.
-*/
-
-public SyntheticArgumentBinding addSyntheticArgument(ReferenceBinding enclosingType) {
- SyntheticArgumentBinding synthLocal = null;
- if (enclosingInstances == null) {
- synthLocal = new SyntheticArgumentBinding(enclosingType);
- enclosingInstances = new SyntheticArgumentBinding[] {synthLocal};
- } else {
- int size = enclosingInstances.length;
- int newArgIndex = size;
- for (int i = size; --i >= 0;) {
- if (enclosingInstances[i].type == enclosingType)
- return enclosingInstances[i]; // already exists
- if (this.enclosingType() == enclosingType)
- newArgIndex = 0;
- }
- SyntheticArgumentBinding[] newInstances = new SyntheticArgumentBinding[size + 1];
- System.arraycopy(enclosingInstances, 0, newInstances, newArgIndex == 0 ? 1 : 0, size);
- newInstances[newArgIndex] = synthLocal = new SyntheticArgumentBinding(enclosingType);
- enclosingInstances = newInstances;
- }
- //System.out.println("Adding synth arg for enclosing type: " + new String(enclosingType.readableName()) + " to: " + new String(this.readableName()));
- if (scope.referenceCompilationUnit().isPropagatingInnerClassEmulation)
- this.updateInnerEmulationDependents();
- return synthLocal;
-}
-/* Add a new synthetic argument and field for <actualOuterLocalVariable>.
-* Answer the new argument or the existing argument if one already existed.
-*/
-
-public SyntheticArgumentBinding addSyntheticArgumentAndField(LocalVariableBinding actualOuterLocalVariable) {
- SyntheticArgumentBinding synthLocal = addSyntheticArgument(actualOuterLocalVariable);
- if (synthLocal == null) return null;
-
- if (synthLocal.matchingField == null)
- synthLocal.matchingField = addSyntheticField(actualOuterLocalVariable);
- return synthLocal;
-}
-/* Add a new synthetic argument and field for <enclosingType>.
-* Answer the new argument or the existing argument if one already existed.
-*/
-
-public SyntheticArgumentBinding addSyntheticArgumentAndField(ReferenceBinding enclosingType) {
- SyntheticArgumentBinding synthLocal = addSyntheticArgument(enclosingType);
- if (synthLocal == null) return null;
-
- if (synthLocal.matchingField == null)
- synthLocal.matchingField = addSyntheticField(enclosingType);
- return synthLocal;
-}
-/**
- * Compute the resolved positions for all the synthetic arguments
- */
-final public void computeSyntheticArgumentsOffset() {
-
- int position = 1; // inside constructor, reserve room for receiver
+ public int enclosingInstancesSlotSize; // amount of slots used by synthetic enclosing instances
+ public int outerLocalVariablesSlotSize; // amount of slots used by synthetic outer local variables
- // insert enclosing instances first, followed by the outerLocals
- SyntheticArgumentBinding[] enclosingInstances = this.syntheticEnclosingInstances();
- int enclosingInstancesCount = enclosingInstances == null ? 0 : enclosingInstances.length;
- for (int i = 0; i < enclosingInstancesCount; i++){
- SyntheticArgumentBinding syntheticArg = enclosingInstances[i];
- syntheticArg.resolvedPosition = position;
- if ((syntheticArg.type == LongBinding) || (syntheticArg.type == DoubleBinding)){
- position += 2;
- } else {
- position ++;
- }
+ public NestedTypeBinding(char[][] typeName, ClassScope scope, SourceTypeBinding enclosingType) {
+ super(typeName, enclosingType.fPackage, scope);
+ this.tagBits |= IsNestedType;
+ this.enclosingType = enclosingType;
}
- SyntheticArgumentBinding[] outerLocals = this.syntheticOuterLocalVariables();
- int outerLocalsCount = outerLocals == null ? 0 : outerLocals.length;
- for (int i = 0; i < outerLocalsCount; i++){
- SyntheticArgumentBinding syntheticArg = outerLocals[i];
- syntheticArg.resolvedPosition = position;
- if ((syntheticArg.type == LongBinding) || (syntheticArg.type == DoubleBinding)){
- position += 2;
+
+ /* Add a new synthetic argument for <actualOuterLocalVariable>.
+ * Answer the new argument or the existing argument if one already existed.
+ */
+ public SyntheticArgumentBinding addSyntheticArgument(LocalVariableBinding actualOuterLocalVariable) {
+ SyntheticArgumentBinding synthLocal = null;
+
+ if (outerLocalVariables == null) {
+ synthLocal = new SyntheticArgumentBinding(actualOuterLocalVariable);
+ outerLocalVariables = new SyntheticArgumentBinding[] {synthLocal};
} else {
- position ++;
+ int size = outerLocalVariables.length;
+ int newArgIndex = size;
+ for (int i = size; --i >= 0;) { // must search backwards
+ if (outerLocalVariables[i].actualOuterLocalVariable == actualOuterLocalVariable)
+ return outerLocalVariables[i]; // already exists
+ if (outerLocalVariables[i].id > actualOuterLocalVariable.id)
+ newArgIndex = i;
+ }
+ SyntheticArgumentBinding[] synthLocals = new SyntheticArgumentBinding[size + 1];
+ System.arraycopy(outerLocalVariables, 0, synthLocals, 0, newArgIndex);
+ synthLocals[newArgIndex] = synthLocal = new SyntheticArgumentBinding(actualOuterLocalVariable);
+ System.arraycopy(outerLocalVariables, newArgIndex, synthLocals, newArgIndex + 1, size - newArgIndex);
+ outerLocalVariables = synthLocals;
}
+ //System.out.println("Adding synth arg for local var: " + new String(actualOuterLocalVariable.name) + " to: " + new String(this.readableName()));
+ if (scope.referenceCompilationUnit().isPropagatingInnerClassEmulation)
+ this.updateInnerEmulationDependents();
+ return synthLocal;
}
- this.syntheticArgumentsOffset = position;
-}
-/* Answer the receiver's enclosing type... null if the receiver is a top level type.
-*/
-public ReferenceBinding enclosingType() {
- return enclosingType;
-}
-/* Answer the synthetic argument for <actualOuterLocalVariable> or null if one does not exist.
-*/
+ /* Add a new synthetic argument for <enclosingType>.
+ * Answer the new argument or the existing argument if one already existed.
+ */
+ public SyntheticArgumentBinding addSyntheticArgument(ReferenceBinding enclosingType) {
+ SyntheticArgumentBinding synthLocal = null;
+ if (enclosingInstances == null) {
+ synthLocal = new SyntheticArgumentBinding(enclosingType);
+ enclosingInstances = new SyntheticArgumentBinding[] {synthLocal};
+ } else {
+ int size = enclosingInstances.length;
+ int newArgIndex = size;
+ for (int i = size; --i >= 0;) {
+ if (enclosingInstances[i].type == enclosingType)
+ return enclosingInstances[i]; // already exists
+ if (this.enclosingType() == enclosingType)
+ newArgIndex = 0;
+ }
+ SyntheticArgumentBinding[] newInstances = new SyntheticArgumentBinding[size + 1];
+ System.arraycopy(enclosingInstances, 0, newInstances, newArgIndex == 0 ? 1 : 0, size);
+ newInstances[newArgIndex] = synthLocal = new SyntheticArgumentBinding(enclosingType);
+ enclosingInstances = newInstances;
+ }
+ //System.out.println("Adding synth arg for enclosing type: " + new String(enclosingType.readableName()) + " to: " + new String(this.readableName()));
+ if (scope.referenceCompilationUnit().isPropagatingInnerClassEmulation)
+ this.updateInnerEmulationDependents();
+ return synthLocal;
+ }
-public SyntheticArgumentBinding getSyntheticArgument(LocalVariableBinding actualOuterLocalVariable) {
- if (outerLocalVariables == null) return null; // is null if no outer local variables are known
+ /* Add a new synthetic argument and field for <actualOuterLocalVariable>.
+ * Answer the new argument or the existing argument if one already existed.
+ */
+ public SyntheticArgumentBinding addSyntheticArgumentAndField(LocalVariableBinding actualOuterLocalVariable) {
+ SyntheticArgumentBinding synthLocal = addSyntheticArgument(actualOuterLocalVariable);
+ if (synthLocal == null) return null;
+
+ if (synthLocal.matchingField == null)
+ synthLocal.matchingField = addSyntheticField(actualOuterLocalVariable);
+ return synthLocal;
+ }
- for (int i = outerLocalVariables.length; --i >= 0;)
- if (outerLocalVariables[i].actualOuterLocalVariable == actualOuterLocalVariable)
- return outerLocalVariables[i];
- return null;
-}
-public SyntheticArgumentBinding[] syntheticEnclosingInstances() {
- return enclosingInstances; // is null if no enclosing instances are required
-}
-public ReferenceBinding[] syntheticEnclosingInstanceTypes() {
- if (enclosingInstances == null)
+ /* Add a new synthetic argument and field for <enclosingType>.
+ * Answer the new argument or the existing argument if one already existed.
+ */
+ public SyntheticArgumentBinding addSyntheticArgumentAndField(ReferenceBinding enclosingType) {
+ SyntheticArgumentBinding synthLocal = addSyntheticArgument(enclosingType);
+ if (synthLocal == null) return null;
+
+ if (synthLocal.matchingField == null)
+ synthLocal.matchingField = addSyntheticField(enclosingType);
+ return synthLocal;
+ }
+
+ /**
+ * Compute the resolved positions for all the synthetic arguments
+ */
+ final public void computeSyntheticArgumentSlotSizes() {
+
+ int slotSize = 0;
+ // insert enclosing instances first, followed by the outerLocals
+ SyntheticArgumentBinding[] enclosingInstances = this.syntheticEnclosingInstances();
+ int enclosingInstancesCount = enclosingInstances == null ? 0 : enclosingInstances.length;
+ for (int i = 0; i < enclosingInstancesCount; i++){
+ SyntheticArgumentBinding argument = enclosingInstances[i];
+ // position the enclosing instance synthetic arg
+ argument.resolvedPosition = slotSize + 1; // shift by 1 to leave room for aload0==this
+ if (slotSize + 1 > 0xFF) { // no more than 255 words of arguments
+ this.scope.problemReporter().noMoreAvailableSpaceForArgument(argument, this.scope.referenceType());
+ }
+ if ((argument.type == LongBinding) || (argument.type == DoubleBinding)){
+ slotSize += 2;
+ } else {
+ slotSize ++;
+ }
+ }
+ this.enclosingInstancesSlotSize = slotSize;
+
+ slotSize = 0; // reset, outer local are not positionned yet, since will be appended to user arguments
+ SyntheticArgumentBinding[] outerLocals = this.syntheticOuterLocalVariables();
+ int outerLocalsCount = outerLocals == null ? 0 : outerLocals.length;
+ for (int i = 0; i < outerLocalsCount; i++){
+ SyntheticArgumentBinding argument = outerLocals[i];
+ // do NOT position the outerlocal synthetic arg yet, since will be appended to user arguments
+ if ((argument.type == LongBinding) || (argument.type == DoubleBinding)){
+ slotSize += 2;
+ } else {
+ slotSize ++;
+ }
+ }
+ this.outerLocalVariablesSlotSize = slotSize;
+ }
+
+ /* Answer the receiver's enclosing type... null if the receiver is a top level type.
+ */
+ public ReferenceBinding enclosingType() {
+
+ return enclosingType;
+ }
+
+ /* Answer the synthetic argument for <actualOuterLocalVariable> or null if one does not exist.
+ */
+ public SyntheticArgumentBinding getSyntheticArgument(LocalVariableBinding actualOuterLocalVariable) {
+
+ if (outerLocalVariables == null) return null; // is null if no outer local variables are known
+
+ for (int i = outerLocalVariables.length; --i >= 0;)
+ if (outerLocalVariables[i].actualOuterLocalVariable == actualOuterLocalVariable)
+ return outerLocalVariables[i];
return null;
-
- int length = enclosingInstances.length;
- ReferenceBinding types[] = new ReferenceBinding[length];
- for (int i = 0; i < length; i++)
- types[i] = (ReferenceBinding) enclosingInstances[i].type;
- return types;
-}
-public SyntheticArgumentBinding[] syntheticOuterLocalVariables() {
- return outerLocalVariables; // is null if no enclosing instances are required
-}
-/*
- * Trigger the dependency mechanism forcing the innerclass emulation
- * to be propagated to all dependent source types.
- */
-public void updateInnerEmulationDependents() {
- // nothing to do in general, only local types are doing anything
-}
-
-/* Answer the synthetic argument for <targetEnclosingType> or null if one does not exist.
-*/
-
-public SyntheticArgumentBinding getSyntheticArgument(ReferenceBinding targetEnclosingType, BlockScope scope, boolean onlyExactMatch) {
- if (enclosingInstances == null) return null; // is null if no enclosing instances are known
-
- // exact match
- for (int i = enclosingInstances.length; --i >= 0;)
- if (enclosingInstances[i].type == targetEnclosingType)
- if (enclosingInstances[i].actualOuterLocalVariable == null)
- return enclosingInstances[i];
-
- // type compatibility : to handle cases such as
- // class T { class M{}}
- // class S extends T { class N extends M {}} --> need to use S as a default enclosing instance for the super constructor call in N().
- if (!onlyExactMatch){
- for (int i = enclosingInstances.length; --i >= 0;)
- if (enclosingInstances[i].actualOuterLocalVariable == null)
- if (targetEnclosingType.isSuperclassOf((ReferenceBinding) enclosingInstances[i].type))
- return enclosingInstances[i];
}
- return null;
-}
+
+ public SyntheticArgumentBinding[] syntheticEnclosingInstances() {
+ return enclosingInstances; // is null if no enclosing instances are required
+ }
+
+ public ReferenceBinding[] syntheticEnclosingInstanceTypes() {
+ if (enclosingInstances == null)
+ return null;
+
+ int length = enclosingInstances.length;
+ ReferenceBinding types[] = new ReferenceBinding[length];
+ for (int i = 0; i < length; i++)
+ types[i] = (ReferenceBinding) enclosingInstances[i].type;
+ return types;
+ }
+
+ public SyntheticArgumentBinding[] syntheticOuterLocalVariables() {
+
+ return outerLocalVariables; // is null if no outer locals are required
+ }
+
+ /*
+ * Trigger the dependency mechanism forcing the innerclass emulation
+ * to be propagated to all dependent source types.
+ */
+ public void updateInnerEmulationDependents() {
+ // nothing to do in general, only local types are doing anything
+ }
+
+ /* Answer the synthetic argument for <targetEnclosingType> or null if one does not exist.
+ */
+ public SyntheticArgumentBinding getSyntheticArgument(ReferenceBinding targetEnclosingType, boolean onlyExactMatch) {
+
+ if (enclosingInstances == null) return null; // is null if no enclosing instances are known
+
+ // exact match
+ for (int i = enclosingInstances.length; --i >= 0;)
+ if (enclosingInstances[i].type == targetEnclosingType)
+ if (enclosingInstances[i].actualOuterLocalVariable == null)
+ return enclosingInstances[i];
+
+ // type compatibility : to handle cases such as
+ // class T { class M{}}
+ // class S extends T { class N extends M {}} --> need to use S as a default enclosing instance for the super constructor call in N().
+ if (!onlyExactMatch){
+ for (int i = enclosingInstances.length; --i >= 0;)
+ if (enclosingInstances[i].actualOuterLocalVariable == null)
+ if (targetEnclosingType.isSuperclassOf((ReferenceBinding) enclosingInstances[i].type))
+ return enclosingInstances[i];
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
index fe19fd2..6b968d7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.util.HashtableOfPackage;
import org.eclipse.jdt.internal.compiler.util.HashtableOfType;
@@ -36,15 +36,15 @@
*/
public PackageBinding(LookupEnvironment environment) {
- this(NoCharChar, null, environment);
+ this(CharOperation.NO_CHAR_CHAR, null, environment);
}
private void addNotFoundPackage(char[] simpleName) {
- knownPackages.put(simpleName, environment.theNotFoundPackage);
+ knownPackages.put(simpleName, LookupEnvironment.TheNotFoundPackage);
}
private void addNotFoundType(char[] simpleName) {
if (knownTypes == null)
knownTypes = new HashtableOfType(25);
- knownTypes.put(simpleName, environment.theNotFoundType);
+ knownTypes.put(simpleName, LookupEnvironment.TheNotFoundType);
}
void addPackage(PackageBinding element) {
knownPackages.put(element.compoundName[element.compoundName.length - 1], element);
@@ -79,7 +79,7 @@
PackageBinding getPackage(char[] name) {
PackageBinding binding = getPackage0(name);
if (binding != null) {
- if (binding == environment.theNotFoundPackage)
+ if (binding == LookupEnvironment.TheNotFoundPackage)
return null;
else
return binding;
@@ -120,7 +120,7 @@
}
}
- if (binding == environment.theNotFoundType)
+ if (binding == LookupEnvironment.TheNotFoundType)
return null;
if (binding instanceof UnresolvedReferenceBinding)
binding = ((UnresolvedReferenceBinding) binding).resolve(environment);
@@ -153,11 +153,11 @@
public Binding getTypeOrPackage(char[] name) {
PackageBinding packageBinding = getPackage0(name);
- if (packageBinding != null && packageBinding != environment.theNotFoundPackage)
+ if (packageBinding != null && packageBinding != LookupEnvironment.TheNotFoundPackage)
return packageBinding;
ReferenceBinding typeBinding = getType0(name);
- if (typeBinding != null && typeBinding != environment.theNotFoundType) {
+ if (typeBinding != null && typeBinding != LookupEnvironment.TheNotFoundType) {
if (typeBinding instanceof UnresolvedReferenceBinding)
typeBinding = ((UnresolvedReferenceBinding) typeBinding).resolve(environment);
if (typeBinding.isNestedType())
@@ -165,11 +165,10 @@
return typeBinding;
}
- if (typeBinding == null && packageBinding == null) {
- // find the package
- if ((packageBinding = findPackage(name)) != null)
- return packageBinding;
-
+ // always look for the name as a sub-package if its not a known type
+ if (packageBinding == null && (packageBinding = findPackage(name)) != null)
+ return packageBinding;
+ if (typeBinding == null) {
// if no package was found, find the type named name relative to the receiver
if ((typeBinding = environment.askForType(this, name)) != null) {
if (typeBinding.isNestedType())
@@ -182,9 +181,9 @@
addNotFoundPackage(name);
addNotFoundType(name);
} else {
- if (packageBinding == environment.theNotFoundPackage)
+ if (packageBinding == LookupEnvironment.TheNotFoundPackage)
packageBinding = null;
- if (typeBinding == environment.theNotFoundType)
+ if (typeBinding == LookupEnvironment.TheNotFoundType)
typeBinding = null;
}
@@ -197,7 +196,7 @@
return CharOperation.concatWith(compoundName, '.');
}
public String toString() {
- if (compoundName == NoCharChar)
+ if (compoundName == CharOperation.NO_CHAR_CHAR)
return "The Default Package"; //$NON-NLS-1$
else
return "package " + ((compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED"); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemBinding.java
index e036c03..9ada637 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemBinding.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
public class ProblemBinding extends Binding {
public char[] name;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java
index 5f4cc85..f7b16b7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemFieldBinding.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
public class ProblemFieldBinding extends FieldBinding {
private int problemId;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java
index 0609ed5..f4af28f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemMethodBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public class ProblemMethodBinding extends MethodBinding {
@@ -27,6 +27,7 @@
public ProblemMethodBinding(MethodBinding closestMatch, char[] selector, TypeBinding[] args, int problemId) {
this(selector, args, problemId);
this.closestMatch = closestMatch;
+ if (closestMatch != null) this.declaringClass = closestMatch.declaringClass;
}
/* API
* Answer the problem id associated with the receiver.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemPackageBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemPackageBinding.java
index 8bc5dd0..e3f1c9a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemPackageBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemPackageBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public class ProblemPackageBinding extends PackageBinding {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java
index b45e6ab..faba067 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public interface ProblemReasons {
@@ -19,4 +19,5 @@
final int InheritedNameHidesEnclosingName = 5;
final int NonStaticReferenceInConstructorInvocation = 6;
final int NonStaticReferenceInStaticContext = 7;
+ final int ReceiverTypeNotVisible = 8;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java
index 18f506f..afa3635 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public class ProblemReferenceBinding extends ReferenceBinding {
@@ -38,4 +38,12 @@
public final int problemId() {
return problemId;
}
+
+/**
+ * @see org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding#shortReadableName()
+ */
+public char[] shortReadableName() {
+ return readableName();
+}
+
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
index 2cf2fc9..ed890ec 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.IDependent;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/*
Not all fields defined by this type (& its subclasses) are initialized when it is created.
@@ -123,26 +123,22 @@
} while ((type = type.superclass()) != null);
return false;
}
-/* Answer true if the receiver is visible to the type provided by the scope.
-*
-* NOTE: Cannot invoke this method with a compilation unit scope.
-*/
+/*
+ * Answer true if the receiver is visible to the type provided by the scope.
+ */
public final boolean canBeSeenBy(Scope scope) {
+
if (isPublic()) return true;
+ if (scope.kind == Scope.COMPILATION_UNIT_SCOPE){
+ return this.canBeSeenBy(((CompilationUnitScope)scope).fPackage);
+ }
+
SourceTypeBinding invocationType = scope.enclosingSourceType();
if (invocationType == this) return true;
if (isProtected()) {
- // answer true if the receiver (or its enclosing type) is the superclass
- // of the invocationType or in the same package
- return invocationType.fPackage == fPackage
- || isSuperclassOf(invocationType)
- || enclosingType().isSuperclassOf(invocationType); // protected types always have an enclosing one
- }
-
- if (isProtected()) {
// answer true if the invocationType is the declaringClass or they are in the same package
// OR the invocationType is a subclass of the declaringClass
// AND the invocationType is the invocationType or its subclass
@@ -444,7 +440,7 @@
/* Answer true if the receiver type can be assigned to the argument type (right)
*/
-boolean isCompatibleWith(TypeBinding right) {
+public boolean isCompatibleWith(TypeBinding right) {
if (right == this)
return true;
if (right.id == T_Object)
@@ -495,6 +491,12 @@
public final boolean isPrivate() {
return (modifiers & AccPrivate) != 0;
}
+/* Answer true if the receiver has private visibility and is used locally
+*/
+
+public final boolean isPrivateUsed() {
+ return (modifiers & AccPrivateUsed) != 0;
+}
/* Answer true if the receiver has protected visibility
*/
@@ -564,6 +566,14 @@
else
return CharOperation.concatWith(compoundName, '.');
}
+
+public char[] shortReadableName() /*Object*/ {
+ if (isMemberType())
+ return CharOperation.concat(enclosingType().shortReadableName(), sourceName, '.');
+ else
+ return sourceName;
+}
+
/* Answer the receiver's signature.
*
* NOTE: This method should only be used during/after code gen.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
index 3636a6d..bbebdf5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java
@@ -1,19 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
public abstract class Scope
@@ -56,12 +59,6 @@
return true;
}
- /* Answer true if the left type can be assigned to right
- */
- public static boolean areTypesCompatible(TypeBinding left, TypeBinding right) {
- return left.isCompatibleWith(right);
- }
-
/* Answer an int describing the relationship between the given types.
*
* NotRelated
@@ -69,9 +66,9 @@
* MoreGeneric : right is compatible with left
*/
public static int compareTypes(TypeBinding left, TypeBinding right) {
- if (areTypesCompatible(left, right))
+ if (left.isCompatibleWith(right))
return EqualOrMoreSpecific;
- if (areTypesCompatible(right, left))
+ if (right.isCompatibleWith(left))
return MoreGeneric;
return NotRelated;
}
@@ -105,6 +102,14 @@
return new ArrayBinding(type, dimension);
}
+ public final MethodScope enclosingMethodScope() {
+ Scope scope = this;
+ while ((scope = scope.parent) != null) {
+ if (scope instanceof MethodScope) return (MethodScope)scope;
+ }
+ return null; // may answer null if no method around
+ }
+
/* Answer the receiver's enclosing source type.
*/
public final SourceTypeBinding enclosingSourceType() {
@@ -174,6 +179,11 @@
public FieldBinding findField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite) {
if (receiverType.isBaseType()) return null;
if (receiverType.isArrayType()) {
+ TypeBinding leafType = receiverType.leafComponentType();
+ if (leafType instanceof ReferenceBinding) {
+ if (!((ReferenceBinding) leafType).canBeSeenBy(this))
+ return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ReceiverTypeNotVisible);
+ }
if (CharOperation.equals(fieldName, LENGTH))
return ArrayBinding.LengthField;
return null;
@@ -183,8 +193,7 @@
ReferenceBinding currentType = (ReferenceBinding) receiverType;
if (!currentType.canBeSeenBy(this))
- return new ProblemFieldBinding(currentType, fieldName, NotVisible);
- // *** Need a new problem id - TypeNotVisible?
+ return new ProblemFieldBinding(currentType, fieldName, ReceiverTypeNotVisible);
FieldBinding field = currentType.getField(fieldName);
if (field != null) {
@@ -419,11 +428,40 @@
currentType = getJavaLangObject();
}
+ boolean isCompliant14 = compilationUnitScope().environment.options.complianceLevel >= CompilerOptions.JDK1_4;
// superclass lookup
ReferenceBinding classHierarchyStart = currentType;
while (currentType != null) {
MethodBinding[] currentMethods = currentType.getMethods(selector);
int currentLength = currentMethods.length;
+
+ /*
+ * if 1.4 compliant, must filter out redundant protected methods from superclasses
+ */
+ if (isCompliant14){
+ nextMethod: for (int i = 0; i < currentLength; i++){
+ MethodBinding currentMethod = currentMethods[i];
+ // protected method need to be checked only - default access is already dealt with in #canBeSeen implementation
+ // when checking that p.C -> q.B -> p.A cannot see default access members from A through B.
+ if ((currentMethod.modifiers & AccProtected) == 0) continue nextMethod;
+ if (matchingMethod != null){
+ if (currentMethod.areParametersEqual(matchingMethod)){
+ currentLength--;
+ currentMethods[i] = null; // discard this match
+ continue nextMethod;
+ }
+ } else {
+ for (int j = 0, max = found.size; j < max; j++) {
+ if (((MethodBinding)found.elementAt(j)).areParametersEqual(currentMethod)){
+ currentLength--;
+ currentMethods[i] = null;
+ continue nextMethod;
+ }
+ }
+ }
+ }
+ }
+
if (currentLength == 1 && matchingMethod == null && found.size == 0) {
matchingMethod = currentMethods[0];
} else if (currentLength > 0) {
@@ -431,15 +469,31 @@
found.add(matchingMethod);
matchingMethod = null;
}
- found.addAll(currentMethods);
+ // append currentMethods, filtering out null entries
+ int maxMethod = currentMethods.length;
+ if (maxMethod == currentLength) { // no method was eliminated for 1.4 compliance (see above)
+ found.addAll(currentMethods);
+ } else {
+ for (int i = 0, max = currentMethods.length; i < max; i++) {
+ MethodBinding currentMethod = currentMethods[i];
+ if (currentMethod != null) found.add(currentMethod);
+ }
+ }
}
currentType = currentType.superclass();
}
int foundSize = found.size;
if (foundSize == 0) {
- if (matchingMethod != null && areParametersAssignable(matchingMethod.parameters, argumentTypes))
+ if (matchingMethod != null && areParametersAssignable(matchingMethod.parameters, argumentTypes)) {
+ // (if no default abstract) must explicitly look for one instead, which could be a better match
+ if (!matchingMethod.canBeSeenBy(receiverType, invocationSite, this)) {
+ // ignore matching method (to be consistent with multiple matches, none visible (matching method is then null)
+ MethodBinding interfaceMethod = findDefaultAbstractMethod(receiverType, selector, argumentTypes, invocationSite, classHierarchyStart, null, found);
+ if (interfaceMethod != null) return interfaceMethod;
+ }
return matchingMethod;
+ }
return findDefaultAbstractMethod(receiverType, selector, argumentTypes, invocationSite, classHierarchyStart, matchingMethod, found);
}
@@ -498,7 +552,7 @@
MethodBinding interfaceMethod =
findDefaultAbstractMethod(receiverType, selector, argumentTypes, invocationSite, classHierarchyStart, matchingMethod, found);
if (interfaceMethod != null) return interfaceMethod;
- return new ProblemMethodBinding(candidates[0].selector, argumentTypes, candidates[0].declaringClass, NotVisible);
+ return new ProblemMethodBinding(candidates[0], candidates[0].selector, candidates[0].parameters, NotVisible);
}
if (candidates[0].declaringClass.isClass()) {
return mostSpecificClassMethodBinding(candidates, visiblesCount);
@@ -625,6 +679,12 @@
TypeBinding[] argumentTypes,
InvocationSite invocationSite) {
+ TypeBinding leafType = receiverType.leafComponentType();
+ if (leafType instanceof ReferenceBinding) {
+ if (!((ReferenceBinding) leafType).canBeSeenBy(this))
+ return new ProblemMethodBinding(selector, MethodBinding.NoParameters, (ReferenceBinding)leafType, ReceiverTypeNotVisible);
+ }
+
ReferenceBinding object = getJavaLangObject();
MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes);
if (methodBinding != null) {
@@ -653,9 +713,9 @@
NotFound);
if (!methodBinding.canBeSeenBy(receiverType, invocationSite, this))
return new ProblemMethodBinding(
+ methodBinding,
selector,
- argumentTypes,
- methodBinding.declaringClass,
+ methodBinding.parameters,
NotVisible);
}
return methodBinding;
@@ -673,8 +733,6 @@
return null;
if (typeBinding.isValidBinding()) {
-// Not convinced that this is necessary
-// compilationUnitScope().recordTypeReference(typeBinding); // to record supertypes
if (declarationPackage != invocationPackage && !typeBinding.canBeSeenBy(invocationPackage))
return new ProblemReferenceBinding(typeName, typeBinding, NotVisible);
}
@@ -993,12 +1051,7 @@
break;
case CLASS_SCOPE :
SourceTypeBinding sourceType = ((ClassScope) scope).referenceContext.binding;
- if (CharOperation.equals(sourceType.sourceName, name)) {
- if (foundType != null && foundType != sourceType)
- return new ProblemReferenceBinding(name, InheritedNameHidesEnclosingName);
- return sourceType;
- }
-
+ // 6.5.5.1 - simple name favors member type over top-level type in same unit
ReferenceBinding memberType = findMemberType(name, sourceType);
if (memberType != null) { // skip it if we did not find anything
if (memberType.problemId() == Ambiguous) {
@@ -1011,7 +1064,7 @@
}
if (memberType.isValidBinding()) {
if (sourceType == memberType.enclosingType()
- || environment().options.complianceLevel >= CompilerOptions.JDK1_4) {
+ || environment().options.complianceLevel >= CompilerOptions.JDK1_4) {
// found a valid type in the 'immediate' scope (ie. not inherited)
// OR in 1.4 mode (inherited shadows enclosing)
if (foundType == null)
@@ -1026,6 +1079,11 @@
// only remember the memberType if its the first one found or the previous one was not visible & memberType is...
foundType = memberType;
}
+ if (CharOperation.equals(sourceType.sourceName, name)) {
+ if (foundType != null && foundType != sourceType && foundType.problemId() != NotVisible)
+ return new ProblemReferenceBinding(name, InheritedNameHidesEnclosingName);
+ return sourceType;
+ }
break;
case COMPILATION_UNIT_SCOPE :
break done;
@@ -1042,25 +1100,29 @@
if ((mask & TYPE) != 0) {
// check single type imports.
ImportBinding[] imports = unitScope.imports;
- if (imports != null){
+ if (imports != null) {
// copy the list, since single type imports are removed if they cannot be resolved
for (int i = 0, length = imports.length; i < length; i++) {
ImportBinding typeImport = imports[i];
- if (!typeImport.onDemand)
- if (CharOperation.equals(typeImport.compoundName[typeImport.compoundName.length - 1], name))
+ if (!typeImport.onDemand) {
+ if (CharOperation.equals(typeImport.compoundName[typeImport.compoundName.length - 1], name)) {
if (unitScope.resolveSingleTypeImport(typeImport) != null) {
if (typeImport.reference != null) typeImport.reference.used = true;
return typeImport.resolvedImport; // already know its visible
}
+ }
+ }
}
}
- // check if the name is in the current package (answer the problem binding unless its not found in which case continue to look)
- ReferenceBinding type = findType(name, unitScope.fPackage, unitScope.fPackage); // is always visible
- if (type != null) return type;
+ // check if the name is in the current package, skip it if its a sub-package
+ unitScope.recordReference(unitScope.fPackage.compoundName, name);
+ Binding binding = unitScope.fPackage.getTypeOrPackage(name);
+ if (binding instanceof ReferenceBinding) return binding; // type is always visible to its own package
// check on demand imports
boolean foundInImport = false;
- if (imports != null){
+ ReferenceBinding type = null;
+ if (imports != null) {
for (int i = 0, length = imports.length; i < length; i++) {
ImportBinding someImport = imports[i];
if (someImport.onDemand) {
@@ -1080,22 +1142,17 @@
}
}
}
- if (type != null)
- return type;
- }
- // see if the name is a package
- if ((mask & PACKAGE) != 0) {
- compilationUnitScope().recordSimpleReference(name);
- PackageBinding packageBinding = unitScope.environment.getTopLevelPackage(name);
- if (packageBinding != null)
- return packageBinding;
+ if (type != null) return type;
}
- compilationUnitScope().recordSimpleReference(name);
- // Answer error binding -- could not find name
- if (foundType != null){
- return foundType;
+ unitScope.recordSimpleReference(name);
+ if ((mask & PACKAGE) != 0) {
+ PackageBinding packageBinding = unitScope.environment.getTopLevelPackage(name);
+ if (packageBinding != null) return packageBinding;
}
+
+ // Answer error binding -- could not find name
+ if (foundType != null) return foundType; // problem type from above
return new ProblemReferenceBinding(name, NotFound);
}
@@ -1121,17 +1178,104 @@
return false;
}
- public final boolean isJavaIoSerializable(TypeBinding tb) {
- //a first -none optimized version-...:-)....
- //please modify as needed
+ /* Answer true if the scope is nested inside a given field declaration.
+ * Note: it works as long as the scope.fieldDeclarationIndex is reflecting the field being traversed
+ * e.g. during name resolution.
+ */
+ public final boolean isDefinedInField(FieldBinding field) {
+ Scope scope = this;
+ do {
+ if (scope instanceof MethodScope) {
+ MethodScope methodScope = (MethodScope) scope;
+ ReferenceContext refContext = methodScope.referenceContext;
+ if (refContext instanceof TypeDeclaration
+ && ((TypeDeclaration)refContext).binding == field.declaringClass
+ && methodScope.fieldDeclarationIndex == field.id) {
+ return true;
+ }
+ }
+ scope = scope.parent;
+ } while (scope != null);
+ return false;
+ }
+ /* Answer true if the scope is nested inside a given method declaration
+ */
+ public final boolean isDefinedInMethod(MethodBinding method) {
+ Scope scope = this;
+ do {
+ if (scope instanceof MethodScope) {
+ ReferenceContext refContext = ((MethodScope) scope).referenceContext;
+ if (refContext instanceof AbstractMethodDeclaration
+ && ((AbstractMethodDeclaration)refContext).binding == method) {
+ return true;
+ }
+ }
+ scope = scope.parent;
+ } while (scope != null);
+ return false;
+ }
+
+ /* Answer true if the scope is nested inside a given type declaration
+ */
+ public final boolean isDefinedInType(ReferenceBinding type) {
+ Scope scope = this;
+ do {
+ if (scope instanceof ClassScope)
+ if (((ClassScope) scope).referenceContext.binding == type){
+ return true;
+ }
+ scope = scope.parent;
+ } while (scope != null);
+ return false;
+ }
+
+ public boolean isInsideDeprecatedCode(){
+ switch(kind){
+ case Scope.BLOCK_SCOPE :
+ case Scope.METHOD_SCOPE :
+ MethodScope methodScope = methodScope();
+ if (!methodScope.isInsideInitializer()){
+ // check method modifiers to see if deprecated
+ MethodBinding context = ((AbstractMethodDeclaration)methodScope.referenceContext).binding;
+ if (context != null && context.isViewedAsDeprecated()) {
+ return true;
+ }
+ } else {
+ SourceTypeBinding type = ((BlockScope)this).referenceType().binding;
+
+ // inside field declaration ? check field modifier to see if deprecated
+ if (methodScope.fieldDeclarationIndex != MethodScope.NotInFieldDecl) {
+ for (int i = 0; i < type.fields.length; i++){
+ if (type.fields[i].id == methodScope.fieldDeclarationIndex) {
+ // currently inside this field initialization
+ if (type.fields[i].isViewedAsDeprecated()){
+ return true;
+ }
+ break;
+ }
+ }
+ }
+ if (type != null && type.isViewedAsDeprecated()) {
+ return true;
+ }
+ }
+ break;
+ case Scope.CLASS_SCOPE :
+ ReferenceBinding context = ((ClassScope)this).referenceType().binding;
+ if (context != null && context.isViewedAsDeprecated()) {
+ return true;
+ }
+ break;
+ }
+ return false;
+ }
+
+ public final boolean isJavaIoSerializable(TypeBinding tb) {
return tb == getJavaIoSerializable();
}
public final boolean isJavaLangCloneable(TypeBinding tb) {
- //a first -none optimized version-...:-)....
- //please modify as needed
-
return tb == getJavaLangCloneable();
}
@@ -1259,4 +1403,4 @@
int startIndex() {
return 0;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index 36e81c8..e297cc9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -1,18 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
import java.util.Enumeration;
import java.util.Hashtable;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.AssertStatement;
@@ -24,7 +25,6 @@
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class SourceTypeBinding extends ReferenceBinding {
public ReferenceBinding superclass;
@@ -35,13 +35,14 @@
public ClassScope scope;
- // Synthetics are separated into 4 categories: methods, fields, class literals and changed declaring class bindings
+ // Synthetics are separated into 4 categories: methods, super methods, fields, class literals and changed declaring class bindings
public final static int METHOD = 0;
public final static int FIELD = 1;
public final static int CLASS_LITERAL = 2;
public final static int CHANGED_DECLARING_CLASS = 3;
Hashtable[] synthetics;
+
protected SourceTypeBinding() {
}
public SourceTypeBinding(char[][] compoundName, PackageBinding fPackage, ClassScope scope) {
@@ -170,7 +171,7 @@
SyntheticArgumentBinding.EnclosingInstancePrefix,
String.valueOf(enclosingType.depth()).toCharArray()),
enclosingType,
- AccPrivate | AccFinal | AccSynthetic,
+ AccDefault | AccFinal | AccSynthetic,
this,
Constant.NotAConstant,
synthetics[FIELD].size());
@@ -250,7 +251,7 @@
AccDefault | AccStatic | AccSynthetic | AccFinal,
this,
Constant.NotAConstant,
- 0);
+ synthetics[FIELD].size());
synthetics[FIELD].put("assertionEmulation", synthField); //$NON-NLS-1$
}
// ensure there is not already such a field defined by the user
@@ -305,10 +306,11 @@
return accessMethod;
}
/* Add a new synthetic access method for access to <targetMethod>.
+ * Must distinguish access method used for super access from others (need to use invokespecial bytecode)
Answer the new method or the existing method if one already existed.
*/
-public SyntheticAccessMethodBinding addSyntheticMethod(MethodBinding targetMethod) {
+public SyntheticAccessMethodBinding addSyntheticMethod(MethodBinding targetMethod, boolean isSuperAccess) {
if (synthetics == null) {
synthetics = new Hashtable[4];
@@ -317,10 +319,17 @@
synthetics[METHOD] = new Hashtable(5);
}
- SyntheticAccessMethodBinding accessMethod = (SyntheticAccessMethodBinding) synthetics[METHOD].get(targetMethod);
- if (accessMethod == null) {
- accessMethod = new SyntheticAccessMethodBinding(targetMethod, this);
- synthetics[METHOD].put(targetMethod, accessMethod);
+ SyntheticAccessMethodBinding accessMethod = null;
+ SyntheticAccessMethodBinding[] accessors = (SyntheticAccessMethodBinding[]) synthetics[METHOD].get(targetMethod);
+ if (accessors == null) {
+ accessMethod = new SyntheticAccessMethodBinding(targetMethod, isSuperAccess, this);
+ synthetics[METHOD].put(targetMethod, accessors = new SyntheticAccessMethodBinding[2]);
+ accessors[isSuperAccess ? 0 : 1] = accessMethod;
+ } else {
+ if ((accessMethod = accessors[isSuperAccess ? 0 : 1]) == null) {
+ accessMethod = new SyntheticAccessMethodBinding(targetMethod, isSuperAccess, this);
+ accessors[isSuperAccess ? 0 : 1] = accessMethod;
+ }
}
return accessMethod;
}
@@ -880,12 +889,24 @@
SyntheticAccessMethodBinding[] bindings = new SyntheticAccessMethodBinding[1];
Enumeration fieldsOrMethods = synthetics[METHOD].keys();
while (fieldsOrMethods.hasMoreElements()) {
+
Object fieldOrMethod = fieldsOrMethods.nextElement();
+
if (fieldOrMethod instanceof MethodBinding) {
- if (index + 1 > bindings.length)
- System.arraycopy(bindings, 0, (bindings = new SyntheticAccessMethodBinding[index + 1]), 0, index);
- bindings[index++] = (SyntheticAccessMethodBinding) synthetics[METHOD].get(fieldOrMethod);
+
+ SyntheticAccessMethodBinding[] methodAccessors = (SyntheticAccessMethodBinding[]) synthetics[METHOD].get(fieldOrMethod);
+ int numberOfAccessors = 0;
+ if (methodAccessors[0] != null) numberOfAccessors++;
+ if (methodAccessors[1] != null) numberOfAccessors++;
+ if (index + numberOfAccessors > bindings.length)
+ System.arraycopy(bindings, 0, (bindings = new SyntheticAccessMethodBinding[index + numberOfAccessors]), 0, index);
+ if (methodAccessors[0] != null)
+ bindings[index++] = methodAccessors[0]; // super access
+ if (methodAccessors[1] != null)
+ bindings[index++] = methodAccessors[1]; // normal access
+
} else {
+
SyntheticAccessMethodBinding[] fieldAccessors = (SyntheticAccessMethodBinding[]) synthetics[METHOD].get(fieldOrMethod);
int numberOfAccessors = 0;
if (fieldAccessors[0] != null) numberOfAccessors++;
@@ -893,9 +914,9 @@
if (index + numberOfAccessors > bindings.length)
System.arraycopy(bindings, 0, (bindings = new SyntheticAccessMethodBinding[index + numberOfAccessors]), 0, index);
if (fieldAccessors[0] != null)
- bindings[index++] = fieldAccessors[0];
+ bindings[index++] = fieldAccessors[0]; // read access
if (fieldAccessors[1] != null)
- bindings[index++] = fieldAccessors[1];
+ bindings[index++] = fieldAccessors[1]; // write access
}
}
@@ -1018,7 +1039,7 @@
* or null if one does not exist.
*/
-public FieldBinding getSyntheticField(ReferenceBinding targetEnclosingType, BlockScope scope, boolean onlyExactMatch) {
+public FieldBinding getSyntheticField(ReferenceBinding targetEnclosingType, boolean onlyExactMatch) {
if (synthetics == null || synthetics[FIELD] == null) return null;
FieldBinding field = (FieldBinding) synthetics[FIELD].get(targetEnclosingType);
@@ -1031,7 +1052,7 @@
Enumeration enum = synthetics[FIELD].elements();
while (enum.hasMoreElements()) {
field = (FieldBinding) enum.nextElement();
- if (CharOperation.startsWith(field.name, SyntheticArgumentBinding.EnclosingInstancePrefix)
+ if (CharOperation.prefixEquals(SyntheticArgumentBinding.EnclosingInstancePrefix, field.name)
&& targetEnclosingType.isSuperclassOf((ReferenceBinding) field.type))
return field;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticAccessMethodBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticAccessMethodBinding.java
index c600fc8..48bdc09 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticAccessMethodBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticAccessMethodBinding.java
@@ -1,283 +1,288 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class SyntheticAccessMethodBinding extends MethodBinding {
- public FieldBinding targetReadField; // read access to a field
+ public FieldBinding targetReadField; // read access to a field
public FieldBinding targetWriteField; // write access to a field
- public MethodBinding targetMethod; // method or constructor
-
+ public MethodBinding targetMethod; // method or constructor
+
public int accessType;
- public final static int FieldReadAccess = 1;
- public final static int FieldWriteAccess = 2;
- public final static int MethodAccess = 3;
- public final static int ConstructorAccess = 4;
+ public final static int FieldReadAccess = 1; // field read
+ public final static int FieldWriteAccess = 2; // field write
+ public final static int MethodAccess = 3; // normal method
+ public final static int ConstructorAccess = 4; // constructor
+ public final static int SuperMethodAccess = 5; // super method
final static char[] AccessMethodPrefix = { 'a', 'c', 'c', 'e', 's', 's', '$' };
public int sourceStart = 0; // start position of the matching declaration
public int index; // used for sorting access methods in the class file
-public SyntheticAccessMethodBinding(FieldBinding targetField, boolean isReadAccess, ReferenceBinding declaringClass) {
- this.modifiers = AccDefault | AccStatic | AccSynthetic;
- SourceTypeBinding declaringSourceType = (SourceTypeBinding) declaringClass;
- SyntheticAccessMethodBinding[] knownAccessMethods = declaringSourceType.syntheticAccessMethods();
- int methodId = knownAccessMethods == null ? 0 : knownAccessMethods.length;
- this.index = methodId;
- this.selector = CharOperation.concat(AccessMethodPrefix, String.valueOf(methodId).toCharArray());
- if (isReadAccess) {
- this.returnType = targetField.type;
- if (targetField.isStatic()) {
- this.parameters = NoParameters;
- } else {
- this.parameters = new TypeBinding[1];
- this.parameters[0] = declaringSourceType;
- }
- this.targetReadField = targetField;
- this.accessType = FieldReadAccess;
- } else {
- this.returnType = VoidBinding;
- if (targetField.isStatic()) {
- this.parameters = new TypeBinding[1];
- this.parameters[0] = targetField.type;
- } else {
- this.parameters = new TypeBinding[2];
- this.parameters[0] = declaringSourceType;
- this.parameters[1] = targetField.type;
- }
- this.targetWriteField = targetField;
- this.accessType = FieldWriteAccess;
- }
- this.thrownExceptions = NoExceptions;
- this.declaringClass = declaringSourceType;
+
+ public SyntheticAccessMethodBinding(FieldBinding targetField, boolean isReadAccess, ReferenceBinding declaringClass) {
- // check for method collision
- boolean needRename;
- do {
- check : {
- needRename = false;
- // check for collision with known methods
- MethodBinding[] methods = declaringSourceType.methods;
- for (int i = 0, length = methods.length; i < length; i++) {
- if (this.selector == methods[i].selector && this.areParametersEqual(methods[i])) {
- needRename = true;
- break check;
- }
+ this.modifiers = AccDefault | AccStatic | AccSynthetic;
+ SourceTypeBinding declaringSourceType = (SourceTypeBinding) declaringClass;
+ SyntheticAccessMethodBinding[] knownAccessMethods = declaringSourceType.syntheticAccessMethods();
+ int methodId = knownAccessMethods == null ? 0 : knownAccessMethods.length;
+ this.index = methodId;
+ this.selector = CharOperation.concat(AccessMethodPrefix, String.valueOf(methodId).toCharArray());
+ if (isReadAccess) {
+ this.returnType = targetField.type;
+ if (targetField.isStatic()) {
+ this.parameters = NoParameters;
+ } else {
+ this.parameters = new TypeBinding[1];
+ this.parameters[0] = declaringSourceType;
}
- // check for collision with synthetic accessors
- if (knownAccessMethods != null) {
- for (int i = 0, length = knownAccessMethods.length; i < length; i++) {
- if (knownAccessMethods[i] == null) continue;
- if (this.selector == knownAccessMethods[i].selector && this.areParametersEqual(methods[i])) {
+ this.targetReadField = targetField;
+ this.accessType = FieldReadAccess;
+ } else {
+ this.returnType = VoidBinding;
+ if (targetField.isStatic()) {
+ this.parameters = new TypeBinding[1];
+ this.parameters[0] = targetField.type;
+ } else {
+ this.parameters = new TypeBinding[2];
+ this.parameters[0] = declaringSourceType;
+ this.parameters[1] = targetField.type;
+ }
+ this.targetWriteField = targetField;
+ this.accessType = FieldWriteAccess;
+ }
+ this.thrownExceptions = NoExceptions;
+ this.declaringClass = declaringSourceType;
+
+ // check for method collision
+ boolean needRename;
+ do {
+ check : {
+ needRename = false;
+ // check for collision with known methods
+ MethodBinding[] methods = declaringSourceType.methods;
+ for (int i = 0, length = methods.length; i < length; i++) {
+ if (this.selector == methods[i].selector && this.areParametersEqual(methods[i])) {
needRename = true;
break check;
}
}
+ // check for collision with synthetic accessors
+ if (knownAccessMethods != null) {
+ for (int i = 0, length = knownAccessMethods.length; i < length; i++) {
+ if (knownAccessMethods[i] == null) continue;
+ if (this.selector == knownAccessMethods[i].selector && this.areParametersEqual(methods[i])) {
+ needRename = true;
+ break check;
+ }
+ }
+ }
}
- }
- if (needRename) { // retry with a selector postfixed by a growing methodId
- this.selector(CharOperation.concat(AccessMethodPrefix, String.valueOf(++methodId).toCharArray()));
- }
- } while (needRename);
-
- // retrieve sourceStart position for the target field for line number attributes
- FieldDeclaration[] fieldDecls = declaringSourceType.scope.referenceContext.fields;
- if (fieldDecls != null) {
- for (int i = 0, max = fieldDecls.length; i < max; i++) {
- if (fieldDecls[i].binding == targetField) {
- this.sourceStart = fieldDecls[i].sourceStart;
- return;
+ if (needRename) { // retry with a selector postfixed by a growing methodId
+ this.selector(CharOperation.concat(AccessMethodPrefix, String.valueOf(++methodId).toCharArray()));
}
- }
- }
-
-/* did not find the target field declaration - it is a synthetic one
- public class A {
- public class B {
- public class C {
- void foo() {
- System.out.println("A.this = " + A.this);
+ } while (needRename);
+
+ // retrieve sourceStart position for the target field for line number attributes
+ FieldDeclaration[] fieldDecls = declaringSourceType.scope.referenceContext.fields;
+ if (fieldDecls != null) {
+ for (int i = 0, max = fieldDecls.length; i < max; i++) {
+ if (fieldDecls[i].binding == targetField) {
+ this.sourceStart = fieldDecls[i].sourceStart;
+ return;
}
}
}
- public static void main(String args[]) {
- new A().new B().new C().foo();
- }
- }
-*/
- // We now at this point - per construction - it is for sure an enclosing instance, we are going to
- // show the target field type declaration location.
- this.sourceStart = declaringSourceType.scope.referenceContext.sourceStart; // use the target declaring class name position instead
-}
-public SyntheticAccessMethodBinding(MethodBinding targetMethod, ReferenceBinding receiverType) {
-
- if (targetMethod.isConstructor()) {
- this.initializeConstructorAccessor(targetMethod);
- } else {
- this.initializeMethodAccessor(targetMethod, receiverType);
- }
-}
-/**
- * An constructor accessor is a constructor with an extra argument (declaringClass), in case of
- * collision with an existing constructor, then add again an extra argument (declaringClass again).
- */
- public void initializeConstructorAccessor(MethodBinding targetConstructor) {
-
- this.targetMethod = targetConstructor;
- this.modifiers = AccDefault | AccSynthetic;
- SourceTypeBinding sourceType =
- (SourceTypeBinding) targetConstructor.declaringClass;
- SyntheticAccessMethodBinding[] knownAccessMethods =
- sourceType.syntheticAccessMethods();
- this.index = knownAccessMethods == null ? 0 : knownAccessMethods.length;
-
- this.selector = targetConstructor.selector;
- this.returnType = targetConstructor.returnType;
- this.accessType = ConstructorAccess;
- this.parameters = new TypeBinding[targetConstructor.parameters.length + 1];
- System.arraycopy(
- targetConstructor.parameters,
- 0,
- this.parameters,
- 0,
- targetConstructor.parameters.length);
- parameters[targetConstructor.parameters.length] =
- targetConstructor.declaringClass;
- this.thrownExceptions = targetConstructor.thrownExceptions;
- this.declaringClass = sourceType;
-
- // check for method collision
- boolean needRename;
- do {
- check : {
- needRename = false;
- // check for collision with known methods
- MethodBinding[] methods = sourceType.methods;
- for (int i = 0, length = methods.length; i < length; i++) {
- if (this.selector == methods[i].selector
- && this.areParametersEqual(methods[i])) {
- needRename = true;
- break check;
+
+ /* did not find the target field declaration - it is a synthetic one
+ public class A {
+ public class B {
+ public class C {
+ void foo() {
+ System.out.println("A.this = " + A.this);
+ }
}
}
- // check for collision with synthetic accessors
- if (knownAccessMethods != null) {
- for (int i = 0, length = knownAccessMethods.length; i < length; i++) {
- if (knownAccessMethods[i] == null)
- continue;
- if (this.selector == knownAccessMethods[i].selector
+ public static void main(String args[]) {
+ new A().new B().new C().foo();
+ }
+ }
+ */
+ // We now at this point - per construction - it is for sure an enclosing instance, we are going to
+ // show the target field type declaration location.
+ this.sourceStart = declaringSourceType.scope.referenceContext.sourceStart; // use the target declaring class name position instead
+ }
+
+ public SyntheticAccessMethodBinding(MethodBinding targetMethod, boolean isSuperAccess, ReferenceBinding receiverType) {
+
+ if (targetMethod.isConstructor()) {
+ this.initializeConstructorAccessor(targetMethod);
+ } else {
+ this.initializeMethodAccessor(targetMethod, isSuperAccess, receiverType);
+ }
+ }
+
+ /**
+ * An constructor accessor is a constructor with an extra argument (declaringClass), in case of
+ * collision with an existing constructor, then add again an extra argument (declaringClass again).
+ */
+ public void initializeConstructorAccessor(MethodBinding targetConstructor) {
+
+ this.targetMethod = targetConstructor;
+ this.modifiers = AccDefault | AccSynthetic;
+ SourceTypeBinding sourceType = (SourceTypeBinding) targetConstructor.declaringClass;
+ SyntheticAccessMethodBinding[] knownAccessMethods =
+ sourceType.syntheticAccessMethods();
+ this.index = knownAccessMethods == null ? 0 : knownAccessMethods.length;
+
+ this.selector = targetConstructor.selector;
+ this.returnType = targetConstructor.returnType;
+ this.accessType = ConstructorAccess;
+ this.parameters = new TypeBinding[targetConstructor.parameters.length + 1];
+ System.arraycopy(
+ targetConstructor.parameters,
+ 0,
+ this.parameters,
+ 0,
+ targetConstructor.parameters.length);
+ parameters[targetConstructor.parameters.length] =
+ targetConstructor.declaringClass;
+ this.thrownExceptions = targetConstructor.thrownExceptions;
+ this.declaringClass = sourceType;
+
+ // check for method collision
+ boolean needRename;
+ do {
+ check : {
+ needRename = false;
+ // check for collision with known methods
+ MethodBinding[] methods = sourceType.methods;
+ for (int i = 0, length = methods.length; i < length; i++) {
+ if (this.selector == methods[i].selector
&& this.areParametersEqual(methods[i])) {
needRename = true;
break check;
}
}
- }
- }
- if (needRename) { // retry with a new extra argument
- int length = this.parameters.length;
- System.arraycopy(
- this.parameters,
- 0,
- this.parameters = new TypeBinding[length + 1],
- 0,
- length);
- this.parameters[length] = this.declaringClass;
- }
- } while (needRename);
-
- // retrieve sourceStart position for the target method for line number attributes
- AbstractMethodDeclaration[] methodDecls =
- sourceType.scope.referenceContext.methods;
- if (methodDecls != null) {
- for (int i = 0, length = methodDecls.length; i < length; i++) {
- if (methodDecls[i].binding == targetConstructor) {
- this.sourceStart = methodDecls[i].sourceStart;
- return;
- }
- }
- }
-}
-/**
- * An method accessor is a method with an access$N selector, where N is incremented in case of collisions.
- */
-
-public void initializeMethodAccessor(MethodBinding targetMethod, ReferenceBinding declaringClass) {
-
- this.targetMethod = targetMethod;
- this.modifiers = AccDefault | AccStatic | AccSynthetic;
- SourceTypeBinding declaringSourceType = (SourceTypeBinding) declaringClass;
- SyntheticAccessMethodBinding[] knownAccessMethods = declaringSourceType.syntheticAccessMethods();
- int methodId = knownAccessMethods == null ? 0 : knownAccessMethods.length;
- this.index = methodId;
-
- this.selector = CharOperation.concat(AccessMethodPrefix, String.valueOf(methodId).toCharArray());
- this.returnType = targetMethod.returnType;
- this.accessType = MethodAccess;
-
- if (targetMethod.isStatic()) {
- this.parameters = targetMethod.parameters;
- } else {
- this.parameters = new TypeBinding[targetMethod.parameters.length + 1];
- this.parameters[0] = declaringSourceType;
- System.arraycopy(targetMethod.parameters, 0, this.parameters, 1, targetMethod.parameters.length);
- }
- this.thrownExceptions = targetMethod.thrownExceptions;
- this.declaringClass = declaringSourceType;
-
- // check for method collision
- boolean needRename;
- do {
- check : {
- needRename = false;
- // check for collision with known methods
- MethodBinding[] methods = declaringSourceType.methods;
- for (int i = 0, length = methods.length; i < length; i++) {
- if (this.selector == methods[i].selector && this.areParametersEqual(methods[i])) {
- needRename = true;
- break check;
+ // check for collision with synthetic accessors
+ if (knownAccessMethods != null) {
+ for (int i = 0, length = knownAccessMethods.length; i < length; i++) {
+ if (knownAccessMethods[i] == null)
+ continue;
+ if (this.selector == knownAccessMethods[i].selector
+ && this.areParametersEqual(knownAccessMethods[i])) {
+ needRename = true;
+ break check;
+ }
+ }
}
}
- // check for collision with synthetic accessors
- if (knownAccessMethods != null) {
- for (int i = 0, length = knownAccessMethods.length; i < length; i++) {
- if (knownAccessMethods[i] == null) continue;
- if (this.selector == knownAccessMethods[i].selector && this.areParametersEqual(methods[i])) {
+ if (needRename) { // retry with a new extra argument
+ int length = this.parameters.length;
+ System.arraycopy(
+ this.parameters,
+ 0,
+ this.parameters = new TypeBinding[length + 1],
+ 0,
+ length);
+ this.parameters[length] = this.declaringClass;
+ }
+ } while (needRename);
+
+ // retrieve sourceStart position for the target method for line number attributes
+ AbstractMethodDeclaration[] methodDecls =
+ sourceType.scope.referenceContext.methods;
+ if (methodDecls != null) {
+ for (int i = 0, length = methodDecls.length; i < length; i++) {
+ if (methodDecls[i].binding == targetConstructor) {
+ this.sourceStart = methodDecls[i].sourceStart;
+ return;
+ }
+ }
+ }
+ }
+
+ /**
+ * An method accessor is a method with an access$N selector, where N is incremented in case of collisions.
+ */
+ public void initializeMethodAccessor(MethodBinding targetMethod, boolean isSuperAccess, ReferenceBinding declaringClass) {
+
+ this.targetMethod = targetMethod;
+ this.modifiers = AccDefault | AccStatic | AccSynthetic;
+ SourceTypeBinding declaringSourceType = (SourceTypeBinding) declaringClass;
+ SyntheticAccessMethodBinding[] knownAccessMethods = declaringSourceType.syntheticAccessMethods();
+ int methodId = knownAccessMethods == null ? 0 : knownAccessMethods.length;
+ this.index = methodId;
+
+ this.selector = CharOperation.concat(AccessMethodPrefix, String.valueOf(methodId).toCharArray());
+ this.returnType = targetMethod.returnType;
+ this.accessType = isSuperAccess ? SuperMethodAccess : MethodAccess;
+
+ if (targetMethod.isStatic()) {
+ this.parameters = targetMethod.parameters;
+ } else {
+ this.parameters = new TypeBinding[targetMethod.parameters.length + 1];
+ this.parameters[0] = declaringSourceType;
+ System.arraycopy(targetMethod.parameters, 0, this.parameters, 1, targetMethod.parameters.length);
+ }
+ this.thrownExceptions = targetMethod.thrownExceptions;
+ this.declaringClass = declaringSourceType;
+
+ // check for method collision
+ boolean needRename;
+ do {
+ check : {
+ needRename = false;
+ // check for collision with known methods
+ MethodBinding[] methods = declaringSourceType.methods;
+ for (int i = 0, length = methods.length; i < length; i++) {
+ if (this.selector == methods[i].selector && this.areParametersEqual(methods[i])) {
needRename = true;
break check;
}
}
+ // check for collision with synthetic accessors
+ if (knownAccessMethods != null) {
+ for (int i = 0, length = knownAccessMethods.length; i < length; i++) {
+ if (knownAccessMethods[i] == null) continue;
+ if (this.selector == knownAccessMethods[i].selector && this.areParametersEqual(knownAccessMethods[i])) {
+ needRename = true;
+ break check;
+ }
+ }
+ }
}
- }
- if (needRename) { // retry with a selector & a growing methodId
- this.selector(CharOperation.concat(AccessMethodPrefix, String.valueOf(++methodId).toCharArray()));
- }
- } while (needRename);
-
- // retrieve sourceStart position for the target method for line number attributes
- AbstractMethodDeclaration[] methodDecls = declaringSourceType.scope.referenceContext.methods;
- if (methodDecls != null) {
- for (int i = 0, length = methodDecls.length; i < length; i++) {
- if (methodDecls[i].binding == targetMethod) {
- this.sourceStart = methodDecls[i].sourceStart;
- return;
+ if (needRename) { // retry with a selector & a growing methodId
+ this.selector(CharOperation.concat(AccessMethodPrefix, String.valueOf(++methodId).toCharArray()));
+ }
+ } while (needRename);
+
+ // retrieve sourceStart position for the target method for line number attributes
+ AbstractMethodDeclaration[] methodDecls = declaringSourceType.scope.referenceContext.methods;
+ if (methodDecls != null) {
+ for (int i = 0, length = methodDecls.length; i < length; i++) {
+ if (methodDecls[i].binding == targetMethod) {
+ this.sourceStart = methodDecls[i].sourceStart;
+ return;
+ }
}
}
}
-}
-protected boolean isConstructorRelated() {
- return accessType == ConstructorAccess;
-}
+
+ protected boolean isConstructorRelated() {
+ return accessType == ConstructorAccess;
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticArgumentBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticArgumentBinding.java
index 2ad9483..359a41f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticArgumentBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticArgumentBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
/**
@@ -21,14 +21,15 @@
* the user arguments.
*/
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
public class SyntheticArgumentBinding extends LocalVariableBinding {
{
this.isArgument = true;
- this.used = true;
+ this.useFlag = USED;
}
+
// if the argument is mapping to an outer local variable, this denotes the outer actual variable
public LocalVariableBinding actualOuterLocalVariable;
// if the argument has a matching synthetic field
@@ -36,21 +37,25 @@
final static char[] OuterLocalPrefix = { 'v', 'a', 'l', '$' };
final static char[] EnclosingInstancePrefix = { 't', 'h', 'i', 's', '$' };
-public SyntheticArgumentBinding(LocalVariableBinding actualOuterLocalVariable) {
- super(
- CharOperation.concat(OuterLocalPrefix, actualOuterLocalVariable.name),
- actualOuterLocalVariable.type,
- AccFinal,
- true);
- this.actualOuterLocalVariable = actualOuterLocalVariable;
-}
-public SyntheticArgumentBinding(ReferenceBinding enclosingType) {
- super(
- CharOperation.concat(
- SyntheticArgumentBinding.EnclosingInstancePrefix,
- String.valueOf(enclosingType.depth()).toCharArray()),
- enclosingType,
- AccFinal,
- true);
-}
+
+ public SyntheticArgumentBinding(LocalVariableBinding actualOuterLocalVariable) {
+
+ super(
+ CharOperation.concat(OuterLocalPrefix, actualOuterLocalVariable.name),
+ actualOuterLocalVariable.type,
+ AccFinal,
+ true);
+ this.actualOuterLocalVariable = actualOuterLocalVariable;
+ }
+
+ public SyntheticArgumentBinding(ReferenceBinding enclosingType) {
+
+ super(
+ CharOperation.concat(
+ SyntheticArgumentBinding.EnclosingInstancePrefix,
+ String.valueOf(enclosingType.depth()).toCharArray()),
+ enclosingType,
+ AccFinal,
+ true);
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticFieldBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticFieldBinding.java
index 30cfe61..c6dfcdf 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticFieldBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticFieldBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
import org.eclipse.jdt.internal.compiler.impl.Constant;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java
index 41e2e05..61b6794 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public interface TagBits {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
index fcf6db5..39011c4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java
@@ -1,15 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
+import org.eclipse.jdt.core.compiler.CharOperation;
+
/*
* Not all fields defined by this type (& its subclasses) are initialized when it is created.
* Some are initialized only when needed.
@@ -45,6 +47,12 @@
String debugName() {
return new String(readableName());
}
+/*
+ * Answer the receiver's dimensions - 0 for non-array types
+ */
+public int dimensions(){
+ return 0;
+}
public abstract PackageBinding getPackage();
/* Answer true if the receiver is an array
*/
@@ -64,7 +72,7 @@
/* Answer true if the receiver type can be assigned to the argument type (right)
*/
-abstract boolean isCompatibleWith(TypeBinding right);
+public abstract boolean isCompatibleWith(TypeBinding right);
/* Answer true if the receiver's hierarchy has problems (always false for arrays & base types)
*/
@@ -101,7 +109,10 @@
*/
public char[] qualifiedPackageName() {
- return getPackage() == null ? NoChar : getPackage().readableName();
+ PackageBinding packageBinding = getPackage();
+ return packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR
+ ? CharOperation.NO_CHAR
+ : packageBinding.readableName();
}
/**
* Answer the source name for the type.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
index c80d799..feb9d5d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java
@@ -1,61 +1,67 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public interface TypeConstants {
- final char[] JAVA = new char[] {'j', 'a', 'v', 'a'};
- final char[] LANG = new char[] {'l', 'a', 'n', 'g'};
- final char[] IO = new char[] {'i', 'o'};
- final char[] REFLECT = new char[] {'r', 'e', 'f', 'l', 'e', 'c', 't'};
- final char[] CharArray_JAVA_LANG_OBJECT = new char[] {'j', 'a', 'v', 'a', '.', 'l', 'a', 'n', 'g', '.', 'O', 'b', 'j', 'e', 'c', 't'};
- final char[] LENGTH = new char[] {'l', 'e', 'n', 'g', 't', 'h'};
- final char[] CLONE = new char[] {'c', 'l', 'o', 'n', 'e'};
-
+ final char[] JAVA = "java".toCharArray(); //$NON-NLS-1$
+ final char[] LANG = "lang".toCharArray(); //$NON-NLS-1$
+ final char[] IO = "io".toCharArray(); //$NON-NLS-1$
+ final char[] REFLECT = "reflect".toCharArray(); //$NON-NLS-1$
+ final char[] CharArray_JAVA_LANG_OBJECT = "java.lang.Object".toCharArray(); //$NON-NLS-1$
+ final char[] LENGTH = "length".toCharArray(); //$NON-NLS-1$
+ final char[] CLONE = "clone".toCharArray(); //$NON-NLS-1$
+ final char[] OBJECT = "Object".toCharArray(); //$NON-NLS-1$
+ final char[] MAIN = "main".toCharArray(); //$NON-NLS-1$
+ final char[] SERIALVERSIONUID = "serialVersionUID".toCharArray(); //$NON-NLS-1$
+ final char[] READRESOLVE = "readResolve".toCharArray(); //$NON-NLS-1$
+ final char[] WRITEREPLACE = "writeReplace".toCharArray(); //$NON-NLS-1$
+ final char[] READOBJECT = "readObject".toCharArray(); //$NON-NLS-1$
+ final char[] WRITEOBJECT = "writeObject".toCharArray(); //$NON-NLS-1$
+ final char[] CharArray_JAVA_IO_OBJECTINPUTSTREAM = "java.io.ObjectInputStream".toCharArray(); //$NON-NLS-1$
+ final char[] CharArray_JAVA_IO_OBJECTOUTPUTSTREAM = "java.io.ObjectOutputStream".toCharArray(); //$NON-NLS-1$
+
// Constant compound names
- final char[][] JAVA_LANG = new char[][] {JAVA, LANG};
- final char[][] JAVA_IO = new char[][] {JAVA, IO};
- final char[][] JAVA_LANG_ASSERTIONERROR = new char[][] {JAVA, LANG, "AssertionError".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_CLASS = new char[][] {JAVA, LANG, {'C', 'l', 'a', 's', 's'}};
- final char[][] JAVA_LANG_CLASSNOTFOUNDEXCEPTION = new char[][] {JAVA, LANG, {'C', 'l', 'a', 's', 's', 'N', 'o', 't', 'F', 'o', 'u', 'n', 'd', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n'}};
- final char[][] JAVA_LANG_CLONEABLE = new char[][] {JAVA, LANG, {'C', 'l', 'o', 'n', 'e', 'a', 'b', 'l', 'e'}};
- final char[][] JAVA_LANG_EXCEPTION = new char[][] {JAVA, LANG, {'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n'}};
- final char[][] JAVA_LANG_ERROR = new char[][] {JAVA, LANG, {'E', 'r', 'r', 'o', 'r'}};
- final char[][] JAVA_LANG_NOCLASSDEFERROR = new char[][] {JAVA, LANG, {'N', 'o', 'C', 'l', 'a', 's', 's', 'D', 'e', 'f', 'E', 'r', 'r', 'o', 'r'}};
- final char[][] JAVA_LANG_OBJECT = new char[][] {JAVA, LANG, {'O', 'b', 'j', 'e', 'c', 't'}};
- final char[][] JAVA_LANG_STRING = new char[][] {JAVA, LANG, {'S', 't', 'r', 'i', 'n', 'g'}};
- final char[][] JAVA_LANG_STRINGBUFFER = new char[][] {JAVA, LANG, {'S', 't', 'r', 'i', 'n', 'g', 'B', 'u', 'f', 'f', 'e', 'r'}};
- final char[][] JAVA_LANG_SYSTEM = new char[][] {JAVA, LANG, {'S', 'y', 's', 't', 'e', 'm'}};
- final char[][] JAVA_LANG_RUNTIMEEXCEPTION = new char[][] {JAVA, LANG, {'R', 'u', 'n', 't', 'i', 'm', 'e', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n'}};
- final char[][] JAVA_LANG_THROWABLE = new char[][] {JAVA, LANG, {'T', 'h', 'r', 'o', 'w', 'a', 'b', 'l', 'e'}};
- final char[][] JAVA_LANG_REFLECT_CONSTRUCTOR = new char[][] {JAVA, LANG, REFLECT, {'C', 'o', 'n', 's', 't', 'r', 'u', 'c', 't', 'o', 'r'}};
- final char[][] JAVA_IO_PRINTSTREAM = new char[][] {JAVA, IO, {'P', 'r', 'i', 'n', 't', 'S', 't', 'r', 'e', 'a', 'm'}};
- final char[][] JAVA_IO_SERIALIZABLE = new char[][] {JAVA, IO, {'S', 'e', 'r', 'i', 'a', 'l', 'i', 'z', 'a', 'b', 'l', 'e'}};
- final char[][] JAVA_LANG_BYTE = new char[][] {JAVA, LANG, "Byte".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_SHORT = new char[][] {JAVA, LANG, "Short".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_CHARACTER = new char[][] {JAVA, LANG, "Character".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_INTEGER = new char[][] {JAVA, LANG, "Integer".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_LONG = new char[][] {JAVA, LANG, "Long".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_FLOAT = new char[][] {JAVA, LANG, "Float".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_DOUBLE = new char[][] {JAVA, LANG, "Double".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_BOOLEAN = new char[][] {JAVA, LANG, "Boolean".toCharArray()}; //$NON-NLS-1$
- final char[][] JAVA_LANG_VOID = new char[][] {JAVA, LANG, "Void".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG = {JAVA, LANG};
+ final char[][] JAVA_IO = {JAVA, IO};
+ final char[][] JAVA_LANG_ASSERTIONERROR = {JAVA, LANG, "AssertionError".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_CLASS = {JAVA, LANG, "Class".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_CLASSNOTFOUNDEXCEPTION = {JAVA, LANG, "ClassNotFoundException".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_CLONEABLE = {JAVA, LANG, "Cloneable".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_EXCEPTION = {JAVA, LANG, "Exception".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_ERROR = {JAVA, LANG, "Error".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_NOCLASSDEFERROR = {JAVA, LANG, "NoClassDefError".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_OBJECT = {JAVA, LANG, OBJECT};
+ final char[][] JAVA_LANG_STRING = {JAVA, LANG, "String".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_STRINGBUFFER = {JAVA, LANG, "StringBuffer".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_SYSTEM = {JAVA, LANG, "System".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_RUNTIMEEXCEPTION = {JAVA, LANG, "RuntimeException".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_THROWABLE = {JAVA, LANG, "Throwable".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_REFLECT_CONSTRUCTOR = {JAVA, LANG, REFLECT, "Constructor".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_IO_PRINTSTREAM = {JAVA, IO, "PrintStream".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_IO_SERIALIZABLE = {JAVA, IO, "Serializable".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_BYTE = {JAVA, LANG, "Byte".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_SHORT = {JAVA, LANG, "Short".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_CHARACTER = {JAVA, LANG, "Character".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_INTEGER = {JAVA, LANG, "Integer".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_LONG = {JAVA, LANG, "Long".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_FLOAT = {JAVA, LANG, "Float".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_DOUBLE = {JAVA, LANG, "Double".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_BOOLEAN = {JAVA, LANG, "Boolean".toCharArray()}; //$NON-NLS-1$
+ final char[][] JAVA_LANG_VOID = {JAVA, LANG, "Void".toCharArray()}; //$NON-NLS-1$
// Constants used by the flow analysis
final int EqualOrMoreSpecific = -1;
final int NotRelated = 0;
final int MoreGeneric = 1;
- // Empty Collection which can later assign to null if performance is an issue.
- final char[] NoChar = new char[0];
- final char[][] NoCharChar = new char[0][];
// Method collections
final TypeBinding[] NoParameters = new TypeBinding[0];
final ReferenceBinding[] NoExceptions = new ReferenceBinding[0];
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java
index 1b0e539..6e61744 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
public interface TypeIds {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
index 73244a2..a602786 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/UnresolvedReferenceBinding.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
public class UnresolvedReferenceBinding extends ReferenceBinding {
ReferenceBinding resolvedType;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java
index 09d674e..38209b8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
import org.eclipse.jdt.internal.compiler.impl.Constant;
@@ -18,9 +18,14 @@
public char[] name;
public Constant constant;
public int id; // for flow-analysis (position in flowInfo bit vector)
+
public boolean isConstantValue() {
return constant != Constant.NotAConstant;
}
+
+public final boolean isBlankFinal(){
+ return (modifiers & AccBlankFinal) != 0;
+}
/* Answer true if the receiver is final and cannot be changed
*/
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/NLSLine.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/NLSLine.java
index ca6eb13..666f78f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/NLSLine.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/NLSLine.java
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index 06138d4..4d99fb1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -1,29 +1,35 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ * Tom Tromey - patch for readTable(String) as described in http://bugs.eclipse.org/bugs/show_bug.cgi?id=32196
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
-import org.eclipse.jdt.core.compiler.*;
-import org.eclipse.jdt.core.compiler.InvalidInputException;
-import org.eclipse.jdt.internal.compiler.*;
-import org.eclipse.jdt.internal.compiler.env.*;
-import org.eclipse.jdt.internal.compiler.impl.*;
-import org.eclipse.jdt.internal.compiler.ast.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
-
import java.io.*;
-import java.util.ArrayList;
-public class Parser implements BindingIds, ParserBasicInformation, ITerminalSymbols, CompilerModifiers, OperatorIds, TypeIds {
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
+import org.eclipse.jdt.internal.compiler.lookup.BindingIds;
+import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
+import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
+import org.eclipse.jdt.internal.compiler.util.Util;
+
+public class Parser implements BindingIds, ParserBasicInformation, TerminalTokens, CompilerModifiers, OperatorIds, TypeIds {
+
protected ProblemReporter problemReporter;
public int firstToken ; // handle for multiple parsing goals
public int lastAct ; //handle for multiple parsing goals
@@ -109,248 +115,245 @@
1,3,3,2,1,1,1,1,1,1,1,5,7,7,6,
2,3,3,4,1,2,2,1,2,3,2,5,5,7,9,
9,1,1,1,1,3,3,5,2,3,2,3,3,3,5,
- 1,3,4,1,2,5,2,1,1,1,1,1,1,3,1,
- 1,3,3,3,3,3,1,1,5,6,8,7,2,0,2,
- 0,1,3,4,4,1,2,3,2,1,1,2,2,3,3,
- 4,6,6,4,4,1,1,1,1,2,2,0,1,1,3,
- 3,1,3,3,1,3,3,1,5,5,4,1,3,3,3,
- 1,3,3,1,3,3,3,1,3,3,3,3,3,1,3,
- 3,1,3,1,3,1,3,1,3,1,3,1,5,1,1,
- 3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,
- 0,1,0,2,0,1,0,1,0,1,0,1,0,1,0,
- 1,0,1,0,2,0,0,1,0,1,0,1,0,1,0,
- 1
+ 1,3,4,1,2,5,2,1,1,1,1,1,1,1,3,
+ 1,1,3,3,3,3,3,1,1,5,6,8,7,2,0,
+ 2,0,1,3,3,4,3,4,1,2,3,2,1,1,2,
+ 2,3,3,4,6,6,4,4,4,1,1,1,1,2,2,
+ 0,1,1,3,3,1,3,3,1,3,3,1,6,6,5,
+ 0,0,1,3,3,3,1,3,3,1,3,3,3,1,3,
+ 3,3,3,3,1,3,3,1,3,1,3,1,3,1,3,
+ 1,3,1,5,1,1,3,3,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,
+ 1,0,1,0,1,0,2,0,1,0,1,0,1,0,1,
+ 0,1,0,1,0,1,0,2,0,0,1,0,1,0,1,
+ 0,1
};
-
public static char asb[] = null;
public static char asr[] = null;
public static char symbol_index[] = null;
private static final String UNEXPECTED_EOF = "Unexpected End Of File" ; //$NON-NLS-1$
- public final static String name[] = { null,
- "++",//$NON-NLS-1$
- "--",//$NON-NLS-1$
- "==",//$NON-NLS-1$
- "<=",//$NON-NLS-1$
- ">=",//$NON-NLS-1$
- "!=",//$NON-NLS-1$
- "<<",//$NON-NLS-1$
- ">>",//$NON-NLS-1$
- ">>>",//$NON-NLS-1$
- "+=",//$NON-NLS-1$
- "-=",//$NON-NLS-1$
- "*=",//$NON-NLS-1$
- "/=",//$NON-NLS-1$
- "&=",//$NON-NLS-1$
- "|=",//$NON-NLS-1$
- "^=",//$NON-NLS-1$
- "%=",//$NON-NLS-1$
- "<<=",//$NON-NLS-1$
- ">>=",//$NON-NLS-1$
- ">>>=",//$NON-NLS-1$
- "||",//$NON-NLS-1$
- "&&",//$NON-NLS-1$
- "+",//$NON-NLS-1$
- "-",//$NON-NLS-1$
- "!",//$NON-NLS-1$
- "%",//$NON-NLS-1$
- "^",//$NON-NLS-1$
- "&",//$NON-NLS-1$
- "*",//$NON-NLS-1$
- "|",//$NON-NLS-1$
- "~",//$NON-NLS-1$
- "/",//$NON-NLS-1$
- ">",//$NON-NLS-1$
- "<",//$NON-NLS-1$
- "(",//$NON-NLS-1$
- ")",//$NON-NLS-1$
- "{",//$NON-NLS-1$
- "}",//$NON-NLS-1$
- "[",//$NON-NLS-1$
- "]",//$NON-NLS-1$
- ";",//$NON-NLS-1$
- "?",//$NON-NLS-1$
- ":",//$NON-NLS-1$
- ",",//$NON-NLS-1$
- ".",//$NON-NLS-1$
- "=",//$NON-NLS-1$
- "",//$NON-NLS-1$
- "$empty",//$NON-NLS-1$
- "Identifier",//$NON-NLS-1$
- "abstract",//$NON-NLS-1$
- "assert",//$NON-NLS-1$
- "boolean",//$NON-NLS-1$
- "break",//$NON-NLS-1$
- "byte",//$NON-NLS-1$
- "case",//$NON-NLS-1$
- "catch",//$NON-NLS-1$
- "char",//$NON-NLS-1$
- "class",//$NON-NLS-1$
- "continue",//$NON-NLS-1$
- "default",//$NON-NLS-1$
- "do",//$NON-NLS-1$
- "double",//$NON-NLS-1$
- "else",//$NON-NLS-1$
- "extends",//$NON-NLS-1$
- "false",//$NON-NLS-1$
- "final",//$NON-NLS-1$
- "finally",//$NON-NLS-1$
- "float",//$NON-NLS-1$
- "for",//$NON-NLS-1$
- "if",//$NON-NLS-1$
- "implements",//$NON-NLS-1$
- "import",//$NON-NLS-1$
- "instanceof",//$NON-NLS-1$
- "int",//$NON-NLS-1$
- "interface",//$NON-NLS-1$
- "long",//$NON-NLS-1$
- "native",//$NON-NLS-1$
- "new",//$NON-NLS-1$
- "null",//$NON-NLS-1$
- "package",//$NON-NLS-1$
- "private",//$NON-NLS-1$
- "protected",//$NON-NLS-1$
- "public",//$NON-NLS-1$
- "return",//$NON-NLS-1$
- "short",//$NON-NLS-1$
- "static",//$NON-NLS-1$
- "strictfp",//$NON-NLS-1$
- "super",//$NON-NLS-1$
- "switch",//$NON-NLS-1$
- "synchronized",//$NON-NLS-1$
- "this",//$NON-NLS-1$
- "throw",//$NON-NLS-1$
- "throws",//$NON-NLS-1$
- "transient",//$NON-NLS-1$
- "true",//$NON-NLS-1$
- "try",//$NON-NLS-1$
- "void",//$NON-NLS-1$
- "volatile",//$NON-NLS-1$
- "while",//$NON-NLS-1$
- "IntegerLiteral",//$NON-NLS-1$
- "LongLiteral",//$NON-NLS-1$
- "FloatingPointLiteral",//$NON-NLS-1$
- "DoubleLiteral",//$NON-NLS-1$
- "CharacterLiteral",//$NON-NLS-1$
- "StringLiteral",//$NON-NLS-1$
- UNEXPECTED_EOF,
- "Invalid Character",//$NON-NLS-1$
- "Goal",//$NON-NLS-1$
- "MethodBody",//$NON-NLS-1$
- "ConstructorBody",//$NON-NLS-1$
- "StaticInitializer",//$NON-NLS-1$
- "Initializer",//$NON-NLS-1$
- "Headers",//$NON-NLS-1$
- "BlockStatements",//$NON-NLS-1$
- "MethodPushModifiersHeader",//$NON-NLS-1$
- "CatchHeader",//$NON-NLS-1$
- "FieldDeclaration",//$NON-NLS-1$
- "ImportDeclaration",//$NON-NLS-1$
- "PackageDeclaration",//$NON-NLS-1$
- "TypeDeclaration",//$NON-NLS-1$
- "GenericMethodDeclaration",//$NON-NLS-1$
- "ClassBodyDeclaration",//$NON-NLS-1$
- "Expression",//$NON-NLS-1$
- "Type",//$NON-NLS-1$
- "PrimitiveType",//$NON-NLS-1$
- "ReferenceType",//$NON-NLS-1$
- "ClassOrInterfaceType",//$NON-NLS-1$
- "ArrayType",//$NON-NLS-1$
- "Name",//$NON-NLS-1$
- "Dims",//$NON-NLS-1$
- "ClassType",//$NON-NLS-1$
- "SimpleName",//$NON-NLS-1$
- "Header",//$NON-NLS-1$
- "ClassHeader",//$NON-NLS-1$
- "InterfaceHeader",//$NON-NLS-1$
- "MethodHeader",//$NON-NLS-1$
- "ConstructorHeader",//$NON-NLS-1$
- "FormalParameter",//$NON-NLS-1$
- "ImportDeclarations",//$NON-NLS-1$
- "TypeDeclarations",//$NON-NLS-1$
- "PackageDeclarationName",//$NON-NLS-1$
- "SingleTypeImportDeclarationName",//$NON-NLS-1$
- "TypeImportOnDemandDeclarationName",//$NON-NLS-1$
- "Modifiers",//$NON-NLS-1$
- "Modifier",//$NON-NLS-1$
- "ClassBody",//$NON-NLS-1$
- "ClassHeaderName",//$NON-NLS-1$
- "InterfaceTypeList",//$NON-NLS-1$
- "InterfaceType",//$NON-NLS-1$
- "ClassBodyDeclarations",//$NON-NLS-1$
- "Block",//$NON-NLS-1$
- "VariableDeclarators",//$NON-NLS-1$
- "VariableDeclarator",//$NON-NLS-1$
- "VariableDeclaratorId",//$NON-NLS-1$
- "VariableInitializer",//$NON-NLS-1$
- "ArrayInitializer",//$NON-NLS-1$
- "MethodHeaderName",//$NON-NLS-1$
- "MethodHeaderParameters",//$NON-NLS-1$
- "MethodPushModifiersHeaderName",//$NON-NLS-1$
- "ClassTypeList",//$NON-NLS-1$
- "ConstructorHeaderName",//$NON-NLS-1$
- "FormalParameterList",//$NON-NLS-1$
- "ClassTypeElt",//$NON-NLS-1$
- "StaticOnly",//$NON-NLS-1$
- "ExplicitConstructorInvocation",//$NON-NLS-1$
- "Primary",//$NON-NLS-1$
- "InterfaceBody",//$NON-NLS-1$
- "InterfaceHeaderName",//$NON-NLS-1$
- "InterfaceMemberDeclarations",//$NON-NLS-1$
- "InterfaceMemberDeclaration",//$NON-NLS-1$
- "VariableInitializers",//$NON-NLS-1$
- "BlockStatement",//$NON-NLS-1$
- "Statement",//$NON-NLS-1$
- "LocalVariableDeclaration",//$NON-NLS-1$
- "StatementWithoutTrailingSubstatement",//$NON-NLS-1$
- "StatementNoShortIf",//$NON-NLS-1$
- "StatementExpression",//$NON-NLS-1$
- "PostIncrementExpression",//$NON-NLS-1$
- "PostDecrementExpression",//$NON-NLS-1$
- "MethodInvocation",//$NON-NLS-1$
- "ClassInstanceCreationExpression",//$NON-NLS-1$
- "SwitchBlock",//$NON-NLS-1$
- "SwitchBlockStatements",//$NON-NLS-1$
- "SwitchLabels",//$NON-NLS-1$
- "SwitchBlockStatement",//$NON-NLS-1$
- "SwitchLabel",//$NON-NLS-1$
- "ConstantExpression",//$NON-NLS-1$
- "StatementExpressionList",//$NON-NLS-1$
- "OnlySynchronized",//$NON-NLS-1$
- "Catches",//$NON-NLS-1$
- "Finally",//$NON-NLS-1$
- "CatchClause",//$NON-NLS-1$
- "PushLPAREN",//$NON-NLS-1$
- "PushRPAREN",//$NON-NLS-1$
- "PrimaryNoNewArray",//$NON-NLS-1$
- "FieldAccess",//$NON-NLS-1$
- "ArrayAccess",//$NON-NLS-1$
- "ClassInstanceCreationExpressionName",//$NON-NLS-1$
- "ArgumentList",//$NON-NLS-1$
- "DimWithOrWithOutExprs",//$NON-NLS-1$
- "DimWithOrWithOutExpr",//$NON-NLS-1$
- "DimsLoop",//$NON-NLS-1$
- "OneDimLoop",//$NON-NLS-1$
- "PostfixExpression",//$NON-NLS-1$
- "UnaryExpression",//$NON-NLS-1$
- "UnaryExpressionNotPlusMinus",//$NON-NLS-1$
- "MultiplicativeExpression",//$NON-NLS-1$
- "AdditiveExpression",//$NON-NLS-1$
- "ShiftExpression",//$NON-NLS-1$
- "RelationalExpression",//$NON-NLS-1$
- "EqualityExpression",//$NON-NLS-1$
- "AndExpression",//$NON-NLS-1$
- "ExclusiveOrExpression",//$NON-NLS-1$
- "InclusiveOrExpression",//$NON-NLS-1$
- "ConditionalAndExpression",//$NON-NLS-1$
- "ConditionalOrExpression",//$NON-NLS-1$
- "ConditionalExpression",//$NON-NLS-1$
- "AssignmentExpression",//$NON-NLS-1$
- "LeftHandSide",//$NON-NLS-1$
- "AssignmentOperator"//$NON-NLS-1$
- };
+ public final static String name[] = { null,
+ "++", //$NON-NLS-1$
+ "--", //$NON-NLS-1$
+ "==", //$NON-NLS-1$
+ "<=", //$NON-NLS-1$
+ ">=", //$NON-NLS-1$
+ "!=", //$NON-NLS-1$
+ "<<", //$NON-NLS-1$
+ ">>", //$NON-NLS-1$
+ ">>>", //$NON-NLS-1$
+ "+=", //$NON-NLS-1$
+ "-=", //$NON-NLS-1$
+ "*=", //$NON-NLS-1$
+ "/=", //$NON-NLS-1$
+ "&=", //$NON-NLS-1$
+ "|=", //$NON-NLS-1$
+ "^=", //$NON-NLS-1$
+ "%=", //$NON-NLS-1$
+ "<<=", //$NON-NLS-1$
+ ">>=", //$NON-NLS-1$
+ ">>>=", //$NON-NLS-1$
+ "||", //$NON-NLS-1$
+ "&&", //$NON-NLS-1$
+ "+", //$NON-NLS-1$
+ "-", //$NON-NLS-1$
+ "!", //$NON-NLS-1$
+ "%", //$NON-NLS-1$
+ "^", //$NON-NLS-1$
+ "&", //$NON-NLS-1$
+ "*", //$NON-NLS-1$
+ "|", //$NON-NLS-1$
+ "~", //$NON-NLS-1$
+ "/", //$NON-NLS-1$
+ ">", //$NON-NLS-1$
+ "<", //$NON-NLS-1$
+ "(", //$NON-NLS-1$
+ ")", //$NON-NLS-1$
+ "{", //$NON-NLS-1$
+ "}", //$NON-NLS-1$
+ "[", //$NON-NLS-1$
+ "]", //$NON-NLS-1$
+ ";", //$NON-NLS-1$
+ "?", //$NON-NLS-1$
+ ":", //$NON-NLS-1$
+ ",", //$NON-NLS-1$
+ ".", //$NON-NLS-1$
+ "=", //$NON-NLS-1$
+ "", //$NON-NLS-1$
+ "$empty", //$NON-NLS-1$
+ "Identifier", //$NON-NLS-1$
+ "abstract", //$NON-NLS-1$
+ "assert", //$NON-NLS-1$
+ "boolean", //$NON-NLS-1$
+ "break", //$NON-NLS-1$
+ "byte", //$NON-NLS-1$
+ "case", //$NON-NLS-1$
+ "catch", //$NON-NLS-1$
+ "char", //$NON-NLS-1$
+ "class", //$NON-NLS-1$
+ "continue", //$NON-NLS-1$
+ "default", //$NON-NLS-1$
+ "do", //$NON-NLS-1$
+ "double", //$NON-NLS-1$
+ "else", //$NON-NLS-1$
+ "extends", //$NON-NLS-1$
+ "false", //$NON-NLS-1$
+ "final", //$NON-NLS-1$
+ "finally", //$NON-NLS-1$
+ "float", //$NON-NLS-1$
+ "for", //$NON-NLS-1$
+ "if", //$NON-NLS-1$
+ "implements", //$NON-NLS-1$
+ "import", //$NON-NLS-1$
+ "instanceof", //$NON-NLS-1$
+ "int", //$NON-NLS-1$
+ "interface", //$NON-NLS-1$
+ "long", //$NON-NLS-1$
+ "native", //$NON-NLS-1$
+ "new", //$NON-NLS-1$
+ "null", //$NON-NLS-1$
+ "package", //$NON-NLS-1$
+ "private", //$NON-NLS-1$
+ "protected", //$NON-NLS-1$
+ "public", //$NON-NLS-1$
+ "return", //$NON-NLS-1$
+ "short", //$NON-NLS-1$
+ "static", //$NON-NLS-1$
+ "strictfp", //$NON-NLS-1$
+ "super", //$NON-NLS-1$
+ "switch", //$NON-NLS-1$
+ "synchronized", //$NON-NLS-1$
+ "this", //$NON-NLS-1$
+ "throw", //$NON-NLS-1$
+ "throws", //$NON-NLS-1$
+ "transient", //$NON-NLS-1$
+ "true", //$NON-NLS-1$
+ "try", //$NON-NLS-1$
+ "void", //$NON-NLS-1$
+ "volatile", //$NON-NLS-1$
+ "while", //$NON-NLS-1$
+ "IntegerLiteral", //$NON-NLS-1$
+ "LongLiteral", //$NON-NLS-1$
+ "FloatingPointLiteral", //$NON-NLS-1$
+ "DoubleLiteral", //$NON-NLS-1$
+ "CharacterLiteral", //$NON-NLS-1$
+ "StringLiteral", //$NON-NLS-1$
+ UNEXPECTED_EOF,
+ "Invalid Character", //$NON-NLS-1$
+ "Goal", //$NON-NLS-1$
+ "MethodBody", //$NON-NLS-1$
+ "ConstructorBody", //$NON-NLS-1$
+ "StaticInitializer", //$NON-NLS-1$
+ "Initializer", //$NON-NLS-1$
+ "Headers", //$NON-NLS-1$
+ "BlockStatements", //$NON-NLS-1$
+ "MethodPushModifiersHeader", //$NON-NLS-1$
+ "CatchHeader", //$NON-NLS-1$
+ "FieldDeclaration", //$NON-NLS-1$
+ "ImportDeclaration", //$NON-NLS-1$
+ "PackageDeclaration", //$NON-NLS-1$
+ "TypeDeclaration", //$NON-NLS-1$
+ "GenericMethodDeclaration", //$NON-NLS-1$
+ "ClassBodyDeclaration", //$NON-NLS-1$
+ "Expression", //$NON-NLS-1$
+ "Type", //$NON-NLS-1$
+ "PrimitiveType", //$NON-NLS-1$
+ "ReferenceType", //$NON-NLS-1$
+ "ClassOrInterfaceType", //$NON-NLS-1$
+ "ArrayType", //$NON-NLS-1$
+ "Name", //$NON-NLS-1$
+ "Dims", //$NON-NLS-1$
+ "ClassType", //$NON-NLS-1$
+ "SimpleName", //$NON-NLS-1$
+ "Header", //$NON-NLS-1$
+ "ClassHeader", //$NON-NLS-1$
+ "InterfaceHeader", //$NON-NLS-1$
+ "MethodHeader", //$NON-NLS-1$
+ "ConstructorHeader", //$NON-NLS-1$
+ "FormalParameter", //$NON-NLS-1$
+ "ImportDeclarations", //$NON-NLS-1$
+ "TypeDeclarations", //$NON-NLS-1$
+ "PackageDeclarationName", //$NON-NLS-1$
+ "SingleTypeImportDeclarationName", //$NON-NLS-1$
+ "TypeImportOnDemandDeclarationName", //$NON-NLS-1$
+ "Modifiers", //$NON-NLS-1$
+ "Modifier", //$NON-NLS-1$
+ "ClassBody", //$NON-NLS-1$
+ "ClassHeaderName", //$NON-NLS-1$
+ "InterfaceTypeList", //$NON-NLS-1$
+ "InterfaceType", //$NON-NLS-1$
+ "ClassBodyDeclarations", //$NON-NLS-1$
+ "Block", //$NON-NLS-1$
+ "VariableDeclarators", //$NON-NLS-1$
+ "VariableDeclarator", //$NON-NLS-1$
+ "VariableDeclaratorId", //$NON-NLS-1$
+ "VariableInitializer", //$NON-NLS-1$
+ "ArrayInitializer", //$NON-NLS-1$
+ "MethodHeaderName", //$NON-NLS-1$
+ "MethodHeaderParameters", //$NON-NLS-1$
+ "MethodPushModifiersHeaderName", //$NON-NLS-1$
+ "ClassTypeList", //$NON-NLS-1$
+ "ConstructorHeaderName", //$NON-NLS-1$
+ "FormalParameterList", //$NON-NLS-1$
+ "ClassTypeElt", //$NON-NLS-1$
+ "StaticOnly", //$NON-NLS-1$
+ "ExplicitConstructorInvocation", //$NON-NLS-1$
+ "Primary", //$NON-NLS-1$
+ "InterfaceBody", //$NON-NLS-1$
+ "InterfaceHeaderName", //$NON-NLS-1$
+ "InterfaceMemberDeclarations", //$NON-NLS-1$
+ "InterfaceMemberDeclaration", //$NON-NLS-1$
+ "VariableInitializers", //$NON-NLS-1$
+ "BlockStatement", //$NON-NLS-1$
+ "Statement", //$NON-NLS-1$
+ "LocalVariableDeclaration", //$NON-NLS-1$
+ "StatementWithoutTrailingSubstatement", //$NON-NLS-1$
+ "StatementNoShortIf", //$NON-NLS-1$
+ "StatementExpression", //$NON-NLS-1$
+ "PostIncrementExpression", //$NON-NLS-1$
+ "PostDecrementExpression", //$NON-NLS-1$
+ "MethodInvocation", //$NON-NLS-1$
+ "ClassInstanceCreationExpression", //$NON-NLS-1$
+ "SwitchBlock", //$NON-NLS-1$
+ "SwitchBlockStatements", //$NON-NLS-1$
+ "SwitchLabels", //$NON-NLS-1$
+ "SwitchBlockStatement", //$NON-NLS-1$
+ "SwitchLabel", //$NON-NLS-1$
+ "ConstantExpression", //$NON-NLS-1$
+ "StatementExpressionList", //$NON-NLS-1$
+ "OnlySynchronized", //$NON-NLS-1$
+ "Catches", //$NON-NLS-1$
+ "Finally", //$NON-NLS-1$
+ "CatchClause", //$NON-NLS-1$
+ "PushLPAREN", //$NON-NLS-1$
+ "PushRPAREN", //$NON-NLS-1$
+ "PrimaryNoNewArray", //$NON-NLS-1$
+ "ArrayCreationWithArrayInitializer", //$NON-NLS-1$
+ "ClassInstanceCreationExpressionName", //$NON-NLS-1$
+ "ArgumentList", //$NON-NLS-1$
+ "DimWithOrWithOutExprs", //$NON-NLS-1$
+ "DimWithOrWithOutExpr", //$NON-NLS-1$
+ "DimsLoop", //$NON-NLS-1$
+ "OneDimLoop", //$NON-NLS-1$
+ "PostfixExpression", //$NON-NLS-1$
+ "UnaryExpression", //$NON-NLS-1$
+ "UnaryExpressionNotPlusMinus", //$NON-NLS-1$
+ "MultiplicativeExpression", //$NON-NLS-1$
+ "AdditiveExpression", //$NON-NLS-1$
+ "ShiftExpression", //$NON-NLS-1$
+ "RelationalExpression", //$NON-NLS-1$
+ "EqualityExpression", //$NON-NLS-1$
+ "AndExpression", //$NON-NLS-1$
+ "ExclusiveOrExpression", //$NON-NLS-1$
+ "InclusiveOrExpression", //$NON-NLS-1$
+ "ConditionalAndExpression", //$NON-NLS-1$
+ "ConditionalOrExpression", //$NON-NLS-1$
+ "ConditionalExpression", //$NON-NLS-1$
+ "AssignmentExpression", //$NON-NLS-1$
+ "AssignmentOperator", //$NON-NLS-1$
+ };
public static short check_table[] = null;
public static char lhs[] = null;
@@ -406,7 +409,7 @@
pushOnExpressionStack(ai);
//positionning
ai.sourceEnd = endStatementPosition;
- int searchPosition = length == 0 ? endPosition : ai.expressions[0].sourceStart;
+ int searchPosition = length == 0 ? endPosition + 1 : ai.expressions[0].sourceStart;
try {
//does not work with comments(that contain '{') nor '{' describes as a unicode....
while (scanner.source[--searchPosition] != '{') {
@@ -535,7 +538,8 @@
TypeDeclaration type = (TypeDeclaration) referenceContext;
for (int i = 0; i < type.fields.length; i++){
FieldDeclaration field = type.fields[i];
- if (!field.isField()
+ if (field != null
+ && !field.isField()
&& field.declarationSourceStart <= scanner.initialPosition
&& scanner.initialPosition <= field.declarationSourceEnd
&& scanner.eofPosition <= field.declarationSourceEnd+1){
@@ -643,7 +647,7 @@
scanner.pushLineSeparator();
}
}
- isWhiteSpace = Character.isWhitespace(scanner.currentCharacter);
+ isWhiteSpace = CharOperation.isWhitespace(scanner.currentCharacter);
}
} while (isWhiteSpace && (scanner.currentPosition < scanner.eofPosition));
@@ -806,6 +810,9 @@
if (scanner.lineEnds[scanner.linePtr] < scanner.startPosition) {
// only record line positions we have not recorded yet
scanner.pushLineSeparator();
+ if (this.scanner.taskTags != null) {
+ this.scanner.checkTaskTag(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
+ }
}
}
break;
@@ -858,6 +865,9 @@
}
}
}
+ if (this.scanner.taskTags != null) {
+ this.scanner.checkTaskTag(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
+ }
break;
}
break;
@@ -963,39 +973,26 @@
int lastAnnotationIndex = -1;
//since jdk1.2 look only in the last java doc comment...
- found : for (lastAnnotationIndex = scanner.commentPtr; lastAnnotationIndex >= 0; lastAnnotationIndex--){
+ nextComment : for (lastAnnotationIndex = scanner.commentPtr; lastAnnotationIndex >= 0; lastAnnotationIndex--){
//look for @deprecated into the first javadoc comment preceeding the declaration
int commentSourceStart = scanner.commentStarts[lastAnnotationIndex];
// javadoc only (non javadoc comment have negative end positions.)
if (modifiersSourceStart != -1 && modifiersSourceStart < commentSourceStart) {
- continue;
+ continue nextComment;
}
if (scanner.commentStops[lastAnnotationIndex] < 0) {
- break found;
+ continue nextComment;
}
checkDeprecated = true;
int commentSourceEnd = scanner.commentStops[lastAnnotationIndex] - 1; //stop is one over
char[] comment = scanner.source;
- for (int i = commentSourceStart + 3; i < commentSourceEnd - 10; i++) {
- if ((comment[i] == '@')
- && (comment[i + 1] == 'd')
- && (comment[i + 2] == 'e')
- && (comment[i + 3] == 'p')
- && (comment[i + 4] == 'r')
- && (comment[i + 5] == 'e')
- && (comment[i + 6] == 'c')
- && (comment[i + 7] == 'a')
- && (comment[i + 8] == 't')
- && (comment[i + 9] == 'e')
- && (comment[i + 10] == 'd')) {
- // ensure the tag is properly ended: either followed by a space, a tab, line end or asterisk.
- int nextPos = i+11;
- deprecated = (comment[nextPos] == ' ') || (comment[nextPos] == '\t') || (comment[nextPos] == '\n') || (comment[nextPos] == '\r') || (comment[nextPos] == '*');
- break found;
- }
- }
- break found;
+ deprecated =
+ checkDeprecation(
+ commentSourceStart,
+ commentSourceEnd,
+ comment);
+ break nextComment;
}
if (deprecated) {
checkAndSetModifiers(AccDeprecated);
@@ -1005,6 +1002,74 @@
modifiersSourceStart = scanner.commentStarts[lastAnnotationIndex];
}
}
+protected boolean checkDeprecation(
+ int commentSourceStart,
+ int commentSourceEnd,
+ char[] comment) {
+
+ boolean deprecated = false;
+ boolean oneStar = false;
+ boolean invalidate = false;
+ for (int[] index = new int[] {commentSourceStart + 3}; index[0] < commentSourceEnd - 10;) {
+ char nextCharacter = getNextCharacter(comment, index);
+ switch(nextCharacter) {
+ case '@' :
+ if ((getNextCharacter(comment, index) == 'd')
+ && (getNextCharacter(comment, index) == 'e')
+ && (getNextCharacter(comment, index) == 'p')
+ && (getNextCharacter(comment, index) == 'r')
+ && (getNextCharacter(comment, index) == 'e')
+ && (getNextCharacter(comment, index) == 'c')
+ && (getNextCharacter(comment, index) == 'a')
+ && (getNextCharacter(comment, index) == 't')
+ && (getNextCharacter(comment, index) == 'e')
+ && (getNextCharacter(comment, index) == 'd')) {
+ // ensure the tag is properly ended: either followed by a space, a tab, line end or asterisk.
+ nextCharacter = getNextCharacter(comment, index);
+ deprecated = !invalidate && (Character.isWhitespace(nextCharacter) || nextCharacter == '*');
+ if (deprecated) {
+ return true;
+ }
+ }
+ break;
+ case '\n' :
+ case '\r' :
+ case '\f' :
+ oneStar = false;
+ invalidate = false;
+ break;
+ case '*' :
+ if (oneStar) {
+ invalidate = true;
+ }
+ oneStar = true;
+ break;
+ default :
+ if (!CharOperation.isWhitespace(nextCharacter)) {
+ invalidate = true;
+ }
+ }
+ }
+ return deprecated;
+}
+protected char getNextCharacter(char[] comment, int[] index) {
+ char nextCharacter = comment[index[0]++];
+ switch(nextCharacter) {
+ case '\\' :
+ int c1, c2, c3, c4;
+ index[0]++;
+ while (comment[index[0]] == 'u') index[0]++;
+ if (!(((c1 = Character.getNumericValue(comment[index[0]++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(comment[index[0]++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(comment[index[0]++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(comment[index[0]++])) > 15 || c4 < 0))) {
+ nextCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ break;
+ }
+ return nextCharacter;
+}
protected void classInstanceCreation(boolean alwaysQualified) {
// ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
@@ -1049,8 +1114,8 @@
astPtr--;
astLengthPtr--;
- // mark fields and initializer with local type mark if needed
- markFieldsWithLocalType(anonymousTypeDeclaration);
+ // mark initializers with local type mark if needed
+ markInitializersWithLocalType(anonymousTypeDeclaration);
}
}
protected final void concatExpressionLists() {
@@ -1123,18 +1188,38 @@
}
exp.sourceEnd = endPosition;
}
-protected void consumeArrayCreationExpression() {
- // ArrayCreationExpression ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializeropt
- // ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializeropt
+protected void consumeArrayCreationExpressionWithoutInitializer() {
+ // ArrayCreationWithoutArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
+ // ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
int length;
ArrayAllocationExpression aae = new ArrayAllocationExpression();
- if (expressionLengthStack[expressionLengthPtr] != 0) {
- expressionLengthPtr -- ;
- aae.initializer = (ArrayInitializer) expressionStack[expressionPtr--];
+ aae.type = getTypeReference(0);
+ length = (expressionLengthStack[expressionLengthPtr--]);
+ expressionPtr -= length ;
+ System.arraycopy(
+ expressionStack,
+ expressionPtr+1,
+ aae.dimensions = new Expression[length],
+ 0,
+ length);
+ aae.sourceStart = intStack[intPtr--];
+ if (aae.initializer == null) {
+ aae.sourceEnd = endPosition;
} else {
- expressionLengthPtr--;
+ aae.sourceEnd = aae.initializer.sourceEnd ;
}
+ pushOnExpressionStack(aae);
+}
+
+protected void consumeArrayCreationExpressionWithInitializer() {
+ // ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
+ // ArrayCreationWithArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializer
+
+ int length;
+ ArrayAllocationExpression aae = new ArrayAllocationExpression();
+ expressionLengthPtr -- ;
+ aae.initializer = (ArrayInitializer) expressionStack[expressionPtr--];
aae.type = getTypeReference(0);
length = (expressionLengthStack[expressionLengthPtr--]);
@@ -1307,8 +1392,8 @@
pushOnAstStack(new Case(intStack[intPtr--], expressionStack[expressionPtr--]));
}
protected void consumeCastExpression() {
- // CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression
- // CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus
+ // CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN InsideCastExpression UnaryExpression
+ // CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
//intStack : posOfLeftParen dim posOfRightParen
@@ -1322,23 +1407,21 @@
cast.sourceEnd = exp.sourceEnd;
}
protected void consumeCastExpressionLL1() {
- //CastExpression ::= '(' Expression ')' UnaryExpressionNotPlusMinus
+ //CastExpression ::= '(' Expression ')' InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
// Expression is used in order to make the grammar LL1
//optimize push/pop
- Expression castType,cast,exp;
+ Expression cast,exp;
expressionPtr--;
expressionStack[expressionPtr] =
- cast = new CastExpression( exp=expressionStack[expressionPtr+1] ,
- castType = getTypeReference(expressionStack[expressionPtr]));
+ cast = new CastExpression(
+ exp=expressionStack[expressionPtr+1] ,
+ getTypeReference(expressionStack[expressionPtr]));
expressionLengthPtr -- ;
- updateSourcePosition(castType);
- cast.sourceStart=castType.sourceStart;
+ updateSourcePosition(cast);
cast.sourceEnd=exp.sourceEnd;
- castType.sourceStart++;
- castType.sourceEnd--;
- }
+}
protected void consumeCatches() {
// Catches ::= Catches CatchClause
optimizedConcatNodeLists();
@@ -1401,8 +1484,8 @@
TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr];
- // mark fields and initializer with local type mark if needed
- markFieldsWithLocalType(typeDecl);
+ // mark initializers with local type mark if needed
+ markInitializersWithLocalType(typeDecl);
//convert constructor that do not have the type's name into methods
boolean hasConstructor = typeDecl.checkConstructors(this);
@@ -1486,7 +1569,7 @@
} else {
// Record that the block has a declaration for local types
typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult);
- markCurrentMethodWithLocalType();
+ markEnclosingMemberWithLocalType();
blockReal();
}
@@ -1620,7 +1703,17 @@
constructorCall = SuperReference.implicitSuperConstructorCall();
}
} else {
- if (!diet){
+ boolean insideFieldInitializer = false;
+ if (diet) {
+ for (int i = nestedType; i > 0; i--){
+ if (variablesCounter[i] > 0) {
+ insideFieldInitializer = true;
+ break;
+ }
+ }
+ }
+
+ if (!diet || insideFieldInitializer){
// add it only in non-diet mode, if diet_bodies, then constructor call will be added elsewhere.
constructorCall = SuperReference.implicitSuperConstructorCall();
}
@@ -1721,6 +1814,7 @@
// Diet ::= $empty
checkAnnotation();
pushOnIntStack(modifiersSourceStart); // push the start position of a javadoc comment if there is one
+ resetModifiers();
jumpOverMethodBody();
}
protected void consumeDims() {
@@ -1820,7 +1914,7 @@
new AnonymousLocalTypeDeclaration(this.compilationUnit.compilationResult);
alloc =
anonymousType.allocation = new QualifiedAllocationExpression(anonymousType);
- markCurrentMethodWithLocalType();
+ markEnclosingMemberWithLocalType();
pushOnAstStack(anonymousType);
alloc.sourceEnd = rParenPos; //the position has been stored explicitly
@@ -1846,8 +1940,7 @@
listLength = 0; // will be updated when reading super-interfaces
// recovery
if (currentElement != null){
- lastCheckPoint = anonymousType.bodyStart;
- // the recoveryTokenCheck will deal with the open brace
+ lastCheckPoint = anonymousType.bodyStart;
currentElement = currentElement.add(anonymousType, 0);
currentToken = 0; // opening brace already taken into account
lastIgnoredToken = -1;
@@ -1975,10 +2068,17 @@
// source end position of the initialization expression
variableDecl.declarationSourceEnd = variableDecl.initialization.sourceEnd;
variableDecl.declarationEnd = variableDecl.initialization.sourceEnd;
+
+ this.recoveryExitFromVariable();
}
protected void consumeExitVariableWithoutInitialization() {
// ExitVariableWithoutInitialization ::= $empty
// do nothing by default
+
+ AbstractVariableDeclaration variableDecl = (AbstractVariableDeclaration) astStack[astPtr];
+ variableDecl.declarationSourceEnd = variableDecl.declarationEnd;
+
+ this.recoveryExitFromVariable();
}
protected void consumeExplicitConstructorInvocation(int flag, int recFlag) {
@@ -2089,7 +2189,9 @@
if (currentElement != null) {
lastCheckPoint = endPos + 1;
if (currentElement.parent != null && currentElement instanceof RecoveredField){
- currentElement = currentElement.parent;
+ if (!(currentElement instanceof RecoveredInitializer)) {
+ currentElement = currentElement.parent;
+ }
}
restartRecovery = true;
}
@@ -2160,6 +2262,13 @@
length);
}
}
+protected void consumeInsideCastExpression() {
+ // InsideCastExpression ::= $empty
+}
+protected void consumeInsideCastExpressionLL1() {
+ // InsideCastExpressionLL1 ::= $empty
+}
+
protected void consumeInstanceOfExpression(int op) {
// RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType
//optimize the push/pop
@@ -2189,8 +2298,8 @@
TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr];
- // mark fields and initializer with local type mark if needed
- markFieldsWithLocalType(typeDecl);
+ // mark initializers with local type mark if needed
+ markInitializersWithLocalType(typeDecl);
//convert constructor that do not have the type's name into methods
typeDecl.checkConstructors(this);
@@ -2247,7 +2356,7 @@
} else {
// Record that the block has a declaration for local types
typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult);
- markCurrentMethodWithLocalType();
+ markEnclosingMemberWithLocalType();
blockReal();
}
@@ -2298,11 +2407,6 @@
// InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType
optimizedConcatNodeLists();
}
-protected void consumeLeftHandSide() {
- // LeftHandSide ::= Name
-
- pushOnExpressionStack(getUnspecifiedReferenceOptimized());
-}
protected void consumeLeftParen() {
// PushLPAREN ::= '('
pushOnIntStack(lParenPos);
@@ -2526,7 +2630,7 @@
md.thrownExceptions = new TypeReference[length],
0,
length);
- md.sourceEnd = md.thrownExceptions[length-1].sourceEnd;
+ md.sourceEnd = md.thrownExceptions[length-1].sourceEnd;
md.bodyStart = md.thrownExceptions[length-1].sourceEnd + 1;
listLength = 0; // reset listLength after having read all thrown exceptions
// recovery
@@ -2545,7 +2649,7 @@
(int) ((m.nameSourcePosition = identifierPositionStack[identifierPtr]) >>> 32);
m.selector = identifierStack[identifierPtr--];
if (identifierLengthStack[identifierLengthPtr] == 1) {
- m.receiver = ThisReference.ThisImplicit;
+ m.receiver = ThisReference.implicitThis();
identifierLengthPtr--;
} else {
identifierLengthStack[identifierLengthPtr]--;
@@ -2718,7 +2822,11 @@
}
protected void consumePrimaryNoNewArray() {
// PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN
- updateSourcePosition(expressionStack[expressionPtr]);
+ final Expression parenthesizedExpression = expressionStack[expressionPtr];
+ updateSourcePosition(parenthesizedExpression);
+ int numberOfParenthesis = (parenthesizedExpression.bits & AstNode.ParenthesizedMASK) >> AstNode.ParenthesizedSHIFT;
+ parenthesizedExpression.bits &= ~AstNode.ParenthesizedMASK;
+ parenthesizedExpression.bits |= (numberOfParenthesis + 1) << AstNode.ParenthesizedSHIFT;
}
protected void consumePrimaryNoNewArrayArrayType() {
// PrimaryNoNewArray ::= ArrayType '.' 'class'
@@ -2800,897 +2908,907 @@
// PushRPAREN ::= ')'
pushOnIntStack(rParenPos);
}
- // This method is part of an automatic generation : do NOT edit-modify
- // This method is part of an automatic generation : do NOT edit-modify
- protected void consumeRule(int act) {
- switch ( act ) {
- case 29 : // System.out.println("Type ::= PrimitiveType");
- consumePrimitiveType();
- break ;
-
- case 43 : // System.out.println("ReferenceType ::= ClassOrInterfaceType");
- consumeReferenceType();
- break ;
-
- case 52 : // System.out.println("QualifiedName ::= Name DOT SimpleName");
- consumeQualifiedName();
- break ;
-
- case 53 : // System.out.println("CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt");
- consumeCompilationUnit();
- break ;
-
- case 54 : // System.out.println("EnterCompilationUnit ::=");
- consumeEnterCompilationUnit();
- break ;
-
- case 66 : // System.out.println("CatchHeader ::= catch LPAREN FormalParameter RPAREN LBRACE");
- consumeCatchHeader();
- break ;
-
- case 68 : // System.out.println("ImportDeclarations ::= ImportDeclarations ImportDeclaration");
- consumeImportDeclarations();
- break ;
-
- case 70 : // System.out.println("TypeDeclarations ::= TypeDeclarations TypeDeclaration");
- consumeTypeDeclarations();
- break ;
-
- case 71 : // System.out.println("PackageDeclaration ::= PackageDeclarationName SEMICOLON");
- consumePackageDeclaration();
- break ;
-
- case 72 : // System.out.println("PackageDeclarationName ::= package Name");
- consumePackageDeclarationName();
- break ;
-
- case 75 : // System.out.println("SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName SEMICOLON");
- consumeSingleTypeImportDeclaration();
- break ;
-
- case 76 : // System.out.println("SingleTypeImportDeclarationName ::= import Name");
- consumeSingleTypeImportDeclarationName();
- break ;
-
- case 77 : // System.out.println("TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName SEMICOLON");
- consumeTypeImportOnDemandDeclaration();
- break ;
-
- case 78 : // System.out.println("TypeImportOnDemandDeclarationName ::= import Name DOT MULTIPLY");
- consumeTypeImportOnDemandDeclarationName();
- break ;
-
- case 81 : // System.out.println("TypeDeclaration ::= SEMICOLON");
- consumeEmptyTypeDeclaration();
- break ;
-
- case 95 : // System.out.println("ClassDeclaration ::= ClassHeader ClassBody");
- consumeClassDeclaration();
- break ;
-
- case 96 : // System.out.println("ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt");
- consumeClassHeader();
- break ;
-
- case 97 : // System.out.println("ClassHeaderName ::= Modifiersopt class Identifier");
- consumeClassHeaderName();
- break ;
-
- case 98 : // System.out.println("ClassHeaderExtends ::= extends ClassType");
- consumeClassHeaderExtends();
- break ;
-
- case 99 : // System.out.println("ClassHeaderImplements ::= implements InterfaceTypeList");
- consumeClassHeaderImplements();
- break ;
-
- case 101 : // System.out.println("InterfaceTypeList ::= InterfaceTypeList COMMA InterfaceType");
- consumeInterfaceTypeList();
- break ;
-
- case 102 : // System.out.println("InterfaceType ::= ClassOrInterfaceType");
- consumeInterfaceType();
- break ;
-
- case 105 : // System.out.println("ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration");
- consumeClassBodyDeclarations();
- break ;
-
- case 109 : // System.out.println("ClassBodyDeclaration ::= Diet NestedMethod Block");
- consumeClassBodyDeclaration();
- break ;
-
- case 110 : // System.out.println("Diet ::=");
- consumeDiet();
- break ;
-
- case 111 : // System.out.println("Initializer ::= Diet NestedMethod Block");
- consumeClassBodyDeclaration();
- break ;
-
- case 118 : // System.out.println("ClassMemberDeclaration ::= SEMICOLON");
- consumeEmptyClassMemberDeclaration();
- break ;
-
- case 119 : // System.out.println("FieldDeclaration ::= Modifiersopt Type VariableDeclarators SEMICOLON");
- consumeFieldDeclaration();
- break ;
-
- case 121 : // System.out.println("VariableDeclarators ::= VariableDeclarators COMMA VariableDeclarator");
- consumeVariableDeclarators();
- break ;
-
- case 124 : // System.out.println("EnterVariable ::=");
- consumeEnterVariable();
- break ;
-
- case 125 : // System.out.println("ExitVariableWithInitialization ::=");
- consumeExitVariableWithInitialization();
- break ;
-
- case 126 : // System.out.println("ExitVariableWithoutInitialization ::=");
- consumeExitVariableWithoutInitialization();
- break ;
-
- case 127 : // System.out.println("ForceNoDiet ::=");
- consumeForceNoDiet();
- break ;
-
- case 128 : // System.out.println("RestoreDiet ::=");
- consumeRestoreDiet();
- break ;
-
- case 133 : // System.out.println("MethodDeclaration ::= MethodHeader MethodBody");
- // set to true to consume a method with a body
- consumeMethodDeclaration(true);
- break ;
-
- case 134 : // System.out.println("AbstractMethodDeclaration ::= MethodHeader SEMICOLON");
- // set to false to consume a method without body
- consumeMethodDeclaration(false);
- break ;
-
- case 135 : // System.out.println("MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims");
- consumeMethodHeader();
- break ;
-
- case 136 : // System.out.println("MethodPushModifiersHeader ::= MethodPushModifiersHeaderName MethodHeaderParameters");
- consumeMethodHeader();
- break ;
-
- case 137 : // System.out.println("MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers Identifier LPAREN");
- consumeMethodPushModifiersHeaderName();
- break ;
-
- case 138 : // System.out.println("MethodPushModifiersHeaderName ::= Type PushModifiers Identifier LPAREN");
- consumeMethodPushModifiersHeaderName();
- break ;
-
- case 139 : // System.out.println("MethodHeaderName ::= Modifiersopt Type Identifier LPAREN");
- consumeMethodHeaderName();
- break ;
-
- case 140 : // System.out.println("MethodHeaderParameters ::= FormalParameterListopt RPAREN");
- consumeMethodHeaderParameters();
- break ;
-
- case 141 : // System.out.println("MethodHeaderExtendedDims ::= Dimsopt");
- consumeMethodHeaderExtendedDims();
- break ;
-
- case 142 : // System.out.println("MethodHeaderThrowsClause ::= throws ClassTypeList");
- consumeMethodHeaderThrowsClause();
- break ;
-
- case 143 : // System.out.println("ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters...");
- consumeConstructorHeader();
- break ;
-
- case 144 : // System.out.println("ConstructorHeaderName ::= Modifiersopt Identifier LPAREN");
- consumeConstructorHeaderName();
- break ;
-
- case 146 : // System.out.println("FormalParameterList ::= FormalParameterList COMMA FormalParameter");
- consumeFormalParameterList();
- break ;
-
- case 147 : // System.out.println("FormalParameter ::= Modifiersopt Type VariableDeclaratorId");
- // the boolean is used to know if the modifiers should be reset
- consumeFormalParameter();
- break ;
-
- case 149 : // System.out.println("ClassTypeList ::= ClassTypeList COMMA ClassTypeElt");
- consumeClassTypeList();
- break ;
-
- case 150 : // System.out.println("ClassTypeElt ::= ClassType");
- consumeClassTypeElt();
- break ;
-
- case 151 : // System.out.println("MethodBody ::= NestedMethod LBRACE BlockStatementsopt RBRACE");
- consumeMethodBody();
- break ;
-
- case 152 : // System.out.println("NestedMethod ::=");
- consumeNestedMethod();
- break ;
-
- case 153 : // System.out.println("StaticInitializer ::= StaticOnly Block");
- consumeStaticInitializer();
- break ;
-
- case 154 : // System.out.println("StaticOnly ::= static");
- consumeStaticOnly();
- break ;
-
- case 155 : // System.out.println("ConstructorDeclaration ::= ConstructorHeader ConstructorBody");
- consumeConstructorDeclaration() ;
- break ;
-
- case 156 : // System.out.println("ConstructorDeclaration ::= ConstructorHeader SEMICOLON");
- consumeInvalidConstructorDeclaration() ;
- break ;
-
- case 157 : // System.out.println("ConstructorBody ::= NestedMethod LBRACE ConstructorBlockStatementsopt RBRACE");
- consumeConstructorBody();
- break ;
-
- case 160 : // System.out.println("ConstructorBlockStatementsopt ::= ExplicitConstructorInvocation BlockStatements");
- consumeConstructorBlockStatements();
- break ;
-
- case 161 : // System.out.println("ExplicitConstructorInvocation ::= this LPAREN ArgumentListopt RPAREN SEMICOLON");
- consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.This);
- break ;
-
- case 162 : // System.out.println("ExplicitConstructorInvocation ::= super LPAREN ArgumentListopt RPAREN SEMICOLON");
- consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.Super);
- break ;
-
- case 163 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT super LPAREN ArgumentListopt RPAREN");
- consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.Super);
- break ;
-
- case 164 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT super LPAREN ArgumentListopt RPAREN...");
- consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.Super);
- break ;
-
- case 165 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT this LPAREN ArgumentListopt RPAREN...");
- consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.This);
- break ;
-
- case 166 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT this LPAREN ArgumentListopt RPAREN...");
- consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.This);
- break ;
-
- case 167 : // System.out.println("InterfaceDeclaration ::= InterfaceHeader InterfaceBody");
- consumeInterfaceDeclaration();
- break ;
-
- case 168 : // System.out.println("InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt");
- consumeInterfaceHeader();
- break ;
-
- case 169 : // System.out.println("InterfaceHeaderName ::= Modifiersopt interface Identifier");
- consumeInterfaceHeaderName();
- break ;
-
- case 171 : // System.out.println("InterfaceHeaderExtends ::= extends InterfaceTypeList");
- consumeInterfaceHeaderExtends();
- break ;
-
- case 174 : // System.out.println("InterfaceMemberDeclarations ::= InterfaceMemberDeclarations...");
- consumeInterfaceMemberDeclarations();
- break ;
-
- case 175 : // System.out.println("InterfaceMemberDeclaration ::= SEMICOLON");
- consumeEmptyInterfaceMemberDeclaration();
- break ;
-
- case 178 : // System.out.println("InterfaceMemberDeclaration ::= InvalidMethodDeclaration");
- ignoreMethodBody();
- break ;
-
- case 179 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody");
- ignoreInvalidConstructorDeclaration(true);
- break ;
-
- case 180 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader SEMICOLON");
- ignoreInvalidConstructorDeclaration(false);
- break ;
-
- case 186 : // System.out.println("ArrayInitializer ::= LBRACE ,opt RBRACE");
- consumeEmptyArrayInitializer();
- break ;
-
- case 187 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers RBRACE");
- consumeArrayInitializer();
- break ;
-
- case 188 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers COMMA RBRACE");
- consumeArrayInitializer();
- break ;
-
- case 190 : // System.out.println("VariableInitializers ::= VariableInitializers COMMA VariableInitializer");
- consumeVariableInitializers();
- break ;
-
- case 191 : // System.out.println("Block ::= OpenBlock LBRACE BlockStatementsopt RBRACE");
- consumeBlock();
- break ;
-
- case 192 : // System.out.println("OpenBlock ::=");
- consumeOpenBlock() ;
- break ;
-
- case 194 : // System.out.println("BlockStatements ::= BlockStatements BlockStatement");
- consumeBlockStatements() ;
- break ;
-
- case 198 : // System.out.println("BlockStatement ::= InvalidInterfaceDeclaration");
- ignoreInterfaceDeclaration();
- break ;
-
- case 199 : // System.out.println("LocalVariableDeclarationStatement ::= LocalVariableDeclaration SEMICOLON");
- consumeLocalVariableDeclarationStatement();
- break ;
-
- case 200 : // System.out.println("LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators");
- consumeLocalVariableDeclaration();
- break ;
-
- case 201 : // System.out.println("LocalVariableDeclaration ::= Modifiers Type PushModifiers VariableDeclarators");
- consumeLocalVariableDeclaration();
- break ;
-
- case 202 : // System.out.println("PushModifiers ::=");
- consumePushModifiers();
- break ;
-
- case 226 : // System.out.println("EmptyStatement ::= SEMICOLON");
- consumeEmptyStatement();
- break ;
-
- case 227 : // System.out.println("LabeledStatement ::= Identifier COLON Statement");
- consumeStatementLabel() ;
- break ;
-
- case 228 : // System.out.println("LabeledStatementNoShortIf ::= Identifier COLON StatementNoShortIf");
- consumeStatementLabel() ;
- break ;
-
- case 229 : // System.out.println("ExpressionStatement ::= StatementExpression SEMICOLON");
- consumeExpressionStatement();
- break ;
-
- case 237 : // System.out.println("IfThenStatement ::= if LPAREN Expression RPAREN Statement");
- consumeStatementIfNoElse();
- break ;
-
- case 238 : // System.out.println("IfThenElseStatement ::= if LPAREN Expression RPAREN StatementNoShortIf else...");
- consumeStatementIfWithElse();
- break ;
-
- case 239 : // System.out.println("IfThenElseStatementNoShortIf ::= if LPAREN Expression RPAREN StatementNoShortIf...");
- consumeStatementIfWithElse();
- break ;
-
- case 240 : // System.out.println("SwitchStatement ::= switch OpenBlock LPAREN Expression RPAREN SwitchBlock");
- consumeStatementSwitch() ;
- break ;
-
- case 241 : // System.out.println("SwitchBlock ::= LBRACE RBRACE");
- consumeEmptySwitchBlock() ;
- break ;
-
- case 244 : // System.out.println("SwitchBlock ::= LBRACE SwitchBlockStatements SwitchLabels RBRACE");
- consumeSwitchBlock() ;
- break ;
-
- case 246 : // System.out.println("SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement");
- consumeSwitchBlockStatements() ;
- break ;
-
- case 247 : // System.out.println("SwitchBlockStatement ::= SwitchLabels BlockStatements");
- consumeSwitchBlockStatement() ;
- break ;
-
- case 249 : // System.out.println("SwitchLabels ::= SwitchLabels SwitchLabel");
- consumeSwitchLabels() ;
- break ;
-
- case 250 : // System.out.println("SwitchLabel ::= case ConstantExpression COLON");
- consumeCaseLabel();
- break ;
-
- case 251 : // System.out.println("SwitchLabel ::= default COLON");
- consumeDefaultLabel();
- break ;
-
- case 252 : // System.out.println("WhileStatement ::= while LPAREN Expression RPAREN Statement");
- consumeStatementWhile() ;
- break ;
-
- case 253 : // System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression RPAREN StatementNoShortIf");
- consumeStatementWhile() ;
- break ;
-
- case 254 : // System.out.println("DoStatement ::= do Statement while LPAREN Expression RPAREN SEMICOLON");
- consumeStatementDo() ;
- break ;
-
- case 255 : // System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON...");
- consumeStatementFor() ;
- break ;
-
- case 256 : // System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON");
- consumeStatementFor() ;
- break ;
-
- case 257 : // System.out.println("ForInit ::= StatementExpressionList");
- consumeForInit() ;
- break ;
-
- case 261 : // System.out.println("StatementExpressionList ::= StatementExpressionList COMMA StatementExpression");
- consumeStatementExpressionList() ;
- break ;
-
- case 262 : // System.out.println("AssertStatement ::= assert Expression SEMICOLON");
- consumeSimpleAssertStatement() ;
- break ;
-
- case 263 : // System.out.println("AssertStatement ::= assert Expression COLON Expression SEMICOLON");
- consumeAssertStatement() ;
- break ;
-
- case 264 : // System.out.println("BreakStatement ::= break SEMICOLON");
- consumeStatementBreak() ;
- break ;
-
- case 265 : // System.out.println("BreakStatement ::= break Identifier SEMICOLON");
- consumeStatementBreakWithLabel() ;
- break ;
-
- case 266 : // System.out.println("ContinueStatement ::= continue SEMICOLON");
- consumeStatementContinue() ;
- break ;
-
- case 267 : // System.out.println("ContinueStatement ::= continue Identifier SEMICOLON");
- consumeStatementContinueWithLabel() ;
- break ;
-
- case 268 : // System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON");
- consumeStatementReturn() ;
- break ;
-
- case 269 : // System.out.println("ThrowStatement ::= throw Expression SEMICOLON");
- consumeStatementThrow();
-
- break ;
-
- case 270 : // System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN Expression RPAREN Block");
- consumeStatementSynchronized();
- break ;
-
- case 271 : // System.out.println("OnlySynchronized ::= synchronized");
- consumeOnlySynchronized();
- break ;
-
- case 272 : // System.out.println("TryStatement ::= try Block Catches");
- consumeStatementTry(false);
- break ;
-
- case 273 : // System.out.println("TryStatement ::= try Block Catchesopt Finally");
- consumeStatementTry(true);
- break ;
-
- case 275 : // System.out.println("Catches ::= Catches CatchClause");
- consumeCatches();
- break ;
-
- case 276 : // System.out.println("CatchClause ::= catch LPAREN FormalParameter RPAREN Block");
- consumeStatementCatch() ;
- break ;
-
- case 278 : // System.out.println("PushLPAREN ::= LPAREN");
- consumeLeftParen();
- break ;
-
- case 279 : // System.out.println("PushRPAREN ::= RPAREN");
- consumeRightParen();
- break ;
-
- case 283 : // System.out.println("PrimaryNoNewArray ::= this");
- consumePrimaryNoNewArrayThis();
- break ;
-
- case 284 : // System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN");
- consumePrimaryNoNewArray();
- break ;
-
- case 287 : // System.out.println("PrimaryNoNewArray ::= Name DOT this");
- consumePrimaryNoNewArrayNameThis();
- break ;
-
- case 288 : // System.out.println("PrimaryNoNewArray ::= Name DOT super");
- consumePrimaryNoNewArrayNameSuper();
- break ;
-
- case 289 : // System.out.println("PrimaryNoNewArray ::= Name DOT class");
- consumePrimaryNoNewArrayName();
- break ;
-
- case 290 : // System.out.println("PrimaryNoNewArray ::= ArrayType DOT class");
- consumePrimaryNoNewArrayArrayType();
- break ;
-
- case 291 : // System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class");
- consumePrimaryNoNewArrayPrimitiveType();
- break ;
-
- case 294 : // System.out.println("AllocationHeader ::= new ClassType LPAREN ArgumentListopt RPAREN");
- consumeAllocationHeader();
- break ;
-
- case 295 : // System.out.println("ClassInstanceCreationExpression ::= new ClassType LPAREN ArgumentListopt RPAREN...");
- consumeClassInstanceCreationExpression();
- break ;
-
- case 296 : // System.out.println("ClassInstanceCreationExpression ::= Primary DOT new SimpleName LPAREN...");
- consumeClassInstanceCreationExpressionQualified() ;
- break ;
-
- case 297 : // System.out.println("ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName new...");
- consumeClassInstanceCreationExpressionQualified() ;
- break ;
-
- case 298 : // System.out.println("ClassInstanceCreationExpressionName ::= Name DOT");
- consumeClassInstanceCreationExpressionName() ;
- break ;
-
- case 299 : // System.out.println("ClassBodyopt ::=");
- consumeClassBodyopt();
- break ;
-
- case 301 : // System.out.println("EnterAnonymousClassBody ::=");
- consumeEnterAnonymousClassBody();
- break ;
-
- case 303 : // System.out.println("ArgumentList ::= ArgumentList COMMA Expression");
- consumeArgumentList();
- break ;
-
- case 304 : // System.out.println("ArrayCreationExpression ::= new PrimitiveType DimWithOrWithOutExprs...");
- consumeArrayCreationExpression();
- break ;
-
- case 305 : // System.out.println("ArrayCreationExpression ::= new ClassOrInterfaceType DimWithOrWithOutExprs...");
- consumeArrayCreationExpression();
- break ;
-
- case 307 : // System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr");
- consumeDimWithOrWithOutExprs();
- break ;
-
- case 309 : // System.out.println("DimWithOrWithOutExpr ::= LBRACKET RBRACKET");
- consumeDimWithOrWithOutExpr();
- break ;
-
- case 310 : // System.out.println("Dims ::= DimsLoop");
- consumeDims();
- break ;
-
- case 313 : // System.out.println("OneDimLoop ::= LBRACKET RBRACKET");
- consumeOneDimLoop();
- break ;
-
- case 314 : // System.out.println("FieldAccess ::= Primary DOT Identifier");
- consumeFieldAccess(false);
- break ;
-
- case 315 : // System.out.println("FieldAccess ::= super DOT Identifier");
- consumeFieldAccess(true);
- break ;
-
- case 316 : // System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN");
- consumeMethodInvocationName();
- break ;
-
- case 317 : // System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN ArgumentListopt RPAREN");
- consumeMethodInvocationPrimary();
- break ;
-
- case 318 : // System.out.println("MethodInvocation ::= super DOT Identifier LPAREN ArgumentListopt RPAREN");
- consumeMethodInvocationSuper();
- break ;
-
- case 319 : // System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET");
- consumeArrayAccess(true);
- break ;
-
- case 320 : // System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression RBRACKET");
- consumeArrayAccess(false);
- break ;
-
- case 322 : // System.out.println("PostfixExpression ::= Name");
- consumePostfixExpression();
- break ;
-
- case 325 : // System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS");
- consumeUnaryExpression(OperatorExpression.PLUS,true);
- break ;
-
- case 326 : // System.out.println("PostDecrementExpression ::= PostfixExpression MINUS_MINUS");
- consumeUnaryExpression(OperatorExpression.MINUS,true);
- break ;
-
- case 327 : // System.out.println("PushPosition ::=");
- consumePushPosition();
- break ;
-
- case 330 : // System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.PLUS);
- break ;
-
- case 331 : // System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.MINUS);
- break ;
-
- case 333 : // System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.PLUS,false);
- break ;
-
- case 334 : // System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.MINUS,false);
- break ;
-
- case 336 : // System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.TWIDDLE);
- break ;
-
- case 337 : // System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition UnaryExpression");
- consumeUnaryExpression(OperatorExpression.NOT);
- break ;
-
- case 339 : // System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression");
- consumeCastExpression();
- break ;
-
- case 340 : // System.out.println("CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus");
- consumeCastExpression();
- break ;
-
- case 341 : // System.out.println("CastExpression ::= PushLPAREN Expression PushRPAREN UnaryExpressionNotPlusMinus");
- consumeCastExpressionLL1();
- break ;
-
- case 343 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression MULTIPLY UnaryExpression");
- consumeBinaryExpression(OperatorExpression.MULTIPLY);
- break ;
-
- case 344 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression DIVIDE UnaryExpression");
- consumeBinaryExpression(OperatorExpression.DIVIDE);
- break ;
-
- case 345 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression REMAINDER UnaryExpression");
- consumeBinaryExpression(OperatorExpression.REMAINDER);
- break ;
-
- case 347 : // System.out.println("AdditiveExpression ::= AdditiveExpression PLUS MultiplicativeExpression");
- consumeBinaryExpression(OperatorExpression.PLUS);
- break ;
-
- case 348 : // System.out.println("AdditiveExpression ::= AdditiveExpression MINUS MultiplicativeExpression");
- consumeBinaryExpression(OperatorExpression.MINUS);
- break ;
-
- case 350 : // System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT AdditiveExpression");
- consumeBinaryExpression(OperatorExpression.LEFT_SHIFT);
- break ;
-
- case 351 : // System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT AdditiveExpression");
- consumeBinaryExpression(OperatorExpression.RIGHT_SHIFT);
- break ;
-
- case 352 : // System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT AdditiveExpression");
- consumeBinaryExpression(OperatorExpression.UNSIGNED_RIGHT_SHIFT);
- break ;
-
- case 354 : // System.out.println("RelationalExpression ::= RelationalExpression LESS ShiftExpression");
- consumeBinaryExpression(OperatorExpression.LESS);
- break ;
-
- case 355 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER ShiftExpression");
- consumeBinaryExpression(OperatorExpression.GREATER);
- break ;
-
- case 356 : // System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL ShiftExpression");
- consumeBinaryExpression(OperatorExpression.LESS_EQUAL);
- break ;
-
- case 357 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER_EQUAL ShiftExpression");
- consumeBinaryExpression(OperatorExpression.GREATER_EQUAL);
- break ;
-
- case 358 : // System.out.println("RelationalExpression ::= RelationalExpression instanceof ReferenceType");
- consumeInstanceOfExpression(OperatorExpression.INSTANCEOF);
- break ;
-
- case 360 : // System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL RelationalExpression");
- consumeEqualityExpression(OperatorExpression.EQUAL_EQUAL);
- break ;
-
- case 361 : // System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL RelationalExpression");
- consumeEqualityExpression(OperatorExpression.NOT_EQUAL);
- break ;
-
- case 363 : // System.out.println("AndExpression ::= AndExpression AND EqualityExpression");
- consumeBinaryExpression(OperatorExpression.AND);
- break ;
-
- case 365 : // System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR AndExpression");
- consumeBinaryExpression(OperatorExpression.XOR);
- break ;
-
- case 367 : // System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR ExclusiveOrExpression");
- consumeBinaryExpression(OperatorExpression.OR);
- break ;
-
- case 369 : // System.out.println("ConditionalAndExpression ::= ConditionalAndExpression AND_AND InclusiveOrExpression");
- consumeBinaryExpression(OperatorExpression.AND_AND);
- break ;
-
- case 371 : // System.out.println("ConditionalOrExpression ::= ConditionalOrExpression OR_OR ConditionalAndExpression");
- consumeBinaryExpression(OperatorExpression.OR_OR);
- break ;
-
- case 373 : // System.out.println("ConditionalExpression ::= ConditionalOrExpression QUESTION Expression COLON...");
- consumeConditionalExpression(OperatorExpression.QUESTIONCOLON) ;
- break ;
-
- case 376 : // System.out.println("Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression");
- consumeAssignment();
- break ;
-
- case 378 : // System.out.println("Assignment ::= InvalidArrayInitializerAssignement");
- ignoreExpressionAssignment();
- break ;
-
- case 379 : // System.out.println("LeftHandSide ::= Name");
- consumeLeftHandSide();
- break ;
-
- case 382 : // System.out.println("AssignmentOperator ::= EQUAL");
- consumeAssignmentOperator(EQUAL);
- break ;
-
- case 383 : // System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL");
- consumeAssignmentOperator(MULTIPLY);
- break ;
-
- case 384 : // System.out.println("AssignmentOperator ::= DIVIDE_EQUAL");
- consumeAssignmentOperator(DIVIDE);
- break ;
-
- case 385 : // System.out.println("AssignmentOperator ::= REMAINDER_EQUAL");
- consumeAssignmentOperator(REMAINDER);
- break ;
-
- case 386 : // System.out.println("AssignmentOperator ::= PLUS_EQUAL");
- consumeAssignmentOperator(PLUS);
- break ;
-
- case 387 : // System.out.println("AssignmentOperator ::= MINUS_EQUAL");
- consumeAssignmentOperator(MINUS);
- break ;
-
- case 388 : // System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL");
- consumeAssignmentOperator(LEFT_SHIFT);
- break ;
-
- case 389 : // System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL");
- consumeAssignmentOperator(RIGHT_SHIFT);
- break ;
-
- case 390 : // System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL");
- consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT);
- break ;
-
- case 391 : // System.out.println("AssignmentOperator ::= AND_EQUAL");
- consumeAssignmentOperator(AND);
- break ;
-
- case 392 : // System.out.println("AssignmentOperator ::= XOR_EQUAL");
- consumeAssignmentOperator(XOR);
- break ;
-
- case 393 : // System.out.println("AssignmentOperator ::= OR_EQUAL");
- consumeAssignmentOperator(OR);
- break ;
-
- case 400 : // System.out.println("Expressionopt ::=");
- consumeEmptyExpression();
- break ;
-
- case 404 : // System.out.println("ImportDeclarationsopt ::=");
- consumeEmptyImportDeclarationsopt();
- break ;
-
- case 405 : // System.out.println("ImportDeclarationsopt ::= ImportDeclarations");
- consumeImportDeclarationsopt();
- break ;
-
- case 406 : // System.out.println("TypeDeclarationsopt ::=");
- consumeEmptyTypeDeclarationsopt();
- break ;
-
- case 407 : // System.out.println("TypeDeclarationsopt ::= TypeDeclarations");
- consumeTypeDeclarationsopt();
- break ;
-
- case 408 : // System.out.println("ClassBodyDeclarationsopt ::=");
- consumeEmptyClassBodyDeclarationsopt();
- break ;
-
- case 409 : // System.out.println("ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations");
- consumeClassBodyDeclarationsopt();
- break ;
-
- case 410 : // System.out.println("Modifiersopt ::=");
- consumeDefaultModifiers();
- break ;
-
- case 411 : // System.out.println("Modifiersopt ::= Modifiers");
- consumeModifiers();
- break ;
-
- case 412 : // System.out.println("BlockStatementsopt ::=");
- consumeEmptyBlockStatementsopt();
- break ;
-
- case 414 : // System.out.println("Dimsopt ::=");
- consumeEmptyDimsopt();
- break ;
-
- case 416 : // System.out.println("ArgumentListopt ::=");
- consumeEmptyArgumentListopt();
- break ;
-
- case 420 : // System.out.println("FormalParameterListopt ::=");
- consumeFormalParameterListopt();
- break ;
-
- case 424 : // System.out.println("InterfaceMemberDeclarationsopt ::=");
- consumeEmptyInterfaceMemberDeclarationsopt();
- break ;
-
- case 425 : // System.out.println("InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations");
- consumeInterfaceMemberDeclarationsopt();
- break ;
-
- case 426 : // System.out.println("NestedType ::=");
- consumeNestedType();
- break ;
-
- case 427 : // System.out.println("ForInitopt ::=");
- consumeEmptyForInitopt();
- break ;
-
- case 429 : // System.out.println("ForUpdateopt ::=");
- consumeEmptyForUpdateopt();
- break ;
-
- case 433 : // System.out.println("Catchesopt ::=");
- consumeEmptyCatchesopt();
- break ;
-
- case 435 : // System.out.println("ArrayInitializeropt ::=");
- consumeEmptyArrayInitializeropt();
- break ;
-
- }
- }
+ // This method is part of an automatic generation : do NOT edit-modify
+protected void consumeRule(int act) {
+ switch ( act ) {
+ case 29 : // System.out.println("Type ::= PrimitiveType");
+ consumePrimitiveType();
+ break ;
+
+ case 43 : // System.out.println("ReferenceType ::= ClassOrInterfaceType");
+ consumeReferenceType();
+ break ;
+
+ case 52 : // System.out.println("QualifiedName ::= Name DOT SimpleName");
+ consumeQualifiedName();
+ break ;
+
+ case 53 : // System.out.println("CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt");
+ consumeCompilationUnit();
+ break ;
+
+ case 54 : // System.out.println("EnterCompilationUnit ::=");
+ consumeEnterCompilationUnit();
+ break ;
+
+ case 66 : // System.out.println("CatchHeader ::= catch LPAREN FormalParameter RPAREN LBRACE");
+ consumeCatchHeader();
+ break ;
+
+ case 68 : // System.out.println("ImportDeclarations ::= ImportDeclarations ImportDeclaration");
+ consumeImportDeclarations();
+ break ;
+
+ case 70 : // System.out.println("TypeDeclarations ::= TypeDeclarations TypeDeclaration");
+ consumeTypeDeclarations();
+ break ;
+
+ case 71 : // System.out.println("PackageDeclaration ::= PackageDeclarationName SEMICOLON");
+ consumePackageDeclaration();
+ break ;
+
+ case 72 : // System.out.println("PackageDeclarationName ::= package Name");
+ consumePackageDeclarationName();
+ break ;
+
+ case 75 : // System.out.println("SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName SEMICOLON");
+ consumeSingleTypeImportDeclaration();
+ break ;
+
+ case 76 : // System.out.println("SingleTypeImportDeclarationName ::= import Name");
+ consumeSingleTypeImportDeclarationName();
+ break ;
+
+ case 77 : // System.out.println("TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName SEMICOLON");
+ consumeTypeImportOnDemandDeclaration();
+ break ;
+
+ case 78 : // System.out.println("TypeImportOnDemandDeclarationName ::= import Name DOT MULTIPLY");
+ consumeTypeImportOnDemandDeclarationName();
+ break ;
+
+ case 81 : // System.out.println("TypeDeclaration ::= SEMICOLON");
+ consumeEmptyTypeDeclaration();
+ break ;
+
+ case 95 : // System.out.println("ClassDeclaration ::= ClassHeader ClassBody");
+ consumeClassDeclaration();
+ break ;
+
+ case 96 : // System.out.println("ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt");
+ consumeClassHeader();
+ break ;
+
+ case 97 : // System.out.println("ClassHeaderName ::= Modifiersopt class Identifier");
+ consumeClassHeaderName();
+ break ;
+
+ case 98 : // System.out.println("ClassHeaderExtends ::= extends ClassType");
+ consumeClassHeaderExtends();
+ break ;
+
+ case 99 : // System.out.println("ClassHeaderImplements ::= implements InterfaceTypeList");
+ consumeClassHeaderImplements();
+ break ;
+
+ case 101 : // System.out.println("InterfaceTypeList ::= InterfaceTypeList COMMA InterfaceType");
+ consumeInterfaceTypeList();
+ break ;
+
+ case 102 : // System.out.println("InterfaceType ::= ClassOrInterfaceType");
+ consumeInterfaceType();
+ break ;
+
+ case 105 : // System.out.println("ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration");
+ consumeClassBodyDeclarations();
+ break ;
+
+ case 109 : // System.out.println("ClassBodyDeclaration ::= Diet NestedMethod Block");
+ consumeClassBodyDeclaration();
+ break ;
+
+ case 110 : // System.out.println("Diet ::=");
+ consumeDiet();
+ break ;
+
+ case 111 : // System.out.println("Initializer ::= Diet NestedMethod Block");
+ consumeClassBodyDeclaration();
+ break ;
+
+ case 118 : // System.out.println("ClassMemberDeclaration ::= SEMICOLON");
+ consumeEmptyClassMemberDeclaration();
+ break ;
+
+ case 119 : // System.out.println("FieldDeclaration ::= Modifiersopt Type VariableDeclarators SEMICOLON");
+ consumeFieldDeclaration();
+ break ;
+
+ case 121 : // System.out.println("VariableDeclarators ::= VariableDeclarators COMMA VariableDeclarator");
+ consumeVariableDeclarators();
+ break ;
+
+ case 124 : // System.out.println("EnterVariable ::=");
+ consumeEnterVariable();
+ break ;
+
+ case 125 : // System.out.println("ExitVariableWithInitialization ::=");
+ consumeExitVariableWithInitialization();
+ break ;
+
+ case 126 : // System.out.println("ExitVariableWithoutInitialization ::=");
+ consumeExitVariableWithoutInitialization();
+ break ;
+
+ case 127 : // System.out.println("ForceNoDiet ::=");
+ consumeForceNoDiet();
+ break ;
+
+ case 128 : // System.out.println("RestoreDiet ::=");
+ consumeRestoreDiet();
+ break ;
+
+ case 133 : // System.out.println("MethodDeclaration ::= MethodHeader MethodBody");
+ // set to true to consume a method with a body
+ consumeMethodDeclaration(true);
+ break ;
+
+ case 134 : // System.out.println("AbstractMethodDeclaration ::= MethodHeader SEMICOLON");
+ // set to false to consume a method without body
+ consumeMethodDeclaration(false);
+ break ;
+
+ case 135 : // System.out.println("MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims");
+ consumeMethodHeader();
+ break ;
+
+ case 136 : // System.out.println("MethodPushModifiersHeader ::= MethodPushModifiersHeaderName MethodHeaderParameters");
+ consumeMethodHeader();
+ break ;
+
+ case 137 : // System.out.println("MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers Identifier LPAREN");
+ consumeMethodPushModifiersHeaderName();
+ break ;
+
+ case 138 : // System.out.println("MethodPushModifiersHeaderName ::= Type PushModifiers Identifier LPAREN");
+ consumeMethodPushModifiersHeaderName();
+ break ;
+
+ case 139 : // System.out.println("MethodHeaderName ::= Modifiersopt Type Identifier LPAREN");
+ consumeMethodHeaderName();
+ break ;
+
+ case 140 : // System.out.println("MethodHeaderParameters ::= FormalParameterListopt RPAREN");
+ consumeMethodHeaderParameters();
+ break ;
+
+ case 141 : // System.out.println("MethodHeaderExtendedDims ::= Dimsopt");
+ consumeMethodHeaderExtendedDims();
+ break ;
+
+ case 142 : // System.out.println("MethodHeaderThrowsClause ::= throws ClassTypeList");
+ consumeMethodHeaderThrowsClause();
+ break ;
+
+ case 143 : // System.out.println("ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters...");
+ consumeConstructorHeader();
+ break ;
+
+ case 144 : // System.out.println("ConstructorHeaderName ::= Modifiersopt Identifier LPAREN");
+ consumeConstructorHeaderName();
+ break ;
+
+ case 146 : // System.out.println("FormalParameterList ::= FormalParameterList COMMA FormalParameter");
+ consumeFormalParameterList();
+ break ;
+
+ case 147 : // System.out.println("FormalParameter ::= Modifiersopt Type VariableDeclaratorId");
+ // the boolean is used to know if the modifiers should be reset
+ consumeFormalParameter();
+ break ;
+
+ case 149 : // System.out.println("ClassTypeList ::= ClassTypeList COMMA ClassTypeElt");
+ consumeClassTypeList();
+ break ;
+
+ case 150 : // System.out.println("ClassTypeElt ::= ClassType");
+ consumeClassTypeElt();
+ break ;
+
+ case 151 : // System.out.println("MethodBody ::= NestedMethod LBRACE BlockStatementsopt RBRACE");
+ consumeMethodBody();
+ break ;
+
+ case 152 : // System.out.println("NestedMethod ::=");
+ consumeNestedMethod();
+ break ;
+
+ case 153 : // System.out.println("StaticInitializer ::= StaticOnly Block");
+ consumeStaticInitializer();
+ break ;
+
+ case 154 : // System.out.println("StaticOnly ::= static");
+ consumeStaticOnly();
+ break ;
+
+ case 155 : // System.out.println("ConstructorDeclaration ::= ConstructorHeader ConstructorBody");
+ consumeConstructorDeclaration() ;
+ break ;
+
+ case 156 : // System.out.println("ConstructorDeclaration ::= ConstructorHeader SEMICOLON");
+ consumeInvalidConstructorDeclaration() ;
+ break ;
+
+ case 157 : // System.out.println("ConstructorBody ::= NestedMethod LBRACE ConstructorBlockStatementsopt RBRACE");
+ consumeConstructorBody();
+ break ;
+
+ case 160 : // System.out.println("ConstructorBlockStatementsopt ::= ExplicitConstructorInvocation BlockStatements");
+ consumeConstructorBlockStatements();
+ break ;
+
+ case 161 : // System.out.println("ExplicitConstructorInvocation ::= this LPAREN ArgumentListopt RPAREN SEMICOLON");
+ consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.This);
+ break ;
+
+ case 162 : // System.out.println("ExplicitConstructorInvocation ::= super LPAREN ArgumentListopt RPAREN SEMICOLON");
+ consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.Super);
+ break ;
+
+ case 163 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT super LPAREN ArgumentListopt RPAREN");
+ consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.Super);
+ break ;
+
+ case 164 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT super LPAREN ArgumentListopt RPAREN...");
+ consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.Super);
+ break ;
+
+ case 165 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT this LPAREN ArgumentListopt RPAREN...");
+ consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.This);
+ break ;
+
+ case 166 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT this LPAREN ArgumentListopt RPAREN...");
+ consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.This);
+ break ;
+
+ case 167 : // System.out.println("InterfaceDeclaration ::= InterfaceHeader InterfaceBody");
+ consumeInterfaceDeclaration();
+ break ;
+
+ case 168 : // System.out.println("InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt");
+ consumeInterfaceHeader();
+ break ;
+
+ case 169 : // System.out.println("InterfaceHeaderName ::= Modifiersopt interface Identifier");
+ consumeInterfaceHeaderName();
+ break ;
+
+ case 171 : // System.out.println("InterfaceHeaderExtends ::= extends InterfaceTypeList");
+ consumeInterfaceHeaderExtends();
+ break ;
+
+ case 174 : // System.out.println("InterfaceMemberDeclarations ::= InterfaceMemberDeclarations...");
+ consumeInterfaceMemberDeclarations();
+ break ;
+
+ case 175 : // System.out.println("InterfaceMemberDeclaration ::= SEMICOLON");
+ consumeEmptyInterfaceMemberDeclaration();
+ break ;
+
+ case 178 : // System.out.println("InterfaceMemberDeclaration ::= InvalidMethodDeclaration");
+ ignoreMethodBody();
+ break ;
+
+ case 179 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody");
+ ignoreInvalidConstructorDeclaration(true);
+ break ;
+
+ case 180 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader SEMICOLON");
+ ignoreInvalidConstructorDeclaration(false);
+ break ;
+
+ case 186 : // System.out.println("ArrayInitializer ::= LBRACE ,opt RBRACE");
+ consumeEmptyArrayInitializer();
+ break ;
+
+ case 187 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers RBRACE");
+ consumeArrayInitializer();
+ break ;
+
+ case 188 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers COMMA RBRACE");
+ consumeArrayInitializer();
+ break ;
+
+ case 190 : // System.out.println("VariableInitializers ::= VariableInitializers COMMA VariableInitializer");
+ consumeVariableInitializers();
+ break ;
+
+ case 191 : // System.out.println("Block ::= OpenBlock LBRACE BlockStatementsopt RBRACE");
+ consumeBlock();
+ break ;
+
+ case 192 : // System.out.println("OpenBlock ::=");
+ consumeOpenBlock() ;
+ break ;
+
+ case 194 : // System.out.println("BlockStatements ::= BlockStatements BlockStatement");
+ consumeBlockStatements() ;
+ break ;
+
+ case 198 : // System.out.println("BlockStatement ::= InvalidInterfaceDeclaration");
+ ignoreInterfaceDeclaration();
+ break ;
+
+ case 199 : // System.out.println("LocalVariableDeclarationStatement ::= LocalVariableDeclaration SEMICOLON");
+ consumeLocalVariableDeclarationStatement();
+ break ;
+
+ case 200 : // System.out.println("LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators");
+ consumeLocalVariableDeclaration();
+ break ;
+
+ case 201 : // System.out.println("LocalVariableDeclaration ::= Modifiers Type PushModifiers VariableDeclarators");
+ consumeLocalVariableDeclaration();
+ break ;
+
+ case 202 : // System.out.println("PushModifiers ::=");
+ consumePushModifiers();
+ break ;
+
+ case 226 : // System.out.println("EmptyStatement ::= SEMICOLON");
+ consumeEmptyStatement();
+ break ;
+
+ case 227 : // System.out.println("LabeledStatement ::= Identifier COLON Statement");
+ consumeStatementLabel() ;
+ break ;
+
+ case 228 : // System.out.println("LabeledStatementNoShortIf ::= Identifier COLON StatementNoShortIf");
+ consumeStatementLabel() ;
+ break ;
+
+ case 229 : // System.out.println("ExpressionStatement ::= StatementExpression SEMICOLON");
+ consumeExpressionStatement();
+ break ;
+
+ case 237 : // System.out.println("IfThenStatement ::= if LPAREN Expression RPAREN Statement");
+ consumeStatementIfNoElse();
+ break ;
+
+ case 238 : // System.out.println("IfThenElseStatement ::= if LPAREN Expression RPAREN StatementNoShortIf else...");
+ consumeStatementIfWithElse();
+ break ;
+
+ case 239 : // System.out.println("IfThenElseStatementNoShortIf ::= if LPAREN Expression RPAREN StatementNoShortIf...");
+ consumeStatementIfWithElse();
+ break ;
+
+ case 240 : // System.out.println("SwitchStatement ::= switch OpenBlock LPAREN Expression RPAREN SwitchBlock");
+ consumeStatementSwitch() ;
+ break ;
+
+ case 241 : // System.out.println("SwitchBlock ::= LBRACE RBRACE");
+ consumeEmptySwitchBlock() ;
+ break ;
+
+ case 244 : // System.out.println("SwitchBlock ::= LBRACE SwitchBlockStatements SwitchLabels RBRACE");
+ consumeSwitchBlock() ;
+ break ;
+
+ case 246 : // System.out.println("SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement");
+ consumeSwitchBlockStatements() ;
+ break ;
+
+ case 247 : // System.out.println("SwitchBlockStatement ::= SwitchLabels BlockStatements");
+ consumeSwitchBlockStatement() ;
+ break ;
+
+ case 249 : // System.out.println("SwitchLabels ::= SwitchLabels SwitchLabel");
+ consumeSwitchLabels() ;
+ break ;
+
+ case 250 : // System.out.println("SwitchLabel ::= case ConstantExpression COLON");
+ consumeCaseLabel();
+ break ;
+
+ case 251 : // System.out.println("SwitchLabel ::= default COLON");
+ consumeDefaultLabel();
+ break ;
+
+ case 252 : // System.out.println("WhileStatement ::= while LPAREN Expression RPAREN Statement");
+ consumeStatementWhile() ;
+ break ;
+
+ case 253 : // System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression RPAREN StatementNoShortIf");
+ consumeStatementWhile() ;
+ break ;
+
+ case 254 : // System.out.println("DoStatement ::= do Statement while LPAREN Expression RPAREN SEMICOLON");
+ consumeStatementDo() ;
+ break ;
+
+ case 255 : // System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON...");
+ consumeStatementFor() ;
+ break ;
+
+ case 256 : // System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON");
+ consumeStatementFor() ;
+ break ;
+
+ case 257 : // System.out.println("ForInit ::= StatementExpressionList");
+ consumeForInit() ;
+ break ;
+
+ case 261 : // System.out.println("StatementExpressionList ::= StatementExpressionList COMMA StatementExpression");
+ consumeStatementExpressionList() ;
+ break ;
+
+ case 262 : // System.out.println("AssertStatement ::= assert Expression SEMICOLON");
+ consumeSimpleAssertStatement() ;
+ break ;
+
+ case 263 : // System.out.println("AssertStatement ::= assert Expression COLON Expression SEMICOLON");
+ consumeAssertStatement() ;
+ break ;
+
+ case 264 : // System.out.println("BreakStatement ::= break SEMICOLON");
+ consumeStatementBreak() ;
+ break ;
+
+ case 265 : // System.out.println("BreakStatement ::= break Identifier SEMICOLON");
+ consumeStatementBreakWithLabel() ;
+ break ;
+
+ case 266 : // System.out.println("ContinueStatement ::= continue SEMICOLON");
+ consumeStatementContinue() ;
+ break ;
+
+ case 267 : // System.out.println("ContinueStatement ::= continue Identifier SEMICOLON");
+ consumeStatementContinueWithLabel() ;
+ break ;
+
+ case 268 : // System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON");
+ consumeStatementReturn() ;
+ break ;
+
+ case 269 : // System.out.println("ThrowStatement ::= throw Expression SEMICOLON");
+ consumeStatementThrow();
+
+ break ;
+
+ case 270 : // System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN Expression RPAREN Block");
+ consumeStatementSynchronized();
+ break ;
+
+ case 271 : // System.out.println("OnlySynchronized ::= synchronized");
+ consumeOnlySynchronized();
+ break ;
+
+ case 272 : // System.out.println("TryStatement ::= try Block Catches");
+ consumeStatementTry(false);
+ break ;
+
+ case 273 : // System.out.println("TryStatement ::= try Block Catchesopt Finally");
+ consumeStatementTry(true);
+ break ;
+
+ case 275 : // System.out.println("Catches ::= Catches CatchClause");
+ consumeCatches();
+ break ;
+
+ case 276 : // System.out.println("CatchClause ::= catch LPAREN FormalParameter RPAREN Block");
+ consumeStatementCatch() ;
+ break ;
+
+ case 278 : // System.out.println("PushLPAREN ::= LPAREN");
+ consumeLeftParen();
+ break ;
+
+ case 279 : // System.out.println("PushRPAREN ::= RPAREN");
+ consumeRightParen();
+ break ;
+
+ case 284 : // System.out.println("PrimaryNoNewArray ::= this");
+ consumePrimaryNoNewArrayThis();
+ break ;
+
+ case 285 : // System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN");
+ consumePrimaryNoNewArray();
+ break ;
+
+ case 288 : // System.out.println("PrimaryNoNewArray ::= Name DOT this");
+ consumePrimaryNoNewArrayNameThis();
+ break ;
+
+ case 289 : // System.out.println("PrimaryNoNewArray ::= Name DOT super");
+ consumePrimaryNoNewArrayNameSuper();
+ break ;
+
+ case 290 : // System.out.println("PrimaryNoNewArray ::= Name DOT class");
+ consumePrimaryNoNewArrayName();
+ break ;
+
+ case 291 : // System.out.println("PrimaryNoNewArray ::= ArrayType DOT class");
+ consumePrimaryNoNewArrayArrayType();
+ break ;
+
+ case 292 : // System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class");
+ consumePrimaryNoNewArrayPrimitiveType();
+ break ;
+
+ case 295 : // System.out.println("AllocationHeader ::= new ClassType LPAREN ArgumentListopt RPAREN");
+ consumeAllocationHeader();
+ break ;
+
+ case 296 : // System.out.println("ClassInstanceCreationExpression ::= new ClassType LPAREN ArgumentListopt RPAREN...");
+ consumeClassInstanceCreationExpression();
+ break ;
+
+ case 297 : // System.out.println("ClassInstanceCreationExpression ::= Primary DOT new SimpleName LPAREN...");
+ consumeClassInstanceCreationExpressionQualified() ;
+ break ;
+
+ case 298 : // System.out.println("ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName new...");
+ consumeClassInstanceCreationExpressionQualified() ;
+ break ;
+
+ case 299 : // System.out.println("ClassInstanceCreationExpressionName ::= Name DOT");
+ consumeClassInstanceCreationExpressionName() ;
+ break ;
+
+ case 300 : // System.out.println("ClassBodyopt ::=");
+ consumeClassBodyopt();
+ break ;
+
+ case 302 : // System.out.println("EnterAnonymousClassBody ::=");
+ consumeEnterAnonymousClassBody();
+ break ;
+
+ case 304 : // System.out.println("ArgumentList ::= ArgumentList COMMA Expression");
+ consumeArgumentList();
+ break ;
+
+ case 305 : // System.out.println("ArrayCreationWithoutArrayInitializer ::= new PrimitiveType DimWithOrWithOutExprs");
+ consumeArrayCreationExpressionWithoutInitializer();
+ break ;
+
+ case 306 : // System.out.println("ArrayCreationWithArrayInitializer ::= new PrimitiveType DimWithOrWithOutExprs...");
+ consumeArrayCreationExpressionWithInitializer();
+ break ;
+
+ case 307 : // System.out.println("ArrayCreationWithoutArrayInitializer ::= new ClassOrInterfaceType...");
+ consumeArrayCreationExpressionWithoutInitializer();
+ break ;
+
+ case 308 : // System.out.println("ArrayCreationWithArrayInitializer ::= new ClassOrInterfaceType...");
+ consumeArrayCreationExpressionWithInitializer();
+ break ;
+
+ case 310 : // System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr");
+ consumeDimWithOrWithOutExprs();
+ break ;
+
+ case 312 : // System.out.println("DimWithOrWithOutExpr ::= LBRACKET RBRACKET");
+ consumeDimWithOrWithOutExpr();
+ break ;
+
+ case 313 : // System.out.println("Dims ::= DimsLoop");
+ consumeDims();
+ break ;
+
+ case 316 : // System.out.println("OneDimLoop ::= LBRACKET RBRACKET");
+ consumeOneDimLoop();
+ break ;
+
+ case 317 : // System.out.println("FieldAccess ::= Primary DOT Identifier");
+ consumeFieldAccess(false);
+ break ;
+
+ case 318 : // System.out.println("FieldAccess ::= super DOT Identifier");
+ consumeFieldAccess(true);
+ break ;
+
+ case 319 : // System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN");
+ consumeMethodInvocationName();
+ break ;
+
+ case 320 : // System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN ArgumentListopt RPAREN");
+ consumeMethodInvocationPrimary();
+ break ;
+
+ case 321 : // System.out.println("MethodInvocation ::= super DOT Identifier LPAREN ArgumentListopt RPAREN");
+ consumeMethodInvocationSuper();
+ break ;
+
+ case 322 : // System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET");
+ consumeArrayAccess(true);
+ break ;
+
+ case 323 : // System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression RBRACKET");
+ consumeArrayAccess(false);
+ break ;
+ case 324 : // System.out.println("ArrayAccess ::= ArrayCreationWithArrayInitializer LBRACKET Expression RBRACKET");
+ consumeArrayAccess(false);
+ break ;
+
+ case 326 : // System.out.println("PostfixExpression ::= Name");
+ consumePostfixExpression();
+ break ;
+
+ case 329 : // System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS");
+ consumeUnaryExpression(OperatorExpression.PLUS,true);
+ break ;
+
+ case 330 : // System.out.println("PostDecrementExpression ::= PostfixExpression MINUS_MINUS");
+ consumeUnaryExpression(OperatorExpression.MINUS,true);
+ break ;
+
+ case 331 : // System.out.println("PushPosition ::=");
+ consumePushPosition();
+ break ;
+
+ case 334 : // System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.PLUS);
+ break ;
+
+ case 335 : // System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.MINUS);
+ break ;
+
+ case 337 : // System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.PLUS,false);
+ break ;
+
+ case 338 : // System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.MINUS,false);
+ break ;
+
+ case 340 : // System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.TWIDDLE);
+ break ;
+
+ case 341 : // System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition UnaryExpression");
+ consumeUnaryExpression(OperatorExpression.NOT);
+ break ;
+
+ case 343 : // System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN InsideCastExpression");
+ consumeCastExpression();
+ break ;
+
+ case 344 : // System.out.println("CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression...");
+ consumeCastExpression();
+ break ;
+
+ case 345 : // System.out.println("CastExpression ::= PushLPAREN Expression PushRPAREN InsideCastExpressionLL1...");
+ consumeCastExpressionLL1();
+ break ;
+
+ case 346 : // System.out.println("InsideCastExpression ::=");
+ consumeInsideCastExpression();
+ break ;
+
+ case 347 : // System.out.println("InsideCastExpressionLL1 ::=");
+ consumeInsideCastExpressionLL1();
+ break ;
+
+ case 349 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression MULTIPLY UnaryExpression");
+ consumeBinaryExpression(OperatorExpression.MULTIPLY);
+ break ;
+
+ case 350 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression DIVIDE UnaryExpression");
+ consumeBinaryExpression(OperatorExpression.DIVIDE);
+ break ;
+
+ case 351 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression REMAINDER UnaryExpression");
+ consumeBinaryExpression(OperatorExpression.REMAINDER);
+ break ;
+
+ case 353 : // System.out.println("AdditiveExpression ::= AdditiveExpression PLUS MultiplicativeExpression");
+ consumeBinaryExpression(OperatorExpression.PLUS);
+ break ;
+
+ case 354 : // System.out.println("AdditiveExpression ::= AdditiveExpression MINUS MultiplicativeExpression");
+ consumeBinaryExpression(OperatorExpression.MINUS);
+ break ;
+
+ case 356 : // System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT AdditiveExpression");
+ consumeBinaryExpression(OperatorExpression.LEFT_SHIFT);
+ break ;
+
+ case 357 : // System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT AdditiveExpression");
+ consumeBinaryExpression(OperatorExpression.RIGHT_SHIFT);
+ break ;
+
+ case 358 : // System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT AdditiveExpression");
+ consumeBinaryExpression(OperatorExpression.UNSIGNED_RIGHT_SHIFT);
+ break ;
+
+ case 360 : // System.out.println("RelationalExpression ::= RelationalExpression LESS ShiftExpression");
+ consumeBinaryExpression(OperatorExpression.LESS);
+ break ;
+
+ case 361 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER ShiftExpression");
+ consumeBinaryExpression(OperatorExpression.GREATER);
+ break ;
+
+ case 362 : // System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL ShiftExpression");
+ consumeBinaryExpression(OperatorExpression.LESS_EQUAL);
+ break ;
+
+ case 363 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER_EQUAL ShiftExpression");
+ consumeBinaryExpression(OperatorExpression.GREATER_EQUAL);
+ break ;
+
+ case 364 : // System.out.println("RelationalExpression ::= RelationalExpression instanceof ReferenceType");
+ consumeInstanceOfExpression(OperatorExpression.INSTANCEOF);
+ break ;
+
+ case 366 : // System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL RelationalExpression");
+ consumeEqualityExpression(OperatorExpression.EQUAL_EQUAL);
+ break ;
+
+ case 367 : // System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL RelationalExpression");
+ consumeEqualityExpression(OperatorExpression.NOT_EQUAL);
+ break ;
+
+ case 369 : // System.out.println("AndExpression ::= AndExpression AND EqualityExpression");
+ consumeBinaryExpression(OperatorExpression.AND);
+ break ;
+
+ case 371 : // System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR AndExpression");
+ consumeBinaryExpression(OperatorExpression.XOR);
+ break ;
+
+ case 373 : // System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR ExclusiveOrExpression");
+ consumeBinaryExpression(OperatorExpression.OR);
+ break ;
+
+ case 375 : // System.out.println("ConditionalAndExpression ::= ConditionalAndExpression AND_AND InclusiveOrExpression");
+ consumeBinaryExpression(OperatorExpression.AND_AND);
+ break ;
+
+ case 377 : // System.out.println("ConditionalOrExpression ::= ConditionalOrExpression OR_OR ConditionalAndExpression");
+ consumeBinaryExpression(OperatorExpression.OR_OR);
+ break ;
+
+ case 379 : // System.out.println("ConditionalExpression ::= ConditionalOrExpression QUESTION Expression COLON...");
+ consumeConditionalExpression(OperatorExpression.QUESTIONCOLON) ;
+ break ;
+
+ case 382 : // System.out.println("Assignment ::= PostfixExpression AssignmentOperator AssignmentExpression");
+ consumeAssignment();
+ break ;
+
+ case 384 : // System.out.println("Assignment ::= InvalidArrayInitializerAssignement");
+ ignoreExpressionAssignment();
+ break ;
+
+ case 385 : // System.out.println("AssignmentOperator ::= EQUAL");
+ consumeAssignmentOperator(EQUAL);
+ break ;
+
+ case 386 : // System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL");
+ consumeAssignmentOperator(MULTIPLY);
+ break ;
+
+ case 387 : // System.out.println("AssignmentOperator ::= DIVIDE_EQUAL");
+ consumeAssignmentOperator(DIVIDE);
+ break ;
+
+ case 388 : // System.out.println("AssignmentOperator ::= REMAINDER_EQUAL");
+ consumeAssignmentOperator(REMAINDER);
+ break ;
+
+ case 389 : // System.out.println("AssignmentOperator ::= PLUS_EQUAL");
+ consumeAssignmentOperator(PLUS);
+ break ;
+
+ case 390 : // System.out.println("AssignmentOperator ::= MINUS_EQUAL");
+ consumeAssignmentOperator(MINUS);
+ break ;
+
+ case 391 : // System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL");
+ consumeAssignmentOperator(LEFT_SHIFT);
+ break ;
+
+ case 392 : // System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL");
+ consumeAssignmentOperator(RIGHT_SHIFT);
+ break ;
+
+ case 393 : // System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL");
+ consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT);
+ break ;
+
+ case 394 : // System.out.println("AssignmentOperator ::= AND_EQUAL");
+ consumeAssignmentOperator(AND);
+ break ;
+
+ case 395 : // System.out.println("AssignmentOperator ::= XOR_EQUAL");
+ consumeAssignmentOperator(XOR);
+ break ;
+
+ case 396 : // System.out.println("AssignmentOperator ::= OR_EQUAL");
+ consumeAssignmentOperator(OR);
+ break ;
+
+ case 403 : // System.out.println("Expressionopt ::=");
+ consumeEmptyExpression();
+ break ;
+
+ case 407 : // System.out.println("ImportDeclarationsopt ::=");
+ consumeEmptyImportDeclarationsopt();
+ break ;
+
+ case 408 : // System.out.println("ImportDeclarationsopt ::= ImportDeclarations");
+ consumeImportDeclarationsopt();
+ break ;
+
+ case 409 : // System.out.println("TypeDeclarationsopt ::=");
+ consumeEmptyTypeDeclarationsopt();
+ break ;
+
+ case 410 : // System.out.println("TypeDeclarationsopt ::= TypeDeclarations");
+ consumeTypeDeclarationsopt();
+ break ;
+
+ case 411 : // System.out.println("ClassBodyDeclarationsopt ::=");
+ consumeEmptyClassBodyDeclarationsopt();
+ break ;
+
+ case 412 : // System.out.println("ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations");
+ consumeClassBodyDeclarationsopt();
+ break ;
+
+ case 413 : // System.out.println("Modifiersopt ::=");
+ consumeDefaultModifiers();
+ break ;
+
+ case 414 : // System.out.println("Modifiersopt ::= Modifiers");
+ consumeModifiers();
+ break ;
+
+ case 415 : // System.out.println("BlockStatementsopt ::=");
+ consumeEmptyBlockStatementsopt();
+ break ;
+
+ case 417 : // System.out.println("Dimsopt ::=");
+ consumeEmptyDimsopt();
+ break ;
+
+ case 419 : // System.out.println("ArgumentListopt ::=");
+ consumeEmptyArgumentListopt();
+ break ;
+
+ case 423 : // System.out.println("FormalParameterListopt ::=");
+ consumeFormalParameterListopt();
+ break ;
+
+ case 427 : // System.out.println("InterfaceMemberDeclarationsopt ::=");
+ consumeEmptyInterfaceMemberDeclarationsopt();
+ break ;
+
+ case 428 : // System.out.println("InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations");
+ consumeInterfaceMemberDeclarationsopt();
+ break ;
+
+ case 429 : // System.out.println("NestedType ::=");
+ consumeNestedType();
+ break ;
+
+ case 430 : // System.out.println("ForInitopt ::=");
+ consumeEmptyForInitopt();
+ break ;
+
+ case 432 : // System.out.println("ForUpdateopt ::=");
+ consumeEmptyForUpdateopt();
+ break ;
+
+ case 436 : // System.out.println("Catchesopt ::=");
+ consumeEmptyCatchesopt();
+ break ;
+
+ }
+}
protected void consumeSimpleAssertStatement() {
// AssertStatement ::= 'assert' Expression ';'
@@ -3887,27 +4005,15 @@
length);
}
};
- if (action instanceof Block) {
- pushOnAstStack(
- new ForStatement(
- inits,
- cond,
- updates,
- action,
- scope,
- intStack[intPtr--],
- endStatementPosition));
- } else {
- pushOnAstStack(
- new ForStatement(
- inits,
- cond,
- updates,
- action,
- scope,
- intStack[intPtr--],
- endPosition));
- }
+ pushOnAstStack(
+ new ForStatement(
+ inits,
+ cond,
+ updates,
+ action,
+ scope,
+ intStack[intPtr--],
+ endStatementPosition));
}
protected void consumeStatementIfNoElse() {
// IfThenStatement ::= 'if' '(' Expression ')' Statement
@@ -3915,14 +4021,7 @@
//optimize the push/pop
expressionLengthPtr--;
Statement thenStatement = (Statement) astStack[astPtr];
- if (thenStatement instanceof Block) {
- astStack[astPtr] =
- new IfStatement(
- expressionStack[expressionPtr--],
- thenStatement,
- intStack[intPtr--],
- endStatementPosition);
- } else if (thenStatement instanceof EmptyStatement) {
+ if (thenStatement instanceof EmptyStatement) {
astStack[astPtr] =
new IfStatement(
expressionStack[expressionPtr--],
@@ -3953,23 +4052,13 @@
if (thenStatement instanceof EmptyStatement) {
thenStatement = Block.None;
}
- if (elseStatement instanceof Block) {
- astStack[astPtr] =
- new IfStatement(
- expressionStack[expressionPtr--],
- thenStatement,
- elseStatement,
- intStack[intPtr--],
- endStatementPosition);
- } else {
- astStack[astPtr] =
- new IfStatement(
- expressionStack[expressionPtr--],
- thenStatement,
- elseStatement,
- intStack[intPtr--],
- endStatementPosition);
- }
+ astStack[astPtr] =
+ new IfStatement(
+ expressionStack[expressionPtr--],
+ thenStatement,
+ elseStatement,
+ intStack[intPtr--],
+ endStatementPosition);
}
protected void consumeStatementLabel() {
// LabeledStatement ::= 'Identifier' ':' Statement
@@ -4195,7 +4284,6 @@
problemReporter().nonExternalizedStringLiteral(literals[i]);
}
}
- scanner.currentLine = null;
scanner.wasNonExternalizedStringLiteral = false;
}
// clear the commentPtr of the scanner in case we read something different from a modifier
@@ -4629,11 +4717,11 @@
return typeRef.copyDims(dim);
}
protected FieldDeclaration createFieldDeclaration(Expression initialization, char[] name, int sourceStart, int sourceEnd) {
- return new FieldDeclaration(null, name, sourceStart, sourceEnd);
+ return new FieldDeclaration(null, name, sourceStart, sourceEnd); // TODO: (olivier) why don't we persist the initialization expression?
}
protected LocalDeclaration createLocalDeclaration(Expression initialization, char[] name, int sourceStart, int sourceEnd) {
- return new LocalDeclaration(null, name, sourceStart, sourceEnd);
+ return new LocalDeclaration(null, name, sourceStart, sourceEnd); // TODO: (olivier) why don't we persist the initialization expression?
}
public CompilationUnitDeclaration dietParse(ICompilationUnit sourceUnit, CompilationResult compilationResult) {
@@ -4759,6 +4847,16 @@
if (scanner.recordLineSeparator) {
compilationUnit.compilationResult.lineSeparatorPositions = scanner.getLineEnds();
}
+ if (scanner.taskTags != null){
+ for (int i = 0; i < scanner.foundTaskCount; i++){
+ problemReporter().task(
+ new String(scanner.foundTaskTags[i]),
+ new String(scanner.foundTaskMessages[i]),
+ scanner.foundTaskPriorities[i] == null ? null : new String(scanner.foundTaskPriorities[i]),
+ scanner.foundTaskPositions[i][0],
+ scanner.foundTaskPositions[i][1]);
+ }
+ }
return compilationUnit;
}
/*
@@ -4805,17 +4903,7 @@
}
}
}
- // position can be located in the middle of a line break
- // this is a bug on Windows platform only.
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=10557
- char[] source = scanner.source;
-
- if ((position < source.length)
- && (source[position] == '\r')
- && ((position + 1) < source.length)
- && (source[position + 1] == '\n')) {
- position++;
- }
+
if (index < 0) return position; // no obsolete comment
if (validCount > 0){ // move valid comment infos, overriding obsolete comment infos
@@ -5039,9 +5127,9 @@
firstToken = TokenNamePLUS_PLUS ;
scanner.linePtr = -1;
+ scanner.foundTaskCount = 0;
scanner.recordLineSeparator = true;
scanner.currentLine= null;
- scanner.lines= new ArrayList();
}
public void goForConstructorBody(){
//tells the scanner to go for compilation unit parsing
@@ -5926,7 +6014,8 @@
/.$putCase consumeRightParen(); $break ./
Primary -> PrimaryNoNewArray
-Primary -> ArrayCreationExpression
+Primary -> ArrayCreationWithArrayInitializer
+Primary -> ArrayCreationWithoutArrayInitializer
PrimaryNoNewArray -> Literal
PrimaryNoNewArray ::= 'this'
@@ -5993,17 +6082,17 @@
ArgumentList ::= ArgumentList ',' Expression
/.$putCase consumeArgumentList(); $break ./
---Thess rules are re-written in order to be ll1
---ArrayCreationExpression ::= 'new' ArrayType ArrayInitializer
---ArrayCreationExpression ::= 'new' PrimitiveType DimExprs Dimsopt
---ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimExprs Dimsopt
---DimExprs ::= DimExpr
---DimExprs ::= DimExprs DimExpr
+ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
+/.$putCase consumeArrayCreationExpressionWithoutInitializer(); $break ./
-ArrayCreationExpression ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializeropt
-/.$putCase consumeArrayCreationExpression(); $break ./
-ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializeropt
-/.$putCase consumeArrayCreationExpression(); $break ./
+ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
+/.$putCase consumeArrayCreationExpressionWithInitializer(); $break ./
+
+ArrayCreationWithoutArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
+/.$putCase consumeArrayCreationExpressionWithoutInitializer(); $break ./
+
+ArrayCreationWithArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializer
+/.$putCase consumeArrayCreationExpressionWithInitializer(); $break ./
DimWithOrWithOutExprs ::= DimWithOrWithOutExpr
DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr
@@ -6040,6 +6129,8 @@
/.$putCase consumeArrayAccess(true); $break ./
ArrayAccess ::= PrimaryNoNewArray '[' Expression ']'
/.$putCase consumeArrayAccess(false); $break ./
+ArrayAccess ::= ArrayCreationWithArrayInitializer '[' Expression ']'
+/.$putCase consumeArrayAccess(false); $break ./
PostfixExpression -> Primary
PostfixExpression ::= Name
@@ -6078,14 +6169,19 @@
/.$putCase consumeUnaryExpression(OperatorExpression.NOT); $break ./
UnaryExpressionNotPlusMinus -> CastExpression
-CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression
+CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN InsideCastExpression UnaryExpression
/.$putCase consumeCastExpression(); $break ./
- CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus
+ CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
/.$putCase consumeCastExpression(); $break ./
-- Expression is here only in order to make the grammar LL1
-CastExpression ::= PushLPAREN Expression PushRPAREN UnaryExpressionNotPlusMinus
+CastExpression ::= PushLPAREN Expression PushRPAREN InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
/.$putCase consumeCastExpressionLL1(); $break ./
+InsideCastExpression ::= $empty
+/.$putCase consumeInsideCastExpression(); $break ./
+InsideCastExpressionLL1 ::= $empty
+/.$putCase consumeInsideCastExpressionLL1(); $break ./
+
MultiplicativeExpression -> UnaryExpression
MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression
/.$putCase consumeBinaryExpression(OperatorExpression.MULTIPLY); $break ./
@@ -6153,19 +6249,14 @@
AssignmentExpression -> ConditionalExpression
AssignmentExpression -> Assignment
-Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
+Assignment ::= PostfixExpression AssignmentOperator AssignmentExpression
/.$putCase consumeAssignment(); $break ./
-- this rule is added to parse an array initializer in a assigment and then report a syntax error knowing the exact senario
-InvalidArrayInitializerAssignement ::= LeftHandSide AssignmentOperator ArrayInitializer
+InvalidArrayInitializerAssignement ::= PostfixExpression AssignmentOperator ArrayInitializer
Assignment ::= InvalidArrayInitializerAssignement
/.$putcase ignoreExpressionAssignment();$break ./
-LeftHandSide ::= Name
-/.$putCase consumeLeftHandSide(); $break ./
-LeftHandSide -> FieldAccess
-LeftHandSide -> ArrayAccess
-
AssignmentOperator ::= '='
/.$putCase consumeAssignmentOperator(EQUAL); $break ./
AssignmentOperator ::= '*='
@@ -6290,10 +6381,6 @@
/. $putCase consumeEmptyCatchesopt(); $break ./
Catchesopt -> Catches
-ArrayInitializeropt ::= $empty
-/. $putCase consumeEmptyArrayInitializeropt(); $break ./
-ArrayInitializeropt -> ArrayInitializer
-
/. }
} ./
@@ -6385,8 +6472,8 @@
typeDecl.bodyEnd = endStatementPosition;
problemReporter().cannotDeclareLocalInterface(typeDecl.name, typeDecl.sourceStart, typeDecl.sourceEnd);
- // mark fields and initializer with local type mark if needed
- markFieldsWithLocalType(typeDecl);
+ // mark initializers with local type mark if needed
+ markInitializersWithLocalType(typeDecl);
// remove the ast node created in interface header
astPtr--;
@@ -6495,6 +6582,7 @@
// reset scanner state
scanner.commentPtr = -1;
+ scanner.foundTaskCount = 0;
scanner.eofPosition = Integer.MAX_VALUE;
resetModifiers();
@@ -6510,7 +6598,14 @@
listLength = 0;
}
public void initializeScanner(){
- this.scanner = new Scanner(false, false, this.problemReporter.options.getNonExternalizedStringLiteralSeverity() != ProblemSeverities.Ignore , this.assertMode);
+ CompilerOptions options = this.problemReporter.options;
+ this.scanner = new Scanner(
+ false /*comment*/,
+ false /*whitespace*/,
+ options.getSeverity(CompilerOptions.NonExternalizedString) != ProblemSeverities.Ignore /*nls*/,
+ this.assertMode /*assert*/,
+ options.taskTags/*taskTags*/,
+ options.taskPriorites/*taskPriorities*/);
}
public final static void initTables() throws java.io.IOException {
@@ -6537,12 +6632,13 @@
if (diet && (dietInt == 0))
scanner.diet = true;
}
-protected void markCurrentMethodWithLocalType() {
+protected void markEnclosingMemberWithLocalType() {
if (this.currentElement != null) return; // this is already done in the recovery code
for (int i = this.astPtr; i >= 0; i--) {
AstNode node = this.astStack[i];
if (node instanceof AbstractMethodDeclaration
- || node instanceof TypeDeclaration) { // mark type for now: all fields will be marked when added to this type
+ || node instanceof FieldDeclaration
+ || node instanceof TypeDeclaration) { // mark type for now: all initializers will be marked when added to this type
node.bits |= AstNode.HasLocalTypeMASK;
return;
}
@@ -6553,10 +6649,13 @@
((AstNode)this.referenceContext).bits |= AstNode.HasLocalTypeMASK;
}
}
-protected void markFieldsWithLocalType(TypeDeclaration type) {
+protected void markInitializersWithLocalType(TypeDeclaration type) {
if (type.fields == null || (type.bits & AstNode.HasLocalTypeMASK) == 0) return;
for (int i = 0, length = type.fields.length; i < length; i++) {
- type.fields[i].bits |= AstNode.HasLocalTypeMASK;
+ FieldDeclaration field = type.fields[i];
+ if (field instanceof Initializer) {
+ field.bits |= AstNode.HasLocalTypeMASK;
+ }
}
}
/*
@@ -6606,6 +6705,7 @@
scanner.startPosition = pos;
scanner.currentPosition = pos;
scanner.commentPtr = -1;
+ scanner.foundTaskCount = 0;
return true;
@@ -6868,6 +6968,45 @@
// A P I
public void parse(
+ FieldDeclaration field,
+ TypeDeclaration type,
+ CompilationUnitDeclaration unit,
+ char[] initializationSource) {
+ //only parse the initializationSource of the given field
+
+ //convert bugs into parse error
+
+ initialize();
+ goForExpression();
+ nestedMethod[nestedType]++;
+
+ referenceContext = type;
+ compilationUnit = unit;
+
+ scanner.setSource(initializationSource);
+ scanner.resetTo(0, initializationSource.length-1);
+ try {
+ parse();
+ } catch (AbortCompilation ex) {
+ lastAct = ERROR_ACTION;
+ } finally {
+ nestedMethod[nestedType]--;
+ }
+
+ if (lastAct == ERROR_ACTION) {
+ return;
+ }
+
+ field.initialization = expressionStack[expressionPtr];
+
+ // mark field with local type if one was found during parsing
+ if ((type.bits & AstNode.HasLocalTypeMASK) != 0) {
+ field.bits |= AstNode.HasLocalTypeMASK;
+ }
+}
+// A P I
+
+public void parse(
Initializer ini,
TypeDeclaration type,
CompilationUnitDeclaration unit) {
@@ -7167,12 +7306,13 @@
//files are located at Parser.class directory
- InputStream stream = new BufferedInputStream(Parser.class.getResourceAsStream(filename));
+ InputStream stream = Parser.class.getResourceAsStream(filename);
if (stream == null) {
throw new java.io.IOException(Util.bind("parser.missingFile",filename)); //$NON-NLS-1$
}
byte[] bytes = null;
try {
+ stream = new BufferedInputStream(stream);
bytes = Util.getInputStreamAsByteArray(stream, -1);
} finally {
try {
@@ -7198,6 +7338,22 @@
}
return chars;
}
+public void recoveryExitFromVariable() {
+ if(currentElement != null && currentElement.parent != null) {
+ if(currentElement instanceof RecoveredLocalVariable) {
+
+ int end = ((RecoveredLocalVariable)currentElement).localDeclaration.sourceEnd;
+ currentElement.updateSourceEndIfNecessary(end);
+ currentElement = currentElement.parent;
+ } else if(currentElement instanceof RecoveredField
+ && !(currentElement instanceof RecoveredInitializer)) {
+
+ int end = ((RecoveredField)currentElement).fieldDeclaration.sourceEnd;
+ currentElement.updateSourceEndIfNecessary(end);
+ currentElement = currentElement.parent;
+ }
+ }
+}
/* Token check performed on every token shift once having entered
* recovery mode.
*/
@@ -7218,7 +7374,7 @@
RecoveredElement newElement =
currentElement.updateOnClosingBrace(scanner.startPosition, scanner.currentPosition -1);
lastCheckPoint = scanner.currentPosition;
- if (newElement != currentElement){
+ if (newElement != currentElement){
currentElement = newElement;
}
}
@@ -7264,13 +7420,52 @@
expectings);
}
} else { //the next test is HEAVILY grammar DEPENDENT.
- if ((length == 2)
- && (tokenName.equals(";")) //$NON-NLS-1$
- && (expectings[0] == "++") //$NON-NLS-1$
- && (expectings[1] == "--") //$NON-NLS-1$
+ if ((length == 14)
+ && (expectings[0] == "=") //$NON-NLS-1$
+ && (expectings[1] == "*=") //$NON-NLS-1$
&& (expressionPtr > -1)) {
- // the ; is not the expected token ==> it ends a statement when an expression is not ended
- problemReporter().invalidExpressionAsStatement(expressionStack[expressionPtr]);
+ switch(currentKind) {
+ case TerminalTokens.TokenNameSEMICOLON:
+ case TerminalTokens.TokenNamePLUS:
+ case TerminalTokens.TokenNameMINUS:
+ case TerminalTokens.TokenNameDIVIDE:
+ case TerminalTokens.TokenNameREMAINDER:
+ case TerminalTokens.TokenNameMULTIPLY:
+ case TerminalTokens.TokenNameLEFT_SHIFT:
+ case TerminalTokens.TokenNameRIGHT_SHIFT:
+ case TerminalTokens.TokenNameUNSIGNED_RIGHT_SHIFT:
+ case TerminalTokens.TokenNameLESS:
+ case TerminalTokens.TokenNameGREATER:
+ case TerminalTokens.TokenNameLESS_EQUAL:
+ case TerminalTokens.TokenNameGREATER_EQUAL:
+ case TerminalTokens.TokenNameEQUAL_EQUAL:
+ case TerminalTokens.TokenNameNOT_EQUAL:
+ case TerminalTokens.TokenNameXOR:
+ case TerminalTokens.TokenNameAND:
+ case TerminalTokens.TokenNameOR:
+ case TerminalTokens.TokenNameOR_OR:
+ case TerminalTokens.TokenNameAND_AND:
+ // the ; is not the expected token ==> it ends a statement when an expression is not ended
+ problemReporter().invalidExpressionAsStatement(expressionStack[expressionPtr]);
+ break;
+ case TerminalTokens.TokenNameRBRACE :
+ problemReporter().missingSemiColon(expressionStack[expressionPtr]);
+ break;
+ default:
+ char[] tokenSource;
+ try {
+ tokenSource = this.scanner.getCurrentTokenSource();
+ } catch (Exception e) {
+ tokenSource = new char[] {};
+ }
+ problemReporter().parseError(
+ this.scanner.startPosition,
+ this.scanner.currentPosition - 1,
+ tokenSource,
+ tokenName,
+ expectings);
+ this.checkAndReportBracketAnomalies(problemReporter());
+ }
} else {
char[] tokenSource;
try {
@@ -7314,6 +7509,8 @@
realBlockStack[realBlockPtr = 0] = 0;
recoveredStaticInitializerStart = 0;
listLength = 0;
+ // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=29365
+ if (this.scanner != null) this.scanner.currentLine = null;
}
/*
* Reset context so as to resume to regular parse loop
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
index d836744..4907ff9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ParserBasicInformation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
/*An interface that contains static declarations for some basic information
@@ -16,21 +16,18 @@
public interface ParserBasicInformation {
public final static int
- ERROR_SYMBOL = 307,
- MAX_NAME_LENGTH = 36,
- NUM_STATES = 591,
NT_OFFSET = 308,
SCOPE_UBOUND = -1,
SCOPE_SIZE = 0,
- LA_STATE_OFFSET = 16966,
+ LA_STATE_OFFSET = 17759,
MAX_LA = 1,
- NUM_RULES = 436,
- NUM_TERMINALS = 105,
- NUM_NON_TERMINALS = 203,
+ NUM_RULES = 437,
+ NUM_TERMINALS = 104,
+ NUM_NON_TERMINALS = 204,
NUM_SYMBOLS = 308,
- START_STATE = 12260,
- EOFT_SYMBOL = 158,
- EOLT_SYMBOL = 158,
- ACCEPT_ACTION = 16965,
- ERROR_ACTION = 16966;
+ START_STATE = 16034,
+ EOFT_SYMBOL = 114,
+ EOLT_SYMBOL = 105,
+ ACCEPT_ACTION = 17758,
+ ERROR_ACTION = 17759;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java
index 1da4500..a4bdb7c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredBlock.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
/**
* Internal block structure for parsing recovery
*/
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.Block;
@@ -23,9 +23,8 @@
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.BaseTypes;
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-public class RecoveredBlock extends RecoveredStatement implements CompilerModifiers, ITerminalSymbols, BaseTypes {
+public class RecoveredBlock extends RecoveredStatement implements CompilerModifiers, TerminalTokens, BaseTypes {
public Block blockDeclaration;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
index c1a9434..0d13637 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredElement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java
index 8d938e1..7924977 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredField.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredImport.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredImport.java
index f42091a..e6a8aa3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredImport.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredImport.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
index 9798e6e..1eaf4b0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredInitializer.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
/**
* Internal initializer structure for parsing recovery
*/
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.Block;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
@@ -24,9 +24,8 @@
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.BaseTypes;
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-public class RecoveredInitializer extends RecoveredField implements CompilerModifiers, ITerminalSymbols, BaseTypes {
+public class RecoveredInitializer extends RecoveredField implements CompilerModifiers, TerminalTokens, BaseTypes {
public RecoveredType[] localTypes;
public int localTypeCount;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java
index b450a75..b3bd778 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredLocalVariable.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
/**
@@ -15,6 +15,7 @@
*/
import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
+import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Statement;
@@ -27,6 +28,21 @@
this.localDeclaration = localDeclaration;
this.alreadyCompletedLocalInitialization = localDeclaration.initialization != null;
}
+/*
+ * Record an expression statement if local variable is expecting an initialization expression.
+ */
+public RecoveredElement add(Statement statement, int bracketBalance) {
+
+ if (this.alreadyCompletedLocalInitialization || !(statement instanceof Expression)) {
+ return super.add(statement, bracketBalance);
+ } else {
+ this.alreadyCompletedLocalInitialization = true;
+ this.localDeclaration.initialization = (Expression)statement;
+ this.localDeclaration.declarationSourceEnd = statement.sourceEnd;
+ this.localDeclaration.declarationEnd = statement.sourceEnd;
+ return this;
+ }
+}
/*
* Answer the associated parsed structure
*/
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
index 53f8825..6b5814c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredMethod.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
@@ -26,13 +26,12 @@
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.lookup.BaseTypes;
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* Internal method structure for parsing recovery
*/
-public class RecoveredMethod extends RecoveredElement implements CompilerModifiers, ITerminalSymbols, BaseTypes {
+public class RecoveredMethod extends RecoveredElement implements CompilerModifiers, TerminalTokens, BaseTypes {
public AbstractMethodDeclaration methodDeclaration;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java
index 3bca1f5..ab9efd7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
/**
@@ -19,7 +19,6 @@
public class RecoveredStatement extends RecoveredElement {
public Statement statement;
- boolean alreadyCompletedLocalInitialization;
public RecoveredStatement(Statement statement, RecoveredElement parent, int bracketBalance){
super(parent, bracketBalance);
this.statement = statement;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java
index 34a1447..960feb9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredType.java
@@ -1,16 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
@@ -28,7 +27,7 @@
* Internal type structure for parsing recovery
*/
-public class RecoveredType extends RecoveredStatement implements ITerminalSymbols, CompilerModifiers {
+public class RecoveredType extends RecoveredStatement implements TerminalTokens, CompilerModifiers {
public TypeDeclaration typeDeclaration;
public RecoveredType[] memberTypes;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java
index 28ebcc4..3ca9a5e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/RecoveredUnit.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
index 87f4889..c98f487 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java
@@ -1,25 +1,29 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
-import java.util.ArrayList;
import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.compiler.IScanner;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
-public class Scanner implements IScanner, ITerminalSymbols {
+/**
+ * IMPORTANT NOTE: Internal Scanner implementation. It is mirrored in
+ * org.eclipse.jdt.core.compiler public package where it is API.
+ * The mirror implementation is using the backward compatible ITerminalSymbols constant
+ * definitions (stable with 2.0), whereas the internal implementation uses TerminalTokens
+ * which constant values reflect the latest parser generation state.
+ */
+public class Scanner implements TerminalTokens {
/* APIs ares
- getNextToken() which return the current type of the token
@@ -31,20 +35,20 @@
*/
// 1.4 feature
- private boolean assertMode;
+ private boolean assertMode = false;
public boolean useAssertAsAnIndentifier = false;
//flag indicating if processed source contains occurrences of keyword assert
public boolean containsAssertKeyword = false;
- public boolean recordLineSeparator;
+ public boolean recordLineSeparator = false;
public char currentCharacter;
public int startPosition;
public int currentPosition;
public int initialPosition, eofPosition;
// after this position eof are generated instead of real token from the source
- public boolean tokenizeComments;
- public boolean tokenizeWhiteSpace;
+ public boolean tokenizeComments = false;
+ public boolean tokenizeWhiteSpace = false;
//source should be viewed as a window (aka a part)
//of a entire very large stream
@@ -58,11 +62,19 @@
public boolean scanningFloatLiteral = false;
//support for /** comments
- //public char[][] comments = new char[10][];
public int[] commentStops = new int[10];
public int[] commentStarts = new int[10];
public int commentPtr = -1; // no comment test with commentPtr value -1
-
+
+ // task tag support
+ public char[][] foundTaskTags = null;
+ public char[][] foundTaskMessages;
+ public char[][] foundTaskPriorities = null;
+ public int[][] foundTaskPositions;
+ public int foundTaskCount = 0;
+ public char[][] taskTags = null;
+ public char[][] taskPriorities = null;
+
//diet parsing support - jump over some method body when requested
public boolean diet = false;
@@ -76,8 +88,7 @@
public static final String INVALID_HEXA = "Invalid_Hexa_Literal"; //$NON-NLS-1$
public static final String INVALID_OCTAL = "Invalid_Octal_Literal"; //$NON-NLS-1$
- public static final String INVALID_CHARACTER_CONSTANT =
- "Invalid_Character_Constant"; //$NON-NLS-1$
+ public static final String INVALID_CHARACTER_CONSTANT = "Invalid_Character_Constant"; //$NON-NLS-1$
public static final String INVALID_ESCAPE = "Invalid_Escape"; //$NON-NLS-1$
public static final String INVALID_INPUT = "Invalid_Input"; //$NON-NLS-1$
public static final String INVALID_UNICODE_ESCAPE = "Invalid_Unicode_Escape"; //$NON-NLS-1$
@@ -126,13 +137,12 @@
int currentLineNr= -1;
int previousLineNr= -1;
NLSLine currentLine= null;
- List lines= new ArrayList();
public static final String TAG_PREFIX= "//$NON-NLS-"; //$NON-NLS-1$
public static final int TAG_PREFIX_LENGTH= TAG_PREFIX.length();
public static final String TAG_POSTFIX= "$"; //$NON-NLS-1$
public static final int TAG_POSTFIX_LENGTH= TAG_POSTFIX.length();
public StringLiteral[] nonNLSStrings = null;
- public boolean checkNonExternalizedStringLiterals = true;
+ public boolean checkNonExternalizedStringLiterals = false;
public boolean wasNonExternalizedStringLiteral = false;
/*static*/ {
@@ -154,18 +164,130 @@
public static final int SquareBracket = 1;
public static final int CurlyBracket = 2;
public static final int BracketKinds = 3;
+
public Scanner() {
- this(false, false);
+ this(false /*comment*/, false /*whitespace*/, false /*nls*/, false /*assert*/, null/*taskTag*/, null/*taskPriorities*/);
}
-public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace) {
- this(tokenizeComments, tokenizeWhiteSpace, false);
+public Scanner(
+ boolean tokenizeComments,
+ boolean tokenizeWhiteSpace,
+ boolean checkNonExternalizedStringLiterals,
+ boolean assertMode,
+ char[][] taskTags,
+ char[][] taskPriorities) {
+
+ this.eofPosition = Integer.MAX_VALUE;
+ this.tokenizeComments = tokenizeComments;
+ this.tokenizeWhiteSpace = tokenizeWhiteSpace;
+ this.checkNonExternalizedStringLiterals = checkNonExternalizedStringLiterals;
+ this.assertMode = assertMode;
+ this.taskTags = taskTags;
+ this.taskPriorities = taskPriorities;
}
+
+
public final boolean atEnd() {
// This code is not relevant if source is
// Only a part of the real stream input
return source.length == currentPosition;
}
+
+private void checkNonExternalizeString() throws InvalidInputException {
+ if (currentLine == null)
+ return;
+ parseTags(currentLine);
+}
+
+// chech presence of task: tags
+public void checkTaskTag(int commentStart, int commentEnd) {
+
+ // only look for newer task: tags
+ if (this.foundTaskCount > 0 && this.foundTaskPositions[this.foundTaskCount-1][0] >= commentStart) {
+ return;
+ }
+ int foundTaskIndex = this.foundTaskCount;
+ nextChar: for (int i = commentStart; i < commentEnd && i < this.eofPosition; i++) {
+
+ int nextPos = -1;
+ char[] tag = null;
+ char[] priority = null;
+
+ // check for tag occurrence
+ nextTag: for (int itag = 0; itag < this.taskTags.length; itag++){
+ tag = this.taskTags[itag];
+ priority =
+ this.taskPriorities != null && itag < this.taskPriorities.length ?
+ this.taskPriorities[itag] :
+ null;
+ int tagLength = tag.length;
+ for (int t = 0; t < tagLength; t++){
+ if (this.source[i+t] != tag[t]) continue nextTag;
+ }
+ nextPos = i + tagLength;
+
+ if (this.foundTaskTags == null){
+ this.foundTaskTags = new char[5][];
+ this.foundTaskMessages = new char[5][];
+ this.foundTaskPriorities = new char[5][];
+ this.foundTaskPositions = new int[5][];
+ } else if (this.foundTaskCount == this.foundTaskTags.length) {
+ System.arraycopy(this.foundTaskTags, 0, this.foundTaskTags = new char[this.foundTaskCount*2][], 0, this.foundTaskCount);
+ System.arraycopy(this.foundTaskMessages, 0, this.foundTaskMessages = new char[this.foundTaskCount*2][], 0, this.foundTaskCount);
+ System.arraycopy(this.foundTaskPriorities, 0, this.foundTaskPriorities = new char[this.foundTaskCount*2][], 0, this.foundTaskCount);
+ System.arraycopy(this.foundTaskPositions, 0, this.foundTaskPositions = new int[this.foundTaskCount*2][], 0, this.foundTaskCount);
+ }
+ this.foundTaskTags[this.foundTaskCount] = tag;
+ this.foundTaskPriorities[this.foundTaskCount] = priority;
+ this.foundTaskPositions[this.foundTaskCount] = new int[]{ i, -1 };
+ this.foundTaskCount++;
+
+ i = nextPos;
+ }
+ }
+
+ for (int i = foundTaskIndex; i < this.foundTaskCount; i++) {
+ // retrieve message start and end positions
+ int msgStart = this.foundTaskPositions[i][0] + this.foundTaskTags[i].length;
+ int end;
+ char c;
+ int max_value = i + 1 < this.foundTaskCount ? this.foundTaskPositions[i + 1][0] - 1 : Integer.MAX_VALUE;
+
+ end = -1;
+ for (int j = msgStart; j < commentEnd; j++){
+ if ((c = this.source[j]) == '\n' || c == '\r'){
+ end = j - 1;
+ break;
+ }
+ }
+ end = end < max_value ? end : max_value;
+
+ if (end < 0){
+ for (int j = commentEnd-1; j >= msgStart; j--){
+ if ((c = this.source[j]) == '*') {
+ end = j-1;
+ break;
+ }
+ }
+ if (end < 0) end = commentEnd-1;
+ }
+
+ // trim the message
+ while (CharOperation.isWhitespace(source[end]) && msgStart <= end) end--;
+ while (CharOperation.isWhitespace(source[msgStart]) && msgStart <= end) msgStart++;
+
+ // update the end position of the task
+ this.foundTaskPositions[i][1] = end;
+
+ // get the message source
+ final int messageLength = end-msgStart+1;
+ char[] message = new char[messageLength];
+
+ System.arraycopy(source, msgStart, message, 0, messageLength);
+ this.foundTaskMessages[i] = message;
+ }
+}
+
public char[] getCurrentIdentifierSource() {
//return the token REAL source (aka unicodes are precomputed)
@@ -246,6 +368,14 @@
}
return result;
}
+
+public final char[] getRawTokenSource() {
+ int length = this.currentPosition - this.startPosition;
+ char[] tokenSource = new char[length];
+ System.arraycopy(source, this.startPosition, tokenSource, 0, length);
+ return tokenSource;
+}
+
public int getCurrentTokenStartPosition(){
return this.startPosition;
}
@@ -266,6 +396,15 @@
if (lineNumber == lineEnds.length - 1) return eofPosition;
return lineEnds[lineNumber-1]; // next line start one character behind the lineEnd of the previous line
}
+
+public final int[] getLineEnds() {
+ //return a bounded copy of this.lineEnds
+
+ int[] copy;
+ System.arraycopy(lineEnds, 0, copy = new int[linePtr + 1], 0, linePtr + 1);
+ return copy;
+}
+
/**
* Search the source position corresponding to the beginning of a given line number
*
@@ -651,20 +790,37 @@
diet = false;
return currentPosition > source.length ? TokenNameEOF : TokenNameRBRACE;
}
+ int whiteStart = 0;
try {
while (true) { //loop for jumping over comments
withoutUnicodePtr = 0;
//start with a new token (even comment written with unicode )
// ---------Consume white space and handles startPosition---------
- int whiteStart = currentPosition;
- boolean isWhiteSpace;
+ whiteStart = currentPosition;
+ boolean isWhiteSpace, hasWhiteSpaces = false;
+ int offset = 0;
do {
startPosition = currentPosition;
- if (((currentCharacter = source[currentPosition++]) == '\\')
- && (source[currentPosition] == 'u')) {
+ boolean checkIfUnicode = false;
+ try {
+ checkIfUnicode = ((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u');
+ } catch(IndexOutOfBoundsException e) {
+ if (tokenizeWhiteSpace && (whiteStart != currentPosition - 1)) {
+ // reposition scanner in case we are interested by spaces as tokens
+ currentPosition--;
+ startPosition = whiteStart;
+ return TokenNameWHITESPACE;
+ }
+ if (currentPosition > eofPosition)
+ return TokenNameEOF;
+ }
+ if (checkIfUnicode) {
isWhiteSpace = jumpOverUnicodeWhiteSpace();
+ offset = 6;
} else {
+ offset = 1;
if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
checkNonExternalizeString();
if (recordLineSeparator) {
@@ -674,12 +830,15 @@
}
}
isWhiteSpace =
- (currentCharacter == ' ') || Character.isWhitespace(currentCharacter);
+ (currentCharacter == ' ') || CharOperation.isWhitespace(currentCharacter);
+ }
+ if (isWhiteSpace) {
+ hasWhiteSpaces = true;
}
} while (isWhiteSpace);
- if (tokenizeWhiteSpace && (whiteStart != currentPosition - 1)) {
+ if (tokenizeWhiteSpace && hasWhiteSpaces) {
// reposition scanner in case we are interested by spaces as tokens
- currentPosition--;
+ currentPosition-=offset;
startPosition = whiteStart;
return TokenNameWHITESPACE;
}
@@ -840,8 +999,16 @@
scanEscapeCharacter();
else { // consume next character
unicodeAsBackSlash = false;
- if (((currentCharacter = source[currentPosition++]) == '\\')
- && (source[currentPosition] == 'u')) {
+ boolean checkIfUnicode = false;
+ try {
+ checkIfUnicode = ((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u');
+ } catch(IndexOutOfBoundsException e) {
+ if (currentPosition > eofPosition)
+ return TokenNameEOF;
+ throw new InvalidInputException(INVALID_CHARACTER_CONSTANT);
+ }
+ if (checkIfUnicode) {
getNextUnicodeChar();
} else {
if (withoutUnicodePtr != 0) {
@@ -948,8 +1115,7 @@
}
if (checkNonExternalizedStringLiterals){ // check for presence of NLS tags //$NON-NLS-?$ where ? is an int.
if (currentLine == null) {
- currentLine= new NLSLine();
- lines.add(currentLine);
+ currentLine = new NLSLine();
}
currentLine.add(
new StringLiteral(
@@ -962,7 +1128,6 @@
{
int test;
if ((test = getNextChar('/', '*')) == 0) { //line comment
- int endPositionForLineComment = 0;
try { //get the next char
if (((currentCharacter = source[currentPosition++]) == '\\')
&& (source[currentPosition] == 'u')) {
@@ -1023,12 +1188,46 @@
currentPosition++;
} //jump over the \\
}
- if (isUnicode) {
- endPositionForLineComment = currentPosition - 6;
- } else {
- endPositionForLineComment = currentPosition - 1;
- }
+ /*
+ * We need to completely consume the line break
+ */
+ if (currentCharacter == '\r'
+ && source.length > currentPosition) {
+ if (source[currentPosition] == '\n') {
+ currentPosition++;
+ currentCharacter = '\n';
+ } else if ((source[currentPosition] == '\\')
+ && (source[currentPosition + 1] == 'u')) {
+ isUnicode = true;
+ char unicodeChar;
+ int index = currentPosition + 1;
+ index++;
+ while (source[index] == 'u') {
+ index++;
+ }
+ //-------------unicode traitement ------------
+ int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
+ if ((c1 = Character.getNumericValue(source[index++])) > 15
+ || c1 < 0
+ || (c2 = Character.getNumericValue(source[index++])) > 15
+ || c2 < 0
+ || (c3 = Character.getNumericValue(source[index++])) > 15
+ || c3 < 0
+ || (c4 = Character.getNumericValue(source[index++])) > 15
+ || c4 < 0) {
+ currentPosition = index;
+ throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
+ } else {
+ unicodeChar = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ if (unicodeChar == '\n') {
+ currentPosition = index;
+ currentCharacter = '\n';
+ }
+ }
+ }
recordComment(false);
+ if (this.taskTags != null) checkTaskTag(this.startPosition, this.currentPosition);
if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
checkNonExternalizeString();
if (recordLineSeparator) {
@@ -1042,65 +1241,71 @@
}
}
if (tokenizeComments) {
- if (!isUnicode) {
- currentPosition = endPositionForLineComment; // reset one character behind
- }
return TokenNameCOMMENT_LINE;
}
- } catch (IndexOutOfBoundsException e) { //an eof will them be generated
- if (tokenizeComments) {
- currentPosition--; // reset one character behind
- return TokenNameCOMMENT_LINE;
- }
+ } catch (IndexOutOfBoundsException e) {
+ recordComment(false);
+ if (this.taskTags != null) checkTaskTag(this.startPosition, this.currentPosition-1);
+ if (tokenizeComments) {
+ this.currentPosition--; // reset one character behind
+ return TokenNameCOMMENT_LINE;
+ }
}
break;
}
if (test > 0) { //traditional and annotation comment
- boolean isJavadoc = false, star = false;
- // consume next character
- unicodeAsBackSlash = false;
- if (((currentCharacter = source[currentPosition++]) == '\\')
- && (source[currentPosition] == 'u')) {
- getNextUnicodeChar();
- } else {
- if (withoutUnicodePtr != 0) {
- withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
- }
- }
-
- if (currentCharacter == '*') {
- isJavadoc = true;
- star = true;
- }
- if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
- checkNonExternalizeString();
- if (recordLineSeparator) {
- pushLineSeparator();
+ try { //get the next char
+ boolean isJavadoc = false, star = false;
+ boolean isUnicode = false;
+ // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ isUnicode = true;
} else {
- currentLine = null;
+ isUnicode = false;
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
}
- }
- try { //get the next char
+
+ if (currentCharacter == '*') {
+ isJavadoc = true;
+ star = true;
+ }
+ if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+ checkNonExternalizeString();
+ if (recordLineSeparator) {
+ if (!isUnicode) {
+ pushLineSeparator();
+ }
+ } else {
+ currentLine = null;
+ }
+ }
+ isUnicode = false;
if (((currentCharacter = source[currentPosition++]) == '\\')
&& (source[currentPosition] == 'u')) {
//-------------unicode traitement ------------
getNextUnicodeChar();
+ isUnicode = true;
+ } else {
+ isUnicode = false;
}
//handle the \\u case manually into comment
if (currentCharacter == '\\') {
if (source[currentPosition] == '\\')
currentPosition++; //jump over the \\
}
- // empty comment is not a javadoc /**/
- if (currentCharacter == '/') {
- isJavadoc = false;
- }
//loop until end of comment */
while ((currentCharacter != '/') || (!star)) {
if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
checkNonExternalizeString();
if (recordLineSeparator) {
- pushLineSeparator();
+ if (!isUnicode) {
+ pushLineSeparator();
+ }
} else {
currentLine = null;
}
@@ -1111,6 +1316,9 @@
&& (source[currentPosition] == 'u')) {
//-------------unicode traitement ------------
getNextUnicodeChar();
+ isUnicode = true;
+ } else {
+ isUnicode = false;
}
//handle the \\u case manually into comment
if (currentCharacter == '\\') {
@@ -1119,6 +1327,7 @@
} //jump over the \\
}
recordComment(isJavadoc);
+ if (this.taskTags != null) checkTaskTag(this.startPosition, this.currentPosition);
if (tokenizeComments) {
if (isJavadoc)
return TokenNameCOMMENT_JAVADOC;
@@ -1149,6 +1358,12 @@
}
} //-----------------end switch while try--------------------
catch (IndexOutOfBoundsException e) {
+ if (tokenizeWhiteSpace && (whiteStart != currentPosition - 1)) {
+ // reposition scanner in case we are interested by spaces as tokens
+ currentPosition--;
+ startPosition = whiteStart;
+ return TokenNameWHITESPACE;
+ }
}
return TokenNameEOF;
}
@@ -1196,6 +1411,11 @@
}
unicodeAsBackSlash = currentCharacter == '\\';
}
+
+public char[] getSource(){
+ return this.source;
+}
+
/* Tokenize a method body, assuming that curly brackets are properly balanced.
*/
public final void jumpOverMethodBody() {
@@ -1215,7 +1435,7 @@
if (recordLineSeparator
&& ((currentCharacter == '\r') || (currentCharacter == '\n')))
pushLineSeparator();
- isWhiteSpace = Character.isWhitespace(currentCharacter);
+ isWhiteSpace = CharOperation.isWhitespace(currentCharacter);
}
} while (isWhiteSpace);
@@ -1303,12 +1523,14 @@
case '/' :
{
int test;
+ boolean isUnicode;
if ((test = getNextChar('/', '*')) == 0) { //line comment
try {
//get the next char
if (((currentCharacter = source[currentPosition++]) == '\\')
&& (source[currentPosition] == 'u')) {
//-------------unicode traitement ------------
+ isUnicode = true;
int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
currentPosition++;
while (source[currentPosition] == 'u') {
@@ -1327,6 +1549,8 @@
else {
currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
}
+ } else {
+ isUnicode = false;
}
while (currentCharacter != '\r' && currentCharacter != '\n') {
@@ -1336,6 +1560,7 @@
//-------------unicode traitement ------------
int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
currentPosition++;
+ isUnicode = true;
while (source[currentPosition] == 'u') {
currentPosition++;
}
@@ -1352,23 +1577,31 @@
else {
currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
}
+ } else {
+ isUnicode = false;
}
}
if (recordLineSeparator
- && ((currentCharacter == '\r') || (currentCharacter == '\n')))
- pushLineSeparator();
+ && ((currentCharacter == '\r') || (currentCharacter == '\n'))) {
+ if (!isUnicode) {
+ pushLineSeparator();
+ }
+ }
} catch (IndexOutOfBoundsException e) {
} //an eof will them be generated
break;
}
if (test > 0) { //traditional and annotation comment
+ isUnicode = false;
boolean star = false;
try { // consume next character
unicodeAsBackSlash = false;
if (((currentCharacter = source[currentPosition++]) == '\\')
&& (source[currentPosition] == 'u')) {
getNextUnicodeChar();
+ isUnicode = true;
} else {
+ isUnicode = false;
if (withoutUnicodePtr != 0) {
withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
}
@@ -1379,12 +1612,16 @@
star = true;
}
if (recordLineSeparator
- && ((currentCharacter == '\r') || (currentCharacter == '\n')))
- pushLineSeparator();
+ && ((currentCharacter == '\r') || (currentCharacter == '\n'))) {
+ if (!isUnicode) {
+ pushLineSeparator();
+ }
+ }
try { //get the next char
if (((currentCharacter = source[currentPosition++]) == '\\')
&& (source[currentPosition] == 'u')) {
//-------------unicode traitement ------------
+ isUnicode = true;
int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
currentPosition++;
while (source[currentPosition] == 'u') {
@@ -1403,17 +1640,23 @@
else {
currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
}
+ } else {
+ isUnicode = false;
}
//loop until end of comment */
while ((currentCharacter != '/') || (!star)) {
if (recordLineSeparator
- && ((currentCharacter == '\r') || (currentCharacter == '\n')))
- pushLineSeparator();
+ && ((currentCharacter == '\r') || (currentCharacter == '\n'))) {
+ if (!isUnicode) {
+ pushLineSeparator();
+ }
+ }
star = currentCharacter == '*';
//get next char
if (((currentCharacter = source[currentPosition++]) == '\\')
&& (source[currentPosition] == 'u')) {
//-------------unicode traitement ------------
+ isUnicode = true;
int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
currentPosition++;
while (source[currentPosition] == 'u') {
@@ -1432,6 +1675,8 @@
else {
currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
}
+ } else {
+ isUnicode = false;
}
}
} catch (IndexOutOfBoundsException e) {
@@ -1491,10 +1736,7 @@
}
currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
- if (recordLineSeparator
- && ((currentCharacter == '\r') || (currentCharacter == '\n')))
- pushLineSeparator();
- if (Character.isWhitespace(currentCharacter))
+ if (CharOperation.isWhitespace(currentCharacter))
return true;
//buffer the new char which is not a white space
@@ -1505,17 +1747,7 @@
throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
}
}
-public final int[] getLineEnds() {
- //return a bounded copy of this.lineEnds
- int[] copy;
- System.arraycopy(lineEnds, 0, copy = new int[linePtr + 1], 0, linePtr + 1);
- return copy;
-}
-
-public char[] getSource(){
- return this.source;
-}
final char[] optimizedCurrentTokenSource1() {
//return always the same char[] build only once
@@ -1763,6 +1995,48 @@
newEntry6 = max;
return r;
}
+private void parseTags(NLSLine line) throws InvalidInputException {
+ String s = new String(getCurrentTokenSource());
+ int pos = s.indexOf(TAG_PREFIX);
+ int lineLength = line.size();
+ while (pos != -1) {
+ int start = pos + TAG_PREFIX_LENGTH;
+ int end = s.indexOf(TAG_POSTFIX, start);
+ if (end != -1) {
+ String index = s.substring(start, end);
+ int i = 0;
+ try {
+ i = Integer.parseInt(index) - 1; // Tags are one based not zero based.
+ } catch (NumberFormatException e) {
+ i = -1; // we don't want to consider this as a valid NLS tag
+ }
+ if (line.exists(i)) {
+ line.set(i, null);
+ }
+ }
+ pos = s.indexOf(TAG_PREFIX, start);
+ }
+
+ this.nonNLSStrings = new StringLiteral[lineLength];
+ int nonNLSCounter = 0;
+ for (Iterator iterator = line.iterator(); iterator.hasNext(); ) {
+ StringLiteral literal = (StringLiteral) iterator.next();
+ if (literal != null) {
+ this.nonNLSStrings[nonNLSCounter++] = literal;
+ }
+ }
+ if (nonNLSCounter == 0) {
+ this.nonNLSStrings = null;
+ currentLine = null;
+ return;
+ }
+ this.wasNonExternalizedStringLiteral = true;
+ if (nonNLSCounter != lineLength) {
+ System.arraycopy(this.nonNLSStrings, 0, (this.nonNLSStrings = new StringLiteral[nonNLSCounter]), 0, nonNLSCounter);
+ }
+ currentLine = null;
+}
+
public final void pushLineSeparator() throws InvalidInputException {
//see comment on isLineDelimiter(char) for the use of '\n' and '\r'
final int INCREMENT = 250;
@@ -1827,13 +2101,6 @@
}
}
public final void pushUnicodeLineSeparator() {
- // isUnicode means that the \r or \n has been read as a unicode character
-
- //see comment on isLineDelimiter(char) for the use of '\n' and '\r'
-
- final int INCREMENT = 250;
- //currentCharacter is at position currentPosition-1
-
if (this.checkNonExternalizedStringLiterals) {
// reinitialize the current line for non externalize strings purpose
currentLine = null;
@@ -1841,24 +2108,7 @@
// cr 000D
if (currentCharacter == '\r') {
- int separatorPos = currentPosition - 6;
- if ((linePtr > 0) && (lineEnds[linePtr] >= separatorPos)) return;
- //System.out.println("CR-" + separatorPos);
- try {
- lineEnds[++linePtr] = separatorPos;
- } catch (IndexOutOfBoundsException e) {
- //linePtr value is correct
- int oldLength = lineEnds.length;
- int[] old = lineEnds;
- lineEnds = new int[oldLength + INCREMENT];
- System.arraycopy(old, 0, lineEnds, 0, oldLength);
- lineEnds[linePtr] = separatorPos;
- }
- // look-ahead for merged cr+lf
if (source[currentPosition] == '\n') {
- //System.out.println("look-ahead LF-" + currentPosition);
- lineEnds[linePtr] = currentPosition;
- currentPosition++;
wasAcr = false;
} else {
wasAcr = true;
@@ -1866,24 +2116,6 @@
} else {
// lf 000A
if (currentCharacter == '\n') { //must merge eventual cr followed by lf
- if (wasAcr && (lineEnds[linePtr] == (currentPosition - 7))) {
- //System.out.println("merge LF-" + (currentPosition - 1));
- lineEnds[linePtr] = currentPosition - 6;
- } else {
- int separatorPos = currentPosition - 6;
- if ((linePtr > 0) && (lineEnds[linePtr] >= separatorPos)) return;
- // System.out.println("LF-" + separatorPos);
- try {
- lineEnds[++linePtr] = separatorPos;
- } catch (IndexOutOfBoundsException e) {
- //linePtr value is correct
- int oldLength = lineEnds.length;
- int[] old = lineEnds;
- lineEnds = new int[oldLength + INCREMENT];
- System.arraycopy(old, 0, lineEnds, 0, oldLength);
- lineEnds[linePtr] = separatorPos;
- }
- }
wasAcr = false;
}
}
@@ -1892,22 +2124,23 @@
// a new annotation comment is recorded
try {
- commentStops[++commentPtr] = isJavadoc ? currentPosition : -currentPosition;
+ this.commentStops[++this.commentPtr] = isJavadoc ? this.currentPosition : -this.currentPosition;
} catch (IndexOutOfBoundsException e) {
- int oldStackLength = commentStops.length;
- int[] oldStack = commentStops;
- commentStops = new int[oldStackLength + 30];
- System.arraycopy(oldStack, 0, commentStops, 0, oldStackLength);
- commentStops[commentPtr] = isJavadoc ? currentPosition : -currentPosition;
+ int oldStackLength = this.commentStops.length;
+ int[] oldStack = this.commentStops;
+ this.commentStops = new int[oldStackLength + 30];
+ System.arraycopy(oldStack, 0, this.commentStops, 0, oldStackLength);
+ this.commentStops[this.commentPtr] = isJavadoc ? this.currentPosition : -this.currentPosition;
//grows the positions buffers too
- int[] old = commentStarts;
- commentStarts = new int[oldStackLength + 30];
- System.arraycopy(old, 0, commentStarts, 0, oldStackLength);
+ int[] old = this.commentStarts;
+ this.commentStarts = new int[oldStackLength + 30];
+ System.arraycopy(old, 0, this.commentStarts, 0, oldStackLength);
}
//the buffer is of a correct size here
- commentStarts[commentPtr] = startPosition;
+ this.commentStarts[this.commentPtr] = this.startPosition;
}
+
public void resetTo(int begin, int end) {
//reset the scanner to a given position where it may rescan again
@@ -1915,6 +2148,8 @@
initialPosition = startPosition = currentPosition = begin;
eofPosition = end < Integer.MAX_VALUE ? end + 1 : end;
commentPtr = -1; // reset comment stack
+ foundTaskCount = 0;
+
}
public final void scanEscapeCharacter() throws InvalidInputException {
@@ -2004,7 +2239,7 @@
//first dispatch on the first char.
//then the length. If there are several
//keywors with the same length AND the same first char, then do another
- //disptach on the second char :-)...cool....but fast !
+ //dispatch on the second char
useAssertAsAnIndentifier = false;
while (getNextCharAsJavaIdentifierPart()) {};
@@ -2609,9 +2844,25 @@
if (getNextChar('d', 'D') >= 0) {
return TokenNameDoubleLiteral;
} else { //make the distinction between octal and float ....
- if (getNextChar('.')) { //bingo ! ....
+ boolean isInteger = true;
+ if (getNextChar('.')) {
+ isInteger = false;
while (getNextCharAsDigit()) {};
- if (getNextChar('e', 'E') >= 0) { // consume next character
+ }
+ if (getNextChar('e', 'E') >= 0) { // consume next character
+ isInteger = false;
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+
+ if ((currentCharacter == '-')
+ || (currentCharacter == '+')) { // consume next character
unicodeAsBackSlash = false;
if (((currentCharacter = source[currentPosition++]) == '\\')
&& (source[currentPosition] == 'u')) {
@@ -2621,30 +2872,16 @@
withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
}
}
-
- if ((currentCharacter == '-')
- || (currentCharacter == '+')) { // consume next character
- unicodeAsBackSlash = false;
- if (((currentCharacter = source[currentPosition++]) == '\\')
- && (source[currentPosition] == 'u')) {
- getNextUnicodeChar();
- } else {
- if (withoutUnicodePtr != 0) {
- withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
- }
- }
- }
- if (!Character.isDigit(currentCharacter))
- throw new InvalidInputException(INVALID_FLOAT);
- while (getNextCharAsDigit()) {};
}
- if (getNextChar('f', 'F') >= 0)
- return TokenNameFloatingPointLiteral;
- getNextChar('d', 'D'); //jump over potential d or D
- return TokenNameDoubleLiteral;
- } else {
- return TokenNameIntegerLiteral;
+ if (!Character.isDigit(currentCharacter))
+ throw new InvalidInputException(INVALID_FLOAT);
+ while (getNextCharAsDigit()) {};
}
+ if (getNextChar('f', 'F') >= 0)
+ return TokenNameFloatingPointLiteral;
+ if (getNextChar('d', 'D') >= 0 || !isInteger)
+ return TokenNameDoubleLiteral;
+ return TokenNameIntegerLiteral;
}
} else {
/* carry on */
@@ -2734,11 +2971,12 @@
//the source-buffer is set to sourceString
if (source == null) {
- this.source = new char[0];
+ this.source = CharOperation.NO_CHAR;
} else {
this.source = source;
}
startPosition = -1;
+ eofPosition = source.length;
initialPosition = currentPosition = 0;
containsAssertKeyword = false;
withoutUnicodeBuffer = new char[this.source.length];
@@ -2765,7 +3003,7 @@
0,
middleLength);
} else {
- middle = new char[0];
+ middle = CharOperation.NO_CHAR;
}
char end[] = new char[source.length - (currentPosition - 1)];
@@ -2994,62 +3232,4 @@
return "not-a-token"; //$NON-NLS-1$
}
}
-
-public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals) {
- this(tokenizeComments, tokenizeWhiteSpace, checkNonExternalizedStringLiterals, false);
-}
-
-public Scanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean checkNonExternalizedStringLiterals, boolean assertMode) {
- this.eofPosition = Integer.MAX_VALUE;
- this.tokenizeComments = tokenizeComments;
- this.tokenizeWhiteSpace = tokenizeWhiteSpace;
- this.checkNonExternalizedStringLiterals = checkNonExternalizedStringLiterals;
- this.assertMode = assertMode;
-}
-
-private void checkNonExternalizeString() throws InvalidInputException {
- if (currentLine == null)
- return;
- parseTags(currentLine);
-}
-
-private void parseTags(NLSLine line) throws InvalidInputException {
- String s = new String(getCurrentTokenSource());
- int pos = s.indexOf(TAG_PREFIX);
- int lineLength = line.size();
- while (pos != -1) {
- int start = pos + TAG_PREFIX_LENGTH;
- int end = s.indexOf(TAG_POSTFIX, start);
- String index = s.substring(start, end);
- int i = 0;
- try {
- i = Integer.parseInt(index) - 1; // Tags are one based not zero based.
- } catch (NumberFormatException e) {
- i = -1; // we don't want to consider this as a valid NLS tag
- }
- if (line.exists(i)) {
- line.set(i, null);
- }
- pos = s.indexOf(TAG_PREFIX, start);
- }
-
- this.nonNLSStrings = new StringLiteral[lineLength];
- int nonNLSCounter = 0;
- for (Iterator iterator = line.iterator(); iterator.hasNext(); ) {
- StringLiteral literal = (StringLiteral) iterator.next();
- if (literal != null) {
- this.nonNLSStrings[nonNLSCounter++] = literal;
- }
- }
- if (nonNLSCounter == 0) {
- this.nonNLSStrings = null;
- currentLine = null;
- return;
- }
- this.wasNonExternalizedStringLiteral = true;
- if (nonNLSCounter != lineLength) {
- System.arraycopy(this.nonNLSStrings, 0, (this.nonNLSStrings = new StringLiteral[nonNLSCounter]), 0, nonNLSCounter);
- }
- currentLine = null;
-}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceConstructorDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceConstructorDeclaration.java
index 87e35c8..f228186 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceConstructorDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceConstructorDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceFieldDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceFieldDeclaration.java
index 9fdc995..fe97ea5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceFieldDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceFieldDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
import org.eclipse.jdt.internal.compiler.ast.Expression;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceMethodDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceMethodDeclaration.java
index 977b5e9..933f52a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceMethodDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceMethodDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java
index df8d411..a45c709 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
/**
@@ -23,6 +23,7 @@
*
*/
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
@@ -41,31 +42,59 @@
import org.eclipse.jdt.internal.compiler.env.ISourceField;
import org.eclipse.jdt.internal.compiler.env.ISourceMethod;
import org.eclipse.jdt.internal.compiler.env.ISourceType;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class SourceTypeConverter implements CompilerModifiers {
+
+ private boolean needFieldInitialization;
+ private CompilationUnitDeclaration unit;
+ private Parser parser;
+ private ProblemReporter problemReporter;
+
+ private SourceTypeConverter(boolean needFieldInitialization, ProblemReporter problemReporter) {
+ this.needFieldInitialization = needFieldInitialization;
+ this.problemReporter = problemReporter;
+ }
/*
* Convert a set of source element types into a parsed compilation unit declaration
* The argument types are then all grouped in the same unit. The argument types must
* at least contain one type.
- * Can optionally ignore fields & methods or member types
+ * Can optionally ignore fields & methods or member types or field initialization
*/
public static CompilationUnitDeclaration buildCompilationUnit(
ISourceType[] sourceTypes,
boolean needFieldsAndMethods,
boolean needMemberTypes,
+ boolean needFieldInitialization,
ProblemReporter problemReporter,
CompilationResult compilationResult) {
+
+ return
+ new SourceTypeConverter(needFieldInitialization, problemReporter).convert(
+ sourceTypes,
+ needFieldsAndMethods,
+ needMemberTypes,
+ compilationResult);
+ }
+ /*
+ * Convert a set of source element types into a parsed compilation unit declaration
+ * The argument types are then all grouped in the same unit. The argument types must
+ * at least contain one type.
+ */
+ private CompilationUnitDeclaration convert(
+ ISourceType[] sourceTypes,
+ boolean needFieldsAndMethods,
+ boolean needMemberTypes,
+ CompilationResult compilationResult) {
ISourceType sourceType = sourceTypes[0];
if (sourceType.getName() == null)
return null; // do a basic test that the sourceType is valid
- CompilationUnitDeclaration compilationUnit =
- new CompilationUnitDeclaration(problemReporter, compilationResult, 0);
+ this.unit = new CompilationUnitDeclaration(problemReporter, compilationResult, 0);
// not filled at this point
/* only positions available */
@@ -76,27 +105,27 @@
if (sourceType.getPackageName() != null
&& sourceType.getPackageName().length > 0)
// if its null then it is defined in the default package
- compilationUnit.currentPackage =
+ this.unit.currentPackage =
createImportReference(sourceType.getPackageName(), start, end);
char[][] importNames = sourceType.getImports();
int importCount = importNames == null ? 0 : importNames.length;
- compilationUnit.imports = new ImportReference[importCount];
+ this.unit.imports = new ImportReference[importCount];
for (int i = 0; i < importCount; i++)
- compilationUnit.imports[i] = createImportReference(importNames[i], start, end);
+ this.unit.imports[i] = createImportReference(importNames[i], start, end);
/* convert type(s) */
int typeCount = sourceTypes.length;
- compilationUnit.types = new TypeDeclaration[typeCount];
+ this.unit.types = new TypeDeclaration[typeCount];
for (int i = 0; i < typeCount; i++) {
- compilationUnit.types[i] =
+ this.unit.types[i] =
convert(sourceTypes[i], needFieldsAndMethods, needMemberTypes, compilationResult);
}
- return compilationUnit;
+ return this.unit;
}
/*
* Convert a field source element into a parsed field declaration
*/
- private static FieldDeclaration convert(ISourceField sourceField) {
+ private FieldDeclaration convert(ISourceField sourceField, TypeDeclaration type) {
FieldDeclaration field = new FieldDeclaration();
@@ -111,20 +140,28 @@
field.declarationSourceEnd = sourceField.getDeclarationSourceEnd();
field.modifiers = sourceField.getModifiers();
- /* conversion of field constant: if not present, then cannot generate binary against
- converted parse nodes */
- /*
- if (field.modifiers & AccFinal){
+ if (this.needFieldInitialization) {
+ /* conversion of field constant */
char[] initializationSource = sourceField.getInitializationSource();
+ if (initializationSource != null) {
+ if (this.parser == null) {
+ this.parser =
+ new Parser(
+ this.problemReporter,
+ true,
+ this.problemReporter.options.sourceLevel >= CompilerOptions.JDK1_4);
+ }
+ this.parser.parse(field, type, this.unit, initializationSource);
+ }
}
- */
+
return field;
}
/*
* Convert a method source element into a parsed method/constructor declaration
*/
- private static AbstractMethodDeclaration convert(ISourceMethod sourceMethod, CompilationResult compilationResult) {
+ private AbstractMethodDeclaration convert(ISourceMethod sourceMethod, CompilationResult compilationResult) {
AbstractMethodDeclaration method;
@@ -182,7 +219,7 @@
*
* Can optionally ignore fields & methods
*/
- private static TypeDeclaration convert(
+ private TypeDeclaration convert(
ISourceType sourceType,
boolean needFieldsAndMethods,
boolean needMemberTypes,
@@ -234,7 +271,7 @@
int sourceFieldCount = sourceFields == null ? 0 : sourceFields.length;
type.fields = new FieldDeclaration[sourceFieldCount];
for (int i = 0; i < sourceFieldCount; i++) {
- type.fields[i] = convert(sourceFields[i]);
+ type.fields[i] = convert(sourceFields[i], type);
}
/* convert methods - need to add default constructor if necessary */
@@ -243,12 +280,15 @@
/* source type has a constructor ? */
/* by default, we assume that one is needed. */
- int neededCount = 1;
- for (int i = 0; i < sourceMethodCount; i++) {
- if (sourceMethods[i].isConstructor()) {
- neededCount = 0;
- // Does not need the extra constructor since one constructor already exists.
- break;
+ int neededCount = 0;
+ if (!type.isInterface()) {
+ neededCount = 1;
+ for (int i = 0; i < sourceMethodCount; i++) {
+ if (sourceMethods[i].isConstructor()) {
+ neededCount = 0;
+ // Does not need the extra constructor since one constructor already exists.
+ break;
+ }
}
}
type.methods = new AbstractMethodDeclaration[sourceMethodCount + neededCount];
@@ -270,7 +310,7 @@
/*
* Build an import reference from an import name, e.g. java.lang.*
*/
- private static ImportReference createImportReference(
+ private ImportReference createImportReference(
char[] importName,
int start,
int end) {
@@ -293,7 +333,7 @@
positions[i] = position;
}
return new ImportReference(
- CharOperation.splitOn('.', importName, 0, max - (onDemand ? 3 : 1)),
+ CharOperation.splitOn('.', importName, 0, max - (onDemand ? 2 : 0)),
positions,
onDemand);
}
@@ -301,7 +341,7 @@
/*
* Build a type reference from a readable name, e.g. java.lang.Object[][]
*/
- private static TypeReference createTypeReference(
+ private TypeReference createTypeReference(
char[] typeSignature,
int start,
int end) {
@@ -339,7 +379,7 @@
positions[i] = pos;
}
char[][] identifiers =
- CharOperation.splitOn('.', typeSignature, 0, dimStart - 1);
+ CharOperation.splitOn('.', typeSignature, 0, dimStart);
if (dim == 0) {
return new QualifiedTypeReference(identifiers, positions);
} else {
@@ -347,4 +387,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java
new file mode 100644
index 0000000..5591423
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/TerminalTokens.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.internal.compiler.parser;
+
+/**
+ * IMPORTANT NOTE: These constants are dedicated to the internal Scanner implementation.
+ * It is mirrored in org.eclipse.jdt.core.compiler public package where it is API.
+ * The mirror implementation is using the backward compatible ITerminalSymbols constant
+ * definitions (stable with 2.0), whereas the internal implementation uses TerminalTokens
+ * which constant values reflect the latest parser generation state.
+ */
+
+/**
+ * Maps each terminal symbol in the java-grammar into a unique integer.
+ * This integer is used to represent the terminal when computing a parsing action.
+ *
+ * Disclaimer : These constant values are generated automatically using a Java
+ * grammar, therefore their actual values are subject to change if new keywords
+ * were added to the language (i.e. 'assert' keyword in 1.4).
+ */
+public interface TerminalTokens {
+
+ // special tokens not part of grammar - not autogenerated
+ int
+ TokenNameWHITESPACE = 1000,
+ TokenNameCOMMENT_LINE = 1001,
+ TokenNameCOMMENT_BLOCK = 1002,
+ TokenNameCOMMENT_JAVADOC = 1003;
+
+ int
+ TokenNameIdentifier = 6,
+ TokenNameabstract = 99,
+ TokenNameassert = 121,
+ TokenNameboolean = 25,
+ TokenNamebreak = 122,
+ TokenNamebyte = 26,
+ TokenNamecase = 211,
+ TokenNamecatch = 225,
+ TokenNamechar = 27,
+ TokenNameclass = 166,
+ TokenNamecontinue = 123,
+ TokenNamedefault = 212,
+ TokenNamedo = 124,
+ TokenNamedouble = 28,
+ TokenNameelse = 213,
+ TokenNameextends = 243,
+ TokenNamefalse = 44,
+ TokenNamefinal = 100,
+ TokenNamefinally = 226,
+ TokenNamefloat = 29,
+ TokenNamefor = 125,
+ TokenNameif = 126,
+ TokenNameimplements = 268,
+ TokenNameimport = 191,
+ TokenNameinstanceof = 16,
+ TokenNameint = 30,
+ TokenNameinterface = 169,
+ TokenNamelong = 31,
+ TokenNamenative = 101,
+ TokenNamenew = 40,
+ TokenNamenull = 45,
+ TokenNamepackage = 214,
+ TokenNameprivate = 102,
+ TokenNameprotected = 103,
+ TokenNamepublic = 104,
+ TokenNamereturn = 127,
+ TokenNameshort = 32,
+ TokenNamestatic = 97,
+ TokenNamestrictfp = 105,
+ TokenNamesuper = 42,
+ TokenNameswitch = 128,
+ TokenNamesynchronized = 88,
+ TokenNamethis = 43,
+ TokenNamethrow = 129,
+ TokenNamethrows = 227,
+ TokenNametransient = 106,
+ TokenNametrue = 46,
+ TokenNametry = 130,
+ TokenNamevoid = 33,
+ TokenNamevolatile = 107,
+ TokenNamewhile = 120,
+ TokenNameIntegerLiteral = 47,
+ TokenNameLongLiteral = 48,
+ TokenNameFloatingPointLiteral = 49,
+ TokenNameDoubleLiteral = 50,
+ TokenNameCharacterLiteral = 51,
+ TokenNameStringLiteral = 52,
+ TokenNamePLUS_PLUS = 3,
+ TokenNameMINUS_MINUS = 4,
+ TokenNameEQUAL_EQUAL = 23,
+ TokenNameLESS_EQUAL = 17,
+ TokenNameGREATER_EQUAL = 18,
+ TokenNameNOT_EQUAL = 24,
+ TokenNameLEFT_SHIFT = 13,
+ TokenNameRIGHT_SHIFT = 11,
+ TokenNameUNSIGNED_RIGHT_SHIFT = 12,
+ TokenNamePLUS_EQUAL = 170,
+ TokenNameMINUS_EQUAL = 171,
+ TokenNameMULTIPLY_EQUAL = 172,
+ TokenNameDIVIDE_EQUAL = 173,
+ TokenNameAND_EQUAL = 174,
+ TokenNameOR_EQUAL = 175,
+ TokenNameXOR_EQUAL = 176,
+ TokenNameREMAINDER_EQUAL = 177,
+ TokenNameLEFT_SHIFT_EQUAL = 178,
+ TokenNameRIGHT_SHIFT_EQUAL = 179,
+ TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL = 180,
+ TokenNameOR_OR = 73,
+ TokenNameAND_AND = 72,
+ TokenNamePLUS = 1,
+ TokenNameMINUS = 2,
+ TokenNameNOT = 75,
+ TokenNameREMAINDER = 8,
+ TokenNameXOR = 68,
+ TokenNameAND = 38,
+ TokenNameMULTIPLY = 7,
+ TokenNameOR = 71,
+ TokenNameTWIDDLE = 76,
+ TokenNameDIVIDE = 9,
+ TokenNameGREATER = 19,
+ TokenNameLESS = 20,
+ TokenNameLPAREN = 10,
+ TokenNameRPAREN = 81,
+ TokenNameLBRACE = 111,
+ TokenNameRBRACE = 86,
+ TokenNameLBRACKET = 14,
+ TokenNameRBRACKET = 119,
+ TokenNameSEMICOLON = 41,
+ TokenNameQUESTION = 74,
+ TokenNameCOLON = 110,
+ TokenNameCOMMA = 82,
+ TokenNameDOT = 5,
+ TokenNameEQUAL = 167,
+ TokenNameEOF = 114,
+ TokenNameERROR = 308;
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
index 05d68bc..6edc226 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser1.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
index d666990..26e416e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser2.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
index 058dd09..7b3e30a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser3.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
index c50dace..45d144e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser4.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
index bfe7cb4..bb9b124 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/parser5.rsc
Binary files differ
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilation.java
index 8d08665..799840a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
@@ -19,32 +19,41 @@
* should only be thrown from within problem handlers.
*/
public class AbortCompilation extends RuntimeException {
+
public CompilationResult compilationResult;
public Throwable exception;
-
public int problemId;
- public String[] problemArguments;
-
+ public String[] problemArguments, messageArguments;
/* special fields used to abort silently (e.g. when cancelling build process) */
public boolean isSilent;
public RuntimeException silentException;
-public AbortCompilation() {
- this((CompilationResult)null);
-}
-public AbortCompilation(int problemId, String[] problemArguments) {
- this.problemId = problemId;
- this.problemArguments = problemArguments;
-}
-public AbortCompilation(CompilationResult compilationResult) {
- this(compilationResult, null);
-}
-public AbortCompilation(CompilationResult compilationResult, Throwable exception) {
- this.compilationResult = compilationResult;
- this.exception = exception;
-}
-public AbortCompilation(boolean isSilent, RuntimeException silentException) {
- this.isSilent = isSilent;
- this.silentException = silentException;
-}
+ public AbortCompilation() {
+
+ this((CompilationResult)null);
+ }
+
+ public AbortCompilation(int problemId, String[] problemArguments, String[] messageArguments) {
+
+ this.problemId = problemId;
+ this.problemArguments = problemArguments;
+ this.messageArguments = messageArguments;
+ }
+
+ public AbortCompilation(CompilationResult compilationResult) {
+
+ this(compilationResult, null);
+ }
+
+ public AbortCompilation(CompilationResult compilationResult, Throwable exception) {
+
+ this.compilationResult = compilationResult;
+ this.exception = exception;
+ }
+
+ public AbortCompilation(boolean isSilent, RuntimeException silentException) {
+
+ this.isSilent = isSilent;
+ this.silentException = silentException;
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java
index 85bbb39..abd04de 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortCompilationUnit.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortMethod.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortMethod.java
index cfd24e2..f56dd94 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortMethod.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortMethod.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortType.java
index 8c92953..f0aa4ec 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/AbortType.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
index 60a2cde..635428f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblem.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
import org.eclipse.jdt.core.compiler.IProblem;
@@ -246,4 +246,4 @@
}
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java
index 47053b9..87a3c0e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/DefaultProblemFactory.java
@@ -1,22 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.IProblemFactory;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class DefaultProblemFactory implements IProblemFactory {
@@ -46,7 +46,8 @@
* <ul>
* <li>originatingFileName the name of the file name from which the problem is originated
* <li>problemId the problem id
- * <li>arguments the arguments needed to set the error message
+ * <li>problemArguments the fully qualified arguments recorded inside the problem
+ * <li>messageArguments the arguments needed to set the error message (shorter names than problemArguments ones)
* <li>severity the severity of the problem
* <li>startPosition the starting position of the problem
* <li>endPosition the end position of the problem
@@ -64,7 +65,8 @@
public IProblem createProblem(
char[] originatingFileName,
int problemId,
- String[] arguments,
+ String[] problemArguments,
+ String[] messageArguments,
int severity,
int startPosition,
int endPosition,
@@ -72,9 +74,9 @@
return new DefaultProblem(
originatingFileName,
- this.getLocalizedMessage(problemId, arguments),
+ this.getLocalizedMessage(problemId, messageArguments),
problemId,
- arguments,
+ problemArguments,
severity,
startPosition,
endPosition,
@@ -93,7 +95,7 @@
messageTemplates[(id & IProblem.IgnoreCategoriesMask)];
if (message == null) {
return "Unable to retrieve the error message for problem id: " //$NON-NLS-1$
- + id
+ + (id & IProblem.IgnoreCategoriesMask)
+ ". Check compiler resources."; //$NON-NLS-1$
}
@@ -142,7 +144,14 @@
* to the current Locale.
*/
public static String[] loadMessageTemplates(Locale loc) {
- ResourceBundle bundle = ResourceBundle.getBundle("org.eclipse.jdt.internal.compiler.problem.messages", loc); //$NON-NLS-1$
+ ResourceBundle bundle = null;
+ String bundleName = "org.eclipse.jdt.internal.compiler.problem.messages"; //$NON-NLS-1$
+ try {
+ bundle = ResourceBundle.getBundle(bundleName, loc);
+ } catch(MissingResourceException e) {
+ System.out.println("Missing resource : " + bundleName.replace('.', '/') + ".properties for locale " + loc); //$NON-NLS-1$//$NON-NLS-2$
+ throw e;
+ }
String[] templates = new String[500];
for (int i = 0, max = templates.length; i < max; i++) {
try {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
index 4ee4c13..74bda77 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
import org.eclipse.jdt.core.compiler.IProblem;
@@ -28,6 +28,8 @@
public class ProblemHandler implements ProblemSeverities {
+ public final static String[] NoArgument = new String[0];
+
final public IErrorHandlingPolicy policy;
public final IProblemFactory problemFactory;
public final CompilerOptions options;
@@ -55,6 +57,7 @@
char[] fileName,
int problemId,
String[] problemArguments,
+ String[] messageArguments,
int severity,
int problemStartPosition,
int problemEndPosition,
@@ -66,6 +69,7 @@
fileName,
problemId,
problemArguments,
+ messageArguments,
severity,
problemStartPosition,
problemEndPosition,
@@ -74,6 +78,7 @@
public void handle(
int problemId,
String[] problemArguments,
+ String[] messageArguments,
int severity,
int problemStartPosition,
int problemEndPosition,
@@ -86,7 +91,7 @@
// if no reference context, we need to abort from the current compilation process
if (referenceContext == null) {
if ((severity & Error) != 0) { // non reportable error is fatal
- throw new AbortCompilation(problemId, problemArguments);
+ throw new AbortCompilation(problemId, problemArguments, messageArguments);
} else {
return; // ignore non reportable warning
}
@@ -97,6 +102,7 @@
unitResult.getFileName(),
problemId,
problemArguments,
+ messageArguments,
severity,
problemStartPosition,
problemEndPosition,
@@ -132,6 +138,7 @@
public void handle(
int problemId,
String[] problemArguments,
+ String[] messageArguments,
int problemStartPosition,
int problemEndPosition,
ReferenceContext referenceContext,
@@ -140,6 +147,7 @@
this.handle(
problemId,
problemArguments,
+ messageArguments,
this.computeSeverity(problemId), // severity inferred using the ID
problemStartPosition,
problemEndPosition,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index ec8582c..e0bc26f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -1,24 +1,28 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
-import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
-import org.eclipse.jdt.core.compiler.InvalidInputException;
-import org.eclipse.jdt.internal.compiler.*;
+import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
+import org.eclipse.jdt.internal.compiler.IProblemFactory;
import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.*;
-import org.eclipse.jdt.internal.compiler.util.*;
-import org.eclipse.jdt.internal.compiler.impl.*;
+import org.eclipse.jdt.internal.compiler.parser.Parser;
+import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.util.Util;
public class ProblemReporter extends ProblemHandler implements ProblemReasons {
@@ -27,17 +31,21 @@
super(policy, options, problemFactory);
}
public void abortDueToInternalError(String errorMessage) {
+ String[] arguments = new String[] {errorMessage};
this.handle(
IProblem.Unclassified,
- new String[] {errorMessage},
+ arguments,
+ arguments,
Error | Abort,
0,
0);
}
public void abortDueToInternalError(String errorMessage, AstNode location) {
+ String[] arguments = new String[] {errorMessage};
this.handle(
IProblem.Unclassified,
- new String[] {errorMessage},
+ arguments,
+ arguments,
Error | Abort,
location.sourceStart,
location.sourceEnd);
@@ -47,14 +55,30 @@
this.handle(
// %1 must be abstract since it cannot override the inherited package-private abstract method %2
IProblem.AbstractMethodCannotBeOverridden,
- new String[] {new String(type.sourceName()), new String(concreteMethod.readableName())},
+ new String[] {
+ new String(type.sourceName()),
+ new String(
+ CharOperation.concat(
+ concreteMethod.declaringClass.readableName(),
+ concreteMethod.readableName(),
+ '.'))},
+ new String[] {
+ new String(type.sourceName()),
+ new String(
+ CharOperation.concat(
+ concreteMethod.declaringClass.shortReadableName(),
+ concreteMethod.shortReadableName(),
+ '.'))},
type.sourceStart(),
type.sourceEnd());
}
public void abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
+
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.AbstractMethodInAbstractClass,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
@@ -69,22 +93,31 @@
abstractMethod.declaringClass.readableName(),
abstractMethod.readableName(),
'.'))},
+ new String[] {
+ new String(
+ CharOperation.concat(
+ abstractMethod.declaringClass.shortReadableName(),
+ abstractMethod.shortReadableName(),
+ '.'))},
type.sourceStart(),
type.sourceEnd());
}
public void abstractMethodNeedingNoBody(AbstractMethodDeclaration method) {
this.handle(
IProblem.BodyForAbstractMethod,
- new String[0],
+ NoArgument,
+ NoArgument,
method.sourceStart,
method.sourceEnd,
method,
method.compilationResult());
}
public void alreadyDefinedLabel(char[] labelName, AstNode location) {
+ String[] arguments = new String[] {new String(labelName)};
this.handle(
IProblem.DuplicateLabel,
- new String[] {new String(labelName)},
+ arguments,
+ arguments,
location.sourceStart,
location.sourceEnd);
}
@@ -92,20 +125,25 @@
this.handle(
IProblem.AnonymousClassCannotExtendFinalClass,
new String[] {new String(type.readableName())},
+ new String[] {new String(type.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
public void argumentTypeCannotBeVoid(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg) {
+ String[] arguments = new String[] {new String(methodDecl.selector), new String(arg.name)};
this.handle(
IProblem.ArgumentTypeCannotBeVoid,
- new String[] {new String(methodDecl.selector), new String(arg.name)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void argumentTypeCannotBeVoidArray(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg) {
+ String[] arguments = new String[] {new String(methodDecl.selector), new String(arg.name)};
this.handle(
IProblem.ArgumentTypeCannotBeVoidArray,
- new String[] {new String(methodDecl.selector), new String(arg.name)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
@@ -136,42 +174,68 @@
this.handle(
id,
new String[] {new String(methodDecl.selector), arg.name(), new String(expectedType.readableName())},
+ new String[] {new String(methodDecl.selector), arg.name(), new String(expectedType.shortReadableName())},
arg.type.sourceStart,
arg.type.sourceEnd);
}
public void arrayConstantsOnlyInArrayInitializers(int sourceStart, int sourceEnd) {
this.handle(
IProblem.ArrayConstantsOnlyInArrayInitializers,
- new String[0],
+ NoArgument,
+ NoArgument,
sourceStart,
sourceEnd);
}
+public void assignmentHasNoEffect(Assignment assignment, char[] name){
+ String[] arguments = new String[] { new String(name) };
+ this.handle(
+ IProblem.AssignmentHasNoEffect,
+ arguments,
+ arguments,
+ assignment.sourceStart,
+ assignment.sourceEnd);
+}
public void attemptToReturnNonVoidExpression(ReturnStatement returnStatement, TypeBinding expectedType) {
this.handle(
IProblem.VoidMethodReturnsValue,
new String[] {new String(expectedType.readableName())},
+ new String[] {new String(expectedType.shortReadableName())},
returnStatement.sourceStart,
returnStatement.sourceEnd);
}
public void attemptToReturnVoidValue(ReturnStatement returnStatement) {
this.handle(
IProblem.MethodReturnsVoid,
- new String[] {},
+ NoArgument,
+ NoArgument,
returnStatement.sourceStart,
returnStatement.sourceEnd);
}
public void bytecodeExceeds64KLimit(AbstractMethodDeclaration location) {
- this.handle(
- IProblem.BytecodeExceeds64KLimit,
- new String[] {new String(location.selector)},
- Error | Abort,
- location.sourceStart,
- location.sourceEnd);
+ String[] arguments = new String[] {new String(location.selector), parametersAsString(location.binding)};
+ if (location.isConstructor()) {
+ this.handle(
+ IProblem.BytecodeExceeds64KLimitForConstructor,
+ arguments,
+ arguments,
+ Error | Abort,
+ location.sourceStart,
+ location.sourceEnd);
+ } else {
+ this.handle(
+ IProblem.BytecodeExceeds64KLimit,
+ arguments,
+ arguments,
+ Error | Abort,
+ location.sourceStart,
+ location.sourceEnd);
+ }
}
public void bytecodeExceeds64KLimit(TypeDeclaration location) {
this.handle(
IProblem.BytecodeExceeds64KLimitForClinit,
- new String[0],
+ NoArgument,
+ NoArgument,
Error | Abort,
location.sourceStart,
location.sourceEnd);
@@ -179,7 +243,8 @@
public void cannotAllocateVoidArray(Expression expression) {
this.handle(
IProblem.CannotAllocateVoidArray,
- new String[] {},
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
@@ -189,27 +254,44 @@
new String[] {
(field.declaringClass == null ? "array" : new String(field.declaringClass.readableName())), //$NON-NLS-1$
new String(field.readableName())},
+ new String[] {
+ (field.declaringClass == null ? "array" : new String(field.declaringClass.shortReadableName())), //$NON-NLS-1$
+ new String(field.shortReadableName())},
+ location.sourceStart,
+ location.sourceEnd);
+}
+public void cannotAssignToFinalLocal(LocalVariableBinding local, AstNode location) {
+ String[] arguments = new String[] { new String(local.readableName())};
+ this.handle(
+ IProblem.NonBlankFinalLocalAssignment,
+ arguments,
+ arguments,
location.sourceStart,
location.sourceEnd);
}
public void cannotAssignToFinalOuterLocal(LocalVariableBinding local, AstNode location) {
+ String[] arguments = new String[] {new String(local.readableName())};
this.handle(
IProblem.FinalOuterLocalAssignment,
- new String[] {new String(local.readableName())},
+ arguments,
+ arguments,
location.sourceStart,
location.sourceEnd);
}
public void cannotDeclareLocalInterface(char[] interfaceName, int sourceStart, int sourceEnd) {
+ String[] arguments = new String[] {new String(interfaceName)};
this.handle(
IProblem.CannotDefineInterfaceInLocalType,
- new String[] {new String(interfaceName)},
+ arguments,
+ arguments,
sourceStart,
sourceEnd);
}
public void cannotDefineDimensionsAndInitializer(ArrayAllocationExpression expresssion) {
this.handle(
IProblem.CannotDefineDimensionExpressionsWithInit,
- new String[0],
+ NoArgument,
+ NoArgument,
expresssion.sourceStart,
expresssion.sourceEnd);
}
@@ -217,13 +299,16 @@
this.handle(
IProblem.DirectInvocationOfAbstractMethod,
new String[] {new String(method.declaringClass.readableName()), new String(method.selector), parametersAsString(method)},
+ new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), parametersAsShortString(method)},
messageSend.sourceStart,
messageSend.sourceEnd);
}
public void cannotImportPackage(ImportReference importRef) {
+ String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
this.handle(
IProblem.CannotImportPackage,
- new String[] {CharOperation.toString(importRef.tokens)},
+ arguments,
+ arguments,
importRef.sourceStart,
importRef.sourceEnd);
}
@@ -231,27 +316,32 @@
this.handle(
IProblem.InvalidClassInstantiation,
new String[] {new String(type.readableName())},
+ new String[] {new String(type.shortReadableName())},
typeRef.sourceStart,
typeRef.sourceEnd);
}
public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local, AstNode location) {
+ String[] arguments =new String[]{ new String(local.readableName())};
this.handle(
IProblem.OuterLocalMustBeFinal,
- new String[] {new String(local.readableName())},
+ arguments,
+ arguments,
location.sourceStart,
location.sourceEnd);
}
public void cannotReturnInInitializer(AstNode location) {
this.handle(
IProblem.CannotReturnInInitializer,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
public void cannotThrowNull(ThrowStatement statement) {
this.handle(
IProblem.CannotThrowNull,
- new String[0],
+ NoArgument,
+ NoArgument,
statement.sourceStart,
statement.sourceEnd);
}
@@ -259,20 +349,23 @@
this.handle(
IProblem.CannotThrowType,
new String[] {new String(expectedType.readableName())},
+ new String[] {new String(expectedType.shortReadableName())},
exceptionType.sourceStart,
exceptionType.sourceEnd);
}
public void cannotUseSuperInJavaLangObject(AstNode reference) {
this.handle(
IProblem.ObjectHasNoSuperclass,
- new String[0],
+ NoArgument,
+ NoArgument,
reference.sourceStart,
reference.sourceEnd);
}
public void cannotUseSuperInCodeSnippet(int start, int end) {
this.handle(
IProblem.CannotUseSuperInCodeSnippet,
- new String[0],
+ NoArgument,
+ NoArgument,
Error | Abort,
start,
end);
@@ -280,29 +373,39 @@
public void caseExpressionMustBeConstant(Expression expression) {
this.handle(
IProblem.NonConstantExpression,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
public void classExtendFinalClass(SourceTypeBinding type, TypeReference superclass, TypeBinding expectedType) {
+ String name = new String(type.sourceName());
+ String expectedFullName = new String(expectedType.readableName());
+ String expectedShortName = new String(expectedType.shortReadableName());
+ if (expectedShortName.equals(name)) expectedShortName = expectedFullName;
this.handle(
IProblem.ClassExtendFinalClass,
- new String[] {new String(expectedType.readableName()), new String(type.sourceName())},
+ new String[] {expectedFullName, name},
+ new String[] {expectedShortName, name},
superclass.sourceStart,
superclass.sourceEnd);
}
public void codeSnippetMissingClass(String missing, int start, int end) {
+ String[] arguments = new String[]{missing};
this.handle(
IProblem.CodeSnippetMissingClass,
- new String[]{ missing },
+ arguments,
+ arguments,
Error | Abort,
start,
end);
}
public void codeSnippetMissingMethod(String className, String missingMethod, String argumentTypes, int start, int end) {
+ String[] arguments = new String[]{ className, missingMethod, argumentTypes };
this.handle(
IProblem.CodeSnippetMissingMethod,
- new String[]{ className, missingMethod, argumentTypes },
+ arguments,
+ arguments,
Error | Abort,
start,
end);
@@ -384,16 +487,6 @@
}
return Ignore;
-/*
- case UnnecessaryEnclosingInstanceSpecification :
- if ((errorThreshold & UnnecessaryEnclosingInstance) != 0){
- return Error;
- }
- if ((warningThreshold & UnnecessaryEnclosingInstance) != 0){
- return Warning;
- }
- return Ignore;
-*/
case IProblem.MethodButWithConstructorName :
if ((errorThreshold & CompilerOptions.MethodWithConstructorName) != 0){
return Error;
@@ -412,6 +505,16 @@
}
return Ignore;
+ case IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod :
+ case IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod :
+ if ((errorThreshold & CompilerOptions.IncompatibleNonInheritedInterfaceMethod) != 0){
+ return Error;
+ }
+ if ((warningThreshold & CompilerOptions.IncompatibleNonInheritedInterfaceMethod) != 0){
+ return Warning;
+ }
+ return Ignore;
+
case IProblem.OverridingDeprecatedMethod :
case IProblem.UsingDeprecatedType :
case IProblem.UsingDeprecatedMethod :
@@ -479,6 +582,37 @@
return Warning;
}
return Ignore;
+ case IProblem.NonStaticAccessToStaticMethod :
+ case IProblem.NonStaticAccessToStaticField :
+ if ((errorThreshold & CompilerOptions.StaticAccessReceiver) != 0){
+ return Error;
+ }
+ if ((warningThreshold & CompilerOptions.StaticAccessReceiver) != 0){
+ return Warning;
+ }
+ return Ignore;
+ case IProblem.AssignmentHasNoEffect:
+ if ((errorThreshold & CompilerOptions.NoEffectAssignment) != 0){
+ return Error;
+ }
+ if ((warningThreshold & CompilerOptions.NoEffectAssignment) != 0){
+ return Warning;
+ }
+ return Ignore;
+ case IProblem.UnusedPrivateConstructor:
+ case IProblem.UnusedPrivateMethod:
+ case IProblem.UnusedPrivateField:
+ case IProblem.UnusedPrivateType:
+ if ((errorThreshold & CompilerOptions.UnusedPrivateMember) != 0){
+ return Error;
+ }
+ if ((warningThreshold & CompilerOptions.UnusedPrivateMember) != 0){
+ return Warning;
+ }
+ return Ignore;
+
+ case IProblem.Task :
+ return Warning;
default:
return Error;
}
@@ -487,13 +621,16 @@
this.handle(
IProblem.IncompatibleTypesInConditionalOperator,
new String[] {new String(trueType.readableName()), new String(falseType.readableName())},
+ new String[] {new String(trueType.sourceName()), new String(falseType.sourceName())},
expression.sourceStart,
expression.sourceEnd);
}
public void conflictingImport(ImportReference importRef) {
+ String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
this.handle(
IProblem.ConflictingImport,
- new String[] {CharOperation.toString(importRef.tokens)},
+ arguments,
+ arguments,
importRef.sourceStart,
importRef.sourceEnd);
}
@@ -522,10 +659,12 @@
break label;
}
}
+ String[] arguments = new String[] {Radix + " " + new String(source) + " (digit " + new String(new char[] {source[place]}) + ")"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
this.handle(
IProblem.NumericValueOutOfRange,
- new String[] {Radix + " " + new String(source) + " (digit " + new String(new char[] {source[place]}) + ")"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ arguments,
+ arguments,
lit.sourceStart,
lit.sourceEnd);
return;
@@ -539,10 +678,11 @@
public void constantOutOfRange(Literal lit) {
// lit is some how out of range of it declared type
// example 9999999999999999999999999999999999999999999999999999999999999999999
-
+ String[] arguments = new String[] {new String(lit.source())};
this.handle(
IProblem.NumericValueOutOfRange,
- new String[] {new String(lit.source())},
+ arguments,
+ arguments,
lit.sourceStart,
lit.sourceEnd);
}
@@ -550,6 +690,7 @@
this.handle(
IProblem.UsingDeprecatedField,
new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
+ new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
location.sourceStart,
location.sourceEnd);
}
@@ -558,12 +699,14 @@
this.handle(
IProblem.UsingDeprecatedConstructor,
new String[] {new String(method.declaringClass.readableName()), parametersAsString(method)},
+ new String[] {new String(method.declaringClass.shortReadableName()), parametersAsShortString(method)},
location.sourceStart,
location.sourceEnd);
else
this.handle(
IProblem.UsingDeprecatedMethod,
new String[] {new String(method.declaringClass.readableName()), new String(method.selector), parametersAsString(method)},
+ new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), parametersAsShortString(method)},
location.sourceStart,
location.sourceEnd);
}
@@ -572,20 +715,24 @@
this.handle(
IProblem.UsingDeprecatedType,
new String[] {new String(type.readableName())},
+ new String[] {new String(type.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void duplicateCase(Case statement, Constant constant) {
+ String[] arguments = new String[] {String.valueOf(constant.intValue())};
this.handle(
IProblem.DuplicateCase,
- new String[] {String.valueOf(constant.intValue())},
+ arguments,
+ arguments,
statement.sourceStart,
statement.sourceEnd);
}
public void duplicateDefaultCase(DefaultCase statement) {
this.handle(
IProblem.DuplicateDefaultCase,
- new String[0],
+ NoArgument,
+ NoArgument,
statement.sourceStart,
statement.sourceEnd);
}
@@ -593,34 +740,43 @@
this.handle(
IProblem.DuplicateField,
new String[] {new String(type.sourceName()), fieldDecl.name()},
+ new String[] {new String(type.shortReadableName()), fieldDecl.name()},
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void duplicateImport(ImportReference importRef) {
+ String[] arguments = new String[] {CharOperation.toString(importRef.tokens)};
this.handle(
IProblem.DuplicateImport,
- new String[] {CharOperation.toString(importRef.tokens)},
+ arguments,
+ arguments,
importRef.sourceStart,
importRef.sourceEnd);
}
public void duplicateInitializationOfBlankFinalField(FieldBinding field, Reference reference) {
+ String[] arguments = new String[]{ new String(field.readableName())};
this.handle(
IProblem.DuplicateBlankFinalFieldInitialization,
- new String[] {new String(field.readableName())},
+ arguments,
+ arguments,
reference.sourceStart,
reference.sourceEnd);
}
-public void duplicateInitializationOfFinalLocal(LocalVariableBinding local, NameReference reference) {
+public void duplicateInitializationOfFinalLocal(LocalVariableBinding local, AstNode location) {
+ String[] arguments = new String[] { new String(local.readableName())};
this.handle(
IProblem.DuplicateFinalLocalInitialization,
- new String[] {new String(local.readableName())},
- reference.sourceStart,
- reference.sourceEnd);
+ arguments,
+ arguments,
+ location.sourceStart,
+ location.sourceEnd);
}
public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(methodDecl.selector), new String(type.sourceName())};
this.handle(
IProblem.DuplicateMethod,
- new String[] {new String(methodDecl.selector), new String(type.sourceName())},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
@@ -633,10 +789,11 @@
fieldDecl.modifiers.sourceStart,
fieldDecl.modifiers.sourceEnd));
*/
-
+ String[] arguments = new String[] {fieldDecl.name()};
this.handle(
IProblem.DuplicateModifierForField,
- new String[] {fieldDecl.name()},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
@@ -644,29 +801,36 @@
this.handle(
IProblem.DuplicateModifierForMethod,
new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ new String[] {new String(type.shortReadableName()), new String(methodDecl.selector)},
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void duplicateModifierForType(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.DuplicateModifierForType,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void duplicateModifierForVariable(LocalDeclaration localDecl, boolean complainForArgument) {
+ String[] arguments = new String[] {localDecl.name()};
this.handle(
complainForArgument
- ? IProblem.DuplicateModifierForArgument
+ ? IProblem.DuplicateModifierForArgument
: IProblem.DuplicateModifierForVariable,
- new String[] {localDecl.name()},
+ arguments,
+ arguments,
localDecl.sourceStart,
localDecl.sourceEnd);
}
public void duplicateNestedType(TypeDeclaration typeDecl) {
+ String[] arguments = new String[] {new String(typeDecl.name)};
this.handle(
IProblem.DuplicateNestedType,
- new String[] {new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
@@ -676,36 +840,48 @@
new String[] {
new String(superType.readableName()),
new String(type.sourceName())},
+ new String[] {
+ new String(superType.shortReadableName()),
+ new String(type.sourceName())},
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
public void duplicateTypes(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
+ String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
this.handle(
IProblem.DuplicateTypes,
- new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd,
compUnitDecl.compilationResult);
}
public void errorNoMethodFor(MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
StringBuffer buffer = new StringBuffer();
+ StringBuffer shortBuffer = new StringBuffer();
for (int i = 0, length = params.length; i < length; i++) {
- if (i != 0)
+ if (i != 0){
buffer.append(", "); //$NON-NLS-1$
+ shortBuffer.append(", "); //$NON-NLS-1$
+ }
buffer.append(new String(params[i].readableName()));
+ shortBuffer.append(new String(params[i].shortReadableName()));
}
this.handle(
recType.isArrayType() ? IProblem.NoMessageSendOnArrayType : IProblem.NoMessageSendOnBaseType,
new String[] {new String(recType.readableName()), new String(messageSend.selector), buffer.toString()},
+ new String[] {new String(recType.shortReadableName()), new String(messageSend.selector), shortBuffer.toString()},
messageSend.sourceStart,
messageSend.sourceEnd);
}
public void errorThisSuperInStatic(AstNode reference) {
+ String[] arguments = new String[] {reference.isSuper() ? "super" : "this"}; //$NON-NLS-2$ //$NON-NLS-1$
this.handle(
IProblem.ThisInStaticContext,
- new String[] {reference.isSuper() ? "super" : "this"}, //$NON-NLS-2$ //$NON-NLS-1$
+ arguments,
+ arguments,
reference.sourceStart,
reference.sourceEnd);
}
@@ -736,13 +912,23 @@
this.handle(
id,
new String[] {new String(methodDecl.selector), new String(expectedType.readableName())},
+ new String[] {new String(methodDecl.selector), new String(expectedType.shortReadableName())},
exceptionType.sourceStart,
exceptionType.sourceEnd);
}
+public void expressionShouldBeAVariable(Expression expression) {
+ this.handle(
+ IProblem.ExpressionShouldBeAVariable,
+ NoArgument,
+ NoArgument,
+ expression.sourceStart,
+ expression.sourceEnd);
+}
public void fieldsOrThisBeforeConstructorInvocation(ThisReference reference) {
this.handle(
IProblem.ThisSuperDuringConstructorInvocation,
- new String[0],
+ NoArgument,
+ NoArgument,
reference.sourceStart,
reference.sourceEnd);
}
@@ -773,6 +959,7 @@
this.handle(
id,
new String[] {fieldDecl.name(), new String(type.sourceName()), new String(expectedType.readableName())},
+ new String[] {fieldDecl.name(), new String(type.sourceName()), new String(expectedType.shortReadableName())},
fieldDecl.type.sourceStart,
fieldDecl.type.sourceEnd);
}
@@ -782,13 +969,15 @@
// 8.4.3.3 - Final methods cannot be overridden or hidden.
IProblem.FinalMethodCannotBeOverridden,
new String[] {new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
}
public void forwardReference(Reference reference, int indexInQualification, TypeBinding type) {
this.handle(
IProblem.ReferenceToForwardField,
- new String[] {},
+ NoArgument,
+ NoArgument,
reference.sourceStart,
reference.sourceEnd);
}
@@ -799,12 +988,14 @@
private void handle(
int problemId,
String[] problemArguments,
+ String[] messageArguments,
int problemStartPosition,
int problemEndPosition){
this.handle(
problemId,
problemArguments,
+ messageArguments,
problemStartPosition,
problemEndPosition,
referenceContext,
@@ -818,6 +1009,7 @@
private void handle(
int problemId,
String[] problemArguments,
+ String[] messageArguments,
int severity,
int problemStartPosition,
int problemEndPosition){
@@ -825,6 +1017,7 @@
this.handle(
problemId,
problemArguments,
+ messageArguments,
severity,
problemStartPosition,
problemEndPosition,
@@ -838,6 +1031,7 @@
private void handle(
int problemId,
String[] problemArguments,
+ String[] messageArguments,
int problemStartPosition,
int problemEndPosition,
CompilationResult unitResult){
@@ -845,6 +1039,7 @@
this.handle(
problemId,
problemArguments,
+ messageArguments,
problemStartPosition,
problemEndPosition,
referenceContext,
@@ -852,9 +1047,11 @@
referenceContext = null;
}
public void hidingEnclosingType(TypeDeclaration typeDecl) {
+ String[] arguments = new String[] {new String(typeDecl.name)};
this.handle(
IProblem.HidingEnclosingType,
- new String[] {new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
@@ -862,128 +1059,163 @@
int start = 0;
int end = 0;
String typeName = ""; //$NON-NLS-1$
+ String shortTypeName = ""; //$NON-NLS-1$
if (reference == null) { // can only happen when java.lang.Object is busted
start = sourceType.sourceStart();
end = sourceType.sourceEnd();
typeName = new String(superType.readableName());
+ shortTypeName = new String(superType.sourceName());
} else {
start = reference.sourceStart;
end = reference.sourceEnd;
- typeName = CharOperation.toString(reference.getTypeName());
+ char[][] qName = reference.getTypeName();
+ typeName = CharOperation.toString(qName);
+ shortTypeName = new String(qName[qName.length-1]);
}
if (sourceType == superType)
this.handle(
IProblem.HierarchyCircularitySelfReference,
new String[] {new String(sourceType.sourceName()), typeName},
+ new String[] {new String(sourceType.sourceName()), shortTypeName},
start,
end);
else
this.handle(
IProblem.HierarchyCircularity,
new String[] {new String(sourceType.sourceName()), typeName},
+ new String[] {new String(sourceType.sourceName()), shortTypeName},
start,
end);
}
public void hierarchyHasProblems(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.HierarchyHasProblems,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalAbstractModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.IllegalAbstractModifierCombinationForMethod,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void illegalModifierCombinationFinalAbstractForClass(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierCombinationFinalAbstractForClass,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierCombinationFinalVolatileForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {fieldDecl.name()};
+
this.handle(
IProblem.IllegalModifierCombinationFinalVolatileForField,
- new String[] {fieldDecl.name()},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void illegalModifierForClass(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierForClass,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {fieldDecl.name()};
this.handle(
IProblem.IllegalModifierForField,
- new String[] {fieldDecl.name()},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void illegalModifierForInterface(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierForInterface,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierForInterfaceField(ReferenceBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {fieldDecl.name()};
this.handle(
IProblem.IllegalModifierForInterfaceField,
- new String[] {fieldDecl.name()},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void illegalModifierForInterfaceMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.IllegalModifierForInterfaceMethod,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void illegalModifierForLocalClass(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierForLocalClass,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierForMemberClass(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierForMemberClass,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierForMemberInterface(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalModifierForMemberInterface,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.IllegalModifierForMethod,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void illegalModifierForVariable(LocalDeclaration localDecl, boolean complainAsArgument) {
+ String[] arguments = new String[] {localDecl.name()};
this.handle(
complainAsArgument
? IProblem.IllegalModifierForArgument
: IProblem.IllegalModifierForVariable,
- new String[] {localDecl.name()},
+ arguments,
+ arguments,
localDecl.sourceStart,
localDecl.sourceEnd);
}
@@ -991,48 +1223,60 @@
this.handle(
IProblem.IllegalPrimitiveOrArrayTypeForEnclosingInstance,
new String[] {new String(enclosingType.readableName())},
+ new String[] {new String(enclosingType.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void illegalStaticModifierForMemberType(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalStaticModifierForMemberType,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalVisibilityModifierCombinationForField(ReferenceBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {new String(fieldDecl.name())};
this.handle(
IProblem.IllegalVisibilityModifierCombinationForField,
- new String[] {new String(fieldDecl.name())},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void illegalVisibilityModifierCombinationForMemberType(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalVisibilityModifierCombinationForMemberType,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalVisibilityModifierCombinationForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.IllegalVisibilityModifierCombinationForMethod,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void illegalVisibilityModifierForInterfaceMemberType(SourceTypeBinding type) {
+ String[] arguments = new String[] {new String(type.sourceName())};
this.handle(
IProblem.IllegalVisibilityModifierForInterfaceMemberType,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
type.sourceStart(),
type.sourceEnd());
}
public void illegalVoidExpression(AstNode location) {
this.handle(
IProblem.InvalidVoidExpression,
- new String[] {},
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
@@ -1066,14 +1310,22 @@
} else {
argument = CharOperation.toString(importRef.tokens);
}
- this.handle(id, new String[] {argument}, importRef.sourceStart, importRef.sourceEnd);
+ String[] arguments = new String[]{argument};
+ this.handle(id, arguments, arguments, importRef.sourceStart, importRef.sourceEnd);
}
public void incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType) {
- if (type == currentMethod.declaringClass)
+ if (type == currentMethod.declaringClass) {
+ int id;
+ if (currentMethod.declaringClass.isInterface()
+ && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
+ id = IProblem.IncompatibleExceptionInThrowsClauseForNonInheritedInterfaceMethod;
+ } else {
+ id = IProblem.IncompatibleExceptionInThrowsClause;
+ }
this.handle(
// Exception %1 is not compatible with throws clause in %2
// 9.4.4 - The type of exception in the throws clause is incompatible.
- IProblem.IncompatibleExceptionInThrowsClause,
+ id,
new String[] {
new String(exceptionType.sourceName()),
new String(
@@ -1081,9 +1333,16 @@
inheritedMethod.declaringClass.readableName(),
inheritedMethod.readableName(),
'.'))},
+ new String[] {
+ new String(exceptionType.sourceName()),
+ new String(
+ CharOperation.concat(
+ inheritedMethod.declaringClass.shortReadableName(),
+ inheritedMethod.shortReadableName(),
+ '.'))},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
- else
+ } else
this.handle(
// Exception %1 in throws clause of %2 is not compatible with %3
// 9.4.4 - The type of exception in the throws clause is incompatible.
@@ -1100,6 +1359,18 @@
inheritedMethod.declaringClass.readableName(),
inheritedMethod.readableName(),
'.'))},
+ new String[] {
+ new String(exceptionType.sourceName()),
+ new String(
+ CharOperation.concat(
+ currentMethod.declaringClass.sourceName(),
+ currentMethod.shortReadableName(),
+ '.')),
+ new String(
+ CharOperation.concat(
+ inheritedMethod.declaringClass.shortReadableName(),
+ inheritedMethod.shortReadableName(),
+ '.'))},
type.sourceStart(),
type.sourceEnd());
}
@@ -1110,28 +1381,31 @@
.append('.')
.append(inheritedMethod.readableName());
+ StringBuffer shortSignature = new StringBuffer();
+ shortSignature
+ .append(inheritedMethod.declaringClass.shortReadableName())
+ .append('.')
+ .append(inheritedMethod.shortReadableName());
+
+ int id;
+ if (currentMethod.declaringClass.isInterface()
+ && !inheritedMethod.isPublic()){ // interface inheriting Object protected method
+ id = IProblem.IncompatibleReturnTypeForNonInheritedInterfaceMethod;
+ } else {
+ id = IProblem.IncompatibleReturnType;
+ }
this.handle(
- // Return type is incompatible with %1
- // 9.4.2 - The return type from the method is incompatible with the declaration.
- IProblem.IncompatibleReturnType,
+ id,
new String[] {methodSignature.toString()},
+ new String[] {shortSignature.toString()},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
}
-public void incorrectEnclosingInstanceReference(
- QualifiedThisReference reference,
- TypeBinding qualificationType) {
-
- this.handle(
- IProblem.IncorrectEnclosingInstanceReference,
- new String[] { new String(qualificationType.readableName())},
- reference.sourceStart,
- reference.sourceEnd);
-}
public void incorrectLocationForEmptyDimension(ArrayAllocationExpression expression, int index) {
this.handle(
IProblem.IllegalDimension,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.dimensions[index + 1].sourceStart,
expression.dimensions[index + 1].sourceEnd);
}
@@ -1139,6 +1413,7 @@
this.handle(
IProblem.IncorrectSwitchType,
new String[] {new String(testType.readableName())},
+ new String[] {new String(testType.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
@@ -1148,24 +1423,39 @@
.append(concreteMethod.declaringClass.readableName())
.append('.')
.append(concreteMethod.readableName());
+ StringBuffer shortSignature = new StringBuffer();
+ shortSignature
+ .append(concreteMethod.declaringClass.shortReadableName())
+ .append('.')
+ .append(concreteMethod.shortReadableName());
this.handle(
// The inherited method %1 cannot hide the public abstract method in %2
IProblem.InheritedMethodReducesVisibility,
new String[] {
new String(concreteSignature.toString()),
new String(abstractMethods[0].declaringClass.readableName())},
+ new String[] {
+ new String(shortSignature.toString()),
+ new String(abstractMethods[0].declaringClass.shortReadableName())},
type.sourceStart(),
type.sourceEnd());
}
public void inheritedMethodsHaveIncompatibleReturnTypes(SourceTypeBinding type, MethodBinding[] inheritedMethods, int length) {
StringBuffer methodSignatures = new StringBuffer();
+ StringBuffer shortSignatures = new StringBuffer();
for (int i = length; --i >= 0;) {
methodSignatures
.append(inheritedMethods[i].declaringClass.readableName())
.append('.')
.append(inheritedMethods[i].readableName());
- if (i != 0)
+ shortSignatures
+ .append(inheritedMethods[i].declaringClass.shortReadableName())
+ .append('.')
+ .append(inheritedMethods[i].shortReadableName());
+ if (i != 0){
methodSignatures.append(", "); //$NON-NLS-1$
+ shortSignatures.append(", "); //$NON-NLS-1$
+ }
}
this.handle(
@@ -1173,13 +1463,15 @@
// 9.4.2 - The return type from the method is incompatible with the declaration.
IProblem.IncompatibleReturnType,
new String[] {methodSignatures.toString()},
+ new String[] {shortSignatures.toString()},
type.sourceStart(),
type.sourceEnd());
}
public void initializerMustCompleteNormally(FieldDeclaration fieldDecl) {
this.handle(
IProblem.InitializerMustCompleteNormally,
- new String[0],
+ NoArgument,
+ NoArgument,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
@@ -1187,29 +1479,35 @@
this.handle(
IProblem.CannotDefineStaticInitializerInLocalType,
new String[] {new String(innerType.readableName())},
+ new String[] {new String(innerType.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void interfaceCannotHaveConstructors(ConstructorDeclaration constructor) {
this.handle(
IProblem.InterfaceCannotHaveConstructors,
- new String[0],
+ NoArgument,
+ NoArgument,
constructor.sourceStart,
constructor.sourceEnd,
constructor,
constructor.compilationResult());
}
public void interfaceCannotHaveInitializers(SourceTypeBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {new String(type.sourceName())};
+
this.handle(
IProblem.InterfaceCannotHaveInitializers,
- new String[] {new String(type.sourceName())},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void invalidBreak(AstNode location) {
this.handle(
IProblem.InvalidBreak,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
@@ -1261,18 +1559,21 @@
this.handle(
flag,
new String[] {new String(targetConstructor.declaringClass.readableName()), parametersAsString(targetConstructor)},
+ new String[] {new String(targetConstructor.declaringClass.shortReadableName()), parametersAsShortString(targetConstructor)},
statement.sourceStart,
statement.sourceEnd);
}
public void invalidContinue(AstNode location) {
this.handle(
IProblem.InvalidContinue,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
-public void invalidEnclosingType(Expression expression, TypeBinding type, TypeBinding enclosingType) {
+public void invalidEnclosingType(Expression expression, TypeBinding type, ReferenceBinding enclosingType) {
+ if (enclosingType.isAnonymousType()) enclosingType = enclosingType.superclass();
int flag = IProblem.UndefinedType; // default
switch (type.problemId()) {
case NotFound : // 1
@@ -1296,13 +1597,15 @@
this.handle(
flag,
new String[] {new String(enclosingType.readableName()) + "." + new String(type.readableName())}, //$NON-NLS-1$
+ new String[] {new String(enclosingType.shortReadableName()) + "." + new String(type.shortReadableName())}, //$NON-NLS-1$
expression.sourceStart,
expression.sourceEnd);
}
public void invalidExpressionAsStatement(Expression expression){
this.handle(
IProblem.InvalidExpressionAsStatement,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
@@ -1333,15 +1636,26 @@
case InheritedNameHidesEnclosingName :
flag = IProblem.InheritedFieldHidesEnclosingName;
break;
+ case ReceiverTypeNotVisible :
+ this.handle(
+ IProblem.NotVisibleType,
+ new String[] {new String(searchedType.leafComponentType().readableName())},
+ new String[] {new String(searchedType.leafComponentType().shortReadableName())},
+ fieldRef.receiver.sourceStart,
+ fieldRef.receiver.sourceEnd);
+ return;
+
case NoError : // 0
default :
needImplementation(); // want to fail to see why we were here...
break;
}
+ String[] arguments = new String[] {new String(field.readableName())};
this.handle(
flag,
- new String[] {new String(field.readableName())},
+ arguments,
+ arguments,
severity,
fieldRef.sourceStart,
fieldRef.sourceEnd);
@@ -1367,14 +1681,24 @@
case InheritedNameHidesEnclosingName :
flag = IProblem.InheritedFieldHidesEnclosingName;
break;
+ case ReceiverTypeNotVisible :
+ this.handle(
+ IProblem.NotVisibleType,
+ new String[] {new String(field.declaringClass.leafComponentType().readableName())},
+ new String[] {new String(field.declaringClass.leafComponentType().shortReadableName())},
+ nameRef.sourceStart,
+ nameRef.sourceEnd);
+ return;
case NoError : // 0
default :
needImplementation(); // want to fail to see why we were here...
break;
}
+ String[] arguments = new String[] {new String(field.readableName())};
this.handle(
flag,
- new String[] {new String(field.readableName())},
+ arguments,
+ arguments,
nameRef.sourceStart,
nameRef.sourceEnd);
}
@@ -1394,6 +1718,10 @@
new String(searchedType.readableName()),
CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
new String(nameRef.tokens[index])},
+ new String[] {
+ new String(searchedType.sourceName()),
+ CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index)),
+ new String(nameRef.tokens[index])},
nameRef.sourceStart,
nameRef.sourceEnd);
return;
@@ -1423,14 +1751,24 @@
case InheritedNameHidesEnclosingName :
flag = IProblem.InheritedFieldHidesEnclosingName;
break;
+ case ReceiverTypeNotVisible :
+ this.handle(
+ IProblem.NotVisibleType,
+ new String[] {new String(searchedType.leafComponentType().readableName())},
+ new String[] {new String(searchedType.leafComponentType().shortReadableName())},
+ nameRef.sourceStart,
+ nameRef.sourceEnd);
+ return;
case NoError : // 0
default :
needImplementation(); // want to fail to see why we were here...
break;
}
+ String[] arguments = new String[] {CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index + 1))};
this.handle(
flag,
- new String[] {CharOperation.toString(CharOperation.subarray(nameRef.tokens, 0, index + 1))},
+ arguments,
+ arguments,
nameRef.sourceStart,
nameRef.sourceEnd);
}
@@ -1464,6 +1802,15 @@
case NonStaticReferenceInStaticContext :
flag = IProblem.StaticMethodRequested;
break;
+ case ReceiverTypeNotVisible :
+ this.handle(
+ IProblem.NotVisibleType,
+ new String[] {new String(method.declaringClass.leafComponentType().readableName())},
+ new String[] {new String(method.declaringClass.leafComponentType().shortReadableName())},
+ messageSend.receiver.sourceStart,
+ messageSend.receiver.sourceEnd);
+ return;
+
case NoError : // 0
default :
needImplementation(); // want to fail to see why we were here...
@@ -1473,13 +1820,28 @@
if (flag == IProblem.UndefinedMethod) {
ProblemMethodBinding problemMethod = (ProblemMethodBinding) method;
if (problemMethod.closestMatch != null) {
+ String closestParameterTypeNames = parametersAsString(problemMethod.closestMatch);
+ String parameterTypeNames = parametersAsString(method);
+ String closestParameterTypeShortNames = parametersAsShortString(problemMethod.closestMatch);
+ String parameterTypeShortNames = parametersAsShortString(method);
+ if (closestParameterTypeShortNames.equals(parameterTypeShortNames)){
+ closestParameterTypeShortNames = closestParameterTypeNames;
+ parameterTypeShortNames = parameterTypeNames;
+ }
this.handle(
IProblem.ParameterMismatch,
new String[] {
new String(problemMethod.closestMatch.declaringClass.readableName()),
new String(problemMethod.closestMatch.selector),
- parametersAsString(problemMethod.closestMatch),
- parametersAsString(method)},
+ closestParameterTypeNames,
+ parameterTypeNames
+ },
+ new String[] {
+ new String(problemMethod.closestMatch.declaringClass.shortReadableName()),
+ new String(problemMethod.closestMatch.selector),
+ closestParameterTypeShortNames,
+ parameterTypeShortNames
+ },
(int) (messageSend.nameSourcePosition >>> 32),
(int) messageSend.nameSourcePosition);
return;
@@ -1491,31 +1853,57 @@
new String[] {
new String(method.declaringClass.readableName()),
new String(method.selector), parametersAsString(method)},
+ new String[] {
+ new String(method.declaringClass.shortReadableName()),
+ new String(method.selector), parametersAsShortString(method)},
(int) (messageSend.nameSourcePosition >>> 32),
(int) messageSend.nameSourcePosition);
}
public void invalidNullToSynchronize(Expression expression) {
this.handle(
IProblem.InvalidNullToSynchronized,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
public void invalidOperator(BinaryExpression expression, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.InvalidOperator,
new String[] {
expression.operatorToString(),
- new String(leftType.readableName()) + ", " + new String(rightType.readableName())}, //$NON-NLS-1$
+ leftName + ", " + rightName}, //$NON-NLS-1$
+ new String[] {
+ expression.operatorToString(),
+ leftShortName + ", " + rightShortName}, //$NON-NLS-1$
expression.sourceStart,
expression.sourceEnd);
}
public void invalidOperator(CompoundAssignment assign, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.InvalidOperator,
new String[] {
assign.operatorToString(),
- new String(leftType.readableName()) + ", " + new String(rightType.readableName())}, //$NON-NLS-1$
+ leftName + ", " + rightName}, //$NON-NLS-1$
+ new String[] {
+ assign.operatorToString(),
+ leftShortName + ", " + rightShortName}, //$NON-NLS-1$
assign.sourceStart,
assign.sourceEnd);
}
@@ -1523,9 +1911,18 @@
this.handle(
IProblem.InvalidOperator,
new String[] {expression.operatorToString(), new String(type.readableName())},
+ new String[] {expression.operatorToString(), new String(type.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
+public void invalidParenthesizedExpression(AstNode reference) {
+ this.handle(
+ IProblem.InvalidParenthesizedExpression,
+ NoArgument,
+ NoArgument,
+ reference.sourceStart,
+ reference.sourceEnd);
+}
public void invalidSuperclass(SourceTypeBinding type, TypeReference superclassRef, ReferenceBinding expectedType) {
int problemId = expectedType.problemId();
int id;
@@ -1553,6 +1950,7 @@
this.handle(
id,
new String[] {new String(expectedType.readableName()), new String(type.sourceName())},
+ new String[] {new String(expectedType.shortReadableName()), new String(type.sourceName())},
superclassRef.sourceStart,
superclassRef.sourceEnd);
}
@@ -1583,6 +1981,7 @@
this.handle(
id,
new String[] {new String(expectedType.readableName()), new String(type.sourceName())},
+ new String[] {new String(expectedType.shortReadableName()), new String(type.sourceName())},
superinterfaceRef.sourceStart,
superinterfaceRef.sourceEnd);
}
@@ -1613,13 +2012,15 @@
this.handle(
flag,
new String[] {new String(type.readableName())},
+ new String[] {new String(type.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void invalidTypeReference(Expression expression) {
this.handle(
IProblem.InvalidTypeExpression,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
@@ -1627,21 +2028,25 @@
this.handle(
IProblem.InvalidTypeToSynchronized,
new String[] {new String(type.readableName())},
+ new String[] {new String(type.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
public void invalidUnaryExpression(Expression expression) {
this.handle(
IProblem.InvalidUnaryExpression,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
public void isClassPathCorrect(char[][] wellKnownTypeName, CompilationUnitDeclaration compUnitDecl) {
referenceContext = compUnitDecl;
+ String[] arguments = new String[] {CharOperation.toString(wellKnownTypeName)};
this.handle(
IProblem.IsClassPathCorrect,
- new String[] {CharOperation.toString(wellKnownTypeName)},
+ arguments,
+ arguments,
AbortCompilation | Error,
compUnitDecl == null ? 0 : compUnitDecl.sourceStart,
compUnitDecl == null ? 1 : compUnitDecl.sourceEnd);
@@ -1649,62 +2054,79 @@
public void maskedExceptionHandler(ReferenceBinding exceptionType, AstNode location) {
this.handle(
IProblem.MaskedCatch,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
public void methodNeedingAbstractModifier(MethodDeclaration methodDecl) {
this.handle(
IProblem.MethodRequiresBody,
- new String[0],
+ NoArgument,
+ NoArgument,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void methodNeedingNoBody(MethodDeclaration methodDecl) {
this.handle(
((methodDecl.modifiers & CompilerModifiers.AccNative) != 0) ? IProblem.BodyForNativeMethod : IProblem.BodyForAbstractMethod,
- new String[0],
+ NoArgument,
+ NoArgument,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
public void methodWithConstructorName(MethodDeclaration methodDecl) {
this.handle(
IProblem.MethodButWithConstructorName,
- new String[0],
+ NoArgument,
+ NoArgument,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
-public void missingEnclosingInstanceSpecification(ReferenceBinding enclosingType, AstNode location) {
- boolean insideConstructorCall =
- (location instanceof ExplicitConstructorCall)
- && (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper);
-
- this.handle(
- insideConstructorCall
- ? IProblem.MissingEnclosingInstanceForConstructorCall
- : IProblem.MissingEnclosingInstance,
- new String[] {new String(enclosingType.readableName())},
- location.sourceStart,
- location.sourceEnd);
-}
+//public void missingEnclosingInstanceSpecification(ReferenceBinding enclosingType, AstNode location) {
+// boolean insideConstructorCall =
+// (location instanceof ExplicitConstructorCall)
+// && (((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper);
+//
+// this.handle(
+// insideConstructorCall
+// ? IProblem.MissingEnclosingInstanceForConstructorCall
+// : IProblem.MissingEnclosingInstance,
+// new String[] {new String(enclosingType.readableName())},
+// new String[] {new String(enclosingType.shortReadableName())},
+// location.sourceStart,
+// location.sourceEnd);
+//}
public void missingReturnType(AbstractMethodDeclaration methodDecl) {
this.handle(
IProblem.MissingReturnType,
- new String[0],
+ NoArgument,
+ NoArgument,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
+public void missingSemiColon(Expression expression){
+ this.handle(
+ IProblem.MissingSemiColon,
+ NoArgument,
+ NoArgument,
+ expression.sourceStart,
+ expression.sourceEnd);
+}
public void mustDefineDimensionsOrInitializer(ArrayAllocationExpression expression) {
this.handle(
IProblem.MustDefineEitherDimensionExpressionsOrInitializer,
- new String[0],
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
public void mustSpecifyPackage(CompilationUnitDeclaration compUnitDecl) {
+ String[] arguments = new String[] {new String(compUnitDecl.getFileName())};
this.handle(
IProblem.MustSpecifyPackage,
- new String[] {new String(compUnitDecl.getFileName())},
+ arguments,
+ arguments,
compUnitDecl.sourceStart,
compUnitDecl.sourceStart + 1);
}
@@ -1712,13 +2134,17 @@
this.handle(
IProblem.StaticMethodRequested,
new String[] {new String(method.declaringClass.readableName()), new String(method.selector), parametersAsString(method)},
+ new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), parametersAsShortString(method)},
messageSend.sourceStart,
messageSend.sourceEnd);
}
+
public void nativeMethodsCannotBeStrictfp(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.NativeMethodsCannotBeStrictfp,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
@@ -1729,6 +2155,7 @@
this.handle(
IProblem.NeedToEmulateFieldReadAccess,
new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
+ new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
location.sourceStart,
location.sourceEnd);
}
@@ -1736,6 +2163,7 @@
this.handle(
IProblem.NeedToEmulateFieldWriteAccess,
new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
+ new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
location.sourceStart,
location.sourceEnd);
}
@@ -1750,6 +2178,10 @@
new String(method.declaringClass.readableName()),
parametersAsString(method)
},
+ new String[] {
+ new String(method.declaringClass.shortReadableName()),
+ parametersAsShortString(method)
+ },
location.sourceStart,
location.sourceEnd);
else
@@ -1760,59 +2192,149 @@
new String(method.selector),
parametersAsString(method)
},
+ new String[] {
+ new String(method.declaringClass.shortReadableName()),
+ new String(method.selector),
+ parametersAsShortString(method)
+ },
location.sourceStart,
location.sourceEnd);
}
public void nestedClassCannotDeclareInterface(TypeDeclaration typeDecl) {
+ String[] arguments = new String[] {new String(typeDecl.name)};
this.handle(
IProblem.CannotDefineInterfaceInLocalType,
- new String[] {new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
public void noMoreAvailableSpaceForArgument(LocalVariableBinding local, AstNode location) {
+ String[] arguments = new String[]{ new String(local.name) };
this.handle(
- IProblem.TooManyArgumentSlots,
- new String[]{ new String(local.name) },
+ local instanceof SyntheticArgumentBinding
+ ? IProblem.TooManySyntheticArgumentSlots
+ : IProblem.TooManyArgumentSlots,
+ arguments,
+ arguments,
Abort | Error,
location.sourceStart,
location.sourceEnd);
}
public void noMoreAvailableSpaceForLocal(LocalVariableBinding local, AstNode location) {
+ String[] arguments = new String[]{ new String(local.name) };
this.handle(
IProblem.TooManyLocalVariableSlots,
- new String[]{ new String(local.name) },
+ arguments,
+ arguments,
Abort | Error,
location.sourceStart,
location.sourceEnd);
}
+public void noSuchEnclosingInstance(TypeBinding targetType, AstNode location, boolean isConstructorCall) {
+
+ int id;
+
+ if (isConstructorCall) {
+ //28 = No enclosing instance of type {0} is available due to some intermediate constructor invocation
+ id = IProblem.EnclosingInstanceInConstructorCall;
+ } else if ((location instanceof ExplicitConstructorCall)
+ && ((ExplicitConstructorCall) location).accessMode == ExplicitConstructorCall.ImplicitSuper) {
+ //20 = No enclosing instance of type {0} is accessible to invoke the super constructor. Must define a constructor and explicitly qualify its super constructor invocation with an instance of {0} (e.g. x.super() where x is an instance of {0}).
+ id = IProblem.MissingEnclosingInstanceForConstructorCall;
+ } else if (location instanceof AllocationExpression
+ && (((AllocationExpression) location).binding.declaringClass.isMemberType()
+ || (((AllocationExpression) location).binding.declaringClass.isAnonymousType()
+ && ((AllocationExpression) location).binding.declaringClass.superclass().isMemberType()))) {
+ //21 = No enclosing instance of type {0} is accessible. Must qualify the allocation with an enclosing instance of type {0} (e.g. x.new A() where x is an instance of {0}).
+ id = IProblem.MissingEnclosingInstance;
+ } else { // default
+ //22 = No enclosing instance of the type {0} is accessible in scope
+ id = IProblem.IncorrectEnclosingInstanceReference;
+ }
+
+ this.handle(
+ id,
+ new String[] { new String(targetType.readableName())},
+ new String[] { new String(targetType.shortReadableName())},
+ location.sourceStart,
+ location.sourceEnd);
+}
public void notCompatibleTypesError(EqualExpression expression, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.IncompatibleTypesInEqualityOperator,
- new String[] {new String(leftType.readableName()), new String(rightType.readableName())},
+ new String[] {leftName, rightName },
+ new String[] {leftShortName, rightShortName },
expression.sourceStart,
expression.sourceEnd);
}
public void notCompatibleTypesError(InstanceOfExpression expression, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.IncompatibleTypesInConditionalOperator,
- new String[] {new String(leftType.readableName()), new String(rightType.readableName())},
+ new String[] {leftName, rightName },
+ new String[] {leftShortName, rightShortName },
expression.sourceStart,
expression.sourceEnd);
}
+public void objectCannotHaveSuperTypes(SourceTypeBinding type) {
+ this.handle(
+ IProblem.ObjectCannotHaveSuperTypes,
+ NoArgument,
+ NoArgument,
+ type.sourceStart(),
+ type.sourceEnd());
+}
public void operatorOnlyValidOnNumericType(CompoundAssignment assignment, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.TypeMismatch,
- new String[] {new String(leftType.readableName()), new String(rightType.readableName())},
+ new String[] {leftName, rightName },
+ new String[] {leftShortName, rightShortName },
assignment.sourceStart,
assignment.sourceEnd);
}
-public void overridesDeprecatedMethod(MethodBinding currentMethod, MethodBinding inheritedMethod) {
+public void overridesDeprecatedMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
this.handle(
IProblem.OverridingDeprecatedMethod,
- new String[] {new String(inheritedMethod.declaringClass.readableName())},
- currentMethod.sourceStart(),
- currentMethod.sourceEnd());
+ new String[] {
+ new String(
+ CharOperation.concat(
+ localMethod.declaringClass.readableName(),
+ localMethod.readableName(),
+ '.')),
+ new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {
+ new String(
+ CharOperation.concat(
+ localMethod.declaringClass.shortReadableName(),
+ localMethod.shortReadableName(),
+ '.')),
+ new String(inheritedMethod.declaringClass.shortReadableName())},
+ localMethod.sourceStart(),
+ localMethod.sourceEnd());
}
public void overridesPackageDefaultMethod(MethodBinding localMethod, MethodBinding inheritedMethod) {
this.handle(
@@ -1824,20 +2346,31 @@
localMethod.readableName(),
'.')),
new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {
+ new String(
+ CharOperation.concat(
+ localMethod.declaringClass.shortReadableName(),
+ localMethod.shortReadableName(),
+ '.')),
+ new String(inheritedMethod.declaringClass.shortReadableName())},
localMethod.sourceStart(),
localMethod.sourceEnd());
}
public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) {
+ String[] arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)};
this.handle(
IProblem.PackageCollidesWithType,
- new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)},
+ arguments,
+ arguments,
compUnitDecl.currentPackage.sourceStart,
compUnitDecl.currentPackage.sourceEnd);
}
public void packageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl) {
+ String[] arguments = new String[] {CharOperation.toString(compUnitDecl.compilationResult.compilationUnit.getPackageName())};
this.handle(
IProblem.PackageIsNotExpectedPackage,
- new String[] {CharOperation.toString(compUnitDecl.compilationResult.compilationUnit.getPackageName())},
+ arguments,
+ arguments,
compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceStart,
compUnitDecl.currentPackage == null ? 0 : compUnitDecl.currentPackage.sourceEnd);
}
@@ -1851,6 +2384,16 @@
}
return buffer.toString();
}
+private String parametersAsShortString(MethodBinding method) {
+ TypeBinding[] params = method.parameters;
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0, length = params.length; i < length; i++) {
+ if (i != 0)
+ buffer.append(", "); //$NON-NLS-1$
+ buffer.append(new String(params[i].shortReadableName()));
+ }
+ return buffer.toString();
+}
public void parseError(
int startPosition,
int endPosition,
@@ -1860,17 +2403,21 @@
if (possibleTokens.length == 0) { //no suggestion available
if (isKeyword(currentTokenSource)) {
+ String[] arguments = new String[] {new String(currentTokenSource)};
this.handle(
IProblem.ParsingErrorOnKeywordNoSuggestion,
- new String[] {new String(currentTokenSource)},
+ arguments,
+ arguments,
// this is the current -invalid- token position
startPosition,
endPosition);
return;
} else {
+ String[] arguments = new String[] {errorTokenName};
this.handle(
IProblem.ParsingErrorNoSuggestion,
- new String[] {errorTokenName},
+ arguments,
+ arguments,
// this is the current -invalid- token position
startPosition,
endPosition);
@@ -1889,9 +2436,11 @@
}
if (isKeyword(currentTokenSource)) {
+ String[] arguments = new String[] {new String(currentTokenSource), list.toString()};
this.handle(
IProblem.ParsingErrorOnKeyword,
- new String[] {new String(currentTokenSource), list.toString()},
+ arguments,
+ arguments,
// this is the current -invalid- token position
startPosition,
endPosition);
@@ -1908,78 +2457,57 @@
errorTokenName = new String(currentTokenSource);
}
+ String[] arguments = new String[] {errorTokenName, list.toString()};
this.handle(
IProblem.ParsingError,
- new String[] {errorTokenName, list.toString()},
+ arguments,
+ arguments,
// this is the current -invalid- token position
startPosition,
endPosition);
}
public void publicClassMustMatchFileName(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
+ String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
this.handle(
IProblem.PublicClassMustMatchFileName,
- new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd,
compUnitDecl.compilationResult);
}
-/*
- * Flag all constructors involved in a cycle, we know we have a cycle.
- */
-public void recursiveConstructorInvocation(TypeDeclaration typeDeclaration) {
+public void recursiveConstructorInvocation(ExplicitConstructorCall constructorCall) {
- // propagate the reference count, negative counts means leading to a super constructor invocation (directly or indirectly)
- boolean hasChanged;
- AbstractMethodDeclaration[] methods = typeDeclaration.methods;
- int max = methods.length;
- do {
- hasChanged = false;
- for(int i = 0; i < max; i++){
- if (methods[i].isConstructor()){
- ConstructorDeclaration constructor = (ConstructorDeclaration) methods[i];
- if (constructor.referenceCount > 0){
- ConstructorDeclaration targetConstructor = constructor.constructorCall == null
- ? null
- : (ConstructorDeclaration)(typeDeclaration.declarationOf(constructor.constructorCall.binding));
- if ((targetConstructor == null) || (targetConstructor.referenceCount < 0)){
- hasChanged = true;
- constructor.referenceCount = -1;
- }
- }
- }
- }
- } while (hasChanged);
-
- // all remaining constructors with a positive count are still involved in a cycle
- for(int i = 0; i < max; i++){
- if (methods[i].isConstructor()){
- ConstructorDeclaration constructor = (ConstructorDeclaration) methods[i];
- if (constructor.referenceCount > 0){
- this.referenceContext = constructor;
- this.handle(
- IProblem.RecursiveConstructorInvocation,
- new String[] {
- new String(constructor.constructorCall.binding.declaringClass.readableName()),
- parametersAsString(constructor.constructorCall.binding)
- },
- constructor.constructorCall.sourceStart,
- constructor.constructorCall.sourceEnd);
- }
- }
- }
+ this.handle(
+ IProblem.RecursiveConstructorInvocation,
+ new String[] {
+ new String(constructorCall.binding.declaringClass.readableName()),
+ parametersAsString(constructorCall.binding)
+ },
+ new String[] {
+ new String(constructorCall.binding.declaringClass.shortReadableName()),
+ parametersAsShortString(constructorCall.binding)
+ },
+ constructorCall.sourceStart,
+ constructorCall.sourceEnd);
}
+
public void redefineArgument(Argument arg) {
+ String[] arguments = new String[] {new String(arg.name)};
this.handle(
IProblem.RedefinedArgument,
- new String[] {new String(arg.name)},
+ arguments,
+ arguments,
arg.sourceStart,
arg.sourceEnd);
}
public void redefineLocal(LocalDeclaration localDecl) {
+ String[] arguments = new String[] {new String(localDecl.name)};
this.handle(
IProblem.RedefinedLocal,
- new String[] {new String(localDecl.name)},
+ arguments,
+ arguments,
localDecl.sourceStart,
localDecl.sourceEnd);
}
@@ -1987,13 +2515,16 @@
this.handle(
IProblem.ArrayReferenceRequired,
new String[] {new String(arrayType.readableName())},
+ new String[] {new String(arrayType.shortReadableName())},
arrayRef.sourceStart,
arrayRef.sourceEnd);
}
public void returnTypeCannotBeVoidArray(SourceTypeBinding type, MethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(methodDecl.selector)};
this.handle(
IProblem.ReturnTypeCannotBeVoidArray,
- new String[] {new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
@@ -2024,6 +2555,7 @@
this.handle(
id,
new String[] {new String(methodDecl.selector), new String(expectedType.readableName())},
+ new String[] {new String(methodDecl.selector), new String(expectedType.shortReadableName())},
methodDecl.returnType.sourceStart,
methodDecl.returnType.sourceEnd);
}
@@ -2073,11 +2605,13 @@
if (errorTokenName.equals(Scanner.INVALID_CHAR_IN_STRING))
flag = IProblem.UnterminatedString;
+ String[] arguments = flag == IProblem.ParsingErrorNoSuggestion
+ ? new String[] {errorTokenName}
+ : NoArgument;
this.handle(
flag,
- flag == IProblem.ParsingErrorNoSuggestion
- ? new String[] {errorTokenName}
- : new String[0],
+ arguments,
+ arguments,
// this is the current -invalid- token position
startPos,
scanner.currentPosition - 1,
@@ -2087,13 +2621,15 @@
this.handle(
IProblem.ShouldReturnValue,
new String[] { new String (returnType.readableName())},
+ new String[] { new String (returnType.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void signalNoImplicitStringConversionForCharArrayExpression(Expression expression) {
this.handle(
IProblem.NoImplicitStringConversionForCharArrayExpression,
- new String[] {},
+ NoArgument,
+ NoArgument,
expression.sourceStart,
expression.sourceEnd);
}
@@ -2104,6 +2640,7 @@
// 8.4.6.4 - If a class inherits more than one method with the same signature a static (non-abstract) method cannot hide an instance method.
IProblem.CannotHideAnInstanceMethodWithAStaticMethod,
new String[] {new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
else
@@ -2112,27 +2649,34 @@
// 8.4.6.4 - If a class inherits more than one method with the same signature an instance (non-abstract) method cannot override a static method.
IProblem.CannotOverrideAStaticMethodWithAnInstanceMethod,
new String[] {new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
}
public void staticFieldAccessToNonStaticVariable(FieldReference fieldRef, FieldBinding field) {
+ String[] arguments = new String[] {new String(field.readableName())};
this.handle(
IProblem.NonStaticFieldFromStaticInvocation,
- new String[] {new String(field.readableName())},
+ arguments,
+ arguments,
fieldRef.sourceStart,
fieldRef.sourceEnd);
}
public void staticFieldAccessToNonStaticVariable(QualifiedNameReference nameRef, FieldBinding field){
+ String[] arguments = new String[] {new String(field.readableName())};
this.handle(
IProblem.NonStaticFieldFromStaticInvocation,
- new String[] { new String(field.readableName())},
+ arguments,
+ arguments,
nameRef.sourceStart,
nameRef.sourceEnd);
}
public void staticFieldAccessToNonStaticVariable(SingleNameReference nameRef, FieldBinding field) {
+ String[] arguments = new String[] {new String(field.readableName())};
this.handle(
IProblem.NonStaticFieldFromStaticInvocation,
- new String[] {new String(field.readableName())},
+ arguments,
+ arguments,
nameRef.sourceStart,
nameRef.sourceEnd);
}
@@ -2144,13 +2688,17 @@
new String[] {
new String(concreteMethod.readableName()),
new String(abstractMethods[0].declaringClass.readableName())},
+ new String[] {
+ new String(concreteMethod.readableName()),
+ new String(abstractMethods[0].declaringClass.shortReadableName())},
type.sourceStart(),
type.sourceEnd());
}
public void stringConstantIsExceedingUtf8Limit(AstNode location) {
this.handle(
IProblem.StringConstantIsExceedingUtf8Limit,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
@@ -2158,6 +2706,7 @@
this.handle(
IProblem.SuperclassMustBeAClass,
new String[] {new String(superType.readableName()), new String(type.sourceName())},
+ new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
superclassRef.sourceStart,
superclassRef.sourceEnd);
}
@@ -2165,57 +2714,127 @@
this.handle(
IProblem.SuperInterfaceMustBeAnInterface,
new String[] {new String(superType.readableName()), new String(type.sourceName())},
+ new String[] {new String(superType.shortReadableName()), new String(type.sourceName())},
typeDecl.sourceStart,
typeDecl.sourceEnd);
}
+public void task(String tag, String message, String priority, int start, int end){
+ this.handle(
+ IProblem.Task,
+ new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/},
+ new String[] { tag, message, priority/*secret argument that is not surfaced in getMessage()*/},
+ start,
+ end);
+}
+public void tooManyDimensions(AstNode expression) {
+ this.handle(
+ IProblem.TooManyArrayDimensions,
+ NoArgument,
+ NoArgument,
+ expression.sourceStart,
+ expression.sourceEnd);
+}
+public void tooManyFields(TypeDeclaration typeDeclaration) {
+ this.handle(
+ IProblem.TooManyFields,
+ new String[]{ new String(typeDeclaration.binding.readableName())},
+ new String[]{ new String(typeDeclaration.binding.shortReadableName())},
+ Abort | Error,
+ typeDeclaration.sourceStart,
+ typeDeclaration.sourceEnd);
+}
+public void tooManyMethods(TypeDeclaration typeDeclaration) {
+ this.handle(
+ IProblem.TooManyMethods,
+ new String[]{ new String(typeDeclaration.binding.readableName())},
+ new String[]{ new String(typeDeclaration.binding.shortReadableName())},
+ Abort | Error,
+ typeDeclaration.sourceStart,
+ typeDeclaration.sourceEnd);
+}
public void typeCastError(CastExpression expression, TypeBinding leftType, TypeBinding rightType) {
+ String leftName = new String(leftType.readableName());
+ String rightName = new String(rightType.readableName());
+ String leftShortName = new String(leftType.shortReadableName());
+ String rightShortName = new String(rightType.shortReadableName());
+ if (leftShortName.equals(rightShortName)){
+ leftShortName = leftName;
+ rightShortName = rightName;
+ }
this.handle(
IProblem.IllegalCast,
- new String[] {new String(rightType.readableName()), new String(leftType.readableName())},
+ new String[] { rightName, leftName },
+ new String[] { rightShortName, leftShortName },
expression.sourceStart,
expression.sourceEnd);
}
public void typeCollidesWithPackage(CompilationUnitDeclaration compUnitDecl, TypeDeclaration typeDecl) {
this.referenceContext = typeDecl; // report the problem against the type not the entire compilation unit
+ String[] arguments = new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)};
this.handle(
IProblem.TypeCollidesWithPackage,
- new String[] {new String(compUnitDecl.getFileName()), new String(typeDecl.name)},
+ arguments,
+ arguments,
typeDecl.sourceStart,
typeDecl.sourceEnd,
compUnitDecl.compilationResult);
}
public void typeMismatchError(TypeBinding resultType, TypeBinding expectedType, AstNode location) {
+ String resultTypeName = new String(resultType.readableName());
+ String expectedTypeName = new String(expectedType.readableName());
+ String resultTypeShortName = new String(resultType.shortReadableName());
+ String expectedTypeShortName = new String(expectedType.shortReadableName());
+ if (resultTypeShortName.equals(expectedTypeShortName)){
+ resultTypeShortName = resultTypeName;
+ expectedTypeShortName = expectedTypeName;
+ }
this.handle(
IProblem.TypeMismatch,
- new String[] {new String(resultType.readableName()), new String(expectedType.readableName())},
+ new String[] {resultTypeName, expectedTypeName},
+ new String[] {resultTypeShortName, expectedTypeShortName},
location.sourceStart,
location.sourceEnd);
}
public void typeMismatchErrorActualTypeExpectedType(Expression expression, TypeBinding constantType, TypeBinding expectedType) {
+ String constantTypeName = new String(constantType.readableName());
+ String expectedTypeName = new String(expectedType.readableName());
+ String constantTypeShortName = new String(constantType.shortReadableName());
+ String expectedTypeShortName = new String(expectedType.shortReadableName());
+ if (constantTypeShortName.equals(expectedTypeShortName)){
+ constantTypeShortName = constantTypeName;
+ expectedTypeShortName = expectedTypeName;
+ }
this.handle(
IProblem.TypeMismatch,
- new String[] {new String(constantType.readableName()), new String(expectedType.readableName())},
+ new String[] {constantTypeName, expectedTypeName},
+ new String[] {constantTypeShortName, expectedTypeShortName},
expression.sourceStart,
expression.sourceEnd);
}
public void undefinedLabel(BranchStatement statement) {
+ String[] arguments = new String[] {new String(statement.label)};
this.handle(
IProblem.UndefinedLabel,
- new String[] {new String(statement.label)},
+ arguments,
+ arguments,
statement.sourceStart,
statement.sourceEnd);
}
public void unexpectedStaticModifierForField(SourceTypeBinding type, FieldDeclaration fieldDecl) {
+ String[] arguments = new String[] {fieldDecl.name()};
this.handle(
IProblem.UnexpectedStaticModifierForField,
- new String[] {fieldDecl.name()},
+ arguments,
+ arguments,
fieldDecl.sourceStart,
fieldDecl.sourceEnd);
}
public void unexpectedStaticModifierForMethod(ReferenceBinding type, AbstractMethodDeclaration methodDecl) {
+ String[] arguments = new String[] {new String(type.sourceName()), new String(methodDecl.selector)};
this.handle(
IProblem.UnexpectedStaticModifierForMethod,
- new String[] {new String(type.sourceName()), new String(methodDecl.selector)},
+ arguments,
+ arguments,
methodDecl.sourceStart,
methodDecl.sourceEnd);
}
@@ -2235,20 +2854,25 @@
? IProblem.UndefinedConstructorInImplicitConstructorCall
: IProblem.UnhandledException),
new String[] {new String(exceptionType.readableName())},
+ new String[] {new String(exceptionType.shortReadableName())},
location.sourceStart,
location.sourceEnd);
}
public void uninitializedBlankFinalField(FieldBinding binding, AstNode location) {
+ String[] arguments = new String[] {new String(binding.readableName())};
this.handle(
IProblem.UninitializedBlankFinalField,
- new String[] {new String(binding.readableName())},
+ arguments,
+ arguments,
location.sourceStart,
location.sourceEnd);
}
public void uninitializedLocalVariable(LocalVariableBinding binding, AstNode location) {
+ String[] arguments = new String[] {new String(binding.readableName())};
this.handle(
IProblem.UninitializedLocalVariable,
- new String[] {new String(binding.readableName())},
+ arguments,
+ arguments,
location.sourceStart,
location.sourceEnd);
}
@@ -2256,7 +2880,8 @@
this.handle(
IProblem.UnmatchedBracket,
- new String[] {},
+ NoArgument,
+ NoArgument,
position,
position,
context,
@@ -2266,20 +2891,39 @@
this.handle(
IProblem.IllegalEnclosingInstanceSpecification,
new String[]{ new String(targetType.readableName())},
+ new String[]{ new String(targetType.shortReadableName())},
expression.sourceStart,
expression.sourceEnd);
}
+public void unnecessaryReceiverForStaticMethod(AstNode location, MethodBinding method) {
+ this.handle(
+ IProblem.NonStaticAccessToStaticMethod,
+ new String[] {new String(method.declaringClass.readableName()), new String(method.selector), parametersAsString(method)},
+ new String[] {new String(method.declaringClass.shortReadableName()), new String(method.selector), parametersAsShortString(method)},
+ location.sourceStart,
+ location.sourceEnd);
+}
+public void unnecessaryReceiverForStaticField(AstNode location, FieldBinding field) {
+ this.handle(
+ IProblem.NonStaticAccessToStaticField,
+ new String[] {new String(field.declaringClass.readableName()), new String(field.name)},
+ new String[] {new String(field.declaringClass.shortReadableName()), new String(field.name)},
+ location.sourceStart,
+ location.sourceEnd);
+}
public void unreachableCode(Statement statement) {
this.handle(
IProblem.CodeCannotBeReached,
- new String[0],
+ NoArgument,
+ NoArgument,
statement.sourceStart,
statement.sourceEnd);
}
public void unreachableExceptionHandler(ReferenceBinding exceptionType, AstNode location) {
this.handle(
IProblem.UnreachableCatch,
- new String[0],
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
@@ -2292,54 +2936,182 @@
severity = SecondaryError;
}
*/
+ String[] arguments = new String[] {new String(binding.readableName())};
this.handle(
IProblem.UndefinedName,
- new String[] {new String(binding.readableName())},
+ arguments,
+ arguments,
severity,
nameRef.sourceStart,
nameRef.sourceEnd);
}
public void unusedArgument(LocalDeclaration localDecl) {
+
+ String[] arguments = new String[] {localDecl.name()};
this.handle(
IProblem.ArgumentIsNeverUsed,
- new String[] {localDecl.name()},
+ arguments,
+ arguments,
localDecl.sourceStart,
localDecl.sourceEnd);
}
public void unusedImport(ImportReference importRef) {
+ String[] arguments = new String[] { CharOperation.toString(importRef.tokens) };
this.handle(
IProblem.UnusedImport,
- new String[] { CharOperation.toString(importRef.tokens) },
+ arguments,
+ arguments,
importRef.sourceStart,
importRef.sourceEnd);
}
public void unusedLocalVariable(LocalDeclaration localDecl) {
+ String[] arguments = new String[] {localDecl.name()};
this.handle(
IProblem.LocalVariableIsNeverUsed,
- new String[] {localDecl.name()},
+ arguments,
+ arguments,
localDecl.sourceStart,
localDecl.sourceEnd);
}
+public void unusedPrivateConstructor(ConstructorDeclaration constructorDecl) {
+
+ if (computeSeverity(IProblem.UnusedPrivateConstructor) == Ignore) return;
+ // no complaint for no-arg constructors (or default ones) - known pattern to block instantiation
+ if (constructorDecl.arguments == null || constructorDecl.arguments.length == 0) return;
+
+ MethodBinding constructor = constructorDecl.binding;
+ this.handle(
+ IProblem.UnusedPrivateConstructor,
+ new String[] {
+ new String(constructor.declaringClass.readableName()),
+ parametersAsString(constructor)
+ },
+ new String[] {
+ new String(constructor.declaringClass.shortReadableName()),
+ parametersAsShortString(constructor)
+ },
+ constructorDecl.sourceStart,
+ constructorDecl.sourceEnd);
+}
+public void unusedPrivateField(FieldDeclaration fieldDecl) {
+
+ if (computeSeverity(IProblem.UnusedPrivateField) == Ignore) return;
+
+ FieldBinding field = fieldDecl.binding;
+
+ if (CharOperation.equals(TypeConstants.SERIALVERSIONUID, field.name)
+ && field.isStatic()
+ && field.isFinal()
+ && TypeBinding.LongBinding == field.type) {
+ return; // do not report unused serialVersionUID field
+ }
+ this.handle(
+ IProblem.UnusedPrivateField,
+ new String[] {
+ new String(field.declaringClass.readableName()),
+ new String(field.name),
+ },
+ new String[] {
+ new String(field.declaringClass.shortReadableName()),
+ new String(field.name),
+ },
+ fieldDecl.sourceStart,
+ fieldDecl.sourceEnd);
+}
+public void unusedPrivateMethod(AbstractMethodDeclaration methodDecl) {
+
+ if (computeSeverity(IProblem.UnusedPrivateMethod) == Ignore) return;
+
+ MethodBinding method = methodDecl.binding;
+
+ // no report for serialization support 'void readObject(ObjectInputStream)'
+ if (!method.isStatic()
+ && TypeBinding.VoidBinding == method.returnType
+ && method.parameters.length == 1
+ && method.parameters[0].dimensions() == 0
+ && CharOperation.equals(method.selector, TypeConstants.READOBJECT)
+ && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTINPUTSTREAM, method.parameters[0].readableName())) {
+ return;
+ }
+ // no report for serialization support 'void writeObject(ObjectOutputStream)'
+ if (!method.isStatic()
+ && TypeBinding.VoidBinding == method.returnType
+ && method.parameters.length == 1
+ && method.parameters[0].dimensions() == 0
+ && CharOperation.equals(method.selector, TypeConstants.WRITEOBJECT)
+ && CharOperation.equals(TypeConstants.CharArray_JAVA_IO_OBJECTOUTPUTSTREAM, method.parameters[0].readableName())) {
+ return;
+ }
+ // no report for serialization support 'Object readResolve()'
+ if (!method.isStatic()
+ && TypeBinding.T_Object == method.returnType.id
+ && method.parameters.length == 0
+ && CharOperation.equals(method.selector, TypeConstants.READRESOLVE)) {
+ return;
+ }
+ // no report for serialization support 'Object writeReplace()'
+ if (!method.isStatic()
+ && TypeBinding.T_Object == method.returnType.id
+ && method.parameters.length == 0
+ && CharOperation.equals(method.selector, TypeConstants.WRITEREPLACE)) {
+ return;
+ }
+ this.handle(
+ IProblem.UnusedPrivateMethod,
+ new String[] {
+ new String(method.declaringClass.readableName()),
+ new String(method.selector),
+ parametersAsString(method)
+ },
+ new String[] {
+ new String(method.declaringClass.shortReadableName()),
+ new String(method.selector),
+ parametersAsShortString(method)
+ },
+ methodDecl.sourceStart,
+ methodDecl.sourceEnd);
+}
+public void unusedPrivateType(TypeDeclaration typeDecl) {
+
+ if (computeSeverity(IProblem.UnusedPrivateType) == Ignore) return;
+
+ ReferenceBinding type = typeDecl.binding;
+ this.handle(
+ IProblem.UnusedPrivateType,
+ new String[] {
+ new String(type.readableName()),
+ },
+ new String[] {
+ new String(type.shortReadableName()),
+ },
+ typeDecl.sourceStart,
+ typeDecl.sourceEnd);
+}
public void useAssertAsAnIdentifier(int sourceStart, int sourceEnd) {
this.handle(
IProblem.UseAssertAsAnIdentifier,
- new String[0],
+ NoArgument,
+ NoArgument,
sourceStart,
sourceEnd);
}
public void variableTypeCannotBeVoid(AbstractVariableDeclaration varDecl) {
+ String[] arguments = new String[] {new String(varDecl.name)};
this.handle(
IProblem.VariableTypeCannotBeVoid,
- new String[] {new String(varDecl.name)},
+ arguments,
+ arguments,
varDecl.sourceStart,
varDecl.sourceEnd);
}
public void variableTypeCannotBeVoidArray(AbstractVariableDeclaration varDecl) {
+ String[] arguments = new String[] {new String(varDecl.name)};
this.handle(
IProblem.VariableTypeCannotBeVoidArray,
- new String[] {new String(varDecl.name)},
+ arguments,
+ arguments,
varDecl.sourceStart,
varDecl.sourceEnd);
}
@@ -2350,6 +3122,7 @@
// 8.4.6.3 - The access modifier of an overiding method must provide at least as much access as the overriden method.
IProblem.MethodReducesVisibility,
new String[] {new String(inheritedMethod.declaringClass.readableName())},
+ new String[] {new String(inheritedMethod.declaringClass.shortReadableName())},
currentMethod.sourceStart(),
currentMethod.sourceEnd());
}
@@ -2357,15 +3130,11 @@
//the two catch block under and upper are in an incorrect order.
//under should be define BEFORE upper in the source
- //notice that the compiler could arrange automatically the
- //correct order - and the only error would be on cycle ....
- //on this one again , java is compiler-driven instead of being
- //user-driven .....
-
TypeReference typeRef = statement.catchArguments[under].type;
this.handle(
IProblem.UnreachableCatch,
- new String[0],
+ NoArgument,
+ NoArgument,
typeRef.sourceStart,
typeRef.sourceEnd);
}
@@ -2373,15 +3142,27 @@
public void nonExternalizedStringLiteral(AstNode location) {
this.handle(
IProblem.NonExternalizedStringLiteral,
- new String[] {},
+ NoArgument,
+ NoArgument,
location.sourceStart,
location.sourceEnd);
}
+public void noMoreAvailableSpaceForConstant(TypeDeclaration typeDeclaration) {
+ this.handle(
+ IProblem.TooManyBytesForStringConstant,
+ new String[]{ new String(typeDeclaration.binding.readableName())},
+ new String[]{ new String(typeDeclaration.binding.shortReadableName())},
+ Abort | Error,
+ typeDeclaration.sourceStart,
+ typeDeclaration.sourceEnd);
+}
+
public void noMoreAvailableSpaceInConstantPool(TypeDeclaration typeDeclaration) {
this.handle(
IProblem.TooManyConstantsInConstantPool,
new String[]{ new String(typeDeclaration.binding.readableName())},
+ new String[]{ new String(typeDeclaration.binding.shortReadableName())},
Abort | Error,
typeDeclaration.sourceStart,
typeDeclaration.sourceEnd);
@@ -2406,7 +3187,7 @@
return false;
}
int nextToken= scanner.getNextToken();
- if (nextToken == ITerminalSymbols.TokenNameEOF
+ if (nextToken == TerminalTokens.TokenNameEOF
&& scanner.startPosition == scanner.source.length) { // to handle case where we had an ArrayIndexOutOfBoundsException
// while reading the last token
switch(token) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemSeverities.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemSeverities.java
index 166e078..3ecb48c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemSeverities.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemSeverities.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
public interface ProblemSeverities {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ShouldNotImplement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ShouldNotImplement.java
index 8fdea8c..1177c69 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ShouldNotImplement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ShouldNotImplement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.problem;
/*
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
index 2d27c11..d83147c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -1,3 +1,13 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
0 = {0}
1 = super cannot be used in java.lang.Object
2 = {0} cannot be resolved or is not a type
@@ -5,20 +15,21 @@
4 = The type {0} is ambiguous
5 = The type {0} is deprecated
6 = The type {0} is an incorrectly specified nested type; replace the ''$'' with ''.''
+7 = The private type {0} is never used locally
15 = Incompatible operand types {0} and {1}
16 = Incompatible conditional operand types {0} and {1}
17 = Type mismatch: cannot convert from {0} to {1}
-20 = No enclosing instance of the type {0} is accessible to invoke the super constructor. Must define a constructor and explicitly qualify its super constructor invocation with an instance of {0} (e.g. x.super() where x is an instance of {0}).
-21 = Must explicitly qualify the allocation with an enclosing instance of type {0} (e.g. x.new A() where x is an instance of {0}).
+20 = No enclosing instance of type {0} is accessible to invoke the super constructor. Must define a constructor and explicitly qualify its super constructor invocation with an instance of {0} (e.g. x.super() where x is an instance of {0}).
+21 = No enclosing instance of type {0} is accessible. Must qualify the allocation with an enclosing instance of type {0} (e.g. x.new A() where x is an instance of {0}).
22 = No enclosing instance of the type {0} is accessible in scope
23 = Illegal enclosing instance specification for type {0}
24 = Cannot define static initializer in inner type {0}
25 = Cannot refer to a non-final variable {0} inside an inner class defined in a different method
26 = The member interface {0} can only be defined inside a top-level class or interface
27 = Cannot use an expression of the type {0} as a valid enclosing instance
-
+28 = No enclosing instance of type {0} is available due to some intermediate constructor invocation
29 = An anonymous class cannot subclass the final class {0}
50 = {0} cannot be resolved
@@ -29,23 +40,28 @@
55 = Duplicate local variable {0}
56 = Duplicate argument {0}
57 = The final local variable {0} may already have been assigned
+58 = The final local variable {0} cannot be assigned. It must be blank and not using a compound assignment
-60 = Cannot assign to the final local variable {0} defined outside this inner class
+60 = The final local variable {0} cannot be assigned, since it is defined in an enclosing type
61 = The local variable {0} is never read
62 = The argument {0} is never read
-63 = Code of method {0} is exceeding the 65535 bytes limit
-64 = Code for the static initializer is exceeding the 65535 bytes limit
+63 = The code of method {0}({1}) is exceeding the 65535 bytes limit
+64 = The code for the static initializer is exceeding the 65535 bytes limit
65 = Too many arguments, parameter {0} is exceeding the limit of 255 words eligible for method arguments
66 = Too many local variables, local variable {0} is exceeding the limit of 65535 words eligible for method local variables
-
+67 = Too many synthetic arguments, emulated parameter {0} is exceeding the limit of 255 words eligible for method arguments
+68 = Too many array dimensions. Maximum is 255
+69 = The code of constructor {0}({1}) is exceeding the 65535 bytes limit
70 = {0} cannot be resolved or is not a field
71 = The field {0} is not visible
72 = The field {0} is ambiguous
73 = The field {0}.{1} is deprecated
74 = Cannot make a static reference to the non-static field {0}
75 = Cannot reference a field before it is defined
+76 = The static field {0}.{1} should be accessed in a static way
+77 = The private field {0}.{1} is never used locally
-80 = Cannot assign a value to the final field {0}.{1}
+80 = The final field {0}.{1} cannot be assigned. It must be blank in this context, not qualified and not in compound assignment
81 = The blank final field {0} may not have been initialized
82 = The final field {0} may already have been assigned
@@ -66,11 +82,14 @@
114 = Cannot invoke {1}({2}) on the primitive type {0}
115 = The method {1}({2}) in the type {0} is not applicable for the arguments ({3})
116 = Cannot invoke {1}({2}) on the array type {0}
+117 = The static method {1}({2}) from the type {0} should be accessed in a static way
+118 = The private method {1}({2}) from the type {0} is never used locally
130 = The constructor {0}({1}) is undefined
131 = The constructor {0}({1}) is not visible
132 = The constructor {0}({1}) is ambiguous
133 = The constructor {0}({1}) is deprecated
+134 = The private constructor {0}({1}) is never used locally
135 = Cannot refer to an instance field {0} while explicitly invoking a constructor
136 = Cannot refer to an instance method while explicitly invoking a constructor
137 = Recursive constructor invocation {0}({1})
@@ -91,7 +110,7 @@
153 = case expressions must be constant expressions
154 = {0} is out of range
156 = Cannot cast from {0} to {1}
-157 = Cannot instantiate {0}
+157 = The type {0} cannot be instantiated
158 = Cannot define dimension expressions when an array initializer is provided
159 = Variable must provide either dimension expressions or an array initializer
160 = The operator {0} is undefined for the argument type(s) {1}
@@ -100,23 +119,24 @@
163 = Initializer does not complete normally
164 = Expression must return a value
165 = Catch block is hidden by another one in the same try statement
-166 = Duplicate default case
+166 = The default case is already defined
167 = Unreachable catch block
168 = Unhandled exception type {0}
169 = case constant must be a char, byte, short, or int instead of {0}
170 = Duplicate case {0}
171 = Duplicate label {0}
-172 = Missing valid breakable location
-173 = Missing loop-continuation point
-174 = Missing label {0}
+172 = break cannot be used outside of a loop or a switch
+173 = continue cannot be used outside of a loop
+174 = The label {0} is missing
175 = {0} is not a valid type''s argument for the synchronized statement
176 = null is not a valid argument for the synchronized statement
177 = Cannot throw null
+178 = The assignment to variable {0} has no effect
-190 = Read access to enclosing field {0}.{1} is emulated by a synthetic accessor method
-191 = Write access to enclosing field {0}.{1} is emulated by a synthetic accessor method
-192 = Access to enclosing method {1}({2}) from the type {0} is emulated by a synthetic accessor method
-193 = Access to enclosing constructor {0}({1}) is emulated by a synthetic accessor method
+190 = Read access to enclosing field {0}.{1} is emulated by a synthetic accessor method. Increasing its visibility will improve your performance
+191 = Write access to enclosing field {0}.{1} is emulated by a synthetic accessor method. Increasing its visibility will improve your performance
+192 = Access to enclosing method {1}({2}) from the type {0} is emulated by a synthetic accessor method. Increasing its visibility will improve your performance
+193 = Access to enclosing constructor {0}({1}) is emulated by a synthetic accessor method. Increasing its visibility will improve your performance
195 = The method {1} is defined in an inherited type and an enclosing scope
196 = The field {0} is defined in an inherited type and an enclosing scope
197 = The type {0} is defined in an inherited type and an enclosing scope
@@ -136,6 +156,9 @@
220 = Unmatched bracket
221 = The primitive type {0} of {1} does not have a field {2}
222 = Invalid expression as statement
+223 = The left-hand side of an assignment must be a variable
+224 = Missing semicolon
+225 = Invalid parenthesized expression
250 = Unexpected end of file
251 = Invalid hexa literal number
@@ -178,6 +201,7 @@
326 = A package must be specified in {0} or a default package created
327 = The hierarchy of the type {0} is inconsistent
328 = The declared package does not match the expected package {0}
+329 = The type java.lang.Object cannot have a superclass or superinterfaces
330 = {0} cannot be resolved or is not a valid superclass
331 = Superclass {0} is not visible
@@ -256,12 +280,20 @@
409 = Cannot reduce the visibility of the inherited method from {0}
410 = The method {0} does not override the inherited method from {1} since it is private to a different package.
411 = This class must implement the inherited abstract method {1}, but cannot override it since it is not visible from {0}. Either make the type abstract or make the inherited method visible.
-412 = This method overrides deprecated method from {0}
+412 = The method {0} overrides a deprecated method from {1}
+413 = The return type is incompatible with {0}, thus this interface cannot be implemented
+414 = Exception {0} is not compatible with throws clause in {1}, thus this interface cannot be implemented
420 = Code snippet support cannot find the class {0}
421 = Code snippet support cannot find the method {0}.{1}({2})
422 = super cannot be used in the code snippet code
430 = Too many constants, the constant pool for {0} would exceed 65536 entries
+431 = The type generates a string that requires more than 65535 bytes to encode in Utf8 format in the constant pool
-440 = ''assert'' should not be used as an identifier, since it is a reserved keyword from source level 1.4 on
\ No newline at end of file
+432 = Too many fields for type {0}. Maximum is 65535
+433 = Too many methods for type {0}. Maximum is 65535
+
+440 = ''assert'' should not be used as an identifier, since it is a reserved keyword from source level 1.4 on
+
+450 = {0} {1}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java
deleted file mode 100644
index 4f4061e..0000000
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CharOperation.java
+++ /dev/null
@@ -1,703 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.internal.compiler.util;
-
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-
-public final class CharOperation {
-
-public static final char[] append(char[] array, char suffix){
- if (array == null) return new char[]{suffix};
- int length = array.length;
- System.arraycopy(array, 0, array = new char[length+1], 0, length);
- array[length]=suffix;
- return array;
-}
-
-public static final char[][] arrayConcat(char[][] first, char[][] second) {
- if (first == null)
- return second;
- if (second == null)
- return first;
-
- int length1 = first.length;
- int length2 = second.length;
- char[][] result = new char[length1 + length2][];
-/* if we do not trust System.arraycopy on our VM with char[][]'s
- int i;
- for (i = 0; i < length1; i++)
- result[i] = first[i];
- for (int j = 0; j < length2; j++)
- result[i++] = second[j];
-*/
- System.arraycopy(first, 0, result, 0, length1);
- System.arraycopy(second, 0, result, length1, length2);
- return result;
-}
-public static final char[][] arrayConcat(char[][] first, char[] second) {
- if (second == null)
- return first;
- if (first == null)
- return new char[][] {second};
-
- int length = first.length;
- char[][] result = new char[length + 1][];
-/* if we do not trust System.arraycopy on our VM with char[][]'s
- for (int i = 0; i < length; i++)
- result[i] = first[i];
-*/
- System.arraycopy(first, 0, result, 0, length);
- result[length] = second;
- return result;
-}
-public static final char[] concat(char[] first, char[] second) {
- if (first == null)
- return second;
- if (second == null)
- return first;
-
- int length1 = first.length;
- int length2 = second.length;
- char[] result = new char[length1 + length2];
- System.arraycopy(first, 0, result, 0, length1);
- System.arraycopy(second, 0, result, length1, length2);
- return result;
-}
-public static final char[] concat(char[] first, char[] second, char[] third) {
- if (first == null)
- return concat(second, third);
- if (second == null)
- return concat(first, third);
- if (third == null)
- return concat(first, second);
-
- int length1 = first.length;
- int length2 = second.length;
- int length3 = third.length;
- char[] result = new char[length1 + length2 + length3];
- System.arraycopy(first, 0, result, 0, length1);
- System.arraycopy(second, 0, result, length1, length2);
- System.arraycopy(third, 0, result, length1 + length2, length3);
- return result;
-}
-public static final char[] concat(char[] first, char[] second, char separator) {
- if (first == null)
- return second;
- if (second == null)
- return first;
-
- int length1 = first.length;
- if (length1 == 0)
- return second;
- int length2 = second.length;
- if (length2 == 0)
- return first;
-
- char[] result = new char[length1 + length2 + 1];
- System.arraycopy(first, 0, result, 0, length1);
- result[length1] = separator;
- System.arraycopy(second, 0, result, length1 + 1, length2);
- return result;
-}
-public static final char[] concat(char[] first, char sep1, char[] second, char sep2, char[] third) {
- if (first == null)
- return concat(second, third, sep2);
- if (second == null)
- return concat(first, third, sep1);
- if (third == null)
- return concat(first, second, sep1);
-
- int length1 = first.length;
- int length2 = second.length;
- int length3 = third.length;
- char[] result = new char[length1 + length2 + length3 + 2];
- System.arraycopy(first, 0, result, 0, length1);
- result[length1] = sep1;
- System.arraycopy(second, 0, result, length1 + 1, length2);
- result[length1+length2+1] = sep2;
- System.arraycopy(third, 0, result, length1 + length2 + 2, length3);
- return result;
-}
-public static final char[] concat(char prefix, char[] array, char suffix) {
- if (array == null)
- return new char[] {prefix, suffix};
-
- int length = array.length;
- char[] result = new char[length + 2];
- result[0] = prefix;
- System.arraycopy(array, 0, result, 1, length);
- result[length + 1] = suffix;
- return result;
-}
-public static final char[] concatWith(char[] name, char[][] array, char separator) {
- int nameLength = name == null ? 0 : name.length;
- if (nameLength == 0)
- return concatWith(array, separator);
-
- int length = array == null ? 0 : array.length;
- if (length == 0)
- return name;
-
- int size = nameLength;
- int index = length;
- while (--index >= 0)
- if (array[index].length > 0)
- size += array[index].length + 1;
- char[] result = new char[size];
- index = size;
- for (int i = length-1; i >= 0; i--) {
- int subLength = array[i].length;
- if (subLength > 0) {
- index -= subLength;
- System.arraycopy(array[i], 0, result, index, subLength);
- result[--index] = separator;
- }
- }
- System.arraycopy(name, 0, result, 0, nameLength);
- return result;
-}
-public static final char[] concatWith(char[][] array, char[] name, char separator) {
- int nameLength = name == null ? 0 : name.length;
- if (nameLength == 0)
- return concatWith(array, separator);
-
- int length = array == null ? 0 : array.length;
- if (length == 0)
- return name;
-
- int size = nameLength;
- int index = length;
- while (--index >= 0)
- if (array[index].length > 0)
- size += array[index].length + 1;
- char[] result = new char[size];
- index = 0;
- for (int i = 0; i < length; i++) {
- int subLength = array[i].length;
- if (subLength > 0) {
- System.arraycopy(array[i], 0, result, index, subLength);
- index += subLength;
- result[index++] = separator;
- }
- }
- System.arraycopy(name, 0, result, index, nameLength);
- return result;
-}
-public static final char[] concatWith(char[][] array, char separator) {
- int length = array == null ? 0 : array.length;
- if (length == 0)
- return TypeConstants.NoChar;
-
- int size = length - 1;
- int index = length;
- while (--index >= 0) {
- if (array[index].length == 0)
- size--;
- else
- size += array[index].length;
- }
- if (size <= 0)
- return TypeConstants.NoChar;
- char[] result = new char[size];
- index = length;
- while (--index >= 0) {
- length = array[index].length;
- if (length > 0) {
- System.arraycopy(array[index], 0, result, (size -= length), length);
- if (--size >= 0)
- result[size] = separator;
- }
- }
- return result;
-}
-public static final boolean contains(char character, char[][] array) {
- for (int i = array.length; --i >= 0;) {
- char[] subarray = array[i];
- for (int j = subarray.length; --j >= 0;)
- if (subarray[j] == character)
- return true;
- }
- return false;
-}
-public static final boolean contains(char character, char[] array) {
- for (int i = array.length; --i >= 0;)
- if (array[i] == character)
- return true;
- return false;
-}
-public static final char[][] deepCopy(char[][] toCopy) {
- int toCopyLength = toCopy.length;
- char[][] result = new char[toCopyLength][];
- for (int i = 0; i < toCopyLength; i++) {
- char[] toElement = toCopy[i];
- int toElementLength = toElement.length;
- char[] resultElement = new char[toElementLength];
- System.arraycopy(toElement, 0, resultElement, 0, toElementLength);
- result[i] = resultElement;
- }
- return result;
-}
-
-public static final boolean endsWith(char[] array, char[] toBeFound) {
- int i = toBeFound.length;
- int j = array.length - i;
-
- if (j < 0)
- return false;
- while (--i >= 0)
- if (toBeFound[i] != array[i + j])
- return false;
- return true;
-}
-
-public static final boolean equals(char[][] first, char[][] second) {
- if (first == second)
- return true;
- if (first == null || second == null)
- return false;
- if (first.length != second.length)
- return false;
-
- for (int i = first.length; --i >= 0;)
- if (!equals(first[i], second[i]))
- return false;
- return true;
-}
-public static final boolean equals(char[][] first, char[][] second, boolean isCaseSensitive) {
-
- if (isCaseSensitive){
- return equals(first, second);
- }
- if (first == second)
- return true;
- if (first == null || second == null)
- return false;
- if (first.length != second.length)
- return false;
-
- for (int i = first.length; --i >= 0;)
- if (!equals(first[i], second[i], false))
- return false;
- return true;
-}
-public static final boolean equals(char[] first, char[] second) {
- if (first == second)
- return true;
- if (first == null || second == null)
- return false;
- if (first.length != second.length)
- return false;
-
- for (int i = first.length; --i >= 0;)
- if (first[i] != second[i])
- return false;
- return true;
-}
-public static final boolean equals(char[] first, char[] second, boolean isCaseSensitive) {
-
- if (isCaseSensitive){
- return equals(first, second);
- }
- if (first == second)
- return true;
- if (first == null || second == null)
- return false;
- if (first.length != second.length)
- return false;
-
- for (int i = first.length; --i >= 0;)
- if (Character.toLowerCase(first[i]) != Character.toLowerCase(second[i]))
- return false;
- return true;
-}
-public static final boolean fragmentEquals(char[] fragment, char[] name, int startIndex, boolean isCaseSensitive) {
-
- int max = fragment.length;
- if (name.length < max+startIndex) return false;
- if (isCaseSensitive){
- for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
- if (fragment[i] != name[i + startIndex])
- return false;
- return true;
- }
- for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
- if (Character.toLowerCase(fragment[i]) != Character.toLowerCase(name[i + startIndex]))
- return false;
- return true;
-}
-public static final int hashCode(char[] array) {
- int hash = 0;
- int offset = 0;
- int length = array.length;
- if (length < 16) {
- for (int i = length; i > 0; i--)
- hash = (hash * 37) + array[offset++];
- } else {
- // only sample some characters
- int skip = length / 8;
- for (int i = length; i > 0; i -= skip, offset += skip)
- hash = (hash * 39) + array[offset];
- }
- return hash & 0x7FFFFFFF;
-}
-public static final int indexOf(char toBeFound, char[] array) {
- for (int i = 0; i < array.length; i++)
- if (toBeFound == array[i])
- return i;
- return -1;
-}
-public static final int indexOf(char toBeFound, char[] array, int start) {
- for (int i = start; i < array.length; i++)
- if (toBeFound == array[i])
- return i;
- return -1;
-}
-public static final int lastIndexOf(char toBeFound, char[] array) {
- for (int i = array.length; --i >= 0;)
- if (toBeFound == array[i])
- return i;
- return -1;
-}
-public static final int lastIndexOf(char toBeFound, char[] array, int startIndex) {
- for (int i = array.length; --i >= startIndex;)
- if (toBeFound == array[i])
- return i;
- return -1;
-}
-public static final int lastIndexOf(char toBeFound, char[] array, int startIndex, int endIndex) {
- for (int i = endIndex; --i >= startIndex;)
- if (toBeFound == array[i])
- return i;
- return -1;
-}
-/**
- * Answer the last portion of a name given a separator
- * e.g. lastSegment("java.lang.Object".toCharArray(),'.') --> Object
- */
-final static public char[] lastSegment(char[] array, char separator) {
- int pos = lastIndexOf(separator, array);
- if (pos < 0) return array;
- return subarray(array, pos+1, array.length);
-}
-/**
- * char[] pattern matching, accepting wild-cards '*'.
- *
- * When not case sensitive, the pattern is assumed to already be lowercased, the
- * name will be lowercased character per character as comparing.
- */
-public static final boolean match(char[] pattern, char[] name, boolean isCaseSensitive) {
-
- if (name == null) return false; // null name cannot match
- if (pattern == null) return true; // null pattern is equivalent to '*'
- int iPattern = 0, patternLength = pattern.length;
- int iName = 0, nameLength = name.length;
-
- /* check first segment */
- char patternChar = 0;
- while ((iPattern < patternLength) && (patternChar = pattern[iPattern]) != '*'){
- if (iName == nameLength) return false;
- if (patternChar != (isCaseSensitive
- ? name[iName]
- : Character.toLowerCase(name[iName]))){
- return false;
- }
- iName++;
- iPattern++;
- }
- /* check sequence of star+segment */
- int segmentStart;
- if (patternChar == '*'){
- segmentStart = ++iPattern; // skip star
- } else {
- segmentStart = 0; // force iName check
- }
- int prefixStart = iName;
- checkSegment: while (iName < nameLength && iPattern < patternLength){
- /* segment is ending */
- if ((patternChar = pattern[iPattern]) == '*'){
- segmentStart = ++iPattern; // skip start
- prefixStart = iName;
- continue checkSegment;
- }
- /* chech current name character */
- if ((isCaseSensitive
- ? name[iName]
- : Character.toLowerCase(name[iName]))!= patternChar){
- iPattern = segmentStart; // mismatch - restart current segment
- iName = ++prefixStart;
- continue checkSegment;
- }
- iName++;
- iPattern++;
- }
-
- return (segmentStart == patternLength)
- || (iName == nameLength && iPattern == patternLength)
- || (iPattern == patternLength - 1 && pattern[iPattern] == '*');
-}
-public static final int occurencesOf(char toBeFound, char[] array) {
- int count = 0;
- for (int i = 0; i < array.length; i++)
- if (toBeFound == array[i]) count++;
- return count;
-}
-public static final int occurencesOf(char toBeFound, char[] array, int start) {
- int count = 0;
- for (int i = start; i < array.length; i++)
- if (toBeFound == array[i]) count++;
- return count;
-}
-public static final boolean prefixEquals(char[] prefix, char[] name) {
-
- int max = prefix.length;
- if (name.length < max) return false;
- for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
- if (prefix[i] != name[i])
- return false;
- return true;
-}
-public static final boolean prefixEquals(char[] prefix, char[] name, boolean isCaseSensitive) {
-
- int max = prefix.length;
- if (name.length < max) return false;
- if (isCaseSensitive){
- for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
- if (prefix[i] != name[i])
- return false;
- return true;
- }
-
- for (int i = max; --i >= 0;) // assumes the prefix is not larger than the name
- if (Character.toLowerCase(prefix[i]) != Character.toLowerCase(name[i]))
- return false;
- return true;
-}
-public static final void replace(
- char[] array,
- char toBeReplaced,
- char replacementChar) {
- if (toBeReplaced != replacementChar) {
- for (int i = 0, max = array.length; i < max; i++) {
- if (array[i] == toBeReplaced)
- array[i] = replacementChar;
- }
- }
-}
-
-/*
- * Returns a char[] with substitutions. No side-effect is operated on the original
- * array, in case no substitution happened, then the result might be the same as the
- * original one.
- *
- */
-public static final char[] replace(
- char[] array,
- char[] toBeReplaced,
- char[] replacementChars) {
-
-
- int max = array.length;
- int replacedLength = toBeReplaced.length;
- int replacementLength = replacementChars.length;
-
- int[] starts = new int[5];
- int occurrenceCount = 0;
-
- if (!equals(toBeReplaced,replacementChars)) {
-
- next: for (int i = 0; i < max; i++) {
- int j = 0;
- while (j < replacedLength){
- if (i+j == max) continue next;
- if (array[i + j] != toBeReplaced[j++]) continue next;
- }
- if (occurrenceCount == starts.length){
- System.arraycopy(starts, 0, starts = new int[occurrenceCount * 2], 0, occurrenceCount);
- }
- starts[occurrenceCount++] = i;
- }
- }
- if (occurrenceCount == 0) return array;
- char[] result = new char[max + occurrenceCount * (replacementLength - replacedLength)];
- int inStart = 0, outStart = 0;
- for( int i = 0; i < occurrenceCount; i++){
- int offset = starts[i] - inStart;
- System.arraycopy(array, inStart, result, outStart, offset);
- inStart += offset;
- outStart += offset;
- System.arraycopy(replacementChars, 0, result, outStart, replacementLength);
- inStart += replacedLength;
- outStart += replacementLength;
- }
- System.arraycopy(array, inStart, result, outStart, max - inStart);
- return result;
-}
-
-public static final char[][] splitAndTrimOn(char divider, char[] array) {
- int length = array == null ? 0 : array.length;
- if (length == 0)
- return TypeConstants.NoCharChar;
-
- int wordCount = 1;
- for (int i = 0; i < length; i++)
- if (array[i] == divider)
- wordCount++;
- char[][] split = new char[wordCount][];
- int last = 0, currentWord = 0;
- for (int i = 0; i < length; i++) {
- if (array[i] == divider) {
- int start = last, end = i - 1;
- while (start < i && array[start] == ' ') start++;
- while (end > start && array[end] == ' ') end--;
- split[currentWord] = new char[end - start + 1];
- System.arraycopy(array, start, split[currentWord++], 0, end - start + 1);
- last = i + 1;
- }
- }
- int start = last, end = length - 1;
- while (start < length && array[start] == ' ') start++;
- while (end > start && array[end] == ' ') end--;
- split[currentWord] = new char[end - start + 1];
- System.arraycopy(array, start, split[currentWord++], 0, end - start + 1);
- return split;
-}
-
-public static final char[][] splitOn(char divider, char[] array) {
- int length = array == null ? 0 : array.length;
- if (length == 0)
- return TypeConstants.NoCharChar;
-
- int wordCount = 1;
- for (int i = 0; i < length; i++)
- if (array[i] == divider)
- wordCount++;
- char[][] split = new char[wordCount][];
- int last = 0, currentWord = 0;
- for (int i = 0; i < length; i++) {
- if (array[i] == divider) {
- split[currentWord] = new char[i - last];
- System.arraycopy(array, last, split[currentWord++], 0, i - last);
- last = i + 1;
- }
- }
- split[currentWord] = new char[length - last];
- System.arraycopy(array, last, split[currentWord], 0, length - last);
- return split;
-}
-public static final char[][] splitOn(char divider, char[] array, int start, int end) {
- int length = array == null ? 0 : array.length;
- if (length == 0 || start > end)
- return TypeConstants.NoCharChar;
-
- int wordCount = 1;
- for (int i = start; i < end; i++)
- if (array[i] == divider)
- wordCount++;
- char[][] split = new char[wordCount][];
- int last = start, currentWord = 0;
- for (int i = start; i < end; i++) {
- if (array[i] == divider) {
- split[currentWord] = new char[i - last];
- System.arraycopy(array, last, split[currentWord++], 0, i - last);
- last = i + 1;
- }
- }
- split[currentWord] = new char[end - last + 1];
- System.arraycopy(array, last, split[currentWord], 0, end - last + 1);
- return split;
-}
-public static final boolean startsWith(char[] array, char[] toBeFound) {
- int i = toBeFound.length;
- if (i > array.length)
- return false;
- while (--i >= 0)
- if (toBeFound[i] != array[i])
- return false;
- return true;
-}
-/*
- * copies from array[start] through array[end - 1] (does not copy array[end])
- */
-public static final char[][] subarray(char[][] array, int start, int end) {
- if (end == -1) end = array.length;
- if (start > end) return null;
- if (start < 0) return null;
- if (end > array.length) return null;
-
- char[][] result = new char[end - start][];
-/* if we do not trust System.arraycopy on our VM with char[][]'s
- for (int i = 0, s = start; s < end; i++, s++)
- result[i] = array[s];
-*/
- System.arraycopy(array, start, result, 0, end - start);
- return result;
-}
-/*
- * copies from array[start] through array[end - 1] (does not copy array[end])
- */
-public static final char[] subarray(char[] array, int start, int end) {
- if (end == -1) end = array.length;
- if (start > end) return null;
- if (start < 0) return null;
- if (end > array.length) return null;
-
- char[] result = new char[end - start];
- System.arraycopy(array, start, result, 0, end - start);
- return result;
-}
-/**
- * Answers the result of a char[] conversion to lowercase.
- * NOTE: if no conversion was necessary, then answers back the argument one.
- */
-final static public char[] toLowerCase(char[] chars) {
- if (chars == null) return null;
- int length = chars.length;
- char[] lowerChars = null;
- for (int i = 0; i < length; i++){
- char c = chars[i];
- char lc = Character.toLowerCase(c);
- if ((c != lc) || (lowerChars != null)){
- if (lowerChars == null){
- System.arraycopy(chars, 0, lowerChars = new char[length], 0, i);
- }
- lowerChars[i] = lc;
- }
- }
- return lowerChars == null ? chars : lowerChars;
-}
-
-/**
- * Remove leading and trailing spaces
- */
-final static public char[] trim(char[] chars){
-
- if (chars == null) return null;
-
- char[] result = chars;
- int start = 0, length = chars.length, end = length - 1;
- while (start < length && chars[start] == ' ') {
- start++;
- }
- while (end > start && chars[end] == ' '){
- end--;
- }
- if (start != 0 || end != length - 1){
- return subarray(chars, start, end+1);
- }
- return chars;
-}
-final static public String toString(char[][] array) {
- char[] result = concatWith(array, '.');
- if (result == null)
- return ""; //$NON-NLS-1$
- return new String(result);
-}
-}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CompoundNameVector.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CompoundNameVector.java
index 1403ca3..afae047 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CompoundNameVector.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/CompoundNameVector.java
@@ -1,15 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.util;
+import org.eclipse.jdt.core.compiler.CharOperation;
+
public final class CompoundNameVector {
static int INITIAL_SIZE = 10;
@@ -66,4 +68,4 @@
}
return buffer.toString();
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java
index 2d112a6..18cf0bd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfInt.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.util;
/**
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfLong.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfLong.java
new file mode 100644
index 0000000..036d7b5
--- /dev/null
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfLong.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.compiler.util;
+
+ /**
+ * Hashtable for non-zero long keys.
+ */
+
+public final class HashtableOfLong {
+ // to avoid using Enumerations, walk the individual tables skipping nulls
+ public long[] keyTable;
+ public Object[] valueTable;
+
+ int elementSize; // number of elements in the table
+ int threshold;
+public HashtableOfLong() {
+ this(13);
+}
+public HashtableOfLong(int size) {
+ this.elementSize = 0;
+ this.threshold = size; // size represents the expected number of elements
+ int extraRoom = (int) (size * 1.75f);
+ if (this.threshold == extraRoom)
+ extraRoom++;
+ this.keyTable = new long[extraRoom];
+ this.valueTable = new Object[extraRoom];
+}
+public boolean containsKey(long key) {
+ int index = ((int)(key >>> 32)) % valueTable.length;
+ long currentKey;
+ while ((currentKey = keyTable[index]) != 0) {
+ if (currentKey == key)
+ return true;
+ index = (index + 1) % keyTable.length;
+ }
+ return false;
+}
+public Object get(long key) {
+ int index = ((int)(key >>> 32)) % valueTable.length;
+ long currentKey;
+ while ((currentKey = keyTable[index]) != 0) {
+ if (currentKey == key) return valueTable[index];
+ index = (index + 1) % keyTable.length;
+ }
+ return null;
+}
+public Object put(long key, Object value) {
+ int index = ((int)(key >>> 32)) % valueTable.length;
+ long currentKey;
+ while ((currentKey = keyTable[index]) != 0) {
+ if (currentKey == key) return valueTable[index] = value;
+ index = (index + 1) % keyTable.length;
+ }
+ keyTable[index] = key;
+ valueTable[index] = value;
+
+ // assumes the threshold is never equal to the size of the table
+ if (++elementSize > threshold)
+ rehash();
+ return value;
+}
+private void rehash() {
+ HashtableOfLong newHashtable = new HashtableOfLong(elementSize * 2); // double the number of expected elements
+ long currentKey;
+ for (int i = keyTable.length; --i >= 0;)
+ if ((currentKey = keyTable[i]) != 0)
+ newHashtable.put(currentKey, valueTable[i]);
+
+ this.keyTable = newHashtable.keyTable;
+ this.valueTable = newHashtable.valueTable;
+ this.threshold = newHashtable.threshold;
+}
+public int size() {
+ return elementSize;
+}
+public String toString() {
+ String s = ""; //$NON-NLS-1$
+ Object object;
+ for (int i = 0, length = valueTable.length; i < length; i++)
+ if ((object = valueTable[i]) != null)
+ s += keyTable[i] + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
+ return s;
+}
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
index b8365df..0db0c26 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfObject.java
@@ -1,15 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.util;
+import org.eclipse.jdt.core.compiler.CharOperation;
+
/**
* Hashtable of {char[] --> Object }
*/
@@ -145,4 +147,4 @@
s += new String(keyTable[i]) + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java
index d1f13be..ec06e07 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfPackage.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.util;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
public final class HashtableOfPackage {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java
index c47da9b..998c0c3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/HashtableOfType.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.util;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
public final class HashtableOfType {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java
index bc14a06..e09ae01 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/ObjectVector.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.util;
public final class ObjectVector {
@@ -129,4 +129,4 @@
s += this.elements[i].toString() + "\n"; //$NON-NLS-1$
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java
index 15d3aeb..a555720 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/SimpleNameVector.java
@@ -1,15 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.util;
+import org.eclipse.jdt.core.compiler.CharOperation;
+
public final class SimpleNameVector {
static int INITIAL_SIZE = 10;
@@ -91,4 +93,4 @@
}
return buffer.toString();
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
index 249008e..15578ea 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/Util.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.compiler.util;
import java.io.BufferedInputStream;
@@ -23,6 +23,8 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.eclipse.jdt.core.compiler.CharOperation;
+
public class Util {
public static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
@@ -38,7 +40,8 @@
private final static char[] DOUBLE_QUOTES = "''".toCharArray(); //$NON-NLS-1$
private final static char[] SINGLE_QUOTE = "'".toCharArray(); //$NON-NLS-1$
-
+ private static final int DEFAULT_READING_SIZE = 8192;
+
/* Bundle containing messages */
protected static ResourceBundle bundle;
private final static String bundleName =
@@ -121,7 +124,12 @@
* Creates a NLS catalog for the given locale.
*/
public static void relocalize() {
- bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+ try {
+ bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+ } catch(MissingResourceException e) {
+ System.out.println("Missing resource : " + bundleName.replace('.', '/') + ".properties for locale " + Locale.getDefault()); //$NON-NLS-1$//$NON-NLS-2$
+ throw e;
+ }
}
/**
* Returns the given bytes as a char array using a given encoding (null means platform default).
@@ -181,28 +189,28 @@
if (length == -1) {
contents = new byte[0];
int contentsLength = 0;
- int bytesRead = -1;
+ int amountRead = -1;
do {
- int available = stream.available();
-
+ int amountRequested = Math.max(stream.available(), DEFAULT_READING_SIZE); // read at least 8K
+
// resize contents if needed
- if (contentsLength + available > contents.length) {
+ if (contentsLength + amountRequested > contents.length) {
System.arraycopy(
contents,
0,
- contents = new byte[contentsLength + available],
+ contents = new byte[contentsLength + amountRequested],
0,
contentsLength);
}
// read as many bytes as possible
- bytesRead = stream.read(contents, contentsLength, available);
+ amountRead = stream.read(contents, contentsLength, amountRequested);
- if (bytesRead > 0) {
+ if (amountRead > 0) {
// remember length of contents
- contentsLength += bytesRead;
+ contentsLength += amountRead;
}
- } while (bytesRead > 0);
+ } while (amountRead != -1);
// resize contents if necessary
if (contentsLength < contents.length) {
@@ -242,30 +250,30 @@
: new InputStreamReader(stream, encoding);
char[] contents;
if (length == -1) {
- contents = new char[0];
+ contents = CharOperation.NO_CHAR;
int contentsLength = 0;
- int charsRead = -1;
+ int amountRead = -1;
do {
- int available = stream.available();
+ int amountRequested = Math.max(stream.available(), DEFAULT_READING_SIZE); // read at least 8K
// resize contents if needed
- if (contentsLength + available > contents.length) {
+ if (contentsLength + amountRequested > contents.length) {
System.arraycopy(
contents,
0,
- contents = new char[contentsLength + available],
+ contents = new char[contentsLength + amountRequested],
0,
contentsLength);
}
// read as many chars as possible
- charsRead = reader.read(contents, contentsLength, available);
+ amountRead = reader.read(contents, contentsLength, amountRequested);
- if (charsRead > 0) {
+ if (amountRead > 0) {
// remember length of contents
- contentsLength += charsRead;
+ contentsLength += amountRead;
}
- } while (charsRead > 0);
+ } while (amountRead != -1);
// resize contents if necessary
if (contentsLength < contents.length) {
@@ -376,4 +384,4 @@
}
return true;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties
index a96dc9d..99a6994 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/messages.properties
@@ -1,3 +1,13 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
### Eclipse Java Core Compiler messages.
### compilation
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
index af0a223..0ed77a6 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java
@@ -1,21 +1,24 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
import java.util.Map;
+
+import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.AbstractSyntaxTreeVisitorAdapter;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
@@ -29,7 +32,8 @@
* Abstract syntax trees may be hand constructed by clients, using the
* <code>new<it>TYPE</it></code> factory methods to create new nodes, and the
* various <code>set<it>CHILD</it></code> methods
- * (see <code>ASTNode</code> and its subclasses) to connect them together.
+ * (see {@link org.eclipse.jdt.core.dom.ASTNode ASTNode} and its subclasses)
+ * to connect them together.
* </p>
* <p>
* Each AST node belongs to a unique AST instance, called the owning AST.
@@ -38,11 +42,21 @@
* be cloned first to ensures that the added nodes have the correct owning AST.
* </p>
* <p>
- * The static method <code>parseCompilationUnit</code> parses a string
+ * The static method
+ * {@link org.eclipse.jdt.core.dom.AST#parseCompilationUnit(char[])
+ * parseCompilationUnit(char[])} parses a string
* containing a Java compilation unit and returns the abstract syntax tree
* for it. The resulting nodes carry source ranges relating the node back to
- * the original source characters. Optional name and type resolution can also
- * be requested at the time the AST is created.
+ * the original source characters. Other forms of
+ * <code>parseCompilationUnit</code> allow optional name and type resolution
+ * to be requested at the time the AST is created.
+ * </p>
+ * <p>
+ * Note that there is no built-in way to serialize a modified AST to a source
+ * code string. Naive serialization of a newly-constructed AST to a string is
+ * a straightforward application of an AST visitor. However, preserving comments
+ * and formatting from the originating source code string is a challenging
+ * problem (support for this is planned for a future release).
* </p>
* <p>
* Clients may create instances of this class, which is not intended to be
@@ -96,14 +110,13 @@
* @see JavaCore#getDefaultOptions
*/
public AST(Map options) {
- Object value = options.get("org.eclipse.jdt.core.compiler.source"); //$NON-NLS-1$
- if ("1.3".equals(value)) { //$NON-NLS-1$
- // use a 1.3 scanner - treats assert as an identifier
- this.scanner = new Scanner();
- } else {
- // use a 1.4 scanner - treats assert as an keyword
- this.scanner = new Scanner(false, false, false, true);
- }
+ this.scanner = new Scanner(
+ true /*comment*/,
+ true /*whitespace*/,
+ false /*nls*/,
+ JavaCore.VERSION_1_4.equals(options.get(JavaCore.COMPILER_SOURCE)) /*assert*/,
+ null/*taskTag*/,
+ null/*taskPriorities*/);
}
/**
@@ -134,7 +147,16 @@
public long modificationCount() {
return modCount;
}
-
+
+ /**
+ * Set the modification count to the new value
+ *
+ * @param value the new value
+ */
+ void setModificationCount(long value) {
+ this.modCount = value;
+ }
+
/**
* Indicates that this AST is about to be modified.
* <p>
@@ -158,15 +180,27 @@
/**
- * Parses the given string as a Java compilation unit and creates and
- * returns a corresponding abstract syntax tree.
+ * Parses the source string of the given Java model compilation unit element
+ * and creates and returns a corresponding abstract syntax tree. The source
+ * string is obtained from the Java model element using
+ * <code>ICompilationUnit.getSource()</code>.
* <p>
* The returned compilation unit node is the root node of a new AST.
* Each node in the subtree carries source range(s) information relating back
- * to positions in the given source string (the given source string itself
- * is not remembered with the AST). If a syntax error is detected while
- * parsing, the relevant node(s) of the tree will be flagged as
- * <code>MALFORMED</code>.
+ * to positions in the source string (the source string is not remembered
+ * with the AST).
+ * The source range usually begins at the first character of the first token
+ * corresponding to the node; leading whitespace and comments are <b>not</b>
+ * included. The source range usually extends through the last character of
+ * the last token corresponding to the node; trailing whitespace and
+ * comments are <b>not</b> included. There are a handful of exceptions
+ * (including compilation units and the various body declarations); the
+ * specification for these node type spells out the details.
+ * Source ranges nest properly: the source range for a child is always
+ * within the source range of its parent, and the source ranges of sibling
+ * nodes never overlap.
+ * If a syntax error is detected while parsing, the relevant node(s) of the
+ * tree will be flagged as <code>MALFORMED</code>.
* </p>
* <p>
* If <code>resolveBindings</code> is <code>true</code>, the various names
@@ -179,9 +213,11 @@
* requested frivolously. The additional space is not reclaimed until the
* AST, all its nodes, and all its bindings become garbage. So it is very
* important to not retain any of these objects longer than absolutely
- * necessary. Note that bindings can only be resolved while the AST remains
- * in its original unmodified state. Once the AST is modified, all
- * <code>resolveBinding</code> methods return <code>null</code>.
+ * necessary. Bindings are resolved at the time the AST is created. Subsequent
+ * modifications to the AST do not affect the bindings returned by
+ * <code>resolveBinding</code> methods in any way; these methods return the
+ * same binding as before the AST was modified (including modifications
+ * that rearrange subtrees by reparenting nodes).
* If <code>resolveBindings</code> is <code>false</code>, the analysis
* does not go beyond parsing and building the tree, and all
* <code>resolveBinding</code> methods return <code>null</code> from the
@@ -192,6 +228,8 @@
* @param resolveBindings <code>true</code> if bindings are wanted,
* and <code>false</code> if bindings are not of interest
* @return the compilation unit node
+ * @exception IllegalArgumentException if the given Java element does not
+ * exist or if its source string cannot be obtained
* @see ASTNode#getFlags()
* @see ASTNode#MALFORMED
* @see ASTNode#getStartPosition()
@@ -218,7 +256,7 @@
CompilationUnitDeclaration compilationUnitDeclaration = CompilationUnitResolver.resolve(
unit,
new AbstractSyntaxTreeVisitorAdapter());
- ASTConverter converter = new ASTConverter(true);
+ ASTConverter converter = new ASTConverter(unit.getJavaProject().getOptions(true), true);
AST ast = new AST();
BindingResolver resolver = new DefaultBindingResolver(compilationUnitDeclaration.scope);
ast.setBindingResolver(resolver);
@@ -241,15 +279,135 @@
}
/**
+ * Parses the source string corresponding to the given Java class file
+ * element and creates and returns a corresponding abstract syntax tree.
+ * The source string is obtained from the Java model element using
+ * <code>IClassFile.getSource()</code>, and is only available for a class
+ * files with attached source.
+ * <p>
+ * The returned compilation unit node is the root node of a new AST.
+ * Each node in the subtree carries source range(s) information relating back
+ * to positions in the source string (the source string is not remembered
+ * with the AST).
+ * The source range usually begins at the first character of the first token
+ * corresponding to the node; leading whitespace and comments are <b>not</b>
+ * included. The source range usually extends through the last character of
+ * the last token corresponding to the node; trailing whitespace and
+ * comments are <b>not</b> included. There are a handful of exceptions
+ * (including compilation units and the various body declarations); the
+ * specification for these node type spells out the details.
+ * Source ranges nest properly: the source range for a child is always
+ * within the source range of its parent, and the source ranges of sibling
+ * nodes never overlap.
+ * If a syntax error is detected while parsing, the relevant node(s) of the
+ * tree will be flagged as <code>MALFORMED</code>.
+ * </p>
+ * <p>
+ * If <code>resolveBindings</code> is <code>true</code>, the various names
+ * and types appearing in the compilation unit can be resolved to "bindings"
+ * by calling the <code>resolveBinding</code> methods. These bindings
+ * draw connections between the different parts of a program, and
+ * generally afford a more powerful vantage point for clients who wish to
+ * analyze a program's structure more deeply. These bindings come at a
+ * considerable cost in both time and space, however, and should not be
+ * requested frivolously. The additional space is not reclaimed until the
+ * AST, all its nodes, and all its bindings become garbage. So it is very
+ * important to not retain any of these objects longer than absolutely
+ * necessary. Bindings are resolved at the time the AST is created. Subsequent
+ * modifications to the AST do not affect the bindings returned by
+ * <code>resolveBinding</code> methods in any way; these methods return the
+ * same binding as before the AST was modified (including modifications
+ * that rearrange subtrees by reparenting nodes).
+ * If <code>resolveBindings</code> is <code>false</code>, the analysis
+ * does not go beyond parsing and building the tree, and all
+ * <code>resolveBinding</code> methods return <code>null</code> from the
+ * outset.
+ * </p>
+ *
+ * @param classFile the Java model compilation unit whose source code is to be parsed
+ * @param resolveBindings <code>true</code> if bindings are wanted,
+ * and <code>false</code> if bindings are not of interest
+ * @return the compilation unit node
+ * @exception IllegalArgumentException if the given Java element does not
+ * exist or if its source string cannot be obtained
+ * @see ASTNode#getFlags()
+ * @see ASTNode#MALFORMED
+ * @see ASTNode#getStartPosition()
+ * @see ASTNode#getLength()
+ * @since 2.1
+ */
+ public static CompilationUnit parseCompilationUnit(
+ IClassFile classFile,
+ boolean resolveBindings) {
+ if (classFile == null) {
+ throw new IllegalArgumentException();
+ }
+ char[] source = null;
+ String sourceString = null;
+ try {
+ sourceString = classFile.getSource();
+ } catch (JavaModelException e) {
+ throw new IllegalArgumentException();
+ }
+ if (sourceString == null) {
+ throw new IllegalArgumentException();
+ }
+ source = sourceString.toCharArray();
+ if (!resolveBindings) {
+ return AST.parseCompilationUnit(source);
+ }
+ StringBuffer buffer = new StringBuffer(".java"); //$NON-NLS-1$
+
+ String classFileName = classFile.getElementName(); // this includes the trailing .class
+ buffer.insert(0, classFileName.toCharArray(), 0, classFileName.indexOf('.'));
+ IJavaProject project = classFile.getJavaProject();
+ try {
+ CompilationUnitDeclaration compilationUnitDeclaration =
+ CompilationUnitResolver.resolve(
+ source,
+ CharOperation.splitOn('.', classFile.getType().getPackageFragment().getElementName().toCharArray()),
+ buffer.toString(),
+ project,
+ new AbstractSyntaxTreeVisitorAdapter());
+ ASTConverter converter = new ASTConverter(project.getOptions(true), true);
+ AST ast = new AST();
+ BindingResolver resolver = new DefaultBindingResolver(compilationUnitDeclaration.scope);
+ ast.setBindingResolver(resolver);
+ converter.setAST(ast);
+
+ CompilationUnit cu = converter.convert(compilationUnitDeclaration, source);
+ cu.setLineEndTable(compilationUnitDeclaration.compilationResult.lineSeparatorPositions);
+ resolver.storeModificationCount(ast.modificationCount());
+ return cu;
+ } catch(JavaModelException e) {
+ /* if a JavaModelException is thrown trying to retrieve the name environment
+ * then we simply do a parsing without creating bindings.
+ * Therefore all binding resolution will return null.
+ */
+ return parseCompilationUnit(source);
+ }
+ }
+
+ /**
* Parses the given string as the hypothetical contents of the named
* compilation unit and creates and returns a corresponding abstract syntax tree.
* <p>
* The returned compilation unit node is the root node of a new AST.
* Each node in the subtree carries source range(s) information relating back
* to positions in the given source string (the given source string itself
- * is not remembered with the AST). If a syntax error is detected while
- * parsing, the relevant node(s) of the tree will be flagged as
- * <code>MALFORMED</code>.
+ * is not remembered with the AST).
+ * The source range usually begins at the first character of the first token
+ * corresponding to the node; leading whitespace and comments are <b>not</b>
+ * included. The source range usually extends through the last character of
+ * the last token corresponding to the node; trailing whitespace and
+ * comments are <b>not</b> included. There are a handful of exceptions
+ * (including compilation units and the various body declarations); the
+ * specification for these node type spells out the details.
+ * Source ranges nest properly: the source range for a child is always
+ * within the source range of its parent, and the source ranges of sibling
+ * nodes never overlap.
+ * If a syntax error is detected while parsing, the relevant node(s) of the
+ * tree will be flagged as <code>MALFORMED</code>.
* </p>
* <p>
* If the given project is not <code>null</code>, the various names
@@ -262,9 +420,11 @@
* requested frivolously. The additional space is not reclaimed until the
* AST, all its nodes, and all its bindings become garbage. So it is very
* important to not retain any of these objects longer than absolutely
- * necessary. Note that bindings can only be resolved while the AST remains
- * in its original unmodified state. Once the AST is modified, all
- * <code>resolveBinding</code> methods return <code>null</code>.
+ * necessary. Bindings are resolved at the time the AST is created. Subsequent
+ * modifications to the AST do not affect the bindings returned by
+ * <code>resolveBinding</code> methods in any way; these methods return the
+ * same binding as before the AST was modified (including modifications
+ * that rearrange subtrees by reparenting nodes).
* If the given project is <code>null</code>, the analysis
* does not go beyond parsing and building the tree, and all
* <code>resolveBinding</code> methods return <code>null</code> from the
@@ -303,7 +463,7 @@
throw new IllegalArgumentException();
}
if (project == null) {
- // this just reuces to the other simplest case
+ // this just reduces to the other simplest case
return parseCompilationUnit(source);
}
@@ -314,7 +474,7 @@
unitName,
project,
new AbstractSyntaxTreeVisitorAdapter());
- ASTConverter converter = new ASTConverter(true);
+ ASTConverter converter = new ASTConverter(project.getOptions(true), true);
AST ast = new AST();
BindingResolver resolver = new DefaultBindingResolver(compilationUnitDeclaration.scope);
ast.setBindingResolver(resolver);
@@ -340,9 +500,23 @@
* The returned compilation unit node is the root node of a new AST.
* Each node in the subtree carries source range(s) information relating back
* to positions in the given source string (the given source string itself
- * is not remembered with the AST). If a syntax error is detected while
- * parsing, the relevant node(s) of the tree will be flagged as
- * <code>MALFORMED</code>.
+ * is not remembered with the AST).
+ * The source range usually begins at the first character of the first token
+ * corresponding to the node; leading whitespace and comments are <b>not</b>
+ * included. The source range usually extends through the last character of
+ * the last token corresponding to the node; trailing whitespace and
+ * comments are <b>not</b> included. There are a handful of exceptions
+ * (including compilation units and the various body declarations); the
+ * specification for these node type spells out the details.
+ * Source ranges nest properly: the source range for a child is always
+ * within the source range of its parent, and the source ranges of sibling
+ * nodes never overlap.
+ * If a syntax error is detected while parsing, the relevant node(s) of the
+ * tree will be flagged as <code>MALFORMED</code>.
+ * </p>
+ * <p>
+ * This method does not compute binding information; all <code>resolveBinding</code>
+ * methods applied to nodes of the resulting AST return <code>null</code>.
* </p>
*
* @param source the string to be parsed as a Java compilation unit
@@ -356,9 +530,9 @@
throw new IllegalArgumentException();
}
CompilationUnitDeclaration compilationUnitDeclaration =
- CompilationUnitResolver.parse(source);
+ CompilationUnitResolver.parse(source, JavaCore.getOptions()); // no better custom options
- ASTConverter converter = new ASTConverter(false);
+ ASTConverter converter = new ASTConverter(JavaCore.getOptions(), false);
AST ast = new AST();
ast.setBindingResolver(new BindingResolver());
converter.setAST(ast);
@@ -674,8 +848,8 @@
* Creates an unparented method declaration node owned by this AST.
* By default, the declaration is for a method of an unspecified, but
* legal, name; no modifiers; no Javadoc comment; no parameters; return
- * type void; no thrown exceptions; and no body (as opposed to an empty
- * body).
+ * type void; no extra array dimensions; no thrown exceptions; and no
+ * body (as opposed to an empty body).
* <p>
* To create a constructor, use this method and then call
* <code>MethodDeclaration.setConstructor(true)</code> and
@@ -693,7 +867,8 @@
/**
* Creates an unparented single variable declaration node owned by this AST.
* By default, the declaration is for a variable with an unspecified, but
- * legal, name and type; no modifiers; and no initializer.
+ * legal, name and type; no modifiers; no array dimensions after the
+ * variable; and no initializer.
*
* @return a new unparented single variable declaration node
*/
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
index b586bbe..9d3e69c 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
@@ -1,21 +1,29 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
+import java.util.*;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
/**
* Internal class for converting internal compiler ASTs into public ASTs.
@@ -26,10 +34,18 @@
private char[] compilationUnitSource;
private Scanner scanner;
private boolean resolveBindings;
+ private Set pendingThisExpressionScopeResolution;
+ private Set pendingNameScopeResolution;
- public ASTConverter(boolean resolveBindings) {
+ public ASTConverter(Map options, boolean resolveBindings) {
this.resolveBindings = resolveBindings;
- scanner = new Scanner(true, false);
+ scanner = new Scanner(
+ true /*comment*/,
+ false /*whitespace*/,
+ false /*nls*/,
+ JavaCore.VERSION_1_4.equals(options.get(JavaCore.COMPILER_SOURCE)) /*assert*/,
+ null /*taskTags*/,
+ null/*taskPriorities*/);
}
public void setAST(AST ast) {
@@ -46,7 +62,8 @@
recordNodes(compilationUnit, unit);
}
if (unit.currentPackage != null) {
- compilationUnit.setPackage(convertPackage(unit.currentPackage));
+ PackageDeclaration packageDeclaration = convertPackage(unit);
+ compilationUnit.setPackage(packageDeclaration);
}
ImportReference[] imports = unit.imports;
if (imports != null) {
@@ -67,10 +84,14 @@
if (unit.compilationResult.problemCount != 0) {
propagateErrors(compilationUnit, unit.compilationResult.problems, unit.compilationResult.problemCount);
}
+ if (resolveBindings) {
+ lookupForScopes();
+ }
return compilationUnit;
}
- public PackageDeclaration convertPackage(ImportReference importReference) {
+ public PackageDeclaration convertPackage(CompilationUnitDeclaration compilationUnitDeclaration) {
+ ImportReference importReference = compilationUnitDeclaration.currentPackage;
PackageDeclaration packageDeclaration = this.ast.newPackageDeclaration();
char[][] tokens = importReference.tokens;
int length = importReference.tokens.length;
@@ -88,6 +109,7 @@
packageDeclaration.setName(name);
if (resolveBindings) {
recordNodes(packageDeclaration, importReference);
+ recordNodes(name, compilationUnitDeclaration);
}
return packageDeclaration;
}
@@ -126,6 +148,8 @@
* This handles cases where the parser built nodes with invalid modifiers.
*/
try {
+ // AccJustFlag doesn't flush Modifier.TRANSIENT or Modifier.VOLATILE.
+ // Therefore we need to handle these cases
typeDecl.setModifiers(modifiers);
} catch(IllegalArgumentException e) {
int legalModifiers =
@@ -138,7 +162,7 @@
typeDecl.setInterface(typeDeclaration.isInterface());
SimpleName typeName = this.ast.newSimpleName(new String(typeDeclaration.name));
typeName.setSourceRange(typeDeclaration.sourceStart, typeDeclaration.sourceEnd - typeDeclaration.sourceStart + 1);
- typeDecl.setName(this.ast.newSimpleName(new String(typeDeclaration.name)));
+ typeDecl.setName(typeName);
typeDecl.setSourceRange(typeDeclaration.declarationSourceStart, typeDeclaration.bodyEnd - typeDeclaration.declarationSourceStart + 1);
// need to set the superclass and super interfaces here since we cannot distinguish them at
@@ -158,6 +182,7 @@
setJavaDocComment(typeDecl);
if (resolveBindings) {
recordNodes(typeDecl, typeDeclaration);
+ recordNodes(typeName, typeDeclaration);
typeDecl.resolveBinding();
}
return typeDecl;
@@ -303,34 +328,54 @@
private QualifiedName setQualifiedNameNameAndSourceRanges(char[][] typeName, long[] positions, AstNode node) {
int length = typeName.length;
SimpleName firstToken = this.ast.newSimpleName(new String(typeName[0]));
+ firstToken.index = length - 1;
int start0 = (int)(positions[0]>>>32);
int start = start0;
int end = (int)(positions[0] & 0xFFFFFFFF);
firstToken.setSourceRange(start, end - start + 1);
SimpleName secondToken = this.ast.newSimpleName(new String(typeName[1]));
+ secondToken.index = length - 2;
start = (int)(positions[1]>>>32);
end = (int)(positions[1] & 0xFFFFFFFF);
secondToken.setSourceRange(start, end - start + 1);
QualifiedName qualifiedName = this.ast.newQualifiedName(firstToken, secondToken);
+ if (this.resolveBindings) {
+ recordNodes(qualifiedName, node);
+ recordPendingNameScopeResolution(qualifiedName);
+ recordNodes(firstToken, node);
+ recordNodes(secondToken, node);
+ recordPendingNameScopeResolution(firstToken);
+ recordPendingNameScopeResolution(secondToken);
+ }
+ qualifiedName.index = length - 2;
qualifiedName.setSourceRange(start0, end - start0 + 1);
SimpleName newPart = null;
for (int i = 2; i < length; i++) {
newPart = this.ast.newSimpleName(new String(typeName[i]));
+ newPart.index = length - i - 1;
start = (int)(positions[i]>>>32);
end = (int)(positions[i] & 0xFFFFFFFF);
newPart.setSourceRange(start, end - start + 1);
qualifiedName = this.ast.newQualifiedName(qualifiedName, newPart);
+ qualifiedName.index = newPart.index;
qualifiedName.setSourceRange(start0, end - start0 + 1);
+ if (this.resolveBindings) {
+ recordNodes(qualifiedName, node);
+ recordNodes(newPart, node);
+ recordPendingNameScopeResolution(qualifiedName);
+ recordPendingNameScopeResolution(newPart);
+ }
}
QualifiedName name = qualifiedName;
if (this.resolveBindings) {
recordNodes(name, node);
+ recordPendingNameScopeResolution(name);
}
return name;
}
public Expression convert(ThisReference reference) {
- if (reference == ThisReference.ThisImplicit) {
+ if (reference.isImplicitThis()) {
// There is no source associated with an implicit this
return null;
} else if (reference instanceof QualifiedSuperReference) {
@@ -339,21 +384,23 @@
return convert((QualifiedThisReference) reference);
} else {
ThisExpression thisExpression = this.ast.newThisExpression();
+ thisExpression.setSourceRange(reference.sourceStart, reference.sourceEnd - reference.sourceStart + 1);
if (this.resolveBindings) {
recordNodes(thisExpression, reference);
+ recordPendingThisExpressionScopeResolution(thisExpression);
}
- thisExpression.setSourceRange(reference.sourceStart, reference.sourceEnd - reference.sourceStart + 1);
return thisExpression;
}
}
public ThisExpression convert(QualifiedThisReference reference) {
ThisExpression thisExpression = this.ast.newThisExpression();
- if (this.resolveBindings) {
- recordNodes(thisExpression, reference);
- }
thisExpression.setSourceRange(reference.sourceStart, reference.sourceEnd - reference.sourceStart + 1);
thisExpression.setQualifier(convert(reference.qualification));
+ if (this.resolveBindings) {
+ recordNodes(thisExpression, reference);
+ recordPendingThisExpressionScopeResolution(thisExpression);
+ }
return thisExpression;
}
@@ -451,6 +498,8 @@
* This handles cases where the parser built nodes with invalid modifiers.
*/
try {
+ // AccJustFlag doesn't flush Modifier.TRANSIENT or Modifier.VOLATILE.
+ // Therefore we need to handle these cases
typeDecl.setModifiers(modifiers);
} catch(IllegalArgumentException e) {
int legalModifiers =
@@ -463,7 +512,7 @@
typeDecl.setInterface(typeDeclaration.isInterface());
SimpleName typeName = this.ast.newSimpleName(new String(typeDeclaration.name));
typeName.setSourceRange(typeDeclaration.sourceStart, typeDeclaration.sourceEnd - typeDeclaration.sourceStart + 1);
- typeDecl.setName(this.ast.newSimpleName(new String(typeDeclaration.name)));
+ typeDecl.setName(typeName);
typeDecl.setSourceRange(typeDeclaration.declarationSourceStart, typeDeclaration.bodyEnd - typeDeclaration.declarationSourceStart + 1);
// need to set the superclass and super interfaces here since we cannot distinguish them at
@@ -482,11 +531,24 @@
setJavaDocComment(typeDecl);
if (this.resolveBindings) {
recordNodes(typeDecl, typeDeclaration);
+ recordNodes(typeName, typeDeclaration);
typeDecl.resolveBinding();
}
return typeDecl;
}
+ private void completeRecord(ArrayType arrayType, AstNode astNode) {
+ ArrayType array = arrayType;
+ int dimensions = array.getDimensions();
+ for (int i = 0; i < dimensions; i++) {
+ Type componentType = array.getComponentType();
+ this.recordNodes(componentType, astNode);
+ if (componentType.isArrayType()) {
+ array = (ArrayType) componentType;
+ }
+ }
+ }
+
public Type convertType(TypeReference typeReference) {
Type type = null;
int sourceStart = -1;
@@ -500,19 +562,23 @@
if (dimensions != 0) {
// need to find out if this is an array type of primitive types or not
if (isPrimitiveType(name)) {
- int end = retrieveStartingLeftBracketPosition(sourceStart, sourceStart + length);
+ int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length);
if (end == -1) {
- end = sourceStart + length;
+ end = sourceStart + length - 1;
}
PrimitiveType primitiveType = this.ast.newPrimitiveType(getPrimitiveTypeCode(name));
primitiveType.setSourceRange(sourceStart, end - sourceStart + 1);
type = this.ast.newArrayType(primitiveType, dimensions);
+ if (resolveBindings) {
+ // store keys for inner types
+ completeRecord((ArrayType) type, typeReference);
+ }
type.setSourceRange(sourceStart, length);
} else {
SimpleName simpleName = this.ast.newSimpleName(new String(name));
// we need to search for the starting position of the first brace in order to set the proper length
// PR http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
- int end = retrieveStartingLeftBracketPosition(sourceStart, sourceStart + length);
+ int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length);
if (end == -1) {
end = sourceStart + length - 1;
}
@@ -522,6 +588,7 @@
type = this.ast.newArrayType(simpleType, dimensions);
type.setSourceRange(sourceStart, length);
if (this.resolveBindings) {
+ completeRecord((ArrayType) type, typeReference);
this.recordNodes(simpleName, typeReference);
}
}
@@ -545,12 +612,15 @@
long[] positions = ((QualifiedTypeReference) typeReference).sourcePositions;
sourceStart = (int)(positions[0]>>>32);
length = (int)(positions[nameLength - 1] & 0xFFFFFFFF) - sourceStart + 1;
+ Name qualifiedName = this.setQualifiedNameNameAndSourceRanges(name, positions, typeReference);
if (dimensions != 0) {
// need to find out if this is an array type of primitive types or not
- Name qualifiedName = this.setQualifiedNameNameAndSourceRanges(name, positions, typeReference);
SimpleType simpleType = this.ast.newSimpleType(qualifiedName);
simpleType.setSourceRange(sourceStart, length);
type = this.ast.newArrayType(simpleType, dimensions);
+ if (this.resolveBindings) {
+ completeRecord((ArrayType) type, typeReference);
+ }
int end = retrieveEndOfDimensionsPosition(sourceStart+length, this.compilationUnitSource.length);
if (end != -1) {
type.setSourceRange(sourceStart, end - sourceStart + 1);
@@ -558,7 +628,6 @@
type.setSourceRange(sourceStart, length);
}
} else {
- Name qualifiedName = this.setQualifiedNameNameAndSourceRanges(name, positions, typeReference);
type = this.ast.newSimpleType(qualifiedName);
type.setSourceRange(sourceStart, length);
}
@@ -576,6 +645,7 @@
* This handles cases where the parser built nodes with invalid modifiers.
*/
try {
+ // if Modifier.VOLATILE is set, setModifiers is not allowed, but the code has no syntax error.
methodDecl.setModifiers(methodDeclaration.modifiers & org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers.AccJustFlag);
} catch(IllegalArgumentException e) {
int legalModifiers =
@@ -588,7 +658,9 @@
boolean isConstructor = methodDeclaration.isConstructor();
methodDecl.setConstructor(isConstructor);
SimpleName methodName = this.ast.newSimpleName(new String(methodDeclaration.selector));
- methodName.setSourceRange(methodDeclaration.sourceStart, methodDeclaration.sourceEnd - methodDeclaration.sourceStart + 1);
+ int start = methodDeclaration.sourceStart;
+ int end = retrieveIdentifierEndPosition(start, methodDeclaration.sourceEnd);
+ methodName.setSourceRange(start, end - start + 1);
methodDecl.setName(methodName);
TypeReference[] thrownExceptions = methodDeclaration.thrownExceptions;
if (thrownExceptions != null) {
@@ -607,14 +679,21 @@
ExplicitConstructorCall explicitConstructorCall = null;
if (isConstructor) {
// set the return type to VOID
- methodDecl.setReturnType(this.ast.newPrimitiveType(PrimitiveType.VOID));
+ PrimitiveType returnType = this.ast.newPrimitiveType(PrimitiveType.VOID);
+ returnType.setSourceRange(methodDeclaration.sourceStart, 0);
+ methodDecl.setReturnType(returnType);
ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) methodDeclaration;
explicitConstructorCall = constructorDeclaration.constructorCall;
} else {
org.eclipse.jdt.internal.compiler.ast.MethodDeclaration method = (org.eclipse.jdt.internal.compiler.ast.MethodDeclaration) methodDeclaration;
TypeReference typeReference = method.returnType;
if (typeReference != null) {
- methodDecl.setReturnType(convertType(typeReference));
+ Type returnType = convertType(typeReference);
+ // get the positions of the right parenthesis
+ int rightParenthesisPosition = retrieveEndOfRightParenthesisPosition(end, method.bodyEnd);
+ int extraDimensions = retrieveExtraDimension(rightParenthesisPosition, method.bodyEnd);
+ methodDecl.setExtraDimensions(extraDimensions);
+ setTypeForMethodDeclaration(methodDecl, returnType, extraDimensions);
}
}
int declarationSourceStart = methodDeclaration.declarationSourceStart;
@@ -626,10 +705,10 @@
if (statements != null || explicitConstructorCall != null) {
Block block = this.ast.newBlock();
- int start = retrieveStartBlockPosition(methodDeclaration.sourceStart, declarationSourceEnd);
- int end = retrieveEndBlockPosition(methodDeclaration.sourceStart, this.compilationUnitSource.length);
+ start = retrieveStartBlockPosition(methodDeclaration.sourceStart, declarationSourceEnd);
+ end = retrieveEndBlockPosition(methodDeclaration.sourceStart, this.compilationUnitSource.length);
block.setSourceRange(start, end - start + 1);
- if (explicitConstructorCall != null) {
+ if (explicitConstructorCall != null && explicitConstructorCall.accessMode != ExplicitConstructorCall.ImplicitSuper) {
block.statements().add(convert(explicitConstructorCall));
}
int statementsLength = statements == null ? 0 : statements.length;
@@ -642,8 +721,8 @@
}
methodDecl.setBody(block);
} else if (!methodDeclaration.isNative() && !methodDeclaration.isAbstract()) {
- int start = retrieveStartBlockPosition(methodDeclaration.sourceStart, declarationSourceEnd);
- int end = retrieveEndBlockPosition(methodDeclaration.sourceStart, this.compilationUnitSource.length);
+ start = retrieveStartBlockPosition(methodDeclaration.sourceStart, declarationSourceEnd);
+ end = retrieveEndBlockPosition(methodDeclaration.sourceStart, this.compilationUnitSource.length);
if (start != -1 && end != -1) {
/*
* start or end can be equal to -1 if we have an interface's method.
@@ -656,13 +735,14 @@
setJavaDocComment(methodDecl);
if (this.resolveBindings) {
recordNodes(methodDecl, methodDeclaration);
+ recordNodes(methodName, methodDeclaration);
methodDecl.resolveBinding();
}
return methodDecl;
}
public Expression convert(org.eclipse.jdt.internal.compiler.ast.Expression expression) {
- if (checkForParenthesis(expression)) {
+ if ((expression.bits & AstNode.ParenthesizedMASK) != 0) {
return convertToParenthesizedExpression(expression);
}
if (expression instanceof org.eclipse.jdt.internal.compiler.ast.CastExpression) {
@@ -772,6 +852,11 @@
}
parenthesizedExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
adjustSourcePositionsForParent(expression);
+ removeExtraBlanks(expression);
+ // decrement the number of parenthesis
+ int numberOfParenthesis = (expression.bits & AstNode.ParenthesizedMASK) >> AstNode.ParenthesizedSHIFT;
+ expression.bits &= ~AstNode.ParenthesizedMASK;
+ expression.bits |= (numberOfParenthesis - 1) << AstNode.ParenthesizedSHIFT;
parenthesizedExpression.setExpression(convert(expression));
return parenthesizedExpression;
}
@@ -910,6 +995,9 @@
arrayType = (ArrayType) type;
} else {
arrayType = this.ast.newArrayType(type, dimensionsLength);
+ if (this.resolveBindings) {
+ completeRecord(arrayType, expression);
+ }
int start = type.getStartPosition();
int end = type.getStartPosition() + type.getLength();
int previousSearchStart = end;
@@ -927,9 +1015,6 @@
if (expression.initializer != null) {
arrayCreation.setInitializer(convert(expression.initializer));
}
- if (expression.initializer != null) {
- arrayCreation.setInitializer(convert(expression.initializer));
- }
return arrayCreation;
}
@@ -952,12 +1037,20 @@
variableDecl.setModifiers(argument.modifiers);
SimpleName name = this.ast.newSimpleName(argument.name());
- name.setSourceRange(argument.sourceStart, argument.sourceEnd - argument.sourceStart + 1);
+ int start = argument.sourceStart;
+ int nameEnd = argument.sourceEnd;
+ name.setSourceRange(start, nameEnd - start + 1);
variableDecl.setName(name);
+ final int extraDimensions = retrieveExtraDimension(nameEnd + 1, argument.type.sourceEnd);
+ variableDecl.setExtraDimensions(extraDimensions);
Type type = convertType(argument.type);
- variableDecl.setType(type);
int typeEnd = type.getStartPosition() + type.getLength() - 1;
int rightEnd = Math.max(typeEnd, argument.declarationSourceEnd);
+ /*
+ * There is extra work to do to set the proper type positions
+ * See PR http://bugs.eclipse.org/bugs/show_bug.cgi?id=23284
+ */
+ setTypeForSingleVariableDeclaration(variableDecl, type, extraDimensions);
variableDecl.setSourceRange(argument.declarationSourceStart, rightEnd - argument.declarationSourceStart + 1);
if (this.resolveBindings) {
recordNodes(name, argument);
@@ -1113,10 +1206,11 @@
CastExpression castExpression = this.ast.newCastExpression();
castExpression.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
org.eclipse.jdt.internal.compiler.ast.Expression type = expression.type;
+ removeExtraBlanks(type);
if (type instanceof TypeReference ) {
- castExpression.setType(convertType((TypeReference)expression.type));
+ castExpression.setType(convertType((TypeReference)type));
} else if (type instanceof NameReference) {
- castExpression.setType(convertToType((NameReference)expression.type));
+ castExpression.setType(convertToType((NameReference)type));
}
castExpression.setExpression(convert(expression.expression));
if (this.resolveBindings) {
@@ -1295,7 +1389,7 @@
return literal;
}
- public InfixExpression convert(BinaryExpression expression) {
+ public Expression convert(BinaryExpression expression) {
InfixExpression infixExpression = this.ast.newInfixExpression();
if (this.resolveBindings) {
this.recordNodes(infixExpression, expression);
@@ -1361,42 +1455,62 @@
infixExpression.setOperator(InfixExpression.Operator.LESS);
};
- if (expression.left instanceof BinaryExpression) {
+ if (expression.left instanceof BinaryExpression && ((expression.left.bits & AstNode.ParenthesizedMASK) == 0)) {
// create an extended string literal equivalent => use the extended operands list
infixExpression.extendedOperands().add(convert(expression.right));
org.eclipse.jdt.internal.compiler.ast.Expression leftOperand = expression.left;
org.eclipse.jdt.internal.compiler.ast.Expression rightOperand = null;
do {
- if (((leftOperand.bits & OperatorExpression.OperatorMASK) >> OperatorExpression.OperatorSHIFT) != expressionOperatorID) {
- infixExpression.extendedOperands().clear();
- Expression leftExpression = convert(expression.left);
- infixExpression.setLeftOperand(leftExpression);
- infixExpression.setRightOperand(convert(expression.right));
- int startPosition = leftExpression.getStartPosition();
+ rightOperand = ((BinaryExpression) leftOperand).right;
+ if ((((leftOperand.bits & OperatorExpression.OperatorMASK) >> OperatorExpression.OperatorSHIFT) != expressionOperatorID && ((leftOperand.bits & AstNode.ParenthesizedMASK) == 0))
+ || ((rightOperand instanceof BinaryExpression && ((rightOperand.bits & OperatorExpression.OperatorMASK) >> OperatorExpression.OperatorSHIFT) != expressionOperatorID) && ((rightOperand.bits & AstNode.ParenthesizedMASK) == 0))) {
+ List extendedOperands = infixExpression.extendedOperands();
+ InfixExpression temp = this.ast.newInfixExpression();
+ if (this.resolveBindings) {
+ this.recordNodes(temp, expression);
+ }
+ temp.setOperator(getOperatorFor(expressionOperatorID));
+ Expression leftSide = convert(leftOperand);
+ temp.setLeftOperand(leftSide);
+ temp.setSourceRange(leftSide.getStartPosition(), leftSide.getLength());
+ int size = extendedOperands.size();
+ for (int i = 0; i < size - 1; i++) {
+ Expression expr = temp;
+ temp = this.ast.newInfixExpression();
+
+ if (this.resolveBindings) {
+ this.recordNodes(temp, expression);
+ }
+ temp.setLeftOperand(expr);
+ temp.setOperator(getOperatorFor(expressionOperatorID));
+ temp.setSourceRange(expr.getStartPosition(), expr.getLength());
+ }
+ infixExpression = temp;
+ for (int i = 0; i < size; i++) {
+ Expression extendedOperand = (Expression) extendedOperands.remove(size - 1 - i);
+ temp.setRightOperand(extendedOperand);
+ int startPosition = temp.getLeftOperand().getStartPosition();
+ temp.setSourceRange(startPosition, extendedOperand.getStartPosition() + extendedOperand.getLength() - startPosition);
+ if (temp.getLeftOperand().getNodeType() == ASTNode.INFIX_EXPRESSION) {
+ temp = (InfixExpression) temp.getLeftOperand();
+ }
+ }
+ int startPosition = infixExpression.getLeftOperand().getStartPosition();
infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1);
+ if (this.resolveBindings) {
+ this.recordNodes(infixExpression, expression);
+ }
return infixExpression;
}
- rightOperand = ((BinaryExpression) leftOperand).right;
infixExpression.extendedOperands().add(0, convert(rightOperand));
leftOperand = ((BinaryExpression) leftOperand).left;
- } while (leftOperand instanceof BinaryExpression);
- // check that the right operand wasn't a BinaryExpression
- if (rightOperand instanceof BinaryExpression) {
- infixExpression.extendedOperands().clear();
- Expression leftExpression = convert(expression.left);
- infixExpression.setLeftOperand(leftExpression);
- infixExpression.setRightOperand(convert(expression.right));
- int startPosition = leftExpression.getStartPosition();
- infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1);
- return infixExpression;
- } else {
- Expression leftExpression = convert(leftOperand);
- infixExpression.setLeftOperand(leftExpression);
- infixExpression.setRightOperand((Expression)infixExpression.extendedOperands().remove(0));
- int startPosition = leftExpression.getStartPosition();
- infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1);
- return infixExpression;
- }
+ } while (leftOperand instanceof BinaryExpression && ((leftOperand.bits & AstNode.ParenthesizedMASK) == 0));
+ Expression leftExpression = convert(leftOperand);
+ infixExpression.setLeftOperand(leftExpression);
+ infixExpression.setRightOperand((Expression)infixExpression.extendedOperands().remove(0));
+ int startPosition = leftExpression.getStartPosition();
+ infixExpression.setSourceRange(startPosition, expression.sourceEnd - startPosition + 1);
+ return infixExpression;
}
Expression leftExpression = convert(expression.left);
infixExpression.setLeftOperand(leftExpression);
@@ -1457,6 +1571,7 @@
public Expression convert(MessageSend expression) {
// will return a MethodInvocation or a SuperMethodInvocation or
Expression expr;
+ int sourceStart = expression.sourceStart;
if (expression.isSuperAccess()) {
// returns a SuperMethodInvocation
SuperMethodInvocation superMethodInvocation = this.ast.newSuperMethodInvocation();
@@ -1479,6 +1594,9 @@
if (this.resolveBindings) {
recordNodes(qualifier, expression.receiver);
}
+ if (qualifier != null) {
+ sourceStart = qualifier.getStartPosition();
+ }
}
org.eclipse.jdt.internal.compiler.ast.Expression[] arguments = expression.arguments;
if (arguments != null) {
@@ -1522,9 +1640,12 @@
recordNodes(qualifier, expression.receiver);
}
methodInvocation.setExpression(qualifier);
+ if (qualifier != null) {
+ sourceStart = qualifier.getStartPosition();
+ }
expr = methodInvocation;
}
- expr.setSourceRange(expression.sourceStart, expression.sourceEnd - expression.sourceStart + 1);
+ expr.setSourceRange(sourceStart, expression.sourceEnd - sourceStart + 1);
removeTrailingCommentFromExpressionEndingWithAParen(expr);
return expr;
}
@@ -1669,11 +1790,15 @@
public AssertStatement convert(org.eclipse.jdt.internal.compiler.ast.AssertStatement statement) {
AssertStatement assertStatement = this.ast.newAssertStatement();
assertStatement.setExpression(convert(statement.assertExpression));
+ int end = statement.assertExpression.sourceEnd + 1;
org.eclipse.jdt.internal.compiler.ast.Expression exceptionArgument = statement.exceptionArgument;
if (exceptionArgument != null) {
assertStatement.setMessage(convert(exceptionArgument));
+ end = exceptionArgument.sourceEnd + 1;
}
- assertStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ int start = statement.sourceStart;
+ int sourceEnd = retrieveEndingSemiColonPosition(end, compilationUnitSource.length);
+ assertStatement.setSourceRange(start, sourceEnd - start + 1);
return assertStatement;
}
@@ -1704,6 +1829,7 @@
retrieveIdentifierAndSetPositions(statement.sourceStart, statement.sourceEnd, name);
breakStatement.setLabel(name);
}
+ retrieveSemiColonPosition(breakStatement);
return breakStatement;
}
@@ -1715,6 +1841,7 @@
retrieveIdentifierAndSetPositions(statement.sourceStart, statement.sourceEnd, name);
continueStatement.setLabel(name);
}
+ retrieveSemiColonPosition(continueStatement);
return continueStatement;
}
@@ -1723,6 +1850,7 @@
SwitchCase switchCase = this.ast.newSwitchCase();
switchCase.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
switchCase.setExpression(convert(statement.constantExpression));
+ retrieveColonPosition(switchCase);
return switchCase;
}
@@ -1730,6 +1858,7 @@
SwitchCase switchCase = this.ast.newSwitchCase();
switchCase.setExpression(null);
switchCase.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ retrieveColonPosition(switchCase);
return switchCase;
}
@@ -1737,8 +1866,15 @@
DoStatement doStatement = this.ast.newDoStatement();
doStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
doStatement.setExpression(convert(statement.condition));
- if (statement.action != null) {
+ org.eclipse.jdt.internal.compiler.ast.Statement action = statement.action;
+ if (action != null) {
doStatement.setBody(convert(statement.action));
+ } else {
+ EmptyStatement emptyStatement = this.ast.newEmptyStatement();
+ int start = retrieveStartingSemiColonPosition(statement.sourceStart, statement.sourceEnd);
+ int end = retrieveEndingSemiColonPosition(start, statement.sourceEnd);
+ emptyStatement.setSourceRange(start, end - start + 1);
+ doStatement.setBody(emptyStatement);
}
retrieveSemiColonPosition(doStatement);
return doStatement;
@@ -1752,7 +1888,7 @@
public Statement convert(ExplicitConstructorCall statement) {
Statement newStatement;
- if (statement.isSuperAccess() || statement.isSuper() || statement.isImplicitSuper()) {
+ if (statement.isSuperAccess() || statement.isSuper()) {
SuperConstructorInvocation superConstructorInvocation = this.ast.newSuperConstructorInvocation();
if (statement.qualification != null) {
superConstructorInvocation.setExpression(convert(statement.qualification));
@@ -1777,6 +1913,7 @@
newStatement = constructorInvocation;
}
newStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
+ retrieveSemiColonPosition(newStatement);
if (this.resolveBindings) {
recordNodes(newStatement, statement);
}
@@ -1788,9 +1925,19 @@
forStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
org.eclipse.jdt.internal.compiler.ast.Statement[] initializations = statement.initializations;
if (initializations != null) {
- int initializationsLength = initializations.length;
- for (int i = 0; i < initializationsLength; i++) {
- forStatement.initializers().add(convertToExpression(initializations[i]));
+ // we know that we have at least one initialization
+ if (initializations[0] instanceof LocalDeclaration) {
+ VariableDeclarationExpression variableDeclarationExpression = convertToVariableDeclarationExpression((LocalDeclaration) initializations[0]);
+ int initializationsLength = initializations.length;
+ for (int i = 1; i < initializationsLength; i++) {
+ variableDeclarationExpression.fragments().add(convertToVariableDeclarationFragment((LocalDeclaration)initializations[i]));
+ }
+ forStatement.initializers().add(variableDeclarationExpression);
+ } else {
+ int initializationsLength = initializations.length;
+ for (int i = 0; i < initializationsLength; i++) {
+ forStatement.initializers().add(convertToExpression(initializations[i]));
+ }
}
}
if (statement.condition != null) {
@@ -1806,12 +1953,12 @@
org.eclipse.jdt.internal.compiler.ast.Statement action = statement.action;
if (action != null) {
forStatement.setBody(convert(statement.action));
- if (!(action instanceof org.eclipse.jdt.internal.compiler.ast.Block)) {
- // set the end position of the for statement on the semi-colon
- retrieveSemiColonPosition(forStatement);
- }
} else {
- retrieveSemiColonPosition(forStatement);
+ EmptyStatement emptyStatement = this.ast.newEmptyStatement();
+ int start = retrieveStartingSemiColonPosition(statement.sourceStart, compilationUnitSource.length);
+ int end = retrieveEndingSemiColonPosition(start, compilationUnitSource.length);
+ emptyStatement.setSourceRange(start, end - start + 1);
+ forStatement.setBody(emptyStatement);
}
return forStatement;
}
@@ -1819,41 +1966,9 @@
public Expression convertToExpression(org.eclipse.jdt.internal.compiler.ast.Statement statement) {
if (statement instanceof org.eclipse.jdt.internal.compiler.ast.Expression) {
return convert((org.eclipse.jdt.internal.compiler.ast.Expression) statement);
- } else if (statement instanceof LocalDeclaration) {
- LocalDeclaration localDeclaration = (LocalDeclaration) statement;
- VariableDeclarationFragment variableDeclarationFragment = this.ast.newVariableDeclarationFragment();
- SimpleName name = this.ast.newSimpleName(localDeclaration.name());
- name.setSourceRange(localDeclaration.sourceStart, localDeclaration.sourceEnd - localDeclaration.sourceStart + 1);
- variableDeclarationFragment.setName(name);
- variableDeclarationFragment.setSourceRange(localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd - localDeclaration.declarationSourceStart + 1);
- if (localDeclaration.initialization != null) {
- variableDeclarationFragment.setInitializer(convert(localDeclaration.initialization));
- }
- VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
- if (this.resolveBindings) {
- recordNodes(variableDeclarationFragment, localDeclaration);
- }
- variableDeclarationExpression.setSourceRange(localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd - localDeclaration.declarationSourceStart + 1);
- /**
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=13233
- * This handles cases where the parser built variables with invalid modifiers.
- * The compilation unit is tagged as having wrong modifiers for the local.
- * Only final is allowed in this case.
- */
- try {
- variableDeclarationExpression.setModifiers(localDeclaration.modifiers);
- } catch(IllegalArgumentException e) {
- variableDeclarationExpression.setModifiers(localDeclaration.modifiers & Modifier.FINAL);
- variableDeclarationExpression.setFlags(ASTNode.MALFORMED);
- }
- variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(localDeclaration.sourceEnd + 1, this.compilationUnitSource.length));
- Type type = convertType(localDeclaration.type);
- setTypeForVariableDeclarationExpression(variableDeclarationExpression, type, variableDeclarationFragment.getExtraDimensions());
- return variableDeclarationExpression;
- } else {
- // unsupported
- throw new IllegalArgumentException("Not yet implemented: convert(" + statement.getClass() + ")");//$NON-NLS-1$//$NON-NLS-2$
}
+ // unsupported
+ throw new IllegalArgumentException("Not yet implemented: convert(" + statement.getClass() + ")");//$NON-NLS-1$//$NON-NLS-2$
}
public IfStatement convert(org.eclipse.jdt.internal.compiler.ast.IfStatement statement) {
@@ -1864,14 +1979,24 @@
org.eclipse.jdt.internal.compiler.ast.Statement elseStatement = statement.elseStatement;
if (thenStatement != null) {
if (thenStatement == org.eclipse.jdt.internal.compiler.ast.Block.None) {
- ifStatement.setThenStatement(this.ast.newEmptyStatement());
+ EmptyStatement emptyStatement = this.ast.newEmptyStatement();
+ int start = retrieveStartingSemiColonPosition(statement.sourceStart, statement.sourceEnd);
+ int end = retrieveEndingSemiColonPosition(start, statement.sourceEnd);
+ emptyStatement.setSourceRange(start, end - start + 1);
+ ifStatement.setThenStatement(emptyStatement);
} else {
ifStatement.setThenStatement(convert(statement.thenStatement));
}
}
if (elseStatement != null) {
if (elseStatement == org.eclipse.jdt.internal.compiler.ast.Block.None) {
- ifStatement.setElseStatement(this.ast.newEmptyStatement());
+ // retrieve the else position
+ EmptyStatement emptyStatement = this.ast.newEmptyStatement();
+ int start = retrieveElseEndingPosition(statement.sourceStart, statement.sourceEnd);
+ start = retrieveStartingSemiColonPosition(statement.sourceStart, statement.sourceEnd);
+ int end = retrieveEndingSemiColonPosition(start, statement.sourceEnd);
+ emptyStatement.setSourceRange(start, end - start + 1);
+ ifStatement.setElseStatement(emptyStatement);
} else {
ifStatement.setElseStatement(convert(elseStatement));
}
@@ -1882,7 +2007,16 @@
public LabeledStatement convert(org.eclipse.jdt.internal.compiler.ast.LabeledStatement statement) {
LabeledStatement labeledStatement = this.ast.newLabeledStatement();
labeledStatement.setSourceRange(statement.sourceStart, statement.sourceEnd - statement.sourceStart + 1);
- labeledStatement.setBody(convert(statement.statement));
+ org.eclipse.jdt.internal.compiler.ast.Statement body = statement.statement;
+ if (body == org.eclipse.jdt.internal.compiler.ast.Block.None) {
+ EmptyStatement emptyStatement = this.ast.newEmptyStatement();
+ int start = retrieveStartingSemiColonPosition(statement.sourceStart, statement.sourceEnd);
+ int end = retrieveEndingSemiColonPosition(start, statement.sourceEnd);
+ emptyStatement.setSourceRange(start, end - start + 1);
+ labeledStatement.setBody(emptyStatement);
+ } else {
+ labeledStatement.setBody(convert(body));
+ }
SimpleName name = this.ast.newSimpleName(new String(statement.label));
retrieveIdentifierAndSetPositions(statement.sourceStart, statement.sourceEnd, name);
labeledStatement.setLabel(name);
@@ -1966,6 +2100,13 @@
// set the end position of the for statement on the semi-colon
retrieveSemiColonPosition(whileStatement);
}
+ } else {
+ EmptyStatement emptyStatement = this.ast.newEmptyStatement();
+ retrieveSemiColonPosition(whileStatement);
+ int start = retrieveStartingSemiColonPosition(statement.sourceStart, compilationUnitSource.length);
+ int end = retrieveEndingSemiColonPosition(start, compilationUnitSource.length);
+ emptyStatement.setSourceRange(start, end - start + 1);
+ whileStatement.setBody(emptyStatement);
}
return whileStatement;
}
@@ -2136,30 +2277,30 @@
scanner.resetTo(end, this.compilationUnitSource.length);
try {
int token;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameSEMICOLON:
+ case TerminalTokens.TokenNameSEMICOLON:
if (count == 0) {
node.setSourceRange(start, scanner.currentPosition - start);
return;
}
break;
- case Scanner.TokenNameLBRACE :
+ case TerminalTokens.TokenNameLBRACE :
count++;
break;
- case Scanner.TokenNameRBRACE :
+ case TerminalTokens.TokenNameRBRACE :
count--;
break;
- case Scanner.TokenNameLPAREN :
+ case TerminalTokens.TokenNameLPAREN :
count++;
break;
- case Scanner.TokenNameRPAREN :
+ case TerminalTokens.TokenNameRPAREN :
count--;
break;
- case Scanner.TokenNameLBRACKET :
+ case TerminalTokens.TokenNameLBRACKET :
count++;
break;
- case Scanner.TokenNameRBRACKET :
+ case TerminalTokens.TokenNameRBRACKET :
count--;
}
}
@@ -2168,19 +2309,20 @@
}
/**
- * This method is used to set the right end position for switch and
- * try statements. They don't include the close }.
+ * This method is used to set the right end position for expression
+ * statement. The actual AST nodes don't include the trailing semicolon.
+ * This method fixes the length of the corresponding node.
*/
- private void retrieveRightBracePosition(ASTNode node) {
+ private void retrieveColonPosition(ASTNode node) {
int start = node.getStartPosition();
int length = node.getLength();
int end = start + length;
scanner.resetTo(end, this.compilationUnitSource.length);
try {
int token;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameRBRACE:
+ case TerminalTokens.TokenNameCOLON:
node.setSourceRange(start, scanner.currentPosition - start);
return;
}
@@ -2189,6 +2331,93 @@
}
}
+ private int retrieveStartingSemiColonPosition(int start, int end) {
+ int count = 0;
+ scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameSEMICOLON:
+ if (count == 0) {
+ return scanner.startPosition;
+ }
+ break;
+ case TerminalTokens.TokenNameLBRACE :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRBRACE :
+ count--;
+ break;
+ case TerminalTokens.TokenNameLPAREN :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRPAREN :
+ count--;
+ break;
+ case TerminalTokens.TokenNameLBRACKET :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRBRACKET :
+ count--;
+ }
+ }
+ } catch(InvalidInputException e) {
+ }
+ return -1;
+ }
+
+ private int retrieveEndingSemiColonPosition(int start, int end) {
+ int count = 0;
+ scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameSEMICOLON:
+ if (count == 0) {
+ return scanner.currentPosition - 1;
+ }
+ break;
+ case TerminalTokens.TokenNameLBRACE :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRBRACE :
+ count--;
+ break;
+ case TerminalTokens.TokenNameLPAREN :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRPAREN :
+ count--;
+ break;
+ case TerminalTokens.TokenNameLBRACKET :
+ count++;
+ break;
+ case TerminalTokens.TokenNameRBRACKET :
+ count--;
+ }
+ }
+ } catch(InvalidInputException e) {
+ }
+ return -1;
+ }
+
+ private int retrieveElseEndingPosition(int start, int end) {
+ scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameelse:
+ return scanner.currentPosition - 1;
+ }
+ }
+ } catch(InvalidInputException e) {
+ }
+ return -1;
+ }
+
/**
* This method is used to retrieve the array dimension declared after the
* name of a local or a field declaration.
@@ -2202,15 +2431,16 @@
int dimensions = 0;
try {
int token;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameRBRACKET://166
+ case TerminalTokens.TokenNameRBRACKET://166
dimensions++;
break;
- case Scanner.TokenNameCOMMA ://90
- case Scanner.TokenNameEQUAL ://167
- case Scanner.TokenNameSEMICOLON ://64
- case Scanner.TokenNameRPAREN : //86
+ case TerminalTokens.TokenNameLBRACE ://90
+ case TerminalTokens.TokenNameCOMMA ://90
+ case TerminalTokens.TokenNameEQUAL ://167
+ case TerminalTokens.TokenNameSEMICOLON ://64
+ case TerminalTokens.TokenNameRPAREN : //86
return dimensions;
}
}
@@ -2231,14 +2461,14 @@
int foundPosition = -1;
try {
int token;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameLBRACKET:
- case Scanner.TokenNameCOMMENT_BLOCK:
- case Scanner.TokenNameCOMMENT_JAVADOC:
- case Scanner.TokenNameCOMMENT_LINE:
+ case TerminalTokens.TokenNameLBRACKET:
+ case TerminalTokens.TokenNameCOMMENT_BLOCK:
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC:
+ case TerminalTokens.TokenNameCOMMENT_LINE:
break;
- case Scanner.TokenNameRBRACKET://166
+ case TerminalTokens.TokenNameRBRACKET://166
foundPosition = scanner.currentPosition - 1;
break;
default:
@@ -2258,9 +2488,9 @@
scanner.resetTo(start, end);
try {
int token;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNamecatch://225
+ case TerminalTokens.TokenNamecatch://225
return scanner.startPosition;
}
}
@@ -2273,14 +2503,21 @@
* This method is used to retrieve the position just before the left bracket.
* @return int the dimension found, -1 if none
*/
- private int retrieveStartingLeftBracketPosition(int start, int end) {
+ private int retrieveEndOfElementTypeNamePosition(int start, int end) {
scanner.resetTo(start, end);
try {
int token;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameLBRACKET://225
- return scanner.startPosition - 1;
+ case TerminalTokens.TokenNameIdentifier:
+ case TerminalTokens.TokenNamebyte:
+ case TerminalTokens.TokenNamechar:
+ case TerminalTokens.TokenNamedouble:
+ case TerminalTokens.TokenNamefloat:
+ case TerminalTokens.TokenNameint:
+ case TerminalTokens.TokenNamelong:
+ case TerminalTokens.TokenNameshort:
+ return scanner.currentPosition - 1;
}
}
} catch(InvalidInputException e) {
@@ -2296,9 +2533,9 @@
scanner.resetTo(start, end);
try {
int token;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameRBRACKET:
+ case TerminalTokens.TokenNameRBRACKET:
return scanner.currentPosition - 1;
}
}
@@ -2307,13 +2544,32 @@
return -1;
}
+ /**
+ * This method is used to retrieve the position after the right parenthesis.
+ * @return int the position found
+ */
+ private int retrieveEndOfRightParenthesisPosition(int start, int end) {
+ scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameRPAREN:
+ return scanner.currentPosition;
+ }
+ }
+ } catch(InvalidInputException e) {
+ }
+ return -1;
+ }
+
private int retrieveProperRightBracketPosition(int bracketNumber, int start, int end) {
scanner.resetTo(start, end);
try {
int token, count = 0;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameRBRACKET:
+ case TerminalTokens.TokenNameRBRACKET:
count++;
if (count == bracketNumber) {
return scanner.currentPosition - 1;
@@ -2333,9 +2589,9 @@
scanner.resetTo(start, end);
try {
int token;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameLBRACE://110
+ case TerminalTokens.TokenNameLBRACE://110
return scanner.startPosition;
}
}
@@ -2345,6 +2601,25 @@
}
/**
+ * This method is used to retrieve the start position of the block.
+ * @return int the dimension found, -1 if none
+ */
+ private int retrieveIdentifierEndPosition(int start, int end) {
+ scanner.resetTo(start, end);
+ try {
+ int token;
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameIdentifier://110
+ return scanner.getCurrentTokenEndPosition();
+ }
+ }
+ } catch(InvalidInputException e) {
+ }
+ return -1;
+ }
+
+ /**
* This method is used to retrieve the end position of the block.
* @return int the dimension found, -1 if none
*/
@@ -2353,12 +2628,12 @@
int count = 0;
try {
int token;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameLBRACE://110
+ case TerminalTokens.TokenNameLBRACE://110
count++;
break;
- case Scanner.TokenNameRBRACE://95
+ case TerminalTokens.TokenNameRBRACE://95
count--;
if (count == 0) {
return scanner.currentPosition - 1;
@@ -2380,19 +2655,19 @@
try {
int token;
int braceCounter = 0;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameLBRACE :
+ case TerminalTokens.TokenNameLBRACE :
braceCounter++;
break;
- case Scanner.TokenNameRBRACE :
+ case TerminalTokens.TokenNameRBRACE :
braceCounter--;
if (braceCounter == 0) {
node.setSourceRange(start, scanner.currentPosition - start);
return;
}
break;
- case Scanner.TokenNameSEMICOLON :
+ case TerminalTokens.TokenNameSEMICOLON :
if (braceCounter == 0) {
node.setSourceRange(start, scanner.currentPosition - start);
return;
@@ -2412,28 +2687,28 @@
int braceCounter = 0;
try {
int token;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameLBRACE :
+ case TerminalTokens.TokenNameLBRACE :
braceCounter++;
break;
- case Scanner.TokenNameRBRACE :
+ case TerminalTokens.TokenNameRBRACE :
braceCounter--;
break;
- case Scanner.TokenNameLPAREN :
+ case TerminalTokens.TokenNameLPAREN :
braceCounter++;
break;
- case Scanner.TokenNameRPAREN :
+ case TerminalTokens.TokenNameRPAREN :
braceCounter--;
break;
- case Scanner.TokenNameLBRACKET :
+ case TerminalTokens.TokenNameLBRACKET :
braceCounter++;
break;
- case Scanner.TokenNameRBRACKET :
+ case TerminalTokens.TokenNameRBRACKET :
braceCounter--;
break;
- case Scanner.TokenNameCOMMA :
- case Scanner.TokenNameSEMICOLON :
+ case TerminalTokens.TokenNameCOMMA :
+ case TerminalTokens.TokenNameSEMICOLON :
if (braceCounter == 0) {
return scanner.startPosition - 1;
}
@@ -2489,6 +2764,7 @@
variableDeclarationFragment.setExtraDimensions(retrieveExtraDimension(localDeclaration.sourceEnd + 1, this.compilationUnitSource.length));
if (this.resolveBindings) {
recordNodes(variableDeclarationFragment, localDeclaration);
+ recordNodes(name, localDeclaration);
variableDeclarationFragment.resolveBinding();
}
return variableDeclarationFragment;
@@ -2538,7 +2814,7 @@
* Only final is allowed in this case.
*/
try {
- variableDeclarationStatement.setModifiers(localDeclaration.modifiers);
+ variableDeclarationStatement.setModifiers(localDeclaration.modifiers & ~CompilerModifiers.AccBlankFinal);
} catch(IllegalArgumentException e) {
variableDeclarationStatement.setModifiers(localDeclaration.modifiers & Modifier.FINAL);
variableDeclarationStatement.setFlags(ASTNode.MALFORMED);
@@ -2547,6 +2823,30 @@
return variableDeclarationStatement;
}
+ private VariableDeclarationExpression convertToVariableDeclarationExpression(LocalDeclaration localDeclaration) {
+ VariableDeclarationFragment variableDeclarationFragment = convertToVariableDeclarationFragment(localDeclaration);
+ VariableDeclarationExpression variableDeclarationExpression = this.ast.newVariableDeclarationExpression(variableDeclarationFragment);
+ if (this.resolveBindings) {
+ recordNodes(variableDeclarationFragment, localDeclaration);
+ }
+ variableDeclarationExpression.setSourceRange(localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd - localDeclaration.declarationSourceStart + 1);
+ Type type = convertType(localDeclaration.type);
+ setTypeForVariableDeclarationExpression(variableDeclarationExpression, type, variableDeclarationFragment.getExtraDimensions());
+ /**
+ * http://dev.eclipse.org/bugs/show_bug.cgi?id=13233
+ * This handles cases where the parser built variables with invalid modifiers.
+ * The compilation unit is tagged as having wrong modifiers for the local.
+ * Only final is allowed in this case.
+ */
+ try {
+ variableDeclarationExpression.setModifiers(localDeclaration.modifiers & ~CompilerModifiers.AccBlankFinal);
+ } catch(IllegalArgumentException e) {
+ variableDeclarationExpression.setModifiers(localDeclaration.modifiers & Modifier.FINAL);
+ variableDeclarationExpression.setFlags(ASTNode.MALFORMED);
+ }
+ return variableDeclarationExpression;
+ }
+
private void setTypeForField(FieldDeclaration fieldDeclaration, Type type, int extraDimension) {
if (extraDimension != 0) {
if (type.isArrayType()) {
@@ -2581,6 +2881,74 @@
}
}
+ private void setTypeForSingleVariableDeclaration(SingleVariableDeclaration singleVariableDeclaration, Type type, int extraDimension) {
+ if (extraDimension != 0) {
+ if (type.isArrayType()) {
+ ArrayType arrayType = (ArrayType) type;
+ int remainingDimensions = arrayType.getDimensions() - extraDimension;
+ if (remainingDimensions == 0) {
+ // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
+ Type elementType = arrayType.getElementType();
+ elementType.setParent(null);
+ this.ast.getBindingResolver().updateKey(type, elementType);
+ singleVariableDeclaration.setType(elementType);
+ } else {
+ int start = type.getStartPosition();
+ int length = type.getLength();
+ ArrayType subarrayType = arrayType;
+ int index = extraDimension;
+ while (index > 0) {
+ subarrayType = (ArrayType) subarrayType.getComponentType();
+ index--;
+ }
+ int end = retrieveProperRightBracketPosition(remainingDimensions, start, start + length);
+ subarrayType.setSourceRange(start, end - start + 1);
+ subarrayType.setParent(null);
+ singleVariableDeclaration.setType(subarrayType);
+ this.ast.getBindingResolver().updateKey(type, subarrayType);
+ }
+ } else {
+ singleVariableDeclaration.setType(type);
+ }
+ } else {
+ singleVariableDeclaration.setType(type);
+ }
+ }
+
+ private void setTypeForMethodDeclaration(MethodDeclaration methodDeclaration, Type type, int extraDimension) {
+ if (extraDimension != 0) {
+ if (type.isArrayType()) {
+ ArrayType arrayType = (ArrayType) type;
+ int remainingDimensions = arrayType.getDimensions() - extraDimension;
+ if (remainingDimensions == 0) {
+ // the dimensions are after the name so the type of the fieldDeclaration is a simpleType
+ Type elementType = arrayType.getElementType();
+ elementType.setParent(null);
+ this.ast.getBindingResolver().updateKey(type, elementType);
+ methodDeclaration.setReturnType(elementType);
+ } else {
+ int start = type.getStartPosition();
+ int length = type.getLength();
+ ArrayType subarrayType = arrayType;
+ int index = extraDimension;
+ while (index > 0) {
+ subarrayType = (ArrayType) subarrayType.getComponentType();
+ index--;
+ }
+ int end = retrieveProperRightBracketPosition(remainingDimensions, start, start + length);
+ subarrayType.setSourceRange(start, end - start + 1);
+ subarrayType.setParent(null);
+ methodDeclaration.setReturnType(subarrayType);
+ this.ast.getBindingResolver().updateKey(type, subarrayType);
+ }
+ } else {
+ methodDeclaration.setReturnType(type);
+ }
+ } else {
+ methodDeclaration.setReturnType(type);
+ }
+ }
+
private void setTypeForVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement, Type type, int extraDimension) {
if (extraDimension != 0) {
if (type.isArrayType()) {
@@ -2653,9 +3021,9 @@
scanner.resetTo(bodyDeclaration.getStartPosition(), bodyDeclaration.getStartPosition() + bodyDeclaration.getLength());
try {
int token;
- while ((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameCOMMENT_JAVADOC: //1003
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC: //1003
Javadoc javadocComment = this.ast.newJavadoc();
int start = scanner.startPosition;
int length = scanner.currentPosition - start;
@@ -2665,6 +3033,8 @@
javadocComment.setSourceRange(start, length);
bodyDeclaration.setJavadoc(javadocComment);
return;
+ default :
+ return;
}
}
} catch(InvalidInputException e) {
@@ -2682,62 +3052,51 @@
ASTSyntaxErrorPropagator syntaxErrorPropagator = new ASTSyntaxErrorPropagator(resizeProblems);
unit.accept(syntaxErrorPropagator);
// store the messages error on the compulation unit
- Message[] messages = new Message[problemLength];
- for (int i = 0; i < problemLength; i++) {
- IProblem problem = problems[i];
- int start = problem.getSourceStart();
- int end = problem.getSourceEnd();
- messages[i] = new Message(problem.getMessage(), start, end - start + 1);
- }
- unit.setMessages(messages);
- }
-
- private boolean checkAndTagAsMalformed(ASTNode node, int position) {
- int start = node.getStartPosition();
- int end = start + node.getLength();
- if ((start <= position) && (position <= end)) {
- node.setFlags(ASTNode.MALFORMED);
- return true;
- }
- return false;
+ unit.setProblems(resizeProblems);
}
private void recordNodes(ASTNode node, org.eclipse.jdt.internal.compiler.ast.AstNode oldASTNode) {
this.ast.getBindingResolver().store(node, oldASTNode);
}
- private boolean checkForParenthesis(org.eclipse.jdt.internal.compiler.ast.Expression expression) {
- /*
- * We need to handle multiple parenthesis
- */
+ /**
+ * Remove whitespaces before and after the expression.
+ */
+ private void removeExtraBlanks(org.eclipse.jdt.internal.compiler.ast.Expression expression) {
int start = expression.sourceStart;
int end = expression.sourceEnd;
- scanner.resetTo(start, end);
- int dangling = 0, token;
+ int token;
+ int trimLeftPosition = expression.sourceStart;
+ int trimRigthPosition = expression.sourceEnd;
boolean first = true;
+ Scanner removeBlankScanner = this.ast.scanner;
try {
+ removeBlankScanner.setSource(this.compilationUnitSource);
+ removeBlankScanner.resetTo(start, end);
while (true) {
- token = scanner.getNextToken();
+ token = removeBlankScanner.getNextToken();
switch (token) {
- case Scanner.TokenNameLPAREN :
- dangling ++;
+ case TerminalTokens.TokenNameWHITESPACE :
+ if (first) {
+ trimLeftPosition = removeBlankScanner.currentPosition;
+ }
+ trimRigthPosition = removeBlankScanner.startPosition - 1;
break;
- case Scanner.TokenNameRPAREN :
- if (first) return false;
- dangling --;
- break;
- case Scanner.TokenNameEOF :
- if (first) return false;
- return dangling == 0;
+ case TerminalTokens.TokenNameEOF :
+ expression.sourceStart = trimLeftPosition;
+ expression.sourceEnd = trimRigthPosition;
+ return;
default :
- if (first) return false;
- if (dangling == 0) return false;
+ /*
+ * if we find something else than a whitespace, then we reset the trimRigthPosition
+ * to the expression source end.
+ */
+ trimRigthPosition = expression.sourceEnd;
}
first = false;
}
} catch (InvalidInputException e){
}
- return false;
}
private void adjustSourcePositionsForParent(org.eclipse.jdt.internal.compiler.ast.Expression expression) {
@@ -2750,12 +3109,12 @@
int token = scanner.getNextToken();
expression.sourceStart = scanner.currentPosition;
boolean stop = false;
- while (!stop && ((token = scanner.getNextToken()) != Scanner.TokenNameEOF)) {
+ while (!stop && ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF)) {
switch(token) {
- case Scanner.TokenNameLPAREN:
+ case TerminalTokens.TokenNameLPAREN:
leftParentCount++;
break;
- case Scanner.TokenNameRPAREN:
+ case TerminalTokens.TokenNameRPAREN:
rightParentCount++;
if (rightParentCount == leftParentCount) {
// we found the matching parenthesis
@@ -2774,8 +3133,8 @@
int token;
int index = 0;
try {
- while((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
- if (token == Scanner.TokenNameIdentifier) {
+ while((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ if (token == TerminalTokens.TokenNameIdentifier) {
positions[index] = (((long) scanner.startPosition) << 32) + (scanner.currentPosition - 1);
index++;
}
@@ -2789,8 +3148,8 @@
scanner.resetTo(start, end);
int token;
try {
- while((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
- if (token == Scanner.TokenNameIdentifier) {
+ while((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ if (token == TerminalTokens.TokenNameIdentifier) {
int startName = scanner.startPosition;
int endName = scanner.currentPosition - 1;
name.setSourceRange(startName, endName - startName + 1);
@@ -2810,12 +3169,12 @@
int token;
int parenCounter = 0;
try {
- while((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameLPAREN :
+ case TerminalTokens.TokenNameLPAREN :
parenCounter++;
break;
- case Scanner.TokenNameRPAREN :
+ case TerminalTokens.TokenNameRPAREN :
parenCounter--;
if (parenCounter == 0) {
int end = scanner.currentPosition - 1;
@@ -2836,20 +3195,20 @@
int token;
int startPosition = -1;
try {
- while((token = scanner.getNextToken()) != Scanner.TokenNameEOF) {
+ while((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch(token) {
- case Scanner.TokenNameIntegerLiteral :
- case Scanner.TokenNameFloatingPointLiteral :
- case Scanner.TokenNameLongLiteral :
- case Scanner.TokenNameDoubleLiteral :
- case Scanner.TokenNameCharacterLiteral :
+ case TerminalTokens.TokenNameIntegerLiteral :
+ case TerminalTokens.TokenNameFloatingPointLiteral :
+ case TerminalTokens.TokenNameLongLiteral :
+ case TerminalTokens.TokenNameDoubleLiteral :
+ case TerminalTokens.TokenNameCharacterLiteral :
if (startPosition == -1) {
startPosition = scanner.startPosition;
}
int end = scanner.currentPosition;
node.setSourceRange(startPosition, end - startPosition);
return;
- case Scanner.TokenNameMINUS :
+ case TerminalTokens.TokenNameMINUS :
startPosition = scanner.startPosition;
break;
}
@@ -2857,5 +3216,79 @@
} catch(InvalidInputException e) {
}
}
+
+ private void recordPendingThisExpressionScopeResolution(ThisExpression thisExpression) {
+ if (this.pendingThisExpressionScopeResolution == null) {
+ this.pendingThisExpressionScopeResolution = new HashSet();
+ }
+ this.pendingThisExpressionScopeResolution.add(thisExpression);
+ }
+
+ private void recordPendingNameScopeResolution(Name name) {
+ if (this.pendingNameScopeResolution == null) {
+ this.pendingNameScopeResolution = new HashSet();
+ }
+ this.pendingNameScopeResolution.add(name);
+ }
+
+ private void lookupForScopes() {
+ if (this.pendingNameScopeResolution != null) {
+ for (Iterator iterator = this.pendingNameScopeResolution.iterator(); iterator.hasNext(); ) {
+ Name name = (Name) iterator.next();
+ this.ast.getBindingResolver().recordScope(name, name.lookupScope());
+ }
+ }
+ if (this.pendingThisExpressionScopeResolution != null) {
+ for (Iterator iterator = this.pendingThisExpressionScopeResolution.iterator(); iterator.hasNext(); ) {
+ ThisExpression thisExpression = (ThisExpression) iterator.next();
+ this.ast.getBindingResolver().recordScope(thisExpression, thisExpression.lookupScope());
+ }
+ }
+
+ }
+
+ private InfixExpression.Operator getOperatorFor(int operatorID) {
+ switch (operatorID) {
+ case OperatorIds.EQUAL_EQUAL :
+ return InfixExpression.Operator.EQUALS;
+ case OperatorIds.LESS_EQUAL :
+ return InfixExpression.Operator.LESS_EQUALS;
+ case OperatorIds.GREATER_EQUAL :
+ return InfixExpression.Operator.GREATER_EQUALS;
+ case OperatorIds.NOT_EQUAL :
+ return InfixExpression.Operator.NOT_EQUALS;
+ case OperatorIds.LEFT_SHIFT :
+ return InfixExpression.Operator.LEFT_SHIFT;
+ case OperatorIds.RIGHT_SHIFT :
+ return InfixExpression.Operator.RIGHT_SHIFT_SIGNED;
+ case OperatorIds.UNSIGNED_RIGHT_SHIFT :
+ return InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED;
+ case OperatorIds.OR_OR :
+ return InfixExpression.Operator.CONDITIONAL_OR;
+ case OperatorIds.AND_AND :
+ return InfixExpression.Operator.CONDITIONAL_AND;
+ case OperatorIds.PLUS :
+ return InfixExpression.Operator.PLUS;
+ case OperatorIds.MINUS :
+ return InfixExpression.Operator.MINUS;
+ case OperatorIds.REMAINDER :
+ return InfixExpression.Operator.REMAINDER;
+ case OperatorIds.XOR :
+ return InfixExpression.Operator.XOR;
+ case OperatorIds.AND :
+ return InfixExpression.Operator.AND;
+ case OperatorIds.MULTIPLY :
+ return InfixExpression.Operator.TIMES;
+ case OperatorIds.OR :
+ return InfixExpression.Operator.OR;
+ case OperatorIds.DIVIDE :
+ return InfixExpression.Operator.DIVIDE;
+ case OperatorIds.GREATER :
+ return InfixExpression.Operator.GREATER;
+ case OperatorIds.LESS :
+ return InfixExpression.Operator.LESS;
+ };
+ return null;
+ }
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java
index d8a5cb9..143f094 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTMatcher.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 IBM Corporation and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
import java.util.Iterator;
@@ -883,6 +883,14 @@
* other object is a node of the same type with structurally isomorphic
* child subtrees. Subclasses may override this method as needed.
* </p>
+ * <p>
+ * Note that extra array dimensions are compared since they are an
+ * important part of the method declaration.
+ * </p>
+ * <p>
+ * Note that the method return types are compared even for constructor
+ * declarations.
+ * </p>
*
* @param node the node
* @param other the other object, or <code>null</code>
@@ -899,9 +907,11 @@
(node.getModifiers() == o.getModifiers())
&& (node.isConstructor() == o.isConstructor())
&& safeSubtreeMatch(node.getJavadoc(), o.getJavadoc())
+ // n.b. compare return type even for constructors
&& safeSubtreeMatch(node.getReturnType(), o.getReturnType())
&& safeSubtreeMatch(node.getName(), o.getName())
&& safeSubtreeListMatch(node.parameters(), o.parameters())
+ && node.getExtraDimensions() == o.getExtraDimensions()
&& safeSubtreeListMatch(node.thrownExceptions(), o.thrownExceptions())
&& safeSubtreeMatch(node.getBody(), o.getBody()));
}
@@ -1185,6 +1195,10 @@
* other object is a node of the same type with structurally isomorphic
* child subtrees. Subclasses may override this method as needed.
* </p>
+ * <p>
+ * Note that extra array dimensions are compared since they are an
+ * important part of the declaration.
+ * </p>
*
* @param node the node
* @param other the other object, or <code>null</code>
@@ -1201,6 +1215,7 @@
(node.getModifiers() == o.getModifiers())
&& safeSubtreeMatch(node.getType(), o.getType())
&& safeSubtreeMatch(node.getName(), o.getName())
+ && node.getExtraDimensions() == o.getExtraDimensions()
&& safeSubtreeMatch(node.getInitializer(), o.getInitializer()));
}
@@ -1542,6 +1557,10 @@
* other object is a node of the same type with structurally isomorphic
* child subtrees. Subclasses may override this method as needed.
* </p>
+ * <p>
+ * Note that extra array dimensions are compared since they are an
+ * important part of the type of the variable.
+ * </p>
*
* @param node the node
* @param other the other object, or <code>null</code>
@@ -1607,4 +1626,4 @@
&& safeSubtreeMatch(node.getBody(), o.getBody()));
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
index 4fa3a07..cf3b086 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTNode.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -41,7 +41,10 @@
* For nodes with properties that include a list of children (for example,
* <code>Block</code> whose <code>statements</code> property is a list
* of statements), adding or removing an element to/for the list property
- * automatically updates the parent links.
+ * automatically updates the parent links. These lists support the
+ * <code>List.set</code> method; however, the constraint that the same
+ * node cannot appear more than once means that this method cannot be used
+ * to swap elements without first removing the node.
* </p>
* <p>
* ASTs must not contain cycles. All operations that could create a cycle
@@ -97,6 +100,13 @@
* ASTs also support the visitor pattern; see the class <code>ASTVisitor</code>
* for details.
* </p>
+ * <p>
+ * Note that there is no built-in way to serialize a modified AST to a source
+ * code string. Naive serialization of a newly-constructed AST to a string is
+ * a straightforward application of an AST visitor. However, preserving comments
+ * and formatting from the originating source code string is a challenging
+ * problem (support for this is planned for a future release).
+ * </p>
*
* @see AST#parseCompilationUnit
* @see ASTVisitor
@@ -620,8 +630,13 @@
* <p>
* Be stingy on storage - assume that list will be empty.
* </p>
+ * <p>
+ * This field declared default visibility (rather than private)
+ * so that accesses from <code>NodeList.Cursor</code> do not require
+ * a synthetic accessor method.
+ * </p>
*/
- private ArrayList store = new ArrayList(0);
+ ArrayList store = new ArrayList(0);
/**
* Indicated whether cycles are a risk. A cycle is possible
@@ -1262,7 +1277,8 @@
* which may be different from the ASTs of the given node.
* Even if the given node has a parent, the result node will be unparented.
* <p>
- * Note that client properties are not carried over to the new nodes.
+ * Source range information on the original nodes is automatically copied to the new
+ * nodes. Client properties (<code>properties</code>) are not carried over.
* </p>
*
* @param target the AST that is to own the nodes in the result
@@ -1285,7 +1301,8 @@
* Even if the nodes in the list have parents, the nodes in the result
* will be unparented.
* <p>
- * Note that client properties are not carried over to the new nodes.
+ * Source range information on the original nodes is automatically copied to the new
+ * nodes. Client properties (<code>properties</code>) are not carried over.
* </p>
*
* @param target the AST that is to own the nodes in the result
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTSyntaxErrorPropagator.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTSyntaxErrorPropagator.java
index 09e63d8..ccb0082 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTSyntaxErrorPropagator.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTSyntaxErrorPropagator.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java
index bb403a5..113a209 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTVisitor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -432,4 +432,4 @@
}
public void endVisit(WhileStatement node) {
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnonymousClassDeclaration.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnonymousClassDeclaration.java
index 2a03eee..bca7323 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnonymousClassDeclaration.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AnonymousClassDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 IBM Corporation and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
import java.util.List;
@@ -60,6 +60,7 @@
*/
ASTNode clone(AST target) {
AnonymousClassDeclaration result = new AnonymousClassDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.bodyDeclarations().addAll(
ASTNode.copySubtrees(target, bodyDeclarations()));
return result;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayAccess.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayAccess.java
index 1ff5e54..c7db6bd 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayAccess.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayAccess.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -61,6 +61,7 @@
*/
ASTNode clone(AST target) {
ArrayAccess result = new ArrayAccess(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setArray((Expression) getArray().clone(target));
result.setIndex((Expression) getIndex().clone(target));
return result;
@@ -95,7 +96,9 @@
public Expression getArray() {
if (arrayExpression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setArray(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return arrayExpression;
}
@@ -129,7 +132,9 @@
public Expression getIndex() {
if (indexExpression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setIndex(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return indexExpression;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayCreation.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayCreation.java
index 4964ff7..0365f13 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayCreation.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayCreation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -80,6 +80,7 @@
*/
ASTNode clone(AST target) {
ArrayCreation result = new ArrayCreation(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setType((ArrayType) getType().clone(target));
result.dimensions().addAll(ASTNode.copySubtrees(target, dimensions()));
result.setInitializer(
@@ -117,8 +118,10 @@
public ArrayType getType() {
if (arrayType == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setType(getAST().newArrayType(
getAST().newPrimitiveType(PrimitiveType.INT)));
+ getAST().setModificationCount(count);
}
return arrayType;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayInitializer.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayInitializer.java
index 7ff4963..c798cd8 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayInitializer.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayInitializer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -54,6 +54,7 @@
*/
ASTNode clone(AST target) {
ArrayInitializer result = new ArrayInitializer(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.expressions().addAll(ASTNode.copySubtrees(target, expressions()));
return result;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayType.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayType.java
index 83aa9a1..0f684c1 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayType.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ArrayType.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -55,6 +55,7 @@
*/
ASTNode clone(AST target) {
ArrayType result = new ArrayType(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setComponentType((Type) getComponentType().clone(target));
return result;
}
@@ -87,7 +88,9 @@
public Type getComponentType() {
if (componentType == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setComponentType(new SimpleType(getAST()));
+ getAST().setModificationCount(count);
}
return componentType;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AssertStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AssertStatement.java
index 5b8a5a4..df698fa 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AssertStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AssertStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -60,7 +60,8 @@
*/
ASTNode clone(AST target) {
AssertStatement result = new AssertStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setExpression(
(Expression) ASTNode.copySubtree(target, getExpression()));
result.setMessage(
@@ -97,7 +98,9 @@
public Expression getExpression() {
if (expression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return expression;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Assignment.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Assignment.java
index 2bbf262..89cf529 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Assignment.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Assignment.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -94,10 +94,10 @@
/** <<== operator. */
public static final Operator LEFT_SHIFT_ASSIGN =
new Operator("<<=");//$NON-NLS-1$
- /** >>== operator. */
+ /** >>= operator. */
public static final Operator RIGHT_SHIFT_SIGNED_ASSIGN =
new Operator(">>=");//$NON-NLS-1$
- /** >>>== operator. */
+ /** >>>= operator. */
public static final Operator RIGHT_SHIFT_UNSIGNED_ASSIGN =
new Operator(">>>=");//$NON-NLS-1$
@@ -184,6 +184,7 @@
*/
ASTNode clone(AST target) {
Assignment result = new Assignment(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setOperator(getOperator());
result.setLeftHandSide((Expression) getLeftHandSide().clone(target));
result.setRightHandSide((Expression) getRightHandSide().clone(target));
@@ -242,7 +243,9 @@
public Expression getLeftHandSide() {
if (leftHandSide == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setLeftHandSide(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return leftHandSide;
}
@@ -275,7 +278,9 @@
public Expression getRightHandSide() {
if (rightHandSide == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setRightHandSide(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return rightHandSide;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java
index e6e7c55..908e735 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BindingResolver.java
@@ -1,16 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
+import org.eclipse.jdt.internal.compiler.ast.AstNode;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+
/**
* A binding resolver is an internal mechanism for figuring out the binding
* for a major declaration, type, or name reference.
@@ -50,7 +53,7 @@
* @param newNode the new AST node
* @param oldNode the old AST node
*/
- void store(ASTNode newNode, org.eclipse.jdt.internal.compiler.ast.AstNode oldASTNode) {
+ void store(ASTNode newNode, AstNode oldASTNode) {
}
/**
@@ -180,7 +183,46 @@
IMethodBinding resolveMethod(MethodDeclaration method) {
return null;
}
-
+ /**
+ * Resolves the given method invocation and returns the binding for it.
+ * <p>
+ * The implementation of <code>MethodInvocation.resolveMethodBinding</code>
+ * forwards to this method. How the method resolves is often a function of
+ * the context in which the method invocation node is embedded as well as
+ * the method invocation subtree itself.
+ * </p>
+ * <p>
+ * The default implementation of this method returns <code>null</code>.
+ * Subclasses may reimplement.
+ * </p>
+ *
+ * @param method the method invocation of interest
+ * @return the binding for the given method invocation, or
+ * <code>null</code> if no binding is available
+ */
+ IMethodBinding resolveMethod(MethodInvocation method) {
+ return null;
+ }
+ /**
+ * Resolves the given method invocation and returns the binding for it.
+ * <p>
+ * The implementation of <code>MethodInvocation.resolveMethodBinding</code>
+ * forwards to this method. How the method resolves is often a function of
+ * the context in which the method invocation node is embedded as well as
+ * the method invocation subtree itself.
+ * </p>
+ * <p>
+ * The default implementation of this method returns <code>null</code>.
+ * Subclasses may reimplement.
+ * </p>
+ *
+ * @param method the method invocation of interest
+ * @return the binding for the given method invocation, or
+ * <code>null</code> if no binding is available
+ */
+ IMethodBinding resolveMethod(SuperMethodInvocation method) {
+ return null;
+ }
/**
* Resolves the given variable declaration and returns the binding for it.
* <p>
@@ -396,6 +438,21 @@
}
/**
+ * Finds the corresponding AST node from which the given binding key originated.
+ *
+ * The default implementation of this method returns <code>null</code>.
+ * Subclasses may reimplement.
+ * </p>
+ *
+ * @param bindingKey the binding key
+ * @return the corresponding node where the bindings is declared,
+ * or <code>null</code> if none
+ */
+ ASTNode findDeclaringNode(String bindingKey) {
+ return null;
+ }
+
+ /**
* Returns the new type binding corresponding to the given old type binding.
* <p>
* The default implementation of this method returns <code>null</code>.
@@ -464,4 +521,30 @@
*/
void updateKey(ASTNode node, ASTNode newNode) {
}
+
+ /**
+ * Allows the user to get information about the given old/new pair of
+ * AST nodes.
+ * <p>
+ * The default implementation of this method does nothing.
+ * Subclasses may reimplement.
+ * </p>
+ *
+ * @param currentNode the new node
+ * @return AstNode
+ */
+ AstNode getCorrespondingNode(ASTNode currentNode) {
+ return null;
+ }
+
+ /**
+ * This method is used to record the scope and its corresponding node.
+ * <p>
+ * The default implementation of this method does nothing.
+ * Subclasses may reimplement.
+ * </p>
+ * @param astNode
+ */
+ void recordScope(ASTNode astNode, BlockScope blockScope) {
+ }
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Block.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Block.java
index b773aaf..351796a 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Block.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Block.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -57,7 +57,8 @@
*/
ASTNode clone(AST target) {
Block result = new Block(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.statements().addAll(
ASTNode.copySubtrees(target, statements()));
return result;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BodyDeclaration.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BodyDeclaration.java
index 53061b1..64c6545 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BodyDeclaration.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BodyDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BooleanLiteral.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BooleanLiteral.java
index 9f4634e..735d924 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BooleanLiteral.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BooleanLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -53,6 +53,7 @@
*/
ASTNode clone(AST target) {
BooleanLiteral result = new BooleanLiteral(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setBooleanValue(booleanValue());
return result;
}
@@ -69,7 +70,7 @@
* Method declared on ASTNode.
*/
void accept0(ASTVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
+ visitor.visit(this);
visitor.endVisit(this);
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java
index b943025..3851fda 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/BreakStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -53,7 +53,8 @@
*/
ASTNode clone(AST target) {
BreakStatement result = new BreakStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setLabel((SimpleName) ASTNode.copySubtree(target, getLabel()));
return result;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CastExpression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CastExpression.java
index d5e82fb..9db8553 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CastExpression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CastExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -60,6 +60,7 @@
*/
ASTNode clone(AST target) {
CastExpression result = new CastExpression(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setType((Type) getType().clone(target));
result.setExpression((Expression) getExpression().clone(target));
return result;
@@ -94,7 +95,9 @@
public Type getType() {
if (type == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setType(getAST().newPrimitiveType(PrimitiveType.INT));
+ getAST().setModificationCount(count);
}
return type;
}
@@ -126,7 +129,9 @@
public Expression getExpression() {
if (expression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return expression;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CatchClause.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CatchClause.java
index 52dc5c6..b373218 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CatchClause.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CatchClause.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -59,6 +59,7 @@
*/
ASTNode clone(AST target) {
CatchClause result = new CatchClause(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setBody((Block) getBody().clone(target));
result.setException(
(SingleVariableDeclaration) ASTNode.copySubtree(target, getException()));
@@ -94,7 +95,9 @@
public SingleVariableDeclaration getException() {
if (exceptionDecl == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setException(new SingleVariableDeclaration(getAST()));
+ getAST().setModificationCount(count);
}
return exceptionDecl;
}
@@ -128,7 +131,9 @@
public Block getBody() {
if (body == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setBody(new Block(getAST()));
+ getAST().setModificationCount(count);
}
return body;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CharacterLiteral.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CharacterLiteral.java
index 8ec5e7f..ee53b90 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CharacterLiteral.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CharacterLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -52,6 +52,7 @@
*/
ASTNode clone(AST target) {
CharacterLiteral result = new CharacterLiteral(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setEscapedValue(getEscapedValue());
return result;
}
@@ -68,7 +69,7 @@
* Method declared on ASTNode.
*/
void accept0(ASTVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
+ visitor.visit(this);
visitor.endVisit(this);
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ClassInstanceCreation.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ClassInstanceCreation.java
index d0694f2..3c7d293 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ClassInstanceCreation.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ClassInstanceCreation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -80,6 +80,7 @@
*/
ASTNode clone(AST target) {
ClassInstanceCreation result = new ClassInstanceCreation(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setExpression(
(Expression) ASTNode.copySubtree(target, getExpression()));
result.setName((Name) getName().clone(target));
@@ -151,7 +152,9 @@
public Name getName() {
if (typeName == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return typeName;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnit.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnit.java
index 3cde615..eebaa57 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnit.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnit.java
@@ -1,23 +1,27 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.jdt.core.compiler.IProblem;
+
/**
* Java compilation unit AST node type. This is the type of the root of an AST.
- *
- * Range 0: first character through last character of the source file.
+ * <p>
+ * The source range for this type of node is ordinarily the entire source file,
+ * including leading and trailing whitespace and comments.
+ * </p>
*
* <pre>
* CompilationUnit:
@@ -66,10 +70,19 @@
private static final Message[] EMPTY_MESSAGES = new Message[0];
/**
- * Messages reported by the compiler during parsing or name resolution;
- * defaults to the empty list.
+ * Canonical empty list of problems.
*/
- private Message[] messages = EMPTY_MESSAGES;
+ private static final IProblem[] EMPTY_PROBLEMS = new IProblem[0];
+
+ /**
+ * Messages reported by the compiler during parsing or name resolution.
+ */
+ private Message[] messages;
+
+ /**
+ * Problems reported by the compiler during parsing or name resolution.
+ */
+ private IProblem[] problems = EMPTY_PROBLEMS;
/**
* Sets the line end table for this compilation unit.
@@ -118,6 +131,7 @@
ASTNode clone(AST target) {
CompilationUnit result = new CompilationUnit(target);
// n.b do not copy line number table or messages
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setPackage(
(PackageDeclaration) ASTNode.copySubtree(target, getPackage()));
result.imports().addAll(ASTNode.copySubtrees(target, imports()));
@@ -202,6 +216,8 @@
* Finds the corresponding AST node in the given compilation unit from
* which the given binding originated. Returns <code>null</code> if the
* binding does not correspond to any node in this compilation unit.
+ * This method always returns <code>null</code> if bindings were not requested
+ * when this AST was built.
* <p>
* The following table indicates the expected node type for the various
* different kinds of bindings:
@@ -223,18 +239,62 @@
* </ul>
* </p>
* <p>
- * Note that bindings are generally unavailable unless requested when the
- * AST is being built.
+ * Each call to <code>AST.parseCompilationUnit</code> with a request for bindings
+ * gives rise to separate universe of binding objects. This method always returns
+ * <code>null</code> when the binding object comes from a different AST.
+ * Use <code>findDeclaringNode(binding.getKey())</code> when the binding comes
+ * from a different AST.
* </p>
*
* @param binding the binding
- * @return the corresponding node where the bindings is declared,
- * or <code>null</code> if none
+ * @return the corresponding node where the given binding is declared,
+ * or <code>null</code> if the binding does not correspond to a node in this
+ * compilation unit or if bindings were not requested when this AST was built
+ * @see #findDeclaringNode(java.lang.String)
*/
public ASTNode findDeclaringNode(IBinding binding) {
return getAST().getBindingResolver().findDeclaringNode(binding);
}
-
+
+ /**
+ * Finds the corresponding AST node in the given compilation unit from
+ * which the binding with the given key originated. Returns
+ * <code>null</code> if the corresponding node cannot be determined.
+ * This method always returns <code>null</code> if bindings were not requested
+ * when this AST was built.
+ * <p>
+ * The following table indicates the expected node type for the various
+ * different kinds of binding keys:
+ * <ul>
+ * <li></li>
+ * <li>package - a <code>PackageDeclaration</code></li>
+ * <li>class or interface - a <code>TypeDeclaration</code> or a
+ * <code>ClassInstanceCreation</code> (for anonymous classes) </li>
+ * <li>primitive type - none</li>
+ * <li>array type - none</li>
+ * <li>field - a <code>VariableDeclarationFragment</code> in a
+ * <code>FieldDeclaration</code> </li>
+ * <li>local variable - a <code>SingleVariableDeclaration</code>, or
+ * a <code>VariableDeclarationFragment</code> in a
+ * <code>VariableDeclarationStatement</code> or
+ * <code>VariableDeclarationExpression</code></li>
+ * <li>method - a <code>MethodDeclaration</code> </li>
+ * <li>constructor - a <code>MethodDeclaration</code> </li>
+ * </ul>
+ * </p>
+ *
+ * @param key the binding key, or <code>null</code>
+ * @return the corresponding node where a binding with the given
+ * key is declared, or <code>null</code> if the key is <code>null</code>
+ * or if the key does not correspond to a node in this compilation unit
+ * or if bindings were not requested when this AST was built
+ * @see IBinding#getKey
+ * @since 2.1
+ */
+ public ASTNode findDeclaringNode(String key) {
+ return getAST().getBindingResolver().findDeclaringNode(key);
+ }
+
/**
* Returns the line number corresponding to the given source character
* position in the original source string. The initial line of the
@@ -242,7 +302,7 @@
* last character of the end-of-line delimiter. The very last line extends
* through the end of the source string and has no line delimiter.
* For example, the source string <code>class A\n{\n}</code> has 3 lines
- * corresponding to inclusive character ranges [0,8], [8,9], and [10,10].
+ * corresponding to inclusive character ranges [0,7], [8,9], and [10,10].
* Returns 1 for a character position that does not correspond to any
* source line, or if no line number information is available for this
* compilation unit.
@@ -311,25 +371,65 @@
* Returns the list of messages reported by the compiler during the parsing
* or the type checking of this compilation unit. This list might be a subset of
* errors detected and reported by a Java compiler.
- *
+ * <p>
+ * This list of messages is suitable for simple clients that do little
+ * more than log the messages or display them to the user. Clients that
+ * need further details should call <code>getProblems</code> to get
+ * compiler problem objects.
+ * </p>
+ *
* @return the list of messages, possibly empty
+ * @see #getProblems
* @see AST#parseCompilationUnit
*/
public Message[] getMessages() {
- return messages;
+ if (this.messages == null) {
+ int problemLength = this.problems.length;
+ if (problemLength == 0) {
+ this.messages = EMPTY_MESSAGES;
+ } else {
+ this.messages = new Message[problemLength];
+ for (int i = 0; i < problemLength; i++) {
+ IProblem problem = this.problems[i];
+ int start = problem.getSourceStart();
+ int end = problem.getSourceEnd();
+ messages[i] = new Message(problem.getMessage(), start, end - start + 1);
+ }
+ }
+ }
+ return this.messages;
}
/**
- * Sets the array of messages reported by the compiler during the parsing or
+ * Returns the list of detailed problem reports noted by the compiler
+ * during the parsing or the type checking of this compilation unit. This
+ * list might be a subset of errors detected and reported by a Java
+ * compiler.
+ * <p>
+ * Simple clients that do little more than log the messages or display
+ * them to the user should probably call <code>getMessages</code> instead.
+ * </p>
+ *
+ * @return the list of detailed problem objects, possibly empty
+ * @see #getMessages
+ * @see AST#parseCompilationUnit
+ * @since 2.1
+ */
+ public IProblem[] getProblems() {
+ return problems;
+ }
+
+ /**
+ * Sets the array of problems reported by the compiler during the parsing or
* name resolution of this compilation unit.
*
- * @param messages the list of messages
+ * @param problems the list of problems
*/
- void setMessages(Message[] messages) {
- if (messages == null) {
+ void setProblems(IProblem[] problems) {
+ if (problems == null) {
throw new IllegalArgumentException();
}
- this.messages = messages;
+ this.problems = problems;
}
/* (omit javadoc for this method)
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java
index 29a5241..bd968b8 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -16,6 +16,7 @@
import org.eclipse.jdt.internal.compiler.env.*;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.core.*;
import org.eclipse.jdt.internal.compiler.impl.*;
@@ -24,7 +25,6 @@
import org.eclipse.jdt.internal.compiler.parser.Parser;
import org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter;
import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import java.util.*;
@@ -84,9 +84,10 @@
// need to hold onto this
CompilationUnitDeclaration unit =
SourceTypeConverter.buildCompilationUnit(
- sourceTypes,
- true,
- true,
+ sourceTypes,//sourceTypes[0] is always toplevel here
+ true, // need field and methods
+ true, // need member types
+ false, // no need for field initialization
lookupEnvironment.problemReporter,
result);
@@ -140,17 +141,18 @@
throws JavaModelException {
char[] fileName = unitElement.getElementName().toCharArray();
+ IJavaProject project = unitElement.getJavaProject();
CompilationUnitResolver compilationUnitVisitor =
new CompilationUnitResolver(
getNameEnvironment(unitElement),
getHandlingPolicy(),
- JavaCore.getOptions(),
+ project.getOptions(true),
getRequestor(),
getProblemFactory(fileName, visitor));
CompilationUnitDeclaration unit = null;
try {
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
+ String encoding = project.getOption(JavaCore.CORE_ENCODING, true);
IPackageFragment packageFragment = (IPackageFragment)unitElement.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
char[][] expectedPackageName = null;
@@ -164,7 +166,10 @@
unitElement.getSource().toCharArray(),
expectedPackageName,
new String(fileName),
- encoding));
+ encoding),
+ true, // method verification
+ true, // analyze code
+ true); // generate code
return unit;
} finally {
if (unit != null) {
@@ -173,11 +178,11 @@
}
}
- public static CompilationUnitDeclaration parse(char[] source) {
+ public static CompilationUnitDeclaration parse(char[] source, Map settings) {
if (source == null) {
throw new IllegalArgumentException();
}
- CompilerOptions compilerOptions = new CompilerOptions(JavaCore.getOptions());
+ CompilerOptions compilerOptions = new CompilerOptions(settings);
Parser parser =
new Parser(
new ProblemReporter(
@@ -185,7 +190,7 @@
compilerOptions,
new DefaultProblemFactory(Locale.getDefault())),
false,
- compilerOptions.assertMode);
+ compilerOptions.sourceLevel >= CompilerOptions.JDK1_4);
org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit =
new org.eclipse.jdt.internal.compiler.batch.CompilationUnit(
source,
@@ -216,7 +221,8 @@
public IProblem createProblem(
char[] originatingFileName,
int problemId,
- String[] arguments,
+ String[] problemArguments,
+ String[] messageArguments,
int severity,
int startPosition,
int endPosition,
@@ -226,7 +232,8 @@
super.createProblem(
originatingFileName,
problemId,
- arguments,
+ problemArguments,
+ messageArguments,
severity,
startPosition,
endPosition,
@@ -251,18 +258,62 @@
new CompilationUnitResolver(
getNameEnvironment(javaProject),
getHandlingPolicy(),
- JavaCore.getOptions(),
+ javaProject.getOptions(true),
getRequestor(),
getProblemFactory(unitName.toCharArray(), visitor));
CompilationUnitDeclaration unit = null;
try {
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
- char[][] expectedPackageName = null;
-
+ String encoding = javaProject.getOption(JavaCore.CORE_ENCODING, true);
+
unit =
compilationUnitVisitor.resolve(
- new BasicCompilationUnit(source, expectedPackageName, unitName, encoding));
+ new BasicCompilationUnit(
+ source,
+ null,
+ unitName,
+ encoding),
+ true, // method verification
+ true, // analyze code
+ true); // generate code
+ return unit;
+ } finally {
+ if (unit != null) {
+ unit.cleanUp();
+ }
+ }
+ }
+
+ public static CompilationUnitDeclaration resolve(
+ char[] source,
+ char[][] packageName,
+ String unitName,
+ IJavaProject javaProject,
+ IAbstractSyntaxTreeVisitor visitor)
+ throws JavaModelException {
+
+ CompilationUnitResolver compilationUnitVisitor =
+ new CompilationUnitResolver(
+ getNameEnvironment(javaProject),
+ getHandlingPolicy(),
+ javaProject.getOptions(true),
+ getRequestor(),
+ getProblemFactory(unitName.toCharArray(), visitor));
+
+ CompilationUnitDeclaration unit = null;
+ try {
+ String encoding = javaProject.getOption(JavaCore.CORE_ENCODING, true);
+
+ unit =
+ compilationUnitVisitor.resolve(
+ new BasicCompilationUnit(
+ source,
+ packageName,
+ unitName,
+ encoding),
+ true, // method verification
+ true, // analyze code
+ true); // generate code
return unit;
} finally {
if (unit != null) {
@@ -270,4 +321,5 @@
}
}
}
-}
\ No newline at end of file
+
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConditionalExpression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConditionalExpression.java
index 9ea0d7f..b2d1db7 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConditionalExpression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConditionalExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -67,6 +67,7 @@
*/
ASTNode clone(AST target) {
ConditionalExpression result = new ConditionalExpression(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setExpression((Expression) getExpression().clone(target));
result.setThenExpression(
(Expression) getThenExpression().clone(target));
@@ -105,7 +106,9 @@
public Expression getExpression() {
if (conditionExpression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return conditionExpression;
}
@@ -139,7 +142,9 @@
public Expression getThenExpression() {
if (thenExpression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setThenExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return thenExpression;
}
@@ -173,7 +178,9 @@
public Expression getElseExpression() {
if (elseExpression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setElseExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return elseExpression;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConstructorInvocation.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConstructorInvocation.java
index 5e7744d..a5eeb55 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConstructorInvocation.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ConstructorInvocation.java
@@ -1,24 +1,24 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
import java.util.List;
/**
- * Alternate constructor invocation expression AST node type.
+ * Alternate constructor invocation statement AST node type.
*
* <pre>
* ConstructorInvocation:
- * <b>this</b> <b>(</b> [ Expression { <b>,</b> Expression } ] <b>)</b>
+ * <b>this</b> <b>(</b> [ Expression { <b>,</b> Expression } ] <b>)</b> <b>;</b>
* </pre>
*
* @since 2.0
@@ -54,7 +54,8 @@
*/
ASTNode clone(AST target) {
ConstructorInvocation result = new ConstructorInvocation(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.arguments().addAll(ASTNode.copySubtrees(target, arguments()));
return result;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ContinueStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ContinueStatement.java
index 66f5054..5d65b26 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ContinueStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ContinueStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -53,7 +53,8 @@
*/
ASTNode clone(AST target) {
ContinueStatement result = new ContinueStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setLabel((SimpleName) ASTNode.copySubtree(target, getLabel()));
return result;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
index 5bb02fd..795ade4 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
@@ -1,51 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ArrayAllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.ArrayReference;
-import org.eclipse.jdt.internal.compiler.ast.AstNode;
-import org.eclipse.jdt.internal.compiler.ast.CharLiteral;
-import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall;
-import org.eclipse.jdt.internal.compiler.ast.FalseLiteral;
-import org.eclipse.jdt.internal.compiler.ast.FieldReference;
-import org.eclipse.jdt.internal.compiler.ast.ImportReference;
-import org.eclipse.jdt.internal.compiler.ast.Literal;
-import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.MessageSend;
-import org.eclipse.jdt.internal.compiler.ast.NameReference;
-import org.eclipse.jdt.internal.compiler.ast.OperatorExpression;
-import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
-import org.eclipse.jdt.internal.compiler.ast.QualifiedSuperReference;
-import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
-import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
-import org.eclipse.jdt.internal.compiler.ast.ThisReference;
-import org.eclipse.jdt.internal.compiler.ast.TrueLiteral;
-import org.eclipse.jdt.internal.compiler.ast.TypeReference;
-import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
-import org.eclipse.jdt.internal.compiler.lookup.Binding;
-import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
-import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.lookup.*;
/**
* Internal class for resolving bindings using old ASTs.
@@ -74,30 +45,35 @@
Map bindingsToAstNodes;
/**
+ * This map is used to get an ast node from its binding key.
+ */
+ Map bindingKeysToAstNodes;
+
+ /**
* This map is used to get a binding from its ast node
*/
Map astNodesToBindings;
/**
+ * This map is used to retrieve the corresponding block scope for a ast node
+ */
+ Map astNodesToBlockScope;
+
+ /**
* Compilation unit scope
*/
private CompilationUnitScope scope;
/**
- * Check if the binding resolver has to ensure the modification cound
- * didn't change
- */
- private boolean checkModificationCount;
-
- /**
* Constructor for DefaultBindingResolver.
*/
DefaultBindingResolver() {
- checkModificationCount = false;
this.newAstToOldAst = new HashMap();
this.compilerBindingsToASTBindings = new HashMap();
this.bindingsToAstNodes = new HashMap();
this.astNodesToBindings = new HashMap();
+ this.astNodesToBlockScope = new HashMap();
+ this.bindingKeysToAstNodes = new HashMap();
}
/**
@@ -112,186 +88,249 @@
* Method declared on BindingResolver.
*/
IBinding resolveName(Name name) {
- if (this.checkModificationCount && this.modificationCount != name.getAST().modificationCount()) {
- return null;
+ AstNode node = (AstNode) this.newAstToOldAst.get(name);
+ int index = name.index;
+ if (node instanceof QualifiedNameReference) {
+ QualifiedNameReference qualifiedNameReference = (QualifiedNameReference) node;
+ final char[][] tokens = qualifiedNameReference.tokens;
+ int qualifiedNameLength = tokens.length;
+ int indexInQualifiedName = qualifiedNameLength - index; // one-based
+ int indexOfFirstFieldBinding = qualifiedNameReference.indexOfFirstFieldBinding; // one-based
+ int otherBindingLength = qualifiedNameLength - indexOfFirstFieldBinding;
+ if (indexInQualifiedName < indexOfFirstFieldBinding) {
+ // a extra lookup is required
+ BlockScope internalScope = (BlockScope) this.astNodesToBlockScope.get(name);
+ Binding binding = null;
+ if (internalScope == null) {
+ binding = this.scope.getTypeOrPackage(CharOperation.subarray(tokens, 0, indexInQualifiedName));
+ } else {
+ binding = internalScope.getTypeOrPackage(CharOperation.subarray(tokens, 0, indexInQualifiedName));
+ }
+ if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
+ return this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
+ } else if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
+ // it is a type
+ return this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
+ }
+ } else if (indexInQualifiedName == indexOfFirstFieldBinding) {
+ if (qualifiedNameReference.isTypeReference()) {
+ return this.getTypeBinding((ReferenceBinding)qualifiedNameReference.binding);
+ } else {
+ Binding binding = qualifiedNameReference.binding;
+ if (binding != null) {
+ if (binding.isValidBinding()) {
+ return this.getVariableBinding((org.eclipse.jdt.internal.compiler.lookup.VariableBinding) binding);
+ } else {
+ if (binding instanceof ProblemFieldBinding) {
+ ProblemFieldBinding problemFieldBinding = (ProblemFieldBinding) binding;
+ switch(problemFieldBinding.problemId()) {
+ case ProblemReasons.NotVisible :
+ case ProblemReasons.NonStaticReferenceInStaticContext :
+ ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
+ if (declaringClass != null) {
+ FieldBinding exactBinding = declaringClass.getField(tokens[tokens.length - 1]);
+ if (exactBinding != null) {
+ IVariableBinding variableBinding = (IVariableBinding) this.compilerBindingsToASTBindings.get(exactBinding);
+ if (variableBinding != null) {
+ return variableBinding;
+ }
+ variableBinding = new VariableBinding(this, exactBinding);
+ this.compilerBindingsToASTBindings.put(exactBinding, variableBinding);
+ return variableBinding;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ /* This is the case for a name which is part of a qualified name that
+ * cannot be resolved. See PR 13063.
+ */
+ if (qualifiedNameReference.otherBindings == null || (otherBindingLength - index - 1) < 0) {
+ return null;
+ } else {
+ return this.getVariableBinding(qualifiedNameReference.otherBindings[otherBindingLength - index - 1]);
+ }
+ }
+ } else if (node instanceof QualifiedTypeReference) {
+ QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) node;
+ if (qualifiedTypeReference.resolvedType == null) {
+ return null;
+ }
+ if (index == 0) {
+ return this.getTypeBinding(qualifiedTypeReference.resolvedType.leafComponentType());
+ } else {
+ int qualifiedTypeLength = qualifiedTypeReference.tokens.length;
+ int indexInQualifiedName = qualifiedTypeLength - index; // one-based
+ if (indexInQualifiedName >= 0) {
+ BlockScope internalScope = (BlockScope) this.astNodesToBlockScope.get(name);
+ Binding binding = null;
+ if (internalScope == null) {
+ binding = this.scope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, indexInQualifiedName));
+ } else {
+ binding = internalScope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, indexInQualifiedName));
+ }
+ if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
+ return this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
+ } else if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
+ // it is a type
+ return this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
+ } else {
+ return null;
+ }
+ }
+ }
+ } else if (node instanceof ImportReference) {
+ ImportReference importReference = (ImportReference) node;
+ int importReferenceLength = importReference.tokens.length;
+ int indexInImportReference = importReferenceLength - index; // one-based
+ if (indexInImportReference >= 0) {
+ Binding binding = this.scope.getTypeOrPackage(CharOperation.subarray(importReference.tokens, 0, indexInImportReference));
+ if (binding != null) {
+ if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
+ return this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
+ } else if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
+ // it is a type
+ return this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
+ } else {
+ return null;
+ }
+ }
+ }
+ } else if (node instanceof CompilationUnitDeclaration) {
+ CompilationUnitDeclaration compilationUnitDeclaration = (CompilationUnitDeclaration) node;
+ org.eclipse.jdt.internal.compiler.ast.TypeDeclaration[] types = compilationUnitDeclaration.types;
+ if (types == null || types.length == 0) {
+ return null;
+ }
+ org.eclipse.jdt.internal.compiler.ast.TypeDeclaration type = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) types[0];
+ if (type != null) {
+ ITypeBinding typeBinding = this.getTypeBinding(type.binding);
+ if (typeBinding != null) {
+ return typeBinding.getPackage();
+ }
+ }
+ } else if (node instanceof AbstractMethodDeclaration) {
+ AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) node;
+ if (methodDeclaration != null) {
+ IMethodBinding methodBinding = this.getMethodBinding(methodDeclaration.binding);
+ if (methodBinding != null) {
+ return methodBinding;
+ }
+ }
+ } else if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
+ org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node;
+ ITypeBinding typeBinding = this.getTypeBinding(typeDeclaration.binding);
+ if (typeBinding != null) {
+ return typeBinding;
+ }
+ } if (node instanceof SingleNameReference) {
+ SingleNameReference singleNameReference = (SingleNameReference) node;
+ if (singleNameReference.isTypeReference()) {
+ return this.getTypeBinding((ReferenceBinding)singleNameReference.binding);
+ } else {
+ // this is a variable or a field
+ Binding binding = singleNameReference.binding;
+ if (binding != null) {
+ if (binding.isValidBinding()) {
+ return this.getVariableBinding((org.eclipse.jdt.internal.compiler.lookup.VariableBinding) binding);
+ } else {
+ /*
+ * http://dev.eclipse.org/bugs/show_bug.cgi?id=24449
+ */
+ if (binding instanceof ProblemFieldBinding) {
+ ProblemFieldBinding problemFieldBinding = (ProblemFieldBinding) binding;
+ switch(problemFieldBinding.problemId()) {
+ case ProblemReasons.NotVisible :
+ case ProblemReasons.NonStaticReferenceInStaticContext :
+ case ProblemReasons.NonStaticReferenceInConstructorInvocation :
+ ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
+ FieldBinding exactBinding = declaringClass.getField(problemFieldBinding.name);
+ if (exactBinding != null) {
+ IVariableBinding variableBinding2 = (IVariableBinding) this.compilerBindingsToASTBindings.get(exactBinding);
+ if (variableBinding2 != null) {
+ return variableBinding2;
+ }
+ variableBinding2 = new VariableBinding(this, exactBinding);
+ this.compilerBindingsToASTBindings.put(exactBinding, variableBinding2);
+ return variableBinding2;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ } else if (node instanceof QualifiedSuperReference) {
+ QualifiedSuperReference qualifiedSuperReference = (QualifiedSuperReference) node;
+ return this.getTypeBinding(qualifiedSuperReference.qualification.resolvedType);
+ } else if (node instanceof LocalDeclaration) {
+ return this.getVariableBinding(((LocalDeclaration)node).binding);
+ } else if (node instanceof FieldReference) {
+ return getVariableBinding(((FieldReference) node).binding);
+ } else if (node instanceof SingleTypeReference) {
+ SingleTypeReference singleTypeReference = (SingleTypeReference) node;
+ org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding = singleTypeReference.resolvedType;
+ if (binding != null && binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
+ return this.getTypeBinding(binding.leafComponentType());
+ }
+ } else if (node instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) {
+ org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) node;
+ return this.getVariableBinding(fieldDeclaration.binding);
+ } else if (node instanceof MessageSend) {
+ MessageSend messageSend = (MessageSend) node;
+ return getMethodBinding(messageSend.binding);
}
- ASTNode parent = name.getParent();
- if (parent instanceof MethodDeclaration && name.equals(((MethodDeclaration) parent).getName())) {
- return this.resolveMethod((MethodDeclaration)parent);
- }
- if (parent instanceof TypeDeclaration && name.equals(((TypeDeclaration) parent).getName())) {
- return this.resolveType((TypeDeclaration)parent);
- }
- if ((parent instanceof MethodInvocation && name.equals(((MethodInvocation) parent).getName()))
- || (parent instanceof SuperMethodInvocation && name.equals(((SuperMethodInvocation) parent).getName()))) {
- return this.internalResolveNameForMethodInvocation(name);
- }
- if ((parent instanceof FieldAccess && name.equals(((FieldAccess) parent).getName()))
- || (parent instanceof SuperFieldAccess && name.equals(((SuperFieldAccess) parent).getName()))) {
- return this.internalResolveNameForFieldAccess(name);
- }
- if (parent instanceof PackageDeclaration && name.equals(((PackageDeclaration) parent).getName())) {
- return this.internalResolveNameForPackageDeclaration(name);
- }
- if (parent instanceof SimpleType && name.equals(((SimpleType) parent).getName())) {
- return this.internalResolveNameForSimpleType(name);
- }
- if (parent instanceof ThisExpression) {
- return this.internalResolveNameForThisExpression(name);
- }
- if (name instanceof QualifiedName) {
- return this.internalResolveNameForQualifiedName(name);
- }
- if (name instanceof SimpleName) {
- return this.internalResolveNameForSimpleName(name);
- }
- return super.resolveName(name);
+ return null;
}
- private IBinding internalResolveNameForPackageDeclaration(Name name) {
- PackageDeclaration packageDeclaration = (PackageDeclaration) name.getParent();
- CompilationUnit unit = (CompilationUnit) packageDeclaration.getParent();
- List types = unit.types();
- if (types.size() == 0) {
- return super.resolveName(name);
- }
- TypeDeclaration type = (TypeDeclaration) types.get(0);
- ITypeBinding typeBinding = type.resolveBinding();
- return typeBinding.getPackage();
- }
/*
* Method declared on BindingResolver.
*/
ITypeBinding resolveType(Type type) {
- if (this.checkModificationCount && this.modificationCount != type.getAST().modificationCount()) {
- return null;
- }
// retrieve the old ast node
- int index = 0;
- ASTNode parentType = type.getParent();
- Type arrayType = null;
AstNode node = (AstNode) this.newAstToOldAst.get(type);
- if (node == null) {
- if (parentType instanceof ArrayCreation) {
- node = (AstNode) this.newAstToOldAst.get(parentType);
- } else {
- // we try to retrieve the type as an element type of an array type
- while ((parentType instanceof Type) && ((Type) parentType).isArrayType()) {
- arrayType = (Type) parentType;
- parentType = parentType.getParent();
- index++;
- }
- if (index != 0) {
- node = (AstNode) this.newAstToOldAst.get(arrayType);
- }
- }
- }
+ org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding = null;
if (node != null) {
if (node instanceof TypeReference) {
TypeReference typeReference = (TypeReference) node;
- if (typeReference.binding == null) {
- return null;
- }
- ITypeBinding typeBinding = this.getTypeBinding(typeReference.binding);
- if (index != 0) {
- if (typeBinding.isArray()) {
- ArrayBinding arrayBinding = (ArrayBinding)typeReference.binding;
- if (index == arrayBinding.dimensions) {
- return this.getTypeBinding(arrayBinding.leafComponentType);
- } else {
- for (int i = 0; i < index; i++) {
- arrayBinding = (ArrayBinding) arrayBinding.elementsType(this.scope);
- }
- return this.getTypeBinding(arrayBinding);
- }
- } else {
- return null;
- }
- } else {
- if (type.isArrayType()) {
- ArrayType array = (ArrayType) type;
- if (typeBinding.getDimensions() != array.getDimensions()) {
- ArrayBinding arrayBinding = (ArrayBinding)typeReference.binding;
- for (int i = 0, max = typeBinding.getDimensions() - array.getDimensions(); i < max; i++) {
- arrayBinding = (ArrayBinding) arrayBinding.elementsType(this.scope);
- }
- return this.getTypeBinding(arrayBinding);
- }
- } else if (typeBinding.isArray() && type.isSimpleType()) {
- return this.getTypeBinding(((ArrayBinding)typeReference.binding).leafComponentType());
- }
- return typeBinding;
- }
- } else if (node instanceof SingleNameReference) {
- SingleNameReference singleNameReference = (SingleNameReference) node;
- if (singleNameReference.binding == null) {
- return null;
- }
- if (singleNameReference.isTypeReference()) {
- ITypeBinding typeBinding = this.getTypeBinding((ReferenceBinding)singleNameReference.binding);
- if (index != 0) {
- if (typeBinding.isArray()) {
- ArrayBinding arrayBinding = (ArrayBinding)singleNameReference.binding;
- if (index == arrayBinding.dimensions) {
- return this.getTypeBinding(arrayBinding.leafComponentType);
- } else {
- for (int i = 0; i < index; i++) {
- arrayBinding = (ArrayBinding) arrayBinding.elementsType(this.scope);
- }
- return this.getTypeBinding(arrayBinding);
- }
- } else {
- return null;
- }
- } else {
- return typeBinding;
- }
- } else {
- // it should be a type reference
- return null;
- }
- } else if (node instanceof QualifiedNameReference) {
- QualifiedNameReference qualifiedNameReference = (QualifiedNameReference) node;
- if (qualifiedNameReference.isTypeReference()) {
- if (qualifiedNameReference.binding == null) {
- return null;
- }
- ITypeBinding typeBinding = this.getTypeBinding((ReferenceBinding)qualifiedNameReference.binding);
- if (index != 0) {
- if (typeBinding.isArray()) {
- ArrayBinding arrayBinding = (ArrayBinding)qualifiedNameReference.binding;
- if (index == arrayBinding.dimensions) {
- return this.getTypeBinding(arrayBinding.leafComponentType);
- } else {
- for (int i = 0; i < index; i++) {
- arrayBinding = (ArrayBinding) arrayBinding.elementsType(this.scope);
- }
- }
- return this.getTypeBinding(arrayBinding);
- } else {
- return null;
- }
- } else {
- return typeBinding;
- }
- } else {
- // it should be a type reference
- return null;
- }
+ binding = typeReference.resolvedType;
+ } else if (node instanceof SingleNameReference && ((SingleNameReference)node).isTypeReference()) {
+ binding = (org.eclipse.jdt.internal.compiler.lookup.TypeBinding) (((SingleNameReference)node).binding);
+ } else if (node instanceof QualifiedNameReference && ((QualifiedNameReference)node).isTypeReference()) {
+ binding = (org.eclipse.jdt.internal.compiler.lookup.TypeBinding) (((QualifiedNameReference)node).binding);
} else if (node instanceof ArrayAllocationExpression) {
- ArrayAllocationExpression arrayAllocationExpression = (ArrayAllocationExpression) node;
- ArrayBinding arrayBinding = arrayAllocationExpression.arrayTb;
- if (arrayBinding == null) {
- return null;
+ binding = ((ArrayAllocationExpression) node).resolvedType;
+ }
+ if (binding != null) {
+ if (type.isArrayType()) {
+ ArrayType arrayType = (ArrayType) type;
+ if (binding.isArrayType()) {
+ ArrayBinding arrayBinding = (ArrayBinding) binding;
+ return getTypeBinding(this.scope.createArray(arrayBinding.leafComponentType, arrayType.getDimensions()));
+ } else {
+ return getTypeBinding(this.scope.createArray(binding, arrayType.getDimensions()));
+ }
+ } else {
+ if (binding.isArrayType()) {
+ ArrayBinding arrayBinding = (ArrayBinding) binding;
+ return getTypeBinding(arrayBinding.leafComponentType);
+ } else {
+ return getTypeBinding(binding);
+ }
}
- if (index != 0) {
- return this.getTypeBinding(this.scope.createArray(arrayBinding.leafComponentType, arrayBinding.dimensions - index));
- }
- return this.getTypeBinding(arrayBinding);
+ }
+ } else if (type.isPrimitiveType()) {
+ if (((PrimitiveType) type).getPrimitiveTypeCode() == PrimitiveType.VOID) {
+ return this.getTypeBinding(BaseTypeBinding.VoidBinding);
}
}
return null;
}
+
/*
* Method declared on BindingResolver.
*/
@@ -323,83 +362,163 @@
} else if ("java.lang.Class".equals(name)) {//$NON-NLS-1$
return this.getTypeBinding(this.scope.getJavaLangClass());
} else {
- return super.resolveWellKnownType(name);
+ return null;
}
}
/*
* Method declared on BindingResolver.
*/
ITypeBinding resolveType(TypeDeclaration type) {
- if (this.checkModificationCount && this.modificationCount != type.getAST().modificationCount()) {
- return null;
+ final Object node = this.newAstToOldAst.get(type);
+ if (node instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
+ org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) node;
+ if (typeDeclaration != null) {
+ ITypeBinding typeBinding = this.getTypeBinding(typeDeclaration.binding);
+ if (typeBinding == null) {
+ return null;
+ }
+ this.bindingsToAstNodes.put(typeBinding, type);
+ String key = typeBinding.getKey();
+ if (key != null) {
+ this.bindingKeysToAstNodes.put(key, type);
+ }
+ return typeBinding;
+ }
}
- org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.newAstToOldAst.get(type);
- if (typeDeclaration != null) {
- ITypeBinding typeBinding = this.getTypeBinding(typeDeclaration.binding);
- this.bindingsToAstNodes.put(typeBinding, type);
- return typeBinding;
- }
- return super.resolveType(type);
+ return null;
}
/*
* Method declared on BindingResolver.
*/
IMethodBinding resolveMethod(MethodDeclaration method) {
- if (this.checkModificationCount && this.modificationCount != method.getAST().modificationCount()) {
- return null;
+ Object oldNode = this.newAstToOldAst.get(method);
+ if (oldNode instanceof AbstractMethodDeclaration) {
+ AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) oldNode;
+ if (methodDeclaration != null) {
+ IMethodBinding methodBinding = this.getMethodBinding(methodDeclaration.binding);
+ if (methodBinding == null) {
+ return null;
+ }
+ this.bindingsToAstNodes.put(methodBinding, method);
+ String key = methodBinding.getKey();
+ if (key != null) {
+ this.bindingKeysToAstNodes.put(key, method);
+ }
+ return methodBinding;
+ }
}
- AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclaration) this.newAstToOldAst.get(method);
- if (methodDeclaration != null) {
- IMethodBinding methodBinding = this.getMethodBinding(methodDeclaration.binding);
- this.bindingsToAstNodes.put(methodBinding, method);
- return methodBinding;
+ return null;
+ }
+ /*
+ * Method declared on BindingResolver.
+ */
+ IMethodBinding resolveMethod(MethodInvocation method) {
+ Object oldNode = this.newAstToOldAst.get(method);
+ if (oldNode instanceof MessageSend) {
+ MessageSend messageSend = (MessageSend) oldNode;
+ if (messageSend != null) {
+ IMethodBinding methodBinding = this.getMethodBinding(messageSend.binding);
+ if (methodBinding == null) {
+ return null;
+ }
+ this.bindingsToAstNodes.put(methodBinding, method);
+ String key = methodBinding.getKey();
+ if (key != null) {
+ this.bindingKeysToAstNodes.put(key, method);
+ }
+ return methodBinding;
+ }
}
- return super.resolveMethod(method);
+ return null;
+ }
+ /*
+ * Method declared on BindingResolver.
+ */
+ IMethodBinding resolveMethod(SuperMethodInvocation method) {
+ Object oldNode = this.newAstToOldAst.get(method);
+ if (oldNode instanceof MessageSend) {
+ MessageSend messageSend = (MessageSend) oldNode;
+ if (messageSend != null) {
+ IMethodBinding methodBinding = this.getMethodBinding(messageSend.binding);
+ if (methodBinding == null) {
+ return null;
+ }
+ this.bindingsToAstNodes.put(methodBinding, method);
+ String key = methodBinding.getKey();
+ if (key != null) {
+ this.bindingKeysToAstNodes.put(key, method);
+ }
+ return methodBinding;
+ }
+ }
+ return null;
}
/*
* Method declared on BindingResolver.
*/
IVariableBinding resolveVariable(VariableDeclaration variable) {
- if (this.checkModificationCount && this.modificationCount != variable.getAST().modificationCount()) {
- return null;
- }
- AbstractVariableDeclaration abstractVariableDeclaration = (AbstractVariableDeclaration) this.newAstToOldAst.get(variable);
- if (abstractVariableDeclaration instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) {
- org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) abstractVariableDeclaration;
- IVariableBinding variableBinding = this.getVariableBinding(fieldDeclaration.binding);
+ final Object node = this.newAstToOldAst.get(variable);
+ if (node instanceof AbstractVariableDeclaration) {
+ AbstractVariableDeclaration abstractVariableDeclaration = (AbstractVariableDeclaration) node;
+ if (abstractVariableDeclaration instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) {
+ org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) abstractVariableDeclaration;
+ IVariableBinding variableBinding = this.getVariableBinding(fieldDeclaration.binding);
+ if (variableBinding == null) {
+ return null;
+ }
+ this.bindingsToAstNodes.put(variableBinding, variable);
+ String key = variableBinding.getKey();
+ if (key != null) {
+ this.bindingKeysToAstNodes.put(key, variable);
+ }
+ return variableBinding;
+ }
+ IVariableBinding variableBinding = this.getVariableBinding(((LocalDeclaration) abstractVariableDeclaration).binding);
+ if (variableBinding == null) {
+ return null;
+ }
this.bindingsToAstNodes.put(variableBinding, variable);
+ String key = variableBinding.getKey();
+ if (key != null) {
+ this.bindingKeysToAstNodes.put(key, variable);
+ }
return variableBinding;
}
- IVariableBinding variableBinding = this.getVariableBinding(((LocalDeclaration) abstractVariableDeclaration).binding);
- this.bindingsToAstNodes.put(variableBinding, variable);
- return variableBinding;
+ return null;
}
/*
* Method declared on BindingResolver.
*/
IVariableBinding resolveVariable(FieldDeclaration variable) {
- if (this.checkModificationCount && this.modificationCount != variable.getAST().modificationCount()) {
- return null;
+ final Object node = this.newAstToOldAst.get(variable);
+ if (node instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) {
+ org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) node;
+ IVariableBinding variableBinding = this.getVariableBinding(fieldDeclaration.binding);
+ if (variableBinding == null) {
+ return null;
+ }
+ this.bindingsToAstNodes.put(variableBinding, variable);
+ String key = variableBinding.getKey();
+ if (key != null) {
+ this.bindingKeysToAstNodes.put(key, variable);
+ }
+ return variableBinding;
}
- org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) this.newAstToOldAst.get(variable);
- IVariableBinding variableBinding = this.getVariableBinding(fieldDeclaration.binding);
- this.bindingsToAstNodes.put(variableBinding, variable);
- return variableBinding;
+ return null;
}
/*
* Method declared on BindingResolver.
*/
ITypeBinding resolveExpressionType(Expression expression) {
- if (this.checkModificationCount && this.modificationCount != expression.getAST().modificationCount()) {
- return null;
- }
if (expression instanceof ClassInstanceCreation) {
AstNode astNode = (AstNode) this.newAstToOldAst.get(expression);
if (astNode instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDeclaration = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) astNode;
if (typeDeclaration != null) {
ITypeBinding typeBinding = this.getTypeBinding(typeDeclaration.binding);
- this.bindingsToAstNodes.put(typeBinding, expression);
+ if (typeBinding == null) {
+ return null;
+ }
return typeBinding;
}
} else {
@@ -426,12 +545,12 @@
} else if (expression instanceof ArrayInitializer) {
org.eclipse.jdt.internal.compiler.ast.ArrayInitializer oldAst = (org.eclipse.jdt.internal.compiler.ast.ArrayInitializer) this.newAstToOldAst.get(expression);
if (oldAst == null || oldAst.binding == null) {
- return super.resolveExpressionType(expression);
+ return null;
}
return this.getTypeBinding(oldAst.binding);
} else if (expression instanceof ArrayCreation) {
ArrayAllocationExpression arrayAllocationExpression = (ArrayAllocationExpression) this.newAstToOldAst.get(expression);
- return this.getTypeBinding(arrayAllocationExpression.arrayTb);
+ return this.getTypeBinding(arrayAllocationExpression.resolvedType);
} else if (expression instanceof Assignment) {
Assignment assignment = (Assignment) expression;
return this.resolveExpressionType(assignment.getLeftHandSide());
@@ -443,15 +562,9 @@
return this.resolveExpressionType(preFixExpression.getOperand());
} else if (expression instanceof CastExpression) {
org.eclipse.jdt.internal.compiler.ast.CastExpression castExpression = (org.eclipse.jdt.internal.compiler.ast.CastExpression) this.newAstToOldAst.get(expression);
- return this.getTypeBinding(castExpression.castTb);
+ return this.getTypeBinding(castExpression.resolvedType);
} else if (expression instanceof StringLiteral) {
- org.eclipse.jdt.internal.compiler.ast.StringLiteral stringLiteral = (org.eclipse.jdt.internal.compiler.ast.StringLiteral) this.newAstToOldAst.get(expression);
- BlockScope blockScope = this.retrieveEnclosingScope(expression);
- if (blockScope == null) {
- return this.getTypeBinding(this.scope.getJavaLangString());
- } else {
- return this.getTypeBinding(stringLiteral.literalType(blockScope));
- }
+ return this.getTypeBinding(this.scope.getJavaLangString());
} else if (expression instanceof TypeLiteral) {
return this.getTypeBinding(this.scope.getJavaLangClass());
} else if (expression instanceof BooleanLiteral) {
@@ -474,10 +587,10 @@
return this.getTypeBinding(literal.literalType(null));
} else if (expression instanceof InfixExpression) {
OperatorExpression operatorExpression = (OperatorExpression) this.newAstToOldAst.get(expression);
- return this.getTypeBinding(operatorExpression.typeBinding);
+ return this.getTypeBinding(operatorExpression.resolvedType);
} else if (expression instanceof InstanceofExpression) {
org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression instanceOfExpression = (org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression) this.newAstToOldAst.get(expression);
- return this.getTypeBinding(instanceOfExpression.typeBinding);
+ return this.getTypeBinding(instanceOfExpression.resolvedType);
} else if (expression instanceof FieldAccess) {
FieldReference fieldReference = (FieldReference) this.newAstToOldAst.get(expression);
IVariableBinding variableBinding = this.getVariableBinding(fieldReference.binding);
@@ -496,15 +609,16 @@
}
} else if (expression instanceof ArrayAccess) {
ArrayReference arrayReference = (ArrayReference) this.newAstToOldAst.get(expression);
- return this.getTypeBinding(arrayReference.arrayElementBinding);
+ return this.getTypeBinding(arrayReference.resolvedType);
} else if (expression instanceof ThisExpression) {
ThisReference thisReference = (ThisReference) this.newAstToOldAst.get(expression);
- BlockScope blockScope = this.retrieveEnclosingScope(expression);
+ BlockScope blockScope = (BlockScope) this.astNodesToBlockScope.get(expression);
if (blockScope == null) {
return null;
}
return this.getTypeBinding(thisReference.resolveType(blockScope));
- } else if (expression instanceof MethodInvocation) {
+ } else if (expression instanceof MethodInvocation
+ || expression instanceof SuperMethodInvocation) {
MessageSend messageSend = (MessageSend) this.newAstToOldAst.get(expression);
IMethodBinding methodBinding = this.getMethodBinding(messageSend.binding);
if (methodBinding == null) {
@@ -517,58 +631,75 @@
return this.resolveExpressionType(parenthesizedExpression.getExpression());
} else if (expression instanceof ConditionalExpression) {
org.eclipse.jdt.internal.compiler.ast.ConditionalExpression conditionalExpression = (org.eclipse.jdt.internal.compiler.ast.ConditionalExpression) this.newAstToOldAst.get(expression);
- return this.getTypeBinding(conditionalExpression.typeBinding);
+ return this.getTypeBinding(conditionalExpression.resolvedType);
+ } else if (expression instanceof VariableDeclarationExpression) {
+ VariableDeclarationExpression variableDeclarationExpression = (VariableDeclarationExpression) expression;
+ Type type = variableDeclarationExpression.getType();
+ if (type != null) {
+ return type.resolveBinding();
+ }
}
- return super.resolveExpressionType(expression);
+ return null;
}
/*
* @see BindingResolver#resolveImport(ImportDeclaration)
*/
IBinding resolveImport(ImportDeclaration importDeclaration) {
- if (this.checkModificationCount && this.modificationCount != importDeclaration.getAST().modificationCount()) {
- return null;
- }
AstNode node = (AstNode) this.newAstToOldAst.get(importDeclaration);
if (node instanceof ImportReference) {
ImportReference importReference = (ImportReference) node;
if (importReference.onDemand) {
Binding binding = this.scope.getTypeOrPackage(CharOperation.subarray(importReference.tokens, 0, importReference.tokens.length));
- if ((binding != null) && (binding.isValidBinding())) {
- IPackageBinding packageBinding = this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding) binding);
- this.bindingsToAstNodes.put(packageBinding, importDeclaration);
- return packageBinding;
+ if (binding != null) {
+ if (binding.bindingType() == Binding.PACKAGE) {
+ IPackageBinding packageBinding = this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding) binding);
+ if (packageBinding == null) {
+ return null;
+ }
+ return packageBinding;
+ } else {
+ // if it is not a package, it has to be a type
+ ITypeBinding typeBinding = this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) binding);
+ if (typeBinding == null) {
+ return null;
+ }
+ return typeBinding;
+ }
}
} else {
Binding binding = this.scope.getTypeOrPackage(importReference.tokens);
- if (binding != null && binding.isValidBinding()) {
+ if (binding != null && binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
ITypeBinding typeBinding = this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) binding);
- this.bindingsToAstNodes.put(typeBinding, importDeclaration);
- return typeBinding;
+ return typeBinding == null ? null : typeBinding;
}
}
}
- return super.resolveImport(importDeclaration);
+ return null;
}
/*
* @see BindingResolver#resolvePackage(PackageDeclaration)
*/
IPackageBinding resolvePackage(PackageDeclaration pkg) {
- if (this.checkModificationCount && this.modificationCount != pkg.getAST().modificationCount()) {
- return null;
- }
AstNode node = (AstNode) this.newAstToOldAst.get(pkg);
if (node instanceof ImportReference) {
ImportReference importReference = (ImportReference) node;
Binding binding = this.scope.getTypeOrPackage(CharOperation.subarray(importReference.tokens, 0, importReference.tokens.length));
if ((binding != null) && (binding.isValidBinding())) {
IPackageBinding packageBinding = this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding) binding);
+ if (packageBinding == null) {
+ return null;
+ }
this.bindingsToAstNodes.put(packageBinding, pkg);
+ String key = packageBinding.getKey();
+ if (key != null) {
+ this.bindingKeysToAstNodes.put(key, pkg);
+ }
return packageBinding;
}
}
- return super.resolvePackage(pkg);
+ return null;
}
/*
@@ -580,6 +711,14 @@
}
return (ASTNode) this.bindingsToAstNodes.get(binding);
}
+
+ ASTNode findDeclaringNode(String bindingKey) {
+ if (bindingKey == null) {
+ return null;
+ }
+ return (ASTNode) this.bindingKeysToAstNodes.get(bindingKey);
+ }
+
/*
* Method declared on BindingResolver.
*/
@@ -601,16 +740,36 @@
* Method declared on BindingResolver.
*/
protected ITypeBinding getTypeBinding(org.eclipse.jdt.internal.compiler.lookup.TypeBinding referenceBinding) {
- if (referenceBinding == null || !referenceBinding.isValidBinding()) {
+ if (referenceBinding == null) {
return null;
- }
- TypeBinding binding = (TypeBinding) this.compilerBindingsToASTBindings.get(referenceBinding);
- if (binding != null) {
+ } else if (!referenceBinding.isValidBinding()) {
+ switch(referenceBinding.problemId()) {
+ case ProblemReasons.NotVisible :
+ case ProblemReasons.NonStaticReferenceInStaticContext :
+ if (referenceBinding instanceof ProblemReferenceBinding) {
+ ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBinding) referenceBinding;
+ Binding binding2 = problemReferenceBinding.original;
+ if (binding2 != null && binding2 instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
+ TypeBinding binding = (TypeBinding) this.compilerBindingsToASTBindings.get(binding2);
+ if (binding != null) {
+ return binding;
+ }
+ binding = new TypeBinding(this, (org.eclipse.jdt.internal.compiler.lookup.TypeBinding) binding2);
+ this.compilerBindingsToASTBindings.put(binding2, binding);
+ return binding;
+ }
+ }
+ }
+ return null;
+ } else {
+ TypeBinding binding = (TypeBinding) this.compilerBindingsToASTBindings.get(referenceBinding);
+ if (binding != null) {
+ return binding;
+ }
+ binding = new TypeBinding(this, referenceBinding);
+ this.compilerBindingsToASTBindings.put(referenceBinding, binding);
return binding;
}
- binding = new TypeBinding(this, referenceBinding);
- this.compilerBindingsToASTBindings.put(referenceBinding, binding);
- return binding;
}
/*
* Method declared on BindingResolver.
@@ -631,289 +790,81 @@
* Method declared on BindingResolver.
*/
protected IVariableBinding getVariableBinding(org.eclipse.jdt.internal.compiler.lookup.VariableBinding variableBinding) {
- if (variableBinding == null || !variableBinding.isValidBinding()) {
- return null;
- }
- IVariableBinding binding = (IVariableBinding) this.compilerBindingsToASTBindings.get(variableBinding);
- if (binding != null) {
- return binding;
- }
- binding = new VariableBinding(this, variableBinding);
- this.compilerBindingsToASTBindings.put(variableBinding, binding);
- return binding;
+ if (variableBinding != null) {
+ if (variableBinding.isValidBinding()) {
+ IVariableBinding binding = (IVariableBinding) this.compilerBindingsToASTBindings.get(variableBinding);
+ if (binding != null) {
+ return binding;
+ }
+ binding = new VariableBinding(this, variableBinding);
+ this.compilerBindingsToASTBindings.put(variableBinding, binding);
+ return binding;
+ } else {
+ /*
+ * http://dev.eclipse.org/bugs/show_bug.cgi?id=24449
+ */
+ if (variableBinding instanceof ProblemFieldBinding) {
+ ProblemFieldBinding problemFieldBinding = (ProblemFieldBinding) variableBinding;
+ switch(problemFieldBinding.problemId()) {
+ case ProblemReasons.NotVisible :
+ case ProblemReasons.NonStaticReferenceInStaticContext :
+ case ProblemReasons.NonStaticReferenceInConstructorInvocation :
+ ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
+ FieldBinding exactBinding = declaringClass.getField(problemFieldBinding.name);
+ if (exactBinding != null) {
+ IVariableBinding variableBinding2 = (IVariableBinding) this.compilerBindingsToASTBindings.get(exactBinding);
+ if (variableBinding2 != null) {
+ return variableBinding2;
+ }
+ variableBinding2 = new VariableBinding(this, exactBinding);
+ this.compilerBindingsToASTBindings.put(exactBinding, variableBinding2);
+ return variableBinding2;
+ }
+ break;
+ }
+ }
+ }
+ }
+ return null;
}
/*
* Method declared on BindingResolver.
*/
protected IMethodBinding getMethodBinding(org.eclipse.jdt.internal.compiler.lookup.MethodBinding methodBinding) {
- if (methodBinding == null || !methodBinding.isValidBinding()) {
- return null;
- }
- IMethodBinding binding = (IMethodBinding) this.compilerBindingsToASTBindings.get(methodBinding);
- if (binding != null) {
- return binding;
- }
- binding = new MethodBinding(this, methodBinding);
- this.compilerBindingsToASTBindings.put(methodBinding, binding);
- return binding;
- }
-
- private BlockScope retrieveEnclosingScope(ASTNode node) {
- ASTNode currentNode = node;
- while(currentNode != null
- &&!(currentNode instanceof MethodDeclaration)
- && !(currentNode instanceof Initializer)
- && !(currentNode instanceof FieldDeclaration)) {
- currentNode = currentNode.getParent();
- }
- if (currentNode == null) {
- return null;
- }
- if (currentNode instanceof Initializer) {
- Initializer initializer = (Initializer) currentNode;
- while(!(currentNode instanceof TypeDeclaration)) {
- currentNode = currentNode.getParent();
- }
- org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.newAstToOldAst.get(currentNode);
- if ((initializer.getModifiers() & Modifier.STATIC) != 0) {
- return typeDecl.staticInitializerScope;
- } else {
- return typeDecl.initializerScope;
- }
- } else if (currentNode instanceof FieldDeclaration) {
- FieldDeclaration fieldDeclaration = (FieldDeclaration) currentNode;
- while(!(currentNode instanceof TypeDeclaration)) {
- currentNode = currentNode.getParent();
- }
- org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.newAstToOldAst.get(currentNode);
- if ((fieldDeclaration.getModifiers() & Modifier.STATIC) != 0) {
- return typeDecl.staticInitializerScope;
- } else {
- return typeDecl.initializerScope;
- }
- }
- AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) this.newAstToOldAst.get(currentNode);
- return abstractMethodDeclaration.scope;
- }
-
- private IBinding internalResolveNameForQualifiedName(Name name) {
- QualifiedName qualifiedName = (QualifiedName) name;
- ASTNode parent = qualifiedName.getParent();
- int index = 0;
- while (parent instanceof QualifiedName) {
- qualifiedName = (QualifiedName) parent;
- parent = parent.getParent();
- index++;
- }
- return returnBindingForQualifiedNamePart(qualifiedName, index);
- }
-
- private IBinding returnBindingForQualifiedNamePart(ASTNode parent, int index) {
- // now we can retrieve the compiler's node
- AstNode node = (AstNode) this.newAstToOldAst.get(parent);
- if (node instanceof QualifiedNameReference) {
- QualifiedNameReference qualifiedNameReference = (QualifiedNameReference) node;
- int qualifiedNameLength = qualifiedNameReference.tokens.length;
- int indexInQualifiedName = qualifiedNameLength - index; // one-based
- int indexOfFirstFieldBinding = qualifiedNameReference.indexOfFirstFieldBinding; // one-based
- int otherBindingLength = qualifiedNameLength - indexOfFirstFieldBinding;
- if (indexInQualifiedName < indexOfFirstFieldBinding) {
- // a extra lookup is required
- BlockScope internalScope = retrieveEnclosingScope(parent);
- Binding binding = null;
- if (internalScope == null) {
- binding = this.scope.getTypeOrPackage(CharOperation.subarray(qualifiedNameReference.tokens, 0, indexInQualifiedName));
- } else {
- binding = internalScope.getTypeOrPackage(CharOperation.subarray(qualifiedNameReference.tokens, 0, indexInQualifiedName));
+ if (methodBinding != null) {
+ if (methodBinding.isValidBinding()) {
+ IMethodBinding binding = (IMethodBinding) this.compilerBindingsToASTBindings.get(methodBinding);
+ if (binding != null) {
+ return binding;
}
- if (binding != null && binding.isValidBinding()) {
- if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
- return this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
- } else {
- // it is a type
- return this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
- }
- }
- return null;
+ binding = new MethodBinding(this, methodBinding);
+ this.compilerBindingsToASTBindings.put(methodBinding, binding);
+ return binding;
} else {
- if (indexInQualifiedName == indexOfFirstFieldBinding) {
- if (qualifiedNameReference.isTypeReference()) {
- return this.getTypeBinding((ReferenceBinding)qualifiedNameReference.binding);
- } else {
- Binding binding = qualifiedNameReference.binding;
- if (binding != null && binding.isValidBinding()) {
- return this.getVariableBinding((org.eclipse.jdt.internal.compiler.lookup.VariableBinding) binding);
- } else {
- return null;
+ /*
+ * http://dev.eclipse.org/bugs/show_bug.cgi?id=23597
+ */
+ switch(methodBinding.problemId()) {
+ case ProblemReasons.NotVisible :
+ case ProblemReasons.NonStaticReferenceInStaticContext :
+ case ProblemReasons.NonStaticReferenceInConstructorInvocation :
+ ReferenceBinding declaringClass = methodBinding.declaringClass;
+ if (declaringClass != null) {
+ org.eclipse.jdt.internal.compiler.lookup.MethodBinding exactBinding = declaringClass.getExactMethod(methodBinding.selector, methodBinding.parameters);
+ if (exactBinding != null) {
+ IMethodBinding binding = (IMethodBinding) this.compilerBindingsToASTBindings.get(exactBinding);
+ if (binding != null) {
+ return binding;
+ }
+ binding = new MethodBinding(this, exactBinding);
+ this.compilerBindingsToASTBindings.put(exactBinding, binding);
+ return binding;
+ }
}
- }
- } else {
- /* This is the case for a name which is part of a qualified name that
- * cannot be resolved. See PR 13063.
- */
- if (qualifiedNameReference.otherBindings == null) {
- return null;
- } else {
- return this.getVariableBinding(qualifiedNameReference.otherBindings[otherBindingLength - index - 1]);
- }
+ break;
}
}
- } else if (node instanceof QualifiedTypeReference) {
- QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) node;
- if (qualifiedTypeReference.binding == null) {
- return null;
- }
- if (index == 0) {
- return this.getTypeBinding(qualifiedTypeReference.binding.leafComponentType());
- } else {
- int qualifiedTypeLength = qualifiedTypeReference.tokens.length;
- int indexInQualifiedName = qualifiedTypeLength - index; // one-based
- BlockScope internalScope = retrieveEnclosingScope(parent);
- Binding binding = null;
- if (internalScope == null) {
- binding = this.scope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, indexInQualifiedName));
- } else {
- binding = internalScope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, indexInQualifiedName));
- }
- if (binding != null && binding.isValidBinding()) {
- if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
- return this.getPackageBinding((org.eclipse.jdt.internal.compiler.lookup.PackageBinding)binding);
- } else {
- // it is a type
- return this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
- }
- }
- }
- }
- return null;
- }
-
- private IBinding internalResolveNameForSimpleName(Name name) {
- AstNode node = (AstNode) this.newAstToOldAst.get(name);
- if (node == null) {
- ASTNode parent = name.getParent();
- if (parent instanceof QualifiedName) {
- // retrieve the qualified name and remember at which position is the simple name
- QualifiedName qualifiedName = (QualifiedName) parent;
- int index = -1;
- if (qualifiedName.getQualifier() == name) {
- index++;
- }
- while (parent instanceof QualifiedName) {
- qualifiedName = (QualifiedName) parent;
- parent = parent.getParent();
- index++;
- }
- return returnBindingForQualifiedNamePart(qualifiedName, index);
- }
- }
- if (node instanceof SingleNameReference) {
- SingleNameReference singleNameReference = (SingleNameReference) node;
- if (singleNameReference.isTypeReference()) {
- return this.getTypeBinding((ReferenceBinding)singleNameReference.binding);
- } else {
- // this is a variable or a field
- Binding binding = singleNameReference.binding;
- if (binding != null && binding.isValidBinding()) {
- return this.getVariableBinding((org.eclipse.jdt.internal.compiler.lookup.VariableBinding) binding);
- } else {
- return null;
- }
- }
- } else if (node instanceof QualifiedSuperReference) {
- QualifiedSuperReference qualifiedSuperReference = (QualifiedSuperReference) node;
- return this.getTypeBinding(qualifiedSuperReference.qualification.binding);
- } else if (node instanceof LocalDeclaration) {
- return this.getVariableBinding(((LocalDeclaration)node).binding);
- } else if (node instanceof FieldReference) {
- return getVariableBinding(((FieldReference) node).binding);
- } else if (node instanceof SingleTypeReference) {
- SingleTypeReference singleTypeReference = (SingleTypeReference) node;
- if (singleTypeReference.binding == null) {
- return null;
- }
- return this.getTypeBinding(singleTypeReference.binding.leafComponentType());
- } else if (node instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) {
- org.eclipse.jdt.internal.compiler.ast.FieldDeclaration fieldDeclaration = (org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) node;
- IVariableBinding variableBinding = this.getVariableBinding(fieldDeclaration.binding);
- return variableBinding;
- }
- return null;
- }
-
- private IBinding internalResolveNameForMethodInvocation(Name name) {
- ASTNode parent = name.getParent();
- if (parent instanceof MethodInvocation) {
- MethodInvocation methodInvocation = (MethodInvocation) parent;
- if (name == methodInvocation.getExpression()) {
- if (name.isQualifiedName()) {
- return this.internalResolveNameForQualifiedName(name);
- } else {
- return this.internalResolveNameForSimpleName(name);
- }
- } else {
- AstNode node = (AstNode) this.newAstToOldAst.get(name);
- if (node instanceof MessageSend) {
- MessageSend messageSend = (MessageSend) node;
- return getMethodBinding(messageSend.binding);
- } else if (name.isQualifiedName()) {
- return this.internalResolveNameForQualifiedName(name);
- } else {
- return this.internalResolveNameForSimpleName(name);
- }
- }
- } else {
- SuperMethodInvocation superMethodInvocation = (SuperMethodInvocation) parent;
- if (name == superMethodInvocation.getQualifier()) {
- if (name.isQualifiedName()) {
- return this.internalResolveNameForQualifiedName(name);
- } else {
- return this.internalResolveNameForSimpleName(name);
- }
- } else {
- AstNode node = (AstNode) this.newAstToOldAst.get(name);
- if (node instanceof MessageSend) {
- MessageSend messageSend = (MessageSend) node;
- return getMethodBinding(messageSend.binding);
- } else if (name.isQualifiedName()) {
- return this.internalResolveNameForQualifiedName(name);
- } else {
- return this.internalResolveNameForSimpleName(name);
- }
- }
- }
- }
-
- private IBinding internalResolveNameForFieldAccess(Name name) {
- if (name.isQualifiedName()) {
- return this.internalResolveNameForQualifiedName(name);
- } else {
- return this.internalResolveNameForSimpleName(name);
- }
- }
-
- private IBinding internalResolveNameForSimpleType(Name name) {
- AstNode node = (AstNode) this.newAstToOldAst.get(name);
- if (node instanceof TypeReference) {
- org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding = ((TypeReference) node).binding;
- if (binding == null) {
- return null;
- }
- return this.getTypeBinding(binding.leafComponentType());
- } else if (node instanceof NameReference) {
- NameReference nameReference = (NameReference) node;
- if (nameReference.isTypeReference()) {
- return this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) nameReference.binding);
- }
- }
- return null;
- }
-
- private IBinding internalResolveNameForThisExpression(Name name) {
- AstNode node = (AstNode) this.newAstToOldAst.get(name);
- if (node instanceof TypeReference) {
- return this.getTypeBinding(((TypeReference) node).binding);
}
return null;
}
@@ -922,9 +873,6 @@
* @see BindingResolver#resolveConstructor(ClassInstanceCreation)
*/
IMethodBinding resolveConstructor(ClassInstanceCreation expression) {
- if (this.checkModificationCount && this.modificationCount != expression.getAST().modificationCount()) {
- return null;
- }
AstNode node = (AstNode) this.newAstToOldAst.get(expression);
if (node instanceof AnonymousLocalTypeDeclaration) {
AnonymousLocalTypeDeclaration anonymousLocalTypeDeclaration = (AnonymousLocalTypeDeclaration) node;
@@ -939,9 +887,6 @@
* @see BindingResolver#resolveConstructor(ConstructorInvocation)
*/
IMethodBinding resolveConstructor(ConstructorInvocation expression) {
- if (this.checkModificationCount && this.modificationCount != expression.getAST().modificationCount()) {
- return null;
- }
AstNode node = (AstNode) this.newAstToOldAst.get(expression);
if (node instanceof ExplicitConstructorCall) {
ExplicitConstructorCall explicitConstructorCall = (ExplicitConstructorCall) node;
@@ -954,9 +899,6 @@
* @see BindingResolver#resolveConstructor(SuperConstructorInvocation)
*/
IMethodBinding resolveConstructor(SuperConstructorInvocation expression) {
- if (this.checkModificationCount && this.modificationCount != expression.getAST().modificationCount()) {
- return null;
- }
AstNode node = (AstNode) this.newAstToOldAst.get(expression);
if (node instanceof ExplicitConstructorCall) {
ExplicitConstructorCall explicitConstructorCall = (ExplicitConstructorCall) node;
@@ -968,25 +910,33 @@
* @see BindingResolver#resolveType(AnonymousClassDeclaration)
*/
ITypeBinding resolveType(AnonymousClassDeclaration type) {
- if (this.checkModificationCount && this.modificationCount != type.getAST().modificationCount()) {
- return null;
+ final Object node = this.newAstToOldAst.get(type);
+ if (node instanceof org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration) {
+ org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration anonymousLocalTypeDeclaration = (org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration) node;
+ if (anonymousLocalTypeDeclaration != null) {
+ ITypeBinding typeBinding = this.getTypeBinding(anonymousLocalTypeDeclaration.binding);
+ if (typeBinding == null) {
+ return null;
+ }
+ this.bindingsToAstNodes.put(typeBinding, type);
+ String key = typeBinding.getKey();
+ if (key != null) {
+ this.bindingKeysToAstNodes.put(key, type);
+ }
+ return typeBinding;
+ }
}
- org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration anonymousLocalTypeDeclaration = (org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration) this.newAstToOldAst.get(type);
- if (anonymousLocalTypeDeclaration != null) {
- ITypeBinding typeBinding = this.getTypeBinding(anonymousLocalTypeDeclaration.binding);
- this.bindingsToAstNodes.put(typeBinding, type);
- return typeBinding;
- }
- return super.resolveType(type);
+ return null;
}
+ AstNode getCorrespondingNode(ASTNode currentNode) {
+ return (AstNode) this.newAstToOldAst.get(currentNode);
+ }
/**
- * Store the number of modifications done using the ast. This is used to validate
- * resolveBinding methods. If the number changed, all resolve bindings methods
- * simply return null.
+ * @see org.eclipse.jdt.core.dom.BindingResolver#recordScope(ASTNode, BlockScope)
*/
- protected void storeModificationCount(long modificationCount) {
- super.storeModificationCount(modificationCount);
- this.checkModificationCount = true;
+ void recordScope(ASTNode astNode, BlockScope blockScope) {
+ this.astNodesToBlockScope.put(astNode, blockScope);
}
-}
\ No newline at end of file
+
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DoStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DoStatement.java
index dc61f00..6903a0e 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DoStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DoStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -60,7 +60,8 @@
*/
ASTNode clone(AST target) {
DoStatement result = new DoStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setExpression((Expression) getExpression().clone(target));
result.setBody((Statement) getBody().clone(target));
return result;
@@ -81,8 +82,8 @@
boolean visitChildren = visitor.visit(this);
if (visitChildren) {
// visit children in normal left to right reading order
- acceptChild(visitor, getExpression());
acceptChild(visitor, getBody());
+ acceptChild(visitor, getExpression());
}
visitor.endVisit(this);
}
@@ -95,7 +96,9 @@
public Expression getExpression() {
if (expression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return expression;
}
@@ -128,7 +131,9 @@
public Statement getBody() {
if (body == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setBody(new Block(getAST()));
+ getAST().setModificationCount(count);
}
return body;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EmptyStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EmptyStatement.java
index c0310d1..368ffc5 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EmptyStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/EmptyStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -47,7 +47,8 @@
*/
ASTNode clone(AST target) {
EmptyStatement result = new EmptyStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
return result;
}
@@ -63,7 +64,7 @@
* Method declared on ASTNode.
*/
void accept0(ASTVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
+ visitor.visit(this);
visitor.endVisit(this);
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Expression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Expression.java
index 058aef1..207a83c 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Expression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Expression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ExpressionStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ExpressionStatement.java
index f0f386d..e1e0884 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ExpressionStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ExpressionStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -58,7 +58,8 @@
*/
ASTNode clone(AST target) {
ExpressionStatement result = new ExpressionStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setExpression((Expression) getExpression().clone(target));
return result;
}
@@ -90,7 +91,9 @@
public Expression getExpression() {
if (expression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new MethodInvocation(getAST()));
+ getAST().setModificationCount(count);
}
return expression;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldAccess.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldAccess.java
index 305cdd7..bbb1cdd 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldAccess.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldAccess.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -18,6 +18,38 @@
* FieldAccess:
* Expression <b>.</b> Identifier
* </pre>
+ *
+ * <p>
+ * Note that there are several kinds of expressions that resemble field access
+ * expressions: qualified names, this expressions, and super field access
+ * expressions. The following guidelines help with correct usage:
+ * <ul>
+ * <li>An expression like "foo.this" can only be represented as a this
+ * expression (<code>ThisExpression</code>) containing a simple name.
+ * "this" is a keyword, and therefore invalid as an identifier.</li>
+ * <li>An expression like "this.foo" can only be represented as a field
+ * access expression (<code>FieldAccess</code>) containing a this expression
+ * and a simple name. Again, this is because "this" is a keyword, and
+ * therefore invalid as an identifier.</li>
+ * <li>An expression with "super" can only be represented as a super field
+ * access expression (<code>SuperFieldAccess</code>). "super" is a also
+ * keyword, and therefore invalid as an identifier.</li>
+ * <li>An expression like "foo.bar" can be represented either as a
+ * qualified name (<code>QualifiedName</code>) or as a field access
+ * expression (<code>FieldAccess</code>) containing simple names. Either
+ * is acceptable, and there is no way to choose between them without
+ * information about what the names resolve to
+ * (<code>AST.parseCompilationUnit</code> may return either).</li>
+ * <li>Other expressions ending in an identifier, such as "foo().bar" can
+ * only be represented as field access expressions
+ * (<code>FieldAccess</code>).</li>
+ * </ul>
+ * </p>
+ *
+ * @see QualifiedName
+ * @see ThisExpression
+ * @see SuperFieldAccess
+ * @since 2.0
*/
public class FieldAccess extends Expression {
@@ -59,6 +91,7 @@
*/
ASTNode clone(AST target) {
FieldAccess result = new FieldAccess(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setExpression((Expression) getExpression().clone(target));
result.setName((SimpleName) getName().clone(target));
return result;
@@ -93,7 +126,9 @@
public Expression getExpression() {
if (expression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return expression;
}
@@ -125,7 +160,10 @@
*/
public SimpleName getName() {
if (fieldName == null) {
+ // lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return fieldName;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldDeclaration.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldDeclaration.java
index 8e86c9c..ea06be1 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldDeclaration.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/FieldDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -91,6 +91,7 @@
*/
ASTNode clone(AST target) {
FieldDeclaration result = new FieldDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setJavadoc(
(Javadoc) ASTNode.copySubtree(target,(ASTNode) getJavadoc()));
result.setModifiers(getModifiers());
@@ -168,7 +169,9 @@
public Type getType() {
if (baseType == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setType(getAST().newPrimitiveType(PrimitiveType.INT));
+ getAST().setModificationCount(count);
}
return baseType;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ForStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ForStatement.java
index f9247d4..6ae1220 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ForStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ForStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -24,8 +24,8 @@
* [ ForUpdate ] <b>)</b>
* Statement
* ForInit:
- * ( SingleVariableDeclaration | Expression )
- * { <b>,</b> ( SingleVariableDeclaration | Expression ) }
+ * ( VariableDeclarationExpression
+ * | { Expression {<b>,</b> Expression } }
* ForUpdate:
* Expression { <b>,</b> Expression }
* </pre>
@@ -82,7 +82,8 @@
*/
ASTNode clone(AST target) {
ForStatement result = new ForStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.initializers().addAll(ASTNode.copySubtrees(target, initializers()));
result.setExpression(
(Expression) ASTNode.copySubtree(target, getExpression()));
@@ -120,9 +121,8 @@
* statement.
* <p>
* The list should consist of either a list of so called statement
- * expressions (JLS2, 14.8), or a list of variable declaration expressions
- * all with the same type. Otherwise, the for statement would have no Java
- * source equivalent.
+ * expressions (JLS2, 14.8), or a single <code>VariableDeclarationExpression</code>.
+ * Otherwise, the for statement would have no Java source equivalent.
* </p>
*
* @return the live list of initializer expressions
@@ -184,7 +184,9 @@
public Statement getBody() {
if (body == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setBody(new Block(getAST()));
+ getAST().setModificationCount(count);
}
return body;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IBinding.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IBinding.java
index 980a519..18805af 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IBinding.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -175,4 +175,4 @@
* @return a debug string
*/
public String toString();
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IMethodBinding.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IMethodBinding.java
index f13a71b..99e4b61 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IMethodBinding.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IMethodBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -81,4 +81,4 @@
* thrown by this method or constructor
*/
public ITypeBinding[] getExceptionTypes();
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IPackageBinding.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IPackageBinding.java
index da5e0a5..80688e2 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IPackageBinding.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IPackageBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -70,4 +70,4 @@
// * if there is no such type
// */
// public ITypeBinding findTypeBinding(String name);
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ITypeBinding.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ITypeBinding.java
index 0b6555e..1708962 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ITypeBinding.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ITypeBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -141,6 +141,7 @@
*
* @return the unqualified name of the type represented by this binding, an
* empty string this is an anonymous type, or "null" for the null type
+ * @see #getQualifiedName
*/
public String getName();
@@ -180,6 +181,12 @@
* superclass of this class is returned. If this type binding represents
* the class <code>java.lang.Object</code>, then <code>null</code> is
* returned.
+ * <p>
+ * Loops that ascend the class hierarchy need a suitable termination test.
+ * Rather than test the superclass for <code>null</code>, it is more
+ * transparent to check whether the class is <code>Object</code>, by
+ * comparing whether the class binding is identical to
+ * <code>ast.resolveWellKnownType("java.lang.Object")</code>.
* </p>
* <p>
* If this type binding represents an interface, an array type, a
@@ -188,6 +195,7 @@
*
* @return the superclass of the class represented by this type binding,
* or <code>null</code> if none
+ * @see AST#resolveWellKnownType
*/
public ITypeBinding getSuperclass();
@@ -376,4 +384,38 @@
* and <code>false</code> otherwise
*/
public boolean isFromSource();
-}
\ No newline at end of file
+
+ /**
+ * Returns the fully qualified name of the type represented by this
+ * binding if it has one.
+ * <ul>
+ * <li>For top-level types, the fully qualified name is the simple name of
+ * the type qualified by the package name (or unqualified if in a default
+ * package).
+ * Example: <code>"java.lang.String"</code>.</li>
+ * <li>For members of top-level types, the fully qualified name is the
+ * simple name of the type qualified by the fully qualified name of the
+ * enclosing type.
+ * Example: <code>"java.io.ObjectInputStream.GetField"</code>.</li>
+ * <li>For primitive types, the fully qualified name is the keyword for
+ * the primitive type.
+ * Example: <code>"int"</code>.</li>
+ * <li>For array types whose component type has a fully qualified name,
+ * the fully qualified name is the fully qualified name of the component
+ * type followed by "[]".
+ * Example: <code>"java.lang.String[]"</code>.</li>
+ * <li>For the null type, the fully qualified name is the string
+ * "null".</li>
+ * <li>Local types (including anonymous classes) and members of local
+ * types do not have a fully qualified name. For these types, and array
+ * types thereof, this method returns an empty string.</li>
+ * </ul>
+ *
+ * @return the fully qualified name of the type represented by this
+ * binding, or an empty string if this type does not have such an
+ * unambiguous name
+ * @see #getName
+ * @since 2.1
+ */
+ public String getQualifiedName();
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IVariableBinding.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IVariableBinding.java
index a5068bb..6171dbf 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IVariableBinding.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IVariableBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -91,4 +91,4 @@
* @return a small non-negative variable id
*/
public int getVariableId();
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IfStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IfStatement.java
index 8bcf227..fd6c685 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IfStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/IfStatement.java
@@ -1,24 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
/**
* If statement AST node type.
- *
- * Range 0: first character of "if" keyword through last character of
- * the last statement.
- * Range 1: first character of "else" keyword through last character of
- * the last statement; if "else" keyword is absent then an empty range
- *
* <pre>
* IfStatement:
* <b>if</b> <b>(</b> Expression <b>)</b> Statement [ <b>else</b> Statement]
@@ -72,7 +66,8 @@
*/
ASTNode clone(AST target) {
IfStatement result = new IfStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setExpression((Expression) getExpression().clone(target));
result.setThenStatement(
(Statement) getThenStatement().clone(target));
@@ -111,7 +106,9 @@
public Expression getExpression() {
if (expression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return expression;
}
@@ -144,7 +141,9 @@
public Statement getThenStatement() {
if (thenStatement == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setThenStatement(new Block(getAST()));
+ getAST().setModificationCount(count);
}
return thenStatement;
}
@@ -219,7 +218,7 @@
int treeSize() {
return
memSize()
- + (expression == null ? 0 : getElseStatement().treeSize())
+ + (expression == null ? 0 : getExpression().treeSize())
+ (thenStatement == null ? 0 : getThenStatement().treeSize())
+ (optionalElseStatement == null ? 0 : getElseStatement().treeSize());
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ImportDeclaration.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ImportDeclaration.java
index 43c0236..a564d00 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ImportDeclaration.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ImportDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -61,6 +61,7 @@
*/
ASTNode clone(AST target) {
ImportDeclaration result = new ImportDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setOnDemand(isOnDemand());
result.setName((Name) getName().clone(target));
return result;
@@ -97,8 +98,10 @@
public Name getName() {
if (importName == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(getAST().newQualifiedName(
new SimpleName(getAST()), new SimpleName(getAST())));
+ getAST().setModificationCount(count);
}
return importName;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InfixExpression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InfixExpression.java
index 77e1c23..1a67ebd 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InfixExpression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InfixExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -17,11 +17,6 @@
/**
* Infix expression AST node type.
- *
- * Range 0: first character of left operand expression through last character
- * of the last extended operand expression. If there are no extended operands,
- * the range ends after the right operand expression.
- *
* <pre>
* InfixExpression:
* Expression InfixOperator Expression { InfixOperator Expression }
@@ -222,6 +217,7 @@
*/
ASTNode clone(AST target) {
InfixExpression result = new InfixExpression(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setOperator(getOperator());
result.setLeftOperand((Expression) getLeftOperand().clone(target));
result.setRightOperand((Expression) getRightOperand().clone(target));
@@ -289,7 +285,9 @@
public Expression getLeftOperand() {
if (leftOperand == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setLeftOperand(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return leftOperand;
}
@@ -322,7 +320,9 @@
public Expression getRightOperand() {
if (rightOperand == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setRightOperand(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return rightOperand;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Initializer.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Initializer.java
index c4bc74b..0ac56ce 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Initializer.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Initializer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -65,6 +65,7 @@
*/
ASTNode clone(AST target) {
Initializer result = new Initializer(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setModifiers(getModifiers());
result.setJavadoc(
(Javadoc) ASTNode.copySubtree(target,(ASTNode) getJavadoc()));
@@ -131,7 +132,9 @@
public Block getBody() {
if (body == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setBody(new Block(getAST()));
+ getAST().setModificationCount(count);
}
return body;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InstanceofExpression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InstanceofExpression.java
index ddadbca..444408b 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InstanceofExpression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/InstanceofExpression.java
@@ -1,22 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
/**
* Instanceof expression AST node type.
- *
- * Range 0: first character of left operand expression through last character
- * of the right operand expression.
- *
* <pre>
* InstanceofExpression:
* Expression <b>instanceof</b> Type
@@ -61,6 +57,7 @@
*/
ASTNode clone(AST target) {
InstanceofExpression result = new InstanceofExpression(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setLeftOperand((Expression) getLeftOperand().clone(target));
result.setRightOperand((Type) getRightOperand().clone(target));
return result;
@@ -95,7 +92,9 @@
public Expression getLeftOperand() {
if (leftOperand == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setLeftOperand(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return leftOperand;
}
@@ -128,7 +127,9 @@
public Type getRightOperand() {
if (rightOperand == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setRightOperand(new SimpleType(getAST()));
+ getAST().setModificationCount(count);
}
return rightOperand;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Javadoc.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Javadoc.java
index 5340f39..b739950 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Javadoc.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Javadoc.java
@@ -1,16 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
+import org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
+
/**
* AST node for a Javadoc comment.
*
@@ -51,6 +55,7 @@
*/
ASTNode clone(AST target) {
Javadoc result = new Javadoc(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setComment(getComment());
return result;
}
@@ -67,7 +72,7 @@
* Method declared on ASTNode.
*/
void accept0(ASTVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
+ visitor.visit(this);
visitor.endVisit(this);
}
@@ -93,7 +98,29 @@
if (javadocComment == null) {
throw new IllegalArgumentException();
}
- if (javadocComment.length() < 5 || !javadocComment.startsWith("/**") || !javadocComment.endsWith("*/")) {//$NON-NLS-1$//$NON-NLS-2$
+ char[] source = javadocComment.toCharArray();
+ Scanner scanner = this.getAST().scanner;
+ scanner.resetTo(0, source.length);
+ scanner.setSource(source);
+ try {
+ int token;
+ boolean onlyOneComment = false;
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC :
+ if (onlyOneComment) {
+ throw new IllegalArgumentException();
+ }
+ onlyOneComment = true;
+ break;
+ default:
+ onlyOneComment = false;
+ }
+ }
+ if (!onlyOneComment) {
+ throw new IllegalArgumentException();
+ }
+ } catch (InvalidInputException e) {
throw new IllegalArgumentException();
}
modifying();
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/LabeledStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/LabeledStatement.java
index d5ca1c0..5083b6d 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/LabeledStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/LabeledStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -61,6 +61,7 @@
*/
ASTNode clone(AST target) {
LabeledStatement result = new LabeledStatement(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setLabel(
(SimpleName) ASTNode.copySubtree(target, getLabel()));
result.setBody(
@@ -97,7 +98,9 @@
public SimpleName getLabel() {
if (labelName == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setLabel(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return labelName;
}
@@ -128,7 +131,9 @@
public Statement getBody() {
if (body == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setBody(new EmptyStatement(getAST()));
+ getAST().setModificationCount(count);
}
return body;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Message.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Message.java
index dce2d58..dac9d95 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Message.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Message.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java
index fc665c4..6814e69 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -142,7 +142,10 @@
*/
public String getKey() {
StringBuffer buffer = new StringBuffer();
- buffer.append(getReturnType().getKey());
+ ITypeBinding returnType = getReturnType();
+ if (returnType != null) {
+ buffer.append(returnType.getKey());
+ }
if (!isConstructor()) {
buffer.append(this.getName());
buffer.append('/');
@@ -160,5 +163,12 @@
}
return buffer.toString();
}
-
+
+ /*
+ * For debugging purpose only.
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return this.binding.toString();
+ }
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodDeclaration.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodDeclaration.java
index c50fb7a..b767669 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodDeclaration.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -28,21 +28,8 @@
* [ Javadoc ] { Modifier } Identifier <b>(</b>
* [ FormalParameter
* { <b>,</b> FormalParameter } ] <b>)</b>
- * [<b>throws</b> TypeName { <b>,</b> TypeName } ] MethodBody
+ * [<b>throws</b> TypeName { <b>,</b> TypeName } ] Block
* </pre>
- * Normal form:
- * <pre>
- * MethodDeclaration:
- * [ Javadoc ] { Modifier } ( Type | <b>void</b> ) Identifier
- * <b>(</b> [ FormalParamter { <b>,</b> FormalParameter } ] <b>)</b>
- * [ <b>throws</b> TypeName { <b>,</b> TypeName } ]
- * ( Block | <b>;</b> )
- * ConstructorDeclaration:
- * [ Javadoc ] { Modifier } Identifier
- * <b>(</b> [ FormalParameter { <b>,</b> FormalParameter } ] <b>)</b>
- * [ <b>throws</b> TypeName { <b>,</b> TypeName } ]
- * Block
- * </pre>
* <p>
* When a Javadoc comment is present, the source
* range begins with the first character of the "/**" comment delimiter.
@@ -90,7 +77,7 @@
* Defaults to an empty list.
*/
private ASTNode.NodeList parameters =
- new ASTNode.NodeList(true, SingleVariableDeclaration.class);;
+ new ASTNode.NodeList(true, SingleVariableDeclaration.class);
/**
* The return type; lazily initialized; defaults to void. Note that this
@@ -99,6 +86,14 @@
private Type returnType = null;
/**
+ * The number of array dimensions that appear after the parameters, rather
+ * than after the return type itself; defaults to 0.
+ *
+ * @since 2.1
+ */
+ private int extraArrayDimensions = 0;
+
+ /**
* The list of thrown exception names (element type: <code>Name</code>).
* Defaults to an empty list.
*/
@@ -115,8 +110,8 @@
* Creates a new AST node for a method declaration owned
* by the given AST. By default, the declaration is for a method of an
* unspecified, but legal, name; no modifiers; no javadoc; no parameters;
- * void return type; no thrown exceptions; and no body (as opposed to an
- * empty body).
+ * void return type; no array dimensions after the parameters; no thrown
+ * exceptions; and no body (as opposed to an empty body).
* <p>
* N.B. This constructor is package-private; all subclasses must be
* declared in the same package; clients are unable to declare
@@ -141,12 +136,14 @@
*/
ASTNode clone(AST target) {
MethodDeclaration result = new MethodDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setJavadoc(
(Javadoc) ASTNode.copySubtree(target,(ASTNode) getJavadoc()));
result.setModifiers(getModifiers());
result.setConstructor(isConstructor());
result.setReturnType(
(Type) ASTNode.copySubtree(target, getReturnType()));
+ result.setExtraDimensions(getExtraDimensions());
result.setName((SimpleName) getName().clone(target));
result.parameters().addAll(
ASTNode.copySubtrees(target, parameters()));
@@ -173,6 +170,7 @@
if (visitChildren) {
// visit children in normal left to right reading order
acceptChild(visitor, getJavadoc());
+ // n.b. visit return type even for constructors
acceptChild(visitor, getReturnType());
acceptChild(visitor, getName());
acceptChildren(visitor, parameters);
@@ -248,7 +246,9 @@
public SimpleName getName() {
if (methodName == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return methodName;
}
@@ -297,11 +297,13 @@
/**
* Returns the return type of the method declared in this method
- * declaration. This is one of the few places where the void type
- * is meaningful.
+ * declaration, exclusive of any extra array dimensions.
+ * This is one of the few places where the void type is meaningful.
* <p>
* Note that this child is not relevant for constructor declarations
- * (although it does still figure in subtree equality comparisons).
+ * (although it does still figure in subtree equality comparisons
+ * and visits), and is devoid of the binding information ordinarily
+ * available.
* </p>
*
* @return the return type, possibly the void primitive type
@@ -309,18 +311,20 @@
public Type getReturnType() {
if (returnType == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setReturnType(getAST().newPrimitiveType(PrimitiveType.VOID));
+ getAST().setModificationCount(count);
}
return returnType;
}
/**
* Sets the return type of the method declared in this method declaration
- * to the given type. This is one of the few places where the void type is
- * meaningful.
+ * to the given type, exclusive of any extra array dimensions. This is one
+ * of the few places where the void type is meaningful.
* <p>
* Note that this child is not relevant for constructor declarations
- * (although it does still figure in subtree equality comparisons).
+ * (although it does still figure in subtree equality comparisons and visits).
* </p>
*
* @param type the new return type, possibly the void primitive type
@@ -339,6 +343,50 @@
}
/**
+ * Returns the number of extra array dimensions over and above the
+ * explicitly-specified return type.
+ * <p>
+ * For example, <code>int foo()[][]</code> has a return type of
+ * <code>int</code> and two extra array dimensions;
+ * <code>int[][] foo()</code> has a return type of <code>int[][]</code>
+ * and zero extra array dimensions. The two constructs have different
+ * ASTs, even though there are really syntactic variants of the same
+ * method declaration.
+ * </p>
+ *
+ * @return the number of extra array dimensions
+ * @since 2.1
+ */
+ public int getExtraDimensions() {
+ return extraArrayDimensions;
+ }
+
+ /**
+ * Sets the number of extra array dimensions over and above the
+ * explicitly-specified return type.
+ * <p>
+ * For example, <code>int foo()[][]</code> is rendered as a return
+ * type of <code>int</code> with two extra array dimensions;
+ * <code>int[][] foo()</code> is rendered as a return type of
+ * <code>int[][]</code> with zero extra array dimensions. The two
+ * constructs have different ASTs, even though there are really syntactic
+ * variants of the same method declaration.
+ * </p>
+ *
+ * @param dimensions the number of array dimensions
+ * @exception IllegalArgumentException if the number of dimensions is
+ * negative
+ * @since 2.1
+ */
+ public void setExtraDimensions(int dimensions) {
+ if (dimensions < 0) {
+ throw new IllegalArgumentException();
+ }
+ modifying();
+ this.extraArrayDimensions = dimensions;
+ }
+
+ /**
* Returns the body of this method declaration, or <code>null</code> if
* this method has <b>no</b> body.
* <p>
@@ -419,7 +467,7 @@
* Method declared on ASTNode.
*/
int memSize() {
- return super.memSize() + 7 * 4;
+ return super.memSize() + 8 * 4;
}
/* (omit javadoc for this method)
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java
index 535c2cd..71d6ba1 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -67,6 +67,7 @@
*/
ASTNode clone(AST target) {
MethodInvocation result = new MethodInvocation(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setName((SimpleName) getName().clone(target));
result.setExpression(
(Expression) ASTNode.copySubtree(target, getExpression()));
@@ -132,7 +133,9 @@
public SimpleName getName() {
if (methodName == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return methodName;
}
@@ -167,6 +170,22 @@
return arguments;
}
+ /**
+ * Resolves and returns the binding for the method invoked by this
+ * expression.
+ * <p>
+ * Note that bindings are generally unavailable unless requested when the
+ * AST is being built.
+ * </p>
+ *
+ * @return the method binding, or <code>null</code> if the binding cannot
+ * be resolved
+ * @since 2.1
+ */
+ public IMethodBinding resolveMethodBinding() {
+ return getAST().getBindingResolver().resolveMethod(this);
+ }
+
/* (omit javadoc for this method)
* Method declared on ASTNode.
*/
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java
index a685330..7fe30a7 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Modifier.java
@@ -1,14 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
-
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
/**
@@ -34,6 +33,10 @@
* This class provides constants and static methods only; it is not intended
* to be instantiated or subclassed.
* </p>
+ * <p>
+ * Note that Java model class <code>Flags</code> provides the same functionality
+ * as this class, only in the <code>org.eclipse.jdt.core</code> package.
+ * </p>
*
* @since 2.0
*/
@@ -42,73 +45,73 @@
/**
* Modifier constant (bit mask, value 0) indicating no modifiers.
*/
- public static int NONE = 0x0000;
+ public static final int NONE = 0x0000;
/**
* "public" modifier constant (bit mask).
* Applicable to types, methods, constructors, and fields.
*/
- public static int PUBLIC = 0x0001;
+ public static final int PUBLIC = 0x0001;
/**
* "private" modifier constant (bit mask).
* Applicable to types, methods, constructors, and fields.
*/
- public static int PRIVATE = 0x0002;
+ public static final int PRIVATE = 0x0002;
/**
* "protected" modifier constant (bit mask).
* Applicable to types, methods, constructors, and fields.
*/
- public static int PROTECTED = 0x0004;
+ public static final int PROTECTED = 0x0004;
/**
* "static" modifier constant (bit mask).
* Applicable to types, methods, fields, and initializers.
*/
- public static int STATIC = 0x0008;
+ public static final int STATIC = 0x0008;
/**
* "final" modifier constant (bit mask).
* Applicable to types, methods, fields, and variables.
*/
- public static int FINAL = 0x0010;
+ public static final int FINAL = 0x0010;
/**
* "synchronized" modifier constant (bit mask).
* Applicable only to methods.
*/
- public static int SYNCHRONIZED = 0x0020;
+ public static final int SYNCHRONIZED = 0x0020;
/**
* "volatile" modifier constant (bit mask).
* Applicable only to fields.
*/
- public static int VOLATILE = 0x0040;
+ public static final int VOLATILE = 0x0040;
/**
* "transient" modifier constant (bit mask).
* Applicable only to fields.
*/
- public static int TRANSIENT = 0x0080;
+ public static final int TRANSIENT = 0x0080;
/**
* "native" modifier constant (bit mask).
* Applicable only to methods.
*/
- public static int NATIVE = 0x0100;
+ public static final int NATIVE = 0x0100;
/**
* "abstract" modifier constant (bit mask).
* Applicable to types and methods.
*/
- public static int ABSTRACT = 0x0400;
+ public static final int ABSTRACT = 0x0400;
/**
* "strictfp" modifier constant (bit mask).
* Applicable to types and methods.
*/
- public static int STRICTFP = 0x0800;
+ public static final int STRICTFP = 0x0800;
/**
* Returns whether the given flags includes the "public" modifier.
@@ -248,4 +251,4 @@
private Modifier() {
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NaiveASTFlattener.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NaiveASTFlattener.java
index 1af192b..4a918ce 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NaiveASTFlattener.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NaiveASTFlattener.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2002 IBM Corporation and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
import java.util.Iterator;
/**
- * Internal AST visitor for serializing an AST in a qucik and dirty fashion.
+ * Internal AST visitor for serializing an AST in a quick and dirty fashion.
* For various reasons the resulting string is not necessarily legal
* Java code; and even if it is legal Java code, it is not necessarily the string
* that corresponds to the given AST. Although useless for most purposes, it's
@@ -425,14 +425,14 @@
e.accept(this);
}
buffer.append("; ");//$NON-NLS-1$
+ if (node.getExpression() != null) {
+ node.getExpression().accept(this);
+ }
+ buffer.append("; ");//$NON-NLS-1$
for (Iterator it = node.updaters().iterator(); it.hasNext(); ) {
Expression e = (Expression) it.next();
e.accept(this);
}
- buffer.append("; ");//$NON-NLS-1$
- if (node.getExpression() != null) {
- node.getExpression().accept(this);
- }
buffer.append(") ");//$NON-NLS-1$
node.getBody().accept(this);
return false;
@@ -765,9 +765,13 @@
* @see ASTVisitor#visit(SwitchCase)
*/
public boolean visit(SwitchCase node) {
- buffer.append("case ");//$NON-NLS-1$
- node.getExpression().accept(this);
- buffer.append(": ");//$NON-NLS-1$
+ if (node.isDefault()) {
+ buffer.append("default : ");//$NON-NLS-1$
+ } else {
+ buffer.append("case ");//$NON-NLS-1$
+ node.getExpression().accept(this);
+ buffer.append(": ");//$NON-NLS-1$
+ }
return false;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Name.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Name.java
index 10e3f6b..3f5fb1a 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Name.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Name.java
@@ -1,16 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+
/**
* Abstract base class for all AST nodes that represent names.
* There are exactly two kinds of name: simple ones
@@ -28,6 +31,11 @@
public abstract class Name extends Expression {
/**
+ * This index reprensents the position inside a qualified name.
+ */
+ int index;
+
+ /**
* Creates a new AST node for a name owned by the given AST.
* <p>
* N.B. This constructor is package-private.
@@ -74,4 +82,43 @@
public final IBinding resolveBinding() {
return getAST().getBindingResolver().resolveName(this);
}
+
+ BlockScope lookupScope() {
+ ASTNode currentNode = this;
+ while(currentNode != null
+ &&!(currentNode instanceof MethodDeclaration)
+ && !(currentNode instanceof Initializer)
+ && !(currentNode instanceof FieldDeclaration)) {
+ currentNode = currentNode.getParent();
+ }
+ if (currentNode == null) {
+ return null;
+ }
+ if (currentNode instanceof Initializer) {
+ Initializer initializer = (Initializer) currentNode;
+ while(!(currentNode instanceof TypeDeclaration)) {
+ currentNode = currentNode.getParent();
+ }
+ org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.getAST().getBindingResolver().getCorrespondingNode(currentNode);
+ if ((initializer.getModifiers() & Modifier.STATIC) != 0) {
+ return typeDecl.staticInitializerScope;
+ } else {
+ return typeDecl.initializerScope;
+ }
+ } else if (currentNode instanceof FieldDeclaration) {
+ FieldDeclaration fieldDeclaration = (FieldDeclaration) currentNode;
+ while(!(currentNode instanceof TypeDeclaration)) {
+ currentNode = currentNode.getParent();
+ }
+ org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.getAST().getBindingResolver().getCorrespondingNode(currentNode);
+ if ((fieldDeclaration.getModifiers() & Modifier.STATIC) != 0) {
+ return typeDecl.staticInitializerScope;
+ } else {
+ return typeDecl.initializerScope;
+ }
+ }
+ AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) this.getAST().getBindingResolver().getCorrespondingNode(currentNode);
+ return abstractMethodDeclaration.scope;
+ }
+
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NullLiteral.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NullLiteral.java
index a5b5659..fb0c1a5 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NullLiteral.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NullLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -40,7 +40,9 @@
* Method declared on ASTNode.
*/
ASTNode clone(AST target) {
- return new NullLiteral(target);
+ NullLiteral result = new NullLiteral(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ return result;
}
/* (omit javadoc for this method)
@@ -55,7 +57,7 @@
* Method declared on ASTNode.
*/
void accept0(ASTVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
+ visitor.visit(this);
visitor.endVisit(this);
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NumberLiteral.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NumberLiteral.java
index c734fc4..bd2166d 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NumberLiteral.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/NumberLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -51,6 +51,7 @@
*/
ASTNode clone(AST target) {
NumberLiteral result = new NumberLiteral(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setToken(getToken());
return result;
}
@@ -67,7 +68,7 @@
* Method declared on ASTNode.
*/
void accept0(ASTVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
+ visitor.visit(this);
visitor.endVisit(this);
}
@@ -96,6 +97,8 @@
char[] source = token.toCharArray();
scanner.setSource(source);
scanner.resetTo(0, source.length);
+ scanner.tokenizeComments = false;
+ scanner.tokenizeWhiteSpace = false;
try {
int tokenType = scanner.getNextToken();
switch(tokenType) {
@@ -121,6 +124,9 @@
}
} catch(InvalidInputException e) {
throw new IllegalArgumentException();
+ } finally {
+ scanner.tokenizeComments = true;
+ scanner.tokenizeWhiteSpace = true;
}
modifying();
this.tokenValue = token;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageBinding.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageBinding.java
index 7155ee7..d748421 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageBinding.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageBinding.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+import org.eclipse.jdt.core.compiler.CharOperation;
/**
* Internal implementation of package bindings.
@@ -94,18 +94,9 @@
return getName();
}
- private String concat(String[] array, char c) {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0, max = array.length; i < max - 1; i++) {
- buffer.append(array[i]).append(c);
- }
- buffer.append(array[array.length - 1]);
- return buffer.toString();
- }
-
private void computeNameAndComponents() {
char[][] compoundName = this.binding.compoundName;
- if (compoundName == TypeConstants.NoCharChar || compoundName == null) {
+ if (compoundName == CharOperation.NO_CHAR_CHAR || compoundName == null) {
name = UNNAMED;
components = NO_NAME_COMPONENTS;
} else {
@@ -120,5 +111,13 @@
buffer.append(compoundName[length - 1]);
name = buffer.toString();
}
- }
+ }
+
+ /*
+ * For debugging purpose only.
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return this.binding.toString();
+ }
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageDeclaration.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageDeclaration.java
index d33c27a..50bf3a6 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageDeclaration.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PackageDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -56,6 +56,7 @@
*/
ASTNode clone(AST target) {
PackageDeclaration result = new PackageDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setName((Name) getName().clone(target));
return result;
}
@@ -87,7 +88,9 @@
public Name getName() {
if (packageName == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return packageName;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParenthesizedExpression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParenthesizedExpression.java
index a1fb62f..275e8de 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParenthesizedExpression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ParenthesizedExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -54,6 +54,7 @@
*/
ASTNode clone(AST target) {
ParenthesizedExpression result = new ParenthesizedExpression(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setExpression((Expression) getExpression().clone(target));
return result;
}
@@ -85,7 +86,9 @@
public Expression getExpression() {
if (expression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return expression;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PostfixExpression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PostfixExpression.java
index dcd3620..3ab218f 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PostfixExpression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PostfixExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -136,6 +136,7 @@
*/
ASTNode clone(AST target) {
PostfixExpression result = new PostfixExpression(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setOperator(getOperator());
result.setOperand((Expression) getOperand().clone(target));
return result;
@@ -191,7 +192,9 @@
public Expression getOperand() {
if (operand == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setOperand(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return operand;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrefixExpression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrefixExpression.java
index ef0c4b2..5f88479 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrefixExpression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrefixExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -152,6 +152,7 @@
*/
ASTNode clone(AST target) {
PrefixExpression result = new PrefixExpression(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setOperator(getOperator());
result.setOperand((Expression) getOperand().clone(target));
return result;
@@ -208,7 +209,9 @@
public Expression getOperand() {
if (operand == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setOperand(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return operand;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrimitiveType.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrimitiveType.java
index f57ba88..c10007c 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrimitiveType.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/PrimitiveType.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -176,6 +176,7 @@
*/
ASTNode clone(AST target) {
PrimitiveType result = new PrimitiveType(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setPrimitiveTypeCode(getPrimitiveTypeCode());
return result;
}
@@ -192,7 +193,7 @@
* Method declared on ASTNode.
*/
void accept0(ASTVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
+ visitor.visit(this);
visitor.endVisit(this);
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/QualifiedName.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/QualifiedName.java
index d044770..92ab854 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/QualifiedName.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/QualifiedName.java
@@ -1,16 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
+
/**
* AST node for a qualified name. A qualified name is defined recursively
* as a simple name preceded by a name, which qualifies it. Expressing it this
@@ -19,10 +20,12 @@
* QualifiedName:
* Name <b>.</b> SimpleName
* </pre>
- *
- * Range 0: first character of qualified name through the last character
- * of the simple name.
- *
+ * <p>
+ * See <code>FieldAccess</code> for guidelines on handling other expressions
+ * that resemble qualified names.
+ * </p>
+ *
+ * @see FieldAccess
* @since 2.0
*/
public class QualifiedName extends Name {
@@ -64,6 +67,7 @@
*/
ASTNode clone(AST target) {
QualifiedName result = new QualifiedName(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setQualifier((Name) getQualifier().clone(target));
result.setName((SimpleName) getName().clone(target));
return result;
@@ -98,7 +102,9 @@
public Name getQualifier() {
if (qualifier == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setQualifier(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return qualifier;
}
@@ -131,7 +137,9 @@
public SimpleName getName() {
if (name == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return name;
}
@@ -158,7 +166,7 @@
* Method declared on ASTNode.
*/
int memSize() {
- return BASE_NODE_SIZE + 2 * 4;
+ return BASE_NODE_SIZE + 3 * 4;
}
/* (omit javadoc for this method)
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ReturnStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ReturnStatement.java
index 01d6f1c..8e9e5d1 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ReturnStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ReturnStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -50,7 +50,8 @@
*/
ASTNode clone(AST target) {
ReturnStatement result = new ReturnStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setExpression(
(Expression) ASTNode.copySubtree(target, getExpression()));
return result;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleName.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleName.java
index 17b5082..3f1db4d 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleName.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleName.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -17,9 +17,6 @@
/**
* AST node for a simple name. A simple name is an identifier other than
* a keyword, boolean literal ("true", "false") or null literal ("null").
- * <p>
- * Range 0: first character through last character of identifier.
- * </p>
* <pre>
* SimpleName:
* Identifier
@@ -66,12 +63,8 @@
*/
ASTNode clone(AST target) {
SimpleName result = new SimpleName(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setIdentifier(getIdentifier());
- int startPosition = getStartPosition();
- int length = getLength();
- if (startPosition >= 0 && length > 0) {
- result.setSourceRange(startPosition, length);
- }
return result;
}
@@ -87,7 +80,7 @@
* Method declared on ASTNode.
*/
void accept0(ASTVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
+ visitor.visit(this);
visitor.endVisit(this);
}
@@ -191,7 +184,7 @@
int memSize() {
int size = BASE_NODE_SIZE + 1 * 4;
if (identifier != null) {
- size += HEADERS + 2 * 4 + HEADERS + 2 * identifier.length();
+ size += HEADERS + 3 * 4 + HEADERS + 2 * identifier.length();
}
return size;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleType.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleType.java
index 90283b7..16a126d 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleType.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleType.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -52,6 +52,7 @@
*/
ASTNode clone(AST target) {
SimpleType result = new SimpleType(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setName((Name) ((ASTNode) getName()).clone(target));
return result;
}
@@ -83,7 +84,9 @@
public Name getName() {
if (typeName == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return typeName;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SingleVariableDeclaration.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SingleVariableDeclaration.java
index 7a8c4c9..31d2f7e 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SingleVariableDeclaration.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SingleVariableDeclaration.java
@@ -1,43 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
/**
- * VariableDeclaration declaration AST node type. Union of field declaration,
- * local variable declaration, and formal parameter declaration.
+ * Single variable declaration AST node type. Single variable
+ * declaration nodes are used in a limited number of places, including formal
+ * parameter lists and catch clauses. They are not used for field declarations
+ * and regular variable declaration statements.
*
* <pre>
- * FieldDeclaration:
- * { Modifier } Type Identifier { <b>[</b><b>]</b> } [ <b>=</b> Expression ]
- * { <b>,</b> Identifier { <b>[</b><b>]</b> } [ <b>=</b> Expression] }
- * <b>;</b>
- * LocalVariableDeclaration:
- * { <b>final</b> } Type
- * Identifier { <b>[</b><b>]</b> } [ <b>=</b> Expression ]
- * { <b>,</b> Identifier { <b>[</b><b>]</b> } [ <b>=</b> Expression] }
- * <b>;</b>
- * FormalParameter:
- * { <b>final</b> } Type Identifier { <b>[</b><b>]</b> }
- * </pre>
- * Simplified normalized form:
- * <pre>
* SingleVariableDeclaration:
- * { Modifier } Type Identifier [ <b>=</b> Expression ]
- * FieldDeclaration:
- * SingleVariableDeclaration <b>;</b>
- * LocalVariableDeclaration:
- * SingleVariableDeclaration <b>;</b>
- * FormalParameter:
- * SingleVariableDeclaration
+ * { Modifier } Type Identifier { <b>[</b><b>]</b> } [ <b>=</b> Expression ]
* </pre>
*
* @since 2.0
@@ -71,6 +53,14 @@
private Type type = null;
/**
+ * The number of extra array dimensions that appear after the variable;
+ * defaults to 0.
+ *
+ * @since 2.1
+ */
+ private int extraArrayDimensions = 0;
+
+ /**
* The initializer expression, or <code>null</code> if none;
* defaults to none.
*/
@@ -80,7 +70,7 @@
* Creates a new AST node for a variable declaration owned by the given
* AST. By default, the variable declaration has: no modifiers, an
* unspecified (but legal) type, an unspecified (but legal) variable name,
- * no initializer.
+ * 0 dimensions after the variable; no initializer.
* <p>
* N.B. This constructor is package-private.
* </p>
@@ -103,8 +93,10 @@
*/
ASTNode clone(AST target) {
SingleVariableDeclaration result = new SingleVariableDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setModifiers(getModifiers());
result.setType((Type) getType().clone(target));
+ result.setExtraDimensions(getExtraDimensions());
result.setName((SimpleName) getName().clone(target));
result.setInitializer(
(Expression) ASTNode.copySubtree(target, getInitializer()));
@@ -173,7 +165,9 @@
public SimpleName getName() {
if (variableName == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return variableName;
}
@@ -190,21 +184,24 @@
}
/**
- * Returns the type of the variable declared in this variable declaration.
+ * Returns the type of the variable declared in this variable declaration,
+ * exclusive of any extra array dimensions.
*
* @return the type
*/
public Type getType() {
if (type == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setType(getAST().newPrimitiveType(PrimitiveType.INT));
+ getAST().setModificationCount(count);
}
return type;
}
/**
* Sets the type of the variable declared in this variable declaration to
- * the given type.
+ * the given type, exclusive of any extra array dimensions.
*
* @param type the new type
* @exception IllegalArgumentException if:
@@ -223,6 +220,26 @@
/* (omit javadoc for this method)
* Method declared on VariableDeclaration.
+ * @since 2.1
+ */
+ public int getExtraDimensions() {
+ return extraArrayDimensions;
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on VariableDeclaration.
+ * @since 2.1
+ */
+ public void setExtraDimensions(int dimensions) {
+ if (dimensions < 0) {
+ throw new IllegalArgumentException();
+ }
+ modifying();
+ this.extraArrayDimensions = dimensions;
+ }
+
+ /* (omit javadoc for this method)
+ * Method declared on VariableDeclaration.
*/
public Expression getInitializer() {
return optionalInitializer;
@@ -243,7 +260,7 @@
*/
int memSize() {
// treat Operator as free
- return BASE_NODE_SIZE + 4 * 4;
+ return BASE_NODE_SIZE + 5 * 4;
}
/* (omit javadoc for this method)
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Statement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Statement.java
index 60185ca..49c8ee3 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Statement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Statement.java
@@ -1,16 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
+import org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
+
/**
* Abstract base class of AST nodes that represent statements.
* There are many kinds of statements.
@@ -48,6 +52,8 @@
/**
* The leading comment, or <code>null</code> if none.
* Defaults to none.
+ *
+ * @deprecated The leading comment feature was removed in 2.1.
*/
private String optionalLeadingComment = null;
@@ -67,13 +73,21 @@
* Returns the leading comment string, including the starting
* and ending comment delimiters, and any embedded line breaks.
* <p>
- * A leading comment is one that appears before the statement.
- * It may be either an end-of-line or a multi-line comment.
- * Multi-line comments may contain line breaks; end-of-line
- * comments must not.
+ * A leading comment is a comment that appears before the statement.
+ * It may be either a traditional comment or an end-of-line comment.
+ * Traditional comments must begin with "/*, may contain line breaks,
+ * and must end with "*/. End-of-line comments must begin with "//",
+ * must end with a line delimiter (as per JLS 3.7), and must not contain
+ * line breaks.
* </p>
*
* @return the comment string, or <code>null</code> if none
+ * @deprecated This feature was removed in the 2.1 release because it was
+ * only a partial, and inadequate, solution to the issue of associating
+ * comments with statements. Furthermore, AST.parseCompilationUnit did not
+ * associate leading comments, making this moot. Clients that need to access
+ * comments preceding a statement should use a scanner to reanalyze the
+ * source text immediately preceding the statement's source range.
*/
public String getLeadingComment() {
return optionalLeadingComment;
@@ -84,42 +98,76 @@
* string must include the starting and ending comment delimiters,
* and any embedded linebreaks.
* <p>
- * A leading comment is one that appears before the statement.
- * It may be either an end-of-line or a multi-line comment.
- * Multi-line comments may contain line breaks; end-of-line
- * comments must not.
+ * A leading comment is a comment that appears before the statement.
+ * It may be either a traditional comment or an end-of-line comment.
+ * Traditional comments must begin with "/*, may contain line breaks,
+ * and must end with "*/. End-of-line comments must begin with "//"
+ * (as per JLS 3.7), and must not contain line breaks.
* </p>
* <p>
* Examples:
* <code>
* <pre>
- * setLeadingComment("/* single-line comment */") - correct
- * setLeadingComment("missing comment delimiters") - wrong!
- * setLeadingComment("/* unterminated comment ") - wrong!
- * setLeadingComment("// end-of-line comment") - correct
- * setLeadingComment("/* multi-line\n comment */") - correct
- * setLeadingComment("// broken end-of-line\n comment ") - wrong!
+ * setLeadingComment("/* traditional comment */"); // correct
+ * setLeadingComment("missing comment delimiters"); // wrong
+ * setLeadingComment("/* unterminated traditional comment "); // wrong
+ * setLeadingComment("/* broken\n traditional comment */"); // correct
+ * setLeadingComment("// end-of-line comment\n"); // correct
+ * setLeadingComment("// end-of-line comment without line terminator"); // correct
+ * setLeadingComment("// broken\n end-of-line comment\n"); // wrong
* </pre>
* </code>
* </p>
*
* @param comment the comment string, or <code>null</code> if none
* @exception IllegalArgumentException if the comment string is invalid
+ * @deprecated This feature was removed in the 2.1 release because it was
+ * only a partial, and inadequate, solution to the issue of associating
+ * comments with statements.
*/
public void setLeadingComment(String comment) {
if (comment != null) {
- if (comment.startsWith("/*") && comment.endsWith("*/") && comment.length() >= 4) {//$NON-NLS-1$//$NON-NLS-2$
- // this is ok
- } else if (comment.startsWith("//") && comment.indexOf('\n') < 0) {//$NON-NLS-1$
- // this is ok too
- } else {
- // but anything else if not good
+ char[] source = comment.toCharArray();
+ Scanner scanner = this.getAST().scanner;
+ scanner.resetTo(0, source.length);
+ scanner.setSource(source);
+ try {
+ int token;
+ boolean onlyOneComment = false;
+ while ((token = scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
+ switch(token) {
+ case TerminalTokens.TokenNameCOMMENT_BLOCK :
+ case TerminalTokens.TokenNameCOMMENT_JAVADOC :
+ case TerminalTokens.TokenNameCOMMENT_LINE :
+ if (onlyOneComment) {
+ throw new IllegalArgumentException();
+ }
+ onlyOneComment = true;
+ break;
+ default:
+ onlyOneComment = false;
+ }
+ }
+ if (!onlyOneComment) {
+ throw new IllegalArgumentException();
+ }
+ } catch (InvalidInputException e) {
throw new IllegalArgumentException();
}
}
modifying();
this.optionalLeadingComment = comment;
}
+
+ /**
+ * Copies the leading comment from the given statement.
+ *
+ * @param source the statement that supplies the leading comment
+ * @since 2.1
+ */
+ void copyLeadingComment(Statement source) {
+ setLeadingComment(source.getLeadingComment());
+ }
/* (omit javadoc for this method)
* Method declared on ASTNode.
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/StringLiteral.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/StringLiteral.java
index 358d074..1e2c1b2 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/StringLiteral.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/StringLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -52,6 +52,7 @@
*/
ASTNode clone(AST target) {
StringLiteral result = new StringLiteral(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setEscapedValue(getEscapedValue());
return result;
}
@@ -68,7 +69,7 @@
* Method declared on ASTNode.
*/
void accept0(ASTVisitor visitor) {
- boolean visitChildren = visitor.visit(this);
+ visitor.visit(this);
visitor.endVisit(this);
}
@@ -149,96 +150,22 @@
if (len < 2 || s.charAt(0) != '\"' || s.charAt(len-1) != '\"' ) {
throw new IllegalArgumentException();
}
- StringBuffer b = new StringBuffer(len - 2);
- for (int i = 1; i< len - 1; i++) {
- char c = s.charAt(i);
- if (c == '\"') {
- throw new IllegalArgumentException();
+
+ Scanner scanner = getAST().scanner;
+ char[] source = s.toCharArray();
+ scanner.setSource(source);
+ scanner.resetTo(0, source.length);
+ try {
+ int tokenType = scanner.getNextToken();
+ switch(tokenType) {
+ case Scanner.TokenNameStringLiteral:
+ return new String(scanner.getCurrentTokenSourceString());
+ default:
+ throw new IllegalArgumentException();
}
- if (c == '\\') {
- // legal: b, t, n, f, r, ", ', \, 0, 1, 2, 3, 4, 5, 6, or 7
- char nextChar;
- if ((i + 1) < len - 1) {
- nextChar = s.charAt(i + 1);
- i++;
- switch(nextChar) {
- case 'b' :
- b.append('\b');
- break;
- case 't' :
- b.append('\t');
- break;
- case 'n' :
- b.append('\n');
- break;
- case 'f' :
- b.append('\f');
- break;
- case 'r' :
- b.append('\r');
- break;
- case '\"':
- b.append('\"');
- break;
- case '\'':
- b.append('\'');
- break;
- case '\\':
- b.append('\\');
- break;
- case '0' :
- b.append('\0');
- break;
- case '1' :
- b.append('\1');
- break;
- case '2' :
- b.append('\2');
- break;
- case '3' :
- b.append('\3');
- break;
- case '4' :
- b.append('\4');
- break;
- case '5' :
- b.append('\5');
- break;
- case '6' :
- b.append('\6');
- break;
- case '7' :
- b.append('\7');
- break;
- case 'u' :
- //handle the case of unicode.
- int currentPosition = i + 1;
- int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
- if ((c1 = Character.getNumericValue(s.charAt(currentPosition++))) > 15
- || c1 < 0
- || (c2 = Character.getNumericValue(s.charAt(currentPosition++))) > 15
- || c2 < 0
- || (c3 = Character.getNumericValue(s.charAt(currentPosition++))) > 15
- || c3 < 0
- || (c4 = Character.getNumericValue(s.charAt(currentPosition++))) > 15
- || c4 < 0){
- throw new IllegalArgumentException("Invalid string literal"); //$NON-NLS-1$
- } else {
- b.append((char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4));
- i = currentPosition - 1;
- }
- break;
- default:
- throw new IllegalArgumentException("Invalid string literal");//$NON-NLS-1$
- }
- } else {
- throw new IllegalArgumentException("Invalid string literal");//$NON-NLS-1$
- }
- } else {
- b.append(c);
- }
+ } catch(InvalidInputException e) {
+ throw new IllegalArgumentException();
}
- return b.toString();
}
/**
@@ -346,4 +273,3 @@
return memSize();
}
}
-
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperConstructorInvocation.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperConstructorInvocation.java
index a3ac4f5..a8e4ed2 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperConstructorInvocation.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperConstructorInvocation.java
@@ -1,25 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
import java.util.List;
/**
- * Super constructor invocation expression AST node type.
+ * Super constructor invocation statement AST node type.
*
* <pre>
* SuperConstructorInvocation:
* [ Expression <b>.</b> ] <b>super</b>
- * <b>(</b> [ Expression { <b>,</b> Expression } ] <b>)</b>
+ * <b>(</b> [ Expression { <b>,</b> Expression } ] <b>)</b> <b>;</b>
* </pre>
*
* @since 2.0
@@ -60,7 +60,8 @@
*/
ASTNode clone(AST target) {
SuperConstructorInvocation result = new SuperConstructorInvocation(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setExpression(
(Expression) ASTNode.copySubtree(target, getExpression()));
result.arguments().addAll(ASTNode.copySubtrees(target, arguments()));
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperFieldAccess.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperFieldAccess.java
index 55eb5d7..1959a48 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperFieldAccess.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperFieldAccess.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -19,6 +19,12 @@
* [ ClassName <b>.</b> ] <b>super</b> <b>.</b> Identifier
* </pre>
*
+ * <p>
+ * See <code>FieldAccess</code> for guidelines on handling other expressions
+ * that resemble qualified names.
+ * </p>
+ *
+ * @see FieldAccess
* @since 2.0
*/
public class SuperFieldAccess extends Expression {
@@ -60,6 +66,7 @@
*/
ASTNode clone(AST target) {
SuperFieldAccess result = new SuperFieldAccess(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setName((SimpleName) ASTNode.copySubtree(target, getName()));
result.setQualifier((Name) ASTNode.copySubtree(target, getQualifier()));
return result;
@@ -121,7 +128,10 @@
*/
public SimpleName getName() {
if (fieldName == null) {
+ // lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return fieldName;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperMethodInvocation.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperMethodInvocation.java
index ec4b6d8..1190315 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperMethodInvocation.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SuperMethodInvocation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -67,6 +67,7 @@
*/
ASTNode clone(AST target) {
SuperMethodInvocation result = new SuperMethodInvocation(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setName((SimpleName) getName().clone(target));
result.setQualifier((Name) ASTNode.copySubtree(target, getQualifier()));
result.arguments().addAll(ASTNode.copySubtrees(target, arguments()));
@@ -130,7 +131,9 @@
public SimpleName getName() {
if (methodName == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return methodName;
}
@@ -165,6 +168,22 @@
return arguments;
}
+ /**
+ * Resolves and returns the binding for the method invoked by this
+ * expression.
+ * <p>
+ * Note that bindings are generally unavailable unless requested when the
+ * AST is being built.
+ * </p>
+ *
+ * @return the method binding, or <code>null</code> if the binding cannot
+ * be resolved
+ * @since 2.1
+ */
+ public IMethodBinding resolveMethodBinding() {
+ return getAST().getBindingResolver().resolveMethod(this);
+ }
+
/* (omit javadoc for this method)
* Method declared on ASTNode.
*/
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java
index e6a44d4..df93190 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchCase.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -60,7 +60,8 @@
*/
ASTNode clone(AST target) {
SwitchCase result = new SwitchCase(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setExpression(
(Expression) ASTNode.copySubtree(target, getExpression()));
return result;
@@ -94,7 +95,9 @@
public Expression getExpression() {
if (!expressionInitialized) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return optionalExpression;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchStatement.java
index b49c216..e2a72d6 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SwitchStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -72,7 +72,8 @@
*/
ASTNode clone(AST target) {
SwitchStatement result = new SwitchStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setExpression((Expression) getExpression().clone(target));
result.statements().addAll(ASTNode.copySubtrees(target, statements()));
return result;
@@ -107,7 +108,9 @@
public Expression getExpression() {
if (expression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return expression;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SynchronizedStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SynchronizedStatement.java
index 01741ec..a4148c7 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SynchronizedStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SynchronizedStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -60,7 +60,8 @@
*/
ASTNode clone(AST target) {
SynchronizedStatement result = new SynchronizedStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setExpression((Expression) getExpression().clone(target));
result.setBody((Block) getBody().clone(target));
return result;
@@ -95,7 +96,9 @@
public Expression getExpression() {
if (expression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return expression;
}
@@ -129,7 +132,9 @@
public Block getBody() {
if (body == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setBody(new Block(getAST()));
+ getAST().setModificationCount(count);
}
return body;
}
@@ -170,4 +175,4 @@
+ (expression == null ? 0 : getExpression().treeSize())
+ (body == null ? 0 : getBody().treeSize());
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ThisExpression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ThisExpression.java
index 589605c..2230c83 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ThisExpression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ThisExpression.java
@@ -1,16 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+
/**
* Simple or qualified "this" AST node type.
*
@@ -18,7 +21,12 @@
* ThisExpression:
* [ ClassName <b>.</b> ] <b>this</b>
* </pre>
+ * <p>
+ * See <code>FieldAccess</code> for guidelines on handling other expressions
+ * that resemble qualified names.
+ * </p>
*
+ * @see FieldAccess
* @since 2.0
*/
public class ThisExpression extends Expression {
@@ -50,6 +58,7 @@
*/
ASTNode clone(AST target) {
ThisExpression result = new ThisExpression(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setQualifier((Name) ASTNode.copySubtree(target, getQualifier()));
return result;
}
@@ -116,4 +125,42 @@
memSize()
+ (optionalQualifier == null ? 0 : getQualifier().treeSize());
}
+
+ BlockScope lookupScope() {
+ ASTNode currentNode = this;
+ while(currentNode != null
+ &&!(currentNode instanceof MethodDeclaration)
+ && !(currentNode instanceof Initializer)
+ && !(currentNode instanceof FieldDeclaration)) {
+ currentNode = currentNode.getParent();
+ }
+ if (currentNode == null) {
+ return null;
+ }
+ if (currentNode instanceof Initializer) {
+ Initializer initializer = (Initializer) currentNode;
+ while(!(currentNode instanceof TypeDeclaration)) {
+ currentNode = currentNode.getParent();
+ }
+ org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.getAST().getBindingResolver().getCorrespondingNode(currentNode);
+ if ((initializer.getModifiers() & Modifier.STATIC) != 0) {
+ return typeDecl.staticInitializerScope;
+ } else {
+ return typeDecl.initializerScope;
+ }
+ } else if (currentNode instanceof FieldDeclaration) {
+ FieldDeclaration fieldDeclaration = (FieldDeclaration) currentNode;
+ while(!(currentNode instanceof TypeDeclaration)) {
+ currentNode = currentNode.getParent();
+ }
+ org.eclipse.jdt.internal.compiler.ast.TypeDeclaration typeDecl = (org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) this.getAST().getBindingResolver().getCorrespondingNode(currentNode);
+ if ((fieldDeclaration.getModifiers() & Modifier.STATIC) != 0) {
+ return typeDecl.staticInitializerScope;
+ } else {
+ return typeDecl.initializerScope;
+ }
+ }
+ AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) this.getAST().getBindingResolver().getCorrespondingNode(currentNode);
+ return abstractMethodDeclaration.scope;
+ }
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ThrowStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ThrowStatement.java
index 648e3dc..2d4e5a2 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ThrowStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ThrowStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -55,7 +55,8 @@
*/
ASTNode clone(AST target) {
ThrowStatement result = new ThrowStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setExpression((Expression) getExpression().clone(target));
return result;
}
@@ -87,7 +88,9 @@
public Expression getExpression() {
if (expression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return expression;
}
@@ -128,4 +131,4 @@
memSize()
+ (expression == null ? 0 : getExpression().treeSize());
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java
index c5cbab5..87575fa 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TryStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -72,7 +72,8 @@
*/
ASTNode clone(AST target) {
TryStatement result = new TryStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setBody((Block) getBody().clone(target));
result.catchClauses().addAll(
ASTNode.copySubtrees(target, catchClauses()));
@@ -111,7 +112,9 @@
public Block getBody() {
if (body == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setBody(new Block(getAST()));
+ getAST().setModificationCount(count);
}
return body;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Type.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Type.java
index 889804c..5332f8d 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Type.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/Type.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java
index 68d7637..38a9066 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java
@@ -1,21 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
import org.eclipse.jdt.internal.compiler.lookup.BaseTypes;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* Internal implementation of type bindings.
@@ -30,8 +31,6 @@
private org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding;
private BindingResolver resolver;
- private IVariableBinding[] fields;
- private IMethodBinding[] methods;
public TypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding) {
this.binding = binding;
@@ -42,7 +41,7 @@
* @see ITypeBinding#isPrimitive()
*/
public boolean isPrimitive() {
- return binding.isBaseType();
+ return !isNullType() && binding.isBaseType();
}
/*
@@ -264,7 +263,7 @@
public boolean isLocal() {
if (this.binding.isClass() || this.binding.isInterface()) {
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;
- return referenceBinding.isLocalType();
+ return referenceBinding.isLocalType() && !referenceBinding.isMemberType();
}
return false;
}
@@ -324,9 +323,16 @@
ReferenceBinding referenceBinding = (ReferenceBinding) this.binding;
org.eclipse.jdt.internal.compiler.lookup.MethodBinding[] methods = referenceBinding.methods();
int length = methods.length;
+ int removeSyntheticsCounter = 0;
IMethodBinding[] newMethods = new IMethodBinding[length];
for (int i = 0; i < length; i++) {
- newMethods[i] = this.resolver.getMethodBinding(methods[i]);
+ org.eclipse.jdt.internal.compiler.lookup.MethodBinding methodBinding = methods[i];
+ if (!shouldBeRemoved(methodBinding)) {
+ newMethods[removeSyntheticsCounter++] = this.resolver.getMethodBinding(methodBinding);
+ }
+ }
+ if (removeSyntheticsCounter != length) {
+ System.arraycopy(newMethods, 0, (newMethods = new IMethodBinding[removeSyntheticsCounter]), 0, removeSyntheticsCounter);
}
return newMethods;
} else {
@@ -334,6 +340,10 @@
}
}
+ private boolean shouldBeRemoved(org.eclipse.jdt.internal.compiler.lookup.MethodBinding methodBinding) {
+ return methodBinding.isDefaultAbstract() || methodBinding.isSynthetic() || (methodBinding.isConstructor() && isInterface());
+ }
+
/*
* @see ITypeBinding#isFromSource()
*/
@@ -398,4 +408,58 @@
return this.binding == BaseTypes.NullBinding;
}
+ /**
+ * @see org.eclipse.jdt.core.dom.ITypeBinding#getQualifiedName()
+ */
+ public String getQualifiedName() {
+ if (isAnonymous() || isLocal()) {
+ return NO_NAME;
+ }
+
+ if (isPrimitive() || isNullType()) {
+ return getName();
+ }
+
+ if (isArray()) {
+ ITypeBinding elementType = getElementType();
+ String elementTypeQualifiedName = elementType.getQualifiedName();
+ if (elementTypeQualifiedName.length() != 0) {
+ int dimensions = getDimensions();
+ char[] brackets = new char[dimensions * 2];
+ for (int i = dimensions * 2 - 1; i >= 0; i -= 2) {
+ brackets[i] = ']';
+ brackets[i - 1] = '[';
+ }
+ StringBuffer stringBuffer = new StringBuffer(elementTypeQualifiedName);
+ stringBuffer.append(brackets);
+ return stringBuffer.toString();
+ } else {
+ return NO_NAME;
+ }
+ }
+
+ if (isTopLevel() || isMember()) {
+ PackageBinding packageBinding = this.binding.getPackage();
+
+ if (packageBinding == null || packageBinding.compoundName == CharOperation.NO_CHAR_CHAR) {
+ return new String(this.binding.qualifiedSourceName());
+ } else {
+ StringBuffer stringBuffer = new StringBuffer();
+ stringBuffer
+ .append(this.binding.qualifiedPackageName())
+ .append('.')
+ .append(this.binding.qualifiedSourceName());
+ return stringBuffer.toString();
+ }
+ }
+ return NO_NAME;
+ }
+
+ /*
+ * For debugging purpose only.
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return this.binding.toString();
+ }
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclaration.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclaration.java
index c84b686..1eb603c 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclaration.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -124,6 +124,7 @@
*/
ASTNode clone(AST target) {
TypeDeclaration result = new TypeDeclaration(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setModifiers(getModifiers());
result.setJavadoc(
(Javadoc) ASTNode.copySubtree(target,(ASTNode) getJavadoc()));
@@ -230,7 +231,9 @@
public SimpleName getName() {
if (typeName == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return typeName;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclarationStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclarationStatement.java
index b8383ff..4b05f59 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclarationStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeDeclarationStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -60,7 +60,8 @@
ASTNode clone(AST target) {
TypeDeclarationStatement result =
new TypeDeclarationStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setTypeDeclaration(
(TypeDeclaration) getTypeDeclaration().clone(target));
return result;
@@ -94,7 +95,9 @@
public TypeDeclaration getTypeDeclaration() {
if (typeDecl == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setTypeDeclaration(new TypeDeclaration(getAST()));
+ getAST().setModificationCount(count);
}
return typeDecl;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeLiteral.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeLiteral.java
index 6fc6b0a..3cf6395 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeLiteral.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeLiteral.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -54,6 +54,7 @@
*/
ASTNode clone(AST target) {
TypeLiteral result = new TypeLiteral(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setType((Type) getType().clone(target));
return result;
}
@@ -85,7 +86,9 @@
public Type getType() {
if (type == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setType(getAST().newPrimitiveType(PrimitiveType.INT));
+ getAST().setModificationCount(count);
}
return type;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java
index b0bbd0f..fe87e31 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java
@@ -1,16 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
+import org.eclipse.jdt.core.util.IModifierConstants;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
/**
@@ -85,6 +86,9 @@
if (isField()) {
return ((FieldBinding) this.binding).getAccessFlags();
}
+ if (binding.isFinal()) {
+ return IModifierConstants.ACC_FINAL;
+ }
return 0;
}
@@ -130,4 +134,11 @@
return this.binding.id;
}
+ /*
+ * For debugging purpose only.
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return this.binding.toString();
+ }
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclaration.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclaration.java
index 6e7380e..8d06364 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclaration.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -61,6 +61,42 @@
public abstract void setName(SimpleName variableName);
/**
+ * Returns the number of extra array dimensions over and above the
+ * explicitly-specified type.
+ * <p>
+ * For example, <code>int x[][]</code> has a type of
+ * <code>int</code> and two extra array dimensions;
+ * <code>int[][] x</code> has a type of <code>int[][]</code>
+ * and zero extra array dimensions. The two constructs have different
+ * ASTs, even though there are really syntactic variants of the same
+ * variable declaration.
+ * </p>
+ *
+ * @return the number of extra array dimensions
+ * @since 2.1
+ */
+ public abstract int getExtraDimensions();
+
+ /**
+ * Sets the number of extra array dimensions over and above the
+ * explicitly-specified type.
+ * <p>
+ * For example, <code>int x[][]</code> has a type of
+ * <code>int</code> and two extra array dimensions;
+ * <code>int[][] x</code> has a type of <code>int[][]</code>
+ * and zero extra array dimensions. The two constructs have different
+ * ASTs, even though there are really syntactic variants of the same
+ * variable declaration.
+ * </p>
+ *
+ * @param dimensions the number of array dimensions
+ * @exception IllegalArgumentException if the number of dimensions is
+ * negative
+ * @since 2.1
+ */
+ public abstract void setExtraDimensions(int dimensions);
+
+ /**
* Returns the initializer of this variable declaration, or
* <code>null</code> if there is none.
*
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationExpression.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationExpression.java
index 03d01a9..d5d745b 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationExpression.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -84,6 +84,7 @@
ASTNode clone(AST target) {
VariableDeclarationExpression result =
new VariableDeclarationExpression(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setModifiers(getModifiers());
result.setType((Type) getType().clone(target));
result.fragments().addAll(
@@ -159,7 +160,9 @@
public Type getType() {
if (baseType == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setType(getAST().newPrimitiveType(PrimitiveType.INT));
+ getAST().setModificationCount(count);
}
return baseType;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationFragment.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationFragment.java
index 8d5b4c9..00c3966 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationFragment.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationFragment.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -34,7 +34,7 @@
private SimpleName variableName = null;
/**
- * The number of extra array dimensions that this variable;
+ * The number of extra array dimensions that this variable has;
* defaults to 0.
*/
private int extraArrayDimensions = 0;
@@ -71,6 +71,7 @@
*/
ASTNode clone(AST target) {
VariableDeclarationFragment result = new VariableDeclarationFragment(target);
+ result.setSourceRange(this.getStartPosition(), this.getLength());
result.setName((SimpleName) getName().clone(target));
result.setExtraDimensions(getExtraDimensions());
result.setInitializer(
@@ -105,7 +106,9 @@
public SimpleName getName() {
if (variableName == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setName(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return variableName;
}
@@ -131,7 +134,7 @@
* dimensions, respectively.
* </p>
*
- * @return the number of extra array dimensions
+ * @since 2.0
*/
public int getExtraDimensions() {
return extraArrayDimensions;
@@ -140,10 +143,14 @@
/**
* Sets the number of extra array dimensions this variable has over
* and above the type specified in the enclosing declaration.
+ * <p>
+ * For example, in the AST for <code>int[] i, j[], k[][]</code> the
+ * variable declaration fragments for the variables <code>i</code>,
+ * <code>j</code>, and <code>k</code>, have 0, 1, and 2 extra array
+ * dimensions, respectively.
+ * </p>
*
- * @return the number of extra array dimensions
- * @see Modifier
- * @exception IllegalArgumentException if the number of dimensions is negative
+ * @since 2.0
*/
public void setExtraDimensions(int dimensions) {
if (dimensions < 0) {
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationStatement.java
index a9d5b8c..da00c07 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableDeclarationStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -82,7 +82,8 @@
ASTNode clone(AST target) {
VariableDeclarationStatement result =
new VariableDeclarationStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setModifiers(getModifiers());
result.setType((Type) getType().clone(target));
result.fragments().addAll(
@@ -157,7 +158,9 @@
public Type getType() {
if (baseType == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setType(getAST().newPrimitiveType(PrimitiveType.INT));
+ getAST().setModificationCount(count);
}
return baseType;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/WhileStatement.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/WhileStatement.java
index 67e8e1f..c6ecb02 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/WhileStatement.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/WhileStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.dom;
@@ -61,7 +61,8 @@
*/
ASTNode clone(AST target) {
WhileStatement result = new WhileStatement(target);
- result.setLeadingComment(getLeadingComment());
+ result.setSourceRange(this.getStartPosition(), this.getLength());
+ result.copyLeadingComment(this);
result.setExpression((Expression) getExpression().clone(target));
result.setBody((Statement) getBody().clone(target));
return result;
@@ -96,7 +97,9 @@
public Expression getExpression() {
if (expression == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setExpression(new SimpleName(getAST()));
+ getAST().setModificationCount(count);
}
return expression;
}
@@ -129,7 +132,9 @@
public Statement getBody() {
if (body == null) {
// lazy initialize - use setter to ensure parent link set too
+ long count = getAST().modificationCount();
setBody(new Block(getAST()));
+ getAST().setModificationCount(count);
}
return body;
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/package.html b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/package.html
index bc086db..b5d3f68 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/package.html
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/package.html
@@ -7,13 +7,17 @@
<title>Package-level Javadoc</title>
</head>
<body>
-The Java DOM is the set of classes that model Java program as a structured document.
+The Java DOM is the set of classes that model the source code of a Java program
+as a structured document.
<h2>
Package Specification</h2>
-<p><br>This package contains the Java DOM classes. An API for manipulating a Java program
-as a structured document. In particular, it provides a full abstract syntax tree, which
-can be queried for resolved type information, and modified.
+<p><br>This package contains the Java DOM classes. An API for manipulating the
+source code of a Java program as a structured document. In particular, it provides
+a full abstract syntax tree for a Java compilation unit, which can be queried for
+resolved type information, and modified.
+The principal classes are {@link org.eclipse.jdt.core.dom.AST AST}
+and {@link org.eclipse.jdt.core.dom.ASTNode ASTNode}.
</body>
</html>
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java
index 5cc334f..e8b8113 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
@@ -46,13 +46,13 @@
// better highlight for allocation: display the type individually
codeStream.recordPositionsFrom(pc, type.sourceStart);
- // handling innerclass instance allocation
+ // handling innerclass instance allocation - enclosing instance arguments
if (allocatedType.isNestedType()) {
- codeStream.generateSyntheticArgumentValues(
- currentScope,
- allocatedType,
- enclosingInstance(),
- this);
+ codeStream.generateSyntheticEnclosingInstanceValues(
+ currentScope,
+ allocatedType,
+ enclosingInstance(),
+ this);
}
// generate the arguments for constructor
if (arguments != null) {
@@ -60,6 +60,13 @@
arguments[i].generateCode(currentScope, codeStream, true);
}
}
+ // handling innerclass instance allocation - outer local arguments
+ if (allocatedType.isNestedType()) {
+ codeStream.generateSyntheticOuterArgumentValues(
+ currentScope,
+ allocatedType,
+ this);
+ }
// invoke constructor
codeStream.invokespecial(binding);
} else {
@@ -107,7 +114,7 @@
public TypeBinding resolveType(BlockScope scope) {
// Propagate the type checking to the arguments, and check if the constructor is defined.
constant = NotAConstant;
- TypeBinding typeBinding = type.resolveType(scope); // will check for null after args are resolved
+ this.resolvedType = type.resolveType(scope); // will check for null after args are resolved
// buffering the arguments' types
TypeBinding[] argumentTypes = NoParameters;
@@ -119,16 +126,16 @@
if ((argumentTypes[i] = arguments[i].resolveType(scope)) == null)
argHasError = true;
if (argHasError)
- return typeBinding;
+ return this.resolvedType;
}
- if (typeBinding == null)
+ if (this.resolvedType == null)
return null;
- if (!typeBinding.canBeInstantiated()) {
- scope.problemReporter().cannotInstantiate(type, typeBinding);
- return typeBinding;
+ if (!this.resolvedType.canBeInstantiated()) {
+ scope.problemReporter().cannotInstantiate(type, this.resolvedType);
+ return this.resolvedType;
}
- ReferenceBinding allocatedType = (ReferenceBinding) typeBinding;
+ ReferenceBinding allocatedType = (ReferenceBinding) this.resolvedType;
if (!(binding = scope.getConstructor(allocatedType, argumentTypes, this)).isValidBinding()) {
if (binding instanceof ProblemMethodBinding
&& ((ProblemMethodBinding) binding).problemId() == NotVisible) {
@@ -138,13 +145,13 @@
if (binding.declaringClass == null)
binding.declaringClass = allocatedType;
scope.problemReporter().invalidConstructor(this, binding);
- return typeBinding;
+ return this.resolvedType;
}
} else {
if (binding.declaringClass == null)
binding.declaringClass = allocatedType;
scope.problemReporter().invalidConstructor(this, binding);
- return typeBinding;
+ return this.resolvedType;
}
CodeSnippetScope localScope = new CodeSnippetScope(scope);
MethodBinding privateBinding = localScope.getConstructor((ReferenceBinding)delegateThis.type, argumentTypes, this);
@@ -152,7 +159,7 @@
if (binding.declaringClass == null)
binding.declaringClass = allocatedType;
scope.problemReporter().invalidConstructor(this, binding);
- return typeBinding;
+ return this.resolvedType;
} else {
binding = privateBinding;
}
@@ -160,7 +167,7 @@
if (binding.declaringClass == null)
binding.declaringClass = allocatedType;
scope.problemReporter().invalidConstructor(this, binding);
- return typeBinding;
+ return this.resolvedType;
}
}
if (isMethodUseDeprecated(binding, scope))
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetClassFile.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetClassFile.java
index 85e9cb9..1c4b316 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetClassFile.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetClassFile.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.core.compiler.IProblem;
@@ -18,7 +18,6 @@
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
@@ -86,16 +85,6 @@
accessFlags &= ~AccStrictfp;
this.enclosingClassFile = enclosingClassFile;
- // innerclasses get their names computed at code gen time
- if (aType.isLocalType()) {
- ((LocalTypeBinding) aType).constantPoolName(
- computeConstantPoolName((LocalTypeBinding) aType));
- ReferenceBinding[] memberTypes = aType.memberTypes();
- for (int i = 0, max = memberTypes.length; i < max; i++) {
- ((LocalTypeBinding) memberTypes[i]).constantPoolName(
- computeConstantPoolName((LocalTypeBinding) memberTypes[i]));
- }
- }
contents = new byte[INITIAL_CONTENTS_SIZE];
// now we continue to generate the bytes inside the contents array
contents[contentsOffset++] = (byte) (accessFlags >> 8);
@@ -162,7 +151,7 @@
if ((fields != null) && (fields != NoFields)) {
for (int i = 0, max = fields.length; i < max; i++) {
if (fields[i].constant == null) {
- FieldReference.getConstantFor(fields[i], false, null, null, 0);
+ FieldReference.getConstantFor(fields[i], null, false, null);
}
}
classFile.addFieldInfos();
@@ -178,7 +167,7 @@
AbstractMethodDeclaration[] methodDeclarations = typeDeclaration.methods;
int maxMethodDecl = methodDeclarations == null ? 0 : methodDeclarations.length;
int problemsLength;
- IProblem[] problems = unitResult.getProblems();
+ IProblem[] problems = unitResult.getErrors();
if (problems == null) {
problems = new IProblem[0];
}
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCodeStream.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCodeStream.java
index 2c055bf..c96723f 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCodeStream.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCodeStream.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCompiler.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCompiler.java
index 44107aa..72cafcc 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCompiler.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetCompiler.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import java.util.Map;
@@ -17,26 +17,34 @@
import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
import org.eclipse.jdt.internal.compiler.IProblemFactory;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
/**
* A compiler that compiles code snippets.
*/
public class CodeSnippetCompiler extends Compiler {
-/**
- * Creates a new code snippet compiler initialized with a code snippet parser.
- */
-public CodeSnippetCompiler(
- INameEnvironment environment,
- IErrorHandlingPolicy policy,
- Map settings,
- ICompilerRequestor requestor,
+ /**
+ * Creates a new code snippet compiler initialized with a code snippet parser.
+ */
+ public CodeSnippetCompiler(
+ INameEnvironment environment,
+ IErrorHandlingPolicy policy,
+ Map settings,
+ ICompilerRequestor requestor,
IProblemFactory problemFactory,
EvaluationContext evaluationContext,
int codeSnippetStart,
int codeSnippetEnd) {
- super(environment, policy, settings, requestor, problemFactory);
- this.parser =
- new CodeSnippetParser(problemReporter, evaluationContext, this.options.parseLiteralExpressionsAsConstants, this.options.assertMode, codeSnippetStart, codeSnippetEnd);
- this.parseThreshold = 1; // fully parse only the code snippet compilation unit
-}
+ super(environment, policy, settings, requestor, problemFactory);
+ this.parser =
+ new CodeSnippetParser(
+ problemReporter,
+ evaluationContext,
+ this.options.parseLiteralExpressionsAsConstants,
+ this.options.sourceLevel >= CompilerOptions.JDK1_4,
+ codeSnippetStart,
+ codeSnippetEnd);
+ this.parseThreshold = 1;
+ // fully parse only the code snippet compilation unit
+ }
}
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetConstantPool.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetConstantPool.java
index 2a9183d..eda210c 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetConstantPool.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetConstantPool.java
@@ -1,22 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.codegen.ConstantPool;
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* This constant pool is used to manage well known methods and fields related specifically to the
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java
index 11619a8..cf134a0 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEnvironment.java
@@ -1,22 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* An environment that wraps the client's name environment.
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java
index 62ac4f6..2050d71 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetEvaluator.java
@@ -1,17 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import java.util.Map;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.Compiler;
@@ -22,7 +23,6 @@
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* A code snippet evaluator compiles and returns class file for a code snippet.
@@ -104,7 +104,7 @@
* @see org.eclipse.jdt.internal.eval.Evaluator
*/
protected char[] getClassName() {
- return CharOperation.concat(CODE_SNIPPET_CLASS_NAME_PREFIX, Integer.toString(this.context.CODE_SNIPPET_COUNTER + 1).toCharArray());
+ return CharOperation.concat(CODE_SNIPPET_CLASS_NAME_PREFIX, Integer.toString(EvaluationContext.CODE_SNIPPET_COUNTER + 1).toCharArray());
}
/**
* @see Evaluator.
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java
index 208833a..bf9179e 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.internal.compiler.ast.Assignment;
@@ -15,7 +15,6 @@
import org.eclipse.jdt.internal.compiler.ast.Expression;
import org.eclipse.jdt.internal.compiler.ast.FieldReference;
import org.eclipse.jdt.internal.compiler.ast.IntLiteral;
-import org.eclipse.jdt.internal.compiler.ast.ThisReference;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
@@ -72,6 +71,7 @@
* @param valueRequired boolean
*/
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
+
int pc = codeStream.position;
if (constant != NotAConstant) {
if (valueRequired) {
@@ -79,7 +79,7 @@
}
} else {
boolean isStatic = this.codegenBinding.isStatic();
- receiver.generateCode(currentScope, codeStream, valueRequired && (!isStatic) && (this.codegenBinding.constant == NotAConstant));
+ receiver.generateCode(currentScope, codeStream, !isStatic);
if (valueRequired) {
if (this.codegenBinding.constant == NotAConstant) {
if (this.codegenBinding.declaringClass == null) { // array length
@@ -101,12 +101,22 @@
}
codeStream.generateImplicitConversion(implicitConversion);
} else {
+ if (!isStatic) {
+ codeStream.invokeObjectGetClass(); // perform null check
+ codeStream.pop();
+ }
codeStream.generateConstant(this.codegenBinding.constant, implicitConversion);
}
+ } else {
+ if (!isStatic){
+ codeStream.invokeObjectGetClass(); // perform null check
+ codeStream.pop();
+ }
}
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
+
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
boolean isStatic;
@@ -274,12 +284,12 @@
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, field's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
if (binding.declaringClass != this.receiverType
&& !this.receiverType.isArrayType()
&& binding.declaringClass != null // array.length
&& binding.constant == NotAConstant
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
&& binding.declaringClass.id != T_Object) //no change for Object fields (in case there was)
|| !binding.declaringClass.canBeSeenBy(currentScope))){
this.codegenBinding = currentScope.enclosingSourceType().getUpdatedFieldBinding(binding, (ReferenceBinding) this.receiverType);
@@ -293,12 +303,12 @@
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, field's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
if (binding.declaringClass != this.receiverType
&& !this.receiverType.isArrayType()
&& binding.declaringClass != null // array.length
&& binding.constant == NotAConstant
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
&& binding.declaringClass.id != T_Object) //no change for Object fields (in case there was)
|| !binding.declaringClass.canBeSeenBy(currentScope))){
this.codegenBinding = currentScope.enclosingSourceType().getUpdatedFieldBinding(binding, (ReferenceBinding) this.receiverType);
@@ -353,10 +363,10 @@
scope.problemReporter().deprecatedField(binding, this);
// check for this.x in static is done in the resolution of the receiver
- constant = FieldReference.getConstantFor(binding, receiver == ThisReference.ThisImplicit, this, scope, 0);
+ constant = FieldReference.getConstantFor(binding, this, receiver.isImplicitThis(), scope);
if (!receiver.isThis())
constant = NotAConstant;
- return binding.type;
+ return this.resolvedType = binding.type;
}
}
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java
index aab4a87..cd901bf 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java
@@ -1,18 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.NameReference;
-import org.eclipse.jdt.internal.compiler.ast.ThisReference;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
@@ -54,15 +53,13 @@
// outer access ?
if (!isStatic && ((bits & DepthMASK) != 0)) {
// outer method can be reached through emulation
- Object[] path =
- currentScope.getExactEmulationPath(
- currentScope.enclosingSourceType().enclosingTypeAt(
- (bits & DepthMASK) >> DepthSHIFT));
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] path = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
if (path == null) {
// emulation was not possible (should not happen per construction)
currentScope.problemReporter().needImplementation();
} else {
- codeStream.generateOuterAccess(path, this, currentScope);
+ codeStream.generateOuterAccess(path, this, targetType, currentScope);
}
} else {
receiver.generateCode(currentScope, codeStream, !isStatic);
@@ -164,12 +161,12 @@
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, method's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, method's declaring class is touched if any different from receiver type
// and not from Object or implicit static method call.
if (binding.declaringClass != this.qualifyingType
&& !this.qualifyingType.isArrayType()
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
- && (receiver != ThisReference.ThisImplicit || !binding.isStatic())
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
+ && (!receiver.isImplicitThis() || !binding.isStatic())
&& binding.declaringClass.id != T_Object) // no change for Object methods
|| !binding.declaringClass.canBeSeenBy(currentScope))) {
codegenBinding = currentScope.enclosingSourceType().getUpdatedMethodBinding(binding, (ReferenceBinding) this.qualifyingType);
@@ -203,7 +200,7 @@
}
binding =
- receiver == ThisReference.ThisImplicit
+ receiver.isImplicitThis()
? scope.getImplicitMethod(selector, argumentTypes, this)
: scope.getMethod(receiverType, selector, argumentTypes, this);
if (!binding.isValidBinding()) {
@@ -277,6 +274,6 @@
if (isMethodUseDeprecated(binding, scope))
scope.problemReporter().deprecatedMethod(binding, this);
- return binding.returnType;
+ return this.resolvedType = binding.returnType;
}
}
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
index 0978e1d..373a4e8 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
@@ -1,21 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
-import org.eclipse.jdt.core.compiler.*;
-import org.eclipse.jdt.internal.compiler.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.*;
-import org.eclipse.jdt.internal.compiler.parser.*;
-import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.*;
+import org.eclipse.jdt.internal.compiler.parser.Parser;
+import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
+import org.eclipse.jdt.internal.compiler.util.Util;
/**
* A parser for code snippets.
@@ -79,8 +80,8 @@
astPtr--;
astLengthPtr--;
- // mark fields and initializer with local type mark if needed
- markFieldsWithLocalType(anonymousTypeDeclaration);
+ // mark initializers with local type mark if needed
+ markInitializersWithLocalType(anonymousTypeDeclaration);
}
}
protected void consumeClassDeclaration() {
@@ -100,7 +101,7 @@
} else {
// Record that the block has a declaration for local types
typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult);
- markCurrentMethodWithLocalType();
+ markEnclosingMemberWithLocalType();
blockReal();
}
@@ -178,7 +179,7 @@
} else {
// Record that the block has a declaration for local types
typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult);
- markCurrentMethodWithLocalType();
+ markEnclosingMemberWithLocalType();
blockReal();
}
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java
index 6702911..f632b71 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.internal.compiler.ast.Assignment;
@@ -56,7 +56,8 @@
return getOtherFieldBindings(scope);
}
public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) {
- generateReadSequence(currentScope, codeStream, true);
+
+ generateReadSequence(currentScope, codeStream);
if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
// the last field access is a write access
assignment.expression.generateCode(currentScope, codeStream, true);
@@ -85,13 +86,17 @@
codeStream.generateConstant(constant, implicitConversion);
}
} else {
- generateReadSequence(currentScope, codeStream, valueRequired);
+ generateReadSequence(currentScope, codeStream);
if (valueRequired) {
if (lastFieldBinding.declaringClass == null) { // array length
codeStream.arraylength();
codeStream.generateImplicitConversion(implicitConversion);
} else {
if (lastFieldBinding.constant != NotAConstant) {
+ if (!lastFieldBinding.isStatic()){
+ codeStream.invokeObjectGetClass();
+ codeStream.pop();
+ }
// inline the last field constant
codeStream.generateConstant(lastFieldBinding.constant, implicitConversion);
} else {
@@ -107,13 +112,18 @@
codeStream.generateImplicitConversion(implicitConversion);
}
}
- }
+ } else {
+ if (lastFieldBinding != null && !lastFieldBinding.isStatic()){
+ codeStream.invokeObjectGetClass(); // perform null check
+ codeStream.pop();
+ }
+ }
}
codeStream.recordPositionsFrom(pc, this.sourceStart);
}
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
- generateReadSequence(currentScope, codeStream, true);
+ generateReadSequence(currentScope, codeStream);
if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
if (lastFieldBinding.isStatic()){
codeStream.getstatic(lastFieldBinding);
@@ -193,7 +203,7 @@
}
}
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
- generateReadSequence(currentScope, codeStream, true);
+ generateReadSequence(currentScope, codeStream);
if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
if (lastFieldBinding.isStatic()){
@@ -239,7 +249,7 @@
if (lastFieldBinding.isStatic()) {
codeStream.aconst_null();
} else {
- generateReadSequence(currentScope, codeStream, true);
+ generateReadSequence(currentScope, codeStream);
}
codeStream.dup_x2();
codeStream.pop();
@@ -249,7 +259,7 @@
if (lastFieldBinding.isStatic()) {
codeStream.aconst_null();
} else {
- generateReadSequence(currentScope, codeStream, true);
+ generateReadSequence(currentScope, codeStream);
}
codeStream.dup_x1();
codeStream.pop();
@@ -264,41 +274,29 @@
* Generate code for all bindings (local and fields) excluding the last one, which may then be generated code
* for a read or write access.
*/
-public void generateReadSequence(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
-
+public void generateReadSequence(BlockScope currentScope, CodeStream codeStream) {
// determine the rank until which we now we do not need any actual value for the field access
int otherBindingsCount = this.otherCodegenBindings == null ? 0 : otherCodegenBindings.length;
- int indexOfFirstValueRequired;
- if (valueRequired) {
- indexOfFirstValueRequired = otherBindingsCount;
- while (indexOfFirstValueRequired > 0) {
- FieldBinding otherBinding = this.otherCodegenBindings[indexOfFirstValueRequired - 1];
- if (otherBinding.isStatic() || otherBinding.constant != NotAConstant)
- break; // no longer need any value before this point
- indexOfFirstValueRequired--;
- }
- } else {
- indexOfFirstValueRequired = otherBindingsCount + 1;
- }
- if (indexOfFirstValueRequired == 0) {
- switch (bits & RestrictiveFlagMASK) {
- case FIELD :
- lastFieldBinding = (FieldBinding) binding;
- // if first field is actually constant, we can inline it
- if (lastFieldBinding.constant != NotAConstant) {
- codeStream.generateConstant(lastFieldBinding.constant, 0); // no implicit conversion
- lastFieldBinding = null; // will not generate it again
- break;
- }
+
+ boolean needValue = otherBindingsCount == 0 || !this.otherBindings[0].isStatic();
+ switch (bits & RestrictiveFlagMASK) {
+ case FIELD :
+ lastFieldBinding = (FieldBinding) this.codegenBinding;
+ // if first field is actually constant, we can inline it
+ if (lastFieldBinding.constant != NotAConstant) {
+ break;
+ }
+ if (needValue) {
if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
if (!lastFieldBinding.isStatic()) {
if ((bits & DepthMASK) != 0) {
- Object[] emulationPath = currentScope.getExactEmulationPath(currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT));
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
if (emulationPath == null) {
// internal error, per construction we should have found it
currentScope.problemReporter().needImplementation();
} else {
- codeStream.generateOuterAccess(emulationPath, this, currentScope);
+ codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
}
} else {
generateReceiver(codeStream);
@@ -316,59 +314,74 @@
} else {
codeStream.aconst_null();
}
- }
- break;
- case LOCAL : // reading the first local variable
- lastFieldBinding = null;
- LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding;
-
- // regular local variable read
- if (localBinding.constant != NotAConstant) {
- codeStream.generateConstant(localBinding.constant, 0); // no implicit conversion
- } else {
- // outer local?
- if ((bits & DepthMASK) != 0) {
- // outer local can be reached either through a synthetic arg or a synthetic field
- VariableBinding[] path = currentScope.getEmulationPath(localBinding);
- if (path == null) {
- // emulation was not possible (should not happen per construction)
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(path, this, currentScope);
- }
+ }
+ }
+ break;
+ case LOCAL : // reading the first local variable
+ if (!needValue) break; // no value needed
+ lastFieldBinding = null;
+ LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding;
+ // regular local variable read
+ if (localBinding.constant != NotAConstant) {
+ codeStream.generateConstant(localBinding.constant, 0);
+ // no implicit conversion
+ } else {
+ // outer local?
+ if ((bits & DepthMASK) != 0) {
+ // outer local can be reached either through a synthetic arg or a synthetic field
+ VariableBinding[] path = currentScope.getEmulationPath(localBinding);
+ if (path == null) {
+ // emulation was not possible (should not happen per construction)
+ currentScope.problemReporter().needImplementation();
} else {
- codeStream.load(localBinding);
+ codeStream.generateOuterAccess(path, this, localBinding, currentScope);
}
- }
- }
- } else {
- lastFieldBinding = null;
- }
- // all intermediate field accesses are read accesses
- // only the last field binding is a write access
- if (otherBindings != null) {
- int start = indexOfFirstValueRequired == 0 ? 0 : indexOfFirstValueRequired - 1;
- for (int i = start; i < otherBindingsCount; i++) {
- if (lastFieldBinding != null) {
- if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
- if (lastFieldBinding.isStatic())
- codeStream.getstatic(lastFieldBinding);
- else
- codeStream.getfield(lastFieldBinding);
} else {
- ((CodeSnippetCodeStream) codeStream).generateEmulatedReadAccessForField(lastFieldBinding);
+ codeStream.load(localBinding);
}
}
+ }
- lastFieldBinding = this.otherCodegenBindings[i];
+ // all intermediate field accesses are read accesses
+ // only the last field binding is a write access
+ if (this.otherCodegenBindings != null) {
+ for (int i = 0; i < otherBindingsCount; i++) {
+ FieldBinding nextField = this.otherCodegenBindings[i];
+ if (lastFieldBinding != null) {
+ needValue = !nextField.isStatic();
+ if (needValue) {
+ if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
+ if (lastFieldBinding.constant != NotAConstant) {
+ if (this.lastFieldBinding != this.codegenBinding && !this.lastFieldBinding.isStatic()) {
+ codeStream.invokeObjectGetClass(); // perform null check
+ codeStream.pop();
+ }
+ codeStream.generateConstant(lastFieldBinding.constant, 0);
+ } else if (lastFieldBinding.isStatic()) {
+ codeStream.getstatic(lastFieldBinding);
+ } else {
+ codeStream.getfield(lastFieldBinding);
+ }
+ } else {
+ ((CodeSnippetCodeStream) codeStream).generateEmulatedReadAccessForField(lastFieldBinding);
+ }
+ } else {
+ if (this.codegenBinding != this.lastFieldBinding && !this.lastFieldBinding.isStatic()){
+ codeStream.invokeObjectGetClass(); // perform null check
+ codeStream.pop();
+ }
+ }
+ }
+ this.lastFieldBinding = nextField;
if (lastFieldBinding != null && !lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
if (lastFieldBinding.isStatic()) {
codeStream.aconst_null();
}
}
- }
+ }
}
}
+
public void generateReceiver(CodeStream codeStream) {
codeStream.aload_0();
if (delegateThis != null) codeStream.getfield(delegateThis); // delegated field access
@@ -397,7 +410,7 @@
int index = indexOfFirstFieldBinding;
int length = tokens.length;
if (index == length) { // restrictiveFlag == FIELD
- constant = FieldReference.getConstantFor((FieldBinding) binding, false, this, scope, index - 1);
+ constant = FieldReference.getConstantFor((FieldBinding) binding, this, false, scope);
return type;
}
@@ -408,7 +421,7 @@
// fill the first constant (the one of the binding)
constant =
((bits & FIELD) != 0)
- ? FieldReference.getConstantFor((FieldBinding) binding, false, this, scope, index - 1)
+ ? FieldReference.getConstantFor((FieldBinding) binding, this, false, scope)
: ((VariableBinding) binding).constant;
// iteration on each field
@@ -428,7 +441,9 @@
return super.reportError(scope);
}
} else {
- return super.reportError(scope);
+ constant = NotAConstant; //don't fill other constants slots...
+ scope.problemReporter().invalidField(this, field, index, type);
+ return null;
}
}
field = localScope.getFieldForCodeSnippet(delegateThis.type, token, this);
@@ -437,7 +452,7 @@
if (field.isValidBinding()) {
if (isFieldUseDeprecated(field, scope))
scope.problemReporter().deprecatedField(field, this);
- Constant someConstant = FieldReference.getConstantFor(field, false, this, scope, place);
+ Constant someConstant = FieldReference.getConstantFor(field, this, false, scope);
// constant propagation can only be performed as long as the previous one is a constant too.
if (constant != NotAConstant){
constant = someConstant;
@@ -476,7 +491,7 @@
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, field's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
boolean useDelegate = index == 0 && this.delegateThis != null;
if (useDelegate) lastReceiverType = this.delegateThis.type;
@@ -484,7 +499,7 @@
&& !lastReceiverType.isArrayType()
&& fieldBinding.declaringClass != null
&& fieldBinding.constant == NotAConstant
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
&& (index > 0 || indexOfFirstFieldBinding > 1 || !fieldBinding.isStatic())
&& fieldBinding.declaringClass.id != T_Object)
|| !(useDelegate
@@ -511,7 +526,7 @@
// if the binding declaring class is not visible, need special action
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
- // NOTE: from 1.4 on, field's declaring class is touched if any different from receiver type
+ // NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type
boolean useDelegate = fieldBinding == binding && this.delegateThis != null;
if (useDelegate) lastReceiverType = this.delegateThis.type;
@@ -519,7 +534,7 @@
&& !lastReceiverType.isArrayType()
&& fieldBinding.declaringClass != null
&& fieldBinding.constant == NotAConstant
- && ((currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4
+ && ((currentScope.environment().options.targetJDK >= CompilerOptions.JDK1_2
&& (fieldBinding != binding || indexOfFirstFieldBinding > 1 || !fieldBinding.isStatic())
&& fieldBinding.declaringClass.id != T_Object)
|| !(useDelegate
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java
index e44b625..ec9d7fb 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.internal.compiler.ast.Expression;
@@ -45,12 +45,12 @@
* Dump the suitable return bytecode for a return statement
*
*/
-public void generateReturnBytecode(BlockScope currentScope, CodeStream codeStream) {
+public void generateReturnBytecode(CodeStream codeStream) {
// output the return bytecode
codeStream.return_();
}
-public void generateStoreSaveValueIfNecessary(BlockScope currentScope, CodeStream codeStream){
+public void generateStoreSaveValueIfNecessary(CodeStream codeStream){
// push receiver
codeStream.aload_0();
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java
index ce11126..c5703ec 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
@@ -27,7 +28,6 @@
import org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.VariableBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
/**
@@ -266,6 +266,11 @@
if (receiverType.isBaseType())
return null;
if (receiverType.isArrayType()) {
+ TypeBinding leafType = receiverType.leafComponentType();
+ if (leafType instanceof ReferenceBinding)
+ if (!((ReferenceBinding)leafType).canBeSeenBy(this)) {
+ return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ReceiverTypeNotVisible);
+ }
if (CharOperation.equals(fieldName, LENGTH))
return ArrayBinding.LengthField;
return null;
@@ -273,7 +278,7 @@
ReferenceBinding currentType = (ReferenceBinding) receiverType;
if (!currentType.canBeSeenBy(this))
- return new ProblemFieldBinding(currentType, fieldName, NotVisible); // *** Need a new problem id - TypeNotVisible?
+ return new ProblemFieldBinding(currentType, fieldName, ReceiverTypeNotVisible);
FieldBinding field = currentType.getField(fieldName);
if (field != null) {
@@ -465,7 +470,7 @@
if (interfaceMethod != null) return interfaceMethod;
return new ProblemMethodBinding(
candidates[0].selector,
- argumentTypes,
+ candidates[0].parameters,
candidates[0].declaringClass,
NotVisible);
}
@@ -496,7 +501,7 @@
if (!areParametersAssignable(methodBinding.parameters, argumentTypes))
return new ProblemMethodBinding(methodBinding, selector, argumentTypes, NotFound);
if (!canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
- return new ProblemMethodBinding(selector, argumentTypes, methodBinding.declaringClass, NotVisible);
+ return new ProblemMethodBinding(selector, methodBinding.parameters, methodBinding.declaringClass, NotVisible);
}
return methodBinding;
}
@@ -633,7 +638,7 @@
if (visibleIndex == 1)
return visible[0];
if (visibleIndex == 0)
- return new ProblemMethodBinding(ConstructorDeclaration.ConstantPoolName, argumentTypes, NotVisible);
+ return new ProblemMethodBinding(ConstructorDeclaration.ConstantPoolName, compatible[0].parameters, NotVisible);
return mostSpecificClassMethodBinding(visible, visibleIndex);
}
/* API
@@ -697,7 +702,7 @@
return methodBinding;
else
// make the user qualify the method, likely wants the first inherited method (javac generates an ambiguous error instead)
- return new ProblemMethodBinding(selector, argumentTypes, InheritedNameHidesEnclosingName);
+ return new ProblemMethodBinding(selector, methodBinding.parameters, InheritedNameHidesEnclosingName);
}
ProblemMethodBinding fuzzyProblem = null;
@@ -711,6 +716,7 @@
fuzzyProblem = new ProblemMethodBinding(selector, argumentTypes, methodBinding.declaringClass, NotVisible);
}
}
+ //TODO: (philippe) should set closest match
if (fuzzyProblem == null && !methodBinding.isStatic()) {
if (insideConstructorCall) {
insideProblem = new ProblemMethodBinding(methodBinding.selector, methodBinding.parameters, NonStaticReferenceInConstructorInvocation);
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java
index 289b4bc..7813c74 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.internal.compiler.ast.Assignment;
@@ -21,6 +21,7 @@
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.impl.Constant;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
@@ -42,6 +43,7 @@
EvaluationContext evaluationContext;
FieldBinding delegateThis;
+
public CodeSnippetSingleNameReference(char[] source, long pos, EvaluationContext evaluationContext) {
super(source, pos);
this.evaluationContext = evaluationContext;
@@ -52,7 +54,8 @@
case FIELD : // reading a field
// check if reading a final blank field
FieldBinding fieldBinding;
- if ((fieldBinding = (FieldBinding) binding).isFinal() && currentScope.allowBlankFinalFieldAssignment(fieldBinding)) {
+ if ((fieldBinding = (FieldBinding) binding).isBlankFinal()
+ && currentScope.allowBlankFinalFieldAssignment(fieldBinding)) {
if (!flowInfo.isDefinitelyAssigned(fieldBinding)) {
currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
}
@@ -63,7 +66,11 @@
if (!flowInfo.isDefinitelyAssigned(localBinding = (LocalVariableBinding) binding)) {
currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
}
- if (!flowInfo.isFakeReachable()) localBinding.used = true;
+ if (flowInfo.isReachable()) {
+ localBinding.useFlag = LocalVariableBinding.USED;
+ } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
+ localBinding.useFlag = LocalVariableBinding.FAKE_USED;
+ }
}
return flowInfo;
}
@@ -87,7 +94,7 @@
return null;
}
}
- constant = FieldReference.getConstantFor(fieldBinding, true, this, scope, 0);
+ constant = FieldReference.getConstantFor(fieldBinding, this, true, scope);
if (isFieldUseDeprecated(fieldBinding, scope))
scope.problemReporter().deprecatedField(fieldBinding, this);
@@ -123,13 +130,9 @@
if (fieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
if (!fieldBinding.isStatic()) { // need a receiver?
if ((bits & DepthMASK) != 0) {
- Object[] emulationPath = currentScope.getExactEmulationPath(currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT));
- if (emulationPath == null) {
- // internal error, per construction we should have found it
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(emulationPath, this, currentScope);
- }
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
+ codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
} else {
this.generateReceiver(codeStream);
}
@@ -220,13 +223,9 @@
boolean isStatic;
if (!(isStatic = fieldBinding.isStatic())) {
if ((bits & DepthMASK) != 0) {
- Object[] emulationPath = currentScope.getExactEmulationPath(currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT));
- if (emulationPath == null) {
- // internal error, per construction we should have found it
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(emulationPath, this, currentScope);
- }
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
+ codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
} else {
generateReceiver(codeStream);
}
@@ -265,12 +264,7 @@
if ((bits & DepthMASK) != 0) {
// outer local can be reached either through a synthetic arg or a synthetic field
VariableBinding[] path = currentScope.getEmulationPath(localBinding);
- if (path == null) {
- // emulation was not possible (should not happen per construction)
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(path, this, currentScope);
- }
+ codeStream.generateOuterAccess(path, this, localBinding, currentScope);
} else {
// regular local variable read
codeStream.load(localBinding);
@@ -304,13 +298,9 @@
} else {
if (fieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
if ((bits & DepthMASK) != 0) {
- Object[] emulationPath = currentScope.getExactEmulationPath(currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT));
- if (emulationPath == null) {
- // internal error, per construction we should have found it
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(emulationPath, this, currentScope);
- }
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
+ codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
} else {
generateReceiver(codeStream);
}
@@ -429,13 +419,9 @@
codeStream.getstatic(fieldBinding);
} else {
if ((bits & DepthMASK) != 0) {
- Object[] emulationPath = currentScope.getExactEmulationPath(currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT));
- if (emulationPath == null) {
- // internal error, per construction we should have found it
- currentScope.problemReporter().needImplementation();
- } else {
- codeStream.generateOuterAccess(emulationPath, this, currentScope);
- }
+ ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT);
+ Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
+ codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
} else {
generateReceiver(codeStream);
}
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java
index dfe8c04..b671d76 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSkeleton.java
@@ -1,21 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.IBinaryField;
import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.IConstants;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* The skeleton of the class 'org.eclipse.jdt.internal.eval.target.CodeSnippet'
@@ -55,7 +55,7 @@
this.selector = selector;
this.methodDescriptor = methodDescriptor;
this.exceptionTypeNames = exceptionTypeNames;
- this.isConstructor = this.isConstructor;
+ this.isConstructor = isConstructor;
}
public char[][] getExceptionTypeNames() {
@@ -87,7 +87,7 @@
public char[][] getArgumentNames() {
return null;
}
-
+
}
/**
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java
index 439b83e..bb22c74 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSuperReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.internal.compiler.ast.SuperReference;
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java
index 8899269..8e9d4a2 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetThisReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.internal.compiler.ast.ThisReference;
@@ -38,7 +38,7 @@
this.evaluationContext = evaluationContext;
this.isImplicit = isImplicit;
}
-protected boolean checkAccess(MethodScope methodScope) {
+public boolean checkAccess(MethodScope methodScope) {
// this/super cannot be used in constructor call
if (evaluationContext.isConstructorCall) {
methodScope.problemReporter().fieldsOrThisBeforeConstructorInvocation(this);
@@ -78,8 +78,8 @@
delegateThis = scope.getField(snippetType, DELEGATE_THIS, this);
if (delegateThis == null) return null; // internal error, field should have been found
- if (delegateThis.isValidBinding()) return delegateThis.type;
- return snippetType;
+ if (delegateThis.isValidBinding()) return this.resolvedType = delegateThis.type;
+ return this.resolvedType = snippetType;
}
public void setActualReceiverType(ReferenceBinding receiverType) {
// ignored
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java
index e80f94c..4e3b39b 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetToCuMapper.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.core.ICompletionRequestor;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.codeassist.ISelectionRequestor;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.Util;
/**
@@ -40,17 +40,17 @@
public int startPosOffset = 0;
// Internal fields
- private char[] codeSnippet;
- private char[] packageName;
- private char[][] imports;
- char[] className; // NB: Make it package default visibility to optimize access from inner classes
- private char[] varClassName;
+ char[] codeSnippet;
+ char[] packageName;
+ char[][] imports;
+ char[] className;
+ char[] varClassName;
// Mapping of external local variables
- private char[][] localVarNames;
- private char[][] localVarTypeNames;
- private int[] localVarModifiers;
- private char[] declaringTypeName;
+ char[][] localVarNames;
+ char[][] localVarTypeNames;
+ int[] localVarModifiers;
+ char[] declaringTypeName;
/**
* Rebuild source in presence of external local variables
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetTypeDeclaration.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetTypeDeclaration.java
index 1e3aa19..2722fa9 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetTypeDeclaration.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetTypeDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.internal.compiler.ClassFile;
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationConstants.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationConstants.java
index e36d293..316fb85 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationConstants.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationConstants.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
public interface EvaluationConstants {
public static final char[] CODE_SNIPPET_CLASS_NAME_PREFIX = "CodeSnippet_".toCharArray(); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java
index 4402177..4c68d1e 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationContext.java
@@ -1,19 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
-import java.io.File;
import java.util.Map;
import org.eclipse.jdt.core.ICompletionRequestor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.codeassist.CompletionEngine;
import org.eclipse.jdt.internal.codeassist.ISearchableNameEnvironment;
@@ -25,7 +26,6 @@
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* @see org.eclipse.jdt.core.eval.IEvaluationContext
@@ -44,8 +44,8 @@
GlobalVariable[] variables = new GlobalVariable[5];
int variableCount = 0;
- char[][] imports = new char[0][];
- char[] packageName = new char[0];
+ char[][] imports = CharOperation.NO_CHAR_CHAR;
+ char[] packageName = CharOperation.NO_CHAR;
boolean varsChanged = true;
VariablesInfo installedVars;
IBinaryType codeSnippetBinary;
@@ -87,7 +87,7 @@
* @param options
* set of options used to configure the code assist engine.
*/
-public void complete(char[] codeSnippet, int completionPosition, ISearchableNameEnvironment environment, ICompletionRequestor requestor, Map options) {
+public void complete(char[] codeSnippet, int completionPosition, ISearchableNameEnvironment environment, ICompletionRequestor requestor, Map options, IJavaProject project) {
final char[] className = "CodeSnippetCompletion".toCharArray(); //$NON-NLS-1$
final CodeSnippetToCuMapper mapper = new CodeSnippetToCuMapper(
codeSnippet,
@@ -114,7 +114,7 @@
return null;
}
};
- CompletionEngine engine = new CompletionEngine(environment, mapper.getCompletionRequestor(requestor), options);
+ CompletionEngine engine = new CompletionEngine(environment, mapper.getCompletionRequestor(requestor), options, project);
engine.complete(sourceUnit, mapper.startPosOffset + completionPosition, 0);
}
/**
@@ -288,15 +288,18 @@
packageName = splitDeclaration[splitLength - 2];
}
if (!environment.isPackage(parentName, packageName)) {
- problems[0] = problemFactory.createProblem(importDeclaration, IProblem.ImportNotFound, new String[] {new String(importDeclaration)}, ProblemSeverities.Warning, 0, importDeclaration.length - 1, i);
+ String[] arguments = new String[] {new String(importDeclaration)};
+ problems[0] = problemFactory.createProblem(importDeclaration, IProblem.ImportNotFound, arguments, arguments, ProblemSeverities.Warning, 0, importDeclaration.length - 1, i);
}
} else {
if (environment.findType(splitDeclaration) == null) {
- problems[0] = problemFactory.createProblem(importDeclaration, IProblem.ImportNotFound, new String[] {new String(importDeclaration)}, ProblemSeverities.Warning, 0, importDeclaration.length - 1, i);
+ String[] arguments = new String[] {new String(importDeclaration)};
+ problems[0] = problemFactory.createProblem(importDeclaration, IProblem.ImportNotFound, arguments, arguments, ProblemSeverities.Warning, 0, importDeclaration.length - 1, i);
}
}
} else {
- problems[0] = problemFactory.createProblem(importDeclaration, IProblem.ImportNotFound, new String[] {new String(importDeclaration)}, ProblemSeverities.Warning, 0, importDeclaration.length - 1, i);
+ String[] arguments = new String[] {new String(importDeclaration)};
+ problems[0] = problemFactory.createProblem(importDeclaration, IProblem.ImportNotFound, arguments, arguments, ProblemSeverities.Warning, 0, importDeclaration.length - 1, i);
}
if (problems[0] != null) {
requestor.acceptProblem(problems[0], importDeclaration, EvaluationResult.T_IMPORT);
@@ -364,7 +367,7 @@
buffer.toString()
]
*/
-private byte[] getCodeSnippetBytes() {
+byte[] getCodeSnippetBytes() {
return new byte[] {
-54, -2, -70, -66, 0, 3, 0, 45, 0, 35, 1, 0, 48, 111, 114, 103, 47, 101, 99, 108, 105, 112, 115, 101, 47, 106, 100, 116, 47, 105, 110, 116, 101, 114, 110, 97, 108, 47, 101, 118, 97, 108, 47, 116, 97, 114, 103, 101, 116, 47, 67, 111, 100, 101, 83, 110, 105, 112, 112, 101, 116, 7, 0, 1, 1, 0, 16, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101, 99, 116, 7, 0, 3, 1, 0, 10, 114, 101, 115, 117, 108, 116, 84, 121, 112, 101, 1, 0, 17, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 67, 108, 97, 115, 115, 59, 1, 0, 11, 114, 101, 115, 117, 108, 116, 86, 97, 108, 117, 101, 1, 0, 18, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101, 99, 116, 59, 1, 0, 7, 99, 108, 97, 115, 115, 36, 48, 1, 0, 9, 83, 121, 110, 116, 104, 101, 116, 105, 99, 1, 0, 6, 60, 105, 110, 105, 116, 62, 1, 0, 3, 40, 41, 86, 1, 0, 4, 67, 111, 100, 101, 12, 0, 11, 0, 12, 10, 0, 4, 0, 14, 1, 0, 14, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 86, 111, 105, 100, 7, 0, 16, 1, 0, 4, 84, 89, 80, 69, 12, 0, 18, 0, 6, 9, 0, 17, 0, 19, 12, 0, 5, 0, 6, 9, 0, 2, 0, 21, 12, 0, 7, 0, 8, 9, 0, 2, 0, 23, 1, 0, 15, 76, 105, 110, 101, 78, 117, 109, 98, 101, 114, 84, 97, 98, 108, 101, 1, 0, 13, 103, 101, 116, 82, 101, 115, 117, 108, 116, 84, 121, 112, 101, 1, 0, 19, 40, 41, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 67, 108, 97, 115, 115, 59, 1, 0, 14, 103, 101, 116, 82, 101, 115, 117, 108, 116, 86, 97, 108, 117, 101, 1, 0, 20, 40, 41, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101, 99, 116, 59, 1, 0, 3, 114, 117, 110, 1, 0, 9, 115, 101, 116, 82, 101, 115, 117, 108, 116, 1, 0, 38, 40, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101, 99, 116, 59, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 67, 108, 97, 115, 115, 59, 41, 86, 1, 0, 10, 83, 111, 117, 114, 99, 101, 70, 105, 108, 101, 1, 0, 16, 67, 111, 100, 101, 83, 110, 105, 112, 112, 101, 116, 46, 106, 97, 118, 97, 0, 33, 0, 2, 0, 4, 0, 0, 0, 3, 0, 2, 0, 5, 0, 6, 0, 0, 0, 2, 0, 7, 0, 8, 0, 0, 0, 8, 0, 9, 0, 6, 0, 1, 0, 10, 0, 0, 0, 0, 0, 5, 0, 1, 0, 11, 0, 12, 0, 1, 0, 13, 0, 0, 0, 53, 0, 2, 0, 1, 0, 0, 0, 17, 42, -73, 0, 15, 42, -78, 0, 20, -75, 0, 22, 42, 1, -75, 0, 24, -79, 0, 0, 0, 1, 0, 25, 0, 0, 0, 18, 0, 4, 0, 0, 0, 17, 0, 4, 0, 18, 0, 11, 0, 19, 0, 16, 0, 17, 0, 1, 0, 26, 0, 27, 0, 1, 0, 13, 0, 0, 0, 29, 0, 1, 0, 1, 0, 0, 0, 5, 42, -76, 0, 22, -80, 0, 0, 0, 1, 0, 25, 0, 0, 0, 6, 0, 1, 0, 0, 0, 24, 0, 1, 0, 28, 0, 29, 0, 1, 0, 13, 0, 0, 0, 29, 0, 1, 0, 1, 0, 0, 0, 5, 42, -76, 0, 24, -80, 0, 0, 0, 1, 0, 25, 0, 0, 0, 6, 0, 1, 0, 0, 0, 30, 0, 1, 0, 30, 0, 12, 0, 1, 0, 13, 0, 0, 0, 25, 0, 0, 0, 1, 0, 0, 0, 1, -79, 0, 0, 0, 1, 0, 25, 0, 0, 0, 6, 0, 1, 0, 0, 0, 36, 0, 1, 0, 31, 0, 32, 0, 1, 0, 13, 0, 0, 0, 43, 0, 2, 0, 3, 0, 0, 0, 11, 42, 43, -75, 0, 24, 42, 44, -75, 0, 22, -79, 0, 0, 0, 1, 0, 25, 0, 0, 0, 14, 0, 3, 0, 0, 0, 42, 0, 5, 0, 43, 0, 10, 0, 41, 0, 1, 0, 33, 0, 0, 0, 2, 0, 34
};
@@ -446,16 +449,6 @@
return this.codeSnippetBinary;
}
/**
- * Returns the name of the file (including the package name) of the given class file.
- * The simple name doesn't contain the extension ".class".
- * The returned name doesn't start with a "/"
- */
-private String getSupportClassFileName(String simpleName) {
- char separator = File.separatorChar;
- char[][] compoundPackageName = CharOperation.splitOn('.', PACKAGE_NAME);
- return new String(CharOperation.concatWith(compoundPackageName, separator)) + separator + simpleName + ".class"; //$NON-NLS-1$
-}
-/**
* Creates a new global variable with the given name, type and initializer.
* If the variable is not initialized, the initializer can be null.
* Note that this doesn't install it to this evaluation context's VM.
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationResult.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationResult.java
index b575743..9ab3bdf 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationResult.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/EvaluationResult.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.core.compiler.IProblem;
@@ -210,7 +210,7 @@
break;
}
buffer.append(": "); //$NON-NLS-1$
- buffer.append(this.evaluationID);
+ buffer.append(this.evaluationID == null ? "<unknown>".toCharArray() : this.evaluationID); //$NON-NLS-1$
buffer.append("\n"); //$NON-NLS-1$
if (hasProblems()) {
buffer.append("Problems:\n"); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/Evaluator.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/Evaluator.java
index 291df56..c5357b6 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/Evaluator.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/Evaluator.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import java.util.ArrayList;
@@ -15,6 +15,7 @@
import java.util.Iterator;
import java.util.Map;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
@@ -24,7 +25,6 @@
import org.eclipse.jdt.internal.compiler.IProblemFactory;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* A evaluator builds a compilation unit and compiles it into class files.
@@ -61,7 +61,7 @@
*/
protected EvaluationResult[] evaluationResultsForCompilationProblems(CompilationResult result, char[] cuSource) {
// Break down the problems and group them by ids in evaluation results
- IProblem[] problems = result.getProblems();
+ IProblem[] problems = result.getAllProblems();
HashMap resultsByIDs = new HashMap(5);
for (int i = 0; i < problems.length; i++) {
addEvaluationResultForCompilationProblem(resultsByIDs, problems[i], cuSource);
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/GlobalVariable.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/GlobalVariable.java
index bd38cee..8abdf22 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/GlobalVariable.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/GlobalVariable.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
/**
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/IRequestor.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/IRequestor.java
index a7ce6ec..46db295 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/IRequestor.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/IRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import org.eclipse.jdt.core.compiler.IProblem;
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/InstallException.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/InstallException.java
index 427d0a7..072bb36 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/InstallException.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/InstallException.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
/**
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java
index 6c58d59..6489a0e 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesEvaluator.java
@@ -1,17 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
import java.util.Map;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.Compiler;
@@ -21,7 +22,6 @@
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.Util;
/**
@@ -140,7 +140,7 @@
* @see org.eclipse.jdt.internal.eval.Evaluator
*/
protected char[] getClassName() {
- return CharOperation.concat(this.context.GLOBAL_VARS_CLASS_NAME_PREFIX, Integer.toString(this.context.VAR_CLASS_COUNTER + 1).toCharArray());
+ return CharOperation.concat(EvaluationContext.GLOBAL_VARS_CLASS_NAME_PREFIX, Integer.toString(EvaluationContext.VAR_CLASS_COUNTER + 1).toCharArray());
}
/**
* Creates and returns a compiler for this evaluator.
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesInfo.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesInfo.java
index 2fffd76..c973607 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesInfo.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/VariablesInfo.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.eval;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.ClassFile;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* This contains information about the installed variables such as
@@ -20,7 +20,7 @@
* compiling the code snippet).
*/
public class VariablesInfo {
- GlobalVariable[] variables;;
+ GlobalVariable[] variables;
int variableCount;
char[] packageName;
char[] className;
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatter.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatter.java
index e012da7..a7c310f 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatter.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatter.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.formatter;
import java.io.BufferedReader;
@@ -18,10 +18,11 @@
import java.util.Map;
import org.eclipse.jdt.core.ICodeFormatter;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.ConfigurableOption;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
import org.eclipse.jdt.internal.formatter.impl.FormatterOptions;
import org.eclipse.jdt.internal.formatter.impl.SplitLine;
@@ -31,14 +32,14 @@
* on this instance to format <code>aString</code>.
* It will return the formatted string.</ul>
*/
-public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
+public class CodeFormatter implements TerminalTokens, ICodeFormatter {
public FormatterOptions options;
/**
* Represents a block in the <code>constructions</code> stack.
*/
- public static final int BLOCK = ITerminalSymbols.TokenNameLBRACE;
+ public static final int BLOCK = TerminalTokens.TokenNameLBRACE;
/**
* Represents a block following a control statement in the <code>constructions</code> stack.
@@ -142,22 +143,14 @@
* Creates a new instance of Code Formatter using the given settings.
*/
public CodeFormatter(Map settings) {
-
- // initialize internal state
- constructionsCount = 0;
- constructions = new int[10];
- currentLineIndentationLevel = indentationLevel = initialIndentationLevel;
- currentCommentOffset = -1;
-
// initialize primary and secondary scanners
- scanner = new Scanner(true, true); // regular scanner for forming lines
+ scanner = new Scanner(true /*comment*/, true /*whitespace*/, false /*nls*/, false /*assert*/, null /*taskTags*/, null/*taskPriorities*/); // regular scanner for forming lines
+ // to record positions of the beginning of lines.
scanner.recordLineSeparator = true;
- // to remind of the position of the beginning of the line.
- splitScanner = new Scanner(true, true);
- // secondary scanner to split long lines formed by primary scanning
- // initialize current line buffer
- currentLineBuffer = new StringBuffer();
+ // secondary scanner to split long lines formed by primary scanning
+ splitScanner = new Scanner(true /*comment*/, true /*whitespace*/, false /*nls*/, false /*assert*/, null /*taskTags*/, null/*taskPriorities*/);
+
this.options = new FormatterOptions(settings);
}
@@ -176,7 +169,7 @@
}
}
- /**
+ /**
* @deprecated backport 1.0 internal functionality
*/
private static Map convertConfigurableOptions(ConfigurableOption[] settings) {
@@ -213,6 +206,8 @@
} else if(optionName.equals("tabulation.size")) { //$NON-NLS-1$
options.put("org.eclipse.jdt.core.formatter.tabulation.size", String.valueOf(valueIndex)); //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (optionName.equals("space.castexpression")) { //$NON-NLS-1$
+ options.put("org.eclipse.jdt.core.formatter.space.castexpression", valueIndex == 0 ? "insert" : "do not insert" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
}
@@ -287,12 +282,16 @@
}
}
updateMappedPositions(scanner.startPosition);
+
+ updateRemainingMappedPositions();
}
/**
* Formats the input string.
*/
private void format() {
+ reset();
+
int token = 0;
int previousToken = 0;
int previousCompilableToken = 0;
@@ -346,6 +345,22 @@
// exit the loop.
try {
token = scanner.getNextToken();
+
+ // Patch for line comment
+ // See PR http://dev.eclipse.org/bugs/show_bug.cgi?id=23096
+ if (token == TerminalTokens.TokenNameCOMMENT_LINE) {
+ int length = scanner.currentPosition;
+ loop: for (int index = length - 1; index >= 0; index--) {
+ switch(scanner.source[index]) {
+ case '\r' :
+ case '\n' :
+ scanner.currentPosition--;
+ break;
+ default:
+ break loop;
+ }
+ }
+ }
} catch (InvalidInputException e) {
if (!handleInvalidToken(e)) {
throw e;
@@ -902,8 +917,38 @@
&& (previousToken == TokenNameLBRACE || token == TokenNameRBRACE))
&& previousToken != Scanner.TokenNameCOMMENT_LINE) {
if ((!(options.compactAssignmentMode && token == TokenNameEQUAL))
- && !openAndCloseBrace)
- space();
+ && !openAndCloseBrace) {
+ if (previousCompilableToken == TokenNameRPAREN) {
+ switch(token) {
+ case TokenNameIdentifier :
+ case TokenNameDoubleLiteral :
+ case TokenNameIntegerLiteral :
+ case TokenNameFloatingPointLiteral :
+ case TokenNameStringLiteral :
+ case TokenNameCharacterLiteral :
+ case TokenNameLongLiteral :
+ case TokenNamenew :
+ case TokenNamethis :
+ case TokenNamesuper :
+ case TokenNameboolean :
+ case TokenNamebyte :
+ case TokenNamechar :
+ case TokenNameint :
+ case TokenNamelong :
+ case TokenNameshort :
+ case TokenNamedouble :
+ case TokenNamefloat :
+ if (options.isAddindSpaceInCastExpression()) {
+ space();
+ }
+ break;
+ default:
+ space();
+ }
+ } else {
+ space();
+ }
+ }
}
// Add the next token to the formatted source string.
outputCurrentToken(token);
@@ -1068,7 +1113,8 @@
new ConfigurableOption(componentName, "line.split", locale, options.maxLineLength),//$NON-NLS-1$
new ConfigurableOption(componentName, "style.compactAssignment", locale, options.compactAssignmentMode ? 0 : 1), //$NON-NLS-1$
new ConfigurableOption(componentName, "tabulation.char", locale, options.indentWithTab ? 0 : 1), //$NON-NLS-1$
- new ConfigurableOption(componentName, "tabulation.size", locale, options.tabSize) //$NON-NLS-1$
+ new ConfigurableOption(componentName, "tabulation.size", locale, options.tabSize), //$NON-NLS-1$
+ new ConfigurableOption(componentName, "space.castexpression", locale, options.spaceInCastExpression ? 0 : 1) //$NON-NLS-1$
};
}
@@ -1761,37 +1807,6 @@
}
/**
- * Pops the top statement of the stack if it is a <code>BLOCK</code> or a <code>NONINDENT_BLOCK</code>.
- */
- private int popBlock() {
- int delta = 0;
- if ((constructionsCount > 0)
- && ((constructions[constructionsCount - 1] == BLOCK)
- || (constructions[constructionsCount - 1] == NONINDENT_BLOCK))) {
- if (constructions[constructionsCount - 1] == BLOCK)
- delta--;
- constructionsCount--;
- }
- return delta;
- }
-
- /**
- * Pops elements until the stack is empty or the top element is <code>token</code>.<br>
- * Does not remove <code>token</code> from the stack.
- * @param token the token to be left as the top of the stack
- */
- private int popExclusiveUntil(int token) {
- int delta = 0;
- int startCount = constructionsCount;
- for (int i = startCount - 1; i >= 0 && constructions[i] != token; i--) {
- if (constructions[i] != NONINDENT_BLOCK)
- delta--;
- constructionsCount--;
- }
- return delta;
- }
-
- /**
* Pops elements until the stack is empty or the top element is
* a <code>BLOCK</code> or a <code>NONINDENT_BLOCK</code>.<br>
* Does not remove it from the stack.
@@ -1914,7 +1929,20 @@
constructions[constructionsCount++] = token;
return 1;
}
-
+
+ private void reset() {
+ // initialize internal state
+ constructionsCount = 0;
+ if (constructions == null) {
+ constructions = new int[10];
+ }
+ currentLineIndentationLevel = indentationLevel = initialIndentationLevel;
+ currentCommentOffset = -1;
+
+ // initialize current line buffer
+ currentLineBuffer = new StringBuffer();
+ }
+
private static boolean separateFirstArgumentOn(int currentToken) {
//return (currentToken == TokenNameCOMMA || currentToken == TokenNameSEMICOLON);
return currentToken != TokenNameif
@@ -2476,7 +2504,7 @@
indexToMap = positionsToMap.length; // no more mapping
return;
}
- if (Character.isWhitespace(source[posToMap])) {
+ if (CharOperation.isWhitespace(source[posToMap])) {
mappedPositions[indexToMap] = startPosition + globalDelta + lineDelta;
} else {
if (posToMap == sourceLength - 1) {
@@ -2503,6 +2531,20 @@
indexInMap++;
}
}
+
+ /**
+ * Update positions which are beyond the source length
+ */
+ private void updateRemainingMappedPositions() {
+ if (positionsToMap == null) {
+ return;
+ }
+ int sourceLength = formattedSource.length();
+ while (indexToMap < positionsToMap.length) {
+ mappedPositions[indexToMap] = sourceLength - 1;
+ indexToMap++;
+ }
+ }
private int getLength(String s, int tabDepth) {
int length = 0;
@@ -2532,4 +2574,4 @@
this.initialIndentationLevel =
currentLineIndentationLevel = indentationLevel = newIndentationLevel;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/FormatterOptions.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/FormatterOptions.java
index bdaa693..4ab9b65 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/FormatterOptions.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/FormatterOptions.java
Binary files differ
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/SplitLine.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/SplitLine.java
index 6edd966..e718611 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/SplitLine.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/impl/SplitLine.java
@@ -1,20 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.formatter.impl;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
/** Represents a split line: contains an operator and all substrings
*/
-public class SplitLine implements ITerminalSymbols{
+public class SplitLine implements TerminalTokens{
public int[] operators; // the operator on which the string was split.
public String[] substrings;
public int[] startSubstringsIndexes;
@@ -44,8 +44,8 @@
for (int i=0,max=substrings.length;i<max;i++){
int currentOperator = operators[i];
String currentString = substrings[i];
- boolean placeOperatorAhead = currentOperator != ITerminalSymbols.TokenNameCOMMA && currentOperator != ITerminalSymbols.TokenNameSEMICOLON;
- boolean placeOperatorBehind = currentOperator == ITerminalSymbols.TokenNameCOMMA || currentOperator == ITerminalSymbols.TokenNameSEMICOLON;
+ boolean placeOperatorAhead = currentOperator != TerminalTokens.TokenNameCOMMA && currentOperator != TerminalTokens.TokenNameSEMICOLON;
+ boolean placeOperatorBehind = currentOperator == TerminalTokens.TokenNameCOMMA || currentOperator == TerminalTokens.TokenNameSEMICOLON;
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/options.properties b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/options.properties
new file mode 100644
index 0000000..2e0abfe
--- /dev/null
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/options.properties
@@ -0,0 +1,75 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+newline.openingBrace.number=1
+newline.openingBrace.category=Newline
+newline.openingBrace.name=I&nsert new line before opening brace
+newline.openingBrace.possibleValues=2|Insert|Do not insert
+newline.openingBrace.description=When Insert, a new line is inserted before an opening brace, otherwise nothing is inserted
+
+newline.controlStatement.number=2
+newline.controlStatement.category=Newline
+newline.controlStatement.name=Insert new &line in control statement
+newline.controlStatement.possibleValues=2|Insert|Do not insert
+newline.controlStatement.description=When Insert, a new line is inserted between } and else, catch, finally
+
+newline.clearAll.number=3
+newline.clearAll.category=Newline
+newline.clearAll.name=Clear all &blank lines
+newline.clearAll.possibleValues=2|Clear|Preserve one
+newline.clearAll.description=When Clear, all blank lines are removed. When Preserve one, only one is kept and all others removed.
+
+newline.elseIf.number=4
+newline.elseIf.category=Newline
+newline.elseIf.name=&Keep else if on the same line
+newline.elseIf.possibleValues=2|Yes|No
+newline.elseIf.description=When Yes, a blank line is inserted between a else and a if when they are contiguous
+
+newline.emptyBlock.number=5
+newline.emptyBlock.category=Newline
+newline.emptyBlock.name=In&sert a new line inside an empty block
+newline.emptyBlock.possibleValues=2|Insert|Do not insert
+newline.emptyBlock.description=When insert, a line break is inserted between contiguous { and }, if } is not followed by a keyword.
+
+line.split.number=6
+line.split.category=Line splitting
+line.split.name=Ma&ximum line length
+line.split.possibleValues=-1
+line.split.description=Enable splitting of long lines (exceeding the configurable length). Length of 0 will disable line splitting
+
+style.compactAssignment.number=7
+style.compactAssignment.category=Style
+style.compactAssignment.name=&Compact assignment
+style.compactAssignment.possibleValues=2|Compact|Normal
+style.compactAssignment.description=Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space is inserted before the assignment operator
+
+style.reuseExistingLayout.number=8
+style.reuseExistingLayout.category=Style
+style.reuseExistingLayout.name=&Reuse existing layout
+style.reuseExistingLayout.possibleValues=2|Reuse|Do not reuse
+style.reuseExistingLayout.description=If the user has formatted his code a certain way, the formatter does not try to reformat it
+
+tabulation.char.number=9
+tabulation.char.category=Style
+tabulation.char.name=Indentation is represented by &tab
+tabulation.char.possibleValues=2|Tab|Spaces
+tabulation.char.description=Either choose to indent with tab characters or spaces
+
+tabulation.size.number=10
+tabulation.size.category=Style
+tabulation.size.name=&Amount of spaces representing a tab
+tabulation.size.possibleValues=-1
+tabulation.size.description=Tabulation size in term of space characters
+
+space.castexpression.number=11
+space.castexpression.category=Style
+space.castexpression.name=&Insert a space in cast expression
+space.castexpression.size.possibleValues=2|Insert|Do not insert
+space.castexpression.description=When insert, a space is added between the closing parenthesis and the expression of the cast expression
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/grammar/java_1_4.g b/org.eclipse.jdt.core/grammar/java_1_4.g
new file mode 100644
index 0000000..8d0ca72
--- /dev/null
+++ b/org.eclipse.jdt.core/grammar/java_1_4.g
@@ -0,0 +1,1249 @@
+--main options
+%options ACTION, AN=JavaAction.java, GP=java,
+%options FILE-PREFIX=java, ESCAPE=$, PREFIX=TokenName, OUTPUT-SIZE=125 ,
+%options NOGOTO-DEFAULT, SINGLE-PRODUCTIONS, LALR=1 , TABLE=TIME ,
+
+--error recovering options.....
+%options ERROR_MAPS
+
+--grammar understanding options
+%options first follow
+%options TRACE=FULL ,
+%options VERBOSE
+
+--Usefull macros helping reading/writing semantic actions
+$Define
+$putCase
+/. case $rule_number : // System.out.println("$rule_text");
+ ./
+
+$break
+/.
+ break ;
+./
+
+-- here it starts really ------------------------------------------
+$Terminals
+
+ Identifier
+
+ abstract assert boolean break byte case catch char class
+ continue default do double else extends false final finally float
+ for if implements import instanceof int
+ interface long native new null package private
+ protected public return short static strictfp super switch
+ synchronized this throw throws transient true try void
+ volatile while
+
+ IntegerLiteral
+ LongLiteral
+ FloatingPointLiteral
+ DoubleLiteral
+ CharacterLiteral
+ StringLiteral
+
+ PLUS_PLUS
+ MINUS_MINUS
+ EQUAL_EQUAL
+ LESS_EQUAL
+ GREATER_EQUAL
+ NOT_EQUAL
+ LEFT_SHIFT
+ RIGHT_SHIFT
+ UNSIGNED_RIGHT_SHIFT
+ PLUS_EQUAL
+ MINUS_EQUAL
+ MULTIPLY_EQUAL
+ DIVIDE_EQUAL
+ AND_EQUAL
+ OR_EQUAL
+ XOR_EQUAL
+ REMAINDER_EQUAL
+ LEFT_SHIFT_EQUAL
+ RIGHT_SHIFT_EQUAL
+ UNSIGNED_RIGHT_SHIFT_EQUAL
+ OR_OR
+ AND_AND
+ PLUS
+ MINUS
+ NOT
+ REMAINDER
+ XOR
+ AND
+ MULTIPLY
+ OR
+ TWIDDLE
+ DIVIDE
+ GREATER
+ LESS
+ LPAREN
+ RPAREN
+ LBRACE
+ RBRACE
+ LBRACKET
+ RBRACKET
+ SEMICOLON
+ QUESTION
+ COLON
+ COMMA
+ DOT
+ EQUAL
+
+-- BodyMarker
+
+$Alias
+
+ '++' ::= PLUS_PLUS
+ '--' ::= MINUS_MINUS
+ '==' ::= EQUAL_EQUAL
+ '<=' ::= LESS_EQUAL
+ '>=' ::= GREATER_EQUAL
+ '!=' ::= NOT_EQUAL
+ '<<' ::= LEFT_SHIFT
+ '>>' ::= RIGHT_SHIFT
+ '>>>' ::= UNSIGNED_RIGHT_SHIFT
+ '+=' ::= PLUS_EQUAL
+ '-=' ::= MINUS_EQUAL
+ '*=' ::= MULTIPLY_EQUAL
+ '/=' ::= DIVIDE_EQUAL
+ '&=' ::= AND_EQUAL
+ '|=' ::= OR_EQUAL
+ '^=' ::= XOR_EQUAL
+ '%=' ::= REMAINDER_EQUAL
+ '<<=' ::= LEFT_SHIFT_EQUAL
+ '>>=' ::= RIGHT_SHIFT_EQUAL
+ '>>>=' ::= UNSIGNED_RIGHT_SHIFT_EQUAL
+ '||' ::= OR_OR
+ '&&' ::= AND_AND
+
+ '+' ::= PLUS
+ '-' ::= MINUS
+ '!' ::= NOT
+ '%' ::= REMAINDER
+ '^' ::= XOR
+ '&' ::= AND
+ '*' ::= MULTIPLY
+ '|' ::= OR
+ '~' ::= TWIDDLE
+ '/' ::= DIVIDE
+ '>' ::= GREATER
+ '<' ::= LESS
+ '(' ::= LPAREN
+ ')' ::= RPAREN
+ '{' ::= LBRACE
+ '}' ::= RBRACE
+ '[' ::= LBRACKET
+ ']' ::= RBRACKET
+ ';' ::= SEMICOLON
+ '?' ::= QUESTION
+ ':' ::= COLON
+ ',' ::= COMMA
+ '.' ::= DOT
+ '=' ::= EQUAL
+
+$Start
+ Goal
+
+$Rules
+
+/. // This method is part of an automatic generation : do NOT edit-modify
+protected void consumeRule(int act) {
+ switch ( act ) {
+./
+
+
+
+Goal ::= '++' CompilationUnit
+Goal ::= '--' MethodBody
+Goal ::= '==' ConstructorBody
+-- Initializer
+Goal ::= '>>' StaticInitializer
+Goal ::= '>>' Initializer
+-- error recovery
+Goal ::= '>>>' Headers
+Goal ::= '*' BlockStatements
+Goal ::= '*' MethodPushModifiersHeader
+Goal ::= '*' CatchHeader
+-- JDOM
+Goal ::= '&&' FieldDeclaration
+Goal ::= '||' ImportDeclaration
+Goal ::= '?' PackageDeclaration
+Goal ::= '+' TypeDeclaration
+Goal ::= '/' GenericMethodDeclaration
+Goal ::= '&' ClassBodyDeclaration
+-- code snippet
+Goal ::= '%' Expression
+-- completion parser
+Goal ::= '!' ConstructorBlockStatementsopt
+Goal ::= '~' BlockStatementsopt
+
+Literal -> IntegerLiteral
+Literal -> LongLiteral
+Literal -> FloatingPointLiteral
+Literal -> DoubleLiteral
+Literal -> CharacterLiteral
+Literal -> StringLiteral
+Literal -> null
+Literal -> BooleanLiteral
+BooleanLiteral -> true
+BooleanLiteral -> false
+
+-------------------------------------------------------------
+-------------------------------------------------------------
+--a Type results in both a push of its dimension(s) and its name(s).
+
+Type ::= PrimitiveType
+ /.$putCase consumePrimitiveType(); $break ./
+Type -> ReferenceType
+
+PrimitiveType -> NumericType
+NumericType -> IntegralType
+NumericType -> FloatingPointType
+
+PrimitiveType -> 'boolean'
+PrimitiveType -> 'void'
+IntegralType -> 'byte'
+IntegralType -> 'short'
+IntegralType -> 'int'
+IntegralType -> 'long'
+IntegralType -> 'char'
+FloatingPointType -> 'float'
+FloatingPointType -> 'double'
+
+ReferenceType ::= ClassOrInterfaceType
+/.$putCase consumeReferenceType(); $break ./
+ReferenceType -> ArrayType -- here a push of dimensions is done, that explains the two previous push 0
+
+ClassOrInterfaceType -> Name
+
+--
+-- These rules have been rewritten to avoid some conflicts introduced
+-- by adding the 1.1 features
+--
+-- ArrayType ::= PrimitiveType '[' ']'
+-- ArrayType ::= Name '[' ']'
+-- ArrayType ::= ArrayType '[' ']'
+--
+
+ArrayType ::= PrimitiveType Dims
+ArrayType ::= Name Dims
+
+ClassType -> ClassOrInterfaceType
+
+
+--------------------------------------------------------------
+--------------------------------------------------------------
+
+Name -> SimpleName
+Name -> QualifiedName
+
+SimpleName -> 'Identifier'
+
+QualifiedName ::= Name '.' SimpleName
+/.$putCase consumeQualifiedName(); $break ./
+
+CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsopt
+/.$putCase consumeCompilationUnit(); $break ./
+
+EnterCompilationUnit ::= $empty
+/.$putCase consumeEnterCompilationUnit(); $break ./
+
+Headers -> Header
+Headers ::= Headers Header
+
+Header -> ImportDeclaration
+Header -> PackageDeclaration
+Header -> ClassHeader
+Header -> InterfaceHeader
+Header -> StaticInitializer
+Header -> MethodHeader
+Header -> ConstructorHeader
+Header -> FieldDeclaration
+Header -> AllocationHeader
+
+CatchHeader ::= 'catch' '(' FormalParameter ')' '{'
+/.$putCase consumeCatchHeader(); $break ./
+
+ImportDeclarations -> ImportDeclaration
+ImportDeclarations ::= ImportDeclarations ImportDeclaration
+/.$putCase consumeImportDeclarations(); $break ./
+
+TypeDeclarations -> TypeDeclaration
+TypeDeclarations ::= TypeDeclarations TypeDeclaration
+/.$putCase consumeTypeDeclarations(); $break ./
+
+PackageDeclaration ::= PackageDeclarationName ';'
+/.$putCase consumePackageDeclaration(); $break ./
+
+PackageDeclarationName ::= 'package' Name
+/.$putCase consumePackageDeclarationName(); $break ./
+
+ImportDeclaration -> SingleTypeImportDeclaration
+ImportDeclaration -> TypeImportOnDemandDeclaration
+
+SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';'
+/.$putCase consumeSingleTypeImportDeclaration(); $break ./
+
+SingleTypeImportDeclarationName ::= 'import' Name
+/.$putCase consumeSingleTypeImportDeclarationName(); $break ./
+
+TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName ';'
+/.$putCase consumeTypeImportOnDemandDeclaration(); $break ./
+
+TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*'
+/.$putCase consumeTypeImportOnDemandDeclarationName(); $break ./
+
+TypeDeclaration -> ClassDeclaration
+TypeDeclaration -> InterfaceDeclaration
+-- this declaration in part of a list od declaration and we will
+-- use and optimized list length calculation process
+-- thus we decrement the number while it will be incremend.....
+TypeDeclaration ::= ';'
+/. $putCase consumeEmptyTypeDeclaration(); $break ./
+
+--18.7 Only in the LALR(1) Grammar
+
+Modifiers ::= Modifier
+Modifiers ::= Modifiers Modifier
+
+Modifier -> 'public'
+Modifier -> 'protected'
+Modifier -> 'private'
+Modifier -> 'static'
+Modifier -> 'abstract'
+Modifier -> 'final'
+Modifier -> 'native'
+Modifier -> 'synchronized'
+Modifier -> 'transient'
+Modifier -> 'volatile'
+Modifier -> 'strictfp'
+
+--18.8 Productions from 8: Class Declarations
+--ClassModifier ::=
+-- 'abstract'
+-- | 'final'
+-- | 'public'
+--18.8.1 Productions from 8.1: Class Declarations
+
+ClassDeclaration ::= ClassHeader ClassBody
+/.$putCase consumeClassDeclaration(); $break ./
+
+ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt
+/.$putCase consumeClassHeader(); $break ./
+
+ClassHeaderName ::= Modifiersopt 'class' 'Identifier'
+/.$putCase consumeClassHeaderName(); $break ./
+
+ClassHeaderExtends ::= 'extends' ClassType
+/.$putCase consumeClassHeaderExtends(); $break ./
+
+ClassHeaderImplements ::= 'implements' InterfaceTypeList
+/.$putCase consumeClassHeaderImplements(); $break ./
+
+InterfaceTypeList -> InterfaceType
+InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType
+/.$putCase consumeInterfaceTypeList(); $break ./
+
+InterfaceType ::= ClassOrInterfaceType
+/.$putCase consumeInterfaceType(); $break ./
+
+ClassBody ::= '{' ClassBodyDeclarationsopt '}'
+
+ClassBodyDeclarations ::= ClassBodyDeclaration
+ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration
+/.$putCase consumeClassBodyDeclarations(); $break ./
+
+ClassBodyDeclaration -> ClassMemberDeclaration
+ClassBodyDeclaration -> StaticInitializer
+ClassBodyDeclaration -> ConstructorDeclaration
+--1.1 feature
+ClassBodyDeclaration ::= Diet NestedMethod Block
+/.$putCase consumeClassBodyDeclaration(); $break ./
+Diet ::= $empty
+/.$putCase consumeDiet(); $break./
+
+Initializer ::= Diet NestedMethod Block
+/.$putCase consumeClassBodyDeclaration(); $break ./
+
+ClassMemberDeclaration -> FieldDeclaration
+ClassMemberDeclaration -> MethodDeclaration
+--1.1 feature
+ClassMemberDeclaration -> ClassDeclaration
+--1.1 feature
+ClassMemberDeclaration -> InterfaceDeclaration
+
+-- Empty declarations are not valid Java ClassMemberDeclarations.
+-- However, since the current (2/14/97) Java compiler accepts them
+-- (in fact, some of the official tests contain this erroneous
+-- syntax)
+
+GenericMethodDeclaration -> MethodDeclaration
+GenericMethodDeclaration -> ConstructorDeclaration
+
+ClassMemberDeclaration ::= ';'
+/.$putCase consumeEmptyClassMemberDeclaration(); $break./
+
+--18.8.2 Productions from 8.3: Field Declarations
+--VariableModifier ::=
+-- 'public'
+-- | 'protected'
+-- | 'private'
+-- | 'static'
+-- | 'final'
+-- | 'transient'
+-- | 'volatile'
+
+FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
+/.$putCase consumeFieldDeclaration(); $break ./
+
+VariableDeclarators -> VariableDeclarator
+VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator
+/.$putCase consumeVariableDeclarators(); $break ./
+
+VariableDeclarator ::= VariableDeclaratorId EnterVariable ExitVariableWithoutInitialization
+
+VariableDeclarator ::= VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
+
+EnterVariable ::= $empty
+/.$putCase consumeEnterVariable(); $break ./
+
+ExitVariableWithInitialization ::= $empty
+/.$putCase consumeExitVariableWithInitialization(); $break ./
+
+ExitVariableWithoutInitialization ::= $empty
+/.$putCase consumeExitVariableWithoutInitialization(); $break ./
+
+ForceNoDiet ::= $empty
+/.$putCase consumeForceNoDiet(); $break ./
+RestoreDiet ::= $empty
+/.$putCase consumeRestoreDiet(); $break ./
+
+VariableDeclaratorId ::= 'Identifier' Dimsopt
+
+VariableInitializer -> Expression
+VariableInitializer -> ArrayInitializer
+
+--18.8.3 Productions from 8.4: Method Declarations
+--MethodModifier ::=
+-- 'public'
+-- | 'protected'
+-- | 'private'
+-- | 'static'
+-- | 'abstract'
+-- | 'final'
+-- | 'native'
+-- | 'synchronized'
+--
+
+MethodDeclaration -> AbstractMethodDeclaration
+MethodDeclaration ::= MethodHeader MethodBody
+/.$putCase // set to true to consume a method with a body
+ consumeMethodDeclaration(true); $break ./
+
+AbstractMethodDeclaration ::= MethodHeader ';'
+/.$putCase // set to false to consume a method without body
+ consumeMethodDeclaration(false); $break ./
+
+MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims MethodHeaderThrowsClauseopt
+/.$putCase consumeMethodHeader(); $break ./
+
+MethodPushModifiersHeader ::= MethodPushModifiersHeaderName MethodHeaderParameters MethodHeaderExtendedDims MethodHeaderThrowsClauseopt
+/.$putCase consumeMethodHeader(); $break ./
+
+MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers 'Identifier' '('
+/.$putCase consumeMethodPushModifiersHeaderName(); $break ./
+
+MethodPushModifiersHeaderName ::= Type PushModifiers 'Identifier' '('
+/.$putCase consumeMethodPushModifiersHeaderName(); $break ./
+
+MethodHeaderName ::= Modifiersopt Type 'Identifier' '('
+/.$putCase consumeMethodHeaderName(); $break ./
+
+MethodHeaderParameters ::= FormalParameterListopt ')'
+/.$putCase consumeMethodHeaderParameters(); $break ./
+
+MethodHeaderExtendedDims ::= Dimsopt
+/.$putCase consumeMethodHeaderExtendedDims(); $break ./
+
+MethodHeaderThrowsClause ::= 'throws' ClassTypeList
+/.$putCase consumeMethodHeaderThrowsClause(); $break ./
+
+ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters MethodHeaderThrowsClauseopt
+/.$putCase consumeConstructorHeader(); $break ./
+
+ConstructorHeaderName ::= Modifiersopt 'Identifier' '('
+/.$putCase consumeConstructorHeaderName(); $break ./
+
+FormalParameterList -> FormalParameter
+FormalParameterList ::= FormalParameterList ',' FormalParameter
+/.$putCase consumeFormalParameterList(); $break ./
+
+--1.1 feature
+FormalParameter ::= Modifiersopt Type VariableDeclaratorId
+/.$putCase // the boolean is used to know if the modifiers should be reset
+ consumeFormalParameter(); $break ./
+
+ClassTypeList -> ClassTypeElt
+ClassTypeList ::= ClassTypeList ',' ClassTypeElt
+/.$putCase consumeClassTypeList(); $break ./
+
+ClassTypeElt ::= ClassType
+/.$putCase consumeClassTypeElt(); $break ./
+
+
+MethodBody ::= NestedMethod '{' BlockStatementsopt '}'
+/.$putCase consumeMethodBody(); $break ./
+
+NestedMethod ::= $empty
+/.$putCase consumeNestedMethod(); $break ./
+
+--18.8.4 Productions from 8.5: Static Initializers
+
+StaticInitializer ::= StaticOnly Block
+/.$putCase consumeStaticInitializer(); $break./
+
+StaticOnly ::= 'static'
+/.$putCase consumeStaticOnly(); $break ./
+
+--18.8.5 Productions from 8.6: Constructor Declarations
+--ConstructorModifier ::=
+-- 'public'
+-- | 'protected'
+-- | 'private'
+--
+--
+ConstructorDeclaration ::= ConstructorHeader ConstructorBody
+/.$putCase consumeConstructorDeclaration() ; $break ./
+
+-- These rules are added to be able to parse constructors with no body
+ConstructorDeclaration ::= ConstructorHeader ';'
+/.$putCase consumeInvalidConstructorDeclaration() ; $break ./
+
+-- the rules ExplicitConstructorInvocationopt has been expanded
+-- in the rule below in order to make the grammar lalr(1).
+-- ConstructorBody ::= '{' ExplicitConstructorInvocationopt BlockStatementsopt '}'
+-- Other inlining has occured into the next rule too....
+
+ConstructorBody ::= NestedMethod '{' ConstructorBlockStatementsopt '}'
+/.$putCase consumeConstructorBody(); $break ./
+
+ConstructorBlockStatementsopt -> BlockStatementsopt
+
+ConstructorBlockStatementsopt -> ExplicitConstructorInvocation
+
+ConstructorBlockStatementsopt ::= ExplicitConstructorInvocation BlockStatements
+/.$putCase consumeConstructorBlockStatements(); $break ./
+
+ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.This); $break ./
+
+ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.Super); $break ./
+
+--1.1 feature
+ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.Super); $break ./
+
+--1.1 feature
+ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.Super); $break ./
+
+--1.1 feature
+ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.This); $break ./
+
+--1.1 feature
+ExplicitConstructorInvocation ::= Name '.' 'this' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.This); $break ./
+
+--18.9 Productions from 9: Interface Declarations
+
+--18.9.1 Productions from 9.1: Interface Declarations
+--InterfaceModifier ::=
+-- 'public'
+-- | 'abstract'
+--
+InterfaceDeclaration ::= InterfaceHeader InterfaceBody
+/.$putCase consumeInterfaceDeclaration(); $break ./
+
+InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt
+/.$putCase consumeInterfaceHeader(); $break ./
+
+InterfaceHeaderName ::= Modifiersopt 'interface' 'Identifier'
+/.$putCase consumeInterfaceHeaderName(); $break ./
+
+-- This rule will be used to accept inner local interface and then report a relevant error message
+InvalidInterfaceDeclaration -> InterfaceHeader InterfaceBody
+
+InterfaceHeaderExtends ::= 'extends' InterfaceTypeList
+/.$putCase consumeInterfaceHeaderExtends(); $break ./
+
+InterfaceBody ::= '{' InterfaceMemberDeclarationsopt '}'
+
+InterfaceMemberDeclarations -> InterfaceMemberDeclaration
+InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration
+/.$putCase consumeInterfaceMemberDeclarations(); $break ./
+
+--same as for class members
+InterfaceMemberDeclaration ::= ';'
+/.$putCase consumeEmptyInterfaceMemberDeclaration(); $break ./
+
+-- This rule is added to be able to parse non abstract method inside interface and then report a relevent error message
+InvalidMethodDeclaration -> MethodHeader MethodBody
+
+InterfaceMemberDeclaration -> ConstantDeclaration
+InterfaceMemberDeclaration ::= InvalidMethodDeclaration
+/.$putCase ignoreMethodBody(); $break ./
+
+-- These rules are added to be able to parse constructors inside interface and then report a relevent error message
+InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody
+/.$putCase ignoreInvalidConstructorDeclaration(true); $break ./
+
+InvalidConstructorDeclaration ::= ConstructorHeader ';'
+/.$putCase ignoreInvalidConstructorDeclaration(false); $break ./
+
+InterfaceMemberDeclaration -> AbstractMethodDeclaration
+InterfaceMemberDeclaration -> InvalidConstructorDeclaration
+
+--1.1 feature
+InterfaceMemberDeclaration -> ClassDeclaration
+--1.1 feature
+InterfaceMemberDeclaration -> InterfaceDeclaration
+
+ConstantDeclaration -> FieldDeclaration
+
+ArrayInitializer ::= '{' ,opt '}'
+/.$putCase consumeEmptyArrayInitializer(); $break ./
+ArrayInitializer ::= '{' VariableInitializers '}'
+/.$putCase consumeArrayInitializer(); $break ./
+ArrayInitializer ::= '{' VariableInitializers , '}'
+/.$putCase consumeArrayInitializer(); $break ./
+
+VariableInitializers ::= VariableInitializer
+VariableInitializers ::= VariableInitializers ',' VariableInitializer
+/.$putCase consumeVariableInitializers(); $break ./
+
+Block ::= OpenBlock '{' BlockStatementsopt '}'
+/.$putCase consumeBlock(); $break ./
+OpenBlock ::= $empty
+/.$putCase consumeOpenBlock() ; $break ./
+
+BlockStatements -> BlockStatement
+BlockStatements ::= BlockStatements BlockStatement
+/.$putCase consumeBlockStatements() ; $break ./
+
+BlockStatement -> LocalVariableDeclarationStatement
+BlockStatement -> Statement
+--1.1 feature
+BlockStatement -> ClassDeclaration
+BlockStatement ::= InvalidInterfaceDeclaration
+/.$putCase ignoreInterfaceDeclaration(); $break ./
+
+LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';'
+/.$putCase consumeLocalVariableDeclarationStatement(); $break ./
+
+LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators
+/.$putCase consumeLocalVariableDeclaration(); $break ./
+
+-- 1.1 feature
+-- The modifiers part of this rule makes the grammar more permissive.
+-- The only modifier here is final. We put Modifiers to allow multiple modifiers
+-- This will require to check the validity of the modifier
+
+LocalVariableDeclaration ::= Modifiers Type PushModifiers VariableDeclarators
+/.$putCase consumeLocalVariableDeclaration(); $break ./
+
+PushModifiers ::= $empty
+/.$putCase consumePushModifiers(); $break ./
+
+Statement -> StatementWithoutTrailingSubstatement
+Statement -> LabeledStatement
+Statement -> IfThenStatement
+Statement -> IfThenElseStatement
+Statement -> WhileStatement
+Statement -> ForStatement
+
+StatementNoShortIf -> StatementWithoutTrailingSubstatement
+StatementNoShortIf -> LabeledStatementNoShortIf
+StatementNoShortIf -> IfThenElseStatementNoShortIf
+StatementNoShortIf -> WhileStatementNoShortIf
+StatementNoShortIf -> ForStatementNoShortIf
+
+StatementWithoutTrailingSubstatement -> AssertStatement
+StatementWithoutTrailingSubstatement -> Block
+StatementWithoutTrailingSubstatement -> EmptyStatement
+StatementWithoutTrailingSubstatement -> ExpressionStatement
+StatementWithoutTrailingSubstatement -> SwitchStatement
+StatementWithoutTrailingSubstatement -> DoStatement
+StatementWithoutTrailingSubstatement -> BreakStatement
+StatementWithoutTrailingSubstatement -> ContinueStatement
+StatementWithoutTrailingSubstatement -> ReturnStatement
+StatementWithoutTrailingSubstatement -> SynchronizedStatement
+StatementWithoutTrailingSubstatement -> ThrowStatement
+StatementWithoutTrailingSubstatement -> TryStatement
+
+EmptyStatement ::= ';'
+/.$putCase consumeEmptyStatement(); $break ./
+
+LabeledStatement ::= 'Identifier' ':' Statement
+/.$putCase consumeStatementLabel() ; $break ./
+
+LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf
+/.$putCase consumeStatementLabel() ; $break ./
+
+ExpressionStatement ::= StatementExpression ';'
+/. $putCase consumeExpressionStatement(); $break ./
+
+StatementExpression ::= Assignment
+StatementExpression ::= PreIncrementExpression
+StatementExpression ::= PreDecrementExpression
+StatementExpression ::= PostIncrementExpression
+StatementExpression ::= PostDecrementExpression
+StatementExpression ::= MethodInvocation
+StatementExpression ::= ClassInstanceCreationExpression
+
+IfThenStatement ::= 'if' '(' Expression ')' Statement
+/.$putCase consumeStatementIfNoElse(); $break ./
+
+IfThenElseStatement ::= 'if' '(' Expression ')' StatementNoShortIf 'else' Statement
+/.$putCase consumeStatementIfWithElse(); $break ./
+
+IfThenElseStatementNoShortIf ::= 'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf
+/.$putCase consumeStatementIfWithElse(); $break ./
+
+SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock
+/.$putCase consumeStatementSwitch() ; $break ./
+
+SwitchBlock ::= '{' '}'
+/.$putCase consumeEmptySwitchBlock() ; $break ./
+
+SwitchBlock ::= '{' SwitchBlockStatements '}'
+SwitchBlock ::= '{' SwitchLabels '}'
+SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}'
+/.$putCase consumeSwitchBlock() ; $break ./
+
+SwitchBlockStatements -> SwitchBlockStatement
+SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement
+/.$putCase consumeSwitchBlockStatements() ; $break ./
+
+SwitchBlockStatement ::= SwitchLabels BlockStatements
+/.$putCase consumeSwitchBlockStatement() ; $break ./
+
+SwitchLabels -> SwitchLabel
+SwitchLabels ::= SwitchLabels SwitchLabel
+/.$putCase consumeSwitchLabels() ; $break ./
+
+SwitchLabel ::= 'case' ConstantExpression ':'
+/. $putCase consumeCaseLabel(); $break ./
+
+SwitchLabel ::= 'default' ':'
+/. $putCase consumeDefaultLabel(); $break ./
+
+WhileStatement ::= 'while' '(' Expression ')' Statement
+/.$putCase consumeStatementWhile() ; $break ./
+
+WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf
+/.$putCase consumeStatementWhile() ; $break ./
+
+DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';'
+/.$putCase consumeStatementDo() ; $break ./
+
+ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement
+/.$putCase consumeStatementFor() ; $break ./
+ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf
+/.$putCase consumeStatementFor() ; $break ./
+
+--the minus one allows to avoid a stack-to-stack transfer
+ForInit ::= StatementExpressionList
+/.$putCase consumeForInit() ; $break ./
+ForInit -> LocalVariableDeclaration
+
+ForUpdate -> StatementExpressionList
+
+StatementExpressionList -> StatementExpression
+StatementExpressionList ::= StatementExpressionList ',' StatementExpression
+/.$putCase consumeStatementExpressionList() ; $break ./
+
+-- 1.4 feature
+AssertStatement ::= 'assert' Expression ';'
+/.$putCase consumeSimpleAssertStatement() ; $break ./
+
+AssertStatement ::= 'assert' Expression ':' Expression ';'
+/.$putCase consumeAssertStatement() ; $break ./
+
+BreakStatement ::= 'break' ';'
+/.$putCase consumeStatementBreak() ; $break ./
+
+BreakStatement ::= 'break' Identifier ';'
+/.$putCase consumeStatementBreakWithLabel() ; $break ./
+
+ContinueStatement ::= 'continue' ';'
+/.$putCase consumeStatementContinue() ; $break ./
+
+ContinueStatement ::= 'continue' Identifier ';'
+/.$putCase consumeStatementContinueWithLabel() ; $break ./
+
+ReturnStatement ::= 'return' Expressionopt ';'
+/.$putCase consumeStatementReturn() ; $break ./
+
+ThrowStatement ::= 'throw' Expression ';'
+/.$putCase consumeStatementThrow();
+$break ./
+
+SynchronizedStatement ::= OnlySynchronized '(' Expression ')' Block
+/.$putCase consumeStatementSynchronized(); $break ./
+OnlySynchronized ::= 'synchronized'
+/.$putCase consumeOnlySynchronized(); $break ./
+
+
+TryStatement ::= 'try' Block Catches
+/.$putCase consumeStatementTry(false); $break ./
+TryStatement ::= 'try' Block Catchesopt Finally
+/.$putCase consumeStatementTry(true); $break ./
+
+Catches -> CatchClause
+Catches ::= Catches CatchClause
+/.$putCase consumeCatches(); $break ./
+
+CatchClause ::= 'catch' '(' FormalParameter ')' Block
+/.$putCase consumeStatementCatch() ; $break ./
+
+Finally ::= 'finally' Block
+
+--18.12 Productions from 14: Expressions
+
+--for source positionning purpose
+PushLPAREN ::= '('
+/.$putCase consumeLeftParen(); $break ./
+PushRPAREN ::= ')'
+/.$putCase consumeRightParen(); $break ./
+
+Primary -> PrimaryNoNewArray
+Primary -> ArrayCreationWithArrayInitializer
+Primary -> ArrayCreationWithoutArrayInitializer
+
+PrimaryNoNewArray -> Literal
+PrimaryNoNewArray ::= 'this'
+/.$putCase consumePrimaryNoNewArrayThis(); $break ./
+
+PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN
+/.$putCase consumePrimaryNoNewArray(); $break ./
+
+PrimaryNoNewArray -> ClassInstanceCreationExpression
+PrimaryNoNewArray -> FieldAccess
+--1.1 feature
+PrimaryNoNewArray ::= Name '.' 'this'
+/.$putCase consumePrimaryNoNewArrayNameThis(); $break ./
+PrimaryNoNewArray ::= Name '.' 'super'
+/.$putCase consumePrimaryNoNewArrayNameSuper(); $break ./
+
+--1.1 feature
+--PrimaryNoNewArray ::= Type '.' 'class'
+--inline Type in the previous rule in order to make the grammar LL1 instead
+-- of LL2. The result is the 3 next rules.
+PrimaryNoNewArray ::= Name '.' 'class'
+/.$putCase consumePrimaryNoNewArrayName(); $break ./
+
+PrimaryNoNewArray ::= ArrayType '.' 'class'
+/.$putCase consumePrimaryNoNewArrayArrayType(); $break ./
+
+PrimaryNoNewArray ::= PrimitiveType '.' 'class'
+/.$putCase consumePrimaryNoNewArrayPrimitiveType(); $break ./
+
+PrimaryNoNewArray -> MethodInvocation
+PrimaryNoNewArray -> ArrayAccess
+
+--1.1 feature
+--
+-- In Java 1.0 a ClassBody could not appear at all in a
+-- ClassInstanceCreationExpression.
+--
+
+AllocationHeader ::= 'new' ClassType '(' ArgumentListopt ')'
+/.$putCase consumeAllocationHeader(); $break ./
+
+ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
+/.$putCase consumeClassInstanceCreationExpression(); $break ./
+--1.1 feature
+
+ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
+/.$putCase consumeClassInstanceCreationExpressionQualified() ; $break ./
+
+--1.1 feature
+ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
+/.$putCase consumeClassInstanceCreationExpressionQualified() ; $break ./
+
+ClassInstanceCreationExpressionName ::= Name '.'
+/.$putCase consumeClassInstanceCreationExpressionName() ; $break ./
+
+ClassBodyopt ::= $empty --test made using null as contents
+/.$putCase consumeClassBodyopt(); $break ./
+ClassBodyopt ::= EnterAnonymousClassBody ClassBody
+
+EnterAnonymousClassBody ::= $empty
+/.$putCase consumeEnterAnonymousClassBody(); $break ./
+
+ArgumentList ::= Expression
+ArgumentList ::= ArgumentList ',' Expression
+/.$putCase consumeArgumentList(); $break ./
+
+ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
+/.$putCase consumeArrayCreationExpressionWithoutInitializer(); $break ./
+
+ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
+/.$putCase consumeArrayCreationExpressionWithInitializer(); $break ./
+
+ArrayCreationWithoutArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
+/.$putCase consumeArrayCreationExpressionWithoutInitializer(); $break ./
+
+ArrayCreationWithArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializer
+/.$putCase consumeArrayCreationExpressionWithInitializer(); $break ./
+
+DimWithOrWithOutExprs ::= DimWithOrWithOutExpr
+DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr
+/.$putCase consumeDimWithOrWithOutExprs(); $break ./
+
+DimWithOrWithOutExpr ::= '[' Expression ']'
+DimWithOrWithOutExpr ::= '[' ']'
+/. $putCase consumeDimWithOrWithOutExpr(); $break ./
+-- -----------------------------------------------
+
+Dims ::= DimsLoop
+/. $putCase consumeDims(); $break ./
+DimsLoop -> OneDimLoop
+DimsLoop ::= DimsLoop OneDimLoop
+OneDimLoop ::= '[' ']'
+/. $putCase consumeOneDimLoop(); $break ./
+
+FieldAccess ::= Primary '.' 'Identifier'
+/.$putCase consumeFieldAccess(false); $break ./
+
+FieldAccess ::= 'super' '.' 'Identifier'
+/.$putCase consumeFieldAccess(true); $break ./
+
+MethodInvocation ::= Name '(' ArgumentListopt ')'
+/.$putCase consumeMethodInvocationName(); $break ./
+
+MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')'
+/.$putCase consumeMethodInvocationPrimary(); $break ./
+
+MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')'
+/.$putCase consumeMethodInvocationSuper(); $break ./
+
+ArrayAccess ::= Name '[' Expression ']'
+/.$putCase consumeArrayAccess(true); $break ./
+ArrayAccess ::= PrimaryNoNewArray '[' Expression ']'
+/.$putCase consumeArrayAccess(false); $break ./
+ArrayAccess ::= ArrayCreationWithArrayInitializer '[' Expression ']'
+/.$putCase consumeArrayAccess(false); $break ./
+
+PostfixExpression -> Primary
+PostfixExpression ::= Name
+/.$putCase consumePostfixExpression(); $break ./
+PostfixExpression -> PostIncrementExpression
+PostfixExpression -> PostDecrementExpression
+
+PostIncrementExpression ::= PostfixExpression '++'
+/.$putCase consumeUnaryExpression(OperatorExpression.PLUS,true); $break ./
+
+PostDecrementExpression ::= PostfixExpression '--'
+/.$putCase consumeUnaryExpression(OperatorExpression.MINUS,true); $break ./
+
+--for source managment purpose
+PushPosition ::= $empty
+ /.$putCase consumePushPosition(); $break ./
+
+UnaryExpression -> PreIncrementExpression
+UnaryExpression -> PreDecrementExpression
+UnaryExpression ::= '+' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.PLUS); $break ./
+UnaryExpression ::= '-' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.MINUS); $break ./
+UnaryExpression -> UnaryExpressionNotPlusMinus
+
+PreIncrementExpression ::= '++' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.PLUS,false); $break ./
+
+PreDecrementExpression ::= '--' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.MINUS,false); $break ./
+
+UnaryExpressionNotPlusMinus -> PostfixExpression
+UnaryExpressionNotPlusMinus ::= '~' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.TWIDDLE); $break ./
+UnaryExpressionNotPlusMinus ::= '!' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.NOT); $break ./
+UnaryExpressionNotPlusMinus -> CastExpression
+
+CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN InsideCastExpression UnaryExpression
+/.$putCase consumeCastExpression(); $break ./
+ CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
+/.$putCase consumeCastExpression(); $break ./
+-- Expression is here only in order to make the grammar LL1
+CastExpression ::= PushLPAREN Expression PushRPAREN InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
+/.$putCase consumeCastExpressionLL1(); $break ./
+
+InsideCastExpression ::= $empty
+/.$putCase consumeInsideCastExpression(); $break ./
+InsideCastExpressionLL1 ::= $empty
+/.$putCase consumeInsideCastExpressionLL1(); $break ./
+
+MultiplicativeExpression -> UnaryExpression
+MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.MULTIPLY); $break ./
+MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.DIVIDE); $break ./
+MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.REMAINDER); $break ./
+
+AdditiveExpression -> MultiplicativeExpression
+AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.PLUS); $break ./
+AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.MINUS); $break ./
+
+ShiftExpression -> AdditiveExpression
+ShiftExpression ::= ShiftExpression '<<' AdditiveExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.LEFT_SHIFT); $break ./
+ShiftExpression ::= ShiftExpression '>>' AdditiveExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.RIGHT_SHIFT); $break ./
+ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.UNSIGNED_RIGHT_SHIFT); $break ./
+
+RelationalExpression -> ShiftExpression
+RelationalExpression ::= RelationalExpression '<' ShiftExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.LESS); $break ./
+RelationalExpression ::= RelationalExpression '>' ShiftExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.GREATER); $break ./
+RelationalExpression ::= RelationalExpression '<=' ShiftExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.LESS_EQUAL); $break ./
+RelationalExpression ::= RelationalExpression '>=' ShiftExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.GREATER_EQUAL); $break ./
+RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType
+/.$putCase consumeInstanceOfExpression(OperatorExpression.INSTANCEOF); $break ./
+
+EqualityExpression -> RelationalExpression
+EqualityExpression ::= EqualityExpression '==' RelationalExpression
+/.$putCase consumeEqualityExpression(OperatorExpression.EQUAL_EQUAL); $break ./
+EqualityExpression ::= EqualityExpression '!=' RelationalExpression
+/.$putCase consumeEqualityExpression(OperatorExpression.NOT_EQUAL); $break ./
+
+AndExpression -> EqualityExpression
+AndExpression ::= AndExpression '&' EqualityExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.AND); $break ./
+
+ExclusiveOrExpression -> AndExpression
+ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.XOR); $break ./
+
+InclusiveOrExpression -> ExclusiveOrExpression
+InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.OR); $break ./
+
+ConditionalAndExpression -> InclusiveOrExpression
+ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.AND_AND); $break ./
+
+ConditionalOrExpression -> ConditionalAndExpression
+ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.OR_OR); $break ./
+
+ConditionalExpression -> ConditionalOrExpression
+ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression
+/.$putCase consumeConditionalExpression(OperatorExpression.QUESTIONCOLON) ; $break ./
+
+AssignmentExpression -> ConditionalExpression
+AssignmentExpression -> Assignment
+
+Assignment ::= PostfixExpression AssignmentOperator AssignmentExpression
+/.$putCase consumeAssignment(); $break ./
+
+-- this rule is added to parse an array initializer in a assigment and then report a syntax error knowing the exact senario
+InvalidArrayInitializerAssignement ::= PostfixExpression AssignmentOperator ArrayInitializer
+Assignment ::= InvalidArrayInitializerAssignement
+/.$putcase ignoreExpressionAssignment();$break ./
+
+AssignmentOperator ::= '='
+/.$putCase consumeAssignmentOperator(EQUAL); $break ./
+AssignmentOperator ::= '*='
+/.$putCase consumeAssignmentOperator(MULTIPLY); $break ./
+AssignmentOperator ::= '/='
+/.$putCase consumeAssignmentOperator(DIVIDE); $break ./
+AssignmentOperator ::= '%='
+/.$putCase consumeAssignmentOperator(REMAINDER); $break ./
+AssignmentOperator ::= '+='
+/.$putCase consumeAssignmentOperator(PLUS); $break ./
+AssignmentOperator ::= '-='
+/.$putCase consumeAssignmentOperator(MINUS); $break ./
+AssignmentOperator ::= '<<='
+/.$putCase consumeAssignmentOperator(LEFT_SHIFT); $break ./
+AssignmentOperator ::= '>>='
+/.$putCase consumeAssignmentOperator(RIGHT_SHIFT); $break ./
+AssignmentOperator ::= '>>>='
+/.$putCase consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT); $break ./
+AssignmentOperator ::= '&='
+/.$putCase consumeAssignmentOperator(AND); $break ./
+AssignmentOperator ::= '^='
+/.$putCase consumeAssignmentOperator(XOR); $break ./
+AssignmentOperator ::= '|='
+/.$putCase consumeAssignmentOperator(OR); $break ./
+
+Expression -> AssignmentExpression
+
+ConstantExpression -> Expression
+
+-- The following rules are for optional nonterminals.
+--
+
+PackageDeclarationopt -> $empty
+PackageDeclarationopt -> PackageDeclaration
+
+ClassHeaderExtendsopt ::= $empty
+ClassHeaderExtendsopt -> ClassHeaderExtends
+
+Expressionopt ::= $empty
+/.$putCase consumeEmptyExpression(); $break ./
+Expressionopt -> Expression
+
+
+---------------------------------------------------------------------------------------
+--
+-- The rules below are for optional terminal symbols. An optional comma,
+-- is only used in the context of an array initializer - It is a
+-- "syntactic sugar" that otherwise serves no other purpose. By contrast,
+-- an optional identifier is used in the definition of a break and
+-- continue statement. When the identifier does not appear, a NULL
+-- is produced. When the identifier is present, the user should use the
+-- corresponding TOKEN(i) method. See break statement as an example.
+--
+---------------------------------------------------------------------------------------
+
+,opt -> $empty
+,opt -> ,
+
+ImportDeclarationsopt ::= $empty
+/.$putCase consumeEmptyImportDeclarationsopt(); $break ./
+ImportDeclarationsopt ::= ImportDeclarations
+/.$putCase consumeImportDeclarationsopt(); $break ./
+
+
+TypeDeclarationsopt ::= $empty
+/.$putCase consumeEmptyTypeDeclarationsopt(); $break ./
+TypeDeclarationsopt ::= TypeDeclarations
+/.$putCase consumeTypeDeclarationsopt(); $break ./
+
+ClassBodyDeclarationsopt ::= $empty
+/.$putCase consumeEmptyClassBodyDeclarationsopt(); $break ./
+ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations
+/.$putCase consumeClassBodyDeclarationsopt(); $break ./
+
+Modifiersopt ::= $empty
+/. $putCase consumeDefaultModifiers(); $break ./
+Modifiersopt ::= Modifiers
+/.$putCase consumeModifiers(); $break ./
+
+BlockStatementsopt ::= $empty
+/.$putCase consumeEmptyBlockStatementsopt(); $break ./
+BlockStatementsopt -> BlockStatements
+
+Dimsopt ::= $empty
+/. $putCase consumeEmptyDimsopt(); $break ./
+Dimsopt -> Dims
+
+ArgumentListopt ::= $empty
+/. $putCase consumeEmptyArgumentListopt(); $break ./
+ArgumentListopt -> ArgumentList
+
+MethodHeaderThrowsClauseopt ::= $empty
+MethodHeaderThrowsClauseopt -> MethodHeaderThrowsClause
+
+FormalParameterListopt ::= $empty
+/.$putcase consumeFormalParameterListopt(); $break ./
+FormalParameterListopt -> FormalParameterList
+
+ClassHeaderImplementsopt ::= $empty
+ClassHeaderImplementsopt -> ClassHeaderImplements
+
+InterfaceMemberDeclarationsopt ::= $empty
+/. $putCase consumeEmptyInterfaceMemberDeclarationsopt(); $break ./
+InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations
+/. $putCase consumeInterfaceMemberDeclarationsopt(); $break ./
+
+NestedType ::= $empty
+/.$putCase consumeNestedType(); $break./
+
+ForInitopt ::= $empty
+/. $putCase consumeEmptyForInitopt(); $break ./
+ForInitopt -> ForInit
+
+ForUpdateopt ::= $empty
+/. $putCase consumeEmptyForUpdateopt(); $break ./
+ ForUpdateopt -> ForUpdate
+
+InterfaceHeaderExtendsopt ::= $empty
+InterfaceHeaderExtendsopt -> InterfaceHeaderExtends
+
+Catchesopt ::= $empty
+/. $putCase consumeEmptyCatchesopt(); $break ./
+Catchesopt -> Catches
+
+/. }
+} ./
+
+---------------------------------------------------------------------------------------
+
+$names
+
+-- BodyMarker ::= '"class Identifier { ... MethodHeader "'
+
+-- void ::= 'void'
+
+PLUS_PLUS ::= '++'
+MINUS_MINUS ::= '--'
+EQUAL_EQUAL ::= '=='
+LESS_EQUAL ::= '<='
+GREATER_EQUAL ::= '>='
+NOT_EQUAL ::= '!='
+LEFT_SHIFT ::= '<<'
+RIGHT_SHIFT ::= '>>'
+UNSIGNED_RIGHT_SHIFT ::= '>>>'
+PLUS_EQUAL ::= '+='
+MINUS_EQUAL ::= '-='
+MULTIPLY_EQUAL ::= '*='
+DIVIDE_EQUAL ::= '/='
+AND_EQUAL ::= '&='
+OR_EQUAL ::= '|='
+XOR_EQUAL ::= '^='
+REMAINDER_EQUAL ::= '%='
+LEFT_SHIFT_EQUAL ::= '<<='
+RIGHT_SHIFT_EQUAL ::= '>>='
+UNSIGNED_RIGHT_SHIFT_EQUAL ::= '>>>='
+OR_OR ::= '||'
+AND_AND ::= '&&'
+
+PLUS ::= '+'
+MINUS ::= '-'
+NOT ::= '!'
+REMAINDER ::= '%'
+XOR ::= '^'
+AND ::= '&'
+MULTIPLY ::= '*'
+OR ::= '|'
+TWIDDLE ::= '~'
+DIVIDE ::= '/'
+GREATER ::= '>'
+LESS ::= '<'
+LPAREN ::= '('
+RPAREN ::= ')'
+LBRACE ::= '{'
+RBRACE ::= '}'
+LBRACKET ::= '['
+RBRACKET ::= ']'
+SEMICOLON ::= ';'
+QUESTION ::= '?'
+COLON ::= ':'
+COMMA ::= ','
+DOT ::= '.'
+EQUAL ::= '='
+
+$end
+-- need a carriage return after the $end
diff --git a/org.eclipse.jdt.core/grammar/java_1_5.g b/org.eclipse.jdt.core/grammar/java_1_5.g
new file mode 100644
index 0000000..dcf5112
--- /dev/null
+++ b/org.eclipse.jdt.core/grammar/java_1_5.g
@@ -0,0 +1,1340 @@
+--main options
+%options ACTION, AN=JavaAction.java, GP=java, CONFLICTS, WARNINGS,
+%options FILE-PREFIX=java, ESCAPE=$, PREFIX=TokenName, OUTPUT-SIZE=125 ,
+%options NOGOTO-DEFAULT, SINGLE-PRODUCTIONS, LALR=1 , TABLE=TIME ,
+
+--error recovering options.....
+%options ERROR_MAPS
+
+--grammar understanding options
+%options first follow
+%options TRACE=FULL ,
+%options VERBOSE
+
+--Usefull macros helping reading/writing semantic actions
+$Define
+$putCase
+/. case $rule_number : // System.out.println("$rule_text");
+ ./
+
+$break
+/.
+ break ;
+./
+
+-- here it starts really ------------------------------------------
+$Terminals
+
+ Identifier
+
+ abstract assert boolean break byte case catch char class
+ continue default do double else extends false final finally float
+ for if implements import instanceof int
+ interface long native new null package private
+ protected public return short static strictfp super switch
+ synchronized this throw throws transient true try void
+ volatile while
+
+ IntegerLiteral
+ LongLiteral
+ FloatingPointLiteral
+ DoubleLiteral
+ CharacterLiteral
+ StringLiteral
+
+ PLUS_PLUS
+ MINUS_MINUS
+ EQUAL_EQUAL
+ LESS_EQUAL
+ GREATER_EQUAL
+ NOT_EQUAL
+ LEFT_SHIFT
+ RIGHT_SHIFT
+ UNSIGNED_RIGHT_SHIFT
+ PLUS_EQUAL
+ MINUS_EQUAL
+ MULTIPLY_EQUAL
+ DIVIDE_EQUAL
+ AND_EQUAL
+ OR_EQUAL
+ XOR_EQUAL
+ REMAINDER_EQUAL
+ LEFT_SHIFT_EQUAL
+ RIGHT_SHIFT_EQUAL
+ UNSIGNED_RIGHT_SHIFT_EQUAL
+ OR_OR
+ AND_AND
+ PLUS
+ MINUS
+ NOT
+ REMAINDER
+ XOR
+ AND
+ MULTIPLY
+ OR
+ TWIDDLE
+ DIVIDE
+ GREATER
+ LESS
+ LPAREN
+ RPAREN
+ LBRACE
+ RBRACE
+ LBRACKET
+ RBRACKET
+ SEMICOLON
+ QUESTION
+ COLON
+ COMMA
+ DOT
+ EQUAL
+
+-- BodyMarker
+
+$Alias
+
+ '++' ::= PLUS_PLUS
+ '--' ::= MINUS_MINUS
+ '==' ::= EQUAL_EQUAL
+ '<=' ::= LESS_EQUAL
+ '>=' ::= GREATER_EQUAL
+ '!=' ::= NOT_EQUAL
+ '<<' ::= LEFT_SHIFT
+ '>>' ::= RIGHT_SHIFT
+ '>>>' ::= UNSIGNED_RIGHT_SHIFT
+ '+=' ::= PLUS_EQUAL
+ '-=' ::= MINUS_EQUAL
+ '*=' ::= MULTIPLY_EQUAL
+ '/=' ::= DIVIDE_EQUAL
+ '&=' ::= AND_EQUAL
+ '|=' ::= OR_EQUAL
+ '^=' ::= XOR_EQUAL
+ '%=' ::= REMAINDER_EQUAL
+ '<<=' ::= LEFT_SHIFT_EQUAL
+ '>>=' ::= RIGHT_SHIFT_EQUAL
+ '>>>=' ::= UNSIGNED_RIGHT_SHIFT_EQUAL
+ '||' ::= OR_OR
+ '&&' ::= AND_AND
+
+ '+' ::= PLUS
+ '-' ::= MINUS
+ '!' ::= NOT
+ '%' ::= REMAINDER
+ '^' ::= XOR
+ '&' ::= AND
+ '*' ::= MULTIPLY
+ '|' ::= OR
+ '~' ::= TWIDDLE
+ '/' ::= DIVIDE
+ '>' ::= GREATER
+ '<' ::= LESS
+ '(' ::= LPAREN
+ ')' ::= RPAREN
+ '{' ::= LBRACE
+ '}' ::= RBRACE
+ '[' ::= LBRACKET
+ ']' ::= RBRACKET
+ ';' ::= SEMICOLON
+ '?' ::= QUESTION
+ ':' ::= COLON
+ ',' ::= COMMA
+ '.' ::= DOT
+ '=' ::= EQUAL
+
+$Start
+ Goal
+
+$Rules
+
+/. // This method is part of an automatic generation : do NOT edit-modify
+protected void consumeRule(int act) {
+ switch ( act ) {
+./
+
+Goal ::= '++' CompilationUnit
+Goal ::= '--' MethodBody
+Goal ::= '==' ConstructorBody
+
+-- Initializer
+Goal ::= '>>' StaticInitializer
+Goal ::= '>>' Initializer
+
+-- error recovery
+Goal ::= '>>>' Headers
+Goal ::= '*' BlockStatements
+Goal ::= '*' MethodPushModifiersHeader
+Goal ::= '*' CatchHeader
+
+-- JDOM
+Goal ::= '&&' FieldDeclaration
+Goal ::= '||' ImportDeclaration
+Goal ::= '?' PackageDeclaration
+Goal ::= '+' TypeDeclaration
+Goal ::= '/' GenericMethodDeclaration
+Goal ::= '&' ClassBodyDeclaration
+
+-- code snippet
+Goal ::= '%' Expression
+
+-- completion parser
+Goal ::= '!' ConstructorBlockStatementsopt
+Goal ::= '~' BlockStatementsopt
+
+Literal -> IntegerLiteral
+Literal -> LongLiteral
+Literal -> FloatingPointLiteral
+Literal -> DoubleLiteral
+Literal -> CharacterLiteral
+Literal -> StringLiteral
+Literal -> null
+Literal -> BooleanLiteral
+BooleanLiteral -> true
+BooleanLiteral -> false
+
+-------------------------------------------------------------
+-------------------------------------------------------------
+--a Type results in both a push of its dimension(s) and its name(s).
+
+Type ::= PrimitiveType
+ /.$putCase consumePrimitiveType(); $break ./
+Type -> ReferenceType
+
+PrimitiveType -> NumericType
+NumericType -> IntegralType
+NumericType -> FloatingPointType
+
+PrimitiveType -> 'boolean'
+PrimitiveType -> 'void'
+IntegralType -> 'byte'
+IntegralType -> 'short'
+IntegralType -> 'int'
+IntegralType -> 'long'
+IntegralType -> 'char'
+FloatingPointType -> 'float'
+FloatingPointType -> 'double'
+
+ReferenceType ::= ClassOrInterfaceType
+/.$putCase consumeReferenceType(); $break ./
+ReferenceType -> ArrayType -- here a push of dimensions is done, that explains the two previous push 0
+
+ClassOrInterfaceType -> Name
+-- 1.5 feature
+ClassOrInterfaceType ::= Name '<' ReferenceTypeList1
+
+-- BEGIN-1.5 : Additional rules to address 1.5 generics
+-- These rules are dealing with the fact that nested type parameters may use sequences
+-- of '>' which would be tokenized as distinct tokens ('>>' is right shift operator, '>>>' is unsigned right shift operator).
+
+TypeVariable -> 'Identifier'
+
+ReferenceTypeList -> ReferenceType
+ReferenceTypeList ::= ReferenceTypeList ',' ReferenceType
+
+ReferenceTypeList1 -> ReferenceType1
+ReferenceTypeList1 ::= ReferenceTypeList ',' ReferenceType1
+
+ReferenceType1 ::= ReferenceType '>'
+ReferenceType1 ::= Name '<' ReferenceTypeList2
+
+ReferenceTypeList2 -> ReferenceType2
+ReferenceTypeList2 ::= ReferenceTypeList ',' ReferenceType2
+
+ReferenceType2 ::= ReferenceType '>>'
+ReferenceType2 ::= Name '<' ReferenceTypeList3
+
+ReferenceTypeList3 -> ReferenceType3
+ReferenceTypeList3 ::= ReferenceTypeList ',' ReferenceType3
+
+ReferenceType3 ::= ReferenceType '>>>'
+
+TypeParameters ::= '<' TypeParameterList1
+
+TypeParameterList1 -> TypeParameter1
+TypeParameterList1 ::= TypeParameterList1 ',' TypeParameter1
+
+TypeParameter1 ::= TypeParameter '>'
+TypeParameter1 ::= TypeVariable 'extends' ReferenceType2
+
+-- following isn't supported
+-- TypeParameter1 ::= TypeVariable 'implements' ReferenceType2
+
+TypeParameter ::= TypeVariable TypeBoundopt
+
+TypeBound ::= 'extends' ClassOrInterfaceType AdditionalBoundListopt
+
+AdditionalBoundList -> AdditionalBound
+AdditionalBoundList ::= AdditionalBoundList ',' AdditionalBound
+
+AdditionalBound ::= '&' InterfaceType
+
+-- END-1.5 : Additional rules to address 1.5 generics
+
+--
+-- These rules have been rewritten to avoid some conflicts introduced
+-- by adding the 1.1 features
+--
+-- ArrayType ::= PrimitiveType '[' ']'
+-- ArrayType ::= Name '[' ']'
+-- ArrayType ::= ArrayType '[' ']'
+--
+
+ArrayType ::= PrimitiveType Dims
+ArrayType ::= Name Dims
+
+ClassType -> ClassOrInterfaceType
+
+
+--------------------------------------------------------------
+--------------------------------------------------------------
+
+Name -> SimpleName
+Name -> QualifiedName
+
+SimpleName -> 'Identifier'
+
+QualifiedName ::= Name '.' SimpleName
+/.$putCase consumeQualifiedName(); $break ./
+
+CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsopt
+/.$putCase consumeCompilationUnit(); $break ./
+
+EnterCompilationUnit ::= $empty
+/.$putCase consumeEnterCompilationUnit(); $break ./
+
+Headers -> Header
+Headers ::= Headers Header
+
+Header -> ImportDeclaration
+Header -> PackageDeclaration
+Header -> ClassHeader
+Header -> InterfaceHeader
+Header -> StaticInitializer
+Header -> MethodHeader
+Header -> ConstructorHeader
+Header -> FieldDeclaration
+Header -> AllocationHeader
+
+CatchHeader ::= 'catch' '(' FormalParameter ')' '{'
+/.$putCase consumeCatchHeader(); $break ./
+
+ImportDeclarations -> ImportDeclaration
+ImportDeclarations ::= ImportDeclarations ImportDeclaration
+/.$putCase consumeImportDeclarations(); $break ./
+
+TypeDeclarations -> TypeDeclaration
+TypeDeclarations ::= TypeDeclarations TypeDeclaration
+/.$putCase consumeTypeDeclarations(); $break ./
+
+PackageDeclaration ::= PackageDeclarationName ';'
+/.$putCase consumePackageDeclaration(); $break ./
+
+PackageDeclarationName ::= 'package' Name
+/.$putCase consumePackageDeclarationName(); $break ./
+
+ImportDeclaration -> SingleTypeImportDeclaration
+ImportDeclaration -> TypeImportOnDemandDeclaration
+
+SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';'
+/.$putCase consumeSingleTypeImportDeclaration(); $break ./
+
+SingleTypeImportDeclarationName ::= 'import' Name
+/.$putCase consumeSingleTypeImportDeclarationName(); $break ./
+
+TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName ';'
+/.$putCase consumeTypeImportOnDemandDeclaration(); $break ./
+
+TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*'
+/.$putCase consumeTypeImportOnDemandDeclarationName(); $break ./
+
+TypeDeclaration -> ClassDeclaration
+TypeDeclaration -> InterfaceDeclaration
+-- this declaration in part of a list od declaration and we will
+-- use and optimized list length calculation process
+-- thus we decrement the number while it will be incremend.....
+TypeDeclaration ::= ';'
+/. $putCase consumeEmptyTypeDeclaration(); $break ./
+
+--18.7 Only in the LALR(1) Grammar
+
+Modifiers ::= Modifier
+Modifiers ::= Modifiers Modifier
+
+Modifier -> 'public'
+Modifier -> 'protected'
+Modifier -> 'private'
+Modifier -> 'static'
+Modifier -> 'abstract'
+Modifier -> 'final'
+Modifier -> 'native'
+Modifier -> 'synchronized'
+Modifier -> 'transient'
+Modifier -> 'volatile'
+Modifier -> 'strictfp'
+
+--18.8 Productions from 8: Class Declarations
+--ClassModifier ::=
+-- 'abstract'
+-- | 'final'
+-- | 'public'
+--18.8.1 Productions from 8.1: Class Declarations
+
+ClassDeclaration ::= ClassHeader ClassBody
+/.$putCase consumeClassDeclaration(); $break ./
+
+ClassHeader ::= ClassHeaderName ClassHeaderParametersopt ClassHeaderExtendsopt ClassHeaderImplementsopt
+/.$putCase consumeClassHeader(); $break ./
+
+ClassHeaderName ::= Modifiersopt 'class' 'Identifier'
+/.$putCase consumeClassHeaderName(); $break ./
+
+ClassHeaderParameters -> TypeParameters
+/.$putCase consumeClassHeaderParameters(); $break ./
+
+ClassHeaderExtends ::= 'extends' ClassType
+/.$putCase consumeClassHeaderExtends(); $break ./
+
+ClassHeaderImplements ::= 'implements' InterfaceTypeList
+/.$putCase consumeClassHeaderImplements(); $break ./
+
+InterfaceTypeList -> InterfaceType
+InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType
+/.$putCase consumeInterfaceTypeList(); $break ./
+
+InterfaceType ::= ClassOrInterfaceType
+/.$putCase consumeInterfaceType(); $break ./
+
+ClassBody ::= '{' ClassBodyDeclarationsopt '}'
+
+ClassBodyDeclarations ::= ClassBodyDeclaration
+ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration
+/.$putCase consumeClassBodyDeclarations(); $break ./
+
+ClassBodyDeclaration -> ClassMemberDeclaration
+ClassBodyDeclaration -> StaticInitializer
+ClassBodyDeclaration -> ConstructorDeclaration
+--1.1 feature
+ClassBodyDeclaration ::= Diet NestedMethod Block
+/.$putCase consumeClassBodyDeclaration(); $break ./
+Diet ::= $empty
+/.$putCase consumeDiet(); $break./
+
+Initializer ::= Diet NestedMethod Block
+/.$putCase consumeClassBodyDeclaration(); $break ./
+
+ClassMemberDeclaration -> FieldDeclaration
+ClassMemberDeclaration -> MethodDeclaration
+--1.1 feature
+ClassMemberDeclaration -> ClassDeclaration
+--1.1 feature
+ClassMemberDeclaration -> InterfaceDeclaration
+
+-- Empty declarations are not valid Java ClassMemberDeclarations.
+-- However, since the current (2/14/97) Java compiler accepts them
+-- (in fact, some of the official tests contain this erroneous
+-- syntax)
+
+GenericMethodDeclaration -> MethodDeclaration
+GenericMethodDeclaration -> ConstructorDeclaration
+
+ClassMemberDeclaration ::= ';'
+/.$putCase consumeEmptyClassMemberDeclaration(); $break./
+
+--18.8.2 Productions from 8.3: Field Declarations
+--VariableModifier ::=
+-- 'public'
+-- | 'protected'
+-- | 'private'
+-- | 'static'
+-- | 'final'
+-- | 'transient'
+-- | 'volatile'
+
+FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
+/.$putCase consumeFieldDeclaration(); $break ./
+
+VariableDeclarators -> VariableDeclarator
+VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator
+/.$putCase consumeVariableDeclarators(); $break ./
+
+VariableDeclarator ::= VariableDeclaratorId EnterVariable ExitVariableWithoutInitialization
+
+VariableDeclarator ::= VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization
+
+EnterVariable ::= $empty
+/.$putCase consumeEnterVariable(); $break ./
+
+ExitVariableWithInitialization ::= $empty
+/.$putCase consumeExitVariableWithInitialization(); $break ./
+
+ExitVariableWithoutInitialization ::= $empty
+/.$putCase consumeExitVariableWithoutInitialization(); $break ./
+
+ForceNoDiet ::= $empty
+/.$putCase consumeForceNoDiet(); $break ./
+RestoreDiet ::= $empty
+/.$putCase consumeRestoreDiet(); $break ./
+
+VariableDeclaratorId ::= 'Identifier' Dimsopt
+
+VariableInitializer -> Expression
+VariableInitializer -> ArrayInitializer
+
+--18.8.3 Productions from 8.4: Method Declarations
+--MethodModifier ::=
+-- 'public'
+-- | 'protected'
+-- | 'private'
+-- | 'static'
+-- | 'abstract'
+-- | 'final'
+-- | 'native'
+-- | 'synchronized'
+--
+
+MethodDeclaration -> AbstractMethodDeclaration
+MethodDeclaration ::= MethodHeader MethodBody
+/.$putCase // set to true to consume a method with a body
+ consumeMethodDeclaration(true); $break ./
+
+AbstractMethodDeclaration ::= MethodHeader ';'
+/.$putCase // set to false to consume a method without body
+ consumeMethodDeclaration(false); $break ./
+
+MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims MethodHeaderThrowsClauseopt
+/.$putCase consumeMethodHeader(); $break ./
+
+MethodPushModifiersHeader ::= MethodPushModifiersHeaderName MethodHeaderParameters MethodHeaderExtendedDims MethodHeaderThrowsClauseopt
+/.$putCase consumeMethodHeader(); $break ./
+
+MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers 'Identifier' '('
+/.$putCase consumeMethodPushModifiersHeaderName(); $break ./
+
+MethodPushModifiersHeaderName ::= Type PushModifiers 'Identifier' '('
+/.$putCase consumeMethodPushModifiersHeaderName(); $break ./
+
+MethodHeaderName ::= Modifiersopt Type 'Identifier' '('
+/.$putCase consumeMethodHeaderName(); $break ./
+
+MethodHeaderParameters ::= FormalParameterListopt ')'
+/.$putCase consumeMethodHeaderParameters(); $break ./
+
+MethodHeaderExtendedDims ::= Dimsopt
+/.$putCase consumeMethodHeaderExtendedDims(); $break ./
+
+MethodHeaderThrowsClause ::= 'throws' ClassTypeList
+/.$putCase consumeMethodHeaderThrowsClause(); $break ./
+
+ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters MethodHeaderThrowsClauseopt
+/.$putCase consumeConstructorHeader(); $break ./
+
+ConstructorHeaderName ::= Modifiersopt 'Identifier' '('
+/.$putCase consumeConstructorHeaderName(); $break ./
+
+FormalParameterList -> FormalParameter
+FormalParameterList ::= FormalParameterList ',' FormalParameter
+/.$putCase consumeFormalParameterList(); $break ./
+
+--1.1 feature
+FormalParameter ::= Modifiersopt Type VariableDeclaratorId
+/.$putCase // the boolean is used to know if the modifiers should be reset
+ consumeFormalParameter(); $break ./
+
+ClassTypeList -> ClassTypeElt
+ClassTypeList ::= ClassTypeList ',' ClassTypeElt
+/.$putCase consumeClassTypeList(); $break ./
+
+ClassTypeElt ::= ClassType
+/.$putCase consumeClassTypeElt(); $break ./
+
+
+MethodBody ::= NestedMethod '{' BlockStatementsopt '}'
+/.$putCase consumeMethodBody(); $break ./
+
+NestedMethod ::= $empty
+/.$putCase consumeNestedMethod(); $break ./
+
+--18.8.4 Productions from 8.5: Static Initializers
+
+StaticInitializer ::= StaticOnly Block
+/.$putCase consumeStaticInitializer(); $break./
+
+StaticOnly ::= 'static'
+/.$putCase consumeStaticOnly(); $break ./
+
+--18.8.5 Productions from 8.6: Constructor Declarations
+--ConstructorModifier ::=
+-- 'public'
+-- | 'protected'
+-- | 'private'
+--
+--
+ConstructorDeclaration ::= ConstructorHeader ConstructorBody
+/.$putCase consumeConstructorDeclaration() ; $break ./
+
+-- These rules are added to be able to parse constructors with no body
+ConstructorDeclaration ::= ConstructorHeader ';'
+/.$putCase consumeInvalidConstructorDeclaration() ; $break ./
+
+-- the rules ExplicitConstructorInvocationopt has been expanded
+-- in the rule below in order to make the grammar lalr(1).
+-- ConstructorBody ::= '{' ExplicitConstructorInvocationopt BlockStatementsopt '}'
+-- Other inlining has occured into the next rule too....
+
+ConstructorBody ::= NestedMethod '{' ConstructorBlockStatementsopt '}'
+/.$putCase consumeConstructorBody(); $break ./
+
+ConstructorBlockStatementsopt -> BlockStatementsopt
+
+ConstructorBlockStatementsopt -> ExplicitConstructorInvocation
+
+ConstructorBlockStatementsopt ::= ExplicitConstructorInvocation BlockStatements
+/.$putCase consumeConstructorBlockStatements(); $break ./
+
+ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.This); $break ./
+
+ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.Super); $break ./
+
+--1.1 feature
+ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.Super); $break ./
+
+--1.1 feature
+ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.Super); $break ./
+
+--1.1 feature
+ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.This); $break ./
+
+--1.1 feature
+ExplicitConstructorInvocation ::= Name '.' 'this' '(' ArgumentListopt ')' ';'
+/.$putCase consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.This); $break ./
+
+--18.9 Productions from 9: Interface Declarations
+
+--18.9.1 Productions from 9.1: Interface Declarations
+--InterfaceModifier ::=
+-- 'public'
+-- | 'abstract'
+--
+InterfaceDeclaration ::= InterfaceHeader InterfaceBody
+/.$putCase consumeInterfaceDeclaration(); $break ./
+
+InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderParametersopt InterfaceHeaderExtendsopt
+/.$putCase consumeInterfaceHeader(); $break ./
+
+InterfaceHeaderName ::= Modifiersopt 'interface' 'Identifier'
+/.$putCase consumeInterfaceHeaderName(); $break ./
+
+-- This rule will be used to accept inner local interface and then report a relevant error message
+InvalidInterfaceDeclaration -> InterfaceHeader InterfaceBody
+
+-- 1.5 feature
+InterfaceHeaderParameters -> TypeParameters
+/.$putCase consumeInterfaceHeaderParameters(); $break ./
+
+InterfaceHeaderExtends ::= 'extends' InterfaceTypeList
+/.$putCase consumeInterfaceHeaderExtends(); $break ./
+
+InterfaceBody ::= '{' InterfaceMemberDeclarationsopt '}'
+
+InterfaceMemberDeclarations -> InterfaceMemberDeclaration
+InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration
+/.$putCase consumeInterfaceMemberDeclarations(); $break ./
+
+--same as for class members
+InterfaceMemberDeclaration ::= ';'
+/.$putCase consumeEmptyInterfaceMemberDeclaration(); $break ./
+
+-- This rule is added to be able to parse non abstract method inside interface and then report a relevent error message
+InvalidMethodDeclaration -> MethodHeader MethodBody
+
+InterfaceMemberDeclaration -> ConstantDeclaration
+InterfaceMemberDeclaration ::= InvalidMethodDeclaration
+/.$putCase ignoreMethodBody(); $break ./
+
+-- These rules are added to be able to parse constructors inside interface and then report a relevent error message
+InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody
+/.$putCase ignoreInvalidConstructorDeclaration(true); $break ./
+
+InvalidConstructorDeclaration ::= ConstructorHeader ';'
+/.$putCase ignoreInvalidConstructorDeclaration(false); $break ./
+
+InterfaceMemberDeclaration -> AbstractMethodDeclaration
+InterfaceMemberDeclaration -> InvalidConstructorDeclaration
+
+--1.1 feature
+InterfaceMemberDeclaration -> ClassDeclaration
+--1.1 feature
+InterfaceMemberDeclaration -> InterfaceDeclaration
+
+ConstantDeclaration -> FieldDeclaration
+
+ArrayInitializer ::= '{' ,opt '}'
+/.$putCase consumeEmptyArrayInitializer(); $break ./
+ArrayInitializer ::= '{' VariableInitializers '}'
+/.$putCase consumeArrayInitializer(); $break ./
+ArrayInitializer ::= '{' VariableInitializers , '}'
+/.$putCase consumeArrayInitializer(); $break ./
+
+VariableInitializers ::= VariableInitializer
+VariableInitializers ::= VariableInitializers ',' VariableInitializer
+/.$putCase consumeVariableInitializers(); $break ./
+
+Block ::= OpenBlock '{' BlockStatementsopt '}'
+/.$putCase consumeBlock(); $break ./
+OpenBlock ::= $empty
+/.$putCase consumeOpenBlock() ; $break ./
+
+BlockStatements -> BlockStatement
+BlockStatements ::= BlockStatements BlockStatement
+/.$putCase consumeBlockStatements() ; $break ./
+
+BlockStatement -> LocalVariableDeclarationStatement
+BlockStatement -> Statement
+--1.1 feature
+BlockStatement -> ClassDeclaration
+BlockStatement ::= InvalidInterfaceDeclaration
+/.$putCase ignoreInterfaceDeclaration(); $break ./
+
+LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';'
+/.$putCase consumeLocalVariableDeclarationStatement(); $break ./
+
+LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators
+/.$putCase consumeLocalVariableDeclaration(); $break ./
+
+-- 1.1 feature
+-- The modifiers part of this rule makes the grammar more permissive.
+-- The only modifier here is final. We put Modifiers to allow multiple modifiers
+-- This will require to check the validity of the modifier
+
+LocalVariableDeclaration ::= Modifiers Type PushModifiers VariableDeclarators
+/.$putCase consumeLocalVariableDeclaration(); $break ./
+
+PushModifiers ::= $empty
+/.$putCase consumePushModifiers(); $break ./
+
+Statement -> StatementWithoutTrailingSubstatement
+Statement -> LabeledStatement
+Statement -> IfThenStatement
+Statement -> IfThenElseStatement
+Statement -> WhileStatement
+Statement -> ForStatement
+
+StatementNoShortIf -> StatementWithoutTrailingSubstatement
+StatementNoShortIf -> LabeledStatementNoShortIf
+StatementNoShortIf -> IfThenElseStatementNoShortIf
+StatementNoShortIf -> WhileStatementNoShortIf
+StatementNoShortIf -> ForStatementNoShortIf
+
+StatementWithoutTrailingSubstatement -> AssertStatement
+StatementWithoutTrailingSubstatement -> Block
+StatementWithoutTrailingSubstatement -> EmptyStatement
+StatementWithoutTrailingSubstatement -> ExpressionStatement
+StatementWithoutTrailingSubstatement -> SwitchStatement
+StatementWithoutTrailingSubstatement -> DoStatement
+StatementWithoutTrailingSubstatement -> BreakStatement
+StatementWithoutTrailingSubstatement -> ContinueStatement
+StatementWithoutTrailingSubstatement -> ReturnStatement
+StatementWithoutTrailingSubstatement -> SynchronizedStatement
+StatementWithoutTrailingSubstatement -> ThrowStatement
+StatementWithoutTrailingSubstatement -> TryStatement
+
+EmptyStatement ::= ';'
+/.$putCase consumeEmptyStatement(); $break ./
+
+LabeledStatement ::= 'Identifier' ':' Statement
+/.$putCase consumeStatementLabel() ; $break ./
+
+LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf
+/.$putCase consumeStatementLabel() ; $break ./
+
+ExpressionStatement ::= StatementExpression ';'
+/. $putCase consumeExpressionStatement(); $break ./
+
+StatementExpression ::= Assignment
+StatementExpression ::= PreIncrementExpression
+StatementExpression ::= PreDecrementExpression
+StatementExpression ::= PostIncrementExpression
+StatementExpression ::= PostDecrementExpression
+StatementExpression ::= MethodInvocation
+StatementExpression ::= ClassInstanceCreationExpression
+
+IfThenStatement ::= 'if' '(' Expression ')' Statement
+/.$putCase consumeStatementIfNoElse(); $break ./
+
+IfThenElseStatement ::= 'if' '(' Expression ')' StatementNoShortIf 'else' Statement
+/.$putCase consumeStatementIfWithElse(); $break ./
+
+IfThenElseStatementNoShortIf ::= 'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf
+/.$putCase consumeStatementIfWithElse(); $break ./
+
+SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock
+/.$putCase consumeStatementSwitch() ; $break ./
+
+SwitchBlock ::= '{' '}'
+/.$putCase consumeEmptySwitchBlock() ; $break ./
+
+SwitchBlock ::= '{' SwitchBlockStatements '}'
+SwitchBlock ::= '{' SwitchLabels '}'
+SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}'
+/.$putCase consumeSwitchBlock() ; $break ./
+
+SwitchBlockStatements -> SwitchBlockStatement
+SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement
+/.$putCase consumeSwitchBlockStatements() ; $break ./
+
+SwitchBlockStatement ::= SwitchLabels BlockStatements
+/.$putCase consumeSwitchBlockStatement() ; $break ./
+
+SwitchLabels -> SwitchLabel
+SwitchLabels ::= SwitchLabels SwitchLabel
+/.$putCase consumeSwitchLabels() ; $break ./
+
+SwitchLabel ::= 'case' ConstantExpression ':'
+/. $putCase consumeCaseLabel(); $break ./
+
+SwitchLabel ::= 'default' ':'
+/. $putCase consumeDefaultLabel(); $break ./
+
+WhileStatement ::= 'while' '(' Expression ')' Statement
+/.$putCase consumeStatementWhile() ; $break ./
+
+WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf
+/.$putCase consumeStatementWhile() ; $break ./
+
+DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';'
+/.$putCase consumeStatementDo() ; $break ./
+
+ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement
+/.$putCase consumeStatementFor() ; $break ./
+ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf
+/.$putCase consumeStatementFor() ; $break ./
+
+--the minus one allows to avoid a stack-to-stack transfer
+ForInit ::= StatementExpressionList
+/.$putCase consumeForInit() ; $break ./
+ForInit -> LocalVariableDeclaration
+
+ForUpdate -> StatementExpressionList
+
+StatementExpressionList -> StatementExpression
+StatementExpressionList ::= StatementExpressionList ',' StatementExpression
+/.$putCase consumeStatementExpressionList() ; $break ./
+
+-- 1.4 feature
+AssertStatement ::= 'assert' Expression ';'
+/.$putCase consumeSimpleAssertStatement() ; $break ./
+
+AssertStatement ::= 'assert' Expression ':' Expression ';'
+/.$putCase consumeAssertStatement() ; $break ./
+
+BreakStatement ::= 'break' ';'
+/.$putCase consumeStatementBreak() ; $break ./
+
+BreakStatement ::= 'break' Identifier ';'
+/.$putCase consumeStatementBreakWithLabel() ; $break ./
+
+ContinueStatement ::= 'continue' ';'
+/.$putCase consumeStatementContinue() ; $break ./
+
+ContinueStatement ::= 'continue' Identifier ';'
+/.$putCase consumeStatementContinueWithLabel() ; $break ./
+
+ReturnStatement ::= 'return' Expressionopt ';'
+/.$putCase consumeStatementReturn() ; $break ./
+
+ThrowStatement ::= 'throw' Expression ';'
+/.$putCase consumeStatementThrow();
+$break ./
+
+SynchronizedStatement ::= OnlySynchronized '(' Expression ')' Block
+/.$putCase consumeStatementSynchronized(); $break ./
+OnlySynchronized ::= 'synchronized'
+/.$putCase consumeOnlySynchronized(); $break ./
+
+
+TryStatement ::= 'try' Block Catches
+/.$putCase consumeStatementTry(false); $break ./
+TryStatement ::= 'try' Block Catchesopt Finally
+/.$putCase consumeStatementTry(true); $break ./
+
+Catches -> CatchClause
+Catches ::= Catches CatchClause
+/.$putCase consumeCatches(); $break ./
+
+CatchClause ::= 'catch' '(' FormalParameter ')' Block
+/.$putCase consumeStatementCatch() ; $break ./
+
+Finally ::= 'finally' Block
+
+--18.12 Productions from 14: Expressions
+
+--for source positionning purpose
+PushLPAREN ::= '('
+/.$putCase consumeLeftParen(); $break ./
+PushRPAREN ::= ')'
+/.$putCase consumeRightParen(); $break ./
+
+Primary -> PrimaryNoNewArray
+Primary -> ArrayCreationExpression
+
+PrimaryNoNewArray -> Literal
+PrimaryNoNewArray ::= 'this'
+/.$putCase consumePrimaryNoNewArrayThis(); $break ./
+
+PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN
+/.$putCase consumePrimaryNoNewArray(); $break ./
+
+PrimaryNoNewArray -> ClassInstanceCreationExpression
+PrimaryNoNewArray -> FieldAccess
+--1.1 feature
+PrimaryNoNewArray ::= Name '.' 'this'
+/.$putCase consumePrimaryNoNewArrayNameThis(); $break ./
+PrimaryNoNewArray ::= Name '.' 'super'
+/.$putCase consumePrimaryNoNewArrayNameSuper(); $break ./
+
+--1.1 feature
+--PrimaryNoNewArray ::= Type '.' 'class'
+--inline Type in the previous rule in order to make the grammar LL1 instead
+-- of LL2. The result is the 3 next rules.
+PrimaryNoNewArray ::= Name '.' 'class'
+/.$putCase consumePrimaryNoNewArrayName(); $break ./
+
+PrimaryNoNewArray ::= ArrayType '.' 'class'
+/.$putCase consumePrimaryNoNewArrayArrayType(); $break ./
+
+PrimaryNoNewArray ::= PrimitiveType '.' 'class'
+/.$putCase consumePrimaryNoNewArrayPrimitiveType(); $break ./
+
+PrimaryNoNewArray -> MethodInvocation
+PrimaryNoNewArray -> ArrayAccess
+
+--1.1 feature
+--
+-- In Java 1.0 a ClassBody could not appear at all in a
+-- ClassInstanceCreationExpression.
+--
+
+AllocationHeader ::= 'new' ClassType '(' ArgumentListopt ')'
+/.$putCase consumeAllocationHeader(); $break ./
+
+ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
+/.$putCase consumeClassInstanceCreationExpression(); $break ./
+--1.1 feature
+
+ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
+/.$putCase consumeClassInstanceCreationExpressionQualified() ; $break ./
+
+--1.1 feature
+ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
+/.$putCase consumeClassInstanceCreationExpressionQualified() ; $break ./
+
+ClassInstanceCreationExpressionName ::= Name '.'
+/.$putCase consumeClassInstanceCreationExpressionName() ; $break ./
+
+ClassBodyopt ::= $empty --test made using null as contents
+/.$putCase consumeClassBodyopt(); $break ./
+ClassBodyopt ::= EnterAnonymousClassBody ClassBody
+
+EnterAnonymousClassBody ::= $empty
+/.$putCase consumeEnterAnonymousClassBody(); $break ./
+
+ArgumentList ::= Expression
+ArgumentList ::= ArgumentList ',' Expression
+/.$putCase consumeArgumentList(); $break ./
+
+--Thess rules are re-written in order to be ll1
+--ArrayCreationExpression ::= 'new' ArrayType ArrayInitializer
+--ArrayCreationExpression ::= 'new' PrimitiveType DimExprs Dimsopt
+--ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimExprs Dimsopt
+--DimExprs ::= DimExpr
+--DimExprs ::= DimExprs DimExpr
+
+ArrayCreationExpression ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializeropt
+/.$putCase consumeArrayCreationExpression(); $break ./
+ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializeropt
+/.$putCase consumeArrayCreationExpression(); $break ./
+
+DimWithOrWithOutExprs ::= DimWithOrWithOutExpr
+DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr
+/.$putCase consumeDimWithOrWithOutExprs(); $break ./
+
+DimWithOrWithOutExpr ::= '[' Expression ']'
+DimWithOrWithOutExpr ::= '[' ']'
+/. $putCase consumeDimWithOrWithOutExpr(); $break ./
+-- -----------------------------------------------
+
+Dims ::= DimsLoop
+/. $putCase consumeDims(); $break ./
+DimsLoop -> OneDimLoop
+DimsLoop ::= DimsLoop OneDimLoop
+OneDimLoop ::= '[' ']'
+/. $putCase consumeOneDimLoop(); $break ./
+
+FieldAccess ::= Primary '.' 'Identifier'
+/.$putCase consumeFieldAccess(false); $break ./
+
+FieldAccess ::= 'super' '.' 'Identifier'
+/.$putCase consumeFieldAccess(true); $break ./
+
+MethodInvocation ::= Name '(' ArgumentListopt ')'
+/.$putCase consumeMethodInvocationName(); $break ./
+
+MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')'
+/.$putCase consumeMethodInvocationPrimary(); $break ./
+
+MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')'
+/.$putCase consumeMethodInvocationSuper(); $break ./
+
+ArrayAccess ::= Name '[' Expression ']'
+/.$putCase consumeArrayAccess(true); $break ./
+ArrayAccess ::= PrimaryNoNewArray '[' Expression ']'
+/.$putCase consumeArrayAccess(false); $break ./
+
+PostfixExpression -> Primary
+PostfixExpression ::= Name
+/.$putCase consumePostfixExpression(); $break ./
+PostfixExpression -> PostIncrementExpression
+PostfixExpression -> PostDecrementExpression
+
+PostIncrementExpression ::= PostfixExpression '++'
+/.$putCase consumeUnaryExpression(OperatorExpression.PLUS,true); $break ./
+
+PostDecrementExpression ::= PostfixExpression '--'
+/.$putCase consumeUnaryExpression(OperatorExpression.MINUS,true); $break ./
+
+--for source managment purpose
+PushPosition ::= $empty
+ /.$putCase consumePushPosition(); $break ./
+
+UnaryExpression -> PreIncrementExpression
+UnaryExpression -> PreDecrementExpression
+UnaryExpression ::= '+' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.PLUS); $break ./
+UnaryExpression ::= '-' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.MINUS); $break ./
+UnaryExpression -> UnaryExpressionNotPlusMinus
+
+PreIncrementExpression ::= '++' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.PLUS,false); $break ./
+
+PreDecrementExpression ::= '--' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.MINUS,false); $break ./
+
+UnaryExpressionNotPlusMinus -> PostfixExpression
+UnaryExpressionNotPlusMinus ::= '~' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.TWIDDLE); $break ./
+UnaryExpressionNotPlusMinus ::= '!' PushPosition UnaryExpression
+/.$putCase consumeUnaryExpression(OperatorExpression.NOT); $break ./
+UnaryExpressionNotPlusMinus -> CastExpression
+
+CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression
+/.$putCase consumeCastExpression(); $break ./
+CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus
+/.$putCase consumeCastExpression(); $break ./
+-- Expression is here only in order to make the grammar LL1
+CastExpression ::= PushLPAREN Expression PushRPAREN UnaryExpressionNotPlusMinus
+/.$putCase consumeCastExpressionLL1(); $break ./
+
+MultiplicativeExpression -> UnaryExpression
+MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.MULTIPLY); $break ./
+MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.DIVIDE); $break ./
+MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.REMAINDER); $break ./
+
+AdditiveExpression -> MultiplicativeExpression
+AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.PLUS); $break ./
+AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.MINUS); $break ./
+
+ShiftExpression -> AdditiveExpression
+ShiftExpression ::= ShiftExpression '<<' AdditiveExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.LEFT_SHIFT); $break ./
+ShiftExpression ::= ShiftExpression '>>' AdditiveExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.RIGHT_SHIFT); $break ./
+ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.UNSIGNED_RIGHT_SHIFT); $break ./
+
+RelationalExpression -> ShiftExpression
+RelationalExpression ::= RelationalExpression '<' ShiftExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.LESS); $break ./
+RelationalExpression ::= RelationalExpression '>' ShiftExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.GREATER); $break ./
+RelationalExpression ::= RelationalExpression '<=' ShiftExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.LESS_EQUAL); $break ./
+RelationalExpression ::= RelationalExpression '>=' ShiftExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.GREATER_EQUAL); $break ./
+RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType
+/.$putCase consumeInstanceOfExpression(OperatorExpression.INSTANCEOF); $break ./
+
+EqualityExpression -> RelationalExpression
+EqualityExpression ::= EqualityExpression '==' RelationalExpression
+/.$putCase consumeEqualityExpression(OperatorExpression.EQUAL_EQUAL); $break ./
+EqualityExpression ::= EqualityExpression '!=' RelationalExpression
+/.$putCase consumeEqualityExpression(OperatorExpression.NOT_EQUAL); $break ./
+
+AndExpression -> EqualityExpression
+AndExpression ::= AndExpression '&' EqualityExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.AND); $break ./
+
+ExclusiveOrExpression -> AndExpression
+ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.XOR); $break ./
+
+InclusiveOrExpression -> ExclusiveOrExpression
+InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.OR); $break ./
+
+ConditionalAndExpression -> InclusiveOrExpression
+ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.AND_AND); $break ./
+
+ConditionalOrExpression -> ConditionalAndExpression
+ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression
+/.$putCase consumeBinaryExpression(OperatorExpression.OR_OR); $break ./
+
+ConditionalExpression -> ConditionalOrExpression
+ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression
+/.$putCase consumeConditionalExpression(OperatorExpression.QUESTIONCOLON) ; $break ./
+
+AssignmentExpression -> ConditionalExpression
+AssignmentExpression -> Assignment
+
+Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
+/.$putCase consumeAssignment(); $break ./
+
+-- this rule is added to parse an array initializer in a assigment and then report a syntax error knowing the exact senario
+InvalidArrayInitializerAssignement ::= LeftHandSide AssignmentOperator ArrayInitializer
+Assignment ::= InvalidArrayInitializerAssignement
+/.$putcase ignoreExpressionAssignment();$break ./
+
+LeftHandSide ::= Name
+/.$putCase consumeLeftHandSide(); $break ./
+LeftHandSide -> FieldAccess
+LeftHandSide -> ArrayAccess
+
+AssignmentOperator ::= '='
+/.$putCase consumeAssignmentOperator(EQUAL); $break ./
+AssignmentOperator ::= '*='
+/.$putCase consumeAssignmentOperator(MULTIPLY); $break ./
+AssignmentOperator ::= '/='
+/.$putCase consumeAssignmentOperator(DIVIDE); $break ./
+AssignmentOperator ::= '%='
+/.$putCase consumeAssignmentOperator(REMAINDER); $break ./
+AssignmentOperator ::= '+='
+/.$putCase consumeAssignmentOperator(PLUS); $break ./
+AssignmentOperator ::= '-='
+/.$putCase consumeAssignmentOperator(MINUS); $break ./
+AssignmentOperator ::= '<<='
+/.$putCase consumeAssignmentOperator(LEFT_SHIFT); $break ./
+AssignmentOperator ::= '>>='
+/.$putCase consumeAssignmentOperator(RIGHT_SHIFT); $break ./
+AssignmentOperator ::= '>>>='
+/.$putCase consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT); $break ./
+AssignmentOperator ::= '&='
+/.$putCase consumeAssignmentOperator(AND); $break ./
+AssignmentOperator ::= '^='
+/.$putCase consumeAssignmentOperator(XOR); $break ./
+AssignmentOperator ::= '|='
+/.$putCase consumeAssignmentOperator(OR); $break ./
+
+Expression -> AssignmentExpression
+
+ConstantExpression -> Expression
+
+-- The following rules are for optional nonterminals.
+--
+
+PackageDeclarationopt -> $empty
+PackageDeclarationopt -> PackageDeclaration
+
+ClassHeaderExtendsopt ::= $empty
+ClassHeaderExtendsopt -> ClassHeaderExtends
+
+Expressionopt ::= $empty
+/.$putCase consumeEmptyExpression(); $break ./
+Expressionopt -> Expression
+
+
+---------------------------------------------------------------------------------------
+--
+-- The rules below are for optional terminal symbols. An optional comma,
+-- is only used in the context of an array initializer - It is a
+-- "syntactic sugar" that otherwise serves no other purpose. By contrast,
+-- an optional identifier is used in the definition of a break and
+-- continue statement. When the identifier does not appear, a NULL
+-- is produced. When the identifier is present, the user should use the
+-- corresponding TOKEN(i) method. See break statement as an example.
+--
+---------------------------------------------------------------------------------------
+
+,opt -> $empty
+,opt -> ,
+
+-- 1.5 feature
+TypeBoundopt ::= $empty
+/.$putCase consumeEmptyTypeBoundopt(); $break ./
+-- 1.5 feature
+TypeBoundopt ::= TypeBound
+/.$putCase consumeTypeBoundopt(); $break ./
+
+-- 1.5 feature
+AdditionalBoundListopt ::= $empty
+/.$putCase consumeEmptyAdditionalBoundListopt(); $break ./
+-- 1.5 feature
+AdditionalBoundListopt ::= AdditionalBoundList
+/.$putCase consumeAdditionalBoundListopt(); $break ./
+
+-- 1.5 feature
+ClassHeaderParametersopt ::= $empty
+/.$putCase consumeEmptyClassHeaderParametersopt(); $break ./
+-- 1.5 feature
+ClassHeaderParametersopt ::= ClassHeaderParameters
+/.$putCase consumeClassHeaderParametersopt(); $break ./
+
+-- 1.5 feature
+InterfaceHeaderParametersopt ::= $empty
+/.$putCase consumeEmptyInterfaceHeaderParametersopt(); $break ./
+-- 1.5 feature
+InterfaceHeaderParametersopt ::= InterfaceHeaderParameters
+/.$putCase consumeInterfaceHeaderParametersopt(); $break ./
+
+ImportDeclarationsopt ::= $empty
+/.$putCase consumeEmptyImportDeclarationsopt(); $break ./
+ImportDeclarationsopt ::= ImportDeclarations
+/.$putCase consumeImportDeclarationsopt(); $break ./
+
+
+TypeDeclarationsopt ::= $empty
+/.$putCase consumeEmptyTypeDeclarationsopt(); $break ./
+TypeDeclarationsopt ::= TypeDeclarations
+/.$putCase consumeTypeDeclarationsopt(); $break ./
+
+ClassBodyDeclarationsopt ::= $empty
+/.$putCase consumeEmptyClassBodyDeclarationsopt(); $break ./
+ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations
+/.$putCase consumeClassBodyDeclarationsopt(); $break ./
+
+Modifiersopt ::= $empty
+/. $putCase consumeDefaultModifiers(); $break ./
+Modifiersopt ::= Modifiers
+/.$putCase consumeModifiers(); $break ./
+
+BlockStatementsopt ::= $empty
+/.$putCase consumeEmptyBlockStatementsopt(); $break ./
+BlockStatementsopt -> BlockStatements
+
+Dimsopt ::= $empty
+/. $putCase consumeEmptyDimsopt(); $break ./
+Dimsopt -> Dims
+
+ArgumentListopt ::= $empty
+/. $putCase consumeEmptyArgumentListopt(); $break ./
+ArgumentListopt -> ArgumentList
+
+MethodHeaderThrowsClauseopt ::= $empty
+MethodHeaderThrowsClauseopt -> MethodHeaderThrowsClause
+
+FormalParameterListopt ::= $empty
+/.$putcase consumeFormalParameterListopt(); $break ./
+FormalParameterListopt -> FormalParameterList
+
+ClassHeaderImplementsopt ::= $empty
+ClassHeaderImplementsopt -> ClassHeaderImplements
+
+InterfaceMemberDeclarationsopt ::= $empty
+/. $putCase consumeEmptyInterfaceMemberDeclarationsopt(); $break ./
+InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations
+/. $putCase consumeInterfaceMemberDeclarationsopt(); $break ./
+
+NestedType ::= $empty
+/.$putCase consumeNestedType(); $break./
+
+ForInitopt ::= $empty
+/. $putCase consumeEmptyForInitopt(); $break ./
+ForInitopt -> ForInit
+
+ForUpdateopt ::= $empty
+/. $putCase consumeEmptyForUpdateopt(); $break ./
+ ForUpdateopt -> ForUpdate
+
+InterfaceHeaderExtendsopt ::= $empty
+InterfaceHeaderExtendsopt -> InterfaceHeaderExtends
+
+Catchesopt ::= $empty
+/. $putCase consumeEmptyCatchesopt(); $break ./
+Catchesopt -> Catches
+
+ArrayInitializeropt ::= $empty
+/. $putCase consumeEmptyArrayInitializeropt(); $break ./
+ArrayInitializeropt -> ArrayInitializer
+
+/. }
+} ./
+
+---------------------------------------------------------------------------------------
+
+$names
+
+-- BodyMarker ::= '"class Identifier { ... MethodHeader "'
+
+-- void ::= 'void'
+
+PLUS_PLUS ::= '++'
+MINUS_MINUS ::= '--'
+EQUAL_EQUAL ::= '=='
+LESS_EQUAL ::= '<='
+GREATER_EQUAL ::= '>='
+NOT_EQUAL ::= '!='
+LEFT_SHIFT ::= '<<'
+RIGHT_SHIFT ::= '>>'
+UNSIGNED_RIGHT_SHIFT ::= '>>>'
+PLUS_EQUAL ::= '+='
+MINUS_EQUAL ::= '-='
+MULTIPLY_EQUAL ::= '*='
+DIVIDE_EQUAL ::= '/='
+AND_EQUAL ::= '&='
+OR_EQUAL ::= '|='
+XOR_EQUAL ::= '^='
+REMAINDER_EQUAL ::= '%='
+LEFT_SHIFT_EQUAL ::= '<<='
+RIGHT_SHIFT_EQUAL ::= '>>='
+UNSIGNED_RIGHT_SHIFT_EQUAL ::= '>>>='
+OR_OR ::= '||'
+AND_AND ::= '&&'
+
+PLUS ::= '+'
+MINUS ::= '-'
+NOT ::= '!'
+REMAINDER ::= '%'
+XOR ::= '^'
+AND ::= '&'
+MULTIPLY ::= '*'
+OR ::= '|'
+TWIDDLE ::= '~'
+DIVIDE ::= '/'
+GREATER ::= '>'
+LESS ::= '<'
+LPAREN ::= '('
+RPAREN ::= ')'
+LBRACE ::= '{'
+RBRACE ::= '}'
+LBRACKET ::= '['
+RBRACKET ::= ']'
+SEMICOLON ::= ';'
+QUESTION ::= '?'
+COLON ::= ':'
+COMMA ::= ','
+DOT ::= '.'
+EQUAL ::= '='
+
+$end
+-- need a carriage return after the $end
+
+
diff --git a/org.eclipse.jdt.core/jdtCompilerAdapter.jar b/org.eclipse.jdt.core/jdtCompilerAdapter.jar
deleted file mode 100644
index d6b3342..0000000
--- a/org.eclipse.jdt.core/jdtCompilerAdapter.jar
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BufferChangedEvent.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BufferChangedEvent.java
index 3c4d667..e11692d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BufferChangedEvent.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/BufferChangedEvent.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import java.util.EventObject;
@@ -62,6 +62,11 @@
/**
* Creates a new buffer changed event indicating that the given buffer has changed.
+ *
+ * @param buffer the given buffer
+ * @param offset the given offset
+ * @param length the given length
+ * @param text the given text
*/
public BufferChangedEvent(IBuffer buffer, int offset, int length, String text) {
super(buffer);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ClasspathContainerInitializer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ClasspathContainerInitializer.java
index 4a40549..9914df7 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ClasspathContainerInitializer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ClasspathContainerInitializer.java
@@ -1,14 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
-
+ * IBM Corporation - added support for requesting updates of a particular
+ * container for generic container operations.
+ * - canUpdateClasspathContainer(IPath, IJavaProject)
+ * - requestClasspathContainerUpdate(IPath, IJavaProject, IClasspathContainer)
+ * IBM Corporation - allow initializers to provide a readable description
+ * of a container reference, ahead of actual resolution.
+ * - getDescription(IPath, IJavaProject)
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.CoreException;
@@ -66,5 +72,65 @@
* @see IClasspathContainer
*/
public abstract void initialize(IPath containerPath, IJavaProject project) throws CoreException;
+
+ /**
+ * Returns <code>true</code> if this container initializer can be requested to perform updates
+ * on its own container values. If so, then an update request will be performed using
+ * <code>ClasspathContainerInitializer#requestClasspathContainerUpdate</code>/
+ * <p>
+ * @param containerPath the path of the container which requires to be updated
+ * @param project the project for which the container is to be updated
+ * @return returns <code>true</code> if the container can be updated
+ * @since 2.1
+ */
+ public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) {
+
+ // By default, classpath container initializers do not accept updating containers
+ return false;
+ }
+
+ /**
+ * Request a registered container definition to be updated according to a container suggestion. The container suggestion
+ * only acts as a place-holder to pass along the information to update the matching container definition(s) held by the
+ * container initializer. In particular, it is not expected to store the container suggestion as is, but rather adjust
+ * the actual container definition based on suggested changes.
+ * <p>
+ * IMPORTANT: In reaction to receiving an update request, a container initializer will update the corresponding
+ * container definition (after reconciling changes) at its earliest convenience, using
+ * <code>JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)</code>.
+ * Until it does so, the update will not be reflected in the Java Model.
+ * <p>
+ * In order to anticipate whether the container initializer allows to update its containers, the predicate
+ * <code>JavaCore#canUpdateClasspathContainer</code> should be used.
+ * <p>
+ * @param containerPath the path of the container which requires to be updated
+ * @param project the project for which the container is to be updated
+ * @param containerSuggestion a suggestion to update the corresponding container definition
+ * @throws CoreException when <code>JavaCore#setClasspathContainer</code> would throw any.
+ * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)
+ * @see ClasspathContainerInitializer#canUpdateClasspathContainer(IPath, IJavaProject)
+ * @since 2.1
+ */
+ public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException {
+
+ // By default, classpath container initializers do not accept updating containers
+ }
+
+ /**
+ * Returns a readable description for a container path. A readable description for a container path can be
+ * used for improving the display of references to container, without actually needing to resolve them.
+ * A good implementation should answer a description consistent with the description of the associated
+ * target container (see <code>IClasspathContainer.getDescription()</code>).
+ *
+ * @param containerPath the path of the container which requires a readable description
+ * @param project the project from which the container is referenced
+ * @return a string description of the container
+ * @since 2.1
+ */
+ public String getDescription(IPath containerPath, IJavaProject project) {
+
+ // By default, a container path is the only available description
+ return containerPath.makeRelative().toString();
+ }
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ClasspathVariableInitializer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ClasspathVariableInitializer.java
index 9cf75a9..3bc1d04 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ClasspathVariableInitializer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ClasspathVariableInitializer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CompletionRequestorAdapter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CompletionRequestorAdapter.java
index 9649346..db43e7f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CompletionRequestorAdapter.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CompletionRequestorAdapter.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.jdt.core.compiler.IProblem;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CorrectionEngine.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CorrectionEngine.java
index 7e48493..3a84f32 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CorrectionEngine.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/CorrectionEngine.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import java.util.Map;
@@ -18,7 +18,6 @@
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
import org.eclipse.jdt.internal.compiler.parser.*;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.*;
/**
@@ -260,17 +259,17 @@
scanner.resetTo(correctionStart, correctionEnd);
int token = 0;
- char[] argumentSource = new char[0];
+ char[] argumentSource = CharOperation.NO_CHAR;
// search last segment position
while(true) {
token = scanner.getNextToken();
- if (token == ITerminalSymbols.TokenNameEOF) return;
+ if (token == TerminalTokens.TokenNameEOF) return;
char[] tokenSource = scanner.getCurrentTokenSource();
argumentSource = CharOperation.concat(argumentSource, tokenSource);
- if(!CharOperation.startsWith(argument, argumentSource))
+ if(!CharOperation.prefixEquals(argumentSource, argument))
return;
if(CharOperation.equals(argument, argumentSource)) {
@@ -411,4 +410,19 @@
public void acceptType(char[] packageName,char[] typeName,char[] completionName,int completionStart,int completionEnd, int relevance) {}
public void acceptVariableName(char[] typePackageName,char[] typeName,char[] name,char[] completionName,int completionStart,int completionEnd, int relevance) {}
};
-}
\ No newline at end of file
+
+ /**
+ * Helper method for decoding problem marker attributes. Returns an array of String arguments
+ * extracted from the problem marker "arguments" attribute, or <code>null</code> if the marker
+ * "arguments" attribute is missing or ill-formed.
+ *
+ * @param problemMarker
+ * the problem marker to decode arguments from.
+ * @return an array of String arguments, or <code>null</code> if unable to extract arguments
+ * @since 2.1
+ */
+ public static String[] getProblemArguments(IMarker problemMarker){
+ String argumentsString = problemMarker.getAttribute(IJavaModelMarker.ARGUMENTS, null);
+ return Util.getProblemArgumentsFromMarker(argumentsString);
+ }
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ElementChangedEvent.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ElementChangedEvent.java
index 55609a8..219097d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ElementChangedEvent.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ElementChangedEvent.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import java.util.EventObject;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java
index 52e365a..ca9a3e4 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Flags.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.jdt.internal.compiler.env.IConstants;
@@ -18,6 +18,12 @@
* This class provides static methods only; it is not intended to be
* instantiated or subclassed by clients.
* </p>
+ * <p>
+ * Note that the numeric values of these flags match the ones for class files
+ * as described in the Java Virtual Machine Specification. The AST class
+ * <code>Modifier</code> provides the same functionality as this class, only in
+ * the <code>org.eclipse.jdt.core.dom</code> package.
+ * </p>
*
* @see IMember#getFlags
*/
@@ -291,4 +297,4 @@
sb.setLength(len - 1);
return sb.toString();
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBuffer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBuffer.java
index acef9ba..0388cd4 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBuffer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBuffer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.resources.IResource;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBufferChangedListener.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBufferChangedListener.java
index a6f0f86..044164a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBufferChangedListener.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBufferChangedListener.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBufferFactory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBufferFactory.java
index 96034f4..4816919 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBufferFactory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IBufferFactory.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClassFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClassFile.java
index cdeac66..6110e53 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClassFile.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClassFile.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.IProgressMonitor;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathContainer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathContainer.java
index 267c9a5..d928cd1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathContainer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathContainer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.IPath;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathEntry.java
index e62ea52..78ef639 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IClasspathEntry.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.IPath;
@@ -27,7 +27,11 @@
* represent compilation units. All compilation units will be compiled when
* the project is built. The classpath entry must specify the
* absolute path to the root folder. Entries of this kind are
- * associated with the <code>CPE_SOURCE</code> constant.</li>
+ * associated with the <code>CPE_SOURCE</code> constant.
+ * Source classpath entries can carry patterns to exclude selected files.
+ * Excluded <code>.java</code> source files do not appear as compilation
+ * units and are not compiled when the project is built.
+ * </li>
*
* <li>A binary library in the current project, in another project, or in the external
* file system. In this case the entry identifies a JAR (or root folder) containing
@@ -90,9 +94,10 @@
* <p>
* Any classpath entry other than a source folder (kind <code>CPE_SOURCE</code>) can
* be marked as being exported. Exported entries are automatically contributed to
- * dependent projects, along with the project's output folder, which is implicitly
- * exported. The project's output folder is always listed first, followed by the
- * any exported entries.
+ * dependent projects, along with the project's default output folder, which is
+ * implicitly exported, and any auxiliary output folders specified on source
+ * classpath entries. The project's output folder(s) are always listed first,
+ * followed by the any exported entries.
* <p>
* This interface is not intended to be implemented by clients.
* Classpath entries can be created via methods on <code>JavaCore</code>.
@@ -103,8 +108,8 @@
* @see JavaCore#newSourceEntry
* @see JavaCore#newVariableEntry
* @see JavaCore#newContainerEntry
- * @see org.eclipse.jdt.core.ClasspathVariableInitializer
- * @see org.eclipse.jdt.core.ClasspathContainerInitializer
+ * @see ClasspathVariableInitializer
+ * @see ClasspathContainerInitializer
*/
public interface IClasspathEntry {
@@ -113,26 +118,26 @@
* library. A library is a folder or JAR containing package
* fragments consisting of pre-compiled binaries.
*/
- public static final int CPE_LIBRARY = 1;
+ int CPE_LIBRARY = 1;
/**
* Entry kind constant describing a classpath entry identifying a
* required project.
*/
- public static final int CPE_PROJECT = 2;
+ int CPE_PROJECT = 2;
/**
* Entry kind constant describing a classpath entry identifying a
* folder containing package fragments with source code
* to be compiled.
*/
- public static final int CPE_SOURCE = 3;
+ int CPE_SOURCE = 3;
/**
* Entry kind constant describing a classpath entry defined using
* a path that begins with a classpath variable reference.
*/
- public static final int CPE_VARIABLE = 4;
+ int CPE_VARIABLE = 4;
/**
* Entry kind constant describing a classpath entry representing
@@ -140,7 +145,7 @@
*
* @since 2.0
*/
- public static final int CPE_CONTAINER = 5;
+ int CPE_CONTAINER = 5;
/**
* Returns the kind of files found in the package fragments identified by this
@@ -175,6 +180,104 @@
int getEntryKind();
/**
+ * Returns the set of patterns used to exclude resources associated with
+ * this source entry.
+ * <p>
+ * Exclusion patterns allow specified portions of the resource tree rooted
+ * at this source entry's path to be filtered out. If no exclusion patterns
+ * are specified, this source entry includes all relevent files. Each path
+ * specified must be a relative path, and will be interpreted relative
+ * to this source entry's path. File patterns are case-sensitive. A file
+ * matched by one or more of these patterns is excluded from the
+ * corresponding package fragment root.
+ * </p>
+ * <p>
+ * Note that there is no need to supply a pattern to exclude ".class" files
+ * because a source entry filters these out automatically.
+ * </p>
+ * <p>
+ * The pattern mechanism is similar to Ant's. Each pattern is represented as
+ * a relative path. The path segments can be regular file or folder names or simple patterns
+ * involving standard wildcard characters.
+ * </p>
+ * <p>
+ * '*' matches 0 or more characters within a segment. So
+ * <code>*.java</code> matches <code>.java</code>, <code>a.java</code>
+ * and <code>Foo.java</code>, but not <code>Foo.properties</code>
+ * (does not end with <code>.java</code>).
+ * </p>
+ * <p>
+ * '?' matches 1 character within a segment. So <code>?.java</code>
+ * matches <code>a.java</code>, <code>A.java</code>,
+ * but not <code>.java</code> or <code>xyz.java</code> (neither have
+ * just one character before <code>.java</code>).
+ * </p>
+ * <p>
+ * Combinations of *'s and ?'s are allowed.
+ * </p>
+ * <p>
+ * The special pattern '**' matches zero or more segments. A path
+ * like <code>tests/</code> that ends in a trailing separator is interpreted
+ * as <code>tests/**</code>, and would match all files under the
+ * the folder named <code>tests</code>.
+ * </p>
+ * <p>
+ * Examples:
+ * <ul>
+ * <li>
+ * <code>tests/**</code> (or simply <code>tests/</code>)
+ * matches all files under a root folder
+ * named <code>tests</code>. This includes <code>tests/Foo.java</code>
+ * and <code>tests/com/example/Foo.java</code>, but not
+ * <code>com/example/tests/Foo.java</code> (not under a root folder named
+ * <code>tests</code>).
+ * </li>
+ * <li>
+ * <code>tests/*</code> matches all files directly below a root
+ * folder named <code>tests</code>. This includes <code>tests/Foo.java</code>
+ * and <code>tests/FooHelp.java</code>
+ * but not <code>tests/com/example/Foo.java</code> (not directly under
+ * a folder named <code>tests</code>) or
+ * <code>com/Foo.java</code> (not under a folder named <code>tests</code>).
+ * </li>
+ * <li>
+ * <code>**/tests/**</code> matches all files under any
+ * folder named <code>tests</code>. This includes <code>tests/Foo.java</code>,
+ * <code>com/examples/tests/Foo.java</code>, and
+ * <code>com/examples/tests/unit/Foo.java</code>, but not
+ * <code>com/example/Foo.java</code> (not under a folder named
+ * <code>tests</code>).
+ * </li>
+ * </ul>
+ * </p>
+ *
+ * @return the possibly empty list of resource exclusion patterns
+ * associated with this source entry, and <code>null</code> for other
+ * kinds of classpath entries
+ * @since 2.1
+ */
+ IPath[] getExclusionPatterns();
+
+ /**
+ * Returns the full path to the specific location where the builder writes
+ * <code>.class</code> files generated for this source entry
+ * (entry kind <code>CPE_SOURCE</code>).
+ * <p>
+ * Source entries can optionally be associated with a specific output location.
+ * If none is provided, the source entry will be implicitly associated with its project
+ * default output location (see <code>IJavaProject#getOutputLocation</code>).
+ * </p><p>
+ * NOTE: A specific output location cannot coincidate with another source/library entry.
+ * </p>
+ *
+ * @return the full path to the specific location where the builder writes
+ * <code>.class</code> files for this source entry, or <code>null</code>
+ * if using default output folder
+ * @since 2.1
+ */
+ IPath getOutputLocation();
+
+ /**
* Returns the path of this classpath entry.
*
* The meaning of the path of a classpath entry depends on its entry kind:<ul>
@@ -204,29 +307,30 @@
IPath getPath();
/**
- * Returns the path to the source archive associated with this
+ * Returns the path to the source archive or folder associated with this
* classpath entry, or <code>null</code> if this classpath entry has no
* source attachment.
* <p>
* Only library and variable classpath entries may have source attachments.
* For library classpath entries, the result path (if present) locates a source
- * archive. For variable classpath entries, the result path (if present) has
- * an analogous form and meaning as the variable path, namely the first segment
- * is the name of a classpath variable.
+ * archive or folder. This archive or folder can be located in a project of the
+ * workspace or outside thr workspace. For variable classpath entries, the
+ * result path (if present) has an analogous form and meaning as the
+ * variable path, namely the first segment is the name of a classpath variable.
* </p>
*
- * @return the path to the source archive, or <code>null</code> if none
+ * @return the path to the source archive or folder, or <code>null</code> if none
*/
IPath getSourceAttachmentPath();
/**
- * Returns the path within the source archive where package fragments
+ * Returns the path within the source archive or folder where package fragments
* are located. An empty path indicates that packages are located at
- * the root of the source archive. Returns a non-<code>null</code> value
+ * the root of the source archive or folder. Returns a non-<code>null</code> value
* if and only if <code>getSourceAttachmentPath</code> returns
* a non-<code>null</code> value.
*
- * @return the path within the source archive, or <code>null</code> if
+ * @return the path within the source archive or folder, or <code>null</code> if
* not applicable
*/
IPath getSourceAttachmentRootPath();
@@ -263,4 +367,4 @@
* @deprecated - use JavaCore.getResolvedClasspathEntry(...)
*/
IClasspathEntry getResolvedEntry();
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeAssist.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeAssist.java
index b8dd590..ee96da0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeAssist.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeAssist.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
@@ -78,4 +78,4 @@
*/
void codeComplete(int offset, ICodeCompletionRequestor requestor)
throws JavaModelException;
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeCompletionRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeCompletionRequestor.java
index f5c4c9c..edd9ed7 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeCompletionRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeCompletionRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.resources.IMarker;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeFormatter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeFormatter.java
index b3fd206..39f1eba 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeFormatter.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICodeFormatter.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
@@ -31,10 +31,10 @@
* level of zero has no effect.
* @param positions an array of positions to map. These are
* character-based source positions inside the original source,
- * for which corresponding positions in the formatted source will
- * be computed (so as to relocate elements associated with the original
- * source). It updates the positions array with updated positions.
- * If set to <code>null</code>, then no positions are mapped.
+ * arranged in non-decreasing order, for which corresponding positions in
+ * the formatted source will be computed (so as to relocate elements associated
+ * with the original source). It updates the positions array with updated
+ * positions. If set to <code>null</code>, then no positions are mapped.
* @param lineSeparator the line separator to use in formatted source,
* if set to <code>null</code>, then the platform default one will be used.
* @return the formatted output string.
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompilationUnit.java
index 4bbb11e..849a51e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompilationUnit.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.IProgressMonitor;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompletionRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompletionRequestor.java
index 2ec7525..edcce37 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompletionRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICompletionRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.jdt.core.compiler.IProblem;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICorrectionRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICorrectionRequestor.java
index a8917ba..fb8e54a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICorrectionRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ICorrectionRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IElementChangedListener.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IElementChangedListener.java
index b467abd..4a48747 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IElementChangedListener.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IElementChangedListener.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IField.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IField.java
index 8389ac8..3260d86 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IField.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IField.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IImportContainer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IImportContainer.java
index 5f46ed2..356ad01 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IImportContainer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IImportContainer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IImportDeclaration.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IImportDeclaration.java
index 28f7179..c000b96 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IImportDeclaration.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IImportDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IInitializer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IInitializer.java
index 5b41242..e291d19 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IInitializer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IInitializer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaElement.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaElement.java
index 37b70be..1fa8c15 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaElement.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaElement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.resources.IResource;
@@ -36,240 +36,269 @@
* Constant representing a Java model (workspace level object).
* A Java element with this type can be safely cast to <code>IJavaModel</code>.
*/
- public static final int JAVA_MODEL = 1;
+ int JAVA_MODEL = 1;
/**
* Constant representing a Java project.
* A Java element with this type can be safely cast to <code>IJavaProject</code>.
*/
- public static final int JAVA_PROJECT = 2;
+ int JAVA_PROJECT = 2;
/**
* Constant representing a package fragment root.
* A Java element with this type can be safely cast to <code>IPackageFragmentRoot</code>.
*/
- public static final int PACKAGE_FRAGMENT_ROOT = 3;
+ int PACKAGE_FRAGMENT_ROOT = 3;
/**
* Constant representing a package fragment.
* A Java element with this type can be safely cast to <code>IPackageFragment</code>.
*/
- public static final int PACKAGE_FRAGMENT = 4;
+ int PACKAGE_FRAGMENT = 4;
/**
* Constant representing a Java compilation unit.
* A Java element with this type can be safely cast to <code>ICompilationUnit</code>.
*/
- public static final int COMPILATION_UNIT = 5;
+ int COMPILATION_UNIT = 5;
/**
* Constant representing a class file.
* A Java element with this type can be safely cast to <code>IClassFile</code>.
*/
- public static final int CLASS_FILE = 6;
+ int CLASS_FILE = 6;
/**
* Constant representing a type (a class or interface).
* A Java element with this type can be safely cast to <code>IType</code>.
*/
- public static final int TYPE = 7;
+ int TYPE = 7;
/**
* Constant representing a field.
* A Java element with this type can be safely cast to <code>IField</code>.
*/
- public static final int FIELD = 8;
+ int FIELD = 8;
/**
* Constant representing a method or constructor.
* A Java element with this type can be safely cast to <code>IMethod</code>.
*/
- public static final int METHOD = 9;
+ int METHOD = 9;
/**
* Constant representing a stand-alone instance or class initializer.
* A Java element with this type can be safely cast to <code>IInitializer</code>.
*/
- public static final int INITIALIZER = 10;
+ int INITIALIZER = 10;
/**
* Constant representing a package declaration within a compilation unit.
* A Java element with this type can be safely cast to <code>IPackageDeclaration</code>.
*/
- public static final int PACKAGE_DECLARATION = 11;
+ int PACKAGE_DECLARATION = 11;
/**
* Constant representing all import declarations within a compilation unit.
* A Java element with this type can be safely cast to <code>IImportContainer</code>.
*/
- public static final int IMPORT_CONTAINER = 12;
+ int IMPORT_CONTAINER = 12;
/**
* Constant representing an import declaration within a compilation unit.
* A Java element with this type can be safely cast to <code>IImportDeclaration</code>.
*/
- public static final int IMPORT_DECLARATION = 13;
+ int IMPORT_DECLARATION = 13;
-/**
- * Returns whether this Java element exists in the model.
- *
- * @return <code>true</code> if this element exists in the Java model
- */
-boolean exists();
-/**
- * Returns the first ancestor of this Java element that has the given type.
- * Returns <code>null</code> if no such an ancestor can be found.
- * This is a handle-only method.
- *
- * @param ancestorType the given type
- * @return the first ancestor of this Java element that has the given type, null if no such an ancestor can be found
- * @since 2.0
- */
-IJavaElement getAncestor(int ancestorType);
-/**
- * Returns the resource that corresponds directly to this element,
- * or <code>null</code> if there is no resource that corresponds to
- * this element.
- * <p>
- * For example, the corresponding resource for an <code>ICompilationUnit</code>
- * is its underlying <code>IFile</code>. The corresponding resource for
- * an <code>IPackageFragment</code> that is not contained in an archive
- * is its underlying <code>IFolder</code>. An <code>IPackageFragment</code>
- * contained in an archive has no corresponding resource. Similarly, there
- * are no corresponding resources for <code>IMethods</code>,
- * <code>IFields</code>, etc.
- * <p>
- *
- * @return the corresponding resource, or <code>null</code> if none
- * @exception JavaModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource
- */
-IResource getCorrespondingResource() throws JavaModelException;
-/**
- * Returns the name of this element. This is a handle-only method.
- *
- * @return the element name
- */
-String getElementName();
-/**
- * Returns this element's kind encoded as an integer.
- * This is a handle-only method.
- *
- * @return the kind of element; one of the constants declared in
- * <code>IJavaElement</code>
- * @see IJavaElement
- */
-public int getElementType();
-/**
- * Returns a string representation of this element handle. The format of
- * the string is not specified; however, the identifier is stable across
- * workspace sessions, and can be used to recreate this handle via the
- * <code>JavaCore.create(String)</code> method.
- *
- * @return the string handle identifier
- * @see JavaCore#create(java.lang.String)
- */
-String getHandleIdentifier();
-/**
- * Returns the Java model.
- * This is a handle-only method.
- *
- * @return the Java model
- */
-IJavaModel getJavaModel();
-/**
- * Returns the Java project this element is contained in,
- * or <code>null</code> if this element is not contained in any Java project
- * (for instance, the <code>IJavaModel</code> is not contained in any Java
- * project).
- * This is a handle-only method.
- *
- * @return the containing Java project, or <code>null</code> if this element is
- * not contained in a Java project
- */
-IJavaProject getJavaProject();
-/**
- * Returns the first openable parent. If this element is openable, the element
- * itself is returned. Returns <code>null</code> if this element doesn't have
- * an openable parent.
- * This is a handle-only method.
- *
- * @return the first openable parent or <code>null</code> if this element doesn't have
- * an openable parent.
- * @since 2.0
- */
-IOpenable getOpenable();
-/**
- * Returns the element directly containing this element,
- * or <code>null</code> if this element has no parent.
- * This is a handle-only method.
- *
- * @return the parent element, or <code>null</code> if this element has no parent
- */
-IJavaElement getParent();
-/**
- * Returns the path to the innermost resource enclosing this element.
- * If this element is not included in an external archive,
- * the path returned is the full, absolute path to the underlying resource,
- * relative to the workbench.
- * If this element is included in an external archive,
- * the path returned is the absolute path to the archive in the file system.
- * This is a handle-only method.
- *
- * @return the path to the innermost resource enclosing this element
- * @since 2.0
- */
-IPath getPath();
-/**
- * Returns the innermost resource enclosing this element.
- * If this element is included in an archive and this archive is not external,
- * this is the underlying resource corresponding to the archive.
- * If this element is included in an external archive, <code>null</code>
- * is returned.
- * If this element is a working copy, <code>null</code> is returned.
- * This is a handle-only method.
- *
- * @return the innermost resource enclosing this element, <code>null</code> if this
- * element is a working copy or is included in an external archive
- * @since 2.0
- */
-IResource getResource();
-/**
- * Returns the smallest underlying resource that contains
- * this element, or <code>null</code> if this element is not contained
- * in a resource.
- *
- * @return the underlying resource, or <code>null</code> if none
- * @exception JavaModelException if this element does not exist or if an
- * exception occurs while accessing its underlying resource
- */
-IResource getUnderlyingResource() throws JavaModelException;
-/**
- * Returns whether this Java element is read-only. An element is read-only
- * if its structure cannot be modified by the java model.
- * <p>
- * Note this is different from IResource.isReadOnly(). For example, .jar
- * files are read-only as the java model doesn't know how to add/remove
- * elements in this file, but the underlying IFile can be writable.
- * <p>
- * This is a handle-only method.
- *
- * @return <code>true</code> if this element is read-only
- */
-boolean isReadOnly();
-/**
- * Returns whether the structure of this element is known. For example, for a
- * compilation unit that could not be parsed, <code>false</code> is returned.
- * If the structure of an element is unknown, navigations will return reasonable
- * defaults. For example, <code>getChildren</code> will return an empty collection.
- * <p>
- * Note: This does not imply anything about consistency with the
- * underlying resource/buffer contents.
- * </p>
- *
- * @return <code>true</code> if the structure of this element is known
- * @exception JavaModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource
- */
-boolean isStructureKnown() throws JavaModelException;
+ /**
+ * Returns whether this Java element exists in the model.
+ * <p>
+ * Java elements are handle objects that may or may not be backed by an
+ * actual element. Java elements that are backed by an actual element are
+ * said to "exist", and this method returns <code>true</code>. For Java
+ * elements that are not working copies, it is always the case that if the
+ * element exists, then its parent also exists (provided it has one) and
+ * includes the element as one of its children. It is therefore possible
+ * to navigated to any existing Java element from the root of the Java model
+ * along a chain of existing Java elements. On the other hand, working
+ * copies are said to exist until they are destroyed (with
+ * <code>IWorkingCopy.destroy</code>). Unlike regular Java elements, a
+ * working copy never shows up among the children of its parent element
+ * (which may or may not exist).
+ * </p>
+ *
+ * @return <code>true</code> if this element exists in the Java model, and
+ * <code>false</code> if this element does not exist
+ */
+ boolean exists();
+
+ /**
+ * Returns the first ancestor of this Java element that has the given type.
+ * Returns <code>null</code> if no such an ancestor can be found.
+ * This is a handle-only method.
+ *
+ * @param ancestorType the given type
+ * @return the first ancestor of this Java element that has the given type, null if no such an ancestor can be found
+ * @since 2.0
+ */
+ IJavaElement getAncestor(int ancestorType);
+
+ /**
+ * Returns the resource that corresponds directly to this element,
+ * or <code>null</code> if there is no resource that corresponds to
+ * this element.
+ * <p>
+ * For example, the corresponding resource for an <code>ICompilationUnit</code>
+ * is its underlying <code>IFile</code>. The corresponding resource for
+ * an <code>IPackageFragment</code> that is not contained in an archive
+ * is its underlying <code>IFolder</code>. An <code>IPackageFragment</code>
+ * contained in an archive has no corresponding resource. Similarly, there
+ * are no corresponding resources for <code>IMethods</code>,
+ * <code>IFields</code>, etc.
+ * <p>
+ *
+ * @return the corresponding resource, or <code>null</code> if none
+ * @exception JavaModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ */
+ IResource getCorrespondingResource() throws JavaModelException;
+
+ /**
+ * Returns the name of this element. This is a handle-only method.
+ *
+ * @return the element name
+ */
+ String getElementName();
+
+ /**
+ * Returns this element's kind encoded as an integer.
+ * This is a handle-only method.
+ *
+ * @return the kind of element; one of the constants declared in
+ * <code>IJavaElement</code>
+ * @see IJavaElement
+ */
+ int getElementType();
+
+ /**
+ * Returns a string representation of this element handle. The format of
+ * the string is not specified; however, the identifier is stable across
+ * workspace sessions, and can be used to recreate this handle via the
+ * <code>JavaCore.create(String)</code> method.
+ *
+ * @return the string handle identifier
+ * @see JavaCore#create(java.lang.String)
+ */
+ String getHandleIdentifier();
+
+ /**
+ * Returns the Java model.
+ * This is a handle-only method.
+ *
+ * @return the Java model
+ */
+ IJavaModel getJavaModel();
+
+ /**
+ * Returns the Java project this element is contained in,
+ * or <code>null</code> if this element is not contained in any Java project
+ * (for instance, the <code>IJavaModel</code> is not contained in any Java
+ * project).
+ * This is a handle-only method.
+ *
+ * @return the containing Java project, or <code>null</code> if this element is
+ * not contained in a Java project
+ */
+ IJavaProject getJavaProject();
+
+ /**
+ * Returns the first openable parent. If this element is openable, the element
+ * itself is returned. Returns <code>null</code> if this element doesn't have
+ * an openable parent.
+ * This is a handle-only method.
+ *
+ * @return the first openable parent or <code>null</code> if this element doesn't have
+ * an openable parent.
+ * @since 2.0
+ */
+ IOpenable getOpenable();
+
+ /**
+ * Returns the element directly containing this element,
+ * or <code>null</code> if this element has no parent.
+ * This is a handle-only method.
+ *
+ * @return the parent element, or <code>null</code> if this element has no parent
+ */
+ IJavaElement getParent();
+
+ /**
+ * Returns the path to the innermost resource enclosing this element.
+ * If this element is not included in an external archive,
+ * the path returned is the full, absolute path to the underlying resource,
+ * relative to the workbench.
+ * If this element is included in an external archive,
+ * the path returned is the absolute path to the archive in the file system.
+ * This is a handle-only method.
+ *
+ * @return the path to the innermost resource enclosing this element
+ * @since 2.0
+ */
+ IPath getPath();
+
+ /**
+ * Returns the innermost resource enclosing this element.
+ * If this element is included in an archive and this archive is not external,
+ * this is the underlying resource corresponding to the archive.
+ * If this element is included in an external archive, <code>null</code>
+ * is returned.
+ * If this element is a working copy, <code>null</code> is returned.
+ * This is a handle-only method.
+ *
+ * @return the innermost resource enclosing this element, <code>null</code> if this
+ * element is a working copy or is included in an external archive
+ * @since 2.0
+ */
+ IResource getResource();
+
+ /**
+ * Returns the smallest underlying resource that contains
+ * this element, or <code>null</code> if this element is not contained
+ * in a resource.
+ *
+ * @return the underlying resource, or <code>null</code> if none
+ * @exception JavaModelException if this element does not exist or if an
+ * exception occurs while accessing its underlying resource
+ */
+ IResource getUnderlyingResource() throws JavaModelException;
+
+ /**
+ * Returns whether this Java element is read-only. An element is read-only
+ * if its structure cannot be modified by the java model.
+ * <p>
+ * Note this is different from IResource.isReadOnly(). For example, .jar
+ * files are read-only as the java model doesn't know how to add/remove
+ * elements in this file, but the underlying IFile can be writable.
+ * <p>
+ * This is a handle-only method.
+ *
+ * @return <code>true</code> if this element is read-only
+ */
+ boolean isReadOnly();
+
+ /**
+ * Returns whether the structure of this element is known. For example, for a
+ * compilation unit that could not be parsed, <code>false</code> is returned.
+ * If the structure of an element is unknown, navigations will return reasonable
+ * defaults. For example, <code>getChildren</code> will return an empty collection.
+ * <p>
+ * Note: This does not imply anything about consistency with the
+ * underlying resource/buffer contents.
+ * </p>
+ *
+ * @return <code>true</code> if the structure of this element is known
+ * @exception JavaModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ */
+ boolean isStructureKnown() throws JavaModelException;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaElementDelta.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaElementDelta.java
index f329af3..4e57c4d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaElementDelta.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaElementDelta.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.resources.IResourceDelta;
@@ -120,7 +120,7 @@
* Status constant indicating that the element has been changed,
* as described by the change flags.
*
- * @see getFlags
+ * @see #getFlags
*/
public int CHANGED = 4;
@@ -169,8 +169,17 @@
/**
* Change flag indicating that a classpath entry corresponding to the element has changed position in the project's
* classpath. This flag is only valid if the element is an <code>IPackageFragmentRoot</code>.
+ * @deprecated Use F_REORDER instead.
*/
public int F_CLASSPATH_REORDER = 0x0100;
+ /**
+ * Change flag indicating that the element has changed position relatively to its siblings.
+ * If the element is an <code>IPackageFragmentRoot</code>, a classpath entry corresponding
+ * to the element has changed position in the project's classpath.
+ *
+ * @since 2.1
+ */
+ public int F_REORDER = 0x0100;
/**
* Change flag indicating that the underlying <code>IProject</code> has been
@@ -229,8 +238,21 @@
*/
public int F_ARCHIVE_CONTENT_CHANGED = 0x8000;
+// /**
+// * Change flag indicating that the project custom options have changed on the file system,
+// * i.e. independently from a change performed using the <code>IJavaProject#setOptions</code>
+// * functionality.
+// * This flag is only valid if the element is an <code>IJavaProject</code>
+// *
+// * @see IJavaProject#setOptions(Map)
+// * @since 2.1
+// */
+// public int F_OPTIONS_CHANGED = 0x10000;
+
+
/**
* Returns deltas for the children that have been added.
+ * @return deltas for the children that have been added
*/
public IJavaElementDelta[] getAddedChildren();
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModel.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModel.java
index b20d4ca..4c5b04b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModel.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModel.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -34,6 +35,22 @@
*/
public interface IJavaModel extends IJavaElement, IOpenable, IParent {
/**
+ * Returns whether this Java model contains an <code>IJavaElement</code> whose
+ * resource is the given resource or a non-Java resource which is the given resource.
+ * <p>
+ * Note: no existency check is performed on the argument resource. If it is not accessible
+ * (see <code>IResource.isAccessible()</code>) yet but would be located in Java model
+ * range, then it will return <code>true</code>.
+ * </p><p>
+ * If the resource is accessible, it can be reached by navigating the Java model down using the
+ * <code>getChildren()</code> and/or <code>getNonJavaResources()</code> methods.
+ * </p>
+ * @param resource the resource to check
+ * @return true if the resource is accessible through the Java model
+ * @since 2.1
+ */
+boolean contains(IResource resource);
+/**
* Copies the given elements to the specified container(s).
* If one container is specified, all elements are copied to that
* container. If more than one container is specified, the number of
@@ -68,14 +85,15 @@
* @param monitor a progress monitor
* @exception JavaModelException if an element could not be copied. Reasons include:
* <ul>
+ * <li> There is no element to process (NO_ELEMENTS_TO_PROCESS). The given elements is null or empty</li>
* <li> A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
- * <li> A <code>CoreException</code> occurred while updating an underlying resource
- * <li> A container is of an incompatible type (<code>INVALID_DESTINATION</code>)
- * <li> A sibling is not a child of it associated container (<code>INVALID_SIBLING</code>)
- * <li> A new name is invalid (<code>INVALID_NAME</code>)
+ * <li> A <code>CoreException</code> occurred while updating an underlying resource</li>
+ * <li> A container is of an incompatible type (<code>INVALID_DESTINATION</code>)</li>
+ * <li> A sibling is not a child of it associated container (<code>INVALID_SIBLING</code>)</li>
+ * <li> A new name is invalid (<code>INVALID_NAME</code>)</li>
* <li> A child in its associated container already exists with the same
- * name and <code>replace</code> has been specified as <code>false</code> (<code>NAME_COLLISION</code>)
- * <li> A container or element is read-only (<code>READ_ONLY</code>)
+ * name and <code>replace</code> has been specified as <code>false</code> (<code>NAME_COLLISION</code>)</li>
+ * <li> A container or element is read-only (<code>READ_ONLY</code>) </li>
* </ul>
*/
void copy(IJavaElement[] elements, IJavaElement[] containers, IJavaElement[] siblings, String[] renamings, boolean replace, IProgressMonitor monitor) throws JavaModelException;
@@ -88,9 +106,10 @@
* @param monitor a progress monitor
* @exception JavaModelException if an element could not be deleted. Reasons include:
* <ul>
+ * <li> There is no element to process (NO_ELEMENTS_TO_PROCESS). The given elements is null or empty</li>
* <li> A specified element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
- * <li> A <code>CoreException</code> occurred while updating an underlying resource
- * <li> An element is read-only (<code>READ_ONLY</code>)
+ * <li> A <code>CoreException</code> occurred while updating an underlying resource</li>
+ * <li> An element is read-only (<code>READ_ONLY</code>) </li>
* </ul>
*/
void delete(IJavaElement[] elements, boolean force, IProgressMonitor monitor) throws JavaModelException;
@@ -111,6 +130,20 @@
*/
IJavaProject[] getJavaProjects() throws JavaModelException;
/**
+ * Returns an array of non-Java resources (i.e. non-Java projects) in
+ * the workspace.
+ * <p>
+ * Non-Java projects include all projects that are closed (even if they have the
+ * Java nature).
+ * </p>
+ *
+ * @return an array of non-Java projects contained in the workspace.
+ * @throws JavaModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ * @since 2.1
+ */
+Object[] getNonJavaResources() throws JavaModelException;
+/**
* Returns the workspace associated with this Java model.
*
* @return the workspace associated with this Java model
@@ -151,14 +184,15 @@
* @param monitor a progress monitor
* @exception JavaModelException if an element could not be moved. Reasons include:
* <ul>
+ * <li> There is no element to process (NO_ELEMENTS_TO_PROCESS). The given elements is null or empty</li>
* <li> A specified element, container, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
- * <li> A <code>CoreException</code> occurred while updating an underlying resource
- * <li> A container is of an incompatible type (<code>INVALID_DESTINATION</code>)
- * <li> A sibling is not a child of it associated container (<code>INVALID_SIBLING</code>)
- * <li> A new name is invalid (<code>INVALID_NAME</code>)
+ * <li> A <code>CoreException</code> occurred while updating an underlying resource</li>
+ * <li> A container is of an incompatible type (<code>INVALID_DESTINATION</code>)</li>
+ * <li> A sibling is not a child of it associated container (<code>INVALID_SIBLING</code>)</li>
+ * <li> A new name is invalid (<code>INVALID_NAME</code>)</li>
* <li> A child in its associated container already exists with the same
- * name and <code>replace</code> has been specified as <code>false</code> (<code>NAME_COLLISION</code>)
- * <li> A container or element is read-only (<code>READ_ONLY</code>)
+ * name and <code>replace</code> has been specified as <code>false</code> (<code>NAME_COLLISION</code>)</li>
+ * <li> A container or element is read-only (<code>READ_ONLY</code>) </li>
* </ul>
*
* @exception IllegalArgumentException any element or container is <code>null</code>
@@ -209,6 +243,7 @@
* @param monitor a progress monitor
* @exception JavaModelException if an element could not be renamed. Reasons include:
* <ul>
+ * <li> There is no element to process (NO_ELEMENTS_TO_PROCESS). The given elements is null or empty</li>
* <li> A specified element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource
* <li> A new name is invalid (<code>INVALID_NAME</code>)
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelMarker.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelMarker.java
index d27afe7..5cc7f4f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelMarker.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelMarker.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
@@ -34,18 +34,31 @@
* detected by the outliner, or a problem detected during a code completion)
*/
public static final String TRANSIENT_PROBLEM = JavaCore.PLUGIN_ID + ".transient_problem"; //$NON-NLS-1$
+
+ /**
+ * Java model task marker type (value <code>"org.eclipse.jdt.core.task"</code>).
+ * This can be used to recognize task markers in the workspace that correspond to tasks
+ * specified in Java source comments and detected during compilation (e.g. 'TO-DO: ...').
+ * Tasks are identified by a task tag, which can be customized through <code>JavaCore</code>
+ * option <code>"org.eclipse.jdt.core.compiler.taskTag"</code>.
+ * @since 2.1
+ */
+ public static final String TASK_MARKER = JavaCore.PLUGIN_ID + ".task"; //$NON-NLS-1$
+
/**
* Id marker attribute (value <code>"arguments"</code>).
- * Reserved for future use.
- *
+ * Arguments are concatenated into one String, prefixed with an argument count (followed with colon
+ * separator) and separated with '#' characters.
+ * e.g.
+ * { "foo", "bar" } is encoded as "2:foo#bar",
+ * { } is encoded as "0: "
* @since 2.0
*/
public static final String ARGUMENTS = "arguments"; //$NON-NLS-1$
/**
* Id marker attribute (value <code>"id"</code>).
- * Reserved for future use.
*/
public static final String ID = "id"; //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatus.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatus.java
index c41a889..3b099be 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatus.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatus.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.IPath;
@@ -67,6 +67,7 @@
*
* @return the string culprit, or <code>null</code> if none
* @see IJavaModelStatusConstants
+ * @deprecated Use IStatus#getMessage instead
*/
String getString();
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatusConstants.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatusConstants.java
index 4952ac3..da8149c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatusConstants.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaModelStatusConstants.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
@@ -249,4 +249,35 @@
* has been made locally available.
*/
public static final int NO_LOCAL_CONTENTS = 999;
+
+ /**
+ * Status indicating that a .classpath file is ill-formed, and thus cannot
+ * be read/written successfully.
+ * @since 2.1
+ */
+ public static final int INVALID_CLASSPATH_FILE_FORMAT = 1000;
+
+ /**
+ * Status indicating that a project is involved in a build path cycle.
+ * @since 2.1
+ */
+ public static final int CLASSPATH_CYCLE = 1001;
+
+ /**
+ * Status constant indicating that an exclusion pattern got specified
+ * on a classpath source entry, though it was explicitely disabled
+ * according to its project preference settings.
+ * @see org.eclipse.jdt.core.IJavaProject#getOptions(boolean)
+ * @since 2.1
+ */
+ public static final int DISABLED_CP_EXCLUSION_PATTERNS = 1002;
+
+ /**
+ * Status constant indicating that a specific output location got associated
+ * with a source entry, though it was explicitely disabled according to its project
+ * preference settings.
+ * @see org.eclipse.jdt.core.IJavaProject#getOptions(boolean)
+ * @since 2.1
+ */
+ public static final int DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS = 1003;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java
index 6672fd9..7aff3d2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IJavaProject.java
@@ -1,15 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ * IBM Corporation - added getOption(String, boolean), getOptions(boolean) and setOptions(Map)
+ * IBM Corporation - deprecated getPackageFragmentRoots(IClasspathEntry) and
+ * added findPackageFragmentRoots(IClasspathEntry)
+ * IBM Corporation - added isOnClasspath(IResource)
+ *******************************************************************************/
package org.eclipse.jdt.core;
+import java.util.Map;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -28,11 +34,10 @@
* defining where the builder writes <code>.class</code> files. A project that
* references packages in another project can access the packages by including
* the required project in a classpath entry. The Java model will present the
- * source elements in the required project, and when building, the compiler will
- * use the binaries from that project (that is, the output location of the
- * required project is used as a library). The classpath format is a sequence
- * of classpath entries describing the location and contents of package fragment
- * roots.
+ * source elements in the required project; when building, the compiler will use
+ * the corresponding generated class files from the required project's output
+ * location(s)). The classpath format is a sequence of classpath entries
+ * describing the location and contents of package fragment roots.
* </p>
* Java project elements need to be opened before they can be navigated or manipulated.
* The children of a Java project are the package fragment roots that are
@@ -106,12 +111,37 @@
IPackageFragmentRoot findPackageFragmentRoot(IPath path)
throws JavaModelException;
/**
+ * Returns the existing package fragment roots identified by the given entry.
+ * Note that a classpath entry that refers to another project may
+ * have more than one root (if that project has more than on root
+ * containing source), and classpath entries within the current
+ * project identify a single root.
+ * <p>
+ * If the classpath entry denotes a variable, it will be resolved and return
+ * the roots of the target entry (empty if not resolvable).
+ * <p>
+ * If the classpath entry denotes a container, it will be resolved and return
+ * the roots corresponding to the set of container entries (empty if not resolvable).
+ *
+ * @param entry the given entry
+ * @return the existing package fragment roots identified by the given entry
+ * @see IClasspathContainer
+ * @since 2.1
+ */
+ IPackageFragmentRoot[] findPackageFragmentRoots(IClasspathEntry entry);
+ /**
* Returns the first type found following this project's classpath
* with the given fully qualified name or <code>null</code> if none is found.
* The fully qualified name is a dot-separated name. For example,
* a class B defined as a member type of a class A in package x.y should have a
* the fully qualified name "x.y.A.B".
*
+ * Note that in order to be found, a type name (or its toplevel enclosing
+ * type name) must match its corresponding compilation unit name. As a
+ * consequence, secondary types cannot be found using this functionality.
+ * Secondary types can however be explicitely accessed through their enclosing
+ * unit or found by the <code>SearchEngine</code>.
+ *
* @param fullyQualifiedName the given fully qualified name
* @exception JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
@@ -130,6 +160,12 @@
* a class B defined as a member type of a class A should have the
* type qualified name "A.B".
*
+ * Note that in order to be found, a type name (or its toplevel enclosing
+ * type name) must match its corresponding compilation unit name. As a
+ * consequence, secondary types cannot be found using this functionality.
+ * Secondary types can however be explicitely accessed through their enclosing
+ * unit or found by the <code>SearchEngine</code>.
+ *
* @param packageName the given package name
* @param typeQualifiedName the given type qualified name
* @exception JavaModelException if this element does not exist or if an
@@ -138,6 +174,7 @@
* with the given package name and type qualified name
* or <code>null</code> if none is found
* @see IType#getTypeQualifiedName(char)
+
* @since 2.0
*/
IType findType(String packageName, String typeQualifiedName) throws JavaModelException;
@@ -157,18 +194,71 @@
* Returns an array of non-Java resources directly contained in this project.
* It does not transitively answer non-Java resources contained in folders;
* these would have to be explicitly iterated over.
+ * <p>
+ * Non-Java resources includes other files and folders located in the
+ * project not accounted for by any of it source or binary package fragment
+ * roots. If the project is a source folder itself, resources excluded from the
+ * corresponding source classpath entry by one or more exclusion patterns
+ * are considered non-Java resources and will appear in the result
+ * (possibly in a folder)
+ * </p>
+ *
* @return an array of non-Java resources directly contained in this project
- */
- Object[] getNonJavaResources() throws JavaModelException;
-
- /**
- * Returns the full path to the location where the builder writes
- * <code>.class</code> files.
- *
* @exception JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
- * @return the full path to the location where the builder writes
- * <code>.class</code> files
+ */
+ Object[] getNonJavaResources() throws JavaModelException;
+
+ /**
+ * Helper method for returning one option value only. Equivalent to <code>(String)this.getOptions(inheritJavaCoreOptions).get(optionName)</code>
+ * Note that it may answer <code>null</code> if this option does not exist, or if there is no custom value for it.
+ * <p>
+ * For a complete description of the configurable options, see <code>JavaCore#getDefaultOptions</code>.
+ * </p>
+ *
+ * @param optionName the name of an option
+ * @param inheritJavaCoreOptions - boolean indicating whether JavaCore options should be inherited as well
+ * @return the String value of a given option
+ * @see JavaCore#getDefaultOptions
+ * @since 2.1
+ */
+ String getOption(String optionName, boolean inheritJavaCoreOptions);
+
+ /**
+ * Returns the table of the current custom options for this project. Projects remember their custom options,
+ * i.e. only the options different from the the JavaCore global options for the workspace.
+ * A boolean argument allows to directly merge the project options with global ones from <code>JavaCore</code>.
+ * <p>
+ * For a complete description of the configurable options, see <code>JavaCore#getDefaultOptions</code>.
+ * </p>
+ *
+ * @param inheritJavaCoreOptions - boolean indicating whether JavaCore options should be inherited as well
+ * @return table of current settings of all options
+ * (key type: <code>String</code>; value type: <code>String</code>)
+ * @see JavaCore#getDefaultOptions
+ * @since 2.1
+ */
+ Map getOptions(boolean inheritJavaCoreOptions);
+
+ /**
+ * Returns the default output location for this project as a workspace-
+ * relative absolute path.
+ * <p>
+ * The default output location is where class files are ordinarily generated
+ * (and resource files, copied). Each source classpath entry can also
+ * specify an output location for the generated class files (and copied
+ * resource files) corresponding to compilation units under that source
+ * folder. This makes it possible to arrange generated class files for
+ * different source folders in different output folders, and not
+ * necessarily the default output folder. This means that the generated
+ * class files for the project may end up scattered across several folders,
+ * rather than all in the default output folder (which is more standard).
+ * </p>
+ *
+ * @return the workspace-relative absolute path of the default output folder
+ * @exception JavaModelException if this element does not exist
+ * @see #setOutputLocation
+ * @see IClasspathEntry#getOutputLocation
*/
IPath getOutputLocation() throws JavaModelException;
@@ -227,6 +317,7 @@
* @param entry the given entry
* @return the existing package fragment roots identified by the given entry
* @see IClasspathContainer
+ * @deprecated Use IJavaProject#findPackageFragmentRoots instead
*/
IPackageFragmentRoot[] getPackageFragmentRoots(IClasspathEntry entry);
@@ -254,34 +345,6 @@
IProject getProject();
/**
- * This is a helper method returning the resolved classpath for the project, as a list of classpath entries,
- * where all classpath variable entries have been resolved and substituted with their final target entries.
- * <p>
- * A resolved classpath corresponds to a particular instance of the raw classpath bound in the context of
- * the current values of the referred variables, and thus should not be persisted.
- * <p>
- * A classpath variable provides an indirection level for better sharing a classpath. As an example, it allows
- * a classpath to no longer refer directly to external JARs located in some user specific location. The classpath
- * can simply refer to some variables defining the proper locations of these external JARs.
- * <p>
- * The boolean argument <code>ignoreUnresolvedVariable</code> allows to specify how to handle unresolvable variables,
- * when set to <code>true</code>, missing variables are simply ignored, the resulting path is then only formed of the
- * resolvable entries, without any indication about which variable(s) was ignored. When set to <code>false</code>, a
- * JavaModelException will be thrown for the first unresolved variable (from left to right).
- *
- * @exception JavaModelException in one of the corresponding situation:
- * <ul>
- * <li> this element does not exist </li>
- * <li> an exception occurs while accessing its corresponding resource </li>
- * <li> a classpath variable was not resolvable and <code>ignoreUnresolvedVariable</code> was set to <code>false</code>. </li>
- * </ul>
- * @return
- * @see IClasspathEntry
- */
-// IClasspathEntry[] getExpandedClasspath(boolean ignoreUnresolvedVariable)
-// throws JavaModelException;
-
- /**
* Returns the raw classpath for the project, as a list of classpath entries. This corresponds to the exact set
* of entries which were assigned using <code>setRawClasspath</code>, in particular such a classpath may contain
* classpath variable entries. Classpath variable entries can be resolved individually (see <code>JavaCore#getClasspathVariable</code>),
@@ -304,42 +367,50 @@
/**
* Returns the names of the projects that are directly required by this
* project. A project is required if it is in its classpath.
+ * <p>
+ * The project names are returned in the order they appear on the classpath.
*
* @return the names of the projects that are directly required by this
- * project
+ * project in classpath order
* @exception JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
String[] getRequiredProjectNames() throws JavaModelException;
/**
- * This is a helper method returning the resolved classpath for the project, as a list of classpath entries,
- * where all classpath variable entries have been resolved and substituted with their final target entries.
+ * This is a helper method returning the resolved classpath for the project
+ * as a list of simple (non-variable, non-container) classpath entries.
+ * All classpath variable and classpath container entries in the project's
+ * raw classpath will be replaced by the simple classpath entries they
+ * resolve to.
* <p>
- * A resolved classpath corresponds to a particular instance of the raw classpath bound in the context of
- * the current values of the referred variables, and thus should not be persisted.
- * <p>
- * A classpath variable provides an indirection level for better sharing a classpath. As an example, it allows
- * a classpath to no longer refer directly to external JARs located in some user specific location. The classpath
- * can simply refer to some variables defining the proper locations of these external JARs.
- * <p>
- * The boolean argument <code>ignoreUnresolvedVariable</code> allows to specify how to handle unresolvable variables,
- * when set to <code>true</code>, missing variables are simply ignored, the resulting path is then only formed of the
- * resolvable entries, without any indication about which variable(s) was ignored. When set to <code>false</code>, a
- * JavaModelException will be thrown for the first unresolved variable (from left to right).
+ * The resulting resolved classpath is accurate for the given point in time.
+ * If the project's raw classpath is later modified, or if classpath
+ * variables are changed, the resolved classpath can become out of date.
+ * Because of this, hanging on resolved classpath is not recommended.
+ * </p>
*
- * @param ignoreUnresolvedVariable specify how to handle unresolvable variables
- * @return the resolved classpath for the project, as a list of classpath entries,
- * where all classpath variable entries have been resolved and substituted with their final target entries
+ * @param ignoreUnresolvedEntry indicates how to handle unresolvable
+ * variables and containers; <code>true</code> indicates that missing
+ * variables and unresolvable classpath containers should be silently
+ * ignored, and that the resulting list should consist only of the
+ * entries that could be successfully resolved; <code>false</code> indicates
+ * that a <code>JavaModelException</code> should be thrown for the first
+ * unresolved variable or container
+ * @return the resolved classpath for the project as a list of simple
+ * classpath entries, where all classpath variable and container entries
+ * have been resolved and substituted with their final target entries
* @exception JavaModelException in one of the corresponding situation:
* <ul>
- * <li> this element does not exist </li>
- * <li> an exception occurs while accessing its corresponding resource </li>
- * <li> a classpath variable was not resolvable and <code>ignoreUnresolvedVariable</code> was set to <code>false</code>. </li>
+ * <li>this element does not exist</li>
+ * <li>an exception occurs while accessing its corresponding resource</li>
+ * <li>a classpath variable or classpath container was not resolvable
+ * and <code>ignoreUnresolvedEntry</code> is <code>false</code>.</li>
* </ul>
- * @see IClasspathEntry
+ * @see IClasspathEntry
*/
- IClasspathEntry[] getResolvedClasspath(boolean ignoreUnresolvedVariable) throws JavaModelException;
+ IClasspathEntry[] getResolvedClasspath(boolean ignoreUnresolvedEntry)
+ throws JavaModelException;
/**
* Returns whether this project has been built at least once and thus whether it has a build state.
@@ -359,15 +430,29 @@
*/
boolean hasClasspathCycle(IClasspathEntry[] entries);
/**
- * Returns whether the given element is on the classpath of this project.
+ * Returns whether the given element is on the classpath of this project,
+ * that is, referenced from a classpath entry and not explicitly excluded
+ * using an exclusion pattern.
*
* @param element the given element
- * @exception JavaModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource
- * @return true if the given element is on the classpath of this project, false otherwise
+ * @return <code>true</code> if the given element is on the classpath of
+ * this project, <code>false</code> otherwise
+ * @see IClasspathEntry#getExclusionPatterns
* @since 2.0
*/
- boolean isOnClasspath(IJavaElement element) throws JavaModelException;
+ boolean isOnClasspath(IJavaElement element);
+ /**
+ * Returns whether the given resource is on the classpath of this project,
+ * that is, referenced from a classpath entry and not explicitly excluded
+ * using an exclusion pattern.
+ *
+ * @param element the given element
+ * @return <code>true</code> if the given resource is on the classpath of
+ * this project, <code>false</code> otherwise
+ * @see IClasspathEntry#getExclusionPatterns
+ * @since 2.1
+ */
+ boolean isOnClasspath(IResource resource);
/**
* Creates a new evaluation context.
@@ -412,21 +497,49 @@
throws JavaModelException;
/**
- * Sets the output location of this project to the location
- * described by the given absolute path.
+ * Sets the project custom options. All and only the options explicitly included in the given table
+ * are remembered; all previous option settings are forgotten, including ones not explicitly
+ * mentioned.
* <p>
- *
- * @param path the given absolute path
- * @param monitor the given progress monitor
+ * For a complete description of the configurable options, see <code>JavaCore#getDefaultOptions</code>.
+ * </p>
+ *
+ * @param newOptions the new options (key type: <code>String</code>; value type: <code>String</code>),
+ * or <code>null</code> to flush all custom options (clients will automatically get the global JavaCore options).
+ * @see JavaCore#getDefaultOptions
+ * @since 2.1
+ */
+ void setOptions(Map newOptions);
+
+ /**
+ * Sets the default output location of this project to the location
+ * described by the given workspace-relative absolute path.
+ * <p>
+ * The default output location is where class files are ordinarily generated
+ * (and resource files, copied). Each source classpath entries can also
+ * specify an output location for the generated class files (and copied
+ * resource files) corresponding to compilation units under that source
+ * folder. This makes it possible to arrange that generated class files for
+ * different source folders to end up in different output folders, and not
+ * necessarily the default output folder. This means that the generated
+ * class files for the project may end up scattered across several folders,
+ * rather than all in the default output folder (which is more standard).
+ * </p>
+ *
+ * @param path the workspace-relative absolute path of the default output
+ * folder
+ * @param monitor the progress monitor
*
* @exception JavaModelException if the classpath could not be set. Reasons include:
* <ul>
- * <li>This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
- * <li>The path refers to a location not contained in this project (<code>PATH_OUTSIDE_PROJECT</code>)
- * <li>The path is not an absolute path (<code>RELATIVE_PATH</code>)
- * <li>The path is nested inside a package fragment root of this project (<code>INVALID_PATH</code>)
+ * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
+ * <li> The path refers to a location not contained in this project (<code>PATH_OUTSIDE_PROJECT</code>)
+ * <li> The path is not an absolute path (<code>RELATIVE_PATH</code>)
+ * <li> The path is nested inside a package fragment root of this project (<code>INVALID_PATH</code>)
* <li> The output location is being modified during resource change event notification (CORE_EXCEPTION)
* </ul>
+ * @see #getOutputLocation
+ * @see IClasspathEntry#getOutputLocation
*/
void setOutputLocation(IPath path, IProgressMonitor monitor)
throws JavaModelException;
@@ -463,29 +576,37 @@
throws JavaModelException;
/**
- * Sets the both the classpath of this project and its output location at once.
- * The classpath is defined using a list of classpath entries. In particular such a classpath may contain
- * classpath variable entries. Classpath variable entries can be resolved individually (see <code>JavaCore#getClasspathVariable</code>),
- * or the full classpath can be resolved at once using the helper method <code>getResolvedClasspath</code>.
+ * Sets the both the classpath of this project and its default output
+ * location at once. The classpath is defined using a list of classpath
+ * entries. In particular, such a classpath may contain classpath variable
+ * entries. Classpath variable entries can be resolved individually (see
+ * <code>JavaCore#getClasspathVariable</code>), or the full classpath can be
+ * resolved at once using the helper method
+ * <code>getResolvedClasspath</code>.
* <p>
- * A classpath variable provides an indirection level for better sharing a classpath. As an example, it allows
- * a classpath to no longer refer directly to external JARs located in some user specific location. The classpath
- * can simply refer to some variables defining the proper locations of these external JARs.
+ * A classpath variable provides an indirection level for better sharing a
+ * classpath. As an example, it allows a classpath to no longer refer
+ * directly to external JARs located in some user specific location. The
+ * classpath can simply refer to some variables defining the proper
+ * locations of these external JARs.
+ * </p>
* <p>
* Setting the classpath to <code>null</code> specifies a default classpath
* (the project root). Setting the classpath to an empty array specifies an
* empty classpath.
+ * </p>
* <p>
- * If a cycle is detected while setting this classpath, an error marker will be added
- * to the project closing the cycle.
- * To avoid this problem, use <code>hasClasspathCycle(IClasspathEntry[] entries)</code>
- * before setting the classpath.
- *
- * @param entries a list of classpath entries
- * @param monitor the given progress monitor
- * @param outputLocation the given output location
+ * If a cycle is detected while setting this classpath, an error marker will
+ * be added to the project closing the cycle. To avoid this problem, use
+ * <code>hasClasspathCycle(IClasspathEntry[] entries)</code> before setting
+ * the classpath.
+ * </p>
*
- * @exception JavaModelException if the classpath could not be set. Reasons include:
+ * @param entries a list of classpath entries
+ * @param monitor the progress monitor
+ * @param outputLocation the default output location
+ * @exception JavaModelException if the classpath could not be set. Reasons
+ * include:
* <ul>
* <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> Two or more entries specify source roots with the same or overlapping paths (NAME_COLLISION)
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMember.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMember.java
index e40c446..4f0e009 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMember.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMember.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
@@ -49,6 +49,10 @@
/**
* Returns the modifier flags for this member. The flags can be examined using class
* <code>Flags</code>.
+ * <p>
+ * Note that only flags as indicated in the source are returned. Thus if an interface
+ * defines a method <code>void myMethod();</code> the flags don't include the
+ * 'public' flag.
*
* @exception JavaModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMethod.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMethod.java
index bece91a..dd0afce 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMethod.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMethod.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IOpenable.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IOpenable.java
index c2c25d8..2b8a8d4 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IOpenable.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IOpenable.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.IProgressMonitor;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageDeclaration.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageDeclaration.java
index 15b1cf2..0f82fd5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageDeclaration.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragment.java
index d18072d..36f7a61 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragment.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -135,8 +135,17 @@
int getKind() throws JavaModelException;
/**
* Returns an array of non-Java resources contained in this package fragment.
+ * <p>
+ * Non-Java resources includes other files and folders located in the same
+ * directory as the compilation units or class files for this package
+ * fragment. Source files excluded from this package by one or more
+ * exclusion patterns on the corresponding source classpath entry are
+ * considered non-Java resources and will appear in the result
+ * (possibly in a folder).
+ * </p>
*
* @return an array of non-Java resources contained in this package fragment
+ * @see IClasspathEntry#getExclusionPatterns
*/
Object[] getNonJavaResources() throws JavaModelException;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragmentRoot.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragmentRoot.java
index ee5d31d..ded1f77 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragmentRoot.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageFragmentRoot.java
@@ -1,17 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ * IBM Corporation - specified that a source archive or a source folder can be attached to a binary
+ * package fragment root.
+ * IBM Corporation - added root manipulation APIs: copy, delete, move
+ * IBM Corporation - added DESTINATION_PROJECT_CLASSPATH
+ * IBM Corporation - added OTHER_REFERRING_PROJECTS_CLASSPATH
+ * IBM Corporation - added NO_RESOURCE_MODIFICATION
+ * IBM Corporation - added REPLACE
+ * IBM Corporation - added ORIGINATING_PROJECT_CLASSPATH
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IProgressMonitor;
/**
* A package fragment root contains a set of package fragments.
@@ -45,29 +53,122 @@
*/
String DEFAULT_PACKAGEROOT_PATH = ""; //$NON-NLS-1$
/**
+ * Update model flag constant (bit mask value 1) indicating that the operation
+ * is to not copy/move/delete the package fragment root resource.
+ * @since 2.1
+ */
+ int NO_RESOURCE_MODIFICATION = 1;
+ /**
+ * Update model flag constant (bit mask value 2) indicating that the operation
+ * is to update the classpath of the originating project.
+ * @since 2.1
+ */
+ int ORIGINATING_PROJECT_CLASSPATH = 2;
+ /**
+ * Update model flag constant (bit mask value 4) indicating that the operation
+ * is to update the classpath of all referring projects except the originating project.
+ * @since 2.1
+ */
+ int OTHER_REFERRING_PROJECTS_CLASSPATH = 4;
+ /**
+ * Update model flag constant (bit mask value 8) indicating that the operation
+ * is to update the classpath of the destination project.
+ * @since 2.1
+ */
+ int DESTINATION_PROJECT_CLASSPATH = 8;
+ /**
+ * Update model flag constant (bit mask value 16) indicating that the operation
+ * is to replace the resource and the destination project's classpath entry.
+ * @since 2.1
+ */
+ int REPLACE = 16;
+ /**
* Attaches the source archive identified by the given absolute path to this
- * JAR package fragment root. <code>rootPath</code> specifies the location
- * of the root within the archive (<code>null</code> or empty specifies the default root).
- * Once a source archive is attached to the JAR,
+ * binary package fragment root. <code>rootPath</code> specifies the location
+ * of the root within the archive or folder (empty specifies the default root
+ * and <code>null</code> specifies the root path should be detected).
+ * Once a source archive or folder is attached to the package fragment root,
* the <code>getSource</code> and <code>getSourceRange</code>
* methods become operational for binary types/members.
- * To detach a source archive from a JAR, specify <code>null</code> as the
- * archivePath.
+ * To detach a source archive or folder from a package fragment root, specify
+ * <code>null</code> as the source path.
*
- * @param archivePath the given absolute path to this JAR package fragment root
- * @param rootPath specifies the location of the root within the archive (<code>null</code> or empty specifies the default root)
+ * @param sourcePath the given absolute path to the source archive or folder
+ * @param rootPath specifies the location of the root within the archive
+ * (empty specifies the default root and <code>null</code> specifies
+ * automatic detection of the root path)
* @param monitor the given progress monitor
* @exception JavaModelException if this operation fails. Reasons include:
* <ul>
* <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating a server property
- * <li> This package fragment root is not a JAR (INVALID_ELEMENT_TYPES)
+ * <li> This package fragment root is not of kind binary (INVALID_ELEMENT_TYPES)
* <li> The path provided is not absolute (RELATIVE_PATH)
* </ul>
*/
- void attachSource(IPath archivePath, IPath rootPath, IProgressMonitor monitor)
+ void attachSource(IPath sourcePath, IPath rootPath, IProgressMonitor monitor)
throws JavaModelException;
-
+
+ /**
+ * Copies the resource of this package fragment root to the destination path
+ * as specified by <code>IResource.copy(IPath, int, IProgressMonitor)</code>
+ * but excluding nested source folders.
+ * <p>
+ * If <code>NO_RESOURCE_MODIFICATION</code> is specified in
+ * <code>updateModelFlags</code> or if this package fragment root is external,
+ * this operation doesn't copy the resource. <code>updateResourceFlags</code>
+ * is then ignored.
+ * </p><p>
+ * If <code>DESTINATION_PROJECT_CLASSPATH</code> is specified in
+ * <code>updateModelFlags</code>, updates the classpath of the
+ * destination's project (if it is a Java project). If a non-<code>null</code>
+ * sibling is specified, a copy of this root's classpath entry is inserted before the
+ * sibling on the destination project's raw classpath. If <code>null</code> is
+ * specified, the classpath entry is added at the end of the raw classpath.
+ * </p><p>
+ * If <code>REPLACE</code> is specified in <code>updateModelFlags</code>,
+ * overwrites the resource at the destination path if any.
+ * If the same classpath entry already exists on the destination project's raw
+ * classpath, then the sibling is ignored and the new classpath entry replaces the
+ * existing one.
+ * </p><p>
+ * If no flags is specified in <code>updateModelFlags</code> (using
+ * <code>IResource.NONE</code>), the default behavior applies: the
+ * resource is copied (if this package fragment root is not external) and the
+ * classpath is not updated.
+ * </p>
+ *
+ * @param destination the destination path
+ * @param updateResourceFlags bit-wise or of update resource flag constants
+ * (<code>IResource.FORCE</code> and <code>IResource.SHALLOW</code>)
+ * @param updateModelFlags bit-wise or of update resource flag constants
+ * (<code>DESTINATION_PROJECT_CLASSPATH</code> and
+ * <code>NO_RESOURCE_MODIFICATION</code>)
+ * @param sibling the classpath entry before which a copy of the classpath
+ * entry should be inserted or <code>null</code> if the classpath entry should
+ * be inserted at the end
+ * @param monitor a progress monitor
+ *
+ * @exception JavaModelException if this root could not be copied. Reasons
+ * include:
+ * <ul>
+ * <li> This root does not exist (ELEMENT_DOES_NOT_EXIST)</li>
+ * <li> A <code>CoreException</code> occurred while copying the
+ * resource or updating a classpath</li>
+ * <li>
+ * The destination is not inside an existing project and <code>updateModelFlags</code>
+ * has been specified as <code>DESTINATION_PROJECT_CLASSPATH</code>
+ * (INVALID_DESTINATION)</li>
+ * <li> The sibling is not a classpath entry on the destination project's
+ * raw classpath (INVALID_SIBLING)</li>
+ * <li> The same classpath entry already exists on the destination project's
+ * classpath (NAME_COLLISION) and <code>updateModelFlags</code>
+ * has not been specified as <code>REPLACE</code></li>
+ * </ul>
+ * @see org.eclipse.core.resources.IResource#copy
+ * @since 2.1
+ */
+ void copy(IPath destination, int updateResourceFlags, int updateModelFlags, IClasspathEntry sibling, IProgressMonitor monitor) throws JavaModelException;
/**
* Creates and returns a package fragment in this root with the
* given dot-separated package name. An empty string specifies the default package.
@@ -97,7 +198,51 @@
boolean force,
IProgressMonitor monitor)
throws JavaModelException;
-
+ /**
+ * Deletes the resource of this package fragment root as specified by
+ * <code>IResource.delete(int, IProgressMonitor)</code> but excluding nested
+ * source folders.
+ * <p>
+ * If <code>NO_RESOURCE_MODIFICATION</code> is specified in
+ * <code>updateModelFlags</code> or if this package fragment root is external,
+ * this operation doesn't delete the resource. <code>updateResourceFlags</code>
+ * is then ignored.
+ * </p><p>
+ * If <code>ORIGINATING_PROJECT_CLASSPATH</code> is specified in
+ * <code>updateModelFlags</code>, update the raw classpath of this package
+ * fragment root's project by removing the corresponding classpath entry.
+ * </p><p>
+ * If <code>OTHER_REFERRING_PROJECTS_CLASSPATH</code> is specified in
+ * <code>updateModelFlags</code>, update the raw classpaths of all other Java
+ * projects referring to this root's resource by removing the corresponding classpath
+ * entries.
+ * </p><p>
+ * If no flags is specified in <code>updateModelFlags</code> (using
+ * <code>IResource.NONE</code>), the default behavior applies: the
+ * resource is deleted (if this package fragment root is not external) and no
+ * classpaths are updated.
+ * </p>
+ *
+ * @param updateResourceFlags bit-wise or of update resource flag constants
+ * (<code>IResource.FORCE</code> and <code>IResource.KEEP_HISTORY</code>)
+ * @param updateModelFlags bit-wise or of update resource flag constants
+ * (<code>ORIGINATING_PROJECT_CLASSPATH</code>,
+ * <code>OTHER_REFERRING_PROJECTS_CLASSPATH</code> and
+ * <code>NO_RESOURCE_MODIFICATION</code>)
+ * @param monitor a progress monitor
+ *
+ * @exception JavaModelException if this root could not be deleted. Reasons
+ * include:
+ * <ul>
+ * <li> This root does not exist (ELEMENT_DOES_NOT_EXIST)</li>
+ * <li> A <code>CoreException</code> occurred while deleting the resource
+ * or updating a classpath
+ * </li>
+ * </ul>
+ * @see org.eclipse.core.resources.IResource#delete
+ * @since 2.1
+ */
+ void delete(int updateResourceFlags, int updateModelFlags, IProgressMonitor monitor) throws JavaModelException;
/**
* Returns this package fragment root's kind encoded as an integer.
* A package fragment root can contain <code>.java</code> source files,
@@ -117,8 +262,17 @@
/**
* Returns an array of non-Java resources contained in this package fragment root.
- *
+ * <p>
+ * Non-Java resources includes other files and folders located in the same
+ * directories as the compilation units or class files under this package
+ * fragment root. Resources excluded from this package fragment root
+ * by one or more exclusion patterns on the corresponding source classpath
+ * entry are considered non-Java resources and will appear in the result
+ * (possibly in a folder). Thus when a nested source folder is excluded, it will appear
+ * in the non-Java resources of the outer folder.
+ * </p>
* @return an array of non-Java resources contained in this package fragment root
+ * @see IClasspathEntry#getExclusionPatterns
*/
Object[] getNonJavaResources() throws JavaModelException;
@@ -176,7 +330,7 @@
* Returns whether this package fragment root's underlying
* resource is a binary archive (a JAR or zip file).
*
- * @return true if this package ragment root's underlying resource is a binary archive, false otherwise
+ * @return true if this package fragment root's underlying resource is a binary archive, false otherwise
*/
public boolean isArchive();
@@ -190,4 +344,77 @@
* underlying resource, false otherwise
*/
boolean isExternal();
+
+ /**
+ * Moves the resource of this package fragment root to the destination path
+ * as specified by <code>IResource.move(IPath,int,IProgressMonitor)</code>
+ * but excluding nested source folders.
+ * <p>
+ * If <code>NO_RESOURCE_MODIFICATION</code> is specified in
+ * <code>updateModelFlags</code> or if this package fragment root is external,
+ * this operation doesn't move the resource. <code>updateResourceFlags</code>
+ * is then ignored.
+ * </p><p>
+ * If <code>DESTINATION_PROJECT_CLASSPATH</code> is specified in
+ * <code>updateModelFlags</code>, updates the classpath of the
+ * destination's project (if it is a Java project). If a non-<code>null</code>
+ * sibling is specified, a copy of this root's classpath entry is inserted before the
+ * sibling on the destination project's raw classpath. If <code>null</code> is
+ * specified, the classpath entry is added at the end of the raw classpath.
+ * </p><p>
+ * If <code>ORIGINATING_PROJECT_CLASSPATH</code> is specified in
+ * <code>updateModelFlags</code>, update the raw classpath of this package
+ * fragment root's project by removing the corresponding classpath entry.
+ * </p><p>
+ * If <code>OTHER_REFERRING_PROJECTS_CLASSPATH</code> is specified in
+ * <code>updateModelFlags</code>, update the raw classpaths of all other Java
+ * projects referring to this root's resource by removing the corresponding classpath
+ * entries.
+ * </p><p>
+ * If <code>REPLACE</code> is specified in <code>updateModelFlags</code>,
+ * overwrites the resource at the destination path if any.
+ * If the same classpath entry already exists on the destination project's raw
+ * classpath, then the sibling is ignored and the new classpath entry replaces the
+ * existing one.
+ * </p><p>
+ * If no flags is specified in <code>updateModelFlags</code> (using
+ * <code>IResource.NONE</code>), the default behavior applies: the
+ * resource is moved (if this package fragment root is not external) and no
+ * classpaths are updated.
+ * </p>
+ *
+ * @param destination the destination path
+ * @param updateFlags bit-wise or of update flag constants
+ * (<code>IResource.FORCE</code>, <code>IResource.KEEP_HISTORY</code>
+ * and <code>IResource.SHALLOW</code>)
+ * @param updateModelFlags bit-wise or of update resource flag constants
+ * (<code>DESTINATION_PROJECT_CLASSPATH</code>,
+ * <code>ORIGINATING_PROJECT_CLASSPATH</code>,
+ * <code>OTHER_REFERRING_PROJECTS_CLASSPATH</code> and
+ * <code>NO_RESOURCE_MODIFICATION</code>)
+ * @param sibling the classpath entry before which a copy of the classpath
+ * entry should be inserted or <code>null</code> if the classpath entry should
+ * be inserted at the end
+ * @param monitor a progress monitor
+ *
+ * @exception JavaModelException if this root could not be moved. Reasons
+ * include:
+ * <ul>
+ * <li> This root does not exist (ELEMENT_DOES_NOT_EXIST)</li>
+ * <li> A <code>CoreException</code> occurred while copying the
+ * resource or updating a classpath</li>
+ * <li>
+ * The destination is not inside an existing project and <code>updateModelFlags</code>
+ * has been specified as <code>DESTINATION_PROJECT_CLASSPATH</code>
+ * (INVALID_DESTINATION)</li>
+ * <li> The sibling is not a classpath entry on the destination project's
+ * raw classpath (INVALID_SIBLING)</li>
+ * <li> The same classpath entry already exists on the destination project's
+ * classpath (NAME_COLLISION) and <code>updateModelFlags</code>
+ * has not been specified as <code>REPLACE</code></li>
+ * </ul>
+ * @see org.eclipse.core.resources.IResource#move
+ * @since 2.1
+ */
+ void move(IPath destination, int updateResourceFlags, int updateModelFlags, IClasspathEntry sibling, IProgressMonitor monitor) throws JavaModelException;
}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IParent.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IParent.java
index 1112cc6..a9d6574 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IParent.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IParent.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IProblemRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IProblemRequestor.java
index eb4477f..3ff34a9 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IProblemRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IProblemRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.jdt.core.compiler.IProblem;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IRegion.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IRegion.java
index 80e8d81..2baa857 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IRegion.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IRegion.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceManipulation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceManipulation.java
index 1172b8f..4ad0c69 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceManipulation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceManipulation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.IProgressMonitor;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceRange.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceRange.java
index 38923e7..0d9712f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceRange.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceRange.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceReference.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceReference.java
index 26866ba..330aa10 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceReference.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ISourceReference.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java
index d36b350..ce0f024 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IType.java
@@ -1,15 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
+import java.io.InputStream;
+
import org.eclipse.core.runtime.IProgressMonitor;
/**
@@ -354,7 +356,7 @@
* For classes, this gives the interfaces that this class implements.
* For interfaces, this gives the interfaces that this interface extends.
* An empty collection is returned if this type does not implement or
- * extend any interfaces. For source types, simples name are returned,
+ * extend any interfaces. For source types, simple names are returned,
* for binary types, qualified names are returned.
*
* @exception JavaModelException if this element does not exist or if an
@@ -473,7 +475,27 @@
* @since 2.0
*/
boolean isMember() throws JavaModelException;
-
+ /**
+ * Loads a previously saved ITypeHierarchy from an input stream. A type hierarchy can
+ * be stored using ITypeHierachy#store(OutputStream).
+ *
+ * Only hierarchies originally created by the following methods can be load:
+ * <ul>
+ * <li>IType#newSupertypeHierarchy(IProgressMonitor)</li>
+ * <li>IType#newTypeHierarchy(IJavaProject, IProgressMonitor)</li>
+ * <li>IType#newTypeHierarchy(IProgressMonitor)</li>
+ * </u>
+ *
+ * @param input stream where hierarchy will be read
+ * @param monitor the given progress monitor
+ * @return the stored hierarchy
+ * @exception JavaModelException if the hierarchy could not be restored, reasons include:
+ * - type is not the focus of the hierarchy or
+ * - unable to read the input stream (wrong format, IOException during reading, ...)
+ * @see ITypeHierarchy#store(OutputStream, IProgressMonitor)
+ * @since 2.1
+ */
+ ITypeHierarchy loadTypeHierachy(InputStream input, IProgressMonitor monitor) throws JavaModelException;
/**
* Creates and returns a type hierarchy for this type containing
* this type and all of its supertypes.
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeHierarchy.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeHierarchy.java
index 1eab4dc..fe4885b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeHierarchy.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeHierarchy.java
@@ -1,15 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
+import java.io.OutputStream;
+
import org.eclipse.core.runtime.IProgressMonitor;
/**
@@ -274,4 +276,23 @@
* @param listener the listener
*/
void removeTypeHierarchyChangedListener(ITypeHierarchyChangedListener listener);
+/**
+ * Stores the type hierarchy in an output stream. This stored hierarchy can be load by
+ * IType#loadTypeHierachy(IJavaProject, InputStream, IProgressMonitor).
+ * Listeners of this hierarchy are not stored.
+ *
+ * Only hierarchies created by the following methods can be store:
+ * <ul>
+ * <li>IType#newSupertypeHierarchy(IProgressMonitor)</li>
+ * <li>IType#newTypeHierarchy(IJavaProject, IProgressMonitor)</li>
+ * <li>IType#newTypeHierarchy(IProgressMonitor)</li>
+ * </u>
+ *
+ * @param outputStream output stream where the hierarchy will be stored
+ * @param monitor the given progress monitor
+ * @exception JavaModelException if unable to store the hierarchy in the ouput stream
+ * @see IType#loadTypeHierachy(InputStream, IProgressMonitor)
+ * @since 2.1
+ */
+void store(OutputStream outputStream, IProgressMonitor monitor) throws JavaModelException;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeHierarchyChangedListener.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeHierarchyChangedListener.java
index cd249bb..ffa1a82 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeHierarchyChangedListener.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ITypeHierarchyChangedListener.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IWorkingCopy.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IWorkingCopy.java
index 0231ade..44a2850 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IWorkingCopy.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IWorkingCopy.java
@@ -1,15 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
- * IBM Corporation - initial API
- * IBM Corporation, 2002/03/01- added notion of shared working copy
- * IBM Corporation, 2002/26/01- added notion of IProblemRequestor
- ******************************************************************************/
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.resources.IMarker;
@@ -68,13 +66,16 @@
* a subsequent change in the resource</li>
* <li> <code>false</code> - in this case a <code>JavaModelException</code> is thrown</li>
* </ul>
- *
+ * <p>
+ * Since 2.1, a working copy can be created on a not-yet existing compilation
+ * unit. In particular, such a working copy can then be committed in order to create
+ * the corresponding compilation unit.
+ * </p>
* @param force a flag to handle the cases when the contents of the original resource have changed
* since this working copy was created
* @param monitor the given progress monitor
* @exception JavaModelException if this working copy could not commit. Reasons include:
* <ul>
- * <li> The original Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
* <li> A <code>CoreException</code> occurred while updating an underlying resource
* <li> This element is not a working copy (INVALID_ELEMENT_TYPES)
* <li> A update conflict (described above) (UPDATE_CONFLICT)
@@ -91,7 +92,10 @@
* If this working copy is shared, it is destroyed only when the number of calls to
* <code>destroy()</code> is the same as the number of calls to <code>
* getSharedWorkingCopy(IProgressMonitor, IBufferFactory)</code>.
- * A REMOVED IJavaElementDelta is then reported on this working copy.
+ * </p><p>
+ * When it is destroyed, a REMOVED IJavaElementDelta is reported on this
+ * working copy.
+ * </p>
*/
void destroy();
@@ -190,10 +194,7 @@
* reconciling as they are discovered. The requestor can be set to <code>null</code> indicating
* that the client is not interested in problems.
* @exception JavaModelException if the contents of this element can
- * not be determined. Reasons include:
- * <ul>
- * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
- * </ul>
+ * not be determined.
* @return a shared working copy on this element using the given factory to create
* the buffer, or this element if this element is already a working copy
* @see IBufferFactory
@@ -209,15 +210,19 @@
/**
* Returns a new working copy of this element if this element is not
* a working copy, or this element if this element is already a working copy.
- *
+ * <p>
* Note: if intending to share a working copy amongst several clients, then
* <code>#getSharedWorkingCopy</code> should be used instead.
- *
+ * </p><p>
+ * When the working copy instance is created, an ADDED IJavaElementDelta is
+ * reported on this working copy.
+ * </p><p>
+ * Since 2.1, a working copy can be created on a not-yet existing compilation
+ * unit. In particular, such a working copy can then be committed in order to create
+ * the corresponding compilation unit.
+ * </p>
* @exception JavaModelException if the contents of this element can
- * not be determined. Reasons include:
- * <ul>
- * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
- * </ul>
+ * not be determined.
* @return a new working copy of this element if this element is not
* a working copy, or this element if this element is already a working copy
*/
@@ -230,10 +235,17 @@
* working copy is closed then reopened, this factory will be reused.
* The buffer will be automatically initialized with the original's compilation unit content
* upon creation.
- *
+ * <p>
* Note: if intending to share a working copy amongst several clients, then
* <code>#getSharedWorkingCopy</code> should be used instead.
- *
+ * </p><p>
+ * When the working copy instance is created, an ADDED IJavaElementDelta is
+ * reported on this working copy.
+ * </p><p>
+ * Since 2.1, a working copy can be created on a not-yet existing compilation
+ * unit. In particular, such a working copy can then be committed in order to create
+ * the corresponding compilation unit.
+ * </p>
* @param monitor a progress monitor used to report progress while opening this compilation unit
* or <code>null</code> if no progress should be reported
* @param factory the factory that creates a buffer that is used to get the content of the working copy
@@ -242,10 +254,7 @@
* reconciling as they are discovered. The requestor can be set to <code>null</code> indicating
* that the client is not interested in problems.
* @exception JavaModelException if the contents of this element can
- * not be determined. Reasons include:
- * <ul>
- * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
- * </ul>
+ * not be determined.
* @return a new working copy of this element using the given factory to create
* the buffer, or this element if this element is already a working copy
* @since 2.0
@@ -346,4 +355,4 @@
* </ul>
*/
void restore() throws JavaModelException;
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java
index e489c0b..8e68a28 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java
@@ -1,17 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import java.io.File;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;
@@ -24,10 +23,11 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
+import org.eclipse.jdt.internal.core.*;
import org.eclipse.jdt.internal.core.JavaModel;
import org.eclipse.jdt.internal.core.JavaModelStatus;
import org.eclipse.jdt.internal.core.Util;
@@ -40,492 +40,640 @@
* </p>
*/
public final class JavaConventions {
+
private final static char fgDot= '.';
- private final static String fgJAVA= "JAVA"; //$NON-NLS-1$
private final static Scanner SCANNER = new Scanner();
-/**
- * Not instantiable.
- */
-private JavaConventions() {}
-/**
- * Returns whether the given package fragment root paths are considered
- * to overlap.
- * <p>
- * Two root paths overlap if one is a prefix of the other, or they point to
- * the same location. However, a JAR is allowed to be nested in a root.
- *
- * @param rootPath1 the first root path
- * @param rootPath2 the second root path
- * @return true if the given package fragment root paths are considered to overlap, false otherwise
- */
-public static boolean isOverlappingRoots(IPath rootPath1, IPath rootPath2) {
- if (rootPath1 == null || rootPath2 == null) {
- return false;
+
+ /**
+ * Not instantiable.
+ */
+ private JavaConventions() {}
+
+ /*
+ * Returns the index of the first argument paths which is strictly enclosing the path to check
+ */
+ private static int indexOfEnclosingPath(IPath checkedPath, IPath[] paths, int pathCount) {
+
+ for (int i = 0; i < pathCount; i++){
+ if (paths[i].equals(checkedPath)) continue;
+ if (paths[i].isPrefixOf(checkedPath)) return i;
+ }
+ return -1;
}
- String extension1 = rootPath1.getFileExtension();
- String extension2 = rootPath2.getFileExtension();
- String jarExtension = "JAR"; //$NON-NLS-1$
- String zipExtension = "ZIP"; //$NON-NLS-1$
- if (extension1 != null && (extension1.equalsIgnoreCase(jarExtension) || extension1.equalsIgnoreCase(zipExtension))) {
- return false;
- }
- if (extension2 != null && (extension2.equalsIgnoreCase(jarExtension) || extension2.equalsIgnoreCase(zipExtension))) {
- return false;
+
+ /*
+ * Returns the index of the first argument paths which is equal to the path to check
+ */
+ private static int indexOfMatchingPath(IPath checkedPath, IPath[] paths, int pathCount) {
+
+ for (int i = 0; i < pathCount; i++){
+ if (paths[i].equals(checkedPath)) return i;
+ }
+ return -1;
}
- return rootPath1.isPrefixOf(rootPath2) || rootPath2.isPrefixOf(rootPath1);
-}
-/**
- * Returns the current identifier extracted by the scanner (ie. without unicodes)
- * from the given id.
- * Returns <code>null</code> if the id was not valid.
- */
-private static synchronized char[] scannedIdentifier(String id) {
- if (id == null) {
- return null;
+
+ /*
+ * Returns the index of the first argument paths which is strictly nested inside the path to check
+ */
+ private static int indexOfNestedPath(IPath checkedPath, IPath[] paths, int pathCount) {
+
+ for (int i = 0; i < pathCount; i++){
+ if (checkedPath.equals(paths[i])) continue;
+ if (checkedPath.isPrefixOf(paths[i])) return i;
+ }
+ return -1;
}
- String trimmed = id.trim();
- if (!trimmed.equals(id)) {
- return null;
+
+ /**
+ * Returns whether the given package fragment root paths are considered
+ * to overlap.
+ * <p>
+ * Two root paths overlap if one is a prefix of the other, or they point to
+ * the same location. However, a JAR is allowed to be nested in a root.
+ *
+ * @param rootPath1 the first root path
+ * @param rootPath2 the second root path
+ * @return true if the given package fragment root paths are considered to overlap, false otherwise
+ * @deprecated Overlapping roots are allowed in 2.1
+ */
+ public static boolean isOverlappingRoots(IPath rootPath1, IPath rootPath2) {
+ if (rootPath1 == null || rootPath2 == null) {
+ return false;
+ }
+ String extension1 = rootPath1.getFileExtension();
+ String extension2 = rootPath2.getFileExtension();
+ String jarExtension = "JAR"; //$NON-NLS-1$
+ String zipExtension = "ZIP"; //$NON-NLS-1$
+ if (extension1 != null && (extension1.equalsIgnoreCase(jarExtension) || extension1.equalsIgnoreCase(zipExtension))) {
+ return false;
+ }
+ if (extension2 != null && (extension2.equalsIgnoreCase(jarExtension) || extension2.equalsIgnoreCase(zipExtension))) {
+ return false;
+ }
+ return rootPath1.isPrefixOf(rootPath2) || rootPath2.isPrefixOf(rootPath1);
}
- try {
- SCANNER.setSource(id.toCharArray());
- int token = SCANNER.getNextToken();
- char[] currentIdentifier;
+
+ /**
+ * Returns the current identifier extracted by the scanner (ie. without unicodes)
+ * from the given id.
+ * Returns <code>null</code> if the id was not valid.
+ */
+ private static synchronized char[] scannedIdentifier(String id) {
+ if (id == null) {
+ return null;
+ }
+ String trimmed = id.trim();
+ if (!trimmed.equals(id)) {
+ return null;
+ }
try {
- currentIdentifier = SCANNER.getCurrentIdentifierSource();
- } catch (ArrayIndexOutOfBoundsException e) {
- return null;
- }
- int nextToken= SCANNER.getNextToken();
- if (token == ITerminalSymbols.TokenNameIdentifier
- && nextToken == ITerminalSymbols.TokenNameEOF
- && SCANNER.startPosition == SCANNER.source.length) { // to handle case where we had an ArrayIndexOutOfBoundsException
- // while reading the last token
- return currentIdentifier;
- } else {
- return null;
- }
- }
- catch (InvalidInputException e) {
- return null;
- }
-}
-/**
- * Validate the given compilation unit name.
- * A compilation unit name must obey the following rules:
- * <ul>
- * <li> it must not be null
- * <li> it must include the <code>".java"</code> suffix
- * <li> its prefix must be a valid identifier
- * <li> it must not contain any characters or substrings that are not valid
- * on the file system on which workspace root is located.
- * </ul>
- * </p>
- * @param name the name of a compilation unit
- * @return a status object with code <code>IStatus.OK</code> if
- * the given name is valid as a compilation unit name, otherwise a status
- * object indicating what is wrong with the name
- */
-public static IStatus validateCompilationUnitName(String name) {
- if (name == null) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.nullName"), null); //$NON-NLS-1$
- }
- String identifier;
- int index;
- index = name.lastIndexOf('.');
- if (index == -1) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"), null); //$NON-NLS-1$
- }
- identifier = name.substring(0, index);
- IStatus status = validateIdentifier(identifier);
- if (!status.isOK()) {
- return status;
- }
- if (!Util.isJavaFileName(name)) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"), null); //$NON-NLS-1$
- }
- status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
- if (!status.isOK()) {
- return status;
- }
- return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK", null); //$NON-NLS-1$
-}
-/**
- * Validate the given .class file name.
- * A .class file name must obey the following rules:
- * <ul>
- * <li> it must not be null
- * <li> it must include the <code>".class"</code> suffix
- * <li> its prefix must be a valid identifier
- * <li> it must not contain any characters or substrings that are not valid
- * on the file system on which workspace root is located.
- * </ul>
- * </p>
- * @param name the name of a .class file
- * @return a status object with code <code>IStatus.OK</code> if
- * the given name is valid as a .class file name, otherwise a status
- * object indicating what is wrong with the name
- * @since 2.0
- */
-public static IStatus validateClassFileName(String name) {
- if (name == null) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.classFile.nullName"), null); //$NON-NLS-1$
- }
- String identifier;
- int index;
- index = name.lastIndexOf('.');
- if (index == -1) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.classFile.notJavaName"), null); //$NON-NLS-1$
- }
- identifier = name.substring(0, index);
- IStatus status = validateIdentifier(identifier);
- if (!status.isOK()) {
- return status;
- }
- if (!Util.isClassFileName(name)) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.classFile.notClassFileName"), null); //$NON-NLS-1$
- }
- status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
- if (!status.isOK()) {
- return status;
- }
- return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK", null); //$NON-NLS-1$
-}
-/**
- * Validate the given field name.
- * <p>
- * Syntax of a field name corresponds to VariableDeclaratorId (JLS2 8.3).
- * For example, <code>"x"</code>.
- *
- * @param name the name of a field
- * @return a status object with code <code>IStatus.OK</code> if
- * the given name is valid as a field name, otherwise a status
- * object indicating what is wrong with the name
- */
-public static IStatus validateFieldName(String name) {
- return validateIdentifier(name);
-}
-/**
- * Validate the given Java identifier.
- * The identifier must have the same spelling as a Java keyword,
- * boolean literal (<code>"true"</code>, <code>"false"</code>), or null literal (<code>"null"</code>).
- * See section 3.8 of the <em>Java Language Specification, Second Edition</em> (JLS2).
- * A valid identifier can act as a simple type name, method name or field name.
- *
- * @param id the Java identifier
- * @return a status object with code <code>IStatus.OK</code> if
- * the given identifier is a valid Java identifier, otherwise a status
- * object indicating what is wrong with the identifier
- */
-public static IStatus validateIdentifier(String id) {
- if (scannedIdentifier(id) != null) {
- return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK", null); //$NON-NLS-1$
- } else {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.illegalIdentifier", id), null); //$NON-NLS-1$
- }
-}
-/**
- * Validate the given import declaration name.
- * <p>
- * The name of an import corresponds to a fully qualified type name
- * or an on-demand package name as defined by ImportDeclaration (JLS2 7.5).
- * For example, <code>"java.util.*"</code> or <code>"java.util.Hashtable"</code>.
- *
- * @param name the import declaration
- * @return a status object with code <code>IStatus.OK</code> if
- * the given name is valid as an import declaration, otherwise a status
- * object indicating what is wrong with the name
- */
-public static IStatus validateImportDeclaration(String name) {
- if (name == null || name.length() == 0) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.import.nullImport"), null); //$NON-NLS-1$
- }
- if (name.charAt(name.length() - 1) == '*') {
- if (name.charAt(name.length() - 2) == '.') {
- return validatePackageName(name.substring(0, name.length() - 2));
- } else {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.import.unqualifiedImport"), null); //$NON-NLS-1$
- }
- }
- return validatePackageName(name);
-}
-/**
- * Validate the given Java type name, either simple or qualified.
- * For example, <code>"java.lang.Object"</code>, or <code>"Object"</code>.
- * <p>
- *
- * @param name the name of a type
- * @return a status object with code <code>IStatus.OK</code> if
- * the given name is valid as a Java type name,
- * a status with code <code>IStatus.WARNING</code>
- * indicating why the given name is discouraged,
- * otherwise a status object indicating what is wrong with
- * the name
- */
-public static IStatus validateJavaTypeName(String name) {
- if (name == null) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.nullName"), null); //$NON-NLS-1$
- }
- String trimmed = name.trim();
- if (!name.equals(trimmed)) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.nameWithBlanks"), null); //$NON-NLS-1$
- }
- int index = name.lastIndexOf('.');
- char[] scannedID;
- if (index == -1) {
- // simple name
- scannedID = scannedIdentifier(name);
- } else {
- // qualified name
- String pkg = name.substring(0, index).trim();
- IStatus status = validatePackageName(pkg);
- if (!status.isOK()) {
- return status;
- }
- String type = name.substring(index + 1).trim();
- scannedID = scannedIdentifier(type);
- }
-
- if (scannedID != null) {
- IStatus status = ResourcesPlugin.getWorkspace().validateName(new String(scannedID), IResource.FILE);
- if (!status.isOK()) {
- return status;
- }
- if (CharOperation.contains('$', scannedID)) {
- return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.dollarName"), null); //$NON-NLS-1$
- }
- if ((scannedID.length > 0 && Character.isLowerCase(scannedID[0]))) {
- return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.lowercaseName"), null); //$NON-NLS-1$
- }
- return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK", null); //$NON-NLS-1$
- } else {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.invalidName", name), null); //$NON-NLS-1$
- }
-}
-/**
- * Validate the given method name.
- * The special names "<init>" and "<clinit>" are not valid.
- * <p>
- * The syntax for a method name is defined by Identifier
- * of MethodDeclarator (JLS2 8.4). For example "println".
- *
- * @param name the name of a method
- * @return a status object with code <code>IStatus.OK</code> if
- * the given name is valid as a method name, otherwise a status
- * object indicating what is wrong with the name
- */
-public static IStatus validateMethodName(String name) {
- return validateIdentifier(name);
-}
-/**
- * Validate the given package name.
- * <p>
- * The syntax of a package name corresponds to PackageName as
- * defined by PackageDeclaration (JLS2 7.4). For example, <code>"java.lang"</code>.
- * <p>
- * Note that the given name must be a non-empty package name (ie. attempting to
- * validate the default package will return an error status.)
- * Also it must not contain any characters or substrings that are not valid
- * on the file system on which workspace root is located.
- *
- * @param name the name of a package
- * @return a status object with code <code>IStatus.OK</code> if
- * the given name is valid as a package name, otherwise a status
- * object indicating what is wrong with the name
- */
-public static IStatus validatePackageName(String name) {
- if (name == null) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.nullName"), null); //$NON-NLS-1$
- }
- int length;
- if ((length = name.length()) == 0) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.emptyName"), null); //$NON-NLS-1$
- }
- if (name.charAt(0) == fgDot || name.charAt(length-1) == fgDot) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.dotName"), null); //$NON-NLS-1$
- }
- if (Character.isWhitespace(name.charAt(0)) || Character.isWhitespace(name.charAt(name.length() - 1))) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.nameWithBlanks"), null); //$NON-NLS-1$
- }
- int dot = 0;
- while (dot != -1 && dot < length-1) {
- if ((dot = name.indexOf(fgDot, dot+1)) != -1 && dot < length-1 && name.charAt(dot+1) == fgDot) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.consecutiveDotsName"), null); //$NON-NLS-1$
+ SCANNER.setSource(id.toCharArray());
+ int token = SCANNER.getNextToken();
+ char[] currentIdentifier;
+ try {
+ currentIdentifier = SCANNER.getCurrentIdentifierSource();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return null;
}
- }
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- StringTokenizer st = new StringTokenizer(name, new String(new char[] {fgDot}));
- boolean firstToken = true;
- while (st.hasMoreTokens()) {
- String typeName = st.nextToken();
- typeName = typeName.trim(); // grammar allows spaces
- char[] scannedID = scannedIdentifier(typeName);
- if (scannedID == null) {
- return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.illegalIdentifier", typeName), null); //$NON-NLS-1$
+ int nextToken= SCANNER.getNextToken();
+ if (token == TerminalTokens.TokenNameIdentifier
+ && nextToken == TerminalTokens.TokenNameEOF
+ && SCANNER.startPosition == SCANNER.source.length) { // to handle case where we had an ArrayIndexOutOfBoundsException
+ // while reading the last token
+ return currentIdentifier;
+ } else {
+ return null;
+ }
}
- IStatus status = workspace.validateName(new String(scannedID), IResource.FOLDER);
+ catch (InvalidInputException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Validate the given compilation unit name.
+ * A compilation unit name must obey the following rules:
+ * <ul>
+ * <li> it must not be null
+ * <li> it must include the <code>".java"</code> suffix
+ * <li> its prefix must be a valid identifier
+ * <li> it must not contain any characters or substrings that are not valid
+ * on the file system on which workspace root is located.
+ * </ul>
+ * </p>
+ * @param name the name of a compilation unit
+ * @return a status object with code <code>IStatus.OK</code> if
+ * the given name is valid as a compilation unit name, otherwise a status
+ * object indicating what is wrong with the name
+ */
+ public static IStatus validateCompilationUnitName(String name) {
+ if (name == null) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.nullName"), null); //$NON-NLS-1$
+ }
+ if (!Util.isJavaFileName(name)) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"), null); //$NON-NLS-1$
+ }
+ String identifier;
+ int index;
+ index = name.lastIndexOf('.');
+ if (index == -1) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"), null); //$NON-NLS-1$
+ }
+ identifier = name.substring(0, index);
+ IStatus status = validateIdentifier(identifier);
if (!status.isOK()) {
return status;
}
- if (firstToken && scannedID.length > 0 && Character.isUpperCase(scannedID[0])) {
- return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.uppercaseName"), null); //$NON-NLS-1$
+ status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
+ if (!status.isOK()) {
+ return status;
}
- firstToken = false;
+ return JavaModelStatus.VERIFIED_OK;
}
- return new Status(IStatus.OK, JavaCore.PLUGIN_ID, -1, "OK", null); //$NON-NLS-1$
-}
-/**
- * Validate the given classpath and output location, using the following rules:
- * <ul>
- * <li> No duplicate path amongst classpath entries.
- * <li> Output location path is not null, it is absolute and located inside the project.
- * <li> A project cannot depend on itself directly.
- * <li> Source/library folders cannot be nested inside the binary output, and reciprocally.
- * <li> Source/library folders cannot be nested in each other.
- * <li> Output location must be nested inside project.
- * </ul>
- *
- * Note that the classpath entries are not validated automatically. Only bound variables or containers are considered
- * in the checking process (this allows to perform a consistency check on a classpath which has references to
- * yet non existing projects, folders, ...).
- *
- * @param javaProject the given java project
- * @param classpath a given classpath
- * @param outputLocation a given output location
- * @return a status object with code <code>IStatus.OK</code> if
- * the given classpath and output location are compatible, otherwise a status
- * object indicating what is wrong with the classpath or output location
- * @since 2.0
- */
-public static IJavaModelStatus validateClasspath(IJavaProject javaProject, IClasspathEntry[] classpath, IPath outputLocation) {
-
- IProject project = javaProject.getProject();
- IPath projectPath= project.getFullPath();
-
- /* validate output location */
- if (outputLocation == null) {
- return new JavaModelStatus(IJavaModelStatusConstants.NULL_PATH);
- }
- if (outputLocation.isAbsolute()) {
- if (!projectPath.isPrefixOf(outputLocation)) {
- return new JavaModelStatus(IJavaModelStatusConstants.PATH_OUTSIDE_PROJECT, javaProject, outputLocation.toString());
+ /**
+ * Validate the given .class file name.
+ * A .class file name must obey the following rules:
+ * <ul>
+ * <li> it must not be null
+ * <li> it must include the <code>".class"</code> suffix
+ * <li> its prefix must be a valid identifier
+ * <li> it must not contain any characters or substrings that are not valid
+ * on the file system on which workspace root is located.
+ * </ul>
+ * </p>
+ * @param name the name of a .class file
+ * @return a status object with code <code>IStatus.OK</code> if
+ * the given name is valid as a .class file name, otherwise a status
+ * object indicating what is wrong with the name
+ * @since 2.0
+ */
+ public static IStatus validateClassFileName(String name) {
+ if (name == null) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.classFile.nullName"), null); //$NON-NLS-1$
}
- } else {
- return new JavaModelStatus(IJavaModelStatusConstants.RELATIVE_PATH, outputLocation);
+ if (!Util.isClassFileName(name)) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.classFile.notClassFileName"), null); //$NON-NLS-1$
+ }
+ String identifier;
+ int index;
+ index = name.lastIndexOf('.');
+ if (index == -1) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.classFile.notJavaName"), null); //$NON-NLS-1$
+ }
+ identifier = name.substring(0, index);
+ IStatus status = validateIdentifier(identifier);
+ if (!status.isOK()) {
+ return status;
+ }
+ status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
+ if (!status.isOK()) {
+ return status;
+ }
+ return JavaModelStatus.VERIFIED_OK;
}
- boolean allowNestingInOutput = false;
- boolean hasSource = false;
+ /**
+ * Validate the given field name.
+ * <p>
+ * Syntax of a field name corresponds to VariableDeclaratorId (JLS2 8.3).
+ * For example, <code>"x"</code>.
+ *
+ * @param name the name of a field
+ * @return a status object with code <code>IStatus.OK</code> if
+ * the given name is valid as a field name, otherwise a status
+ * object indicating what is wrong with the name
+ */
+ public static IStatus validateFieldName(String name) {
+ return validateIdentifier(name);
+ }
- // tolerate null path, it will be reset to default
- int length = classpath == null ? 0 : classpath.length;
+ /**
+ * Validate the given Java identifier.
+ * The identifier must have the same spelling as a Java keyword,
+ * boolean literal (<code>"true"</code>, <code>"false"</code>), or null literal (<code>"null"</code>).
+ * See section 3.8 of the <em>Java Language Specification, Second Edition</em> (JLS2).
+ * A valid identifier can act as a simple type name, method name or field name.
+ *
+ * @param id the Java identifier
+ * @return a status object with code <code>IStatus.OK</code> if
+ * the given identifier is a valid Java identifier, otherwise a status
+ * object indicating what is wrong with the identifier
+ */
+ public static IStatus validateIdentifier(String id) {
+ if (scannedIdentifier(id) != null) {
+ return JavaModelStatus.VERIFIED_OK;
+ } else {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.illegalIdentifier", id), null); //$NON-NLS-1$
+ }
+ }
- ArrayList resolvedEntries = new ArrayList();
- for (int i = 0 ; i < length; i++) {
- IClasspathEntry rawEntry = classpath[i];
- switch(rawEntry.getEntryKind()){
-
- case IClasspathEntry.CPE_VARIABLE :
- IClasspathEntry resolvedEntry = JavaCore.getResolvedClasspathEntry(rawEntry);
- if (resolvedEntry != null){
- // check if any source entries coincidates with binary output - in which case nesting inside output is legal
- if (resolvedEntry.getPath().equals(outputLocation)) allowNestingInOutput = true;
- resolvedEntries.add(resolvedEntry);
+ /**
+ * Validate the given import declaration name.
+ * <p>
+ * The name of an import corresponds to a fully qualified type name
+ * or an on-demand package name as defined by ImportDeclaration (JLS2 7.5).
+ * For example, <code>"java.util.*"</code> or <code>"java.util.Hashtable"</code>.
+ *
+ * @param name the import declaration
+ * @return a status object with code <code>IStatus.OK</code> if
+ * the given name is valid as an import declaration, otherwise a status
+ * object indicating what is wrong with the name
+ */
+ public static IStatus validateImportDeclaration(String name) {
+ if (name == null || name.length() == 0) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.import.nullImport"), null); //$NON-NLS-1$
+ }
+ if (name.charAt(name.length() - 1) == '*') {
+ if (name.charAt(name.length() - 2) == '.') {
+ return validatePackageName(name.substring(0, name.length() - 2));
+ } else {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.import.unqualifiedImport"), null); //$NON-NLS-1$
+ }
+ }
+ return validatePackageName(name);
+ }
+
+ /**
+ * Validate the given Java type name, either simple or qualified.
+ * For example, <code>"java.lang.Object"</code>, or <code>"Object"</code>.
+ * <p>
+ *
+ * @param name the name of a type
+ * @return a status object with code <code>IStatus.OK</code> if
+ * the given name is valid as a Java type name,
+ * a status with code <code>IStatus.WARNING</code>
+ * indicating why the given name is discouraged,
+ * otherwise a status object indicating what is wrong with
+ * the name
+ */
+ public static IStatus validateJavaTypeName(String name) {
+ if (name == null) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.nullName"), null); //$NON-NLS-1$
+ }
+ String trimmed = name.trim();
+ if (!name.equals(trimmed)) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.nameWithBlanks"), null); //$NON-NLS-1$
+ }
+ int index = name.lastIndexOf('.');
+ char[] scannedID;
+ if (index == -1) {
+ // simple name
+ scannedID = scannedIdentifier(name);
+ } else {
+ // qualified name
+ String pkg = name.substring(0, index).trim();
+ IStatus status = validatePackageName(pkg);
+ if (!status.isOK()) {
+ return status;
+ }
+ String type = name.substring(index + 1).trim();
+ scannedID = scannedIdentifier(type);
+ }
+
+ if (scannedID != null) {
+ IStatus status = ResourcesPlugin.getWorkspace().validateName(new String(scannedID), IResource.FILE);
+ if (!status.isOK()) {
+ return status;
+ }
+ if (CharOperation.contains('$', scannedID)) {
+ return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.dollarName"), null); //$NON-NLS-1$
+ }
+ if ((scannedID.length > 0 && Character.isLowerCase(scannedID[0]))) {
+ return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.lowercaseName"), null); //$NON-NLS-1$
+ }
+ return JavaModelStatus.VERIFIED_OK;
+ } else {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.type.invalidName", name), null); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Validate the given method name.
+ * The special names "<init>" and "<clinit>" are not valid.
+ * <p>
+ * The syntax for a method name is defined by Identifier
+ * of MethodDeclarator (JLS2 8.4). For example "println".
+ *
+ * @param name the name of a method
+ * @return a status object with code <code>IStatus.OK</code> if
+ * the given name is valid as a method name, otherwise a status
+ * object indicating what is wrong with the name
+ */
+ public static IStatus validateMethodName(String name) {
+
+ return validateIdentifier(name);
+ }
+
+ /**
+ * Validate the given package name.
+ * <p>
+ * The syntax of a package name corresponds to PackageName as
+ * defined by PackageDeclaration (JLS2 7.4). For example, <code>"java.lang"</code>.
+ * <p>
+ * Note that the given name must be a non-empty package name (ie. attempting to
+ * validate the default package will return an error status.)
+ * Also it must not contain any characters or substrings that are not valid
+ * on the file system on which workspace root is located.
+ *
+ * @param name the name of a package
+ * @return a status object with code <code>IStatus.OK</code> if
+ * the given name is valid as a package name, otherwise a status
+ * object indicating what is wrong with the name
+ */
+ public static IStatus validatePackageName(String name) {
+
+ if (name == null) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.nullName"), null); //$NON-NLS-1$
+ }
+ int length;
+ if ((length = name.length()) == 0) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.emptyName"), null); //$NON-NLS-1$
+ }
+ if (name.charAt(0) == fgDot || name.charAt(length-1) == fgDot) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.dotName"), null); //$NON-NLS-1$
+ }
+ if (CharOperation.isWhitespace(name.charAt(0)) || CharOperation.isWhitespace(name.charAt(name.length() - 1))) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.nameWithBlanks"), null); //$NON-NLS-1$
+ }
+ int dot = 0;
+ while (dot != -1 && dot < length-1) {
+ if ((dot = name.indexOf(fgDot, dot+1)) != -1 && dot < length-1 && name.charAt(dot+1) == fgDot) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.consecutiveDotsName"), null); //$NON-NLS-1$
}
- break;
+ }
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ StringTokenizer st = new StringTokenizer(name, new String(new char[] {fgDot}));
+ boolean firstToken = true;
+ while (st.hasMoreTokens()) {
+ String typeName = st.nextToken();
+ typeName = typeName.trim(); // grammar allows spaces
+ char[] scannedID = scannedIdentifier(typeName);
+ if (scannedID == null) {
+ return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.illegalIdentifier", typeName), null); //$NON-NLS-1$
+ }
+ IStatus status = workspace.validateName(new String(scannedID), IResource.FOLDER);
+ if (!status.isOK()) {
+ return status;
+ }
+ if (firstToken && scannedID.length > 0 && Character.isUpperCase(scannedID[0])) {
+ return new Status(IStatus.WARNING, JavaCore.PLUGIN_ID, -1, Util.bind("convention.package.uppercaseName"), null); //$NON-NLS-1$
+ }
+ firstToken = false;
+ }
+ return JavaModelStatus.VERIFIED_OK;
+ }
+
+ /**
+ * Validate a given classpath and output location for a project, using the following rules:
+ * <ul>
+ * <li> Classpath entries cannot collide with each other, i.e. all entry paths must be unique.
+ * <li> The project output location path cannot be null, must be absolute and located inside the project.
+ * <li> Specific output locations (specified on source entries) can be null, if not they must be located inside the project,
+ * <li> A project entry cannot refer to itself directly (i.e. a project cannot prerequisite itself).
+ * <li> Classpath entries or output locations cannot coincidate or be nested in each other, except for the following scenarii listed below:
+ * <ul><li> A source folder can coincidate with its own output location, in which case this output can then contain library archives.
+ * However, an output location cannot coincidate with any library or a distinct source folder than the one referring to it. </li>
+ * <li> A source/library folder can be nested in any source folder as long as the nested folder is excluded from the enclosing one. </li>
+ * <li> An output location can be nested in a source folder, if the source folder coincidates with the project itself. </li>
+ * </ul>
+ * </ul>
+ *
+ * Note that the classpath entries are not validated automatically. Only bound variables or containers are considered
+ * in the checking process (this allows to perform a consistency check on a classpath which has references to
+ * yet non existing projects, folders, ...).
+ * <p>
+ * This validation is intended to anticipate classpath issues prior to assigning it to a project. In particular, it will automatically
+ * be performed during the classpath setting operation (if validation fails, the classpath setting will not complete).
+ * <p>
+ * @param javaProject the given java project
+ * @param classpath a given classpath
+ * @param outputLocation a given output location
+ * @return a status object with code <code>IStatus.OK</code> if
+ * the given classpath and output location are compatible, otherwise a status
+ * object indicating what is wrong with the classpath or output location
+ * @since 2.0
+ */
+ public static IJavaModelStatus validateClasspath(IJavaProject javaProject, IClasspathEntry[] rawClasspath, IPath projectOutputLocation) {
+
+ IProject project = javaProject.getProject();
+ IPath projectPath= project.getFullPath();
+
+ /* validate output location */
+ if (projectOutputLocation == null) {
+ return new JavaModelStatus(IJavaModelStatusConstants.NULL_PATH);
+ }
+ if (projectOutputLocation.isAbsolute()) {
+ if (!projectPath.isPrefixOf(projectOutputLocation)) {
+ return new JavaModelStatus(IJavaModelStatusConstants.PATH_OUTSIDE_PROJECT, javaProject, projectOutputLocation.toString());
+ }
+ } else {
+ return new JavaModelStatus(IJavaModelStatusConstants.RELATIVE_PATH, projectOutputLocation);
+ }
+
+ boolean hasSource = false;
+ boolean hasLibFolder = false;
+
- case IClasspathEntry.CPE_CONTAINER :
- try {
- IClasspathContainer container = JavaCore.getClasspathContainer(rawEntry.getPath(), javaProject);
- if (container != null){
- IClasspathEntry[] containerEntries = container.getClasspathEntries();
- if (containerEntries != null){
- for (int j = 0, containerLength = containerEntries.length; j < containerLength; j++){
- //resolvedEntry = JavaCore.getResolvedClasspathEntry(containerEntries[j]);
- resolvedEntry = containerEntries[j];
- if (resolvedEntry != null){
- // check if any source entries coincidates with binary output - in which case nesting inside output is legal
- if (resolvedEntry.getPath().equals(outputLocation)) allowNestingInOutput = true;
- resolvedEntries.add(resolvedEntry);
+ // tolerate null path, it will be reset to default
+ if (rawClasspath == null)
+ return JavaModelStatus.VERIFIED_OK;
+
+ // retrieve resolved classpath
+ IClasspathEntry[] classpath;
+ try {
+ classpath = ((JavaProject)javaProject).getResolvedClasspath(rawClasspath, null /*output*/, true/*ignore pb*/, false/*no marker*/, null /*no reverse map*/);
+ } catch(JavaModelException e){
+ return e.getJavaModelStatus();
+ }
+ int length = classpath.length;
+
+ int outputCount = 1;
+ IPath[] outputLocations = new IPath[length+1];
+ boolean[] allowNestingInOutputLocations = new boolean[length+1];
+ outputLocations[0] = projectOutputLocation;
+
+ // retrieve and check output locations
+ IPath potentialNestedOutput = null;
+ int sourceEntryCount = 0;
+ for (int i = 0 ; i < length; i++) {
+ IClasspathEntry resolvedEntry = classpath[i];
+ switch(resolvedEntry.getEntryKind()){
+ case IClasspathEntry.CPE_SOURCE :
+ sourceEntryCount++;
+
+ if (resolvedEntry.getExclusionPatterns() != null && resolvedEntry.getExclusionPatterns().length > 0
+ && JavaCore.DISABLED.equals(javaProject.getOption(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, true))) {
+ return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_EXCLUSION_PATTERNS, resolvedEntry.getPath());
+ }
+ IPath customOutput;
+ if ((customOutput = resolvedEntry.getOutputLocation()) != null) {
+
+ if (JavaCore.DISABLED.equals(javaProject.getOption(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, true))) {
+ return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS, resolvedEntry.getPath());
+ }
+ // ensure custom output is in project
+ if (customOutput.isAbsolute()) {
+ if (!javaProject.getPath().isPrefixOf(customOutput)) {
+ return new JavaModelStatus(IJavaModelStatusConstants.PATH_OUTSIDE_PROJECT, javaProject, customOutput.toString());
+ }
+ } else {
+ return new JavaModelStatus(IJavaModelStatusConstants.RELATIVE_PATH, customOutput);
+ }
+
+ // ensure custom output doesn't conflict with other outputs
+ int index;
+ if ((index = indexOfMatchingPath(customOutput, outputLocations, outputCount)) != -1) {
+ continue; // already found
+ }
+ if ((index = indexOfEnclosingPath(customOutput, outputLocations, outputCount)) != -1) {
+ if (index == 0) {
+ // custom output is nested in project's output: need to check if all source entries have a custom
+ // output before complaining
+ if (potentialNestedOutput == null) potentialNestedOutput = customOutput;
+ } else {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestOutputInOutput", customOutput.makeRelative().toString(), outputLocations[index].makeRelative().toString())); //$NON-NLS-1$
+ }
+ }
+ outputLocations[outputCount++] = resolvedEntry.getOutputLocation();
+ }
+ }
+ }
+ // allow custom output nesting in project's output if all source entries have a custom output
+ if (potentialNestedOutput != null && sourceEntryCount > outputCount-1) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestOutputInOutput", potentialNestedOutput.makeRelative().toString(), outputLocations[0].makeRelative().toString())); //$NON-NLS-1$
+ }
+
+ for (int i = 0 ; i < length; i++) {
+ IClasspathEntry resolvedEntry = classpath[i];
+ IPath path = resolvedEntry.getPath();
+ int index;
+ switch(resolvedEntry.getEntryKind()){
+
+ case IClasspathEntry.CPE_SOURCE :
+ hasSource = true;
+ if ((index = indexOfMatchingPath(path, outputLocations, outputCount)) != -1){
+ allowNestingInOutputLocations[index] = true;
+ }
+ break;
+
+ case IClasspathEntry.CPE_LIBRARY:
+ hasLibFolder |= !org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(path.lastSegment());
+ if ((index = indexOfMatchingPath(path, outputLocations, outputCount)) != -1){
+ allowNestingInOutputLocations[index] = true;
+ }
+ break;
+ }
+ }
+ if (!hasSource && !hasLibFolder) { // if no source and no lib folder, then allowed
+ for (int i = 0; i < outputCount; i++) allowNestingInOutputLocations[i] = true;
+ }
+
+ HashSet pathes = new HashSet(length);
+
+ // check all entries
+ for (int i = 0 ; i < length; i++) {
+ IClasspathEntry entry = classpath[i];
+ if (entry == null) continue;
+ IPath entryPath = entry.getPath();
+ int kind = entry.getEntryKind();
+
+ // complain if duplicate path
+ if (!pathes.add(entryPath)){
+ return new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION, Util.bind("classpath.duplicateEntryPath", entryPath.makeRelative().toString())); //$NON-NLS-1$
+ }
+ // no further check if entry coincidates with project or output location
+ if (entryPath.equals(projectPath)){
+ // complain if self-referring project entry
+ if (kind == IClasspathEntry.CPE_PROJECT){
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, Util.bind("classpath.cannotReferToItself", entryPath.makeRelative().toString()));//$NON-NLS-1$
+ }
+ // tolerate nesting output in src if src==prj
+ continue;
+ }
+
+ // allow nesting source entries in each other as long as the outer entry excludes the inner one
+ if (kind == IClasspathEntry.CPE_SOURCE
+ || (kind == IClasspathEntry.CPE_LIBRARY && !org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(entryPath.lastSegment()))){
+ for (int j = 0; j < classpath.length; j++){
+ IClasspathEntry otherEntry = classpath[j];
+ if (otherEntry == null) continue;
+ int otherKind = otherEntry.getEntryKind();
+ IPath otherPath = otherEntry.getPath();
+ if (entry != otherEntry
+ && (otherKind == IClasspathEntry.CPE_SOURCE
+ || (otherKind == IClasspathEntry.CPE_LIBRARY
+ && !org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(otherPath.lastSegment())))){
+ char[][] exclusionPatterns;
+ if (otherPath.isPrefixOf(entryPath)
+ && !otherPath.equals(entryPath)
+ && !Util.isExcluded(entryPath.append("*"), exclusionPatterns = ((ClasspathEntry)otherEntry).fullExclusionPatternChars())) { //$NON-NLS-1$
+
+ String exclusionPattern = entryPath.removeFirstSegments(otherPath.segmentCount()).segment(0);
+ if (Util.isExcluded(entryPath, exclusionPatterns)) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.mustEndWithSlash", exclusionPattern, entryPath.makeRelative().toString())); //$NON-NLS-1$
+ } else {
+ if (otherKind == IClasspathEntry.CPE_SOURCE) {
+ exclusionPattern += '/';
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestEntryInEntry", new String[] {entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString(), exclusionPattern})); //$NON-NLS-1$
+ } else {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestEntryInLibrary", new String[] {entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString()})); //$NON-NLS-1$
}
}
}
}
- } catch(JavaModelException e){
- return new JavaModelStatus(e);
}
- break;
-
- case IClasspathEntry.CPE_SOURCE :
- hasSource = true;
- default :
- // check if any source entries coincidates with binary output - in which case nesting inside output is legal
- if (rawEntry.getPath().equals(outputLocation)) allowNestingInOutput = true;
- resolvedEntries.add(rawEntry);
- break;
- }
- }
- if (!hasSource) allowNestingInOutput = true; // if no source, then allowed
-
- length = resolvedEntries.size();
- classpath = new IClasspathEntry[length];
- resolvedEntries.toArray(classpath);
-
- HashSet pathes = new HashSet(length);
-
- // check all entries
- for (int i = 0 ; i < length; i++) {
- IClasspathEntry entry = classpath[i];
-
- if (entry == null) continue;
-
- IPath entryPath = entry.getPath();
- int kind = entry.getEntryKind();
-
- // complain if duplicate path
- if (!pathes.add(entryPath)){
- return new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION, Util.bind("classpath.duplicateEntryPath", entryPath.toString())); //$NON-NLS-1$
- }
- // no further check if entry coincidates with project or output location
- if (entryPath.equals(projectPath)){
- // complain if self-referring project entry
- if (kind == IClasspathEntry.CPE_PROJECT){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, Util.bind("classpath.cannotReferToItself", entryPath.toString()));//$NON-NLS-1$
}
- continue;
- }
+
+ // prevent nesting output location inside entry
+ int index;
+ if ((index = indexOfNestedPath(entryPath, outputLocations, outputCount)) != -1) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestOutputInEntry", outputLocations[index].makeRelative().toString(), entryPath.makeRelative().toString())); //$NON-NLS-1$
+ }
- // prevent nesting source entries in each other
- if (kind == IClasspathEntry.CPE_SOURCE
- || (kind == IClasspathEntry.CPE_LIBRARY && !org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(entryPath.lastSegment()))){
- for (int j = 0; j < classpath.length; j++){
- IClasspathEntry otherEntry = classpath[j];
- if (otherEntry == null) continue;
- int otherKind = otherEntry.getEntryKind();
- if (entry != otherEntry
- && (otherKind == IClasspathEntry.CPE_SOURCE
- || (otherKind == IClasspathEntry.CPE_LIBRARY
- && !org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(otherEntry.getPath().lastSegment())))){
- if (otherEntry.getPath().isPrefixOf(entryPath)){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestEntryInEntry", entryPath.toString(), otherEntry.getPath().toString())); //$NON-NLS-1$
+ // prevent nesting entry inside output location - when distinct from project or a source folder
+ if ((index = indexOfEnclosingPath(entryPath, outputLocations, outputCount)) != -1) {
+ if (!allowNestingInOutputLocations[index]) {
+ // allow nesting in project's output if all source entries have a custom output
+ if (index != 0 || sourceEntryCount > outputCount - 1) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestEntryInOutput", entryPath.makeRelative().toString(), outputLocations[index].makeRelative().toString())); //$NON-NLS-1$
}
}
}
}
- // prevent nesting output location inside entry
- if (!entryPath.equals(outputLocation) && entryPath.isPrefixOf(outputLocation)) {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestEntryInOutput",entryPath.toString(), outputLocation.toString())); //$NON-NLS-1$
- }
+ // ensure that no output is coincidating with another source folder (only allowed if matching current source folder)
+ // perform one separate iteration so as to not take precedence over previously checked scenarii (in particular should
+ // diagnose nesting source folder issue before this one, e.g. [src]"Project/", [src]"Project/source/" and output="Project/" should
+ // first complain about missing exclusion pattern
+ for (int i = 0 ; i < length; i++) {
+ IClasspathEntry entry = classpath[i];
+ if (entry == null) continue;
+ IPath entryPath = entry.getPath();
+ int kind = entry.getEntryKind();
- // prevent nesting entry inside output location - when distinct from project or a source folder
- if (!allowNestingInOutput && outputLocation.isPrefixOf(entryPath)) {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotNestOutputInEntry", outputLocation.toString(), entryPath.toString())); //$NON-NLS-1$
+ if (kind == IClasspathEntry.CPE_SOURCE) {
+ IPath output = entry.getOutputLocation();
+ if (output == null) output = projectOutputLocation; // if no specific output, still need to check using default output
+ for (int j = 0; j < length; j++) {
+ IClasspathEntry otherEntry = classpath[j];
+ if (otherEntry == entry) continue;
+ switch (otherEntry.getEntryKind()) {
+ case IClasspathEntry.CPE_SOURCE :
+ if (otherEntry.getPath().equals(output)) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotUseDistinctSourceFolderAsOutput", entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString())); //$NON-NLS-1$
+ }
+ break;
+ case IClasspathEntry.CPE_LIBRARY :
+ if (otherEntry.getPath().equals(output)) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.cannotUseLibraryAsOutput", entryPath.makeRelative().toString(), otherEntry.getPath().makeRelative().toString())); //$NON-NLS-1$
+ }
+ }
+ }
+ }
}
+ return JavaModelStatus.VERIFIED_OK;
}
- return JavaModelStatus.VERIFIED_OK;
-}
-
+
/**
* Returns a java model status describing the problem related to this classpath entry if any,
* a status object with code <code>IStatus.OK</code> if the entry is fine.
@@ -541,9 +689,8 @@
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IPath path = entry.getPath();
-
switch(entry.getEntryKind()){
-
+
// container entry check
case IClasspathEntry.CPE_CONTAINER :
if (path != null && path.segmentCount() >= 1){
@@ -551,7 +698,7 @@
IClasspathContainer container = JavaCore.getClasspathContainer(path, javaProject);
// container retrieval is performing validation check on container entry kinds.
if (container == null){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundContainerPath", path.toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND, javaProject, path);
}
IClasspathEntry[] containerEntries = container.getClasspathEntries();
if (containerEntries != null){
@@ -562,9 +709,9 @@
|| kind == IClasspathEntry.CPE_SOURCE
|| kind == IClasspathEntry.CPE_VARIABLE
|| kind == IClasspathEntry.CPE_CONTAINER){
- return new JavaModelStatus(
- IJavaModelStatusConstants.INVALID_CP_CONTAINER_ENTRY,
- container.getPath().toString());
+ String description = container.getDescription();
+ if (description == null) description = path.makeRelative().toString();
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CP_CONTAINER_ENTRY, javaProject, path);
}
IJavaModelStatus containerEntryStatus = validateClasspathEntry(javaProject, containerEntry, checkSourceAttachment);
if (!containerEntryStatus.isOK()){
@@ -576,20 +723,20 @@
return new JavaModelStatus(e);
}
} else {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalContainerPath", path.toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalContainerPath", path.makeRelative().toString())); //$NON-NLS-1$
}
break;
-
+
// variable entry check
case IClasspathEntry.CPE_VARIABLE :
if (path != null && path.segmentCount() >= 1){
entry = JavaCore.getResolvedClasspathEntry(entry);
if (entry == null){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundVariablePath", path.toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND, javaProject, path);
}
return validateClasspathEntry(javaProject, entry, checkSourceAttachment);
} else {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalVariablePath", path.toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalVariablePath", path.makeRelative().toString())); //$NON-NLS-1$
}
// library entry check
@@ -601,13 +748,12 @@
IResource resolvedResource = (IResource) target;
switch(resolvedResource.getType()){
case IResource.FILE :
- String extension = resolvedResource.getFileExtension();
- if ("jar".equalsIgnoreCase(extension) || "zip".equalsIgnoreCase(extension)){ // internal binary archive //$NON-NLS-2$ //$NON-NLS-1$
+ if (Util.isArchiveFileName(resolvedResource.getFileExtension())) {
if (checkSourceAttachment
&& sourceAttachment != null
&& !sourceAttachment.isEmpty()
&& JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.toString(), path.toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.makeRelative().toString(), path.makeRelative().toString())); //$NON-NLS-1$
}
}
break;
@@ -616,7 +762,7 @@
&& sourceAttachment != null
&& !sourceAttachment.isEmpty()
&& JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.toString(), path.toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.makeRelative().toString(), path.makeRelative().toString())); //$NON-NLS-1$
}
}
} else if (target instanceof File){
@@ -624,13 +770,13 @@
&& sourceAttachment != null
&& !sourceAttachment.isEmpty()
&& JavaModel.getTarget(workspaceRoot, sourceAttachment, true) == null){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.toString(), path.toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceAttachment", sourceAttachment.toString(), path.makeRelative().toString())); //$NON-NLS-1$
}
} else {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundLibrary", path.toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundLibrary", path.makeRelative().toString())); //$NON-NLS-1$
}
} else {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalLibraryPath", path.toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalLibraryPath", path.makeRelative().toString())); //$NON-NLS-1$
}
break;
@@ -640,7 +786,7 @@
IProject project = workspaceRoot.getProject(path.segment(0));
try {
if (!project.exists() || !project.hasNature(JavaCore.NATURE_ID)){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundProject", path.segment(0).toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundProject", path.makeRelative().segment(0).toString())); //$NON-NLS-1$
}
if (!project.isOpen()){
return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.closedProject", path.segment(0).toString())); //$NON-NLS-1$
@@ -655,16 +801,24 @@
// project source folder
case IClasspathEntry.CPE_SOURCE :
+ if (entry.getExclusionPatterns() != null
+ && entry.getExclusionPatterns().length > 0
+ && JavaCore.DISABLED.equals(javaProject.getOption(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, true))) {
+ return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_EXCLUSION_PATTERNS, path);
+ }
+ if (entry.getOutputLocation() != null && JavaCore.DISABLED.equals(javaProject.getOption(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, true))) {
+ return new JavaModelStatus(IJavaModelStatusConstants.DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS, path);
+ }
if (path != null && path.isAbsolute() && !path.isEmpty()) {
IPath projectPath= javaProject.getProject().getFullPath();
if (!projectPath.isPrefixOf(path) || JavaModel.getTarget(workspaceRoot, path, true) == null){
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceFolder", path.toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.unboundSourceFolder", path.makeRelative().toString())); //$NON-NLS-1$
}
} else {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalSourceFolderPath", path.toString())); //$NON-NLS-1$
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_CLASSPATH, Util.bind("classpath.illegalSourceFolderPath", path.makeRelative().toString())); //$NON-NLS-1$
}
break;
}
- return JavaModelStatus.VERIFIED_OK;
-}
+ return JavaModelStatus.VERIFIED_OK;
+ }
}
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 72971a8..b5c3c06 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
@@ -1,55 +1,44 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ * IBM Corporation - added the following constants:
+ * COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE
+ * COMPILER_PB_STATIC_ACCESS_RECEIVER
+ * COMPILER_TASK_TAGS
+ * CORE_CIRCULAR_CLASSPATH
+ * CORE_INCOMPLETE_CLASSPATH
+ * IBM Corporation - added run(IWorkspaceRunnable, IProgressMonitor)
+ * IBM Corporation - added exclusion patterns to source classpath entries
+ * IBM Corporation - added specific output location to source classpath entries
+ * IBM Corporation - added the following constants:
+ * CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER
+ * CLEAN
+ * IBM Corporation - added getClasspathContainerInitializer(String)
+ * IBM Corporation - added the following constants:
+ * CODEASSIST_ARGUMENT_PREFIXES
+ * CODEASSIST_ARGUMENT_SUFFIXES
+ * CODEASSIST_FIELD_PREFIXES
+ * CODEASSIST_FIELD_SUFFIXES
+ * CODEASSIST_LOCAL_PREFIXES
+ * CODEASSIST_LOCAL_SUFFIXES
+ * CODEASSIST_STATIC_FIELD_PREFIXES
+ * CODEASSIST_STATIC_FIELD_SUFFIXES
+ * COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION
+ *******************************************************************************/
package org.eclipse.jdt.core;
import java.io.File;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.*;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IMarkerDelta;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jdt.internal.core.Assert;
-import org.eclipse.jdt.internal.core.BufferManager;
-import org.eclipse.jdt.internal.core.ClasspathEntry;
-import org.eclipse.jdt.internal.core.JavaModel;
-import org.eclipse.jdt.internal.core.JavaModelManager;
-import org.eclipse.jdt.internal.core.JavaProject;
-import org.eclipse.jdt.internal.core.Region;
-import org.eclipse.jdt.internal.core.SetClasspathOperation;
-import org.eclipse.jdt.internal.core.Util;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jdt.internal.core.*;
/**
* The plug-in runtime class for the Java model plug-in containing the core
@@ -159,6 +148,12 @@
/**
* Possible configurable option ID.
* @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE = PLUGIN_ID + ".compiler.problem.deprecationInDeprecatedCode"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
*/
public static final String COMPILER_PB_HIDDEN_CATCH_BLOCK = PLUGIN_ID + ".compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
/**
@@ -174,6 +169,18 @@
/**
* Possible configurable option ID.
* @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT = PLUGIN_ID + ".compiler.problem.unusedParameterWhenImplementingAbstract"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE = PLUGIN_ID + ".compiler.problem.unusedParameterWhenOverridingConcrete"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
* @since 2.0
*/
public static final String COMPILER_PB_UNUSED_IMPORT = PLUGIN_ID + ".compiler.problem.unusedImport"; //$NON-NLS-1$
@@ -197,6 +204,36 @@
/**
* Possible configurable option ID.
* @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_PB_STATIC_ACCESS_RECEIVER = PLUGIN_ID + ".compiler.problem.staticAccessReceiver"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_PB_NO_EFFECT_ASSIGNMENT = PLUGIN_ID + ".compiler.problem.noEffectAssignment"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD = PLUGIN_ID + ".compiler.problem.incompatibleNonInheritedInterfaceMethod"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_PB_UNUSED_PRIVATE_MEMBER = PLUGIN_ID + ".compiler.problem.unusedPrivateMember"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION = PLUGIN_ID + ".compiler.problem.noImplicitStringConversion"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
* @since 2.0
*/
public static final String COMPILER_PB_MAX_PER_UNIT = PLUGIN_ID + ".compiler.maxProblemPerUnit"; //$NON-NLS-1$
@@ -215,6 +252,36 @@
/**
* Possible configurable option ID.
* @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_TASK_PRIORITIES = PLUGIN_ID + ".compiler.taskPriorities"; //$NON-NLS-1$
+ /**
+ * Possible configurable option value for COMPILER_TASK_PRIORITIES.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_TASK_PRIORITY_HIGH = "HIGH"; //$NON-NLS-1$
+ /**
+ * Possible configurable option value for COMPILER_TASK_PRIORITIES.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_TASK_PRIORITY_LOW = "LOW"; //$NON-NLS-1$
+ /**
+ * Possible configurable option value for COMPILER_TASK_PRIORITIES.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_TASK_PRIORITY_NORMAL = "NORMAL"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String COMPILER_TASK_TAGS = PLUGIN_ID + ".compiler.taskTags"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
*/
public static final String CORE_JAVA_BUILD_ORDER = PLUGIN_ID + ".computeJavaBuildOrder"; //$NON-NLS-1$
/**
@@ -226,6 +293,30 @@
/**
* Possible configurable option ID.
* @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CORE_JAVA_BUILD_DUPLICATE_RESOURCE = PLUGIN_ID + ".builder.duplicateResourceTask"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER = PLUGIN_ID + ".builder.cleanOutputFolder"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID + ".incompleteClasspath"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID + ".circularClasspath"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
* @since 2.0
*/
public static final String CORE_JAVA_BUILD_INVALID_CLASSPATH = PLUGIN_ID + ".builder.invalidClasspath"; //$NON-NLS-1$
@@ -238,6 +329,28 @@
/**
* Possible configurable option ID.
* @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS = PLUGIN_ID + ".classpath.exclusionPatterns"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS = PLUGIN_ID + ".classpath.multipleOutputLocations"; //$NON-NLS-1$
+ /**
+ * Default task tag
+ * @since 2.1
+ */
+ public static final String DEFAULT_TASK_TAG = "TODO"; //$NON-NLS-1$
+ /**
+ * Default task priority
+ * @since 2.1
+ */
+ public static final String DEFAULT_TASK_PRIORITY = "NORMAL"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
* @since 2.0
*/
public static final String FORMATTER_NEWLINE_OPENING_BRACE = PLUGIN_ID + ".formatter.newline.openingBrace"; //$NON-NLS-1$
@@ -290,6 +403,12 @@
*/
public static final String FORMATTER_TAB_SIZE = PLUGIN_ID + ".formatter.tabulation.size"; //$NON-NLS-1$
/**
+ * Possible configurable option ID
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String FORMATTER_SPACE_CASTEXPRESSION = PLUGIN_ID + ".formatter.space.castexpression"; //$NON-NLS-1$
+ /**
* Possible configurable option ID.
* @see #getDefaultOptions
* @since 2.0
@@ -301,6 +420,54 @@
* @since 2.0
*/
public static final String CODEASSIST_IMPLICIT_QUALIFICATION = PLUGIN_ID + ".codeComplete.forceImplicitQualification"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CODEASSIST_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.fieldPrefixes"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CODEASSIST_STATIC_FIELD_PREFIXES = PLUGIN_ID + ".codeComplete.staticFieldPrefixes"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CODEASSIST_LOCAL_PREFIXES = PLUGIN_ID + ".codeComplete.localPrefixes"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CODEASSIST_ARGUMENT_PREFIXES = PLUGIN_ID + ".codeComplete.argumentPrefixes"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CODEASSIST_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.fieldSuffixes"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CODEASSIST_STATIC_FIELD_SUFFIXES = PLUGIN_ID + ".codeComplete.staticFieldSuffixes"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CODEASSIST_LOCAL_SUFFIXES = PLUGIN_ID + ".codeComplete.localSuffixes"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CODEASSIST_ARGUMENT_SUFFIXES = PLUGIN_ID + ".codeComplete.argumentSuffixes"; //$NON-NLS-1$
// *************** Possible values for configurable options. ********************
@@ -432,9 +599,16 @@
* @since 2.0
*/
public static final String DISABLED = "disabled"; //$NON-NLS-1$
+ /**
+ * Possible configurable option value.
+ * @see #getDefaultOptions
+ * @since 2.1
+ */
+ public static final String CLEAN = "clean"; //$NON-NLS-1$
/**
* Creates the Java core plug-in.
+ * @since 2.1
*/
public JavaCore(IPluginDescriptor pluginDescriptor) {
super(pluginDescriptor);
@@ -602,7 +776,7 @@
* <li>a <code>.class</code> file - the element returned is the corresponding <code>IClassFile</code></li>
* <li>a <code>.jar</code> file - the element returned is the corresponding <code>IPackageFragmentRoot</code></li>
* <li>a folder - the element returned is the corresponding <code>IPackageFragmentRoot</code>
- * or <code>IPackageFragment</code></li>
+ * or <code>IPackageFragment</code></li>
* <li>the workspace root resource - the element returned is the <code>IJavaModel</code></li>
* </ul>
* <p>
@@ -700,18 +874,17 @@
*/
public static IClasspathContainer getClasspathContainer(final IPath containerPath, final IJavaProject project) throws JavaModelException {
- Map projectContainers = (Map)JavaModelManager.Containers.get(project);
- if (projectContainers == null){
- projectContainers = new HashMap(1);
- JavaModelManager.Containers.put(project, projectContainers);
- }
- IClasspathContainer container = (IClasspathContainer)projectContainers.get(containerPath);
-
+ IClasspathContainer container = JavaModelManager.containerGet(project, containerPath);
if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle
+
if (container == null){
- final ClasspathContainerInitializer initializer = JavaModelManager.getClasspathContainerInitializer(containerPath.segment(0));
+ final ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
if (initializer != null){
- projectContainers.put(containerPath, JavaModelManager.ContainerInitializationInProgress); // avoid initialization cycles
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPContainer INIT - triggering initialization of: ["+project.getElementName()+"] " + containerPath + " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
+ new Exception("FAKE exception for dumping current CPContainer (["+project.getElementName()+"] "+ containerPath+ ")INIT invocation stack trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ }
+ JavaModelManager.containerPut(project, containerPath, JavaModelManager.ContainerInitializationInProgress); // avoid initialization cycles
boolean ok = false;
try {
// wrap initializer call with Safe runnable in case initializer would be causing some grief
@@ -725,17 +898,14 @@
});
// retrieve value (if initialization was successful)
- container = (IClasspathContainer)projectContainers.get(containerPath);
+ container = JavaModelManager.containerGet(project, containerPath);
if (container == JavaModelManager.ContainerInitializationInProgress) return null; // break cycle
ok = true;
} finally {
- if (!ok) JavaModelManager.Containers.put(project, null); // flush cache
- }
- if (container != null){
- projectContainers.put(containerPath, container);
+ if (!ok) JavaModelManager.containerPut(project, containerPath, null); // flush cache
}
if (JavaModelManager.CP_RESOLVE_VERBOSE){
- System.out.print("CPContainer INIT - after resolution: " + containerPath + " --> "); //$NON-NLS-2$//$NON-NLS-1$
+ System.out.print("CPContainer INIT - after resolution: ["+project.getElementName()+"] " + containerPath + " --> "); //$NON-NLS-2$//$NON-NLS-1$//$NON-NLS-3$
if (container != null){
System.out.print("container: "+container.getDescription()+" {"); //$NON-NLS-2$//$NON-NLS-1$
IClasspathEntry[] entries = container.getClasspathEntries();
@@ -750,12 +920,58 @@
System.out.println("{unbound}");//$NON-NLS-1$
}
}
+ } else {
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPContainer INIT - no initializer found for: "+project.getElementName()+"] " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
}
return container;
}
/**
+ * Helper method finding the classpath container initializer registered for a given classpath container ID
+ * or <code>null</code> if none was found while iterating over the contributions to extension point to
+ * the extension point "org.eclipse.jdt.core.classpathContainerInitializer".
+ * <p>
+ * A containerID is the first segment of any container path, used to identify the registered container initializer.
+ * <p>
+ * @param String - a containerID identifying a registered initializer
+ * @return ClasspathContainerInitializer - the registered classpath container initializer or <code>null</code> if
+ * none was found.
+ * @since 2.1
+ */
+ public static ClasspathContainerInitializer getClasspathContainerInitializer(String containerID){
+
+ Plugin jdtCorePlugin = JavaCore.getPlugin();
+ if (jdtCorePlugin == null) return null;
+
+ IExtensionPoint extension = jdtCorePlugin.getDescriptor().getExtensionPoint(JavaModelManager.CPCONTAINER_INITIALIZER_EXTPOINT_ID);
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ for(int i = 0; i < extensions.length; i++){
+ IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
+ for(int j = 0; j < configElements.length; j++){
+ String initializerID = configElements[j].getAttribute("id"); //$NON-NLS-1$
+ if (initializerID != null && initializerID.equals(containerID)){
+ if (JavaModelManager.CP_RESOLVE_VERBOSE) {
+ System.out.println("CPContainer INIT - found initializer: "+containerID +" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ }
+ try {
+ Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
+ if (execExt instanceof ClasspathContainerInitializer){
+ return (ClasspathContainerInitializer)execExt;
+ }
+ } catch(CoreException e) {
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
* Returns the path held in the given classpath variable.
* Returns <node>null</code> if unable to bind.
* <p>
@@ -764,46 +980,70 @@
* <p>
* Note that classpath variables can be contributed registered initializers for,
* using the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
+ * If an initializer is registered for a variable, its persisted value will be ignored:
+ * its initializer will thus get the opportunity to rebind the variable differently on
+ * each session.
*
* @param variableName the name of the classpath variable
* @return the path, or <code>null</code> if none
* @see #setClasspathVariable
*/
public static IPath getClasspathVariable(final String variableName) {
-
- IPath variablePath = (IPath) JavaModelManager.variableGet(variableName);
+
+ IPath variablePath = JavaModelManager.variableGet(variableName);
if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle
- if (variablePath == null){
- final ClasspathVariableInitializer initializer = getClasspathVariableInitializer(variableName);
- if (initializer != null){
- JavaModelManager.variablePut(variableName, JavaModelManager.VariableInitializationInProgress); // avoid initialization cycles
+ if (variablePath != null) {
+ return variablePath;
+ }
+
+ // even if persisted value exists, initializer is given priority, only if no initializer is found the persisted value is reused
+ final ClasspathVariableInitializer initializer = JavaCore.getClasspathVariableInitializer(variableName);
+ if (initializer != null){
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPVariable INIT - triggering initialization of: " + variableName+ " using initializer: "+ initializer); //$NON-NLS-1$ //$NON-NLS-2$
+ new Exception("FAKE exception for dumping current CPVariable ("+variableName+ ")INIT invocation stack trace").printStackTrace(); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ JavaModelManager.variablePut(variableName, JavaModelManager.VariableInitializationInProgress); // avoid initialization cycles
+ boolean ok = false;
+ try {
// wrap initializer call with Safe runnable in case initializer would be causing some grief
Platform.run(new ISafeRunnable() {
public void handleException(Throwable exception) {
- Util.log(exception, "Exception occurred in classpath variable initializer: "+initializer); //$NON-NLS-1$
+ Util.log(exception, "Exception occurred in classpath variable initializer: "+initializer+" while initializing variable: "+variableName); //$NON-NLS-1$ //$NON-NLS-2$
}
public void run() throws Exception {
initializer.initialize(variableName);
}
});
- variablePath = (IPath) JavaModelManager.variableGet(variableName); // retry
- if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle
+ variablePath = (IPath) JavaModelManager.variableGet(variableName); // initializer should have performed side-effect
+ if (variablePath == JavaModelManager.VariableInitializationInProgress) return null; // break cycle (initializer did not init or reentering call)
if (JavaModelManager.CP_RESOLVE_VERBOSE){
System.out.println("CPVariable INIT - after initialization: " + variableName + " --> " + variablePath); //$NON-NLS-2$//$NON-NLS-1$
}
+ ok = true;
+ } finally {
+ if (!ok) JavaModelManager.variablePut(variableName, null); // flush cache
+ }
+ } else {
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPVariable INIT - no initializer found for: " + variableName); //$NON-NLS-1$
}
}
return variablePath;
}
/**
- * Retrieve the client classpath variable initializer registered for a given variable if any
- *
+ * Helper method finding the classpath variable initializer registered for a given classpath variable name
+ * or <code>null</code> if none was found while iterating over the contributions to extension point to
+ * the extension point "org.eclipse.jdt.core.classpathVariableInitializer".
+ * <p>
* @param the given variable
- * @return the client classpath variable initializer registered for a given variable, <code>null</code> if none
+ * @return ClasspathVariableInitializer - the registered classpath variable initializer or <code>null</code> if
+ * none was found.
+ * @since 2.1
*/
- private static ClasspathVariableInitializer getClasspathVariableInitializer(String variable){
+ public static ClasspathVariableInitializer getClasspathVariableInitializer(String variable){
Plugin jdtCorePlugin = JavaCore.getPlugin();
if (jdtCorePlugin == null) return null;
@@ -813,23 +1053,20 @@
IExtension[] extensions = extension.getExtensions();
for(int i = 0; i < extensions.length; i++){
IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
- IPluginDescriptor plugin = extension.getDeclaringPluginDescriptor();
- if (plugin.isPluginActivated()) {
- for(int j = 0; j < configElements.length; j++){
- try {
- String varAttribute = configElements[j].getAttribute("variable"); //$NON-NLS-1$
- if (variable.equals(varAttribute)) {
- if (JavaModelManager.CP_RESOLVE_VERBOSE) {
- System.out.println("CPVariable INIT - found initializer: "+variable+" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
- if (execExt instanceof ClasspathVariableInitializer){
- return (ClasspathVariableInitializer)execExt;
- }
- }
- } catch(CoreException e){
+ for(int j = 0; j < configElements.length; j++){
+ try {
+ String varAttribute = configElements[j].getAttribute("variable"); //$NON-NLS-1$
+ if (variable.equals(varAttribute)) {
+ if (JavaModelManager.CP_RESOLVE_VERBOSE) {
+ System.out.println("CPVariable INIT - found initializer: "+variable+" --> " + configElements[j].getAttribute("class"));//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
+ }
+ Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
+ if (execExt instanceof ClasspathVariableInitializer){
+ return (ClasspathVariableInitializer)execExt;
}
}
+ } catch(CoreException e){
+ }
}
}
}
@@ -862,257 +1099,425 @@
* Note: more options might be added in further releases.
* <pre>
* RECOGNIZED OPTIONS:
- * COMPILER / Generating Local Variable Debug Attribute
- * 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)
- * - option id: "org.eclipse.jdt.core.compiler.debug.localVariable"
- * - possible values: { "generate", "do not generate" }
- * - default: "generate"
+ * COMPILER / Generating Local Variable Debug Attribute
+ * 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)
+ * - option id: "org.eclipse.jdt.core.compiler.debug.localVariable"
+ * - possible values: { "generate", "do not generate" }
+ * - default: "generate"
*
- * COMPILER / Generating Line Number Debug Attribute
- * When generated, this attribute will enable source code highlighting in debugger
- * (.class file is then bigger).
- * - option id: "org.eclipse.jdt.core.compiler.debug.lineNumber"
- * - possible values: { "generate", "do not generate" }
- * - default: "generate"
- *
- * COMPILER / Generating Source Debug Attribute
- * When generated, this attribute will enable the debugger to present the
- * corresponding source code.
- * - option id: "org.eclipse.jdt.core.compiler.debug.sourceFile"
- * - possible values: { "generate", "do not generate" }
- * - default: "generate"
- *
- * COMPILER / Preserving Unused Local Variables
- * Unless requested to preserve unused local variables (i.e. never read), the
- * compiler will optimize them out, potentially altering debugging
- * - option id: "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
- * - possible values: { "preserve", "optimize out" }
- * - default: "preserve"
+ * COMPILER / Generating Line Number Debug Attribute
+ * When generated, this attribute will enable source code highlighting in debugger
+ * (.class file is then bigger).
+ * - option id: "org.eclipse.jdt.core.compiler.debug.lineNumber"
+ * - possible values: { "generate", "do not generate" }
+ * - default: "generate"
+ *
+ * COMPILER / Generating Source Debug Attribute
+ * When generated, this attribute will enable the debugger to present the
+ * corresponding source code.
+ * - option id: "org.eclipse.jdt.core.compiler.debug.sourceFile"
+ * - possible values: { "generate", "do not generate" }
+ * - default: "generate"
+ *
+ * COMPILER / Preserving Unused Local Variables
+ * Unless requested to preserve unused local variables (i.e. never read), the
+ * compiler will optimize them out, potentially altering debugging
+ * - option id: "org.eclipse.jdt.core.compiler.codegen.unusedLocal"
+ * - possible values: { "preserve", "optimize out" }
+ * - default: "preserve"
*
- * COMPILER / Defining Target Java Platform
- * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
- * Note that "1.4" target require to toggle compliance mode to "1.4" too.
- * - option id: "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
- * - possible values: { "1.1", "1.2", "1.3", "1.4" }
- * - default: "1.1"
+ * COMPILER / Defining Target Java Platform
+ * For binary compatibility reason, .class files can be tagged to with certain VM versions and later.
+ * Note that "1.4" target require to toggle compliance mode to "1.4" too.
+ * - option id: "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
+ * - possible values: { "1.1", "1.2", "1.3", "1.4" }
+ * - default: "1.1"
*
- * COMPILER / Reporting Unreachable Code
- * Unreachable code can optionally be reported as an error, warning or simply
- * ignored. The bytecode generation will always optimized it out.
- * - option id: "org.eclipse.jdt.core.compiler.problem.unreachableCode"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "error"
+ * COMPILER / Reporting Unreachable Code
+ * Unreachable code can optionally be reported as an error, warning or simply
+ * ignored. The bytecode generation will always optimized it out.
+ * - option id: "org.eclipse.jdt.core.compiler.problem.unreachableCode"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "error"
*
- * COMPILER / Reporting Invalid Import
- * An import statement that cannot be resolved might optionally be reported
- * as an error, as a warning or ignored.
- * - option id: "org.eclipse.jdt.core.compiler.problem.invalidImport"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "error"
+ * COMPILER / Reporting Invalid Import
+ * An import statement that cannot be resolved might optionally be reported
+ * as an error, as a warning or ignored.
+ * - option id: "org.eclipse.jdt.core.compiler.problem.invalidImport"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "error"
*
- * COMPILER / Reporting Attempt to Override Package-Default Method
- * A package default method is not visible in a different package, and thus
- * cannot be overridden. When enabling this option, the compiler will signal
- * such scenarii either as an error or a warning.
- * - option id: "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "warning"
+ * COMPILER / Reporting Attempt to Override Package-Default Method
+ * A package default method is not visible in a different package, and thus
+ * cannot be overridden. When enabling this option, the compiler will signal
+ * such scenarii either as an error or a warning.
+ * - option id: "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "warning"
*
- * COMPILER / Reporting Method With Constructor Name
- * Naming a method with a constructor name is generally considered poor
- * style programming. When enabling this option, the compiler will signal such
- * scenarii either as an error or a warning.
- * - option id: "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "warning"
+ * COMPILER / Reporting Method With Constructor Name
+ * Naming a method with a constructor name is generally considered poor
+ * style programming. When enabling this option, the compiler will signal such
+ * scenarii either as an error or a warning.
+ * - option id: "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "warning"
*
- * COMPILER / Reporting Deprecation
- * When enabled, the compiler will signal use of deprecated API either as an
- * error or a warning.
- * - option id: "org.eclipse.jdt.core.compiler.problem.deprecation"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "warning"
+ * COMPILER / Reporting Deprecation
+ * When enabled, the compiler will signal use of deprecated API either as an
+ * error or a warning.
+ * - option id: "org.eclipse.jdt.core.compiler.problem.deprecation"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "warning"
*
- * COMPILER / Reporting Hidden Catch Block
- * 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 an error or a warning for hidden
- * catch blocks corresponding to checked exceptions
- * - option id: "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "warning"
+ * COMPILER / Reporting Deprecation Inside Deprecated Code
+ * When enabled, the compiler will signal use of deprecated API inside deprecated code.
+ * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.deprecation".
+ * - option id: "org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode"
+ * - possible values: { "enabled", "disabled" }
+ * - default: "disabled"
*
- * COMPILER / Reporting Unused Local
- * When enabled, the compiler will issue an error or a warning for unused local
- * variables (i.e. variables never read from)
- * - option id: "org.eclipse.jdt.core.compiler.problem.unusedLocal"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "ignore"
+ * COMPILER / Reporting Hidden Catch Block
+ * 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 an error or a warning for hidden
+ * catch blocks corresponding to checked exceptions
+ * - option id: "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "warning"
*
- * COMPILER / Reporting Unused Parameter
- * When enabled, the compiler will issue an error or a warning for unused method
- * parameters (i.e. parameters never read from)
- * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameter"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "ignore"
+ * COMPILER / Reporting Unused Local
+ * When enabled, the compiler will issue an error or a warning for unused local
+ * variables (i.e. variables never read from)
+ * - option id: "org.eclipse.jdt.core.compiler.problem.unusedLocal"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "ignore"
*
- * COMPILER / Reporting Unused Import
- * When enabled, the compiler will issue an error or a warning for unused import
- * reference
- * - option id: "org.eclipse.jdt.core.compiler.problem.unusedImport"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "ignore"
+ * COMPILER / Reporting Unused Parameter
+ * When enabled, the compiler will issue an error or a warning for unused method
+ * parameters (i.e. parameters never read from)
+ * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameter"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "ignore"
*
- * COMPILER / Reporting Synthetic Access Emulation
- * When enabled, the compiler will issue an error or a warning whenever it emulates
- * access to a non-accessible member of an enclosing type. Such access can have
- * performance implications.
- * - option id: "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "ignore"
+ * COMPILER / Reporting Unused Parameter if Implementing Abstract Method
+ * When enabled, the compiler will signal unused parameters in abstract method implementations.
+ * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
+ * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract"
+ * - possible values: { "enabled", "disabled" }
+ * - default: "disabled"
*
- * COMPILER / Reporting Non-Externalized String Literal
- * When enabled, the compiler will issue an error or a warning for non externalized
- * String literal (i.e. non tagged with //$NON-NLS-<n>$).
- * - option id: "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "ignore"
+ * COMPILER / Reporting Unused Parameter if Overriding Concrete Method
+ * When enabled, the compiler will signal unused parameters in methods overriding concrete ones.
+ * The severity of the problem is controlled with option "org.eclipse.jdt.core.compiler.problem.unusedParameter".
+ * - option id: "org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete"
+ * - possible values: { "enabled", "disabled" }
+ * - default: "disabled"
+ *
+ * COMPILER / Reporting Unused Import
+ * When enabled, the compiler will issue an error or a warning for unused import
+ * reference
+ * - option id: "org.eclipse.jdt.core.compiler.problem.unusedImport"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "warning"
+ *
+ * COMPILER / Reporting Unused Private Members
+ * When enabled, the compiler will issue an error or a warning whenever a private
+ * method or field is declared but never used within the same unit.
+ * - option id: "org.eclipse.jdt.core.compiler.problem.unusedPrivateMember"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "ignore"
+ *
+ * COMPILER / Reporting Synthetic Access Emulation
+ * When enabled, the compiler will issue an error or a warning whenever it emulates
+ * access to a non-accessible member of an enclosing type. Such access can have
+ * performance implications.
+ * - option id: "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "ignore"
+ *
+ * COMPILER / Reporting Non-Externalized String Literal
+ * When enabled, the compiler will issue an error or a warning for non externalized
+ * String literal (i.e. non tagged with //$NON-NLS-<n>$).
+ * - option id: "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "ignore"
*
* COMPILER / Reporting Usage of 'assert' Identifier
* When enabled, the compiler will issue an error or a warning whenever 'assert' is
* used as an identifier (reserved keyword in 1.4)
- * - option id: "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
- * - possible values: { "error", "warning", "ignore" }
- * - default: "ignore"
+ * - option id: "org.eclipse.jdt.core.compiler.problem.assertIdentifier"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "ignore"
*
+ * COMPILER / Reporting Non-Static Reference to a Static Member
+ * When enabled, the compiler will issue an error or a warning whenever a static field
+ * or method is accessed with an expression receiver.
+ * - option id: "org.eclipse.jdt.core.compiler.problem.staticAccessReceiver"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "warning"
+ *
+ * COMPILER / Reporting Assignment with no Effect
+ * When enabled, the compiler will issue an error or a warning whenever an assignment
+ * has no effect (e.g 'x = x').
+ * - option id: "org.eclipse.jdt.core.compiler.problem.noEffectAssignment"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "warning"
+ *
+ * COMPILER / Reporting Interface Method not Compatible with non-Inherited Methods
+ * When enabled, the compiler will issue an error or a warning whenever an interface
+ * defines a method incompatible with a non-inherited Object one.
+ * - option id: "org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "warning"
+ *
+ * COMPILER / Reporting Usage of char[] Expressions in String Concatenations
+ * When enabled, the compiler will issue an error or a warning whenever a char[] expression
+ * is used in String concatenations (e.g. "hello" + new char[]{'w','o','r','l','d'}).
+ * - option id: "org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "warning"
+ *
* COMPILER / Setting Source Compatibility Mode
* Specify whether source is 1.3 or 1.4 compatible. From 1.4 on, 'assert' is a keyword
* reserved for assertion support. Also note, than when toggling to 1.4 mode, the target VM
* level should be set to "1.4" and the compliance mode should be "1.4".
- * - option id: "org.eclipse.jdt.core.compiler.source"
- * - possible values: { "1.3", "1.4" }
- * - default: "1.3"
+ * - option id: "org.eclipse.jdt.core.compiler.source"
+ * - possible values: { "1.3", "1.4" }
+ * - default: "1.3"
*
* COMPILER / Setting Compliance Level
* Select the compliance level for the compiler. In "1.3" mode, source and target settings
* should not go beyond "1.3" level.
- * - option id: "org.eclipse.jdt.core.compiler.compliance"
- * - possible values: { "1.3", "1.4" }
- * - default: "1.3"
+ * - option id: "org.eclipse.jdt.core.compiler.compliance"
+ * - possible values: { "1.3", "1.4" }
+ * - default: "1.3"
*
* COMPILER / Maximum number of problems reported per compilation unit
* Specify the maximum number of problems reported on each compilation unit.
- * - option id: "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
+ * - option id: "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
* - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
- * - default: "100"
+ * - default: "100"
*
+ * COMPILER / Define the Automatic Task Tags
+ * When the tag is non empty, the compiler will issue a task marker whenever it encounters
+ * one of the corresponding tag inside any comment in Java source code.
+ * Generated task messages will include the tag, and range until the next line separator or comment ending, and will be trimmed.
+ * - option id: "org.eclipse.jdt.core.compiler.taskTags"
+ * - possible values: { "<tag>[,<tag>]*" } where <tag> is a String without any wild-card
+ * - default: ""
+ *
+ * COMPILER / Define the Automatic Task Priorities
+ * In parallel with the Automatic Task Tags, this list defines the priorities (high, normal or low)
+ * of the task markers issued by the compiler.
+ * If the default is specified, the priority of each task marker is "NORMAL".
+ * - option id: "org.eclipse.jdt.core.compiler.taskPriorities"
+ * - possible values: { "<priority>[,<priority>]*" } where <priority> is one of "HIGH", "NORMAL" or "LOW"
+ * - default: ""
+ *
* BUILDER / Specifying Filters for Resource Copying Control
* Allow to specify some filters to control the resource copy process.
- * - option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
- * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (only * wild-cards allowed)
+ * - option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilter"
+ * - possible values: { "<name>[,<name>]* } where <name> is a file name pattern (* and ? wild-cards allowed)
* or the name of a folder which ends with '/'
- * - default: ""
+ * - default: ""
*
* BUILDER / Abort if Invalid Classpath
* Allow to toggle the builder to abort if the classpath is invalid
- * - option id: "org.eclipse.jdt.core.builder.invalidClasspath"
- * - possible values: { "abort", "ignore" }
- * - default: "ignore"
+ * - option id: "org.eclipse.jdt.core.builder.invalidClasspath"
+ * - possible values: { "abort", "ignore" }
+ * - default: "ignore"
*
- * JAVACORE / Computing Project Build Order
+ * BUILDER / Cleaning Output Folder(s)
+ * Indicate whether the JavaBuilder is allowed to clean the output folders
+ * when performing full build operations.
+ * - option id: "org.eclipse.jdt.core.builder.cleanOutputFolder"
+ * - possible values: { "clean", "ignore" }
+ * - default: "clean"
+ *
+ * JAVACORE / Computing Project Build Order
* Indicate whether JavaCore should enforce the project build order to be based on
* the classpath prerequisite chain. When requesting to compute, this takes over
* the platform default order (based on project references).
- * - option id: "org.eclipse.jdt.core.computeJavaBuildOrder"
- * - possible values: { "compute", "ignore" }
- * - default: "ignore"
+ * - option id: "org.eclipse.jdt.core.computeJavaBuildOrder"
+ * - possible values: { "compute", "ignore" }
+ * - default: "ignore"
*
* JAVACORE / Specify Default Source Encoding Format
* Get the encoding format for compiled sources. This setting is read-only, it is equivalent
* to 'ResourcesPlugin.getEncoding()'.
- * - option id: "org.eclipse.jdt.core.encoding"
- * - possible values: { any of the supported encoding name}.
- * - default: <platform default>
+ * - option id: "org.eclipse.jdt.core.encoding"
+ * - possible values: { any of the supported encoding name}.
+ * - default: <platform default>
+ *
+ * JAVACORE / Reporting Incomplete Classpath
+ * Indicate the severity of the problem reported when an entry on the classpath doesn't exist
+ * is not legite or is not visible (e.g. a referenced project is closed).
+ * - option id: "org.eclipse.jdt.core.incompleteClasspath"
+ * - possible values: { "error", "warning"}
+ * - default: "error"
+ *
+ * JAVACORE / Reporting Classpath Cycle
+ * Indicate the severity of the problem reported when a project is involved in a cycle.
+ * - option id: "org.eclipse.jdt.core.circularClasspath"
+ * - possible values: { "error", "warning" }
+ * - default: "error"
+ *
+ * JAVACORE / Enabling Usage of Classpath Exclusion Patterns
+ * When set to "disabled", no entry on a project classpath can be associated with
+ * an exclusion pattern.
+ * - option id: "org.eclipse.jdt.core.classpath.exclusionPatterns"
+ * - possible values: { "enabled", "disabled" }
+ * - default: "enabled"
+ *
+ * JAVACORE / Enabling Usage of Classpath Multiple Output Locations
+ * When set to "disabled", no entry on a project classpath can be associated with
+ * a specific output location, preventing thus usage of multiple output locations.
+ * - option id: "org.eclipse.jdt.core.classpath.multipleOutputLocations"
+ * - possible values: { "enabled", "disabled" }
+ * - default: "enabled"
*
* FORMATTER / Inserting New Line Before Opening Brace
* When Insert, a new line is inserted before an opening brace, otherwise nothing
* is inserted
- * - option id: "org.eclipse.jdt.core.formatter.newline.openingBrace"
- * - possible values: { "insert", "do not insert" }
- * - default: "do not insert"
+ * - option id: "org.eclipse.jdt.core.formatter.newline.openingBrace"
+ * - possible values: { "insert", "do not insert" }
+ * - default: "do not insert"
*
* FORMATTER / Inserting New Line Inside Control Statement
* When Insert, a new line is inserted between } and following else, catch, finally
- * - option id: "org.eclipse.jdt.core.formatter.newline.controlStatement"
- * - possible values: { "insert", "do not insert" }
- * - default: "do not insert"
+ * - option id: "org.eclipse.jdt.core.formatter.newline.controlStatement"
+ * - possible values: { "insert", "do not insert" }
+ * - default: "do not insert"
*
* FORMATTER / Clearing Blank Lines
* When Clear all, all blank lines are removed. When Preserve one, only one is kept
* and all others removed.
- * - option id: "org.eclipse.jdt.core.formatter.newline.clearAll"
- * - possible values: { "clear all", "preserve one" }
- * - default: "preserve one"
+ * - option id: "org.eclipse.jdt.core.formatter.newline.clearAll"
+ * - possible values: { "clear all", "preserve one" }
+ * - default: "preserve one"
*
* FORMATTER / Inserting New Line Between Else/If
* When Insert, a blank line is inserted between an else and an if when they are
* contiguous. When choosing to not insert, else-if will be kept on the same
* line when possible.
- * - option id: "org.eclipse.jdt.core.formatter.newline.elseIf"
- * - possible values: { "insert", "do not insert" }
- * - default: "do not insert"
+ * - option id: "org.eclipse.jdt.core.formatter.newline.elseIf"
+ * - possible values: { "insert", "do not insert" }
+ * - default: "do not insert"
*
* FORMATTER / Inserting New Line In Empty Block
* When insert, a line break is inserted between contiguous { and }, if } is not followed
* by a keyword.
- * - option id: "org.eclipse.jdt.core.formatter.newline.emptyBlock"
- * - possible values: { "insert", "do not insert" }
- * - default: "insert"
+ * - option id: "org.eclipse.jdt.core.formatter.newline.emptyBlock"
+ * - possible values: { "insert", "do not insert" }
+ * - default: "insert"
*
* FORMATTER / Splitting Lines Exceeding Length
* Enable splitting of long lines (exceeding the configurable length). Length of 0 will
* disable line splitting
- * - option id: "org.eclipse.jdt.core.formatter.lineSplit"
+ * - option id: "org.eclipse.jdt.core.formatter.lineSplit"
* - possible values: "<n>", where n is zero or a positive integer
- * - default: "80"
+ * - default: "80"
*
* FORMATTER / Compacting Assignment
* Assignments can be formatted asymmetrically, e.g. 'int x= 2;', when Normal, a space
* is inserted before the assignment operator
- * - option id: "org.eclipse.jdt.core.formatter.style.assignment"
- * - possible values: { "compact", "normal" }
- * - default: "normal"
+ * - option id: "org.eclipse.jdt.core.formatter.style.assignment"
+ * - possible values: { "compact", "normal" }
+ * - default: "normal"
*
* FORMATTER / Defining Indentation Character
* Either choose to indent with tab characters or spaces
- * - option id: "org.eclipse.jdt.core.formatter.tabulation.char"
- * - possible values: { "tab", "space" }
- * - default: "tab"
+ * - option id: "org.eclipse.jdt.core.formatter.tabulation.char"
+ * - possible values: { "tab", "space" }
+ * - default: "tab"
*
* FORMATTER / Defining Space Indentation Length
* When using spaces, set the amount of space characters to use for each
* indentation mark.
- * - option id: "org.eclipse.jdt.core.formatter.tabulation.size"
+ * - option id: "org.eclipse.jdt.core.formatter.tabulation.size"
* - possible values: "<n>", where n is a positive integer
- * - default: "4"
+ * - default: "4"
+ *
+ * FORMATTER / Inserting space in cast expression
+ * When Insert, a space is added between the type and the expression in a cast expression.
+ * - option id: "org.eclipse.jdt.core.formatter.space.castexpression"
+ * - possible values: { "insert", "do not insert" }
+ * - default: "insert"
*
* CODEASSIST / Activate Visibility Sensitive Completion
* When active, completion doesn't show that you can not see
* (e.g. you can not see private methods of a super class).
- * - option id: "org.eclipse.jdt.core.codeComplete.visibilityCheck"
- * - possible values: { "enabled", "disabled" }
- * - default: "disabled"
+ * - option id: "org.eclipse.jdt.core.codeComplete.visibilityCheck"
+ * - possible values: { "enabled", "disabled" }
+ * - default: "disabled"
*
* CODEASSIST / Automatic Qualification of Implicit Members
* When active, completion automatically qualifies completion on implicit
* field references and message expressions.
- * - option id: "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
- * - possible values: { "enabled", "disabled" }
- * - default: "disabled"
+ * - option id: "org.eclipse.jdt.core.codeComplete.forceImplicitQualification"
+ * - possible values: { "enabled", "disabled" }
+ * - default: "disabled"
+ *
+ * CODEASSIST / Define the Prefixes for Field Name
+ * When the prefixes is non empty, completion for field name will begin with
+ * one of the proposed prefixes.
+ * - option id: "org.eclipse.jdt.core.codeComplete.fieldPrefixes"
+ * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
+ * - default: ""
+ *
+ * CODEASSIST / Define the Prefixes for Static Field Name
+ * When the prefixes is non empty, completion for static field name will begin with
+ * one of the proposed prefixes.
+ * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldPrefixes"
+ * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
+ * - default: ""
+ *
+ * CODEASSIST / Define the Prefixes for Local Variable Name
+ * When the prefixes is non empty, completion for local variable name will begin with
+ * one of the proposed prefixes.
+ * - option id: "org.eclipse.jdt.core.codeComplete.localPrefixes"
+ * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
+ * - default: ""
+ *
+ * CODEASSIST / Define the Prefixes for Argument Name
+ * When the prefixes is non empty, completion for argument name will begin with
+ * one of the proposed prefixes.
+ * - option id: "org.eclipse.jdt.core.codeComplete.argumentPrefixes"
+ * - possible values: { "<prefix>[,<prefix>]*" } where <prefix> is a String without any wild-card
+ * - default: ""
+ *
+ * CODEASSIST / Define the Suffixes for Field Name
+ * When the suffixes is non empty, completion for field name will end with
+ * one of the proposed suffixes.
+ * - option id: "org.eclipse.jdt.core.codeComplete.fieldSuffixes"
+ * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
+ * - default: ""
+ *
+ * CODEASSIST / Define the Suffixes for Static Field Name
+ * When the suffixes is non empty, completion for static field name will end with
+ * one of the proposed suffixes.
+ * - option id: "org.eclipse.jdt.core.codeComplete.staticFieldSuffixes"
+ * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
+ * - default: ""
+ *
+ * CODEASSIST / Define the Suffixes for Local Variable Name
+ * When the suffixes is non empty, completion for local variable name will end with
+ * one of the proposed suffixes.
+ * - option id: "org.eclipse.jdt.core.codeComplete.localSuffixes"
+ * - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
+ * - default: ""
+ *
+ * CODEASSIST / Define the Suffixes for Argument Name
+ * When the suffixes is non empty, completion for argument name will end with
+ * one of the proposed suffixes.
+ * - option id: "org.eclipse.jdt.core.codeComplete.argumentSuffixes"
+ * - possible values: { "<suffix>[,<suffix>]*" } where <prefix> is a String without any wild-card
+ * - default: ""
* </pre>
*
* @return a mutable table containing the default settings of all known options
@@ -1125,7 +1530,7 @@
// see #initializeDefaultPluginPreferences() for changing default settings
Preferences preferences = getPlugin().getPluginPreferences();
- HashSet optionNames = JavaModelManager.getJavaModelManager().OptionNames;
+ HashSet optionNames = JavaModelManager.OptionNames;
// get preferences set to their default
String[] defaultPropertyNames = preferences.defaultPropertyNames();
@@ -1158,28 +1563,6 @@
public static JavaCore getJavaCore() {
return (JavaCore) getPlugin();
}
- /**
- * Returns the <code>IJavaProject</code> associated with the
- * given <code>IProject</code>, or <code>null</code> if the
- * project does not have a Java nature.
- *
- * @param the given <code>IProject</code>
- * @return the <code>IJavaProject</code> associated with the
- * given <code>IProject</code>, or <code>null</code> if the
- * project does not have a Java nature
- */
- private IJavaProject getJavaProject(IProject project) {
- try {
- if (project.hasNature(NATURE_ID)) {
- JavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
- if (model != null) {
- return model.getJavaProject(project);
- }
- }
- } catch (CoreException e) {
- }
- return null;
- }
/**
* Helper method for returning one option value only. Equivalent to <code>(String)JavaCore.getOptions().get(optionName)</code>
@@ -1198,9 +1581,9 @@
if (CORE_ENCODING.equals(optionName)){
return ResourcesPlugin.getEncoding();
}
- if (JavaModelManager.getJavaModelManager().OptionNames.contains(optionName)){
+ if (JavaModelManager.OptionNames.contains(optionName)){
Preferences preferences = getPlugin().getPluginPreferences();
- return preferences.getString(optionName);
+ return preferences.getString(optionName).trim();
}
return null;
}
@@ -1221,28 +1604,30 @@
Hashtable options = new Hashtable(10);
// see #initializeDefaultPluginPreferences() for changing default settings
- Preferences preferences = getPlugin().getPluginPreferences();
- HashSet optionNames = JavaModelManager.getJavaModelManager().OptionNames;
-
- // get preferences set to their default
- String[] defaultPropertyNames = preferences.defaultPropertyNames();
- for (int i = 0; i < defaultPropertyNames.length; i++){
- String propertyName = defaultPropertyNames[i];
- if (optionNames.contains(propertyName)){
- options.put(propertyName, preferences.getString(propertyName));
- }
- }
- // get preferences not set to their default
- String[] propertyNames = preferences.propertyNames();
- for (int i = 0; i < propertyNames.length; i++){
- String propertyName = propertyNames[i];
- if (optionNames.contains(propertyName)){
- options.put(propertyName, preferences.getString(propertyName));
- }
- }
- // get encoding through resource plugin
- options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
-
+ Plugin plugin = getPlugin();
+ if (plugin != null) {
+ Preferences preferences = getPlugin().getPluginPreferences();
+ HashSet optionNames = JavaModelManager.OptionNames;
+
+ // get preferences set to their default
+ String[] defaultPropertyNames = preferences.defaultPropertyNames();
+ for (int i = 0; i < defaultPropertyNames.length; i++){
+ String propertyName = defaultPropertyNames[i];
+ if (optionNames.contains(propertyName)){
+ options.put(propertyName, preferences.getDefaultString(propertyName));
+ }
+ }
+ // get preferences not set to their default
+ String[] propertyNames = preferences.propertyNames();
+ for (int i = 0; i < propertyNames.length; i++){
+ String propertyName = propertyNames[i];
+ if (optionNames.contains(propertyName)){
+ options.put(propertyName, preferences.getString(propertyName).trim());
+ }
+ }
+ // get encoding through resource plugin
+ options.put(CORE_ENCODING, ResourcesPlugin.getEncoding());
+ }
return options;
}
@@ -1270,7 +1655,7 @@
* Variable source attachment path and root path are also resolved and recorded in the resulting classpath entry.
* <p>
* NOTE: This helper method does not handle classpath containers, for which should rather be used
- * <code>JavaCore#getResolvedClasspathContainer(IPath, IJavaProject)</code>.
+ * <code>JavaCore#getClasspathContainer(IPath, IJavaProject)</code>.
* <p>
*
* @param entry the given variable entry
@@ -1278,19 +1663,19 @@
* if the given variable entry could not be resolved to a valid classpath entry
*/
public static IClasspathEntry getResolvedClasspathEntry(IClasspathEntry entry) {
-
+
if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE)
return entry;
-
+
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IPath resolvedPath = JavaCore.getResolvedVariablePath(entry.getPath());
if (resolvedPath == null)
return null;
-
+
Object target = JavaModel.getTarget(workspaceRoot, resolvedPath, false);
if (target == null)
return null;
-
+
// inside the workspace
if (target instanceof IResource) {
IResource resolvedResource = (IResource) target;
@@ -1302,9 +1687,7 @@
return JavaCore.newProjectEntry(resolvedPath, entry.isExported());
case IResource.FILE :
- String extension = resolvedResource.getFileExtension();
- if ("jar".equalsIgnoreCase(extension) //$NON-NLS-1$
- || "zip".equalsIgnoreCase(extension)) { //$NON-NLS-1$
+ if (Util.isArchiveFileName(resolvedResource.getName())) {
// internal binary archive
return JavaCore.newLibraryEntry(
resolvedPath,
@@ -1359,19 +1742,19 @@
* @return the resolved variable path or <code>null</code> if none
*/
public static IPath getResolvedVariablePath(IPath variablePath) {
-
+
if (variablePath == null)
return null;
int count = variablePath.segmentCount();
if (count == 0)
return null;
-
+
// lookup variable
String variableName = variablePath.segment(0);
IPath resolvedPath = JavaCore.getClasspathVariable(variableName);
if (resolvedPath == null)
return null;
-
+
// append path suffix
if (count > 1) {
resolvedPath = resolvedPath.append(variablePath.removeFirstSegments(1));
@@ -1409,7 +1792,7 @@
protected void initializeDefaultPluginPreferences() {
Preferences preferences = getPluginPreferences();
- HashSet optionNames = JavaModelManager.getJavaModelManager().OptionNames;
+ HashSet optionNames = JavaModelManager.OptionNames;
// Compiler settings
preferences.setDefault(COMPILER_LOCAL_VARIABLE_ATTR, GENERATE);
@@ -1442,6 +1825,9 @@
preferences.setDefault(COMPILER_PB_DEPRECATION, WARNING);
optionNames.add(COMPILER_PB_DEPRECATION);
+ preferences.setDefault(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE, DISABLED);
+ optionNames.add(COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE);
+
preferences.setDefault(COMPILER_PB_HIDDEN_CATCH_BLOCK, WARNING);
optionNames.add(COMPILER_PB_HIDDEN_CATCH_BLOCK);
@@ -1451,9 +1837,18 @@
preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER, IGNORE);
optionNames.add(COMPILER_PB_UNUSED_PARAMETER);
- preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, IGNORE);
+ preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT, DISABLED);
+ optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT);
+
+ preferences.setDefault(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE, DISABLED);
+ optionNames.add(COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE);
+
+ preferences.setDefault(COMPILER_PB_UNUSED_IMPORT, WARNING);
optionNames.add(COMPILER_PB_UNUSED_IMPORT);
+ preferences.setDefault(COMPILER_PB_UNUSED_PRIVATE_MEMBER, IGNORE);
+ optionNames.add(COMPILER_PB_UNUSED_PRIVATE_MEMBER);
+
preferences.setDefault(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION, IGNORE);
optionNames.add(COMPILER_PB_SYNTHETIC_ACCESS_EMULATION);
@@ -1463,6 +1858,24 @@
preferences.setDefault(COMPILER_PB_ASSERT_IDENTIFIER, IGNORE);
optionNames.add(COMPILER_PB_ASSERT_IDENTIFIER);
+ preferences.setDefault(COMPILER_PB_STATIC_ACCESS_RECEIVER, WARNING);
+ optionNames.add(COMPILER_PB_STATIC_ACCESS_RECEIVER);
+
+ preferences.setDefault(COMPILER_PB_NO_EFFECT_ASSIGNMENT, WARNING);
+ optionNames.add(COMPILER_PB_NO_EFFECT_ASSIGNMENT);
+
+ preferences.setDefault(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD, WARNING);
+ optionNames.add(COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD);
+
+ preferences.setDefault(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION, WARNING);
+ optionNames.add(COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION);
+
+ preferences.setDefault(COMPILER_TASK_TAGS, DEFAULT_TASK_TAG); //$NON-NLS-1$
+ optionNames.add(COMPILER_TASK_TAGS);
+
+ preferences.setDefault(COMPILER_TASK_PRIORITIES, DEFAULT_TASK_PRIORITY); //$NON-NLS-1$
+ optionNames.add(COMPILER_TASK_PRIORITIES);
+
preferences.setDefault(COMPILER_SOURCE, VERSION_1_3);
optionNames.add(COMPILER_SOURCE);
@@ -1478,11 +1891,32 @@
preferences.setDefault(CORE_JAVA_BUILD_INVALID_CLASSPATH, ABORT);
optionNames.add(CORE_JAVA_BUILD_INVALID_CLASSPATH);
+
+ preferences.setDefault(CORE_JAVA_BUILD_DUPLICATE_RESOURCE, WARNING);
+ optionNames.add(CORE_JAVA_BUILD_DUPLICATE_RESOURCE);
+ preferences.setDefault(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, CLEAN);
+ optionNames.add(CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER);
+
// JavaCore settings
- preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE); //$NON-NLS-1$
+ preferences.setDefault(CORE_JAVA_BUILD_ORDER, IGNORE);
optionNames.add(CORE_JAVA_BUILD_ORDER);
+ preferences.setDefault(CORE_CIRCULAR_CLASSPATH, ERROR);
+ optionNames.add(CORE_CIRCULAR_CLASSPATH);
+
+ preferences.setDefault(CORE_INCOMPLETE_CLASSPATH, ERROR);
+ optionNames.add(CORE_INCOMPLETE_CLASSPATH);
+
+ preferences.setDefault(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, ENABLED);
+ optionNames.add(CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS);
+
+ preferences.setDefault(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, ENABLED);
+ optionNames.add(CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS);
+
+ // encoding setting comes from resource plug-in
+ optionNames.add(CORE_ENCODING);
+
// Formatter settings
preferences.setDefault(FORMATTER_NEWLINE_OPENING_BRACE, DO_NOT_INSERT);
optionNames.add(FORMATTER_NEWLINE_OPENING_BRACE);
@@ -1511,6 +1945,9 @@
preferences.setDefault(FORMATTER_TAB_SIZE, "4"); //$NON-NLS-1$
optionNames.add(FORMATTER_TAB_SIZE);
+ preferences.setDefault(FORMATTER_SPACE_CASTEXPRESSION, INSERT); //$NON-NLS-1$
+ optionNames.add(FORMATTER_SPACE_CASTEXPRESSION);
+
// CodeAssist settings
preferences.setDefault(CODEASSIST_VISIBILITY_CHECK, DISABLED); //$NON-NLS-1$
optionNames.add(CODEASSIST_VISIBILITY_CHECK);
@@ -1518,6 +1955,29 @@
preferences.setDefault(CODEASSIST_IMPLICIT_QUALIFICATION, DISABLED); //$NON-NLS-1$
optionNames.add(CODEASSIST_IMPLICIT_QUALIFICATION);
+ preferences.setDefault(CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$
+ optionNames.add(CODEASSIST_FIELD_PREFIXES);
+
+ preferences.setDefault(CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$
+ optionNames.add(CODEASSIST_STATIC_FIELD_PREFIXES);
+
+ preferences.setDefault(CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$
+ optionNames.add(CODEASSIST_LOCAL_PREFIXES);
+
+ preferences.setDefault(CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$
+ optionNames.add(CODEASSIST_ARGUMENT_PREFIXES);
+
+ preferences.setDefault(CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$
+ optionNames.add(CODEASSIST_FIELD_SUFFIXES);
+
+ preferences.setDefault(CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
+ optionNames.add(CODEASSIST_STATIC_FIELD_SUFFIXES);
+
+ preferences.setDefault(CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
+ optionNames.add(CODEASSIST_LOCAL_SUFFIXES);
+
+ preferences.setDefault(CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
+ optionNames.add(CODEASSIST_ARGUMENT_SUFFIXES);
}
/**
@@ -1691,7 +2151,7 @@
* @param containerPath the path identifying the container, it must be formed of at least
* one segment (ID+hints)
* @param isExported a boolean indicating whether this entry is contributed to dependent
- * projects in addition to the output location
+ * projects in addition to the output location
* @return a new container classpath entry
*
* @see JavaCore#getClasspathContainer(IPath, IJavaProject)
@@ -1701,16 +2161,19 @@
*/
public static IClasspathEntry newContainerEntry(IPath containerPath, boolean isExported) {
- Assert.isTrue(
- containerPath != null && containerPath.segmentCount() >= 1,
- Util.bind("classpath.illegalContainerPath" )); //$NON-NLS-1$
-
+ if (containerPath == null || containerPath.segmentCount() < 1) {
+ Assert.isTrue(
+ false,
+ "Illegal classpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
+ }
return new ClasspathEntry(
IPackageFragmentRoot.K_SOURCE,
IClasspathEntry.CPE_CONTAINER,
containerPath,
- null,
- null,
+ ClasspathEntry.NO_EXCLUSION_PATTERNS,
+ null, // source attachment
+ null, // source attachment root
+ null, // specific output folder
isExported);
}
@@ -1736,10 +2199,10 @@
* <p>
*
* @param path the absolute path of the binary archive
- * @param sourceAttachmentPath the absolute path of the corresponding source archive,
+ * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder,
* or <code>null</code> if none
- * @param sourceAttachmentRootPath the location of the root within the source archive
- * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
+ * @param sourceAttachmentRootPath the location of the root within the source archive or folder
+ * or <code>null</code> if this location should be automatically detected.
* @return a new library classpath entry
*
* @see #newLibraryEntry(IPath, IPath, IPath, boolean)
@@ -1771,10 +2234,10 @@
* <p>
*
* @param path the absolute path of the binary archive
- * @param sourceAttachmentPath the absolute path of the corresponding source archive,
+ * @param sourceAttachmentPath the absolute path of the corresponding source archive or folder,
* or <code>null</code> if none
- * @param sourceAttachmentRootPath the location of the root within the source archive
- * or <code>null</code> if <code>archivePath</code> is also <code>null</code>
+ * @param sourceAttachmentRootPath the location of the root within the source archive or folder
+ * or <code>null</code> if this location should be automatically detected.
* @param isExported indicates whether this entry is contributed to dependent
* projects in addition to the output location
* @return a new library classpath entry
@@ -1786,16 +2249,16 @@
IPath sourceAttachmentRootPath,
boolean isExported) {
- Assert.isTrue(
- path.isAbsolute(),
- Util.bind("classpath.needAbsolutePath" )); //$NON-NLS-1$
-
+ if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
+
return new ClasspathEntry(
IPackageFragmentRoot.K_BINARY,
IClasspathEntry.CPE_LIBRARY,
JavaProject.canonicalizedPath(path),
+ ClasspathEntry.NO_EXCLUSION_PATTERNS,
sourceAttachmentPath,
sourceAttachmentRootPath,
+ null, // specific output folder
isExported);
}
@@ -1846,15 +2309,17 @@
* @since 2.0
*/
public static IClasspathEntry newProjectEntry(IPath path, boolean isExported) {
- Assert.isTrue(
- path.isAbsolute(),
- Util.bind("classpath.needAbsolutePath" )); //$NON-NLS-1$
+
+ if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
+
return new ClasspathEntry(
IPackageFragmentRoot.K_SOURCE,
IClasspathEntry.CPE_PROJECT,
path,
- null,
- null,
+ ClasspathEntry.NO_EXCLUSION_PATTERNS,
+ null, // source attachment
+ null, // source attachment root
+ null, // specific output folder
isExported);
}
@@ -1868,37 +2333,175 @@
}
/**
- * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code> for the project's source folder
- * identified by the given absolute path. This specifies that all package fragments within the root will
- * have children of type <code>ICompilationUnit</code>.
+ * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
+ * for the project's source folder identified by the given absolute
+ * workspace-relative path. This specifies that all package fragments
+ * within the root will have children of type <code>ICompilationUnit</code>.
* <p>
- * The source folder is referred to using an absolute path relative to the workspace root, e.g. <code>"/Project/src"</code>.
+ * The source folder is referred to using an absolute path relative to the
+ * workspace root, e.g. <code>/Project/src</code>. A project's source
+ * folders are located with that project. That is, a source classpath
+ * entry specifying the path <code>/P1/src</code> is only usable for
+ * project <code>P1</code>.
* </p>
* <p>
- * A source entry is used to set up the internal source layout of a project, and cannot be used out of the
- * context of the containing project (a source entry "Proj1/src" cannot be used on the classpath of Proj2).
+ * The source classpath entry created by this method includes all source
+ * files below the given workspace-relative path. To selectively exclude
+ * some of these source files, use the factory method
+ * <code>JavaCore.newSourceEntry(IPath,IPath[])</code> instead.
* </p>
* <p>
- * A particular source entry cannot be exported to other projects. All sources/binaries inside a project are
- * contributed as a whole through a project entry (see <code>JavaCore.newProjectEntry</code>).
+ * Note that all sources/binaries inside a project are contributed as a whole through
+ * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
+ * source entries cannot be selectively exported.
* </p>
*
- * @param path the absolute path of a source folder
- * @return a new source classpath entry
+ * @param path the absolute workspace-relative path of a source folder
+ * @return a new source classpath entry with not exclusion patterns
+ *
+ * @see #newSourceEntry(org.eclipse.core.runtime.IPath,org.eclipse.core.runtime.IPath[])
*/
public static IClasspathEntry newSourceEntry(IPath path) {
- Assert.isTrue(
- path.isAbsolute(),
- Util.bind("classpath.needAbsolutePath" )); //$NON-NLS-1$
+
+ return newSourceEntry(path, ClasspathEntry.NO_EXCLUSION_PATTERNS, null /*output location*/);
+ }
+
+ /**
+ * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
+ * for the project's source folder identified by the given absolute
+ * workspace-relative path but excluding all source files with paths
+ * matching any of the given patterns. This specifies that all package
+ * fragments within the root will have children of type
+ * <code>ICompilationUnit</code>.
+ * <p>
+ * The source folder is referred to using an absolute path relative to the
+ * workspace root, e.g. <code>/Project/src</code>. A project's source
+ * folders are located with that project. That is, a source classpath
+ * entry specifying the path <code>/P1/src</code> is only usable for
+ * project <code>P1</code>.
+ * </p>
+ * <p>
+ * The source classpath entry created by this method includes all source
+ * files below the given workspace-relative path except for those matched
+ * by one (or more) of the given exclusion patterns. Each exclusion pattern
+ * is represented by a relative path, which is interpreted as relative to
+ * the source folder. For example, if the source folder path is
+ * <code>/Project/src</code> and the exclusion pattern is
+ * <code>com/xyz/tests/**</code>, then source files
+ * like <code>/Project/src/com/xyz/Foo.java</code>
+ * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
+ * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
+ * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
+ * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
+ * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code>
+ * for the full description of the syntax and semantics of exclusion
+ * patterns.
+ * </p>
+ * If the empty list of exclusion patterns is specified, the source folder
+ * will automatically include all resources located inside the source
+ * folder. In that case, the result is entirely equivalent to using the
+ * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
+ * </p>
+ * <p>
+ * Note that all sources/binaries inside a project are contributed as a whole through
+ * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
+ * source entries cannot be selectively exported.
+ * </p>
+ *
+ * @param path the absolute workspace-relative path of a source folder
+ * @param exclusionPatterns the possibly empty list of exclusion patterns
+ * represented as relative paths
+ * @return a new source classpath entry with the given exclusion patterns
+ * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
+ * @see IClasspathEntry#getExclusionPatterns
+ *
+ * @since 2.1
+ */
+ public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) {
+
+ return newSourceEntry(path, exclusionPatterns, null /*output location*/);
+ }
+
+ /**
+ * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
+ * for the project's source folder identified by the given absolute
+ * workspace-relative path but excluding all source files with paths
+ * matching any of the given patterns, and associated with a specific output location
+ * (i.e. ".class" files are not going to the project default output location).
+ * All package fragments within the root will have children of type
+ * <code>ICompilationUnit</code>.
+ * <p>
+ * The source folder is referred to using an absolute path relative to the
+ * workspace root, e.g. <code>/Project/src</code>. A project's source
+ * folders are located with that project. That is, a source classpath
+ * entry specifying the path <code>/P1/src</code> is only usable for
+ * project <code>P1</code>.
+ * </p>
+ * <p>
+ * The source classpath entry created by this method includes all source
+ * files below the given workspace-relative path except for those matched
+ * by one (or more) of the given exclusion patterns. Each exclusion pattern
+ * is represented by a relative path, which is interpreted as relative to
+ * the source folder. For example, if the source folder path is
+ * <code>/Project/src</code> and the exclusion pattern is
+ * <code>com/xyz/tests/**</code>, then source files
+ * like <code>/Project/src/com/xyz/Foo.java</code>
+ * and <code>/Project/src/com/xyz/utils/Bar.java</code> would be included,
+ * whereas <code>/Project/src/com/xyz/tests/T1.java</code>
+ * and <code>/Project/src/com/xyz/tests/quick/T2.java</code> would be
+ * excluded. Exclusion patterns can contain can contain '**', '*' or '?'
+ * wildcards; see <code>IClasspathEntry.getExclusionPatterns</code>
+ * for the full description of the syntax and semantics of exclusion
+ * patterns.
+ * </p>
+ * If the empty list of exclusion patterns is specified, the source folder
+ * will automatically include all resources located inside the source
+ * folder. In that case, the result is entirely equivalent to using the
+ * factory method <code>JavaCore.newSourceEntry(IPath)</code>.
+ * </p>
+ * <p>
+ * Additionally, a source entry can be associated with a specific output location.
+ * By doing so, the Java builder will ensure that the generated ".class" files will
+ * be issued inside this output location, as opposed to be generated into the
+ * project default output location (when output location is <code>null</code>).
+ * Note that multiple source entries may target the same output location.
+ * The output location is referred to using an absolute path relative to the
+ * workspace root, e.g. <code>"/Project/bin"</code>, it must be located inside
+ * the same project as the source folder.
+ * </p>
+ * <p>
+ * Also note that all sources/binaries inside a project are contributed as a whole through
+ * a project entry (see <code>JavaCore.newProjectEntry</code>). Particular
+ * source entries cannot be selectively exported.
+ * </p>
+ *
+ * @param path the absolute workspace-relative path of a source folder
+ * @param exclusionPatterns the possibly empty list of exclusion patterns
+ * represented as relative paths
+ * @param outputLocation the specific output location for this source entry (<code>null</code> if using project default ouput location)
+ * @return a new source classpath entry with the given exclusion patterns
+ * @see #newSourceEntry(org.eclipse.core.runtime.IPath)
+ * @see IClasspathEntry#getExclusionPatterns
+ * @see IClasspathEntry#getOutputLocation()
+ *
+ * @since 2.1
+ */
+ public static IClasspathEntry newSourceEntry(IPath path, IPath[] exclusionPatterns, IPath specificOutputLocation) {
+
+ if (!path.isAbsolute()) Assert.isTrue(false, "Path for IClasspathEntry must be absolute"); //$NON-NLS-1$
+ if (exclusionPatterns == null) Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
+
return new ClasspathEntry(
IPackageFragmentRoot.K_SOURCE,
IClasspathEntry.CPE_SOURCE,
path,
- null,
- null,
+ exclusionPatterns,
+ null, // source attachment
+ null, // source attachment root
+ specificOutputLocation, // custom output location
false);
}
-
+
/**
* Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code>
* for the given path. The first segment of the path is the name of a classpath variable.
@@ -1942,9 +2545,7 @@
IPath variablePath,
IPath variableSourceAttachmentPath,
IPath sourceAttachmentRootPath) {
- Assert.isTrue(
- variablePath != null && variablePath.segmentCount() >= 1,
- Util.bind("classpath.illegalVariablePath" )); //$NON-NLS-1$
+
return newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, false);
}
@@ -1988,19 +2589,23 @@
public static IClasspathEntry newVariableEntry(
IPath variablePath,
IPath variableSourceAttachmentPath,
- IPath sourceAttachmentRootPath,
+ IPath variableSourceAttachmentRootPath,
boolean isExported) {
- Assert.isTrue(
- variablePath != null && variablePath.segmentCount() >= 1,
- Util.bind("classpath.illegalVariablePath" )); //$NON-NLS-1$
-
+ if (variablePath == null || variablePath.segmentCount() < 1) {
+ Assert.isTrue(
+ false,
+ "Illegal classpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
return new ClasspathEntry(
IPackageFragmentRoot.K_SOURCE,
IClasspathEntry.CPE_VARIABLE,
variablePath,
- variableSourceAttachmentPath,
- sourceAttachmentRootPath,
+ ClasspathEntry.NO_EXCLUSION_PATTERNS,
+ variableSourceAttachmentPath, // source attachment
+ variableSourceAttachmentRootPath, // source attachment root
+ null, // specific output folder
isExported);
}
@@ -2056,7 +2661,43 @@
public static void removeElementChangedListener(IElementChangedListener listener) {
JavaModelManager.getJavaModelManager().removeElementChangedListener(listener);
}
-
+ /**
+ * Runs the given action as an atomic java model operation.
+ * <p>
+ * After running a method that modifies java elements,
+ * registered listeners receive after-the-fact notification of
+ * what just transpired, in the form of a element changed event.
+ * This method allows clients to call a number of
+ * methods that modify java elements and only have element
+ * changed event notifications reported at the end of the entire
+ * batch.
+ * </p>
+ * <p>
+ * If this method is called outside the dynamic scope of another such
+ * call, this method runs the action and then reports a single
+ * element changed event describing the net effect of all changes
+ * done to java elements by the action.
+ * </p>
+ * <p>
+ * If this method is called in the dynamic scope of another such
+ * call, this method simply runs the action.
+ * </p>
+ *
+ * @param action the action to perform
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting and cancellation are not desired
+ * @exception CoreException if the operation failed.
+ * @since 2.1
+ */
+ public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ if (workspace.isTreeLocked()) {
+ new BatchOperation(action).run(monitor);
+ } else {
+ // use IWorkspace.run(...) to ensure that a build will be done in autobuild mode
+ workspace.run(new BatchOperation(action), monitor);
+ }
+ }
/**
* Bind a container reference path to some actual containers (<code>IClasspathContainer</code>).
* This API must be invoked whenever changes in container need to be reflected onto the JavaModel.
@@ -2086,7 +2727,10 @@
* <code>ClasspathContainerInitializer</code> for each referenced container
* (through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer").
* <p>
- *
+ * Note: setting a container to <code>null</code> will cause it to be lazily resolved again whenever
+ * its value is required. In particular, this will cause a registered initializer to be invoked
+ * again.
+ * <p>
* @param containerPath - the name of the container reference, which is being updated
* @param affectedProjects - the set of projects for which this container is being bound
* @param respectiveContainers - the set of respective containers for the affected projects
@@ -2097,27 +2741,42 @@
* @see IClasspathContainer
* @since 2.0
*/
- public static void setClasspathContainer(IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer[] respectiveContainers, IProgressMonitor monitor) throws JavaModelException {
+ public static void setClasspathContainer(final IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer[] respectiveContainers, IProgressMonitor monitor) throws JavaModelException {
- Assert.isTrue(affectedProjects.length == respectiveContainers.length, Util.bind("classpath.mismatchProjectsContainers" )); //$NON-NLS-1$
-
+ if (affectedProjects.length != respectiveContainers.length) Assert.isTrue(false, "Projects and containers collections should have the same size"); //$NON-NLS-1$
+
if (monitor != null && monitor.isCanceled()) return;
+
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPContainer SET - setting container: ["+containerPath+"] for projects: {" //$NON-NLS-1$ //$NON-NLS-2$
+ + (Util.toString(affectedProjects,
+ new Util.Displayable(){
+ public String displayString(Object o) { return ((IJavaProject) o).getElementName(); }
+ }))
+ + "} with values: " //$NON-NLS-1$
+ + (Util.toString(respectiveContainers,
+ new Util.Displayable(){
+ public String displayString(Object o) { return ((IClasspathContainer) o).getDescription(); }
+ }))
+ );
+ }
- int projectLength = affectedProjects.length;
- JavaModelManager manager = JavaModelManager.getJavaModelManager();
- IClasspathEntry[][] oldResolvedPaths = new IClasspathEntry[projectLength][];
-
+ final int projectLength = affectedProjects.length;
+ final IJavaProject[] modifiedProjects;
+ System.arraycopy(affectedProjects, 0, modifiedProjects = new IJavaProject[projectLength], 0, projectLength);
+ final IClasspathEntry[][] oldResolvedPaths = new IClasspathEntry[projectLength][];
+
// filter out unmodified project containers
int remaining = 0;
for (int i = 0; i < projectLength; i++){
-
+
if (monitor != null && monitor.isCanceled()) return;
-
+
IJavaProject affectedProject = affectedProjects[i];
IClasspathContainer newContainer = respectiveContainers[i];
-
+ if (newContainer == null) newContainer = JavaModelManager.ContainerInitializationInProgress; // 30920 - prevent infinite loop
boolean found = false;
- if (affectedProject.getProject().exists()){
+ if (JavaProject.hasJavaNature(affectedProject.getProject())){
IClasspathEntry[] rawClasspath = affectedProject.getRawClasspath();
for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
IClasspathEntry entry = rawClasspath[j];
@@ -2128,75 +2787,80 @@
}
}
if (!found){
- affectedProjects[i] = null; // filter out this project - does not reference the container path
+ modifiedProjects[i] = null; // filter out this project - does not reference the container path, or isnt't yet Java project
+ JavaModelManager.containerPut(affectedProject, containerPath, newContainer);
+ continue;
}
-
- Map perProjectContainers = (Map)JavaModelManager.Containers.get(affectedProject);
- if (perProjectContainers == null){
- perProjectContainers = new HashMap();
- JavaModelManager.Containers.put(affectedProject, perProjectContainers);
- } else {
- IClasspathContainer oldContainer = (IClasspathContainer) perProjectContainers.get(containerPath);
- if (oldContainer != null && oldContainer.equals(respectiveContainers[i])){
- affectedProjects[i] = null; // filter out this project - container did not change
- continue;
+ IClasspathContainer oldContainer = JavaModelManager.containerGet(affectedProject, containerPath);
+ if (oldContainer == JavaModelManager.ContainerInitializationInProgress) {
+ Map previousContainerValues = (Map)JavaModelManager.PreviousSessionContainers.get(affectedProject);
+ if (previousContainerValues != null){
+ IClasspathContainer previousContainer = (IClasspathContainer)previousContainerValues.get(containerPath);
+ if (previousContainer != null) {
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPContainer INIT - reentering access to project container: ["+affectedProject.getElementName()+"] " + containerPath + " during its initialization, will see previous value: "+ previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ JavaModelManager.containerPut(affectedProject, containerPath, previousContainer);
+ }
+ oldContainer = null; //33695 - cannot filter out restored container, must update affected project to reset cached CP
+ } else {
+ oldContainer = null;
}
}
- if (found){
- remaining++;
- oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
+ if (oldContainer != null && oldContainer.equals(respectiveContainers[i])){// TODO: could improve to only compare entries
+ modifiedProjects[i] = null; // filter out this project - container did not change
+ continue;
}
- perProjectContainers.put(containerPath, newContainer);
+ remaining++;
+ oldResolvedPaths[i] = affectedProject.getResolvedClasspath(true);
+ JavaModelManager.containerPut(affectedProject, containerPath, newContainer);
}
if (remaining == 0) return;
// trigger model refresh
- boolean wasFiring = manager.isFiring();
- int count = 0;
try {
- if (wasFiring)
- manager.stopDeltas();
-
- for(int i = 0; i < projectLength; i++){
+ JavaCore.run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ for(int i = 0; i < projectLength; i++){
+
+ if (monitor != null && monitor.isCanceled()) return;
+
+ JavaProject affectedProject = (JavaProject)modifiedProjects[i];
+ if (affectedProject == null) continue; // was filtered out
+
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPContainer SET - updating affected project: ["+affectedProject.getElementName()+"] due to setting container: " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
+ }
- if (monitor != null && monitor.isCanceled()) return;
-
- JavaProject affectedProject = (JavaProject)affectedProjects[i];
- if (affectedProject == null) continue; // was filtered out
-
- if (++count == remaining) { // re-enable firing for the last operation
- if (wasFiring) {
- wasFiring = false;
- manager.startDeltas();
+ // force a refresh of the affected project (will compute deltas)
+ affectedProject.setRawClasspath(
+ affectedProject.getRawClasspath(),
+ SetClasspathOperation.ReuseOutputLocation,
+ monitor,
+ !ResourcesPlugin.getWorkspace().isTreeLocked(), // can save resources
+ oldResolvedPaths[i],
+ false, // updating - no validation
+ false); // updating - no need to save
}
}
-
- // force a refresh of the affected project (will compute deltas)
- affectedProject.setRawClasspath(
- affectedProject.getRawClasspath(),
- SetClasspathOperation.ReuseOutputLocation,
- monitor,
- !JavaModelManager.IsResourceTreeLocked, // can save resources
- !JavaModelManager.IsResourceTreeLocked && affectedProject.getWorkspace().isAutoBuilding(), // force save?
- oldResolvedPaths[i],
- remaining == 1, // no individual cycle check if more than 1 project
- false); // updating - no validation
+ },
+ monitor);
+ } catch(CoreException e) {
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION: "+containerPath); //$NON-NLS-1$
+ e.printStackTrace();
}
- if (remaining > 1){
- // use workspace runnable so as to allow marker creation - workaround bug 14733
-// ResourcesPlugin.getWorkspace().run(
-// new IWorkspaceRunnable() {
-// public void run(IProgressMonitor monitor) throws CoreException {
- JavaProject.updateAllCycleMarkers(); // update them all at once
-// }
-// },
-// monitor);
+ if (e instanceof JavaModelException) {
+ throw (JavaModelException)e;
+ } else {
+ throw new JavaModelException(e);
}
} finally {
- if (wasFiring) {
- manager.startDeltas();
- // in case of exception traversing, deltas may be fired only in the next #fire() iteration
+ for (int i = 0; i < projectLength; i++) {
+ if (respectiveContainers[i] == null) {
+ JavaModelManager.containerPut(affectedProjects[i], containerPath, null); // reset init in progress marker
+ }
}
}
@@ -2246,7 +2910,7 @@
IProgressMonitor monitor)
throws JavaModelException {
- Assert.isTrue(path != null, Util.bind("classpath.nullVariablePath" )); //$NON-NLS-1$
+ if (path == null) Assert.isTrue(false, "Variable path cannot be null"); //$NON-NLS-1$
setClasspathVariables(new String[]{variableName}, new IPath[]{ path }, monitor);
}
@@ -2274,7 +2938,8 @@
IProgressMonitor monitor)
throws JavaModelException {
- Assert.isTrue(variableNames.length == paths.length, Util.bind("classpath.mismatchNamePath" )); //$NON-NLS-1$
+ if (variableNames.length != paths.length) Assert.isTrue(false, "Variable names and paths collections should have the same size"); //$NON-NLS-1$
+ //TODO: should check that null cannot be used as variable paths
updateVariableValues(variableNames, paths, monitor);
}
@@ -2312,6 +2977,7 @@
Enumeration keys = newOptions.keys();
while (keys.hasMoreElements()){
String key = (String)keys.nextElement();
+ if (!JavaModelManager.OptionNames.contains(key)) continue; // unrecognized option
if (key.equals(CORE_ENCODING)) continue; // skipped, contributed by resource prefs
String value = (String)newOptions.get(key);
preferences.setValue(key, value);
@@ -2366,12 +3032,13 @@
// retrieve variable values
JavaCore.getPlugin().getPluginPreferences().addPropertyChangeListener(new JavaModelManager.PluginPreferencesListener());
- manager.loadVariables();
+ manager.loadVariablesAndContainers();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.addResourceChangeListener(
manager.deltaProcessor,
IResourceChangeEvent.PRE_AUTO_BUILD
+ | IResourceChangeEvent.POST_AUTO_BUILD
| IResourceChangeEvent.POST_CHANGE
| IResourceChangeEvent.PRE_DELETE
| IResourceChangeEvent.PRE_CLOSE);
@@ -2394,22 +3061,36 @@
String[] variableNames,
IPath[] variablePaths,
IProgressMonitor monitor) throws JavaModelException {
-
+
if (monitor != null && monitor.isCanceled()) return;
- boolean needCycleCheck = false;
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPVariable SET - setting variables: {" + Util.toString(variableNames) //$NON-NLS-1$
+ + "} with values: " + Util.toString(variablePaths)); //$NON-NLS-1$
+ }
+
int varLength = variableNames.length;
// gather classpath information for updating
- HashMap affectedProjects = new HashMap(5);
+ final HashMap affectedProjects = new HashMap(5);
JavaModelManager manager = JavaModelManager.getJavaModelManager();
IJavaModel model = manager.getJavaModel();
-
+
// filter out unmodified variables
int discardCount = 0;
for (int i = 0; i < varLength; i++){
- IPath oldPath = (IPath)JavaModelManager.variableGet(variableNames[i]);
- if (oldPath == JavaModelManager.VariableInitializationInProgress) oldPath = null;
+ String variableName = variableNames[i];
+ IPath oldPath = (IPath)JavaModelManager.variableGet(variableName); // if reentering will provide previous session value
+ if (oldPath == JavaModelManager.VariableInitializationInProgress){
+ IPath previousPath = (IPath)JavaModelManager.PreviousSessionVariables.get(variableName);
+ if (previousPath != null){
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPVariable INIT - reentering access to variable: " + variableName+ " during its initialization, will see previous value: "+ previousPath); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ JavaModelManager.variablePut(variableName, previousPath); // replace value so reentering calls are seeing old value
+ }
+ oldPath = null; //33695 - cannot filter out restored variable, must update affected project to reset cached CP
+ }
if (oldPath != null && oldPath.equals(variablePaths[i])){
variableNames[i] = null;
discardCount++;
@@ -2445,33 +3126,19 @@
IClasspathEntry entry = classpath[j];
for (int k = 0; k < varLength; k++){
-
+
String variableName = variableNames[k];
if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE){
-
+
if (variableName.equals(entry.getPath().segment(0))){
- affectedProjects.put(project, ((JavaProject)project).getResolvedClasspath(true));
-
- // also check whether it will be necessary to update proj references and cycle markers
- if (!needCycleCheck && entry.getPath().segmentCount() == 1){
- IPath oldPath = (IPath)JavaModelManager.variableGet(variableName);
- if (oldPath == JavaModelManager.VariableInitializationInProgress) oldPath = null;
- if (oldPath != null && oldPath.segmentCount() == 1) {
- needCycleCheck = true;
- } else {
- IPath newPath = variablePaths[k];
- if (newPath != null && newPath.segmentCount() == 1) {
- needCycleCheck = true;
- }
- }
- }
+ affectedProjects.put(project, project.getResolvedClasspath(true));
continue nextProject;
}
IPath sourcePath, sourceRootPath;
if (((sourcePath = entry.getSourceAttachmentPath()) != null && variableName.equals(sourcePath.segment(0)))
|| ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null && variableName.equals(sourceRootPath.segment(0)))) {
-
- affectedProjects.put(project, ((JavaProject)project).getResolvedClasspath(true));
+
+ affectedProjects.put(project, project.getResolvedClasspath(true));
continue nextProject;
}
}
@@ -2481,58 +3148,50 @@
}
// update variables
for (int i = 0; i < varLength; i++){
- IPath path = variablePaths[i];
- JavaModelManager.variablePut(variableNames[i], path);
+ JavaModelManager.variablePut(variableNames[i], variablePaths[i]);
}
+ final String[] dbgVariableNames = variableNames;
// update affected project classpaths
- int size = affectedProjects.size();
-
if (!affectedProjects.isEmpty()) {
- boolean wasFiring = manager.isFiring();
try {
- if (wasFiring)
- manager.stopDeltas();
- // propagate classpath change
- Iterator projectsToUpdate = affectedProjects.keySet().iterator();
- while (projectsToUpdate.hasNext()) {
+ JavaCore.run(
+ new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ // propagate classpath change
+ Iterator projectsToUpdate = affectedProjects.keySet().iterator();
+ while (projectsToUpdate.hasNext()) {
+
+ if (monitor != null && monitor.isCanceled()) return;
+
+ JavaProject project = (JavaProject) projectsToUpdate.next();
- if (monitor != null && monitor.isCanceled()) return;
-
- JavaProject project = (JavaProject) projectsToUpdate.next();
-
- if (!projectsToUpdate.hasNext()) {
- // re-enable firing for the last operation
- if (wasFiring) {
- wasFiring = false;
- manager.startDeltas();
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPVariable SET - updating affected project: ["+project.getElementName()+"] due to setting variables: "+ Util.toString(dbgVariableNames)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ project
+ .setRawClasspath(
+ project.getRawClasspath(),
+ SetClasspathOperation.ReuseOutputLocation,
+ null, // don't call beginTask on the monitor (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=3717)
+ !ResourcesPlugin.getWorkspace().isTreeLocked(), // can change resources
+ (IClasspathEntry[]) affectedProjects.get(project),
+ false, // updating - no validation
+ false); // updating - no need to save
+ }
}
- }
- project
- .setRawClasspath(
- project.getRawClasspath(),
- SetClasspathOperation.ReuseOutputLocation,
- monitor,
- !JavaModelManager.IsResourceTreeLocked, // can change resources
- !JavaModelManager.IsResourceTreeLocked && project.getWorkspace().isAutoBuilding(),// force build if in auto build mode
- (IClasspathEntry[]) affectedProjects.get(project),
- size == 1 && needCycleCheck, // no individual check if more than 1 project to update
- false); // updating - no validation
+ },
+ monitor);
+ } catch (CoreException e) {
+ if (JavaModelManager.CP_RESOLVE_VERBOSE){
+ System.out.println("CPVariable SET - FAILED DUE TO EXCEPTION: "+Util.toString(dbgVariableNames)); //$NON-NLS-1$
+ e.printStackTrace();
}
- if (size > 1 && needCycleCheck){
- // use workspace runnable for protecting marker manipulation
-// ResourcesPlugin.getWorkspace().run(
-// new IWorkspaceRunnable() {
-// public void run(IProgressMonitor monitor) throws CoreException {
- JavaProject.updateAllCycleMarkers(); // update them all at once
-// }
-// },
-// monitor);
- }
- } finally {
- if (wasFiring) {
- manager.startDeltas();
- // in case of exception traversing, deltas may be fired only in the next #fire() iteration
+ if (e instanceof JavaModelException) {
+ throw (JavaModelException)e;
+ } else {
+ throw new JavaModelException(e);
}
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaModelException.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaModelException.java
index 937184f..7163262 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaModelException.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaModelException.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import org.eclipse.core.runtime.CoreException;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/NamingConventions.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/NamingConventions.java
new file mode 100644
index 0000000..2909ce5
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/NamingConventions.java
@@ -0,0 +1,850 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core;
+
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.codeassist.impl.AssistOptions;
+import org.eclipse.jdt.internal.core.INamingRequestor;
+import org.eclipse.jdt.internal.core.InternalNamingConventions;
+
+
+/**
+ * Provides methods for computing Java-specific names.
+ * <p>
+ * The bevavior of the methods is dependent of several JavaCore options.<br>
+ * The possible options are :
+ * <ul>
+ * <li>CODEASSIST_FIELD_PREFIXES : Define the Prefixes for Field Name.</li>
+ * <li>CODEASSIST_STATIC_FIELD_PREFIXES : Define the Prefixes for Static Field Name.</li>
+ * <li>CODEASSIST_LOCAL_PREFIXES : Define the Prefixes for Local Variable Name.</li>
+ * <li>CODEASSIST_ARGUMENT_PREFIXES : Define the Prefixes for Argument Name.</li>
+ * <li>CODEASSIST_FIELD_SUFFIXES : Define the Suffixes for Field Name.</li>
+ * <li>CODEASSIST_STATIC_FIELD_SUFFIXES : Define the Suffixes for Static Field Name.</li>
+ * <li>CODEASSIST_LOCAL_SUFFIXES : Define the Suffixes for Local Variable Name.</li>
+ * <li>CODEASSIST_ARGUMENT_SUFFIXES : Define the Suffixes for Argument Name.</li>
+ * </ul>
+ * <p>
+ *
+ * For a complete description of the configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ *
+ * This class provides static methods and constants only; it is not intended to be
+ * instantiated or subclassed by clients.
+ * </p>
+ *
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ * @since 2.1
+ */
+public final class NamingConventions {
+ private static final char[] GETTER_BOOL_NAME = "is".toCharArray(); //$NON-NLS-1$
+ private static final char[] GETTER_NAME = "get".toCharArray(); //$NON-NLS-1$
+ private static final char[] SETTER_NAME = "set".toCharArray(); //$NON-NLS-1$
+
+ private static class NamingRequestor implements INamingRequestor {
+ private final static int SIZE = 10;
+
+ // for acceptNameWithPrefixAndSuffix
+ private char[][] firstPrefixAndFirstSuffixResults = new char[SIZE][];
+ private int firstPrefixAndFirstSuffixResultsCount = 0;
+ private char[][] firstPrefixAndSuffixResults = new char[SIZE][];
+ private int firstPrefixAndSuffixResultsCount = 0;
+ private char[][] prefixAndFirstSuffixResults = new char[SIZE][];
+ private int prefixAndFirstSuffixResultsCount = 0;
+ private char[][] prefixAndSuffixResults = new char[SIZE][];
+ private int prefixAndSuffixResultsCount = 0;
+
+ // for acceptNameWithPrefix
+ private char[][] firstPrefixResults = new char[SIZE][];
+ private int firstPrefixResultsCount = 0;
+ private char[][] prefixResults = new char[SIZE][];
+ private int prefixResultsCount = 0;
+
+ // for acceptNameWithSuffix
+ private char[][] firstSuffixResults = new char[SIZE][];
+ private int firstSuffixResultsCount = 0;
+ private char[][] suffixResults = new char[SIZE][];
+ private int suffixResultsCount = 0;
+
+ // for acceptNameWithoutPrefixAndSuffix
+ private char[][] otherResults = new char[SIZE][];
+ private int otherResultsCount = 0;
+ public void acceptNameWithPrefixAndSuffix(char[] name, boolean isFirstPrefix, boolean isFirstSuffix) {
+ if(isFirstPrefix && isFirstSuffix) {
+ int length = firstPrefixAndFirstSuffixResults.length;
+ if(length == firstPrefixAndFirstSuffixResultsCount) {
+ System.arraycopy(
+ firstPrefixAndFirstSuffixResults,
+ 0,
+ firstPrefixAndFirstSuffixResults = new char[length * 2][],
+ 0,
+ length);
+ }
+ firstPrefixAndFirstSuffixResults[firstPrefixAndFirstSuffixResultsCount++] = name;
+ } else if (isFirstPrefix) {
+ int length = firstPrefixAndSuffixResults.length;
+ if(length == firstPrefixAndSuffixResultsCount) {
+ System.arraycopy(
+ firstPrefixAndSuffixResults,
+ 0,
+ firstPrefixAndSuffixResults = new char[length * 2][],
+ 0,
+ length);
+ }
+ firstPrefixAndSuffixResults[firstPrefixAndSuffixResultsCount++] = name;
+ } else if(isFirstSuffix) {
+ int length = prefixAndFirstSuffixResults.length;
+ if(length == prefixAndFirstSuffixResultsCount) {
+ System.arraycopy(
+ prefixAndFirstSuffixResults,
+ 0,
+ prefixAndFirstSuffixResults = new char[length * 2][],
+ 0,
+ length);
+ }
+ prefixAndFirstSuffixResults[prefixAndFirstSuffixResultsCount++] = name;
+ } else {
+ int length = prefixAndSuffixResults.length;
+ if(length == prefixAndSuffixResultsCount) {
+ System.arraycopy(
+ prefixAndSuffixResults,
+ 0,
+ prefixAndSuffixResults = new char[length * 2][],
+ 0,
+ length);
+ }
+ prefixAndSuffixResults[prefixAndSuffixResultsCount++] = name;
+ }
+ }
+
+ public void acceptNameWithPrefix(char[] name, boolean isFirstPrefix) {
+ if(isFirstPrefix) {
+ int length = firstPrefixResults.length;
+ if(length == firstPrefixResultsCount) {
+ System.arraycopy(
+ firstPrefixResults,
+ 0,
+ firstPrefixResults = new char[length * 2][],
+ 0,
+ length);
+ }
+ firstPrefixResults[firstPrefixResultsCount++] = name;
+ } else{
+ int length = prefixResults.length;
+ if(length == prefixResultsCount) {
+ System.arraycopy(
+ prefixResults,
+ 0,
+ prefixResults = new char[length * 2][],
+ 0,
+ length);
+ }
+ prefixResults[prefixResultsCount++] = name;
+ }
+ }
+
+ public void acceptNameWithSuffix(char[] name, boolean isFirstSuffix) {
+ if(isFirstSuffix) {
+ int length = firstSuffixResults.length;
+ if(length == firstSuffixResultsCount) {
+ System.arraycopy(
+ firstSuffixResults,
+ 0,
+ firstSuffixResults = new char[length * 2][],
+ 0,
+ length);
+ }
+ firstSuffixResults[firstSuffixResultsCount++] = name;
+ } else {
+ int length = suffixResults.length;
+ if(length == suffixResultsCount) {
+ System.arraycopy(
+ suffixResults,
+ 0,
+ suffixResults = new char[length * 2][],
+ 0,
+ length);
+ }
+ suffixResults[suffixResultsCount++] = name;
+ }
+ }
+
+ public void acceptNameWithoutPrefixAndSuffix(char[] name) {
+ int length = otherResults.length;
+ if(length == otherResultsCount) {
+ System.arraycopy(
+ otherResults,
+ 0,
+ otherResults = new char[length * 2][],
+ 0,
+ length);
+ }
+ otherResults[otherResultsCount++] = name;
+ }
+ public char[][] getResults(){
+ int count =
+ firstPrefixAndFirstSuffixResultsCount
+ + firstPrefixAndSuffixResultsCount
+ + prefixAndFirstSuffixResultsCount
+ + prefixAndSuffixResultsCount
+ + firstPrefixResultsCount
+ + prefixResultsCount
+ + firstSuffixResultsCount
+ + suffixResultsCount
+ + otherResultsCount;
+
+ char[][] results = new char[count][];
+
+ int index = 0;
+ System.arraycopy(firstPrefixAndFirstSuffixResults, 0, results, index, firstPrefixAndFirstSuffixResultsCount);
+ index += firstPrefixAndFirstSuffixResultsCount;
+ System.arraycopy(firstPrefixAndSuffixResults, 0, results, index, firstPrefixAndSuffixResultsCount);
+ index += firstPrefixAndSuffixResultsCount;
+ System.arraycopy(prefixAndFirstSuffixResults, 0, results, index, prefixAndFirstSuffixResultsCount);
+ index += prefixAndFirstSuffixResultsCount;
+ System.arraycopy(prefixAndSuffixResults, 0, results, index, prefixAndSuffixResultsCount);
+ index += prefixAndSuffixResultsCount;
+ System.arraycopy(firstPrefixResults, 0, results, index, firstPrefixResultsCount);
+ index += firstPrefixResultsCount;
+ System.arraycopy(prefixResults, 0, results, index, prefixResultsCount);
+ index += prefixResultsCount;
+ System.arraycopy(firstSuffixResults, 0, results, index, firstSuffixResultsCount);
+ index += firstSuffixResultsCount;
+ System.arraycopy(suffixResults, 0, results, index, suffixResultsCount);
+ index += suffixResultsCount;
+ System.arraycopy(otherResults, 0, results, index, otherResultsCount);
+
+ return results;
+ }
+ }
+
+
+ /**
+ * Not instantiable.
+ */
+ private NamingConventions() {}
+
+ private static char[] removePrefixAndSuffix(char[] name, char[][] prefixes, char[][] suffixes) {
+ // remove longer prefix
+ char[] withoutPrefixName = name;
+ if (prefixes != null) {
+ int bestLength = 0;
+ for (int i= 0; i < prefixes.length; i++) {
+ char[] prefix = prefixes[i];
+ if (CharOperation.prefixEquals(prefix, name)) {
+ int currLen = prefix.length;
+ boolean lastCharIsLetter = Character.isLetter(prefix[currLen - 1]);
+ if(!lastCharIsLetter || (lastCharIsLetter && name.length > currLen && Character.isUpperCase(name[currLen]))) {
+ if (bestLength < currLen && name.length != currLen) {
+ withoutPrefixName = CharOperation.subarray(name, currLen, name.length);
+ bestLength = currLen;
+ }
+ }
+ }
+ }
+ }
+
+ // remove longer suffix
+ char[] withoutSuffixName = withoutPrefixName;
+ if(suffixes != null) {
+ int bestLength = 0;
+ for (int i = 0; i < suffixes.length; i++) {
+ char[] suffix = suffixes[i];
+ if(CharOperation.endsWith(withoutPrefixName, suffix)) {
+ int currLen = suffix.length;
+ if(bestLength < currLen && withoutPrefixName.length != currLen) {
+ withoutSuffixName = CharOperation.subarray(withoutPrefixName, 0, withoutPrefixName.length - currLen);
+ bestLength = currLen;
+ }
+ }
+ }
+ }
+
+ withoutSuffixName[0] = Character.toLowerCase(withoutSuffixName[0]);
+ return withoutSuffixName;
+ }
+
+ /**
+ * Remove prefix and suffix from an argument name.<br>
+ * If argument name prefix is <code>pre</code> and argument name suffix is <code>suf</code>
+ * then for an argument named <code>preArgsuf</code> the result of this method is <code>arg</code>.
+ * If there is no prefix or suffix defined in JavaCore options the result is the unchanged
+ * name <code>preArgsuf</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_ARGUMENT_PREFIXES and
+ * CODEASSIST_ARGUMENT_SUFFIXES.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ *
+ * @param javaProject project which contains the argument.
+ * @param argumentName argument's name.
+ * @return char[] the name without prefix and suffix.
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static char[] removePrefixAndSuffixForArgumentName(IJavaProject javaProject, char[] argumentName) {
+ AssistOptions assistOptions = new AssistOptions(javaProject.getOptions(true));
+ return removePrefixAndSuffix(
+ argumentName,
+ assistOptions.argumentPrefixes,
+ assistOptions.argumentSuffixes);
+ }
+
+ /**
+ * Remove prefix and suffix from an argument name.<br>
+ * If argument name prefix is <code>pre</code> and argument name suffix is <code>suf</code>
+ * then for an argument named <code>preArgsuf</code> the result of this method is <code>arg</code>.
+ * If there is no prefix or suffix defined in JavaCore options the result is the unchanged
+ * name <code>preArgsuf</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_ARGUMENT_PREFIXES and
+ * CODEASSIST_ARGUMENT_SUFFIXES.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ *
+ * @param javaProject project which contains the argument.
+ * @param argumentName argument's name.
+ * @return char[] the name without prefix and suffix.
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static String removePrefixAndSuffixForArgumentName(IJavaProject javaProject, String argumentName) {
+ return String.valueOf(removePrefixAndSuffixForArgumentName(javaProject, argumentName.toCharArray()));
+ }
+
+ /**
+ * Remove prefix and suffix from a field name.<br>
+ * If field name prefix is <code>pre</code> and field name suffix is <code>suf</code>
+ * then for a field named <code>preFieldsuf</code> the result of this method is <code>field</code>.
+ * If there is no prefix or suffix defined in JavaCore options the result is the unchanged
+ * name <code>preFieldsuf</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_FIELD_PREFIXES,
+ * CODEASSIST_FIELD_SUFFIXES for instance field and CODEASSIST_STATIC_FIELD_PREFIXES,
+ * CODEASSIST_STATIC_FIELD_SUFFIXES for static field.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ *
+ * @param javaProject project which contains the field.
+ * @param fieldName field's name.
+ * @param modifiers field's modifiers as defined by the class
+ * <code>Flags</code>.
+ * @return char[] the name without prefix and suffix.
+ * @see Flags
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static char[] removePrefixAndSuffixForFieldName(IJavaProject javaProject, char[] fieldName, int modifiers) {
+ boolean isStatic = Flags.isStatic(modifiers);
+ AssistOptions assistOptions = new AssistOptions(javaProject.getOptions(true));
+ return removePrefixAndSuffix(
+ fieldName,
+ isStatic ? assistOptions.staticFieldPrefixes : assistOptions.fieldPrefixes,
+ isStatic ? assistOptions.staticFieldSuffixes : assistOptions.fieldSuffixes);
+ }
+
+ /**
+ * Remove prefix and suffix from a field name.<br>
+ * If field name prefix is <code>pre</code> and field name suffix is <code>suf</code>
+ * then for a field named <code>preFieldsuf</code> the result of this method is <code>field</code>.
+ * If there is no prefix or suffix defined in JavaCore options the result is the unchanged
+ * name <code>preFieldsuf</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_FIELD_PREFIXES,
+ * CODEASSIST_FIELD_SUFFIXES for instance field and CODEASSIST_STATIC_FIELD_PREFIXES,
+ * CODEASSIST_STATIC_FIELD_SUFFIXES for static field.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ *
+ * @param javaProject project which contains the field.
+ * @param fieldName field's name.
+ * @param modifiers field's modifiers as defined by the class
+ * <code>Flags</code>.
+ * @return char[] the name without prefix and suffix.
+ * @see Flags
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static String removePrefixAndSuffixForFieldName(IJavaProject javaProject, String fieldName, int modifiers) {
+ return String.valueOf(removePrefixAndSuffixForFieldName(javaProject, fieldName.toCharArray(), modifiers));
+ }
+ /**
+ * Remove prefix and suffix from a local variable name.<br>
+ * If local variable name prefix is <code>pre</code> and local variable name suffix is <code>suf</code>
+ * then for a local variable named <code>preLocalsuf</code> the result of this method is <code>local</code>.
+ * If there is no prefix or suffix defined in JavaCore options the result is the unchanged
+ * name <code>preLocalsuf</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_LOCAL_PREFIXES and
+ * CODEASSIST_LOCAL_SUFFIXES.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ *
+ * @param javaProject project which contains the variable.
+ * @param localName variable's name.
+ * @return char[] the name without prefix and suffix.
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static char[] removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, char[] localName) {
+ AssistOptions assistOptions = new AssistOptions(javaProject.getOptions(true));
+ return removePrefixAndSuffix(
+ localName,
+ assistOptions.argumentPrefixes,
+ assistOptions.argumentSuffixes);
+ }
+
+ /**
+ * Remove prefix and suffix from a local variable name.<br>
+ * If local variable name prefix is <code>pre</code> and local variable name suffix is <code>suf</code>
+ * then for a local variable named <code>preLocalsuf</code> the result of this method is <code>local</code>.
+ * If there is no prefix or suffix defined in JavaCore options the result is the unchanged
+ * name <code>preLocalsuf</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_LOCAL_PREFIXES and
+ * CODEASSIST_LOCAL_SUFFIXES.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ *
+ * @param javaProject project which contains the variable.
+ * @param localName variable's name.
+ * @return char[] the name without prefix and suffix.
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static String removePrefixAndSuffixForLocalVariableName(IJavaProject javaProject, String localName) {
+ return String.valueOf(removePrefixAndSuffixForLocalVariableName(javaProject, localName.toCharArray()));
+ }
+
+ /**
+ * Suggest names for an argument. The name is computed from argument's type
+ * and possible prefixes or suffixes are added.<br>
+ * If the type of the argument is <code>TypeName</code>, the prefix for argument is <code>pre</code>
+ * and the suffix for argument is <code>suf</code> then the proposed names are <code>preTypeNamesuf</code>
+ * and <code>preNamesuf</code>. If there is no prefix or suffix the proposals are <code>typeName</code>
+ * and <code>name</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_ARGUMENT_PREFIXES and
+ * CODEASSIST_ARGUMENT_SUFFIXES.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ *
+ * @param javaProject project which contains the argument.
+ * @param packageName package of the argument's type.
+ * @param qualifiedTypeName argument's type.
+ * @param dim argument's dimension (0 if the argument is not an array).
+ * @param excludedNames a list of names which cannot be suggested (already used names).
+ * Can be <code>null</code> if there is no excluded names.
+ * @return char[][] an array of names.
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static char[][] suggestArgumentNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames) {
+ NamingRequestor requestor = new NamingRequestor();
+ InternalNamingConventions.suggestArgumentNames(
+ javaProject,
+ packageName,
+ qualifiedTypeName,
+ dim,
+ excludedNames,
+ requestor);
+
+ return requestor.getResults();
+ }
+
+ /**
+ * Suggest names for an argument. The name is computed from argument's type
+ * and possible prefixes or suffixes are added.<br>
+ * If the type of the argument is <code>TypeName</code>, the prefix for argument is <code>pre</code>
+ * and the suffix for argument is <code>suf</code> then the proposed names are <code>preTypeNamesuf</code>
+ * and <code>preNamesuf</code>. If there is no prefix or suffix the proposals are <code>typeName</code>
+ * and <code>name</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_ARGUMENT_PREFIXES and
+ * CODEASSIST_ARGUMENT_SUFFIXES.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ *
+ * @param javaProject project which contains the argument.
+ * @param packageName package of the argument's type.
+ * @param qualifiedTypeName argument's type.
+ * @param dim argument's dimension (0 if the argument is not an array).
+ * @param excludedNames a list of names which cannot be suggested (already used names).
+ * Can be <code>null</code> if there is no excluded names.
+ * @return char[][] an array of names.
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static String[] suggestArgumentNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames) {
+ return convertCharsToString(
+ suggestArgumentNames(
+ javaProject,
+ packageName.toCharArray(),
+ qualifiedTypeName.toCharArray(),
+ dim,
+ convertStringToChars(excludedNames)));
+ }
+ /**
+ * Suggest names for a field. The name is computed from field's type
+ * and possible prefixes or suffixes are added.<br>
+ * If the type of the field is <code>TypeName</code>, the prefix for field is <code>pre</code>
+ * and the suffix for field is <code>suf</code> then the proposed names are <code>preTypeNamesuf</code>
+ * and <code>preNamesuf</code>. If there is no prefix or suffix the proposals are <code>typeName</code>
+ * and <code>name</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_FIELD_PREFIXES,
+ * CODEASSIST_FIELD_SUFFIXES and for instance field and CODEASSIST_STATIC_FIELD_PREFIXES,
+ * CODEASSIST_STATIC_FIELD_SUFFIXES for static field.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ * @param javaProject project which contains the field.
+ * @param packageName package of the field's type.
+ * @param qualifiedTypeName field's type.
+ * @param dim field's dimension (0 if the field is not an array).
+ * @param modifiers field's modifiers as defined by the class
+ * <code>Flags</code>.
+ * @param excludedNames a list of names which cannot be suggested (already used names).
+ * Can be <code>null</code> if there is no excluded names.
+ * @return char[][] an array of names.
+ * @see Flags
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static char[][] suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames) {
+ NamingRequestor requestor = new NamingRequestor();
+ InternalNamingConventions.suggestFieldNames(
+ javaProject,
+ packageName,
+ qualifiedTypeName,
+ dim,
+ modifiers,
+ excludedNames,
+ requestor);
+
+ return requestor.getResults();
+ }
+
+ /**
+ * Suggest names for a field. The name is computed from field's type
+ * and possible prefixes or suffixes are added.<br>
+ * If the type of the field is <code>TypeName</code>, the prefix for field is <code>pre</code>
+ * and the suffix for field is <code>suf</code> then the proposed names are <code>preTypeNamesuf</code>
+ * and <code>preNamesuf</code>. If there is no prefix or suffix the proposals are <code>typeName</code>
+ * and <code>name</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_FIELD_PREFIXES,
+ * CODEASSIST_FIELD_SUFFIXES and for instance field and CODEASSIST_STATIC_FIELD_PREFIXES,
+ * CODEASSIST_STATIC_FIELD_SUFFIXES for static field.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ * @param javaProject project which contains the field.
+ * @param packageName package of the field's type.
+ * @param qualifiedTypeName field's type.
+ * @param dim field's dimension (0 if the field is not an array).
+ * @param modifiers field's modifiers as defined by the class
+ * <code>Flags</code>.
+ * @param excludedNames a list of names which cannot be suggested (already used names).
+ * Can be <code>null</code> if there is no excluded names.
+ * @return char[][] an array of names.
+ * @see Flags
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static String[] suggestFieldNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, int modifiers, String[] excludedNames) {
+ return convertCharsToString(
+ suggestFieldNames(
+ javaProject,
+ packageName.toCharArray(),
+ qualifiedTypeName.toCharArray(),
+ dim,
+ modifiers,
+ convertStringToChars(excludedNames)));
+ }
+
+ /**
+ * Suggest names for a local variable. The name is computed from variable's type
+ * and possible prefixes or suffixes are added.<br>
+ * If the type of the local variable is <code>TypeName</code>, the prefix for local variable is <code>pre</code>
+ * and the suffix for local variable is <code>suf</code> then the proposed names are <code>preTypeNamesuf</code>
+ * and <code>preNamesuf</code>. If there is no prefix or suffix the proposals are <code>typeName</code>
+ * and <code>name</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_LOCAL_PREFIXES and
+ * CODEASSIST_LOCAL_SUFFIXES.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ * @param javaProject project which contains the variable.
+ * @param packageName package of the variable's type.
+ * @param qualifiedTypeName variable's type.
+ * @param dim variable's dimension (0 if the variable is not an array).
+ * @param excludedNames a list of names which cannot be suggested (already used names).
+ * Can be <code>null</code> if there is no excluded names.
+ * @return char[][] an array of names.
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static char[][] suggestLocalVariableNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames) {
+ NamingRequestor requestor = new NamingRequestor();
+ InternalNamingConventions.suggestLocalVariableNames(
+ javaProject,
+ packageName,
+ qualifiedTypeName,
+ dim,
+ excludedNames,
+ requestor);
+
+ return requestor.getResults();
+ }
+
+ /**
+ * Suggest names for a local variable. The name is computed from variable's type
+ * and possible prefixes or suffixes are added.<br>
+ * If the type of the local variable is <code>TypeName</code>, the prefix for local variable is <code>pre</code>
+ * and the suffix for local variable is <code>suf</code> then the proposed names are <code>preTypeNamesuf</code>
+ * and <code>preNamesuf</code>. If there is no prefix or suffix the proposals are <code>typeName</code>
+ * and <code>name</code>.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_LOCAL_PREFIXES and
+ * CODEASSIST_LOCAL_SUFFIXES.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ * @param javaProject project which contains the variable.
+ * @param packageName package of the variable's type.
+ * @param qualifiedTypeName variable's type.
+ * @param dim variable's dimension (0 if the variable is not an array).
+ * @param excludedNames a list of names which cannot be suggested (already used names).
+ * Can be <code>null</code> if there is no excluded names.
+ * @return char[][] an array of names.
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static String[] suggestLocalVariableNames(IJavaProject javaProject, String packageName, String qualifiedTypeName, int dim, String[] excludedNames) {
+ return convertCharsToString(
+ suggestLocalVariableNames(
+ javaProject,
+ packageName.toCharArray(),
+ qualifiedTypeName.toCharArray(),
+ dim,
+ convertStringToChars(excludedNames)));
+ }
+
+ /**
+ * Suggest name for a getter method. The name is computed from field's name
+ * and possible prefixes or suffixes are removed.<br>
+ * If the field name is <code>preFieldNamesuf</code> and the prefix for field is <code>pre</code> and
+ * the suffix for field is <code>suf</code> then the prosposed name is <code>isFieldName</code> for boolean field or
+ * <code>getFieldName</code> for others. If there is no prefix and suffix the proposal is <code>isPreFieldNamesuf</code>
+ * for boolean field or <code>getPreFieldNamesuf</code> for others.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_FIELD_PREFIXES,
+ * CODEASSIST_FIELD_SUFFIXES for instance field and CODEASSIST_STATIC_FIELD_PREFIXES,
+ * CODEASSIST_STATIC_FIELD_SUFFIXES for static field.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ * @param project project which contains the field.
+ * @param fieldName field's name's.
+ * @param modifiers field's modifiers as defined by the class
+ * <code>Flags</code>.
+ * @param isBoolean <code>true</code> if the field's type is boolean
+ * @param excludedNames a list of names which cannot be suggested (already used names).
+ * Can be <code>null</code> if there is no excluded names.
+ * @return char[] a name.
+ * @see Flags
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static char[] suggestGetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames) {
+ if (isBoolean) {
+ char[] name = removePrefixAndSuffixForFieldName(project, fieldName, modifiers);
+ int prefixLen = GETTER_BOOL_NAME.length;
+ if (CharOperation.prefixEquals(GETTER_BOOL_NAME, name)
+ && name.length > prefixLen && Character.isUpperCase(name[prefixLen])) {
+ return suggestNewName(name, excludedNames);
+ } else {
+ return suggestNewName(
+ CharOperation.concat(GETTER_BOOL_NAME, suggestAccessorName(project, fieldName, modifiers)),
+ excludedNames
+ );
+ }
+ } else {
+ return suggestNewName(
+ CharOperation.concat(GETTER_NAME, suggestAccessorName(project, fieldName, modifiers)),
+ excludedNames
+ );
+ }
+ }
+
+ /**
+ * Suggest name for a getter method. The name is computed from field's name
+ * and possible prefixes or suffixes are removed.<br>
+ * If the field name is <code>preFieldNamesuf</code> and the prefix for field is <code>pre</code> and
+ * the suffix for field is <code>suf</code> then the prosposed name is <code>isFieldName</code> for boolean field or
+ * <code>getFieldName</code> for others. If there is no prefix and suffix the proposal is <code>isPreFieldNamesuf</code>
+ * for boolean field or <code>getPreFieldNamesuf</code> for others.<br>
+ *
+ * This method is affected by the following JavaCore options : CODEASSIST_FIELD_PREFIXES,
+ * CODEASSIST_FIELD_SUFFIXES for instance field and CODEASSIST_STATIC_FIELD_PREFIXES,
+ * CODEASSIST_STATIC_FIELD_SUFFIXES for static field.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ * @param project project which contains the field.
+ * @param fieldName field's name's.
+ * @param modifiers field's modifiers as defined by the class
+ * <code>Flags</code>.
+ * @param isBoolean <code>true</code> if the field's type is boolean
+ * @param excludedNames a list of names which cannot be suggested (already used names).
+ * Can be <code>null</code> if there is no excluded names.
+ * @return char[] a name.
+ * @see Flags
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static String suggestGetterName(IJavaProject project, String fieldName, int modifiers, boolean isBoolean, String[] excludedNames) {
+ return String.valueOf(
+ suggestGetterName(
+ project,
+ fieldName.toCharArray(),
+ modifiers,
+ isBoolean,
+ convertStringToChars(excludedNames)));
+ }
+
+ /**
+ * Suggest name for a setter method. The name is computed from field's name
+ * and possible prefixes or suffixes are removed.<br>
+ * If the field name is <code>preFieldNamesuf</code> and the prefix for field is <code>pre</code> and
+ * the suffix for field is <code>suf</code> then the prosposed name is <code>setFieldName</code>.
+ * If there is no prefix and suffix the proposal is <code>setPreFieldNamesuf</code>.<br>
+ * This method is affected by the following JavaCore options : CODEASSIST_FIELD_PREFIXES,
+ * CODEASSIST_FIELD_SUFFIXES for instance field and CODEASSIST_STATIC_FIELD_PREFIXES,
+ * CODEASSIST_STATIC_FIELD_SUFFIXES for static field.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ * @param project project which contains the field.
+ * @param fieldName field's name's.
+ * @param modifiers field's modifiers as defined by the class
+ * <code>Flags</code>.
+ * @param isBoolean <code>true</code> if the field's type is boolean
+ * @param excludedNames a list of names which cannot be suggested (already used names).
+ * Can be <code>null</code> if there is no excluded names.
+ * @return char[] a name.
+ * @see Flags
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static char[] suggestSetterName(IJavaProject project, char[] fieldName, int modifiers, boolean isBoolean, char[][] excludedNames) {
+
+ if (isBoolean) {
+ char[] name = removePrefixAndSuffixForFieldName(project, fieldName, modifiers);
+ int prefixLen = GETTER_BOOL_NAME.length;
+ if (CharOperation.prefixEquals(GETTER_BOOL_NAME, name)
+ && name.length > prefixLen && Character.isUpperCase(name[prefixLen])) {
+ name = CharOperation.subarray(name, prefixLen, name.length);
+ return suggestNewName(
+ CharOperation.concat(SETTER_NAME, suggestAccessorName(project, name, modifiers)),
+ excludedNames
+ );
+ } else {
+ return suggestNewName(
+ CharOperation.concat(SETTER_NAME, suggestAccessorName(project, fieldName, modifiers)),
+ excludedNames
+ );
+ }
+ } else {
+ return suggestNewName(
+ CharOperation.concat(SETTER_NAME, suggestAccessorName(project, fieldName, modifiers)),
+ excludedNames
+ );
+ }
+ }
+
+ /**
+ * Suggest name for a setter method. The name is computed from field's name
+ * and possible prefixes or suffixes are removed.<br>
+ * If the field name is <code>preFieldNamesuf</code> and the prefix for field is <code>pre</code> and
+ * the suffix for field is <code>suf</code> then the prosposed name is <code>setFieldName</code>.
+ * If there is no prefix and suffix the proposal is <code>setPreFieldNamesuf</code>.<br>
+ * This method is affected by the following JavaCore options : CODEASSIST_FIELD_PREFIXES,
+ * CODEASSIST_FIELD_SUFFIXES for instance field and CODEASSIST_STATIC_FIELD_PREFIXES,
+ * CODEASSIST_STATIC_FIELD_SUFFIXES for static field.<br>
+ * For a complete description of these configurable options, see <code>getDefaultOptions</code>.
+ * For programmaticaly change these options, see <code>JavaCore#setOptions()</code>.
+ * @param project project which contains the field.
+ * @param fieldName field's name's.
+ * @param modifiers field's modifiers as defined by the class
+ * <code>Flags</code>.
+ * @param isBoolean <code>true</code> if the field's type is boolean
+ * @param excludedNames a list of names which cannot be suggested (already used names).
+ * Can be <code>null</code> if there is no excluded names.
+ * @return char[] a name.
+ * @see Flags
+ * @see JavaCore#setOptions
+ * @see JavaCore#getDefaultOptions
+ */
+ public static String suggestSetterName(IJavaProject project, String fieldName, int modifiers, boolean isBoolean, String[] excludedNames) {
+ return String.valueOf(
+ suggestSetterName(
+ project,
+ fieldName.toCharArray(),
+ modifiers,
+ isBoolean,
+ convertStringToChars(excludedNames)));
+ }
+
+ private static char[] suggestAccessorName(IJavaProject project, char[] fieldName, int modifiers) {
+ char[] name = removePrefixAndSuffixForFieldName(project, fieldName, modifiers);
+ if (name.length > 0 && Character.isLowerCase(name[0])) {
+ name[0] = Character.toUpperCase(name[0]);
+ }
+ return name;
+ }
+
+ private static char[] suggestNewName(char[] name, char[][] excludedNames){
+ if(excludedNames == null) {
+ return name;
+ }
+
+ char[] newName = name;
+ int count = 2;
+ int i = 0;
+ while (i < excludedNames.length) {
+ if(CharOperation.equals(newName, excludedNames[i], false)) {
+ newName = CharOperation.concat(name, String.valueOf(count++).toCharArray());
+ i = 0;
+ } else {
+ i++;
+ }
+ }
+ return newName;
+ }
+
+ private static String[] convertCharsToString(char[][] c) {
+ int length = c == null ? 0 : c.length;
+ String[] s = new String[length];
+ for (int i = 0; i < length; i++) {
+ s[i] = String.valueOf(c[i]);
+ }
+ return s;
+ }
+
+ private static char[][] convertStringToChars(String[] s) {
+ int length = s == null ? 0 : s.length;
+ char[][] c = new char[length][];
+ for (int i = 0; i < length; i++) {
+ if(s[i] == null) {
+ c[i] = CharOperation.NO_CHAR;
+ } else {
+ c[i] = s[i].toCharArray();
+ }
+ }
+ return c;
+ }
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
index 601c62c..8384752 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
@@ -1,20 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
-import org.eclipse.jdt.core.compiler.InvalidInputException;
-import org.eclipse.jdt.internal.compiler.parser.Scanner;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-
+import org.eclipse.jdt.core.compiler.*;
/**
* Provides methods for encoding and decoding type and method signature strings.
* <p>
@@ -228,8 +224,6 @@
*/
public static final String SIG_VOID = "V"; //$NON-NLS-1$
- private static final char[] NO_CHAR = new char[0];
- private static final char[][] NO_CHAR_CHAR = new char[0][];
private static final char[] BOOLEAN = {'b', 'o', 'o', 'l', 'e', 'a', 'n'};
private static final char[] BYTE = {'b', 'y', 't', 'e'};
private static final char[] CHAR = {'c', 'h', 'a', 'r'};
@@ -240,6 +234,7 @@
private static final char[] SHORT = {'s', 'h', 'o', 'r', 't'};
private static final char[] VOID = {'v', 'o', 'i', 'd'};
+ private static final String EMPTY = new String(CharOperation.NO_CHAR);
/**
* Not instantiable.
@@ -436,90 +431,132 @@
* @since 2.0
*/
public static char[] createCharArrayTypeSignature(char[] typeName, boolean isResolved) {
- try {
- Scanner scanner = new Scanner();
- scanner.setSource(typeName);
- int token = scanner.getNextToken();
- boolean primitive = true;
- char primitiveSig = ' ';
- StringBuffer sig = null;
- int arrayCount = 0;
- switch (token) {
- case ITerminalSymbols.TokenNameIdentifier :
- char[] idSource = scanner.getCurrentIdentifierSource();
- sig = new StringBuffer(idSource.length);
- sig.append(idSource);
- primitive = false;
+
+ if (typeName == null) throw new IllegalArgumentException("null"); //$NON-NLS-1$
+ int length = typeName.length;
+ if (length == 0) throw new IllegalArgumentException(new String(typeName));
+
+ int arrayCount = CharOperation.occurencesOf('[', typeName);
+ char[] sig;
+
+ switch (typeName[0]) {
+ // primitive type?
+ case 'b' :
+ if (CharOperation.fragmentEquals(BOOLEAN, typeName, 0, true)) {
+ sig = new char[arrayCount+1];
+ sig[arrayCount] = C_BOOLEAN;
break;
- case ITerminalSymbols.TokenNameboolean :
- primitiveSig = Signature.C_BOOLEAN;
+ } else if (CharOperation.fragmentEquals(BYTE, typeName, 0, true)) {
+ sig = new char[arrayCount+1];
+ sig[arrayCount] = C_BYTE;
break;
- case ITerminalSymbols.TokenNamebyte :
- primitiveSig = Signature.C_BYTE;
- break;
- case ITerminalSymbols.TokenNamechar :
- primitiveSig = Signature.C_CHAR;
- break;
- case ITerminalSymbols.TokenNamedouble :
- primitiveSig = Signature.C_DOUBLE;
- break;
- case ITerminalSymbols.TokenNamefloat :
- primitiveSig = Signature.C_FLOAT;
- break;
- case ITerminalSymbols.TokenNameint :
- primitiveSig = Signature.C_INT;
- break;
- case ITerminalSymbols.TokenNamelong :
- primitiveSig = Signature.C_LONG;
- break;
- case ITerminalSymbols.TokenNameshort :
- primitiveSig = Signature.C_SHORT;
- break;
- case ITerminalSymbols.TokenNamevoid :
- primitiveSig = Signature.C_VOID;
- break;
- default :
- throw new IllegalArgumentException();
- }
- token = scanner.getNextToken();
- while (!primitive && token == ITerminalSymbols.TokenNameDOT) {
- sig.append(scanner.getCurrentIdentifierSource());
- token = scanner.getNextToken();
- if (token == ITerminalSymbols.TokenNameIdentifier) {
- sig.append(scanner.getCurrentIdentifierSource());
- token = scanner.getNextToken();
- } else {
- throw new IllegalArgumentException();
}
- }
- while (token == ITerminalSymbols.TokenNameLBRACKET) {
- token = scanner.getNextToken();
- if (token != ITerminalSymbols.TokenNameRBRACKET)
- throw new IllegalArgumentException();
- arrayCount++;
- token = scanner.getNextToken();
- }
- if (token != ITerminalSymbols.TokenNameEOF)
- throw new IllegalArgumentException();
- char[] result;
- if (primitive) {
- result = new char[arrayCount+1];
- result[arrayCount] = primitiveSig;
- } else {
- int sigLength = sig.length();
- int resultLength = arrayCount + 1 + sigLength + 1; // e.g. '[[[Ljava.lang.String;'
- result = new char[resultLength];
- sig.getChars(0, sigLength, result, arrayCount + 1);
- result[arrayCount] = isResolved ? C_RESOLVED : C_UNRESOLVED;
- result[resultLength-1] = C_NAME_END;
- }
- for (int i = 0; i < arrayCount; i++) {
- result[i] = C_ARRAY;
- }
- return result;
- } catch (InvalidInputException e) {
- throw new IllegalArgumentException();
+ case 'c':
+ if (CharOperation.fragmentEquals(CHAR, typeName, 0, true)) {
+ sig = new char[arrayCount+1];
+ sig[arrayCount] = C_CHAR;
+ break;
+ }
+ case 'd':
+ if (CharOperation.fragmentEquals(DOUBLE, typeName, 0, true)) {
+ sig = new char[arrayCount+1];
+ sig[arrayCount] = C_DOUBLE;
+ break;
+ }
+ case 'f':
+ if (CharOperation.fragmentEquals(FLOAT, typeName, 0, true)) {
+ sig = new char[arrayCount+1];
+ sig[arrayCount] = C_FLOAT;
+ break;
+ }
+ case 'i':
+ if (CharOperation.fragmentEquals(INT, typeName, 0, true)) {
+ sig = new char[arrayCount+1];
+ sig[arrayCount] = C_INT;
+ break;
+ }
+ case 'l':
+ if (CharOperation.fragmentEquals(LONG, typeName, 0, true)) {
+ sig = new char[arrayCount+1];
+ sig[arrayCount] = C_LONG;
+ break;
+ }
+ case 's':
+ if (CharOperation.fragmentEquals(SHORT, typeName, 0, true)) {
+ sig = new char[arrayCount+1];
+ sig[arrayCount] = C_SHORT;
+ break;
+ }
+ case 'v':
+ if (CharOperation.fragmentEquals(VOID, typeName, 0, true)) {
+ sig = new char[arrayCount+1];
+ sig[arrayCount] = C_VOID;
+ break;
+ }
+ default:
+ // non primitive type
+ int sigLength = arrayCount + 1 + length + 1; // e.g. '[[[Ljava.lang.String;'
+ sig = new char[sigLength];
+ int sigIndex = arrayCount+1; // index in sig
+ int startID = 0; // start of current ID in typeName
+ int index = 0; // index in typeName
+ while (index < length) {
+ char currentChar = typeName[index];
+ switch (currentChar) {
+ case '.':
+ if (startID == -1) throw new IllegalArgumentException(new String(typeName));
+ if (startID < index) {
+ sig = CharOperation.append(sig, sigIndex, typeName, startID, index);
+ sigIndex += index-startID;
+ }
+ sig[sigIndex++] = C_DOT;
+ index++;
+ startID = index;
+ break;
+ case '[':
+ if (startID != -1) {
+ if (startID < index) {
+ sig = CharOperation.append(sig, sigIndex, typeName, startID, index);
+ sigIndex += index-startID;
+ }
+ startID = -1; // no more id after []
+ }
+ index++;
+ break;
+ default :
+ if (startID != -1 && CharOperation.isWhitespace(currentChar)) {
+ if (startID < index) {
+ sig = CharOperation.append(sig, sigIndex, typeName, startID, index);
+ sigIndex += index-startID;
+ }
+ startID = index+1;
+ }
+ index++;
+ break;
+ }
+ }
+ // last id
+ if (startID != -1 && startID < index) {
+ sig = CharOperation.append(sig, sigIndex, typeName, startID, index);
+ sigIndex += index-startID;
+ }
+
+ // add L (or Q) at the beigininig and ; at the end
+ sig[arrayCount] = isResolved ? C_RESOLVED : C_UNRESOLVED;
+ sig[sigIndex++] = C_NAME_END;
+
+ // resize if needed
+ if (sigLength > sigIndex) {
+ System.arraycopy(sig, 0, sig = new char[sigIndex], 0, sigIndex);
+ }
}
+
+ // add array info
+ for (int i = 0; i < arrayCount; i++) {
+ sig[i] = C_ARRAY;
+ }
+
+ return sig;
}
/**
* Creates a new type signature from the given type name. If the type name is qualified,
@@ -545,7 +582,7 @@
* @return the encoded type signature
*/
public static String createTypeSignature(String typeName, boolean isResolved) {
- return createTypeSignature(typeName.toCharArray(), isResolved);
+ return createTypeSignature(typeName == null ? null : typeName.toCharArray(), isResolved);
}
/**
* Returns the array count (array nesting depth) of the given type signature.
@@ -806,13 +843,13 @@
* @param name the name
* @return the qualifier prefix, or the empty char array if the name contains no
* dots
- *
+ * @exception NullPointerException if name is null
* @since 2.0
*/
public static char[] getQualifier(char[] name) {
int lastDot = CharOperation.lastIndexOf(C_DOT, name);
if (lastDot == -1) {
- return NO_CHAR; //$NON-NLS-1$
+ return CharOperation.NO_CHAR;
}
return CharOperation.subarray(name, 0, lastDot);
}
@@ -832,9 +869,14 @@
* @param name the name
* @return the qualifier prefix, or the empty string if the name contains no
* dots
+ * @exception NullPointerException if name is null
*/
public static String getQualifier(String name) {
- return new String(getQualifier(name.toCharArray()));
+ int lastDot = name.lastIndexOf(C_DOT);
+ if (lastDot == -1) {
+ return EMPTY;
+ }
+ return name.substring(0, lastDot);
}
/**
* Extracts the return type from the given method signature. The method signature is
@@ -880,7 +922,7 @@
*
* @param name the name
* @return the last segment of the qualified name
- *
+ * @exception NullPointerException if name is null
* @since 2.0
*/
public static char[] getSimpleName(char[] name) {
@@ -904,9 +946,14 @@
*
* @param name the name
* @return the last segment of the qualified name
+ * @exception NullPointerException if name is null
*/
public static String getSimpleName(String name) {
- return new String(getSimpleName(name.toCharArray()));
+ int lastDot = name.lastIndexOf(C_DOT);
+ if (lastDot == -1) {
+ return name;
+ }
+ return name.substring(lastDot + 1, name.length());
}
/**
* Returns all segments of the given dot-separated qualified name.
@@ -924,12 +971,12 @@
*
* @param name the name
* @return the list of simple names, possibly empty
- *
+ * @exception NullPointerException if name is null
* @since 2.0
*/
public static char[][] getSimpleNames(char[] name) {
if (name.length == 0) {
- return NO_CHAR_CHAR;
+ return CharOperation.NO_CHAR_CHAR;
}
int dot = CharOperation.indexOf(C_DOT, name);
if (dot == -1) {
@@ -965,6 +1012,7 @@
*
* @param name the name
* @return the list of simple names, possibly empty
+ * @exception NullPointerException if name is null
*/
public static String[] getSimpleNames(String name) {
char[][] simpleNames = getSimpleNames(name.toCharArray());
@@ -1185,7 +1233,7 @@
int sigLength = signature.length;
if (sigLength == 0 || signature[0] == C_PARAM_START) {
- return toCharArray(signature, NO_CHAR, null, true, true);
+ return toCharArray(signature, CharOperation.NO_CHAR, null, true, true);
}
// compute result length
@@ -1270,7 +1318,7 @@
*/
public static char[] toQualifiedName(char[][] segments) {
int length = segments.length;
- if (length == 0) return NO_CHAR;
+ if (length == 0) return CharOperation.NO_CHAR;
if (length == 1) return segments[0];
int resultLength = 0;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java
index f024ce3..f553d9e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/ToolFactory.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core;
import java.io.File;
@@ -16,23 +16,22 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.jdt.core.compiler.IScanner;
+import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
import org.eclipse.jdt.core.util.ClassFormatException;
-import org.eclipse.jdt.core.util.IClassFileDisassembler;
import org.eclipse.jdt.core.util.IClassFileReader;
-import org.eclipse.jdt.internal.compiler.parser.Scanner;
import org.eclipse.jdt.internal.compiler.util.Util;
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.util.ClassFileReader;
import org.eclipse.jdt.internal.core.util.Disassembler;
+import org.eclipse.jdt.internal.core.util.PublicScanner;
import org.eclipse.jdt.internal.formatter.CodeFormatter;
/**
@@ -64,19 +63,16 @@
IExtension[] extensions = extension.getExtensions();
for(int i = 0; i < extensions.length; i++){
IConfigurationElement [] configElements = extensions[i].getConfigurationElements();
- IPluginDescriptor plugin = extension.getDeclaringPluginDescriptor();
- if (plugin.isPluginActivated()) {
- for(int j = 0; j < configElements.length; j++){
- try {
- Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
- if (execExt instanceof ICodeFormatter){
- // use first contribution found
- return (ICodeFormatter)execExt;
- }
- } catch(CoreException e){
- }
+ for(int j = 0; j < configElements.length; j++){
+ try {
+ Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
+ if (execExt instanceof ICodeFormatter){
+ // use first contribution found
+ return (ICodeFormatter)execExt;
}
+ } catch(CoreException e){
}
+ }
}
}
// no proper contribution found, use default formatter
@@ -107,15 +103,29 @@
*
* @return a classfile bytecode disassembler
* @see IClassFileDisassembler
+ * @deprecated - should use factory method creating ClassFileBytesDisassembler instead
*/
- public static IClassFileDisassembler createDefaultClassFileDisassembler(){
- return new Disassembler();
+ public static org.eclipse.jdt.core.util.IClassFileDisassembler createDefaultClassFileDisassembler(){
+ class DeprecatedDisassembler extends Disassembler implements org.eclipse.jdt.core.util.IClassFileDisassembler {};
+ return new DeprecatedDisassembler();
}
/**
+ * Create a classfile bytecode disassembler, able to produce a String representation of a given classfile.
+ *
+ * @return a classfile bytecode disassembler
+ * @see ClassFileBytesDisassembler
+ * @since 2.1
+ */
+ public static ClassFileBytesDisassembler createDefaultClassFileBytesDisassembler(){
+ return new Disassembler();
+ }
+
+ /**
* Create a default classfile reader, able to expose the internal representation of a given classfile
* according to the decoding flag used to initialize the reader.
* Answer null if the file named fileName doesn't represent a valid .class file.
+ * The fileName has to be an absolute OS path to the given .class file.
*
* The decoding flags are described in IClassFileReader.
*
@@ -151,11 +161,9 @@
*/
public static IClassFileReader createDefaultClassFileReader(IClassFile classfile, int decodingFlag){
- IPath filePath = classfile.getPath();
IPackageFragmentRoot root = (IPackageFragmentRoot) classfile.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
if (root != null){
try {
- IPath rootPath = root.getPath();
if (root instanceof JarPackageFragmentRoot) {
String archiveName = ((JarPackageFragmentRoot)root).getJar().getName();
@@ -168,7 +176,9 @@
}
return createDefaultClassFileReader(archiveName, entryName, decodingFlag);
} else {
- return createDefaultClassFileReader(classfile.getCorrespondingResource().getLocation().toOSString(), decodingFlag);
+ IPath location = classfile.getResource().getLocation();
+ if (location == null) return null;
+ return createDefaultClassFileReader(location.toOSString(), decodingFlag);
}
} catch(CoreException e){
}
@@ -193,6 +203,9 @@
*/
public static IClassFileReader createDefaultClassFileReader(String zipFileName, String zipEntryName, int decodingFlag){
try {
+ if (JavaModelManager.ZIP_ACCESS_VERBOSE) {
+ System.out.println("(" + Thread.currentThread() + ") [ToolFactory.createDefaultClassFileReader()] Creating ZipFile on " + zipFileName); //$NON-NLS-1$ //$NON-NLS-2$
+ }
ZipFile zipFile = new ZipFile(zipFileName);
ZipEntry zipEntry = zipFile.getEntry(zipEntryName);
if (zipEntry == null) {
@@ -227,6 +240,10 @@
* </pre>
* </code>
*
+ * <p>
+ * The returned scanner will tolerate unterminated line comments (missing line separator). It can be made stricter
+ * by using API with extra boolean parameter (<code>strictCommentMode</code>).
+ * <p>
* @param tokenizeComments if set to <code>false</code>, comments will be silently consumed
* @param tokenizeWhiteSpace if set to <code>false</code>, white spaces will be silently consumed,
* @param assertKeyword if set to <code>false</code>, occurrences of 'assert' will be reported as identifiers
@@ -235,14 +252,15 @@
* a new 'assert' keyword.
* @param recordLineSeparator if set to <code>true</code>, the scanner will record positions of encountered line
* separator ends. In case of multi-character line separators, the last character position is considered. These positions
- * can then be extracted using <code>IScanner#getLineEnds</code>
+ * can then be extracted using <code>IScanner#getLineEnds</code>. Only non-unicode escape sequences are
+ * considered as valid line separators.
* @return a scanner
- *
+ * @see ToolFactory#createScanner(boolean,boolean,boolean,boolean, boolean)
* @see org.eclipse.jdt.core.compiler.IScanner
*/
public static IScanner createScanner(boolean tokenizeComments, boolean tokenizeWhiteSpace, boolean assertMode, boolean recordLineSeparator){
- Scanner scanner = new Scanner(tokenizeComments, tokenizeWhiteSpace, false, assertMode);
+ PublicScanner scanner = new PublicScanner(tokenizeComments, tokenizeWhiteSpace, false/*nls*/, assertMode /*assert*/, null/*taskTags*/, null/*taskPriorities*/);
scanner.recordLineSeparator = recordLineSeparator;
return scanner;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IScanner.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/IScanner.java
similarity index 82%
rename from org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IScanner.java
rename to org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/IScanner.java
index 3f969e5..5087540 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IScanner.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/IScanner.java
@@ -1,15 +1,17 @@
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v0.5
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v05.html
-
-Contributors:
- IBM Corporation - initial API and implementation
-**********************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.jdt.core.compiler;
+
+import org.eclipse.jdt.core.compiler.InvalidInputException;
/**
* Definition of a Java scanner, as returned by the <code>ToolFactory</code>.
@@ -36,6 +38,17 @@
* been translated into unicode characters
*/
char[] getCurrentTokenSource();
+
+ /**
+ * Answers the current identifier source, before unicode escape sequences have
+ * been translated into unicode characters.
+ * e.g. if original source was <code>\\u0061bc</code> then it will answer <code>\\u0061bc</code>.
+ *
+ * @return the current identifier source, before unicode escape sequences have
+ * been translated into unicode characters
+ * @since 2.1
+ */
+ char[] getRawTokenSource();
/**
* Answers the starting position of the current token inside the original source.
@@ -103,7 +116,7 @@
* Note that the actual token ID values are subject to change if new keywords were added to the language
* (i.e. 'assert' keyword in 1.4).
*
- * @throws InvalidInputException - in case a lexical error was detected while reading the current token
+ * @throws InvalidInputException in case a lexical error was detected while reading the current token
*/
int getNextToken() throws InvalidInputException;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/ITerminalSymbols.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/ITerminalSymbols.java
similarity index 85%
rename from org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/ITerminalSymbols.java
rename to org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/ITerminalSymbols.java
index 16fe5e3..7ac6bba 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/ITerminalSymbols.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/compiler/ITerminalSymbols.java
@@ -1,13 +1,13 @@
-/**********************************************************************
-Copyright (c) 2002 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v0.5
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v05.html
-
-Contributors:
- IBM Corporation - initial API and implementation
-**********************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package org.eclipse.jdt.core.compiler;
@@ -54,7 +54,7 @@
TokenNamefloat = 22,
TokenNamefor = 122,
TokenNameif = 123,
- TokenNameimplements = 267,
+ TokenNameimplements = 268,
TokenNameimport = 191,
TokenNameinstanceof = 65,
TokenNameint = 23,
@@ -71,10 +71,10 @@
TokenNameshort = 25,
TokenNamestatic = 94,
TokenNamestrictfp = 104,
- TokenNamesuper = 34,
+ TokenNamesuper = 33,
TokenNameswitch = 125,
TokenNamesynchronized = 85,
- TokenNamethis = 35,
+ TokenNamethis = 34,
TokenNamethrow = 126,
TokenNamethrows = 227,
TokenNametransient = 105,
@@ -91,7 +91,7 @@
TokenNameStringLiteral = 45,
TokenNamePLUS_PLUS = 1,
TokenNameMINUS_MINUS = 2,
- TokenNameEQUAL_EQUAL = 33,
+ TokenNameEQUAL_EQUAL = 35,
TokenNameLESS_EQUAL = 66,
TokenNameGREATER_EQUAL = 67,
TokenNameNOT_EQUAL = 36,
@@ -136,5 +136,5 @@
TokenNameDOT = 6,
TokenNameEQUAL = 167,
TokenNameEOF = 158,
- TokenNameERROR = 307;
+ TokenNameERROR = 309;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/ICodeSnippetRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/ICodeSnippetRequestor.java
index f6825a2..32fdc7b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/ICodeSnippetRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/ICodeSnippetRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.eval;
import org.eclipse.core.resources.IMarker;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/IEvaluationContext.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/IEvaluationContext.java
index c2c6f41..52dc47e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/IEvaluationContext.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/IEvaluationContext.java
@@ -1,17 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.eval;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.ICodeCompletionRequestor;
import org.eclipse.jdt.core.ICompletionRequestor;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
@@ -333,7 +332,7 @@
public void codeComplete(
String codeSnippet,
int position,
- ICodeCompletionRequestor requestor)
+ org.eclipse.jdt.core.ICodeCompletionRequestor requestor)
throws JavaModelException;
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/IGlobalVariable.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/IGlobalVariable.java
index a39f662..079aca1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/IGlobalVariable.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/eval/IGlobalVariable.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.eval;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMException.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMException.java
index 48f6526..c34aa52 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMException.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMException.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMFactory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMFactory.java
index fd5524a..59d6132 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMFactory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/DOMFactory.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
import org.eclipse.jdt.internal.compiler.util.Util;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMCompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMCompilationUnit.java
index 8c20515..be8f924 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMCompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMCompilationUnit.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMFactory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMFactory.java
index 4efe0f7..71f2fed 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMFactory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMFactory.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMField.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMField.java
index 86f9831..3a2f9af 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMField.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMField.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMImport.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMImport.java
index 117599b..acc7b81 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMImport.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMImport.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMInitializer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMInitializer.java
index f0c591c..216cb3e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMInitializer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMInitializer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMMember.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMMember.java
index 2a5fc74..f9475ee 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMMember.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMMember.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMMethod.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMMethod.java
index f939e8e..b79e1b3 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMMethod.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMMethod.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMNode.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMNode.java
index 64caccc..967c94a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMNode.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMNode.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
import java.util.Enumeration;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMPackage.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMPackage.java
index 82f62d2..e3b1f9c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMPackage.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMPackage.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
/**
* Represents a package declaration.
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMType.java
index 867edb8..877b560 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/jdom/IDOMType.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.jdom;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ByteCodeVisitorAdapter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ByteCodeVisitorAdapter.java
index f7c9a77..f07cd93 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ByteCodeVisitorAdapter.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ByteCodeVisitorAdapter.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ClassFileBytesDisassembler.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ClassFileBytesDisassembler.java
new file mode 100644
index 0000000..664be7a
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ClassFileBytesDisassembler.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.util;
+
+/**
+ * This class is intended to be subclassed to disassemble
+ * classfile bytes onto a String using the proper line separator.
+ *
+ * @since 2.1
+ */
+public abstract class ClassFileBytesDisassembler {
+
+ /**
+ * The mode is the detailed mode to disassemble IClassFileReader. It returns the magic
+ * numbers, the version numbers and field and method descriptors.
+ */
+ public final static int DETAILED = 1;
+
+ /**
+ * The mode is the default mode to disassemble IClassFileReader.
+ */
+ public final static int DEFAULT = 2;
+
+ /**
+ * Answers back the disassembled string of the classfile bytes using the default
+ * mode.
+ * This is an output quite similar to the javap tool, using DEFAULT mode.
+ *
+ * @param classFileBytes The bytes of the classfile
+ * @param lineSeparator the line separator to use.
+ *
+ * @return the disassembled string of the IClassFileReader using the default mode.
+ * @exception ClassFormatException if the classfile bytes are ill-formed
+ */
+ public abstract String disassemble(byte[] classFileBytes, String lineSeparator) throws ClassFormatException;
+
+ /**
+ * Answers back the disassembled string of the classfile bytes according to the
+ * mode.
+ * This is an output quite similar to the javap tool.
+ *
+ * @param classFileBytes The bytes of the classfile
+ * @param lineSeparator the line separator to use.
+ * @param mode the mode used to disassemble the IClassFileReader
+ *
+ * @return the disassembled string of the IClassFileReader according to the mode
+ * @exception ClassFormatException if the classfile bytes are ill-formed
+ */
+ public abstract String disassemble(byte[] classFileBytes, String lineSeparator, int mode) throws ClassFormatException;
+
+ /**
+ * Answers a readable short description of this disassembler
+ *
+ * @return String - a string description of the disassembler
+ */
+ public abstract String getDescription();
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ClassFormatException.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ClassFormatException.java
index 31c22cf..b5e38ce 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ClassFormatException.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ClassFormatException.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java
new file mode 100644
index 0000000..7a60c5b
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/CompilationUnitSorter.java
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.core.util;
+
+import java.util.Comparator;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.JavaElement;
+import org.eclipse.jdt.internal.core.SortElementsOperation;
+
+/**
+ * Operation for sorting members within a compilation unit.
+ * <p>
+ * This class provides all functionality via static members; it is not
+ * intended to be instantiated or subclassed.
+ * </p>
+ *
+ * @since 2.1
+ */
+public final class CompilationUnitSorter {
+
+ /**
+ * Private constructor to prevent instantiation.
+ */
+ private CompilationUnitSorter() {
+ }
+
+ /**
+ * Name of auxillary property whose value can be used to determine the
+ * original relative order of two body declarations. This allows a
+ * comparator to preserve the relative positions of certain kinds of
+ * body declarations when required.
+ * <p>
+ * All body declarations passed to the comparator's <code>compare</code>
+ * method by <code>CompilationUnitSorter.sort</code> carry an
+ * Integer-valued property. The body declaration with the lower value
+ * comes before the one with the higher value. The exact numeric value
+ * of these properties is unspecified.
+ * </p>
+ * <p>
+ * Example usage:
+ * <pre>
+ * BodyDeclaration b1 = (BodyDeclaration) object1;
+ * BodyDeclaration b2 = (BodyDeclaration) object2;
+ * Integer i1 = (Integer) b1.getProperty(RELATIVE_ORDER);
+ * Integer i2 = (Integer) b2.getProperty(RELATIVE_ORDER);
+ * return i1.intValue() - i2.intValue(); // preserve original order
+ * </pre>
+ * </p>
+ *
+ * @see #sort
+ * @see org.eclipse.jdt.core.dom.BodyDeclaration
+ */
+ public static final String RELATIVE_ORDER = "relativeOrder"; //$NON-NLS-1$
+
+ /**
+ * Reorders the declarations in the given compilation unit. The caller is
+ * responsible for arranging in advance that the given compilation unit is
+ * a working copy, and for saving the changes afterwards.
+ * <p>
+ * <b>Note:</b> Reordering the members within a type declaration might be
+ * more than a cosmetic change and could have potentially serious
+ * repercussions. Firstly, the order in which the fields of a type are
+ * initialized is significant in the Java language; reordering fields
+ * and initializers may result in compilation errors or change the execution
+ * behavior of the code. Secondly, reordering a class's members may affect
+ * how its instances are serialized. This operation should therefore be used
+ * with caution and due concern for potential negative side effects.
+ * </p>
+ * <p>
+ * The optional <code>positions</code> array contains a non-decreasing
+ * ordered list of character-based source positions within the compilation
+ * unit's source code string. Upon return from this method, the positions in
+ * the array reflect the corresponding new locations in the modified source
+ * code string, Note that this operation modifies the given array in place.
+ * </p>
+ * <p>
+ * The <code>compare</code> method of the given comparator is passed pairs
+ * of AST body declarations (subclasses of <code>BodyDeclaration</code>)
+ * representing body declarations at the same level. The comparator is
+ * called on body declarations of nested classes, including anonymous and
+ * local classes, but always at the same level. Clients need to provide
+ * a comparator implementation (there is no standard comparator). The
+ * <code>RELATIVE_ORDER</code> property attached to these AST nodes afforts
+ * the comparator a way to preserve the original relative order.
+ * </p>
+ * <p>
+ * The body declarations passed as parameters to the comparator
+ * always carry at least the following minimal signature information:
+ * <br>
+ * <table border="1" width="80%" cellpadding="5">
+ * <tr>
+ * <td width="20%"><code>TypeDeclaration</code></td>
+ * <td width="50%"><code>modifiers, isInterface, name, superclass,
+ * superInterfaces<br>
+ * RELATIVE_ORDER property</code></td>
+ * </tr>
+ * <tr>
+ * <td width="20%"><code>FieldDeclaration</code></td>
+ * <td width="50%"><code>modifiers, type, fragments
+ * (VariableDeclarationFragments
+ * with name only)<br>
+ * RELATIVE_ORDER property</code></td>
+ * </tr>
+ * <tr>
+ * <td width="20%"><code>MethodDeclaration</code></td>
+ * <td width="50%"><code>modifiers, isConstructor, returnType, name,
+ * parameters
+ * (SingleVariableDeclarations with name and type only),
+ * thrownExceptions<br>
+ * RELATIVE_ORDER property</code></td>
+ * </tr>
+ * <tr>
+ * <td width="20%"><code>Initializer</code></td>
+ * <td width="50%"><code>modifiers<br>
+ * RELATIVE_ORDER property</code></td>
+ * </tr>
+ * </table>
+ * Clients should rely on the AST nodes being properly parented or on
+ * having source range information. (Future releases may provide options
+ * for requesting additional information like source positions, full ASTs,
+ * non-recursive sorting, etc.)
+ * </p>
+ *
+ * @param compilationUnit the given compilation unit, which must be a
+ * working copy
+ * @param positions an array of source positions to map, or
+ * <code>null</code> if none. If supplied, the positions must
+ * character-based source positions within the original source code for
+ * the given compilation unit, arranged in non-decreasing order.
+ * The array is updated in place when this method returns to reflect the
+ * corresponding source positions in the permuted source code string
+ * (but not necessarily any longer in non-decreasing order).
+ * @param comparator the comparator capable of ordering
+ * <code>BodyDeclaration</code>s
+ * @param options bitwise-or of option flags; <code>0</code> for default
+ * behavior (reserved for future growth)
+ * @param monitor the progress monitor to notify, or <code>null</code> if
+ * none
+ * @exception JavaModelException if the compilation unit could not be
+ * sorted. Reasons include:
+ * <ul>
+ * <li> The given compilation unit does not exist (ELEMENT_DOES_NOT_EXIST)</li>
+ * <li> The given compilation unit is not a working copy (INVALID_ELEMENT_TYPES)</li>
+ * <li> A <code>CoreException</code> occurred while accessing the underlying
+ * resource
+ * </ul>
+ * @exception IllegalArgumentException if the given compilation unit is null
+ * or if the given comparator is null.
+ * @see org.eclipse.jdt.core.dom.BodyDeclaration
+ * @see #RELATIVE_ORDER
+ */
+ public static void sort(ICompilationUnit compilationUnit,
+ int[] positions,
+ Comparator comparator,
+ int options,
+ IProgressMonitor monitor) throws JavaModelException {
+ if (compilationUnit == null || comparator == null) {
+ throw new IllegalArgumentException();
+ }
+ ICompilationUnit[] compilationUnits = new ICompilationUnit[] { compilationUnit };
+ SortElementsOperation operation = new SortElementsOperation(compilationUnits, positions, comparator);
+ JavaElement.runOperation(operation, monitor);
+ }
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IAttributeNamesConstants.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IAttributeNamesConstants.java
index eaa0e63..a9a0a0b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IAttributeNamesConstants.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IAttributeNamesConstants.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IBytecodeVisitor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IBytecodeVisitor.java
index 9697b92..ffdc584 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IBytecodeVisitor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IBytecodeVisitor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
@@ -282,4 +282,4 @@
void _breakpoint(int pc);
void _impdep1(int pc);
void _impdep2(int pc);
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileAttribute.java
index 7dc1e5e..6849ad8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileDisassembler.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileDisassembler.java
index ceb3c65..71585d3 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileDisassembler.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileDisassembler.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
@@ -15,6 +15,7 @@
* IClassFileReader onto a String using the proper line separator.
*
* @since 2.0
+ * @deprecated - should use ClassFileBytesDisassembler instead
*/
public interface IClassFileDisassembler {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileReader.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileReader.java
index 2e136b0..07b3bd6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileReader.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileReader.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
@@ -228,4 +228,4 @@
* @return the number of method infos
*/
int getMethodsCount();
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ICodeAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ICodeAttribute.java
index b6a8c64..3cb01e6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ICodeAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ICodeAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
@@ -106,4 +106,4 @@
* @exception ClassFormatException Exception thrown if the opcodes contain invalid bytes
*/
void traverse(IBytecodeVisitor visitor) throws ClassFormatException;
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPool.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPool.java
index ed311b9..723a11f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPool.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPool.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPoolConstant.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPoolConstant.java
index 4be4749..0950732 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPoolConstant.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPoolConstant.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPoolEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPoolEntry.java
index 207ed40..f6f56e5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPoolEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPoolEntry.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantValueAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantValueAttribute.java
index d278d74..130ff8f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantValueAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantValueAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExceptionAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExceptionAttribute.java
index 3cd2a95..826affd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExceptionAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExceptionAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExceptionTableEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExceptionTableEntry.java
index 55b674b..095437f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExceptionTableEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IExceptionTableEntry.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IFieldInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IFieldInfo.java
index 48de04b..040fa57 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IFieldInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IFieldInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
@@ -107,4 +107,4 @@
* Returns an empty collection if none
*/
IClassFileAttribute[] getAttributes();
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IInnerClassesAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IInnerClassesAttribute.java
index 4f0d663..fb8317b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IInnerClassesAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IInnerClassesAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IInnerClassesAttributeEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IInnerClassesAttributeEntry.java
index 3211419..2061817 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IInnerClassesAttributeEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IInnerClassesAttributeEntry.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
@@ -83,4 +83,4 @@
*/
char[] getInnerClassName();
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILineNumberAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILineNumberAttribute.java
index db28db0..3d0ec0f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILineNumberAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILineNumberAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILocalVariableAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILocalVariableAttribute.java
index f13f63a..3561769 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILocalVariableAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILocalVariableAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILocalVariableTableEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILocalVariableTableEntry.java
index f6bd922..00d9d8a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILocalVariableTableEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ILocalVariableTableEntry.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IMethodInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IMethodInfo.java
index 5163c04..79cd6d5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IMethodInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IMethodInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
@@ -134,4 +134,4 @@
* Returns an empty collection if none
*/
IClassFileAttribute[] getAttributes();
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IModifierConstants.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IModifierConstants.java
index 4a39daa..49bd52a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IModifierConstants.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IModifierConstants.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IOpcodeMnemonics.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IOpcodeMnemonics.java
index 6178ec4..0089b03 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IOpcodeMnemonics.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IOpcodeMnemonics.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ISourceAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ISourceAttribute.java
index fbcf0c6..916b551 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ISourceAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/ISourceAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/OpcodeStringValues.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/OpcodeStringValues.java
index 420d37f..34d97f3 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/OpcodeStringValues.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/OpcodeStringValues.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Assert.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Assert.java
index 213ef27..324a08b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Assert.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Assert.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
public final class Assert {
@@ -61,7 +61,7 @@
*/
public static void isNotNull(Object object, String message) {
if (object == null)
- throw new AssertionFailedException(Util.bind("assert.nullArgument",message)); //$NON-NLS-1$
+ throw new AssertionFailedException("null argument; " + message); //$NON-NLS-1$
}
/** Asserts that the given boolean is <code>true</code>. If this
* is not the case, some kind of unchecked exception is thrown.
@@ -84,7 +84,7 @@
*/
public static boolean isTrue(boolean expression, String message) {
if (!expression)
- throw new AssertionFailedException(Util.bind("assert.failed", message)); //$NON-NLS-1$
+ throw new AssertionFailedException("Assertion failed; " + message); //$NON-NLS-1$
return expression;
}
@@ -95,4 +95,4 @@
super(detail);
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BasicCompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BasicCompilationUnit.java
index f7afa21..d2eb5ac 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BasicCompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BasicCompilationUnit.java
@@ -1,18 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.File;
import java.io.IOException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.util.Util;
@@ -53,7 +54,7 @@
return Util.getFileCharContent(new File(new String(fileName)), this.encoding);
} catch (IOException e) {
}
- return new char[0];
+ return CharOperation.NO_CHAR;
}
public char[] getFileName() {
return this.fileName;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BatchOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BatchOperation.java
new file mode 100644
index 0000000..c088217
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BatchOperation.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaModelStatus;
+import org.eclipse.jdt.core.JavaModelException;
+
+/**
+ * An operation created as a result of a call to JavaCore.run(IWorkspaceRunnable, IProgressMonitor)
+ * that encapsulates a user defined IWorkspaceRunnable.
+ */
+public class BatchOperation extends JavaModelOperation {
+ protected IWorkspaceRunnable runnable;
+ public BatchOperation(IWorkspaceRunnable runnable) {
+ this.runnable = runnable;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.core.JavaModelOperation#executeOperation()
+ */
+ protected void executeOperation() throws JavaModelException {
+ try {
+ this.runnable.run(fMonitor);
+ } catch (CoreException ce) {
+ if (ce instanceof JavaModelException) {
+ throw (JavaModelException)ce;
+ } else {
+ if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
+ Throwable e= ce.getStatus().getException();
+ if (e instanceof JavaModelException) {
+ throw (JavaModelException) e;
+ }
+ }
+ throw new JavaModelException(ce);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.core.JavaModelOperation#verify()
+ */
+ protected IJavaModelStatus verify() {
+ // cannot verify user defined operation
+ return JavaModelStatus.VERIFIED_OK;
+ }
+
+
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryField.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryField.java
index 75d0a9e..a160530 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryField.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryField.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IField;
@@ -32,14 +32,14 @@
* @see IField
*/
public Object getConstant() throws JavaModelException {
- IBinaryField info = (IBinaryField) getRawInfo();
+ IBinaryField info = (IBinaryField) getElementInfo();
return convertConstant(info.getConstant());
}
/**
* @see IMember
*/
public int getFlags() throws JavaModelException {
- IBinaryField info = (IBinaryField) getRawInfo();
+ IBinaryField info = (IBinaryField) getElementInfo();
return info.getModifiers();
}
/**
@@ -52,7 +52,7 @@
* @see IField
*/
public String getTypeSignature() throws JavaModelException {
- IBinaryField info = (IBinaryField) getRawInfo();
+ IBinaryField info = (IBinaryField) getElementInfo();
return new String(ClassFile.translatedName(info.getTypeName()));
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMember.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMember.java
index 36e894d..68df607 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMember.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMember.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -35,9 +35,12 @@
/**
* @see ISourceReference
*/
-public ISourceRange getNameRange() {
+public ISourceRange getNameRange() throws JavaModelException {
SourceMapper mapper= getSourceMapper();
if (mapper != null) {
+ // ensure the class file's buffer is open so that source ranges are computed
+ ((ClassFile)getClassFile()).getBuffer();
+
return mapper.getNameRange(this);
} else {
return SourceMapper.fgUnknownRange;
@@ -49,6 +52,9 @@
public ISourceRange getSourceRange() throws JavaModelException {
SourceMapper mapper= getSourceMapper();
if (mapper != null) {
+ // ensure the class file's buffer is open so that source ranges are computed
+ ((ClassFile)getClassFile()).getBuffer();
+
return mapper.getSourceRange(this);
} else {
return SourceMapper.fgUnknownRange;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java
index 8e23bd3..0ee15b9 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.Flags;
@@ -103,7 +103,7 @@
*/
public String[] getExceptionTypes() throws JavaModelException {
if (fExceptionTypes == null) {
- IBinaryMethod info = (IBinaryMethod) getRawInfo();
+ IBinaryMethod info = (IBinaryMethod) getElementInfo();
char[][] eTypeNames = info.getExceptionTypeNames();
if (eTypeNames == null || eTypeNames.length == 0) {
fExceptionTypes = fgEmptyList;
@@ -127,7 +127,7 @@
* @see IMember
*/
public int getFlags() throws JavaModelException {
- IBinaryMethod info = (IBinaryMethod) getRawInfo();
+ IBinaryMethod info = (IBinaryMethod) getElementInfo();
return info.getModifiers();
}
/**
@@ -187,7 +187,7 @@
}
// if still no parameter names, produce fake ones
if (fParameterNames == null) {
- IBinaryMethod info = (IBinaryMethod) getRawInfo();
+ IBinaryMethod info = (IBinaryMethod) getElementInfo();
int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor()));
fParameterNames = new String[paramCount];
for (int i = 0; i < paramCount; i++) {
@@ -207,7 +207,7 @@
* @see IMethod
*/
public String getReturnType() throws JavaModelException {
- IBinaryMethod info = (IBinaryMethod) getRawInfo();
+ IBinaryMethod info = (IBinaryMethod) getElementInfo();
if (fReturnType == null) {
String returnType= Signature.getReturnType(new String(info.getMethodDescriptor()));
fReturnType= new String(ClassFile.translatedName(returnType.toCharArray()));
@@ -218,14 +218,14 @@
* @see IMethod
*/
public String getSignature() throws JavaModelException {
- IBinaryMethod info = (IBinaryMethod) getRawInfo();
+ IBinaryMethod info = (IBinaryMethod) getElementInfo();
return new String(info.getMethodDescriptor());
}
/**
* @see IMethod
*/
public boolean isConstructor() throws JavaModelException {
- IBinaryMethod info = (IBinaryMethod) getRawInfo();
+ IBinaryMethod info = (IBinaryMethod) getElementInfo();
return info.isConstructor();
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java
index fd4d57a..4de1ca1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java
@@ -1,37 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
+import java.io.InputStream;
import java.util.ArrayList;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.ICompletionRequestor;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IInitializer;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IOpenable;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeHierarchy;
-import org.eclipse.jdt.core.IWorkingCopy;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.internal.codeassist.CompletionEngine;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy;
/**
* Parent is an IClassFile.
@@ -58,26 +46,36 @@
Object info = JavaModelManager.getJavaModelManager().peekAtInfo(this);
if (info != null) {
- ClassFileInfo cfi = getClassFileInfo();
- if (cfi.hasReadBinaryChildren()) {
- try {
- IJavaElement[] children = getChildren();
- for (int i = 0, size = children.length; i < size; ++i) {
- JavaElement child = (JavaElement) children[i];
- if (child instanceof BinaryType) {
- ((IOpenable)child.getParent()).close();
- } else {
- child.close();
- }
- }
- } catch (JavaModelException e) {
+ boolean wasVerbose = false;
+ try {
+ if (JavaModelManager.VERBOSE) {
+ System.out.println("CLOSING Element ("+ Thread.currentThread()+"): " + this.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$
+ wasVerbose = true;
+ JavaModelManager.VERBOSE = false;
}
- }
- closing(info);
- JavaModelManager.getJavaModelManager().removeInfo(this);
- if (JavaModelManager.VERBOSE){
- System.out.println("-> Package cache size = " + JavaModelManager.getJavaModelManager().cache.pkgSize()); //$NON-NLS-1$
- System.out.println("-> Openable cache filling ratio = " + JavaModelManager.getJavaModelManager().cache.openableFillingRatio() + "%"); //$NON-NLS-1$//$NON-NLS-2$
+ ClassFileInfo cfi = getClassFileInfo();
+ if (cfi.hasReadBinaryChildren()) {
+ try {
+ IJavaElement[] children = getChildren();
+ for (int i = 0, size = children.length; i < size; ++i) {
+ JavaElement child = (JavaElement) children[i];
+ if (child instanceof BinaryType) {
+ ((IOpenable)child.getParent()).close();
+ } else {
+ child.close();
+ }
+ }
+ } catch (JavaModelException e) {
+ }
+ }
+ closing(info);
+ JavaModelManager.getJavaModelManager().removeInfo(this);
+ if (JavaModelManager.VERBOSE){
+ System.out.println("-> Package cache size = " + JavaModelManager.getJavaModelManager().cache.pkgSize()); //$NON-NLS-1$
+ System.out.println("-> Openable cache filling ratio = " + JavaModelManager.getJavaModelManager().cache.openableFillingRatio() + "%"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ } finally {
+ JavaModelManager.VERBOSE = wasVerbose;
}
}
}
@@ -85,9 +83,6 @@
* Remove my cached children from the Java Model
*/
protected void closing(Object info) throws JavaModelException {
- if (JavaModelManager.VERBOSE){
- System.out.println("CLOSING Element ("+ Thread.currentThread()+"): " + this.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$
- }
ClassFileInfo cfi = getClassFileInfo();
cfi.removeBinaryChildren();
if (JavaModelManager.VERBOSE){
@@ -102,14 +97,14 @@
if (requestor == null) {
throw new IllegalArgumentException(Util.bind("codeAssist.nullRequestor")); //$NON-NLS-1$
}
-
- SearchableEnvironment environment = (SearchableEnvironment) ((JavaProject) getJavaProject()).getSearchableNameEnvironment();
- NameLookup nameLookup = ((JavaProject) getJavaProject()).getNameLookup();
- CompletionEngine engine = new CompletionEngine(environment, new CompletionRequestorWrapper(requestor,nameLookup), JavaCore.getOptions());
+ JavaProject project = (JavaProject) getJavaProject();
+ SearchableEnvironment environment = (SearchableEnvironment) project.getSearchableNameEnvironment();
+ NameLookup nameLookup = project.getNameLookup();
+ CompletionEngine engine = new CompletionEngine(environment, new CompletionRequestorWrapper(requestor,nameLookup), project.getOptions(true), project);
String source = getClassFile().getSource();
if (source != null && insertion > -1 && insertion < source.length()) {
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
+ String encoding = project.getOption(JavaCore.CORE_ENCODING, true);
char[] prefix = CharOperation.concat(source.substring(0, insertion).toCharArray(), new char[]{'{'});
char[] suffix = CharOperation.concat(new char[]{'}'}, source.substring(insertion).toCharArray());
@@ -186,7 +181,7 @@
IClassFile classFile = this.getClassFile();
if (classFile.isOpen()) {
try {
- char[] enclosingTypeName = ((IBinaryType) getRawInfo()).getEnclosingTypeName();
+ char[] enclosingTypeName = ((IBinaryType) getElementInfo()).getEnclosingTypeName();
if (enclosingTypeName == null) {
return null;
}
@@ -254,7 +249,7 @@
* @see IMember#getFlags()
*/
public int getFlags() throws JavaModelException {
- IBinaryType info = (IBinaryType) getRawInfo();
+ IBinaryType info = (IBinaryType) getElementInfo();
return info.getModifiers();
}
/**
@@ -325,7 +320,7 @@
* @see IType#getSuperclassName()
*/
public String getSuperclassName() throws JavaModelException {
- IBinaryType info = (IBinaryType) getRawInfo();
+ IBinaryType info = (IBinaryType) getElementInfo();
char[] superclassName = info.getSuperclassName();
if (superclassName == null) {
return null;
@@ -336,7 +331,7 @@
* @see IType#getSuperInterfaceNames()
*/
public String[] getSuperInterfaceNames() throws JavaModelException {
- IBinaryType info = (IBinaryType) getRawInfo();
+ IBinaryType info = (IBinaryType) getElementInfo();
char[][] names= info.getInterfaceNames();
int length;
if (names == null || (length = names.length) == 0) {
@@ -407,7 +402,7 @@
* @see IType#isAnonymous()
*/
public boolean isAnonymous() throws JavaModelException {
- IBinaryType info = (IBinaryType) getRawInfo();
+ IBinaryType info = (IBinaryType) getElementInfo();
return info.isAnonymous();
}
/**
@@ -420,7 +415,7 @@
* @see IType#isInterface()
*/
public boolean isInterface() throws JavaModelException {
- IBinaryType info = (IBinaryType) getRawInfo();
+ IBinaryType info = (IBinaryType) getElementInfo();
return info.isInterface();
}
@@ -428,17 +423,23 @@
* @see IType#isLocal()
*/
public boolean isLocal() throws JavaModelException {
- IBinaryType info = (IBinaryType) getRawInfo();
+ IBinaryType info = (IBinaryType) getElementInfo();
return info.isLocal();
}
/**
* @see IType#isMember()
*/
public boolean isMember() throws JavaModelException {
- IBinaryType info = (IBinaryType) getRawInfo();
+ IBinaryType info = (IBinaryType) getElementInfo();
return info.isMember();
}
/**
+ * @see IType
+ */
+public ITypeHierarchy loadTypeHierachy(InputStream input, IProgressMonitor monitor) throws JavaModelException {
+ return TypeHierarchy.load(this, input);
+}
+/**
* @see IType#newSupertypeHierarchy(IProgressMonitor monitor)
*/
public ITypeHierarchy newSupertypeHierarchy(IProgressMonitor monitor) throws JavaModelException {
@@ -485,8 +486,8 @@
}
CreateTypeHierarchyOperation op= new CreateTypeHierarchyOperation(
this,
- null, // no working copies
- SearchEngine.createJavaSearchScope(new IJavaElement[] {project}),
+ (IWorkingCopy[])null, // no working copies
+ project,
true);
runOperation(op, monitor);
return op.getResult();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java
index 87fba56..67b2696 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.ByteArrayInputStream;
@@ -20,13 +20,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.jdt.core.BufferChangedEvent;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.IBufferChangedListener;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IOpenable;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.*;
/**
* @see IBuffer
@@ -336,7 +330,7 @@
// use a platform operation to update the resource contents
try {
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
+ String encoding = ((IJavaElement)this.owner).getJavaProject().getOption(JavaCore.CORE_ENCODING, true);
String contents = this.getContents();
if (contents == null) return;
byte[] bytes = encoding == null
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferCache.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferCache.java
index 43f2d92..72716fb 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferCache.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferCache.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IBuffer;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferManager.java
index 8a1e626..4672244 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BufferManager.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.Enumeration;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
index 6e1fdc0..a5435b6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFile.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.IOException;
@@ -26,7 +26,6 @@
import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.IBufferFactory;
import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.ICodeCompletionRequestor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.ICompletionRequestor;
import org.eclipse.jdt.core.IJavaElement;
@@ -69,13 +68,13 @@
public void codeComplete(int offset, ICompletionRequestor requestor) throws JavaModelException {
String source = getSource();
if (source != null) {
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
-
+ String encoding = this.getJavaProject().getOption(JavaCore.CORE_ENCODING, true);
+ String elementName = getElementName();
BasicCompilationUnit cu =
new BasicCompilationUnit(
getSource().toCharArray(),
null,
- getElementName() + ".java", //$NON-NLS-1$
+ elementName.substring(0, elementName.length()-".class".length()) + ".java", //$NON-NLS-1$ //$NON-NLS-2$
encoding);
codeComplete(cu, cu, offset, requestor);
}
@@ -240,6 +239,9 @@
if (mapper == null) {
return null;
} else {
+ // ensure this class file's buffer is open so that source ranges are computed
+ getBuffer();
+
IType type = getType();
return findElement(type, position, mapper);
}
@@ -417,6 +419,11 @@
}
return null;
}
+protected void openWhenClosed(IProgressMonitor pm) throws JavaModelException {
+ IResource resource = this.getResource();
+ if (resource != null && !resource.isAccessible()) throw newNotPresentException();
+ super.openWhenClosed(pm);
+}
/*
* @see JavaElement#rootedAt(IJavaProject)
*/
@@ -526,7 +533,7 @@
* @see ICodeAssist#codeComplete(int, ICodeCompletionRequestor)
* @deprecated - should use codeComplete(int, ICompletionRequestor) instead
*/
-public void codeComplete(int offset, final ICodeCompletionRequestor requestor) throws JavaModelException {
+public void codeComplete(int offset, final org.eclipse.jdt.core.ICodeCompletionRequestor requestor) throws JavaModelException {
if (requestor == null){
codeComplete(offset, (ICompletionRequestor)null);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java
index 863c33f..bff3eb0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileWorkingCopy.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileWorkingCopy.java
index 3100fe3..66f3163 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileWorkingCopy.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClassFileWorkingCopy.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.resources.IMarker;
@@ -16,7 +16,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.IBufferFactory;
-import org.eclipse.jdt.core.ICodeCompletionRequestor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.ICompletionRequestor;
import org.eclipse.jdt.core.IImportContainer;
@@ -499,7 +498,7 @@
* @see org.eclipse.jdt.core.ICodeAssist#codeComplete(int, ICodeCompletionRequestor)
* @deprecated
*/
- public void codeComplete(int offset, ICodeCompletionRequestor requestor)
+ public void codeComplete(int offset, org.eclipse.jdt.core.ICodeCompletionRequestor requestor)
throws JavaModelException {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this));
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java
index 21848c4..5f30c85 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java
@@ -1,19 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* @see IClasspathEntry
@@ -24,14 +30,14 @@
* Describes the kind of classpath entry - one of
* CPE_PROJECT, CPE_LIBRARY, CPE_SOURCE, CPE_VARIABLE or CPE_CONTAINER
*/
- protected int entryKind;
+ public int entryKind;
/**
* Describes the kind of package fragment roots found on
* this classpath entry - either K_BINARY or K_SOURCE or
* K_OUTPUT.
*/
- protected int contentKind;
+ public int contentKind;
/**
* The meaning of the path of a classpath entry depends on its entry kind:<ul>
@@ -53,9 +59,24 @@
* registered), and the remaining segments are used as additional hints for resolving the container entry to
* an actual <code>IClasspathContainer</code>.</li>
*/
- protected IPath path;
+ public IPath path;
/**
+ * Patterns allowing to exclude portions of the resource tree denoted by this entry path.
+ */
+
+ public IPath[] exclusionPatterns;
+ private char[][] fullCharExclusionPatterns;
+ private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$
+
+ private String rootID;
+
+ /**
+ * Default exclusion pattern set
+ */
+ public final static IPath[] NO_EXCLUSION_PATTERNS = {};
+
+ /**
* Describes the path to the source archive associated with this
* classpath entry, or <code>null</code> if this classpath entry has no
* source attachment.
@@ -66,7 +87,7 @@
* an analogous form and meaning as the variable path, namely the first segment
* is the name of a classpath variable.
*/
- protected IPath sourceAttachmentPath;
+ public IPath sourceAttachmentPath;
/**
* Describes the path within the source archive where package fragments
@@ -75,17 +96,22 @@
* if and only if <code>getSourceAttachmentPath</code> returns
* a non-<code>null</code> value.
*/
- protected IPath sourceAttachmentRootPath;
+ public IPath sourceAttachmentRootPath;
/**
+ * Specific output location (for this source entry)
+ */
+ public IPath specificOutputLocation;
+
+ /**
* A constant indicating an output location.
*/
- protected static final int K_OUTPUT = 10;
+ public static final int K_OUTPUT = 10;
/**
* The export flag
*/
- protected boolean isExported;
+ public boolean isExported;
/**
* Creates a class path entry of the specified kind with the given path.
@@ -94,18 +120,186 @@
int contentKind,
int entryKind,
IPath path,
+ IPath[] exclusionPatterns,
IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath,
+ IPath specificOutputLocation,
boolean isExported) {
this.contentKind = contentKind;
this.entryKind = entryKind;
this.path = path;
+ this.exclusionPatterns = exclusionPatterns;
+ if (exclusionPatterns.length > 0) {
+ this.fullCharExclusionPatterns = UNINIT_PATTERNS;
+ }
this.sourceAttachmentPath = sourceAttachmentPath;
this.sourceAttachmentRootPath = sourceAttachmentRootPath;
+ this.specificOutputLocation = specificOutputLocation;
this.isExported = isExported;
}
+ /*
+ * Returns a char based representation of the exclusions patterns full path.
+ */
+ public char[][] fullExclusionPatternChars() {
+
+ if (this.fullCharExclusionPatterns == UNINIT_PATTERNS) {
+ int length = this.exclusionPatterns.length;
+ this.fullCharExclusionPatterns = new char[length][];
+ IPath prefixPath = path.removeTrailingSeparator();
+ for (int i = 0; i < length; i++) {
+ this.fullCharExclusionPatterns[i] =
+ prefixPath.append(this.exclusionPatterns[i]).toString().toCharArray();
+ }
+ }
+ return this.fullCharExclusionPatterns;
+ }
+
+ /**
+ * Returns the XML encoding of the class path.
+ */
+ public Element elementEncode(
+ Document document,
+ IPath projectPath)
+ throws JavaModelException {
+
+ Element element = document.createElement("classpathentry"); //$NON-NLS-1$
+ element.setAttribute("kind", kindToString(this.entryKind)); //$NON-NLS-1$
+ IPath xmlPath = this.path;
+ if (this.entryKind != IClasspathEntry.CPE_VARIABLE && this.entryKind != IClasspathEntry.CPE_CONTAINER) {
+ // translate to project relative from absolute (unless a device path)
+ if (xmlPath.isAbsolute()) {
+ if (projectPath != null && projectPath.isPrefixOf(xmlPath)) {
+ if (xmlPath.segment(0).equals(projectPath.segment(0))) {
+ xmlPath = xmlPath.removeFirstSegments(1);
+ xmlPath = xmlPath.makeRelative();
+ } else {
+ xmlPath = xmlPath.makeAbsolute();
+ }
+ }
+ }
+ }
+ element.setAttribute("path", xmlPath.toString()); //$NON-NLS-1$
+ if (this.sourceAttachmentPath != null) {
+ element.setAttribute("sourcepath", this.sourceAttachmentPath.toString()); //$NON-NLS-1$
+ }
+ if (this.sourceAttachmentRootPath != null) {
+ element.setAttribute("rootpath", this.sourceAttachmentRootPath.toString()); //$NON-NLS-1$
+ }
+ if (this.isExported) {
+ element.setAttribute("exported", "true"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ if (this.exclusionPatterns.length > 0) {
+ StringBuffer excludeRule = new StringBuffer(10);
+ for (int i = 0, max = this.exclusionPatterns.length; i < max; i++){
+ if (i > 0) excludeRule.append('|');
+ excludeRule.append(this.exclusionPatterns[i]);
+ }
+ element.setAttribute("excluding", excludeRule.toString()); //$NON-NLS-1$
+ }
+
+ if (this.specificOutputLocation != null) {
+ IPath outputLocation = this.specificOutputLocation.removeFirstSegments(1);
+ outputLocation = outputLocation.makeRelative();
+ element.setAttribute("output", outputLocation.toString()); //$NON-NLS-1$
+ }
+ return element;
+ }
+
+ public static IClasspathEntry elementDecode(Element element, IJavaProject project) {
+
+ IPath projectPath = project.getProject().getFullPath();
+ String kindAttr = element.getAttribute("kind"); //$NON-NLS-1$
+ String pathAttr = element.getAttribute("path"); //$NON-NLS-1$
+
+ // ensure path is absolute
+ IPath path = new Path(pathAttr);
+ int kind = kindFromString(kindAttr);
+ if (kind != IClasspathEntry.CPE_VARIABLE && kind != IClasspathEntry.CPE_CONTAINER && !path.isAbsolute()) {
+ path = projectPath.append(path);
+ }
+ // source attachment info (optional)
+ IPath sourceAttachmentPath =
+ element.hasAttribute("sourcepath") //$NON-NLS-1$
+ ? new Path(element.getAttribute("sourcepath")) //$NON-NLS-1$
+ : null;
+ IPath sourceAttachmentRootPath =
+ element.hasAttribute("rootpath") //$NON-NLS-1$
+ ? new Path(element.getAttribute("rootpath")) //$NON-NLS-1$
+ : null;
+
+ // exported flag (optional)
+ boolean isExported = element.getAttribute("exported").equals("true"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // exclusion patterns (optional)
+ String exclusion = element.getAttribute("excluding"); //$NON-NLS-1$
+ IPath[] exclusionPatterns = ClasspathEntry.NO_EXCLUSION_PATTERNS;
+ if (!exclusion.equals("")) { //$NON-NLS-1$
+ char[][] patterns = CharOperation.splitOn('|', exclusion.toCharArray());
+ int patternCount;
+ if ((patternCount = patterns.length) > 0) {
+ exclusionPatterns = new IPath[patternCount];
+ for (int j = 0; j < patterns.length; j++){
+ exclusionPatterns[j] = new Path(new String(patterns[j]));
+ }
+ }
+ }
+
+ // custom output location
+ IPath outputLocation = element.hasAttribute("output") ? projectPath.append(element.getAttribute("output")) : null; //$NON-NLS-1$ //$NON-NLS-2$
+
+ // recreate the CP entry
+ switch (kind) {
+
+ case IClasspathEntry.CPE_PROJECT :
+ return JavaCore.newProjectEntry(path, isExported);
+
+ case IClasspathEntry.CPE_LIBRARY :
+ return JavaCore.newLibraryEntry(
+ path,
+ sourceAttachmentPath,
+ sourceAttachmentRootPath,
+ isExported);
+
+ case IClasspathEntry.CPE_SOURCE :
+ // must be an entry in this project or specify another project
+ String projSegment = path.segment(0);
+ if (projSegment != null && projSegment.equals(project.getElementName())) { // this project
+ return JavaCore.newSourceEntry(path, exclusionPatterns, outputLocation);
+ } else { // another project
+ return JavaCore.newProjectEntry(path, isExported);
+ }
+
+ case IClasspathEntry.CPE_VARIABLE :
+ return JavaCore.newVariableEntry(
+ path,
+ sourceAttachmentPath,
+ sourceAttachmentRootPath,
+ isExported);
+
+ case IClasspathEntry.CPE_CONTAINER :
+ return JavaCore.newContainerEntry(
+ path,
+ isExported);
+
+ case ClasspathEntry.K_OUTPUT :
+ if (!path.isAbsolute()) return null;
+ return new ClasspathEntry(
+ ClasspathEntry.K_OUTPUT,
+ IClasspathEntry.CPE_LIBRARY,
+ path,
+ ClasspathEntry.NO_EXCLUSION_PATTERNS,
+ null, // source attachment
+ null, // source attachment root
+ null, // custom output location
+ false);
+ default :
+ throw new Assert.AssertionFailedException(Util.bind("classpath.unknownKind", kindAttr)); //$NON-NLS-1$
+ }
+ }
+
/**
* Returns true if the given object is a classpath entry
* with equivalent attributes.
@@ -146,6 +340,27 @@
return false;
}
+ IPath[] otherExcludes = otherEntry.getExclusionPatterns();
+ if (this.exclusionPatterns != otherExcludes){
+ int excludeLength = this.exclusionPatterns.length;
+ if (otherExcludes.length != excludeLength)
+ return false;
+ for (int i = 0; i < excludeLength; i++) {
+ // compare toStrings instead of IPaths
+ // since IPath.equals is specified to ignore trailing separators
+ if (!this.exclusionPatterns[i].toString().equals(otherExcludes[i].toString()))
+ return false;
+ }
+ }
+
+ otherPath = otherEntry.getOutputLocation();
+ if (this.specificOutputLocation == null) {
+ if (otherPath != null)
+ return false;
+ } else {
+ if (!this.specificOutputLocation.equals(otherPath))
+ return false;
+ }
return true;
} else {
return false;
@@ -167,6 +382,20 @@
}
/**
+ * @see IClasspathEntry#getExclusionPatterns()
+ */
+ public IPath[] getExclusionPatterns() {
+ return this.exclusionPatterns;
+ }
+
+ /**
+ * @see IClasspathEntry#getOutputLocation()
+ */
+ public IPath getOutputLocation() {
+ return this.specificOutputLocation;
+ }
+
+ /**
* @see IClasspathEntry
*/
public IPath getPath() {
@@ -202,6 +431,49 @@
}
/**
+ * Returns the kind of a <code>PackageFragmentRoot</code> from its <code>String</code> form.
+ */
+ static int kindFromString(String kindStr) {
+
+ if (kindStr.equalsIgnoreCase("prj")) //$NON-NLS-1$
+ return IClasspathEntry.CPE_PROJECT;
+ if (kindStr.equalsIgnoreCase("var")) //$NON-NLS-1$
+ return IClasspathEntry.CPE_VARIABLE;
+ if (kindStr.equalsIgnoreCase("con")) //$NON-NLS-1$
+ return IClasspathEntry.CPE_CONTAINER;
+ if (kindStr.equalsIgnoreCase("src")) //$NON-NLS-1$
+ return IClasspathEntry.CPE_SOURCE;
+ if (kindStr.equalsIgnoreCase("lib")) //$NON-NLS-1$
+ return IClasspathEntry.CPE_LIBRARY;
+ if (kindStr.equalsIgnoreCase("output")) //$NON-NLS-1$
+ return ClasspathEntry.K_OUTPUT;
+ return -1;
+ }
+
+ /**
+ * Returns a <code>String</code> for the kind of a class path entry.
+ */
+ static String kindToString(int kind) {
+
+ switch (kind) {
+ case IClasspathEntry.CPE_PROJECT :
+ return "src"; // backward compatibility //$NON-NLS-1$
+ case IClasspathEntry.CPE_SOURCE :
+ return "src"; //$NON-NLS-1$
+ case IClasspathEntry.CPE_LIBRARY :
+ return "lib"; //$NON-NLS-1$
+ case IClasspathEntry.CPE_VARIABLE :
+ return "var"; //$NON-NLS-1$
+ case IClasspathEntry.CPE_CONTAINER :
+ return "con"; //$NON-NLS-1$
+ case ClasspathEntry.K_OUTPUT :
+ return "output"; //$NON-NLS-1$
+ default :
+ return "unknown"; //$NON-NLS-1$
+ }
+ }
+
+ /**
* Returns a printable representation of this classpath entry.
*/
public String toString() {
@@ -251,6 +523,23 @@
buffer.append("[isExported:"); //$NON-NLS-1$
buffer.append(this.isExported);
buffer.append(']');
+ IPath[] patterns = getExclusionPatterns();
+ int length;
+ if ((length = patterns.length) > 0) {
+ buffer.append("[excluding:"); //$NON-NLS-1$
+ for (int i = 0; i < length; i++) {
+ buffer.append(patterns[i]);
+ if (i != length-1) {
+ buffer.append('|');
+ }
+ }
+ buffer.append(']');
+ }
+ if (getOutputLocation() != null) {
+ buffer.append("[output:"); //$NON-NLS-1$
+ buffer.append(getOutputLocation());
+ buffer.append(']');
+ }
return buffer.toString();
}
@@ -259,21 +548,30 @@
* fragment root computations
*/
public String rootID(){
- StringBuffer buffer = new StringBuffer(10);
- buffer.append('[');
- switch(this.entryKind){
- case IClasspathEntry.CPE_LIBRARY :
- return "[LIB]"+this.path; //$NON-NLS-1$
- case IClasspathEntry.CPE_PROJECT :
- return "[PRJ]"+this.path; //$NON-NLS-1$
- case IClasspathEntry.CPE_SOURCE :
- return "[SRC]"+this.path; //$NON-NLS-1$
- case IClasspathEntry.CPE_VARIABLE :
- return "[VAR]"+this.path; //$NON-NLS-1$
- case IClasspathEntry.CPE_CONTAINER :
- return "[CON]"+this.path; //$NON-NLS-1$
+
+ if (this.rootID == null) {
+ switch(this.entryKind){
+ case IClasspathEntry.CPE_LIBRARY :
+ this.rootID = "[LIB]"+this.path; //$NON-NLS-1$
+ break;
+ case IClasspathEntry.CPE_PROJECT :
+ this.rootID = "[PRJ]"+this.path; //$NON-NLS-1$
+ break;
+ case IClasspathEntry.CPE_SOURCE :
+ this.rootID = "[SRC]"+this.path; //$NON-NLS-1$
+ break;
+ case IClasspathEntry.CPE_VARIABLE :
+ this.rootID = "[VAR]"+this.path; //$NON-NLS-1$
+ break;
+ case IClasspathEntry.CPE_CONTAINER :
+ this.rootID = "[CON]"+this.path; //$NON-NLS-1$
+ break;
+ default :
+ this.rootID = ""; //$NON-NLS-1$
+ break;
+ }
}
- return ""; //$NON-NLS-1$
+ return this.rootID;
}
/**
@@ -284,5 +582,4 @@
return JavaCore.getResolvedClasspathEntry(this);
}
-
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CommitWorkingCopyOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CommitWorkingCopyOperation.java
index 76b1663..82d9ab7 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CommitWorkingCopyOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CommitWorkingCopyOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.resources.IResource;
@@ -16,8 +16,6 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModelStatus;
import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IPackageDeclaration;
-import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaModelException;
/**
@@ -46,133 +44,102 @@
* containing the compilation unit).
*/
public class CommitWorkingCopyOperation extends JavaModelOperation {
-/**
- * Constructs an operation to commit the contents of a working copy
- * to its original compilation unit.
- */
-public CommitWorkingCopyOperation(ICompilationUnit element, boolean force) {
- super(new IJavaElement[] {element}, force);
-}
-/**
- * Checks that the package declaration in the compilation unit matches the actual
- * package fragment the CU is defined in.
- *
- * @exception JavaModelException with an <code>INVALID_PACKAGE</code> JavaModelStatus if the
- * package declaration is invalid.
- * @see IJavaModelStatusConstants.INVALID_PACKAGE
- */
-private void checkPackageDeclaration(ICompilationUnit cu)
- throws JavaModelException {
- IPackageFragment frag = (IPackageFragment) cu.getParent();
- IPackageDeclaration[] decls = cu.getPackageDeclarations();
- String pkgName = frag.getElementName();
- if (pkgName.equals(IPackageFragment.DEFAULT_PACKAGE_NAME)) {
- if (decls != null && decls.length > 0) {
- throw new JavaModelException(
- new JavaModelStatus(
- IJavaModelStatusConstants.INVALID_PACKAGE,
- cu,
- decls[0].getElementName()));
- }
- } else {
- if (decls == null
- || decls.length != 1
- || !pkgName.equals(decls[0].getElementName())) {
- throw new JavaModelException(
- new JavaModelStatus(
- IJavaModelStatusConstants.INVALID_PACKAGE,
- cu,
- (decls == null || decls.length == 0) ? IPackageFragment.DEFAULT_PACKAGE_NAME : decls[0].getElementName()));
- }
+ /**
+ * Constructs an operation to commit the contents of a working copy
+ * to its original compilation unit.
+ */
+ public CommitWorkingCopyOperation(ICompilationUnit element, boolean force) {
+ super(new IJavaElement[] {element}, force);
}
-}
-/**
- * @exception JavaModelException if setting the source
- * of the original compilation unit fails
- */
-protected void executeOperation() throws JavaModelException {
- try {
- beginTask(Util.bind("workingCopy.commit"), 2); //$NON-NLS-1$
- WorkingCopy copy = (WorkingCopy)getCompilationUnit();
- ICompilationUnit original = (ICompilationUnit) copy.getOriginalElement();
-
-
- // creates the delta builder (this remembers the content of the cu)
- if (!original.isOpen()) {
- // force opening so that the delta builder can get the old info
- original.open(null);
- }
- JavaElementDeltaBuilder deltaBuilder = new JavaElementDeltaBuilder(original);
-
- // save the cu
- IBuffer originalBuffer = original.getBuffer();
- if (originalBuffer == null) return;
- char[] originalContents = originalBuffer.getCharacters();
- boolean hasSaved = false;
+ /**
+ * @exception JavaModelException if setting the source
+ * of the original compilation unit fails
+ */
+ protected void executeOperation() throws JavaModelException {
try {
- IBuffer copyBuffer = copy.getBuffer();
- if (copyBuffer == null) return;
- originalBuffer.setContents(copyBuffer.getCharacters());
- original.save(fMonitor, fForce);
- this.hasModifiedResource = true;
- hasSaved = true;
- } finally {
- if (!hasSaved){
- // restore original buffer contents since something went wrong
- originalBuffer.setContents(originalContents);
+ beginTask(Util.bind("workingCopy.commit"), 2); //$NON-NLS-1$
+ WorkingCopy copy = (WorkingCopy)getCompilationUnit();
+ ICompilationUnit original = (ICompilationUnit) copy.getOriginalElement();
+
+
+ // creates the delta builder (this remembers the content of the cu)
+ if (!original.isOpen()) {
+ // force opening so that the delta builder can get the old info
+ original.open(null);
}
+ JavaElementDeltaBuilder deltaBuilder;
+ if (Util.isExcluded(original)) {
+ deltaBuilder = null;
+ } else {
+ deltaBuilder = new JavaElementDeltaBuilder(original);
+ }
+
+ // save the cu
+ IBuffer originalBuffer = original.getBuffer();
+ if (originalBuffer == null) return;
+ char[] originalContents = originalBuffer.getCharacters();
+ boolean hasSaved = false;
+ try {
+ IBuffer copyBuffer = copy.getBuffer();
+ if (copyBuffer == null) return;
+ originalBuffer.setContents(copyBuffer.getCharacters());
+ original.save(fMonitor, fForce);
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ hasSaved = true;
+ } finally {
+ if (!hasSaved){
+ // restore original buffer contents since something went wrong
+ originalBuffer.setContents(originalContents);
+ }
+ }
+ // make sure working copy is in sync
+ copy.updateTimeStamp((CompilationUnit)original);
+ copy.makeConsistent(this);
+ worked(1);
+
+ if (deltaBuilder != null) {
+ // build the deltas
+ deltaBuilder.buildDeltas();
+
+ // add the deltas to the list of deltas created during this operation
+ if (deltaBuilder.delta != null) {
+ addDelta(deltaBuilder.delta);
+ }
+ }
+ worked(1);
+ } finally {
+ done();
}
- // make sure working copy is in sync
- copy.updateTimeStamp((CompilationUnit)original);
- copy.makeConsistent(this);
- worked(1);
-
- // build the deltas
- deltaBuilder.buildDeltas();
-
- // add the deltas to the list of deltas created during this operation
- if (deltaBuilder.delta != null) {
- addDelta(deltaBuilder.delta);
+ }
+ /**
+ * Returns the compilation unit this operation is working on.
+ */
+ protected ICompilationUnit getCompilationUnit() {
+ return (ICompilationUnit)getElementToProcess();
+ }
+ /**
+ * Possible failures: <ul>
+ * <li>INVALID_ELEMENT_TYPES - the compilation unit supplied to this
+ * operation is not a working copy
+ * <li>ELEMENT_NOT_PRESENT - the compilation unit the working copy is
+ * based on no longer exists.
+ * <li>UPDATE_CONFLICT - the original compilation unit has changed since
+ * the working copy was created and the operation specifies no force
+ * <li>READ_ONLY - the original compilation unit is in read-only mode
+ * </ul>
+ */
+ public IJavaModelStatus verify() {
+ ICompilationUnit cu = getCompilationUnit();
+ if (!cu.isWorkingCopy()) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, cu);
}
- worked(1);
- } finally {
- done();
+ ICompilationUnit original= (ICompilationUnit)cu.getOriginalElement();
+ IResource resource = original.getResource();
+ if (!cu.isBasedOn(resource) && !fForce) {
+ return new JavaModelStatus(IJavaModelStatusConstants.UPDATE_CONFLICT);
+ }
+ // no read-only check, since some repository adapters can change the flag on save
+ // operation.
+ return JavaModelStatus.VERIFIED_OK;
}
}
-/**
- * Returns the compilation unit this operation is working on.
- */
-protected ICompilationUnit getCompilationUnit() {
- return (ICompilationUnit)getElementToProcess();
-}
-/**
- * Possible failures: <ul>
- * <li>INVALID_ELEMENT_TYPES - the compilation unit supplied to this
- * operation is not a working copy
- * <li>ELEMENT_NOT_PRESENT - the compilation unit the working copy is
- * based on no longer exists.
- * <li>UPDATE_CONFLICT - the original compilation unit has changed since
- * the working copy was created and the operation specifies no force
- * <li>READ_ONLY - the original compilation unit is in read-only mode
- * </ul>
- */
-public IJavaModelStatus verify() {
- ICompilationUnit cu = getCompilationUnit();
- if (!cu.isWorkingCopy()) {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, cu);
- }
- ICompilationUnit original= (ICompilationUnit)cu.getOriginalElement();
- IResource resource= null;
- try {
- resource = original.getUnderlyingResource();
- } catch (JavaModelException e) {
- return e.getJavaModelStatus();
- }
- if (!cu.isBasedOn(resource) && !fForce) {
- return new JavaModelStatus(IJavaModelStatusConstants.UPDATE_CONFLICT);
- }
- // no read-only check, since some repository adapters can change the flag on save
- // operation.
- return JavaModelStatus.VERIFIED_OK;
-}
-}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java
index 559d692..71803de 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnit.java
@@ -1,50 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.*;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.IBufferFactory;
-import org.eclipse.jdt.core.ICodeCompletionRequestor;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.ICompletionRequestor;
-import org.eclipse.jdt.core.IImportContainer;
-import org.eclipse.jdt.core.IImportDeclaration;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaModelMarker;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageDeclaration;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IProblemRequestor;
-import org.eclipse.jdt.core.ISourceRange;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.jdom.IDOMNode;
import org.eclipse.jdt.internal.compiler.IAbstractSyntaxTreeVisitor;
@@ -52,6 +23,7 @@
import org.eclipse.jdt.internal.compiler.SourceElementParser;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
+
/**
* @see ICompilationUnit
*/
@@ -59,6 +31,9 @@
public class CompilationUnit extends Openable implements ICompilationUnit, org.eclipse.jdt.internal.compiler.env.ICompilationUnit {
public static boolean SHARED_WC_VERBOSE = false;
+
+ // TODO: Remove when we are certain that every client is ready for this fix
+ public static final boolean FIX_BUG25184 = true;
/**
* Constructs a handle to a compilation unit with the given name in the
@@ -99,23 +74,13 @@
removeInfo();
HashMap newElements = new HashMap(11);
- info.setIsStructureKnown(generateInfos(info, monitor, newElements, getUnderlyingResource()));
+ info.setIsStructureKnown(generateInfos(info, monitor, newElements, getResource()));
JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().remove(this);
for (Iterator iter = newElements.keySet().iterator(); iter.hasNext();) {
IJavaElement key = (IJavaElement) iter.next();
Object value = newElements.get(key);
JavaModelManager.getJavaModelManager().putInfo(key, value);
}
- // problem detection
- if (monitor != null && monitor.isCanceled()) return;
-
- IProblemRequestor problemRequestor = this.getProblemRequestor();
- if (problemRequestor != null && problemRequestor.isActive()){
- problemRequestor.beginReporting();
- CompilationUnitProblemFinder.resolve(this, problemRequestor, monitor);
- problemRequestor.endReporting();
- }
-
// add the info for this at the end, to ensure that a getInfo cannot reply null in case the LRU cache needs
// to be flushed. Might lead to performance issues.
// see PR 1G2K5S7: ITPJCORE:ALL - NPE when accessing source for a binary type
@@ -343,14 +308,13 @@
// generate structure
CompilationUnitStructureRequestor requestor = new CompilationUnitStructureRequestor(this, unitInfo, newElements);
IProblemFactory factory = new DefaultProblemFactory();
- SourceElementParser parser = new SourceElementParser(requestor, factory, new CompilerOptions(JavaCore.getOptions()));
+ SourceElementParser parser = new SourceElementParser(requestor, factory, new CompilerOptions(getJavaProject().getOptions(true)));
+ requestor.parser = parser;
parser.parseCompilationUnit(this, false);
if (isWorkingCopy()) {
CompilationUnit original = (CompilationUnit) getOriginalElement();
- unitInfo.fTimestamp = ((IFile) original.getUnderlyingResource()).getModificationStamp();
- if(unitInfo.fTimestamp == IResource.NULL_STAMP){
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_RESOURCE));
- }
+ // might be IResource.NULL_STAMP if original does not exist
+ unitInfo.fTimestamp = ((IFile) original.getResource()).getModificationStamp();
}
return unitInfo.isStructureKnown();
}
@@ -392,10 +356,8 @@
try {
IBuffer buffer = this.getBuffer();
return buffer == null ? null : buffer.getCharacters();
- } catch (NullPointerException e) { // buffer could be null
- return new char[0];
} catch (JavaModelException e) {
- return new char[0];
+ return CharOperation.NO_CHAR;
}
}
/**
@@ -533,13 +495,6 @@
}
}
-/*
- * Answer requestor to notify with problems
- */
-public IProblemRequestor getProblemRequestor(){
- return null;
-}
-
/**
* @see ISourceReference#getSource()
*/
@@ -569,6 +524,13 @@
list.toArray(array);
return array;
}
+public IResource getUnderlyingResource() throws JavaModelException {
+ if (FIX_BUG25184) {
+ return super.getUnderlyingResource();
+ } else {
+ return getResource();
+ }
+}
/**
* @see IWorkingCopy#getSharedWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)
*/
@@ -599,19 +561,9 @@
return workingCopy;
} else {
- workingCopy = (WorkingCopy)this.getWorkingCopy(pm, factory, problemRequestor);
- perFactoryWorkingCopies.put(this, workingCopy);
-
- if (SHARED_WC_VERBOSE) {
- System.out.println("Creating shared working copy " + workingCopy.toStringWithAncestors()); //$NON-NLS-1$
- }
-
- // report added java delta
- JavaElementDelta delta = new JavaElementDelta(this.getJavaModel());
- delta.added(workingCopy);
- manager.fire(delta, JavaModelManager.DEFAULT_CHANGE_EVENT);
-
- return workingCopy;
+ CreateWorkingCopyOperation op = new CreateWorkingCopyOperation(this, perFactoryWorkingCopies, factory, problemRequestor);
+ runOperation(op, pm);
+ return op.getResultElements()[0];
}
}
/**
@@ -625,10 +577,9 @@
* @see IWorkingCopy#getWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)
*/
public IJavaElement getWorkingCopy(IProgressMonitor pm, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException {
- WorkingCopy workingCopy = new WorkingCopy((IPackageFragment)getParent(), getElementName(), factory, problemRequestor);
- // open the working copy now to ensure contents are that of the current state of this element
- workingCopy.open(pm);
- return workingCopy;
+ CreateWorkingCopyOperation op = new CreateWorkingCopyOperation(this, null, factory, problemRequestor);
+ runOperation(op, pm);
+ return op.getResultElements()[0];
}
/**
@@ -678,11 +629,11 @@
/**
* @see IOpenable#makeConsistent(IProgressMonitor)
*/
-public void makeConsistent(IProgressMonitor pm) throws JavaModelException {
- if (!isConsistent()) {
+public void makeConsistent(IProgressMonitor monitor) throws JavaModelException {
+ if (!isConsistent()) { // TODO: this code isn't synchronized with regular opening of a working copy
// create a new info and make it the current info
OpenableElementInfo info = createElementInfo();
- buildStructure(info, pm);
+ buildStructure(info, monitor);
}
}
@@ -704,45 +655,6 @@
}
/**
- * Changes the source end index of this element and all children (following
- * <code>child</code>).
- */
-public void offsetSourceEndAndChildren(int amount, IJavaElement child) {
- try {
- CompilationUnitElementInfo cuInfo = (CompilationUnitElementInfo) getElementInfo();
- cuInfo.setSourceLength(cuInfo.getSourceLength() + amount);
- IJavaElement[] children = getChildren();
- boolean afterChild = false;
- for (int i = 0; i < children.length; i++) {
- IJavaElement aChild = children[i];
- if (child == null || aChild.equals(child)) {
- afterChild = true;
- } else
- if (afterChild) {
- ((JavaElement) aChild).offsetSourceRange(amount);
- }
- }
- } catch (JavaModelException npe) {
- return;
- }
-}
-/**
- * Changes the source indexes of this element and all children elements.
- */
-public void offsetSourceRange(int amount) {
- try {
- CompilationUnitElementInfo cuInfo = (CompilationUnitElementInfo) getElementInfo();
- cuInfo.setSourceLength(cuInfo.getSourceLength() + amount);
- IJavaElement[] children = getChildren();
- for (int i = 0; i < children.length; i++) {
- IJavaElement aChild = children[i];
- ((JavaElement) aChild).offsetSourceRange(amount);
- }
- } catch (JavaModelException npe) {
- return;
- }
-}
-/**
* @see Openable#openBuffer(IProgressMonitor)
*/
protected IBuffer openBuffer(IProgressMonitor pm) throws JavaModelException {
@@ -754,7 +666,9 @@
// set the buffer source
if (buffer.getCharacters() == null){
- buffer.setContents(Util.getResourceContentsAsCharArray((IFile)this.getResource()));
+ IFile file = (IFile)this.getResource();
+ if (file == null || !file.exists()) throw newNotPresentException();
+ buffer.setContents(Util.getResourceContentsAsCharArray(file));
}
// add buffer to buffer cache
@@ -765,27 +679,26 @@
return buffer;
}
-/*
- * @see Openable#openParent(IProgressMonitor)
- */
protected void openParent(IProgressMonitor pm) throws JavaModelException {
- try {
+ if (FIX_BUG25184) {
super.openParent(pm);
- } catch(JavaModelException e){
- // allow parent to not exist for fake units defined outside classpath
- // will be ok for both working copies and compilation units
- if (!e.isDoesNotExist()){
- throw e;
+ } else {
+ try {
+ super.openParent(pm);
+ } catch(JavaModelException e){
+ // allow parent to not exist for compilation units defined outside classpath
+ if (!e.isDoesNotExist()){
+ throw e;
+ }
}
}
}
-/**
- * Answers true if the parent exists (null parent is answering true)
- *
- */
-protected boolean parentExists(){
-
- return true; // tolerate units outside classpath
+protected boolean parentExists() {
+ if (FIX_BUG25184) {
+ return super.parentExists();
+ } else {
+ return true; // tolerate units outside classpath
+ }
}
/**
@@ -826,23 +739,6 @@
public void restore () throws JavaModelException {
}
/**
- * Updates the source end index for this element.
- */
-public void triggerSourceEndOffset(int amount, int nameStart, int nameEnd) {
- try {
- CompilationUnitElementInfo cuInfo = (CompilationUnitElementInfo) getRawInfo();
- cuInfo.setSourceLength(cuInfo.getSourceLength() + amount);
- } catch (JavaModelException npe) {
- return;
- }
-}
-/**
- * Updates the source indexes for this element.
- */
-public void triggerSourceRangeOffset(int amount, int nameStart, int nameEnd) {
- triggerSourceEndOffset(amount, nameStart, nameEnd);
-}
-/**
* @see ICodeAssist#codeComplete(int, ICodeCompletionRequestor)
* @deprecated - use codeComplete(int, ICompletionRequestor)
*/
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitElementInfo.java
index 2936356..e1e140e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitElementInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.ISourceRange;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java
index 76241cf..ca389c8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitProblemFinder.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.Locale;
@@ -15,15 +15,12 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IProblemRequestor;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.Compiler;
-import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
import org.eclipse.jdt.internal.compiler.IProblemFactory;
@@ -34,7 +31,6 @@
import org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* Responsible for resolving types inside a compilation unit being reconciled,
@@ -91,14 +87,20 @@
* Add additional source types
*/
public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding) {
+ // ensure to jump back to toplevel type for first one (could be a member)
+// while (sourceTypes[0].getEnclosingType() != null)
+// sourceTypes[0] = sourceTypes[0].getEnclosingType();
+
CompilationResult result =
new CompilationResult(sourceTypes[0].getFileName(), 1, 1, this.options.maxProblemsPerUnit);
+
// need to hold onto this
CompilationUnitDeclaration unit =
SourceTypeConverter.buildCompilationUnit(
- sourceTypes,
- true,
- true,
+ sourceTypes,//sourceTypes[0] is always toplevel here
+ true, // need field and methods
+ true, // need member types
+ true, // need field initialization
lookupEnvironment.problemReporter,
result);
@@ -131,46 +133,6 @@
};
}
- public static CompilationUnitDeclaration resolve(
- ICompilationUnit unitElement,
- IProblemRequestor problemRequestor,
- IProgressMonitor monitor)
- throws JavaModelException {
-
- char[] fileName = unitElement.getElementName().toCharArray();
-
- CompilationUnitProblemFinder problemFinder =
- new CompilationUnitProblemFinder(
- getNameEnvironment(unitElement),
- getHandlingPolicy(),
- JavaCore.getOptions(),
- getRequestor(),
- getProblemFactory(fileName, problemRequestor, monitor));
-
- CompilationUnitDeclaration unit = null;
- try {
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
-
- IPackageFragment packageFragment = (IPackageFragment)unitElement.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
- char[][] expectedPackageName = null;
- if (packageFragment != null){
- expectedPackageName = CharOperation.splitOn('.', packageFragment.getElementName().toCharArray());
- }
- unit = problemFinder.resolve(
- new BasicCompilationUnit(
- unitElement.getSource().toCharArray(),
- expectedPackageName,
- new String(fileName),
- encoding));
- return unit;
- } finally {
- if (unit != null) {
- unit.cleanUp();
- }
- problemFinder.lookupEnvironment.reset();
- }
- }
-
protected static IProblemFactory getProblemFactory(
final char[] fileName,
final IProblemRequestor problemRequestor,
@@ -180,7 +142,8 @@
public IProblem createProblem(
char[] originatingFileName,
int problemId,
- String[] arguments,
+ String[] problemArguments,
+ String[] messageArguments,
int severity,
int startPosition,
int endPosition,
@@ -194,7 +157,8 @@
super.createProblem(
originatingFileName,
problemId,
- arguments,
+ problemArguments,
+ messageArguments,
severity,
startPosition,
endPosition,
@@ -215,5 +179,48 @@
};
}
+ public static CompilationUnitDeclaration process(
+ ICompilationUnit unitElement,
+ IProblemRequestor problemRequestor,
+ IProgressMonitor monitor)
+ throws JavaModelException {
+
+ char[] fileName = unitElement.getElementName().toCharArray();
+
+ IJavaProject project = unitElement.getJavaProject();
+ CompilationUnitProblemFinder problemFinder =
+ new CompilationUnitProblemFinder(
+ getNameEnvironment(unitElement),
+ getHandlingPolicy(),
+ project.getOptions(true),
+ getRequestor(),
+ getProblemFactory(fileName, problemRequestor, monitor));
+
+ CompilationUnitDeclaration unit = null;
+ try {
+ String encoding = project.getOption(JavaCore.CORE_ENCODING, true);
+
+ IPackageFragment packageFragment = (IPackageFragment)unitElement.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
+ char[][] expectedPackageName = null;
+ if (packageFragment != null){
+ expectedPackageName = CharOperation.splitOn('.', packageFragment.getElementName().toCharArray());
+ }
+ unit = problemFinder.resolve(
+ new BasicCompilationUnit(
+ unitElement.getSource().toCharArray(),
+ expectedPackageName,
+ new String(fileName),
+ encoding),
+ true, // verify methods
+ true, // analyze code
+ true); // generate code
+ return unit;
+ } finally {
+ if (unit != null) {
+ unit.cleanUp();
+ }
+ problemFinder.lookupEnvironment.reset();
+ }
+ }
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java
index f96f437..175f1c3 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java
@@ -1,19 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.Iterator;
import java.util.Map;
import java.util.Stack;
+import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IImportContainer;
@@ -27,6 +28,7 @@
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
+import org.eclipse.jdt.internal.compiler.parser.Parser;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
import org.eclipse.jdt.internal.core.util.ReferenceInfoAdapter;
@@ -104,6 +106,11 @@
*/
protected boolean hasSyntaxErrors = false;
+ /*
+ * The parser this requestor is using.
+ */
+ protected Parser parser;
+
/**
* Empty collections used for efficient initialization
*/
@@ -500,8 +507,26 @@
/**
* @see ISourceElementRequestor
*/
-public void exitField(int declarationEnd) {
- exitMember(declarationEnd);
+public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
+ SourceFieldElementInfo info = (SourceFieldElementInfo) fInfoStack.pop();
+ info.setSourceRangeEnd(declarationSourceEnd);
+
+ // remember initializer source if field is a constant
+ if (initializationStart != -1) {
+ int flags = info.flags;
+ Object typeInfo;
+ if (Flags.isStatic(flags) && Flags.isFinal(flags)
+ || ((typeInfo = fInfoStack.peek()) instanceof SourceTypeElementInfo
+ && (Flags.isInterface(((SourceTypeElementInfo)typeInfo).flags)))) {
+ int length = declarationEnd - initializationStart;
+ if (length > 0) {
+ char[] initializer = new char[length];
+ System.arraycopy(this.parser.scanner.source, initializationStart, initializer, 0, length);
+ info.initializationSource = initializer;
+ }
+ }
+ }
+ fHandleStack.pop();
}
/**
* @see ISourceElementRequestor
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java
index a8c3a95..2664966 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitVisitor.java
@@ -1,23 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.Locale;
import java.util.Map;
+import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.Compiler;
@@ -31,7 +33,6 @@
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
import org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class CompilationUnitVisitor extends Compiler {
@@ -87,9 +88,10 @@
// need to hold onto this
CompilationUnitDeclaration unit =
SourceTypeConverter.buildCompilationUnit(
- sourceTypes,
- true,
- true,
+ sourceTypes,//sourceTypes[0] is always toplevel here
+ true, // need field and methods
+ true, // need member types
+ false, // no need for field initialization
lookupEnvironment.problemReporter,
result);
@@ -136,17 +138,18 @@
IAbstractSyntaxTreeVisitor visitor)
throws JavaModelException {
+ IJavaProject project = unitElement.getJavaProject();
CompilationUnitVisitor compilationUnitVisitor =
new CompilationUnitVisitor(
getNameEnvironment(unitElement),
getHandlingPolicy(),
- JavaCore.getOptions(),
+ project.getOptions(true),
getRequestor(),
getProblemFactory(visitor));
CompilationUnitDeclaration unit = null;
try {
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
+ String encoding = project.getOption(JavaCore.CORE_ENCODING, true);
IPackageFragment packageFragment = (IPackageFragment)unitElement.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
char[][] expectedPackageName = null;
@@ -159,7 +162,10 @@
unitElement.getSource().toCharArray(),
expectedPackageName,
unitElement.getElementName(),
- encoding));
+ encoding),
+ true, // method verification
+ false, // no flow analysis
+ false); // no code generation
if (unit != null) {
unit.traverse(visitor, unit.scope);
}
@@ -176,7 +182,8 @@
public IProblem createProblem(
char[] originatingFileName,
int problemId,
- String[] arguments,
+ String[] problemArguments,
+ String[] messageArguments,
int severity,
int startPosition,
int endPosition,
@@ -186,7 +193,8 @@
super.createProblem(
originatingFileName,
problemId,
- arguments,
+ problemArguments,
+ messageArguments,
severity,
startPosition,
endPosition,
@@ -196,4 +204,4 @@
}
};
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompletionRequestorWrapper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompletionRequestorWrapper.java
index a540a55..f62115a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompletionRequestorWrapper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompletionRequestorWrapper.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.ICompletionRequestor;
@@ -15,9 +15,9 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.codeassist.CompletionEngine;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class CompletionRequestorWrapper implements ICompletionRequestor {
static final char[] ARG = "arg".toCharArray(); //$NON-NLS-1$
@@ -292,7 +292,6 @@
public void acceptVariableName(char[] typePackageName, char[] typeName, char[] name, char[] completionName, int completionStart, int completionEnd, int relevance){
if(CompletionEngine.DEBUG) {
- System.out.println("COMPLETION - acceptVariableName"); //$NON-NLS-1$
printDebug("acceptVariableName", new String[]{ //$NON-NLS-1$
String.valueOf(typePackageName),
String.valueOf(typeName),
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java
index 9a622bc..a718352 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyElementsOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.HashMap;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyPackageFragmentRootOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyPackageFragmentRootOperation.java
new file mode 100644
index 0000000..8593e80
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyPackageFragmentRootOperation.java
@@ -0,0 +1,256 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaModelStatus;
+import org.eclipse.jdt.core.JavaModelException;
+
+public class CopyPackageFragmentRootOperation extends JavaModelOperation {
+ IPath destination;
+ int updateResourceFlags;
+ int updateModelFlags;
+ IClasspathEntry sibling;
+
+ public CopyPackageFragmentRootOperation(
+ IPackageFragmentRoot root,
+ IPath destination,
+ int updateResourceFlags,
+ int updateModelFlags,
+ IClasspathEntry sibling) {
+
+ super(root);
+ this.destination = destination;
+ this.updateResourceFlags = updateResourceFlags;
+ this.updateModelFlags = updateModelFlags;
+ this.sibling = sibling;
+ }
+ protected void executeOperation() throws JavaModelException {
+
+ IPackageFragmentRoot root = (IPackageFragmentRoot)this.getElementToProcess();
+ IClasspathEntry rootEntry = root.getRawClasspathEntry();
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+
+ // copy resource
+ if (!root.isExternal() && (this.updateModelFlags & IPackageFragmentRoot.NO_RESOURCE_MODIFICATION) == 0) {
+ copyResource(root, rootEntry, workspaceRoot);
+ }
+
+ // update classpath if needed
+ if ((this.updateModelFlags & IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH) != 0) {
+ addEntryToClasspath(rootEntry, workspaceRoot);
+ }
+ }
+ protected void copyResource(
+ IPackageFragmentRoot root,
+ IClasspathEntry rootEntry,
+ final IWorkspaceRoot workspaceRoot)
+ throws JavaModelException {
+ final char[][] exclusionPatterns = ((ClasspathEntry)rootEntry).fullExclusionPatternChars();
+ IResource rootResource = root.getResource();
+ if (root.getKind() == IPackageFragmentRoot.K_BINARY || exclusionPatterns == null) {
+ try {
+ IResource destRes;
+ if ((this.updateModelFlags & IPackageFragmentRoot.REPLACE) != 0) {
+ if (rootEntry.getPath().equals(this.destination)) return;
+ if ((destRes = workspaceRoot.findMember(this.destination)) != null) {
+ destRes.delete(this.updateResourceFlags, fMonitor);
+ }
+ }
+ rootResource.copy(this.destination, this.updateResourceFlags, fMonitor);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+ } else {
+ final int sourceSegmentCount = rootEntry.getPath().segmentCount();
+ final IFolder destFolder = workspaceRoot.getFolder(this.destination);
+ final IPath[] nestedFolders = getNestedFolders(root);
+ IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ if (proxy.getType() == IResource.FOLDER) {
+ IPath path = proxy.requestFullPath();
+ if (prefixesOneOf(path, nestedFolders)) {
+ if (equalsOneOf(path, nestedFolders)) {
+ // nested source folder
+ return false;
+ } else {
+ // folder containing nested source folder
+ IFolder folder = destFolder.getFolder(path.removeFirstSegments(sourceSegmentCount));
+ if ((updateModelFlags & IPackageFragmentRoot.REPLACE) != 0
+ && folder.exists()) {
+ return true;
+ }
+ folder.create(updateResourceFlags, true, fMonitor);
+ return true;
+ }
+ } else {
+ // subtree doesn't contain any nested source folders
+ IPath destPath = destination.append(path.removeFirstSegments(sourceSegmentCount));
+ IResource destRes;
+ if ((updateModelFlags & IPackageFragmentRoot.REPLACE) != 0
+ && (destRes = workspaceRoot.findMember(destPath)) != null) {
+ destRes.delete(updateResourceFlags, fMonitor);
+ }
+ proxy.requestResource().copy(destPath, updateResourceFlags, fMonitor);
+ return false;
+ }
+ } else {
+ IPath path = proxy.requestFullPath();
+ IPath destPath = destination.append(path.removeFirstSegments(sourceSegmentCount));
+ IResource destRes;
+ if ((updateModelFlags & IPackageFragmentRoot.REPLACE) != 0
+ && (destRes = workspaceRoot.findMember(destPath)) != null) {
+ destRes.delete(updateResourceFlags, fMonitor);
+ }
+ proxy.requestResource().copy(destPath, updateResourceFlags, fMonitor);
+ return false;
+ }
+ }
+ };
+ try {
+ rootResource.accept(visitor, IResource.NONE);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+ }
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ }
+ protected void addEntryToClasspath(IClasspathEntry rootEntry, IWorkspaceRoot workspaceRoot) throws JavaModelException {
+
+ IProject destProject = workspaceRoot.getProject(this.destination.segment(0));
+ IJavaProject jProject = JavaCore.create(destProject);
+ IClasspathEntry[] classpath = jProject.getRawClasspath();
+ int length = classpath.length;
+ IClasspathEntry[] newClasspath;
+
+ // case of existing entry and REPLACE was specified
+ if ((this.updateModelFlags & IPackageFragmentRoot.REPLACE) != 0) {
+ // find existing entry
+ for (int i = 0; i < length; i++) {
+ if (this.destination.equals(classpath[i].getPath())) {
+ newClasspath = new IClasspathEntry[length];
+ System.arraycopy(classpath, 0, newClasspath, 0, length);
+ newClasspath[i] = copy(rootEntry);
+ jProject.setRawClasspath(newClasspath, fMonitor);
+ return;
+ }
+ }
+ }
+
+ // other cases
+ int position;
+ if (this.sibling == null) {
+ // insert at the end
+ position = length;
+ } else {
+ // insert before sibling
+ position = -1;
+ for (int i = 0; i < length; i++) {
+ if (this.sibling.equals(classpath[i])) {
+ position = i;
+ break;
+ }
+ }
+ }
+ if (position == -1) {
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_SIBLING, this.sibling.toString()));
+ }
+ newClasspath = new IClasspathEntry[length+1];
+ if (position != 0) {
+ System.arraycopy(classpath, 0, newClasspath, 0, position);
+ }
+ if (position != length) {
+ System.arraycopy(classpath, position, newClasspath, position+1, length-position);
+ }
+ IClasspathEntry newEntry = copy(rootEntry);
+ newClasspath[position] = newEntry;
+ jProject.setRawClasspath(newClasspath, fMonitor);
+ }
+ /*
+ * Copies the given classpath entry replacing its path with the destination path
+ * if it is a source folder or a library.
+ */
+ protected IClasspathEntry copy(IClasspathEntry entry) throws JavaModelException {
+ switch (entry.getEntryKind()) {
+ case IClasspathEntry.CPE_CONTAINER:
+ return JavaCore.newContainerEntry(entry.getPath(), entry.isExported());
+ case IClasspathEntry.CPE_LIBRARY:
+ return JavaCore.newLibraryEntry(this.destination, entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.isExported());
+ case IClasspathEntry.CPE_PROJECT:
+ return JavaCore.newProjectEntry(entry.getPath(), entry.isExported());
+ case IClasspathEntry.CPE_SOURCE:
+ return JavaCore.newSourceEntry(this.destination, entry.getExclusionPatterns(), entry.getOutputLocation());
+ case IClasspathEntry.CPE_VARIABLE:
+ return JavaCore.newVariableEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.isExported());
+ default:
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this.getElementToProcess()));
+ }
+ }
+ public IJavaModelStatus verify() {
+ IJavaModelStatus status = super.verify();
+ if (!status.isOK()) {
+ return status;
+ }
+ IPackageFragmentRoot root = (IPackageFragmentRoot)getElementToProcess();
+ if (root == null || !root.exists()) {
+ return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, root);
+ }
+
+ IResource resource = root.getResource();
+ if (resource instanceof IFolder) {
+ if (resource.isLinked()) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_RESOURCE, root);
+ }
+ }
+
+ if ((this.updateModelFlags & IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH) != 0) {
+ String destProjectName = this.destination.segment(0);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(destProjectName);
+ if (JavaProject.hasJavaNature(project)) {
+ try {
+ IJavaProject destProject = JavaCore.create(project);
+ IClasspathEntry[] destClasspath = destProject.getRawClasspath();
+ boolean foundSibling = false;
+ boolean foundExistingEntry = false;
+ for (int i = 0, length = destClasspath.length; i < length; i++) {
+ IClasspathEntry entry = destClasspath[i];
+ if (entry.equals(this.sibling)) {
+ foundSibling = true;
+ break;
+ }
+ if (entry.getPath().equals(this.destination)) {
+ foundExistingEntry = true;
+ }
+ }
+ if (this.sibling != null && !foundSibling) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_SIBLING, this.sibling == null ? "null" : this.sibling.toString()); //$NON-NLS-1$
+ }
+ if (foundExistingEntry && (this.updateModelFlags & IPackageFragmentRoot.REPLACE) == 0) {
+ return new JavaModelStatus(
+ IJavaModelStatusConstants.NAME_COLLISION,
+ Util.bind("status.nameCollision", this.destination.toString())); //$NON-NLS-1$
+ }
+ } catch (JavaModelException e) {
+ return e.getJavaModelStatus();
+ }
+ }
+ }
+
+ return JavaModelStatus.VERIFIED_OK;
+ }
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
index f7ee7ab..ef2fe10 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CopyResourceElementsOperation.java
@@ -1,47 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.*;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.IJavaModelStatus;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.core.jdom.DOMException;
-import org.eclipse.jdt.core.jdom.DOMFactory;
-import org.eclipse.jdt.core.jdom.IDOMCompilationUnit;
-import org.eclipse.jdt.core.jdom.IDOMNode;
-import org.eclipse.jdt.core.jdom.IDOMPackage;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.jdom.*;
import org.eclipse.jdt.internal.compiler.util.Util;
/**
@@ -89,315 +67,395 @@
* The list of new resources created during this operation.
*/
protected ArrayList fCreatedElements;
-/**
- * When executed, this operation will copy the given resources to the
- * given containers. The resources and destination containers must be in
- * the correct order. If there is > 1 destination, the number of destinations
- * must be the same as the number of resources being copied/moved.
- */
-public CopyResourceElementsOperation(IJavaElement[] resourcesToCopy, IJavaElement[] destContainers, boolean force) {
- super(resourcesToCopy, destContainers, force);
- fFactory = new DOMFactory();
-}
-/**
- * When executed, this operation will copy the given resources to the
- * given container.
- */
-public CopyResourceElementsOperation(IJavaElement[] resourcesToCopy, IJavaElement destContainer, boolean force) {
- this(resourcesToCopy, new IJavaElement[]{destContainer}, force);
-}
-/**
- * Returns the children of <code>source</code> which are affected by this operation.
- * If <code>source</code> is a <code>K_SOURCE</code>, these are the <code>.java</code>
- * files, if it is a <code>K_BINARY</code>, they are the <code>.class</code> files.
- */
-private IResource[] collectResourcesOfInterest(IPackageFragment source) throws JavaModelException {
- IJavaElement[] children = source.getChildren();
- int childOfInterest = IJavaElement.COMPILATION_UNIT;
- if (source.getKind() == IPackageFragmentRoot.K_BINARY) {
- childOfInterest = IJavaElement.CLASS_FILE;
+ /**
+ * When executed, this operation will copy the given resources to the
+ * given containers. The resources and destination containers must be in
+ * the correct order. If there is > 1 destination, the number of destinations
+ * must be the same as the number of resources being copied/moved.
+ */
+ public CopyResourceElementsOperation(IJavaElement[] resourcesToCopy, IJavaElement[] destContainers, boolean force) {
+ super(resourcesToCopy, destContainers, force);
+ fFactory = new DOMFactory();
}
- ArrayList correctKindChildren = new ArrayList(children.length);
- for (int i = 0; i < children.length; i++) {
- IJavaElement child = children[i];
- if (child.getElementType() == childOfInterest) {
- correctKindChildren.add(child.getUnderlyingResource());
+ /**
+ * When executed, this operation will copy the given resources to the
+ * given container.
+ */
+ public CopyResourceElementsOperation(IJavaElement[] resourcesToCopy, IJavaElement destContainer, boolean force) {
+ this(resourcesToCopy, new IJavaElement[]{destContainer}, force);
+ }
+ /**
+ * Returns the children of <code>source</code> which are affected by this operation.
+ * If <code>source</code> is a <code>K_SOURCE</code>, these are the <code>.java</code>
+ * files, if it is a <code>K_BINARY</code>, they are the <code>.class</code> files.
+ */
+ private IResource[] collectResourcesOfInterest(IPackageFragment source) throws JavaModelException {
+ IJavaElement[] children = source.getChildren();
+ int childOfInterest = IJavaElement.COMPILATION_UNIT;
+ if (source.getKind() == IPackageFragmentRoot.K_BINARY) {
+ childOfInterest = IJavaElement.CLASS_FILE;
}
- }
- // Gather non-java resources
- Object[] nonJavaResources = source.getNonJavaResources();
- int actualNonJavaResourceCount = 0;
- for (int i = 0, max = nonJavaResources.length; i < max; i++){
- if (nonJavaResources[i] instanceof IResource) actualNonJavaResourceCount++;
- }
- IResource[] actualNonJavaResources = new IResource[actualNonJavaResourceCount];
- for (int i = 0, max = nonJavaResources.length, index = 0; i < max; i++){
- if (nonJavaResources[i] instanceof IResource) actualNonJavaResources[index++] = (IResource)nonJavaResources[i];
- }
-
- if (actualNonJavaResourceCount != 0) {
- int correctKindChildrenSize = correctKindChildren.size();
- IResource[] result = new IResource[correctKindChildrenSize + actualNonJavaResourceCount];
- correctKindChildren.toArray(result);
- System.arraycopy(actualNonJavaResources, 0, result, correctKindChildrenSize, actualNonJavaResourceCount);
- return result;
- } else {
- IResource[] result = new IResource[correctKindChildren.size()];
- correctKindChildren.toArray(result);
- return result;
- }
-}
-/**
- * Creates any destination package fragment(s) which do not exists yet.
- */
-private void createNeededPackageFragments(IPackageFragmentRoot root, String newFragName) throws JavaModelException {
- IContainer parentFolder = (IContainer) root.getUnderlyingResource();
- JavaElementDelta projectDelta = getDeltaFor(root.getJavaProject());
- String[] names = Signature.getSimpleNames(newFragName);
- StringBuffer sideEffectPackageName = new StringBuffer();
- for (int i = 0; i < names.length; i++) {
- String subFolderName = names[i];
- sideEffectPackageName.append(subFolderName);
- IResource subFolder = parentFolder.findMember(subFolderName);
- if (subFolder == null) {
- createFolder(parentFolder, subFolderName, fForce);
- parentFolder = parentFolder.getFolder(new Path(subFolderName));
- IPackageFragment sideEffectPackage = root.getPackageFragment(sideEffectPackageName.toString());
- if (i < names.length - 1) { // all but the last one are side effect packages
- projectDelta.added(sideEffectPackage);
+ ArrayList correctKindChildren = new ArrayList(children.length);
+ for (int i = 0; i < children.length; i++) {
+ IJavaElement child = children[i];
+ if (child.getElementType() == childOfInterest) {
+ correctKindChildren.add(child.getResource());
}
- fCreatedElements.add(sideEffectPackage);
+ }
+ // Gather non-java resources
+ Object[] nonJavaResources = source.getNonJavaResources();
+ int actualNonJavaResourceCount = 0;
+ for (int i = 0, max = nonJavaResources.length; i < max; i++){
+ if (nonJavaResources[i] instanceof IResource) actualNonJavaResourceCount++;
+ }
+ IResource[] actualNonJavaResources = new IResource[actualNonJavaResourceCount];
+ for (int i = 0, max = nonJavaResources.length, index = 0; i < max; i++){
+ if (nonJavaResources[i] instanceof IResource) actualNonJavaResources[index++] = (IResource)nonJavaResources[i];
+ }
+
+ if (actualNonJavaResourceCount != 0) {
+ int correctKindChildrenSize = correctKindChildren.size();
+ IResource[] result = new IResource[correctKindChildrenSize + actualNonJavaResourceCount];
+ correctKindChildren.toArray(result);
+ System.arraycopy(actualNonJavaResources, 0, result, correctKindChildrenSize, actualNonJavaResourceCount);
+ return result;
} else {
- parentFolder = (IContainer) subFolder;
+ IResource[] result = new IResource[correctKindChildren.size()];
+ correctKindChildren.toArray(result);
+ return result;
}
- sideEffectPackageName.append('.');
}
-}
-/**
- * Returns the <code>JavaElementDelta</code> for <code>javaProject</code>,
- * creating it and putting it in <code>fDeltasPerProject</code> if
- * it does not exist yet.
- */
-private JavaElementDelta getDeltaFor(IJavaProject javaProject) {
- JavaElementDelta delta = (JavaElementDelta) fDeltasPerProject.get(javaProject);
- if (delta == null) {
- delta = new JavaElementDelta(javaProject);
- fDeltasPerProject.put(javaProject, delta);
- }
- return delta;
-}
-/**
- * @see MultiOperation
- */
-protected String getMainTaskName() {
- return org.eclipse.jdt.internal.core.Util.bind("operation.copyResourceProgress"); //$NON-NLS-1$
-}
-/**
- * Sets the deltas to register the changes resulting from this operation
- * for this source element and its destination.
- * If the operation is a cross project operation<ul>
- * <li>On a copy, the delta should be rooted in the dest project
- * <li>On a move, two deltas are generated<ul>
- * <li>one rooted in the source project
- * <li>one rooted in the destination project</ul></ul>
- * If the operation is rooted in a single project, the delta is rooted in that project
- *
- */
-protected void prepareDeltas(IJavaElement sourceElement, IJavaElement destinationElement) {
- IJavaProject destProject = destinationElement.getJavaProject();
- if (isMove()) {
- IJavaProject sourceProject = sourceElement.getJavaProject();
- getDeltaFor(sourceProject).movedFrom(sourceElement, destinationElement);
- getDeltaFor(destProject).movedTo(destinationElement, sourceElement);
- } else {
- getDeltaFor(destProject).added(destinationElement);
- }
-}
-/**
- * Copies/moves a compilation unit with the name <code>newCUName</code>
- * to the destination package.<br>
- * The package statement in the compilation unit is updated if necessary.
- * The main type of the compilation unit is renamed if necessary.
- *
- * @exception JavaModelException if the operation is unable to
- * complete
- */
-private void processCompilationUnitResource(ICompilationUnit source, IPackageFragment dest) throws JavaModelException {
- String newCUName = getNewNameFor(source);
- String destName = (newCUName != null) ? newCUName : source.getElementName();
- String newContent = updatedContent(source, dest, newCUName); // null if unchanged
-
- // copy resource
- IFile sourceResource = (IFile)(source.isWorkingCopy() ? source.getOriginalElement() : source).getCorrespondingResource();
- IContainer destFolder = (IContainer)dest.getCorrespondingResource(); // can be an IFolder or an IProject
- IFile destFile = destFolder.getFile(new Path(destName));
- if (!destFile.equals(sourceResource)) {
- try {
- if (destFile.exists()) {
- if (fForce) {
- // we can remove it
- deleteResource(destFile, IResource.KEEP_HISTORY);
- } else {
- // abort
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION));
+ /**
+ * Creates any destination package fragment(s) which do not exists yet.
+ */
+ private void createNeededPackageFragments(IContainer sourceFolder, IPackageFragmentRoot root, String newFragName, boolean moveFolder) throws JavaModelException {
+ IContainer parentFolder = (IContainer) root.getResource();
+ JavaElementDelta projectDelta = null;
+ String[] names = org.eclipse.jdt.internal.core.Util.getTrimmedSimpleNames(newFragName);
+ StringBuffer sideEffectPackageName = new StringBuffer();
+ char[][] exclusionsPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars();
+ for (int i = 0; i < names.length; i++) {
+ String subFolderName = names[i];
+ sideEffectPackageName.append(subFolderName);
+ IResource subFolder = parentFolder.findMember(subFolderName);
+ if (subFolder == null) {
+ // create deepest folder only if not a move (folder will be moved in processPackageFragmentResource)
+ if (!(moveFolder && i == names.length-1)) {
+ createFolder(parentFolder, subFolderName, fForce);
}
- }
- int flags = newContent != null ? IResource.NONE : IResource.KEEP_HISTORY;
- if (fForce) flags |= IResource.FORCE;
- if (this.isMove()) {
- sourceResource.move(destFile.getFullPath(), flags, getSubProgressMonitor(1));
+ parentFolder = parentFolder.getFolder(new Path(subFolderName));
+ sourceFolder = sourceFolder.getFolder(new Path(subFolderName));
+ if (sourceFolder.isReadOnly()) {
+ parentFolder.setReadOnly(true);
+ }
+ IPackageFragment sideEffectPackage = root.getPackageFragment(sideEffectPackageName.toString());
+ if (i < names.length - 1 // all but the last one are side effect packages
+ && !org.eclipse.jdt.internal.core.Util.isExcluded(parentFolder, exclusionsPatterns)) {
+ if (projectDelta == null) {
+ projectDelta = getDeltaFor(root.getJavaProject());
+ }
+ projectDelta.added(sideEffectPackage);
+ }
+ fCreatedElements.add(sideEffectPackage);
} else {
- sourceResource.copy(destFile.getFullPath(), flags, getSubProgressMonitor(1));
+ parentFolder = (IContainer) subFolder;
}
- this.hasModifiedResource = true;
- } catch (JavaModelException e) {
- throw e;
- } catch (CoreException e) {
- throw new JavaModelException(e);
+ sideEffectPackageName.append('.');
}
-
- // update new resource content
- try {
- if (newContent != null){
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
- destFile.setContents(
- new ByteArrayInputStream(encoding == null ? newContent.getBytes() : newContent.getBytes(encoding)),
- fForce ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
- getSubProgressMonitor(1));
- }
- } catch(IOException e) {
- throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
- } catch (CoreException e) {
- throw new JavaModelException(e);
+ }
+ /**
+ * Returns the <code>JavaElementDelta</code> for <code>javaProject</code>,
+ * creating it and putting it in <code>fDeltasPerProject</code> if
+ * it does not exist yet.
+ */
+ private JavaElementDelta getDeltaFor(IJavaProject javaProject) {
+ JavaElementDelta delta = (JavaElementDelta) fDeltasPerProject.get(javaProject);
+ if (delta == null) {
+ delta = new JavaElementDelta(javaProject);
+ fDeltasPerProject.put(javaProject, delta);
}
+ return delta;
+ }
+ /**
+ * @see MultiOperation
+ */
+ protected String getMainTaskName() {
+ return org.eclipse.jdt.internal.core.Util.bind("operation.copyResourceProgress"); //$NON-NLS-1$
+ }
+ /**
+ * Sets the deltas to register the changes resulting from this operation
+ * for this source element and its destination.
+ * If the operation is a cross project operation<ul>
+ * <li>On a copy, the delta should be rooted in the dest project
+ * <li>On a move, two deltas are generated<ul>
+ * <li>one rooted in the source project
+ * <li>one rooted in the destination project</ul></ul>
+ * If the operation is rooted in a single project, the delta is rooted in that project
+ *
+ */
+ protected void prepareDeltas(IJavaElement sourceElement, IJavaElement destinationElement, boolean isMove) {
+ if (org.eclipse.jdt.internal.core.Util.isExcluded(sourceElement) || org.eclipse.jdt.internal.core.Util.isExcluded(destinationElement)) return;
+ IJavaProject destProject = destinationElement.getJavaProject();
+ if (isMove) {
+ IJavaProject sourceProject = sourceElement.getJavaProject();
+ getDeltaFor(sourceProject).movedFrom(sourceElement, destinationElement);
+ getDeltaFor(destProject).movedTo(destinationElement, sourceElement);
+ } else {
+ getDeltaFor(destProject).added(destinationElement);
+ }
+ }
+ /**
+ * Copies/moves a compilation unit with the name <code>newCUName</code>
+ * to the destination package.<br>
+ * The package statement in the compilation unit is updated if necessary.
+ * The main type of the compilation unit is renamed if necessary.
+ *
+ * @exception JavaModelException if the operation is unable to
+ * complete
+ */
+ private void processCompilationUnitResource(ICompilationUnit source, IPackageFragment dest) throws JavaModelException {
+ String newCUName = getNewNameFor(source);
+ String destName = (newCUName != null) ? newCUName : source.getElementName();
+ String newContent = updatedContent(source, dest, newCUName); // null if unchanged
- // register the correct change deltas
- ICompilationUnit destCU = dest.getCompilationUnit(destName);
- prepareDeltas(source, destCU);
- if (newCUName != null) {
- //the main type has been renamed
- String oldName = source.getElementName();
- oldName = oldName.substring(0, oldName.length() - 5);
- String newName = newCUName;
- newName = newName.substring(0, newName.length() - 5);
- prepareDeltas(source.getType(oldName), destCU.getType(newName));
+ // copy resource
+ IFile sourceResource = (IFile)(source.isWorkingCopy() ? source.getOriginalElement() : source).getResource();
+ IContainer destFolder = (IContainer)dest.getResource(); // can be an IFolder or an IProject
+ IFile destFile = destFolder.getFile(new Path(destName));
+ if (!destFile.equals(sourceResource)) {
+ try {
+ if (destFile.exists()) {
+ if (fForce) {
+ // we can remove it
+ deleteResource(destFile, IResource.KEEP_HISTORY);
+ } else {
+ // abort
+ throw new JavaModelException(new JavaModelStatus(
+ IJavaModelStatusConstants.NAME_COLLISION,
+ Util.bind("status.nameCollision", destFile.getFullPath().toString()))); //$NON-NLS-1$
+ }
+ }
+ int flags = fForce ? IResource.FORCE : IResource.NONE;
+ if (this.isMove()) {
+ flags |= IResource.KEEP_HISTORY;
+ sourceResource.move(destFile.getFullPath(), flags, getSubProgressMonitor(1));
+ } else {
+ if (newContent != null) flags |= IResource.KEEP_HISTORY;
+ sourceResource.copy(destFile.getFullPath(), flags, getSubProgressMonitor(1));
+ }
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ } catch (JavaModelException e) {
+ throw e;
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+
+ // update new resource content
+ try {
+ if (newContent != null){
+ String encoding = source.getJavaProject().getOption(JavaCore.CORE_ENCODING, true);
+ destFile.setContents(
+ new ByteArrayInputStream(encoding == null ? newContent.getBytes() : newContent.getBytes(encoding)),
+ fForce ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
+ getSubProgressMonitor(1));
+ }
+ } catch(IOException e) {
+ throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+
+ // register the correct change deltas
+ ICompilationUnit destCU = dest.getCompilationUnit(destName);
+ prepareDeltas(source, destCU, isMove());
+ if (newCUName != null) {
+ //the main type has been renamed
+ String oldName = source.getElementName();
+ oldName = oldName.substring(0, oldName.length() - 5);
+ String newName = newCUName;
+ newName = newName.substring(0, newName.length() - 5);
+ prepareDeltas(source.getType(oldName), destCU.getType(newName), isMove());
+ }
+ } else {
+ if (!fForce) {
+ throw new JavaModelException(new JavaModelStatus(
+ IJavaModelStatusConstants.NAME_COLLISION,
+ Util.bind("status.nameCollision", destFile.getFullPath().toString()))); //$NON-NLS-1$
+ }
+ // update new resource content
+ // in case we do a saveas on the same resource we have to simply update the contents
+ // see http://dev.eclipse.org/bugs/show_bug.cgi?id=9351
+ try {
+ if (newContent != null){
+ String encoding = source.getJavaProject().getOption(JavaCore.CORE_ENCODING, true);
+ destFile.setContents(
+ new ByteArrayInputStream(encoding == null ? newContent.getBytes() : newContent.getBytes(encoding)),
+ fForce ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
+ getSubProgressMonitor(1));
+ }
+ } catch(IOException e) {
+ throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
}
- } else {
- if (!fForce) {
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION));
+ }
+ /**
+ * Process all of the changed deltas generated by this operation.
+ */
+ protected void processDeltas() {
+ for (Iterator deltas = this.fDeltasPerProject.values().iterator(); deltas.hasNext();){
+ addDelta((IJavaElementDelta) deltas.next());
}
- // update new resource content
- // in case we do a saveas on the same resource we have to simply update the contents
- // see http://dev.eclipse.org/bugs/show_bug.cgi?id=9351
+ }
+ /**
+ * @see MultiOperation
+ * This method delegates to <code>processCompilationUnitResource</code> or
+ * <code>processPackageFragmentResource</code>, depending on the type of
+ * <code>element</code>.
+ */
+ protected void processElement(IJavaElement element) throws JavaModelException {
+ IJavaElement dest = getDestinationParent(element);
+ switch (element.getElementType()) {
+ case IJavaElement.COMPILATION_UNIT :
+ processCompilationUnitResource((ICompilationUnit) element, (IPackageFragment) dest);
+ fCreatedElements.add(((IPackageFragment) dest).getCompilationUnit(element.getElementName()));
+ break;
+ case IJavaElement.PACKAGE_FRAGMENT :
+ processPackageFragmentResource((IPackageFragment) element, (IPackageFragmentRoot) dest, getNewNameFor(element));
+ break;
+ default :
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element));
+ }
+ }
+ /**
+ * @see MultiOperation
+ * Overridden to allow special processing of <code>JavaElementDelta</code>s
+ * and <code>fResultElements</code>.
+ */
+ protected void processElements() throws JavaModelException {
+ fCreatedElements = new ArrayList(fElementsToProcess.length);
try {
- if (newContent != null){
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
- destFile.setContents(
- new ByteArrayInputStream(encoding == null ? newContent.getBytes() : newContent.getBytes(encoding)),
- fForce ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
- getSubProgressMonitor(1));
- }
- } catch(IOException e) {
- throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
- } catch (CoreException e) {
- throw new JavaModelException(e);
+ super.processElements();
+ } catch (JavaModelException jme) {
+ throw jme;
+ } finally {
+ fResultElements = new IJavaElement[fCreatedElements.size()];
+ fCreatedElements.toArray(fResultElements);
+ processDeltas();
}
}
-}
-/**
- * Process all of the changed deltas generated by this operation.
- */
-protected void processDeltas() {
- for (Iterator deltas = this.fDeltasPerProject.values().iterator(); deltas.hasNext();){
- addDelta((IJavaElementDelta) deltas.next());
- }
-}
-/**
- * @see MultiOperation
- * This method delegates to <code>processCompilationUnitResource</code> or
- * <code>processPackageFragmentResource</code>, depending on the type of
- * <code>element</code>.
- */
-protected void processElement(IJavaElement element) throws JavaModelException {
- IJavaElement dest = getDestinationParent(element);
- switch (element.getElementType()) {
- case IJavaElement.COMPILATION_UNIT :
- processCompilationUnitResource((ICompilationUnit) element, (IPackageFragment) dest);
- fCreatedElements.add(((IPackageFragment) dest).getCompilationUnit(element.getElementName()));
- break;
- case IJavaElement.PACKAGE_FRAGMENT :
- processPackageFragmentResource((IPackageFragment) element, (IPackageFragmentRoot) dest, getNewNameFor(element));
- break;
- default :
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element));
- }
-}
-/**
- * @see MultiOperation
- * Overridden to allow special processing of <code>JavaElementDelta</code>s
- * and <code>fResultElements</code>.
- */
-protected void processElements() throws JavaModelException {
- fCreatedElements = new ArrayList(fElementsToProcess.length);
- try {
- super.processElements();
- } catch (JavaModelException jme) {
- throw jme;
- } finally {
- fResultElements = new IJavaElement[fCreatedElements.size()];
- fCreatedElements.toArray(fResultElements);
- processDeltas();
- }
-}
-/**
- * Copies/moves a package fragment with the name <code>newName</code>
- * to the destination package.<br>
- *
- * @exception JavaModelException if the operation is unable to
- * complete
- */
-private void processPackageFragmentResource(IPackageFragment source, IPackageFragmentRoot root, String newName) throws JavaModelException {
- try {
- String newFragName = (newName == null) ? source.getElementName() : newName;
- createNeededPackageFragments(root, newFragName);
- IPackageFragment newFrag = root.getPackageFragment(newFragName);
-
- // process the leaf resources
- IResource[] resources = collectResourcesOfInterest(source);
- if (resources.length > 0) {
- IPath destPath = newFrag.getUnderlyingResource().getFullPath();
- if (isRename()) {
- if (! destPath.equals(source.getUnderlyingResource().getFullPath())) {
- moveResources(resources, destPath);
- }
- } else if (isMove()) {
- // we need to delete this resource if this operation wants to override existing resources
- for (int i = 0, max = resources.length; i < max; i++) {
- IResource destinationResource = getWorkspace().getRoot().findMember(destPath.append(resources[i].getName()));
- if (destinationResource != null) {
- if (fForce) {
- deleteResource(destinationResource, IResource.KEEP_HISTORY);
- } else {
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION));
+ /**
+ * Copies/moves a package fragment with the name <code>newName</code>
+ * to the destination package.<br>
+ *
+ * @exception JavaModelException if the operation is unable to
+ * complete
+ */
+ private void processPackageFragmentResource(IPackageFragment source, IPackageFragmentRoot root, String newName) throws JavaModelException {
+ try {
+ String newFragName = (newName == null) ? source.getElementName() : newName;
+ IPackageFragment newFrag = root.getPackageFragment(newFragName);
+ IResource[] resources = collectResourcesOfInterest(source);
+
+ // if isMove() can we move the folder itself ? (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=22458)
+ boolean shouldMoveFolder = isMove() && !newFrag.getResource().exists(); // if new pkg fragment exists, it is an override
+ IFolder srcFolder = (IFolder)source.getResource();
+ IPath destPath = newFrag.getPath();
+ if (shouldMoveFolder) {
+ // check if destination is not included in source
+ if (srcFolder.getFullPath().isPrefixOf(destPath)) {
+ shouldMoveFolder = false;
+ } else {
+ // check if there are no sub-packages
+ IResource[] members = srcFolder.members();
+ for (int i = 0; i < members.length; i++) {
+ if ( members[i] instanceof IFolder) {
+ shouldMoveFolder = false;
+ break;
}
}
- }
- moveResources(resources, destPath);
- } else {
- // we need to delete this resource if this operation wants to override existing resources
- for (int i = 0, max = resources.length; i < max; i++) {
- IResource destinationResource = getWorkspace().getRoot().findMember(destPath.append(resources[i].getName()));
- if (destinationResource != null) {
- if (fForce) {
- // we need to delete this resource if this operation wants to override existing resources
- deleteResource(destinationResource, IResource.KEEP_HISTORY);
- } else {
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION));
- }
- }
- }
- copyResources(resources, destPath);
+ }
}
+ createNeededPackageFragments((IContainer) source.getParent().getResource(), root, newFragName, shouldMoveFolder);
+
+ // Process resources
+ if (shouldMoveFolder) {
+ // move underlying resource
+ srcFolder.move(destPath, fForce, true /* keep history */, getSubProgressMonitor(1));
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ } else {
+ // process the leaf resources
+ if (resources.length > 0) {
+ if (isRename()) {
+ if (! destPath.equals(source.getPath())) {
+ moveResources(resources, destPath);
+ }
+ } else if (isMove()) {
+ // we need to delete this resource if this operation wants to override existing resources
+ for (int i = 0, max = resources.length; i < max; i++) {
+ IResource destinationResource = ResourcesPlugin.getWorkspace().getRoot().findMember(destPath.append(resources[i].getName()));
+ if (destinationResource != null) {
+ if (fForce) {
+ deleteResource(destinationResource, IResource.KEEP_HISTORY);
+ } else {
+ throw new JavaModelException(new JavaModelStatus(
+ IJavaModelStatusConstants.NAME_COLLISION,
+ Util.bind("status.nameCollision", destinationResource.getFullPath().toString()))); //$NON-NLS-1$
+ }
+ }
+ }
+ moveResources(resources, destPath);
+ } else {
+ // we need to delete this resource if this operation wants to override existing resources
+ for (int i = 0, max = resources.length; i < max; i++) {
+ IResource destinationResource = ResourcesPlugin.getWorkspace().getRoot().findMember(destPath.append(resources[i].getName()));
+ if (destinationResource != null) {
+ if (fForce) {
+ // we need to delete this resource if this operation wants to override existing resources
+ deleteResource(destinationResource, IResource.KEEP_HISTORY);
+ } else {
+ throw new JavaModelException(new JavaModelStatus(
+ IJavaModelStatusConstants.NAME_COLLISION,
+ Util.bind("status.nameCollision", destinationResource.getFullPath().toString()))); //$NON-NLS-1$
+ }
+ }
+ }
+ copyResources(resources, destPath);
+ }
+ }
+ }
+
+ // Discard empty old package (if still empty after the rename)
+ boolean isEmpty = true;
+ if (isMove()) {
+ // delete remaining files in this package (.class file in the case where Proj=src=bin)
+ if (srcFolder.exists()) {
+ IResource[] remaingFiles = srcFolder.members();
+ for (int i = 0, length = remaingFiles.length; i < length; i++) {
+ IResource file = remaingFiles[i];
+ if (file instanceof IFile) {
+ this.deleteResource(file, IResource.FORCE | IResource.KEEP_HISTORY);
+ } else {
+ isEmpty = false;
+ }
+ }
+ }
+ if (isEmpty) {
+ IResource rootResource;
+ // check if source is included in destination
+ if (destPath.isPrefixOf(srcFolder.getFullPath())) {
+ rootResource = newFrag.getResource();
+ } else {
+ rootResource = source.getParent().getResource();
+ }
+
+ // delete recursively empty folders
+ deleteEmptyPackageFragment(source, false, rootResource);
+ }
+ }
+
+ // Update package statement in compilation unit if needed
if (!newFrag.getElementName().equals(source.getElementName())) { // if package has been renamed, update the compilation units
for (int i = 0; i < resources.length; i++) {
if (resources[i].getName().endsWith(".java")) { //$NON-NLS-1$
@@ -424,157 +482,144 @@
}
}
}
- }
-
- // discard empty old package (if still empty after the rename)
- if (isMove()) {
- // delete remaining files in this package (.class file in the case where Proj=src=bin)
- IResource[] remaingFiles = ((IContainer)source.getUnderlyingResource()).members();
- boolean isEmpty = true;
- for (int i = 0, length = remaingFiles.length; i < length; i++) {
- IResource file = remaingFiles[i];
- if (file instanceof IFile) {
- this.deleteResource(file, IResource.FORCE | IResource.KEEP_HISTORY);
- } else {
- isEmpty = false;
- }
- }
- if (isEmpty) {
- // delete recursively empty folders
- deleteEmptyPackageFragment(source, false);
- }
- }
-
- //register the correct change deltas
- prepareDeltas(source, newFrag);
- } catch (DOMException dom) {
- throw new JavaModelException(dom, IJavaModelStatusConstants.DOM_EXCEPTION);
- } catch (JavaModelException e) {
- throw e;
- } catch (CoreException ce) {
- throw new JavaModelException(ce);
- }
-}
-/**
- * Updates the content of <code>cu</code>, modifying the type name and/or package
- * declaration as necessary.
- *
- * @return the new source
- */
-private String updatedContent(ICompilationUnit cu, IPackageFragment dest, String newName) throws JavaModelException {
- String currPackageName = cu.getParent().getElementName();
- String destPackageName = dest.getElementName();
- if (currPackageName.equals(destPackageName) && newName == null) {
- return null; //nothing to change
- } else {
- String typeName = cu.getElementName();
- typeName = typeName.substring(0, typeName.length() - 5);
- IDOMCompilationUnit cuDOM = null;
- IBuffer buffer = cu.getBuffer();
- if (buffer == null) return null;
- char[] contents = buffer.getCharacters();
- if (contents == null) return null;
- cuDOM = fFactory.createCompilationUnit(contents, typeName);
- updateTypeName(cu, cuDOM, cu.getElementName(), newName);
- updatePackageStatement(cuDOM, destPackageName);
- return cuDOM.getContents();
- }
-}
-/**
- * Makes sure that <code>cu</code> declares to be in the <code>pkgName</code> package.
- */
-private void updatePackageStatement(IDOMCompilationUnit domCU, String pkgName) throws JavaModelException {
- boolean defaultPackage = pkgName.equals(IPackageFragment.DEFAULT_PACKAGE_NAME);
- boolean seenPackageNode = false;
- Enumeration enum = domCU.getChildren();
- while (enum.hasMoreElements()) {
- IDOMNode node = (IDOMNode) enum.nextElement();
- if (node.getNodeType() == IDOMNode.PACKAGE) {
- if (! defaultPackage) {
- node.setName(pkgName);
- } else {
- node.remove();
- }
- seenPackageNode = true;
- break;
+
+ //register the correct change deltas
+ prepareDeltas(source, newFrag, isMove() && isEmpty);
+ } catch (DOMException dom) {
+ throw new JavaModelException(dom, IJavaModelStatusConstants.DOM_EXCEPTION);
+ } catch (JavaModelException e) {
+ throw e;
+ } catch (CoreException ce) {
+ throw new JavaModelException(ce);
}
}
- if (!seenPackageNode && !defaultPackage) {
- //the cu was in a default package...no package declaration
- //create the new package declaration as the first child of the cu
- IDOMPackage pkg = fFactory.createPackage("package " + pkgName + ";" + Util.LINE_SEPARATOR); //$NON-NLS-1$ //$NON-NLS-2$
- IDOMNode firstChild = domCU.getFirstChild();
- if (firstChild != null) {
- firstChild.insertSibling(pkg);
- } // else the cu was empty: leave it empty
- }
-}
/**
- * Renames the main type in <code>cu</code>.
+ * Updates the content of <code>cu</code>, modifying the type name and/or package
+ * declaration as necessary.
+ *
+ * @return the new source
*/
- private void updateTypeName(ICompilationUnit cu, IDOMCompilationUnit domCU, String oldName, String newName) throws JavaModelException {
- if (newName != null) {
- if (fRenamedCompilationUnits == null) {
- fRenamedCompilationUnits= new ArrayList(1);
+ private String updatedContent(ICompilationUnit cu, IPackageFragment dest, String newName) throws JavaModelException {
+ String currPackageName = cu.getParent().getElementName();
+ String destPackageName = dest.getElementName();
+ if (currPackageName.equals(destPackageName) && newName == null) {
+ return null; //nothing to change
+ } else {
+ String typeName = cu.getElementName();
+ typeName = typeName.substring(0, typeName.length() - 5);
+ IDOMCompilationUnit cuDOM = null;
+ IBuffer buffer = cu.getBuffer();
+ if (buffer == null) return null;
+ char[] contents = buffer.getCharacters();
+ if (contents == null) return null;
+ cuDOM = fFactory.createCompilationUnit(contents, typeName);
+ updateTypeName(cu, cuDOM, cu.getElementName(), newName);
+ updatePackageStatement(cuDOM, destPackageName);
+ return cuDOM.getContents();
+ }
+ }
+ /**
+ * Makes sure that <code>cu</code> declares to be in the <code>pkgName</code> package.
+ */
+ private void updatePackageStatement(IDOMCompilationUnit domCU, String pkgName) throws JavaModelException {
+ boolean defaultPackage = pkgName.equals(IPackageFragment.DEFAULT_PACKAGE_NAME);
+ boolean seenPackageNode = false;
+ Enumeration enum = domCU.getChildren();
+ while (enum.hasMoreElements()) {
+ IDOMNode node = (IDOMNode) enum.nextElement();
+ if (node.getNodeType() == IDOMNode.PACKAGE) {
+ if (! defaultPackage) {
+ node.setName(pkgName);
+ } else {
+ node.remove();
+ }
+ seenPackageNode = true;
+ break;
}
- fRenamedCompilationUnits.add(cu);
- String oldTypeName= oldName.substring(0, oldName.length() - 5);
- String newTypeName= newName.substring(0, newName.length() - 5);
- // update main type name
- IType[] types = cu.getTypes();
- for (int i = 0, max = types.length; i < max; i++) {
- IType currentType = types[i];
- if (currentType.getElementName().equals(oldTypeName)) {
- IDOMNode typeNode = ((JavaElement) currentType).findNode(domCU);
- if (typeNode != null) {
- typeNode.setName(newTypeName);
+ }
+ if (!seenPackageNode && !defaultPackage) {
+ //the cu was in a default package...no package declaration
+ //create the new package declaration as the first child of the cu
+ IDOMPackage pkg = fFactory.createPackage("package " + pkgName + ";" + Util.LINE_SEPARATOR); //$NON-NLS-1$ //$NON-NLS-2$
+ IDOMNode firstChild = domCU.getFirstChild();
+ if (firstChild != null) {
+ firstChild.insertSibling(pkg);
+ } // else the cu was empty: leave it empty
+ }
+ }
+ /**
+ * Renames the main type in <code>cu</code>.
+ */
+ private void updateTypeName(ICompilationUnit cu, IDOMCompilationUnit domCU, String oldName, String newName) throws JavaModelException {
+ if (newName != null) {
+ if (fRenamedCompilationUnits == null) {
+ fRenamedCompilationUnits= new ArrayList(1);
+ }
+ fRenamedCompilationUnits.add(cu);
+ String oldTypeName= oldName.substring(0, oldName.length() - 5);
+ String newTypeName= newName.substring(0, newName.length() - 5);
+ // update main type name
+ IType[] types = cu.getTypes();
+ for (int i = 0, max = types.length; i < max; i++) {
+ IType currentType = types[i];
+ if (currentType.getElementName().equals(oldTypeName)) {
+ IDOMNode typeNode = ((JavaElement) currentType).findNode(domCU);
+ if (typeNode != null) {
+ typeNode.setName(newTypeName);
+ }
}
}
}
}
- }
-/**
- * Possible failures:
- * <ul>
- * <li>NO_ELEMENTS_TO_PROCESS - no elements supplied to the operation
- * <li>INDEX_OUT_OF_BOUNDS - the number of renamings supplied to the operation
- * does not match the number of elements that were supplied.
- * </ul>
- */
-protected IJavaModelStatus verify() {
- IJavaModelStatus status = super.verify();
- if (!status.isOK()) {
- return status;
- }
-
- if (fRenamingsList != null && fRenamingsList.length != fElementsToProcess.length) {
- return new JavaModelStatus(IJavaModelStatusConstants.INDEX_OUT_OF_BOUNDS);
- }
- return JavaModelStatus.VERIFIED_OK;
-}
-/**
- * @see MultiOperation
- */
-protected void verify(IJavaElement element) throws JavaModelException {
- if (element == null || !element.exists())
- error(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element);
-
- if (element.isReadOnly() && (isRename() || isMove()))
- error(IJavaModelStatusConstants.READ_ONLY, element);
-
- int elementType = element.getElementType();
-
- if (elementType == IJavaElement.COMPILATION_UNIT) {
- if (isMove() && ((ICompilationUnit) element).isWorkingCopy())
- error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
- } else if (elementType != IJavaElement.PACKAGE_FRAGMENT) {
- error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
- }
+ /**
+ * Possible failures:
+ * <ul>
+ * <li>NO_ELEMENTS_TO_PROCESS - no elements supplied to the operation
+ * <li>INDEX_OUT_OF_BOUNDS - the number of renamings supplied to the operation
+ * does not match the number of elements that were supplied.
+ * </ul>
+ */
+ protected IJavaModelStatus verify() {
+ IJavaModelStatus status = super.verify();
+ if (!status.isOK()) {
+ return status;
+ }
- JavaElement dest = (JavaElement) getDestinationParent(element);
- verifyDestination(element, dest);
- if (fRenamings != null) {
- verifyRenaming(element);
+ if (fRenamingsList != null && fRenamingsList.length != fElementsToProcess.length) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INDEX_OUT_OF_BOUNDS);
+ }
+ return JavaModelStatus.VERIFIED_OK;
}
+ /**
+ * @see MultiOperation
+ */
+ protected void verify(IJavaElement element) throws JavaModelException {
+ if (element == null || !element.exists())
+ error(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element);
+
+ if (element.isReadOnly() && (isRename() || isMove()))
+ error(IJavaModelStatusConstants.READ_ONLY, element);
+
+ IResource resource = element.getResource();
+ if (resource instanceof IFolder) {
+ if (resource.isLinked()) {
+ error(JavaModelStatus.INVALID_RESOURCE, element);
+ }
+ }
+
+ int elementType = element.getElementType();
+
+ if (elementType == IJavaElement.COMPILATION_UNIT) {
+ if (isMove() && ((ICompilationUnit) element).isWorkingCopy())
+ error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
+ } else if (elementType != IJavaElement.PACKAGE_FRAGMENT) {
+ error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
+ }
+
+ JavaElement dest = (JavaElement) getDestinationParent(element);
+ verifyDestination(element, dest);
+ if (fRenamings != null) {
+ verifyRenaming(element);
+ }
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateCompilationUnitOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateCompilationUnitOperation.java
index 337c688..3bb3d16 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateCompilationUnitOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateCompilationUnitOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.ByteArrayInputStream;
@@ -78,7 +78,7 @@
JavaElementDelta delta = newJavaElementDelta();
ICompilationUnit unit = getCompilationUnit();
IPackageFragment pkg = (IPackageFragment) getParentElement();
- IContainer folder = (IContainer) pkg.getUnderlyingResource();
+ IContainer folder = (IContainer) pkg.getResource();
worked(1);
IFile compilationUnitFile = folder.getFile(new Path(fName));
if (compilationUnitFile.exists()) {
@@ -89,22 +89,26 @@
buffer.setContents(fSource);
unit.save(new NullProgressMonitor(), false);
fResultElements = new IJavaElement[] {unit};
- if (unit.getParent().exists()) {
+ if (!Util.isExcluded(unit)
+ && unit.getParent().exists()) {
for (int i = 0; i < fResultElements.length; i++) {
delta.changed(fResultElements[i], IJavaElementDelta.F_CONTENT);
}
addDelta(delta);
}
} else {
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION));
+ throw new JavaModelException(new JavaModelStatus(
+ IJavaModelStatusConstants.NAME_COLLISION,
+ Util.bind("status.nameCollision", compilationUnitFile.getFullPath().toString()))); //$NON-NLS-1$
}
} else {
try {
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
+ String encoding = unit.getJavaProject().getOption(JavaCore.CORE_ENCODING, true);
InputStream stream = new ByteArrayInputStream(encoding == null ? fSource.getBytes() : fSource.getBytes(encoding));
createFile(folder, unit.getElementName(), stream, false);
fResultElements = new IJavaElement[] {unit};
- if (unit.getParent().exists()) {
+ if (!Util.isExcluded(unit)
+ && unit.getParent().exists()) {
for (int i = 0; i < fResultElements.length; i++) {
delta.added(fResultElements[i]);
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java
index 2ea2dd5..a751d4c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateElementInCUOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IBuffer;
@@ -87,77 +87,79 @@
* or -1 if the new element is append to the end of the CU.
*/
protected int fReplacementLength = -1;
-/**
- * Constructs an operation that creates a Java Language Element with
- * the specified parent, contained within a compilation unit.
- */
-public CreateElementInCUOperation(IJavaElement parentElement) {
- super(null, new IJavaElement[]{parentElement});
- initializeDefaultPosition();
-}
-/**
- * Only allow cancelling if this operation is not nested.
- */
-protected void checkCanceled() {
- if (!fNested) {
- super.checkCanceled();
+ /**
+ * Constructs an operation that creates a Java Language Element with
+ * the specified parent, contained within a compilation unit.
+ */
+ public CreateElementInCUOperation(IJavaElement parentElement) {
+ super(null, new IJavaElement[]{parentElement});
+ initializeDefaultPosition();
}
-}
-/**
- * Instructs this operation to position the new element after
- * the given sibling, or to add the new element as the last child
- * of its parent if <code>null</code>.
- */
-public void createAfter(IJavaElement sibling) {
- setRelativePosition(sibling, INSERT_AFTER);
-}
-/**
- * Instructs this operation to position the new element before
- * the given sibling, or to add the new element as the last child
- * of its parent if <code>null</code>.
- */
-public void createBefore(IJavaElement sibling) {
- setRelativePosition(sibling, INSERT_BEFORE);
-}
-/**
- * Execute the operation - generate new source for the compilation unit
- * and save the results.
- *
- * @exception JavaModelException if the operation is unable to complete
- */
-protected void executeOperation() throws JavaModelException {
- try {
- beginTask(getMainTaskName(), getMainAmountOfWork());
- JavaElementDelta delta = newJavaElementDelta();
- ICompilationUnit unit = getCompilationUnit();
- generateNewCompilationUnitDOM(unit);
- if (fCreationOccurred) {
- //a change has really occurred
- IBuffer buffer = unit.getBuffer();
- if (buffer == null) return;
- char[] bufferContents = buffer.getCharacters();
- if (bufferContents == null) return;
- char[] elementContents = org.eclipse.jdt.internal.core.Util.normalizeCRs(fCreatedElement.getCharacters(), bufferContents);
- switch (fReplacementLength) {
- case -1 :
- // element is append at the end
- buffer.append(elementContents);
- break;
- case 0 :
- // element is inserted
- buffer.replace(fInsertionPosition, 0, elementContents);
- break;
- default :
- // element is replacing the previous one
- buffer.replace(fInsertionPosition, fReplacementLength, elementContents);
- }
- unit.save(null, false);
- boolean isWorkingCopy = unit.isWorkingCopy();
- this.hasModifiedResource = !isWorkingCopy;
- worked(1);
- fResultElements = generateResultHandles();
- if (!isWorkingCopy) { // if unit is working copy, then save will have already fired the delta
- if (unit.getParent().exists()) {
+ /**
+ * Only allow cancelling if this operation is not nested.
+ */
+ protected void checkCanceled() {
+ if (!fNested) {
+ super.checkCanceled();
+ }
+ }
+ /**
+ * Instructs this operation to position the new element after
+ * the given sibling, or to add the new element as the last child
+ * of its parent if <code>null</code>.
+ */
+ public void createAfter(IJavaElement sibling) {
+ setRelativePosition(sibling, INSERT_AFTER);
+ }
+ /**
+ * Instructs this operation to position the new element before
+ * the given sibling, or to add the new element as the last child
+ * of its parent if <code>null</code>.
+ */
+ public void createBefore(IJavaElement sibling) {
+ setRelativePosition(sibling, INSERT_BEFORE);
+ }
+ /**
+ * Execute the operation - generate new source for the compilation unit
+ * and save the results.
+ *
+ * @exception JavaModelException if the operation is unable to complete
+ */
+ protected void executeOperation() throws JavaModelException {
+ try {
+ beginTask(getMainTaskName(), getMainAmountOfWork());
+ JavaElementDelta delta = newJavaElementDelta();
+ ICompilationUnit unit = getCompilationUnit();
+ generateNewCompilationUnitDOM(unit);
+ if (fCreationOccurred) {
+ //a change has really occurred
+ IBuffer buffer = unit.getBuffer();
+ if (buffer == null) return;
+ char[] bufferContents = buffer.getCharacters();
+ if (bufferContents == null) return;
+ char[] elementContents = org.eclipse.jdt.internal.core.Util.normalizeCRs(fCreatedElement.getCharacters(), bufferContents);
+ switch (fReplacementLength) {
+ case -1 :
+ // element is append at the end
+ buffer.append(elementContents);
+ break;
+ case 0 :
+ // element is inserted
+ buffer.replace(fInsertionPosition, 0, elementContents);
+ break;
+ default :
+ // element is replacing the previous one
+ buffer.replace(fInsertionPosition, fReplacementLength, elementContents);
+ }
+ unit.save(null, false);
+ boolean isWorkingCopy = unit.isWorkingCopy();
+ if (!isWorkingCopy)
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ worked(1);
+ fResultElements = generateResultHandles();
+ if (!isWorkingCopy // if unit is working copy, then save will have already fired the delta
+ && !Util.isExcluded(unit)
+ && unit.getParent().exists()) {
for (int i = 0; i < fResultElements.length; i++) {
delta.added(fResultElements[i]);
}
@@ -165,152 +167,150 @@
} // else unit is created outside classpath
// non-java resource delta will be notified by delta processor
}
- }
- } finally {
- done();
- }
-}
-/**
- * Returns a JDOM document fragment for the element being created.
- */
-protected abstract IDOMNode generateElementDOM() throws JavaModelException;
-/**
- * Returns the DOM with the new source to use for the given compilation unit.
- */
-protected void generateNewCompilationUnitDOM(ICompilationUnit cu) throws JavaModelException {
- IBuffer buffer = cu.getBuffer();
- if (buffer == null) return;
- char[] prevSource = buffer.getCharacters();
- if (prevSource == null) return;
-
- // create a JDOM for the compilation unit
- fCUDOM = (new DOMFactory()).createCompilationUnit(prevSource, cu.getElementName());
- IDOMNode child = generateElementDOM();
- if (child != null) {
- insertDOMNode(fCUDOM, child);
- }
- worked(1);
-}
-/**
- * Creates and returns the handle for the element this operation created.
- */
-protected abstract IJavaElement generateResultHandle();
-/**
- * Creates and returns the handles for the elements this operation created.
- */
-protected IJavaElement[] generateResultHandles() throws JavaModelException {
- return new IJavaElement[]{generateResultHandle()};
-}
-/**
- * Returns the compilation unit in which the new element is being created.
- */
-protected ICompilationUnit getCompilationUnit() {
- return getCompilationUnitFor(getParentElement());
-}
-/**
- * Returns the amount of work for the main task of this operation for
- * progress reporting.
- */
-protected int getMainAmountOfWork(){
- return 2;
-}
-/**
- * Returns the name of the main task of this operation for
- * progress reporting.
- */
-public abstract String getMainTaskName();
-/**
- * Returns the elements created by this operation.
- */
-public IJavaElement[] getResultElements() {
- return fResultElements;
-}
-/**
- * Sets the default position in which to create the new type
- * member. By default, the new element is positioned as the
- * last child of the parent element in which it is created.
- * Operations that require a different default position must
- * override this method.
- */
-protected void initializeDefaultPosition() {
-
-}
-/**
- * Inserts the given child into the given JDOM,
- * based on the position settings of this operation.
- *
- * @see createAfter(IJavaElement)
- * @see createBefore(IJavaElement);
- */
-protected void insertDOMNode(IDOMNode parent, IDOMNode child) {
- if (fInsertionPolicy != INSERT_LAST) {
- IDOMNode sibling = ((JavaElement)fAnchorElement).findNode(fCUDOM);
- if (sibling != null && fInsertionPolicy == INSERT_AFTER) {
- sibling = sibling.getNextNode();
- }
- if (sibling != null) {
- sibling.insertSibling(child);
- fCreatedElement = (DOMNode)child;
- fInsertionPosition = ((DOMNode)sibling).getStartPosition();
- fReplacementLength = 0;
- return;
+ } finally {
+ done();
}
}
- //add as the last element of the parent
- parent.addChild(child);
- fCreatedElement = (DOMNode)child;
- DOMNode lastChild = (DOMNode)fCreatedElement.getPreviousNode();
- fInsertionPosition = ((DOMNode)parent).getInsertionPosition();
-// fInsertionPosition = lastChild == null ? ((DOMNode)parent).getInsertionPosition() : lastChild.getInsertionPosition();
- fReplacementLength = parent.getParent() == null ? -1 : 0;
-}
-/**
- * Sets the name of the <code>DOMNode</code> that will be used to
- * create this new element.
- * Used by the <code>CopyElementsOperation</code> for renaming.
- * Only used for <code>CreateTypeMemberOperation</code>
- */
-protected void setAlteredName(String newName) {
-}
-/**
- * Instructs this operation to position the new element relative
- * to the given sibling, or to add the new element as the last child
- * of its parent if <code>null</code>. The <code>position</code>
- * must be one of the position constants.
- */
-protected void setRelativePosition(IJavaElement sibling, int policy) throws IllegalArgumentException {
- if (sibling == null) {
- fAnchorElement = null;
- fInsertionPolicy = INSERT_LAST;
- } else {
- fAnchorElement = sibling;
- fInsertionPolicy = policy;
- }
-}
-/**
- * Possible failures: <ul>
- * <li>NO_ELEMENTS_TO_PROCESS - the compilation unit supplied to the operation is
- * <code>null</code>.
- * <li>INVALID_NAME - no name, a name was null or not a valid
- * import declaration name.
- * <li>INVALID_SIBLING - the sibling provided for positioning is not valid.
- * </ul>
- * @see IJavaModelStatus
- * @see JavaConventions
- */
-public IJavaModelStatus verify() {
- if (getParentElement() == null) {
- return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
- }
- if (fAnchorElement != null) {
- IJavaElement domPresentParent = fAnchorElement.getParent();
- if (domPresentParent.getElementType() == IJavaElement.IMPORT_CONTAINER) {
- domPresentParent = domPresentParent.getParent();
+ /**
+ * Returns a JDOM document fragment for the element being created.
+ */
+ protected abstract IDOMNode generateElementDOM() throws JavaModelException;
+ /**
+ * Returns the DOM with the new source to use for the given compilation unit.
+ */
+ protected void generateNewCompilationUnitDOM(ICompilationUnit cu) throws JavaModelException {
+ IBuffer buffer = cu.getBuffer();
+ if (buffer == null) return;
+ char[] prevSource = buffer.getCharacters();
+ if (prevSource == null) return;
+
+ // create a JDOM for the compilation unit
+ fCUDOM = (new DOMFactory()).createCompilationUnit(prevSource, cu.getElementName());
+ IDOMNode child = generateElementDOM();
+ if (child != null) {
+ insertDOMNode(fCUDOM, child);
}
- if (!domPresentParent.equals(getParentElement())) {
- return new JavaModelStatus(IJavaModelStatusConstants.INVALID_SIBLING, fAnchorElement);
+ worked(1);
+ }
+ /**
+ * Creates and returns the handle for the element this operation created.
+ */
+ protected abstract IJavaElement generateResultHandle();
+ /**
+ * Creates and returns the handles for the elements this operation created.
+ */
+ protected IJavaElement[] generateResultHandles() throws JavaModelException {
+ return new IJavaElement[]{generateResultHandle()};
+ }
+ /**
+ * Returns the compilation unit in which the new element is being created.
+ */
+ protected ICompilationUnit getCompilationUnit() {
+ return getCompilationUnitFor(getParentElement());
+ }
+ /**
+ * Returns the amount of work for the main task of this operation for
+ * progress reporting.
+ */
+ protected int getMainAmountOfWork(){
+ return 2;
+ }
+ /**
+ * Returns the name of the main task of this operation for
+ * progress reporting.
+ */
+ public abstract String getMainTaskName();
+ /**
+ * Returns the elements created by this operation.
+ */
+ public IJavaElement[] getResultElements() {
+ return fResultElements;
+ }
+ /**
+ * Sets the default position in which to create the new type
+ * member. By default, the new element is positioned as the
+ * last child of the parent element in which it is created.
+ * Operations that require a different default position must
+ * override this method.
+ */
+ protected void initializeDefaultPosition() {
+
+ }
+ /**
+ * Inserts the given child into the given JDOM,
+ * based on the position settings of this operation.
+ *
+ * @see createAfter(IJavaElement)
+ * @see createBefore(IJavaElement);
+ */
+ protected void insertDOMNode(IDOMNode parent, IDOMNode child) {
+ if (fInsertionPolicy != INSERT_LAST) {
+ IDOMNode sibling = ((JavaElement)fAnchorElement).findNode(fCUDOM);
+ if (sibling != null && fInsertionPolicy == INSERT_AFTER) {
+ sibling = sibling.getNextNode();
+ }
+ if (sibling != null) {
+ sibling.insertSibling(child);
+ fCreatedElement = (DOMNode)child;
+ fInsertionPosition = ((DOMNode)sibling).getStartPosition();
+ fReplacementLength = 0;
+ return;
+ }
+ }
+ //add as the last element of the parent
+ parent.addChild(child);
+ fCreatedElement = (DOMNode)child;
+ fInsertionPosition = ((DOMNode)parent).getInsertionPosition();
+ // fInsertionPosition = lastChild == null ? ((DOMNode)parent).getInsertionPosition() : lastChild.getInsertionPosition();
+ fReplacementLength = parent.getParent() == null ? -1 : 0;
+ }
+ /**
+ * Sets the name of the <code>DOMNode</code> that will be used to
+ * create this new element.
+ * Used by the <code>CopyElementsOperation</code> for renaming.
+ * Only used for <code>CreateTypeMemberOperation</code>
+ */
+ protected void setAlteredName(String newName) {
+ }
+ /**
+ * Instructs this operation to position the new element relative
+ * to the given sibling, or to add the new element as the last child
+ * of its parent if <code>null</code>. The <code>position</code>
+ * must be one of the position constants.
+ */
+ protected void setRelativePosition(IJavaElement sibling, int policy) throws IllegalArgumentException {
+ if (sibling == null) {
+ fAnchorElement = null;
+ fInsertionPolicy = INSERT_LAST;
+ } else {
+ fAnchorElement = sibling;
+ fInsertionPolicy = policy;
}
}
- return JavaModelStatus.VERIFIED_OK;
-}
+ /**
+ * Possible failures: <ul>
+ * <li>NO_ELEMENTS_TO_PROCESS - the compilation unit supplied to the operation is
+ * <code>null</code>.
+ * <li>INVALID_NAME - no name, a name was null or not a valid
+ * import declaration name.
+ * <li>INVALID_SIBLING - the sibling provided for positioning is not valid.
+ * </ul>
+ * @see IJavaModelStatus
+ * @see JavaConventions
+ */
+ public IJavaModelStatus verify() {
+ if (getParentElement() == null) {
+ return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
+ }
+ if (fAnchorElement != null) {
+ IJavaElement domPresentParent = fAnchorElement.getParent();
+ if (domPresentParent.getElementType() == IJavaElement.IMPORT_CONTAINER) {
+ domPresentParent = domPresentParent.getParent();
+ }
+ if (!domPresentParent.equals(getParentElement())) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_SIBLING, fAnchorElement);
+ }
+ }
+ return JavaModelStatus.VERIFIED_OK;
+ }
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateFieldOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateFieldOperation.java
index 0093c31..51ada30 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateFieldOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateFieldOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IJavaElement;
@@ -96,7 +96,9 @@
protected IJavaModelStatus verifyNameCollision() {
IType type= getType();
if (type.getField(fDOMNode.getName()).exists()) {
- return new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION);
+ return new JavaModelStatus(
+ IJavaModelStatusConstants.NAME_COLLISION,
+ Util.bind("status.nameCollision", fDOMNode.getName())); //$NON-NLS-1$
}
return JavaModelStatus.VERIFIED_OK;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateImportOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateImportOperation.java
index 8c285d9..8681705 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateImportOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateImportOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.runtime.IStatus;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateInitializerOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateInitializerOperation.java
index 2aefeb5..0e29139 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateInitializerOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateInitializerOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IJavaElement;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateMethodOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateMethodOperation.java
index 890c5cb..4bbc568 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateMethodOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateMethodOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IJavaElement;
@@ -107,7 +107,9 @@
}
String[] types = convertDOMMethodTypesToSignatures();
if (type.getMethod(name, types).exists()) {
- return new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION);
+ return new JavaModelStatus(
+ IJavaModelStatusConstants.NAME_COLLISION,
+ Util.bind("status.nameCollision", name)); //$NON-NLS-1$
}
}
return JavaModelStatus.VERIFIED_OK;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageDeclarationOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageDeclarationOperation.java
index ec420a0..1c88ff2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageDeclarationOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageDeclarationOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.runtime.IStatus;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageFragmentOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageFragmentOperation.java
index ffe12e3..dc2a24b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageFragmentOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreatePackageFragmentOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
@@ -23,7 +23,6 @@
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
/**
* This operation creates a new package fragment under a given package fragment root.
@@ -65,13 +64,14 @@
* @exception JavaModelException if the operation is unable to complete
*/
protected void executeOperation() throws JavaModelException {
- JavaElementDelta delta = newJavaElementDelta();
+ JavaElementDelta delta = null;
IPackageFragmentRoot root = (IPackageFragmentRoot) getParentElement();
- String[] names = Signature.getSimpleNames(fName);
+ String[] names = Util.getTrimmedSimpleNames(fName);
beginTask(Util.bind("operation.createPackageFragmentProgress"), names.length); //$NON-NLS-1$
- IContainer parentFolder = (IContainer) root.getUnderlyingResource();
+ IContainer parentFolder = (IContainer) root.getResource();
String sideEffectPackageName = ""; //$NON-NLS-1$
ArrayList resultElements = new ArrayList(names.length);
+ char[][] exclusionPatterns = ((PackageFragmentRoot)root).fullExclusionPatternChars();
int i;
for (i = 0; i < names.length; i++) {
String subFolderName = names[i];
@@ -81,7 +81,12 @@
createFolder(parentFolder, subFolderName, fForce);
parentFolder = parentFolder.getFolder(new Path(subFolderName));
IPackageFragment addedFrag = root.getPackageFragment(sideEffectPackageName);
- delta.added(addedFrag);
+ if (!Util.isExcluded(parentFolder, exclusionPatterns)) {
+ if (delta == null) {
+ delta = newJavaElementDelta();
+ }
+ delta.added(addedFrag);
+ }
resultElements.add(addedFrag);
} else {
parentFolder = (IContainer) subFolder;
@@ -92,7 +97,9 @@
if (resultElements.size() > 0) {
fResultElements = new IJavaElement[resultElements.size()];
resultElements.toArray(fResultElements);
- addDelta(delta);
+ if (delta != null) {
+ addDelta(delta);
+ }
}
done();
}
@@ -122,21 +129,19 @@
if (root.isReadOnly()) {
return new JavaModelStatus(IJavaModelStatusConstants.READ_ONLY, root);
}
- String[] names = Signature.getSimpleNames(fName);
- try {
- IContainer parentFolder = (IContainer) root.getUnderlyingResource();
- int i;
- for (i = 0; i < names.length; i++) {
- IResource subFolder = parentFolder.findMember(names[i]);
- if (subFolder != null) {
- if (subFolder.getType() != IResource.FOLDER) {
- return new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION);
- }
- parentFolder = (IContainer) subFolder;
+ String[] names = Util.getTrimmedSimpleNames(fName);
+ IContainer parentFolder = (IContainer) root.getResource();
+ int i;
+ for (i = 0; i < names.length; i++) {
+ IResource subFolder = parentFolder.findMember(names[i]);
+ if (subFolder != null) {
+ if (subFolder.getType() != IResource.FOLDER) {
+ return new JavaModelStatus(
+ IJavaModelStatusConstants.NAME_COLLISION,
+ Util.bind("status.nameCollision", subFolder.getFullPath().toString())); //$NON-NLS-1$
}
+ parentFolder = (IContainer) subFolder;
}
- } catch (JavaModelException npe) {
- return npe.getJavaModelStatus();
}
return JavaModelStatus.VERIFIED_OK;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeHierarchyOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeHierarchyOperation.java
index 220d02c..fc03f61 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeHierarchyOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeHierarchyOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IJavaElement;
@@ -62,6 +62,15 @@
this.workingCopies = workingCopies;
}
/**
+ * Constructs an operation to create a type hierarchy for the
+ * given type and working copies.
+ */
+public CreateTypeHierarchyOperation(IType element, IWorkingCopy[] workingCopies, IJavaProject project, boolean computeSubtypes) throws JavaModelException {
+ super(element);
+ this.typeHierarchy = new TypeHierarchy(element, project, computeSubtypes);
+ this.workingCopies = workingCopies;
+}
+/**
* Performs the operation - creates the type hierarchy
* @exception JavaModelException The operation has failed.
*/
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
index c6b6b96..b5278e7 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IBuffer;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeOperation.java
index 5e05bd3..edaab05 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.ICompilationUnit;
@@ -92,12 +92,16 @@
int type = parent.getElementType();
if (type == IJavaElement.TYPE) {
if (((IType) parent).getType(fDOMNode.getName()).exists()) {
- return new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION);
+ return new JavaModelStatus(
+ IJavaModelStatusConstants.NAME_COLLISION,
+ Util.bind("status.nameCollision", fDOMNode.getName())); //$NON-NLS-1$
}
} else
if (type == IJavaElement.COMPILATION_UNIT) {
if (((ICompilationUnit) parent).getType(fDOMNode.getName()).exists()) {
- return new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION);
+ return new JavaModelStatus(
+ IJavaModelStatusConstants.NAME_COLLISION,
+ Util.bind("status.nameCollision", fDOMNode.getName())); //$NON-NLS-1$
}
}
return JavaModelStatus.VERIFIED_OK;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateWorkingCopyOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateWorkingCopyOperation.java
new file mode 100644
index 0000000..387e4e5
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateWorkingCopyOperation.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+import java.util.Map;
+
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.JavaModelException;
+
+/**
+ * Creates a new working copy and signal its addition through a delta.
+ */
+public class CreateWorkingCopyOperation extends JavaModelOperation {
+
+ Map perFactoryWorkingCopies;
+ IBufferFactory factory;
+ IProblemRequestor problemRequestor;
+
+ /*
+ * Creates a working copy from the given original cu and the given buffer factory.
+ * perFactoryWorkingCopies map is not null if the working copy is a shared working copy.
+ */
+ public CreateWorkingCopyOperation(ICompilationUnit originalElement, Map perFactoryWorkingCopies, IBufferFactory factory, IProblemRequestor problemRequestor) {
+ super(new IJavaElement[] {originalElement});
+ this.perFactoryWorkingCopies = perFactoryWorkingCopies;
+ this.factory = factory;
+ this.problemRequestor = problemRequestor;
+ }
+ protected void executeOperation() throws JavaModelException {
+ ICompilationUnit cu = getCompilationUnit();
+
+ WorkingCopy workingCopy = new WorkingCopy((IPackageFragment)cu.getParent(), cu.getElementName(), this.factory, this.problemRequestor);
+ // open the working copy now to ensure contents are that of the current state of this element
+ workingCopy.open(this.fMonitor);
+
+ if (this.perFactoryWorkingCopies != null) {
+ this.perFactoryWorkingCopies.put(cu, workingCopy);
+ if (CompilationUnit.SHARED_WC_VERBOSE) {
+ System.out.println("Creating shared working copy " + workingCopy.toStringWithAncestors()); //$NON-NLS-1$
+ }
+ }
+
+ // report added java delta
+ JavaElementDelta delta = new JavaElementDelta(this.getJavaModel());
+ delta.added(workingCopy);
+ addDelta(delta);
+
+ fResultElements = new IJavaElement[] {workingCopy};
+ }
+ /**
+ * Returns the compilation unit this operation is working on.
+ */
+ protected ICompilationUnit getCompilationUnit() {
+ return (ICompilationUnit)getElementToProcess();
+ }
+ /**
+ * @see JavaModelOperation#isReadOnly
+ */
+ public boolean isReadOnly() {
+ return true;
+ }
+
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
index fef22c6..59602f1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteElementsOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.HashMap;
@@ -20,6 +20,7 @@
import org.eclipse.jdt.core.IJavaModelStatusConstants;
import org.eclipse.jdt.core.IRegion;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.jdom.DOMFactory;
import org.eclipse.jdt.core.jdom.IDOMCompilationUnit;
import org.eclipse.jdt.internal.core.jdom.DOMNode;
@@ -35,7 +36,6 @@
* should be used.
*/
public class DeleteElementsOperation extends MultiOperation {
- char[] NO_CHAR = new char[0];
/**
* The elements this operation processes grouped by compilation unit
* @see processElements(). Keys are compilation units,
@@ -48,116 +48,116 @@
* <code>ICompilationUnit</code>s.
*/
protected DOMFactory fFactory;
-/**
- * When executed, this operation will delete the given elements. The elements
- * to delete cannot be <code>null</code> or empty, and must be contained within a
- * compilation unit.
- */
-public DeleteElementsOperation(IJavaElement[] elementsToDelete, boolean force) {
- super(elementsToDelete, force);
- fFactory = new DOMFactory();
-}
-
-/**
- * @see MultiOperation
- */
-protected String getMainTaskName() {
- return Util.bind("operation.deleteElementProgress"); //$NON-NLS-1$
-}
-/**
- * Groups the elements to be processed by their compilation unit.
- * If parent/child combinations are present, children are
- * discarded (only the parents are processed). Removes any
- * duplicates specified in elements to be processed.
- */
-protected void groupElements() throws JavaModelException {
- fChildrenToRemove = new HashMap(1);
- int uniqueCUs = 0;
- for (int i = 0, length = fElementsToProcess.length; i < length; i++) {
- IJavaElement e = fElementsToProcess[i];
- ICompilationUnit cu = getCompilationUnitFor(e);
- if (cu == null) {
- throw new JavaModelException(new JavaModelStatus(JavaModelStatus.READ_ONLY, e));
- } else {
- IRegion region = (IRegion) fChildrenToRemove.get(cu);
- if (region == null) {
- region = new Region();
- fChildrenToRemove.put(cu, region);
- uniqueCUs += 1;
+ /**
+ * When executed, this operation will delete the given elements. The elements
+ * to delete cannot be <code>null</code> or empty, and must be contained within a
+ * compilation unit.
+ */
+ public DeleteElementsOperation(IJavaElement[] elementsToDelete, boolean force) {
+ super(elementsToDelete, force);
+ fFactory = new DOMFactory();
+ }
+
+ /**
+ * @see MultiOperation
+ */
+ protected String getMainTaskName() {
+ return Util.bind("operation.deleteElementProgress"); //$NON-NLS-1$
+ }
+ /**
+ * Groups the elements to be processed by their compilation unit.
+ * If parent/child combinations are present, children are
+ * discarded (only the parents are processed). Removes any
+ * duplicates specified in elements to be processed.
+ */
+ protected void groupElements() throws JavaModelException {
+ fChildrenToRemove = new HashMap(1);
+ int uniqueCUs = 0;
+ for (int i = 0, length = fElementsToProcess.length; i < length; i++) {
+ IJavaElement e = fElementsToProcess[i];
+ ICompilationUnit cu = getCompilationUnitFor(e);
+ if (cu == null) {
+ throw new JavaModelException(new JavaModelStatus(JavaModelStatus.READ_ONLY, e));
+ } else {
+ IRegion region = (IRegion) fChildrenToRemove.get(cu);
+ if (region == null) {
+ region = new Region();
+ fChildrenToRemove.put(cu, region);
+ uniqueCUs += 1;
+ }
+ region.add(e);
}
- region.add(e);
+ }
+ fElementsToProcess = new IJavaElement[uniqueCUs];
+ Iterator iter = fChildrenToRemove.keySet().iterator();
+ int i = 0;
+ while (iter.hasNext()) {
+ fElementsToProcess[i++] = (IJavaElement) iter.next();
}
}
- fElementsToProcess = new IJavaElement[uniqueCUs];
- Iterator iter = fChildrenToRemove.keySet().iterator();
- int i = 0;
- while (iter.hasNext()) {
- fElementsToProcess[i++] = (IJavaElement) iter.next();
- }
-}
-/**
- * Deletes this element from its compilation unit.
- * @see MultiOperation
- */
-protected void processElement(IJavaElement element) throws JavaModelException {
- ICompilationUnit cu = (ICompilationUnit) element;
+ /**
+ * Deletes this element from its compilation unit.
+ * @see MultiOperation
+ */
+ protected void processElement(IJavaElement element) throws JavaModelException {
+ ICompilationUnit cu = (ICompilationUnit) element;
+
+ // keep track of the import statements - if all are removed, delete
+ // the import container (i.e. report it in the delta)
+ int numberOfImports = cu.getImports().length;
+
+ IBuffer buffer = cu.getBuffer();
+ if (buffer == null) return;
+ JavaElementDelta delta = new JavaElementDelta(cu);
+ IJavaElement[] cuElements = ((IRegion) fChildrenToRemove.get(cu)).getElements();
+ for (int i = 0, length = cuElements.length; i < length; i++) {
+ IJavaElement e = cuElements[i];
+ if (e.exists()) {
+ char[] contents = buffer.getCharacters();
+ if (contents == null) continue;
+ IDOMCompilationUnit cuDOM = fFactory.createCompilationUnit(contents, cu.getElementName());
+ DOMNode node = (DOMNode)((JavaElement) e).findNode(cuDOM);
+ if (node == null) Assert.isTrue(false, "Failed to locate " + e.getElementName() + " in " + cuDOM.getName()); //$NON-NLS-1$//$NON-NLS-2$
- // keep track of the import statements - if all are removed, delete
- // the import container (i.e. report it in the delta)
- int numberOfImports = cu.getImports().length;
-
- IBuffer buffer = cu.getBuffer();
- if (buffer == null) return;
- JavaElementDelta delta = new JavaElementDelta(cu);
- IJavaElement[] cuElements = ((IRegion) fChildrenToRemove.get(cu)).getElements();
- for (int i = 0, length = cuElements.length; i < length; i++) {
- IJavaElement e = cuElements[i];
- if (e.exists()) {
- char[] contents = buffer.getCharacters();
- if (contents == null) continue;
- IDOMCompilationUnit cuDOM = fFactory.createCompilationUnit(contents, cu.getElementName());
- DOMNode node = (DOMNode)((JavaElement) e).findNode(cuDOM);
- // TBD
- Assert.isTrue(node != null, Util.bind("element.cannotLocate", e.getElementName(), cuDOM.getName())); //$NON-NLS-1$
- int startPosition = node.getStartPosition();
- buffer.replace(startPosition, node.getEndPosition() - startPosition + 1, NO_CHAR);
- delta.removed(e);
- if (e.getElementType() == IJavaElement.IMPORT_DECLARATION) {
- numberOfImports--;
- if (numberOfImports == 0) {
- delta.removed(cu.getImportContainer());
+ int startPosition = node.getStartPosition();
+ buffer.replace(startPosition, node.getEndPosition() - startPosition + 1, CharOperation.NO_CHAR);
+ delta.removed(e);
+ if (e.getElementType() == IJavaElement.IMPORT_DECLARATION) {
+ numberOfImports--;
+ if (numberOfImports == 0) {
+ delta.removed(cu.getImportContainer());
+ }
}
}
}
- }
- if (delta.getAffectedChildren().length > 0) {
- cu.save(getSubProgressMonitor(1), fForce);
- if (!cu.isWorkingCopy()) { // if unit is working copy, then save will have already fired the delta
- addDelta(delta);
- this.hasModifiedResource = true;
+ if (delta.getAffectedChildren().length > 0) {
+ cu.save(getSubProgressMonitor(1), fForce);
+ if (!cu.isWorkingCopy()) { // if unit is working copy, then save will have already fired the delta
+ addDelta(delta);
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ }
}
}
-}
-/**
- * @see MultiOperation
- * This method first group the elements by <code>ICompilationUnit</code>,
- * and then processes the <code>ICompilationUnit</code>.
- */
-protected void processElements() throws JavaModelException {
- groupElements();
- super.processElements();
-}
-/**
- * @see MultiOperation
- */
-protected void verify(IJavaElement element) throws JavaModelException {
- IJavaElement[] children = ((IRegion) fChildrenToRemove.get(element)).getElements();
- for (int i = 0; i < children.length; i++) {
- IJavaElement child = children[i];
- if (child.getCorrespondingResource() != null)
- error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, child);
- if (child.isReadOnly())
- error(IJavaModelStatusConstants.READ_ONLY, child);
+ /**
+ * @see MultiOperation
+ * This method first group the elements by <code>ICompilationUnit</code>,
+ * and then processes the <code>ICompilationUnit</code>.
+ */
+ protected void processElements() throws JavaModelException {
+ groupElements();
+ super.processElements();
}
-}
+ /**
+ * @see MultiOperation
+ */
+ protected void verify(IJavaElement element) throws JavaModelException {
+ IJavaElement[] children = ((IRegion) fChildrenToRemove.get(element)).getElements();
+ for (int i = 0; i < children.length; i++) {
+ IJavaElement child = children[i];
+ if (child.getCorrespondingResource() != null)
+ error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, child);
+ if (child.isReadOnly())
+ error(IJavaModelStatusConstants.READ_ONLY, child);
+ }
+ }
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeletePackageFragmentRootOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeletePackageFragmentRootOperation.java
new file mode 100644
index 0000000..5c7bc1d
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeletePackageFragmentRootOperation.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.*;
+
+public class DeletePackageFragmentRootOperation extends JavaModelOperation {
+
+ int updateResourceFlags;
+ int updateModelFlags;
+
+ public DeletePackageFragmentRootOperation(
+ IPackageFragmentRoot root,
+ int updateResourceFlags,
+ int updateModelFlags) {
+
+ super(root);
+ this.updateResourceFlags = updateResourceFlags;
+ this.updateModelFlags = updateModelFlags;
+ }
+
+ protected void executeOperation() throws JavaModelException {
+
+ IPackageFragmentRoot root = (IPackageFragmentRoot)this.getElementToProcess();
+ IClasspathEntry rootEntry = root.getRawClasspathEntry();
+
+ // delete resource
+ if (!root.isExternal() && (this.updateModelFlags & IPackageFragmentRoot.NO_RESOURCE_MODIFICATION) == 0) {
+ deleteResource(root, rootEntry);
+ }
+
+ // update classpath if needed
+ if ((this.updateModelFlags & IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH) != 0) {
+ updateProjectClasspath(rootEntry.getPath(), root.getJavaProject());
+ }
+ if ((this.updateModelFlags & IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH) != 0) {
+ updateReferringProjectClasspaths(rootEntry.getPath(), root.getJavaProject());
+ }
+ }
+
+ protected void deleteResource(
+ IPackageFragmentRoot root,
+ IClasspathEntry rootEntry)
+ throws JavaModelException {
+ final char[][] exclusionPatterns = ((ClasspathEntry)rootEntry).fullExclusionPatternChars();
+ IResource rootResource = root.getResource();
+ if (rootEntry.getEntryKind() != IClasspathEntry.CPE_SOURCE || exclusionPatterns == null) {
+ try {
+ rootResource.delete(this.updateResourceFlags, fMonitor);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+ } else {
+ final IPath[] nestedFolders = getNestedFolders(root);
+ IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ if (proxy.getType() == IResource.FOLDER) {
+ IPath path = proxy.requestFullPath();
+ if (prefixesOneOf(path, nestedFolders)) {
+ // equals if nested source folder
+ return !equalsOneOf(path, nestedFolders);
+ } else {
+ // subtree doesn't contain any nested source folders
+ proxy.requestResource().delete(updateResourceFlags, fMonitor);
+ return false;
+ }
+ } else {
+ proxy.requestResource().delete(updateResourceFlags, fMonitor);
+ return false;
+ }
+ }
+ };
+ try {
+ rootResource.accept(visitor, IResource.NONE);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+ }
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ }
+
+
+ /*
+ * Deletes the classpath entries equals to the given rootPath from all Java projects.
+ */
+ protected void updateReferringProjectClasspaths(IPath rootPath, IJavaProject projectOfRoot) throws JavaModelException {
+ IJavaModel model = this.getJavaModel();
+ IJavaProject[] projects = model.getJavaProjects();
+ for (int i = 0, length = projects.length; i < length; i++) {
+ IJavaProject project = projects[i];
+ if (project.equals(projectOfRoot)) continue;
+ updateProjectClasspath(rootPath, project);
+ }
+ }
+
+ /*
+ * Deletes the classpath entries equals to the given rootPath from the given project.
+ */
+ protected void updateProjectClasspath(IPath rootPath, IJavaProject project)
+ throws JavaModelException {
+ IClasspathEntry[] classpath = project.getRawClasspath();
+ IClasspathEntry[] newClasspath = null;
+ int cpLength = classpath.length;
+ int newCPIndex = -1;
+ for (int j = 0; j < cpLength; j++) {
+ IClasspathEntry entry = classpath[j];
+ if (rootPath.equals(entry.getPath())) {
+ if (newClasspath == null) {
+ newClasspath = new IClasspathEntry[cpLength-1];
+ System.arraycopy(classpath, 0, newClasspath, 0, j);
+ newCPIndex = j;
+ }
+ } else if (newClasspath != null) {
+ newClasspath[newCPIndex++] = entry;
+ }
+ }
+ if (newClasspath != null) {
+ if (newCPIndex < newClasspath.length) {
+ System.arraycopy(newClasspath, 0, newClasspath = new IClasspathEntry[newCPIndex], 0, newCPIndex);
+ }
+ project.setRawClasspath(newClasspath, fMonitor);
+ }
+ }
+ protected IJavaModelStatus verify() {
+ IJavaModelStatus status = super.verify();
+ if (!status.isOK()) {
+ return status;
+ }
+ IPackageFragmentRoot root = (IPackageFragmentRoot) this.getElementToProcess();
+ if (root == null || !root.exists()) {
+ return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, root);
+ }
+
+ IResource resource = root.getResource();
+ if (resource instanceof IFolder) {
+ if (resource.isLinked()) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_RESOURCE, root);
+ }
+ }
+ return JavaModelStatus.VERIFIED_OK;
+ }
+
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteResourceElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteResourceElementsOperation.java
index fd36017..375a141 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteResourceElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeleteResourceElementsOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.resources.IFile;
@@ -40,7 +40,7 @@
*/
private void deletePackageFragment(IPackageFragment frag)
throws JavaModelException {
- IResource res = frag.getCorrespondingResource();
+ IResource res = frag.getResource();
if (res != null && res.getType() == IResource.FOLDER) {
// collect the children to remove
IJavaElement[] childrenOfInterest = frag.getChildren();
@@ -83,7 +83,10 @@
}
if (isEmpty) {
// delete recursively empty folders
- deleteEmptyPackageFragment(frag, false);
+ IResource fragResource = frag.getResource();
+ if (fragResource != null) {
+ deleteEmptyPackageFragment(frag, false, fragResource.getParent());
+ }
}
}
}
@@ -101,7 +104,7 @@
switch (element.getElementType()) {
case IJavaElement.CLASS_FILE :
case IJavaElement.COMPILATION_UNIT :
- deleteResource(element.getCorrespondingResource(), fForce ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY);
+ deleteResource(element.getResource(), fForce ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY);
break;
case IJavaElement.PACKAGE_FRAGMENT :
deletePackageFragment((IPackageFragment) element);
@@ -126,5 +129,11 @@
error(JavaModelStatus.INVALID_ELEMENT_TYPES, element);
else if (type == IJavaElement.PACKAGE_FRAGMENT && element instanceof JarPackageFragment)
error(JavaModelStatus.INVALID_ELEMENT_TYPES, element);
+ IResource resource = element.getResource();
+ if (resource instanceof IFolder) {
+ if (resource.isLinked()) {
+ error(JavaModelStatus.INVALID_RESOURCE, element);
+ }
+ }
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
index b6696ad..19e3dfe 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.File;
-import java.io.IOException;
+import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -19,12 +19,12 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -32,6 +32,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IClasspathEntry;
@@ -44,6 +45,7 @@
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.builder.JavaBuilder;
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
/**
@@ -64,40 +66,137 @@
final static String EXTERNAL_JAR_UNCHANGED = "external jar unchanged"; //$NON-NLS-1$
final static String INTERNAL_JAR_IGNORE = "internal jar ignore"; //$NON-NLS-1$
+ final static int NON_JAVA_RESOURCE = -1;
+
/**
* The <code>JavaElementDelta</code> corresponding to the <code>IResourceDelta</code> being translated.
*/
- protected JavaElementDelta fCurrentDelta;
+ protected JavaElementDelta currentDelta;
protected IndexManager indexManager = new IndexManager();
- /* A table from IPath (from a classpath entry) to IJavaProject */
- Map roots;
+ /* A table from IPath (from a classpath entry) to RootInfo */
+ public Map roots;
- /* A table from IPath (from a classpath entry) to HashSet of IJavaProject
+ /* A table from IPath (from a classpath entry) to ArrayList of RootInfo
* Used when an IPath corresponds to more than one root */
Map otherRoots;
- /* The java element that was last created (see createElement(IResource).
+ /* Whether the roots tables should be recomputed */
+ public boolean rootsAreStale = true;
+
+ /* A table from IPath (from a classpath entry) to RootInfo
+ * from the last time the delta processor was invoked. */
+ public Map oldRoots;
+
+ /* A table from IPath (from a classpath entry) to ArrayList of RootInfo
+ * from the last time the delta processor was invoked.
+ * Used when an IPath corresponds to more than one root */
+ Map oldOtherRoots;
+
+ /* A table from IPath (a source attachment path from a classpath entry) to IPath (a root path) */
+ Map sourceAttachments;
+
+ /* The java element that was last created (see createElement(IResource)).
* This is used as a stack of java elements (using getParent() to pop it, and
* using the various get*(...) to push it. */
Openable currentElement;
-
- /*
- * The type of the current event being processed (see ChangedElementEvent)
- */
- int currentEventType;
-
+
public HashMap externalTimeStamps = new HashMap();
public HashSet projectsToUpdate = new HashSet();
// list of root projects which namelookup caches need to be updated for dependents
+ // TODO: (jerome) is it needed? projectsToUpdate might be sufficient
public HashSet projectsForDependentNamelookupRefresh = new HashSet();
JavaModelManager manager;
-
- static final IJavaElementDelta[] NO_DELTA = new IJavaElementDelta[0];
-
+
+ /* A table from IJavaProject to an array of IPackageFragmentRoot.
+ * This table contains the pkg fragment roots of the project that are being deleted.
+ */
+ Map removedRoots;
+
+ /*
+ * A list of IJavaElement used as a scope for external archives refresh during POST_CHANGE.
+ * This is null if no refresh is needed.
+ */
+ HashSet refreshedElements;
public static boolean VERBOSE = false;
+
+ class OutputsInfo {
+ IPath[] paths;
+ int[] traverseModes;
+ int outputCount;
+ OutputsInfo(IPath[] paths, int[] traverseModes, int outputCount) {
+ this.paths = paths;
+ this.traverseModes = traverseModes;
+ this.outputCount = outputCount;
+ }
+ public String toString() {
+ if (this.paths == null) return "<none>"; //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < this.outputCount; i++) {
+ buffer.append("path="); //$NON-NLS-1$
+ buffer.append(this.paths[i].toString());
+ buffer.append("\n->traverse="); //$NON-NLS-1$
+ switch (this.traverseModes[i]) {
+ case BINARY:
+ buffer.append("BINARY"); //$NON-NLS-1$
+ break;
+ case IGNORE:
+ buffer.append("IGNORE"); //$NON-NLS-1$
+ break;
+ case SOURCE:
+ buffer.append("SOURCE"); //$NON-NLS-1$
+ break;
+ default:
+ buffer.append("<unknown>"); //$NON-NLS-1$
+ }
+ if (i+1 < this.outputCount) {
+ buffer.append('\n');
+ }
+ }
+ return buffer.toString();
+ }
+ }
+ class RootInfo {
+ IJavaProject project;
+ IPath rootPath;
+ char[][] exclusionPatterns;
+ RootInfo(IJavaProject project, IPath rootPath, char[][] exclusionPatterns) {
+ this.project = project;
+ this.rootPath = rootPath;
+ this.exclusionPatterns = exclusionPatterns;
+ }
+ boolean isRootOfProject(IPath path) {
+ return this.rootPath.equals(path) && this.project.getProject().getFullPath().isPrefixOf(path);
+ }
+ public String toString() {
+ StringBuffer buffer = new StringBuffer("project="); //$NON-NLS-1$
+ if (this.project == null) {
+ buffer.append("null"); //$NON-NLS-1$
+ } else {
+ buffer.append(this.project.getElementName());
+ }
+ buffer.append("\npath="); //$NON-NLS-1$
+ if (this.rootPath == null) {
+ buffer.append("null"); //$NON-NLS-1$
+ } else {
+ buffer.append(this.rootPath.toString());
+ }
+ buffer.append("\nexcluding="); //$NON-NLS-1$
+ if (this.exclusionPatterns == null) {
+ buffer.append("null"); //$NON-NLS-1$
+ } else {
+ for (int i = 0, length = this.exclusionPatterns.length; i < length; i++) {
+ buffer.append(new String(this.exclusionPatterns[i]));
+ if (i < length-1) {
+ buffer.append("|"); //$NON-NLS-1$
+ }
+ }
+ }
+ return buffer.toString();
+ }
+ }
DeltaProcessor(JavaModelManager manager) {
this.manager = manager;
@@ -109,10 +208,10 @@
*/
void addDependentProjects(IPath projectPath, HashSet result) {
try {
- IJavaProject[] projects = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProjects();
+ IJavaProject[] projects = this.manager.getJavaModel().getJavaProjects();
for (int i = 0, length = projects.length; i < length; i++) {
IJavaProject project = projects[i];
- IClasspathEntry[] classpath = project.getResolvedClasspath(true);
+ IClasspathEntry[] classpath = ((JavaProject)project).getExpandedClasspath(true);
for (int j = 0, length2 = classpath.length; j < length2; j++) {
IClasspathEntry entry = classpath[j];
if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT
@@ -125,6 +224,15 @@
}
}
/*
+ * Adds the given element to the list of elements used as a scope for external jars refresh.
+ */
+ public void addForRefresh(IJavaElement element) {
+ if (this.refreshedElements == null) {
+ this.refreshedElements = new HashSet();
+ }
+ this.refreshedElements.add(element);
+ }
+ /*
* Adds the given project and its dependents to the list of the projects
* to update.
*/
@@ -141,7 +249,7 @@
Openable parent = (Openable) child.getParent();
if (parent != null && parent.isOpen()) {
try {
- JavaElementInfo info = parent.getElementInfo();
+ JavaElementInfo info = (JavaElementInfo)parent.getElementInfo();
info.addChild(child);
} catch (JavaModelException e) {
// do nothing - we already checked if open
@@ -149,81 +257,64 @@
}
}
-
-
- /**
- * Closes the given element, which removes it from the cache of open elements.
- */
- protected static void close(Openable element) {
-
- try {
- element.close();
- } catch (JavaModelException e) {
- // do nothing
- }
- }
-
-
-private void cloneCurrentDelta(IJavaProject project, IPackageFragmentRoot root) {
- JavaElementDelta delta = (JavaElementDelta)fCurrentDelta.find(root);
- if (delta == null) return;
- JavaElementDelta clone = (JavaElementDelta)delta.clone(project);
- fCurrentDelta.insertDeltaTree(clone.getElement(), clone);
- switch (clone.getKind()) {
- case IJavaElementDelta.ADDED:
- this.addToParentInfo((Openable)clone.getElement());
- break;
- case IJavaElementDelta.REMOVED:
- Openable element = (Openable)clone.getElement();
- if (element.isOpen()) {
- try {
- element.close();
- } catch (JavaModelException e) {
- }
- }
- this.removeFromParentInfo(element);
- break;
- }
-}
-
-
- /**
- * Generic processing for elements with changed contents:<ul>
- * <li>The element is closed such that any subsequent accesses will re-open
- * the element reflecting its new structure.
- * <li>An entry is made in the delta reporting a content change (K_CHANGE with F_CONTENT flag set).
- * </ul>
- * Delta argument could be null if processing an external JAR change
- */
- protected void contentChanged(Openable element, IResourceDelta delta) {
-
- close(element);
- int flags = IJavaElementDelta.F_CONTENT;
- if (element instanceof JarPackageFragmentRoot){
- flags |= IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED;
- }
- fCurrentDelta.changed(element, flags);
- }
-
/**
* Check all external archive (referenced by given roots, projects or model) status and issue a corresponding root delta.
* Also triggers index updates
*/
public void checkExternalArchiveChanges(IJavaElement[] refreshedElements, IProgressMonitor monitor) throws JavaModelException {
try {
- HashMap externalArchivesStatus = new HashMap();
- JavaModel model = manager.getJavaModel();
+ for (int i = 0, length = refreshedElements.length; i < length; i++) {
+ this.addForRefresh(refreshedElements[i]);
+ }
+ boolean hasDelta = this.createExternalArchiveDelta(monitor);
+ if (monitor != null && monitor.isCanceled()) return;
+ if (hasDelta){
+ // force classpath marker refresh of affected projects
+ JavaModel.flushExternalFileCache();
+ IJavaElementDelta[] projectDeltas = this.currentDelta.getAffectedChildren();
+ for (int i = 0, length = projectDeltas.length; i < length; i++) {
+ IJavaElementDelta delta = projectDeltas[i];
+ ((JavaProject)delta.getElement()).getResolvedClasspath(
+ true, // ignoreUnresolvedEntry
+ true); // generateMarkerOnError
+ }
+ if (this.currentDelta != null) { // if delta has not been fired while creating markers
+ this.manager.fire(this.currentDelta, JavaModelManager.DEFAULT_CHANGE_EVENT);
+ }
+ }
+ } finally {
+ this.currentDelta = null;
+ if (monitor != null) monitor.done();
+ }
+ }
+ /*
+ * Check if external archives have changed and create the corresponding deltas.
+ * Returns whether at least on delta was created.
+ */
+ public boolean createExternalArchiveDelta(IProgressMonitor monitor) throws JavaModelException {
+
+ if (this.refreshedElements == null) return false;
- // find JARs to refresh
- HashSet archivePathsToRefresh = new HashSet();
- for (int i = 0, elementsLength = refreshedElements.length; i < elementsLength; i++){
- IJavaElement element = refreshedElements[i];
+ HashMap externalArchivesStatus = new HashMap();
+ boolean hasDelta = false;
+
+ // find JARs to refresh
+ HashSet archivePathsToRefresh = new HashSet();
+ try {
+ Iterator iterator = this.refreshedElements.iterator();
+ while (iterator.hasNext()) {
+ IJavaElement element = (IJavaElement)iterator.next();
switch(element.getElementType()){
case IJavaElement.PACKAGE_FRAGMENT_ROOT :
archivePathsToRefresh.add(element.getPath());
break;
case IJavaElement.JAVA_PROJECT :
- IClasspathEntry[] classpath = ((IJavaProject) element).getResolvedClasspath(true);
+ IJavaProject project = (IJavaProject) element;
+ if (!JavaProject.hasJavaNature(project.getProject())) {
+ // project is not accessible or has lost its Java nature
+ break;
+ }
+ IClasspathEntry[] classpath = project.getResolvedClasspath(true);
for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
if (classpath[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY){
archivePathsToRefresh.add(classpath[j].getPath());
@@ -233,7 +324,12 @@
case IJavaElement.JAVA_MODEL :
IJavaProject[] projects = manager.getJavaModel().getOldJavaProjectsList();
for (int j = 0, projectsLength = projects.length; j < projectsLength; j++){
- classpath = ((IJavaProject) projects[j]).getResolvedClasspath(true);
+ project = projects[j];
+ if (!JavaProject.hasJavaNature(project.getProject())) {
+ // project is not accessible or has lost its Java nature
+ continue;
+ }
+ classpath = project.getResolvedClasspath(true);
for (int k = 0, cpLength = classpath.length; k < cpLength; k++){
if (classpath[k].getEntryKind() == IClasspathEntry.CPE_LIBRARY){
archivePathsToRefresh.add(classpath[k].getPath());
@@ -243,116 +339,121 @@
break;
}
}
- // perform refresh
- fCurrentDelta = new JavaElementDelta(model);
- boolean hasDelta = false;
-
- IJavaProject[] projects = manager.getJavaModel().getOldJavaProjectsList();
- IWorkspaceRoot wksRoot = ResourcesPlugin.getWorkspace().getRoot();
- for (int i = 0, length = projects.length; i < length; i++) {
-
- if (monitor != null && monitor.isCanceled()) return;
-
- IJavaProject project = projects[i];
- IClasspathEntry[] entries = project.getResolvedClasspath(true);
- for (int j = 0; j < entries.length; j++){
- if (entries[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+ } finally {
+ this.refreshedElements = null;
+ }
+
+ // perform refresh
+ IJavaProject[] projects = manager.getJavaModel().getOldJavaProjectsList();
+ IWorkspaceRoot wksRoot = ResourcesPlugin.getWorkspace().getRoot();
+ for (int i = 0, length = projects.length; i < length; i++) {
+
+ if (monitor != null && monitor.isCanceled()) break;
+
+ IJavaProject project = projects[i];
+ if (!JavaProject.hasJavaNature(project.getProject())) {
+ // project is not accessible or has lost its Java nature
+ continue;
+ }
+ IClasspathEntry[] entries = project.getResolvedClasspath(true);
+ for (int j = 0; j < entries.length; j++){
+ if (entries[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+
+ IPath entryPath = entries[j].getPath();
+
+ if (!archivePathsToRefresh.contains(entryPath)) continue; // not supposed to be refreshed
+
+ String status = (String)externalArchivesStatus.get(entryPath);
+ if (status == null){
- IPath entryPath = entries[j].getPath();
-
- if (!archivePathsToRefresh.contains(entryPath)) continue; // not supposed to be refreshed
-
- String status = (String)externalArchivesStatus.get(entryPath);
- if (status == null){
+ // compute shared status
+ Object targetLibrary = JavaModel.getTarget(wksRoot, entryPath, true);
+
+ if (targetLibrary == null){ // missing JAR
+ if (this.externalTimeStamps.containsKey(entryPath)){
+ this.externalTimeStamps.remove(entryPath);
+ externalArchivesStatus.put(entryPath, EXTERNAL_JAR_REMOVED);
+ // the jar was physically removed: remove the index
+ indexManager.removeIndex(entryPath);
+ }
+
+ } else if (targetLibrary instanceof File){ // external JAR
+
+ File externalFile = (File)targetLibrary;
- // compute shared status
- Object targetLibrary = JavaModel.getTarget(wksRoot, entryPath, true);
-
- if (targetLibrary == null){ // missing JAR
- if (this.externalTimeStamps.containsKey(entryPath)){
- this.externalTimeStamps.remove(entryPath);
+ // check timestamp to figure if JAR has changed in some way
+ Long oldTimestamp =(Long) this.externalTimeStamps.get(entryPath);
+ long newTimeStamp = getTimeStamp(externalFile);
+ if (oldTimestamp != null){
+
+ if (newTimeStamp == 0){ // file doesn't exist
externalArchivesStatus.put(entryPath, EXTERNAL_JAR_REMOVED);
- // the jar was physically removed: remove the index
+ this.externalTimeStamps.remove(entryPath);
+ // remove the index
indexManager.removeIndex(entryPath);
- }
-
- } else if (targetLibrary instanceof File){ // external JAR
-
- File externalFile = (File)targetLibrary;
-
- // check timestamp to figure if JAR has changed in some way
- Long oldTimestamp =(Long) this.externalTimeStamps.get(entryPath);
- long newTimeStamp = getTimeStamp(externalFile);
- if (oldTimestamp != null){
-
- if (newTimeStamp == 0){ // file doesn't exist
- externalArchivesStatus.put(entryPath, EXTERNAL_JAR_REMOVED);
- this.externalTimeStamps.remove(entryPath);
- // remove the index
- indexManager.removeIndex(entryPath);
-
- } else if (oldTimestamp.longValue() != newTimeStamp){
- externalArchivesStatus.put(entryPath, EXTERNAL_JAR_CHANGED);
- this.externalTimeStamps.put(entryPath, new Long(newTimeStamp));
- // first remove the index so that it is forced to be re-indexed
- indexManager.removeIndex(entryPath);
- // then index the jar
- indexManager.indexLibrary(entryPath, project.getProject());
- } else {
- externalArchivesStatus.put(entryPath, EXTERNAL_JAR_UNCHANGED);
- }
+
+ } else if (oldTimestamp.longValue() != newTimeStamp){
+ externalArchivesStatus.put(entryPath, EXTERNAL_JAR_CHANGED);
+ this.externalTimeStamps.put(entryPath, new Long(newTimeStamp));
+ // first remove the index so that it is forced to be re-indexed
+ indexManager.removeIndex(entryPath);
+ // then index the jar
+ indexManager.indexLibrary(entryPath, project.getProject());
} else {
- if (newTimeStamp == 0){ // jar still doesn't exist
- externalArchivesStatus.put(entryPath, EXTERNAL_JAR_UNCHANGED);
- } else {
- externalArchivesStatus.put(entryPath, EXTERNAL_JAR_ADDED);
- this.externalTimeStamps.put(entryPath, new Long(newTimeStamp));
- // index the new jar
- indexManager.indexLibrary(entryPath, project.getProject());
- }
+ externalArchivesStatus.put(entryPath, EXTERNAL_JAR_UNCHANGED);
}
- } else { // internal JAR
- externalArchivesStatus.put(entryPath, INTERNAL_JAR_IGNORE);
+ } else {
+ if (newTimeStamp == 0){ // jar still doesn't exist
+ externalArchivesStatus.put(entryPath, EXTERNAL_JAR_UNCHANGED);
+ } else {
+ externalArchivesStatus.put(entryPath, EXTERNAL_JAR_ADDED);
+ this.externalTimeStamps.put(entryPath, new Long(newTimeStamp));
+ // index the new jar
+ indexManager.indexLibrary(entryPath, project.getProject());
+ }
}
+ } else { // internal JAR
+ externalArchivesStatus.put(entryPath, INTERNAL_JAR_IGNORE);
}
- // according to computed status, generate a delta
- status = (String)externalArchivesStatus.get(entryPath);
- if (status != null){
- if (status == EXTERNAL_JAR_ADDED){
- PackageFragmentRoot root = (PackageFragmentRoot)project.getPackageFragmentRoot(entryPath.toString());
- if (VERBOSE){
- System.out.println("- External JAR ADDED, affecting root: "+root.getElementName()); //$NON-NLS-1$
- }
- elementAdded(root, null);
- hasDelta = true;
- } else if (status == EXTERNAL_JAR_CHANGED) {
- PackageFragmentRoot root = (PackageFragmentRoot)project.getPackageFragmentRoot(entryPath.toString());
- if (VERBOSE){
- System.out.println("- External JAR CHANGED, affecting root: "+root.getElementName()); //$NON-NLS-1$
- }
- // reset the corresponding project built state, since the builder would miss this change
- this.manager.setLastBuiltState(project.getProject(), null /*no state*/);
- contentChanged(root, null);
- hasDelta = true;
- } else if (status == EXTERNAL_JAR_REMOVED) {
- PackageFragmentRoot root = (PackageFragmentRoot)project.getPackageFragmentRoot(entryPath.toString());
- if (VERBOSE){
- System.out.println("- External JAR REMOVED, affecting root: "+root.getElementName()); //$NON-NLS-1$
- }
- elementRemoved(root, null);
- hasDelta = true;
+ }
+ // according to computed status, generate a delta
+ status = (String)externalArchivesStatus.get(entryPath);
+ if (status != null){
+ if (status == EXTERNAL_JAR_ADDED){
+ PackageFragmentRoot root = (PackageFragmentRoot)project.getPackageFragmentRoot(entryPath.toString());
+ if (VERBOSE){
+ System.out.println("- External JAR ADDED, affecting root: "+root.getElementName()); //$NON-NLS-1$
+ }
+ elementAdded(root, null, null);
+ hasDelta = true;
+ } else if (status == EXTERNAL_JAR_CHANGED) {
+ PackageFragmentRoot root = (PackageFragmentRoot)project.getPackageFragmentRoot(entryPath.toString());
+ if (VERBOSE){
+ System.out.println("- External JAR CHANGED, affecting root: "+root.getElementName()); //$NON-NLS-1$
}
+ // reset the corresponding project built state, since the builder would miss this change
+ this.manager.setLastBuiltState(project.getProject(), null /*no state*/);
+ contentChanged(root, null);
+ hasDelta = true;
+ } else if (status == EXTERNAL_JAR_REMOVED) {
+ PackageFragmentRoot root = (PackageFragmentRoot)project.getPackageFragmentRoot(entryPath.toString());
+ if (VERBOSE){
+ System.out.println("- External JAR REMOVED, affecting root: "+root.getElementName()); //$NON-NLS-1$
+ }
+ elementRemoved(root, null, null);
+ hasDelta = true;
}
}
}
}
- if (hasDelta){
- this.manager.fire(fCurrentDelta, JavaModelManager.DEFAULT_CHANGE_EVENT);
- }
- } finally {
- fCurrentDelta = null;
- if (monitor != null) monitor.done();
}
+ return hasDelta;
+ }
+ JavaElementDelta currentDelta() {
+ if (this.currentDelta == null) {
+ this.currentDelta = new JavaElementDelta(this.manager.getJavaModel());
+ }
+ return this.currentDelta;
}
/*
@@ -390,7 +491,7 @@
this.addToProjectsToUpdateWithDependents(project);
// workaround for bug 15168 circular errors not reported
- if (this.hasJavaNature(project)) {
+ if (JavaProject.hasJavaNature(project)) {
this.addToParentInfo((JavaProject)JavaCore.create(project));
}
@@ -402,7 +503,7 @@
// workaround for bug 15168 circular errors not reported
if (project.isOpen()) {
- if (this.hasJavaNature(project)) {
+ if (JavaProject.hasJavaNature(project)) {
this.addToParentInfo((JavaProject)JavaCore.create(project));
}
} else {
@@ -417,7 +518,7 @@
}
} else if ((delta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
boolean wasJavaProject = this.manager.getJavaModel().findJavaProject(project) != null;
- boolean isJavaProject = this.hasJavaNature(project);
+ boolean isJavaProject = JavaProject.hasJavaNature(project);
if (wasJavaProject != isJavaProject) {
// java nature added or removed: remember project and its dependents
this.addToProjectsToUpdateWithDependents(project);
@@ -427,6 +528,18 @@
this.addToParentInfo((JavaProject)JavaCore.create(project));
} else {
JavaProject javaProject = (JavaProject)JavaCore.create(project);
+
+ // flush classpath markers
+ javaProject.
+ flushClasspathProblemMarkers(
+ true, // flush cycle markers
+ true //flush classpath format markers
+ );
+
+ // remove problems and tasks created by the builder
+ JavaBuilder.removeProblemsAndTasksFor(project);
+
+ // close project
try {
javaProject.close();
} catch (JavaModelException e) {
@@ -435,14 +548,14 @@
}
} else {
// in case the project was removed then added then changed (see bug 19799)
- if (this.hasJavaNature(project)) { // need nature check - 18698
+ if (JavaProject.hasJavaNature(project)) { // need nature check - 18698
this.addToParentInfo((JavaProject)JavaCore.create(project));
}
}
} else {
// workaround for bug 15168 circular errors not reported
// in case the project was removed then added then changed
- if (this.hasJavaNature(project)) { // need nature check - 18698
+ if (JavaProject.hasJavaNature(project)) { // need nature check - 18698
this.addToParentInfo((JavaProject)JavaCore.create(project));
}
}
@@ -451,11 +564,72 @@
}
}
+ private void checkSourceAttachmentChange(IResourceDelta delta, IResource res) {
+ IPath rootPath = (IPath)this.sourceAttachments.get(res.getFullPath());
+ if (rootPath != null) {
+ RootInfo rootInfo = this.rootInfo(rootPath, delta.getKind());
+ if (rootInfo != null) {
+ IJavaProject projectOfRoot = rootInfo.project;
+ IPackageFragmentRoot root = null;
+ try {
+ // close the root so that source attachement cache is flushed
+ root = projectOfRoot.findPackageFragmentRoot(rootPath);
+ if (root != null) {
+ root.close();
+ }
+ } catch (JavaModelException e) {
+ }
+ if (root == null) return;
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ currentDelta().sourceAttached(root);
+ break;
+ case IResourceDelta.CHANGED:
+ currentDelta().sourceDetached(root);
+ currentDelta().sourceAttached(root);
+ break;
+ case IResourceDelta.REMOVED:
+ currentDelta().sourceDetached(root);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Closes the given element, which removes it from the cache of open elements.
+ */
+ protected static void close(Openable element) {
+
+ try {
+ element.close();
+ } catch (JavaModelException e) {
+ // do nothing
+ }
+ }
+ /**
+ * Generic processing for elements with changed contents:<ul>
+ * <li>The element is closed such that any subsequent accesses will re-open
+ * the element reflecting its new structure.
+ * <li>An entry is made in the delta reporting a content change (K_CHANGE with F_CONTENT flag set).
+ * </ul>
+ * Delta argument could be null if processing an external JAR change
+ */
+ protected void contentChanged(Openable element, IResourceDelta delta) {
+
+ close(element);
+ int flags = IJavaElementDelta.F_CONTENT;
+ if (element instanceof JarPackageFragmentRoot){
+ flags |= IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED;
+ }
+ currentDelta().changed(element, flags);
+ }
+
/**
* Creates the openables corresponding to this resource.
* Returns null if none was found.
*/
- protected Openable createElement(IResource resource, int elementType, IJavaProject project) {
+ protected Openable createElement(IResource resource, int elementType, RootInfo rootInfo) {
if (resource == null) return null;
IPath path = resource.getFullPath();
@@ -475,13 +649,12 @@
&& ((IJavaProject)this.currentElement).getProject().equals(resource)) {
return this.currentElement;
}
- if (project != null && project.getProject().equals(resource)){
- element = (Openable)project;
+ if (rootInfo != null && rootInfo.project.getProject().equals(resource)){
+ element = (Openable)rootInfo.project;
break;
}
IProject proj = (IProject)resource;
- boolean isOpened = proj.isOpen();
- if (isOpened && this.hasJavaNature(proj)) {
+ if (JavaProject.hasJavaNature(proj)) {
element = JavaCore.create(proj);
} else {
// java project may have been been closed or removed (look for
@@ -491,20 +664,20 @@
}
break;
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
- element = project == null ? JavaCore.create(resource) : project.getPackageFragmentRoot(resource);
+ element = rootInfo == null ? JavaCore.create(resource) : rootInfo.project.getPackageFragmentRoot(resource);
break;
case IJavaElement.PACKAGE_FRAGMENT:
// find the element that encloses the resource
this.popUntilPrefixOf(path);
if (this.currentElement == null) {
- element = JavaModelManager.getJavaModelManager().create(resource, project);
+ element = rootInfo == null ? JavaCore.create(resource) : JavaModelManager.create(resource, rootInfo.project);
} else {
// find the root
IPackageFragmentRoot root = this.currentElement.getPackageFragmentRoot();
if (root == null) {
- element = JavaModelManager.getJavaModelManager().create(resource, project);
- } else if (!JavaModelManager.conflictsWithOutputLocation(path, (JavaProject)root.getJavaProject())) {
+ element = rootInfo == null ? JavaCore.create(resource) : JavaModelManager.create(resource, rootInfo.project);
+ } else if (((JavaProject)root.getJavaProject()).contains(resource)) {
// create package handle
IPath pkgPath = path.removeFirstSegments(root.getPath().segmentCount());
String pkg = Util.packageName(pkgPath);
@@ -519,7 +692,7 @@
this.popUntilPrefixOf(path);
if (this.currentElement == null) {
- element = element = JavaModelManager.getJavaModelManager().create(resource, project);
+ element = rootInfo == null ? JavaCore.create(resource) : JavaModelManager.create(resource, rootInfo.project);
} else {
// find the package
IPackageFragment pkgFragment = null;
@@ -545,7 +718,7 @@
break;
}
if (pkgFragment == null) {
- element = JavaModelManager.getJavaModelManager().create(resource, project);
+ element = rootInfo == null ? JavaCore.create(resource) : JavaModelManager.create(resource, rootInfo.project);
} else {
if (elementType == IJavaElement.COMPILATION_UNIT) {
// create compilation unit handle
@@ -575,7 +748,27 @@
public void deleting(IProject project) {
try {
+ // discard indexing jobs that belong to this project so that the project can be
+ // deleted without interferences from the index manager
+ this.indexManager.discardJobs(project.getName());
+
JavaProject javaProject = (JavaProject)JavaCore.create(project);
+
+ // remember roots of this project
+ if (this.removedRoots == null) {
+ this.removedRoots = new HashMap();
+ }
+ if (javaProject.isOpen()) {
+ this.removedRoots.put(javaProject, javaProject.getPackageFragmentRoots());
+ } else {
+ // compute roots without opening project
+ this.removedRoots.put(
+ javaProject,
+ javaProject.computePackageFragmentRoots(
+ javaProject.getResolvedClasspath(true),
+ false));
+ }
+
javaProject.close();
// workaround for bug 15168 circular errors not reported
@@ -590,6 +783,7 @@
this.addDependentProjects(project.getFullPath(), this.projectsToUpdate);
}
+
/**
* Processing for an element that has been added:<ul>
* <li>If the element is a project, do nothing, and do not process
@@ -600,22 +794,23 @@
* </ul>
* Delta argument could be null if processing an external JAR change
*/
- protected void elementAdded(Openable element, IResourceDelta delta) {
+ protected void elementAdded(Openable element, IResourceDelta delta, RootInfo rootInfo) {
int elementType = element.getElementType();
if (elementType == IJavaElement.JAVA_PROJECT) {
// project add is handled by JavaProject.configure() because
// when a project is created, it does not yet have a java nature
- if (delta != null && hasJavaNature((IProject)delta.getResource())) {
+ if (delta != null && JavaProject.hasJavaNature((IProject)delta.getResource())) {
addToParentInfo(element);
if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
Openable movedFromElement = (Openable)element.getJavaModel().getJavaProject(delta.getMovedFromPath().lastSegment());
- fCurrentDelta.movedTo(element, movedFromElement);
+ currentDelta().movedTo(element, movedFromElement);
} else {
- fCurrentDelta.added(element);
+ currentDelta().added(element);
}
this.projectsToUpdate.add(element);
this.updateRoots(element.getPath(), delta);
+ this.projectsForDependentNamelookupRefresh.add((JavaProject) element);
}
} else {
addToParentInfo(element);
@@ -642,31 +837,30 @@
}
// find the element type of the moved from element
- IJavaProject projectOfRoot = (IJavaProject)this.roots.get(movedFromPath);
- boolean isPkgFragmentRoot =
- projectOfRoot != null
- && (projectOfRoot.getProject().getFullPath().isPrefixOf(movedFromPath));
+ RootInfo movedFromInfo = this.enclosingRootInfo(movedFromPath, IResourceDelta.REMOVED);
int movedFromType =
this.elementType(
movedFromRes,
- delta.getKind(),
- delta.getFlags(),
+ IResourceDelta.REMOVED,
element.getParent().getElementType(),
- isPkgFragmentRoot);
+ movedFromInfo);
+ // reset current element as it might be inside a nested root (popUntilPrefixOf() may use the outer root)
+ this.currentElement = null;
+
// create the moved from element
Openable movedFromElement =
elementType != IJavaElement.JAVA_PROJECT && movedFromType == IJavaElement.JAVA_PROJECT ?
null : // outside classpath
- this.createElement(movedFromRes, movedFromType, null); // pass null for the project in case the element is moving to another project
+ this.createElement(movedFromRes, movedFromType, movedFromInfo);
if (movedFromElement == null) {
// moved from outside classpath
- fCurrentDelta.added(element);
+ currentDelta().added(element);
} else {
- fCurrentDelta.movedTo(element, movedFromElement);
+ currentDelta().movedTo(element, movedFromElement);
}
} else {
- fCurrentDelta.added(element);
+ currentDelta().added(element);
}
switch (elementType) {
@@ -694,13 +888,16 @@
IResourceDelta child = children[i];
IResource resource = child.getResource();
if (resource instanceof IFolder) {
- String subpkgName =
- name.length() == 0 ?
- resource.getName() :
- name + "." + resource.getName(); //$NON-NLS-1$
- Openable subpkg = (Openable)root.getPackageFragment(subpkgName);
- this.updateIndex(subpkg, child);
- this.elementAdded(subpkg, child);
+ String folderName = resource.getName();
+ if (Util.isValidFolderNameForPackage(folderName)) {
+ String subpkgName =
+ name.length() == 0 ?
+ folderName :
+ name + "." + folderName; //$NON-NLS-1$
+ Openable subpkg = (Openable)root.getPackageFragment(subpkgName);
+ this.updateIndex(subpkg, child);
+ this.elementAdded(subpkg, child, rootInfo);
+ }
}
}
}
@@ -709,10 +906,6 @@
}
}
-
-
-
-
/**
* Generic processing for a removed element:<ul>
* <li>Close the element, removing its structure from the cache
@@ -721,7 +914,7 @@
* </ul>
* Delta argument could be null if processing an external JAR change
*/
- protected void elementRemoved(Openable element, IResourceDelta delta) {
+ protected void elementRemoved(Openable element, IResourceDelta delta, RootInfo rootInfo) {
if (element.isOpen()) {
close(element);
@@ -747,31 +940,30 @@
}
// find the element type of the moved from element
- IJavaProject projectOfRoot = (IJavaProject)this.roots.get(movedToPath);
- boolean isPkgFragmentRoot =
- projectOfRoot != null
- && (projectOfRoot.getProject().getFullPath().isPrefixOf(movedToPath));
+ RootInfo movedToInfo = this.enclosingRootInfo(movedToPath, IResourceDelta.ADDED);
int movedToType =
this.elementType(
movedToRes,
- delta.getKind(),
- delta.getFlags(),
+ IResourceDelta.ADDED,
element.getParent().getElementType(),
- isPkgFragmentRoot);
+ movedToInfo);
+
+ // reset current element as it might be inside a nested root (popUntilPrefixOf() may use the outer root)
+ this.currentElement = null;
// create the moved To element
Openable movedToElement =
elementType != IJavaElement.JAVA_PROJECT && movedToType == IJavaElement.JAVA_PROJECT ?
null : // outside classpath
- this.createElement(movedToRes, movedToType, null); // pass null for the project in case the element is moving to another project
+ this.createElement(movedToRes, movedToType, movedToInfo);
if (movedToElement == null) {
// moved outside classpath
- fCurrentDelta.removed(element);
+ currentDelta().removed(element);
} else {
- fCurrentDelta.movedFrom(element, movedToElement);
+ currentDelta().movedFrom(element, movedToElement);
}
} else {
- fCurrentDelta.removed(element);
+ currentDelta().removed(element);
}
switch (elementType) {
@@ -779,9 +971,10 @@
this.indexManager.reset();
break;
case IJavaElement.JAVA_PROJECT :
- JavaModelManager.getJavaModelManager().removePerProjectInfo(
+ this.manager.removePerProjectInfo(
(JavaProject) element);
this.updateRoots(element.getPath(), delta);
+ this.projectsForDependentNamelookupRefresh.add((JavaProject) element);
break;
case IJavaElement.PACKAGE_FRAGMENT_ROOT :
JavaProject project = (JavaProject) element.getJavaProject();
@@ -805,13 +998,16 @@
IResourceDelta child = children[i];
IResource resource = child.getResource();
if (resource instanceof IFolder) {
- String subpkgName =
- name.length() == 0 ?
- resource.getName() :
- name + "." + resource.getName(); //$NON-NLS-1$
- Openable subpkg = (Openable)root.getPackageFragment(subpkgName);
- this.updateIndex(subpkg, child);
- this.elementRemoved(subpkg, child);
+ String folderName = resource.getName();
+ if (Util.isValidFolderNameForPackage(folderName)) {
+ String subpkgName =
+ name.length() == 0 ?
+ folderName :
+ name + "." + folderName; //$NON-NLS-1$
+ Openable subpkg = (Openable)root.getPackageFragment(subpkgName);
+ this.updateIndex(subpkg, child);
+ this.elementRemoved(subpkg, child, rootInfo);
+ }
}
}
}
@@ -819,40 +1015,54 @@
}
}
- /**
- * Filters the generated <code>JavaElementDelta</code>s to remove those
- * which should not be fired (because they don't represent a real change
- * in the Java Model).
+ /*
+ * Returns the type of the java element the given delta matches to.
+ * Returns NON_JAVA_RESOURCE if unknown (e.g. a non-java resource or excluded .java file)
*/
- protected IJavaElementDelta[] filterRealDeltas(IJavaElementDelta[] deltas) {
-
- int length = deltas.length;
- IJavaElementDelta[] realDeltas = null;
- int index = 0;
- for (int i = 0; i < length; i++) {
- JavaElementDelta delta = (JavaElementDelta)deltas[i];
- if (delta == null) {
- continue;
- }
- if (delta.getAffectedChildren().length > 0
- || delta.getKind() == IJavaElementDelta.ADDED
- || delta.getKind() == IJavaElementDelta.REMOVED
- || (delta.getFlags() & IJavaElementDelta.F_CLOSED) != 0
- || (delta.getFlags() & IJavaElementDelta.F_OPENED) != 0
- || delta.resourceDeltasCounter > 0) {
-
- if (realDeltas == null) {
- realDeltas = new IJavaElementDelta[length];
+ private int elementType(IResource res, int kind, int parentType, RootInfo rootInfo) {
+ switch (parentType) {
+ case IJavaElement.JAVA_MODEL:
+ // case of a movedTo or movedFrom project (other cases are handled in processResourceDelta(...)
+ return IJavaElement.JAVA_PROJECT;
+ case NON_JAVA_RESOURCE:
+ case IJavaElement.JAVA_PROJECT:
+ if (rootInfo == null) {
+ rootInfo = this.enclosingRootInfo(res.getFullPath(), kind);
}
- realDeltas[index++] = delta;
- }
- }
- if (index > 0) {
- IJavaElementDelta[] result = new IJavaElementDelta[index];
- System.arraycopy(realDeltas, 0, result, 0, index);
- return result;
- } else {
- return NO_DELTA;
+ if (rootInfo != null && rootInfo.isRootOfProject(res.getFullPath())) {
+ return IJavaElement.PACKAGE_FRAGMENT_ROOT;
+ } else {
+ return NON_JAVA_RESOURCE; // not yet in a package fragment root or root of another project
+ }
+ case IJavaElement.PACKAGE_FRAGMENT_ROOT:
+ case IJavaElement.PACKAGE_FRAGMENT:
+ if (rootInfo == null) {
+ rootInfo = this.enclosingRootInfo(res.getFullPath(), kind);
+ }
+ if (rootInfo == null || Util.isExcluded(res, rootInfo.exclusionPatterns)) {
+ return NON_JAVA_RESOURCE;
+ }
+ if (res instanceof IFolder) {
+ if (Util.isValidFolderNameForPackage(res.getName())) {
+ return IJavaElement.PACKAGE_FRAGMENT;
+ } else {
+ return NON_JAVA_RESOURCE;
+ }
+ } else {
+ String fileName = res.getName();
+ if (Util.isValidCompilationUnitName(fileName)) {
+ return IJavaElement.COMPILATION_UNIT;
+ } else if (Util.isValidClassFileName(fileName)) {
+ return IJavaElement.CLASS_FILE;
+ } else if (this.rootInfo(res.getFullPath(), kind) != null) {
+ // case of proj=src=bin and resource is a jar file on the classpath
+ return IJavaElement.PACKAGE_FRAGMENT_ROOT;
+ } else {
+ return NON_JAVA_RESOURCE;
+ }
+ }
+ default:
+ return NON_JAVA_RESOURCE;
}
}
@@ -863,27 +1073,145 @@
public static long getTimeStamp(File file) {
return file.lastModified() + file.length();
}
-/**
- * Returns true if the given resource is contained in an open project
- * with a java nature, otherwise false.
- */
-protected boolean hasJavaNature(IResource resource) {
- // ensure the project has a java nature (if open)
- IProject project = resource.getProject();
- if (project.isOpen()) {
+
+ public void initializeRoots() {
+ // remember roots infos as old roots infos
+ this.oldRoots = this.roots == null ? new HashMap() : this.roots;
+ this.oldOtherRoots = this.otherRoots == null ? new HashMap() : this.otherRoots;
+
+ // recompute root infos only if necessary
+ if (!rootsAreStale) return;
+
+ this.roots = new HashMap();
+ this.otherRoots = new HashMap();
+ this.sourceAttachments = new HashMap();
+
+ IJavaModel model = this.manager.getJavaModel();
+ IJavaProject[] projects;
try {
- return project.hasNature(JavaCore.NATURE_ID);
- } catch (CoreException e) {
- // do nothing
+ projects = model.getJavaProjects();
+ } catch (JavaModelException e) {
+ // nothing can be done
+ return;
}
+ for (int i = 0, length = projects.length; i < length; i++) {
+ IJavaProject project = projects[i];
+ IClasspathEntry[] classpath;
+ try {
+ classpath = project.getResolvedClasspath(true);
+ } catch (JavaModelException e) {
+ // continue with next project
+ continue;
+ }
+ for (int j= 0, classpathLength = classpath.length; j < classpathLength; j++) {
+ IClasspathEntry entry = classpath[j];
+ if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) continue;
+
+ // root path
+ IPath path = entry.getPath();
+ if (this.roots.get(path) == null) {
+ this.roots.put(path, new RootInfo(project, path, ((ClasspathEntry)entry).fullExclusionPatternChars()));
+ } else {
+ ArrayList rootList = (ArrayList)this.otherRoots.get(path);
+ if (rootList == null) {
+ rootList = new ArrayList();
+ this.otherRoots.put(path, rootList);
+ }
+ rootList.add(new RootInfo(project, path, ((ClasspathEntry)entry).fullExclusionPatternChars()));
+ }
+
+ // source attachment path
+ if (entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY) continue;
+ QualifiedName qName = new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + path.toOSString()); //$NON-NLS-1$;
+ String propertyString = null;
+ try {
+ propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
+ } catch (CoreException e) {
+ continue;
+ }
+ IPath sourceAttachmentPath;
+ if (propertyString != null) {
+ int index= propertyString.lastIndexOf(JarPackageFragmentRoot.ATTACHMENT_PROPERTY_DELIMITER);
+ sourceAttachmentPath = (index < 0) ? new Path(propertyString) : new Path(propertyString.substring(0, index));
+ } else {
+ sourceAttachmentPath = entry.getSourceAttachmentPath();
+ }
+ if (sourceAttachmentPath != null) {
+ this.sourceAttachments.put(sourceAttachmentPath, path);
+ }
+ }
+ }
+ this.rootsAreStale = false;
}
- return false;
-}
+ /*
+ * Returns whether a given delta contains some information relevant to the JavaModel,
+ * in particular it will not consider SYNC or MARKER only deltas.
+ */
+ public boolean isAffectedBy(IResourceDelta rootDelta){
+ //if (rootDelta == null) System.out.println("NULL DELTA");
+ //long start = System.currentTimeMillis();
+ if (rootDelta != null) {
+ // use local exception to quickly escape from delta traversal
+ class FoundRelevantDeltaException extends RuntimeException {}
+ try {
+ rootDelta.accept(new IResourceDeltaVisitor() {
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ switch (delta.getKind()){
+ case IResourceDelta.ADDED :
+ case IResourceDelta.REMOVED :
+ throw new FoundRelevantDeltaException();
+ case IResourceDelta.CHANGED :
+ // if any flag is set but SYNC or MARKER, this delta should be considered
+ if (delta.getAffectedChildren().length == 0 // only check leaf delta nodes
+ && (delta.getFlags() & ~(IResourceDelta.SYNC | IResourceDelta.MARKERS)) != 0) {
+ throw new FoundRelevantDeltaException();
+ }
+ }
+ return true;
+ }
+ });
+ } catch(FoundRelevantDeltaException e) {
+ //System.out.println("RELEVANT DELTA detected in: "+ (System.currentTimeMillis() - start));
+ return true;
+ } catch(CoreException e) { // ignore delta if not able to traverse
+ }
+ }
+ //System.out.println("IGNORE SYNC DELTA took: "+ (System.currentTimeMillis() - start));
+ return false;
+ }
+
+ /*
+ * Returns whether the given resource is in one of the given output folders and if
+ * it is filtered out from this output folder.
+ */
+ private boolean isResFilteredFromOutput(OutputsInfo info, IResource res, int elementType) {
+ if (info != null) {
+ IPath resPath = res.getFullPath();
+ for (int i = 0; i < info.outputCount; i++) {
+ if (info.paths[i].isPrefixOf(resPath)) {
+ if (info.traverseModes[i] != IGNORE) {
+ // case of bin=src
+ if (info.traverseModes[i] == SOURCE && elementType == IJavaElement.CLASS_FILE) {
+ return true;
+ } else {
+ // case of .class file under project and no source folder
+ // proj=bin
+ if (elementType == IJavaElement.JAVA_PROJECT
+ && res instanceof IFile
+ && Util.isValidClassFileName(res.getName())) {
+ return true;
+ }
+ }
+ } else {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
-private JavaModelException newInvalidElementType() {
- return new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES));
-}
/**
* Generic processing for elements with changed contents:<ul>
* <li>The element is closed such that any subsequent accesses will re-open
@@ -896,15 +1224,19 @@
// reset non-java resources if element was open
if (element.isOpen()) {
- JavaElementInfo info = element.getElementInfo();
+ JavaElementInfo info = (JavaElementInfo)element.getElementInfo();
switch (element.getElementType()) {
+ case IJavaElement.JAVA_MODEL :
+ ((JavaModelInfo) info).nonJavaResources = null;
+ currentDelta().addResourceDelta(delta);
+ return;
case IJavaElement.JAVA_PROJECT :
((JavaProjectElementInfo) info).setNonJavaResources(null);
// if a package fragment root is the project, clear it too
+ JavaProject project = (JavaProject) element;
PackageFragmentRoot projectRoot =
- (PackageFragmentRoot) ((JavaProject) element).getPackageFragmentRoot(
- new Path(IPackageFragment.DEFAULT_PACKAGE_NAME));
+ (PackageFragmentRoot) project.getPackageFragmentRoot(project.getProject());
if (projectRoot.isOpen()) {
((PackageFragmentRootInfo) projectRoot.getElementInfo()).setNonJavaResources(
null);
@@ -918,13 +1250,57 @@
}
}
- JavaElementDelta elementDelta = fCurrentDelta.find(element);
+ JavaElementDelta elementDelta = currentDelta().find(element);
if (elementDelta == null) {
- fCurrentDelta.changed(element, IJavaElementDelta.F_CONTENT);
- elementDelta = fCurrentDelta.find(element);
+ currentDelta().changed(element, IJavaElementDelta.F_CONTENT);
+ elementDelta = currentDelta().find(element);
}
elementDelta.addResourceDelta(delta);
}
+ private OutputsInfo outputsInfo(RootInfo rootInfo, IResource res) {
+ try {
+ IJavaProject proj =
+ rootInfo == null ?
+ (IJavaProject)this.createElement(res.getProject(), IJavaElement.JAVA_PROJECT, null) :
+ rootInfo.project;
+ if (proj != null) {
+ IPath projectOutput = proj.getOutputLocation();
+ int traverseMode = IGNORE;
+ if (proj.getProject().getFullPath().equals(projectOutput)){ // case of proj==bin==src
+ return new OutputsInfo(new IPath[] {projectOutput}, new int[] {SOURCE}, 1);
+ } else {
+ IClasspathEntry[] classpath = proj.getResolvedClasspath(true);
+ IPath[] outputs = new IPath[classpath.length+1];
+ int[] traverseModes = new int[classpath.length+1];
+ int outputCount = 1;
+ outputs[0] = projectOutput;
+ traverseModes[0] = traverseMode;
+ for (int i = 0, length = classpath.length; i < length; i++) {
+ IClasspathEntry entry = classpath[i];
+ IPath entryPath = entry.getPath();
+ IPath output = entry.getOutputLocation();
+ if (output != null) {
+ outputs[outputCount] = output;
+ // check case of src==bin
+ if (entryPath.equals(output)) {
+ traverseModes[outputCount++] = (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) ? SOURCE : BINARY;
+ } else {
+ traverseModes[outputCount++] = IGNORE;
+ }
+ }
+
+ // check case of src==bin
+ if (entryPath.equals(projectOutput)) {
+ traverseModes[0] = (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) ? SOURCE : BINARY;
+ }
+ }
+ return new OutputsInfo(outputs, traverseModes, outputCount);
+ }
+ }
+ } catch (JavaModelException e) {
+ }
+ return null;
+ }
/**
* Check whether the updated file is affecting some of the properties of a given project (like
@@ -938,20 +1314,43 @@
IJavaElement parent) {
IResource resource = delta.getResource();
- IJavaElement element = JavaCore.create(resource);
+ IJavaElement element = null;
boolean processChildren = false;
switch (resource.getType()) {
case IResource.ROOT :
if (delta.getKind() == IResourceDelta.CHANGED) {
+ element = JavaCore.create(resource);
processChildren = true;
}
break;
case IResource.PROJECT :
- // do not visit non-java projects (see bug 16140 Non-java project gets .classpath)
- if (delta.getKind() == IResourceDelta.CHANGED && this.hasJavaNature(resource)) {
- processChildren = true;
+ int kind = delta.getKind();
+ switch (kind) {
+ case IResourceDelta.CHANGED:
+ // do not visit non-java projects (see bug 16140 Non-java project gets .classpath)
+ IProject project = (IProject)resource;
+ if (JavaProject.hasJavaNature(project)) {
+ element = JavaCore.create(resource);
+ processChildren = true;
+ } else if (JavaModelManager.getJavaModelManager().getJavaModel().findJavaProject(project) != null) {
+ // project had the java nature
+ this.rootsAreStale = true;
+
+ // remove classpath cache so that initializeRoots() will not consider the project has a classpath
+ this.manager.removePerProjectInfo((JavaProject)JavaCore.create(project));
+ }
+ break;
+ case IResourceDelta.ADDED:
+ this.rootsAreStale = true;
+ break;
+ case IResourceDelta.REMOVED:
+ // remove classpath cache so that initializeRoots() will not consider the project has a classpath
+ this.manager.removePerProjectInfo((JavaProject)JavaCore.create(resource));
+
+ this.rootsAreStale = true;
+ break;
}
break;
case IResource.FILE :
@@ -959,105 +1358,17 @@
IFile file = (IFile) resource;
JavaProject project = (JavaProject) parent;
- /* check classpath property file change */
- QualifiedName classpathProp;
- if (file.getName().equals(
- project.computeSharedPropertyFileName(
- classpathProp = project.getClasspathPropertyName()))) {
-
- switch (delta.getKind()) {
- case IResourceDelta.REMOVED : // recreate one based on in-memory path
- try {
- project.saveClasspath(project.getRawClasspath(), project.getOutputLocation());
- } catch (JavaModelException e) {
- if (project.getProject().isAccessible()) {
- Util.log(e, "Could not save classpath for "+ project.getPath()); //$NON-NLS-1$
- }
- }
- break;
- case IResourceDelta.CHANGED :
- if ((delta.getFlags() & IResourceDelta.CONTENT) == 0)
- break; // only consider content change
- case IResourceDelta.ADDED :
- // check if any actual difference
- project.flushClasspathProblemMarkers(false, true);
- try {
- // force to (re)read the property file
- IClasspathEntry[] fileEntries = null;
- try {
- String fileClasspathString = project.loadClasspath();
- if (fileClasspathString != null) {
- fileEntries = project.readPaths(fileClasspathString);
- }
- } catch(JavaModelException e) {
- if (project.getProject().isAccessible()) {
- Util.log(e,
- "Exception while retrieving "+ project.getPath() //$NON-NLS-1$
- +"/.classpath, ignore change"); //$NON-NLS-1$
- }
- project.createClasspathProblemMarker(
- Util.bind("classpath.cannotReadClasspathFile", project.getElementName()), //$NON-NLS-1$
- IMarker.SEVERITY_ERROR,
- false, // cycle error
- true); // file format error
- } catch (IOException e) {
- if (project.getProject().isAccessible()) {
- Util.log(e,
- "Exception while retrieving "+ project.getPath() //$NON-NLS-1$
- +"/.classpath, ignore change"); //$NON-NLS-1$
- }
- project.createClasspathProblemMarker(
- Util.bind("classpath.cannotReadClasspathFile", project.getElementName()), //$NON-NLS-1$
- IMarker.SEVERITY_ERROR,
- false, // cycle error
- true); // file format error
- }
- if (fileEntries == null)
- break; // could not read, ignore
- if (project.isClasspathEqualsTo(project.getRawClasspath(), project.getOutputLocation(), fileEntries))
- break;
-
- // will force an update of the classpath/output location based on the file information
- // extract out the output location
- IPath outputLocation = null;
- if (fileEntries != null && fileEntries.length > 0) {
- IClasspathEntry entry = fileEntries[fileEntries.length - 1];
- if (entry.getContentKind() == ClasspathEntry.K_OUTPUT) {
- outputLocation = entry.getPath();
- IClasspathEntry[] copy = new IClasspathEntry[fileEntries.length - 1];
- System.arraycopy(fileEntries, 0, copy, 0, copy.length);
- fileEntries = copy;
- }
- }
- // restore output location
- if (outputLocation == null) {
- outputLocation = SetClasspathOperation.ReuseOutputLocation;
- }
- project.setRawClasspath(
- fileEntries,
- outputLocation,
- null, // monitor
- true, // canChangeResource
- false, // forceSave
- project.getResolvedClasspath(true), // ignoreUnresolvedVariable
- true, // needCycleCheck
- true); // needValidation
- } catch (RuntimeException e) {
- // setRawClasspath might fire a delta, and a listener may throw an exception
- if (project.getProject().isAccessible()) {
- Util.log(e, "Could not set classpath for "+ project.getPath()); //$NON-NLS-1$
- }
- break;
- } catch (CoreException e) {
- // happens if the .classpath could not be written to disk
- if (project.getProject().isAccessible()) {
- Util.log(e, "Could not set classpath for "+ project.getPath()); //$NON-NLS-1$
- }
- break;
- }
-
- }
+ /* check classpath file change */
+ if (file.getName().equals(JavaProject.CLASSPATH_FILENAME)) {
+ reconcileClasspathFileUpdate(delta, file, project);
+ this.rootsAreStale = true;
+ break;
}
+// /* check custom preference file change */
+// if (file.getName().equals(JavaProject.PREF_FILENAME)) {
+// reconcilePreferenceFileUpdate(delta, file, project);
+// break;
+// }
}
break;
}
@@ -1075,11 +1386,7 @@
if (this.currentElement instanceof IPackageFragmentRoot) {
currentElementPath = ((IPackageFragmentRoot)this.currentElement).getPath();
} else {
- IResource currentElementResource = null;
- try {
- currentElementResource = this.currentElement.getUnderlyingResource();
- } catch (JavaModelException e) {
- }
+ IResource currentElementResource = this.currentElement.getResource();
if (currentElementResource != null) {
currentElementPath = currentElementResource.getFullPath();
}
@@ -1098,17 +1405,16 @@
this.currentElement = (Openable)this.currentElement.getParent();
}
}
-
+
/**
* Converts a <code>IResourceDelta</code> rooted in a <code>Workspace</code> into
* the corresponding set of <code>IJavaElementDelta</code>, rooted in the
* relevant <code>JavaModel</code>s.
*/
- public IJavaElementDelta[] processResourceDelta(IResourceDelta changes, int eventType) {
+ public IJavaElementDelta processResourceDelta(IResourceDelta changes) {
try {
- this.currentEventType = eventType;
- IJavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
+ IJavaModel model = this.manager.getJavaModel();
if (!model.isOpen()) {
// force opening of java model so that java element delta are reported
try {
@@ -1117,33 +1423,45 @@
if (VERBOSE) {
e.printStackTrace();
}
- return NO_DELTA;
+ return null;
}
}
- this.initializeRoots(model);
+ this.initializeRoots();
this.currentElement = null;
// get the workspace delta, and start processing there.
IResourceDelta[] deltas = changes.getAffectedChildren();
- IJavaElementDelta[] translatedDeltas = new JavaElementDelta[deltas.length];
for (int i = 0; i < deltas.length; i++) {
IResourceDelta delta = deltas[i];
IResource res = delta.getResource();
- fCurrentDelta = new JavaElementDelta(model);
- // find out whether the delta is a package fragment root
- IJavaProject projectOfRoot = (IJavaProject)this.roots.get(res.getFullPath());
- boolean isPkgFragmentRoot = projectOfRoot != null;
- int elementType =
- this.elementType(
- res,
- delta.getKind(),
- delta.getFlags(),
- IJavaElement.JAVA_MODEL,
- isPkgFragmentRoot);
+ // find out the element type
+ RootInfo rootInfo = null;
+ int elementType;
+ IProject proj = (IProject)res;
+ boolean wasJavaProject = this.manager.getJavaModel().findJavaProject(proj) != null;
+ boolean isJavaProject = JavaProject.hasJavaNature(proj);
+ if (!wasJavaProject && !isJavaProject) {
+ elementType = NON_JAVA_RESOURCE;
+ } else {
+ rootInfo = this.enclosingRootInfo(res.getFullPath(), delta.getKind());
+ if (rootInfo != null && rootInfo.isRootOfProject(res.getFullPath())) {
+ elementType = IJavaElement.PACKAGE_FRAGMENT_ROOT;
+ } else {
+ elementType = IJavaElement.JAVA_PROJECT;
+ }
+ }
- this.traverseDelta(delta, elementType, projectOfRoot, null, IGNORE); // traverse delta
- translatedDeltas[i] = fCurrentDelta;
+ // traverse delta
+ if (!this.traverseDelta(delta, elementType, rootInfo, null)
+ || (wasJavaProject != isJavaProject && (delta.getKind()) == IResourceDelta.CHANGED)) { // project has changed nature (description or open/closed)
+ try {
+ // add child as non java resource
+ nonJavaResourcesChanged((JavaModel)model, delta);
+ } catch (JavaModelException e) {
+ }
+ }
+
}
// update package fragment roots of projects that were affected
@@ -1155,110 +1473,173 @@
updateDependentNamelookups();
- return filterRealDeltas(translatedDeltas);
+ return this.currentDelta;
} finally {
+ this.currentDelta = null;
this.projectsToUpdate.clear();
this.projectsForDependentNamelookupRefresh.clear();
}
}
-
-/*
- * Update the current delta (ie. add/remove/change the given element) and update the correponding index.
- * Returns whether the children of the given delta must be processed.
- * @throws a JavaModelException if the delta doesn't correspond to a java element of the given type.
- */
-private boolean updateCurrentDeltaAndIndex(IResourceDelta delta, int elementType, IJavaProject project) throws JavaModelException {
- Openable element;
- switch (delta.getKind()) {
- case IResourceDelta.ADDED :
- IResource deltaRes = delta.getResource();
- element = this.createElement(deltaRes, elementType, project);
- if (element == null) {
- // resource might be containing shared roots (see bug 19058)
- this.updateRoots(deltaRes.getFullPath(), delta);
- throw newInvalidElementType();
- }
- this.updateIndex(element, delta);
- this.elementAdded(element, delta);
- return false;
- case IResourceDelta.REMOVED :
- deltaRes = delta.getResource();
- element = this.createElement(deltaRes, elementType, project);
- if (element == null) {
- // resource might be containing shared roots (see bug 19058)
- this.updateRoots(deltaRes.getFullPath(), delta);
- throw newInvalidElementType();
- }
- this.updateIndex(element, delta);
- this.elementRemoved(element, delta);
- if (deltaRes.getType() == IResource.PROJECT){
- // reset the corresponding project built state, since cannot reuse if added back
- this.manager.setLastBuiltState((IProject)deltaRes, null /*no state*/);
- }
- return false;
- case IResourceDelta.CHANGED :
- int flags = delta.getFlags();
- if ((flags & IResourceDelta.CONTENT) != 0) {
- // content has changed
- element = this.createElement(delta.getResource(), elementType, project);
- if (element == null) throw newInvalidElementType();
- this.updateIndex(element, delta);
- this.contentChanged(element, delta);
- } else if (elementType == IJavaElement.JAVA_PROJECT) {
- if ((flags & IResourceDelta.OPEN) != 0) {
- // project has been opened or closed
- IProject res = (IProject)delta.getResource();
- element = this.createElement(res, elementType, project);
- if (element == null) {
- // resource might be containing shared roots (see bug 19058)
- this.updateRoots(res.getFullPath(), delta);
- throw newInvalidElementType();
+ /**
+ * Update the JavaModel according to a .classpath file change. The file can have changed as a result of a previous
+ * call to JavaProject#setRawClasspath or as a result of some user update (through repository)
+ */
+ void reconcileClasspathFileUpdate(IResourceDelta delta, IFile file, JavaProject project) {
+
+ switch (delta.getKind()) {
+ case IResourceDelta.REMOVED : // recreate one based on in-memory classpath
+ try {
+ JavaModelManager.PerProjectInfo info = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(project.getProject());
+ if (info.classpath != null) { // if there is an in-memory classpath
+ project.saveClasspath(info.classpath, info.outputLocation);
}
- if (res.isOpen()) {
- if (this.hasJavaNature(res)) {
- this.elementAdded(element, delta);
- this.indexManager.indexAll(res);
- }
- } else {
- JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel();
- boolean wasJavaProject = javaModel.findJavaProject(res) != null;
- if (wasJavaProject) {
- this.elementRemoved(element, delta);
- this.indexManager.discardJobs(element.getElementName());
- this.indexManager.removeIndexFamily(res.getFullPath());
-
- }
+ } catch (JavaModelException e) {
+ if (project.getProject().isAccessible()) {
+ Util.log(e, "Could not save classpath for "+ project.getPath()); //$NON-NLS-1$
}
- return false; // when a project is open/closed don't process children
}
- if ((flags & IResourceDelta.DESCRIPTION) != 0) {
- IProject res = (IProject)delta.getResource();
- JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel();
- boolean wasJavaProject = javaModel.findJavaProject(res) != null;
- boolean isJavaProject = this.hasJavaNature(res);
- if (wasJavaProject != isJavaProject) {
- // project's nature has been added or removed
- element = this.createElement(res, elementType, project);
- if (element == null) throw newInvalidElementType(); // note its resources are still visible as roots to other projects
- if (isJavaProject) {
- this.elementAdded(element, delta);
- this.indexManager.indexAll(res);
+ break;
+ case IResourceDelta.CHANGED :
+ if ((delta.getFlags() & IResourceDelta.CONTENT) == 0 // only consider content change
+ && (delta.getFlags() & IResourceDelta.MOVED_FROM) == 0) // and also move and overide scenario (see http://dev.eclipse.org/bugs/show_bug.cgi?id=21420)
+ break;
+ case IResourceDelta.ADDED :
+ // check if any actual difference
+ project.flushClasspathProblemMarkers(false, true);
+ boolean wasSuccessful = false; // flag recording if .classpath file change got reflected
+ try {
+ // force to (re)read the property file
+ IClasspathEntry[] fileEntries = project.readClasspathFile(true/*create markers*/, false/*don't log problems*/);
+ if (fileEntries == null)
+ break; // could not read, ignore
+ JavaModelManager.PerProjectInfo info = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(project.getProject());
+ if (info.classpath != null) { // if there is an in-memory classpath
+ if (project.isClasspathEqualsTo(info.classpath, info.outputLocation, fileEntries)) {
+ wasSuccessful = true;
+ break;
+ }
+ }
+
+ // will force an update of the classpath/output location based on the file information
+ // extract out the output location
+ IPath outputLocation = null;
+ if (fileEntries != null && fileEntries.length > 0) {
+ IClasspathEntry entry = fileEntries[fileEntries.length - 1];
+ if (entry.getContentKind() == ClasspathEntry.K_OUTPUT) {
+ outputLocation = entry.getPath();
+ IClasspathEntry[] copy = new IClasspathEntry[fileEntries.length - 1];
+ System.arraycopy(fileEntries, 0, copy, 0, copy.length);
+ fileEntries = copy;
+ }
+ }
+ // restore output location
+ if (outputLocation == null) {
+ outputLocation = SetClasspathOperation.ReuseOutputLocation;
+ // clean mode will also default to reusing current one
+ }
+ project.setRawClasspath(
+ fileEntries,
+ outputLocation,
+ null, // monitor
+ true, // canChangeResource
+ project.getResolvedClasspath(true), // ignoreUnresolvedVariable
+ true, // needValidation
+ false); // no need to save
+
+ // if reach that far, the classpath file change got absorbed
+ wasSuccessful = true;
+ } catch (RuntimeException e) {
+ // setRawClasspath might fire a delta, and a listener may throw an exception
+ if (project.getProject().isAccessible()) {
+ Util.log(e, "Could not set classpath for "+ project.getPath()); //$NON-NLS-1$
+ }
+ break;
+ } catch (JavaModelException e) { // CP failed validation
+ if (project.getProject().isAccessible()) {
+ if (e.getJavaModelStatus().getException() instanceof CoreException) {
+ // happens if the .classpath could not be written to disk
+ project.createClasspathProblemMarker(new JavaModelStatus(
+ IJavaModelStatusConstants.INVALID_CLASSPATH_FILE_FORMAT,
+ Util.bind("classpath.couldNotWriteClasspathFile", project.getElementName(), e.getMessage()))); //$NON-NLS-1$
} else {
- this.elementRemoved(element, delta);
- this.indexManager.discardJobs(element.getElementName());
- this.indexManager.removeIndexFamily(res.getFullPath());
- // reset the corresponding project built state, since cannot reuse if added back
- this.manager.setLastBuiltState(res, null /*no state*/);
+ project.createClasspathProblemMarker(new JavaModelStatus(
+ IJavaModelStatusConstants.INVALID_CLASSPATH_FILE_FORMAT,
+ Util.bind("classpath.invalidClasspathInClasspathFile", project.getElementName(), e.getMessage()))); //$NON-NLS-1$
+ }
+ }
+ break;
+ } finally {
+ if (!wasSuccessful) {
+ try {
+ project.setRawClasspath0(JavaProject.INVALID_CLASSPATH);
+ project.updatePackageFragmentRoots();
+ } catch (JavaModelException e) {
}
- return false; // when a project's nature is added/removed don't process children
}
}
- }
- return true;
+ }
}
- return true;
-}
+
+ /**
+ * Update the JavaModel according to a .jprefs file change. The file can have changed as a result of a previous
+ * call to JavaProject#setOptions or as a result of some user update (through repository)
+ * Unused until preference file get shared (.jpref)
+ */
+ void reconcilePreferenceFileUpdate(IResourceDelta delta, IFile file, JavaProject project) {
+
+ switch (delta.getKind()) {
+ case IResourceDelta.REMOVED : // flush project custom settings
+ project.setOptions(null);
+ return;
+ case IResourceDelta.CHANGED :
+ if ((delta.getFlags() & IResourceDelta.CONTENT) == 0 // only consider content change
+ && (delta.getFlags() & IResourceDelta.MOVED_FROM) == 0) // and also move and overide scenario
+ break;
+ identityCheck : { // check if any actual difference
+ // force to (re)read the property file
+ Preferences filePreferences = project.loadPreferences();
+ if (filePreferences == null){
+ project.setOptions(null); // should have got removed delta.
+ return;
+ }
+ Preferences projectPreferences = project.getPreferences();
+ if (projectPreferences == null) return; // not a Java project
+
+ // compare preferences set to their default
+ String[] defaultProjectPropertyNames = projectPreferences.defaultPropertyNames();
+ String[] defaultFilePropertyNames = filePreferences.defaultPropertyNames();
+ if (defaultProjectPropertyNames.length == defaultFilePropertyNames.length) {
+ for (int i = 0; i < defaultProjectPropertyNames.length; i++){
+ String propertyName = defaultProjectPropertyNames[i];
+ if (!projectPreferences.getString(propertyName).trim().equals(filePreferences.getString(propertyName).trim())){
+ break identityCheck;
+ }
+ }
+ } else break identityCheck;
+
+ // compare custom preferences not set to their default
+ String[] projectPropertyNames = projectPreferences.propertyNames();
+ String[] filePropertyNames = filePreferences.propertyNames();
+ if (projectPropertyNames.length == filePropertyNames.length) {
+ for (int i = 0; i < projectPropertyNames.length; i++){
+ String propertyName = projectPropertyNames[i];
+ if (!projectPreferences.getString(propertyName).trim().equals(filePreferences.getString(propertyName).trim())){
+ break identityCheck;
+ }
+ }
+ } else break identityCheck;
+
+ // identical - do nothing
+ return;
+ }
+ case IResourceDelta.ADDED :
+ // not identical, create delta and reset cached preferences
+ project.setPreferences(null);
+ // create delta
+ //fCurrentDelta.changed(project, IJavaElementDelta.F_OPTIONS_CHANGED);
+ }
+ }
/**
* Removes the given element from its parents cache of children. If the
@@ -1270,7 +1651,7 @@
Openable parent = (Openable) child.getParent();
if (parent != null && parent.isOpen()) {
try {
- JavaElementInfo info = parent.getElementInfo();
+ JavaElementInfo info = (JavaElementInfo)parent.getElementInfo();
info.removeChild(child);
} catch (JavaModelException e) {
// do nothing - we already checked if open
@@ -1287,9 +1668,7 @@
* @see IResource
*/
public void resourceChanged(IResourceChangeEvent event) {
-
- JavaModelManager.IsResourceTreeLocked = false;
-
+
if (event.getSource() instanceof IWorkspace) {
IResource resource = event.getResource();
IResourceDelta delta = event.getDelta();
@@ -1307,12 +1686,12 @@
return;
case IResourceChangeEvent.PRE_AUTO_BUILD :
- if(delta != null) {
+ if(isAffectedBy(delta)) { // avoid populating for SYNC or MARKER deltas
this.checkProjectsBeingAddedOrRemoved(delta);
// update the classpath related markers
this.updateClasspathMarkers();
-
+
// the following will close project if affected by the property file change
try {
// don't fire classpath change deltas right away, but batch them
@@ -1325,194 +1704,216 @@
// only fire already computed deltas (resource ones will be processed in post change only)
this.manager.fire(null, ElementChangedEvent.PRE_AUTO_BUILD);
break;
+
+ case IResourceChangeEvent.POST_AUTO_BUILD :
+ JavaBuilder.finishedBuilding(event);
+ break;
case IResourceChangeEvent.POST_CHANGE :
- try {
- JavaModelManager.IsResourceTreeLocked = true;
- if (delta != null) {
- IJavaElementDelta[] translatedDeltas = this.processResourceDelta(delta, ElementChangedEvent.POST_CHANGE);
- if (translatedDeltas.length > 0) {
- for (int i= 0; i < translatedDeltas.length; i++) {
- this.manager.registerJavaModelDelta(translatedDeltas[i]);
+ if (isAffectedBy(delta)) {
+ try {
+ if (this.refreshedElements != null) {
+ try {
+ createExternalArchiveDelta(null);
+ } catch (JavaModelException e) {
+ e.printStackTrace();
}
}
+ IJavaElementDelta translatedDelta = this.processResourceDelta(delta);
+ if (translatedDelta != null) {
+ this.manager.registerJavaModelDelta(translatedDelta);
+ }
this.manager.fire(null, ElementChangedEvent.POST_CHANGE);
- }
- } finally {
- // workaround for bug 15168 circular errors not reported
- this.manager.javaProjectsCache = null;
- JavaModelManager.IsResourceTreeLocked = false;
+ } finally {
+ // workaround for bug 15168 circular errors not reported
+ this.manager.javaProjectsCache = null;
+ this.removedRoots = null;
+ }
}
}
}
}
+ /*
+ * Finds the root info this path is included in.
+ * Returns null if not found.
+ */
+ RootInfo enclosingRootInfo(IPath path, int kind) {
+ while (path != null && path.segmentCount() > 0) {
+ RootInfo rootInfo = this.rootInfo(path, kind);
+ if (rootInfo != null) return rootInfo;
+ path = path.removeLastSegments(1);
+ }
+ return null;
+ }
+ /*
+ * Returns the root info for the given path. Look in the old roots table if kind is REMOVED.
+ */
+ RootInfo rootInfo(IPath path, int kind) {
+ if (kind == IResourceDelta.REMOVED) {
+ return (RootInfo)this.oldRoots.get(path);
+ } else {
+ return (RootInfo)this.roots.get(path);
+ }
+ }
+ /*
+ * Returns the other root infos for the given path. Look in the old other roots table if kind is REMOVED.
+ */
+ ArrayList otherRootsInfo(IPath path, int kind) {
+ if (kind == IResourceDelta.REMOVED) {
+ return (ArrayList)this.oldOtherRoots.get(path);
+ } else {
+ return (ArrayList)this.otherRoots.get(path);
+ }
+ }
/**
* Converts an <code>IResourceDelta</code> and its children into
* the corresponding <code>IJavaElementDelta</code>s.
- * Return whether the delta corresponds to a resource on the classpath.
- * If it is not a resource on the classpath, it will be added as a non-java
+ * Return whether the delta corresponds to a java element.
+ * If it is not a java element, it will be added as a non-java
* resource by the sender of this method.
*/
protected boolean traverseDelta(
IResourceDelta delta,
int elementType,
- IJavaProject currentProject,
- IPath currentOutput,
- int outputTraverseMode) {
+ RootInfo rootInfo,
+ OutputsInfo outputsInfo) {
IResource res = delta.getResource();
+
+ // set stack of elements
+ if (this.currentElement == null && rootInfo != null) {
+ this.currentElement = (Openable)rootInfo.project;
+ }
// process current delta
boolean processChildren = true;
- if (currentProject != null || res instanceof IProject) {
- if (this.currentElement == null || !this.currentElement.getJavaProject().equals(currentProject)) {
- // force the currentProject to be used
- this.currentElement = (Openable)currentProject;
- }
- try {
- processChildren = this.updateCurrentDeltaAndIndex(delta, elementType, currentProject);
- } catch (JavaModelException e) {
- // non java resource or invalid project
- return false;
- }
+ if (res instanceof IProject) {
+ processChildren =
+ this.updateCurrentDeltaAndIndex(
+ delta,
+ elementType == IJavaElement.PACKAGE_FRAGMENT_ROOT ?
+ IJavaElement.JAVA_PROJECT : // case of prj=src
+ elementType,
+ rootInfo);
+ } else if (rootInfo != null) {
+ processChildren = this.updateCurrentDeltaAndIndex(delta, elementType, rootInfo);
} else {
// not yet inside a package fragment root
processChildren = true;
}
- // get the project's output location
- if (currentOutput == null) {
- try {
- IJavaProject proj =
- currentProject == null ?
- (IJavaProject)this.createElement(res.getProject(), IJavaElement.JAVA_PROJECT, null) :
- currentProject;
- if (proj != null) {
- currentOutput = proj.getOutputLocation();
- if (proj.getProject().getFullPath().equals(currentOutput)){ // case of proj==bin==src
- outputTraverseMode = SOURCE;
- } else {
- // check case of src==bin
- IClasspathEntry[] classpath = proj.getResolvedClasspath(true);
- for (int i = 0, length = classpath.length; i < length; i++) {
- IClasspathEntry entry = classpath[i];
- if (entry.getPath().equals(currentOutput)) {
- outputTraverseMode = (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) ? SOURCE : BINARY;
- break;
- }
- }
- }
- }
- } catch (JavaModelException e) {
- }
- }
-
+ // get the project's output locations and traverse mode
+ if (outputsInfo == null) outputsInfo = this.outputsInfo(rootInfo, res);
+
// process children if needed
if (processChildren) {
IResourceDelta[] children = delta.getAffectedChildren();
boolean oneChildOnClasspath = false;
int length = children.length;
- IResourceDelta[] orphanChildren = new IResourceDelta[length];
+ IResourceDelta[] orphanChildren = null;
Openable parent = null;
boolean isValidParent = true;
for (int i = 0; i < length; i++) {
IResourceDelta child = children[i];
IResource childRes = child.getResource();
- IPath childPath = childRes.getFullPath();
-
+
+ // check source attachment change
+ this.checkSourceAttachmentChange(child, childRes);
+
// find out whether the child is a package fragment root of the current project
- IJavaProject projectOfRoot = (IJavaProject)this.roots.get(childPath);
- boolean isPkgFragmentRoot =
- projectOfRoot != null
- && (projectOfRoot.getProject().getFullPath().isPrefixOf(childPath));
+ IPath childPath = childRes.getFullPath();
+ int childKind = child.getKind();
+ RootInfo childRootInfo = this.rootInfo(childPath, childKind);
+ if (childRootInfo != null && !childRootInfo.isRootOfProject(childPath)) {
+ // package fragment root of another project (dealt with later)
+ childRootInfo = null;
+ }
+
+ // compute child type
int childType =
this.elementType(
childRes,
- child.getKind(),
- child.getFlags(),
+ childKind,
elementType,
- isPkgFragmentRoot);
-
- // filter out changes in output location
- if (currentOutput != null && currentOutput.isPrefixOf(childPath)) {
- if (outputTraverseMode != IGNORE) {
- // case of bin=src
- if (outputTraverseMode == SOURCE && childType == IJavaElement.CLASS_FILE) {
- continue;
- }
- // case of .class file under project and no source folder
- // proj=bin
- if (childType == IJavaElement.JAVA_PROJECT
- && childRes instanceof IFile
- && Util.isValidClassFileName(childRes.getName())) {
- continue;
+ rootInfo == null ? childRootInfo : rootInfo
+ );
+
+ // is childRes in the output folder and is it filtered out ?
+ boolean isResFilteredFromOutput = this.isResFilteredFromOutput(outputsInfo, childRes, childType);
+
+ boolean isNestedRoot = rootInfo != null && childRootInfo != null;
+ if (!isResFilteredFromOutput
+ && !isNestedRoot) { // do not treat as non-java rsc if nested root
+ if (!this.traverseDelta(child, childType, rootInfo == null ? childRootInfo : rootInfo, outputsInfo)) { // traverse delta for child in the same project
+ // it is a non-java resource
+ try {
+ if (rootInfo != null) { // if inside a package fragment root
+ if (!isValidParent) continue;
+ if (parent == null) {
+ // find the parent of the non-java resource to attach to
+ if (this.currentElement == null
+ || !this.currentElement.getJavaProject().equals(rootInfo.project)) {
+ // force the currentProject to be used
+ this.currentElement = (Openable)rootInfo.project;
+ }
+ if (elementType == IJavaElement.JAVA_PROJECT
+ || (elementType == IJavaElement.PACKAGE_FRAGMENT_ROOT
+ && res instanceof IProject)) {
+ // NB: attach non-java resource to project (not to its package fragment root)
+ parent = (Openable)rootInfo.project;
+ } else {
+ parent = this.createElement(res, elementType, rootInfo);
+ }
+ if (parent == null) {
+ isValidParent = false;
+ continue;
+ }
+ }
+ // add child as non java resource
+ nonJavaResourcesChanged(parent, child);
+ } else {
+ // the non-java resource (or its parent folder) will be attached to the java project
+ if (orphanChildren == null) orphanChildren = new IResourceDelta[length];
+ orphanChildren[i] = child;
+ }
+ } catch (JavaModelException e) {
}
} else {
- continue;
- }
- }
-
- // traverse delta for child in the same project
- if (childType == -1
- || !this.traverseDelta(child, childType, (currentProject == null && isPkgFragmentRoot) ? projectOfRoot : currentProject, currentOutput, outputTraverseMode)) {
- try {
- if (currentProject != null) {
- if (!isValidParent) continue;
- if (parent == null) {
- if (this.currentElement == null || !this.currentElement.getJavaProject().equals(currentProject)) {
- // force the currentProject to be used
- this.currentElement = (Openable)currentProject;
- }
- if (elementType == IJavaElement.JAVA_PROJECT
- || (elementType == IJavaElement.PACKAGE_FRAGMENT_ROOT && res instanceof IProject)) {
- // NB: attach non-java resource to project (not to its package fragment root)
- parent = (Openable)currentProject;
- } else {
- parent = this.createElement(res, elementType, currentProject);
- }
- if (parent == null) {
- isValidParent = false;
- continue;
- }
- }
- // add child as non java resource
- nonJavaResourcesChanged(parent, child);
- } else {
- orphanChildren[i] = child;
- }
- } catch (JavaModelException e) {
+ oneChildOnClasspath = true;
}
} else {
- oneChildOnClasspath = true;
+ oneChildOnClasspath = true; // to avoid reporting child delta as non-java resource delta
}
-
- // if child is a package fragment root of another project, traverse delta too
- if (projectOfRoot != null && !isPkgFragmentRoot) {
- this.traverseDelta(child, IJavaElement.PACKAGE_FRAGMENT_ROOT, projectOfRoot, null, IGNORE); // binary output of projectOfRoot cannot be this root
+
+ // if child is a nested root
+ // or if it is not a package fragment root of the current project
+ // but it is a package fragment root of another project, traverse delta too
+ if (isNestedRoot
+ || (childRootInfo == null && (childRootInfo = this.rootInfo(childPath, childKind)) != null)) {
+ this.traverseDelta(child, IJavaElement.PACKAGE_FRAGMENT_ROOT, childRootInfo, null); // binary output of childRootInfo.project cannot be this root
// NB: No need to check the return value as the child can only be on the classpath
}
-
+
// if the child is a package fragment root of one or several other projects
- HashSet set;
- if ((set = (HashSet)this.otherRoots.get(childPath)) != null) {
- IPackageFragmentRoot currentRoot =
- (currentProject == null ?
- projectOfRoot :
- currentProject).getPackageFragmentRoot(childRes);
- Iterator iterator = set.iterator();
+ ArrayList rootList;
+ if ((rootList = this.otherRootsInfo(childPath, childKind)) != null) {
+ Iterator iterator = rootList.iterator();
while (iterator.hasNext()) {
- IJavaProject project = (IJavaProject) iterator.next();
- this.cloneCurrentDelta(project, currentRoot);
+ childRootInfo = (RootInfo) iterator.next();
+ this.traverseDelta(child, IJavaElement.PACKAGE_FRAGMENT_ROOT, childRootInfo, null); // binary output of childRootInfo.project cannot be this root
}
}
}
- if (oneChildOnClasspath || res instanceof IProject) {
- // add orphan children (case of non java resources under project)
+ if (orphanChildren != null
+ && (oneChildOnClasspath // orphan children are siblings of a package fragment root
+ || res instanceof IProject)) { // non-java resource directly under a project
+
+ // attach orphan children
IProject rscProject = res.getProject();
- JavaProject adoptiveProject = (JavaProject)JavaCore.getJavaCore().create(rscProject);
+ JavaProject adoptiveProject = (JavaProject)JavaCore.create(rscProject);
if (adoptiveProject != null
- && this.hasJavaNature(rscProject)) { // delta iff Java project (18698)
+ && JavaProject.hasJavaNature(rscProject)) { // delta iff Java project (18698)
for (int i = 0; i < length; i++) {
if (orphanChildren[i] != null) {
try {
@@ -1523,13 +1924,12 @@
}
}
} // else resource delta will be added by parent
- return isValidParent && (currentProject != null || oneChildOnClasspath);
+ return elementType != NON_JAVA_RESOURCE; // TODO: (jerome) do we still need to return? (check could be done by caller)
} else {
- // if not on classpath or if the element type is -1,
- // it's a non-java resource
- return currentProject != null && elementType != -1;
+ return elementType != NON_JAVA_RESOURCE;
}
}
+
/**
* Update the classpath markers and cycle markers for the projects to update.
*/
@@ -1562,6 +1962,104 @@
}
}
+ /*
+ * Update the current delta (ie. add/remove/change the given element) and update the correponding index.
+ * Returns whether the children of the given delta must be processed.
+ * @throws a JavaModelException if the delta doesn't correspond to a java element of the given type.
+ */
+ private boolean updateCurrentDeltaAndIndex(IResourceDelta delta, int elementType, RootInfo rootInfo) {
+ Openable element;
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED :
+ IResource deltaRes = delta.getResource();
+ element = this.createElement(deltaRes, elementType, rootInfo);
+ if (element == null) {
+ // resource might be containing shared roots (see bug 19058)
+ this.updateRoots(deltaRes.getFullPath(), delta);
+ return false;
+ }
+ this.updateIndex(element, delta);
+ this.elementAdded(element, delta, rootInfo);
+ return false;
+ case IResourceDelta.REMOVED :
+ deltaRes = delta.getResource();
+ element = this.createElement(deltaRes, elementType, rootInfo);
+ if (element == null) {
+ // resource might be containing shared roots (see bug 19058)
+ this.updateRoots(deltaRes.getFullPath(), delta);
+ return false;
+ }
+ this.updateIndex(element, delta);
+ this.elementRemoved(element, delta, rootInfo);
+
+ if (deltaRes.getType() == IResource.PROJECT){
+ // reset the corresponding project built state, since cannot reuse if added back
+ this.manager.setLastBuiltState((IProject)deltaRes, null /*no state*/);
+ }
+ return false;
+ case IResourceDelta.CHANGED :
+ int flags = delta.getFlags();
+ if ((flags & IResourceDelta.CONTENT) != 0) {
+ // content has changed
+ element = this.createElement(delta.getResource(), elementType, rootInfo);
+ if (element == null) return false;
+ this.updateIndex(element, delta);
+ this.contentChanged(element, delta);
+ } else if (elementType == IJavaElement.JAVA_PROJECT) {
+ if ((flags & IResourceDelta.OPEN) != 0) {
+ // project has been opened or closed
+ IProject res = (IProject)delta.getResource();
+ element = this.createElement(res, elementType, rootInfo);
+ if (element == null) {
+ // resource might be containing shared roots (see bug 19058)
+ this.updateRoots(res.getFullPath(), delta);
+ return false;
+ }
+ if (res.isOpen()) {
+ if (JavaProject.hasJavaNature(res)) {
+ this.elementAdded(element, delta, rootInfo);
+ this.indexManager.indexAll(res);
+ }
+ } else {
+ JavaModel javaModel = this.manager.getJavaModel();
+ boolean wasJavaProject = javaModel.findJavaProject(res) != null;
+ if (wasJavaProject) {
+ this.elementRemoved(element, delta, rootInfo);
+ this.indexManager.discardJobs(element.getElementName());
+ this.indexManager.removeIndexFamily(res.getFullPath());
+
+ }
+ }
+ return false; // when a project is open/closed don't process children
+ }
+ if ((flags & IResourceDelta.DESCRIPTION) != 0) {
+ IProject res = (IProject)delta.getResource();
+ JavaModel javaModel = this.manager.getJavaModel();
+ boolean wasJavaProject = javaModel.findJavaProject(res) != null;
+ boolean isJavaProject = JavaProject.hasJavaNature(res);
+ if (wasJavaProject != isJavaProject) {
+ // project's nature has been added or removed
+ element = this.createElement(res, elementType, rootInfo);
+ if (element == null) return false; // note its resources are still visible as roots to other projects
+ if (isJavaProject) {
+ this.elementAdded(element, delta, rootInfo);
+ this.indexManager.indexAll(res);
+ } else {
+ this.elementRemoved(element, delta, rootInfo);
+ this.indexManager.discardJobs(element.getElementName());
+ this.indexManager.removeIndexFamily(res.getFullPath());
+ // reset the corresponding project built state, since cannot reuse if added back
+ this.manager.setLastBuiltState(res, null /*no state*/);
+ }
+ return false; // when a project's nature is added/removed don't process children
+ }
+ }
+ }
+ return true;
+ }
+ return true;
+ }
+
/**
* Traverse the set of projects which have changed namespace, and refresh their dependents
*/
@@ -1585,101 +2083,6 @@
}
}
}
-
- /*
- * Returns the type of the java element the given delta matches to.
- * Returns -1 if unknown (e.g. a non-java resource.)
- */
- private int elementType(IResource res, int kind, int flags, int parentType, boolean isPkgFragmentRoot) {
- switch (parentType) {
- case IJavaElement.JAVA_MODEL:
- if (kind != IResourceDelta.CHANGED) {
- // change on the project itself
- return IJavaElement.JAVA_PROJECT;
- } else if ((flags & IResourceDelta.OPEN) != 0) {
- // project is opened or closed
- return IJavaElement.JAVA_PROJECT;
- } else if ((flags & IResourceDelta.DESCRIPTION) != 0) {
- // project's description has changed: need to check if java nature has changed
- IProject proj = res.getProject();
- boolean wasJavaProject = JavaModelManager.getJavaModelManager().getJavaModel().findJavaProject(proj) != null;
- boolean isJavaProject = this.hasJavaNature(proj);
- if (wasJavaProject != isJavaProject) {
- return IJavaElement.JAVA_PROJECT;
- }
- } // else see below
- case IJavaElement.JAVA_PROJECT:
- if (isPkgFragmentRoot) {
- return IJavaElement.PACKAGE_FRAGMENT_ROOT;
- } else {
- return IJavaElement.JAVA_PROJECT; // not yet in a package fragment root
- }
- case IJavaElement.PACKAGE_FRAGMENT_ROOT:
- case IJavaElement.PACKAGE_FRAGMENT:
- if (res instanceof IFolder) {
- if (Util.isValidFolderNameForPackage(res.getName())) {
- return IJavaElement.PACKAGE_FRAGMENT;
- } else {
- return -1;
- }
- } else {
- String fileName = res.getName();
- if (Util.isValidCompilationUnitName(fileName)) {
- return IJavaElement.COMPILATION_UNIT;
- } else if (Util.isValidClassFileName(fileName)) {
- return IJavaElement.CLASS_FILE;
- } else if (this.roots.get(res.getFullPath()) != null) {
- // case of proj=src=bin and resource is a jar file on the classpath
- return IJavaElement.PACKAGE_FRAGMENT_ROOT;
- } else {
- return -1;
- }
- }
- default:
- return -1;
- }
- }
-
-private void initializeRoots(IJavaModel model) {
- this.roots = new HashMap();
- this.otherRoots = new HashMap();
- IJavaProject[] projects;
- try {
- projects = ((JavaModel)model).getOldJavaProjectsList();
- } catch (JavaModelException e) {
- // nothing can be done
- return;
- }
- for (int i = 0, length = projects.length; i < length; i++) {
- IJavaProject project = projects[i];
- IClasspathEntry[] classpath;
- try {
- classpath = project.getResolvedClasspath(true);
- } catch (JavaModelException e) {
- // continue with next project
- continue;
- }
- for (int j= 0, classpathLength = classpath.length; j < classpathLength; j++) {
- IClasspathEntry entry = classpath[j];
- if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) continue;
- IPath path = entry.getPath();
- if (this.roots.get(path) == null) {
- this.roots.put(path, project);
- } else {
- HashSet set = (HashSet)this.otherRoots.get(path);
- if (set == null) {
- set = new HashSet();
- this.otherRoots.put(path, set);
- }
- set.add(project);
- }
- }
- }
-}
-
-private boolean isOnClasspath(IPath path) {
- return this.roots.get(path) != null;
-}
protected void updateIndex(Openable element, IResourceDelta delta) {
@@ -1693,8 +2096,8 @@
this.indexManager.indexAll(element.getJavaProject().getProject());
break;
case IResourceDelta.REMOVED :
- this.indexManager.discardJobs(element.getElementName());
this.indexManager.removeIndexFamily(element.getJavaProject().getProject().getFullPath());
+ // NB: Discarding index jobs belonging to this project was done during PRE_DELETE
break;
// NB: Update of index if project is opened, closed, or its java nature is added or removed
// is done in updateCurrentDeltaAndIndex
@@ -1748,12 +2151,12 @@
IResourceDelta child = children[i];
IResource resource = child.getResource();
if (resource instanceof IFile) {
- String extension = resource.getFileExtension();
- if ("java".equalsIgnoreCase(extension)) { //$NON-NLS-1$
- Openable cu = (Openable)pkg.getCompilationUnit(resource.getName());
+ String name = resource.getName();
+ if (Util.isJavaFileName(name)) {
+ Openable cu = (Openable)pkg.getCompilationUnit(name);
this.updateIndex(cu, child);
- } else if ("class".equalsIgnoreCase(extension)) { //$NON-NLS-1$
- Openable classFile = (Openable)pkg.getClassFile(resource.getName());
+ } else if (Util.isClassFileName(name)) {
+ Openable classFile = (Openable)pkg.getClassFile(name);
this.updateIndex(classFile, child);
}
}
@@ -1827,25 +2230,34 @@
* Update the roots that are affected by the addition or the removal of the given container resource.
*/
private void updateRoots(IPath containerPath, IResourceDelta containerDelta) {
- Iterator iterator = this.roots.keySet().iterator();
+ Map roots;
+ Map otherRoots;
+ if (containerDelta.getKind() == IResourceDelta.REMOVED) {
+ roots = this.oldRoots;
+ otherRoots = this.oldOtherRoots;
+ } else {
+ roots = this.roots;
+ otherRoots = this.otherRoots;
+ }
+ Iterator iterator = roots.keySet().iterator();
while (iterator.hasNext()) {
IPath path = (IPath)iterator.next();
if (containerPath.isPrefixOf(path) && !containerPath.equals(path)) {
IResourceDelta rootDelta = containerDelta.findMember(path.removeFirstSegments(1));
if (rootDelta == null) continue;
- IJavaProject rootProject = (IJavaProject)this.roots.get(path);
- try {
- this.updateCurrentDeltaAndIndex(rootDelta, IJavaElement.PACKAGE_FRAGMENT_ROOT, rootProject);
- } catch (JavaModelException e) {
+ RootInfo rootInfo = (RootInfo)roots.get(path);
+
+ if (!rootInfo.project.getPath().isPrefixOf(path)) { // only consider roots that are not included in the container
+ this.updateCurrentDeltaAndIndex(rootDelta, IJavaElement.PACKAGE_FRAGMENT_ROOT, rootInfo);
}
- HashSet set = (HashSet)this.otherRoots.get(path);
- if (set != null) {
- Iterator otherProjects = set.iterator();
+
+ ArrayList rootList = (ArrayList)otherRoots.get(path);
+ if (rootList != null) {
+ Iterator otherProjects = rootList.iterator();
while (otherProjects.hasNext()) {
- rootProject = (IJavaProject)otherProjects.next();
- try {
- this.updateCurrentDeltaAndIndex(rootDelta, IJavaElement.PACKAGE_FRAGMENT_ROOT, rootProject);
- } catch (JavaModelException e) {
+ rootInfo = (RootInfo)otherProjects.next();
+ if (!rootInfo.project.getPath().isPrefixOf(path)) { // only consider roots that are not included in the container
+ this.updateCurrentDeltaAndIndex(rootDelta, IJavaElement.PACKAGE_FRAGMENT_ROOT, rootInfo);
}
}
}
@@ -1853,4 +2265,4 @@
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DestroyWorkingCopyOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DestroyWorkingCopyOperation.java
new file mode 100644
index 0000000..630666a
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DestroyWorkingCopyOperation.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+import java.util.Map;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.JavaModelException;
+
+/**
+ * Destroys a working copy (remove it from its cache if it is shared)
+ * and signal its removal through a delta.
+ */
+public class DestroyWorkingCopyOperation extends JavaModelOperation {
+
+ public DestroyWorkingCopyOperation(IJavaElement workingCopy) {
+ super(new IJavaElement[] {workingCopy});
+ }
+ /**
+ * @exception JavaModelException if setting the source
+ * of the original compilation unit fails
+ */
+ protected void executeOperation() throws JavaModelException {
+ WorkingCopy workingCopy = getWorkingCopy();
+ workingCopy.close();
+
+ // if original element is not on classpath flush it from the cache
+ IJavaElement originalElement = workingCopy.getOriginalElement();
+ if (!workingCopy.getParent().exists()) {
+ ((CompilationUnit)originalElement).close();
+ }
+
+ // remove working copy from the cache if it is shared
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+
+ // In order to be shared, working copies have to denote the same compilation unit
+ // AND use the same buffer factory.
+ // Assuming there is a little set of buffer factories, then use a 2 level Map cache.
+ Map sharedWorkingCopies = manager.sharedWorkingCopies;
+
+ Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(workingCopy.bufferFactory);
+ if (perFactoryWorkingCopies != null){
+ if (perFactoryWorkingCopies.remove(originalElement) != null
+ && CompilationUnit.SHARED_WC_VERBOSE) {
+ System.out.println("Destroying shared working copy " + workingCopy.toStringWithAncestors());//$NON-NLS-1$
+ }
+ }
+
+ // report removed java delta
+ JavaElementDelta delta = new JavaElementDelta(this.getJavaModel());
+ delta.removed(workingCopy);
+ addDelta(delta);
+ removeReconcileDelta(workingCopy);
+ }
+ /**
+ * Returns the working copy this operation is working on.
+ */
+ protected WorkingCopy getWorkingCopy() {
+ return (WorkingCopy)getElementToProcess();
+ }
+ /**
+ * @see JavaModelOperation#isReadOnly
+ */
+ public boolean isReadOnly() {
+ return true;
+ }
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ElementCache.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ElementCache.java
index 2b164ee..52e9ec8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ElementCache.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ElementCache.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IOpenable;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/FailedReconciliationException.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/FailedReconciliationException.java
index 502318d..247f45a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/FailedReconciliationException.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/FailedReconciliationException.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
public class FailedReconciliationException extends RuntimeException {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/HandleFactory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/HandleFactory.java
index 2ea3644..5bc8b4b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/HandleFactory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/HandleFactory.java
@@ -1,20 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -27,6 +27,7 @@
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.core.index.impl.JarFileEntryDocument;
/**
@@ -61,15 +62,16 @@
* NOTE: This assumes that the resource path is the toString() of an IPath,
* i.e. it uses the IPath.SEPARATOR for file path
* and it uses '/' for entries in a zip file.
+ * If not null, uses the given scope as a hint for getting Java project handles.
*/
- public Openable createOpenable(String resourcePath) {
+ public Openable createOpenable(String resourcePath, IJavaSearchScope scope) {
int separatorIndex;
if ((separatorIndex= resourcePath.indexOf(JarFileEntryDocument.JAR_FILE_ENTRY_SEPARATOR)) > -1) {
// path to a class file inside a jar
String jarPath= resourcePath.substring(0, separatorIndex);
// Optimization: cache package fragment root handle and package handles
if (!jarPath.equals(this.lastPkgFragmentRootPath)) {
- IPackageFragmentRoot root= this.getJarPkgFragmentRoot(jarPath);
+ IPackageFragmentRoot root= this.getJarPkgFragmentRoot(jarPath, scope);
if (root == null)
return null; // match is outside classpath
this.lastPkgFragmentRootPath= jarPath;
@@ -123,16 +125,18 @@
/**
* Returns the package fragment root that corresponds to the given jar path.
* See createOpenable(...) for the format of the jar path string.
+ * If not null, uses the given scope as a hint for getting Java project handles.
*/
- private IPackageFragmentRoot getJarPkgFragmentRoot(String jarPathString) {
+ private IPackageFragmentRoot getJarPkgFragmentRoot(String jarPathString, IJavaSearchScope scope) {
IPath jarPath= new Path(jarPathString);
- IResource jarFile= this.workspace.getRoot().findMember(jarPath);
- if (jarFile != null) {
+ Object target = JavaModel.getTarget(this.workspace.getRoot(), jarPath, false);
+ if (target instanceof IFile) {
// internal jar: is it on the classpath of its project?
// e.g. org.eclipse.swt.win32/ws/win32/swt.jar
// is NOT on the classpath of org.eclipse.swt.win32
+ IFile jarFile = (IFile)target;
IJavaProject javaProject = this.javaModel.getJavaProject(jarFile);
IClasspathEntry[] classpathEntries;
try {
@@ -147,26 +151,53 @@
}
}
- // walk all projects and find the first one that has the given jar path in its classpath
+ // walk projects in the scope and find the first one that has the given jar path in its classpath
IJavaProject[] projects;
+ if (scope != null) {
+ IPath[] enclosingProjectsAndJars = scope.enclosingProjectsAndJars();
+ int length = enclosingProjectsAndJars.length;
+ projects = new IJavaProject[length];
+ int index = 0;
+ for (int i = 0; i < length; i++) {
+ IPath path = enclosingProjectsAndJars[i];
+ if (!Util.isArchiveFileName(path.lastSegment())) {
+ projects[index++] = this.javaModel.getJavaProject(path.segment(0));
+ }
+ }
+ if (index < length) {
+ System.arraycopy(projects, 0, projects = new IJavaProject[index], 0, index);
+ }
+ IPackageFragmentRoot root = getJarPkgFragmentRoot(jarPath, target, projects);
+ if (root != null) {
+ return root;
+ }
+ }
+
+ // not found in the scope, walk all projects
try {
projects = this.javaModel.getJavaProjects();
} catch (JavaModelException e) {
// java model is not accessible
return null;
}
+ return getJarPkgFragmentRoot(jarPath, target, projects);
+ }
+ private IPackageFragmentRoot getJarPkgFragmentRoot(
+ IPath jarPath,
+ Object target,
+ IJavaProject[] projects) {
for (int i= 0, projectCount= projects.length; i < projectCount; i++) {
try {
JavaProject javaProject= (JavaProject)projects[i];
IClasspathEntry[] classpathEntries= javaProject.getResolvedClasspath(true);
for (int j= 0, entryCount= classpathEntries.length; j < entryCount; j++) {
if (classpathEntries[j].getPath().equals(jarPath)) {
- if (jarFile != null) {
+ if (target instanceof IFile) {
// internal jar
- return javaProject.getPackageFragmentRoot(jarFile);
+ return javaProject.getPackageFragmentRoot((IFile)target);
} else {
// external jar
- return javaProject.getPackageFragmentRoot0(jarPathString);
+ return javaProject.getPackageFragmentRoot0(jarPath);
}
}
}
@@ -191,8 +222,8 @@
IJavaProject javaProject= this.javaModel.getJavaProject(project);
IPackageFragmentRoot[] roots= javaProject.getPackageFragmentRoots();
for (int j= 0, rootCount= roots.length; j < rootCount; j++) {
- IPackageFragmentRoot root= roots[j];
- if (root.getPath().isPrefixOf(path)) {
+ PackageFragmentRoot root= (PackageFragmentRoot)roots[j];
+ if (root.getPath().isPrefixOf(path) && !Util.isExcluded(path, root.fullExclusionPatternChars())) {
return root;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/IJavaElementRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/IJavaElementRequestor.java
index 20864f7..b38a1b0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/IJavaElementRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/IJavaElementRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IField;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/INamingRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/INamingRequestor.java
new file mode 100644
index 0000000..d97b126
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/INamingRequestor.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+public interface INamingRequestor {
+ void acceptNameWithPrefixAndSuffix(char[] name, boolean isFirstPrefix, boolean isFirstSuffix);
+ void acceptNameWithPrefix(char[] name, boolean isFirstPrefix);
+ void acceptNameWithSuffix(char[] name, boolean isFirstSuffix);
+ void acceptNameWithoutPrefixAndSuffix(char[] name);
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/IPathRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/IPathRequestor.java
index 53873d1..a1c777b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/IPathRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/IPathRequestor.java
@@ -1,15 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
public interface IPathRequestor {
void acceptPath(String path);
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java
index 22a1cbc..a75352a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportContainer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.ICompilationUnit;
@@ -35,7 +35,7 @@
* @see JavaElement#getHandleMemento()
*/
protected char getHandleMementoDelimiter() {
- Assert.isTrue(false, Util.bind("assert.shouldNotImplement")); //$NON-NLS-1$
+ Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$
return 0;
}
/**
@@ -79,4 +79,14 @@
((JavaElement)children[i]).toString(tab, buffer);
}
}
+/**
+ * Debugging purposes
+ */
+protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
+ buffer.append(this.tabString(tab));
+ buffer.append("[import container]"); //$NON-NLS-1$
+ if (info == null) {
+ buffer.append(" (not open)"); //$NON-NLS-1$
+ }
+}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java
index 3d145da..068c2cb 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IImportContainer;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java
index c2c89be..6a327ad 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Initializer.java
@@ -1,19 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IInitializer;
import org.eclipse.jdt.core.IJavaModelStatusConstants;
+import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.jdom.IDOMNode;
@@ -72,6 +73,12 @@
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this));
}
/**
+ * @see IMember
+ */
+public ISourceRange getNameRange() throws JavaModelException {
+ return null;
+}
+/**
* @private Debugging purposes
*/
protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/InitializerElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/InitializerElementInfo.java
index 8d7f4a7..9b5ef51 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/InitializerElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/InitializerElementInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/InternalNamingConventions.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/InternalNamingConventions.java
new file mode 100644
index 0000000..17ea5fc
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/InternalNamingConventions.java
@@ -0,0 +1,297 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+import java.util.Map;
+
+import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaConventions;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.eclipse.jdt.internal.codeassist.impl.AssistOptions;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
+
+public class InternalNamingConventions {
+ private static final char[] DEFAULT_NAME = "name".toCharArray(); //$NON-NLS-1$
+
+ private static Scanner getNameScanner(CompilerOptions compilerOptions) {
+ return
+ new Scanner(
+ false /*comment*/,
+ false /*whitespace*/,
+ false /*nls*/,
+ compilerOptions.sourceLevel >= CompilerOptions.JDK1_4 /*assert*/,
+ null /*taskTags*/,
+ null/*taskPriorities*/);
+ }
+ public static void suggestArgumentNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames, INamingRequestor requestor) {
+ Map options = javaProject.getOptions(true);
+ CompilerOptions compilerOptions = new CompilerOptions(options);
+ AssistOptions assistOptions = new AssistOptions(options);
+
+ suggestNames(
+ packageName,
+ qualifiedTypeName,
+ dim,
+ assistOptions.argumentPrefixes,
+ assistOptions.argumentSuffixes,
+ excludedNames,
+ getNameScanner(compilerOptions),
+ requestor);
+ }
+ public static void suggestFieldNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, int modifiers, char[][] excludedNames, INamingRequestor requestor) {
+ boolean isStatic = Flags.isStatic(modifiers);
+
+ Map options = javaProject.getOptions(true);
+ CompilerOptions compilerOptions = new CompilerOptions(options);
+ AssistOptions assistOptions = new AssistOptions(options);
+
+ suggestNames(
+ packageName,
+ qualifiedTypeName,
+ dim,
+ isStatic ? assistOptions.staticFieldPrefixes : assistOptions.fieldPrefixes,
+ isStatic ? assistOptions.staticFieldSuffixes : assistOptions.fieldSuffixes,
+ excludedNames,
+ getNameScanner(compilerOptions),
+ requestor);
+ }
+ public static void suggestLocalVariableNames(IJavaProject javaProject, char[] packageName, char[] qualifiedTypeName, int dim, char[][] excludedNames, INamingRequestor requestor) {
+ Map options = javaProject.getOptions(true);
+ CompilerOptions compilerOptions = new CompilerOptions(options);
+ AssistOptions assistOptions = new AssistOptions(options);
+
+ suggestNames(
+ packageName,
+ qualifiedTypeName,
+ dim,
+ assistOptions.localPrefixes,
+ assistOptions.localSuffixes,
+ excludedNames,
+ getNameScanner(compilerOptions),
+ requestor);
+ }
+
+ private static void suggestNames(
+ char[] packageName,
+ char[] qualifiedTypeName,
+ int dim,
+ char[][] prefixes,
+ char[][] suffixes,
+ char[][] excludedNames,
+ Scanner nameScanner,
+ INamingRequestor requestor){
+
+ if(qualifiedTypeName == null || qualifiedTypeName.length == 0)
+ return;
+
+ char[] typeName = CharOperation.lastSegment(qualifiedTypeName, '.');
+
+ if(prefixes == null || prefixes.length == 0) {
+ prefixes = new char[1][0];
+ } else {
+ int length = prefixes.length;
+ System.arraycopy(prefixes, 0, prefixes = new char[length+1][], 0, length);
+ prefixes[length] = CharOperation.NO_CHAR;
+ }
+
+ if(suffixes == null || suffixes.length == 0) {
+ suffixes = new char[1][0];
+ } else {
+ int length = suffixes.length;
+ System.arraycopy(suffixes, 0, suffixes = new char[length+1][], 0, length);
+ suffixes[length] = CharOperation.NO_CHAR;
+ }
+
+ char[][] tempNames = null;
+
+ // compute variable name for base type
+ try{
+ nameScanner.setSource(typeName);
+ switch (nameScanner.getNextToken()) {
+ case TerminalTokens.TokenNameint :
+ case TerminalTokens.TokenNamebyte :
+ case TerminalTokens.TokenNameshort :
+ case TerminalTokens.TokenNamechar :
+ case TerminalTokens.TokenNamelong :
+ case TerminalTokens.TokenNamefloat :
+ case TerminalTokens.TokenNamedouble :
+ case TerminalTokens.TokenNameboolean :
+ char[] name = computeBaseTypeNames(typeName[0], excludedNames);
+ if(name != null) {
+ tempNames = new char[][]{name};
+ }
+ break;
+ }
+ } catch(InvalidInputException e){
+ }
+
+ // compute variable name for non base type
+ if(tempNames == null) {
+ tempNames = computeNames(typeName);
+ }
+
+ boolean acceptDefaultName = true;
+
+ for (int i = 0; i < tempNames.length; i++) {
+ char[] tempName = tempNames[i];
+ if(dim > 0) {
+ int length = tempName.length;
+ if (tempName[length-1] == 's'){
+ System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length);
+ tempName[length] = 'e';
+ tempName[length+1] = 's';
+ } else if(tempName[length-1] == 'y') {
+ System.arraycopy(tempName, 0, tempName = new char[length + 2], 0, length);
+ tempName[length-1] = 'i';
+ tempName[length] = 'e';
+ tempName[length+1] = 's';
+ } else {
+ System.arraycopy(tempName, 0, tempName = new char[length + 1], 0, length);
+ tempName[length] = 's';
+ }
+ }
+
+ for (int j = 0; j < prefixes.length; j++) {
+ if(prefixes[j].length > 0
+ && Character.isLetterOrDigit(prefixes[j][prefixes[j].length - 1])) {
+ tempName[0] = Character.toUpperCase(tempName[0]);
+ } else {
+ tempName[0] = Character.toLowerCase(tempName[0]);
+ }
+ char[] prefixName = CharOperation.concat(prefixes[j], tempName);
+ for (int k = 0; k < suffixes.length; k++) {
+ char[] suffixName = CharOperation.concat(prefixName, suffixes[k]);
+ suffixName =
+ excludeNames(
+ suffixName,
+ prefixName,
+ suffixes[k],
+ excludedNames);
+ if(JavaConventions.validateFieldName(new String(suffixName)).isOK()) {
+ acceptName(suffixName, prefixes[j], suffixes[k], j == 0, k == 0, requestor);
+ acceptDefaultName = false;
+ } else {
+ suffixName = CharOperation.concat(
+ prefixName,
+ String.valueOf(1).toCharArray(),
+ suffixes[k]
+ );
+ suffixName =
+ excludeNames(
+ suffixName,
+ prefixName,
+ suffixes[k],
+ excludedNames);
+ if(JavaConventions.validateFieldName(new String(suffixName)).isOK()) {
+ acceptName(suffixName, prefixes[j], suffixes[k], j == 0, k == 0, requestor);
+ acceptDefaultName = false;
+ }
+ }
+ }
+
+ }
+ }
+ // if no names were found
+ if(acceptDefaultName) {
+ char[] name = excludeNames(DEFAULT_NAME, DEFAULT_NAME, CharOperation.NO_CHAR, excludedNames);
+ requestor.acceptNameWithoutPrefixAndSuffix(name);
+ }
+ }
+
+ private static void acceptName(
+ char[] name,
+ char[] prefix,
+ char[] suffix,
+ boolean isFirstPrefix,
+ boolean isFirstSuffix,
+ INamingRequestor requestor) {
+ if(prefix.length > 0 && suffix.length > 0) {
+ requestor.acceptNameWithPrefixAndSuffix(name, isFirstPrefix, isFirstSuffix);
+ } else if(prefix.length > 0){
+ requestor.acceptNameWithPrefix(name, isFirstPrefix);
+ } else if(suffix.length > 0){
+ requestor.acceptNameWithSuffix(name, isFirstSuffix);
+ } else {
+ requestor.acceptNameWithoutPrefixAndSuffix(name);
+ }
+ }
+
+ private static char[] computeBaseTypeNames(char firstName, char[][] excludedNames){
+ char[] name = new char[]{firstName};
+
+ for(int i = 0 ; i < excludedNames.length ; i++){
+ if(CharOperation.equals(name, excludedNames[i], false)) {
+ name[0]++;
+ if(name[0] > 'z')
+ name[0] = 'a';
+ if(name[0] == firstName)
+ return null;
+ i = 0;
+ }
+ }
+
+ return name;
+ }
+
+ private static char[][] computeNames(char[] sourceName){
+ char[][] names = new char[5][];
+ int nameCount = 0;
+ boolean previousIsUpperCase = false;
+ boolean previousIsLetter = true;
+ for(int i = sourceName.length - 1 ; i >= 0 ; i--){
+ boolean isUpperCase = Character.isUpperCase(sourceName[i]);
+ boolean isLetter = Character.isLetter(sourceName[i]);
+ if(isUpperCase && !previousIsUpperCase && previousIsLetter){
+ char[] name = CharOperation.subarray(sourceName,i,sourceName.length);
+ if(name.length > 1){
+ if(nameCount == names.length) {
+ System.arraycopy(names, 0, names = new char[nameCount * 2][], 0, nameCount);
+ }
+ name[0] = Character.toLowerCase(name[0]);
+ names[nameCount++] = name;
+ }
+ }
+ previousIsUpperCase = isUpperCase;
+ previousIsLetter = isLetter;
+ }
+ if(nameCount == 0){
+ names[nameCount++] = CharOperation.toLowerCase(sourceName);
+ }
+ System.arraycopy(names, 0, names = new char[nameCount][], 0, nameCount);
+ return names;
+ }
+
+ private static char[] excludeNames(
+ char[] suffixName,
+ char[] prefixName,
+ char[] suffix,
+ char[][] excludedNames) {
+ int count = 2;
+ int m = 0;
+ while (m < excludedNames.length) {
+ if(CharOperation.equals(suffixName, excludedNames[m], false)) {
+ suffixName = CharOperation.concat(
+ prefixName,
+ String.valueOf(count++).toCharArray(),
+ suffix
+ );
+ m = 0;
+ } else {
+ m++;
+ }
+ }
+ return suffixName;
+ }
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java
index eee0bdd..f345992 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarEntryFile.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.IOException;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragment.java
index 9405ebe..ea7a551 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragment.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentInfo.java
index 8525714..5d8235b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java
index 4328f02..35db42b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRoot.java
@@ -1,44 +1,24 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
+import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaModel;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IOpenable;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.*;
/**
* A package fragment root that corresponds to a .jar or .zip.
@@ -63,147 +43,23 @@
protected final IPath jarPath;
/**
- * The delimiter between the zip path and source path in the
- * attachment server property.
- */
- protected final static char ATTACHMENT_PROPERTY_DELIMITER= '*';
-
- /**
- * The name of the meta-inf directory not to be included as a
- * jar package fragment.
- * @see #computeJarChildren
- */
- //protected final static String META_INF_NAME = "META-INF/";
- /**
* Constructs a package fragment root which is the root of the Java package directory hierarchy
* based on a JAR file that is not contained in a <code>IJavaProject</code> and
* does not have an associated <code>IResource</code>.
*/
- protected JarPackageFragmentRoot(String jarPath, IJavaProject project) {
- super(null, project, jarPath);
- this.jarPath = new Path(jarPath);
+ protected JarPackageFragmentRoot(IPath jarPath, IJavaProject project) {
+ super(null, project, jarPath.lastSegment());
+ this.jarPath = jarPath;
}
/**
* Constructs a package fragment root which is the root of the Java package directory hierarchy
* based on a JAR file.
*/
protected JarPackageFragmentRoot(IResource resource, IJavaProject project) {
- super(resource, project);
+ super(resource, project, resource.getName());
this.jarPath = resource.getFullPath();
}
- /**
- * @see IPackageFragmentRoot
- */
- public void attachSource(IPath zipPath, IPath rootPath, IProgressMonitor monitor) throws JavaModelException {
- try {
- verifyAttachSource(zipPath);
- if (monitor != null) {
- monitor.beginTask(Util.bind("element.attachingSource"), 2); //$NON-NLS-1$
- }
- SourceMapper mapper= null;
- SourceMapper oldMapper= getSourceMapper();
- IWorkspace workspace= getJavaModel().getWorkspace();
- boolean rootNeedsToBeClosed= false;
- if (zipPath == null) {
- //source being detached
- rootNeedsToBeClosed= true;
- /* Disable deltas (see 1GDTUSD)
- // fire a delta to notify the UI about the source detachement.
- JavaModelManager manager = (JavaModelManager) JavaModelManager.getJavaModelManager();
- JavaModel model = (JavaModel) getJavaModel();
- JavaElementDelta attachedSourceDelta = new JavaElementDelta(model);
- attachedSourceDelta .sourceDetached(this); // this would be a JarPackageFragmentRoot
- manager.registerResourceDelta(attachedSourceDelta );
- manager.fire(); // maybe you want to fire the change later. Let us know about it.
- */
- } else {
- /*
- // fire a delta to notify the UI about the source attachement.
- JavaModelManager manager = (JavaModelManager) JavaModelManager.getJavaModelManager();
- JavaModel model = (JavaModel) getJavaModel();
- JavaElementDelta attachedSourceDelta = new JavaElementDelta(model);
- attachedSourceDelta .sourceAttached(this); // this would be a JarPackageFragmentRoot
- manager.registerResourceDelta(attachedSourceDelta );
- manager.fire(); // maybe you want to fire the change later. Let us know about it.
- */
-
- //check if different from the current attachment
- IPath storedZipPath= getSourceAttachmentPath();
- IPath storedRootPath= getSourceAttachmentRootPath();
- if (monitor != null) {
- monitor.worked(1);
- }
- if (storedZipPath != null) {
- if (!(storedZipPath.equals(zipPath) && rootPath.equals(storedRootPath))) {
- rootNeedsToBeClosed= true;
- }
- }
- if ((zipPath.isAbsolute() && workspace.getRoot().findMember(zipPath) != null) || !zipPath.isAbsolute()) {
- // internal to the workbench
- // a resource
- IResource zipFile= workspace.getRoot().findMember(zipPath);
- if (zipFile == null) {
- if (monitor != null) {
- monitor.done();
- }
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, zipPath));
- }
- if (!(zipFile.getType() == IResource.FILE)) {
- if (monitor != null) {
- monitor.done();
- }
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, zipPath));
- }
- }
- mapper= new SourceMapper(zipPath, rootPath.toOSString());
- }
- setSourceMapper(mapper);
- if (zipPath == null) {
- setSourceAttachmentProperty(null); //remove the property
- } else {
- //set the property to the path of the mapped zip
- setSourceAttachmentProperty(zipPath.toString() + ATTACHMENT_PROPERTY_DELIMITER + rootPath.toString());
- }
- if (rootNeedsToBeClosed) {
- if (oldMapper != null) {
- oldMapper.close();
- }
- BufferManager manager= BufferManager.getDefaultBufferManager();
- Enumeration openBuffers= manager.getOpenBuffers();
- while (openBuffers.hasMoreElements()) {
- IBuffer buffer= (IBuffer) openBuffers.nextElement();
- IOpenable possibleJarMember= buffer.getOwner();
- if (isAncestorOf((IJavaElement) possibleJarMember)) {
- buffer.close();
- }
- }
- if (monitor != null) {
- monitor.worked(1);
- }
- }
- } catch (JavaModelException e) {
- setSourceAttachmentProperty(null); // loose info - will be recomputed
- throw e;
- } finally {
- if (monitor != null) {
- monitor.done();
- }
- }
- }
- /**
- * Close the associated JAR file stored in the info of this element. If
- * this jar has an associated ZIP source attachment, close it too.
- *
- * @see IOpenable
- */
- protected void closing(Object info) throws JavaModelException {
- SourceMapper mapper= getSourceMapper();
- if (mapper != null) {
- mapper.close();
- }
- super.closing(info);
- }
/**
* Compute the package fragment children of this package fragment root.
* These are all of the directory zip entries, and any directories implied
@@ -233,12 +89,6 @@
try {
jar= getJar();
- if (isExternal()){
- // remember the timestamp of this library
- long timestamp = DeltaProcessor.getTimeStamp(new File(getPath().toOSString()));
- JavaModelManager.getJavaModelManager().deltaProcessor.externalTimeStamps.put(getPath(), new Long(timestamp));
- }
-
HashMap packageFragToTypes= new HashMap();
// always create the default package
@@ -325,6 +175,7 @@
vChildren.add(packFrag);
}
} catch (CoreException e) {
+ if (e instanceof JavaModelException) throw (JavaModelException)e;
throw new JavaModelException(e);
} finally {
JavaModelManager.getJavaModelManager().closeZipFile(jar);
@@ -361,73 +212,6 @@
}
return false;
}
-public IClasspathEntry findSourceAttachmentRecommendation() {
-
- try {
-
- IPath rootPath = this.getPath();
- IClasspathEntry entry;
- IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
-
- // try on enclosing project first
- JavaProject parentProject = (JavaProject) getJavaProject();
- try {
- entry = parentProject.getClasspathEntryFor(rootPath);
- if (entry != null){
- Object target = JavaModel.getTarget(workspaceRoot, entry.getSourceAttachmentPath(), true);
- if (target instanceof IFile){
- IFile file = (IFile) target;
- if ("jar".equalsIgnoreCase(file.getFileExtension()) || "zip".equalsIgnoreCase(file.getFileExtension())){ //$NON-NLS-2$ //$NON-NLS-1$
- return entry;
- }
- }
- if (target instanceof java.io.File){
- java.io.File file = (java.io.File) target;
- String name = file.getName();
- if (Util.endsWithIgnoreCase(name, ".jar") || Util.endsWithIgnoreCase(name, ".zip")){ //$NON-NLS-2$ //$NON-NLS-1$
- return entry;
- }
- }
- }
- } catch(JavaModelException e){
- }
-
- // iterate over all projects
- IJavaModel model = getJavaModel();
- IJavaProject[] jProjects = model.getJavaProjects();
- for (int i = 0, max = jProjects.length; i < max; i++){
- JavaProject jProject = (JavaProject) jProjects[i];
- if (jProject == parentProject) continue; // already done
- try {
- entry = jProject.getClasspathEntryFor(rootPath);
- if (entry != null){
- Object target = JavaModel.getTarget(workspaceRoot, entry.getSourceAttachmentPath(), true);
- if (target instanceof IFile){
- IFile file = (IFile) target;
- String name = file.getName();
- if (Util.endsWithIgnoreCase(name, ".jar") || Util.endsWithIgnoreCase(name, ".zip")){ //$NON-NLS-2$ //$NON-NLS-1$
- return entry;
- }
- }
- if (target instanceof java.io.File){
- java.io.File file = (java.io.File) target;
- String name = file.getName();
- if (Util.endsWithIgnoreCase(name, ".jar") || Util.endsWithIgnoreCase(name, ".zip")){ //$NON-NLS-2$ //$NON-NLS-1$
- return entry;
- }
- }
- }
- } catch(JavaModelException e){
- }
- }
- } catch(JavaModelException e){
- }
-
- return null;
-}
-
-
-
/**
* Returns the underlying ZipFile for this Jar package fragment root.
*
@@ -437,17 +221,6 @@
return JavaModelManager.getJavaModelManager().getZipFile(getPath());
}
/**
- * @see IJavaElement
- */
- public IJavaProject getJavaProject() {
- IJavaElement parent= getParent();
- if (parent == null) {
- return null;
- } else {
- return parent.getJavaProject();
- }
- }
- /**
* @see IPackageFragmentRoot
*/
public int getKind() {
@@ -471,95 +244,31 @@
* @see IPackageFragmentRoot
*/
public IPath getPath() {
- if (fResource == null) {
+ if (isExternal()) {
return this.jarPath;
} else {
return super.getPath();
}
}
- /**
- * @see IPackageFragmentRoot
- */
- public IPath getSourceAttachmentPath() throws JavaModelException {
- String serverPathString= getSourceAttachmentProperty();
- if (serverPathString == null) {
- return null;
+ public IResource getResource() {
+ if (this.resource == null) {
+ this.resource = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), this.jarPath, false);
}
- int index= serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
- if (index < 0) return null;
- String serverZipPathString= serverPathString.substring(0, index);
- return new Path(serverZipPathString);
- }
- /**
- * Returns the server property for this package fragment root's
- * source attachement.
- */
- protected String getSourceAttachmentProperty() throws JavaModelException {
- String propertyString = null;
- QualifiedName qName= getSourceAttachmentPropertyName();
- try {
- propertyString = getWorkspace().getRoot().getPersistentProperty(qName);
-
- // if no existing source attachment information, then lookup a recommendation from classpath entries
- if (propertyString == null || propertyString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER) < 0){
- IClasspathEntry recommendation = findSourceAttachmentRecommendation();
- if (recommendation != null){
- propertyString = recommendation.getSourceAttachmentPath().toString()
- + ATTACHMENT_PROPERTY_DELIMITER
- + (recommendation.getSourceAttachmentRootPath() == null ? "" : recommendation.getSourceAttachmentRootPath().toString()); //$NON-NLS-1$
- setSourceAttachmentProperty(propertyString);
- }
- }
- return propertyString;
- } catch (CoreException ce) {
- throw new JavaModelException(ce);
- }
- }
-
- public void setSourceAttachmentProperty(String property){
- try {
- getWorkspace().getRoot().setPersistentProperty(this.getSourceAttachmentPropertyName(), property);
- } catch (CoreException ce) {
- }
- }
-
- /**
- * Returns the qualified name for the source attachment property
- * of this jar.
- */
- protected QualifiedName getSourceAttachmentPropertyName() throws JavaModelException {
- return new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + this.jarPath.toOSString()); //$NON-NLS-1$
- }
- /**
- * @see IPackageFragmentRoot
- */
- public IPath getSourceAttachmentRootPath() throws JavaModelException {
- String serverPathString= getSourceAttachmentProperty();
- if (serverPathString == null) {
- return null;
- }
- int index= serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
- String serverRootPathString= IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH;
- if (index != serverPathString.length() - 1) {
- serverRootPathString= serverPathString.substring(index + 1);
- }
- return new Path(serverRootPathString);
- }
- /**
- * @see JavaElement
- */
- public SourceMapper getSourceMapper() {
- try {
- return ((JarPackageFragmentRootInfo) getElementInfo()).getSourceMapper();
- } catch (JavaModelException e) {
+ if (this.resource instanceof IResource) {
+ return super.getResource();
+ } else {
+ // external jar
return null;
}
}
+
+
/**
* @see IJavaElement
*/
public IResource getUnderlyingResource() throws JavaModelException {
- if (fResource == null) {
+ if (isExternal()) {
+ if (!exists()) throw newNotPresentException();
return null;
} else {
return super.getUnderlyingResource();
@@ -590,7 +299,7 @@
* @see IPackageFragmentRoot
*/
public boolean isExternal() {
- return fResource == null;
+ return getResource() == null;
}
/**
* Jars and jar entries are all read only
@@ -598,74 +307,41 @@
public boolean isReadOnly() {
return true;
}
- /**
- * @see Openable#openWhenClosed()
- */
- protected void openWhenClosed(IProgressMonitor pm) throws JavaModelException {
- super.openWhenClosed(pm);
- try {
- //restore any stored attached source zip
- IPath zipPath= getSourceAttachmentPath();
- if (zipPath != null) {
- IPath rootPath= getSourceAttachmentRootPath();
- attachSource(zipPath, rootPath, pm);
- }
- } catch(JavaModelException e){ // no attached source
- }
- }
+
/**
* An archive cannot refresh its children.
*/
public void refreshChildren() {
// do nothing
}
+/**
+ * Returns whether the corresponding resource or associated file exists
+ */
+protected boolean resourceExists() {
+ if (this.isExternal()) {
+ return
+ JavaModel.getTarget(
+ ResourcesPlugin.getWorkspace().getRoot(),
+ this.getPath(), // don't make the path relative as this is an external archive
+ true) != null;
+ } else {
+ return super.resourceExists();
+ }
+}
/*
* @see JavaElement#rootedAt(IJavaProject)
*/
public IJavaElement rootedAt(IJavaProject project) {
- if (fResource == null) {
+ if (isExternal()) {
return
new JarPackageFragmentRoot(
- this.jarPath.toString(),
+ this.jarPath,
project);
} else {
return
new JarPackageFragmentRoot(
- fResource,
+ getResource(),
project);
}
}
-
- /**
- * For use by <code>AttachSourceOperation</code> only.
- * Sets the source mapper associated with this jar.
- */
- public void setSourceMapper(SourceMapper mapper) throws JavaModelException {
- ((JarPackageFragmentRootInfo) getElementInfo()).setSourceMapper(mapper);
- }
- /**
- * Possible failures: <ul>
- * <li>RELATIVE_PATH - the path supplied to this operation must be
- * an absolute path
- * <li>ELEMENT_NOT_PRESENT - the jar supplied to the operation
- * does not exist
- * </ul>
- */
- protected void verifyAttachSource(IPath zipPath) throws JavaModelException {
- if (!exists()) {
- throw newNotPresentException();
- } else if (zipPath != null && !zipPath.isAbsolute()) {
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.RELATIVE_PATH, zipPath));
- }
- }
-
-/**
- * @see JavaElement#getHandleMemento()
- */
-public String getHandleMemento(){
- StringBuffer buff= new StringBuffer(((JavaElement)getParent()).getHandleMemento());
- buff.append(getHandleMementoDelimiter());
- buff.append(this.jarPath.toString()); // 1GEP51U
- return buff.toString();
-}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRootInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRootInfo.java
index 2eb3b77..03ee082 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRootInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JarPackageFragmentRootInfo.java
@@ -1,24 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
/**
* The element info for <code>JarPackageFragmentRoot</code>s.
*/
class JarPackageFragmentRootInfo extends PackageFragmentRootInfo {
- /**
- * The SourceMapper for this JAR (or <code>null</code> if
- * this JAR does not have source attached).
- */
- protected SourceMapper fSourceMapper= null;
/**
* Returns an array of non-java resources contained in the receiver.
*/
@@ -26,17 +21,4 @@
fNonJavaResources = NO_NON_JAVA_RESOURCES;
return fNonJavaResources;
}
-/**
- * Retuns the SourceMapper for this JAR, or <code>null</code>
- * if this JAR does not have attached source.
- */
-protected SourceMapper getSourceMapper() {
- return fSourceMapper;
-}
-/**
- * Sets the SourceMapper for this JAR.
- */
-protected void setSourceMapper(SourceMapper mapper) {
- fSourceMapper= mapper;
-}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java
index 4e248c6..df898a9 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java
@@ -1,33 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaModel;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IOpenable;
-import org.eclipse.jdt.core.IParent;
-import org.eclipse.jdt.core.ISourceRange;
-import org.eclipse.jdt.core.ISourceReference;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.jdom.IDOMCompilationUnit;
import org.eclipse.jdt.core.jdom.IDOMNode;
@@ -81,597 +69,579 @@
protected static final Object NO_INFO = new Object();
-/**
- * Constructs a handle for a java element of the specified type, with
- * the given parent element and name.
- *
- * @param type - one of the constants defined in IJavaLanguageElement
- *
- * @exception IllegalArgumentException if the type is not one of the valid
- * Java element type constants
- *
- */
-protected JavaElement(int type, IJavaElement parent, String name) throws IllegalArgumentException {
- if (type < JAVA_MODEL || type > IMPORT_DECLARATION) {
- throw new IllegalArgumentException(Util.bind("element.invalidType")); //$NON-NLS-1$
- }
- fLEType= type;
- fParent= parent;
- fName= name;
-}
-/**
- * @see IOpenable
- */
-public void close() throws JavaModelException {
- Object info = JavaModelManager.getJavaModelManager().peekAtInfo(this);
- if (info != null) {
- if (JavaModelManager.VERBOSE && this instanceof JavaModel) {
- System.out.println("CLOSING Java Model"); //$NON-NLS-1$
- // done only when exiting the workbench: disable verbose
- JavaModelManager.VERBOSE = false;
+ /**
+ * Constructs a handle for a java element of the specified type, with
+ * the given parent element and name.
+ *
+ * @param type - one of the constants defined in IJavaLanguageElement
+ *
+ * @exception IllegalArgumentException if the type is not one of the valid
+ * Java element type constants
+ *
+ */
+ protected JavaElement(int type, IJavaElement parent, String name) throws IllegalArgumentException {
+ if (type < JAVA_MODEL || type > IMPORT_DECLARATION) {
+ throw new IllegalArgumentException(Util.bind("element.invalidType")); //$NON-NLS-1$
}
- if (this instanceof IParent) {
- IJavaElement[] children = ((JavaElementInfo) info).getChildren();
- for (int i = 0, size = children.length; i < size; ++i) {
- JavaElement child = (JavaElement) children[i];
- child.close();
- }
- }
- closing(info);
- JavaModelManager.getJavaModelManager().removeInfo(this);
- if (JavaModelManager.VERBOSE){
- System.out.println("-> Package cache size = " + JavaModelManager.getJavaModelManager().cache.pkgSize()); //$NON-NLS-1$
- System.out.println("-> Openable cache filling ratio = " + JavaModelManager.getJavaModelManager().cache.openableFillingRatio() + "%"); //$NON-NLS-1$//$NON-NLS-2$
- }
+ fLEType= type;
+ fParent= parent;
+ fName= name;
}
-}
-/**
- * This element is being closed. Do any necessary cleanup.
- */
-protected void closing(Object info) throws JavaModelException {
- if (JavaModelManager.VERBOSE){
- System.out.println("CLOSING Element ("+ Thread.currentThread()+"): " + this.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$
- }
-}
-/**
- * Returns true if this handle represents the same Java element
- * as the given handle. By default, two handles represent the same
- * element if they are identical or if they represent the same type
- * of element, have equal names, parents, and occurrence counts.
- *
- * <p>If a subclass has other requirements for equality, this method
- * must be overridden.
- *
- * @see Object#equals
- */
-public boolean equals(Object o) {
-
- if (this == o) return true;
-
- // Java model parent is null
- if (fParent == null) return super.equals(o);
-
- if (o instanceof JavaElement) {
- JavaElement other = (JavaElement) o;
- if (fLEType != other.fLEType) return false;
-
- return fName.equals(other.fName) &&
- fParent.equals(other.fParent) &&
- fOccurrenceCount == other.fOccurrenceCount;
- }
- return false;
-}
-/**
- * Returns true if this <code>JavaElement</code> is equivalent to the given
- * <code>IDOMNode</code>.
- */
-protected boolean equalsDOMNode(IDOMNode node) throws JavaModelException {
- return false;
-}
-/**
- * @see IJavaElement
- */
-public boolean exists() {
-
- try {
- getRawInfo();
- return true;
- } catch (JavaModelException e) {
- }
- return false;
-}
-
-/**
- * Returns the <code>IDOMNode</code> that corresponds to this <code>JavaElement</code>
- * or <code>null</code> if there is no corresponding node.
- */
-public IDOMNode findNode(IDOMCompilationUnit dom) {
- int type = getElementType();
- if (type == IJavaElement.COMPILATION_UNIT ||
- type == IJavaElement.FIELD ||
- type == IJavaElement.IMPORT_DECLARATION ||
- type == IJavaElement.INITIALIZER ||
- type == IJavaElement.METHOD ||
- type == IJavaElement.PACKAGE_DECLARATION ||
- type == IJavaElement.TYPE) {
- ArrayList path = new ArrayList();
- IJavaElement element = this;
- while (element != null && element.getElementType() != IJavaElement.COMPILATION_UNIT) {
- if (element.getElementType() != IJavaElement.IMPORT_CONTAINER) {
- // the DOM does not have import containers, so skip them
- path.add(0, element);
- }
- element = element.getParent();
- }
- if (path.size() == 0) {
+ /**
+ * @see IOpenable
+ */
+ public void close() throws JavaModelException {
+ Object info = JavaModelManager.getJavaModelManager().peekAtInfo(this);
+ if (info != null) {
+ boolean wasVerbose = false;
try {
- if (equalsDOMNode(dom)) {
- return dom;
- } else {
- return null;
+ if (JavaModelManager.VERBOSE) {
+ System.out.println("CLOSING Element ("+ Thread.currentThread()+"): " + this.toStringWithAncestors()); //$NON-NLS-1$//$NON-NLS-2$
+ wasVerbose = true;
+ JavaModelManager.VERBOSE = false;
}
- } catch(JavaModelException e) {
- return null;
+ if (this instanceof IParent) {
+ IJavaElement[] children = ((JavaElementInfo) info).getChildren();
+ for (int i = 0, size = children.length; i < size; ++i) {
+ JavaElement child = (JavaElement) children[i];
+ child.close();
+ }
+ }
+ closing(info);
+ JavaModelManager.getJavaModelManager().removeInfo(this);
+ if (wasVerbose) {
+ System.out.println("-> Package cache size = " + JavaModelManager.getJavaModelManager().cache.pkgSize()); //$NON-NLS-1$
+ System.out.println("-> Openable cache filling ratio = " + JavaModelManager.getJavaModelManager().cache.openableFillingRatio() + "%"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ } finally {
+ JavaModelManager.VERBOSE = wasVerbose;
}
}
- return ((JavaElement) path.get(0)).followPath(path, 0, dom.getFirstChild());
- } else {
- return null;
}
-}
-/**
- */
-protected IDOMNode followPath(ArrayList path, int position, IDOMNode node) {
-
- try {
- if (equalsDOMNode(node)) {
- if (position == (path.size() - 1)) {
- return node;
- } else {
- if (node.getFirstChild() != null) {
- position++;
- return ((JavaElement)path.get(position)).followPath(path, position, node.getFirstChild());
- } else {
+ /**
+ * This element is being closed. Do any necessary cleanup.
+ */
+ protected void closing(Object info) throws JavaModelException {
+ }
+ /**
+ * Returns true if this handle represents the same Java element
+ * as the given handle. By default, two handles represent the same
+ * element if they are identical or if they represent the same type
+ * of element, have equal names, parents, and occurrence counts.
+ *
+ * <p>If a subclass has other requirements for equality, this method
+ * must be overridden.
+ *
+ * @see Object#equals
+ */
+ public boolean equals(Object o) {
+
+ if (this == o) return true;
+
+ // Java model parent is null
+ if (fParent == null) return super.equals(o);
+
+ if (o instanceof JavaElement) {
+ JavaElement other = (JavaElement) o;
+ if (fLEType != other.fLEType) return false;
+
+ return fName.equals(other.fName) &&
+ fParent.equals(other.fParent) &&
+ fOccurrenceCount == other.fOccurrenceCount;
+ }
+ return false;
+ }
+ /**
+ * Returns true if this <code>JavaElement</code> is equivalent to the given
+ * <code>IDOMNode</code>.
+ */
+ protected boolean equalsDOMNode(IDOMNode node) throws JavaModelException {
+ return false;
+ }
+ /**
+ * @see IJavaElement
+ */
+ public boolean exists() {
+
+ try {
+ getElementInfo();
+ return true;
+ } catch (JavaModelException e) {
+ }
+ return false;
+ }
+
+ /**
+ * Returns the <code>IDOMNode</code> that corresponds to this <code>JavaElement</code>
+ * or <code>null</code> if there is no corresponding node.
+ */
+ public IDOMNode findNode(IDOMCompilationUnit dom) {
+ int type = getElementType();
+ if (type == IJavaElement.COMPILATION_UNIT ||
+ type == IJavaElement.FIELD ||
+ type == IJavaElement.IMPORT_DECLARATION ||
+ type == IJavaElement.INITIALIZER ||
+ type == IJavaElement.METHOD ||
+ type == IJavaElement.PACKAGE_DECLARATION ||
+ type == IJavaElement.TYPE) {
+ ArrayList path = new ArrayList();
+ IJavaElement element = this;
+ while (element != null && element.getElementType() != IJavaElement.COMPILATION_UNIT) {
+ if (element.getElementType() != IJavaElement.IMPORT_CONTAINER) {
+ // the DOM does not have import containers, so skip them
+ path.add(0, element);
+ }
+ element = element.getParent();
+ }
+ if (path.size() == 0) {
+ try {
+ if (equalsDOMNode(dom)) {
+ return dom;
+ } else {
+ return null;
+ }
+ } catch(JavaModelException e) {
return null;
}
}
- } else if (node.getNextNode() != null) {
- return followPath(path, position, node.getNextNode());
+ return ((JavaElement) path.get(0)).followPath(path, 0, dom.getFirstChild());
} else {
return null;
}
- } catch (JavaModelException e) {
+ }
+ /**
+ */
+ protected IDOMNode followPath(ArrayList path, int position, IDOMNode node) {
+
+ try {
+ if (equalsDOMNode(node)) {
+ if (position == (path.size() - 1)) {
+ return node;
+ } else {
+ if (node.getFirstChild() != null) {
+ position++;
+ return ((JavaElement)path.get(position)).followPath(path, position, node.getFirstChild());
+ } else {
+ return null;
+ }
+ }
+ } else if (node.getNextNode() != null) {
+ return followPath(path, position, node.getNextNode());
+ } else {
+ return null;
+ }
+ } catch (JavaModelException e) {
+ return null;
+ }
+
+ }
+ /**
+ * @see IJavaElement
+ */
+ public IJavaElement getAncestor(int ancestorType) {
+
+ IJavaElement element = this;
+ while (element != null) {
+ if (element.getElementType() == ancestorType) return element;
+ element= element.getParent();
+ }
+ return null;
+ }
+ /**
+ * @see IParent
+ */
+ public IJavaElement[] getChildren() throws JavaModelException {
+ return ((JavaElementInfo)getElementInfo()).getChildren();
+ }
+ /**
+ * Returns a collection of (immediate) children of this node of the
+ * specified type.
+ *
+ * @param type - one of constants defined by IJavaLanguageElementTypes
+ */
+ public ArrayList getChildrenOfType(int type) throws JavaModelException {
+ IJavaElement[] children = getChildren();
+ int size = children.length;
+ ArrayList list = new ArrayList(size);
+ for (int i = 0; i < size; ++i) {
+ JavaElement elt = (JavaElement)children[i];
+ if (elt.getElementType() == type) {
+ list.add(elt);
+ }
+ }
+ return list;
+ }
+ /**
+ * @see IMember
+ */
+ public IClassFile getClassFile() {
+ return null;
+ }
+ /**
+ * @see IMember
+ */
+ public ICompilationUnit getCompilationUnit() {
+ return null;
+ }
+ /**
+ * Returns the info for this handle.
+ * If this element is not already open, it and all of its parents are opened.
+ * Does not return null.
+ * NOTE: BinaryType infos are NJOT rooted under JavaElementInfo.
+ * @exception JavaModelException if the element is not present or not accessible
+ */
+ public Object getElementInfo() throws JavaModelException {
+
+ // workaround to ensure parent project resolved classpath is available to avoid triggering initializers
+ // while the JavaModelManager lock is acquired (can cause deadlocks in clients)
+ IJavaProject project = getJavaProject();
+ if (project != null && !project.isOpen()) {
+ // TODO: need to revisit, since deadlock could still occur if perProjectInfo is removed concurrent before entering the lock
+ try {
+ project.getResolvedClasspath(true); // trigger all possible container/variable initialization outside the model lock
+ } catch (JavaModelException e) {
+ // project is not accessible or is not a java project
+ }
+ }
+
+ // element info creation is done inside a lock on the JavaModelManager
+ JavaModelManager manager;
+ synchronized(manager = JavaModelManager.getJavaModelManager()){
+ Object info = manager.getInfo(this);
+ if (info == null) {
+ openHierarchy();
+ info= manager.getInfo(this);
+ if (info == null) {
+ throw newNotPresentException();
+ }
+ }
+ return info;
+ }
+ }
+ /**
+ * @see IAdaptable
+ */
+ public String getElementName() {
+ return fName;
+ }
+ /**
+ * @see IJavaElement
+ */
+ public int getElementType() {
+ return fLEType;
+ }
+ /**
+ * @see IJavaElement
+ */
+ public String getHandleIdentifier() {
+ return getHandleMemento();
+ }
+ /**
+ * @see JavaElement#getHandleMemento()
+ */
+ public String getHandleMemento(){
+ StringBuffer buff= new StringBuffer(((JavaElement)getParent()).getHandleMemento());
+ buff.append(getHandleMementoDelimiter());
+ buff.append(getElementName());
+ return buff.toString();
+ }
+ /**
+ * Returns the <code>char</code> that marks the start of this handles
+ * contribution to a memento.
+ */
+ protected abstract char getHandleMementoDelimiter();
+ /**
+ * @see IJavaElement
+ */
+ public IJavaModel getJavaModel() {
+ IJavaElement current = this;
+ do {
+ if (current instanceof IJavaModel) return (IJavaModel) current;
+ } while ((current = current.getParent()) != null);
return null;
}
-}
-/**
- * @see IJavaElement
- */
-public IJavaElement getAncestor(int ancestorType) {
+ /**
+ * @see IJavaElement
+ */
+ public IJavaProject getJavaProject() {
+ IJavaElement current = this;
+ do {
+ if (current instanceof IJavaProject) return (IJavaProject) current;
+ } while ((current = current.getParent()) != null);
+ return null;
+ }
+ /**
+ * Returns the occurrence count of the handle.
+ */
+ protected int getOccurrenceCount() {
+ return fOccurrenceCount;
+ }
+ /*
+ * @see IJavaElement
+ */
+ public IOpenable getOpenable() {
+ return this.getOpenableParent();
+ }
+ /**
+ * Return the first instance of IOpenable in the parent
+ * hierarchy of this element.
+ *
+ * <p>Subclasses that are not IOpenable's must override this method.
+ */
+ public IOpenable getOpenableParent() {
+
+ return (IOpenable)fParent;
+ }
+ /**
+ * @see IJavaElement
+ */
+ public IJavaElement getParent() {
+ return fParent;
+ }
- IJavaElement element = this;
- while (element != null) {
- if (element.getElementType() == ancestorType) return element;
- element= element.getParent();
- }
- return null;
-}
-/**
- * @see IParent
- */
-public IJavaElement[] getChildren() throws JavaModelException {
- return getElementInfo().getChildren();
-}
-/**
- * Returns a collection of (immediate) children of this node of the
- * specified type.
- *
- * @param type - one of constants defined by IJavaLanguageElementTypes
- */
-public ArrayList getChildrenOfType(int type) throws JavaModelException {
- IJavaElement[] children = getChildren();
- int size = children.length;
- ArrayList list = new ArrayList(size);
- for (int i = 0; i < size; ++i) {
- JavaElement elt = (JavaElement)children[i];
- if (elt.getElementType() == type) {
- list.add(elt);
- }
- }
- return list;
-}
-/**
- * @see IMember
- */
-public IClassFile getClassFile() {
- return null;
-}
-/**
- * @see IMember
- */
-public ICompilationUnit getCompilationUnit() {
- return null;
-}
-/**
- * Returns the info for this handle.
- * If this element is not already open, it and all of its parents are opened.
- * Does not return null.
- *
- * @exception JavaModelException if the element is not present or not accessible
- */
-public JavaElementInfo getElementInfo() throws JavaModelException {
- JavaModelManager manager;
- synchronized(manager = JavaModelManager.getJavaModelManager()){
- Object info = manager.getInfo(this);
- if (info == null) {
- openHierarchy();
- info= manager.getInfo(this);
- if (info == null) {
- throw newNotPresentException();
- }
- }
- return (JavaElementInfo)info;
- }
-}
-/**
- * @see IAdaptable
- */
-public String getElementName() {
- return fName;
-}
-/**
- * @see IJavaElement
- */
-public int getElementType() {
- return fLEType;
-}
-/**
- * @see IJavaElement
- */
-public String getHandleIdentifier() {
- return getHandleMemento();
-}
-/**
- * @see JavaElement#getHandleMemento()
- */
-public String getHandleMemento(){
- StringBuffer buff= new StringBuffer(((JavaElement)getParent()).getHandleMemento());
- buff.append(getHandleMementoDelimiter());
- buff.append(getElementName());
- return buff.toString();
-}
-/**
- * Returns the <code>char</code> that marks the start of this handles
- * contribution to a memento.
- */
-protected abstract char getHandleMementoDelimiter();
-/**
- * @see IJavaElement
- */
-public IJavaModel getJavaModel() {
- return getParent().getJavaModel();
-}
-/**
- * Returns the JavaModelManager
- */
-public JavaModelManager getJavaModelManager() {
- return JavaModelManager.getJavaModelManager();
-}
-/**
- * @see IJavaElement
- */
-public IJavaProject getJavaProject() {
- return getParent().getJavaProject();
-}
-/**
- * Returns the occurrence count of the handle.
- */
-protected int getOccurrenceCount() {
- return fOccurrenceCount;
-}
-/*
- * @see IJavaElement
- */
-public IOpenable getOpenable() {
- return this.getOpenableParent();
-}
-/**
- * Return the first instance of IOpenable in the parent
- * hierarchy of this element.
- *
- * <p>Subclasses that are not IOpenable's must override this method.
- */
-public IOpenable getOpenableParent() {
-
- return (IOpenable)fParent;
-}
-/**
- * @see IJavaElement
- */
-public IJavaElement getParent() {
- return fParent;
-}
-
-/**
- * Returns the info for this handle.
- * If this element is not already open, it and all of its parents are opened.
- * Does not return null.
- *
- * @exception JavaModelException if the element is not present or not accessible
- */
-public Object getRawInfo() throws JavaModelException {
- synchronized(JavaModelManager.getJavaModelManager()){
- Object info = JavaModelManager.getJavaModelManager().getInfo(this);
- if (info == null) {
- openHierarchy();
- info= JavaModelManager.getJavaModelManager().getInfo(this);
- if (info == null) {
- throw newNotPresentException();
- }
- }
- return info;
- }
-}
-/**
- * Returns the element that is located at the given source position
- * in this element. This is a helper method for <code>ICompilationUnit#getElementAt</code>,
- * and only works on compilation units and types. The position given is
- * known to be within this element's source range already, and if no finer
- * grained element is found at the position, this element is returned.
- */
-protected IJavaElement getSourceElementAt(int position) throws JavaModelException {
- if (this instanceof ISourceReference) {
- IJavaElement[] children = getChildren();
- int i;
- for (i = 0; i < children.length; i++) {
- IJavaElement aChild = children[i];
- if (aChild instanceof SourceRefElement) {
- SourceRefElement child = (SourceRefElement) children[i];
- ISourceRange range = child.getSourceRange();
- if (position < range.getOffset() + range.getLength() && position >= range.getOffset()) {
- if (child instanceof IParent) {
- return child.getSourceElementAt(position);
- } else {
- return child;
+ /**
+ * Returns the element that is located at the given source position
+ * in this element. This is a helper method for <code>ICompilationUnit#getElementAt</code>,
+ * and only works on compilation units and types. The position given is
+ * known to be within this element's source range already, and if no finer
+ * grained element is found at the position, this element is returned.
+ */
+ protected IJavaElement getSourceElementAt(int position) throws JavaModelException {
+ if (this instanceof ISourceReference) {
+ IJavaElement[] children = getChildren();
+ int i;
+ for (i = 0; i < children.length; i++) {
+ IJavaElement aChild = children[i];
+ if (aChild instanceof SourceRefElement) {
+ SourceRefElement child = (SourceRefElement) children[i];
+ ISourceRange range = child.getSourceRange();
+ if (position < range.getOffset() + range.getLength() && position >= range.getOffset()) {
+ if (child instanceof IParent) {
+ return child.getSourceElementAt(position);
+ } else {
+ return child;
+ }
}
}
}
+ } else {
+ // should not happen
+ Assert.isTrue(false);
}
- } else {
- // should not happen
- Assert.isTrue(false);
+ return this;
}
- return this;
-}
-/**
- * Returns the SourceMapper facility for this element, or
- * <code>null</code> if this element does not have a
- * SourceMapper.
- */
-public SourceMapper getSourceMapper() {
- return ((JavaElement)getParent()).getSourceMapper();
-}
-public abstract IResource getUnderlyingResource() throws JavaModelException;
-/**
- * Returns the workspace associated with this object.
- */
-public IWorkspace getWorkspace() {
- return getJavaModel().getWorkspace();
-}
-/**
- * Returns the hash code for this Java element. By default,
- * the hash code for an element is a combination of its name
- * and parent's hash code. Elements with other requirements must
- * override this method.
- */
-public int hashCode() {
- if (fParent == null) return super.hashCode();
- return Util.combineHashCodes(fName.hashCode(), fParent.hashCode());
-}
-/**
- * Returns true if this element is an ancestor of the given element,
- * otherwise false.
- */
-protected boolean isAncestorOf(IJavaElement e) {
- IJavaElement parent= e.getParent();
- while (parent != null && !parent.equals(this)) {
- parent= parent.getParent();
+ /**
+ * Returns the SourceMapper facility for this element, or
+ * <code>null</code> if this element does not have a
+ * SourceMapper.
+ */
+ public SourceMapper getSourceMapper() {
+ return ((JavaElement)getParent()).getSourceMapper();
}
- return parent != null;
-}
-/**
- * @see IJavaElement
- */
-public boolean isReadOnly() {
- return false;
-}
-/**
- * @see IJavaElement
- */
-public boolean isStructureKnown() throws JavaModelException {
- return getElementInfo().isStructureKnown();
-}
-/**
- * Creates and returns and not present exception for this element.
- */
-protected JavaModelException newNotPresentException() {
- return new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this));
-}
-/**
- * Default is to not do any source indices updates.
- */
-public void offsetSourceEndAndChildren(int amount, IJavaElement child) {
+ /**
+ * Returns the hash code for this Java element. By default,
+ * the hash code for an element is a combination of its name
+ * and parent's hash code. Elements with other requirements must
+ * override this method.
+ */
+ public int hashCode() {
+ if (fParent == null) return super.hashCode();
+ return Util.combineHashCodes(fName.hashCode(), fParent.hashCode());
+ }
+ /**
+ * Returns true if this element is an ancestor of the given element,
+ * otherwise false.
+ */
+ protected boolean isAncestorOf(IJavaElement e) {
+ IJavaElement parent= e.getParent();
+ while (parent != null && !parent.equals(this)) {
+ parent= parent.getParent();
+ }
+ return parent != null;
+ }
-}
-/**
- * Default behaviour is not to change the source range
- * for the Java element
- */
-public void offsetSourceRange(int amount) {
-}
-/**
- * Opens this element and all parents that are not already open.
- *
- * @exception JavaModelException this element is not present or accessible
- */
-protected void openHierarchy() throws JavaModelException {
- if (this instanceof IOpenable) {
- ((Openable) this).openWhenClosed(null);
- } else {
- Openable openableParent = (Openable)getOpenableParent();
- if (openableParent != null) {
- JavaElementInfo openableParentInfo = (JavaElementInfo) JavaModelManager.getJavaModelManager().getInfo((IJavaElement) openableParent);
- if (openableParentInfo == null) {
- openableParent.openWhenClosed(null);
+ /**
+ * @see IJavaElement
+ */
+ public boolean isReadOnly() {
+ return false;
+ }
+ /**
+ * @see IJavaElement
+ */
+ public boolean isStructureKnown() throws JavaModelException {
+ return ((JavaElementInfo)getElementInfo()).isStructureKnown();
+ }
+ /**
+ * Creates and returns and not present exception for this element.
+ */
+ protected JavaModelException newNotPresentException() {
+ return new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this));
+ }
+ /**
+ * Opens this element and all parents that are not already open.
+ *
+ * @exception JavaModelException this element is not present or accessible
+ */
+ protected void openHierarchy() throws JavaModelException {
+ if (this instanceof IOpenable) {
+ ((Openable) this).openWhenClosed(null);
+ } else {
+ Openable openableParent = (Openable)getOpenableParent();
+ if (openableParent != null) {
+ JavaElementInfo openableParentInfo = (JavaElementInfo) JavaModelManager.getJavaModelManager().getInfo((IJavaElement) openableParent);
+ if (openableParentInfo == null) {
+ openableParent.openWhenClosed(null);
+ } else {
+ throw newNotPresentException();
+ }
+ }
+ }
+ }
+ /**
+ * This element has just been opened. Do any necessary setup.
+ */
+ protected void opening(Object info) {
+ }
+ /**
+ */
+ public String readableName() {
+ return this.getElementName();
+ }
+ /**
+ * Removes all cached info from the Java Model, including all children,
+ * but does not close this element.
+ */
+ protected void removeInfo() {
+ Object info = JavaModelManager.getJavaModelManager().peekAtInfo(this);
+ if (info != null) {
+ if (this instanceof IParent) {
+ IJavaElement[] children = ((JavaElementInfo)info).getChildren();
+ for (int i = 0, size = children.length; i < size; ++i) {
+ JavaElement child = (JavaElement) children[i];
+ child.removeInfo();
+ }
+ }
+ JavaModelManager.getJavaModelManager().removeInfo(this);
+ }
+ }
+ /**
+ * Returns a copy of this element rooted at the given project.
+ */
+ public abstract IJavaElement rootedAt(IJavaProject project);
+ /**
+ * Runs a Java Model Operation
+ */
+ public static void runOperation(JavaModelOperation operation, IProgressMonitor monitor) throws JavaModelException {
+ try {
+ if (operation.isReadOnly() || ResourcesPlugin.getWorkspace().isTreeLocked()) {
+ operation.run(monitor);
} else {
- throw newNotPresentException();
+ // use IWorkspace.run(...) to ensure that a build will be done in autobuild mode
+ ResourcesPlugin.getWorkspace().run(operation, monitor);
+ }
+ } catch (CoreException ce) {
+ if (ce instanceof JavaModelException) {
+ throw (JavaModelException)ce;
+ } else {
+ if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
+ Throwable e= ce.getStatus().getException();
+ if (e instanceof JavaModelException) {
+ throw (JavaModelException) e;
+ }
+ }
+ throw new JavaModelException(ce);
}
}
}
-}
-/**
- * This element has just been opened. Do any necessary setup.
- */
-protected void opening(Object info) {
-}
-
-
-
-/**
- */
-public String readableName() {
-
- return this.getElementName();
-}
-
-/**
- * Removes all cached info from the Java Model, including all children,
- * but does not close this element.
- */
-protected void removeInfo() {
- Object info = JavaModelManager.getJavaModelManager().peekAtInfo(this);
- if (info != null) {
- if (this instanceof IParent) {
- IJavaElement[] children = ((JavaElementInfo)info).getChildren();
- for (int i = 0, size = children.length; i < size; ++i) {
- JavaElement child = (JavaElement) children[i];
- child.removeInfo();
- }
- }
- JavaModelManager.getJavaModelManager().removeInfo(this);
+ /**
+ * Sets the occurrence count of the handle.
+ */
+ protected void setOccurrenceCount(int count) {
+ fOccurrenceCount = count;
}
-}
-/**
- * Returns a copy of this element rooted at the given project.
- */
-public abstract IJavaElement rootedAt(IJavaProject project);
-/**
- * Runs a Java Model Operation
- */
-protected void runOperation(JavaModelOperation operation, IProgressMonitor monitor) throws JavaModelException {
- JavaModelManager.getJavaModelManager().runOperation(operation, monitor);
-}
-/**
- * Sets the occurrence count of the handle.
- */
-protected void setOccurrenceCount(int count) {
- fOccurrenceCount = count;
-}
-protected String tabString(int tab) {
- StringBuffer buffer = new StringBuffer();
- for (int i = tab; i > 0; i--)
- buffer.append(" "); //$NON-NLS-1$
- return buffer.toString();
-}
-/**
- * Debugging purposes
- */
-public String toDebugString() {
- StringBuffer buffer = new StringBuffer();
- this.toStringInfo(0, buffer, NO_INFO);
- return buffer.toString();
-}
-/**
- * Debugging purposes
- */
-public String toString() {
- StringBuffer buffer = new StringBuffer();
- toString(0, buffer);
- return buffer.toString();
-}
-/**
- * Debugging purposes
- */
-protected void toString(int tab, StringBuffer buffer) {
- Object info = this.toStringInfo(tab, buffer);
- if (tab == 0) {
+ protected String tabString(int tab) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = tab; i > 0; i--)
+ buffer.append(" "); //$NON-NLS-1$
+ return buffer.toString();
+ }
+ /**
+ * Debugging purposes
+ */
+ public String toDebugString() {
+ StringBuffer buffer = new StringBuffer();
+ this.toStringInfo(0, buffer, NO_INFO);
+ return buffer.toString();
+ }
+ /**
+ * Debugging purposes
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ toString(0, buffer);
+ return buffer.toString();
+ }
+ /**
+ * Debugging purposes
+ */
+ protected void toString(int tab, StringBuffer buffer) {
+ Object info = this.toStringInfo(tab, buffer);
+ if (tab == 0) {
+ this.toStringAncestors(buffer);
+ }
+ this.toStringChildren(tab, buffer, info);
+ }
+ /**
+ * Debugging purposes
+ */
+ public String toStringWithAncestors() {
+ StringBuffer buffer = new StringBuffer();
+ this.toStringInfo(0, buffer, NO_INFO);
this.toStringAncestors(buffer);
+ return buffer.toString();
}
- this.toStringChildren(tab, buffer, info);
-}
-/**
- * Debugging purposes
- */
-public String toStringWithAncestors() {
- StringBuffer buffer = new StringBuffer();
- this.toStringInfo(0, buffer, NO_INFO);
- this.toStringAncestors(buffer);
- return buffer.toString();
-}
-/**
- * Debugging purposes
- */
-protected void toStringAncestors(StringBuffer buffer) {
- JavaElement parent = (JavaElement)this.getParent();
- if (parent != null && parent.getParent() != null) {
- buffer.append(" [in "); //$NON-NLS-1$
- parent.toStringInfo(0, buffer, NO_INFO);
- parent.toStringAncestors(buffer);
- buffer.append("]"); //$NON-NLS-1$
+ /**
+ * Debugging purposes
+ */
+ protected void toStringAncestors(StringBuffer buffer) {
+ JavaElement parent = (JavaElement)this.getParent();
+ if (parent != null && parent.getParent() != null) {
+ buffer.append(" [in "); //$NON-NLS-1$
+ parent.toStringInfo(0, buffer, NO_INFO);
+ parent.toStringAncestors(buffer);
+ buffer.append("]"); //$NON-NLS-1$
+ }
}
-}
-/**
- * Debugging purposes
- */
-protected void toStringChildren(int tab, StringBuffer buffer, Object info) {
- if (info == null || !(info instanceof JavaElementInfo)) return;
- IJavaElement[] children = ((JavaElementInfo)info).getChildren();
- for (int i = 0; i < children.length; i++) {
- buffer.append("\n"); //$NON-NLS-1$
- ((JavaElement)children[i]).toString(tab + 1, buffer);
+ /**
+ * Debugging purposes
+ */
+ protected void toStringChildren(int tab, StringBuffer buffer, Object info) {
+ if (info == null || !(info instanceof JavaElementInfo)) return;
+ IJavaElement[] children = ((JavaElementInfo)info).getChildren();
+ for (int i = 0; i < children.length; i++) {
+ buffer.append("\n"); //$NON-NLS-1$
+ ((JavaElement)children[i]).toString(tab + 1, buffer);
+ }
}
-}
-/**
- * Debugging purposes
- */
-public Object toStringInfo(int tab, StringBuffer buffer) {
- Object info = JavaModelManager.getJavaModelManager().peekAtInfo(this);
- this.toStringInfo(tab, buffer, info);
- return info;
-}
-/**
- * Debugging purposes
- */
-protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
- buffer.append(this.tabString(tab));
- buffer.append(getElementName());
- if (info == null) {
- buffer.append(" (not open)"); //$NON-NLS-1$
+ /**
+ * Debugging purposes
+ */
+ public Object toStringInfo(int tab, StringBuffer buffer) {
+ Object info = JavaModelManager.getJavaModelManager().peekAtInfo(this);
+ this.toStringInfo(tab, buffer, info);
+ return info;
}
-}
-/**
- * Updates the source end position for this element.
- * Default behaviour is to do nothing.
- */
-public void triggerSourceEndOffset(int amount, int nameStart, int nameEnd) {
-}
-/**
- * Updates the source positions for this element.
- * Default behaviour is to do nothing.
- */
-public void triggerSourceRangeOffset(int amount, int nameStart, int nameEnd) {
-
-}
+ /**
+ * Debugging purposes
+ */
+ protected void toStringInfo(int tab, StringBuffer buffer, Object info) {
+ buffer.append(this.tabString(tab));
+ buffer.append(getElementName());
+ if (info == null) {
+ buffer.append(" (not open)"); //$NON-NLS-1$
+ }
+ }
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java
index 7518754..c925147 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDelta.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
@@ -235,6 +235,12 @@
insertDeltaTree(element, changedDelta);
}
/**
+ * Mark this delta as a content changed delta.
+ */
+public void contentChanged() {
+ fChangeFlags |= F_CONTENT;
+}
+/**
* Clone this delta so that its elements are rooted at the given project.
*/
public IJavaElementDelta clone(IJavaProject project) {
@@ -324,6 +330,9 @@
* Mark this delta as a fine-grained delta.
*/
public void fineGrained() {
+ if (fKind == 0) { // if not set yet
+ fKind = CHANGED;
+ }
fChangeFlags |= F_FINE_GRAINED;
}
/**
@@ -646,10 +655,10 @@
buffer.append("REMOVED FROM CLASSPATH"); //$NON-NLS-1$
prev = true;
}
- if ((changeFlags & IJavaElementDelta.F_CLASSPATH_REORDER) != 0) {
+ if ((changeFlags & IJavaElementDelta.F_REORDER) != 0) {
if (prev)
buffer.append(" | "); //$NON-NLS-1$
- buffer.append("REORDERED IN CLASSPATH"); //$NON-NLS-1$
+ buffer.append("REORDERED"); //$NON-NLS-1$
prev = true;
}
if ((changeFlags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0) {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDeltaBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDeltaBuilder.java
index 458c434..04d6dd5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDeltaBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementDeltaBuilder.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
@@ -17,11 +17,9 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IParent;
-import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
/**
* A java element delta biulder creates a java element delta on
@@ -139,6 +137,10 @@
this.findDeletions();
this.findChangesInPositioning(this.javaElement, 0);
this.trimDelta(this.delta);
+ if (this.delta.getAffectedChildren().length == 0) {
+ // this is a fine grained but not children affected -> mark as content changed
+ this.delta.contentChanged();
+ }
}
/**
* Finds elements which have been added or changed.
@@ -160,7 +162,7 @@
JavaElementInfo newInfo = null;
try {
- newInfo = ((JavaElement)newElement).getElementInfo();
+ newInfo = (JavaElementInfo)((JavaElement)newElement).getElementInfo();
} catch (JavaModelException npe) {
return;
}
@@ -186,14 +188,13 @@
return;
if (!isPositionedCorrectly(element)) {
- this.delta.removed(element);
- this.delta.added(element);
+ this.delta.changed(element, IJavaElementDelta.F_REORDER);
}
if (element instanceof IParent) {
JavaElementInfo info = null;
try {
- info = ((JavaElement)element).getElementInfo();
+ info = (JavaElementInfo)((JavaElement)element).getElementInfo();
} catch (JavaModelException npe) {
return;
}
@@ -292,79 +293,22 @@
}
}
/**
- * Returns true if the given elements represent the an equivalent declaration.
- *
- * <p>NOTE: Since this comparison can be done with handle info only,
- * none of the internal calls need to use the locally cached contents
- * of the old compilation unit.
- */
-private boolean isIdentical(JavaElement e1, JavaElement e2) {
- if (e1 == null ^ e2 == null)
- return false;
- if (e1 == null)
- return true;
-
- if (e1.fLEType == e2.fLEType) {
- if (e1.getOccurrenceCount() != e2.getOccurrenceCount())
- return false;
- switch (e1.fLEType) {
- case IJavaElement.FIELD:
- case IJavaElement.IMPORT_DECLARATION:
- case IJavaElement.PACKAGE_DECLARATION:
- case IJavaElement.COMPILATION_UNIT:
- return e1.getElementName().equals(e2.getElementName());
- case IJavaElement.TYPE:
- IType t1= (IType)e1;
- IType t2= (IType)e2;
- try {
- return (!(t1.isClass() ^ t2.isClass()) && t1.getElementName().equals(t2.getElementName()));
- } catch (JavaModelException e) {
- return false;
- }
- case IJavaElement.METHOD:
- IMethod m1= (IMethod)e1;
- IMethod m2= (IMethod)e2;
- try {
- return m1.getElementName().equals(m2.getElementName()) && m1.getSignature().equals(m2.getSignature());
- } catch (JavaModelException e) {
- return false;
- }
- case IJavaElement.INITIALIZER:
- case IJavaElement.IMPORT_CONTAINER:
- return true;
- default:
- return false;
- }
- } else {
- return false;
- }
-}
-/**
- * Answers true if the elements position has not changed.
- * Takes into account additions so that elements following
- * new elements will not appear out of place.
+ * Returns whether the elements position has not changed.
*/
private boolean isPositionedCorrectly(IJavaElement element) {
ListItem oldListItem = this.getOldPosition(element);
- if (oldListItem == null)
- return false;
- IJavaElement oldPrevious = oldListItem.previous;
+ if (oldListItem == null) return false;
+
ListItem newListItem = this.getNewPosition(element);
- if (newListItem == null)
- return false;
- IJavaElement newPrevious = newListItem.previous;
- if (oldPrevious == newPrevious)
- return true;
- IJavaElement lastNewPrevious = null;
- while(lastNewPrevious != newPrevious) {
- if (isIdentical((JavaElement)oldPrevious, (JavaElement)newPrevious))
- return true;
- lastNewPrevious = newPrevious;
- // if newPrevious is null at this time we should exit the loop.
- if (newPrevious == null) break;
- newPrevious = (this.getNewPosition(newPrevious)).previous;
+ if (newListItem == null) return false;
+
+ IJavaElement oldPrevious = oldListItem.previous;
+ IJavaElement newPrevious = newListItem.previous;
+ if (oldPrevious == null) {
+ return newPrevious == null;
+ } else {
+ return oldPrevious.equals(newPrevious);
}
- return false;
}
private void putElementInfo(IJavaElement element, JavaElementInfo info) {
this.infos.put(element, info);
@@ -404,7 +348,7 @@
if (depth < this.maxDepth && newElement instanceof IParent) {
JavaElementInfo info = null;
try {
- info = ((JavaElement)newElement).getElementInfo();
+ info = (JavaElementInfo)((JavaElement)newElement).getElementInfo();
} catch (JavaModelException npe) {
return;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementInfo.java
index dde9b9c..fa1717f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IJavaElement;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementRequestor.java
index 4e2b983..f9941a1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElementRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java
index c76c8ca..2c9333f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModel.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.File;
@@ -23,7 +23,6 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
@@ -35,7 +34,6 @@
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
/**
@@ -66,14 +64,35 @@
protected JavaModel() throws Error {
super(JAVA_MODEL, null, "" /*workspace has empty name*/); //$NON-NLS-1$
}
-
-
-
+/*
+ * @see IJavaModel
+ */
+public boolean contains(IResource resource) {
+ switch (resource.getType()) {
+ case IResource.ROOT:
+ case IResource.PROJECT:
+ return true;
+ }
+ // file or folder
+ IJavaProject[] projects;
+ try {
+ projects = this.getJavaProjects();
+ } catch (JavaModelException e) {
+ return false;
+ }
+ for (int i = 0, length = projects.length; i < length; i++) {
+ JavaProject project = (JavaProject)projects[i];
+ if (!project.contains(resource)) {
+ return false;
+ }
+ }
+ return true;
+}
/**
* @see IJavaModel
*/
public void copy(IJavaElement[] elements, IJavaElement[] containers, IJavaElement[] siblings, String[] renamings, boolean force, IProgressMonitor monitor) throws JavaModelException {
- if (elements != null && elements[0] != null && elements[0].getElementType() < IJavaElement.TYPE) {
+ if (elements != null && elements.length > 0 && elements[0] != null && elements[0].getElementType() < IJavaElement.TYPE) {
runOperation(new CopyResourceElementsOperation(elements, containers, force), elements, siblings, renamings, monitor);
} else {
runOperation(new CopyElementsOperation(elements, containers, force), elements, siblings, renamings, monitor);
@@ -90,7 +109,7 @@
* @see IJavaModel
*/
public void delete(IJavaElement[] elements, boolean force, IProgressMonitor monitor) throws JavaModelException {
- if (elements != null && elements[0] != null && elements[0].getElementType() < IJavaElement.TYPE) {
+ if (elements != null && elements.length > 0 && elements[0] != null && elements[0].getElementType() < IJavaElement.TYPE) {
runOperation(new DeleteResourceElementsOperation(elements, force), monitor);
} else {
runOperation(new DeleteElementsOperation(elements, force), monitor);
@@ -131,16 +150,12 @@
JavaModelManager.getJavaModelManager().putInfo(this, info);
// determine my children
- try {
- IProject[] projects = this.getWorkspace().getRoot().getProjects();
- for (int i = 0, max = projects.length; i < max; i++) {
- IProject project = projects[i];
- if (project.isOpen() && project.hasNature(JavaCore.NATURE_ID)) {
- info.addChild(getJavaProject(project));
- }
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (int i = 0, max = projects.length; i < max; i++) {
+ IProject project = projects[i];
+ if (JavaProject.hasJavaNature(project)) {
+ info.addChild(getJavaProject(project));
}
- } catch (CoreException e) {
- throw new JavaModelException(e);
}
return true;
}
@@ -205,6 +220,21 @@
return cf.getType();
}
/**
+ * Returns the <code>IPackageFragmentRoot</code> represented by the <code>String</code>
+ * memento.
+ * @see getHandleMemento()
+ */
+protected IPackageFragmentRoot getHandleFromMementoForRoot(String memento, JavaProject project, int projectEnd, int rootEnd) {
+ String rootName = null;
+ if (rootEnd == projectEnd - 1) {
+ //default root
+ rootName = IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH;
+ } else {
+ rootName = memento.substring(projectEnd + 1, rootEnd);
+ }
+ return project.getPackageFragmentRoot(new Path(rootName));
+}
+/**
* Returns the <code>IJavaElement</code> represented by the <code>String</code>
* memento.
* @see getHandleMemento()
@@ -315,26 +345,14 @@
* contribution to a memento.
*/
protected char getHandleMementoDelimiter(){
- Assert.isTrue(false, Util.bind("assert.shouldNotImplement")); //$NON-NLS-1$
+ Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$
return 0;
}
/**
- * @see IJavaElement
- */
-public IJavaModel getJavaModel() {
- return this;
-}
-/**
- * @see IJavaElement
- */
-public IJavaProject getJavaProject() {
- return null;
-}
-/**
* @see IJavaModel
*/
public IJavaProject getJavaProject(String name) {
- return new JavaProject(this.getWorkspace().getRoot().getProject(name), this);
+ return new JavaProject(ResourcesPlugin.getWorkspace().getRoot().getProject(name), this);
}
/**
* Returns the active Java project associated with the specified
@@ -345,14 +363,15 @@
* is not one of an IProject, IFolder, or IFile.
*/
public IJavaProject getJavaProject(IResource resource) {
- if (resource.getType() == IResource.FOLDER) {
- return new JavaProject(((IFolder)resource).getProject(), this);
- } else if (resource.getType() == IResource.FILE) {
- return new JavaProject(((IFile)resource).getProject(), this);
- } else if (resource.getType() == IResource.PROJECT) {
- return new JavaProject((IProject)resource, this);
- } else {
- throw new IllegalArgumentException(Util.bind("element.invalidResourceForProject")); //$NON-NLS-1$
+ switch(resource.getType()){
+ case IResource.FOLDER:
+ return new JavaProject(((IFolder)resource).getProject(), this);
+ case IResource.FILE:
+ return new JavaProject(((IFile)resource).getProject(), this);
+ case IResource.PROJECT:
+ return new JavaProject((IProject)resource, this);
+ default:
+ throw new IllegalArgumentException(Util.bind("element.invalidResourceForProject")); //$NON-NLS-1$
}
}
/**
@@ -366,12 +385,19 @@
}
/**
+ * @see IJavaModel
+ */
+public Object[] getNonJavaResources() throws JavaModelException {
+ return ((JavaModelInfo) getElementInfo()).getNonJavaResources();
+}
+
+/**
* Workaround for bug 15168 circular errors not reported
* Returns the list of java projects before resource delta processing
* has started.
*/
public IJavaProject[] getOldJavaProjectsList() throws JavaModelException {
- JavaModelManager manager = this.getJavaModelManager();
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
return
manager.javaProjectsCache == null ?
this.getJavaProjects() :
@@ -406,7 +432,7 @@
* @see IJavaModel
*/
public void move(IJavaElement[] elements, IJavaElement[] containers, IJavaElement[] siblings, String[] renamings, boolean force, IProgressMonitor monitor) throws JavaModelException {
- if (elements != null && elements[0] != null && elements[0].getElementType() < IJavaElement.TYPE) {
+ if (elements != null && elements.length > 0 && elements[0] != null && elements[0].getElementType() < IJavaElement.TYPE) {
runOperation(new MoveResourceElementsOperation(elements, containers, force), elements, siblings, renamings, monitor);
} else {
runOperation(new MoveElementsOperation(elements, containers, force), elements, siblings, renamings, monitor);
@@ -420,7 +446,7 @@
if (elementsScope == null){
elementsScope = new IJavaElement[] { this };
}
- getJavaModelManager().deltaProcessor.checkExternalArchiveChanges(elementsScope, monitor);
+ JavaModelManager.getJavaModelManager().deltaProcessor.checkExternalArchiveChanges(elementsScope, monitor);
}
/**
@@ -428,7 +454,7 @@
*/
public void rename(IJavaElement[] elements, IJavaElement[] destinations, String[] renamings, boolean force, IProgressMonitor monitor) throws JavaModelException {
MultiOperation op;
- if (elements != null && elements[0] != null && elements[0].getElementType() < IJavaElement.TYPE) {
+ if (elements != null && elements.length > 0 && elements[0] != null && elements[0].getElementType() < IJavaElement.TYPE) {
op = new RenameResourceElementsOperation(elements, destinations, renamings, force);
} else {
op = new RenameElementsOperation(elements, destinations, renamings, force);
@@ -476,11 +502,19 @@
if (path == null) return null;
// lookup - inside the container
- IResource resource = container.findMember(path);
- if (resource != null){
- if (!checkResourceExistence ||resource.exists()) return resource;
- return null;
+ if (path.getDevice() == null) { // container relative paths should not contain a device
+ // (see http://dev.eclipse.org/bugs/show_bug.cgi?id=18684)
+ // (case of a workspace rooted at d:\ )
+ IResource resource = container.findMember(path);
+ if (resource != null){
+ if (!checkResourceExistence ||resource.exists()) return resource;
+ return null;
+ }
}
+
+ // if path is relative, it cannot be an external path
+ // (see http://dev.eclipse.org/bugs/show_bug.cgi?id=22517)
+ if (!path.isAbsolute()) return null;
// lookup - outside the container
File externalFile = new File(path.toOSString());
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java
index b26391c..9572170 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelCache.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.HashMap;
import java.util.Map;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelInfo.java
index 100cbb6..801fdee 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelInfo.java
@@ -1,15 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+
/**
* Implementation of IJavaModel. A Java Model is specific to a
* workspace.
@@ -18,12 +21,50 @@
*/
public class JavaModelInfo extends OpenableElementInfo {
-
+ /**
+ * A array with all the non-java projects contained by this model
+ */
+ Object[] nonJavaResources;
/**
* Constructs a new Java Model Info
*/
protected JavaModelInfo() {
}
+/**
+ * Compute the non-java resources contained in this java project.
+ */
+private Object[] computeNonJavaResources() {
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ int length = projects.length;
+ Object[] nonJavaResources = null;
+ int index = 0;
+ for (int i = 0; i < length; i++) {
+ IProject project = projects[i];
+ if (!JavaProject.hasJavaNature(project)) {
+ if (nonJavaResources == null) {
+ nonJavaResources = new Object[length];
+ }
+ nonJavaResources[index++] = project;
+ }
+ }
+ if (index == 0) return NO_NON_JAVA_RESOURCES;
+ if (index < length) {
+ System.arraycopy(nonJavaResources, 0, nonJavaResources = new Object[index], 0, index);
+ }
+ return nonJavaResources;
+}
+/**
+ * Returns an array of non-java resources contained in the receiver.
+ */
+Object[] getNonJavaResources() {
+
+ Object[] nonJavaResources = this.nonJavaResources;
+ if (nonJavaResources == null) {
+ nonJavaResources = computeNonJavaResources();
+ this.nonJavaResources = nonJavaResources;
+ }
+ return nonJavaResources;
+}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
index e3235c5..6f88a10 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelManager.java
Binary files differ
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java
index ceb5489..047bc10 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelOperation.java
@@ -1,44 +1,67 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.IJavaModel;
-import org.eclipse.jdt.core.IJavaModelStatus;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.internal.core.util.PerThreadObject;
/**
* Defines behavior common to all Java Model operations
*/
public abstract class JavaModelOperation implements IWorkspaceRunnable, IProgressMonitor {
+ protected interface IPostAction {
+ /*
+ * Returns the id of this action.
+ * @see JavaModelOperation#postAction
+ */
+ String getID();
+ /*
+ * Run this action.
+ */
+ void run() throws JavaModelException;
+ }
+ /*
+ * Constants controlling the insertion mode of an action.
+ * @see JavaModelOperation#postAction
+ */
+ protected static final int APPEND = 1; // insert at the end
+ protected static final int REMOVEALL_APPEND = 2; // remove all existing ones with same ID, and add new one at the end
+ protected static final int KEEP_EXISTING = 3; // do not insert if already existing with same ID
+
+ /*
+ * Whether tracing post actions is enabled.
+ */
+ protected static boolean POST_ACTION_VERBOSE;
+
+ /*
+ * A list of IPostActions.
+ */
+ protected IPostAction[] actions;
+ protected int actionsStart = 0;
+ protected int actionsEnd = -1;
+ /*
+ * A HashMap of attributes that can be used by operations
+ */
+ protected HashMap attributes;
+
+ public static final String HAS_MODIFIED_RESOURCE_ATTR = "hasModifiedResource"; //$NON-NLS-1$
+ public static final String TRUE = "true"; //$NON-NLS-1$
+ //public static final String FALSE = "false"; //$NON-NLS-1$
+
/**
* The elements this operation operates on,
* or <code>null</code> if this operation
@@ -58,14 +81,7 @@
*/
protected static IJavaElement[] fgEmptyResult= new IJavaElement[] {};
- /**
- * Collection of <code>IJavaElementDelta</code>s created by this operation.
- * This collection starts out <code>null</code> and becomes an
- * array of <code>IJavaElementDelta</code>s if the operation creates any
- * deltas. This collection is registered with the Java Model notification
- * manager if the operation completes successfully.
- */
- protected IJavaElementDelta[] fDeltas= null;
+
/**
* The elements created by this operation - empty
* until the operation actually creates elements.
@@ -84,507 +100,686 @@
* Conflict resolution policy - by default do not force (fail on a conflict).
*/
protected boolean fForce= false;
+
/*
- * Whether the operation has modified resources, and thus whether resource
- * delta notifcation will happen.
+ * A per thread stack of java model operations (PerThreadObject of ArrayList).
*/
- protected boolean hasModifiedResource = false;
-/**
- * A common constructor for all Java Model operations.
- */
-protected JavaModelOperation(IJavaElement[] elements) {
- fElementsToProcess = elements;
-}
-/**
- * Common constructor for all Java Model operations.
- */
-protected JavaModelOperation(IJavaElement[] elementsToProcess, IJavaElement[] parentElements) {
- fElementsToProcess = elementsToProcess;
- fParentElements= parentElements;
-}
-/**
- * A common constructor for all Java Model operations.
- */
-protected JavaModelOperation(IJavaElement[] elementsToProcess, IJavaElement[] parentElements, boolean force) {
- fElementsToProcess = elementsToProcess;
- fParentElements= parentElements;
- fForce= force;
-}
-/**
- * A common constructor for all Java Model operations.
- */
-protected JavaModelOperation(IJavaElement[] elements, boolean force) {
- fElementsToProcess = elements;
- fForce= force;
-}
-/**
- * Common constructor for all Java Model operations.
- */
-protected JavaModelOperation(IJavaElement element) {
- fElementsToProcess = new IJavaElement[]{element};
-}
-/**
- * A common constructor for all Java Model operations.
- */
-protected JavaModelOperation(IJavaElement element, boolean force) {
- fElementsToProcess = new IJavaElement[]{element};
- fForce= force;
-}
-/**
- * Adds the given delta to the collection of deltas
- * that this operation has created. These deltas are
- * automatically registered with the Java Model Manager
- * when the operation completes.
- */
-protected void addDelta(IJavaElementDelta delta) {
- if (fDeltas == null) {
- fDeltas= new IJavaElementDelta[] {delta};
- } else {
- IJavaElementDelta[] copy= new IJavaElementDelta[fDeltas.length + 1];
- System.arraycopy(fDeltas, 0, copy, 0, fDeltas.length);
- copy[fDeltas.length]= delta;
- fDeltas= copy;
+ protected static PerThreadObject operationStacks = new PerThreadObject();
+ protected JavaModelOperation() {
}
-}
-/**
- * @see IProgressMonitor
- */
-public void beginTask(String name, int totalWork) {
- if (fMonitor != null) {
- fMonitor.beginTask(name, totalWork);
+ /**
+ * A common constructor for all Java Model operations.
+ */
+ protected JavaModelOperation(IJavaElement[] elements) {
+ fElementsToProcess = elements;
}
-}
-/**
- * Checks with the progress monitor to see whether this operation
- * should be canceled. An operation should regularly call this method
- * during its operation so that the user can cancel it.
- *
- * @exception OperationCanceledException if cancelling the operation has been requested
- * @see IProgressMonitor#isCanceled
- */
-protected void checkCanceled() {
- if (isCanceled()) {
- throw new OperationCanceledException(Util.bind("operation.cancelled")); //$NON-NLS-1$
+ /**
+ * Common constructor for all Java Model operations.
+ */
+ protected JavaModelOperation(IJavaElement[] elementsToProcess, IJavaElement[] parentElements) {
+ fElementsToProcess = elementsToProcess;
+ fParentElements= parentElements;
}
-}
-/**
- * Common code used to verify the elements this operation is processing.
- * @see JavaModelOperation#verify()
- */
-protected IJavaModelStatus commonVerify() {
- if (fElementsToProcess == null || fElementsToProcess.length == 0) {
- return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
+ /**
+ * A common constructor for all Java Model operations.
+ */
+ protected JavaModelOperation(IJavaElement[] elementsToProcess, IJavaElement[] parentElements, boolean force) {
+ fElementsToProcess = elementsToProcess;
+ fParentElements= parentElements;
+ fForce= force;
}
- for (int i = 0; i < fElementsToProcess.length; i++) {
- if (fElementsToProcess[i] == null) {
+ /**
+ * A common constructor for all Java Model operations.
+ */
+ protected JavaModelOperation(IJavaElement[] elements, boolean force) {
+ fElementsToProcess = elements;
+ fForce= force;
+ }
+
+ /**
+ * Common constructor for all Java Model operations.
+ */
+ protected JavaModelOperation(IJavaElement element) {
+ fElementsToProcess = new IJavaElement[]{element};
+ }
+ /**
+ * A common constructor for all Java Model operations.
+ */
+ protected JavaModelOperation(IJavaElement element, boolean force) {
+ fElementsToProcess = new IJavaElement[]{element};
+ fForce= force;
+ }
+
+ /*
+ * Registers the given action at the end of the list of actions to run.
+ */
+ protected void addAction(IPostAction action) {
+ int length = this.actions.length;
+ if (length == ++this.actionsEnd) {
+ System.arraycopy(this.actions, 0, this.actions = new IPostAction[length*2], 0, length);
+ }
+ this.actions[this.actionsEnd] = action;
+ }
+ /*
+ * Registers the given delta with the Java Model Manager.
+ */
+ protected void addDelta(IJavaElementDelta delta) {
+ JavaModelManager.getJavaModelManager().registerJavaModelDelta(delta);
+ }
+ /*
+ * Registers the given reconcile delta with the Java Model Manager.
+ */
+ protected void addReconcileDelta(IWorkingCopy workingCopy, IJavaElementDelta delta) {
+ HashMap reconcileDeltas = JavaModelManager.getJavaModelManager().reconcileDeltas;
+ JavaElementDelta previousDelta = (JavaElementDelta)reconcileDeltas.get(workingCopy);
+ if (previousDelta != null) {
+ IJavaElementDelta[] children = delta.getAffectedChildren();
+ for (int i = 0, length = children.length; i < length; i++) {
+ JavaElementDelta child = (JavaElementDelta)children[i];
+ previousDelta.insertDeltaTree(child.getElement(), child);
+ }
+ } else {
+ reconcileDeltas.put(workingCopy, delta);
+ }
+ }
+ /*
+ * Deregister the reconcile delta for the given working copy
+ */
+ protected void removeReconcileDelta(IWorkingCopy workingCopy) {
+ JavaModelManager.getJavaModelManager().reconcileDeltas.remove(workingCopy);
+ }
+ /**
+ * @see IProgressMonitor
+ */
+ public void beginTask(String name, int totalWork) {
+ if (fMonitor != null) {
+ fMonitor.beginTask(name, totalWork);
+ }
+ }
+ /**
+ * Checks with the progress monitor to see whether this operation
+ * should be canceled. An operation should regularly call this method
+ * during its operation so that the user can cancel it.
+ *
+ * @exception OperationCanceledException if cancelling the operation has been requested
+ * @see IProgressMonitor#isCanceled
+ */
+ protected void checkCanceled() {
+ if (isCanceled()) {
+ throw new OperationCanceledException(Util.bind("operation.cancelled")); //$NON-NLS-1$
+ }
+ }
+ /**
+ * Common code used to verify the elements this operation is processing.
+ * @see JavaModelOperation#verify()
+ */
+ protected IJavaModelStatus commonVerify() {
+ if (fElementsToProcess == null || fElementsToProcess.length == 0) {
return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
}
- }
- return JavaModelStatus.VERIFIED_OK;
-}
-/**
- * Convenience method to copy resources
- */
-protected void copyResources(IResource[] resources, IPath destinationPath) throws JavaModelException {
- IProgressMonitor subProgressMonitor = getSubProgressMonitor(resources.length);
- IWorkspace workspace = resources[0].getWorkspace();
- try {
- workspace.copy(resources, destinationPath, false, subProgressMonitor);
- this.hasModifiedResource = true;
- } catch (CoreException e) {
- throw new JavaModelException(e);
- }
-}
-/**
- * Convenience method to create a file
- */
-protected void createFile(IContainer folder, String name, InputStream contents, boolean force) throws JavaModelException {
- IFile file= folder.getFile(new Path(name));
- try {
- file.create(
- contents,
- force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
- getSubProgressMonitor(1));
- this.hasModifiedResource = true;
- } catch (CoreException e) {
- throw new JavaModelException(e);
- }
-}
-/**
- * Convenience method to create a folder
- */
-protected void createFolder(IContainer parentFolder, String name, boolean force) throws JavaModelException {
- IFolder folder= parentFolder.getFolder(new Path(name));
- try {
- // we should use true to create the file locally. Only VCM should use tru/false
- folder.create(
- force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
- true, // local
- getSubProgressMonitor(1));
- this.hasModifiedResource = true;
- } catch (CoreException e) {
- throw new JavaModelException(e);
- }
-}
-/**
- * Convenience method to delete an empty package fragment
- */
-protected void deleteEmptyPackageFragment(
- IPackageFragment fragment,
- boolean force)
- throws JavaModelException {
-
- IContainer resource = (IContainer) fragment.getCorrespondingResource();
- IResource rootResource = fragment.getParent().getUnderlyingResource();
-
- try {
- resource.delete(
- force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
- getSubProgressMonitor(1));
- while (resource instanceof IFolder) {
- // deleting a package: delete the parent if it is empty (eg. deleting x.y where folder x doesn't have resources but y)
- // without deleting the package fragment root
- resource = resource.getParent();
- if (!resource.equals(rootResource) && resource.members().length == 0) {
- resource.delete(
- force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
- getSubProgressMonitor(1));
- this.hasModifiedResource = true;
+ for (int i = 0; i < fElementsToProcess.length; i++) {
+ if (fElementsToProcess[i] == null) {
+ return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
}
}
- } catch (CoreException e) {
- throw new JavaModelException(e);
+ return JavaModelStatus.VERIFIED_OK;
}
-}
-/**
- * Convenience method to delete a resource
- */
-protected void deleteResource(IResource resource,int flags) throws JavaModelException {
- try {
- resource.delete(flags, getSubProgressMonitor(1));
- this.hasModifiedResource = true;
- } catch (CoreException e) {
- throw new JavaModelException(e);
- }
-}
-/**
- * Convenience method to delete resources
- */
-protected void deleteResources(IResource[] resources, boolean force) throws JavaModelException {
- if (resources == null || resources.length == 0) return;
- IProgressMonitor subProgressMonitor = getSubProgressMonitor(resources.length);
- IWorkspace workspace = resources[0].getWorkspace();
- try {
- workspace.delete(
- resources,
- force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
- subProgressMonitor);
- this.hasModifiedResource = true;
- } catch (CoreException e) {
- throw new JavaModelException(e);
- }
-}
-/**
- * @see IProgressMonitor
- */
-public void done() {
- if (fMonitor != null) {
- fMonitor.done();
- }
-}
-/**
- * Verifies the operation can proceed and executes the operation.
- * Subclasses should override <code>#verify</code> and
- * <code>executeOperation</code> to implement the specific operation behavior.
- *
- * @exception JavaModelException The operation has failed.
- */
-protected void execute() throws JavaModelException {
- IJavaModelStatus status= verify();
- if (status.isOK()) {
- executeOperation();
- } else {
- throw new JavaModelException(status);
- }
-}
-/**
- * Convenience method to run an operation within this operation
- */
-public void executeNestedOperation(JavaModelOperation operation, int subWorkAmount) throws JavaModelException {
- IProgressMonitor subProgressMonitor = getSubProgressMonitor(subWorkAmount);
- // fix for 1FW7IKC, part (1)
- try {
- operation.setNested(true);
- operation.run(subProgressMonitor);
- if (operation.hasModifiedResource()) {
- this.hasModifiedResource = true;
+ /**
+ * Convenience method to copy resources
+ */
+ protected void copyResources(IResource[] resources, IPath destinationPath) throws JavaModelException {
+ IProgressMonitor subProgressMonitor = getSubProgressMonitor(resources.length);
+ IWorkspace workspace = resources[0].getWorkspace();
+ try {
+ workspace.copy(resources, destinationPath, false, subProgressMonitor);
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
}
- //accumulate the nested operation deltas
- if (operation.fDeltas != null) {
- for (int i = 0; i < operation.fDeltas.length; i++) {
- addDelta(operation.fDeltas[i]);
- }
+ }
+ /**
+ * Convenience method to create a file
+ */
+ protected void createFile(IContainer folder, String name, InputStream contents, boolean force) throws JavaModelException {
+ IFile file= folder.getFile(new Path(name));
+ try {
+ file.create(
+ contents,
+ force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
+ getSubProgressMonitor(1));
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
}
- } catch (CoreException ce) {
- if (ce instanceof JavaModelException) {
- throw (JavaModelException)ce;
- } else {
- // translate the core exception to a java model exception
- if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
- Throwable e = ce.getStatus().getException();
- if (e instanceof JavaModelException) {
- throw (JavaModelException) e;
+ }
+ /**
+ * Convenience method to create a folder
+ */
+ protected void createFolder(IContainer parentFolder, String name, boolean force) throws JavaModelException {
+ IFolder folder= parentFolder.getFolder(new Path(name));
+ try {
+ // we should use true to create the file locally. Only VCM should use tru/false
+ folder.create(
+ force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
+ true, // local
+ getSubProgressMonitor(1));
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+ }
+ /**
+ * Convenience method to delete an empty package fragment
+ */
+ protected void deleteEmptyPackageFragment(
+ IPackageFragment fragment,
+ boolean force,
+ IResource rootResource)
+ throws JavaModelException {
+
+ IContainer resource = (IContainer) fragment.getResource();
+
+ try {
+ resource.delete(
+ force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
+ getSubProgressMonitor(1));
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ while (resource instanceof IFolder) {
+ // deleting a package: delete the parent if it is empty (eg. deleting x.y where folder x doesn't have resources but y)
+ // without deleting the package fragment root
+ resource = resource.getParent();
+ if (!resource.equals(rootResource) && resource.members().length == 0) {
+ resource.delete(
+ force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
+ getSubProgressMonitor(1));
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
}
}
- throw new JavaModelException(ce);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
}
}
-}
-/**
- * Performs the operation specific behavior. Subclasses must override.
- */
-protected abstract void executeOperation() throws JavaModelException;
-/**
- * Returns the compilation unit the given element is contained in,
- * or the element itself (if it is a compilation unit),
- * otherwise <code>null</code>.
- */
-protected ICompilationUnit getCompilationUnitFor(IJavaElement element) {
-
- return ((JavaElement)element).getCompilationUnit();
-}
-/**
- * Returns the elements to which this operation applies,
- * or <code>null</code> if not applicable.
- */
-protected IJavaElement[] getElementsToProcess() {
- return fElementsToProcess;
-}
-/**
- * Returns the element to which this operation applies,
- * or <code>null</code> if not applicable.
- */
-protected IJavaElement getElementToProcess() {
- if (fElementsToProcess == null || fElementsToProcess.length == 0) {
- return null;
- }
- return fElementsToProcess[0];
-}
-/**
- * Returns the Java Model this operation is operating in.
- */
-public IJavaModel getJavaModel() {
- if (fElementsToProcess == null || fElementsToProcess.length == 0) {
- return getParentElement().getJavaModel();
- } else {
- return fElementsToProcess[0].getJavaModel();
- }
-}
-/**
- * Returns the parent element to which this operation applies,
- * or <code>null</code> if not applicable.
- */
-protected IJavaElement getParentElement() {
- if (fParentElements == null || fParentElements.length == 0) {
- return null;
- }
- return fParentElements[0];
-}
-/**
- * Returns the parent elements to which this operation applies,
- * or <code>null</code> if not applicable.
- */
-protected IJavaElement[] getParentElements() {
- return fParentElements;
-}
-/**
- * Returns the elements created by this operation.
- */
-public IJavaElement[] getResultElements() {
- return fResultElements;
-}
-/**
- * Creates and returns a subprogress monitor if appropriate.
- */
-protected IProgressMonitor getSubProgressMonitor(int workAmount) {
- IProgressMonitor sub = null;
- if (fMonitor != null) {
- sub = new SubProgressMonitor(fMonitor, workAmount, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
- }
- return sub;
-}
-/**
- * Returns the <code>IWorkspace</code> this operation is working in, or
- * <code>null</code> if this operation has no elements to process.
- */
-protected IWorkspace getWorkspace() {
- if (fElementsToProcess != null && fElementsToProcess.length > 0) {
- IJavaProject project = fElementsToProcess[0].getJavaProject();
- if (project != null) {
- return project.getJavaModel().getWorkspace();
+ /**
+ * Convenience method to delete a resource
+ */
+ protected void deleteResource(IResource resource,int flags) throws JavaModelException {
+ try {
+ resource.delete(flags, getSubProgressMonitor(1));
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
}
}
- return null;
-}
-/**
- * Returns whether this operation has performed any resource modifications.
- * Returns false if this operation has not been executed yet.
- */
-public boolean hasModifiedResource() {
- return !this.isReadOnly() && this.hasModifiedResource;
-}
-public void internalWorked(double work) {
- if (fMonitor != null) {
- fMonitor.internalWorked(work);
- }
-}
-/**
- * @see IProgressMonitor
- */
-public boolean isCanceled() {
- if (fMonitor != null) {
- return fMonitor.isCanceled();
- }
- return false;
-}
-/**
- * Returns <code>true</code> if this operation performs no resource modifications,
- * otherwise <code>false</code>. Subclasses must override.
- */
-public boolean isReadOnly() {
- return false;
-}
-/**
- * Traverses the deltas for an working copies and makes them
- * consistent.
- */
-protected void makeWorkingCopiesConsistent(IJavaElementDelta[] deltas) {
- for (int i= 0; i < deltas.length; i++) {
- walkDeltaMakingWorkingCopiesConsistent(deltas[i]);
- }
-}
-/**
- * Convenience method to move resources
- */
-protected void moveResources(IResource[] resources, IPath destinationPath) throws JavaModelException {
- IProgressMonitor subProgressMonitor = null;
- if (fMonitor != null) {
- subProgressMonitor = new SubProgressMonitor(fMonitor, resources.length, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
- }
- IWorkspace workspace = resources[0].getWorkspace();
- try {
- workspace.move(resources, destinationPath, false, subProgressMonitor);
- this.hasModifiedResource = true;
- } catch (CoreException e) {
- throw new JavaModelException(e);
- }
-}
-/**
- * Creates and returns a new <code>IJavaElementDelta</code>
- * on the Java Model.
- */
-public JavaElementDelta newJavaElementDelta() {
- return new JavaElementDelta(getJavaModel());
-}
-/**
- * Registers any deltas this operation created, with the
- * Java Model manager.
- */
-protected void registerDeltas() {
- if (fDeltas != null && !fNested) {
- // hook to ensure working copies remain consistent
- makeWorkingCopiesConsistent(fDeltas);
- JavaModelManager manager= (JavaModelManager)JavaModelManager.getJavaModelManager();
- for (int i= 0; i < fDeltas.length; i++) {
- manager.registerJavaModelDelta(fDeltas[i]);
+ /**
+ * Convenience method to delete resources
+ */
+ protected void deleteResources(IResource[] resources, boolean force) throws JavaModelException {
+ if (resources == null || resources.length == 0) return;
+ IProgressMonitor subProgressMonitor = getSubProgressMonitor(resources.length);
+ IWorkspace workspace = resources[0].getWorkspace();
+ try {
+ workspace.delete(
+ resources,
+ force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
+ subProgressMonitor);
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
}
}
-}
-/**
- * Main entry point for Java Model operations. Executes this operation
- * and registers any deltas created.
- *
- * @see IWorkspaceRunnable
- * @exception CoreException if the operation fails
- */
-public void run(IProgressMonitor monitor) throws CoreException {
- try {
- fMonitor = monitor;
- execute();
- } finally {
- registerDeltas();
+ /**
+ * @see IProgressMonitor
+ */
+ public void done() {
+ if (fMonitor != null) {
+ fMonitor.done();
+ }
}
-}
-/**
- * @see IProgressMonitor
- */
-public void setCanceled(boolean b) {
- if (fMonitor != null) {
- fMonitor.setCanceled(b);
- }
-}
-/**
- * Sets whether this operation is nested or not.
- * @see CreateElementInCUOperation#checkCanceled
- */
-protected void setNested(boolean nested) {
- fNested = nested;
-}
-/**
- * @see IProgressMonitor
- */
-public void setTaskName(String name) {
- if (fMonitor != null) {
- fMonitor.setTaskName(name);
- }
-}
-/**
- * @see IProgressMonitor
- */
-public void subTask(String name) {
- if (fMonitor != null) {
- fMonitor.subTask(name);
- }
-}
-/**
- * Returns a status indicating if there is any known reason
- * this operation will fail. Operations are verified before they
- * are run.
- *
- * Subclasses must override if they have any conditions to verify
- * before this operation executes.
- *
- * @see IJavaModelStatus
- */
-protected IJavaModelStatus verify() {
- return commonVerify();
-}
-/**
- * Traverses the delta making any working copies consistent
- */
-protected void walkDeltaMakingWorkingCopiesConsistent(IJavaElementDelta delta) {
- if (delta.getElement().getElementType() == IJavaElement.COMPILATION_UNIT) {
- ICompilationUnit unit = (ICompilationUnit) delta.getElement();
- if (unit.isWorkingCopy()) {
- try {
- unit.makeConsistent(null);
- } catch (JavaModelException e) {
+ /*
+ * Returns whether the given path is equals to one of the given other paths.
+ */
+ protected boolean equalsOneOf(IPath path, IPath[] otherPaths) {
+ for (int i = 0, length = otherPaths.length; i < length; i++) {
+ if (path.equals(otherPaths[i])) {
+ return true;
}
}
- } else {
- IJavaElementDelta[] deltas = delta.getAffectedChildren();
- for (int i = 0; i < deltas.length; i++) {
- walkDeltaMakingWorkingCopiesConsistent(deltas[i]);
+ return false;
+ }
+ /**
+ * Verifies the operation can proceed and executes the operation.
+ * Subclasses should override <code>#verify</code> and
+ * <code>executeOperation</code> to implement the specific operation behavior.
+ *
+ * @exception JavaModelException The operation has failed.
+ */
+ protected void execute() throws JavaModelException {
+ IJavaModelStatus status= verify();
+ if (status.isOK()) {
+ // if first time here, computes the root infos before executing the operation
+ DeltaProcessor deltaProcessor = JavaModelManager.getJavaModelManager().deltaProcessor;
+ if (deltaProcessor.roots == null) {
+ deltaProcessor.initializeRoots();
+ }
+
+ executeOperation();
+ } else {
+ throw new JavaModelException(status);
}
}
-}
-/**
- * @see IProgressMonitor
- */
-public void worked(int work) {
- if (fMonitor != null) {
- fMonitor.worked(work);
- checkCanceled();
+ /**
+ * Convenience method to run an operation within this operation
+ */
+ public void executeNestedOperation(JavaModelOperation operation, int subWorkAmount) throws JavaModelException {
+ IProgressMonitor subProgressMonitor = getSubProgressMonitor(subWorkAmount);
+ // fix for 1FW7IKC, part (1)
+ try {
+ operation.setNested(true);
+ operation.run(subProgressMonitor);
+ } catch (CoreException ce) {
+ if (ce instanceof JavaModelException) {
+ throw (JavaModelException)ce;
+ } else {
+ // translate the core exception to a java model exception
+ if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
+ Throwable e = ce.getStatus().getException();
+ if (e instanceof JavaModelException) {
+ throw (JavaModelException) e;
+ }
+ }
+ throw new JavaModelException(ce);
+ }
+ }
}
-}
+ /**
+ * Performs the operation specific behavior. Subclasses must override.
+ */
+ protected abstract void executeOperation() throws JavaModelException;
+ /*
+ * Returns the attribute registered at the given key with the top level operation.
+ * Returns null if no such attribute is found.
+ */
+ protected Object getAttribute(Object key) {
+ ArrayList stack = this.getCurrentOperationStack();
+ if (stack.size() == 0) return null;
+ JavaModelOperation topLevelOp = (JavaModelOperation)stack.get(0);
+ if (topLevelOp.attributes == null) {
+ return null;
+ } else {
+ return topLevelOp.attributes.get(key);
+ }
+ }
+ /**
+ * Returns the compilation unit the given element is contained in,
+ * or the element itself (if it is a compilation unit),
+ * otherwise <code>null</code>.
+ */
+ protected ICompilationUnit getCompilationUnitFor(IJavaElement element) {
+
+ return ((JavaElement)element).getCompilationUnit();
+ }
+ /*
+ * Returns the stack of operations running in the current thread.
+ * Returns an empty stack if no operations are currently running in this thread.
+ */
+ protected ArrayList getCurrentOperationStack() {
+ ArrayList stack = (ArrayList)operationStacks.getCurrent();
+ if (stack == null) {
+ stack = new ArrayList();
+ operationStacks.setCurrent(stack);
+ }
+ return stack;
+ }
+ /**
+ * Returns the elements to which this operation applies,
+ * or <code>null</code> if not applicable.
+ */
+ protected IJavaElement[] getElementsToProcess() {
+ return fElementsToProcess;
+ }
+ /**
+ * Returns the element to which this operation applies,
+ * or <code>null</code> if not applicable.
+ */
+ protected IJavaElement getElementToProcess() {
+ if (fElementsToProcess == null || fElementsToProcess.length == 0) {
+ return null;
+ }
+ return fElementsToProcess[0];
+ }
+ /**
+ * Returns the Java Model this operation is operating in.
+ */
+ public IJavaModel getJavaModel() {
+ if (fElementsToProcess == null || fElementsToProcess.length == 0) {
+ return getParentElement().getJavaModel();
+ } else {
+ return fElementsToProcess[0].getJavaModel();
+ }
+ }
+ protected IPath[] getNestedFolders(IPackageFragmentRoot root) throws JavaModelException {
+ IPath rootPath = root.getPath();
+ IClasspathEntry[] classpath = root.getJavaProject().getRawClasspath();
+ int length = classpath.length;
+ IPath[] result = new IPath[length];
+ int index = 0;
+ for (int i = 0; i < length; i++) {
+ IPath path = classpath[i].getPath();
+ if (rootPath.isPrefixOf(path) && !rootPath.equals(path)) {
+ result[index++] = path;
+ }
+ }
+ if (index < length) {
+ System.arraycopy(result, 0, result = new IPath[index], 0, index);
+ }
+ return result;
+ }
+ /**
+ * Returns the parent element to which this operation applies,
+ * or <code>null</code> if not applicable.
+ */
+ protected IJavaElement getParentElement() {
+ if (fParentElements == null || fParentElements.length == 0) {
+ return null;
+ }
+ return fParentElements[0];
+ }
+ /**
+ * Returns the parent elements to which this operation applies,
+ * or <code>null</code> if not applicable.
+ */
+ protected IJavaElement[] getParentElements() {
+ return fParentElements;
+ }
+ /**
+ * Returns the elements created by this operation.
+ */
+ public IJavaElement[] getResultElements() {
+ return fResultElements;
+ }
+ /**
+ * Creates and returns a subprogress monitor if appropriate.
+ */
+ protected IProgressMonitor getSubProgressMonitor(int workAmount) {
+ IProgressMonitor sub = null;
+ if (fMonitor != null) {
+ sub = new SubProgressMonitor(fMonitor, workAmount, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
+ }
+ return sub;
+ }
+
+ /**
+ * Returns whether this operation has performed any resource modifications.
+ * Returns false if this operation has not been executed yet.
+ */
+ public boolean hasModifiedResource() {
+ return !this.isReadOnly() && this.getAttribute(HAS_MODIFIED_RESOURCE_ATTR) == TRUE;
+ }
+ public void internalWorked(double work) {
+ if (fMonitor != null) {
+ fMonitor.internalWorked(work);
+ }
+ }
+ /**
+ * @see IProgressMonitor
+ */
+ public boolean isCanceled() {
+ if (fMonitor != null) {
+ return fMonitor.isCanceled();
+ }
+ return false;
+ }
+ /**
+ * Returns <code>true</code> if this operation performs no resource modifications,
+ * otherwise <code>false</code>. Subclasses must override.
+ */
+ public boolean isReadOnly() {
+ return false;
+ }
+ /*
+ * Returns whether this operation is the first operation to run in the current thread.
+ */
+ protected boolean isTopLevelOperation() {
+ ArrayList stack;
+ return
+ (stack = this.getCurrentOperationStack()).size() > 0
+ && stack.get(0) == this;
+ }
+ /*
+ * Returns the index of the first registered action with the given id, starting from a given position.
+ * Returns -1 if not found.
+ */
+ protected int firstActionWithID(String id, int start) {
+ for (int i = start; i <= this.actionsEnd; i++) {
+ if (this.actions[i].getID().equals(id)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Convenience method to move resources
+ */
+ protected void moveResources(IResource[] resources, IPath destinationPath) throws JavaModelException {
+ IProgressMonitor subProgressMonitor = null;
+ if (fMonitor != null) {
+ subProgressMonitor = new SubProgressMonitor(fMonitor, resources.length, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
+ }
+ IWorkspace workspace = resources[0].getWorkspace();
+ try {
+ workspace.move(resources, destinationPath, false, subProgressMonitor);
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+ }
+ /**
+ * Creates and returns a new <code>IJavaElementDelta</code>
+ * on the Java Model.
+ */
+ public JavaElementDelta newJavaElementDelta() {
+ return new JavaElementDelta(getJavaModel());
+ }
+ /*
+ * Removes the last pushed operation from the stack of running operations.
+ * Returns the poped operation or null if the stack was empty.
+ */
+ protected JavaModelOperation popOperation() {
+ ArrayList stack = getCurrentOperationStack();
+ int size = stack.size();
+ if (size > 0) {
+ if (size == 1) { // top level operation
+ operationStacks.setCurrent(null); // release reference (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=33927)
+ }
+ return (JavaModelOperation)stack.remove(size-1);
+ } else {
+ return null;
+ }
+ }
+ /*
+ * Registers the given action to be run when the outer most java model operation has finished.
+ * The insertion mode controls whether:
+ * - the action should discard all existing actions with the same id, and be queued at the end (REMOVEALL_APPEND),
+ * - the action should be ignored if there is already an action with the same id (KEEP_EXISTING),
+ * - the action should be queued at the end without looking at existing actions (APPEND)
+ */
+ protected void postAction(IPostAction action, int insertionMode) {
+ if (POST_ACTION_VERBOSE) {
+ System.out.print("(" + Thread.currentThread() + ") [JavaModelOperation.postAction(IPostAction, int)] Posting action " + action.getID()); //$NON-NLS-1$ //$NON-NLS-2$
+ switch(insertionMode) {
+ case REMOVEALL_APPEND:
+ System.out.println(" (REMOVEALL_APPEND)"); //$NON-NLS-1$
+ break;
+ case KEEP_EXISTING:
+ System.out.println(" (KEEP_EXISTING)"); //$NON-NLS-1$
+ break;
+ case APPEND:
+ System.out.println(" (APPEND)"); //$NON-NLS-1$
+ break;
+ }
+ }
+
+ JavaModelOperation topLevelOp = (JavaModelOperation)getCurrentOperationStack().get(0);
+ IPostAction[] postActions = topLevelOp.actions;
+ if (postActions == null) {
+ topLevelOp.actions = postActions = new IPostAction[1];
+ postActions[0] = action;
+ topLevelOp.actionsEnd = 0;
+ } else {
+ String id = action.getID();
+ switch (insertionMode) {
+ case REMOVEALL_APPEND :
+ int index = this.actionsStart-1;
+ while ((index = topLevelOp.firstActionWithID(id, index+1)) >= 0) {
+ // remove action[index]
+ System.arraycopy(postActions, index+1, postActions, index, topLevelOp.actionsEnd - index);
+ postActions[topLevelOp.actionsEnd--] = null;
+ }
+ topLevelOp.addAction(action);
+ break;
+ case KEEP_EXISTING:
+ if (topLevelOp.firstActionWithID(id, 0) < 0) {
+ topLevelOp.addAction(action);
+ }
+ break;
+ case APPEND:
+ topLevelOp.addAction(action);
+ break;
+ }
+ }
+ }
+ /*
+ * Returns whether the given path is the prefix of one of the given other paths.
+ */
+ protected boolean prefixesOneOf(IPath path, IPath[] otherPaths) {
+ for (int i = 0, length = otherPaths.length; i < length; i++) {
+ if (path.isPrefixOf(otherPaths[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+ /*
+ * Pushes the given operation on the stack of operations currently running in this thread.
+ */
+ protected void pushOperation(JavaModelOperation operation) {
+ getCurrentOperationStack().add(operation);
+ }
+
+ /**
+ * Main entry point for Java Model operations. Executes this operation
+ * and registers any deltas created.
+ *
+ * @see IWorkspaceRunnable
+ * @exception CoreException if the operation fails
+ */
+ public void run(IProgressMonitor monitor) throws CoreException {
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ int previousDeltaCount = manager.javaModelDeltas.size();
+ try {
+ fMonitor = monitor;
+ pushOperation(this);
+ try {
+ this.execute();
+ } finally {
+ if (this.isTopLevelOperation()) {
+ this.runPostActions();
+ }
+ }
+ } finally {
+ try {
+ // update JavaModel using deltas that were recorded during this operation
+ for (int i = previousDeltaCount, size = manager.javaModelDeltas.size(); i < size; i++) {
+ manager.updateJavaModel((IJavaElementDelta)manager.javaModelDeltas.get(i));
+ }
+
+ // fire only iff:
+ // - the operation is a top level operation
+ // - the operation did produce some delta(s)
+ // - but the operation has not modified any resource
+ if (this.isTopLevelOperation()) {
+ if ((manager.javaModelDeltas.size() > previousDeltaCount || !manager.reconcileDeltas.isEmpty())
+ && !this.hasModifiedResource()) {
+ manager.fire(null, JavaModelManager.DEFAULT_CHANGE_EVENT);
+ } // else deltas are fired while processing the resource delta
+ }
+ } finally {
+ popOperation();
+ }
+ }
+ }
+ protected void runPostActions() throws JavaModelException {
+ while (this.actionsStart <= this.actionsEnd) {
+ IPostAction postAction = this.actions[this.actionsStart++];
+ if (POST_ACTION_VERBOSE) {
+ System.out.println("(" + Thread.currentThread() + ") [JavaModelOperation.runPostActions()] Running action " + postAction.getID()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ postAction.run();
+ }
+ }
+ /*
+ * Registers the given attribute at the given key with the top level operation.
+ */
+ protected void setAttribute(Object key, Object attribute) {
+ JavaModelOperation topLevelOp = (JavaModelOperation)this.getCurrentOperationStack().get(0);
+ if (topLevelOp.attributes == null) {
+ topLevelOp.attributes = new HashMap();
+ }
+ topLevelOp.attributes.put(key, attribute);
+ }
+ /**
+ * @see IProgressMonitor
+ */
+ public void setCanceled(boolean b) {
+ if (fMonitor != null) {
+ fMonitor.setCanceled(b);
+ }
+ }
+ /**
+ * Sets whether this operation is nested or not.
+ * @see CreateElementInCUOperation#checkCanceled
+ */
+ protected void setNested(boolean nested) {
+ fNested = nested;
+ }
+ /**
+ * @see IProgressMonitor
+ */
+ public void setTaskName(String name) {
+ if (fMonitor != null) {
+ fMonitor.setTaskName(name);
+ }
+ }
+ /**
+ * @see IProgressMonitor
+ */
+ public void subTask(String name) {
+ if (fMonitor != null) {
+ fMonitor.subTask(name);
+ }
+ }
+ /**
+ * Returns a status indicating if there is any known reason
+ * this operation will fail. Operations are verified before they
+ * are run.
+ *
+ * Subclasses must override if they have any conditions to verify
+ * before this operation executes.
+ *
+ * @see IJavaModelStatus
+ */
+ protected IJavaModelStatus verify() {
+ return commonVerify();
+ }
+
+ /**
+ * @see IProgressMonitor
+ */
+ public void worked(int work) {
+ if (fMonitor != null) {
+ fMonitor.worked(work);
+ checkCanceled();
+ }
+ }
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java
index 88fcb7e..f1ea5f2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.resources.IResourceStatus;
@@ -15,11 +15,15 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModelStatus;
import org.eclipse.jdt.core.IJavaModelStatusConstants;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
/**
* @see IJavaModelStatus
@@ -51,7 +55,7 @@
/**
* Singleton OK object
*/
- public static final IJavaModelStatus VERIFIED_OK = new JavaModelStatus(OK);
+ public static final IJavaModelStatus VERIFIED_OK = new JavaModelStatus(OK, OK, Util.bind("status.OK")); //$NON-NLS-1$
/**
* Constructs an Java model status with no corresponding elements.
@@ -80,11 +84,17 @@
* Constructs an Java model status with no corresponding elements.
*/
public JavaModelStatus(int code, String string) {
- super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus", null); //$NON-NLS-1$
+ this(ERROR, code, string);
+ }
+ /**
+ * Constructs an Java model status with no corresponding elements.
+ */
+ public JavaModelStatus(int severity, int code, String string) {
+ super(severity, JavaCore.PLUGIN_ID, code, "JavaModelStatus", null); //$NON-NLS-1$
fElements= JavaElementInfo.fgEmptyChildren;
fPath= null;
fString = string;
- }
+ }
/**
* Constructs an Java model status with no corresponding elements.
*/
@@ -113,8 +123,17 @@
*/
public JavaModelStatus(int code, IJavaElement element, String string) {
this(code, new IJavaElement[]{element});
- fString= string;
+ fString = string;
}
+
+ /**
+ * Constructs an Java model status with the given corresponding
+ * element and path
+ */
+ public JavaModelStatus(int code, IJavaElement element, IPath path) {
+ this(code, new IJavaElement[]{element});
+ fPath = path;
+ }
/**
* Constructs an Java model status with no corresponding elements.
*/
@@ -143,53 +162,81 @@
* Returns the message that is relevant to the code of this status.
*/
public String getMessage() {
- if (getException() == null) {
+ Throwable exception = getException();
+ if (exception == null) {
switch (getCode()) {
case CORE_EXCEPTION :
return Util.bind("status.coreException"); //$NON-NLS-1$
+
case BUILDER_INITIALIZATION_ERROR:
return Util.bind("build.initializationError"); //$NON-NLS-1$
+
case BUILDER_SERIALIZATION_ERROR:
return Util.bind("build.serializationError"); //$NON-NLS-1$
+
case DEVICE_PATH:
return Util.bind("status.cannotUseDeviceOnPath", getPath().toString()); //$NON-NLS-1$
+
case DOM_EXCEPTION:
return Util.bind("status.JDOMError"); //$NON-NLS-1$
+
case ELEMENT_DOES_NOT_EXIST:
- return Util.bind("element.doesNotExist",fElements[0].getElementName()); //$NON-NLS-1$
+ return Util.bind("element.doesNotExist",((JavaElement)fElements[0]).toStringWithAncestors()); //$NON-NLS-1$
+
case EVALUATION_ERROR:
- return Util.bind("status.evaluationError", getString()); //$NON-NLS-1$
+ return Util.bind("status.evaluationError", fString); //$NON-NLS-1$
+
case INDEX_OUT_OF_BOUNDS:
return Util.bind("status.indexOutOfBounds"); //$NON-NLS-1$
+
case INVALID_CONTENTS:
return Util.bind("status.invalidContents"); //$NON-NLS-1$
+
case INVALID_DESTINATION:
- return Util.bind("status.invalidDestination", fElements[0].getElementName()); //$NON-NLS-1$
+ return Util.bind("status.invalidDestination", ((JavaElement)fElements[0]).toStringWithAncestors()); //$NON-NLS-1$
+
case INVALID_ELEMENT_TYPES:
StringBuffer buff= new StringBuffer(Util.bind("operation.notSupported")); //$NON-NLS-1$
for (int i= 0; i < fElements.length; i++) {
if (i > 0) {
buff.append(", "); //$NON-NLS-1$
}
- buff.append(fElements[0].getElementName());
+ buff.append(((JavaElement)fElements[i]).toStringWithAncestors());
}
return buff.toString();
+
case INVALID_NAME:
- return Util.bind("status.invalidName", getString()); //$NON-NLS-1$
+ return Util.bind("status.invalidName", fString); //$NON-NLS-1$
+
case INVALID_PACKAGE:
- return Util.bind("status.invalidPackage", getString()); //$NON-NLS-1$
+ return Util.bind("status.invalidPackage", fString); //$NON-NLS-1$
+
case INVALID_PATH:
- return Util.bind("status.invalidPath", getPath() == null ? "null" : getPath().toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (fString != null) {
+ return fString;
+ } else {
+ return Util.bind("status.invalidPath", getPath() == null ? "null" : getPath().toString()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
case INVALID_PROJECT:
- return Util.bind("status.invalidProject", getString()); //$NON-NLS-1$
+ return Util.bind("status.invalidProject", fString); //$NON-NLS-1$
+
case INVALID_RESOURCE:
- return Util.bind("status.invalidResource", getString()); //$NON-NLS-1$
+ return Util.bind("status.invalidResource", fString); //$NON-NLS-1$
+
case INVALID_RESOURCE_TYPE:
- return Util.bind("status.invalidResourceType", getString()); //$NON-NLS-1$
+ return Util.bind("status.invalidResourceType", fString); //$NON-NLS-1$
+
case INVALID_SIBLING:
- return Util.bind("status.invalidSibling", fElements[0].getElementName()); //$NON-NLS-1$
+ if (fString != null) {
+ return Util.bind("status.invalidSibling", fString); //$NON-NLS-1$
+ } else {
+ return Util.bind("status.invalidSibling", ((JavaElement)fElements[0]).toStringWithAncestors()); //$NON-NLS-1$
+ }
+
case IO_EXCEPTION:
return Util.bind("status.IOException"); //$NON-NLS-1$
+
case NAME_COLLISION:
if (fElements != null && fElements.length > 0) {
IJavaElement element = fElements[0];
@@ -198,17 +245,26 @@
return Util.bind("operation.cannotRenameDefaultPackage"); //$NON-NLS-1$
}
}
- return Util.bind("status.nameCollision"); //$NON-NLS-1$
+ if (fString != null) {
+ return fString;
+ } else {
+ return Util.bind("status.nameCollision", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
case NO_ELEMENTS_TO_PROCESS:
return Util.bind("operation.needElements"); //$NON-NLS-1$
+
case NULL_NAME:
return Util.bind("operation.needName"); //$NON-NLS-1$
+
case NULL_PATH:
return Util.bind("operation.needPath"); //$NON-NLS-1$
+
case NULL_STRING:
return Util.bind("operation.needString"); //$NON-NLS-1$
+
case PATH_OUTSIDE_PROJECT:
- return Util.bind("operation.pathOutsideProject", getString(), fElements[0].getElementName()); //$NON-NLS-1$
+ return Util.bind("operation.pathOutsideProject", fString, ((JavaElement)fElements[0]).toStringWithAncestors()); //$NON-NLS-1$
+
case READ_ONLY:
IJavaElement element = fElements[0];
String name = element.getElementName();
@@ -216,18 +272,74 @@
return Util.bind("status.defaultPackageReadOnly"); //$NON-NLS-1$
}
return Util.bind("status.readOnly", name); //$NON-NLS-1$
+
case RELATIVE_PATH:
return Util.bind("operation.needAbsolutePath", getPath().toString()); //$NON-NLS-1$
+
case TARGET_EXCEPTION:
return Util.bind("status.targetException"); //$NON-NLS-1$
+
case UPDATE_CONFLICT:
return Util.bind("status.updateConflict"); //$NON-NLS-1$
+
case NO_LOCAL_CONTENTS :
return Util.bind("status.noLocalContents", getPath().toString()); //$NON-NLS-1$
+
+ case CP_CONTAINER_PATH_UNBOUND:
+ IPath path = this.fPath;
+ IJavaProject javaProject = (IJavaProject)fElements[0];
+ ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(path.segment(0));
+ String description = null;
+ if (initializer != null) description = initializer.getDescription(path, javaProject);
+ if (description == null) description = path.makeRelative().toString();
+ return Util.bind("classpath.unboundContainerPath", description); //$NON-NLS-1$
+
+ case INVALID_CP_CONTAINER_ENTRY:
+ path = this.fPath;
+ javaProject = (IJavaProject)fElements[0];
+ IClasspathContainer container = null;
+ description = null;
+ try {
+ container = JavaCore.getClasspathContainer(path, javaProject);
+ } catch(JavaModelException e){
+ }
+ if (container == null) {
+ initializer = JavaCore.getClasspathContainerInitializer(path.segment(0));
+ if (initializer != null) description = initializer.getDescription(path, javaProject);
+ } else {
+ description = container.getDescription();
+ }
+ if (description == null) description = path.makeRelative().toString();
+ return Util.bind("classpath.invalidContainer", description); //$NON-NLS-1$
+
+ case CP_VARIABLE_PATH_UNBOUND:
+ path = this.fPath;
+ return Util.bind("classpath.unboundVariablePath", path.makeRelative().toString()); //$NON-NLS-1$
+
+ case CLASSPATH_CYCLE:
+ javaProject = (IJavaProject)fElements[0];
+ return Util.bind("classpath.cycle", javaProject.getElementName()); //$NON-NLS-1$
+
+ case DISABLED_CP_EXCLUSION_PATTERNS:
+ path = this.fPath;
+ return Util.bind("classpath.disabledExclusionPatterns", path.makeRelative().toString()); //$NON-NLS-1$
+
+ case DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS:
+ path = this.fPath;
+ return Util.bind("classpath.disabledMultipleOutputLocations", path.makeRelative().toString()); //$NON-NLS-1$
}
- return getString();
+ if (fString != null) {
+ return fString;
+ } else {
+ return ""; // //$NON-NLS-1$
+ }
} else {
- return getException().getMessage();
+ String message = exception.getMessage();
+ if (message != null) {
+ return message;
+ } else {
+ return exception.toString();
+ }
}
}
/**
@@ -252,6 +364,7 @@
}
/**
* @see IJavaModelStatus#getString()
+ * @deprecated
*/
public String getString() {
return fString;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
index 0818f30..05847f6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
@@ -1,40 +1,41 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
-import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.resources.*;
+import java.io.*;
+import java.util.*;
-import org.eclipse.jdt.internal.codeassist.ISearchableNameEnvironment;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.xerces.dom.DocumentImpl;
+import org.apache.xml.serialize.Method;
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.Serializer;
+import org.apache.xml.serialize.SerializerFactory;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.eval.IEvaluationContext;
+import org.eclipse.jdt.internal.codeassist.ISearchableNameEnvironment;
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
import org.eclipse.jdt.internal.core.eval.EvaluationContextWrapper;
import org.eclipse.jdt.internal.eval.EvaluationContext;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Map;
-
-import javax.xml.parsers.*;
-import org.apache.xerces.dom.*;
-import org.apache.xml.serialize.*;
-import org.w3c.dom.*;
-import org.xml.sax.*;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
/**
* Handle for a Java Project.
@@ -72,8 +73,25 @@
* The platform project this <code>IJavaProject</code> is based on
*/
protected IProject fProject;
+
+ /**
+ * Name of file containing project classpath
+ */
+ public static final String CLASSPATH_FILENAME = ".classpath"; //$NON-NLS-1$
/**
+ * Name of file containing custom project preferences
+ */
+ public static final String PREF_FILENAME = ".jprefs"; //$NON-NLS-1$
+
+ /**
+ * Value of the project's raw classpath if the .classpath file contains invalid entries.
+ */
+ public static final IClasspathEntry[] INVALID_CLASSPATH = new IClasspathEntry[0];
+
+ private static final String CUSTOM_DEFAULT_OPTION_VALUE = "#\r\n\r#custom-non-empty-default-value#\r\n\r#"; //$NON-NLS-1$
+
+ /**
* Returns a canonicalized path from the given external path.
* Note that the return path contains the same number of segments
* and it contains a device only if the given path contained one.
@@ -96,7 +114,9 @@
}
// if not external path, return original path
- if (ResourcesPlugin.getWorkspace().getRoot().findMember(externalPath) != null) {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ if (workspace == null) return externalPath; // protection during shutdown (30487)
+ if (workspace.getRoot().findMember(externalPath) != null) {
// if (JavaModelManager.VERBOSE) {
// System.out.println("JAVA MODEL - Canonical path is original path (member of workspace)"); //$NON-NLS-1$
// }
@@ -148,89 +168,6 @@
// }
return result;
}
-
- /**
- * Returns the XML String encoding of the class path.
- */
- protected static Element getEntryAsXMLElement(
- Document document,
- IClasspathEntry entry,
- IPath prefixPath)
- throws JavaModelException {
-
- Element element = document.createElement("classpathentry"); //$NON-NLS-1$
- element.setAttribute("kind", kindToString(entry.getEntryKind())); //$NON-NLS-1$
- IPath path = entry.getPath();
- if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE && entry.getEntryKind() != IClasspathEntry.CPE_CONTAINER) {
- // translate to project relative from absolute (unless a device path)
- if (path.isAbsolute()) {
- if (prefixPath != null && prefixPath.isPrefixOf(path)) {
- if (path.segment(0).equals(prefixPath.segment(0))) {
- path = path.removeFirstSegments(1);
- path = path.makeRelative();
- } else {
- path = path.makeAbsolute();
- }
- }
- }
- }
- element.setAttribute("path", path.toString()); //$NON-NLS-1$
- if (entry.getSourceAttachmentPath() != null) {
- element.setAttribute("sourcepath", entry.getSourceAttachmentPath().toString()); //$NON-NLS-1$
- }
- if (entry.getSourceAttachmentRootPath() != null) {
- element.setAttribute(
- "rootpath", //$NON-NLS-1$
- entry.getSourceAttachmentRootPath().toString());
- }
- if (entry.isExported()) {
- element.setAttribute("exported", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return element;
- }
-
- /**
- * Returns the kind of a <code>PackageFragmentRoot</code> from its <code>String</code> form.
- */
- static int kindFromString(String kindStr) {
-
- if (kindStr.equalsIgnoreCase("prj")) //$NON-NLS-1$
- return IClasspathEntry.CPE_PROJECT;
- if (kindStr.equalsIgnoreCase("var")) //$NON-NLS-1$
- return IClasspathEntry.CPE_VARIABLE;
- if (kindStr.equalsIgnoreCase("con")) //$NON-NLS-1$
- return IClasspathEntry.CPE_CONTAINER;
- if (kindStr.equalsIgnoreCase("src")) //$NON-NLS-1$
- return IClasspathEntry.CPE_SOURCE;
- if (kindStr.equalsIgnoreCase("lib")) //$NON-NLS-1$
- return IClasspathEntry.CPE_LIBRARY;
- if (kindStr.equalsIgnoreCase("output")) //$NON-NLS-1$
- return ClasspathEntry.K_OUTPUT;
- return -1;
- }
-
- /**
- * Returns a <code>String</code> for the kind of a class path entry.
- */
- static String kindToString(int kind) {
-
- switch (kind) {
- case IClasspathEntry.CPE_PROJECT :
- return "src"; // backward compatibility //$NON-NLS-1$
- case IClasspathEntry.CPE_SOURCE :
- return "src"; //$NON-NLS-1$
- case IClasspathEntry.CPE_LIBRARY :
- return "lib"; //$NON-NLS-1$
- case IClasspathEntry.CPE_VARIABLE :
- return "var"; //$NON-NLS-1$
- case IClasspathEntry.CPE_CONTAINER :
- return "con"; //$NON-NLS-1$
- case ClasspathEntry.K_OUTPUT :
- return "output"; //$NON-NLS-1$
- default :
- return "unknown"; //$NON-NLS-1$
- }
- }
/**
* Constructor needed for <code>IProject.getNature()</code> and <code>IProject.addNature()</code>.
@@ -272,9 +209,12 @@
((JarPackageFragmentRoot) roots[i]).setSourceAttachmentProperty(null);
}
}
+
super.closing(info);
}
+
+
/**
* Internal computation of an expanded classpath. It will eliminate duplicates, and produce copies
* of exported classpath entries to avoid possible side-effects ever after.
@@ -297,7 +237,7 @@
IClasspathEntry[] immediateClasspath =
getResolvedClasspath(ignoreUnresolvedVariable, generateMarkerOnError);
- IWorkspaceRoot workspaceRoot = this.getWorkspace().getRoot();
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
for (int i = 0, length = immediateClasspath.length; i < length; i++){
IClasspathEntry entry = immediateClasspath[i];
@@ -308,15 +248,18 @@
// recurse in project to get all its indirect exports (only consider exported entries from there on)
if (entry.getEntryKind() == ClasspathEntry.CPE_PROJECT) {
- IProject projRsc = (IProject) workspaceRoot.findMember(entry.getPath());
- if (projRsc != null && projRsc.isOpen()) {
- JavaProject project = (JavaProject) JavaCore.create(projRsc);
- project.computeExpandedClasspath(
- initialProject,
- ignoreUnresolvedVariable,
- generateMarkerOnError,
- visitedProjects,
- accumulatedEntries);
+ IResource member = workspaceRoot.findMember(entry.getPath());
+ if (member != null && member.getType() == IResource.PROJECT){ // double check if bound to project (23977)
+ IProject projRsc = (IProject) member;
+ if (JavaProject.hasJavaNature(projRsc)) {
+ JavaProject project = (JavaProject) JavaCore.create(projRsc);
+ project.computeExpandedClasspath(
+ initialProject,
+ ignoreUnresolvedVariable,
+ generateMarkerOnError,
+ visitedProjects,
+ accumulatedEntries);
+ }
}
}
}
@@ -327,48 +270,80 @@
* Returns (local/all) the package fragment roots identified by the given project's classpath.
* Note: this follows project classpath references to find required project contributions,
* eliminating duplicates silently.
+ * Only works with resolved entries
*/
- public IPackageFragmentRoot[] computePackageFragmentRoots(IClasspathEntry[] classpath, boolean retrieveExportedRoots) throws JavaModelException {
+ public IPackageFragmentRoot[] computePackageFragmentRoots(IClasspathEntry[] resolvedClasspath, boolean retrieveExportedRoots) throws JavaModelException {
ObjectVector accumulatedRoots = new ObjectVector();
- computePackageFragmentRoots(classpath, accumulatedRoots, new HashSet(5), true, true, retrieveExportedRoots);
+ computePackageFragmentRoots(
+ resolvedClasspath,
+ accumulatedRoots,
+ new HashSet(5), // rootIDs
+ true, // inside original project
+ true, // check existency
+ retrieveExportedRoots);
IPackageFragmentRoot[] rootArray = new IPackageFragmentRoot[accumulatedRoots.size()];
accumulatedRoots.copyInto(rootArray);
return rootArray;
}
/**
+ * Computes the package fragment roots identified by the given entry.
+ * Only works with resolved entry
+ */
+ public IPackageFragmentRoot[] computePackageFragmentRoots(IClasspathEntry resolvedEntry) {
+ try {
+ return
+ computePackageFragmentRoots(
+ new IClasspathEntry[]{ resolvedEntry },
+ false // don't retrieve exported roots
+ );
+ } catch (JavaModelException e) {
+ return new IPackageFragmentRoot[] {};
+ }
+ }
+
+ /**
* Returns the package fragment roots identified by the given entry. In case it refers to
* a project, it will follow its classpath so as to find exported roots as well.
+ * Only works with resolved entry
*/
public void computePackageFragmentRoots(
- IClasspathEntry entry,
+ IClasspathEntry resolvedEntry,
ObjectVector accumulatedRoots,
HashSet rootIDs,
boolean insideOriginalProject,
boolean checkExistency,
boolean retrieveExportedRoots) throws JavaModelException {
- String rootID = ((ClasspathEntry)entry).rootID();
+ String rootID = ((ClasspathEntry)resolvedEntry).rootID();
if (rootIDs.contains(rootID)) return;
IPath projectPath = getProject().getFullPath();
- IPath entryPath = entry.getPath();
- IWorkspaceRoot workspaceRoot = getWorkspace().getRoot();
+ IPath entryPath = resolvedEntry.getPath();
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- switch(entry.getEntryKind()){
+ switch(resolvedEntry.getEntryKind()){
// source folder
case IClasspathEntry.CPE_SOURCE :
if (projectPath.isPrefixOf(entryPath)){
- Object target = JavaModel.getTarget(workspaceRoot, entryPath, checkExistency);
- if (target == null) return;
-
- if (target instanceof IFolder || target instanceof IProject){
- accumulatedRoots.add(
- new PackageFragmentRoot((IResource)target, this));
- rootIDs.add(rootID);
+ if (checkExistency) {
+ Object target = JavaModel.getTarget(workspaceRoot, entryPath, checkExistency);
+ if (target == null) return;
+
+ if (target instanceof IFolder || target instanceof IProject){
+ accumulatedRoots.add(
+ getPackageFragmentRoot((IResource)target));
+ rootIDs.add(rootID);
+ }
+ } else {
+ IPackageFragmentRoot root = getFolderPackageFragmentRoot(entryPath);
+ if (root != null) {
+ accumulatedRoots.add(root);
+ rootIDs.add(rootID);
+ }
}
}
break;
@@ -376,39 +351,32 @@
// internal/external JAR or folder
case IClasspathEntry.CPE_LIBRARY :
- if (!insideOriginalProject && !entry.isExported()) return;
-
- String extension = entryPath.getFileExtension();
-
- Object target = JavaModel.getTarget(workspaceRoot, entryPath, checkExistency);
- if (target == null) return;
-
- if (target instanceof IResource){
-
- // internal target
- IResource resource = (IResource) target;
- switch (resource.getType()){
- case IResource.FOLDER :
- accumulatedRoots.add(
- new PackageFragmentRoot(resource, this));
+ if (!insideOriginalProject && !resolvedEntry.isExported()) return;
+
+ if (checkExistency) {
+ Object target = JavaModel.getTarget(workspaceRoot, entryPath, checkExistency);
+ if (target == null) return;
+
+ if (target instanceof IResource){
+ // internal target
+ IResource resource = (IResource) target;
+ IPackageFragmentRoot root = getPackageFragmentRoot(resource);
+ if (root != null) {
+ accumulatedRoots.add(root);
rootIDs.add(rootID);
- break;
- case IResource.FILE :
- if ("jar".equalsIgnoreCase(extension) //$NON-NLS-1$
- || "zip".equalsIgnoreCase(extension)) { //$NON-NLS-1$
- accumulatedRoots.add(
- new JarPackageFragmentRoot(resource, this));
- }
- rootIDs.add(rootID);
- break;
+ }
+ } else {
+ // external target - only JARs allowed
+ if (((java.io.File)target).isFile() && (Util.isArchiveFileName(entryPath.lastSegment()))) {
+ accumulatedRoots.add(
+ new JarPackageFragmentRoot(entryPath, this));
+ rootIDs.add(rootID);
+ }
}
} else {
- // external target - only JARs allowed
- if (((java.io.File)target).isFile()
- && ("jar".equalsIgnoreCase(extension) //$NON-NLS-1$
- || "zip".equalsIgnoreCase(extension))) { //$NON-NLS-1$
- accumulatedRoots.add(
- new JarPackageFragmentRoot(entryPath.toOSString(), this));
+ IPackageFragmentRoot root = getPackageFragmentRoot(entryPath);
+ if (root != null) {
+ accumulatedRoots.add(root);
rootIDs.add(rootID);
}
}
@@ -418,31 +386,35 @@
case IClasspathEntry.CPE_PROJECT :
if (!retrieveExportedRoots) return;
- if (!insideOriginalProject && !entry.isExported()) return;
+ if (!insideOriginalProject && !resolvedEntry.isExported()) return;
- JavaProject requiredProject = (JavaProject)getJavaModel().getJavaProject(entryPath.segment(0));
- IProject requiredProjectRsc = requiredProject.getProject();
- if (requiredProjectRsc.exists() && requiredProjectRsc.isOpen()){ // special builder binary output
- rootIDs.add(rootID);
- requiredProject.computePackageFragmentRoots(
- requiredProject.getResolvedClasspath(true),
- accumulatedRoots,
- rootIDs,
- false,
- checkExistency,
- retrieveExportedRoots);
- }
+ IResource member = workspaceRoot.findMember(entryPath);
+ if (member != null && member.getType() == IResource.PROJECT){// double check if bound to project (23977)
+ IProject requiredProjectRsc = (IProject) member;
+ if (JavaProject.hasJavaNature(requiredProjectRsc)){ // special builder binary output
+ rootIDs.add(rootID);
+ JavaProject requiredProject = (JavaProject)JavaCore.create(requiredProjectRsc);
+ requiredProject.computePackageFragmentRoots(
+ requiredProject.getResolvedClasspath(true),
+ accumulatedRoots,
+ rootIDs,
+ false,
+ checkExistency,
+ retrieveExportedRoots);
+ }
break;
}
+ }
}
/**
* Returns (local/all) the package fragment roots identified by the given project's classpath.
* Note: this follows project classpath references to find required project contributions,
* eliminating duplicates silently.
+ * Only works with resolved entries
*/
public void computePackageFragmentRoots(
- IClasspathEntry[] classpath,
+ IClasspathEntry[] resolvedClasspath,
ObjectVector accumulatedRoots,
HashSet rootIDs,
boolean insideOriginalProject,
@@ -452,9 +424,9 @@
if (insideOriginalProject){
rootIDs.add(rootID());
}
- for (int i = 0, length = classpath.length; i < length; i++){
+ for (int i = 0, length = resolvedClasspath.length; i < length; i++){
computePackageFragmentRoots(
- classpath[i],
+ resolvedClasspath[i],
accumulatedRoots,
rootIDs,
insideOriginalProject,
@@ -479,34 +451,126 @@
// register Java builder
addToBuildSpec(JavaCore.BUILDER_ID);
}
+ /*
+ * Returns whether the given resource is accessible through the children or the non-Java resources of this project.
+ * Returns true if the resource is not in the project.
+ * Assumes that the resource is a folder or a file.
+ */
+ public boolean contains(IResource resource) {
+
+ IClasspathEntry[] classpath;
+ IPath output;
+ try {
+ classpath = getResolvedClasspath(true);
+ output = getOutputLocation();
+ } catch (JavaModelException e) {
+ return false;
+ }
+
+ IPath fullPath = resource.getFullPath();
+ IPath innerMostOutput = output.isPrefixOf(fullPath) ? output : null;
+ IClasspathEntry innerMostEntry = null;
+ for (int j = 0, cpLength = classpath.length; j < cpLength; j++) {
+ IClasspathEntry entry = classpath[j];
+
+ IPath entryPath = entry.getPath();
+ if ((innerMostEntry == null || innerMostEntry.getPath().isPrefixOf(entryPath))
+ && entryPath.isPrefixOf(fullPath)) {
+ innerMostEntry = entry;
+ }
+ IPath entryOutput = classpath[j].getOutputLocation();
+ if (entryOutput != null && entryOutput.isPrefixOf(fullPath)) {
+ innerMostOutput = entryOutput;
+ }
+ }
+ if (innerMostEntry != null) {
+ // special case prj==src and nested output location
+ if (innerMostOutput != null && innerMostOutput.segmentCount() > 1 // output isn't project
+ && innerMostEntry.getPath().segmentCount() == 1) { // 1 segment must be project name
+ return false;
+ }
+ if (resource instanceof IFolder) {
+ // folders are always included in src/lib entries
+ return true;
+ }
+ switch (innerMostEntry.getEntryKind()) {
+ case IClasspathEntry.CPE_SOURCE:
+ // .class files are not visible in source folders
+ return !Util.isClassFileName(fullPath.lastSegment());
+ case IClasspathEntry.CPE_LIBRARY:
+ // .java files are not visible in library folders
+ return !Util.isJavaFileName(fullPath.lastSegment());
+ }
+ }
+ if (innerMostOutput != null) {
+ return false;
+ }
+ return true;
+ }
/**
- * Record a new marker denoting a classpath problem
+ * Record a new marker denoting a classpath problem
*/
- void createClasspathProblemMarker(
- String message,
- int severity,
- boolean isCycleProblem,
- boolean isClasspathFileFormatProblem) {
+ IMarker createClasspathProblemMarker(IJavaModelStatus status) {
+
+ IMarker marker = null;
+ int severity;
+ String[] arguments = new String[0];
+ boolean isCycleProblem = false, isClasspathFileFormatProblem = false;
+ switch (status.getCode()) {
+
+ case IJavaModelStatusConstants.CLASSPATH_CYCLE :
+ isCycleProblem = true;
+ if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))) {
+ severity = IMarker.SEVERITY_ERROR;
+ } else {
+ severity = IMarker.SEVERITY_WARNING;
+ }
+ break;
+
+ case IJavaModelStatusConstants.INVALID_CLASSPATH_FILE_FORMAT :
+ isClasspathFileFormatProblem = true;
+ severity = IMarker.SEVERITY_ERROR;
+ break;
+
+ default:
+ IPath path = status.getPath();
+ if (path != null) arguments = new String[] { path.toString() };
+ if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true))) {
+ severity = IMarker.SEVERITY_ERROR;
+ } else {
+ severity = IMarker.SEVERITY_WARNING;
+ }
+ break;
+ }
+
try {
- IMarker marker = getProject().createMarker(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER);
+ marker = getProject().createMarker(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER);
marker.setAttributes(
new String[] {
IMarker.MESSAGE,
IMarker.SEVERITY,
IMarker.LOCATION,
IJavaModelMarker.CYCLE_DETECTED,
- IJavaModelMarker.CLASSPATH_FILE_FORMAT },
+ IJavaModelMarker.CLASSPATH_FILE_FORMAT,
+ IJavaModelMarker.ID,
+ IJavaModelMarker.ARGUMENTS ,
+ },
new Object[] {
- message,
+ status.getMessage(),
new Integer(severity),
Util.bind("classpath.buildPath"),//$NON-NLS-1$
isCycleProblem ? "true" : "false",//$NON-NLS-1$ //$NON-NLS-2$
- isClasspathFileFormatProblem ? "true" : "false"});//$NON-NLS-1$ //$NON-NLS-2$
+ isClasspathFileFormatProblem ? "true" : "false",//$NON-NLS-1$ //$NON-NLS-2$
+ new Integer(status.getCode()),
+ Util.getProblemArgumentsForMarker(arguments) ,
+ }
+ );
} catch (CoreException e) {
}
+ return marker;
}
-
+
/**
* Returns a new element info for this element.
*/
@@ -516,6 +580,87 @@
}
/**
+ * Reads and decode an XML classpath string
+ */
+ protected IClasspathEntry[] decodeClasspath(String xmlClasspath, boolean createMarker, boolean logProblems) {
+
+ ArrayList paths = new ArrayList();
+ IClasspathEntry defaultOutput = null;
+ try {
+ if (xmlClasspath == null) return null;
+ StringReader reader = new StringReader(xmlClasspath);
+ Element cpElement;
+
+ try {
+ DocumentBuilder parser =
+ DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ cpElement = parser.parse(new InputSource(reader)).getDocumentElement();
+ } catch (SAXException e) {
+ throw new IOException(Util.bind("file.badFormat")); //$NON-NLS-1$
+ } catch (ParserConfigurationException e) {
+ throw new IOException(Util.bind("file.badFormat")); //$NON-NLS-1$
+ } finally {
+ reader.close();
+ }
+
+ if (!cpElement.getNodeName().equalsIgnoreCase("classpath")) { //$NON-NLS-1$
+ throw new IOException(Util.bind("file.badFormat")); //$NON-NLS-1$
+ }
+ NodeList list = cpElement.getElementsByTagName("classpathentry"); //$NON-NLS-1$
+ int length = list.getLength();
+
+ for (int i = 0; i < length; ++i) {
+ Node node = list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ IClasspathEntry entry = ClasspathEntry.elementDecode((Element)node, this);
+ if (entry != null){
+ if (entry.getContentKind() == ClasspathEntry.K_OUTPUT) {
+ defaultOutput = entry; // separate output
+ } else {
+ paths.add(entry);
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ // bad format
+ if (createMarker && this.getProject().isAccessible()) {
+ this.createClasspathProblemMarker(new JavaModelStatus(
+ IJavaModelStatusConstants.INVALID_CLASSPATH_FILE_FORMAT,
+ Util.bind("classpath.xmlFormatError", this.getElementName(), e.getMessage()))); //$NON-NLS-1$
+ }
+ if (logProblems) {
+ Util.log(e,
+ "Exception while retrieving "+ this.getPath() //$NON-NLS-1$
+ +"/.classpath, will mark classpath as invalid"); //$NON-NLS-1$
+ }
+ return INVALID_CLASSPATH;
+ } catch (Assert.AssertionFailedException e) {
+ // failed creating CP entries from file
+ if (createMarker && this.getProject().isAccessible()) {
+ this.createClasspathProblemMarker(new JavaModelStatus(
+ IJavaModelStatusConstants.INVALID_CLASSPATH_FILE_FORMAT,
+ Util.bind("classpath.illegalEntryInClasspathFile", this.getElementName(), e.getMessage()))); //$NON-NLS-1$
+ }
+ if (logProblems) {
+ Util.log(e,
+ "Exception while retrieving "+ this.getPath() //$NON-NLS-1$
+ +"/.classpath, will mark classpath as invalid"); //$NON-NLS-1$
+ }
+ return INVALID_CLASSPATH;
+ }
+ int pathSize = paths.size();
+ if (pathSize > 0 || defaultOutput != null) {
+ IClasspathEntry[] entries = new IClasspathEntry[pathSize + (defaultOutput == null ? 0 : 1)];
+ paths.toArray(entries);
+ if (defaultOutput != null) entries[pathSize] = defaultOutput; // ensure output is last item
+ return entries;
+ } else {
+ return null;
+ }
+ }
+
+ /**
/**
* Removes the Java nature from the project.
*/
@@ -544,6 +689,49 @@
}
/**
+ * Returns the XML String encoding of the class path.
+ */
+ protected String encodeClasspath(IClasspathEntry[] classpath, IPath outputLocation, boolean useLineSeparator) throws JavaModelException {
+
+ Document document = new DocumentImpl();
+ Element cpElement = document.createElement("classpath"); //$NON-NLS-1$
+ document.appendChild(cpElement);
+
+ for (int i = 0; i < classpath.length; ++i) {
+ cpElement.appendChild(((ClasspathEntry)classpath[i]).elementEncode(document, getProject().getFullPath()));
+ }
+
+ if (outputLocation != null) {
+ outputLocation = outputLocation.removeFirstSegments(1);
+ outputLocation = outputLocation.makeRelative();
+ Element oElement = document.createElement("classpathentry"); //$NON-NLS-1$
+ oElement.setAttribute("kind", ClasspathEntry.kindToString(ClasspathEntry.K_OUTPUT)); //$NON-NLS-1$
+ oElement.setAttribute("path", outputLocation.toString()); //$NON-NLS-1$
+ cpElement.appendChild(oElement);
+ }
+
+ // produce a String output
+ try {
+ ByteArrayOutputStream s = new ByteArrayOutputStream();
+ OutputFormat format = new OutputFormat();
+ if (useLineSeparator) {
+ format.setIndenting(true);
+ format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$
+ } else {
+ format.setPreserveSpace(true);
+ }
+ Serializer serializer =
+ SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(
+ new OutputStreamWriter(s, "UTF8"), //$NON-NLS-1$
+ format);
+ serializer.asDOMSerializer().serialize(document);
+ return s.toString("UTF8"); //$NON-NLS-1$
+ } catch (IOException e) {
+ throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
+ }
+ }
+
+ /**
* Returns true if this handle represents the same Java project
* as the given handle. Two handles represent the same
* project if they are identical or if they represent a project with
@@ -564,6 +752,11 @@
&& fOccurrenceCount == other.fOccurrenceCount;
}
+ public boolean exists() {
+ if (!hasJavaNature(fProject)) return false;
+ return super.exists();
+ }
+
/**
* @see IJavaProject
*/
@@ -639,7 +832,7 @@
public IPackageFragment findPackageFragment(IPath path)
throws JavaModelException {
- return findPackageFragment0(this.canonicalizedPath(path));
+ return findPackageFragment0(JavaProject.canonicalizedPath(path));
}
/**
@@ -657,7 +850,7 @@
public IPackageFragmentRoot findPackageFragmentRoot(IPath path)
throws JavaModelException {
- return findPackageFragmentRoot0(this.canonicalizedPath(path));
+ return findPackageFragmentRoot0(JavaProject.canonicalizedPath(path));
}
/**
@@ -678,6 +871,24 @@
}
return null;
}
+ /**
+ * @see IJavaProject
+ */
+ public IPackageFragmentRoot[] findPackageFragmentRoots(IClasspathEntry entry) {
+ try {
+ IClasspathEntry[] classpath = this.getRawClasspath();
+ for (int i = 0, length = classpath.length; i < length; i++) {
+ if (classpath[i].equals(entry)) { // entry may need to be resolved
+ return
+ computePackageFragmentRoots(
+ getResolvedClasspath(new IClasspathEntry[] {entry}, null, true, false, null/*no reverse map*/),
+ false); // don't retrieve exported roots
+ }
+ }
+ } catch (JavaModelException e) {
+ }
+ return new IPackageFragmentRoot[] {};
+ }
/**
* @see IJavaProject#findType(String)
@@ -722,14 +933,18 @@
try {
IProject project = getProject();
if (project.exists()) {
- IMarker[] markers = project.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ONE);
+ IMarker[] markers = project.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
for (int i = 0, length = markers.length; i < length; i++) {
IMarker marker = markers[i];
- String cycleAttr = (String)marker.getAttribute(IJavaModelMarker.CYCLE_DETECTED);
- String classpathFileFormatAttr = (String)marker.getAttribute(IJavaModelMarker.CLASSPATH_FILE_FORMAT);
- if ((flushCycleMarkers == (cycleAttr != null && cycleAttr.equals("true"))) //$NON-NLS-1$
- && (flushClasspathFormatMarkers == (classpathFileFormatAttr != null && classpathFileFormatAttr.equals("true")))){ //$NON-NLS-1$
+ if (flushCycleMarkers && flushClasspathFormatMarkers) {
marker.delete();
+ } else {
+ String cycleAttr = (String)marker.getAttribute(IJavaModelMarker.CYCLE_DETECTED);
+ String classpathFileFormatAttr = (String)marker.getAttribute(IJavaModelMarker.CLASSPATH_FILE_FORMAT);
+ if ((flushCycleMarkers == (cycleAttr != null && cycleAttr.equals("true"))) //$NON-NLS-1$
+ && (flushClasspathFormatMarkers == (classpathFileFormatAttr != null && classpathFileFormatAttr.equals("true")))){ //$NON-NLS-1$
+ marker.delete();
+ }
}
}
}
@@ -744,64 +959,37 @@
OpenableElementInfo info,
IProgressMonitor pm,
Map newElements,
- IResource underlyingResource) throws JavaModelException {
+ IResource underlyingResource) throws JavaModelException {
boolean validInfo = false;
try {
- if (((IProject) getUnderlyingResource()).isOpen()) {
- // put the info now, because setting the classpath requires it
+ if (getProject().isOpen()) {
+ // put the info now, because computing the roots requires it
JavaModelManager.getJavaModelManager().putInfo(this, info);
- // read classpath property (contains actual classpath and output location settings)
- IPath outputLocation = null;
- IClasspathEntry[] classpath = null;
-
- // read from file
- try {
- String sharedClasspath = loadClasspath();
- if (sharedClasspath != null) {
- classpath = readPaths(sharedClasspath);
+ // compute the pkg fragment roots
+ updatePackageFragmentRoots();
+
+ // remember the timestamps of external libraries the first time they are looked up
+ IClasspathEntry[] resolvedClasspath = getResolvedClasspath(true/*ignore unresolved variable*/);
+ for (int i = 0, length = resolvedClasspath.length; i < length; i++) {
+ IClasspathEntry entry = resolvedClasspath[i];
+ if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+ IPath path = entry.getPath();
+ Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
+ if (target instanceof java.io.File) {
+ Map externalTimeStamps = JavaModelManager.getJavaModelManager().deltaProcessor.externalTimeStamps;
+ if (externalTimeStamps.get(path) == null) {
+ long timestamp = DeltaProcessor.getTimeStamp((java.io.File)target);
+ externalTimeStamps.put(path, new Long(timestamp));
+ }
+ }
}
- } catch(JavaModelException e) {
- if (JavaModelManager.VERBOSE && this.getProject().isAccessible()){
- Util.log(e,
- "Exception while retrieving "+ this.getPath() //$NON-NLS-1$
- +"/.classpath, will revert to default classpath"); //$NON-NLS-1$
- }
- } catch(IOException e){
- if (JavaModelManager.VERBOSE && this.getProject().isAccessible()){
- Util.log(e,
- "Exception while retrieving "+ this.getPath() //$NON-NLS-1$
- +"/.classpath, will revert to default classpath"); //$NON-NLS-1$
- }
- }
-
- // extract out the output location
- if (classpath != null && classpath.length > 0) {
- IClasspathEntry entry = classpath[classpath.length - 1];
- if (entry.getContentKind() == ClasspathEntry.K_OUTPUT) {
- outputLocation = entry.getPath();
- IClasspathEntry[] copy = new IClasspathEntry[classpath.length - 1];
- System.arraycopy(classpath, 0, copy, 0, copy.length);
- classpath = copy;
- }
- }
- // restore output location
- if (outputLocation == null) {
- outputLocation = defaultOutputLocation();
- }
- ((JavaProjectElementInfo)info).setOutputLocation(outputLocation);
-
- // restore classpath
- if (classpath == null) {
- classpath = defaultClasspath();
- }
- setRawClasspath0(classpath);
+ }
// only valid if reaches here
validInfo = true;
}
- } catch (JavaModelException e) {
} finally {
if (!validInfo)
JavaModelManager.getJavaModelManager().removeInfo(this);
@@ -819,51 +1007,6 @@
}
/**
- * Returns the XML String encoding of the class path.
- */
- protected String getClasspathAsXML(
- IClasspathEntry[] classpath,
- IPath outputLocation)
- throws JavaModelException {
-
- Document doc = new DocumentImpl();
- Element cpElement = doc.createElement("classpath"); //$NON-NLS-1$
- doc.appendChild(cpElement);
-
- for (int i = 0; i < classpath.length; ++i) {
- Element cpeElement =
- getEntryAsXMLElement(doc, classpath[i], getProject().getFullPath());
- cpElement.appendChild(cpeElement);
- }
-
- if (outputLocation != null) {
- outputLocation = outputLocation.removeFirstSegments(1);
- outputLocation = outputLocation.makeRelative();
- Element oElement = doc.createElement("classpathentry"); //$NON-NLS-1$
- oElement.setAttribute("kind", kindToString(ClasspathEntry.K_OUTPUT)); //$NON-NLS-1$
- oElement.setAttribute("path", outputLocation.toOSString()); //$NON-NLS-1$
- cpElement.appendChild(oElement);
- }
-
- // produce a String output
- try {
- ByteArrayOutputStream s= new ByteArrayOutputStream();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
- format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$
-
- Serializer serializer =
- SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(
- new OutputStreamWriter(s, "UTF8"), //$NON-NLS-1$
- format);
- serializer.asDOMSerializer().serialize(doc);
- return s.toString("UTF8"); //$NON-NLS-1$
- } catch (IOException e) {
- throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
- }
- }
-
- /**
* Returns the classpath entry that refers to the given path
* or <code>null</code> if there is no reference to the path.
*/
@@ -879,12 +1022,25 @@
return null;
}
- /**
- * Returns the qualified name for the classpath server property
- * of this project
+ /*
+ * Returns the cycle marker associated with this project or null if none.
*/
- public QualifiedName getClasspathPropertyName() {
- return new QualifiedName(JavaCore.PLUGIN_ID, "classpath"); //$NON-NLS-1$
+ public IMarker getCycleMarker(){
+ try {
+ IProject project = getProject();
+ if (project.exists()) {
+ IMarker[] markers = project.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
+ for (int i = 0, length = markers.length; i < length; i++) {
+ IMarker marker = markers[i];
+ String cycleAttr = (String)marker.getAttribute(IJavaModelMarker.CYCLE_DETECTED);
+ if (cycleAttr != null && cycleAttr.equals("true")){ //$NON-NLS-1$
+ return marker;
+ }
+ }
+ }
+ } catch (CoreException e) {
+ }
+ return null;
}
/**
@@ -940,14 +1096,6 @@
}
/**
- * @see IJavaElement
- */
- public IJavaProject getJavaProject() {
-
- return this;
- }
-
- /**
* Convenience method that returns the specific type of info for a Java project.
*/
protected JavaProjectElementInfo getJavaProjectElementInfo()
@@ -981,107 +1129,133 @@
}
/**
+ * @see org.eclipse.jdt.core.IJavaProject#getOption(String, boolean)
+ */
+ public String getOption(String optionName, boolean inheritJavaCoreOptions) {
+
+ if (JavaModelManager.OptionNames.contains(optionName)){
+
+ Preferences preferences = getPreferences();
+ if (preferences == null || preferences.isDefault(optionName)) {
+ return inheritJavaCoreOptions ? JavaCore.getOption(optionName) : null;
+ }
+ return preferences.getString(optionName).trim();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.IJavaProject#getOptions(boolean)
+ */
+ public Map getOptions(boolean inheritJavaCoreOptions) {
+
+ // initialize to the defaults from JavaCore options pool
+ Map options = inheritJavaCoreOptions ? JavaCore.getOptions() : new Hashtable(5);
+
+ Preferences preferences = getPreferences();
+ if (preferences == null) return options; // cannot do better (non-Java project)
+ HashSet optionNames = JavaModelManager.OptionNames;
+
+ // get preferences set to their default
+ if (inheritJavaCoreOptions){
+ String[] defaultPropertyNames = preferences.defaultPropertyNames();
+ for (int i = 0; i < defaultPropertyNames.length; i++){
+ String propertyName = defaultPropertyNames[i];
+ if (optionNames.contains(propertyName)){
+ options.put(propertyName, preferences.getDefaultString(propertyName).trim());
+ }
+ }
+ }
+ // get custom preferences not set to their default
+ String[] propertyNames = preferences.propertyNames();
+ for (int i = 0; i < propertyNames.length; i++){
+ String propertyName = propertyNames[i];
+ if (optionNames.contains(propertyName)){
+ options.put(propertyName, preferences.getString(propertyName).trim());
+ }
+ }
+ return options;
+ }
+
+ /**
* @see IJavaProject
*/
public IPath getOutputLocation() throws JavaModelException {
- IPath outputLocation = null;
- if (this.isOpen()) {
- JavaProjectElementInfo info = getJavaProjectElementInfo();
- outputLocation = info.getOutputLocation();
- if (outputLocation != null) {
- return outputLocation;
- }
+ JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(fProject);
+ IPath outputLocation = perProjectInfo.outputLocation;
+ if (outputLocation != null) return outputLocation;
+
+ // force to read classpath - will position output location as well
+ this.getRawClasspath();
+ outputLocation = perProjectInfo.outputLocation;
+ if (outputLocation == null) {
return defaultOutputLocation();
}
- // if not already opened, then read from file (avoid populating the model for CP question)
- if (!this.getProject().exists()){
- throw newNotPresentException();
- }
- IClasspathEntry[] classpath = null;
- try {
- String sharedClasspath = loadClasspath();
- if (sharedClasspath != null) {
- classpath = readPaths(sharedClasspath);
- }
- } catch(JavaModelException e) {
- if (JavaModelManager.VERBOSE && this.getProject().isAccessible()){
- Util.log(e,
- "Exception while retrieving "+ this.getPath() //$NON-NLS-1$
- +"/.classpath, will revert to default output location"); //$NON-NLS-1$
- }
- } catch(IOException e){
- if (JavaModelManager.VERBOSE && this.getProject().isAccessible()){
- Util.log(e,
- "Exception while retrieving "+ this.getPath() //$NON-NLS-1$
- +"/.classpath, will revert to default output location"); //$NON-NLS-1$
- }
- }
- // extract out the output location
- if (classpath != null && classpath.length > 0) {
- IClasspathEntry entry = classpath[classpath.length - 1];
- if (entry.getContentKind() == ClasspathEntry.K_OUTPUT) {
- outputLocation = entry.getPath();
- }
- }
- if (outputLocation != null) {
- return outputLocation;
- }
- return defaultOutputLocation();
+ return outputLocation;
}
/**
* @return A handle to the package fragment root identified by the given path.
* This method is handle-only and the element may or may not exist. Returns
* <code>null</code> if unable to generate a handle from the path (for example,
- * an absolute path that has less than 2 segments. The path may be relative or
+ * an absolute path that has less than 1 segment. The path may be relative or
* absolute.
*/
public IPackageFragmentRoot getPackageFragmentRoot(IPath path) {
- Object target = JavaModel.getTarget(getProject().getWorkspace().getRoot(), path, false);
- if (target == null) {
- if (path.segmentCount() > 0) {
- String ext = path.getFileExtension();
- if (ext == null) {
- return getPackageFragmentRoot(getProject().getFolder(path));
- } else {
- // resource jar
- return getPackageFragmentRoot(getProject().getFile(path));
- }
- } else {
+ if (!path.isAbsolute()) {
+ path = getPath().append(path);
+ }
+ int segmentCount = path.segmentCount();
+ switch (segmentCount) {
+ case 0:
+ return null;
+ case 1:
// default root
return getPackageFragmentRoot(getProject());
- }
- } else {
- if (target instanceof IResource) {
- return this.getPackageFragmentRoot((IResource)target);
- } else {
- String ext = path.getFileExtension();
- if (((java.io.File)target).isFile()
- && ("jar".equalsIgnoreCase(ext) //$NON-NLS-1$
- || "zip".equalsIgnoreCase(ext))) { //$NON-NLS-1$
- // external jar
- return getPackageFragmentRoot0(path.toOSString());
+ default:
+ // a path ending with .jar/.zip is still ambiguous and could still resolve to a source/lib folder
+ // thus will try to guess based on existing resource
+ if (Util.isArchiveFileName(path.lastSegment())) {
+ IResource resource = getProject().getWorkspace().getRoot().findMember(path);
+ if (resource != null && resource.getType() == IResource.FOLDER){
+ return getPackageFragmentRoot(resource);
+ }
+ return getPackageFragmentRoot0(path);
} else {
- // unknown path
- return null;
+ return getPackageFragmentRoot(getProject().getWorkspace().getRoot().getFolder(path));
}
- }
}
}
/**
+ * The path is known to match a source/library folder entry.
+ */
+ public IPackageFragmentRoot getFolderPackageFragmentRoot(IPath path) {
+ if (path.segmentCount() == 1) { // default project root
+ return getPackageFragmentRoot(getProject());
+ }
+ return getPackageFragmentRoot(getProject().getWorkspace().getRoot().getFolder(path));
+ }
+
+ /**
* @see IJavaProject
*/
public IPackageFragmentRoot getPackageFragmentRoot(IResource resource) {
- String name = resource.getName();
- if (resource.getType() == IResource.FILE
- && (Util.endsWithIgnoreCase(name, ".jar") //$NON-NLS-1$
- || Util.endsWithIgnoreCase(name, ".zip"))) { //$NON-NLS-1$
- return new JarPackageFragmentRoot(resource, this);
- } else {
- return new PackageFragmentRoot(resource, this);
+ switch (resource.getType()) {
+ case IResource.FILE:
+ if (Util.isArchiveFileName(resource.getName())) {
+ return new JarPackageFragmentRoot(resource, this);
+ } else {
+ return null;
+ }
+ case IResource.FOLDER:
+ return new PackageFragmentRoot(resource, this, resource.getName());
+ case IResource.PROJECT:
+ return new PackageFragmentRoot(resource, this, ""); //$NON-NLS-1$
+ default:
+ return null;
}
}
@@ -1090,13 +1264,13 @@
*/
public IPackageFragmentRoot getPackageFragmentRoot(String jarPath) {
- return getPackageFragmentRoot0(this.canonicalizedPath(new Path(jarPath)).toString());
+ return getPackageFragmentRoot0(JavaProject.canonicalizedPath(new Path(jarPath)));
}
/**
* no path canonicalization
*/
- public IPackageFragmentRoot getPackageFragmentRoot0(String jarPath) {
+ public IPackageFragmentRoot getPackageFragmentRoot0(IPath jarPath) {
return new JarPackageFragmentRoot(jarPath, this);
}
@@ -1122,18 +1296,11 @@
}
/**
- * Returns the package fragment roots identified by the given entry.
+ * @see IJavaProject
+ * @deprecated
*/
public IPackageFragmentRoot[] getPackageFragmentRoots(IClasspathEntry entry) {
-
- try {
-
- IClasspathEntry[] correspondingEntries = this.getResolvedClasspath(new IClasspathEntry[]{entry}, true, false);
- return computePackageFragmentRoots(correspondingEntries, false);
-
- } catch (JavaModelException e) {
- return new IPackageFragmentRoot[] {};
- }
+ return findPackageFragmentRoots(entry);
}
/**
@@ -1204,54 +1371,54 @@
}
/**
+ * Returns the project custom preference pool.
+ * Project preferences may include custom encoding.
+ */
+ public Preferences getPreferences(){
+ IProject project = getProject();
+ if (!JavaProject.hasJavaNature(project)) return null;
+ JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfo(project, true);
+ Preferences preferences = perProjectInfo.preferences;
+ if (preferences != null) return preferences;
+ preferences = loadPreferences();
+ if (preferences == null) preferences = new Preferences();
+ perProjectInfo.preferences = preferences;
+ return preferences;
+ }
+
+ /**
* @see IJavaProject
*/
public IClasspathEntry[] getRawClasspath() throws JavaModelException {
- IClasspathEntry[] classpath = null;
- if (this.isOpen()) {
- JavaProjectElementInfo info = getJavaProjectElementInfo();
- classpath = info.getRawClasspath();
- if (classpath != null) {
- return classpath;
- }
- return defaultClasspath();
- }
- // if not already opened, then read from file (avoid populating the model for CP question)
- if (!this.getProject().exists()){
- throw newNotPresentException();
- }
- try {
- String sharedClasspath = loadClasspath();
- if (sharedClasspath != null) {
- classpath = readPaths(sharedClasspath);
- }
- } catch(JavaModelException e) {
- if (JavaModelManager.VERBOSE && this.getProject().isAccessible()){
- Util.log(e,
- "Exception while retrieving "+ this.getPath() //$NON-NLS-1$
- +"/.classpath, will revert to default classpath"); //$NON-NLS-1$
- }
- } catch(IOException e){
- if (JavaModelManager.VERBOSE && this.getProject().isAccessible()){
- Util.log(e,
- "Exception while retrieving "+ this.getPath() //$NON-NLS-1$
- +"/.classpath, will revert to default classpath"); //$NON-NLS-1$
- }
- }
+ JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(fProject);
+ IClasspathEntry[] classpath = perProjectInfo.classpath;
+ if (classpath != null) return classpath;
+ classpath = this.readClasspathFile(false/*don't create markers*/, true/*log problems*/);
+
// extract out the output location
+ IPath outputLocation = null;
if (classpath != null && classpath.length > 0) {
IClasspathEntry entry = classpath[classpath.length - 1];
if (entry.getContentKind() == ClasspathEntry.K_OUTPUT) {
+ outputLocation = entry.getPath();
IClasspathEntry[] copy = new IClasspathEntry[classpath.length - 1];
System.arraycopy(classpath, 0, copy, 0, copy.length);
classpath = copy;
}
}
- if (classpath != null) {
- return classpath;
+ if (classpath == null) {
+ return defaultClasspath();
}
- return defaultClasspath();
+ /* Disable validate: classpath can contain CP variables and container that need to be resolved
+ if (classpath != INVALID_CLASSPATH
+ && !JavaConventions.validateClasspath(this, classpath, outputLocation).isOK()) {
+ classpath = INVALID_CLASSPATH;
+ }
+ */
+ perProjectInfo.classpath = classpath;
+ perProjectInfo.outputLocation = outputLocation;
+ return classpath;
}
/**
@@ -1265,42 +1432,52 @@
/**
* @see IJavaProject
*/
- public IClasspathEntry[] getResolvedClasspath(boolean ignoreUnresolvedVariable)
+ public IClasspathEntry[] getResolvedClasspath(boolean ignoreUnresolvedEntry)
throws JavaModelException {
return
this.getResolvedClasspath(
- ignoreUnresolvedVariable,
+ ignoreUnresolvedEntry,
false); // generateMarkerOnError
}
/**
* Internal variant which can create marker on project for invalid entries
+ * and caches the resolved classpath on perProjectInfo
*/
public IClasspathEntry[] getResolvedClasspath(
boolean ignoreUnresolvedEntry,
boolean generateMarkerOnError)
throws JavaModelException {
- JavaProjectElementInfo projectInfo;
- if (this.isOpen()){
- projectInfo = getJavaProjectElementInfo();
- } else {
- // avoid populating the model for only retrieving the resolved classpath (13395)
- projectInfo = null;
- }
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ JavaModelManager.PerProjectInfo perProjectInfo = manager.getPerProjectInfoCheckExistence(fProject);
// reuse cache if not needing to refresh markers or checking bound variables
- if (ignoreUnresolvedEntry && !generateMarkerOnError && projectInfo != null){
+ if (ignoreUnresolvedEntry && !generateMarkerOnError && perProjectInfo != null){
// resolved path is cached on its info
- IClasspathEntry[] infoPath = projectInfo.lastResolvedClasspath;
+ IClasspathEntry[] infoPath = perProjectInfo.lastResolvedClasspath;
if (infoPath != null) return infoPath;
}
+ Map reverseMap = perProjectInfo == null ? null : new HashMap(5);
+ IClasspathEntry[] resolvedPath = getResolvedClasspath(
+ getRawClasspath(),
+ generateMarkerOnError ? getOutputLocation() : null,
+ ignoreUnresolvedEntry,
+ generateMarkerOnError,
+ reverseMap);
- IClasspathEntry[] resolvedPath = getResolvedClasspath(getRawClasspath(), ignoreUnresolvedEntry, generateMarkerOnError);
+ if (perProjectInfo != null){
+ if (perProjectInfo.classpath == null // .classpath file could not be read
+ && generateMarkerOnError
+ && JavaProject.hasJavaNature(fProject)) {
+ this.createClasspathProblemMarker(new JavaModelStatus(
+ IJavaModelStatusConstants.INVALID_CLASSPATH_FILE_FORMAT,
+ Util.bind("classpath.cannotReadClasspathFile", this.getElementName()))); //$NON-NLS-1$
+ }
- if (projectInfo != null){
- projectInfo.lastResolvedClasspath = resolvedPath;
+ perProjectInfo.lastResolvedClasspath = resolvedPath;
+ perProjectInfo.resolvedPathToRawEntries = reverseMap;
}
return resolvedPath;
}
@@ -1310,32 +1487,30 @@
*/
public IClasspathEntry[] getResolvedClasspath(
IClasspathEntry[] classpathEntries,
- boolean ignoreUnresolvedEntry,
- boolean generateMarkerOnError)
+ IPath projectOutputLocation, // only set if needing full classpath validation (and markers)
+ boolean ignoreUnresolvedEntry, // if unresolved entries are met, should it trigger initializations
+ boolean generateMarkerOnError,
+ Map reverseMap) // can be null if not interested in reverse mapping
throws JavaModelException {
+ IJavaModelStatus status;
if (generateMarkerOnError){
flushClasspathProblemMarkers(false, false);
}
int length = classpathEntries.length;
- int index = 0;
ArrayList resolvedEntries = new ArrayList();
for (int i = 0; i < length; i++) {
IClasspathEntry rawEntry = classpathEntries[i];
-
+ IPath resolvedPath;
+ status = null;
+
/* validation if needed */
- if (generateMarkerOnError) {
- IJavaModelStatus status =
- JavaConventions.validateClasspathEntry(this, rawEntry, false);
- if (!status.isOK())
- createClasspathProblemMarker(
- status.getMessage(),
- IMarker.SEVERITY_ERROR,
- false,
- false);
+ if (generateMarkerOnError || !ignoreUnresolvedEntry) {
+ status = JavaConventions.validateClasspathEntry(this, rawEntry, false);
+ if (generateMarkerOnError && !status.isOK()) createClasspathProblemMarker(status);
}
switch (rawEntry.getEntryKind()){
@@ -1344,13 +1519,9 @@
IClasspathEntry resolvedEntry = JavaCore.getResolvedClasspathEntry(rawEntry);
if (resolvedEntry == null) {
- if (!ignoreUnresolvedEntry) {
- throw new JavaModelException(
- new JavaModelStatus(
- IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND,
- rawEntry.getPath().toString()));
- }
+ if (!ignoreUnresolvedEntry) throw new JavaModelException(status);
} else {
+ if (reverseMap != null && reverseMap.get(resolvedPath = resolvedEntry.getPath()) == null) reverseMap.put(resolvedPath , rawEntry);
resolvedEntries.add(resolvedEntry);
}
break;
@@ -1359,13 +1530,7 @@
IClasspathContainer container = JavaCore.getClasspathContainer(rawEntry.getPath(), this);
if (container == null){
- // unbound container
- if (!ignoreUnresolvedEntry) {
- throw new JavaModelException(
- new JavaModelStatus(
- IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND,
- rawEntry.getPath().toString()));
- }
+ if (!ignoreUnresolvedEntry) throw new JavaModelException(status);
break;
}
@@ -1374,24 +1539,28 @@
// container was bound
for (int j = 0, containerLength = containerEntries.length; j < containerLength; j++){
- IClasspathEntry containerRawEntry = containerEntries[j];
+ IClasspathEntry cEntry = containerEntries[j];
if (generateMarkerOnError) {
- IJavaModelStatus status =
- JavaConventions.validateClasspathEntry(this, containerRawEntry, false);
- if (!status.isOK())
- createClasspathProblemMarker(
- status.getMessage(),
- IMarker.SEVERITY_ERROR,
- false,
- false);
+ IJavaModelStatus containerStatus = JavaConventions.validateClasspathEntry(this, cEntry, false);
+ if (!containerStatus.isOK()) createClasspathProblemMarker(containerStatus);
}
- resolvedEntries.add(containerRawEntry);
+ // if container is exported, then its nested entries must in turn be exported (21749)
+ if (rawEntry.isExported()){
+ cEntry = new ClasspathEntry(cEntry.getContentKind(),
+ cEntry.getEntryKind(), cEntry.getPath(),
+ cEntry.getExclusionPatterns(), cEntry.getSourceAttachmentPath(),
+ cEntry.getSourceAttachmentRootPath(), cEntry.getOutputLocation(),
+ true); // duplicate container entry for tagging it as exported
+ }
+ if (reverseMap != null && reverseMap.get(resolvedPath = cEntry.getPath()) == null) reverseMap.put(resolvedPath, rawEntry);
+ resolvedEntries.add(cEntry);
}
break;
default :
+ if (reverseMap != null && reverseMap.get(resolvedPath = rawEntry.getPath()) == null) reverseMap.put(resolvedPath, rawEntry);
resolvedEntries.add(rawEntry);
}
@@ -1400,6 +1569,10 @@
IClasspathEntry[] resolvedPath = new IClasspathEntry[resolvedEntries.size()];
resolvedEntries.toArray(resolvedPath);
+ if (generateMarkerOnError && projectOutputLocation != null) {
+ status = JavaConventions.validateClasspath(this, resolvedPath, projectOutputLocation);
+ if (!status.isOK()) createClasspathProblemMarker(status);
+ }
return resolvedPath;
}
@@ -1429,13 +1602,12 @@
* which form of storage to use appropriately. Shared properties produce real resource files which
* can be shared through a VCM onto a server. Persistent properties are not shareable.
*
- * @see JavaProject#setSharedProperty(QualifiedName, String)
+ * @see JavaProject#setSharedProperty(String, String)
*/
- public String getSharedProperty(QualifiedName key) throws CoreException {
+ public String getSharedProperty(String key) throws CoreException {
String property = null;
- String propertyFileName = computeSharedPropertyFileName(key);
- IFile rscFile = getProject().getFile(propertyFileName);
+ IFile rscFile = getProject().getFile(key);
if (rscFile.exists()) {
property = new String(Util.getResourceContentsAsByteArray(rscFile));
}
@@ -1454,7 +1626,7 @@
* @see IJavaElement
*/
public IResource getUnderlyingResource() throws JavaModelException {
-
+ if (!exists()) throw newNotPresentException();
return getProject();
}
@@ -1469,37 +1641,57 @@
/**
* @see IJavaProject
*/
- public boolean hasClasspathCycle(IClasspathEntry[] entries) {
-
- HashSet cycleParticipants = new HashSet();
- updateCycleParticipants(entries, new ArrayList(), cycleParticipants, getWorkspace().getRoot());
- return !cycleParticipants.isEmpty();
+ public boolean hasClasspathCycle(IClasspathEntry[] preferredClasspath) {
+ HashSet visited = new HashSet();
+ visited.add(getElementName());
+ return hasClasspathCycle(preferredClasspath, visited, ResourcesPlugin.getWorkspace().getRoot());
}
- public boolean hasCycleMarker(){
-
+ private boolean hasClasspathCycle(IClasspathEntry[] preferredClasspath, HashSet visited, IWorkspaceRoot workspaceRoot) {
try {
- IProject project = getProject();
- if (project.exists()) {
- IMarker[] markers = project.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ONE);
- for (int i = 0, length = markers.length; i < length; i++) {
- IMarker marker = markers[i];
- String cycleAttr = (String)marker.getAttribute(IJavaModelMarker.CYCLE_DETECTED);
- if (cycleAttr != null && cycleAttr.equals("true")){ //$NON-NLS-1$
- return true;
+ IClasspathEntry[] classpath = preferredClasspath == null ? getResolvedClasspath(true) : preferredClasspath;
+
+ for (int i = 0, length = classpath.length; i < length; i++) {
+ IClasspathEntry entry;
+ if ((entry = classpath[i]).getEntryKind() == IClasspathEntry.CPE_PROJECT){
+ IPath entryPath = entry.getPath();
+ IResource member = workspaceRoot.findMember(entryPath);
+ if (member != null && member.getType() == IResource.PROJECT){
+ String projectName = entryPath.lastSegment();
+ if (!visited.add(projectName)) return true;
+ JavaProject project = (JavaProject)JavaCore.create((IProject)member);
+ if (project.hasClasspathCycle(null, visited, workspaceRoot)) return true;
+ visited.remove(projectName);
}
}
}
- } catch (CoreException e) {
+ } catch(JavaModelException e){
}
return false;
}
+
+ public boolean hasCycleMarker(){
+ return this.getCycleMarker() != null;
+ }
public int hashCode() {
return fProject.hashCode();
}
/**
+ * Returns true if the given project is accessible and it has
+ * a java nature, otherwise false.
+ */
+ public static boolean hasJavaNature(IProject project) {
+ try {
+ return project.hasNature(JavaCore.NATURE_ID);
+ } catch (CoreException e) {
+ // project does not exist or is not open
+ }
+ return false;
+ }
+
+ /**
* Answers true if the project potentially contains any source. A project which has no source is immutable.
*/
public boolean hasSource() {
@@ -1539,44 +1731,100 @@
return false;
}
// compare binary outputs
- if (otherClasspathWithOutput[length - 1].getContentKind()
- == ClasspathEntry.K_OUTPUT
- && otherClasspathWithOutput[length - 1].getPath().equals(newOutputLocation))
+ IClasspathEntry output = otherClasspathWithOutput[length - 1];
+ if (output.getContentKind() == ClasspathEntry.K_OUTPUT
+ && output.getPath().equals(newOutputLocation))
return true;
}
}
return false;
}
+
+
/*
* @see IJavaProject
*/
- public boolean isOnClasspath(IJavaElement element) throws JavaModelException {
- IPath rootPath;
- if (element.getElementType() == IJavaElement.JAVA_PROJECT) {
- rootPath = ((IJavaProject)element).getProject().getFullPath();
- } else {
- IPackageFragmentRoot root = (IPackageFragmentRoot)element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
- if (root == null) {
- return false;
- }
- rootPath = root.getPath();
+ public boolean isOnClasspath(IJavaElement element) {
+ IPath path = element.getPath();
+ switch (element.getElementType()) {
+ case IJavaElement.PACKAGE_FRAGMENT_ROOT:
+ if (!((IPackageFragmentRoot)element).isArchive()) {
+ // ensure that folders are only excluded if all of their children are excluded
+ path = path.append("*"); //$NON-NLS-1$
+ }
+ break;
+ case IJavaElement.PACKAGE_FRAGMENT:
+ if (!((IPackageFragmentRoot)element.getParent()).isArchive()) {
+ // ensure that folders are only excluded if all of their children are excluded
+ path = path.append("*"); //$NON-NLS-1$
+ }
+ break;
}
- return this.findPackageFragmentRoot0(rootPath) != null;
+ return this.isOnClasspath(path);
}
-
- /**
- * load the classpath from a shareable format (VCM-wise)
- */
- public String loadClasspath() throws JavaModelException {
-
+ private boolean isOnClasspath(IPath path) {
+ IClasspathEntry[] classpath;
try {
- return getSharedProperty(getClasspathPropertyName());
- } catch (CoreException e) {
- throw new JavaModelException(e);
+ classpath = this.getResolvedClasspath(true/*ignore unresolved variable*/);
+ } catch(JavaModelException e){
+ return false; // not a Java project
}
+ for (int i = 0; i < classpath.length; i++) {
+ IClasspathEntry entry = classpath[i];
+ if (entry.getPath().isPrefixOf(path)
+ && !Util.isExcluded(path, ((ClasspathEntry)entry).fullExclusionPatternChars())) {
+ return true;
+ }
+ }
+ return false;
+ }
+ /*
+ * @see IJavaProject
+ */
+ public boolean isOnClasspath(IResource resource) {
+ IPath path = resource.getFullPath();
+
+ // ensure that folders are only excluded if all of their children are excluded
+ if (resource.getType() == IResource.FOLDER) {
+ path = path.append("*"); //$NON-NLS-1$
+ }
+
+ return this.isOnClasspath(path);
}
+
+ /*
+ * load preferences from a shareable format (VCM-wise)
+ */
+ public Preferences loadPreferences() {
+
+ Preferences preferences = new Preferences();
+
+// File prefFile = getProject().getLocation().append(PREF_FILENAME).toFile();
+ IPath projectMetaLocation = getProject().getPluginWorkingLocation(JavaCore.getPlugin().getDescriptor());
+ if (projectMetaLocation != null) {
+ File prefFile = projectMetaLocation.append(PREF_FILENAME).toFile();
+ if (prefFile.exists()) { // load preferences from file
+ InputStream in = null;
+ try {
+ in = new BufferedInputStream(new FileInputStream(prefFile));
+ preferences.load(in);
+ return preferences;
+ } catch (IOException e) { // problems loading preference store - quietly ignore
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) { // ignore problems with close
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
/**
* @see IJavaProject#newEvaluationContext
*/
@@ -1640,7 +1888,7 @@
ArrayList prerequisites = new ArrayList();
// need resolution
- entries = getResolvedClasspath(entries, true, false);
+ entries = getResolvedClasspath(entries, null, true, false, null/*no reverse map*/);
for (int i = 0, length = entries.length; i < length; i++) {
IClasspathEntry entry = entries[i];
if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
@@ -1657,131 +1905,32 @@
}
}
- /**
- * Returns a collection of <code>IClasspathEntry</code>s from the given
- * classpath string in XML format.
- *
- * @exception IOException if the stream cannot be read
- */
- protected IClasspathEntry[] readPaths(String xmlClasspath) throws IOException {
- IPath projectPath = getProject().getFullPath();
- StringReader reader = new StringReader(xmlClasspath);
- Element cpElement;
+ /**
+ * Reads the .classpath file from disk and returns the list of entries it contains (including output location entry)
+ * Returns null if .classfile is not present.
+ * Returns INVALID_CLASSPATH if it has a format problem.
+ */
+ protected IClasspathEntry[] readClasspathFile(boolean createMarker, boolean logProblems) {
try {
- DocumentBuilder parser =
- DocumentBuilderFactory.newInstance().newDocumentBuilder();
- cpElement = parser.parse(new InputSource(reader)).getDocumentElement();
- } catch (SAXException e) {
- throw new IOException(Util.bind("file.badFormat")); //$NON-NLS-1$
- } catch (ParserConfigurationException e) {
- reader.close();
- throw new IOException(Util.bind("file.badFormat")); //$NON-NLS-1$
- } finally {
- reader.close();
- }
-
- if (!cpElement.getNodeName().equalsIgnoreCase("classpath")) { //$NON-NLS-1$
- throw new IOException(Util.bind("file.badFormat")); //$NON-NLS-1$
- }
- NodeList list = cpElement.getChildNodes();
- ArrayList paths = new ArrayList();
- int length = list.getLength();
-
- for (int i = 0; i < length; ++i) {
- Node node = list.item(i);
- short type = node.getNodeType();
- if (type == Node.ELEMENT_NODE) {
- Element cpeElement = (Element) node;
-
- if (cpeElement.getNodeName().equalsIgnoreCase("classpathentry")) { //$NON-NLS-1$
- String cpeElementKind = cpeElement.getAttribute("kind"); //$NON-NLS-1$
- String pathStr = cpeElement.getAttribute("path"); //$NON-NLS-1$
- // ensure path is absolute
- IPath path = new Path(pathStr);
- int kind = kindFromString(cpeElementKind);
- if (kind != IClasspathEntry.CPE_VARIABLE && kind != IClasspathEntry.CPE_CONTAINER && !path.isAbsolute()) {
- path = projectPath.append(path);
- }
- // source attachment info (optional)
- String sourceAttachmentPathStr = cpeElement.getAttribute("sourcepath"); //$NON-NLS-1$
- IPath sourceAttachmentPath =
- sourceAttachmentPathStr.equals("") ? null : new Path(sourceAttachmentPathStr); //$NON-NLS-1$
- String sourceAttachmentRootPathStr = cpeElement.getAttribute("rootpath"); //$NON-NLS-1$
- IPath sourceAttachmentRootPath =
- sourceAttachmentRootPathStr.equals("") //$NON-NLS-1$
- ? null
- : new Path(sourceAttachmentRootPathStr);
-
- // exported flag
- boolean isExported = cpeElement.getAttribute("exported").equals("true"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // recreate the CP entry
- switch (kind) {
-
- case IClasspathEntry.CPE_PROJECT :
- if (!path.isAbsolute()) return null;
- paths.add(JavaCore.newProjectEntry(path, isExported));
- break;
-
- case IClasspathEntry.CPE_LIBRARY :
- if (!path.isAbsolute()) return null;
- paths.add(JavaCore.newLibraryEntry(
- path,
- sourceAttachmentPath,
- sourceAttachmentRootPath,
- isExported));
- break;
-
- case IClasspathEntry.CPE_SOURCE :
- if (!path.isAbsolute()) return null;
- // must be an entry in this project or specify another project
- String projSegment = path.segment(0);
- if (projSegment != null && projSegment.equals(getElementName())) {
- // this project
- paths.add(JavaCore.newSourceEntry(path));
- } else {
- // another project
- paths.add(JavaCore.newProjectEntry(path, isExported));
- }
- break;
-
- case IClasspathEntry.CPE_VARIABLE :
- paths.add(JavaCore.newVariableEntry(
- path,
- sourceAttachmentPath,
- sourceAttachmentRootPath,
- isExported));
- break;
-
- case IClasspathEntry.CPE_CONTAINER :
- paths.add(JavaCore.newContainerEntry(
- path,
- isExported));
- break;
-
- case ClasspathEntry.K_OUTPUT :
- if (!path.isAbsolute()) return null;
- paths.add(new ClasspathEntry(
- ClasspathEntry.K_OUTPUT,
- IClasspathEntry.CPE_LIBRARY,
- path,
- null,
- null,
- false));
- break;
- }
- }
+ String xmlClasspath = getSharedProperty(CLASSPATH_FILENAME);
+ if (xmlClasspath == null) return null;
+ return decodeClasspath(xmlClasspath, createMarker, logProblems);
+ } catch(CoreException e) {
+ // file does not exist (or not accessible)
+ if (createMarker && this.getProject().isAccessible()) {
+ this.createClasspathProblemMarker(new JavaModelStatus(
+ IJavaModelStatusConstants.INVALID_CLASSPATH_FILE_FORMAT,
+ Util.bind("classpath.cannotReadClasspathFile", this.getElementName()))); //$NON-NLS-1$
+ }
+ if (logProblems) {
+ Util.log(e,
+ "Exception while retrieving "+ this.getPath() //$NON-NLS-1$
+ +"/.classpath, will revert to default classpath"); //$NON-NLS-1$
}
}
- if (paths.size() > 0) {
- IClasspathEntry[] ips = new IClasspathEntry[paths.size()];
- paths.toArray(ips);
- return ips;
- } else {
- return null;
- }
+ return null;
}
/**
@@ -1803,6 +1952,7 @@
}
}
+
/**
* @see JavaElement#rootedAt(IJavaProject)
*/
@@ -1830,28 +1980,15 @@
if (!getProject().exists()) return false;
- QualifiedName classpathProp = getClasspathPropertyName();
-
- try {
- // attempt to prove the classpath has not change
- String fileClasspathString = getSharedProperty(classpathProp);
- if (fileClasspathString != null) {
- IClasspathEntry[] fileEntries = readPaths(fileClasspathString);
- if (isClasspathEqualsTo(newClasspath, newOutputLocation, fileEntries)) {
- // no need to save it, it is the same
- return false;
- }
- }
- } catch (IOException e) {
- } catch (RuntimeException e) {
- } catch (CoreException e) {
+ IClasspathEntry[] fileEntries = readClasspathFile(false /*don't create markers*/, false/*don't log problems*/);
+ if (fileEntries != null && isClasspathEqualsTo(newClasspath, newOutputLocation, fileEntries)) {
+ // no need to save it, it is the same
+ return false;
}
// actual file saving
try {
- setSharedProperty(
- classpathProp,
- getClasspathAsXML(newClasspath, newOutputLocation));
+ setSharedProperty(CLASSPATH_FILENAME, encodeClasspath(newClasspath, newOutputLocation, true));
return true;
} catch (CoreException e) {
throw new JavaModelException(e);
@@ -1859,6 +1996,51 @@
}
/**
+ * Save project custom preferences to shareable file (.jprefs)
+ */
+ private void savePreferences(Preferences preferences) {
+
+ IProject project = getProject();
+ if (!JavaProject.hasJavaNature(project)) return; // ignore
+
+ if (preferences == null || (!preferences.needsSaving() && preferences.propertyNames().length != 0)) {
+ // nothing to save
+ return;
+ }
+
+ // preferences need to be saved
+ // the preferences file is located in the plug-in's state area
+ // at a well-known name (.jprefs)
+// File prefFile = getProject().getLocation().append(PREF_FILENAME).toFile();
+ File prefFile = project.getPluginWorkingLocation(JavaCore.getPlugin().getDescriptor()).append(PREF_FILENAME).toFile();
+ if (preferences.propertyNames().length == 0) {
+ // there are no preference settings
+ // rather than write an empty file, just delete any existing file
+ if (prefFile.exists()) {
+ prefFile.delete(); // don't worry if delete unsuccessful
+ }
+ return;
+ }
+
+ // write file, overwriting an existing one
+ OutputStream out = null;
+ try {
+ // do it as carefully as we know how so that we don't lose/mangle
+ // the setting in times of stress
+ out = new BufferedOutputStream(new FileOutputStream(prefFile));
+ preferences.store(out, null);
+ } catch (IOException e) { // problems saving preference store - quietly ignore
+ } finally {
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException e) { // ignore problems with close
+ }
+ }
+ }
+ }
+
+ /**
* Update the Java command in the build spec (replace existing one if present,
* add one first if none).
*/
@@ -1892,18 +2074,51 @@
}
/**
+ * @see org.eclipse.jdt.core.IJavaProject#setOptions(Map)
+ */
+ public void setOptions(Map newOptions) {
+
+ Preferences preferences;
+ setPreferences(preferences = new Preferences()); // always reset (26255)
+ if (newOptions != null){
+ Iterator keys = newOptions.keySet().iterator();
+ while (keys.hasNext()){
+ String key = (String)keys.next();
+ if (!JavaModelManager.OptionNames.contains(key)) continue; // unrecognized option
+ // no filtering for encoding (custom encoding for project is allowed)
+ String value = (String)newOptions.get(key);
+ preferences.setDefault(key, CUSTOM_DEFAULT_OPTION_VALUE); // empty string isn't the default (26251)
+ preferences.setValue(key, value);
+ }
+ }
+
+ // persist options
+ savePreferences(preferences);
+ }
+
+ /**
* @see IJavaProject
*/
- public void setOutputLocation(IPath outputLocation, IProgressMonitor monitor)
+ public void setOutputLocation(IPath path, IProgressMonitor monitor)
throws JavaModelException {
- if (outputLocation == null) {
+ if (path == null) {
throw new IllegalArgumentException(Util.bind("path.nullpath")); //$NON-NLS-1$
}
- if (outputLocation.equals(getOutputLocation())) {
+ if (path.equals(getOutputLocation())) {
return;
}
- this.setRawClasspath(SetClasspathOperation.ReuseClasspath, outputLocation, monitor);
+ this.setRawClasspath(SetClasspathOperation.ReuseClasspath, path, monitor);
+ }
+
+ /*
+ * Set cached preferences, no preference file is saved, only info is updated
+ */
+ public void setPreferences(Preferences preferences) {
+ IProject project = getProject();
+ if (!JavaProject.hasJavaNature(project)) return; // ignore
+ JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfo(project, true);
+ perProjectInfo.preferences = preferences;
}
/**
@@ -1933,11 +2148,10 @@
entries,
outputLocation,
monitor,
- true, // canChangeResource
- true, // forceSave
+ true, // canChangeResource (as per API contract)
getResolvedClasspath(true), // ignoreUnresolvedVariable
- true, // needCycleCheck
- true); // needValidation
+ true, // needValidation
+ true); // need to save
}
public void setRawClasspath(
@@ -1945,10 +2159,9 @@
IPath newOutputLocation,
IProgressMonitor monitor,
boolean canChangeResource,
- boolean forceSave,
IClasspathEntry[] oldResolvedPath,
- boolean needCycleCheck,
- boolean needValidation)
+ boolean needValidation,
+ boolean needSave)
throws JavaModelException {
JavaModelManager manager =
@@ -1965,9 +2178,8 @@
newRawPath,
newOutputLocation,
canChangeResource,
- forceSave,
- needCycleCheck,
- needValidation);
+ needValidation,
+ needSave);
runOperation(op, monitor);
} catch (JavaModelException e) {
@@ -1988,11 +2200,10 @@
entries,
SetClasspathOperation.ReuseOutputLocation,
monitor,
- true, // canChangeResource
- true, // forceSave
+ true, // canChangeResource (as per API contract)
getResolvedClasspath(true), // ignoreUnresolvedVariable
- true, // needCycleCheck
- true); // needValidation
+ true, // needValidation
+ true); // need to save
}
/**
@@ -2004,20 +2215,16 @@
protected void setRawClasspath0(IClasspathEntry[] rawEntries)
throws JavaModelException {
- // if not open, will cause opening with default path
- JavaProjectElementInfo info = getJavaProjectElementInfo();
+ JavaModelManager.PerProjectInfo info = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(fProject);
synchronized (info) {
- if (rawEntries == null) {
- rawEntries = defaultClasspath();
+ if (rawEntries != null) {
+ info.classpath = rawEntries;
}
+
// clear cache of resolved classpath
info.lastResolvedClasspath = null;
-
- info.setRawClasspath(rawEntries);
-
- // compute the new roots
- updatePackageFragmentRoots();
+ info.resolvedPathToRawEntries = null;
}
}
@@ -2030,16 +2237,18 @@
* shared properties end up in resource files, and thus cannot be modified during
* delta notifications (a CoreException would then be thrown).
*
- * @see JavaProject#getSharedProperty(QualifiedName key)
+ * @see JavaProject#getSharedProperty(String key)
*/
- public void setSharedProperty(QualifiedName key, String value)
- throws CoreException {
+ public void setSharedProperty(String key, String value) throws CoreException {
- String propertyName = computeSharedPropertyFileName(key);
- IFile rscFile = getProject().getFile(propertyName);
+ IFile rscFile = getProject().getFile(key);
InputStream inputStream = new ByteArrayInputStream(value.getBytes());
// update the resource content
if (rscFile.exists()) {
+ if (rscFile.isReadOnly()) {
+ // provide opportunity to checkout read-only .classpath file (23984)
+ ResourcesPlugin.getWorkspace().validateEdit(new IFile[]{rscFile}, null);
+ }
rscFile.setContents(inputStream, IResource.FORCE, null);
} else {
rscFile.create(inputStream, IResource.FORCE, null);
@@ -2056,8 +2265,14 @@
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
HashSet cycleParticipants = new HashSet();
- ArrayList visited = new ArrayList();
int length = projects.length;
+
+ /* alternate implementation for cycle participants computation
+ computeCycleParticipants(projects, cycleParticipants);
+ */
+
+ // compute cycle participants
+ ArrayList visited = new ArrayList();
for (int i = 0; i < length; i++){
JavaProject project = (JavaProject)projects[i];
if (!cycleParticipants.contains(project)){
@@ -2065,62 +2280,68 @@
project.updateCycleParticipants(null, visited, cycleParticipants, workspaceRoot);
}
}
-
+
for (int i = 0; i < length; i++){
JavaProject project = (JavaProject)projects[i];
if (cycleParticipants.contains(project)){
- if (!project.hasCycleMarker()){
+ IMarker cycleMarker = project.getCycleMarker();
+ String circularCPOption = project.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true);
+ int circularCPSeverity = JavaCore.ERROR.equals(circularCPOption) ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING;
+ if (cycleMarker != null) {
+ // update existing cycle marker if needed
+ try {
+ int existingSeverity = ((Integer)cycleMarker.getAttribute(IMarker.SEVERITY)).intValue();
+ if (existingSeverity != circularCPSeverity) {
+ cycleMarker.setAttribute(IMarker.SEVERITY, circularCPSeverity);
+ }
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+ } else {
+ // create new marker
project.createClasspathProblemMarker(
- Util.bind("classpath.cycle"), //$NON-NLS-1$
- IMarker.SEVERITY_ERROR,
- true,
- false);
+ new JavaModelStatus(IJavaModelStatusConstants.CLASSPATH_CYCLE, project));
}
} else {
project.flushClasspathProblemMarkers(true, false);
}
}
}
-
+
/**
* If a cycle is detected, then cycleParticipants contains all the project involved in this cycle (directly),
* no cycle if the set is empty (and started empty)
*/
public void updateCycleParticipants(IClasspathEntry[] preferredClasspath, ArrayList visited, HashSet cycleParticipants, IWorkspaceRoot workspaceRoot){
-
- int index = visited.indexOf(this);
- if (index >= 0){
- // only consider direct participants inside the cycle
- for (int i = index, size = visited.size(); i < size; i++){
- cycleParticipants.add(visited.get(i));
- }
- return;
- } else {
- visited.add(this);
- }
-
+ visited.add(this);
try {
- IClasspathEntry[] classpath;
- if (preferredClasspath == null) {
- classpath = getResolvedClasspath(true);
- } else {
- classpath = preferredClasspath;
- }
+ IClasspathEntry[] classpath = preferredClasspath == null ? getResolvedClasspath(true) : preferredClasspath;
for (int i = 0, length = classpath.length; i < length; i++) {
IClasspathEntry entry = classpath[i];
if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT){
- String projectName = entry.getPath().lastSegment();
- JavaProject project = (JavaProject)JavaCore.create(workspaceRoot.getProject(projectName));
- project.updateCycleParticipants(null, visited, cycleParticipants, workspaceRoot);
+ IPath entryPath = entry.getPath();
+ IResource member = workspaceRoot.findMember(entryPath);
+ if (member != null && member.getType() == IResource.PROJECT){
+ JavaProject project = (JavaProject)JavaCore.create((IProject)member);
+ int index = visited.indexOf(project);
+ if (index == -1 && cycleParticipants.contains(project))
+ index = visited.indexOf(this); // another loop in the cycle exists
+ if (index >= 0) { // only consider direct participants inside the cycle
+ for (int size = visited.size(); index < size; index++)
+ cycleParticipants.add(visited.get(index));
+ } else {
+ project.updateCycleParticipants(null, visited, cycleParticipants, workspaceRoot);
+ }
+ }
}
}
} catch(JavaModelException e){
}
visited.remove(this);
}
-
+
/**
* Reset the collection of package fragment roots (local ones) - only if opened.
* Need to check *all* package fragment roots in order to reset NameLookup
@@ -2160,4 +2381,6 @@
}
}
}
-}
\ No newline at end of file
+
+
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java
index b46e96f..be86c50 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.resources.IContainer;
@@ -31,11 +31,6 @@
class JavaProjectElementInfo extends OpenableElementInfo {
/**
- * The classpath for this project
- */
- protected IClasspathEntry[] fClasspath;
-
- /**
* The name lookup facility to use with this project.
*/
protected NameLookup fNameLookup = null;
@@ -47,17 +42,10 @@
protected SearchableEnvironment fSearchableEnvironment = null;
/**
- * The output location for this project.
- */
- protected IPath fOutputLocation = null;
-
- /**
* A array with all the non-java resources contained by this PackageFragment
*/
private Object[] fNonJavaResources;
- public IClasspathEntry[] lastResolvedClasspath = null;
-
/**
* Create and initialize a new instance of the receiver
*/
@@ -74,16 +62,21 @@
IPath projectPath = project.getProject().getFullPath();
boolean srcIsProject = false;
boolean binIsProject = false;
+ char[][] exclusionPatterns = null;
+ IClasspathEntry[] classpath = null;
+ IPath projectOutput = null;
try {
- IClasspathEntry[] classpath = project.getExpandedClasspath(true);
+ classpath = project.getResolvedClasspath(true/*ignore unresolved variable*/);
for (int i = 0; i < classpath.length; i++) {
IClasspathEntry entry = classpath[i];
if (projectPath.equals(entry.getPath())) {
srcIsProject = true;
+ exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars();
break;
}
}
- binIsProject = projectPath.equals(project.getOutputLocation());
+ projectOutput = project.getOutputLocation();
+ binIsProject = projectPath.equals(projectOutput);
} catch (JavaModelException e) {
// ignore
}
@@ -91,52 +84,59 @@
Object[] nonJavaResources = new IResource[5];
int nonJavaResourcesCounter = 0;
try {
- IResource[] members = ((IContainer) project.getUnderlyingResource()).members();
+ IResource[] members = ((IContainer) project.getResource()).members();
for (int i = 0, max = members.length; i < max; i++) {
IResource res = members[i];
switch (res.getType()) {
case IResource.FILE :
- // check if this file might be a jar or a zip inside the build path
IPath resFullPath = res.getFullPath();
- if (project.findPackageFragmentRoot0(resFullPath) == null) {
- String resName = res.getName();
- // ignore .java file if src == project
- if (srcIsProject && Util.isValidCompilationUnitName(resName)) {
- break;
- }
- // ignore .class file if bin == project
- if (binIsProject && Util.isValidClassFileName(resName)) {
- break;
- }
- // else add non java resource
- if (nonJavaResources.length == nonJavaResourcesCounter) {
- // resize
- System.arraycopy(
- nonJavaResources,
- 0,
- (nonJavaResources = new IResource[nonJavaResourcesCounter * 2]),
- 0,
- nonJavaResourcesCounter);
- }
- nonJavaResources[nonJavaResourcesCounter++] = res;
+ String resName = res.getName();
+
+ // ignore a jar file on the classpath
+ if (Util.isArchiveFileName(resName) && this.isClasspathEntryOrOutputLocation(resFullPath, classpath, projectOutput)) {
+ break;
}
+ // ignore .java file if src == project
+ if (srcIsProject
+ && Util.isValidCompilationUnitName(resName)
+ && !Util.isExcluded(res, exclusionPatterns)) {
+ break;
+ }
+ // ignore .class file if bin == project
+ if (binIsProject && Util.isValidClassFileName(resName)) {
+ break;
+ }
+ // else add non java resource
+ if (nonJavaResources.length == nonJavaResourcesCounter) {
+ // resize
+ System.arraycopy(
+ nonJavaResources,
+ 0,
+ (nonJavaResources = new IResource[nonJavaResourcesCounter * 2]),
+ 0,
+ nonJavaResourcesCounter);
+ }
+ nonJavaResources[nonJavaResourcesCounter++] = res;
break;
case IResource.FOLDER :
resFullPath = res.getFullPath();
- if (!resFullPath.equals(project.getOutputLocation())
- && project.findPackageFragmentRoot0(resFullPath) == null
- && project.findPackageFragment0(resFullPath) == null) {
- if (nonJavaResources.length == nonJavaResourcesCounter) {
- // resize
- System.arraycopy(
- nonJavaResources,
- 0,
- (nonJavaResources = new IResource[nonJavaResourcesCounter * 2]),
- 0,
- nonJavaResourcesCounter);
- }
- nonJavaResources[nonJavaResourcesCounter++] = res;
+
+ // ignore non-excluded folders on the classpath or that correspond to an output location
+ if ((srcIsProject && !Util.isExcluded(res, exclusionPatterns) && Util.isValidFolderNameForPackage(res.getName()))
+ || this.isClasspathEntryOrOutputLocation(resFullPath, classpath, projectOutput)) {
+ break;
}
+ // else add non java resource
+ if (nonJavaResources.length == nonJavaResourcesCounter) {
+ // resize
+ System.arraycopy(
+ nonJavaResources,
+ 0,
+ (nonJavaResources = new IResource[nonJavaResourcesCounter * 2]),
+ 0,
+ nonJavaResourcesCounter);
+ }
+ nonJavaResources[nonJavaResourcesCounter++] = res;
}
}
if (nonJavaResources.length != nonJavaResourcesCounter) {
@@ -176,28 +176,29 @@
}
/**
- * @see IJavaProject
- */
- protected IPath getOutputLocation() {
-
- return fOutputLocation;
- }
-
- /**
- * Returns the classpath for this project
- */
- protected IClasspathEntry[] getRawClasspath() {
-
- return fClasspath;
- }
-
- /**
* @see IJavaProject
*/
protected SearchableEnvironment getSearchableEnvironment() {
return fSearchableEnvironment;
}
+ /*
+ * Returns whether the given path is a classpath entry or an output location.
+ */
+ private boolean isClasspathEntryOrOutputLocation(IPath path, IClasspathEntry[] resolvedClasspath, IPath projectOutput) {
+ if (projectOutput.equals(path)) return true;
+ for (int i = 0, length = resolvedClasspath.length; i < length; i++) {
+ IClasspathEntry entry = resolvedClasspath[i];
+ if (entry.getPath().equals(path)) {
+ return true;
+ }
+ IPath output;
+ if ((output = entry.getOutputLocation()) != null && output.equals(path)) {
+ return true;
+ }
+ }
+ return false;
+ }
protected void setNameLookup(NameLookup newNameLookup) {
@@ -216,21 +217,8 @@
fNonJavaResources = resources;
}
- protected void setOutputLocation(IPath newOutputLocation) {
-
- fOutputLocation = newOutputLocation;
- }
- /**
- * Sets the classpath for this project
- */
-
- protected void setRawClasspath(IClasspathEntry[] newClasspath) {
-
- this.fClasspath = newClasspath;
- }
-
protected void setSearchableEnvironment(SearchableEnvironment newSearchableEnvironment) {
fSearchableEnvironment = newSearchableEnvironment;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LRUCacheEnumerator.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LRUCacheEnumerator.java
index 41e0de6..4a21e0f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LRUCacheEnumerator.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/LRUCacheEnumerator.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.Enumeration;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java
index db60d41..e9385db 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Member.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
@@ -81,8 +81,6 @@
return new Integer(constant.intValue());
case TypeIds.T_long :
return new Long(constant.longValue());
- case TypeIds.T_null :
- return null;
case TypeIds.T_short :
return new Short(constant.shortValue());
case TypeIds.T_String :
@@ -162,7 +160,7 @@
* @see IMember
*/
public ISourceRange getNameRange() throws JavaModelException {
- MemberElementInfo info= (MemberElementInfo)getRawInfo();
+ MemberElementInfo info= (MemberElementInfo)getElementInfo();
return new SourceRange(info.getNameSourceStart(), info.getNameSourceEnd() - info.getNameSourceStart() + 1);
}
/**
@@ -191,19 +189,6 @@
return getClassFile() != null;
}
/**
- * Changes the source indexes of this element. Updates the name range as well.
- */
-public void offsetSourceRange(int amount) {
- super.offsetSourceRange(amount);
- try {
- MemberElementInfo info = (MemberElementInfo) getRawInfo();
- info.setNameSourceStart(info.getNameSourceStart() + amount);
- info.setNameSourceEnd(info.getNameSourceEnd() + amount);
- } catch (JavaModelException npe) {
- return;
- }
-}
-/**
*/
public String readableName() {
@@ -219,25 +204,11 @@
}
}
/**
- * Updates the source positions for this element.
- */
-public void triggerSourceEndOffset(int amount, int nameStart, int nameEnd) {
- super.triggerSourceEndOffset(amount, nameStart, nameEnd);
- updateNameRange(nameStart, nameEnd);
-}
-/**
- * Updates the source positions for this element.
- */
-public void triggerSourceRangeOffset(int amount, int nameStart, int nameEnd) {
- super.triggerSourceRangeOffset(amount, nameStart, nameEnd);
- updateNameRange(nameStart, nameEnd);
-}
-/**
* Updates the name range for this element.
*/
protected void updateNameRange(int nameStart, int nameEnd) {
try {
- MemberElementInfo info = (MemberElementInfo) getRawInfo();
+ MemberElementInfo info = (MemberElementInfo) getElementInfo();
info.setNameSourceStart(nameStart);
info.setNameSourceEnd(nameEnd);
} catch (JavaModelException npe) {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MemberElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MemberElementInfo.java
index 6fe726c..75cc7d8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MemberElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MemberElementInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModelUpdater.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModelUpdater.java
index 5dcc8fe..3dd6944 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModelUpdater.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ModelUpdater.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
@@ -32,7 +32,7 @@
Openable parent = (Openable) child.getParent();
if (parent != null && parent.isOpen()) {
try {
- JavaElementInfo info = parent.getElementInfo();
+ JavaElementInfo info = (JavaElementInfo)parent.getElementInfo();
info.addChild(child);
} catch (JavaModelException e) {
// do nothing - we already checked if open
@@ -128,7 +128,7 @@
switch (elementType) {
case IJavaElement.JAVA_MODEL :
- element.getJavaModelManager().getIndexManager().reset();
+ JavaModelManager.getJavaModelManager().getIndexManager().reset();
break;
case IJavaElement.JAVA_PROJECT :
JavaModelManager.getJavaModelManager().removePerProjectInfo(
@@ -155,9 +155,9 @@
*/
public void processJavaDelta(IJavaElementDelta delta) {
- if (DeltaProcessor.VERBOSE){
- System.out.println("UPDATING Model with Delta: ["+Thread.currentThread()+":" + delta + "]:");//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- }
+// if (DeltaProcessor.VERBOSE){
+// System.out.println("UPDATING Model with Delta: ["+Thread.currentThread()+":" + delta + "]:");//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+// }
try {
this.traverseDelta(delta, null, null); // traverse delta
@@ -183,7 +183,7 @@
Openable parent = (Openable) child.getParent();
if (parent != null && parent.isOpen()) {
try {
- JavaElementInfo info = parent.getElementInfo();
+ JavaElementInfo info = (JavaElementInfo)parent.getElementInfo();
info.removeChild(child);
} catch (JavaModelException e) {
// do nothing - we already checked if open
@@ -214,6 +214,10 @@
root = (IPackageFragmentRoot) element;
break;
case IJavaElement.COMPILATION_UNIT :
+ // filter out working copies (we don't want to add/remove them to/from the package fragment
+ if (((IWorkingCopy)element).isWorkingCopy()) {
+ return;
+ }
case IJavaElement.CLASS_FILE :
processChildren = false;
break;
@@ -240,4 +244,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveElementsOperation.java
index b9e4c7f..dc008aa 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveElementsOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IJavaElement;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MovePackageFragmentRootOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MovePackageFragmentRootOperation.java
new file mode 100644
index 0000000..f2bfa13
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MovePackageFragmentRootOperation.java
@@ -0,0 +1,227 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.*;
+
+public class MovePackageFragmentRootOperation extends CopyPackageFragmentRootOperation {
+ /*
+ * Renames the classpath entries equal to the given path in the given project.
+ * If an entry with the destination path already existed, remove it.
+ */
+ protected void renameEntryInClasspath(IPath rootPath, IJavaProject project) throws JavaModelException {
+
+ IClasspathEntry[] classpath = project.getRawClasspath();
+ IClasspathEntry[] newClasspath = null;
+ int cpLength = classpath.length;
+ int newCPIndex = -1;
+
+ for (int i = 0; i < cpLength; i++) {
+ IClasspathEntry entry = classpath[i];
+ IPath entryPath = entry.getPath();
+ if (rootPath.equals(entryPath)) {
+ // rename entry
+ if (newClasspath == null) {
+ newClasspath = new IClasspathEntry[cpLength];
+ System.arraycopy(classpath, 0, newClasspath, 0, i);
+ newCPIndex = i;
+ }
+ newClasspath[newCPIndex++] = copy(entry);
+ } else if (this.destination.equals(entryPath)) {
+ // remove entry equals to destination
+ if (newClasspath == null) {
+ newClasspath = new IClasspathEntry[cpLength];
+ System.arraycopy(classpath, 0, newClasspath, 0, i);
+ newCPIndex = i;
+ }
+ } else if (newClasspath != null) {
+ newClasspath[newCPIndex++] = entry;
+ }
+ }
+
+ if (newClasspath != null) {
+ if (newCPIndex < newClasspath.length) {
+ System.arraycopy(newClasspath, 0, newClasspath = new IClasspathEntry[newCPIndex], 0, newCPIndex);
+ }
+ project.setRawClasspath(newClasspath, fMonitor);
+ }
+ }
+
+ public MovePackageFragmentRootOperation(
+ IPackageFragmentRoot root,
+ IPath destination,
+ int updateResourceFlags,
+ int updateModelFlags,
+ IClasspathEntry sibling) {
+
+ super(
+ root,
+ destination,
+ updateResourceFlags,
+ updateModelFlags,
+ sibling);
+ }
+ protected void executeOperation() throws JavaModelException {
+
+ IPackageFragmentRoot root = (IPackageFragmentRoot)this.getElementToProcess();
+ IClasspathEntry rootEntry = root.getRawClasspathEntry();
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+
+ // move resource
+ if (!root.isExternal() && (this.updateModelFlags & IPackageFragmentRoot.NO_RESOURCE_MODIFICATION) == 0) {
+ moveResource(root, rootEntry, workspaceRoot);
+ }
+
+ // update refering projects classpath excluding orignating project
+ IJavaProject originatingProject = root.getJavaProject();
+ if ((this.updateModelFlags & IPackageFragmentRoot.OTHER_REFERRING_PROJECTS_CLASSPATH) != 0) {
+ updateReferringProjectClasspaths(rootEntry.getPath(), originatingProject);
+ }
+
+ boolean isRename = this.destination.segment(0).equals(originatingProject.getElementName());
+ boolean updateOriginating = (this.updateModelFlags & IPackageFragmentRoot.ORIGINATING_PROJECT_CLASSPATH) != 0;
+ boolean updateDestination = (this.updateModelFlags & IPackageFragmentRoot.DESTINATION_PROJECT_CLASSPATH) != 0;
+
+ // update originating classpath
+ if (updateOriginating) {
+ if (isRename && updateDestination) {
+ renameEntryInClasspath(rootEntry.getPath(), originatingProject);
+ } else {
+ removeEntryFromClasspath(rootEntry.getPath(), originatingProject);
+ }
+ }
+
+ // update destination classpath
+ if (updateDestination) {
+ if (!isRename || !updateOriginating) {
+ addEntryToClasspath(rootEntry, workspaceRoot);
+ } // else reference has been updated when updating originating project classpath
+ }
+ }
+ protected void moveResource(
+ IPackageFragmentRoot root,
+ IClasspathEntry rootEntry,
+ final IWorkspaceRoot workspaceRoot)
+ throws JavaModelException {
+
+ final char[][] exclusionPatterns = ((ClasspathEntry)rootEntry).fullExclusionPatternChars();
+ IResource rootResource = root.getResource();
+ if (rootEntry.getEntryKind() != IClasspathEntry.CPE_SOURCE || exclusionPatterns == null) {
+ try {
+ IResource destRes;
+ if ((this.updateModelFlags & IPackageFragmentRoot.REPLACE) != 0
+ && (destRes = workspaceRoot.findMember(this.destination)) != null) {
+ destRes.delete(this.updateResourceFlags, fMonitor);
+ }
+ rootResource.move(this.destination, this.updateResourceFlags, fMonitor);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+ } else {
+ final int sourceSegmentCount = rootEntry.getPath().segmentCount();
+ final IFolder destFolder = workspaceRoot.getFolder(this.destination);
+ final IPath[] nestedFolders = getNestedFolders(root);
+ IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ if (proxy.getType() == IResource.FOLDER) {
+ IPath path = proxy.requestFullPath();
+ if (prefixesOneOf(path, nestedFolders)) {
+ if (equalsOneOf(path, nestedFolders)) {
+ // nested source folder
+ return false;
+ } else {
+ // folder containing nested source folder
+ IFolder folder = destFolder.getFolder(path.removeFirstSegments(sourceSegmentCount));
+ if ((updateModelFlags & IPackageFragmentRoot.REPLACE) != 0
+ && folder.exists()) {
+ return true;
+ }
+ folder.create(updateResourceFlags, true, fMonitor);
+ return true;
+ }
+ } else {
+ // subtree doesn't contain any nested source folders
+ IPath destPath = destination.append(path.removeFirstSegments(sourceSegmentCount));
+ IResource destRes;
+ if ((updateModelFlags & IPackageFragmentRoot.REPLACE) != 0
+ && (destRes = workspaceRoot.findMember(destPath)) != null) {
+ destRes.delete(updateResourceFlags, fMonitor);
+ }
+ proxy.requestResource().move(destPath, updateResourceFlags, fMonitor);
+ return false;
+ }
+ } else {
+ IPath path = proxy.requestFullPath();
+ IPath destPath = destination.append(path.removeFirstSegments(sourceSegmentCount));
+ IResource destRes;
+ if ((updateModelFlags & IPackageFragmentRoot.REPLACE) != 0
+ && (destRes = workspaceRoot.findMember(destPath)) != null) {
+ destRes.delete(updateResourceFlags, fMonitor);
+ }
+ proxy.requestResource().move(destPath, updateResourceFlags, fMonitor);
+ return false;
+ }
+ }
+ };
+ try {
+ rootResource.accept(visitor, IResource.NONE);
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+ }
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ }
+ /*
+ * Renames the classpath entries equal to the given path in all Java projects.
+ */
+ protected void updateReferringProjectClasspaths(IPath rootPath, IJavaProject projectOfRoot) throws JavaModelException {
+ IJavaModel model = this.getJavaModel();
+ IJavaProject[] projects = model.getJavaProjects();
+ for (int i = 0, length = projects.length; i < length; i++) {
+ IJavaProject project = projects[i];
+ if (project.equals(projectOfRoot)) continue;
+ renameEntryInClasspath(rootPath, project);
+ }
+ }
+ /*
+ * Removes the classpath entry equal to the given path from the given project's classpath.
+ */
+ protected void removeEntryFromClasspath(IPath rootPath, IJavaProject project) throws JavaModelException {
+
+ IClasspathEntry[] classpath = project.getRawClasspath();
+ IClasspathEntry[] newClasspath = null;
+ int cpLength = classpath.length;
+ int newCPIndex = -1;
+
+ for (int i = 0; i < cpLength; i++) {
+ IClasspathEntry entry = classpath[i];
+ if (rootPath.equals(entry.getPath())) {
+ if (newClasspath == null) {
+ newClasspath = new IClasspathEntry[cpLength];
+ System.arraycopy(classpath, 0, newClasspath, 0, i);
+ newCPIndex = i;
+ }
+ } else if (newClasspath != null) {
+ newClasspath[newCPIndex++] = entry;
+ }
+ }
+
+ if (newClasspath != null) {
+ if (newCPIndex < newClasspath.length) {
+ System.arraycopy(newClasspath, 0, newClasspath = new IClasspathEntry[newCPIndex], 0, newCPIndex);
+ }
+ project.setRawClasspath(newClasspath, fMonitor);
+ }
+ }
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveResourceElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveResourceElementsOperation.java
index e7be276..3bda54d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveResourceElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MoveResourceElementsOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IJavaElement;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MultiOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MultiOperation.java
index d5a640b..b1e6384 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MultiOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/MultiOperation.java
@@ -1,27 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.IJavaModelStatus;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.JavaConventions;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.*;
/**
* This class is used to perform operations on multiple <code>IJavaElement</code>.
@@ -56,279 +49,252 @@
* convenient way.
*/
protected Map fRenamings;
-/**
- * Creates a new <code>MultiOperation</code>.
- */
-protected MultiOperation(IJavaElement[] elementsToProcess, IJavaElement[] parentElements, boolean force) {
- super(elementsToProcess, parentElements, force);
- fParentElements = new HashMap(elementsToProcess.length);
- if (elementsToProcess.length == parentElements.length) {
- for (int i = 0; i < elementsToProcess.length; i++) {
- fParentElements.put(elementsToProcess[i], parentElements[i]);
- }
- } else { //same destination for all elements to be moved/copied/renamed
- for (int i = 0; i < elementsToProcess.length; i++) {
- fParentElements.put(elementsToProcess[i], parentElements[0]);
- }
- }
-
-}
-/**
- * Creates a new <code>MultiOperation</code> on <code>elementsToProcess</code>.
- */
-protected MultiOperation(IJavaElement[] elementsToProcess, boolean force) {
- super(elementsToProcess, force);
-}
-/**
- * Convenience method to create a <code>JavaModelException</code>
- * embending a <code>JavaModelStatus</code>.
- */
-protected void error(int code, IJavaElement element) throws JavaModelException {
- throw new JavaModelException(new JavaModelStatus(code, element));
-}
-/**
- * Executes the operation.
- *
- * @exception JavaModelException if one or several errors occured during the operation.
- * If multiple errors occured, the corresponding <code>JavaModelStatus</code> is a
- * multi-status. Otherwise, it is a simple one.
- */
-protected void executeOperation() throws JavaModelException {
- try {
- processElements();
- } catch (JavaModelException jme) {
- throw jme;
- } finally {
- mergeDeltas();
- }
-}
-/**
- * Returns the parent of the element being copied/moved/renamed.
- */
-protected IJavaElement getDestinationParent(IJavaElement child) {
- return (IJavaElement)fParentElements.get(child);
-}
-/**
- * Returns the name to be used by the progress monitor.
- */
-protected abstract String getMainTaskName();
-/**
- * Returns the new name for <code>element</code>, or <code>null</code>
- * if there are no renamings specified.
- */
-protected String getNewNameFor(IJavaElement element) {
- if (fRenamings != null)
- return (String) fRenamings.get(element);
- else
- return null;
-}
-/**
- * Sets up the renamings hashtable - keys are the elements and
- * values are the new name.
- */
-private void initializeRenamings() {
- if (fRenamingsList != null && fRenamingsList.length == fElementsToProcess.length) {
- fRenamings = new HashMap(fRenamingsList.length);
- for (int i = 0; i < fRenamingsList.length; i++) {
- if (fRenamingsList[i] != null) {
- fRenamings.put(fElementsToProcess[i], fRenamingsList[i]);
+ /**
+ * Creates a new <code>MultiOperation</code>.
+ */
+ protected MultiOperation(IJavaElement[] elementsToProcess, IJavaElement[] parentElements, boolean force) {
+ super(elementsToProcess, parentElements, force);
+ fParentElements = new HashMap(elementsToProcess.length);
+ if (elementsToProcess.length == parentElements.length) {
+ for (int i = 0; i < elementsToProcess.length; i++) {
+ fParentElements.put(elementsToProcess[i], parentElements[i]);
+ }
+ } else { //same destination for all elements to be moved/copied/renamed
+ for (int i = 0; i < elementsToProcess.length; i++) {
+ fParentElements.put(elementsToProcess[i], parentElements[0]);
}
}
- }
-}
-/**
- * Returns <code>true</code> if this operation represents a move or rename, <code>false</code>
- * if this operation represents a copy.<br>
- * Note: a rename is just a move within the same parent with a name change.
- */
-protected boolean isMove() {
- return false;
-}
-/**
- * Returns <code>true</code> if this operation represents a rename, <code>false</code>
- * if this operation represents a copy or move.
- */
-protected boolean isRename() {
- return false;
-}
-/**
- * Process all of the changed deltas generated by these operations.
- */
-protected void mergeDeltas() {
- if (fDeltas != null) {
- JavaElementDelta rootDelta = newJavaElementDelta();
- boolean insertedTree = false;
- for (int i = 0; i < fDeltas.length; i++) {
- IJavaElementDelta delta = fDeltas[i];
- IJavaElementDelta[] children = delta.getAffectedChildren();
- for (int j = 0; j < children.length; j++) {
- JavaElementDelta projectDelta = (JavaElementDelta) children[j];
- rootDelta.insertDeltaTree(projectDelta.getElement(), projectDelta);
- insertedTree = true;
- }
- }
- if (insertedTree)
- fDeltas = new IJavaElementDelta[] {rootDelta};
- else
- fDeltas = null;
- }
-}
-/**
- * Subclasses must implement this method to process a given <code>IJavaElement</code>.
- */
-protected abstract void processElement(IJavaElement element) throws JavaModelException;
-/**
- * Processes all the <code>IJavaElement</code>s in turn, collecting errors
- * and updating the progress monitor.
- *
- * @exception JavaModelException if one or several operation(s) was unable to
- * be completed.
- */
-protected void processElements() throws JavaModelException {
- beginTask(getMainTaskName(), fElementsToProcess.length);
- IJavaModelStatus[] errors = new IJavaModelStatus[3];
- int errorsCounter = 0;
- for (int i = 0; i < fElementsToProcess.length; i++) {
- try {
- verify(fElementsToProcess[i]);
- processElement(fElementsToProcess[i]);
- } catch (JavaModelException jme) {
- if (errorsCounter == errors.length) {
- // resize
- System.arraycopy(errors, 0, (errors = new IJavaModelStatus[errorsCounter*2]), 0, errorsCounter);
- }
- errors[errorsCounter++] = jme.getJavaModelStatus();
- } finally {
- worked(1);
- }
- }
- done();
- if (errorsCounter == 1) {
- throw new JavaModelException(errors[0]);
- } else if (errorsCounter > 1) {
- if (errorsCounter != errors.length) {
- // resize
- System.arraycopy(errors, 0, (errors = new IJavaModelStatus[errorsCounter]), 0, errorsCounter);
- }
- throw new JavaModelException(JavaModelStatus.newMultiStatus(errors));
- }
-}
-/**
- * Sets the insertion position in the new container for the modified element. The element
- * being modified will be inserted before the specified new sibling. The given sibling
- * must be a child of the destination container specified for the modified element.
- * The default is <code>null</code>, which indicates that the element is to be
- * inserted at the end of the container.
- */
-public void setInsertBefore(IJavaElement modifiedElement, IJavaElement newSibling) {
- fInsertBeforeElements.put(modifiedElement, newSibling);
-}
-/**
- * Sets the new names to use for each element being copied. The renamings
- * correspond to the elements being processed, and the number of
- * renamings must match the number of elements being processed.
- * A <code>null</code> entry in the list indicates that an element
- * is not to be renamed.
- *
- * <p>Note that some renamings may not be used. If both a parent
- * and a child have been selected for copy/move, only the parent
- * is changed. Therefore, if a new name is specified for the child,
- * the child's name will not be changed.
- */
-public void setRenamings(String[] renamings) {
- fRenamingsList = renamings;
- initializeRenamings();
-}
-/**
- * This method is called for each <code>IJavaElement</code> before
- * <code>processElement</code>. It should check that this <code>element</code>
- * can be processed.
- */
-protected abstract void verify(IJavaElement element) throws JavaModelException;
-/**
- * Verifies that the <code>destination</code> specified for the <code>element</code> is valid for the types of the
- * <code>element</code> and <code>destination</code>.
- */
-protected void verifyDestination(IJavaElement element, IJavaElement destination) throws JavaModelException {
- if (destination == null || !destination.exists())
- error(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, destination);
- int destType = destination.getElementType();
- switch (element.getElementType()) {
- case IJavaElement.PACKAGE_DECLARATION :
- case IJavaElement.IMPORT_DECLARATION :
- if (destType != IJavaElement.COMPILATION_UNIT)
- error(IJavaModelStatusConstants.INVALID_DESTINATION, element);
- break;
- case IJavaElement.TYPE :
- if (destType != IJavaElement.COMPILATION_UNIT && destType != IJavaElement.TYPE)
- error(IJavaModelStatusConstants.INVALID_DESTINATION, element);
- break;
- case IJavaElement.METHOD :
- case IJavaElement.FIELD :
- case IJavaElement.INITIALIZER :
- if (destType != IJavaElement.TYPE || destination instanceof BinaryType)
- error(IJavaModelStatusConstants.INVALID_DESTINATION, element);
- break;
- case IJavaElement.COMPILATION_UNIT :
- if (destType != IJavaElement.PACKAGE_FRAGMENT)
- error(IJavaModelStatusConstants.INVALID_DESTINATION, element);
- else if (isMove() && ((ICompilationUnit) element).isWorkingCopy())
- error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
- break;
- case IJavaElement.PACKAGE_FRAGMENT :
- IPackageFragment fragment = (IPackageFragment) element;
- IJavaElement parent = fragment.getParent();
- if (parent.isReadOnly())
- error(IJavaModelStatusConstants.READ_ONLY, element);
- else if (destType != IJavaElement.PACKAGE_FRAGMENT_ROOT)
- error(IJavaModelStatusConstants.INVALID_DESTINATION, element);
- break;
- default :
- error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
}
-}
-/**
- * Verify that the new name specified for <code>element</code> is
- * valid for that type of Java element.
- */
-protected void verifyRenaming(IJavaElement element) throws JavaModelException {
- String newName = getNewNameFor(element);
- boolean isValid = true;
-
- switch (element.getElementType()) {
- case IJavaElement.PACKAGE_FRAGMENT :
- if (element.getElementName().equals(IPackageFragment.DEFAULT_PACKAGE_NAME)) {
- // don't allow renaming of default package (see PR #1G47GUM)
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION, element));
+ /**
+ * Creates a new <code>MultiOperation</code> on <code>elementsToProcess</code>.
+ */
+ protected MultiOperation(IJavaElement[] elementsToProcess, boolean force) {
+ super(elementsToProcess, force);
+ }
+ /**
+ * Convenience method to create a <code>JavaModelException</code>
+ * embending a <code>JavaModelStatus</code>.
+ */
+ protected void error(int code, IJavaElement element) throws JavaModelException {
+ throw new JavaModelException(new JavaModelStatus(code, element));
+ }
+ /**
+ * Executes the operation.
+ *
+ * @exception JavaModelException if one or several errors occured during the operation.
+ * If multiple errors occured, the corresponding <code>JavaModelStatus</code> is a
+ * multi-status. Otherwise, it is a simple one.
+ */
+ protected void executeOperation() throws JavaModelException {
+ processElements();
+ }
+ /**
+ * Returns the parent of the element being copied/moved/renamed.
+ */
+ protected IJavaElement getDestinationParent(IJavaElement child) {
+ return (IJavaElement)fParentElements.get(child);
+ }
+ /**
+ * Returns the name to be used by the progress monitor.
+ */
+ protected abstract String getMainTaskName();
+ /**
+ * Returns the new name for <code>element</code>, or <code>null</code>
+ * if there are no renamings specified.
+ */
+ protected String getNewNameFor(IJavaElement element) {
+ if (fRenamings != null)
+ return (String) fRenamings.get(element);
+ else
+ return null;
+ }
+ /**
+ * Sets up the renamings hashtable - keys are the elements and
+ * values are the new name.
+ */
+ private void initializeRenamings() {
+ if (fRenamingsList != null && fRenamingsList.length == fElementsToProcess.length) {
+ fRenamings = new HashMap(fRenamingsList.length);
+ for (int i = 0; i < fRenamingsList.length; i++) {
+ if (fRenamingsList[i] != null) {
+ fRenamings.put(fElementsToProcess[i], fRenamingsList[i]);
+ }
}
- isValid = JavaConventions.validatePackageName(newName).getSeverity() != IStatus.ERROR;
- break;
- case IJavaElement.COMPILATION_UNIT :
- isValid = JavaConventions.validateCompilationUnitName(newName).getSeverity() != IStatus.ERROR;
- break;
- case IJavaElement.INITIALIZER :
- isValid = false; //cannot rename initializers
- break;
- default :
- isValid = JavaConventions.validateIdentifier(newName).getSeverity() != IStatus.ERROR;
- break;
- }
-
- if (!isValid) {
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_NAME, element, newName));
- }
-}
-/**
- * Verifies that the positioning sibling specified for the <code>element</code> is exists and
- * its parent is the destination container of this <code>element</code>.
- */
-protected void verifySibling(IJavaElement element, IJavaElement destination) throws JavaModelException {
- IJavaElement insertBeforeElement = (IJavaElement) fInsertBeforeElements.get(element);
- if (insertBeforeElement != null) {
- if (!insertBeforeElement.exists() || !insertBeforeElement.getParent().equals(destination)) {
- error(IJavaModelStatusConstants.INVALID_SIBLING, insertBeforeElement);
}
}
-}
+ /**
+ * Returns <code>true</code> if this operation represents a move or rename, <code>false</code>
+ * if this operation represents a copy.<br>
+ * Note: a rename is just a move within the same parent with a name change.
+ */
+ protected boolean isMove() {
+ return false;
+ }
+ /**
+ * Returns <code>true</code> if this operation represents a rename, <code>false</code>
+ * if this operation represents a copy or move.
+ */
+ protected boolean isRename() {
+ return false;
+ }
+
+ /**
+ * Subclasses must implement this method to process a given <code>IJavaElement</code>.
+ */
+ protected abstract void processElement(IJavaElement element) throws JavaModelException;
+ /**
+ * Processes all the <code>IJavaElement</code>s in turn, collecting errors
+ * and updating the progress monitor.
+ *
+ * @exception JavaModelException if one or several operation(s) was unable to
+ * be completed.
+ */
+ protected void processElements() throws JavaModelException {
+ beginTask(getMainTaskName(), fElementsToProcess.length);
+ IJavaModelStatus[] errors = new IJavaModelStatus[3];
+ int errorsCounter = 0;
+ for (int i = 0; i < fElementsToProcess.length; i++) {
+ try {
+ verify(fElementsToProcess[i]);
+ processElement(fElementsToProcess[i]);
+ } catch (JavaModelException jme) {
+ if (errorsCounter == errors.length) {
+ // resize
+ System.arraycopy(errors, 0, (errors = new IJavaModelStatus[errorsCounter*2]), 0, errorsCounter);
+ }
+ errors[errorsCounter++] = jme.getJavaModelStatus();
+ } finally {
+ worked(1);
+ }
+ }
+ done();
+ if (errorsCounter == 1) {
+ throw new JavaModelException(errors[0]);
+ } else if (errorsCounter > 1) {
+ if (errorsCounter != errors.length) {
+ // resize
+ System.arraycopy(errors, 0, (errors = new IJavaModelStatus[errorsCounter]), 0, errorsCounter);
+ }
+ throw new JavaModelException(JavaModelStatus.newMultiStatus(errors));
+ }
+ }
+ /**
+ * Sets the insertion position in the new container for the modified element. The element
+ * being modified will be inserted before the specified new sibling. The given sibling
+ * must be a child of the destination container specified for the modified element.
+ * The default is <code>null</code>, which indicates that the element is to be
+ * inserted at the end of the container.
+ */
+ public void setInsertBefore(IJavaElement modifiedElement, IJavaElement newSibling) {
+ fInsertBeforeElements.put(modifiedElement, newSibling);
+ }
+ /**
+ * Sets the new names to use for each element being copied. The renamings
+ * correspond to the elements being processed, and the number of
+ * renamings must match the number of elements being processed.
+ * A <code>null</code> entry in the list indicates that an element
+ * is not to be renamed.
+ *
+ * <p>Note that some renamings may not be used. If both a parent
+ * and a child have been selected for copy/move, only the parent
+ * is changed. Therefore, if a new name is specified for the child,
+ * the child's name will not be changed.
+ */
+ public void setRenamings(String[] renamings) {
+ fRenamingsList = renamings;
+ initializeRenamings();
+ }
+ /**
+ * This method is called for each <code>IJavaElement</code> before
+ * <code>processElement</code>. It should check that this <code>element</code>
+ * can be processed.
+ */
+ protected abstract void verify(IJavaElement element) throws JavaModelException;
+ /**
+ * Verifies that the <code>destination</code> specified for the <code>element</code> is valid for the types of the
+ * <code>element</code> and <code>destination</code>.
+ */
+ protected void verifyDestination(IJavaElement element, IJavaElement destination) throws JavaModelException {
+ if (destination == null || !destination.exists())
+ error(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, destination);
+
+ int destType = destination.getElementType();
+ switch (element.getElementType()) {
+ case IJavaElement.PACKAGE_DECLARATION :
+ case IJavaElement.IMPORT_DECLARATION :
+ if (destType != IJavaElement.COMPILATION_UNIT)
+ error(IJavaModelStatusConstants.INVALID_DESTINATION, element);
+ break;
+ case IJavaElement.TYPE :
+ if (destType != IJavaElement.COMPILATION_UNIT && destType != IJavaElement.TYPE)
+ error(IJavaModelStatusConstants.INVALID_DESTINATION, element);
+ break;
+ case IJavaElement.METHOD :
+ case IJavaElement.FIELD :
+ case IJavaElement.INITIALIZER :
+ if (destType != IJavaElement.TYPE || destination instanceof BinaryType)
+ error(IJavaModelStatusConstants.INVALID_DESTINATION, element);
+ break;
+ case IJavaElement.COMPILATION_UNIT :
+ if (destType != IJavaElement.PACKAGE_FRAGMENT)
+ error(IJavaModelStatusConstants.INVALID_DESTINATION, element);
+ else if (isMove() && ((ICompilationUnit) element).isWorkingCopy())
+ error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
+ break;
+ case IJavaElement.PACKAGE_FRAGMENT :
+ IPackageFragment fragment = (IPackageFragment) element;
+ IJavaElement parent = fragment.getParent();
+ if (parent.isReadOnly())
+ error(IJavaModelStatusConstants.READ_ONLY, element);
+ else if (destType != IJavaElement.PACKAGE_FRAGMENT_ROOT)
+ error(IJavaModelStatusConstants.INVALID_DESTINATION, element);
+ break;
+ default :
+ error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element);
+ }
+ }
+ /**
+ * Verify that the new name specified for <code>element</code> is
+ * valid for that type of Java element.
+ */
+ protected void verifyRenaming(IJavaElement element) throws JavaModelException {
+ String newName = getNewNameFor(element);
+ boolean isValid = true;
+
+ switch (element.getElementType()) {
+ case IJavaElement.PACKAGE_FRAGMENT :
+ if (element.getElementName().equals(IPackageFragment.DEFAULT_PACKAGE_NAME)) {
+ // don't allow renaming of default package (see PR #1G47GUM)
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.NAME_COLLISION, element));
+ }
+ isValid = JavaConventions.validatePackageName(newName).getSeverity() != IStatus.ERROR;
+ break;
+ case IJavaElement.COMPILATION_UNIT :
+ isValid = JavaConventions.validateCompilationUnitName(newName).getSeverity() != IStatus.ERROR;
+ break;
+ case IJavaElement.INITIALIZER :
+ isValid = false; //cannot rename initializers
+ break;
+ default :
+ isValid = JavaConventions.validateIdentifier(newName).getSeverity() != IStatus.ERROR;
+ break;
+ }
+
+ if (!isValid) {
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_NAME, element, newName));
+ }
+ }
+ /**
+ * Verifies that the positioning sibling specified for the <code>element</code> is exists and
+ * its parent is the destination container of this <code>element</code>.
+ */
+ protected void verifySibling(IJavaElement element, IJavaElement destination) throws JavaModelException {
+ IJavaElement insertBeforeElement = (IJavaElement) fInsertBeforeElements.get(element);
+ if (insertBeforeElement != null) {
+ if (!insertBeforeElement.exists() || !insertBeforeElement.getParent().equals(destination)) {
+ error(IJavaModelStatusConstants.INVALID_SIBLING, insertBeforeElement);
+ }
+ }
+ }
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java
index 04bdfb6..a420167 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NameLookup.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.File;
@@ -17,6 +17,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IClasspathEntry;
@@ -123,7 +124,7 @@
* @throws JavaModelException if the <code>IJavaProject</code> has no classpath.
*/
private void configureFromProject(IJavaProject project) throws JavaModelException {
- workspace= project.getJavaModel().getWorkspace();
+ workspace= ResourcesPlugin.getWorkspace();
fPackageFragmentRoots= ((JavaProject) project).getAllPackageFragmentRoots();
fPackageFragments= new HashMap();
IPackageFragment[] frags = this.getPackageFragmentsInRoots(fPackageFragmentRoots, project);
@@ -273,7 +274,7 @@
IClasspathEntry entry = project.getClasspathEntryFor(path);
if (entry != null) {
IPackageFragmentRoot root =
- project.getPackageFragmentRoot(project.getUnderlyingResource());
+ project.getPackageFragmentRoot(project.getResource());
IPackageFragment[] pkgs = (IPackageFragment[]) fPackageFragments.get(IPackageFragment.DEFAULT_PACKAGE_NAME);
if (pkgs == null) {
return null;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NonVoidMethodRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NonVoidMethodRequestor.java
deleted file mode 100644
index f5e7ea2..0000000
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/NonVoidMethodRequestor.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.internal.core;
-
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.internal.codeassist.ISearchRequestor;
-
-/**
- * This class modifies the <code>SearchableEnvironmentRequestor</code>'s
- * functionality by only accepting methods with return types that are not void.
- */
-public class NonVoidMethodRequestor extends SearchableEnvironmentRequestor {
-/**
- * NonVoidMethodRequestor constructor comment.
- * @param requestor org.eclipse.jdt.internal.codeassist.ISearchRequestor
- */
-public NonVoidMethodRequestor(ISearchRequestor requestor) {
- super(requestor);
-}
-public void acceptMethod(IMethod method) {
- try {
- if (!Signature.getReturnType(method.getSignature()).equals("V")) { //$NON-NLS-1$
- super.acceptMethod(method);
- }
- } catch (JavaModelException npe) {
- }
-}
-}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java
index 5e16335..ab0b70c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Openable.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.Enumeration;
@@ -15,25 +15,14 @@
import java.util.Iterator;
import java.util.Map;
+import org.eclipse.core.resources.*;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.BufferChangedEvent;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.IBufferChangedListener;
-import org.eclipse.jdt.core.IBufferFactory;
-import org.eclipse.jdt.core.ICodeCompletionRequestor;
-import org.eclipse.jdt.core.ICompletionRequestor;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaModelMarker;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IOpenable;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.codeassist.CompletionEngine;
import org.eclipse.jdt.internal.codeassist.ISearchableNameEnvironment;
@@ -80,7 +69,7 @@
// remove existing (old) infos
removeInfo();
HashMap newElements = new HashMap(11);
- info.setIsStructureKnown(generateInfos(info, monitor, newElements, getUnderlyingResource()));
+ info.setIsStructureKnown(generateInfos(info, monitor, newElements, getResource()));
JavaModelManager.getJavaModelManager().getElementsOutOfSynchWithBuffers().remove(this);
for (Iterator iter = newElements.keySet().iterator(); iter.hasNext();) {
IJavaElement key = (IJavaElement) iter.next();
@@ -127,11 +116,12 @@
if (position < -1 || position > buffer.getLength()) {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INDEX_OUT_OF_BOUNDS));
}
- SearchableEnvironment environment = (SearchableEnvironment) ((JavaProject) getJavaProject()).getSearchableNameEnvironment();
- NameLookup nameLookup = ((JavaProject) getJavaProject()).getNameLookup();
+ JavaProject project = (JavaProject) getJavaProject();
+ SearchableEnvironment environment = (SearchableEnvironment) project.getSearchableNameEnvironment();
+ NameLookup nameLookup = project.getNameLookup();
environment.unitToSkip = unitToSkip;
- CompletionEngine engine = new CompletionEngine(environment, new CompletionRequestorWrapper(requestor,nameLookup), JavaCore.getOptions());
+ CompletionEngine engine = new CompletionEngine(environment, new CompletionRequestorWrapper(requestor,nameLookup), project.getOptions(true), project);
engine.complete(cu, position, 0);
environment.unitToSkip = null;
}
@@ -157,10 +147,11 @@
}
// fix for 1FVGGKF
- ISearchableNameEnvironment environment = ((JavaProject)getJavaProject()).getSearchableNameEnvironment();
+ JavaProject project = (JavaProject)getJavaProject();
+ ISearchableNameEnvironment environment = project.getSearchableNameEnvironment();
// fix for 1FVXGDK
- SelectionEngine engine = new SelectionEngine(environment, requestor, JavaCore.getOptions());
+ SelectionEngine engine = new SelectionEngine(environment, requestor, project.getOptions(true));
engine.select(cu, offset, offset + length - 1);
}
/**
@@ -353,6 +344,8 @@
*/
public void open(IProgressMonitor pm) throws JavaModelException {
if (!isOpen()) {
+ // TODO: need to synchronize (IOpenable.open(IProgressMonitor) is API
+ // TODO: could use getElementInfo instead
this.openWhenClosed(pm);
}
}
@@ -396,8 +389,7 @@
// 2) create the new element info and open a buffer if needed
OpenableElementInfo info = createElementInfo();
- IResource resource = getCorrespondingResource();
- if (resource != null && isSourceElement()) {
+ if (isSourceElement()) {
this.openBuffer(pm);
}
@@ -436,8 +428,13 @@
* Returns whether the corresponding resource or associated file exists
*/
protected boolean resourceExists() {
-
- return JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), this.getPath(), true) != null;
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ if (workspace == null) return false; // workaround for http://bugs.eclipse.org/bugs/show_bug.cgi?id=34069
+ return
+ JavaModel.getTarget(
+ workspace.getRoot(),
+ this.getPath().makeRelative(), // ensure path is relative (see http://dev.eclipse.org/bugs/show_bug.cgi?id=22517)
+ true) != null;
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OpenableElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OpenableElementInfo.java
index 99b5b2d..b042a54 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OpenableElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OpenableElementInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
/** Element info for IOpenable elements. */
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java
index 46535f6..82bdac2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/OverflowingLRUCache.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.Enumeration;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageDeclaration.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageDeclaration.java
index b92d33d..5214c02 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageDeclaration.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageDeclaration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.ICompilationUnit;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java
index 97b0547..8151768 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragment.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
@@ -67,10 +67,12 @@
extType = "class"; //$NON-NLS-1$
}
try {
+ char[][] exclusionPatterns = ((PackageFragmentRoot)getPackageFragmentRoot()).fullExclusionPatternChars();
IResource[] members = ((IContainer) resource).members();
for (int i = 0, max = members.length; i < max; i++) {
IResource child = members[i];
- if (child.getType() != IResource.FOLDER) {
+ if (child.getType() != IResource.FOLDER
+ && !Util.isExcluded(child, exclusionPatterns)) {
String extension = child.getProjectRelativePath().getFileExtension();
if (extension != null) {
if (extension.equalsIgnoreCase(extType)) {
@@ -210,7 +212,7 @@
// We don't want to show non java resources of the default package (see PR #1G58NB8)
return JavaElementInfo.NO_NON_JAVA_RESOURCES;
} else {
- return ((PackageFragmentInfo) getElementInfo()).getNonJavaResources(getUnderlyingResource());
+ return ((PackageFragmentInfo) getElementInfo()).getNonJavaResources(getResource(), (PackageFragmentRoot)getPackageFragmentRoot());
}
}
/**
@@ -307,6 +309,10 @@
}
getJavaModel().move(elements, containers, siblings, renamings, force, monitor);
}
+protected void openWhenClosed(IProgressMonitor pm) throws JavaModelException {
+ if (!this.resourceExists()) throw newNotPresentException();
+ super.openWhenClosed(pm);
+}
/**
* Recomputes the children of this element, based on the current state
* of the workbench.
@@ -314,7 +320,7 @@
public void refreshChildren() {
try {
OpenableElementInfo info= (OpenableElementInfo)getElementInfo();
- computeChildren(info, getUnderlyingResource());
+ computeChildren(info, getResource());
} catch (JavaModelException e) {
// do nothing.
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java
index 85d0f7a..0add393 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentInfo.java
@@ -1,18 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.JavaModelException;
/**
* Element info for PackageFragments.
@@ -31,58 +31,6 @@
fNonJavaResources = null;
}
/**
- * Compute the non-java resources of this package fragment.
- *
- * <p>Package fragments which are folders recognize files based on the
- * type of the fragment
- * <p>Package fragments which are in a jar only recognize .class files (
- * @see JarPackageFragment).
- */
-private Object[] computeNonJavaResources(IResource resource) {
- Object[] nonJavaResources = new IResource[5];
- int nonJavaResourcesCounter = 0;
- try{
- IResource[] members = ((IContainer) resource).members();
- for (int i = 0, max = members.length; i < max; i++) {
- IResource child = members[i];
- if (child.getType() == IResource.FILE) {
- String fileName = child.getName();
- if (!Util.isValidCompilationUnitName(fileName) && !Util.isValidClassFileName(fileName)) {
- if (nonJavaResources.length == nonJavaResourcesCounter) {
- // resize
- System.arraycopy(
- nonJavaResources,
- 0,
- (nonJavaResources = new IResource[nonJavaResourcesCounter * 2]),
- 0,
- nonJavaResourcesCounter);
- }
- nonJavaResources[nonJavaResourcesCounter++] = child;
- }
- } else if (child.getType() == IResource.FOLDER) {
- if (!Util.isValidFolderNameForPackage(child.getName())) {
- if (nonJavaResources.length == nonJavaResourcesCounter) {
- // resize
- System.arraycopy(nonJavaResources, 0, (nonJavaResources = new IResource[nonJavaResourcesCounter * 2]), 0, nonJavaResourcesCounter);
- }
- nonJavaResources[nonJavaResourcesCounter++] = child;
- }
- }
- }
- if (nonJavaResourcesCounter == 0) {
- nonJavaResources = NO_NON_JAVA_RESOURCES;
- } else {
- if (nonJavaResources.length != nonJavaResourcesCounter) {
- System.arraycopy(nonJavaResources, 0, (nonJavaResources = new IResource[nonJavaResourcesCounter]), 0, nonJavaResourcesCounter);
- }
- }
- } catch(CoreException e) {
- nonJavaResources = NO_NON_JAVA_RESOURCES;
- nonJavaResourcesCounter = 0;
- }
- return nonJavaResources;
-}
-/**
*/
boolean containsJavaResources() {
return fChildren.length != 0;
@@ -90,10 +38,17 @@
/**
* Returns an array of non-java resources contained in the receiver.
*/
-Object[] getNonJavaResources(IResource underlyingResource) {
+Object[] getNonJavaResources(IResource underlyingResource, PackageFragmentRoot rootHandle) {
Object[] nonJavaResources = fNonJavaResources;
if (nonJavaResources == null) {
- nonJavaResources = computeNonJavaResources(underlyingResource);
+ try {
+ nonJavaResources =
+ PackageFragmentRootInfo.computeFolderNonJavaResources(
+ (JavaProject)rootHandle.getJavaProject(),
+ (IContainer)underlyingResource,
+ rootHandle.fullExclusionPatternChars());
+ } catch (JavaModelException e) {
+ }
fNonJavaResources = nonJavaResources;
}
return nonJavaResources;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
index 0aff338..4a8488f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
@@ -1,33 +1,29 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.Map;
+import org.eclipse.core.resources.*;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
/**
* @see IPackageFragmentRoot
@@ -35,32 +31,166 @@
public class PackageFragmentRoot extends Openable implements IPackageFragmentRoot {
/**
- * The resource associated with this root.
- * @see IResource
+ * The delimiter between the source path and root path in the
+ * attachment server property.
*/
- protected IResource fResource;
+ protected final static char ATTACHMENT_PROPERTY_DELIMITER= '*';
+ /*
+ * No source attachment property
+ */
+ protected final static String NO_SOURCE_ATTACHMENT = ""; //$NON-NLS-1$
+ /*
+ * No source mapper singleton
+ */
+ protected final static SourceMapper NO_SOURCE_MAPPER = new SourceMapper();
+
+ /**
+ * The resource associated with this root.
+ * (an IResource or a java.io.File (for external jar only))
+ */
+ protected Object resource;
+
/**
* Constructs a package fragment root which is the root of the java package
* directory hierarchy.
*/
-protected PackageFragmentRoot(IResource resource, IJavaProject project) {
- this(resource, project, resource.getProjectRelativePath().toString());
- fResource = resource;
+protected PackageFragmentRoot(IResource resource, IJavaProject project, String name) {
+ super(PACKAGE_FRAGMENT_ROOT, project, name);
+ this.resource = resource;
}
-/**
- * Constructs a package fragment root which is the root of the java package
- * directory hierarchy.
- */
-protected PackageFragmentRoot(IResource resource, IJavaProject project, String path) {
- super(PACKAGE_FRAGMENT_ROOT, project, path);
- fResource = resource;
-}
+
/**
* @see IPackageFragmentRoot
*/
-public void attachSource(IPath zipPath, IPath rootPath, IProgressMonitor monitor) throws JavaModelException {
- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this));
+public void attachSource(IPath sourcePath, IPath rootPath, IProgressMonitor monitor) throws JavaModelException {
+ try {
+ verifyAttachSource(sourcePath);
+ if (monitor != null) {
+ monitor.beginTask(Util.bind("element.attachingSource"), 2); //$NON-NLS-1$
+ }
+ SourceMapper oldMapper= getSourceMapper();
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ boolean rootNeedsToBeClosed= false;
+
+ if (sourcePath == null) {
+ //source being detached
+ rootNeedsToBeClosed= true;
+ setSourceMapper(null);
+ /* Disable deltas (see 1GDTUSD)
+ // fire a delta to notify the UI about the source detachement.
+ JavaModelManager manager = (JavaModelManager) JavaModelManager.getJavaModelManager();
+ JavaModel model = (JavaModel) getJavaModel();
+ JavaElementDelta attachedSourceDelta = new JavaElementDelta(model);
+ attachedSourceDelta .sourceDetached(this); // this would be a PackageFragmentRoot
+ manager.registerResourceDelta(attachedSourceDelta );
+ manager.fire(); // maybe you want to fire the change later. Let us know about it.
+ */
+ } else {
+ /*
+ // fire a delta to notify the UI about the source attachement.
+ JavaModelManager manager = (JavaModelManager) JavaModelManager.getJavaModelManager();
+ JavaModel model = (JavaModel) getJavaModel();
+ JavaElementDelta attachedSourceDelta = new JavaElementDelta(model);
+ attachedSourceDelta .sourceAttached(this); // this would be a PackageFragmentRoot
+ manager.registerResourceDelta(attachedSourceDelta );
+ manager.fire(); // maybe you want to fire the change later. Let us know about it.
+ */
+
+ //check if different from the current attachment
+ IPath storedSourcePath= getSourceAttachmentPath();
+ IPath storedRootPath= getSourceAttachmentRootPath();
+ if (monitor != null) {
+ monitor.worked(1);
+ }
+ if (storedSourcePath != null) {
+ if (!(storedSourcePath.equals(sourcePath) && (rootPath != null && rootPath.equals(storedRootPath)) || storedRootPath == null)) {
+ rootNeedsToBeClosed= true;
+ }
+ }
+ // check if source path is valid
+ Object target = JavaModel.getTarget(workspace.getRoot(), sourcePath, false);
+ if (target == null) {
+ if (monitor != null) {
+ monitor.done();
+ }
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, sourcePath));
+ }
+ SourceMapper mapper = createSourceMapper(sourcePath, rootPath);
+ if (rootPath == null && mapper.rootPath != null) {
+ // as a side effect of calling the SourceMapper constructor, the root path was computed
+ rootPath = new Path(mapper.rootPath);
+ }
+ setSourceMapper(mapper);
+ }
+ if (sourcePath == null) {
+ setSourceAttachmentProperty(null); //remove the property
+ } else {
+ //set the property to the path of the mapped source
+ setSourceAttachmentProperty(
+ sourcePath.toString()
+ + (rootPath == null ? "" : (ATTACHMENT_PROPERTY_DELIMITER + rootPath.toString()))); //$NON-NLS-1$
+ }
+ if (rootNeedsToBeClosed) {
+ if (oldMapper != null) {
+ oldMapper.close();
+ }
+ BufferManager manager= BufferManager.getDefaultBufferManager();
+ Enumeration openBuffers= manager.getOpenBuffers();
+ while (openBuffers.hasMoreElements()) {
+ IBuffer buffer= (IBuffer) openBuffers.nextElement();
+ IOpenable possibleMember= buffer.getOwner();
+ if (isAncestorOf((IJavaElement) possibleMember)) {
+ buffer.close();
+ }
+ }
+ if (monitor != null) {
+ monitor.worked(1);
+ }
+ }
+ } catch (JavaModelException e) {
+ setSourceAttachmentProperty(null); // loose info - will be recomputed
+ throw e;
+ } finally {
+ if (monitor != null) {
+ monitor.done();
+ }
+ }
}
+
+SourceMapper createSourceMapper(IPath sourcePath, IPath rootPath) {
+ SourceMapper mapper = new SourceMapper(
+ sourcePath,
+ rootPath == null ? null : rootPath.toOSString(),
+ this.isExternal() ? JavaCore.getOptions() : this.getJavaProject().getOptions(true)); // only project options if associated with resource
+ return mapper;
+}
+/*
+ * @see org.eclipse.jdt.core.IPackageFragmentRoot#delete
+ */
+public void delete(
+ int updateResourceFlags,
+ int updateModelFlags,
+ IProgressMonitor monitor)
+ throws JavaModelException {
+
+ DeletePackageFragmentRootOperation op = new DeletePackageFragmentRootOperation(this, updateResourceFlags, updateModelFlags);
+ runOperation(op, monitor);
+}
+
+/**
+ * This root is being closed. If this root has an associated source attachment,
+ * close it too.
+ *
+ * @see JavaElement
+ */
+protected void closing(Object info) throws JavaModelException {
+ SourceMapper mapper= getSourceMapper();
+ if (mapper != null) {
+ mapper.close();
+ }
+ super.closing(info);
+}
+
/**
* Compute the package fragment children of this package fragment root.
*
@@ -70,9 +200,11 @@
try {
// the underlying resource may be a folder or a project (in the case that the project folder
// is actually the package fragment root)
- if (fResource.getType() == IResource.FOLDER || fResource.getType() == IResource.PROJECT) {
+ IResource resource = getResource();
+ if (resource.getType() == IResource.FOLDER || resource.getType() == IResource.PROJECT) {
ArrayList vChildren = new ArrayList(5);
- computeFolderChildren((IContainer) fResource, "", vChildren); //$NON-NLS-1$
+ char[][] exclusionPatterns = fullExclusionPatternChars();
+ computeFolderChildren((IContainer) resource, "", vChildren, exclusionPatterns); //$NON-NLS-1$
IJavaElement[] children = new IJavaElement[vChildren.size()];
vChildren.toArray(children);
info.setChildren(children);
@@ -84,33 +216,35 @@
}
return true;
}
+
/**
- * Starting at this folder, create package fragments and add the fragments to the collection
- * of children.
+ * Starting at this folder, create package fragments and add the fragments that are not exclused
+ * to the collection of children.
*
* @exception JavaModelException The resource associated with this package fragment does not exist
*/
-protected void computeFolderChildren(IContainer folder, String prefix, ArrayList vChildren) throws JavaModelException {
+protected void computeFolderChildren(IContainer folder, String prefix, ArrayList vChildren, char[][] exclusionPatterns) throws JavaModelException {
IPackageFragment pkg = getPackageFragment(prefix);
vChildren.add(pkg);
try {
- IPath outputLocationPath = getJavaProject().getOutputLocation();
+ JavaProject javaProject = (JavaProject)getJavaProject();
IResource[] members = folder.members();
for (int i = 0, max = members.length; i < max; i++) {
IResource member = members[i];
String memberName = member.getName();
if (member.getType() == IResource.FOLDER
- && Util.isValidFolderNameForPackage(memberName)) {
+ && Util.isValidFolderNameForPackage(memberName)
+ && !Util.isExcluded(member, exclusionPatterns)) {
- String newPrefix;
- if (prefix.length() == 0) {
- newPrefix = memberName;
- } else {
- newPrefix = prefix + "." + memberName; //$NON-NLS-1$
- }
// eliminate binary output only if nested inside direct subfolders
- if (!member.getFullPath().equals(outputLocationPath)) {
- computeFolderChildren((IFolder) member, newPrefix, vChildren);
+ if (javaProject.contains(member)) {
+ String newPrefix;
+ if (prefix.length() == 0) {
+ newPrefix = memberName;
+ } else {
+ newPrefix = prefix + "." + memberName; //$NON-NLS-1$
+ }
+ computeFolderChildren((IFolder) member, newPrefix, vChildren, exclusionPatterns);
}
}
}
@@ -120,12 +254,51 @@
throw new JavaModelException(e);
}
}
+/*
+ * Computes and returns the source attachment root path for the given source attachment path.
+ * Returns <code>null</code> if none could be found.
+ *
+ * @param sourceAttachmentPath the given absolute path to the source archive or folder
+ * @return the computed source attachment root path or <code>null</cde> if none could be found
+ * @throws JavaModelException
+ */
+public IPath computeSourceAttachmentRootPath(IPath sourceAttachmentPath) throws JavaModelException {
+ IPath sourcePath = this.getSourceAttachmentPath();
+ if (sourcePath == null) return null;
+ SourceMapper mapper =
+ new SourceMapper(
+ sourcePath,
+ null, // detect root path
+ this.isExternal() ? JavaCore.getOptions() : this.getJavaProject().getOptions(true) // only project options if associated with resource
+ );
+ if (mapper.rootPath == null) return null;
+ return new Path(mapper.rootPath);
+}
+/*
+ * @see org.eclipse.jdt.core.IPackageFragmentRoot#copy
+ */
+public void copy(
+ IPath destination,
+ int updateResourceFlags,
+ int updateModelFlags,
+ IClasspathEntry sibling,
+ IProgressMonitor monitor)
+ throws JavaModelException {
+
+ CopyPackageFragmentRootOperation op =
+ new CopyPackageFragmentRootOperation(this, destination, updateResourceFlags, updateModelFlags, sibling);
+ runOperation(op, monitor);
+}
+
+
+
/**
* Returns a new element info for this element.
*/
protected OpenableElementInfo createElementInfo() {
return new PackageFragmentRootInfo();
}
+
/**
* @see IPackageFragmentRoot
*/
@@ -134,6 +307,7 @@
runOperation(op, monitor);
return getPackageFragment(name);
}
+
/**
* Returns the root's kind - K_SOURCE or K_BINARY, defaults
* to K_SOURCE if it is not on the classpath.
@@ -151,6 +325,7 @@
}
return IPackageFragmentRoot.K_SOURCE;
}
+
/**
* Compares two objects for equality;
* for <code>PackageFragmentRoot</code>s, equality is having the
@@ -164,7 +339,7 @@
return false;
PackageFragmentRoot other = (PackageFragmentRoot) o;
return getJavaModel().equals(other.getJavaModel()) &&
- fResource.equals(other.fResource) &&
+ this.resource.equals(other.resource) &&
fOccurrenceCount == other.fOccurrenceCount;
}
@@ -172,11 +347,101 @@
* @see IJavaElement
*/
public boolean exists() {
-
return super.exists()
&& isOnClasspath();
}
+
+public IClasspathEntry findSourceAttachmentRecommendation() {
+ try {
+ IPath rootPath = this.getPath();
+ IClasspathEntry entry;
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ // try on enclosing project first
+ JavaProject parentProject = (JavaProject) getJavaProject();
+ try {
+ entry = parentProject.getClasspathEntryFor(rootPath);
+ if (entry != null){
+ Object target = JavaModel.getTarget(workspaceRoot, entry.getSourceAttachmentPath(), true);
+ if (target instanceof IFile){
+ IFile file = (IFile) target;
+ if (Util.isArchiveFileName(file.getName())){
+ return entry;
+ }
+ } else if (target instanceof IFolder) {
+ return entry;
+ }
+ if (target instanceof java.io.File){
+ java.io.File file = (java.io.File) target;
+ if (file.isFile()) {
+ if (Util.isArchiveFileName(file.getName())){
+ return entry;
+ }
+ } else {
+ // external directory
+ return entry;
+ }
+ }
+ }
+ } catch(JavaModelException e){
+ }
+
+ // iterate over all projects
+ IJavaModel model = getJavaModel();
+ IJavaProject[] jProjects = model.getJavaProjects();
+ for (int i = 0, max = jProjects.length; i < max; i++){
+ JavaProject jProject = (JavaProject) jProjects[i];
+ if (jProject == parentProject) continue; // already done
+ try {
+ entry = jProject.getClasspathEntryFor(rootPath);
+ if (entry != null){
+ Object target = JavaModel.getTarget(workspaceRoot, entry.getSourceAttachmentPath(), true);
+ if (target instanceof IFile){
+ IFile file = (IFile) target;
+ if (Util.isArchiveFileName(file.getName())){
+ return entry;
+ }
+ } else if (target instanceof IFolder) {
+ return entry;
+ }
+ if (target instanceof java.io.File){
+ java.io.File file = (java.io.File) target;
+ if (file.isFile()) {
+ if (Util.isArchiveFileName(file.getName())){
+ return entry;
+ }
+ } else {
+ // external directory
+ return entry;
+ }
+ }
+ }
+ } catch(JavaModelException e){
+ }
+ }
+ } catch(JavaModelException e){
+ }
+
+ return null;
+}
+
+/*
+ * Returns the exclusion patterns from the classpath entry associated with this root.
+ */
+char[][] fullExclusionPatternChars() {
+ try {
+ if (this.isOpen() && this.getKind() != IPackageFragmentRoot.K_SOURCE) return null;
+ ClasspathEntry entry = (ClasspathEntry)getRawClasspathEntry();
+ if (entry == null) {
+ return null;
+ } else {
+ return entry.fullExclusionPatternChars();
+ }
+ } catch (JavaModelException e) {
+ return null;
+ }
+}
+
/**
* @see Openable
*/
@@ -185,6 +450,7 @@
((PackageFragmentRootInfo) info).setRootKind(determineKind(underlyingResource));
return computeChildren(info);
}
+
/**
* @see JavaElement#getHandleMemento()
*/
@@ -192,23 +458,59 @@
return JavaElement.JEM_PACKAGEFRAGMENTROOT;
}
/**
+ * @see JavaElement#getHandleMemento()
+ */
+public String getHandleMemento(){
+ IPath path;
+ IResource resource = getResource();
+ if (resource != null) {
+ // internal jar or regular root
+ if (getResource().getProject().equals(getJavaProject().getProject())) {
+ path = resource.getProjectRelativePath();
+ } else {
+ path = resource.getFullPath();
+ }
+ } else {
+ // external jar
+ path = getPath();
+ }
+ StringBuffer buff= new StringBuffer(((JavaElement)getParent()).getHandleMemento());
+ buff.append(getHandleMementoDelimiter());
+ buff.append(path.toString());
+ return buff.toString();
+}
+/**
* @see IPackageFragmentRoot
*/
public int getKind() throws JavaModelException {
return ((PackageFragmentRootInfo)getElementInfo()).getRootKind();
}
+
/**
* Returns an array of non-java resources contained in the receiver.
*/
public Object[] getNonJavaResources() throws JavaModelException {
- return ((PackageFragmentRootInfo) getElementInfo()).getNonJavaResources(getJavaProject(), getUnderlyingResource());
+ return ((PackageFragmentRootInfo) getElementInfo()).getNonJavaResources(getJavaProject(), getResource(), this);
}
+
/**
* @see IPackageFragmentRoot
*/
public IPackageFragment getPackageFragment(String packageName) {
+ if (packageName.indexOf(' ') != -1) { // tolerate package names with spaces (e.g. 'x . y') (http://bugs.eclipse.org/bugs/show_bug.cgi?id=21957)
+ char[][] compoundName = Util.toCompoundChars(packageName);
+ StringBuffer buffer = new StringBuffer(packageName.length());
+ for (int i = 0, length = compoundName.length; i < length; i++) {
+ buffer.append(CharOperation.trim(compoundName[i]));
+ if (i != length-1) {
+ buffer.append('.');
+ }
+ }
+ packageName = buffer.toString();
+ }
return new PackageFragment(this, packageName);
}
+
/**
* Returns the package name for the given folder
* (which is a decendent of this root).
@@ -227,91 +529,196 @@
}
return name.toString();
}
+
/**
* @see IJavaElement
*/
public IPath getPath() {
- return fResource.getFullPath();
+ return getResource().getFullPath();
}
+
/*
* @see IPackageFragmentRoot
*/
public IClasspathEntry getRawClasspathEntry() throws JavaModelException {
- IPath path= this.getPath();
- IClasspathEntry[] entries= this.getJavaProject().getRawClasspath();
- for (int i= 0; i < entries.length; i++) {
- IClasspathEntry entry = entries[i];
-
- switch (entry.getEntryKind()) {
- case IClasspathEntry.CPE_PROJECT:
- // a root's project always refers directly to the root
- // no need to follow the project reference
- continue;
- case IClasspathEntry.CPE_CONTAINER:
- IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), this.getJavaProject());
- if (container != null){
- IClasspathEntry[] containerEntries = container.getClasspathEntries();
- for (int j = 0; j < containerEntries.length; j++){
- IClasspathEntry containerEntry = JavaCore.getResolvedClasspathEntry(containerEntries[j]);
- if (containerEntry != null && path.equals(containerEntry.getPath())) {
- return entry; // answer original entry
- }
- }
- }
- break;
- case IClasspathEntry.CPE_VARIABLE:
- entry = JavaCore.getResolvedClasspathEntry(entry);
- // don't break so as to run default
- default:
- if (entry != null && path.equals(entry.getPath())) {
- return entries[i];
- }
- }
+
+ IClasspathEntry rawEntry = null;
+ IJavaProject project = this.getJavaProject();
+ project.getResolvedClasspath(true); // force the reverse rawEntry cache to be populated
+ JavaModelManager.PerProjectInfo perProjectInfo =
+ JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(project.getProject());
+ if (perProjectInfo != null && perProjectInfo.resolvedPathToRawEntries != null) {
+ rawEntry = (IClasspathEntry) perProjectInfo.resolvedPathToRawEntries.get(this.getPath());
}
- return null;
+ return rawEntry;
}
+
/*
* @see IJavaElement
*/
public IResource getResource() {
- return fResource;
+ return (IResource)this.resource;
}
+
/**
- * Cannot attach source to a folder.
- *
* @see IPackageFragmentRoot
*/
public IPath getSourceAttachmentPath() throws JavaModelException {
- return null;
+ if (getKind() != K_BINARY) return null;
+
+ String serverPathString= getSourceAttachmentProperty();
+ if (serverPathString == null) {
+ return null;
+ }
+ int index= serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
+ if (index < 0) {
+ // no root path specified
+ return new Path(serverPathString);
+ } else {
+ String serverSourcePathString= serverPathString.substring(0, index);
+ return new Path(serverSourcePathString);
+ }
}
+
/**
- * Cannot attach source to a folder.
- *
+ * Returns the server property for this package fragment root's
+ * source attachement.
+ */
+protected String getSourceAttachmentProperty() throws JavaModelException {
+ String propertyString = null;
+ QualifiedName qName= getSourceAttachmentPropertyName();
+ try {
+ propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
+
+ // if no existing source attachment information, then lookup a recommendation from classpath entries
+ if (propertyString == null) {
+ IClasspathEntry recommendation = findSourceAttachmentRecommendation();
+ if (recommendation != null) {
+ IPath rootPath = recommendation.getSourceAttachmentRootPath();
+ propertyString =
+ recommendation.getSourceAttachmentPath().toString()
+ + ((rootPath == null)
+ ? "" : //$NON-NLS-1$
+ (ATTACHMENT_PROPERTY_DELIMITER + rootPath.toString()));
+ setSourceAttachmentProperty(propertyString);
+ } else {
+ // mark as being already looked up
+ setSourceAttachmentProperty(NO_SOURCE_ATTACHMENT);
+ }
+ } else if (NO_SOURCE_ATTACHMENT.equals(propertyString)) {
+ // already looked up and no source attachment found
+ return null;
+ }
+ return propertyString;
+ } catch (CoreException ce) {
+ throw new JavaModelException(ce);
+ }
+}
+
+/**
+ * Returns the qualified name for the source attachment property
+ * of this root.
+ */
+protected QualifiedName getSourceAttachmentPropertyName() throws JavaModelException {
+ return new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + this.getPath().toOSString()); //$NON-NLS-1$
+}
+
+public void setSourceAttachmentProperty(String property) {
+ try {
+ ResourcesPlugin.getWorkspace().getRoot().setPersistentProperty(this.getSourceAttachmentPropertyName(), property);
+ } catch (CoreException ce) {
+ }
+}
+
+/**
+ * For use by <code>AttachSourceOperation</code> only.
+ * Sets the source mapper associated with this root.
+ */
+public void setSourceMapper(SourceMapper mapper) throws JavaModelException {
+ ((PackageFragmentRootInfo) getElementInfo()).setSourceMapper(mapper);
+}
+
+
+
+/**
* @see IPackageFragmentRoot
*/
public IPath getSourceAttachmentRootPath() throws JavaModelException {
- return null;
+ if (getKind() != K_BINARY) return null;
+
+ String serverPathString= getSourceAttachmentProperty();
+ if (serverPathString == null) {
+ return null;
+ }
+ int index = serverPathString.lastIndexOf(ATTACHMENT_PROPERTY_DELIMITER);
+ if (index == -1) return null;
+ String serverRootPathString= IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH;
+ if (index != serverPathString.length() - 1) {
+ serverRootPathString= serverPathString.substring(index + 1);
+ }
+ return new Path(serverRootPathString);
}
+
+/**
+ * @see JavaElement
+ */
+public SourceMapper getSourceMapper() {
+ SourceMapper mapper;
+ try {
+ PackageFragmentRootInfo rootInfo = (PackageFragmentRootInfo) getElementInfo();
+ mapper = rootInfo.getSourceMapper();
+ if (mapper == null) {
+ // first call to this method
+ IPath sourcePath= getSourceAttachmentPath();
+ if (sourcePath != null) {
+ IPath rootPath= getSourceAttachmentRootPath();
+ mapper = this.createSourceMapper(sourcePath, rootPath);
+ if (rootPath == null && mapper.rootPath != null) {
+ // as a side effect of calling the SourceMapper constructor, the root path was computed
+ rootPath = new Path(mapper.rootPath);
+
+ //set the property to the path of the mapped source
+ this.setSourceAttachmentProperty(
+ sourcePath.toString()
+ + ATTACHMENT_PROPERTY_DELIMITER
+ + rootPath.toString());
+ }
+ rootInfo.setSourceMapper(mapper);
+ } else {
+ // remember that no source is attached
+ rootInfo.setSourceMapper(NO_SOURCE_MAPPER);
+ mapper = null;
+ }
+ } else if (mapper == NO_SOURCE_MAPPER) {
+ // a previous call to this method found out that no source was attached
+ mapper = null;
+ }
+ } catch (JavaModelException e) {
+ // no source can be attached
+ mapper = null;
+ }
+ return mapper;
+}
+
/**
* @see IJavaElement
*/
public IResource getUnderlyingResource() throws JavaModelException {
- if (fResource.exists()) {
- return fResource;
- } else {
- throw newNotPresentException();
- }
-
+ if (!exists()) throw newNotPresentException();
+ return getResource();
}
+
public int hashCode() {
- return fResource.hashCode();
+ return this.resource.hashCode();
}
+
/**
* @see IPackageFragmentRoot
*/
public boolean isArchive() {
return false;
}
+
/**
* @see IPackageFragmentRoot
*/
@@ -323,17 +730,14 @@
* Returns whether this package fragment root is on the classpath of its project.
*/
protected boolean isOnClasspath() {
-
- IJavaProject project = this.getJavaProject();
-
if (this.getElementType() == IJavaElement.JAVA_PROJECT){
return true;
}
IPath path = this.getPath();
-
try {
// check package fragment root on classpath of its project
+ IJavaProject project = this.getJavaProject();
IClasspathEntry[] classpath = project.getResolvedClasspath(true);
for (int i = 0, length = classpath.length; i < length; i++) {
IClasspathEntry entry = classpath[i];
@@ -345,11 +749,29 @@
// could not read classpath, then assume it is outside
}
return false;
+}
+/*
+ * @see org.eclipse.jdt.core.IPackageFragmentRoot#move
+ */
+public void move(
+ IPath destination,
+ int updateResourceFlags,
+ int updateModelFlags,
+ IClasspathEntry sibling,
+ IProgressMonitor monitor)
+ throws JavaModelException {
+ MovePackageFragmentRootOperation op =
+ new MovePackageFragmentRootOperation(this, destination, updateResourceFlags, updateModelFlags, sibling);
+ runOperation(op, monitor);
}
+
protected void openWhenClosed(IProgressMonitor pm) throws JavaModelException {
- if (!this.resourceExists() || !this.isOnClasspath()) throw newNotPresentException();
+ if (!this.resourceExists()
+ || !this.isOnClasspath()) {
+ throw newNotPresentException();
+ }
super.openWhenClosed(pm);
}
@@ -365,16 +787,18 @@
// do nothing.
}
}
+
/*
* @see JavaElement#rootedAt(IJavaProject)
*/
public IJavaElement rootedAt(IJavaProject project) {
return
new PackageFragmentRoot(
- fResource,
+ getResource(),
project,
fName);
}
+
/**
* @private Debugging purposes
*/
@@ -383,10 +807,35 @@
if (getElementName().length() == 0) {
buffer.append("[project root]"); //$NON-NLS-1$
} else {
- buffer.append(getElementName());
+ IPath path = getPath();
+ if (getJavaProject().getElementName().equals(path.segment(0))) {
+ buffer.append(path.removeFirstSegments(1).makeRelative());
+ } else {
+ buffer.append(path);
+ }
}
if (info == null) {
buffer.append(" (not open)"); //$NON-NLS-1$
}
}
+
+/**
+ * Possible failures: <ul>
+ * <li>ELEMENT_NOT_PRESENT - the root supplied to the operation
+ * does not exist
+ * <li>INVALID_ELEMENT_TYPES - the root is not of kind K_BINARY
+ * <li>RELATIVE_PATH - the path supplied to this operation must be
+ * an absolute path
+ * </ul>
+ */
+protected void verifyAttachSource(IPath sourcePath) throws JavaModelException {
+ if (!exists()) {
+ throw newNotPresentException();
+ } else if (this.getKind() != K_BINARY) {
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this));
+ } else if (sourcePath != null && !sourcePath.isAbsolute()) {
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.RELATIVE_PATH, sourcePath));
+ }
+}
+
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java
index cd5154a..35ce251 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRootInfo.java
@@ -1,19 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
@@ -24,6 +26,12 @@
class PackageFragmentRootInfo extends OpenableElementInfo {
/**
+ * The SourceMapper for this JAR (or <code>null</code> if
+ * this JAR does not have source attached).
+ */
+ protected SourceMapper sourceMapper = null;
+
+ /**
* The kind of the root associated with this info.
* Valid kinds are: <ul>
* <li><code>IPackageFragmentRoot.K_SOURCE</code>
@@ -47,34 +55,43 @@
*
* @exception JavaModelException The resource associated with this package fragment does not exist
*/
-private Object[] computeFolderNonJavaResources(JavaProject project, IContainer folder) throws JavaModelException {
+static Object[] computeFolderNonJavaResources(JavaProject project, IContainer folder, char[][] exclusionPatterns) throws JavaModelException {
Object[] nonJavaResources = new IResource[5];
int nonJavaResourcesCounter = 0;
try {
+ IClasspathEntry[] classpath = project.getResolvedClasspath(true/*ignore unresolved variable*/);
IResource[] members = folder.members();
- for (int i = 0, max = members.length; i < max; i++) {
+ nextResource: for (int i = 0, max = members.length; i < max; i++) {
IResource member = members[i];
- if (member.getType() == IResource.FILE) {
- String fileName = member.getName();
- if (!Util.isValidCompilationUnitName(fileName) && !Util.isValidClassFileName(fileName)) {
- // check case of a .zip or .jar file on classpath
- if (project.findPackageFragmentRoot0(member.getFullPath()) == null) {
- if (nonJavaResources.length == nonJavaResourcesCounter) {
- // resize
- System.arraycopy(nonJavaResources, 0, (nonJavaResources = new IResource[nonJavaResourcesCounter * 2]), 0, nonJavaResourcesCounter);
- }
- nonJavaResources[nonJavaResourcesCounter++] = member;
- }
- }
- } else if (member.getType() == IResource.FOLDER) {
- if (!Util.isValidFolderNameForPackage(member.getName())) {
- if (nonJavaResources.length == nonJavaResourcesCounter) {
- // resize
- System.arraycopy(nonJavaResources, 0, (nonJavaResources = new IResource[nonJavaResourcesCounter * 2]), 0, nonJavaResourcesCounter);
- }
- nonJavaResources[nonJavaResourcesCounter++] = member;
- }
+ switch (member.getType()) {
+ case IResource.FILE :
+ String fileName = member.getName();
+
+ // ignore .java files that are not excluded
+ if (Util.isValidCompilationUnitName(fileName) && !Util.isExcluded(member, exclusionPatterns))
+ continue nextResource;
+ // ignore .class files
+ if (Util.isValidClassFileName(fileName))
+ continue nextResource;
+ // ignore .zip or .jar file on classpath
+ if (Util.isArchiveFileName(fileName) && isClasspathEntry(member.getFullPath(), classpath))
+ continue nextResource;
+ break;
+
+ case IResource.FOLDER :
+ // ignore valid packages or excluded folders that correspond to a nested pkg fragment root
+ if (Util.isValidFolderNameForPackage(member.getName())
+ && (!Util.isExcluded(member, exclusionPatterns)
+ || isClasspathEntry(member.getFullPath(), classpath)))
+ continue nextResource;
+ break;
}
+ if (nonJavaResources.length == nonJavaResourcesCounter) {
+ // resize
+ System.arraycopy(nonJavaResources, 0, (nonJavaResources = new IResource[nonJavaResourcesCounter * 2]), 0, nonJavaResourcesCounter);
+ }
+ nonJavaResources[nonJavaResourcesCounter++] = member;
+
}
if (nonJavaResources.length != nonJavaResourcesCounter) {
System.arraycopy(nonJavaResources, 0, (nonJavaResources = new IResource[nonJavaResourcesCounter]), 0, nonJavaResourcesCounter);
@@ -89,13 +106,17 @@
*
* @exception JavaModelException The resource associated with this package fragment root does not exist
*/
-private Object[] computeNonJavaResources(IJavaProject project, IResource underlyingResource) {
+private Object[] computeNonJavaResources(IJavaProject project, IResource underlyingResource, PackageFragmentRoot handle) {
Object[] nonJavaResources = NO_NON_JAVA_RESOURCES;
try {
// the underlying resource may be a folder or a project (in the case that the project folder
// is actually the package fragment root)
if (underlyingResource.getType() == IResource.FOLDER || underlyingResource.getType() == IResource.PROJECT) {
- nonJavaResources = computeFolderNonJavaResources((JavaProject)project, (IContainer) underlyingResource);
+ nonJavaResources =
+ computeFolderNonJavaResources(
+ (JavaProject)project,
+ (IContainer) underlyingResource,
+ handle.fullExclusionPatternChars());
}
} catch (JavaModelException e) {
}
@@ -104,10 +125,10 @@
/**
* Returns an array of non-java resources contained in the receiver.
*/
-synchronized Object[] getNonJavaResources(IJavaProject project, IResource underlyingResource) {
+synchronized Object[] getNonJavaResources(IJavaProject project, IResource underlyingResource, PackageFragmentRoot handle) {
Object[] nonJavaResources = fNonJavaResources;
if (nonJavaResources == null) {
- nonJavaResources = this.computeNonJavaResources(project, underlyingResource);
+ nonJavaResources = this.computeNonJavaResources(project, underlyingResource, handle);
fNonJavaResources = nonJavaResources;
}
return nonJavaResources;
@@ -119,6 +140,22 @@
return fRootKind;
}
/**
+ * Retuns the SourceMapper for this root, or <code>null</code>
+ * if this root does not have attached source.
+ */
+protected SourceMapper getSourceMapper() {
+ return this.sourceMapper;
+}
+private static boolean isClasspathEntry(IPath path, IClasspathEntry[] resolvedClasspath) {
+ for (int i = 0, length = resolvedClasspath.length; i < length; i++) {
+ IClasspathEntry entry = resolvedClasspath[i];
+ if (entry.getPath().equals(path)) {
+ return true;
+ }
+ }
+ return false;
+}
+/**
* Set the fNonJavaResources to res value
*/
synchronized void setNonJavaResources(Object[] resources) {
@@ -130,4 +167,10 @@
protected void setRootKind(int newRootKind) {
fRootKind = newRootKind;
}
+/**
+ * Sets the SourceMapper for this root.
+ */
+protected void setSourceMapper(SourceMapper mapper) {
+ this.sourceMapper= mapper;
+}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java
new file mode 100644
index 0000000..2cf66c3
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ReconcileWorkingCopyOperation.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.JavaModelException;
+
+/**
+ * Reconcile a working copy and signal the changes through a delta.
+ */
+public class ReconcileWorkingCopyOperation extends JavaModelOperation {
+
+ boolean forceProblemDetection;
+
+ public ReconcileWorkingCopyOperation(IJavaElement workingCopy, boolean forceProblemDetection) {
+ super(new IJavaElement[] {workingCopy});
+ this.forceProblemDetection = forceProblemDetection;
+ }
+ /**
+ * @exception JavaModelException if setting the source
+ * of the original compilation unit fails
+ */
+ protected void executeOperation() throws JavaModelException {
+ if (fMonitor != null){
+ if (fMonitor.isCanceled()) return;
+ fMonitor.beginTask(Util.bind("element.reconciling"), 10); //$NON-NLS-1$
+ }
+
+ WorkingCopy workingCopy = getWorkingCopy();
+ boolean wasConsistent = workingCopy.isConsistent();
+ JavaElementDeltaBuilder deltaBuilder = null;
+
+ try {
+ // create the delta builder (this remembers the current content of the cu)
+ if (!wasConsistent){
+ deltaBuilder = new JavaElementDeltaBuilder(workingCopy);
+
+ // update the element infos with the content of the working copy
+ workingCopy.makeConsistent(fMonitor);
+ deltaBuilder.buildDeltas();
+
+ }
+
+ if (fMonitor != null) fMonitor.worked(2);
+
+ // force problem detection? - if structure was consistent
+ if (forceProblemDetection && wasConsistent){
+ if (fMonitor != null && fMonitor.isCanceled()) return;
+
+ IProblemRequestor problemRequestor = workingCopy.problemRequestor;
+ if (problemRequestor != null && problemRequestor.isActive()){
+ problemRequestor.beginReporting();
+ CompilationUnitProblemFinder.process(workingCopy, problemRequestor, fMonitor);
+ problemRequestor.endReporting();
+ }
+ }
+
+ // register the deltas
+ if (deltaBuilder != null){
+ if ((deltaBuilder.delta != null) && (deltaBuilder.delta.getAffectedChildren().length > 0)) {
+ addReconcileDelta(workingCopy, deltaBuilder.delta);
+ }
+ }
+ } finally {
+ if (fMonitor != null) fMonitor.done();
+ }
+ }
+ /**
+ * Returns the working copy this operation is working on.
+ */
+ protected WorkingCopy getWorkingCopy() {
+ return (WorkingCopy)getElementToProcess();
+ }
+ /**
+ * @see JavaModelOperation#isReadOnly
+ */
+ public boolean isReadOnly() {
+ return true;
+ }
+ protected IJavaModelStatus verify() {
+ IJavaModelStatus status = super.verify();
+ if (!status.isOK()) {
+ return status;
+ }
+ WorkingCopy workingCopy = getWorkingCopy();
+ if (workingCopy.useCount == 0) {
+ return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, workingCopy); //was destroyed
+ }
+ return status;
+ }
+
+
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java
index e7bd996..c9fa056 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Region.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameElementsOperation.java
index 558ca0f..037ea14 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameElementsOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IJavaElement;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameResourceElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameResourceElementsOperation.java
index 5c35119..67c16cd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameResourceElementsOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/RenameResourceElementsOperation.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.ICompilationUnit;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
index 02872ed..f8c8976 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -17,6 +17,7 @@
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.ITypeNameRequestor;
@@ -28,7 +29,6 @@
import org.eclipse.jdt.internal.compiler.env.IConstants;
import org.eclipse.jdt.internal.compiler.env.ISourceType;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* This class provides a <code>SearchableBuilderEnvironment</code> for code assist which
@@ -70,14 +70,14 @@
if (type instanceof BinaryType) {
try {
return new NameEnvironmentAnswer(
- (IBinaryType) ((BinaryType) type).getRawInfo());
+ (IBinaryType) ((BinaryType) type).getElementInfo());
} catch (JavaModelException npe) {
return null;
}
} else { //SourceType
try {
// retrieve the requested type
- SourceTypeElementInfo sourceType = (SourceTypeElementInfo)((SourceType)type).getRawInfo();
+ SourceTypeElementInfo sourceType = (SourceTypeElementInfo)((SourceType)type).getElementInfo();
ISourceType topLevelType = sourceType;
while (topLevelType.getEnclosingType() != null) {
topLevelType = topLevelType.getEnclosingType();
@@ -90,7 +90,7 @@
sourceTypes[0] = sourceType;
for (int i = 0, index = 1; i < types.length; i++) {
ISourceType otherType =
- (ISourceType) ((JavaElement) types[i]).getRawInfo();
+ (ISourceType) ((JavaElement) types[i]).getElementInfo();
if (!otherType.equals(topLevelType))
sourceTypes[index++] = otherType;
}
@@ -167,11 +167,7 @@
NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES);
return;
}
- excludePath =
- ((IJavaElement) this.unitToSkip)
- .getUnderlyingResource()
- .getFullPath()
- .toString();
+ excludePath = ((IJavaElement) this.unitToSkip).getPath().toString();
} else {
excludePath = null;
}
@@ -234,7 +230,7 @@
};
try {
new SearchEngine().searchAllTypeNames(
- this.project.getUnderlyingResource().getWorkspace(),
+ this.project.getProject().getWorkspace(),
qualification,
simpleName,
PREFIX_MATCH,
@@ -327,4 +323,4 @@
public void cleanup() {
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironmentRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironmentRequestor.java
index a933636..7b51898 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironmentRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironmentRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IInitializer;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
index af60de4..0a6bae1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
@@ -1,17 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.util.ArrayList;
+import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
@@ -19,10 +20,10 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.codeassist.ISelectionRequestor;
import org.eclipse.jdt.internal.codeassist.SelectionEngine;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* Implementation of <code>ISelectionRequestor</code> to assist with
@@ -139,7 +140,15 @@
// need to add a paramater for constructor in binary type
IType declaringDeclaringType = type.getDeclaringType();
- if(declaringDeclaringType != null && isConstructor) {
+
+ boolean isStatic = false;
+ try {
+ isStatic = Flags.isStatic(type.getFlags());
+ } catch (JavaModelException e) {
+ // isStatic == false
+ }
+
+ if(declaringDeclaringType != null && isConstructor && !isStatic) {
int length = parameterPackageNames.length;
System.arraycopy(parameterPackageNames, 0, parameterPackageNames = new char[length+1][], 1, length);
System.arraycopy(parameterTypeNames, 0, parameterTypeNames = new char[length+1][], 1, length);
@@ -220,7 +229,8 @@
boolean match= true;
for (int p = 0; p < signatures.length; p++) {
String simpleName= Signature.getSimpleName(Signature.toString(signatures[p]));
- if (!simpleName.equals(new String(parameterTypeNames[p]))) {
+ char[] simpleParameterName = CharOperation.lastSegment(parameterTypeNames[p], '.');
+ if (!simpleName.equals(new String(simpleParameterName))) {
match = false;
break;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetClasspathOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetClasspathOperation.java
index eb4589d..f5f448f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetClasspathOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SetClasspathOperation.java
@@ -1,16 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.File;
+import java.util.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
@@ -21,6 +22,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -34,6 +36,8 @@
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaModelException;
+
+import org.eclipse.jdt.internal.compiler.util.ObjectVector;
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
/**
@@ -43,14 +47,17 @@
*/
public class SetClasspathOperation extends JavaModelOperation {
- IClasspathEntry[] oldResolvedPath;
+ IClasspathEntry[] oldResolvedPath, newResolvedPath;
IClasspathEntry[] newRawPath;
boolean canChangeResource;
boolean needCycleCheck;
boolean needValidation;
-
+ boolean needSave;
IPath newOutputLocation;
+
public static final IClasspathEntry[] ReuseClasspath = new IClasspathEntry[0];
+ public static final IClasspathEntry[] UpdateClasspath = new IClasspathEntry[0];
+ // if reusing output location, then also reuse clean flag
public static final IPath ReuseOutputLocation = new Path("Reuse Existing Output Location"); //$NON-NLS-1$
/**
@@ -62,17 +69,16 @@
IClasspathEntry[] newRawPath,
IPath newOutputLocation,
boolean canChangeResource,
- boolean forceSave,
- boolean needCycleCheck,
- boolean needValidation) {
+ boolean needValidation,
+ boolean needSave) {
super(new IJavaElement[] { project });
this.oldResolvedPath = oldResolvedPath;
this.newRawPath = newRawPath;
this.newOutputLocation = newOutputLocation;
this.canChangeResource = canChangeResource;
- this.needCycleCheck = needCycleCheck;
this.needValidation = needValidation;
+ this.needSave = needSave;
}
/**
@@ -95,9 +101,7 @@
} catch (JavaModelException e) {
}
// force detach source on jar package fragment roots (source will be lazily computed when needed)
- if (root instanceof JarPackageFragmentRoot) {
- ((JarPackageFragmentRoot) root).setSourceAttachmentProperty(null);// loose info - will be recomputed
- }
+ ((PackageFragmentRoot) root).setSourceAttachmentProperty(null);// loose info - will be recomputed
}
}
}
@@ -113,12 +117,37 @@
IClasspathEntry[] list,
IClasspathEntry entry) {
- for (int i = 0; i < list.length; i++) {
+ IPath[] exclusionPatterns = entry.getExclusionPatterns();
+ nextEntry: for (int i = 0; i < list.length; i++) {
IClasspathEntry other = list[i];
if (other.getContentKind() == entry.getContentKind()
&& other.getEntryKind() == entry.getEntryKind()
&& other.isExported() == entry.isExported()
&& other.getPath().equals(entry.getPath())) {
+ // check custom outputs
+ IPath entryOutput = entry.getOutputLocation();
+ IPath otherOutput = other.getOutputLocation();
+ if (entryOutput == null) {
+ if (otherOutput != null)
+ continue;
+ } else {
+ if (!entryOutput.equals(otherOutput))
+ continue;
+ }
+
+ // check exclusion patterns
+ IPath[] otherExcludes = other.getExclusionPatterns();
+ if (exclusionPatterns != otherExcludes) {
+ int excludeLength = exclusionPatterns.length;
+ if (otherExcludes.length != excludeLength)
+ continue;
+ for (int j = 0; j < excludeLength; j++) {
+ // compare toStrings instead of IPaths
+ // since IPath.equals is specified to ignore trailing separators
+ if (!exclusionPatterns[j].toString().equals(otherExcludes[j].toString()))
+ continue nextEntry;
+ }
+ }
return i;
}
}
@@ -154,7 +183,7 @@
JavaProject project =getProject();
// see if this will cause any package fragments to be affected
- IWorkspace workspace = getWorkspace();
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
IResource resource = null;
if (location != null) {
resource = workspace.getRoot().findMember(location);
@@ -167,7 +196,7 @@
IClasspathEntry entry = classpath[i];
IPath path = classpath[i].getPath();
if (entry.getEntryKind() != IClasspathEntry.CPE_PROJECT && path.isPrefixOf(location) && !path.equals(location)) {
- IPackageFragmentRoot[] roots = project.getPackageFragmentRoots(classpath[i]);
+ IPackageFragmentRoot[] roots = project.computePackageFragmentRoots(classpath[i]);
IPackageFragmentRoot root = roots[0];
// now the output location becomes a package fragment - along with any subfolders
ArrayList folders = new ArrayList();
@@ -196,7 +225,6 @@
* Sets the classpath of the pre-specified project.
*/
protected void executeOperation() throws JavaModelException {
-
// project reference updated - may throw an exception if unable to write .project file
updateProjectReferencesIfNecessary();
@@ -209,7 +237,13 @@
JavaModelException originalException = null;
try {
- if (this.newRawPath != ReuseClasspath) updateClasspath();
+ JavaProject project = getProject();
+ if (this.newRawPath == UpdateClasspath) this.newRawPath = project.getRawClasspath();
+ if (this.newRawPath != ReuseClasspath){
+ updateClasspath();
+ project.updatePackageFragmentRoots();
+ JavaModelManager.getJavaModelManager().deltaProcessor.addForRefresh(project);
+ }
} catch(JavaModelException e){
originalException = e;
@@ -236,53 +270,126 @@
protected void generateClasspathChangeDeltas(
IClasspathEntry[] oldResolvedPath,
IClasspathEntry[] newResolvedPath,
- JavaModelManager manager,
- JavaProject project) {
-
+ final JavaProject project) {
+
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
boolean needToUpdateDependents = false;
-
JavaElementDelta delta = new JavaElementDelta(getJavaModel());
boolean hasDelta = false;
int oldLength = oldResolvedPath.length;
int newLength = newResolvedPath.length;
- boolean oldResolvedPathLongest = oldLength >= newLength;
- IndexManager indexManager = manager.getIndexManager();
- for (int i = 0; i < oldResolvedPath.length; i++) {
+ final IndexManager indexManager = manager.getIndexManager();
+ Map oldRoots = null;
+ IPackageFragmentRoot[] roots = null;
+ if (project.isOpen()) {
+ try {
+ roots = project.getPackageFragmentRoots();
+ } catch (JavaModelException e) {
+ }
+ } else {
+ Map allRemovedRoots ;
+ if ((allRemovedRoots = manager.deltaProcessor.removedRoots) != null) {
+ roots = (IPackageFragmentRoot[]) allRemovedRoots.get(project);
+ }
+ }
+ if (roots != null) {
+ oldRoots = new HashMap();
+ for (int i = 0; i < roots.length; i++) {
+ IPackageFragmentRoot root = roots[i];
+ oldRoots.put(root.getPath(), root);
+ }
+ }
+ for (int i = 0; i < oldLength; i++) {
int index = classpathContains(newResolvedPath, oldResolvedPath[i]);
if (index == -1) {
// do not notify remote project changes
if (oldResolvedPath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT){
needToUpdateDependents = true;
+ this.needCycleCheck = true;
continue;
}
-
- IPackageFragmentRoot[] pkgFragmentRoots =
- project.getPackageFragmentRoots(oldResolvedPath[i]);
+
+ IPackageFragmentRoot[] pkgFragmentRoots = null;
+ if (oldRoots != null) {
+ IPackageFragmentRoot oldRoot = (IPackageFragmentRoot) oldRoots.get(oldResolvedPath[i].getPath());
+ if (oldRoot != null) { // use old root if any (could be none if entry wasn't bound)
+ pkgFragmentRoots = new IPackageFragmentRoot[] { oldRoot };
+ }
+ }
+ if (pkgFragmentRoots == null) {
+ try {
+ ObjectVector accumulatedRoots = new ObjectVector();
+ HashSet rootIDs = new HashSet(5);
+ rootIDs.add(project.rootID());
+ project.computePackageFragmentRoots(
+ oldResolvedPath[i],
+ accumulatedRoots,
+ rootIDs,
+ true, // inside original project
+ false, // don't check existency
+ false); // don't retrieve exported roots
+ pkgFragmentRoots = new IPackageFragmentRoot[accumulatedRoots.size()];
+ accumulatedRoots.copyInto(pkgFragmentRoots);
+ } catch (JavaModelException e) {
+ pkgFragmentRoots = new IPackageFragmentRoot[] {};
+ }
+ }
addClasspathDeltas(pkgFragmentRoots, IJavaElementDelta.F_REMOVED_FROM_CLASSPATH, delta);
-
+
int changeKind = oldResolvedPath[i].getEntryKind();
needToUpdateDependents |= (changeKind == IClasspathEntry.CPE_SOURCE) || oldResolvedPath[i].isExported();
-
- // Remove the .java files from the index.
- // Note that .class files belong to binary folders which can be shared,
- // so leave the index for .class files.
- if (indexManager != null && changeKind == IClasspathEntry.CPE_SOURCE) {
- indexManager.removeSourceFolderFromIndex(project, oldResolvedPath[i].getPath());
+
+ // Remove the .java files from the index for a source folder
+ // For a lib folder or a .jar file, remove the corresponding index if not shared.
+ if (indexManager != null) {
+ IClasspathEntry oldEntry = oldResolvedPath[i];
+ final IPath path = oldEntry.getPath();
+ switch (changeKind) {
+ case IClasspathEntry.CPE_SOURCE:
+ final char[][] exclusionPatterns = ((ClasspathEntry)oldEntry).fullExclusionPatternChars();
+ postAction(new IPostAction() {
+ public String getID() {
+ return path.toString();
+ }
+ public void run() throws JavaModelException {
+ indexManager.removeSourceFolderFromIndex(project, path, exclusionPatterns);
+ }
+ },
+ REMOVEALL_APPEND);
+ break;
+ case IClasspathEntry.CPE_LIBRARY:
+ final DeltaProcessor deltaProcessor = manager.deltaProcessor;
+ postAction(new IPostAction() {
+ public String getID() {
+ return path.toString();
+ }
+ public void run() throws JavaModelException {
+ if (deltaProcessor.otherRoots.get(path) == null) { // if root was not shared
+ indexManager.discardJobs(path.toString());
+ indexManager.removeIndex(path);
+ // TODO: we could just remove the in-memory index and have the indexing check for timestamps
+ }
+ }
+ },
+ REMOVEALL_APPEND);
+ break;
+ }
}
hasDelta = true;
-
+
} else {
// do not notify remote project changes
if (oldResolvedPath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT){
+ this.needCycleCheck |= (oldResolvedPath[i].isExported() != newResolvedPath[index].isExported());
continue;
}
needToUpdateDependents |= (oldResolvedPath[i].isExported() != newResolvedPath[index].isExported());
- if (oldResolvedPathLongest && index != i) { //reordering of the classpath
+ if (index != i) { //reordering of the classpath
addClasspathDeltas(
- project.getPackageFragmentRoots(oldResolvedPath[i]),
- IJavaElementDelta.F_CLASSPATH_REORDER,
+ project.computePackageFragmentRoots(oldResolvedPath[i]),
+ IJavaElementDelta.F_REORDER,
delta);
int changeKind = oldResolvedPath[i].getEntryKind();
needToUpdateDependents |= (changeKind == IClasspathEntry.CPE_SOURCE);
@@ -291,36 +398,40 @@
}
// check source attachment
+ IPath newSourcePath = newResolvedPath[index].getSourceAttachmentPath();
int sourceAttachmentFlags =
this.getSourceAttachmentDeltaFlag(
oldResolvedPath[i].getSourceAttachmentPath(),
- newResolvedPath[index].getSourceAttachmentPath());
+ newSourcePath,
+ null/*not a source root path*/);
int sourceAttachmentRootFlags =
this.getSourceAttachmentDeltaFlag(
oldResolvedPath[i].getSourceAttachmentRootPath(),
- newResolvedPath[index].getSourceAttachmentRootPath());
+ newResolvedPath[index].getSourceAttachmentRootPath(),
+ newSourcePath/*in case both root paths are null*/);
int flags = sourceAttachmentFlags | sourceAttachmentRootFlags;
if (flags != 0) {
addClasspathDeltas(
- project.getPackageFragmentRoots(oldResolvedPath[i]),
+ project.computePackageFragmentRoots(oldResolvedPath[i]),
flags,
delta);
hasDelta = true;
}
}
}
-
- for (int i = 0; i < newResolvedPath.length; i++) {
-
+
+ for (int i = 0; i < newLength; i++) {
+
int index = classpathContains(oldResolvedPath, newResolvedPath[i]);
if (index == -1) {
// do not notify remote project changes
if (newResolvedPath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT){
needToUpdateDependents = true;
+ this.needCycleCheck = true;
continue;
}
addClasspathDeltas(
- project.getPackageFragmentRoots(newResolvedPath[i]),
+ project.computePackageFragmentRoots(newResolvedPath[i]),
IJavaElementDelta.F_ADDED_TO_CLASSPATH,
delta);
int changeKind = newResolvedPath[i].getEntryKind();
@@ -330,8 +441,8 @@
switch (changeKind) {
case IClasspathEntry.CPE_LIBRARY:
boolean pathHasChanged = true;
- IPath newPath = newResolvedPath[i].getPath();
- for (int j = 0; j < oldResolvedPath.length; j++) {
+ final IPath newPath = newResolvedPath[i].getPath();
+ for (int j = 0; j < oldLength; j++) {
IClasspathEntry oldEntry = oldResolvedPath[j];
if (oldEntry.getPath().equals(newPath)) {
pathHasChanged = false;
@@ -339,21 +450,40 @@
}
}
if (pathHasChanged) {
- indexManager.indexLibrary(newPath, project.getProject());
+ postAction(new IPostAction() {
+ public String getID() {
+ return newPath.toString();
+ }
+ public void run() throws JavaModelException {
+ indexManager.indexLibrary(newPath, project.getProject());
+ }
+ },
+ REMOVEALL_APPEND);
}
break;
case IClasspathEntry.CPE_SOURCE:
- indexManager.indexSourceFolder(project, newResolvedPath[i].getPath());
+ IClasspathEntry entry = newResolvedPath[i];
+ final IPath path = entry.getPath();
+ final char[][] exclusionPatterns = ((ClasspathEntry)entry).fullExclusionPatternChars();
+ postAction(new IPostAction() {
+ public String getID() {
+ return path.toString();
+ }
+ public void run() throws JavaModelException {
+ indexManager.indexSourceFolder(project, path, exclusionPatterns);
+ }
+ },
+ APPEND); // append so that a removeSourceFolder action is not removed
break;
}
}
needToUpdateDependents |= (changeKind == IClasspathEntry.CPE_SOURCE) || newResolvedPath[i].isExported();
hasDelta = true;
-
+
} // classpath reordering has already been generated in previous loop
}
-
+
if (hasDelta) {
this.addDelta(delta);
}
@@ -371,12 +501,17 @@
* Returns either F_SOURCEATTACHED, F_SOURCEDETACHED, F_SOURCEATTACHED | F_SOURCEDETACHED
* or 0 if there is no difference.
*/
- private int getSourceAttachmentDeltaFlag(IPath oldPath, IPath newPath) {
+ private int getSourceAttachmentDeltaFlag(IPath oldPath, IPath newPath, IPath sourcePath) {
if (oldPath == null) {
if (newPath != null) {
return IJavaElementDelta.F_SOURCEATTACHED;
} else {
- return 0;
+ if (sourcePath != null) {
+ // if source path is specified and no root path, it needs to be recomputed dynamically
+ return IJavaElementDelta.F_SOURCEATTACHED | IJavaElementDelta.F_SOURCEDETACHED;
+ } else {
+ return 0;
+ }
}
} else if (newPath == null) {
return IJavaElementDelta.F_SOURCEDETACHED;
@@ -397,11 +532,11 @@
protected void saveClasspathIfNecessary() throws JavaModelException {
- if (!this.canChangeResource) return;
+ if (!this.canChangeResource || !this.needSave) return;
IClasspathEntry[] classpathForSave;
JavaProject project = getProject();
- if (this.newRawPath == ReuseClasspath){
+ if (this.newRawPath == ReuseClasspath || this.newRawPath == UpdateClasspath){
classpathForSave = project.getRawClasspath();
} else {
classpathForSave = this.newRawPath;
@@ -413,7 +548,9 @@
outputLocationForSave = this.newOutputLocation;
}
// if read-only .classpath, then the classpath setting will never been performed completely
- this.hasModifiedResource = project.saveClasspath(classpathForSave, outputLocationForSave);
+ if (project.saveClasspath(classpathForSave, outputLocationForSave)) {
+ this.setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
+ }
}
public String toString(){
@@ -449,24 +586,21 @@
project.setRawClasspath0(this.newRawPath);
// resolve new path (asking for marker creation if problems)
- IClasspathEntry[] newResolvedPath =
- project.getResolvedClasspath(
- true, // ignoreUnresolvedEntry
- this.canChangeResource);// also update cp markers
-
+ if (this.newResolvedPath == null) {
+ this.newResolvedPath = project.getResolvedClasspath(true, this.canChangeResource);
+ }
+
if (this.oldResolvedPath != null) {
generateClasspathChangeDeltas(
this.oldResolvedPath,
- newResolvedPath,
- project.getJavaModelManager(),
+ this.newResolvedPath,
project);
} else {
+ this.needCycleCheck = true;
updateAffectedProjects(project.getProject().getFullPath());
}
- if (this.needCycleCheck){
- updateCycleMarkers(newResolvedPath);
- }
+ updateCycleMarkersIfNecessary(newResolvedPath);
}
/**
@@ -493,14 +627,13 @@
if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT
&& entry.getPath().equals(prerequisiteProjectPath)) {
project.setRawClasspath(
- project.getRawClasspath(),
+ UpdateClasspath,
SetClasspathOperation.ReuseOutputLocation,
this.fMonitor,
- this.canChangeResource,
- false,
+ this.canChangeResource,
project.getResolvedClasspath(true),
- false, // no further cycle check
- false); // updating only - no validation
+ false, // updating only - no validation
+ false); // updating only - no need to save
break;
}
}
@@ -515,18 +648,27 @@
/**
* Update cycle markers
*/
- protected void updateCycleMarkers(IClasspathEntry[] newResolvedPath) {
-
+ protected void updateCycleMarkersIfNecessary(IClasspathEntry[] newResolvedPath) {
+
+ if (!this.needCycleCheck) return;
if (!this.canChangeResource) return;
try {
JavaProject project = getProject();
- if (!project.hasClasspathCycle(project.getResolvedClasspath(true))
- && !project.hasCycleMarker()){
+ if (!project.hasCycleMarker() && !project.hasClasspathCycle(project.getResolvedClasspath(true))){
return;
}
- JavaProject.updateAllCycleMarkers();
+ postAction(
+ new IPostAction() {
+ public String getID() {
+ return "updateCycleMarkers"; //$NON-NLS-1$
+ }
+ public void run() throws JavaModelException {
+ JavaProject.updateAllCycleMarkers();
+ }
+ },
+ REMOVEALL_APPEND);
} catch(JavaModelException e){
}
}
@@ -554,8 +696,10 @@
while (iter.hasNext()){
IPackageFragment frag= (IPackageFragment)iter.next();
((IPackageFragmentRoot)frag.getParent()).close();
- delta.added(frag);
- deltaToFire = true;
+ if (!Util.isExcluded(frag)) {
+ delta.added(frag);
+ deltaToFire = true;
+ }
}
// see if this will cause any package fragments to be removed
@@ -563,12 +707,18 @@
iter = removed.iterator();
while (iter.hasNext()){
IPackageFragment frag= (IPackageFragment)iter.next();
- ((IPackageFragmentRoot)frag.getParent()).close();
- delta.removed(frag);
- deltaToFire = true;
+ ((IPackageFragmentRoot)frag.getParent()).close();
+ if (!Util.isExcluded(frag)) {
+ delta.removed(frag);
+ deltaToFire = true;
+ }
}
-
- project.getJavaProjectElementInfo().setOutputLocation(this.newOutputLocation);
+
+ JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(project.getProject());
+ synchronized (perProjectInfo) {
+ perProjectInfo.outputLocation = this.newOutputLocation;
+ }
+
if (deltaToFire) {
addDelta(delta);
}
@@ -581,12 +731,16 @@
protected void updateProjectReferencesIfNecessary() throws JavaModelException {
if (!this.canChangeResource) return;
- if (this.newRawPath == ReuseClasspath || !this.needCycleCheck) return;
-
+ if (this.newRawPath == ReuseClasspath || this.newRawPath == UpdateClasspath) return;
+
JavaProject jproject = getProject();
- String[] oldRequired = jproject.getRequiredProjectNames();
- String[] newRequired =jproject.projectPrerequisites(jproject.getResolvedClasspath(this.newRawPath, true, false));
+ String[] oldRequired = jproject.projectPrerequisites(this.oldResolvedPath);
+ if (this.newResolvedPath == null) {
+ this.newResolvedPath = jproject.getResolvedClasspath(this.newRawPath, null, true, this.needValidation, null /*no reverse map*/);
+ }
+ String[] newRequired = jproject.projectPrerequisites(this.newResolvedPath);
+
try {
IProject project = jproject.getProject();
IProjectDescription description = project.getDescription();
@@ -599,7 +753,7 @@
oldReferences.add(projectName);
}
HashSet newReferences = (HashSet)oldReferences.clone();
-
+
for (int i = 0; i < oldRequired.length; i++){
String projectName = oldRequired[i];
newReferences.remove(projectName);
@@ -608,7 +762,7 @@
String projectName = newRequired[i];
newReferences.add(projectName);
}
-
+
Iterator iter;
int newSize = newReferences.size();
@@ -636,10 +790,10 @@
for (int i = 0; i < newSize; i++){
requiredProjectArray[i] = wksRoot.getProject(requiredProjectNames[i]);
}
-
+
description.setReferencedProjects(requiredProjectArray);
project.setDescription(description, this.fMonitor);
-
+
} catch(CoreException e){
throw new JavaModelException(e);
}
@@ -682,4 +836,4 @@
return JavaModelStatus.VERIFIED_OK;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SingleTypeRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SingleTypeRequestor.java
index 2704bd9..dc3fd9f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SingleTypeRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SingleTypeRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IField;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortElementBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortElementBuilder.java
new file mode 100644
index 0000000..10d6406
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortElementBuilder.java
@@ -0,0 +1,1238 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+import java.util.Comparator;
+import java.util.Stack;
+
+import org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.core.dom.FieldDeclaration;
+import org.eclipse.jdt.core.dom.Initializer;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.Name;
+import org.eclipse.jdt.core.dom.PrimitiveType;
+import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.jdt.core.dom.Type;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.jdt.core.util.CompilationUnitSorter;
+import org.eclipse.jdt.internal.compiler.SourceElementRequestorAdapter;
+import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
+
+/**
+ *
+ * @since 2.1
+ */
+public class SortElementBuilder extends SourceElementRequestorAdapter {
+
+ abstract class SortElement extends SortJavaElement {
+ SortElement(int sourceStart, int modifiers) {
+ super(SortElementBuilder.this);
+ this.sourceStart = normalizeSourceStart(sourceStart);
+ modifiers &= ~org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers.AccInterface; // remove AccInterface flags
+ modifiers &= org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers.AccJustFlag;
+ this.modifiers = modifiers;
+ this.children_count = 0;
+ }
+
+ protected void setParameters(MethodDeclaration methodDeclaration, String[] parameterNames, String[] parameterTypes) {
+ for (int i = 0, max = parameterNames.length; i < max; i++) {
+ String type = parameterTypes[i];
+ SingleVariableDeclaration singleVariableDeclaration = ast.newSingleVariableDeclaration();
+ singleVariableDeclaration.setName(ast.newSimpleName(parameterNames[i]));
+ int indexOfArrayBrace;
+ if (type.indexOf('.') != -1) {
+ String[] typeParts = splitOn('.', type);
+ int length = typeParts.length;
+ indexOfArrayBrace = typeParts[length - 1].indexOf('[');
+ if (indexOfArrayBrace != -1) {
+ int dimensions = occurencesOf('[', typeParts[length - 1]);
+ typeParts[length - 1] = typeParts[length - 1].substring(0, indexOfArrayBrace);
+ String[] typeSubstrings = new String[length];
+ for (int j = 0; j < length; j++) {
+ typeSubstrings[j] = new String(typeParts[j]);
+ }
+ singleVariableDeclaration.setType(ast.newArrayType(ast.newSimpleType(ast.newName(typeSubstrings)), dimensions));
+ } else {
+ String[] typeSubstrings = new String[length];
+ for (int j = 0; j < length; j++) {
+ typeSubstrings[j] = new String(typeParts[j]);
+ }
+ singleVariableDeclaration.setType(ast.newSimpleType(ast.newName(typeSubstrings)));
+ }
+ } else if ((indexOfArrayBrace = type.indexOf('[')) != -1) {
+ int dimensions = occurencesOf('[', type);
+ type = type.substring(0, indexOfArrayBrace);
+ singleVariableDeclaration.setType(ast.newArrayType(newType(type), dimensions));
+ } else {
+ singleVariableDeclaration.setType(newType(type));
+ }
+ methodDeclaration.parameters().add(singleVariableDeclaration);
+ }
+ }
+
+ protected String[] splitOn(char divider, String stringToSplit) {
+ int length = stringToSplit == null ? 0 : stringToSplit.length();
+ if (length == 0)
+ return new String[] { stringToSplit };
+
+ int wordCount = 1;
+ for (int i = 0; i < length; i++)
+ if (stringToSplit.charAt(i) == divider)
+ wordCount++;
+ String[] split = new String[wordCount];
+ int last = 0, currentWord = 0;
+ for (int i = 0; i < length; i++) {
+ if (stringToSplit.charAt(i) == divider) {
+ split[currentWord++] = stringToSplit.substring(last, i);
+ last = i + 1;
+ }
+ }
+ split[currentWord] = stringToSplit.substring(last, length);
+ return split;
+ }
+
+ protected int occurencesOf(char toBeFound, String s) {
+ if (s == null) return 0;
+ int count = 0;
+ for (int i = 0, max = s.length(); i < max; i++)
+ if (toBeFound == s.charAt(i))
+ count++;
+ return count;
+ }
+
+ protected Type newType(String type) {
+ // check if type is a primitive type
+ scanner.setSource(type.toCharArray());
+ scanner.resetTo(0, type.length());
+ int token = 0;
+ try {
+ token = scanner.getNextToken();
+ } catch(InvalidInputException e) {
+ return null;
+ }
+ if (token == TerminalTokens.TokenNameIdentifier) {
+ return ast.newSimpleType(ast.newSimpleName(new String(type)));
+ } else {
+ switch(token) {
+ case TerminalTokens.TokenNameint :
+ return ast.newPrimitiveType(PrimitiveType.INT);
+ case TerminalTokens.TokenNamebyte :
+ return ast.newPrimitiveType(PrimitiveType.BYTE);
+ case TerminalTokens.TokenNameboolean :
+ return ast.newPrimitiveType(PrimitiveType.BOOLEAN);
+ case TerminalTokens.TokenNamechar :
+ return ast.newPrimitiveType(PrimitiveType.CHAR);
+ case TerminalTokens.TokenNamedouble :
+ return ast.newPrimitiveType(PrimitiveType.DOUBLE);
+ case TerminalTokens.TokenNamefloat :
+ return ast.newPrimitiveType(PrimitiveType.FLOAT);
+ case TerminalTokens.TokenNamelong :
+ return ast.newPrimitiveType(PrimitiveType.LONG);
+ case TerminalTokens.TokenNameshort :
+ return ast.newPrimitiveType(PrimitiveType.SHORT);
+ case TerminalTokens.TokenNamevoid :
+ return ast.newPrimitiveType(PrimitiveType.VOID);
+ }
+ }
+ return null;
+ }
+
+ abstract ASTNode convert();
+ }
+
+ abstract class SortAbstractMethodDeclaration extends SortElement {
+
+ SortAbstractMethodDeclaration(int sourceStart, int modifiers, char[] name, char[][] parametersNames, char[][] parametersTypes, char[][] thrownExceptions) {
+ super(sourceStart, modifiers);
+ this.name = new String(name);
+ if (parametersNames != null) {
+ int length = parametersNames.length;
+ this.parametersNames = new String[length];
+ this.parametersTypes = new String[length];
+ for (int i = 0; i < length; i++) {
+ this.parametersNames[i] = new String(parametersNames[i]);
+ this.parametersTypes[i] = new String(parametersTypes[i]);
+ }
+ }
+ if (thrownExceptions != null) {
+ int length = thrownExceptions.length;
+ this.thrownExceptions = new String[length];
+ for (int i = 0; i < length; i++) {
+ this.thrownExceptions[i] = new String(thrownExceptions[i]);
+ }
+ }
+
+ }
+ public String decodeSignature() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("("); //$NON-NLS-1$
+ if (this.parametersNames != null) {
+ int length = parametersNames.length;
+ for (int i = 0; i < length - 1; i++) {
+ buffer.append(parametersTypes[i] + " " + parametersNames[i] + ", "); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ buffer.append(parametersTypes[length - 1] + " " + parametersNames[length - 1]); //$NON-NLS-1$
+ }
+ buffer.append(")"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.core.SortElementBuilder.SortElement#generateSource(java.lang.StringBuffer)
+ */
+ protected void generateSource(StringBuffer buffer) {
+ super.generateSource(buffer);
+ int length = this.children_count;
+ if (length != 0) {
+ int start = this.sourceStart;
+ int end = this.firstChildBeforeSorting.sourceStart - 1;
+
+ for (int i = 0; i < length; i++) {
+ buffer.append(SortElementBuilder.this.source, start, end - start + 1);
+ this.children[i].generateSource(buffer);
+ if (i < length - 1) {
+ start = this.children[i].sourceEnd + 1;
+ } else {
+ start = this.lastChildBeforeSorting.sourceEnd + 1;
+ }
+ if (i < length - 1) {
+ end = this.children[i + 1].sourceStart - 1;
+ } else {
+ end = this.sourceEnd;
+ }
+ }
+ buffer.append(SortElementBuilder.this.source, start, end - start + 1);
+ } else {
+ buffer.append(SortElementBuilder.this.source, this.sourceStart, this.sourceEnd - this.sourceStart + 1);
+ }
+ }
+
+ protected void mapPositions() {
+ int length = this.children_count;
+ if (length != 0) {
+ int start = this.sourceStart;
+ int end = this.firstChildBeforeSorting.sourceStart - 1;
+
+ for (int i = 0; i < length; i++) {
+ mapNextPosition(this, start, end);
+ this.children[i].mapPositions();
+ if (i < length - 1) {
+ start = this.children[i].sourceEnd + 1;
+ } else {
+ start = this.lastChildBeforeSorting.sourceEnd + 1;
+ }
+ if (i < length - 1) {
+ end = this.children[i + 1].sourceStart - 1;
+ } else {
+ end = this.sourceEnd;
+ }
+ }
+ mapNextPosition(this, start, end);
+ } else {
+ mapNextPosition(this, this.sourceStart, this.sourceEnd);
+ }
+ }
+ }
+
+ class SortMethodDeclaration extends SortAbstractMethodDeclaration {
+ SortMethodDeclaration(int sourceStart, int modifiers, char[] name, char[][] parametersNames, char[][] parametersTypes, char[][] thrownExceptions, char[] returnType) {
+ super(sourceStart, modifiers, name, parametersNames, parametersTypes, thrownExceptions);
+ this.id = METHOD;
+ this.returnType = new String(returnType);
+ }
+
+ void display(StringBuffer buffer, int tab) {
+ buffer
+ .append(tab(tab))
+ .append("method ") //$NON-NLS-1$
+ .append(name)
+ .append(decodeSignature())
+ .append(" " + returnType + LINE_SEPARATOR); //$NON-NLS-1$
+ }
+
+ ASTNode convert() {
+ MethodDeclaration methodDeclaration = ast.newMethodDeclaration();
+ methodDeclaration.setConstructor(false);
+ methodDeclaration.setModifiers(this.modifiers);
+ methodDeclaration.setName(ast.newSimpleName(new String(this.name)));
+ methodDeclaration.setProperty(CompilationUnitSorter.RELATIVE_ORDER, new Integer(this.sourceStart));
+ // set parameter names and types
+ if (this.parametersNames != null) {
+ setParameters(methodDeclaration, this.parametersNames, this.parametersTypes);
+ }
+ // set thrown exceptions
+ if (this.thrownExceptions != null) {
+ for (int j = 0, max2 = this.thrownExceptions.length; j < max2; j++) {
+ String currentException = this.thrownExceptions[j];
+ Name exceptionName;
+ if (currentException.indexOf('.') == -1) {
+ exceptionName = ast.newSimpleName(currentException);
+ } else {
+ exceptionName = ast.newName(splitOn('.', currentException));
+ }
+ methodDeclaration.thrownExceptions().add(exceptionName);
+ }
+ }
+ // set return type
+ int indexOfArrayBrace;
+ String currentReturnType = this.returnType;
+ if (currentReturnType.indexOf('.') != -1) {
+ String[] returnTypeSubstrings = splitOn('.', currentReturnType);
+ int length = returnTypeSubstrings.length;
+ indexOfArrayBrace = returnTypeSubstrings[length - 1].indexOf('[');
+ if (indexOfArrayBrace != -1) {
+ int dimensions = occurencesOf('[', returnTypeSubstrings[length - 1]);
+ returnTypeSubstrings[length - 1] = returnTypeSubstrings[length - 1].substring(0, indexOfArrayBrace);
+ methodDeclaration.setReturnType(ast.newArrayType(ast.newSimpleType(ast.newName(returnTypeSubstrings)), dimensions));
+ } else {
+ methodDeclaration.setReturnType(ast.newSimpleType(ast.newName(returnTypeSubstrings)));
+ }
+ } else if ((indexOfArrayBrace = currentReturnType.indexOf('[')) != -1) {
+ int dimensions = occurencesOf('[', currentReturnType);
+ currentReturnType = currentReturnType.substring(0, indexOfArrayBrace);
+ methodDeclaration.setReturnType(ast.newArrayType(newType(currentReturnType), dimensions));
+ } else {
+ methodDeclaration.setReturnType(newType(currentReturnType));
+ }
+ return methodDeclaration;
+ }
+ }
+
+ class SortConstructorDeclaration extends SortAbstractMethodDeclaration {
+ SortConstructorDeclaration(int sourceStart, int modifiers, char[] name, char[][] parametersNames, char[][] parametersTypes, char[][] thrownExceptions) {
+ super(sourceStart, modifiers, name, parametersNames, parametersTypes, thrownExceptions);
+ this.id = CONSTRUCTOR;
+ }
+
+ void display(StringBuffer buffer, int tab) {
+ buffer
+ .append(tab(tab))
+ .append("constructor ") //$NON-NLS-1$
+ .append(decodeSignature() + LINE_SEPARATOR);
+ }
+
+ ASTNode convert() {
+ MethodDeclaration methodDeclaration = ast.newMethodDeclaration();
+ methodDeclaration.setConstructor(true);
+ methodDeclaration.setModifiers(this.modifiers);
+ methodDeclaration.setName(ast.newSimpleName(new String(this.name)));
+ methodDeclaration.setProperty(CompilationUnitSorter.RELATIVE_ORDER, new Integer(this.sourceStart));
+ // set parameter names and types
+ if (this.parametersNames != null) {
+ setParameters(methodDeclaration, this.parametersNames, this.parametersTypes);
+ }
+ // set thrown exceptions
+ if (this.thrownExceptions != null) {
+ for (int j = 0, max2 = this.thrownExceptions.length; j < max2; j++) {
+ String currentException = this.thrownExceptions[j];
+ Name exceptionName;
+ if (currentException.indexOf('.') == -1) {
+ exceptionName = ast.newSimpleName(currentException);
+ } else {
+ exceptionName = ast.newName(splitOn('.', currentException));
+ }
+ methodDeclaration.thrownExceptions().add(exceptionName);
+ }
+ }
+ return methodDeclaration;
+ }
+ }
+
+ public class SortFieldDeclaration extends SortElement {
+ int previousSourceEnd;
+
+ SortFieldDeclaration(int sourceStart, int modifiers, char[] type, char[] name, int nameSourceStart) {
+ super(sourceStart, modifiers);
+ this.declarationStart = sourceStart;
+ this.id = FIELD;
+ this.type = new String(type);
+ this.name = new String(name);
+ this.nameSourceStart = nameSourceStart;
+ }
+
+ void display(StringBuffer buffer, int tab) {
+ buffer
+ .append(tab(tab))
+ .append("field ") //$NON-NLS-1$
+ .append(type + " " + name + LINE_SEPARATOR); //$NON-NLS-1$
+ }
+
+ ASTNode convert() {
+ VariableDeclarationFragment variableDeclarationFragment = ast.newVariableDeclarationFragment();
+ variableDeclarationFragment.setName(ast.newSimpleName(new String(this.name)));
+ FieldDeclaration fieldDeclaration = ast.newFieldDeclaration(variableDeclarationFragment);
+
+ String currentFieldType = this.type;
+
+ int indexOfArrayBrace;
+ if (currentFieldType.indexOf('.') != -1) {
+ String[] typeParts = splitOn('.', currentFieldType);
+ int length = typeParts.length;
+ indexOfArrayBrace = typeParts[length - 1].indexOf('[');
+ if (indexOfArrayBrace != -1) {
+ int dimensions = occurencesOf('[', typeParts[length - 1]);
+ typeParts[length - 1] = typeParts[length - 1].substring(0, indexOfArrayBrace);
+ fieldDeclaration.setType(ast.newArrayType(ast.newSimpleType(ast.newName(typeParts)), dimensions));
+ } else {
+ fieldDeclaration.setType(ast.newSimpleType(ast.newName(typeParts)));
+ }
+ } else if ((indexOfArrayBrace = currentFieldType.indexOf('[')) != -1) {
+ int dimensions = occurencesOf('[', currentFieldType);
+ currentFieldType = currentFieldType.substring(0, indexOfArrayBrace);
+ fieldDeclaration.setType(ast.newArrayType(newType(currentFieldType), dimensions));
+ } else {
+ fieldDeclaration.setType(newType(currentFieldType));
+ }
+ fieldDeclaration.setModifiers(this.modifiers);
+ fieldDeclaration.setProperty(CompilationUnitSorter.RELATIVE_ORDER, new Integer(this.sourceStart));
+ return fieldDeclaration;
+ }
+ /**
+ * @see org.eclipse.jdt.internal.core.SortElementBuilder.SortElement#generateSource(java.lang.StringBuffer)
+ */
+ protected void generateSource(StringBuffer buffer) {
+ super.generateSource(buffer);
+ int length = this.children_count;
+ if (length != 0) {
+ int start = this.sourceStart;
+ int end = this.firstChildBeforeSorting.sourceStart - 1;
+
+ for (int i = 0; i < length; i++) {
+ buffer.append(SortElementBuilder.this.source, start, end - start + 1);
+ this.children[i].generateSource(buffer);
+ if (i < length - 1) {
+ start = this.children[i].sourceEnd + 1;
+ } else {
+ start = this.lastChildBeforeSorting.sourceEnd + 1;
+ }
+ if (i < length - 1) {
+ end = this.children[i + 1].sourceStart - 1;
+ } else {
+ end = this.declarationSourceEnd;
+ }
+ }
+ buffer.append(SortElementBuilder.this.source, start, end - start + 1);
+ } else {
+ buffer.append(SortElementBuilder.this.source, this.sourceStart, this.declarationSourceEnd - this.sourceStart + 1);
+ }
+ }
+ protected void generateReduceSource(StringBuffer buffer) {
+ int length = this.children_count;
+ if (length != 0) {
+ int start = this.nameSourceStart;
+ int end = this.firstChildBeforeSorting.sourceStart - 1;
+
+ for (int i = 0; i < length; i++) {
+ buffer.append(SortElementBuilder.this.source, start, end - start + 1);
+ this.children[i].generateSource(buffer);
+ if (i < length - 1) {
+ start = this.children[i].sourceEnd + 1;
+ } else {
+ start = this.lastChildBeforeSorting.sourceEnd + 1;
+ }
+ if (i < length - 1) {
+ end = this.children[i + 1].sourceStart - 1;
+ } else {
+ end = this.sourceEnd;
+ }
+ }
+ buffer.append(SortElementBuilder.this.source, start, end - start + 1);
+ } else {
+ buffer.append(SortElementBuilder.this.source, this.nameSourceStart, this.sourceEnd - this.nameSourceStart + 1);
+ }
+ }
+ protected void mapReducedPositions() {
+ int length = this.children_count;
+ if (length != 0) {
+ int start = this.nameSourceStart;
+ int end = this.firstChildBeforeSorting.sourceStart - 1;
+ mapNextPosition(this, start, end);
+ for (int i = 0; i < length; i++) {
+ this.children[i].mapPositions();
+ if (i < length - 1) {
+ start = this.children[i].sourceEnd + 1;
+ } else {
+ start = this.lastChildBeforeSorting.sourceEnd + 1;
+ }
+ if (i < length - 1) {
+ end = this.children[i + 1].sourceStart - 1;
+ } else {
+ end = this.sourceEnd;
+ }
+ }
+ mapNextPosition(this, start, end);
+ } else {
+ mapNextPosition(this, this.nameSourceStart, this.sourceEnd);
+ }
+ }
+
+ protected void mapPositions() {
+ int length = this.children_count;
+ if (length != 0) {
+ int start = this.sourceStart;
+ int end = this.firstChildBeforeSorting.sourceStart - 1;
+
+ for (int i = 0; i < length; i++) {
+ mapNextPosition(this, start, end);
+ this.children[i].mapPositions();
+ if (i < length - 1) {
+ start = this.children[i].sourceEnd + 1;
+ } else {
+ start = this.lastChildBeforeSorting.sourceEnd + 1;
+ }
+ if (i < length - 1) {
+ end = this.children[i + 1].sourceStart - 1;
+ } else {
+ end = this.declarationSourceEnd;
+ }
+ }
+ mapNextPosition(this, start, end);
+ } else {
+ mapNextPosition(this, this.sourceStart, this.declarationSourceEnd);
+ }
+ }
+ }
+
+ class SortMultipleFieldDeclaration extends SortElement {
+ int declarationStart;
+
+ SortMultipleFieldDeclaration(SortFieldDeclaration fieldDeclaration) {
+ super(fieldDeclaration.declarationStart, fieldDeclaration.modifiers);
+ this.declarationStart = fieldDeclaration.declarationStart;
+ this.id = MULTIPLE_FIELD;
+ this.innerFields = new SortFieldDeclaration[1];
+ this.fieldCounter = 0;
+ this.innerFields[this.fieldCounter++] = fieldDeclaration;
+ this.type = fieldDeclaration.type;
+ this.sourceStart = fieldDeclaration.sourceStart;
+ fieldDeclaration.sourceEnd = fieldDeclaration.previousSourceEnd;
+ }
+
+ void addField(SortFieldDeclaration fieldDeclaration) {
+ System.arraycopy(this.innerFields, 0, this.innerFields = new SortFieldDeclaration[this.fieldCounter + 1], 0, this.fieldCounter);
+ this.innerFields[this.fieldCounter++] = fieldDeclaration;
+ fieldDeclaration.sourceEnd = fieldDeclaration.previousSourceEnd;
+ }
+
+ void display(StringBuffer buffer, int tab) {
+ buffer
+ .append(tab(tab))
+ .append("multiple fields ") //$NON-NLS-1$
+ .append(LINE_SEPARATOR);
+ if (this.innerFields != null) {
+ buffer
+ .append(tab(tab + 1))
+ .append("INNER FIELDS ------------------------------" + LINE_SEPARATOR); //$NON-NLS-1$
+ for (int i = 0; i < this.fieldCounter; i++) {
+ buffer.append(this.innerFields[i].toString(tab + 2));
+ buffer.append(LINE_SEPARATOR);
+ }
+ }
+ }
+
+ ASTNode convert() {
+ VariableDeclarationFragment variableDeclarationFragment = ast.newVariableDeclarationFragment();
+ variableDeclarationFragment.setName(ast.newSimpleName(new String(this.innerFields[0].name)));
+ FieldDeclaration fieldDeclaration = ast.newFieldDeclaration(variableDeclarationFragment);
+
+ for (int j = 1, max2 = this.innerFields.length; j < max2; j++) {
+ VariableDeclarationFragment fragment = ast.newVariableDeclarationFragment();
+ fragment.setName(ast.newSimpleName(new String(this.innerFields[j].name)));
+ }
+ String currentFieldType = this.type;
+
+ int indexOfArrayBrace;
+ if (currentFieldType.indexOf('.') != -1) {
+ String[] typeParts = splitOn('.', currentFieldType);
+ int length = typeParts.length;
+ indexOfArrayBrace = typeParts[length - 1].indexOf('[');
+ if (indexOfArrayBrace != -1) {
+ int dimensions = occurencesOf('[', typeParts[length - 1]);
+ typeParts[length - 1] = typeParts[length - 1].substring(0, indexOfArrayBrace);
+ fieldDeclaration.setType(ast.newArrayType(ast.newSimpleType(ast.newName(typeParts)), dimensions));
+ } else {
+ fieldDeclaration.setType(ast.newSimpleType(ast.newName(typeParts)));
+ }
+ } else if ((indexOfArrayBrace = currentFieldType.indexOf('[')) != -1) {
+ int dimensions = occurencesOf('[', currentFieldType);
+ currentFieldType = currentFieldType.substring(0, indexOfArrayBrace);
+ fieldDeclaration.setType(ast.newArrayType(newType(currentFieldType), dimensions));
+ } else {
+ fieldDeclaration.setType(newType(currentFieldType));
+ }
+ fieldDeclaration.setProperty(CompilationUnitSorter.RELATIVE_ORDER, new Integer(this.sourceStart));
+ fieldDeclaration.setModifiers(this.modifiers);
+ return fieldDeclaration;
+ }
+ /**
+ * @see org.eclipse.jdt.internal.core.SortElementBuilder.SortElement#generateSource(java.lang.StringBuffer)
+ */
+ protected void generateSource(StringBuffer buffer) {
+ super.generateSource(buffer);
+ int length = this.fieldCounter;
+ int start = this.innerFields[0].sourceStart;
+ int end = this.innerFields[0].nameSourceStart - 1;
+ buffer.append(SortElementBuilder.this.source, start, end - start + 1);
+ for (int i = 0; i < length; i++) {
+ this.innerFields[i].newSourceStart = this.newSourceStart;
+ this.innerFields[i].generateReduceSource(buffer);
+ if (i < length - 1) {
+ start = this.innerFields[i].sourceEnd + 1;
+ end = this.innerFields[i + 1].nameSourceStart - 1;
+ buffer.append(SortElementBuilder.this.source, start, end - start + 1);
+ }
+ }
+ start = this.innerFields[length - 1].sourceEnd + 1;
+ end = this.innerFields[length - 1].declarationSourceEnd;
+ buffer.append(SortElementBuilder.this.source, start, end - start + 1);
+ }
+
+ protected void mapPositions() {
+ int length = this.fieldCounter;
+ int start = this.innerFields[0].sourceStart;
+ int end = this.innerFields[0].nameSourceStart - 1;
+ mapNextPosition(this, start, end);
+ for (int i = 0; i < length; i++) {
+ this.innerFields[i].newSourceStart = this.newSourceStart;
+ this.innerFields[i].mapReducedPositions();
+ if (i < length - 1) {
+ start = this.innerFields[i].sourceEnd + 1;
+ end = this.innerFields[i + 1].nameSourceStart - 1;
+ mapNextPosition(this, start, end);
+ }
+ }
+ start = this.innerFields[length - 1].sourceEnd + 1;
+ end = this.innerFields[length - 1].declarationSourceEnd;
+ mapNextPosition(this, start, end);
+ }
+
+ protected void sort() {
+ for (int i = 0, max = this.fieldCounter; i < max; i++) {
+ this.innerFields[i].sort();
+ }
+ }
+ }
+
+ class SortInitializer extends SortElement {
+ SortInitializer(int sourceStart, int modifiers) {
+ super(sourceStart, modifiers);
+ this.id = INITIALIZER;
+ }
+
+ void display(StringBuffer buffer, int tab) {
+ buffer
+ .append(tab(tab))
+ .append("initializer " + LINE_SEPARATOR); //$NON-NLS-1$
+ }
+
+ ASTNode convert() {
+ Initializer initializer = ast.newInitializer();
+ initializer.setModifiers(this.modifiers);
+ initializer.setProperty(CompilationUnitSorter.RELATIVE_ORDER, new Integer(this.sourceStart));
+ return initializer;
+ }
+ /**
+ * @see org.eclipse.jdt.internal.core.SortElementBuilder.SortElement#generateSource(java.lang.StringBuffer)
+ */
+ protected void generateSource(StringBuffer buffer) {
+ super.generateSource(buffer);
+ int length = this.children_count;
+ if (length != 0) {
+ int start = this.sourceStart;
+ int end = this.firstChildBeforeSorting.sourceStart - 1;
+
+ for (int i = 0; i < length; i++) {
+ buffer.append(SortElementBuilder.this.source, start, end - start + 1);
+ this.children[i].generateSource(buffer);
+ if (i < length - 1) {
+ start = this.children[i].sourceEnd + 1;
+ } else {
+ start = this.lastChildBeforeSorting.sourceEnd + 1;
+ }
+ if (i < length - 1) {
+ end = this.children[i + 1].sourceStart - 1;
+ } else {
+ end = this.sourceEnd;
+ }
+ }
+ buffer.append(SortElementBuilder.this.source, start, end - start + 1);
+ } else {
+ buffer.append(SortElementBuilder.this.source, this.sourceStart, this.sourceEnd - this.sourceStart + 1);
+ }
+ }
+
+ protected void mapPositions() {
+ int length = this.children_count;
+ if (length != 0) {
+ int start = this.sourceStart;
+ int end = this.firstChildBeforeSorting.sourceStart - 1;
+
+ for (int i = 0; i < length; i++) {
+ mapNextPosition(this, start, end);
+ this.children[i].mapPositions();
+ if (i < length - 1) {
+ start = this.children[i].sourceEnd + 1;
+ } else {
+ start = this.lastChildBeforeSorting.sourceEnd + 1;
+ }
+ if (i < length - 1) {
+ end = this.children[i + 1].sourceStart - 1;
+ } else {
+ end = this.sourceEnd;
+ }
+ }
+ mapNextPosition(this, start, end);
+ } else {
+ mapNextPosition(this, this.sourceStart, this.sourceEnd);
+ }
+ }
+ }
+
+ class SortClassDeclaration extends SortType {
+ SortClassDeclaration(int sourceStart, int modifiers, char[] name, char[] superclass, char[][] superinterfaces) {
+ super(sourceStart, modifiers, name, superinterfaces);
+ this.id = CLASS | TYPE;
+ if (superclass != null) {
+ this.superclass = new String(superclass);
+ }
+ }
+
+ void display(StringBuffer buffer, int tab) {
+ buffer
+ .append(tab(tab))
+ .append("class ") //$NON-NLS-1$
+ .append(this.name);
+ if (this.superclass != null) {
+ buffer.append(" extends " + this.superclass); //$NON-NLS-1$
+ }
+ if (this.superInterfaces != null) {
+ int length = this.superInterfaces.length;
+ buffer.append(" implements "); //$NON-NLS-1$
+ for (int i = 0; i < length - 1; i++) {
+ buffer.append(this.superInterfaces[i] + ", "); //$NON-NLS-1$
+ }
+ buffer.append(this.superInterfaces[length - 1]);
+ }
+ buffer.append(LINE_SEPARATOR);
+ }
+
+ ASTNode convert() {
+ TypeDeclaration typeDeclaration = ast.newTypeDeclaration();
+ typeDeclaration.setInterface(false);
+ typeDeclaration.setModifiers(this.modifiers);
+ typeDeclaration.setName(ast.newSimpleName(this.name));
+ // set superclass
+ if (this.superclass != null) {
+ if (this.superclass.indexOf('.') == -1) {
+ // the superclass is a simple name
+ typeDeclaration.setSuperclass(ast.newSimpleName(this.superclass));
+ } else {
+ // the superclass is a qualified name
+ String[] superclassNames = splitOn('.', this.superclass);
+ typeDeclaration.setSuperclass(ast.newName(superclassNames));
+ }
+ }
+ // set superinterfaces
+ if (this.superInterfaces != null) {
+ for (int j = 0, max2 = this.superInterfaces.length; j < max2; j++) {
+ String currentInterfaceName = this.superInterfaces[j];
+ Name interfaceName;
+ if (currentInterfaceName.indexOf('.') == -1) {
+ // the superclass is a simple name
+ interfaceName = ast.newSimpleName(currentInterfaceName);
+ } else {
+ // the superclass is a qualified name
+ String[] interfaceNames = splitOn('.', currentInterfaceName);
+ interfaceName = ast.newName(interfaceNames);
+ }
+ typeDeclaration.superInterfaces().add(interfaceName);
+ }
+ }
+ typeDeclaration.setProperty(CompilationUnitSorter.RELATIVE_ORDER, new Integer(this.sourceStart));
+ return typeDeclaration;
+ }
+ }
+
+ abstract class SortType extends SortElement {
+ SortType(int sourceStart, int modifier, char[] name, char[][] superinterfaces) {
+ super(sourceStart, modifier);
+ this.name = new String(name);
+ if (superinterfaces != null) {
+ int length = superinterfaces.length;
+ this.superInterfaces = new String[length];
+ for (int i = 0; i < length; i++) {
+ this.superInterfaces[i] = new String(superinterfaces[i]);
+ }
+ }
+ }
+ /**
+ * @see org.eclipse.jdt.internal.core.SortElementBuilder.SortElement#generateSource(java.lang.StringBuffer)
+ */
+ protected void generateSource(StringBuffer buffer) {
+ super.generateSource(buffer);
+ int length = this.children_count;
+ int start = this.sourceStart;
+ if (length != 0) {
+ int end = this.firstChildBeforeSorting.sourceStart;
+
+ buffer.append(SortElementBuilder.this.source, start, end - start);
+ for (int i = 0; i < length; i++) {
+ ((SortElementBuilder.SortElement)this.astNodes[i].getProperty(CORRESPONDING_ELEMENT)).generateSource(buffer);
+ }
+ start = this.lastChildBeforeSorting.sourceEnd + 1;
+ buffer.append(SortElementBuilder.this.source, start, this.sourceEnd - start + 1);
+ } else {
+ buffer.append(SortElementBuilder.this.source, start, this.sourceEnd - start + 1);
+ }
+ }
+
+ protected void mapPositions() {
+ int length = this.children_count;
+ int start = this.sourceStart;
+ if (length != 0) {
+ int end = this.firstChildBeforeSorting.sourceStart - 1;
+ mapNextPosition(this, start, end);
+ for (int i = 0; i < length; i++) {
+ children[i].mapPositions();
+ }
+ start = this.lastChildBeforeSorting.sourceEnd + 1;
+ mapNextPosition(this, start, this.sourceEnd);
+ } else {
+ mapNextPosition(this, start, this.sourceEnd);
+ }
+ }
+ }
+
+ class SortInterfaceDeclaration extends SortType {
+ SortInterfaceDeclaration(int sourceStart, int modifiers, char[] name, char[][] superinterfaces) {
+ super(sourceStart, modifiers, name, superinterfaces);
+ this.id = TYPE | INTERFACE;
+ }
+ void display(StringBuffer buffer, int tab) {
+ buffer
+ .append(tab(tab))
+ .append("interface ") //$NON-NLS-1$
+ .append(this.name);
+ if (this.superInterfaces != null) {
+ int length = this.superInterfaces.length;
+ buffer.append(" implements "); //$NON-NLS-1$
+ for (int i = 0; i < length - 1; i++) {
+ buffer.append(this.superInterfaces[i] + ", "); //$NON-NLS-1$
+ }
+ buffer.append(this.superInterfaces[length - 1]);
+ }
+ buffer.append(LINE_SEPARATOR);
+ }
+ ASTNode convert() {
+ TypeDeclaration typeDeclaration = ast.newTypeDeclaration();
+ typeDeclaration.setInterface(true);
+ typeDeclaration.setModifiers(this.modifiers);
+ typeDeclaration.setName(ast.newSimpleName(this.name));
+ // set superinterfaces
+ if (this.superInterfaces != null) {
+ for (int j = 0, max2 = this.superInterfaces.length; j < max2; j++) {
+ String currentInterfaceName = this.superInterfaces[j];
+ Name interfaceName;
+ if (currentInterfaceName.indexOf('.') == -1) {
+ // the superclass is a simple name
+ interfaceName = ast.newSimpleName(currentInterfaceName);
+ } else {
+ // the superclass is a qualified name
+ String[] interfaceNames = splitOn('.', currentInterfaceName);
+ interfaceName = ast.newName(interfaceNames);
+ }
+ typeDeclaration.superInterfaces().add(interfaceName);
+ }
+ }
+ typeDeclaration.setProperty(CompilationUnitSorter.RELATIVE_ORDER, new Integer(this.sourceStart));
+ return typeDeclaration;
+ }
+ }
+
+ class SortCompilationUnit extends SortElement {
+ SortCompilationUnit(int sourceStart) {
+ super(sourceStart, 0);
+ this.id = COMPILATION_UNIT;
+ }
+ void display(StringBuffer buffer, int tab) {
+ }
+
+ ASTNode convert() {
+ return ast.newCompilationUnit();
+ }
+ /**
+ * @see org.eclipse.jdt.internal.core.SortElementBuilder.SortElement#generateSource(java.lang.StringBuffer)
+ */
+ protected void generateSource(StringBuffer buffer) {
+ super.generateSource(buffer);
+ int length = this.children_count;
+ if (length != 0) {
+ int end = this.firstChildBeforeSorting.sourceStart;
+ int start = this.lastChildBeforeSorting.sourceEnd + 1;
+ buffer.append(SortElementBuilder.this.source, 0, end);
+ for (int i = 0; i < length; i++) {
+ ((SortElementBuilder.SortElement)this.astNodes[i].getProperty(CORRESPONDING_ELEMENT)).generateSource(buffer);
+ }
+ buffer.append(SortElementBuilder.this.source, start, this.sourceEnd - start + 1);
+ }
+ }
+
+ protected void mapPositions() {
+ int length = this.children_count;
+ if (length != 0) {
+ int end = this.firstChildBeforeSorting.sourceStart;
+ int start = this.lastChildBeforeSorting.sourceEnd + 1;
+ mapNextPosition(this, 0, end);
+ for (int i = 0; i < length; i++) {
+ children[i].mapPositions();
+ }
+ mapNextPosition(this, start, this.sourceEnd);
+ } else {
+ mapNextPosition(this, this.sourceStart, this.sourceEnd);
+ }
+ }
+ }
+
+ SortElement currentElement;
+ Stack stack;
+ SortCompilationUnit compilationUnit;
+ Scanner scanner;
+ AST ast;
+
+ char[] source;
+ int[] lineEnds;
+ Comparator comparator;
+ int[] positionsToMap;
+ int positionsToMapIndex;
+
+ public SortElementBuilder(char[] source, int[] positionsToMap, Comparator comparator) {
+ this.source = source;
+ this.comparator = comparator;
+ this.positionsToMap = positionsToMap;
+ this.scanner = new Scanner(false, false, false, false, null, null);
+ this.ast = new AST();
+ }
+
+ /*
+ * @see ISourceElementRequestor#acceptLineSeparatorPositions(int[])
+ */
+ public void acceptLineSeparatorPositions(int[] positions) {
+ this.lineEnds = positions;
+ }
+
+ public String getSource() {
+ StringBuffer buffer = new StringBuffer();
+ this.positionsToMapIndex = 0;
+ this.compilationUnit.generateSource(buffer);
+ if (this.positionsToMap != null) {
+ this.compilationUnit.mapPositions();
+ }
+ return buffer.toString();
+ }
+
+ private static int searchLineNumber(
+ int[] startLineIndexes,
+ int position) {
+ // this code is completely useless, but it is the same implementation than
+ // org.eclipse.jdt.internal.compiler.problem.ProblemHandler.searchLineNumber(int[], int)
+ // if (startLineIndexes == null)
+ // return 1;
+ int length = startLineIndexes.length;
+ if (length == 0)
+ return 1;
+ int g = 0, d = length - 1;
+ int m = 0;
+ while (g <= d) {
+ m = (g + d) / 2;
+ if (position < startLineIndexes[m]) {
+ d = m - 1;
+ } else
+ if (position > startLineIndexes[m]) {
+ g = m + 1;
+ } else {
+ return m + 1;
+ }
+ }
+ if (position < startLineIndexes[m]) {
+ return m + 1;
+ }
+ return m + 2;
+ }
+
+ void sort() {
+ compilationUnit.sort();
+ }
+
+ void mapNextPosition(SortJavaElement node, int start, int end) {
+ int i = this.positionsToMapIndex;
+ for (; i < this.positionsToMap.length; i++) {
+ int nextPosition = this.positionsToMap[i];
+ if (nextPosition >= start
+ && nextPosition <= end) {
+ this.positionsToMap[i] += (node.newSourceStart - node.sourceStart);
+ } else {
+ break;
+ }
+ }
+ this.positionsToMapIndex = i;
+ }
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#enterClass(int, int, char, int, int, char, char)
+ */
+ public void enterClass(
+ int declarationStart,
+ int modifiers,
+ char[] name,
+ int nameSourceStart,
+ int nameSourceEnd,
+ char[] superclass,
+ char[][] superinterfaces) {
+ SortType type = new SortClassDeclaration(declarationStart, modifiers, name, superclass, superinterfaces);
+ this.currentElement.addChild(type);
+ push(type);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#enterCompilationUnit()
+ */
+ public void enterCompilationUnit() {
+ this.stack = new Stack();
+ push(compilationUnit = new SortCompilationUnit(0));
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#enterConstructor(int, int, char, int, int, char, char, char)
+ */
+ public void enterConstructor(
+ int declarationStart,
+ int modifiers,
+ char[] name,
+ int nameSourceStart,
+ int nameSourceEnd,
+ char[][] parameterTypes,
+ char[][] parameterNames,
+ char[][] exceptionTypes) {
+ if ((this.currentElement.id & SortJavaElement.TYPE) != 0) {
+ SortConstructorDeclaration constructorDeclaration = new SortConstructorDeclaration(declarationStart, modifiers, name, parameterNames, parameterTypes, exceptionTypes);
+ this.currentElement.addChild(constructorDeclaration);
+ push(constructorDeclaration);
+ }
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#enterField(int, int, char, char, int, int)
+ */
+ public void enterField(
+ int declarationStart,
+ int modifiers,
+ char[] type,
+ char[] name,
+ int nameSourceStart,
+ int nameSourceEnd) {
+ if ((this.currentElement.id & SortJavaElement.TYPE) != 0) {
+ SortFieldDeclaration fieldDeclaration = new SortFieldDeclaration(declarationStart, modifiers, type, name, nameSourceStart);
+ SortElement[] currentElementChildren = this.currentElement.children;
+ if (currentElementChildren != null) {
+ SortElement previousElement = this.currentElement.children[this.currentElement.children_count - 1];
+ if (previousElement.id == SortJavaElement.FIELD && ((SortFieldDeclaration) previousElement).declarationStart == declarationStart) {
+ SortMultipleFieldDeclaration multipleFielDeclaration = new SortMultipleFieldDeclaration((SortFieldDeclaration) previousElement);
+ multipleFielDeclaration.addField(fieldDeclaration);
+ this.currentElement.children[this.currentElement.children_count - 1] = multipleFielDeclaration;
+ } else if (previousElement.id == SortJavaElement.MULTIPLE_FIELD && ((SortMultipleFieldDeclaration) previousElement).declarationStart == declarationStart) {
+ ((SortMultipleFieldDeclaration) previousElement).addField(fieldDeclaration);
+ } else {
+ this.currentElement.addChild(fieldDeclaration);
+ }
+ } else {
+ this.currentElement.addChild(fieldDeclaration);
+ }
+ push(fieldDeclaration);
+ }
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#enterInitializer(int, int)
+ */
+ public void enterInitializer(int declarationStart, int modifiers) {
+ if ((this.currentElement.id & SortJavaElement.TYPE) != 0) {
+ SortInitializer initializer = new SortInitializer(declarationStart, modifiers);
+ this.currentElement.addChild(initializer);
+ push(initializer);
+ }
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#enterInterface(int, int, char, int, int, char)
+ */
+ public void enterInterface(
+ int declarationStart,
+ int modifiers,
+ char[] name,
+ int nameSourceStart,
+ int nameSourceEnd,
+ char[][] superinterfaces) {
+ SortType type = new SortInterfaceDeclaration(declarationStart, modifiers, name, superinterfaces);
+ this.currentElement.addChild(type);
+ push(type);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#enterMethod(int, int, char, char, int, int, char, char, char)
+ */
+ public void enterMethod(
+ int declarationStart,
+ int modifiers,
+ char[] returnType,
+ char[] name,
+ int nameSourceStart,
+ int nameSourceEnd,
+ char[][] parameterTypes,
+ char[][] parameterNames,
+ char[][] exceptionTypes) {
+ if ((this.currentElement.id & SortJavaElement.TYPE) != 0) {
+ SortMethodDeclaration methodDeclaration = new SortMethodDeclaration(declarationStart, modifiers, name, parameterNames, parameterTypes, exceptionTypes, returnType);
+ this.currentElement.addChild(methodDeclaration);
+ push(methodDeclaration);
+ }
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#exitClass(int)
+ */
+ public void exitClass(int declarationEnd) {
+ pop(declarationEnd);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#exitCompilationUnit(int)
+ */
+ public void exitCompilationUnit(int declarationEnd) {
+ pop(declarationEnd);
+ sort();
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#exitConstructor(int)
+ */
+ public void exitConstructor(int declarationEnd) {
+ pop(declarationEnd);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#exitField(int, int)
+ */
+ public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
+ int normalizedDeclarationSourceEnd = this.normalizeSourceEnd(declarationSourceEnd);
+ if (this.currentElement.id == SortJavaElement.FIELD) {
+ SortFieldDeclaration fieldDeclaration = (SortFieldDeclaration) this.currentElement;
+ fieldDeclaration.declarationSourceEnd = normalizedDeclarationSourceEnd;
+ }
+ pop(declarationEnd);
+ if (this.currentElement.children != null) {
+ SortElement element = this.currentElement.children[this.currentElement.children_count - 1];
+ switch(element.id) {
+ case SortJavaElement.MULTIPLE_FIELD :
+ SortMultipleFieldDeclaration multipleFielDeclaration = (SortMultipleFieldDeclaration) element;
+ multipleFielDeclaration.innerFields[multipleFielDeclaration.fieldCounter - 1].declarationSourceEnd = normalizedDeclarationSourceEnd;
+ multipleFielDeclaration.sourceEnd = normalizedDeclarationSourceEnd;
+ break;
+ case SortJavaElement.FIELD :
+ SortFieldDeclaration fieldDeclaration = (SortFieldDeclaration) element;
+ /*
+ * we will revert to the previous source end in case this field is
+ * part of a multiple field declaration
+ */
+ fieldDeclaration.previousSourceEnd = fieldDeclaration.sourceEnd;
+ fieldDeclaration.sourceEnd = normalizedDeclarationSourceEnd;
+ }
+ }
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#exitInitializer(int)
+ */
+ public void exitInitializer(int declarationEnd) {
+ pop(declarationEnd);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#exitInterface(int)
+ */
+ public void exitInterface(int declarationEnd) {
+ pop(declarationEnd);
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ISourceElementRequestor#exitMethod(int)
+ */
+ public void exitMethod(int declarationEnd) {
+ pop(declarationEnd);
+ }
+
+ final int normalizeSourceStart(int position) {
+ if (position == 0) {
+ return 0;
+ }
+ int index = position - 1;
+ while(index >= 0 && Character.isWhitespace(this.source[index])) {
+ index--;
+ }
+
+ int originalLineNumber = searchLineNumber(this.lineEnds, position);
+ int newLineNumber = searchLineNumber(this.lineEnds, index);
+
+ if (originalLineNumber == newLineNumber) {
+ return index + 1;
+ } else {
+ return this.lineEnds[newLineNumber - 1] + 1;
+ }
+ }
+
+ final int normalizeSourceEnd(int position) {
+ int lineNumber = searchLineNumber(this.lineEnds, position);
+ if (lineNumber == 1) {
+ return position;
+ }
+ int normalizeSourceEnd = 0;
+ if (lineNumber - 1 >= this.lineEnds.length) {
+ normalizeSourceEnd = this.source.length - 1;
+ } else {
+ normalizeSourceEnd = this.lineEnds[lineNumber - 1];
+ }
+ int index = position + 1;
+ while (index < normalizeSourceEnd && Character.isWhitespace(this.source[index])) {
+ index++;
+ }
+ if (index == normalizeSourceEnd) {
+ return normalizeSourceEnd;
+ } else {
+ return position;
+ }
+ }
+
+ private void pop(int declarationEnd) {
+ this.currentElement.sourceEnd = normalizeSourceEnd(declarationEnd);
+ this.currentElement.closeCollections();
+ this.stack.pop();
+ if (!this.stack.isEmpty()) {
+ this.currentElement = (SortElement) this.stack.peek();
+ }
+ }
+
+ private void push(SortElement sortElement) {
+ this.currentElement = sortElement;
+ this.stack.push(sortElement);
+ }
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortElementsOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortElementsOperation.java
new file mode 100644
index 0000000..c8222ad
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortElementsOperation.java
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+import java.util.Comparator;
+import java.util.Locale;
+
+import org.eclipse.jdt.core.IBuffer;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaModelStatus;
+import org.eclipse.jdt.core.IJavaModelStatusConstants;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IWorkingCopy;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.SourceElementParser;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.core.builder.ProblemFactory;
+
+/**
+ * This operation is used to sort elements in a compilation unit according to
+ * certain criteria.
+ *
+ * @since 2.1
+ */
+public class SortElementsOperation extends JavaModelOperation {
+
+ Comparator comparator;
+ boolean hasChanged;
+ int[] positions;
+
+ /**
+ * Constructor for SortElementsOperation.
+ * @param elements
+ */
+ public SortElementsOperation(IJavaElement[] elements, int[] positions, Comparator comparator) {
+ super(elements);
+ this.comparator = comparator;
+ this.positions = positions;
+ }
+
+ /**
+ * Returns the amount of work for the main task of this operation for
+ * progress reporting.
+ */
+ protected int getMainAmountOfWork(){
+ return fElementsToProcess.length;
+ }
+
+ /**
+ * @see org.eclipse.jdt.internal.core.JavaModelOperation#executeOperation()
+ */
+ protected void executeOperation() throws JavaModelException {
+ try {
+ beginTask(Util.bind("operation.sortelements"), getMainAmountOfWork()); //$NON-NLS-1$
+ WorkingCopy copy = (WorkingCopy) fElementsToProcess[0];
+ ICompilationUnit unit = (ICompilationUnit) copy.getOriginalElement();
+ IBuffer buffer = copy.getBuffer();
+ if (buffer == null) {
+ return;
+ }
+ char[] bufferContents = buffer.getCharacters();
+ String result = processElement(unit, positions, bufferContents);
+ if (!CharOperation.equals(result.toCharArray(), bufferContents)) {
+ copy.getBuffer().setContents(result);
+ }
+ worked(1);
+ } finally {
+ done();
+ }
+ }
+
+ /**
+ * Method processElement.
+ * @param unit
+ * @param bufferContents
+ */
+ private String processElement(ICompilationUnit unit, int[] positionsToMap, char[] source) throws JavaModelException {
+ this.hasChanged = false;
+ SortElementBuilder builder = new SortElementBuilder(source, positionsToMap, comparator);
+ SourceElementParser parser = new SourceElementParser(builder,
+ ProblemFactory.getProblemFactory(Locale.getDefault()), new CompilerOptions(JavaCore.getOptions()), true);
+
+ if (unit.exists()) {
+ IPackageFragment packageFragment = (IPackageFragment)unit.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
+ char[][] expectedPackageName = null;
+ if (packageFragment != null){
+ expectedPackageName = CharOperation.splitOn('.', packageFragment.getElementName().toCharArray());
+ }
+ parser.parseCompilationUnit(
+ new BasicCompilationUnit(
+ source,
+ expectedPackageName,
+ unit.getElementName(),
+ null),
+ false);
+ } else {
+ parser.parseCompilationUnit(
+ new BasicCompilationUnit(
+ source,
+ null,
+ "",//$NON-NLS-1$
+ null),
+ false);
+ }
+ return builder.getSource();
+ }
+
+ /**
+ * Possible failures:
+ * <ul>
+ * <li>NO_ELEMENTS_TO_PROCESS - the compilation unit supplied to the operation is <code>null</code></li>.
+ * <li>INVALID_ELEMENT_TYPES - the supplied elements are not an instance of IWorkingCopy</li>.
+ * </ul>
+ * @see IJavaModelStatus
+ * @see JavaConventions
+ */
+ public IJavaModelStatus verify() {
+ if (fElementsToProcess.length != 1) {
+ return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
+ }
+ if (fElementsToProcess[0] == null) {
+ return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS);
+ }
+ if (!(fElementsToProcess[0] instanceof IWorkingCopy) || !((IWorkingCopy) fElementsToProcess[0]).isWorkingCopy()) {
+ return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, fElementsToProcess[0]);
+ }
+ return JavaModelStatus.VERIFIED_OK;
+ }
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortJavaElement.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortJavaElement.java
new file mode 100644
index 0000000..d04faef
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SortJavaElement.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core;
+
+import java.util.Arrays;
+import java.util.Hashtable;
+
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.dom.ASTNode;
+import org.eclipse.jdt.internal.core.SortElementBuilder.SortElement;
+
+/**
+ *
+ * @since 2.1
+ */
+public abstract class SortJavaElement implements Comparable {
+
+ public static final int COMPILATION_UNIT = 1;
+ public static final int TYPE = 2;
+ public static final int CLASS = 4;
+ public static final int INTERFACE = 8;
+ public static final int FIELD = 16;
+ public static final int INITIALIZER = 32;
+ public static final int METHOD = 64;
+ public static final int CONSTRUCTOR = 128;
+ public static final int MULTIPLE_FIELD = 256;
+
+ SortElementBuilder builder;
+
+ protected static final String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
+ public static final String CORRESPONDING_ELEMENT = "corresponding_element"; //$NON-NLS-1$
+
+ Hashtable options;
+
+ protected int id;
+ protected int sourceStart;
+ protected int newSourceStart;
+ protected int modifiers;
+ protected String superclass;
+ protected String[] superInterfaces;
+
+ protected String[] parametersNames;
+ protected String[] parametersTypes;
+ protected String[] thrownExceptions;
+ protected String returnType;
+ protected String name;
+ protected String type;
+ protected int fieldCounter;
+ protected SortElementBuilder.SortFieldDeclaration[] innerFields;
+ protected ASTNode[] astNodes;
+
+ protected int sourceEnd;
+ protected int nameSourceStart;
+ protected SortElement[] children;
+ protected int children_count;
+ protected SortElement firstChildBeforeSorting;
+ protected SortElement lastChildBeforeSorting;
+ protected int declarationStart;
+ protected int declarationSourceEnd;
+
+ SortJavaElement(SortElementBuilder builder) {
+ this.builder = builder;
+ this.options = JavaCore.getOptions();
+ }
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(Object o) {
+ return this.builder.comparator.compare(this, o);
+ }
+
+ protected void addChild(SortElement sortElement) {
+ if (this.children_count == 0) {
+ this.children = new SortElement[3];
+ } else if (this.children_count == this.children.length) {
+ System.arraycopy(this.children, 0, this.children = new SortElement[this.children_count * 2], 0, this.children_count);
+ }
+ this.children[this.children_count++] = sortElement;
+ }
+
+ protected void closeCollections() {
+ int length = this.children_count;
+ if (length != 0 && length != this.children.length) {
+ System.arraycopy(this.children, 0, this.children= new SortElement[length], 0, length);
+ }
+ }
+
+ abstract void display(StringBuffer buffer, int tab);
+
+ protected void generateSource(StringBuffer buffer) {
+ this.newSourceStart = buffer.length();
+ }
+
+ abstract void mapPositions();
+
+ public String toString(int tab) {
+ StringBuffer buffer = new StringBuffer();
+ display(buffer, tab);
+ if (this.children != null) {
+ buffer
+ .append(tab(tab))
+ .append("CHILDREN ------------------------------" + LINE_SEPARATOR); //$NON-NLS-1$
+ for (int i = 0; i < this.children_count; i++) {
+ buffer.append(this.children[i].toString(tab + 1));
+ buffer.append(LINE_SEPARATOR);
+ }
+ }
+ return buffer.toString();
+ }
+
+ protected char[] tab(int tab) {
+ char[] tabs = new char[tab];
+ Arrays.fill(tabs, '\t');
+ return tabs;
+ }
+
+ public String toString() {
+ return toString(0);
+ }
+
+ protected void sort() {
+ if (this.children != null) {
+ this.firstChildBeforeSorting = children[0];
+ this.lastChildBeforeSorting = children[this.children_count - 1];
+ switch(this.id) {
+ case CLASS | TYPE :
+ case INTERFACE | TYPE :
+ case COMPILATION_UNIT :
+ this.astNodes = convertChildren();
+ Arrays.sort(astNodes, this.builder.comparator);
+ }
+ for (int i = 0, max = this.children_count; i < max; i++) {
+ children[i].sort();
+ }
+ }
+ }
+
+ private ASTNode[] convertChildren() {
+ ASTNode[] astNodes = new ASTNode[this.children_count];
+ for (int i = 0, max = this.children_count; i < max; i++) {
+ SortElementBuilder.SortElement currentElement = this.children[i];
+ ASTNode newNode = currentElement.convert();
+ newNode.setProperty(CORRESPONDING_ELEMENT, currentElement);
+ astNodes[i] = newNode;
+ }
+ return astNodes;
+ }
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceField.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceField.java
index caa6943..e280fe6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceField.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceField.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IField;
@@ -39,7 +39,7 @@
*/
public Object getConstant() throws JavaModelException {
SourceFieldElementInfo info = (SourceFieldElementInfo) getElementInfo();
- return convertConstant(info.getConstant());
+ return info.initializationSource;
}
/**
* @see JavaElement#getHandleMemento()
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceFieldElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceFieldElementInfo.java
index 4c03da5..9082311 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceFieldElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceFieldElementInfo.java
@@ -1,18 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.internal.compiler.env.ISourceField;
-import org.eclipse.jdt.internal.compiler.impl.Constant;
/**
* Element info for IField elements.
@@ -23,30 +22,25 @@
/**
* The type name of this field.
*/
- protected char[] fTypeName;
+ protected char[] typeName;
/**
- * The field's constant value
+ * The field's initializer string (if the field is a constant).
*/
- protected Constant fConstant;
-/**
- * Constructs an info object for the given field.
+ protected char[] initializationSource;
+
+/*
+ * Returns the initialization source for this field.
+ * Returns null if the field is not a constant or if it has no initialization.
*/
-protected SourceFieldElementInfo() {
- fConstant = Constant.NotAConstant;
-}
-/**
- * Returns the constant associated with this field or
- * Constant.NotAConstant if the field is not constant.
- */
-public Constant getConstant() {
- return fConstant;
+public char[] getInitializationSource() {
+ return this.initializationSource;
}
/**
* Returns the type name of the field.
*/
public char[] getTypeName() {
- return fTypeName;
+ return this.typeName;
}
/**
* Returns the type signature of the field.
@@ -54,19 +48,13 @@
* @see Signature
*/
protected String getTypeSignature() {
- return Signature.createTypeSignature(fTypeName, false);
+ return Signature.createTypeSignature(this.typeName, false);
}
-/**
- * Returns the constant associated with this field or
- * Constant.NotAConstant if the field is not constant.
- */
-public void setConstant(Constant constant) {
- fConstant = constant;
-}
+
/**
* Sets the type name of the field.
*/
protected void setTypeName(char[] typeName) {
- fTypeName= typeName;
+ this.typeName = typeName;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
index fd6f69f..f874598 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java
@@ -1,34 +1,35 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
+import java.io.File;
+import java.io.FilenameFilter;
import java.io.IOException;
+import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.ISourceRange;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.IProblemFactory;
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
@@ -36,7 +37,6 @@
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.Util;
import org.eclipse.jdt.internal.core.util.ReferenceInfoAdapter;
@@ -52,6 +52,15 @@
public class SourceMapper
extends ReferenceInfoAdapter
implements ISourceElementRequestor {
+
+ public static boolean VERBOSE = false;
+
+ /**
+ * Specifies the location of the package fragment roots within
+ * the zip (empty specifies the default root). <code>null</code> is
+ * not a valid root path.
+ */
+ protected HashSet rootPaths;
/**
* The binary type source is being mapped for
@@ -61,13 +70,13 @@
/**
* The location of the zip file containing source.
*/
- protected IPath fZipPath;
+ protected IPath sourcePath;
/**
* Specifies the location of the package fragment root within
* the zip (empty specifies the default root). <code>null</code> is
* not a valid root path.
*/
- protected String fRootPath;
+ protected String rootPath;
/**
* Used for efficiency
@@ -145,28 +154,48 @@
int anonymousClassName;
/**
- * File encoding to be used
+ *Options to be used
*/
String encoding;
+ Map options;
+
+ /**
+ * Use to handle root paths inference
+ */
+ private boolean areRootPathsComputed;
+ private FilenameFilter filenameFilter;
+
+ public SourceMapper() {
+ this.areRootPathsComputed = false;
+ this.filenameFilter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".java"); //$NON-NLS-1$
+ }
+ };
+ }
/**
* Creates a <code>SourceMapper</code> that locates source in the zip file
* at the given location in the specified package fragment root.
*/
- public SourceMapper(IPath zipPath, String rootPath) {
- this.fZipPath = zipPath;
- this.fRootPath = rootPath.replace('\\', '/');
- if (this.fRootPath.endsWith("/" )) { //$NON-NLS-1$
- this.fRootPath = this.fRootPath.substring(0, this.fRootPath.lastIndexOf('/'));
+ public SourceMapper(IPath sourcePath, String rootPath, Map options) {
+ this.areRootPathsComputed = false;
+ this.filenameFilter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".java"); //$NON-NLS-1$
+ }
+ };
+ this.options = options;
+ this.encoding = (String)options.get(JavaCore.CORE_ENCODING);
+ if (rootPath != null) {
+ this.rootPaths = new HashSet();
+ this.rootPaths.add(rootPath);
}
+ this.sourcePath = sourcePath;
this.fSourceRanges = new HashMap();
this.fParameterNames = new HashMap();
this.importsTable = new HashMap();
this.importsCounterTable = new HashMap();
-
- IResource zipResource = ResourcesPlugin.getWorkspace().getRoot().findMember(zipPath);
-
- this.encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
}
/**
@@ -256,12 +285,196 @@
if (lastIndex == -1) {
typeSigs[i] = typeSig;
} else {
- typeSigs[i] = Signature.C_UNRESOLVED + typeSig.substring(lastIndex + 1, typeSig.length());
+ int arrayEnd = 0;
+ while(typeSig.charAt(arrayEnd) == Signature.C_ARRAY) arrayEnd++;
+ typeSigs[i] = typeSig.substring(0, arrayEnd) + Signature.C_UNRESOLVED + typeSig.substring(lastIndex + 1, typeSig.length());
}
}
return typeSigs;
}
+ private void computeAllRootPaths(IType type) {
+ IPackageFragmentRoot root = (IPackageFragmentRoot) type.getPackageFragment().getParent();
+ this.rootPaths = new HashSet();
+ long time = 0;
+ if (VERBOSE) {
+ System.out.println("compute all root paths for " + root.getElementName()); //$NON-NLS-1$
+ time = System.currentTimeMillis();
+ }
+ final HashSet firstLevelPackageNames = new HashSet();
+ boolean containsADefaultPackage = false;
+
+ if (root.isArchive()) {
+ JarPackageFragmentRoot jarPackageFragmentRoot = (JarPackageFragmentRoot) root;
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ ZipFile zip = null;
+ try {
+ zip = manager.getZipFile(jarPackageFragmentRoot.getPath());
+ for (Enumeration entries = zip.entries(); entries.hasMoreElements(); ) {
+ ZipEntry entry = (ZipEntry) entries.nextElement();
+ String entryName = entry.getName();
+ if (!entry.isDirectory()) {
+ int index = entryName.indexOf('/');
+ if (index != -1) {
+ String firstLevelPackageName = entryName.substring(0, index);
+ if (JavaConventions.validatePackageName(firstLevelPackageName).isOK()) {
+ firstLevelPackageNames.add(firstLevelPackageName);
+ }
+ } else if (Util.isClassFileName(entryName)) {
+ containsADefaultPackage = true;
+ }
+ }
+ }
+ } catch (CoreException e) {
+ } finally {
+ manager.closeZipFile(zip); // handle null case
+ }
+ } else {
+ Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), root.getPath(), true);
+ if (target instanceof IFolder) {
+ IResource resource = root.getResource();
+ if (resource.getType() == IResource.FOLDER) {
+ try {
+ IResource[] members = ((IFolder) resource).members();
+ for (int i = 0, max = members.length; i < max; i++) {
+ IResource member = members[i];
+ if (member.getType() == IResource.FOLDER) {
+ firstLevelPackageNames.add(member.getName());
+ } else if (Util.isClassFileName(member.getName())) {
+ containsADefaultPackage = true;
+ }
+ }
+ } catch (CoreException e) {
+ }
+ }
+ } else if (target instanceof File) {
+ File file = (File)target;
+ if (file.isDirectory()) {
+ File[] files = file.listFiles();
+ for (int i = 0, max = files.length; i < max; i++) {
+ File currentFile = files[i];
+ if (currentFile.isDirectory()) {
+ firstLevelPackageNames.add(currentFile.getName());
+ } else if (Util.isClassFileName(currentFile.getName())) {
+ containsADefaultPackage = true;
+ }
+ }
+ }
+ }
+ }
+
+ if (Util.isArchiveFileName(this.sourcePath.lastSegment())) {
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ ZipFile zip = null;
+ try {
+ zip = manager.getZipFile(this.sourcePath);
+ for (Enumeration entries = zip.entries(); entries.hasMoreElements(); ) {
+ ZipEntry entry = (ZipEntry) entries.nextElement();
+ if (!entry.isDirectory()) {
+ IPath path = new Path(entry.getName());
+ int segmentCount = path.segmentCount();
+ if (segmentCount > 1) {
+ loop: for (int i = 0, max = path.segmentCount() - 1; i < max; i++) {
+ if (firstLevelPackageNames.contains(path.segment(i))) {
+ this.rootPaths.add(path.uptoSegment(i).toString());
+ break loop;
+ }
+ if (i == max - 1 && containsADefaultPackage) {
+ this.rootPaths.add(path.uptoSegment(max).toString());
+ }
+ }
+ } else if (containsADefaultPackage) {
+ this.rootPaths.add(""); //$NON-NLS-1$
+ }
+ }
+ }
+ } catch (CoreException e) {
+ } finally {
+ manager.closeZipFile(zip); // handle null case
+ }
+ } else {
+ Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), this.sourcePath, true);
+ if (target instanceof IFolder) {
+ computeRootPath((IFolder)target, firstLevelPackageNames, containsADefaultPackage);
+ } else if (target instanceof File) {
+ File file = (File)target;
+ if (file.isDirectory()) {
+ computeRootPath(file, firstLevelPackageNames, containsADefaultPackage);
+ }
+ }
+ }
+ if (VERBOSE) {
+ System.out.println("Found " + this.rootPaths.size() + " root paths"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.out.println("Spent " + (System.currentTimeMillis() - time) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ this.areRootPathsComputed = true;
+ }
+
+ private void computeRootPath(File directory, HashSet firstLevelPackageNames, boolean hasDefaultPackage) {
+ File[] files = directory.listFiles();
+ boolean hasSubDirectories = false;
+ loop: for (int i = 0, max = files.length; i < max; i++) {
+ File file = files[i];
+ if (file.isDirectory()) {
+ hasSubDirectories = true;
+ if (firstLevelPackageNames.contains(file.getName())) {
+ IPath fullPath = new Path(file.getParentFile().getPath());
+ IPath rootPathEntry = fullPath.removeFirstSegments(this.sourcePath.segmentCount()).setDevice(null);
+ this.rootPaths.add(rootPathEntry.toString());
+ break loop;
+ } else {
+ computeRootPath(file, firstLevelPackageNames, hasDefaultPackage);
+ }
+ } else if (i == max - 1 && !hasSubDirectories && hasDefaultPackage) {
+ File parentDir = file.getParentFile();
+ if (parentDir.list(this.filenameFilter).length != 0) {
+ IPath fullPath = new Path(parentDir.getPath());
+ IPath rootPathEntry = fullPath.removeFirstSegments(this.sourcePath.segmentCount()).setDevice(null);
+ this.rootPaths.add(rootPathEntry.toString());
+ }
+ }
+ }
+ }
+
+ private void computeRootPath(IFolder directory, HashSet firstLevelPackageNames, boolean hasDefaultPackage) {
+ try {
+ IResource[] resources = directory.members();
+ boolean hasSubDirectories = false;
+ loop: for (int i = 0, max = resources.length; i < max; i++) {
+ IResource resource = resources[i];
+ if (resource.getType() == IResource.FOLDER) {
+ hasSubDirectories = true;
+ if (firstLevelPackageNames.contains(resource.getName())) {
+ IPath fullPath = resource.getParent().getFullPath();
+ IPath rootPathEntry = fullPath.removeFirstSegments(this.sourcePath.segmentCount()).setDevice(null);
+ this.rootPaths.add(rootPathEntry.toString());
+ break loop;
+ } else {
+ computeRootPath((IFolder) resource, firstLevelPackageNames, hasDefaultPackage);
+ }
+ }
+ if (i == max - 1 && !hasSubDirectories && hasDefaultPackage) {
+ IContainer container = resource.getParent();
+ // check if one member is a .java file
+ IResource[] members = container.members();
+ boolean hasJavaSourceFile = false;
+ for (int j = 0, max2 = members.length; j < max2; j++) {
+ if (Util.isJavaFileName(members[i].getName())) {
+ hasJavaSourceFile = true;
+ break;
+ }
+ }
+ if (hasJavaSourceFile) {
+ IPath fullPath = container.getFullPath();
+ IPath rootPathEntry = fullPath.removeFirstSegments(this.sourcePath.segmentCount()).setDevice(null);
+ this.rootPaths.add(rootPathEntry.toString());
+ }
+ }
+ }
+ } catch (CoreException e) {
+ }
+ }
+
/**
* @see ISourceElementRequestor
*/
@@ -474,7 +687,7 @@
/**
* @see ISourceElementRequestor
*/
- public void exitField(int declarationEnd) {
+ public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
if (typeDepth >= 0) {
IType currentType = this.types[typeDepth];
setSourceRange(
@@ -539,65 +752,163 @@
}
IBinaryType info = null;
try {
- info = (IBinaryType) declType.getRawInfo();
+ info = (IBinaryType) declType.getElementInfo();
} catch (JavaModelException e) {
return null;
}
- return this.findSource(type, info);
+ String simpleSourceFileName = findSourceFileName(type, info);
+ if (simpleSourceFileName == null) {
+ return null;
+ }
+ return this.findSource(type, simpleSourceFileName);
}
/**
* Locates and returns source code for the given (binary) type, in this
* SourceMapper's ZIP file, or returns <code>null</code> if source
* code cannot be found.
+ * The given simpleSourceFileName is the .java file name (without the enclosing
+ * folder) used to create the given type (e.g. "A.java" for x/y/A$Inner.class)
*/
- public char[] findSource(IType type, IBinaryType info) {
- char[] sourceFileName = info.sourceFileName();
- if (sourceFileName == null)
- return null; // no source file attribute
- String name = new String(sourceFileName);
-
+ public char[] findSource(IType type, String simpleSourceFileName) {
+ long time = 0;
+ if (VERBOSE) {
+ time = System.currentTimeMillis();
+ }
+ String name = simpleSourceFileName;
IPackageFragment pkgFrag = type.getPackageFragment();
if (!pkgFrag.isDefaultPackage()) {
- String pkg = type.getPackageFragment().getElementName().replace('.', '/');
+ String pkg = pkgFrag.getElementName().replace('.', '/');
name = pkg + '/' + name;
}
- // try to get the entry
- ZipEntry entry = null;
- ZipFile zip = null;
+
char[] source = null;
- try {
- String fullName;
- //add the root path if specified
- if (!fRootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) {
- fullName = fRootPath + '/' + name;
- } else {
- fullName = name;
- }
- zip = getZip();
- entry = zip.getEntry(fullName);
- if (entry != null) {
- // now read the source code
- byte[] bytes = null;
- try {
- bytes = Util.getZipEntryByteContent(entry, zip);
- } catch (IOException e) {
- }
- if (bytes != null) {
- try {
- source = Util.bytesToChar(bytes, this.encoding);
- } catch (IOException e) {
- source = null;
+
+ if (!areRootPathsComputed) {
+ computeAllRootPaths(type);
+ }
+
+ if (this.rootPath != null) {
+ source = getSourceForRootPath(this.rootPath, name);
+ }
+
+ if (source == null) {
+ /*
+ * We should try all existing root paths. If none works, try to recompute it.
+ * If it still doesn't work, then return null
+ */
+ if (this.rootPaths != null) {
+ loop: for (Iterator iterator = this.rootPaths.iterator(); iterator.hasNext(); ) {
+ String currentRootPath = (String) iterator.next();
+ if (!currentRootPath.equals(this.rootPath)) {
+ source = getSourceForRootPath(currentRootPath, name);
+ if (source != null) {
+ // remember right root path
+ this.rootPath = currentRootPath;
+ break loop;
+ }
}
}
}
- } catch (CoreException e) {
- return null;
- } finally {
- JavaModelManager.getJavaModelManager().closeZipFile(zip);
+ }
+ if (VERBOSE) {
+ System.out.println("spent " + (System.currentTimeMillis() - time) + "ms for " + type.getElementName()); //$NON-NLS-1$ //$NON-NLS-2$
}
return source;
}
+
+ /*
+ * Finds the source file name (i.e. the simple .java file name) for the given IBinaryType.
+ * Returns null if not found.
+ */
+ public String findSourceFileName(IType type, IBinaryType info) {
+ char[] sourceFileName = info.sourceFileName();
+ if (sourceFileName == null) {
+ /*
+ * We assume that this type has been compiled from a file with its name
+ * For example, A.class comes from A.java and p.A.class comes from a file A.java
+ * in the folder p.
+ */
+ try {
+ if (type.isMember()) {
+ IType enclosingType = type.getDeclaringType();
+ while (enclosingType.getDeclaringType() != null) {
+ enclosingType = enclosingType.getDeclaringType();
+ }
+ return enclosingType.getElementName() + ".java"; //$NON-NLS-1$
+ } else if (type.isLocal() || type.isAnonymous()){
+ String typeQualifiedName = type.getTypeQualifiedName();
+ return typeQualifiedName.substring(0, typeQualifiedName.indexOf('$')) + ".java"; //$NON-NLS-1$
+ } else {
+ return type.getElementName() + ".java"; //$NON-NLS-1$
+ }
+ } catch (JavaModelException e) {
+ }
+ } else {
+ return new String(sourceFileName);
+ }
+ return null;
+ }
+
+ private char[] getSourceForRootPath(String currentRootPath, String name) {
+ String newFullName;
+ if (!currentRootPath.equals(IPackageFragmentRoot.DEFAULT_PACKAGEROOT_PATH)) {
+ if (currentRootPath.endsWith("/")) { //$NON-NLS-1$
+ newFullName = currentRootPath + name;
+ } else {
+ newFullName = currentRootPath + '/' + name;
+ }
+ } else {
+ newFullName = name;
+ }
+ return this.findSource(newFullName);
+ }
+
+ public char[] findSource(String fullName) {
+ char[] source = null;
+ if (Util.isArchiveFileName(this.sourcePath.lastSegment())) {
+ // try to get the entry
+ ZipEntry entry = null;
+ ZipFile zip = null;
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ try {
+ zip = manager.getZipFile(this.sourcePath);
+ entry = zip.getEntry(fullName);
+ if (entry != null) {
+ // now read the source code
+ source = readSource(entry, zip);
+ }
+ } catch (CoreException e) {
+ return null;
+ } finally {
+ manager.closeZipFile(zip); // handle null case
+ }
+ } else {
+ Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), this.sourcePath, true);
+ if (target instanceof IFolder) {
+ IFolder folder = (IFolder)target;
+ IResource res = folder.findMember(fullName);
+ if (res instanceof IFile) {
+ try {
+ source = org.eclipse.jdt.internal.core.Util.getResourceContentsAsCharArray((IFile)res, this.encoding);
+ } catch (JavaModelException e) {
+ }
+ }
+ } else if (target instanceof File) {
+ File file = (File)target;
+ if (file.isDirectory()) {
+ File sourceFile = new File(file, fullName);
+ try {
+ source = Util.getFileCharContent(sourceFile, this.encoding);
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+ return source;
+ }
+
+
/**
* Returns the SourceRange for the name of the given element, or
@@ -717,14 +1028,7 @@
}
return result;
}
-
- /**
- * Returns the <code>ZipFile</code> that source is located in.
- */
- public ZipFile getZip() throws CoreException {
- return JavaModelManager.getJavaModelManager().getZipFile(fZipPath);
- }
-
+
/**
* Maps the given source code to the given binary type and its children.
*/
@@ -737,7 +1041,7 @@
* If a non-null java element is passed, finds the name range for the
* given java element without storing it.
*/
- public ISourceRange mapSource(
+ public synchronized ISourceRange mapSource(
IType type,
char[] contents,
IJavaElement searchedElement) {
@@ -769,7 +1073,7 @@
char[] fullName = null;
this.anonymousClassName = 0;
try {
- IBinaryType binType = (IBinaryType) fType.getRawInfo();
+ IBinaryType binType = (IBinaryType) fType.getElementInfo();
isAnonymousClass = binType.isAnonymous();
fullName = binType.getName();
} catch(JavaModelException e) {
@@ -783,7 +1087,7 @@
}
}
boolean doFullParse = hasToRetrieveSourceRangesForLocalClass(fullName);
- parser = new SourceElementParser(this, factory, new CompilerOptions(JavaCore.getOptions()), doFullParse);
+ parser = new SourceElementParser(this, factory, new CompilerOptions(this.options), doFullParse);
parser.parseCompilationUnit(
new BasicCompilationUnit(contents, null, type.getElementName() + ".java", encoding), //$NON-NLS-1$
doFullParse);
@@ -805,6 +1109,16 @@
this.typeDepth = -1;
}
}
+ private char[] readSource(ZipEntry entry, ZipFile zip) {
+ try {
+ byte[] bytes = Util.getZipEntryByteContent(entry, zip);
+ if (bytes != null) {
+ return Util.bytesToChar(bytes, this.encoding);
+ }
+ } catch (IOException e) {
+ }
+ return null;
+ }
/**
* Sets the mapping for this method to its parameter names.
@@ -815,7 +1129,7 @@
IMethod method,
char[][] parameterNames) {
if (parameterNames == null) {
- parameterNames = new char[0][];
+ parameterNames = CharOperation.NO_CHAR_CHAR;
}
fParameterNames.put(method, parameterNames);
}
@@ -889,4 +1203,4 @@
}
return false;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java
index 3745afa..8d60b42 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethod.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.Flags;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethodElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethodElementInfo.java
index 7c63f96..c2f55b1 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethodElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMethodElementInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.Signature;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRange.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRange.java
index 3c1b07b..4b8bca0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRange.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRange.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.ISourceRange;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElement.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElement.java
index 44f1625..67b8cf6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElement.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElement.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.core.resources.IResource;
@@ -68,6 +68,7 @@
* @see IJavaElement
*/
public IResource getCorrespondingResource() throws JavaModelException {
+ if (!exists()) throw newNotPresentException();
return null;
}
/**
@@ -124,6 +125,7 @@
* @see IJavaElement
*/
public IResource getUnderlyingResource() throws JavaModelException {
+ if (!exists()) throw newNotPresentException();
return getParent().getUnderlyingResource();
}
/**
@@ -146,46 +148,6 @@
getJavaModel().move(elements, containers, siblings, renamings, force, monitor);
}
/**
- * Changes the source end index of this element, all children (following
- * <code>child</code>), and all following elements.
- */
-public void offsetSourceEndAndChildren(int amount, IJavaElement child) {
- try {
- SourceRefElementInfo info = (SourceRefElementInfo) getRawInfo();
- info.setSourceRangeEnd(info.getDeclarationSourceEnd() + amount);
- IJavaElement[] children = getChildren();
- boolean afterChild = false;
- for (int i = 0; i < children.length; i++) {
- IJavaElement aChild = children[i];
- if (afterChild) {
- ((JavaElement) aChild).offsetSourceRange(amount);
- } else {
- afterChild = aChild.equals(child);
- }
- }
- ((JavaElement) getParent()).offsetSourceEndAndChildren(amount, this);
- } catch (JavaModelException npe) {
- return;
- }
-}
-/**
- * Changes the source indexes of this element and all children elements.
- */
-public void offsetSourceRange(int amount) {
- try {
- SourceRefElementInfo info = (SourceRefElementInfo) getRawInfo();
- info.setSourceRangeStart(info.getDeclarationSourceStart() + amount);
- info.setSourceRangeEnd(info.getDeclarationSourceEnd() + amount);
- IJavaElement[] children = getChildren();
- for (int i = 0; i < children.length; i++) {
- IJavaElement aChild = children[i];
- ((JavaElement) aChild).offsetSourceRange(amount);
- }
- } catch (JavaModelException npe) {
- return;
- }
-}
-/**
* @see ISourceManipulation
*/
public void rename(String name, boolean force, IProgressMonitor monitor) throws JavaModelException {
@@ -204,29 +166,4 @@
// not needed
return null;
}
-/**
- * Updates the end source index for this element, and all following elements.
- */
-public void triggerSourceEndOffset(int amount, int nameStart, int nameEnd) {
- try {
- SourceRefElementInfo info = (SourceRefElementInfo) getRawInfo();
- info.setSourceRangeEnd(info.getDeclarationSourceEnd() + amount);
- ((JavaElement) getParent()).offsetSourceEndAndChildren(amount, this);
- } catch (JavaModelException npe) {
- return;
- }
-}
-/**
- * Updates the source indexes of this element and all following elements.
- */
-public void triggerSourceRangeOffset(int amount, int nameStart, int nameEnd) {
- try {
- SourceRefElementInfo info = (SourceRefElementInfo) getRawInfo();
- info.setSourceRangeStart(info.getDeclarationSourceStart() + amount);
- info.setSourceRangeEnd(info.getDeclarationSourceEnd() + amount);
- ((JavaElement) getParent()).offsetSourceEndAndChildren(amount, this);
- } catch (JavaModelException npe) {
- return;
- }
-}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElementInfo.java
index 84689cc..79f1fc9 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceRefElementInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.ISourceRange;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java
index 67bf0eb..92debd8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceType.java
@@ -1,31 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
+import java.io.InputStream;
import java.util.ArrayList;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.ICompletionRequestor;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IInitializer;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeHierarchy;
-import org.eclipse.jdt.core.IWorkingCopy;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.jdom.IDOMNode;
import org.eclipse.jdt.core.search.SearchEngine;
@@ -34,7 +24,7 @@
import org.eclipse.jdt.internal.codeassist.ISelectionRequestor;
import org.eclipse.jdt.internal.codeassist.SelectionEngine;
import org.eclipse.jdt.internal.compiler.env.ISourceType;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.internal.core.hierarchy.TypeHierarchy;
/**
* Handle for a source type. Info object is a SourceTypeElementInfo.
@@ -61,13 +51,14 @@
throw new IllegalArgumentException(Util.bind("codeAssist.nullRequestor")); //$NON-NLS-1$
}
- SearchableEnvironment environment = (SearchableEnvironment) ((JavaProject) getJavaProject()).getSearchableNameEnvironment();
- NameLookup nameLookup = ((JavaProject) getJavaProject()).getNameLookup();
- CompletionEngine engine = new CompletionEngine(environment, new CompletionRequestorWrapper(requestor,nameLookup), JavaCore.getOptions());
+ JavaProject project = (JavaProject) getJavaProject();
+ SearchableEnvironment environment = (SearchableEnvironment) project.getSearchableNameEnvironment();
+ NameLookup nameLookup = project.getNameLookup();
+ CompletionEngine engine = new CompletionEngine(environment, new CompletionRequestorWrapper(requestor,nameLookup), project.getOptions(true), project);
String source = getCompilationUnit().getSource();
if (source != null && insertion > -1 && insertion < source.length()) {
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
+ String encoding = project.getOption(JavaCore.CORE_ENCODING, true);
char[] prefix = CharOperation.concat(source.substring(0, insertion).toCharArray(), new char[]{'{'});
char[] suffix = CharOperation.concat(new char[]{'}'}, source.substring(insertion).toCharArray());
@@ -334,9 +325,14 @@
* @see IType#isMember()
*/
public boolean isMember() throws JavaModelException {
- return getDeclaringType() == null;
+ return getDeclaringType() != null;
}
-
+/**
+ * @see IType
+ */
+public ITypeHierarchy loadTypeHierachy(InputStream input, IProgressMonitor monitor) throws JavaModelException {
+ return TypeHierarchy.load(this, input);
+}
/**
* @see IType
*/
@@ -385,8 +381,8 @@
CreateTypeHierarchyOperation op= new CreateTypeHierarchyOperation(
this,
- null, // no working copies
- SearchEngine.createJavaSearchScope(new IJavaElement[] {project}),
+ (IWorkingCopy[])null, // no working copies
+ project,
true);
runOperation(op, monitor);
return op.getResult();
@@ -427,9 +423,16 @@
}
TypeResolveRequestor requestor = new TypeResolveRequestor();
SelectionEngine engine =
- new SelectionEngine(environment, requestor, JavaCore.getOptions());
+ new SelectionEngine(environment, requestor, this.getJavaProject().getOptions(true));
- engine.selectType(info, typeName.toCharArray(), false);
+ IType[] topLevelTypes = this.getCompilationUnit().getTypes();
+ int length = topLevelTypes.length;
+ ISourceType[] topLevelInfos = new ISourceType[length];
+ for (int i = 0; i < length; i++) {
+ topLevelInfos[i] = (ISourceType)((SourceType)topLevelTypes[i]).getElementInfo();
+ }
+
+ engine.selectType(info, typeName.toCharArray(), topLevelInfos, false);
return requestor.answers;
}
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceTypeElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceTypeElementInfo.java
index 3d63062..5f4e0ce 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceTypeElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceTypeElementInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IJavaElement;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeConverter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeConverter.java
index 325ff0e..ed023d8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeConverter.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeConverter.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IField;
@@ -15,6 +15,7 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
@@ -31,8 +32,6 @@
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
-import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* Converter from a type to an AST type declaration.
@@ -42,7 +41,7 @@
/**
* Convert a type into an AST type declaration and put it in the given compilation unit.
*/
- public static TypeDeclaration buildTypeDeclaration(IType type, CompilationUnitDeclaration compilationUnit, CompilationResult compilationResult, ProblemReporter problemReporter) throws JavaModelException {
+ public static TypeDeclaration buildTypeDeclaration(IType type, CompilationUnitDeclaration compilationUnit, CompilationResult compilationResult) throws JavaModelException {
char[] packageName = type.getPackageFragment().getElementName().toCharArray();
if (packageName != null && packageName.length > 0) {
@@ -199,7 +198,6 @@
private static TypeReference createTypeReference(char[] type, IType contextType) {
try {
String[][] resolvedName = contextType.resolveType(new String(type));
- char[] superClassName = null;
if(resolvedName != null && resolvedName.length == 1) {
type= CharOperation.concat(resolvedName[0][0].toCharArray(), resolvedName[0][1].toCharArray(), '.');
}
@@ -234,7 +232,7 @@
return new ArrayTypeReference(identifier, dim, 0);
}
} else { // qualified type reference
- char[][] identifiers = CharOperation.splitOn('.', type, 0, dimStart - 1);
+ char[][] identifiers = CharOperation.splitOn('.', type, 0, dimStart);
if (dim == 0) {
return new QualifiedTypeReference(identifiers, new long[]{0});
} else {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java
index 36c0f29..a32bb8e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/TypeVector.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.IType;
@@ -18,6 +18,9 @@
public int size;
int maxSize;
IType[] elements;
+
+ public final static IType[] NoElements = new IType[0];
+
public TypeVector() {
maxSize = INITIAL_SIZE;
size = 0;
@@ -66,6 +69,10 @@
return elements[index];
}
public IType[] elements() {
+
+ // do not resize to 0 if empty since may add more elements later
+ if (this.size == 0) return NoElements;
+
if (this.size < this.maxSize) {
maxSize = size;
System.arraycopy(this.elements, 0, (this.elements = new IType[maxSize]), 0, size);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Util.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Util.java
index 6803bf3..2fa59bc 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Util.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Util.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import java.io.BufferedInputStream;
@@ -19,16 +19,18 @@
import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.IJavaModelStatusConstants;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.core.util.CharArrayBuffer;
/**
@@ -57,6 +59,10 @@
int compare(Object a, Object b);
}
+ public interface Displayable {
+ String displayString(Object o);
+ }
+
public static final String[] fgEmptyStringArray = new String[0];
/**
@@ -72,12 +78,92 @@
public final static char[] SUFFIX_CLASS = ".CLASS".toCharArray(); //$NON-NLS-1$
public final static char[] SUFFIX_java = ".java".toCharArray(); //$NON-NLS-1$
public final static char[] SUFFIX_JAVA = ".JAVA".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_jar = ".jar".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_JAR = ".JAR".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_zip = ".zip".toCharArray(); //$NON-NLS-1$
+ public final static char[] SUFFIX_ZIP = ".ZIP".toCharArray(); //$NON-NLS-1$
static {
String ver = System.getProperty("java.version"); //$NON-NLS-1$
JDK1_1 = ((ver != null) && ver.startsWith("1.1")); //$NON-NLS-1$
relocalize();
}
+
+ /**
+ * Lookup the message with the given ID in this catalog
+ */
+ public static String bind(String id) {
+ return bind(id, (String[])null);
+ }
+
+ /**
+ * Lookup the message with the given ID in this catalog and bind its
+ * substitution locations with the given string values.
+ */
+ public static String bind(String id, String[] bindings) {
+ if (id == null)
+ return "No message available"; //$NON-NLS-1$
+ String message = null;
+ try {
+ message = bundle.getString(id);
+ } catch (MissingResourceException e) {
+ // If we got an exception looking for the message, fail gracefully by just returning
+ // the id we were looking for. In most cases this is semi-informative so is not too bad.
+ return "Missing message: " + id + " in: " + bundleName; //$NON-NLS-2$ //$NON-NLS-1$
+ }
+ // for compatibility with MessageFormat which eliminates double quotes in original message
+ char[] messageWithNoDoubleQuotes =
+ CharOperation.replace(message.toCharArray(), DOUBLE_QUOTES, SINGLE_QUOTE);
+ message = new String(messageWithNoDoubleQuotes);
+
+ if (bindings == null)
+ return message;
+
+ int length = message.length();
+ int start = -1;
+ int end = length;
+ StringBuffer output = new StringBuffer(80);
+ while (true) {
+ if ((end = message.indexOf('{', start)) > -1) {
+ output.append(message.substring(start + 1, end));
+ if ((start = message.indexOf('}', end)) > -1) {
+ int index = -1;
+ try {
+ index = Integer.parseInt(message.substring(end + 1, start));
+ output.append(bindings[index]);
+ } catch (NumberFormatException nfe) {
+ output.append(message.substring(end + 1, start + 1));
+ } catch (ArrayIndexOutOfBoundsException e) {
+ output.append("{missing " + Integer.toString(index) + "}"); //$NON-NLS-2$ //$NON-NLS-1$
+ }
+ } else {
+ output.append(message.substring(end, length));
+ break;
+ }
+ } else {
+ output.append(message.substring(start + 1, length));
+ break;
+ }
+ }
+ return output.toString();
+ }
+
+ /**
+ * Lookup the message with the given ID in this catalog and bind its
+ * substitution locations with the given string.
+ */
+ public static String bind(String id, String binding) {
+ return bind(id, new String[] {binding});
+ }
+
+ /**
+ * Lookup the message with the given ID in this catalog and bind its
+ * substitution locations with the given strings.
+ */
+ public static String bind(String id, String binding1, String binding2) {
+ return bind(id, new String[] {binding1, binding2});
+ }
+
/**
* Checks the type signature in String sig,
* starting at start and ending before end (end is not included).
@@ -120,60 +206,64 @@
}
return i;
}
-/**
- * Combines two hash codes to make a new one.
- */
-public static int combineHashCodes(int hashCode1, int hashCode2) {
- return hashCode1 * 17 + hashCode2;
-}
-/**
- * Compares two byte arrays.
- * Returns <0 if a byte in a is less than the corresponding byte in b, or if a is shorter, or if a is null.
- * Returns >0 if a byte in a is greater than the corresponding byte in b, or if a is longer, or if b is null.
- * Returns 0 if they are equal or both null.
- */
-public static int compare(byte[] a, byte[] b) {
- if (a == b)
- return 0;
- if (a == null)
- return -1;
- if (b == null)
- return 1;
- int len = Math.min(a.length, b.length);
- for (int i = 0; i < len; ++i) {
- int diff = a[i] - b[i];
- if (diff != 0)
- return diff;
+
+ /**
+ * Combines two hash codes to make a new one.
+ */
+ public static int combineHashCodes(int hashCode1, int hashCode2) {
+ return hashCode1 * 17 + hashCode2;
}
- if (a.length > len)
- return 1;
- if (b.length > len)
- return -1;
- return 0;
-}
-/**
- * Compares two char arrays lexicographically.
- * The comparison is based on the Unicode value of each character in
- * the char arrays.
- * @return the value <code>0</code> if a is equal to
- * b; a value less than <code>0</code> if a
- * is lexicographically less than b; and a
- * value greater than <code>0</code> if a is
- * lexicographically greater than b.
- */
-public static int compare(char[] v1, char[] v2) {
- int len1 = v1.length;
- int len2 = v2.length;
- int n = Math.min(len1, len2);
- int i = 0;
- while (n-- != 0) {
- if (v1[i] != v2[i]) {
- return v1[i] - v2[i];
+
+ /**
+ * Compares two byte arrays.
+ * Returns <0 if a byte in a is less than the corresponding byte in b, or if a is shorter, or if a is null.
+ * Returns >0 if a byte in a is greater than the corresponding byte in b, or if a is longer, or if b is null.
+ * Returns 0 if they are equal or both null.
+ */
+ public static int compare(byte[] a, byte[] b) {
+ if (a == b)
+ return 0;
+ if (a == null)
+ return -1;
+ if (b == null)
+ return 1;
+ int len = Math.min(a.length, b.length);
+ for (int i = 0; i < len; ++i) {
+ int diff = a[i] - b[i];
+ if (diff != 0)
+ return diff;
}
- ++i;
+ if (a.length > len)
+ return 1;
+ if (b.length > len)
+ return -1;
+ return 0;
}
- return len1 - len2;
-}
+
+ /**
+ * Compares two char arrays lexicographically.
+ * The comparison is based on the Unicode value of each character in
+ * the char arrays.
+ * @return the value <code>0</code> if a is equal to
+ * b; a value less than <code>0</code> if a
+ * is lexicographically less than b; and a
+ * value greater than <code>0</code> if a is
+ * lexicographically greater than b.
+ */
+ public static int compare(char[] v1, char[] v2) {
+ int len1 = v1.length;
+ int len2 = v2.length;
+ int n = Math.min(len1, len2);
+ int i = 0;
+ while (n-- != 0) {
+ if (v1[i] != v2[i]) {
+ return v1[i] - v2[i];
+ }
+ ++i;
+ }
+ return len1 - len2;
+ }
+
/**
* Concatenate two strings with a char in between.
* @see #concat(String, String)
@@ -189,6 +279,7 @@
s2.getChars(0, l2, buf, l1 + 1);
return new String(buf);
}
+
/**
* Concatenate two strings.
* Much faster than using +, which:
@@ -227,805 +318,13 @@
s3.getChars(0, l3, buf, l1 + l2);
return new String(buf);
}
-/**
- * Converts a type signature from the IBinaryType representation to the DC representation.
- */
-public static String convertTypeSignature(char[] sig) {
- return new String(sig).replace('/', '.');
-}
-/**
- * Compares two arrays using equals() on the elements.
- * Either or both arrays may be null.
- * Returns true if both are null.
- * Returns false if only one is null.
- * If both are arrays, returns true iff they have the same length and
- * all elements are equal.
- */
-public static boolean equalArraysOrNull(int[] a, int[] b) {
- if (a == b)
- return true;
- if (a == null || b == null)
- return false;
- int len = a.length;
- if (len != b.length)
- return false;
- for (int i = 0; i < len; ++i) {
- if (a[i] != b[i])
- return false;
- }
- return true;
-}
- /**
- * Compares two arrays using equals() on the elements.
- * Either or both arrays may be null.
- * Returns true if both are null.
- * Returns false if only one is null.
- * If both are arrays, returns true iff they have the same length and
- * all elements compare true with equals.
- */
- public static boolean equalArraysOrNull(Object[] a, Object[] b) {
- if (a == b) return true;
- if (a == null || b == null) return false;
-
- int len = a.length;
- if (len != b.length) return false;
- for (int i = 0; i < len; ++i) {
- if (a[i] == null) {
- if (b[i] != null) return false;
- } else {
- if (!a[i].equals(b[i])) return false;
- }
- }
- return true;
- }
- /**
- * Compares two String arrays using equals() on the elements.
- * The arrays are first sorted.
- * Either or both arrays may be null.
- * Returns true if both are null.
- * Returns false if only one is null.
- * If both are arrays, returns true iff they have the same length and
- * iff, after sorting both arrays, all elements compare true with equals.
- * The original arrays are left untouched.
- */
- public static boolean equalArraysOrNullSortFirst(String[] a, String[] b) {
- if (a == b) return true;
- if (a == null || b == null) return false;
- int len = a.length;
- if (len != b.length) return false;
- if (len >= 2) { // only need to sort if more than two items
- a = sortCopy(a);
- b = sortCopy(b);
- }
- for (int i = 0; i < len; ++i) {
- if (!a[i].equals(b[i])) return false;
- }
- return true;
- }
- /**
- * Compares two arrays using equals() on the elements.
- * The arrays are first sorted.
- * Either or both arrays may be null.
- * Returns true if both are null.
- * Returns false if only one is null.
- * If both are arrays, returns true iff they have the same length and
- * iff, after sorting both arrays, all elements compare true with equals.
- * The original arrays are left untouched.
- */
- public static boolean equalArraysOrNullSortFirst(Comparable[] a, Comparable[] b) {
- if (a == b) return true;
- if (a == null || b == null) return false;
- int len = a.length;
- if (len != b.length) return false;
- if (len >= 2) { // only need to sort if more than two items
- a = sortCopy(a);
- b = sortCopy(b);
- }
- for (int i = 0; i < len; ++i) {
- if (!a[i].equals(b[i])) return false;
- }
- return true;
- }
- /**
- * Compares two objects using equals().
- * Either or both array may be null.
- * Returns true if both are null.
- * Returns false if only one is null.
- * Otherwise, return the result of comparing with equals().
- */
- public static boolean equalOrNull(Object a, Object b) {
- if (a == b) {
- return true;
- }
- if (a == null || b == null) {
- return false;
- }
- return a.equals(b);
- }
- /**
- * Given a qualified name, extract the last component.
- * If the input is not qualified, the same string is answered.
- */
- public static String extractLastName(String qualifiedName) {
- int i = qualifiedName.lastIndexOf('.');
- if (i == -1) return qualifiedName;
- return qualifiedName.substring(i+1);
- }
-/**
- * Extracts the parameter types from a method signature.
- */
-public static String[] extractParameterTypes(char[] sig) {
- int count = getParameterCount(sig);
- String[] result = new String[count];
- if (count == 0)
- return result;
- int i = CharOperation.indexOf('(', sig) + 1;
- count = 0;
- int len = sig.length;
- int start = i;
- for (;;) {
- if (i == len)
- break;
- char c = sig[i];
- if (c == ')')
- break;
- if (c == '[') {
- ++i;
- } else
- if (c == 'L') {
- i = CharOperation.indexOf(';', sig, i + 1) + 1;
- Assert.isTrue(i != 0);
- result[count++] = convertTypeSignature(CharOperation.subarray(sig, start, i));
- start = i;
- } else {
- ++i;
- result[count++] = convertTypeSignature(CharOperation.subarray(sig, start, i));
- start = i;
- }
- }
- return result;
-}
- /**
- * Extracts the return type from a method signature.
- */
- public static String extractReturnType(String sig) {
- int i = sig.lastIndexOf(')');
- Assert.isTrue(i != -1);
- return sig.substring(i+1);
- }
-/**
- * Finds the first line separator used by the given text.
- *
- * @return </code>"\n"</code> or </code>"\r"</code> or </code>"\r\n"</code>,
- * or <code>null</code> if none found
- */
-private static String findLineSeparator(char[] text) {
- // find the first line separator
- int length = text.length;
- if (length > 0) {
- char nextChar = text[0];
- for (int i = 0; i < length; i++) {
- char currentChar = nextChar;
- nextChar = i < length-1 ? text[i+1] : ' ';
- switch (currentChar) {
- case '\n': return "\n"; //$NON-NLS-1$
- case '\r': return nextChar == '\n' ? "\r\n" : "\r"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- // not found
- return null;
-}
-/**
- * Returns the line separator used by the given buffer.
- * Uses the given text if none found.
- *
- * @return </code>"\n"</code> or </code>"\r"</code> or </code>"\r\n"</code>
- */
-private static String getLineSeparator(char[] text, char[] buffer) {
- // search in this buffer's contents first
- String lineSeparator = findLineSeparator(buffer);
- if (lineSeparator == null) {
- // search in the given text
- lineSeparator = findLineSeparator(text);
- if (lineSeparator == null) {
- // default to system line separator
- return org.eclipse.jdt.internal.compiler.util.Util.LINE_SEPARATOR;
- }
- }
- return lineSeparator;
-}
-
-
-/**
- * Returns the number of parameter types in a method signature.
- */
-public static int getParameterCount(char[] sig) {
- int i = CharOperation.indexOf('(', sig) + 1;
- Assert.isTrue(i != 0);
- int count = 0;
- int len = sig.length;
- for (;;) {
- if (i == len)
- break;
- char c = sig[i];
- if (c == ')')
- break;
- if (c == '[') {
- ++i;
- } else
- if (c == 'L') {
- ++count;
- i = CharOperation.indexOf(';', sig, i + 1) + 1;
- Assert.isTrue(i != 0);
- } else {
- ++count;
- ++i;
- }
- }
- return count;
-}
-/**
- * Returns the given file's contents as a byte array.
- */
-public static byte[] getResourceContentsAsByteArray(IFile file) throws JavaModelException {
- InputStream stream= null;
- try {
- stream = new BufferedInputStream(file.getContents(true));
- } catch (CoreException e) {
- throw new JavaModelException(e);
- }
- try {
- return org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(stream, -1);
- } catch (IOException e) {
- throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- }
- }
-}
-/**
- * Returns the given file's contents as a character array.
- */
-public static char[] getResourceContentsAsCharArray(IFile file) throws JavaModelException {
- InputStream stream= null;
- try {
- stream = new BufferedInputStream(file.getContents(true));
- } catch (CoreException e) {
- throw new JavaModelException(e);
- }
- try {
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
- return org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray(stream, -1, encoding);
- } catch (IOException e) {
- throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
- } finally {
- try {
- stream.close();
- } catch (IOException e) {
- }
- }
-}
/**
- * Returns true if the given method signature is valid,
- * false if it is not.
+ * Converts a type signature from the IBinaryType representation to the DC representation.
*/
- public static boolean isValidMethodSignature(String sig) {
- int len = sig.length();
- if (len == 0) return false;
- int i = 0;
- char c = sig.charAt(i++);
- if (c != '(') return false;
- if (i >= len) return false;
- while (sig.charAt(i) != ')') {
- // Void is not allowed as a parameter type.
- i = checkTypeSignature(sig, i, len, false);
- if (i == -1) return false;
- if (i >= len) return false;
- }
- ++i;
- i = checkTypeSignature(sig, i, len, true);
- return i == len;
+ public static String convertTypeSignature(char[] sig) {
+ return new String(sig).replace('/', '.');
}
- /**
- * Returns true if the given type signature is valid,
- * false if it is not.
- */
- public static boolean isValidTypeSignature(String sig, boolean allowVoid) {
- int len = sig.length();
- return checkTypeSignature(sig, 0, len, allowVoid) == len;
- }
- /**
- * Returns true if the given folder name is valid for a package,
- * false if it is not.
- */
- public static boolean isValidFolderNameForPackage(String folderName) {
- return JavaConventions.validateIdentifier(folderName).getSeverity() != IStatus.ERROR;
- }
-
- /*
- * Add a log entry
- */
- public static void log(Throwable e, String message) {
- IStatus status= new Status(
- IStatus.ERROR,
- JavaCore.getPlugin().getDescriptor().getUniqueIdentifier(),
- IStatus.ERROR,
- message,
- e);
- JavaCore.getPlugin().getLog().log(status);
- }
-
-/**
- * Normalizes the cariage returns in the given text.
- * They are all changed to use the given buffer's line sepatator.
- */
-public static char[] normalizeCRs(char[] text, char[] buffer) {
- CharArrayBuffer result = new CharArrayBuffer();
- int lineStart = 0;
- int length = text.length;
- if (length == 0) return text;
- String lineSeparator = getLineSeparator(text, buffer);
- char nextChar = text[0];
- for (int i = 0; i < length; i++) {
- char currentChar = nextChar;
- nextChar = i < length-1 ? text[i+1] : ' ';
- switch (currentChar) {
- case '\n':
- int lineLength = i-lineStart;
- char[] line = new char[lineLength];
- System.arraycopy(text, lineStart, line, 0, lineLength);
- result.append(line);
- result.append(lineSeparator);
- lineStart = i+1;
- break;
- case '\r':
- lineLength = i-lineStart;
- if (lineLength >= 0) {
- line = new char[lineLength];
- System.arraycopy(text, lineStart, line, 0, lineLength);
- result.append(line);
- result.append(lineSeparator);
- if (nextChar == '\n') {
- nextChar = ' ';
- lineStart = i+2;
- } else {
- // when line separator are mixed in the same file
- // \r might not be followed by a \n. If not, we should increment
- // lineStart by one and not by two.
- lineStart = i+1;
- }
- } else {
- // when line separator are mixed in the same file
- // we need to prevent NegativeArraySizeException
- lineStart = i+1;
- }
- break;
- }
- }
- char[] lastLine;
- if (lineStart > 0) {
- int lastLineLength = length-lineStart;
- if (lastLineLength > 0) {
- lastLine = new char[lastLineLength];
- System.arraycopy(text, lineStart, lastLine, 0, lastLineLength);
- result.append(lastLine);
- }
- return result.getContents();
- } else {
- return text;
- }
-}
-
-/**
- * Normalizes the cariage returns in the given text.
- * They are all changed to use given buffer's line sepatator.
- */
-public static String normalizeCRs(String text, String buffer) {
- return new String(normalizeCRs(text.toCharArray(), buffer.toCharArray()));
-}
-
-
-
-/**
- * Sort the objects in the given collection using the given sort order.
- */
-private static void quickSort(Object[] sortedCollection, int left, int right, int[] sortOrder) {
- int original_left = left;
- int original_right = right;
- int mid = sortOrder[ (left + right) / 2];
- do {
- while (sortOrder[left] < mid) {
- left++;
- }
- while (mid < sortOrder[right]) {
- right--;
- }
- if (left <= right) {
- Object tmp = sortedCollection[left];
- sortedCollection[left] = sortedCollection[right];
- sortedCollection[right] = tmp;
- int tmp2 = sortOrder[left];
- sortOrder[left] = sortOrder[right];
- sortOrder[right] = tmp2;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(sortedCollection, original_left, right, sortOrder);
- }
- if (left < original_right) {
- quickSort(sortedCollection, left, original_right, sortOrder);
- }
-}
-/**
- * Sort the objects in the given collection using the given comparer.
- */
-private static void quickSort(Object[] sortedCollection, int left, int right, Comparer comparer) {
- int original_left = left;
- int original_right = right;
- Object mid = sortedCollection[ (left + right) / 2];
- do {
- while (comparer.compare(sortedCollection[left], mid) < 0) {
- left++;
- }
- while (comparer.compare(mid, sortedCollection[right]) < 0) {
- right--;
- }
- if (left <= right) {
- Object tmp = sortedCollection[left];
- sortedCollection[left] = sortedCollection[right];
- sortedCollection[right] = tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(sortedCollection, original_left, right, comparer);
- }
- if (left < original_right) {
- quickSort(sortedCollection, left, original_right, comparer);
- }
-}
-/**
- * Sort the strings in the given collection.
- */
-private static void quickSort(String[] sortedCollection, int left, int right) {
- int original_left = left;
- int original_right = right;
- String mid = sortedCollection[ (left + right) / 2];
- do {
- while (sortedCollection[left].compareTo(mid) < 0) {
- left++;
- }
- while (mid.compareTo(sortedCollection[right]) < 0) {
- right--;
- }
- if (left <= right) {
- String tmp = sortedCollection[left];
- sortedCollection[left] = sortedCollection[right];
- sortedCollection[right] = tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(sortedCollection, original_left, right);
- }
- if (left < original_right) {
- quickSort(sortedCollection, left, original_right);
- }
-}
-/**
- * Converts the given relative path into a package name.
- * Returns null if the path is not a valid package name.
- */
-public static String packageName(IPath pkgPath) {
- StringBuffer pkgName = new StringBuffer(IPackageFragment.DEFAULT_PACKAGE_NAME);
- for (int j = 0, max = pkgPath.segmentCount(); j < max; j++) {
- String segment = pkgPath.segment(j);
- if (!isValidFolderNameForPackage(segment)) {
- return null;
- }
- pkgName.append(segment);
- if (j < pkgPath.segmentCount() - 1) {
- pkgName.append("." ); //$NON-NLS-1$
- }
- }
- return pkgName.toString();
-}
-/**
- * Sort the comparable objects in the given collection.
- */
-private static void quickSort(Comparable[] sortedCollection, int left, int right) {
- int original_left = left;
- int original_right = right;
- Comparable mid = sortedCollection[ (left + right) / 2];
- do {
- while (sortedCollection[left].compareTo(mid) < 0) {
- left++;
- }
- while (mid.compareTo(sortedCollection[right]) < 0) {
- right--;
- }
- if (left <= right) {
- Comparable tmp = sortedCollection[left];
- sortedCollection[left] = sortedCollection[right];
- sortedCollection[right] = tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSort(sortedCollection, original_left, right);
- }
- if (left < original_right) {
- quickSort(sortedCollection, left, original_right);
- }
-}
-/**
- * Sort the strings in the given collection in reverse alphabetical order.
- */
-private static void quickSortReverse(String[] sortedCollection, int left, int right) {
- int original_left = left;
- int original_right = right;
- String mid = sortedCollection[ (left + right) / 2];
- do {
- while (sortedCollection[left].compareTo(mid) > 0) {
- left++;
- }
- while (mid.compareTo(sortedCollection[right]) > 0) {
- right--;
- }
- if (left <= right) {
- String tmp = sortedCollection[left];
- sortedCollection[left] = sortedCollection[right];
- sortedCollection[right] = tmp;
- left++;
- right--;
- }
- } while (left <= right);
- if (original_left < right) {
- quickSortReverse(sortedCollection, original_left, right);
- }
- if (left < original_right) {
- quickSortReverse(sortedCollection, left, original_right);
- }
-}
-/**
- * Sorts an array of objects in place, using the sort order given for each item.
- */
-public static void sort(Object[] objects, int[] sortOrder) {
- if (objects.length > 1)
- quickSort(objects, 0, objects.length - 1, sortOrder);
-}
-/**
- * Sorts an array of objects in place.
- * The given comparer compares pairs of items.
- */
-public static void sort(Object[] objects, Comparer comparer) {
- if (objects.length > 1)
- quickSort(objects, 0, objects.length - 1, comparer);
-}
-/**
- * Sorts an array of strings in place using quicksort.
- */
-public static void sort(String[] strings) {
- if (strings.length > 1)
- quickSort(strings, 0, strings.length - 1);
-}
-/**
- * Sorts an array of Comparable objects in place.
- */
-public static void sort(Comparable[] objects) {
- if (objects.length > 1)
- quickSort(objects, 0, objects.length - 1);
-}
- /**
- * Sorts an array of Strings, returning a new array
- * with the sorted items. The original array is left untouched.
- */
- public static Object[] sortCopy(Object[] objects, Comparer comparer) {
- int len = objects.length;
- Object[] copy = new Object[len];
- System.arraycopy(objects, 0, copy, 0, len);
- sort(copy, comparer);
- return copy;
- }
- /**
- * Sorts an array of Strings, returning a new array
- * with the sorted items. The original array is left untouched.
- */
- public static String[] sortCopy(String[] objects) {
- int len = objects.length;
- String[] copy = new String[len];
- System.arraycopy(objects, 0, copy, 0, len);
- sort(copy);
- return copy;
- }
- /**
- * Sorts an array of Comparable objects, returning a new array
- * with the sorted items. The original array is left untouched.
- */
- public static Comparable[] sortCopy(Comparable[] objects) {
- int len = objects.length;
- Comparable[] copy = new Comparable[len];
- System.arraycopy(objects, 0, copy, 0, len);
- sort(copy);
- return copy;
- }
-/**
- * Sorts an array of strings in place using quicksort
- * in reverse alphabetical order.
- */
-public static void sortReverseOrder(String[] strings) {
- if (strings.length > 1)
- quickSortReverse(strings, 0, strings.length - 1);
-}
- /**
- * Converts a String[] to char[][].
- */
- public static char[][] toCharArrays(String[] a) {
- int len = a.length;
- char[][] result = new char[len][];
- for (int i = 0; i < len; ++i) {
- result[i] = toChars(a[i]);
- }
- return result;
- }
- /**
- * Converts a String to char[].
- */
- public static char[] toChars(String s) {
- int len = s.length();
- char[] chars = new char[len];
- s.getChars(0, len, chars, 0);
- return chars;
- }
- /**
- * Converts a String to char[][], where segments are separate by '.'.
- */
- public static char[][] toCompoundChars(String s) {
- int len = s.length();
- if (len == 0) {
- return new char[0][];
- }
- int segCount = 1;
- for (int off = s.indexOf('.'); off != -1; off = s.indexOf('.', off + 1)) {
- ++segCount;
- }
- char[][] segs = new char[segCount][];
- int start = 0;
- for (int i = 0; i < segCount; ++i) {
- int dot = s.indexOf('.', start);
- int end = (dot == -1 ? s.length() : dot);
- segs[i] = new char[end - start];
- s.getChars(start, end, segs[i], 0);
- start = end + 1;
- }
- return segs;
- }
- /**
- * Converts a char[][] to String, where segments are separated by '.'.
- */
- public static String toString(char[][] c) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0, max = c.length; i < max; ++i) {
- if (i != 0) sb.append('.');
- sb.append(c[i]);
- }
- return sb.toString();
- }
- /**
- * Converts a char[][] and a char[] to String, where segments are separated by '.'.
- */
- public static String toString(char[][] c, char[] d) {
- if (c == null) return new String(d);
- StringBuffer sb = new StringBuffer();
- for (int i = 0, max = c.length; i < max; ++i) {
- sb.append(c[i]);
- sb.append('.');
- }
- sb.append(d);
- return sb.toString();
- }
- /**
- * Converts a char[] to String.
- */
- public static String toString(char[] c) {
- return new String(c);
- }
- /**
- * Asserts that the given method signature is valid.
- */
- public static void validateMethodSignature(String sig) {
- Assert.isTrue(isValidMethodSignature(sig));
- }
- /**
- * Asserts that the given type signature is valid.
- */
- public static void validateTypeSignature(String sig, boolean allowVoid) {
- Assert.isTrue(isValidTypeSignature(sig, allowVoid));
- }
-
-/**
- * Lookup the message with the given ID in this catalog
- */
-public static String bind(String id) {
- return bind(id, (String[])null);
-}
-
-/**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string values.
- */
-public static String bind(String id, String[] bindings) {
- if (id == null)
- return "No message available"; //$NON-NLS-1$
- String message = null;
- try {
- message = bundle.getString(id);
- } catch (MissingResourceException e) {
- // If we got an exception looking for the message, fail gracefully by just returning
- // the id we were looking for. In most cases this is semi-informative so is not too bad.
- return "Missing message: " + id + " in: " + bundleName; //$NON-NLS-2$ //$NON-NLS-1$
- }
- // for compatibility with MessageFormat which eliminates double quotes in original message
- char[] messageWithNoDoubleQuotes =
- CharOperation.replace(message.toCharArray(), DOUBLE_QUOTES, SINGLE_QUOTE);
- message = new String(messageWithNoDoubleQuotes);
-
- if (bindings == null)
- return message;
-
- int length = message.length();
- int start = -1;
- int end = length;
- StringBuffer output = new StringBuffer(80);
- while (true) {
- if ((end = message.indexOf('{', start)) > -1) {
- output.append(message.substring(start + 1, end));
- if ((start = message.indexOf('}', end)) > -1) {
- int index = -1;
- try {
- index = Integer.parseInt(message.substring(end + 1, start));
- output.append(bindings[index]);
- } catch (NumberFormatException nfe) {
- output.append(message.substring(end + 1, start + 1));
- } catch (ArrayIndexOutOfBoundsException e) {
- output.append("{missing " + Integer.toString(index) + "}"); //$NON-NLS-2$ //$NON-NLS-1$
- }
- } else {
- output.append(message.substring(end, length));
- break;
- }
- } else {
- output.append(message.substring(start + 1, length));
- break;
- }
- }
- return output.toString();
-}
-
-/**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given string.
- */
-public static String bind(String id, String binding) {
- return bind(id, new String[] {binding});
-}
-
-/**
- * Lookup the message with the given ID in this catalog and bind its
- * substitution locations with the given strings.
- */
-public static String bind(String id, String binding1, String binding2) {
- return bind(id, new String[] {binding1, binding2});
-}
/**
* Returns true iff str.toLowerCase().endsWith(end.toLowerCase())
@@ -1051,6 +350,308 @@
}
/**
+ * Compares two arrays using equals() on the elements.
+ * Either or both arrays may be null.
+ * Returns true if both are null.
+ * Returns false if only one is null.
+ * If both are arrays, returns true iff they have the same length and
+ * all elements are equal.
+ */
+ public static boolean equalArraysOrNull(int[] a, int[] b) {
+ if (a == b)
+ return true;
+ if (a == null || b == null)
+ return false;
+ int len = a.length;
+ if (len != b.length)
+ return false;
+ for (int i = 0; i < len; ++i) {
+ if (a[i] != b[i])
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Compares two arrays using equals() on the elements.
+ * Either or both arrays may be null.
+ * Returns true if both are null.
+ * Returns false if only one is null.
+ * If both are arrays, returns true iff they have the same length and
+ * all elements compare true with equals.
+ */
+ public static boolean equalArraysOrNull(Object[] a, Object[] b) {
+ if (a == b) return true;
+ if (a == null || b == null) return false;
+
+ int len = a.length;
+ if (len != b.length) return false;
+ for (int i = 0; i < len; ++i) {
+ if (a[i] == null) {
+ if (b[i] != null) return false;
+ } else {
+ if (!a[i].equals(b[i])) return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Compares two String arrays using equals() on the elements.
+ * The arrays are first sorted.
+ * Either or both arrays may be null.
+ * Returns true if both are null.
+ * Returns false if only one is null.
+ * If both are arrays, returns true iff they have the same length and
+ * iff, after sorting both arrays, all elements compare true with equals.
+ * The original arrays are left untouched.
+ */
+ public static boolean equalArraysOrNullSortFirst(String[] a, String[] b) {
+ if (a == b) return true;
+ if (a == null || b == null) return false;
+ int len = a.length;
+ if (len != b.length) return false;
+ if (len >= 2) { // only need to sort if more than two items
+ a = sortCopy(a);
+ b = sortCopy(b);
+ }
+ for (int i = 0; i < len; ++i) {
+ if (!a[i].equals(b[i])) return false;
+ }
+ return true;
+ }
+
+ /**
+ * Compares two arrays using equals() on the elements.
+ * The arrays are first sorted.
+ * Either or both arrays may be null.
+ * Returns true if both are null.
+ * Returns false if only one is null.
+ * If both are arrays, returns true iff they have the same length and
+ * iff, after sorting both arrays, all elements compare true with equals.
+ * The original arrays are left untouched.
+ */
+ public static boolean equalArraysOrNullSortFirst(Comparable[] a, Comparable[] b) {
+ if (a == b) return true;
+ if (a == null || b == null) return false;
+ int len = a.length;
+ if (len != b.length) return false;
+ if (len >= 2) { // only need to sort if more than two items
+ a = sortCopy(a);
+ b = sortCopy(b);
+ }
+ for (int i = 0; i < len; ++i) {
+ if (!a[i].equals(b[i])) return false;
+ }
+ return true;
+ }
+
+ /**
+ * Compares two objects using equals().
+ * Either or both array may be null.
+ * Returns true if both are null.
+ * Returns false if only one is null.
+ * Otherwise, return the result of comparing with equals().
+ */
+ public static boolean equalOrNull(Object a, Object b) {
+ if (a == b) {
+ return true;
+ }
+ if (a == null || b == null) {
+ return false;
+ }
+ return a.equals(b);
+ }
+
+ /**
+ * Given a qualified name, extract the last component.
+ * If the input is not qualified, the same string is answered.
+ */
+ public static String extractLastName(String qualifiedName) {
+ int i = qualifiedName.lastIndexOf('.');
+ if (i == -1) return qualifiedName;
+ return qualifiedName.substring(i+1);
+ }
+
+ /**
+ * Extracts the parameter types from a method signature.
+ */
+ public static String[] extractParameterTypes(char[] sig) {
+ int count = getParameterCount(sig);
+ String[] result = new String[count];
+ if (count == 0)
+ return result;
+ int i = CharOperation.indexOf('(', sig) + 1;
+ count = 0;
+ int len = sig.length;
+ int start = i;
+ for (;;) {
+ if (i == len)
+ break;
+ char c = sig[i];
+ if (c == ')')
+ break;
+ if (c == '[') {
+ ++i;
+ } else
+ if (c == 'L') {
+ i = CharOperation.indexOf(';', sig, i + 1) + 1;
+ Assert.isTrue(i != 0);
+ result[count++] = convertTypeSignature(CharOperation.subarray(sig, start, i));
+ start = i;
+ } else {
+ ++i;
+ result[count++] = convertTypeSignature(CharOperation.subarray(sig, start, i));
+ start = i;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Extracts the return type from a method signature.
+ */
+ public static String extractReturnType(String sig) {
+ int i = sig.lastIndexOf(')');
+ Assert.isTrue(i != -1);
+ return sig.substring(i+1);
+ }
+
+ /**
+ * Finds the first line separator used by the given text.
+ *
+ * @return </code>"\n"</code> or </code>"\r"</code> or </code>"\r\n"</code>,
+ * or <code>null</code> if none found
+ */
+ public static String findLineSeparator(char[] text) {
+ // find the first line separator
+ int length = text.length;
+ if (length > 0) {
+ char nextChar = text[0];
+ for (int i = 0; i < length; i++) {
+ char currentChar = nextChar;
+ nextChar = i < length-1 ? text[i+1] : ' ';
+ switch (currentChar) {
+ case '\n': return "\n"; //$NON-NLS-1$
+ case '\r': return nextChar == '\n' ? "\r\n" : "\r"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+ // not found
+ return null;
+ }
+
+ /**
+ * Returns the line separator used by the given buffer.
+ * Uses the given text if none found.
+ *
+ * @return </code>"\n"</code> or </code>"\r"</code> or </code>"\r\n"</code>
+ */
+ private static String getLineSeparator(char[] text, char[] buffer) {
+ // search in this buffer's contents first
+ String lineSeparator = findLineSeparator(buffer);
+ if (lineSeparator == null) {
+ // search in the given text
+ lineSeparator = findLineSeparator(text);
+ if (lineSeparator == null) {
+ // default to system line separator
+ return org.eclipse.jdt.internal.compiler.util.Util.LINE_SEPARATOR;
+ }
+ }
+ return lineSeparator;
+ }
+
+ /**
+ * Returns the number of parameter types in a method signature.
+ */
+ public static int getParameterCount(char[] sig) {
+ int i = CharOperation.indexOf('(', sig) + 1;
+ Assert.isTrue(i != 0);
+ int count = 0;
+ int len = sig.length;
+ for (;;) {
+ if (i == len)
+ break;
+ char c = sig[i];
+ if (c == ')')
+ break;
+ if (c == '[') {
+ ++i;
+ } else
+ if (c == 'L') {
+ ++count;
+ i = CharOperation.indexOf(';', sig, i + 1) + 1;
+ Assert.isTrue(i != 0);
+ } else {
+ ++count;
+ ++i;
+ }
+ }
+ return count;
+ }
+
+ /**
+ * Returns the given file's contents as a byte array.
+ */
+ public static byte[] getResourceContentsAsByteArray(IFile file) throws JavaModelException {
+ InputStream stream= null;
+ try {
+ stream = new BufferedInputStream(file.getContents(true));
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ }
+ try {
+ return org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(stream, -1);
+ } catch (IOException e) {
+ throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ /**
+ * Returns the given file's contents as a character array.
+ */
+ public static char[] getResourceContentsAsCharArray(IFile file) throws JavaModelException {
+ String encoding = JavaCore.create(file.getProject()).getOption(JavaCore.CORE_ENCODING, true);
+ return getResourceContentsAsCharArray(file, encoding);
+ }
+
+ public static char[] getResourceContentsAsCharArray(IFile file, String encoding) throws JavaModelException {
+ InputStream stream= null;
+ try {
+ stream = new BufferedInputStream(file.getContents(true));
+ } catch (CoreException e) {
+ throw new JavaModelException(e, IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST);
+ }
+ try {
+ return org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsCharArray(stream, -1, encoding);
+ } catch (IOException e) {
+ throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ /**
+ * Returns a trimmed version the simples names returned by Signature.
+ */
+ public static String[] getTrimmedSimpleNames(String name) {
+ String[] result = Signature.getSimpleNames(name);
+ if (result == null) return null;
+ for (int i = 0, length = result.length; i < length; i++) {
+ result[i] = result[i].trim();
+ }
+ return result;
+ }
+
+ /**
* Returns true iff str.toLowerCase().endsWith(".class")
* implementation is not creating extra strings.
*/
@@ -1065,8 +666,79 @@
}
return true;
}
+
+ /*
+ * Returns whether the given java element is exluded from its root's classpath.
+ */
+ public static final boolean isExcluded(IJavaElement element) {
+ int elementType = element.getElementType();
+ switch (elementType) {
+ case IJavaElement.PACKAGE_FRAGMENT:
+ PackageFragmentRoot root = (PackageFragmentRoot)element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
+ IResource resource = element.getResource();
+ return resource != null && Util.isExcluded(resource, root.fullExclusionPatternChars());
+ case IJavaElement.COMPILATION_UNIT:
+ root = (PackageFragmentRoot)element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
+ resource = element.getResource();
+ if (resource != null && Util.isExcluded(resource, root.fullExclusionPatternChars()))
+ return true;
+ return isExcluded(element.getParent());
+ default:
+ IJavaElement cu = element.getAncestor(IJavaElement.COMPILATION_UNIT);
+ return cu != null && isExcluded(cu);
+ }
+ }
+ /*
+ * Returns whether the given resource path matches one of the exclusion
+ * patterns.
+ *
+ * @see IClasspathEntry#getExclusionPatterns
+ */
+ public final static boolean isExcluded(IPath resourcePath, char[][] exclusionPatterns) {
+ if (exclusionPatterns == null) return false;
+ char[] path = resourcePath.toString().toCharArray();
+ for (int i = 0, length = exclusionPatterns.length; i < length; i++)
+ if (CharOperation.pathMatch(exclusionPatterns[i], path, true, '/'))
+ return true;
+ return false;
+ }
+
+ /*
+ * Returns whether the given resource matches one of the exclusion patterns.
+ *
+ * @see IClasspathEntry#getExclusionPatterns
+ */
+ public final static boolean isExcluded(IResource resource, char[][] exclusionPatterns) {
+ IPath path = resource.getFullPath();
+ // ensure that folders are only excluded if all of their children are excluded
+ if (resource.getType() == IResource.FOLDER)
+ path = path.append("*"); //$NON-NLS-1$
+ return isExcluded(path, exclusionPatterns);
+ }
/**
+ * Returns true iff str.toLowerCase().endsWith(".jar" or ".zip")
+ * implementation is not creating extra strings.
+ */
+ public final static boolean isArchiveFileName(String name) {
+ int nameLength = name == null ? 0 : name.length();
+ int suffixLength = SUFFIX_JAR.length;
+ if (nameLength < suffixLength) return false;
+
+ int i, offset;
+ for ( i = 0, offset = nameLength - suffixLength; i < suffixLength; i++) {
+ char c = name.charAt(offset + i);
+ if (c != SUFFIX_jar[i] && c != SUFFIX_JAR[i]) break;
+ }
+ if (i == suffixLength) return true;
+ for ( i = 0, offset = nameLength - suffixLength; i < suffixLength; i++) {
+ char c = name.charAt(offset + i);
+ if (c != SUFFIX_zip[i] && c != SUFFIX_ZIP[i]) return false;
+ }
+ return true;
+ }
+
+ /**
* Validate the given compilation unit name.
* A compilation unit name must obey the following rules:
* <ul>
@@ -1119,10 +791,510 @@
}
/**
+ * Returns true if the given method signature is valid,
+ * false if it is not.
+ */
+ public static boolean isValidMethodSignature(String sig) {
+ int len = sig.length();
+ if (len == 0) return false;
+ int i = 0;
+ char c = sig.charAt(i++);
+ if (c != '(') return false;
+ if (i >= len) return false;
+ while (sig.charAt(i) != ')') {
+ // Void is not allowed as a parameter type.
+ i = checkTypeSignature(sig, i, len, false);
+ if (i == -1) return false;
+ if (i >= len) return false;
+ }
+ ++i;
+ i = checkTypeSignature(sig, i, len, true);
+ return i == len;
+ }
+
+ /**
+ * Returns true if the given type signature is valid,
+ * false if it is not.
+ */
+ public static boolean isValidTypeSignature(String sig, boolean allowVoid) {
+ int len = sig.length();
+ return checkTypeSignature(sig, 0, len, allowVoid) == len;
+ }
+
+ /**
+ * Returns true if the given folder name is valid for a package,
+ * false if it is not.
+ */
+ public static boolean isValidFolderNameForPackage(String folderName) {
+ return JavaConventions.validateIdentifier(folderName).getSeverity() != IStatus.ERROR;
+ }
+
+ /*
+ * Add a log entry
+ */
+ public static void log(Throwable e, String message) {
+ Throwable nestedException;
+ if (e instanceof JavaModelException
+ && (nestedException = ((JavaModelException)e).getException()) != null) {
+ e = nestedException;
+ }
+ IStatus status= new Status(
+ IStatus.ERROR,
+ JavaCore.getPlugin().getDescriptor().getUniqueIdentifier(),
+ IStatus.ERROR,
+ message,
+ e);
+ JavaCore.getPlugin().getLog().log(status);
+ }
+
+ /**
+ * Normalizes the cariage returns in the given text.
+ * They are all changed to use the given buffer's line separator.
+ */
+ public static char[] normalizeCRs(char[] text, char[] buffer) {
+ CharArrayBuffer result = new CharArrayBuffer();
+ int lineStart = 0;
+ int length = text.length;
+ if (length == 0) return text;
+ String lineSeparator = getLineSeparator(text, buffer);
+ char nextChar = text[0];
+ for (int i = 0; i < length; i++) {
+ char currentChar = nextChar;
+ nextChar = i < length-1 ? text[i+1] : ' ';
+ switch (currentChar) {
+ case '\n':
+ int lineLength = i-lineStart;
+ char[] line = new char[lineLength];
+ System.arraycopy(text, lineStart, line, 0, lineLength);
+ result.append(line);
+ result.append(lineSeparator);
+ lineStart = i+1;
+ break;
+ case '\r':
+ lineLength = i-lineStart;
+ if (lineLength >= 0) {
+ line = new char[lineLength];
+ System.arraycopy(text, lineStart, line, 0, lineLength);
+ result.append(line);
+ result.append(lineSeparator);
+ if (nextChar == '\n') {
+ nextChar = ' ';
+ lineStart = i+2;
+ } else {
+ // when line separator are mixed in the same file
+ // \r might not be followed by a \n. If not, we should increment
+ // lineStart by one and not by two.
+ lineStart = i+1;
+ }
+ } else {
+ // when line separator are mixed in the same file
+ // we need to prevent NegativeArraySizeException
+ lineStart = i+1;
+ }
+ break;
+ }
+ }
+ char[] lastLine;
+ if (lineStart > 0) {
+ int lastLineLength = length-lineStart;
+ if (lastLineLength > 0) {
+ lastLine = new char[lastLineLength];
+ System.arraycopy(text, lineStart, lastLine, 0, lastLineLength);
+ result.append(lastLine);
+ }
+ return result.getContents();
+ } else {
+ return text;
+ }
+ }
+
+ /**
+ * Normalizes the cariage returns in the given text.
+ * They are all changed to use given buffer's line sepatator.
+ */
+ public static String normalizeCRs(String text, String buffer) {
+ return new String(normalizeCRs(text.toCharArray(), buffer.toCharArray()));
+ }
+
+ /**
+ * Sort the objects in the given collection using the given sort order.
+ */
+ private static void quickSort(Object[] sortedCollection, int left, int right, int[] sortOrder) {
+ int original_left = left;
+ int original_right = right;
+ int mid = sortOrder[ (left + right) / 2];
+ do {
+ while (sortOrder[left] < mid) {
+ left++;
+ }
+ while (mid < sortOrder[right]) {
+ right--;
+ }
+ if (left <= right) {
+ Object tmp = sortedCollection[left];
+ sortedCollection[left] = sortedCollection[right];
+ sortedCollection[right] = tmp;
+ int tmp2 = sortOrder[left];
+ sortOrder[left] = sortOrder[right];
+ sortOrder[right] = tmp2;
+ left++;
+ right--;
+ }
+ } while (left <= right);
+ if (original_left < right) {
+ quickSort(sortedCollection, original_left, right, sortOrder);
+ }
+ if (left < original_right) {
+ quickSort(sortedCollection, left, original_right, sortOrder);
+ }
+ }
+
+ /**
+ * Sort the objects in the given collection using the given comparer.
+ */
+ private static void quickSort(Object[] sortedCollection, int left, int right, Comparer comparer) {
+ int original_left = left;
+ int original_right = right;
+ Object mid = sortedCollection[ (left + right) / 2];
+ do {
+ while (comparer.compare(sortedCollection[left], mid) < 0) {
+ left++;
+ }
+ while (comparer.compare(mid, sortedCollection[right]) < 0) {
+ right--;
+ }
+ if (left <= right) {
+ Object tmp = sortedCollection[left];
+ sortedCollection[left] = sortedCollection[right];
+ sortedCollection[right] = tmp;
+ left++;
+ right--;
+ }
+ } while (left <= right);
+ if (original_left < right) {
+ quickSort(sortedCollection, original_left, right, comparer);
+ }
+ if (left < original_right) {
+ quickSort(sortedCollection, left, original_right, comparer);
+ }
+ }
+
+ /**
+ * Sort the strings in the given collection.
+ */
+ private static void quickSort(String[] sortedCollection, int left, int right) {
+ int original_left = left;
+ int original_right = right;
+ String mid = sortedCollection[ (left + right) / 2];
+ do {
+ while (sortedCollection[left].compareTo(mid) < 0) {
+ left++;
+ }
+ while (mid.compareTo(sortedCollection[right]) < 0) {
+ right--;
+ }
+ if (left <= right) {
+ String tmp = sortedCollection[left];
+ sortedCollection[left] = sortedCollection[right];
+ sortedCollection[right] = tmp;
+ left++;
+ right--;
+ }
+ } while (left <= right);
+ if (original_left < right) {
+ quickSort(sortedCollection, original_left, right);
+ }
+ if (left < original_right) {
+ quickSort(sortedCollection, left, original_right);
+ }
+ }
+
+ /**
+ * Converts the given relative path into a package name.
+ * Returns null if the path is not a valid package name.
+ */
+ public static String packageName(IPath pkgPath) {
+ StringBuffer pkgName = new StringBuffer(IPackageFragment.DEFAULT_PACKAGE_NAME);
+ for (int j = 0, max = pkgPath.segmentCount(); j < max; j++) {
+ String segment = pkgPath.segment(j);
+ if (!isValidFolderNameForPackage(segment)) {
+ return null;
+ }
+ pkgName.append(segment);
+ if (j < pkgPath.segmentCount() - 1) {
+ pkgName.append("." ); //$NON-NLS-1$
+ }
+ }
+ return pkgName.toString();
+ }
+
+ /**
+ * Sort the comparable objects in the given collection.
+ */
+ private static void quickSort(Comparable[] sortedCollection, int left, int right) {
+ int original_left = left;
+ int original_right = right;
+ Comparable mid = sortedCollection[ (left + right) / 2];
+ do {
+ while (sortedCollection[left].compareTo(mid) < 0) {
+ left++;
+ }
+ while (mid.compareTo(sortedCollection[right]) < 0) {
+ right--;
+ }
+ if (left <= right) {
+ Comparable tmp = sortedCollection[left];
+ sortedCollection[left] = sortedCollection[right];
+ sortedCollection[right] = tmp;
+ left++;
+ right--;
+ }
+ } while (left <= right);
+ if (original_left < right) {
+ quickSort(sortedCollection, original_left, right);
+ }
+ if (left < original_right) {
+ quickSort(sortedCollection, left, original_right);
+ }
+ }
+
+ /**
+ * Sort the strings in the given collection in reverse alphabetical order.
+ */
+ private static void quickSortReverse(String[] sortedCollection, int left, int right) {
+ int original_left = left;
+ int original_right = right;
+ String mid = sortedCollection[ (left + right) / 2];
+ do {
+ while (sortedCollection[left].compareTo(mid) > 0) {
+ left++;
+ }
+ while (mid.compareTo(sortedCollection[right]) > 0) {
+ right--;
+ }
+ if (left <= right) {
+ String tmp = sortedCollection[left];
+ sortedCollection[left] = sortedCollection[right];
+ sortedCollection[right] = tmp;
+ left++;
+ right--;
+ }
+ } while (left <= right);
+ if (original_left < right) {
+ quickSortReverse(sortedCollection, original_left, right);
+ }
+ if (left < original_right) {
+ quickSortReverse(sortedCollection, left, original_right);
+ }
+ }
+
+ /**
+ * Sorts an array of objects in place, using the sort order given for each item.
+ */
+ public static void sort(Object[] objects, int[] sortOrder) {
+ if (objects.length > 1)
+ quickSort(objects, 0, objects.length - 1, sortOrder);
+ }
+
+ /**
+ * Sorts an array of objects in place.
+ * The given comparer compares pairs of items.
+ */
+ public static void sort(Object[] objects, Comparer comparer) {
+ if (objects.length > 1)
+ quickSort(objects, 0, objects.length - 1, comparer);
+ }
+
+ /**
+ * Sorts an array of strings in place using quicksort.
+ */
+ public static void sort(String[] strings) {
+ if (strings.length > 1)
+ quickSort(strings, 0, strings.length - 1);
+ }
+
+ /**
+ * Sorts an array of Comparable objects in place.
+ */
+ public static void sort(Comparable[] objects) {
+ if (objects.length > 1)
+ quickSort(objects, 0, objects.length - 1);
+ }
+
+ /**
+ * Sorts an array of Strings, returning a new array
+ * with the sorted items. The original array is left untouched.
+ */
+ public static Object[] sortCopy(Object[] objects, Comparer comparer) {
+ int len = objects.length;
+ Object[] copy = new Object[len];
+ System.arraycopy(objects, 0, copy, 0, len);
+ sort(copy, comparer);
+ return copy;
+ }
+
+ /**
+ * Sorts an array of Strings, returning a new array
+ * with the sorted items. The original array is left untouched.
+ */
+ public static String[] sortCopy(String[] objects) {
+ int len = objects.length;
+ String[] copy = new String[len];
+ System.arraycopy(objects, 0, copy, 0, len);
+ sort(copy);
+ return copy;
+ }
+
+ /**
+ * Sorts an array of Comparable objects, returning a new array
+ * with the sorted items. The original array is left untouched.
+ */
+ public static Comparable[] sortCopy(Comparable[] objects) {
+ int len = objects.length;
+ Comparable[] copy = new Comparable[len];
+ System.arraycopy(objects, 0, copy, 0, len);
+ sort(copy);
+ return copy;
+ }
+
+ /**
+ * Sorts an array of strings in place using quicksort
+ * in reverse alphabetical order.
+ */
+ public static void sortReverseOrder(String[] strings) {
+ if (strings.length > 1)
+ quickSortReverse(strings, 0, strings.length - 1);
+ }
+
+ /**
+ * Converts a String[] to char[][].
+ */
+ public static char[][] toCharArrays(String[] a) {
+ int len = a.length;
+ char[][] result = new char[len][];
+ for (int i = 0; i < len; ++i) {
+ result[i] = toChars(a[i]);
+ }
+ return result;
+ }
+
+ /**
+ * Converts a String to char[].
+ */
+ public static char[] toChars(String s) {
+ int len = s.length();
+ char[] chars = new char[len];
+ s.getChars(0, len, chars, 0);
+ return chars;
+ }
+
+ /**
+ * Converts a String to char[][], where segments are separate by '.'.
+ */
+ public static char[][] toCompoundChars(String s) {
+ int len = s.length();
+ if (len == 0) {
+ return CharOperation.NO_CHAR_CHAR;
+ }
+ int segCount = 1;
+ for (int off = s.indexOf('.'); off != -1; off = s.indexOf('.', off + 1)) {
+ ++segCount;
+ }
+ char[][] segs = new char[segCount][];
+ int start = 0;
+ for (int i = 0; i < segCount; ++i) {
+ int dot = s.indexOf('.', start);
+ int end = (dot == -1 ? s.length() : dot);
+ segs[i] = new char[end - start];
+ s.getChars(start, end, segs[i], 0);
+ start = end + 1;
+ }
+ return segs;
+ }
+
+ /**
+ * Converts a char[][] to String, where segments are separated by '.'.
+ */
+ public static String toString(char[][] c) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0, max = c.length; i < max; ++i) {
+ if (i != 0) sb.append('.');
+ sb.append(c[i]);
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Converts a char[][] and a char[] to String, where segments are separated by '.'.
+ */
+ public static String toString(char[][] c, char[] d) {
+ if (c == null) return new String(d);
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0, max = c.length; i < max; ++i) {
+ sb.append(c[i]);
+ sb.append('.');
+ }
+ sb.append(d);
+ return sb.toString();
+ }
+
+ /**
+ * Converts a char[] to String.
+ */
+ public static String toString(char[] c) {
+ return new String(c);
+ }
+
+ /**
+ * Converts an array of Objects into String.
+ */
+ public static String toString(Object[] objects) {
+ return toString(objects,
+ new Displayable(){
+ public String displayString(Object o) {
+ if (o == null) return "null"; //$NON-NLS-1$
+ return o.toString();
+ }
+ });
+ }
+
+ /**
+ * Converts an array of Objects into String.
+ */
+ public static String toString(Object[] objects, Displayable renderer) {
+ if (objects == null) return ""; //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer(10);
+ for (int i = 0; i < objects.length; i++){
+ if (i > 0) buffer.append(", "); //$NON-NLS-1$
+ buffer.append(renderer.displayString(objects[i]));
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Asserts that the given method signature is valid.
+ */
+ public static void validateMethodSignature(String sig) {
+ Assert.isTrue(isValidMethodSignature(sig));
+ }
+
+ /**
+ * Asserts that the given type signature is valid.
+ */
+ public static void validateTypeSignature(String sig, boolean allowVoid) {
+ Assert.isTrue(isValidTypeSignature(sig, allowVoid));
+ }
+
+ /**
* Creates a NLS catalog for the given locale.
*/
public static void relocalize() {
- bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+ try {
+ bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+ } catch(MissingResourceException e) {
+ System.out.println("Missing resource : " + bundleName.replace('.', '/') + ".properties for locale " + Locale.getDefault()); //$NON-NLS-1$//$NON-NLS-2$
+ throw e;
+ }
}
/**
@@ -1153,6 +1325,7 @@
* Separate all the arguments of a String made by getProblemArgumentsForMarker
*/
public static String[] getProblemArgumentsFromMarker(String argumentsString){
+ if (argumentsString == null) return null;
int index = argumentsString.indexOf(':');
if(index == -1)
return null;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopy.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopy.java
index 62e9ffc..d85ca59 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopy.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopy.java
@@ -1,34 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
+import java.io.*;
+import java.io.ByteArrayInputStream;
import java.util.ArrayList;
-import java.util.Map;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.ElementChangedEvent;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.IBufferFactory;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IProblemRequestor;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
/**
* Implementation of a working copy compilation unit. A working
@@ -79,8 +70,37 @@
* @see IWorkingCopy
*/
public void commit(boolean force, IProgressMonitor monitor) throws JavaModelException {
- CommitWorkingCopyOperation op= new CommitWorkingCopyOperation(this, force);
- runOperation(op, monitor);
+ ICompilationUnit original = (ICompilationUnit)this.getOriginalElement();
+ if (original.exists()) {
+ CommitWorkingCopyOperation op= new CommitWorkingCopyOperation(this, force);
+ runOperation(op, monitor);
+ } else {
+ String encoding = this.getJavaProject().getOption(JavaCore.CORE_ENCODING, true);
+ String contents = this.getSource();
+ if (contents == null) return;
+ try {
+ byte[] bytes = encoding == null
+ ? contents.getBytes()
+ : contents.getBytes(encoding);
+ ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
+ IFile originalRes = (IFile)original.getResource();
+ if (originalRes.exists()) {
+ originalRes.setContents(
+ stream,
+ force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
+ null);
+ } else {
+ originalRes.create(
+ stream,
+ force,
+ monitor);
+ }
+ } catch (CoreException e) {
+ throw new JavaModelException(e);
+ } catch (UnsupportedEncodingException e) {
+ throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
+ }
+ }
}
/**
* Returns a new element info for this element.
@@ -99,43 +119,16 @@
return;
}
try {
- close();
-
- // if original element is not on classpath flush it from the cache
- IJavaElement originalElement = this.getOriginalElement();
- if (!this.getParent().exists()) {
- ((CompilationUnit)originalElement).close();
- }
-
- // remove working copy from the cache
- JavaModelManager manager = JavaModelManager.getJavaModelManager();
-
- // In order to be shared, working copies have to denote the same compilation unit
- // AND use the same buffer factory.
- // Assuming there is a little set of buffer factories, then use a 2 level Map cache.
- Map sharedWorkingCopies = manager.sharedWorkingCopies;
-
- Map perFactoryWorkingCopies = (Map) sharedWorkingCopies.get(this.bufferFactory);
- if (perFactoryWorkingCopies != null){
- if (perFactoryWorkingCopies.remove(originalElement) != null) {
- if (SHARED_WC_VERBOSE) {
- System.out.println("Destroying shared working copy " + this.toStringWithAncestors());//$NON-NLS-1$
- }
-
- // report removed java delta
- JavaElementDelta delta = new JavaElementDelta(this.getJavaModel());
- delta.removed(this);
- manager.fire(delta, JavaModelManager.DEFAULT_CHANGE_EVENT);
- }
- }
+ DestroyWorkingCopyOperation op = new DestroyWorkingCopyOperation(this);
+ runOperation(op, null);
} catch (JavaModelException e) {
// do nothing
}
}
public boolean exists() {
- if (this.useCount == 0) return false; // no longer exists once destroyed
- return super.exists();
+ // working copy always exists in the model until it is detroyed
+ return this.useCount != 0;
}
@@ -156,7 +149,33 @@
return this == o;
}
+ /**
+ * Returns the info for this handle.
+ * If this element is not already open, it and all of its parents are opened.
+ * Does not return null.
+ * NOTE: BinaryType infos are NJOT rooted under JavaElementInfo.
+ * @exception JavaModelException if the element is not present or not accessible
+ */
+ public Object getElementInfo() throws JavaModelException {
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ boolean shouldPerformProblemDetection = false;
+ synchronized(manager){
+ Object info = manager.getInfo(this);
+ if (info == null) {
+ shouldPerformProblemDetection = true;
+ }
+ }
+ Object info = super.getElementInfo(); // will populate if necessary
+
+ // perform problem detection outside the JavaModelManager lock
+ if (this.problemRequestor != null && shouldPerformProblemDetection && this.problemRequestor.isActive()){
+ this.problemRequestor.beginReporting();
+ CompilationUnitProblemFinder.process(this, this.problemRequestor, null);
+ this.problemRequestor.endReporting();
+ }
+ return info;
+ }
/**
* @see IWorkingCopy
*/
@@ -256,12 +275,6 @@
}
/*
- * Answer requestor to notify with problems
- */
-public IProblemRequestor getProblemRequestor(){
- return this.problemRequestor;
-}
-/*
* @see IJavaElement
*/
public IResource getResource() {
@@ -318,6 +331,23 @@
public boolean isWorkingCopy() {
return true;
}
+
+/**
+ * @see IOpenable#makeConsistent(IProgressMonitor)
+ */
+public void makeConsistent(IProgressMonitor monitor) throws JavaModelException {
+ if (!isConsistent()) { // TODO: this code isn't synchronized with regular opening of a working copy (should use getElementInfo)
+ super.makeConsistent(monitor);
+
+ if (monitor != null && monitor.isCanceled()) return;
+ if (this.problemRequestor != null && this.problemRequestor.isActive()){
+ this.problemRequestor.beginReporting();
+ CompilationUnitProblemFinder.process(this, this.problemRequestor, monitor);
+ this.problemRequestor.endReporting();
+ }
+ }
+}
+
/**
* @see IOpenable
* @see IWorkingCopy
@@ -325,11 +355,18 @@
* @exception JavaModelException attempting to open a read only element for something other than navigation
* or if this is a working copy being opened after it has been destroyed.
*/
-public void open(IProgressMonitor pm) throws JavaModelException {
+public void open(IProgressMonitor monitor) throws JavaModelException {
if (this.useCount == 0) { // was destroyed
throw newNotPresentException();
} else {
- super.open(pm);
+ super.open(monitor);
+
+ if (monitor != null && monitor.isCanceled()) return;
+ if (this.problemRequestor != null && this.problemRequestor.isActive()){
+ this.problemRequestor.beginReporting();
+ CompilationUnitProblemFinder.process(this, this.problemRequestor, monitor);
+ this.problemRequestor.endReporting();
+ }
}
}
/**
@@ -344,13 +381,17 @@
if (buffer == null) return null;
// set the buffer source if needed
- if (buffer.getCharacters() == null){
- ICompilationUnit original= (ICompilationUnit)this.getOriginalElement();
- IBuffer originalBuffer = original.getBuffer();
- if (originalBuffer != null) {
- char[] originalContents = originalBuffer.getCharacters();
- if (originalContents != null) {
- buffer.setContents((char[])originalContents.clone());
+ if (buffer.getCharacters() == null) {
+ ICompilationUnit original = (ICompilationUnit)this.getOriginalElement();
+ if (original.isOpen()) {
+ buffer.setContents(original.getSource());
+ } else {
+ IFile file = (IFile)original.getResource();
+ if (file == null || !file.exists()) {
+ // initialize buffer with empty contents
+ buffer.setContents(CharOperation.NO_CHAR);
+ } else {
+ buffer.setContents(Util.getResourceContentsAsCharArray(file));
}
}
}
@@ -363,6 +404,23 @@
return buffer;
}
+/*
+ * @see Openable#openParent(IProgressMonitor)
+ */
+protected void openParent(IProgressMonitor pm) throws JavaModelException {
+ if (FIX_BUG25184) {
+ try {
+ super.openParent(pm);
+ } catch(JavaModelException e){
+ // allow parent to not exist for working copies defined outside classpath
+ if (!e.isDoesNotExist()){
+ throw e;
+ }
+ }
+ } else {
+ super.openParent(pm);
+ }
+}
/**
* @see IWorkingCopy
@@ -376,52 +434,8 @@
* @see IWorkingCopy
*/
public void reconcile(boolean forceProblemDetection, IProgressMonitor monitor) throws JavaModelException {
-
- if (this.useCount == 0) throw newNotPresentException(); //was destroyed
-
- if (monitor != null){
- if (monitor.isCanceled()) return;
- monitor.beginTask(Util.bind("element.reconciling"), 10); //$NON-NLS-1$
- }
-
- boolean wasConsistent = isConsistent();
- JavaElementDeltaBuilder deltaBuilder = null;
-
- try {
- // create the delta builder (this remembers the current content of the cu)
- if (!wasConsistent){
- deltaBuilder = new JavaElementDeltaBuilder(this);
-
- // update the element infos with the content of the working copy
- this.makeConsistent(monitor);
- deltaBuilder.buildDeltas();
-
- }
-
- if (monitor != null) monitor.worked(2);
-
- // force problem detection? - if structure was consistent
- if (forceProblemDetection && wasConsistent){
- if (monitor != null && monitor.isCanceled()) return;
-
- IProblemRequestor problemRequestor = this.getProblemRequestor();
- if (problemRequestor != null && problemRequestor.isActive()){
- problemRequestor.beginReporting();
- CompilationUnitProblemFinder.resolve(this, problemRequestor, monitor);
- problemRequestor.endReporting();
- }
- }
-
- // fire the deltas
- if (deltaBuilder != null){
- if ((deltaBuilder.delta != null) && (deltaBuilder.delta.getAffectedChildren().length > 0)) {
- JavaModelManager.getJavaModelManager().
- fire(deltaBuilder.delta, ElementChangedEvent.POST_RECONCILE);
- }
- }
- } finally {
- if (monitor != null) monitor.done();
- }
+ ReconcileWorkingCopyOperation op = new ReconcileWorkingCopyOperation(this, forceProblemDetection);
+ runOperation(op, monitor);
}
/**
@@ -456,13 +470,14 @@
if (isReadOnly()) {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.READ_ONLY, this));
}
- IBuffer buf = getBuffer();
- if (buf != null) { // some Openables (like a JavaProject) don't have a buffer
- buf.save(pm, force);
+ // no need to save the buffer for a working copy (this is a noop)
+ //IBuffer buf = getBuffer();
+ //if (buf != null) { // some Openables (like a JavaProject) don't have a buffer
+ // buf.save(pm, force);
this.reconcile(); // not simply makeConsistent, also computes fine-grain deltas
// in case the working copy is being reconciled already (if not it would miss
// one iteration of deltas).
- }
+ //}
}
/**
@@ -475,7 +490,7 @@
}
protected void updateTimeStamp(CompilationUnit original) throws JavaModelException {
long timeStamp =
- ((IFile) original.getUnderlyingResource()).getModificationStamp();
+ ((IFile) original.getResource()).getModificationStamp();
if (timeStamp == IResource.NULL_STAMP) {
throw new JavaModelException(
new JavaModelStatus(IJavaModelStatusConstants.INVALID_RESOURCE));
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopyElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopyElementInfo.java
index 3e22b07..ab1ccac 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopyElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/WorkingCopyElementInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core;
import org.eclipse.jdt.core.compiler.IProblem;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbortIncrementalBuildException.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbortIncrementalBuildException.java
index ff1aba1..377f20e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbortIncrementalBuildException.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbortIncrementalBuildException.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
/**
@@ -22,4 +22,4 @@
public AbortIncrementalBuildException(String qualifiedTypeName) {
this.qualifiedTypeName = qualifiedTypeName;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java
index b2df367..cf56d50 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AbstractImageBuilder.java
@@ -1,33 +1,32 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
import org.eclipse.core.runtime.*;
import org.eclipse.core.resources.*;
import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.Compiler;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.problem.*;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.*;
import java.io.*;
import java.util.*;
/**
- * The abstract superclass of image builders.
+ * The abstract superclass of Java builders.
* Provides the building and compilation mechanism
* in common with the batch and incremental builders.
*/
@@ -37,15 +36,14 @@
protected State newState;
// local copies
-protected IContainer outputFolder;
-protected IContainer[] sourceFolders;
+protected NameEnvironment nameEnvironment;
+protected ClasspathMultiDirectory[] sourceLocations;
protected BuildNotifier notifier;
-protected boolean hasSeparateOutputFolder;
-protected NameEnvironment nameEnvironment;
+protected String encoding;
protected Compiler compiler;
protected WorkQueue workQueue;
-protected ArrayList problemTypeLocations;
+protected ArrayList problemSourceFiles;
protected boolean compiledAllAtOnce;
private boolean inCompiler;
@@ -57,28 +55,14 @@
this.newState = new State(javaBuilder);
// local copies
- this.outputFolder = javaBuilder.outputFolder;
- this.sourceFolders = javaBuilder.sourceFolders;
+ this.nameEnvironment = javaBuilder.nameEnvironment;
+ this.sourceLocations = this.nameEnvironment.sourceLocations;
this.notifier = javaBuilder.notifier;
- // only perform resource copying if the output location does not match a source folder
- // corresponds to: project == src == bin, or several source folders are contributing resources,
- // but one is the output location too (and would get populated with other source folder resources).
- IPath outputPath = outputFolder.getFullPath();
- int index = sourceFolders.length;
- if (index == 0) {
- // handle case of the last source folder is removed... so no source folders exist but the output folder must still be scrubbed
- this.hasSeparateOutputFolder = !outputPath.equals(javaBuilder.currentProject.getFullPath());
- } else {
- this.hasSeparateOutputFolder = true;
- while (this.hasSeparateOutputFolder && --index >= 0)
- this.hasSeparateOutputFolder = !outputPath.equals(sourceFolders[index].getFullPath());
- }
-
- this.nameEnvironment = new NameEnvironment(javaBuilder.classpath);
+ this.encoding = javaBuilder.javaProject.getOption(JavaCore.CORE_ENCODING, true);
this.compiler = newCompiler();
this.workQueue = new WorkQueue();
- this.problemTypeLocations = new ArrayList(3);
+ this.problemSourceFiles = new ArrayList(3);
}
public void acceptResult(CompilationResult result) {
@@ -90,14 +74,14 @@
// Before reporting the new problems, we need to update the problem count &
// remove the old problems. Plus delete additional class files that no longer exist.
- // only need to find resource for the sourceLocation when problems need to be reported against it
- String sourceLocation = new String(result.getFileName()); // the full filesystem path "d:/xyz/eclipse/src1/Test/p1/p2/A.java"
- if (!workQueue.isCompiled(sourceLocation)) {
+ SourceFile compilationUnit = (SourceFile) result.getCompilationUnit(); // go directly back to the sourceFile
+ if (!workQueue.isCompiled(compilationUnit)) {
try {
- workQueue.finished(sourceLocation);
- updateProblemsFor(sourceLocation, result); // record compilation problems before potentially adding duplicate errors
+ workQueue.finished(compilationUnit);
+ updateProblemsFor(compilationUnit, result); // record compilation problems before potentially adding duplicate errors
+ updateTasksFor(compilationUnit, result); // record tasks
- ICompilationUnit compilationUnit = result.getCompilationUnit();
+ String typeLocator = compilationUnit.typeLocator();
ClassFile[] classFiles = result.getClassFiles();
int length = classFiles.length;
ArrayList duplicateTypeNames = null;
@@ -111,27 +95,27 @@
// Look for a possible collision, if one exists, report an error but do not write the class file
if (isNestedType) {
String qualifiedTypeName = new String(classFile.outerMostEnclosingClassFile().fileName());
- if (newState.isDuplicateLocation(qualifiedTypeName, sourceLocation))
+ if (newState.isDuplicateLocator(qualifiedTypeName, typeLocator))
continue;
} else {
String qualifiedTypeName = new String(classFile.fileName()); // the qualified type name "p1/p2/A"
- if (newState.isDuplicateLocation(qualifiedTypeName, sourceLocation)) {
+ if (newState.isDuplicateLocator(qualifiedTypeName, typeLocator)) {
if (duplicateTypeNames == null)
duplicateTypeNames = new ArrayList();
duplicateTypeNames.add(compoundName);
- createErrorFor(resourceForLocation(sourceLocation), Util.bind("build.duplicateClassFile", new String(typeName))); //$NON-NLS-1$
+ createErrorFor(compilationUnit.resource, Util.bind("build.duplicateClassFile", new String(typeName))); //$NON-NLS-1$
continue;
}
- newState.recordLocationForType(qualifiedTypeName, sourceLocation);
+ newState.recordLocatorForType(qualifiedTypeName, typeLocator);
}
- definedTypeNames.add(writeClassFile(classFile, !isNestedType));
+ definedTypeNames.add(writeClassFile(classFile, compilationUnit.sourceLocation.binaryFolder, !isNestedType));
}
- finishedWith(sourceLocation, result, compilationUnit.getMainTypeName(), definedTypeNames, duplicateTypeNames);
+ finishedWith(typeLocator, result, compilationUnit.getMainTypeName(), definedTypeNames, duplicateTypeNames);
notifier.compiled(compilationUnit);
} catch (CoreException e) {
Util.log(e, "JavaBuilder handling CoreException"); //$NON-NLS-1$
- createErrorFor(resourceForLocation(sourceLocation), Util.bind("build.inconsistentClassFile")); //$NON-NLS-1$
+ createErrorFor(compilationUnit.resource, Util.bind("build.inconsistentClassFile")); //$NON-NLS-1$
}
}
}
@@ -140,30 +124,25 @@
this.nameEnvironment.cleanup();
this.javaBuilder = null;
- this.outputFolder = null;
- this.sourceFolders = null;
+ this.nameEnvironment = null;
+ this.sourceLocations = null;
this.notifier = null;
this.compiler = null;
- this.nameEnvironment = null;
this.workQueue = null;
- this.problemTypeLocations = null;
+ this.problemSourceFiles = null;
}
/* Compile the given elements, adding more elements to the work queue
* if they are affected by the changes.
*/
-protected void compile(String[] filenames, String[] initialTypeNames) {
- int toDo = filenames.length;
+protected void compile(SourceFile[] units) {
+ int toDo = units.length;
if (this.compiledAllAtOnce = toDo <= MAX_AT_ONCE) {
// do them all now
- SourceFile[] toCompile = new SourceFile[toDo];
- for (int i = 0; i < toDo; i++) {
- String filename = filenames[i];
- if (JavaBuilder.DEBUG)
- System.out.println("About to compile " + filename); //$NON-NLS-1$
- toCompile[i] = new SourceFile(filename, initialTypeNames[i]);
- }
- compile(toCompile, initialTypeNames, null);
+ if (JavaBuilder.DEBUG)
+ for (int i = 0; i < toDo; i++)
+ System.out.println("About to compile " + units[i].typeLocator()); //$NON-NLS-1$
+ compile(units, null);
} else {
int i = 0;
boolean compilingFirstGroup = true;
@@ -171,52 +150,52 @@
int doNow = toDo < MAX_AT_ONCE ? toDo : MAX_AT_ONCE;
int index = 0;
SourceFile[] toCompile = new SourceFile[doNow];
- String[] initialNamesInLoop = new String[doNow];
while (i < toDo && index < doNow) {
- String filename = filenames[i];
// Although it needed compiling when this method was called, it may have
// already been compiled when it was referenced by another unit.
- if (compilingFirstGroup || workQueue.isWaiting(filename)) {
+ SourceFile unit = units[i++];
+ if (compilingFirstGroup || workQueue.isWaiting(unit)) {
if (JavaBuilder.DEBUG)
- System.out.println("About to compile " + filename);//$NON-NLS-1$
- String initialTypeName = initialTypeNames[i];
- initialNamesInLoop[index] = initialTypeName;
- toCompile[index++] = new SourceFile(filename, initialTypeName);
+ System.out.println("About to compile " + unit.typeLocator()); //$NON-NLS-1$
+ toCompile[index++] = unit;
}
- i++;
}
- if (index < doNow) {
+ if (index < doNow)
System.arraycopy(toCompile, 0, toCompile = new SourceFile[index], 0, index);
- System.arraycopy(initialNamesInLoop, 0, initialNamesInLoop = new String[index], 0, index);
- }
- String[] additionalFilenames = new String[toDo - i];
- System.arraycopy(filenames, i, additionalFilenames, 0, additionalFilenames.length);
+ SourceFile[] additionalUnits = new SourceFile[toDo - i];
+ System.arraycopy(units, i, additionalUnits, 0, additionalUnits.length);
compilingFirstGroup = false;
- compile(toCompile, initialNamesInLoop, additionalFilenames);
+ compile(toCompile, additionalUnits);
}
}
}
-void compile(SourceFile[] units, String[] initialTypeNames, String[] additionalFilenames) {
+void compile(SourceFile[] units, SourceFile[] additionalUnits) {
if (units.length == 0) return;
notifier.aboutToCompile(units[0]); // just to change the message
// extend additionalFilenames with all hierarchical problem types found during this entire build
- if (!problemTypeLocations.isEmpty()) {
- int toAdd = problemTypeLocations.size();
- int length = additionalFilenames == null ? 0 : additionalFilenames.length;
+ if (!problemSourceFiles.isEmpty()) {
+ int toAdd = problemSourceFiles.size();
+ int length = additionalUnits == null ? 0 : additionalUnits.length;
if (length == 0)
- additionalFilenames = new String[toAdd];
+ additionalUnits = new SourceFile[toAdd];
else
- System.arraycopy(additionalFilenames, 0, additionalFilenames = new String[length + toAdd], 0, length);
+ System.arraycopy(additionalUnits, 0, additionalUnits = new SourceFile[length + toAdd], 0, length);
for (int i = 0; i < toAdd; i++)
- additionalFilenames[length + i] = (String) problemTypeLocations.get(i);
+ additionalUnits[length + i] = (SourceFile) problemSourceFiles.get(i);
}
- nameEnvironment.setNames(initialTypeNames, additionalFilenames);
+ String[] initialTypeNames = new String[units.length];
+ for (int i = 0, l = units.length; i < l; i++)
+ initialTypeNames[i] = units[i].initialTypeName;
+ nameEnvironment.setNames(initialTypeNames, additionalUnits);
notifier.checkCancel();
try {
inCompiler = true;
compiler.compile(units);
+ } catch (AbortCompilation ignored) {
+ // ignore the AbortCompilcation coming from BuildNotifier.checkCancelWithinCompiler()
+ // the Compiler failed after the user has chose to cancel... likely due to an OutOfMemory error
} finally {
inCompiler = false;
}
@@ -227,34 +206,29 @@
protected void createErrorFor(IResource resource, String message) {
try {
- IMarker marker = resource.createMarker(JavaBuilder.ProblemMarkerTag);
+ IMarker marker = resource.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
+ int severity = IMarker.SEVERITY_ERROR;
+ if (message.equals(Util.bind("build.duplicateResource"))) //$NON-NLS-1$
+ if (JavaCore.WARNING.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE, true)))
+ severity = IMarker.SEVERITY_WARNING;
marker.setAttributes(
new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IMarker.CHAR_START, IMarker.CHAR_END},
- new Object[] {message, new Integer(IMarker.SEVERITY_ERROR), new Integer(0), new Integer(1)});
+ new Object[] {message, new Integer(severity), new Integer(0), new Integer(1)});
} catch (CoreException e) {
throw internalException(e);
}
}
-protected String extractTypeNameFrom(String sourceLocation) {
- for (int j = 0, k = sourceFolders.length; j < k; j++) {
- String folderLocation = sourceFolders[j].getLocation().addTrailingSeparator().toString();
- if (sourceLocation.startsWith(folderLocation))
- return sourceLocation.substring(folderLocation.length(), sourceLocation.length() - 5); // length of ".java"
- }
- return sourceLocation; // should not reach here
-}
-
-protected void finishedWith(String sourceLocation, CompilationResult result, char[] mainTypeName, ArrayList definedTypeNames, ArrayList duplicateTypeNames) throws CoreException {
+protected void finishedWith(String sourceLocator, CompilationResult result, char[] mainTypeName, ArrayList definedTypeNames, ArrayList duplicateTypeNames) throws CoreException {
if (duplicateTypeNames == null) {
- newState.record(sourceLocation, result.qualifiedReferences, result.simpleNameReferences, mainTypeName, definedTypeNames);
+ newState.record(sourceLocator, result.qualifiedReferences, result.simpleNameReferences, mainTypeName, definedTypeNames);
return;
}
char[][][] qualifiedRefs = result.qualifiedReferences;
char[][] simpleRefs = result.simpleNameReferences;
// for each duplicate type p1.p2.A, add the type name A (package was already added)
- next : for (int i = 0, dLength = duplicateTypeNames.size(); i < dLength; i++) {
+ next : for (int i = 0, l = duplicateTypeNames.size(); i < l; i++) {
char[][] compoundName = (char[][]) duplicateTypeNames.get(i);
char[] typeName = compoundName[compoundName.length - 1];
int sLength = simpleRefs.length;
@@ -264,13 +238,14 @@
System.arraycopy(simpleRefs, 0, simpleRefs = new char[sLength + 1][], 0, sLength);
simpleRefs[sLength] = typeName;
}
- newState.record(sourceLocation, qualifiedRefs, simpleRefs, mainTypeName, definedTypeNames);
+ newState.record(sourceLocator, qualifiedRefs, simpleRefs, mainTypeName, definedTypeNames);
}
-protected IContainer getOutputFolder(IPath packagePath) throws CoreException {
+protected IContainer createFolder(IPath packagePath, IContainer outputFolder) throws CoreException {
+ if (packagePath.isEmpty()) return outputFolder;
IFolder folder = outputFolder.getFolder(packagePath);
if (!folder.exists()) {
- getOutputFolder(packagePath.removeLastSegments(1));
+ createFolder(packagePath.removeLastSegments(1), outputFolder);
folder.create(true, true, null);
folder.setDerived(true);
}
@@ -289,13 +264,21 @@
return new Compiler(
nameEnvironment,
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- JavaCore.getOptions(),
+ javaBuilder.javaProject.getOptions(true),
this,
ProblemFactory.getProblemFactory(Locale.getDefault()));
}
-protected IResource resourceForLocation(String sourceLocation) {
- return javaBuilder.workspaceRoot.getFileForLocation(new Path(sourceLocation));
+protected boolean isExcludedFromProject(IPath childPath) throws JavaModelException {
+ // answer whether the folder should be ignored when walking the project as a source folder
+ if (childPath.segmentCount() > 2) return false; // is a subfolder of a package
+
+ for (int j = 0, k = sourceLocations.length; j < k; j++) {
+ if (childPath.equals(sourceLocations[j].binaryFolder.getFullPath())) return true;
+ if (childPath.equals(sourceLocations[j].sourceFolder.getFullPath())) return true;
+ }
+ // skip default output folder which may not be used by any source folder
+ return childPath.equals(javaBuilder.javaProject.getOutputLocation());
}
/**
@@ -308,16 +291,17 @@
* - its range is the problem's range
* - it has an extra attribute "ID" which holds the problem's id
*/
-protected void storeProblemsFor(IResource resource, IProblem[] problems) throws CoreException {
- if (resource == null || problems == null || problems.length == 0) return;
+protected void storeProblemsFor(SourceFile sourceFile, IProblem[] problems) throws CoreException {
+ if (sourceFile == null || problems == null || problems.length == 0) return;
String missingClassFile = null;
- for (int i = 0, length = problems.length; i < length; i++) {
+ IResource resource = sourceFile.resource;
+ for (int i = 0, l = problems.length; i < l; i++) {
IProblem problem = problems[i];
int id = problem.getID();
switch (id) {
case IProblem.IsClassPathCorrect :
- JavaBuilder.removeProblemsFor(javaBuilder.currentProject); // make this the only problem for this project
+ JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project
String[] args = problem.getArguments();
missingClassFile = args[0];
break;
@@ -337,23 +321,36 @@
case IProblem.InterfaceInternalNameProvided :
case IProblem.InterfaceInheritedNameHidesEnclosingName :
// ensure that this file is always retrieved from source for the rest of the build
- String fileLocation = resource.getLocation().toString();
- if (!problemTypeLocations.contains(fileLocation))
- problemTypeLocations.add(fileLocation);
+ if (!problemSourceFiles.contains(sourceFile))
+ problemSourceFiles.add(sourceFile);
+ break;
}
- IMarker marker = resource.createMarker(JavaBuilder.ProblemMarkerTag);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.ID, IMarker.CHAR_START, IMarker.CHAR_END, IMarker.LINE_NUMBER, IJavaModelMarker.ARGUMENTS},
- new Object[] {
- problem.getMessage(),
- new Integer(problem.isError() ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING),
- new Integer(id),
- new Integer(problem.getSourceStart()),
- new Integer(problem.getSourceEnd() + 1),
- new Integer(problem.getSourceLineNumber()),
- Util.getProblemArgumentsForMarker(problem.getArguments())
- });
+ if (id != IProblem.Task) {
+ IMarker marker = resource.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
+ marker.setAttributes(
+ new String[] {
+ IMarker.MESSAGE,
+ IMarker.SEVERITY,
+ IJavaModelMarker.ID,
+ IMarker.CHAR_START,
+ IMarker.CHAR_END,
+ IMarker.LINE_NUMBER,
+ IJavaModelMarker.ARGUMENTS},
+ new Object[] {
+ problem.getMessage(),
+ new Integer(problem.isError() ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING),
+ new Integer(id),
+ new Integer(problem.getSourceStart()),
+ new Integer(problem.getSourceEnd() + 1),
+ new Integer(problem.getSourceLineNumber()),
+ Util.getProblemArgumentsForMarker(problem.getArguments())
+ });
+ }
+
+/* Do NOT want to populate the Java Model just to find the matching Java element.
+ * Also cannot query compilation units located in folders with invalid package
+ * names such as 'a/b.c.d/e'.
// compute a user-friendly location
IJavaElement element = JavaCore.create(resource);
@@ -367,46 +364,94 @@
location = ((JavaElement) element).readableName();
if (location != null)
marker.setAttribute(IMarker.LOCATION, location);
+*/
+
if (missingClassFile != null)
throw new MissingClassFileException(missingClassFile);
}
}
-protected void updateProblemsFor(String sourceLocation, CompilationResult result) throws CoreException {
+protected void storeTasksFor(SourceFile sourceFile, IProblem[] tasks) throws CoreException {
+ if (sourceFile == null || tasks == null || tasks.length == 0) return;
+
+ IResource resource = sourceFile.resource;
+ for (int i = 0, l = tasks.length; i < l; i++) {
+ IProblem task = tasks[i];
+ if (task.getID() == IProblem.Task) {
+ IMarker marker = resource.createMarker(IJavaModelMarker.TASK_MARKER);
+ int priority = IMarker.PRIORITY_NORMAL;
+ String compilerPriority = task.getArguments()[2];
+ if (JavaCore.COMPILER_TASK_PRIORITY_HIGH.equals(compilerPriority))
+ priority = IMarker.PRIORITY_HIGH;
+ else if (JavaCore.COMPILER_TASK_PRIORITY_LOW.equals(compilerPriority))
+ priority = IMarker.PRIORITY_LOW;
+ marker.setAttributes(
+ new String[] {
+ IMarker.MESSAGE,
+ IMarker.PRIORITY,
+ IMarker.DONE,
+ IMarker.CHAR_START,
+ IMarker.CHAR_END,
+ IMarker.LINE_NUMBER,
+ IMarker.USER_EDITABLE,
+ },
+ new Object[] {
+ task.getMessage(),
+ new Integer(priority),
+ new Boolean(false),
+ new Integer(task.getSourceStart()),
+ new Integer(task.getSourceEnd() + 1),
+ new Integer(task.getSourceLineNumber()),
+ new Boolean(false),
+ });
+ }
+ }
+}
+
+protected void updateProblemsFor(SourceFile sourceFile, CompilationResult result) throws CoreException {
IProblem[] problems = result.getProblems();
if (problems == null || problems.length == 0) return;
notifier.updateProblemCounts(problems);
- storeProblemsFor(resourceForLocation(sourceLocation), problems);
+ storeProblemsFor(sourceFile, problems);
}
-protected char[] writeClassFile(ClassFile classFile, boolean isSecondaryType) throws CoreException {
- // Before writing out the class file, compare it to the previous file
- // If structural changes occured then add dependent source files
+protected void updateTasksFor(SourceFile sourceFile, CompilationResult result) throws CoreException {
+ IProblem[] tasks = result.getTasks();
+ if (tasks == null || tasks.length == 0) return;
+
+ storeTasksFor(sourceFile, tasks);
+}
+
+protected char[] writeClassFile(ClassFile classFile, IContainer outputFolder, boolean isSecondaryType) throws CoreException {
String fileName = new String(classFile.fileName()); // the qualified type name "p1/p2/A"
- IPath filePath = new Path(fileName);
+ IPath filePath = new Path(fileName);
IContainer container = outputFolder;
if (filePath.segmentCount() > 1) {
- container = getOutputFolder(filePath.removeLastSegments(1));
+ container = createFolder(filePath.removeLastSegments(1), outputFolder);
filePath = new Path(filePath.lastSegment());
}
IFile file = container.getFile(filePath.addFileExtension(JavaBuilder.CLASS_EXTENSION));
- byte[] bytes = classFile.getBytes();
- if (writeClassFileCheck(file, fileName, bytes, isSecondaryType)) {
- if (JavaBuilder.DEBUG)
- System.out.println("Writing class file " + file.getName());//$NON-NLS-1$
- file.create(new ByteArrayInputStream(bytes), IResource.FORCE, null);
- file.setDerived(true);
- } else if (JavaBuilder.DEBUG) {
- System.out.println("Skipped over unchanged class file " + file.getName());//$NON-NLS-1$
- }
+ writeClassFileBytes(classFile.getBytes(), file, fileName, isSecondaryType);
// answer the name of the class file as in Y or Y$M
return filePath.lastSegment().toCharArray();
}
-protected boolean writeClassFileCheck(IFile file, String fileName, byte[] bytes, boolean isSecondaryType) throws CoreException {
- // In Incremental mode, compare the bytes against the previous file for structural changes
- return true;
+protected void writeClassFileBytes(byte[] bytes, IFile file, String qualifiedFileName, boolean isSecondaryType) throws CoreException {
+ if (file.exists()) {
+ // Deal with shared output folders... last one wins... no collision cases detected
+ if (JavaBuilder.DEBUG)
+ System.out.println("Writing changed class file " + file.getName());//$NON-NLS-1$
+ file.setContents(new ByteArrayInputStream(bytes), true, false, null);
+ if (!file.isDerived())
+ file.setDerived(true);
+ } else {
+ // Default implementation just writes out the bytes for the new class file...
+ if (JavaBuilder.DEBUG)
+ System.out.println("Writing new class file " + file.getName());//$NON-NLS-1$
+ file.create(new ByteArrayInputStream(bytes), IResource.FORCE, null);
+ file.setDerived(true);
+ }
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AdditionalTypeCollection.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AdditionalTypeCollection.java
index e9da2d2..4b63c77 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AdditionalTypeCollection.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/AdditionalTypeCollection.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
public class AdditionalTypeCollection extends ReferenceCollection {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BatchImageBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BatchImageBuilder.java
index eda3eb6..8bed0ac 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BatchImageBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BatchImageBuilder.java
@@ -1,18 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.Util;
import java.util.*;
@@ -21,6 +23,7 @@
protected BatchImageBuilder(JavaBuilder javaBuilder) {
super(javaBuilder);
+ this.nameEnvironment.isIncrementalBuild = false;
}
public void build() {
@@ -28,27 +31,28 @@
System.out.println("FULL build"); //$NON-NLS-1$
try {
- notifier.subTask(Util.bind("build.scrubbingOutput")); //$NON-NLS-1$
- JavaBuilder.removeProblemsFor(javaBuilder.currentProject);
- scrubOutputFolder();
+ notifier.subTask(Util.bind("build.cleaningOutput")); //$NON-NLS-1$
+ JavaModelManager.getJavaModelManager().deltaProcessor.addForRefresh(javaBuilder.javaProject);
+ JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject);
+ cleanOutputFolders();
notifier.updateProgressDelta(0.1f);
notifier.subTask(Util.bind("build.analyzingSources")); //$NON-NLS-1$
- ArrayList locations = new ArrayList(33);
- ArrayList typeNames = new ArrayList(33);
- addAllSourceFiles(locations, typeNames);
+ ArrayList sourceFiles = new ArrayList(33);
+ addAllSourceFiles(sourceFiles);
notifier.updateProgressDelta(0.15f);
- if (locations.size() > 0) {
- String[] allSourceFiles = new String[locations.size()];
- locations.toArray(allSourceFiles);
- String[] initialTypeNames = new String[typeNames.size()];
- typeNames.toArray(initialTypeNames);
+ if (sourceFiles.size() > 0) {
+ SourceFile[] allSourceFiles = new SourceFile[sourceFiles.size()];
+ sourceFiles.toArray(allSourceFiles);
notifier.setProgressPerCompilationUnit(0.75f / allSourceFiles.length);
workQueue.addAll(allSourceFiles);
- compile(allSourceFiles, initialTypeNames);
+ compile(allSourceFiles);
}
+
+ if (javaBuilder.javaProject.hasCycleMarker())
+ javaBuilder.mustPropagateStructuralChanges();
} catch (CoreException e) {
throw internalException(e);
} finally {
@@ -56,97 +60,184 @@
}
}
-protected void addAllSourceFiles(final ArrayList locations, final ArrayList typeNames) throws CoreException {
- for (int i = 0, length = sourceFolders.length; i < length; i++) {
- final int srcFolderLength = sourceFolders[i].getLocation().addTrailingSeparator().toString().length();
- sourceFolders[i].accept(
- new IResourceVisitor() {
- public boolean visit(IResource resource) {
- if (resource.getType() == IResource.FILE) {
- if (JavaBuilder.JAVA_EXTENSION.equalsIgnoreCase(resource.getFileExtension())) {
- String sourceLocation = resource.getLocation().toString();
- locations.add(sourceLocation);
- typeNames.add(sourceLocation.substring(srcFolderLength, sourceLocation.length() - 5)); // length of .java
- }
- return false;
+protected void addAllSourceFiles(final ArrayList sourceFiles) throws CoreException {
+ for (int i = 0, l = sourceLocations.length; i < l; i++) {
+ final ClasspathMultiDirectory sourceLocation = sourceLocations[i];
+ final char[][] exclusionPatterns = sourceLocation.exclusionPatterns;
+ final boolean isAlsoProject = sourceLocation.sourceFolder.equals(javaBuilder.currentProject);
+ sourceLocation.sourceFolder.accept(
+ new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ IResource resource = null;
+ if (exclusionPatterns != null) {
+ resource = proxy.requestResource();
+ if (Util.isExcluded(resource, exclusionPatterns)) return false;
}
- return true;
- }
- }
- );
- notifier.checkCancel();
- }
-}
-
-protected void scrubOutputFolder() throws CoreException {
- if (hasSeparateOutputFolder) {
- // outputPath is not on the class path so wipe it clean then copy extra resources back
- IResource[] members = outputFolder.members();
- for (int i = 0, length = members.length; i < length; i++)
- members[i].delete(IResource.FORCE, null);
- notifier.checkCancel();
- copyExtraResourcesBack();
- } else {
- // outputPath == a source folder so just remove class files
- outputFolder.accept(
- new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource.getType() == IResource.FILE) {
- if (JavaBuilder.CLASS_EXTENSION.equalsIgnoreCase(resource.getFileExtension()))
- resource.delete(IResource.FORCE, null);
- return false;
- }
- return true;
- }
- }
- );
- }
- notifier.checkCancel();
-}
-
-protected void copyExtraResourcesBack() throws CoreException {
- // When, if ever, does a builder need to copy resources files (not .java or .class) into the output folder?
- // If we wipe the output folder at the beginning of the build then all 'extra' resources must be copied to the output folder.
-
- final IPath outputPath = outputFolder.getFullPath();
- for (int i = 0, length = sourceFolders.length; i < length; i++) {
- IContainer sourceFolder = sourceFolders[i];
- final IPath sourcePath = sourceFolder.getFullPath();
- final int segmentCount = sourcePath.segmentCount();
- sourceFolder.accept(
- new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- switch(resource.getType()) {
+ switch(proxy.getType()) {
case IResource.FILE :
- String extension = resource.getFileExtension();
- if (JavaBuilder.JAVA_EXTENSION.equalsIgnoreCase(extension)) return false;
- if (JavaBuilder.CLASS_EXTENSION.equalsIgnoreCase(extension)) return false;
- if (javaBuilder.filterResource(resource)) return false;
-
- IPath partialPath = resource.getFullPath().removeFirstSegments(segmentCount);
- IResource copiedResource = outputFolder.getFile(partialPath);
- if (copiedResource.exists()) {
- createErrorFor(resource, Util.bind("build.duplicateResource")); //$NON-NLS-1$
- } else {
- resource.copy(copiedResource.getFullPath(), IResource.FORCE, null);
- copiedResource.setDerived(true);
+ if (Util.isJavaFileName(proxy.getName())) {
+ if (resource == null)
+ resource = proxy.requestResource();
+ sourceFiles.add(new SourceFile((IFile) resource, sourceLocation, encoding));
}
return false;
case IResource.FOLDER :
- if (resource.getFullPath().equals(outputPath)) return false;
- if (resource.getFullPath().equals(sourcePath)) return true;
- if (javaBuilder.filterResource(resource)) return false;
-
- getOutputFolder(resource.getFullPath().removeFirstSegments(segmentCount));
+ if (isAlsoProject && isExcludedFromProject(proxy.requestFullPath())) return false;
}
return true;
}
- }
+ },
+ IResource.NONE
);
+ notifier.checkCancel();
}
}
+protected void cleanOutputFolders() throws CoreException {
+ boolean deleteAll = JavaCore.CLEAN.equals(
+ javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, true));
+ if (deleteAll) {
+ ArrayList visited = new ArrayList(sourceLocations.length);
+ for (int i = 0, l = sourceLocations.length; i < l; i++) {
+ notifier.subTask(Util.bind("build.cleaningOutput")); //$NON-NLS-1$
+ ClasspathMultiDirectory sourceLocation = sourceLocations[i];
+ if (sourceLocation.hasIndependentOutputFolder) {
+ IContainer outputFolder = sourceLocation.binaryFolder;
+ if (!visited.contains(outputFolder)) {
+ visited.add(outputFolder);
+ IResource[] members = outputFolder.members();
+ for (int j = 0, m = members.length; j < m; j++)
+ members[j].delete(IResource.FORCE, null);
+ }
+ notifier.checkCancel();
+ copyExtraResourcesBack(sourceLocation, deleteAll);
+ } else {
+ boolean isOutputFolder = sourceLocation.sourceFolder.equals(sourceLocation.binaryFolder);
+ final char[][] exclusionPatterns =
+ isOutputFolder
+ ? sourceLocation.exclusionPatterns
+ : null; // ignore exclusionPatterns if output folder == another source folder... not this one
+ sourceLocation.binaryFolder.accept(
+ new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ IResource resource = null;
+ if (exclusionPatterns != null) {
+ resource = proxy.requestResource();
+ if (Util.isExcluded(resource, exclusionPatterns)) return false;
+ }
+ if (proxy.getType() == IResource.FILE) {
+ if (Util.isClassFileName(proxy.getName())) {
+ if (resource == null)
+ resource = proxy.requestResource();
+ resource.delete(IResource.FORCE, null);
+ }
+ return false;
+ }
+ notifier.checkCancel();
+ return true;
+ }
+ },
+ IResource.NONE
+ );
+ if (!isOutputFolder) {
+ notifier.checkCancel();
+ copyPackages(sourceLocation);
+ }
+ }
+ notifier.checkCancel();
+ }
+ } else {
+ for (int i = 0, l = sourceLocations.length; i < l; i++) {
+ ClasspathMultiDirectory sourceLocation = sourceLocations[i];
+ if (sourceLocation.hasIndependentOutputFolder)
+ copyExtraResourcesBack(sourceLocation, deleteAll);
+ else if (!sourceLocation.sourceFolder.equals(sourceLocation.binaryFolder))
+ copyPackages(sourceLocation); // output folder is different from source folder
+ notifier.checkCancel();
+ }
+ }
+}
+
+protected void copyExtraResourcesBack(ClasspathMultiDirectory sourceLocation, final boolean deletedAll) throws CoreException {
+ // When, if ever, does a builder need to copy resources files (not .java or .class) into the output folder?
+ // If we wipe the output folder at the beginning of the build then all 'extra' resources must be copied to the output folder.
+
+ notifier.subTask(Util.bind("build.copyingResources")); //$NON-NLS-1$
+ final int segmentCount = sourceLocation.sourceFolder.getFullPath().segmentCount();
+ final char[][] exclusionPatterns = sourceLocation.exclusionPatterns;
+ final IContainer outputFolder = sourceLocation.binaryFolder;
+ final boolean isAlsoProject = sourceLocation.sourceFolder.equals(javaBuilder.currentProject);
+ sourceLocation.sourceFolder.accept(
+ new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ IResource resource = null;
+ switch(proxy.getType()) {
+ case IResource.FILE :
+ if (Util.isJavaFileName(proxy.getName()) || Util.isClassFileName(proxy.getName())) return false;
+
+ resource = proxy.requestResource();
+ if (javaBuilder.filterExtraResource(resource)) return false;
+ if (exclusionPatterns != null && Util.isExcluded(resource, exclusionPatterns))
+ return false;
+
+ IPath partialPath = resource.getFullPath().removeFirstSegments(segmentCount);
+ IResource copiedResource = outputFolder.getFile(partialPath);
+ if (copiedResource.exists()) {
+ if (deletedAll) {
+ createErrorFor(resource, Util.bind("build.duplicateResource")); //$NON-NLS-1$
+ return false;
+ }
+ copiedResource.delete(IResource.FORCE, null); // last one wins
+ }
+ resource.copy(copiedResource.getFullPath(), IResource.FORCE, null);
+ copiedResource.setDerived(true);
+ return false;
+ case IResource.FOLDER :
+ resource = proxy.requestResource();
+ if (javaBuilder.filterExtraResource(resource)) return false;
+ if (exclusionPatterns != null && Util.isExcluded(resource, exclusionPatterns))
+ return false;
+
+ IPath folderPath = resource.getFullPath();
+ if (isAlsoProject && isExcludedFromProject(folderPath)) return false; // the sourceFolder == project
+ createFolder(folderPath.removeFirstSegments(segmentCount), outputFolder);
+ }
+ return true;
+ }
+ },
+ IResource.NONE
+ );
+}
+
+protected void copyPackages(ClasspathMultiDirectory sourceLocation) throws CoreException {
+ final int segmentCount = sourceLocation.sourceFolder.getFullPath().segmentCount();
+ final char[][] exclusionPatterns = sourceLocation.exclusionPatterns;
+ final IContainer outputFolder = sourceLocation.binaryFolder;
+ final boolean isAlsoProject = sourceLocation.sourceFolder.equals(javaBuilder.currentProject);
+ sourceLocation.sourceFolder.accept(
+ new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ switch(proxy.getType()) {
+ case IResource.FILE :
+ return false;
+ case IResource.FOLDER :
+ IResource resource = proxy.requestResource();
+ if (javaBuilder.filterExtraResource(resource)) return false;
+ if (exclusionPatterns != null && Util.isExcluded(resource, exclusionPatterns))
+ return false;
+
+ IPath folderPath = resource.getFullPath();
+ if (isAlsoProject && isExcludedFromProject(folderPath)) return false; // the sourceFolder == project
+ createFolder(folderPath.removeFirstSegments(segmentCount), outputFolder);
+ }
+ return true;
+ }
+ },
+ IResource.NONE
+ );
+}
+
public String toString() {
return "batch image builder for:\n\tnew state: " + newState; //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BuildNotifier.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BuildNotifier.java
index 3940d7a..14f9640 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BuildNotifier.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/BuildNotifier.java
@@ -1,27 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.core.Util;
public class BuildNotifier {
protected IProgressMonitor monitor;
-protected int rootPathLength;
protected boolean cancelling;
protected float percentComplete;
protected float progressPerCompilationUnit;
@@ -33,23 +31,25 @@
protected int totalWork;
protected String previousSubtask;
+public static int NewErrorCount = 0;
+public static int FixedErrorCount = 0;
+public static int NewWarningCount = 0;
+public static int FixedWarningCount = 0;
+
+public static void resetProblemCounters() {
+ NewErrorCount = 0;
+ FixedErrorCount = 0;
+ NewWarningCount = 0;
+ FixedWarningCount = 0;
+}
+
public BuildNotifier(IProgressMonitor monitor, IProject project) {
this.monitor = monitor;
- try {
- IPath location = project.getDescription().getLocation();
- if (location == null)
- location = project.getParent().getLocation(); // default workspace location
- else if (project.getName().equalsIgnoreCase(location.lastSegment()))
- location = location.removeLastSegments(1); // want to show project name if possible
- this.rootPathLength = location.addTrailingSeparator().toString().length();
- } catch(CoreException e) {
- this.rootPathLength = 0;
- }
this.cancelling = false;
- this.newErrorCount = 0;
- this.fixedErrorCount = 0;
- this.newWarningCount = 0;
- this.fixedWarningCount = 0;
+ this.newErrorCount = NewErrorCount;
+ this.fixedErrorCount = FixedErrorCount;
+ this.newWarningCount = NewWarningCount;
+ this.fixedWarningCount = FixedWarningCount;
this.workDone = 0;
this.totalWork = 1000000;
}
@@ -57,12 +57,8 @@
/**
* Notification before a compile that a unit is about to be compiled.
*/
-public void aboutToCompile(ICompilationUnit unit) {
- String message = new String(unit.getFileName());
- message = message.replace('\\', '/');
- int end = message.lastIndexOf('/');
- message = Util.bind("build.compiling", //$NON-NLS-1$
- message.substring(rootPathLength, end <= rootPathLength ? message.length() : end));
+public void aboutToCompile(SourceFile unit) {
+ String message = Util.bind("build.compiling", unit.resource.getFullPath().removeLastSegments(1).makeRelative().toString()); //$NON-NLS-1$
subTask(message);
}
@@ -97,18 +93,19 @@
/**
* Notification while within a compile that a unit has finished being compiled.
*/
-public void compiled(ICompilationUnit unit) {
- String message = new String(unit.getFileName());
- message = message.replace('\\', '/');
- int end = message.lastIndexOf('/');
- message = Util.bind("build.compiling", //$NON-NLS-1$
- message.substring(rootPathLength, end <= rootPathLength ? message.length() : end));
+public void compiled(SourceFile unit) {
+ String message = Util.bind("build.compiling", unit.resource.getFullPath().removeLastSegments(1).makeRelative().toString()); //$NON-NLS-1$
subTask(message);
updateProgressDelta(progressPerCompilationUnit);
checkCancelWithinCompiler();
}
public void done() {
+ NewErrorCount = this.newErrorCount;
+ FixedErrorCount = this.fixedErrorCount;
+ NewWarningCount = this.newWarningCount;
+ FixedWarningCount = this.fixedWarningCount;
+
updateProgress(1.0f);
subTask(Util.bind("build.done")); //$NON-NLS-1$
if (monitor != null)
@@ -123,22 +120,58 @@
int numNew = newErrorCount + newWarningCount;
int numFixed = fixedErrorCount + fixedWarningCount;
if (numNew == 0 && numFixed == 0) return ""; //$NON-NLS-1$
- if (numFixed == 0)
- return '(' + (numNew == 1
- ? Util.bind("build.oneProblemFound", String.valueOf(numNew)) //$NON-NLS-1$
- : Util.bind("build.problemsFound", String.valueOf(numNew))) + ')'; //$NON-NLS-1$
- if (numNew == 0)
- return '(' + (numFixed == 1
- ? Util.bind("build.oneProblemFixed", String.valueOf(numFixed)) //$NON-NLS-1$
- : Util.bind("build.problemsFixed", String.valueOf(numFixed))) + ')'; //$NON-NLS-1$
- return
- '(' + (numFixed == 1
- ? Util.bind("build.oneProblemFixed", String.valueOf(numFixed)) //$NON-NLS-1$
- : Util.bind("build.problemsFixed", String.valueOf(numFixed))) //$NON-NLS-1$
- + ", " //$NON-NLS-1$
- + (numNew == 1
- ? Util.bind("build.oneProblemFound", String.valueOf(numNew)) //$NON-NLS-1$
- : Util.bind("build.problemsFound", String.valueOf(numNew))) + ')'; //$NON-NLS-1$
+
+ boolean displayBoth = numNew > 0 && numFixed > 0;
+ StringBuffer buffer = new StringBuffer();
+ buffer.append('(');
+ if (numNew > 0) {
+ // (Found x errors + y warnings)
+ buffer.append(Util.bind("build.foundHeader")); //$NON-NLS-1$
+ buffer.append(' ');
+ if (displayBoth || newErrorCount > 0) {
+ if (newErrorCount == 1)
+ buffer.append(Util.bind("build.oneError")); //$NON-NLS-1$
+ else
+ buffer.append(Util.bind("build.multipleErrors", String.valueOf(newErrorCount))); //$NON-NLS-1$
+ if (displayBoth || newWarningCount > 0)
+ buffer.append(" + "); //$NON-NLS-1$
+ }
+ if (displayBoth || newWarningCount > 0) {
+ if (newWarningCount == 1)
+ buffer.append(Util.bind("build.oneWarning")); //$NON-NLS-1$
+ else
+ buffer.append(Util.bind("build.multipleWarnings", String.valueOf(newWarningCount))); //$NON-NLS-1$
+ }
+ if (numFixed > 0)
+ buffer.append(", "); //$NON-NLS-1$
+ }
+ if (numFixed > 0) {
+ // (Fixed x errors + y warnings) or (Found x errors + y warnings, Fixed x + y)
+ buffer.append(Util.bind("build.fixedHeader")); //$NON-NLS-1$
+ buffer.append(' ');
+ if (displayBoth) {
+ buffer.append(String.valueOf(fixedErrorCount));
+ buffer.append(" + "); //$NON-NLS-1$
+ buffer.append(String.valueOf(fixedWarningCount));
+ } else {
+ if (fixedErrorCount > 0) {
+ if (fixedErrorCount == 1)
+ buffer.append(Util.bind("build.oneError")); //$NON-NLS-1$
+ else
+ buffer.append(Util.bind("build.multipleErrors", String.valueOf(fixedErrorCount))); //$NON-NLS-1$
+ if (fixedWarningCount > 0)
+ buffer.append(" + "); //$NON-NLS-1$
+ }
+ if (fixedWarningCount > 0) {
+ if (fixedWarningCount == 1)
+ buffer.append(Util.bind("build.oneWarning")); //$NON-NLS-1$
+ else
+ buffer.append(Util.bind("build.multipleWarnings", String.valueOf(fixedWarningCount))); //$NON-NLS-1$
+ }
+ }
+ }
+ buffer.append(')');
+ return buffer.toString();
}
/**
@@ -171,7 +204,7 @@
}
protected void updateProblemCounts(IProblem[] newProblems) {
- for (int i = 0, newSize = newProblems.length; i < newSize; ++i)
+ for (int i = 0, l = newProblems.length; i < l; i++)
if (newProblems[i].isError()) newErrorCount++; else newWarningCount++;
}
@@ -181,13 +214,14 @@
*/
protected void updateProblemCounts(IMarker[] oldProblems, IProblem[] newProblems) {
if (newProblems != null) {
- next : for (int i = 0, newSize = newProblems.length; i < newSize; ++i) {
+ next : for (int i = 0, l = newProblems.length; i < l; i++) {
IProblem newProblem = newProblems[i];
+ if (newProblem.getID() == IProblem.Task) continue; // skip task
boolean isError = newProblem.isError();
String message = newProblem.getMessage();
if (oldProblems != null) {
- for (int j = 0, oldSize = oldProblems.length; j < oldSize; ++j) {
+ for (int j = 0, m = oldProblems.length; j < m; j++) {
IMarker pb = oldProblems[j];
if (pb == null) continue; // already matched up with a new problem
boolean wasError = IMarker.SEVERITY_ERROR
@@ -202,7 +236,7 @@
}
}
if (oldProblems != null) {
- next : for (int i = 0, oldSize = oldProblems.length; i < oldSize; ++i) {
+ next : for (int i = 0, l = oldProblems.length; i < l; i++) {
IMarker oldProblem = oldProblems[i];
if (oldProblem == null) continue next; // already matched up with a new problem
boolean wasError = IMarker.SEVERITY_ERROR
@@ -210,8 +244,9 @@
String message = oldProblem.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
if (newProblems != null) {
- for (int j = 0, newSize = newProblems.length; j < newSize; ++j) {
+ for (int j = 0, m = newProblems.length; j < m; j++) {
IProblem pb = newProblems[j];
+ if (pb.getID() == IProblem.Task) continue; // skip task
if (wasError == pb.isError() && message.equals(pb.getMessage()))
continue next;
}
@@ -238,4 +273,4 @@
public void updateProgressDelta(float percentWorked) {
updateProgress(percentComplete + percentWorked);
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java
index a54fcba..4b2242c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathDirectory.java
@@ -1,35 +1,41 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
-
-import java.io.*;
+import org.eclipse.jdt.internal.core.Util;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
class ClasspathDirectory extends ClasspathLocation {
-String binaryPath; // includes .class files for a single directory
+IContainer binaryFolder; // includes .class files for a single directory
+boolean isOutputFolder;
+String binaryLocation;
SimpleLookupTable directoryCache;
String[] missingPackageHolder = new String[1];
-ClasspathDirectory(String binaryPath) {
- this.binaryPath = binaryPath;
- if (!binaryPath.endsWith("/")) //$NON-NLS-1$
- this.binaryPath += "/"; //$NON-NLS-1$
+ClasspathDirectory(IContainer binaryFolder, boolean isOutputFolder) {
+ this.binaryFolder = binaryFolder;
+ this.isOutputFolder = isOutputFolder;
+ IPath location = binaryFolder.getLocation();
+ this.binaryLocation = location != null ? location.addTrailingSeparator().toString() : ""; //$NON-NLS-1$
this.directoryCache = new SimpleLookupTable(5);
}
-void cleanup() {
+public void cleanup() {
this.directoryCache = null;
}
@@ -38,34 +44,30 @@
if (dirList == missingPackageHolder) return null; // package exists in another classpath directory or jar
if (dirList != null) return dirList;
- File dir = new File(binaryPath + qualifiedPackageName);
- notFound : if (dir != null && dir.isDirectory()) {
- // must protect against a case insensitive File call
- // walk the qualifiedPackageName backwards looking for an uppercase character before the '/'
- int index = qualifiedPackageName.length();
- int last = qualifiedPackageName.lastIndexOf('/');
- while (--index > last && !Character.isUpperCase(qualifiedPackageName.charAt(index))) {}
- if (index > last) {
- if (last == -1) {
- if (!doesFileExist(qualifiedPackageName, "")) //$NON-NLS-1$
- break notFound;
- } else {
- String packageName = qualifiedPackageName.substring(last + 1);
- String parentPackage = qualifiedPackageName.substring(0, last);
- if (!doesFileExist(packageName, parentPackage))
- break notFound;
+ try {
+ IResource container = binaryFolder.findMember(qualifiedPackageName); // this is a case-sensitive check
+ if (container instanceof IContainer) {
+ IResource[] members = ((IContainer) container).members();
+ dirList = new String[members.length];
+ int index = 0;
+ for (int i = 0, l = members.length; i < l; i++) {
+ IResource m = members[i];
+ if (m.getType() == IResource.FILE && Util.isClassFileName(m.getName()))
+ // add exclusion pattern check here if we want to hide .class files
+ dirList[index++] = m.getName();
}
+ if (index < dirList.length)
+ System.arraycopy(dirList, 0, dirList = new String[index], 0, index);
+ directoryCache.put(qualifiedPackageName, dirList);
+ return dirList;
}
- if ((dirList = dir.list()) == null)
- dirList = new String[0];
- directoryCache.put(qualifiedPackageName, dirList);
- return dirList;
+ } catch(CoreException ignored) {
}
directoryCache.put(qualifiedPackageName, missingPackageHolder);
return null;
}
-boolean doesFileExist(String fileName, String qualifiedPackageName) {
+boolean doesFileExist(String fileName, String qualifiedPackageName, String qualifiedFullName) {
String[] dirList = directoryList(qualifiedPackageName);
if (dirList == null) return false; // most common case
@@ -79,28 +81,36 @@
if (this == o) return true;
if (!(o instanceof ClasspathDirectory)) return false;
- return binaryPath.equals(((ClasspathDirectory) o).binaryPath);
+ return binaryFolder.equals(((ClasspathDirectory) o).binaryFolder);
}
-NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
- if (!doesFileExist(binaryFileName, qualifiedPackageName)) return null; // most common case
+public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
+ if (!doesFileExist(binaryFileName, qualifiedPackageName, qualifiedBinaryFileName)) return null; // most common case
try {
- ClassFileReader reader = ClassFileReader.read(binaryPath + qualifiedBinaryFileName);
+ ClassFileReader reader = ClassFileReader.read(binaryLocation + qualifiedBinaryFileName);
if (reader != null) return new NameEnvironmentAnswer(reader);
} catch (Exception e) {} // treat as if class file is missing
return null;
}
-boolean isPackage(String qualifiedPackageName) {
+public IPath getProjectRelativePath() {
+ return binaryFolder.getProjectRelativePath();
+}
+
+public boolean isOutputFolder() {
+ return isOutputFolder;
+}
+
+public boolean isPackage(String qualifiedPackageName) {
return directoryList(qualifiedPackageName) != null;
}
-void reset() {
+public void reset() {
this.directoryCache = new SimpleLookupTable(5);
}
public String toString() {
- return "Binary classpath directory " + binaryPath; //$NON-NLS-1$
+ return "Binary classpath directory " + binaryFolder.getFullPath().toString(); //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java
index ac04ec7..9670171 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJar.java
@@ -1,27 +1,33 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.*;
+
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
import java.io.*;
import java.util.*;
import java.util.zip.*;
-class ClasspathJar extends ClasspathLocation {
+public class ClasspathJar extends ClasspathLocation {
String zipFilename; // keep for equals
+IFile resource;
ZipFile zipFile;
-SimpleLookupTable packageCache;
+boolean closeZipFileAtEnd;
+SimpleLookupTable packageCache;
ClasspathJar(String zipFilename) {
this.zipFilename = zipFilename;
@@ -29,8 +35,23 @@
this.packageCache = null;
}
-void cleanup() {
- if (zipFile != null) {
+ClasspathJar(IFile resource) {
+ this.resource = resource;
+ IPath location = resource.getLocation();
+ this.zipFilename = location != null ? location.toString() : ""; //$NON-NLS-1$
+ this.zipFile = null;
+ this.packageCache = null;
+}
+
+public ClasspathJar(ZipFile zipFile) {
+ this.zipFilename = zipFile.getName();
+ this.zipFile = zipFile;
+ this.closeZipFileAtEnd = false;
+ this.packageCache = null;
+}
+
+public void cleanup() {
+ if (zipFile != null && this.closeZipFileAtEnd) {
try { zipFile.close(); } catch(IOException e) {}
this.zipFile = null;
}
@@ -44,7 +65,7 @@
return zipFilename.equals(((ClasspathJar) o).zipFilename);
}
-NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
+public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
if (!isPackage(qualifiedPackageName)) return null; // most common case
try {
@@ -54,14 +75,22 @@
return null;
}
-boolean isPackage(String qualifiedPackageName) {
+public IPath getProjectRelativePath() {
+ if (resource == null) return null;
+ return resource.getProjectRelativePath();
+}
+
+public boolean isPackage(String qualifiedPackageName) {
if (packageCache != null)
return packageCache.containsKey(qualifiedPackageName);
this.packageCache = new SimpleLookupTable(41);
packageCache.put("", ""); //$NON-NLS-1$ //$NON-NLS-2$
try {
- this.zipFile = new ZipFile(zipFilename);
+ if (this.zipFile == null) {
+ this.zipFile = new ZipFile(zipFilename);
+ this.closeZipFileAtEnd = true;
+ }
nextEntry : for (Enumeration e = zipFile.entries(); e.hasMoreElements(); ) {
String fileName = ((ZipEntry) e.nextElement()).getName();
@@ -85,4 +114,4 @@
public String toString() {
return "Classpath jar file " + zipFilename; //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathLocation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathLocation.java
index 4ab1157..7282bbb 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathLocation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathLocation.java
@@ -1,38 +1,52 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
-abstract class ClasspathLocation {
+public abstract class ClasspathLocation {
-static ClasspathLocation forSourceFolder(String sourceFolderPathname, String outputFolderPathname) {
- return new ClasspathMultiDirectory(sourceFolderPathname, outputFolderPathname);
+static ClasspathLocation forSourceFolder(IContainer sourceFolder, IContainer outputFolder, char[][] exclusionPatterns) {
+ return new ClasspathMultiDirectory(sourceFolder, outputFolder, exclusionPatterns);
}
-static ClasspathLocation forBinaryFolder(String binaryFolderPathname) {
- return new ClasspathDirectory(binaryFolderPathname);
+public static ClasspathLocation forBinaryFolder(IContainer binaryFolder, boolean isOutputFolder) {
+ return new ClasspathDirectory(binaryFolder, isOutputFolder);
}
static ClasspathLocation forLibrary(String libraryPathname) {
return new ClasspathJar(libraryPathname);
}
-abstract NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName);
-abstract boolean isPackage(String qualifiedPackageName);
+static ClasspathLocation forLibrary(IFile library) {
+ return new ClasspathJar(library);
+}
+
+public abstract NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName);
+
+public abstract IPath getProjectRelativePath();
+
+public boolean isOutputFolder() {
+ return false;
+}
+
+public abstract boolean isPackage(String qualifiedPackageName);
// free anything which is not required when the state is saved
-void cleanup() {
+public void cleanup() {
}
// reset any internal caches before another compile loop starts
-void reset() {
+public void reset() {
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiDirectory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiDirectory.java
index c0d29a0..fe66631 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiDirectory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiDirectory.java
@@ -1,28 +1,34 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
-import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.jdt.core.compiler.CharOperation;
class ClasspathMultiDirectory extends ClasspathDirectory {
-String sourcePath;
+IContainer sourceFolder;
+char[][] exclusionPatterns; // used by builders when walking source folders
+boolean hasIndependentOutputFolder; // if output folder is not equal to any of the source folders
-ClasspathMultiDirectory(String sourcePath, String binaryPath) {
- super(binaryPath);
+ClasspathMultiDirectory(IContainer sourceFolder, IContainer binaryFolder, char[][] exclusionPatterns) {
+ super(binaryFolder, true);
- this.sourcePath = sourcePath;
- if (!sourcePath.endsWith("/")) //$NON-NLS-1$
- this.sourcePath += "/"; //$NON-NLS-1$
+ this.sourceFolder = sourceFolder;
+ this.exclusionPatterns = exclusionPatterns;
+ this.hasIndependentOutputFolder = false;
+
+ // handle the case when a state rebuilds a source folder
+ if (this.exclusionPatterns != null && this.exclusionPatterns.length == 0)
+ this.exclusionPatterns = null;
}
public boolean equals(Object o) {
@@ -30,30 +36,12 @@
if (!(o instanceof ClasspathMultiDirectory)) return false;
ClasspathMultiDirectory md = (ClasspathMultiDirectory) o;
- return binaryPath.equals(md.binaryPath) && sourcePath.equals(md.sourcePath);
+ return sourceFolder.equals(md.sourceFolder) && binaryFolder.equals(md.binaryFolder)
+ && CharOperation.equals(exclusionPatterns, md.exclusionPatterns);
}
-NameEnvironmentAnswer findSourceFile(
- String qualifiedSourceFileName,
- String qualifiedPackageName,
- char[] typeName,
- String[] additionalSourceFilenames) {
-
- // if an additional source file is waiting to be compiled, answer it
- // BUT not if this is a secondary type search,
- // if we answer the source file X.java which may no longer define Y
- // then the binary type looking for Y will fail & think the class path is wrong
- // let the recompile loop fix up dependents when Y has been deleted from X.java
- String fullSourceName = sourcePath + qualifiedSourceFileName;
- for (int i = 0, l = additionalSourceFilenames.length; i < l; i++)
- if (fullSourceName.equals(additionalSourceFilenames[i]))
- return new NameEnvironmentAnswer(
- new SourceFile(fullSourceName, typeName, CharOperation.splitOn('/', qualifiedPackageName.toCharArray())));
- return null;
-}
-
public String toString() {
- return "Source classpath directory " + sourcePath + //$NON-NLS-1$
- " with binary directory " + binaryPath; //$NON-NLS-1$
+ return "Source classpath directory " + sourceFolder.getFullPath().toString() + //$NON-NLS-1$
+ " with binary directory " + binaryFolder.getFullPath().toString(); //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ImageBuilderInternalException.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ImageBuilderInternalException.java
index 6b28859..fa2a40e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ImageBuilderInternalException.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ImageBuilderInternalException.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
import org.eclipse.core.runtime.CoreException;
@@ -37,4 +37,4 @@
super.printStackTrace();
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java
index d775251..d9402ec 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/IncrementalImageBuilder.java
@@ -1,24 +1,26 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.*;
import org.eclipse.jdt.internal.compiler.classfmt.*;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.Util;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
+import java.io.*;
import java.util.*;
/**
@@ -26,25 +28,27 @@
*/
public class IncrementalImageBuilder extends AbstractImageBuilder {
-protected ArrayList locations;
-protected ArrayList previousLocations;
-protected ArrayList typeNames;
+protected ArrayList sourceFiles;
+protected ArrayList previousSourceFiles;
protected ArrayList qualifiedStrings;
protected ArrayList simpleStrings;
-protected ArrayList secondaryTypesToRemove;
+protected SimpleLookupTable secondaryTypesToRemove;
+protected boolean hasStructuralChanges;
+protected int compileLoop;
public static int MaxCompileLoop = 5; // perform a full build if it takes more than ? incremental compile loops
protected IncrementalImageBuilder(JavaBuilder javaBuilder) {
super(javaBuilder);
- this.nameEnvironment.tagAsIncrementalBuild();
+ this.nameEnvironment.isIncrementalBuild = true;
this.newState.copyFrom(javaBuilder.lastState);
- this.locations = new ArrayList(33);
- this.previousLocations = null;
- this.typeNames = new ArrayList(33);
+ this.sourceFiles = new ArrayList(33);
+ this.previousSourceFiles = null;
this.qualifiedStrings = new ArrayList(33);
this.simpleStrings = new ArrayList(33);
+ this.hasStructuralChanges = false;
+ this.compileLoop = 0;
}
public boolean build(SimpleLookupTable deltas) {
@@ -72,12 +76,12 @@
Object[] keyTable = deltas.keyTable;
Object[] valueTable = deltas.valueTable;
- for (int i = 0, l = keyTable.length; i < l; i++) {
+ for (int i = 0, l = valueTable.length; i < l; i++) {
IResourceDelta delta = (IResourceDelta) valueTable[i];
if (delta != null) {
- IResource[] binaryResources = (IResource[]) javaBuilder.binaryResources.get(keyTable[i]);
- if (binaryResources != null)
- if (!findAffectedSourceFiles(delta, binaryResources)) return false;
+ ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[]) javaBuilder.binaryLocationsPerProject.get(keyTable[i]);
+ if (classFoldersAndJars != null)
+ if (!findAffectedSourceFiles(delta, classFoldersAndJars)) return false;
}
}
notifier.updateProgressDelta(0.10f);
@@ -86,29 +90,29 @@
addAffectedSourceFiles();
notifier.updateProgressDelta(0.05f);
- int compileLoop = 0;
+ this.compileLoop = 0;
float increment = 0.40f;
- while (locations.size() > 0) { // added to in acceptResult
- if (++compileLoop > MaxCompileLoop) {
+ while (sourceFiles.size() > 0) { // added to in acceptResult
+ if (++this.compileLoop > MaxCompileLoop) {
if (JavaBuilder.DEBUG)
System.out.println("ABORTING incremental build... exceeded loop count"); //$NON-NLS-1$
return false;
}
notifier.checkCancel();
- String[] allSourceFiles = new String[locations.size()];
- locations.toArray(allSourceFiles);
- String[] initialTypeStrings = new String[typeNames.size()];
- typeNames.toArray(initialTypeStrings);
+ SourceFile[] allSourceFiles = new SourceFile[sourceFiles.size()];
+ sourceFiles.toArray(allSourceFiles);
resetCollections();
workQueue.addAll(allSourceFiles);
notifier.setProgressPerCompilationUnit(increment / allSourceFiles.length);
increment = increment / 2;
- compile(allSourceFiles, initialTypeStrings);
+ compile(allSourceFiles);
removeSecondaryTypes();
addAffectedSourceFiles();
}
+ if (this.hasStructuralChanges && javaBuilder.javaProject.hasCycleMarker())
+ javaBuilder.mustPropagateStructuralChanges();
} catch (AbortIncrementalBuildException e) {
// abort the incremental build and let the batch builder handle the problem
if (JavaBuilder.DEBUG)
@@ -138,33 +142,44 @@
Object[] keyTable = newState.references.keyTable;
Object[] valueTable = newState.references.valueTable;
- next : for (int i = 0, l = keyTable.length; i < l; i++) {
- String sourceLocation = (String) keyTable[i];
- if (sourceLocation != null && !locations.contains(sourceLocation)) {
- if (compiledAllAtOnce && previousLocations != null && previousLocations.contains(sourceLocation))
- continue next; // can skip previously compiled locations since already saw hierarchy related problems
-
- ReferenceCollection refs = (ReferenceCollection) valueTable[i];
- if (refs.includes(qualifiedNames, simpleNames)) {
- // check that the file still exists... the file or its package may have been deleted
- IResource affectedFile = resourceForLocation(sourceLocation);
- if (affectedFile != null && affectedFile.exists()) {
- if (JavaBuilder.DEBUG)
- System.out.println(" adding affected source file " + sourceLocation); //$NON-NLS-1$
- locations.add(sourceLocation);
- typeNames.add(extractTypeNameFrom(sourceLocation));
+ next : for (int i = 0, l = valueTable.length; i < l; i++) {
+ ReferenceCollection refs = (ReferenceCollection) valueTable[i];
+ if (refs != null && refs.includes(qualifiedNames, simpleNames)) {
+ String typeLocator = (String) keyTable[i];
+ IFile file = javaBuilder.currentProject.getFile(typeLocator);
+ if (file.exists()) {
+ ClasspathMultiDirectory md = sourceLocations[0];
+ if (sourceLocations.length > 1) {
+ IPath sourceFileFullPath = file.getFullPath();
+ for (int j = 0, m = sourceLocations.length; j < m; j++) {
+ if (sourceLocations[j].sourceFolder.getFullPath().isPrefixOf(sourceFileFullPath)) {
+ md = sourceLocations[j];
+ if (md.exclusionPatterns == null || !Util.isExcluded(file, md.exclusionPatterns))
+ break;
+ }
+ }
}
+ SourceFile sourceFile = new SourceFile(file, md, encoding);
+ if (sourceFiles.contains(sourceFile)) continue next;
+ if (compiledAllAtOnce && previousSourceFiles != null && previousSourceFiles.contains(sourceFile))
+ continue next; // can skip previously compiled files since already saw hierarchy related problems
+
+ if (JavaBuilder.DEBUG)
+ System.out.println(" adding affected source file " + typeLocator); //$NON-NLS-1$
+ sourceFiles.add(sourceFile);
}
}
}
}
protected void addDependentsOf(IPath path, boolean hasStructuralChanges) {
- if (hasStructuralChanges)
+ if (hasStructuralChanges) {
newState.tagAsStructurallyChanged();
- // the qualifiedStrings are of the form 'p1/p1' & the simpleStrings are just 'X'
+ this.hasStructuralChanges = true;
+ }
+ // the qualifiedStrings are of the form 'p1/p2' & the simpleStrings are just 'X'
path = path.setDevice(null);
- String packageName = path.uptoSegment(path.segmentCount() - 1).toString();
+ String packageName = path.removeLastSegments(1).toString();
if (!qualifiedStrings.contains(packageName))
qualifiedStrings.add(packageName);
String typeName = path.lastSegment();
@@ -173,7 +188,7 @@
typeName = typeName.substring(0, memberIndex);
if (!simpleStrings.contains(typeName)) {
if (JavaBuilder.DEBUG)
- System.out.println(" adding dependents of " //$NON-NLS-1$
+ System.out.println(" will look for dependents of " //$NON-NLS-1$
+ typeName + " in " + packageName); //$NON-NLS-1$
simpleStrings.add(typeName);
}
@@ -182,35 +197,40 @@
protected void cleanUp() {
super.cleanUp();
- this.locations = null;
- this.previousLocations = null;
- this.typeNames = null;
+ this.sourceFiles = null;
+ this.previousSourceFiles = null;
this.qualifiedStrings = null;
this.simpleStrings = null;
+ this.secondaryTypesToRemove = null;
+ this.hasStructuralChanges = false;
+ this.compileLoop = 0;
}
-protected boolean findAffectedSourceFiles(IResourceDelta delta, IResource[] binaryResources) {
- for (int j = 0, k = binaryResources.length; j < k; j++) {
- IResource binaryResource = binaryResources[j];
+protected boolean findAffectedSourceFiles(IResourceDelta delta, ClasspathLocation[] classFoldersAndJars) {
+ for (int i = 0, l = classFoldersAndJars.length; i < l; i++) {
+ ClasspathLocation bLocation = classFoldersAndJars[i];
// either a .class file folder or a zip/jar file
- if (binaryResource != null) { // skip unchanged output folder
- IResourceDelta binaryDelta = delta.findMember(binaryResource.getProjectRelativePath());
- if (binaryDelta != null) {
- if (binaryResource instanceof IFile) {
- if (JavaBuilder.DEBUG)
- System.out.println("ABORTING incremental build... found delta to jar/zip file"); //$NON-NLS-1$
- return false; // do full build since jar file was added/removed/changed
+ if (bLocation != null) { // skip unchanged output folder
+ IPath p = bLocation.getProjectRelativePath();
+ if (p != null) {
+ IResourceDelta binaryDelta = delta.findMember(p);
+ if (binaryDelta != null) {
+ if (bLocation instanceof ClasspathJar) {
+ if (JavaBuilder.DEBUG)
+ System.out.println("ABORTING incremental build... found delta to jar/zip file"); //$NON-NLS-1$
+ return false; // do full build since jar file was changed (added/removed were caught as classpath change)
+ }
+ if (binaryDelta.getKind() == IResourceDelta.ADDED || binaryDelta.getKind() == IResourceDelta.REMOVED) {
+ if (JavaBuilder.DEBUG)
+ System.out.println("ABORTING incremental build... found added/removed binary folder"); //$NON-NLS-1$
+ return false; // added/removed binary folder should not make it here (classpath change), but handle anyways
+ }
+ int segmentCount = binaryDelta.getFullPath().segmentCount();
+ IResourceDelta[] children = binaryDelta.getAffectedChildren(); // .class files from class folder
+ for (int j = 0, m = children.length; j < m; j++)
+ findAffectedSourceFiles(children[j], segmentCount);
+ notifier.checkCancel();
}
- if (binaryDelta.getKind() == IResourceDelta.ADDED || binaryDelta.getKind() == IResourceDelta.REMOVED) {
- if (JavaBuilder.DEBUG)
- System.out.println("ABORTING incremental build... found added/removed binary folder"); //$NON-NLS-1$
- return false; // added/removed binary folder should not make it here, but handle anyways
- }
- int segmentCount = binaryResource.getLocation().segmentCount();
- IResourceDelta[] children = binaryDelta.getAffectedChildren(); // .class files from class folder
- for (int i = 0, length = children.length; i < length; ++i)
- findAffectedSourceFiles(children[i], segmentCount);
- notifier.checkCancel();
}
}
}
@@ -221,20 +241,18 @@
// When a package becomes a type or vice versa, expect 2 deltas,
// one on the folder & one on the class file
IResource resource = binaryDelta.getResource();
- IPath location = resource.getLocation();
switch(resource.getType()) {
- case IResource.PROJECT :
case IResource.FOLDER :
switch (binaryDelta.getKind()) {
case IResourceDelta.ADDED :
case IResourceDelta.REMOVED :
- IPath packagePath = location.removeFirstSegments(segmentCount).makeRelative().setDevice(null);
+ IPath packagePath = resource.getFullPath().removeFirstSegments(segmentCount);
String packageName = packagePath.toString();
if (binaryDelta.getKind() == IResourceDelta.ADDED) {
// see if any known source file is from the same package... classpath already includes new package
if (!newState.isKnownPackage(packageName)) {
if (JavaBuilder.DEBUG)
- System.out.println("Add dependents of added package " + packageName); //$NON-NLS-1$
+ System.out.println("Found added package " + packageName); //$NON-NLS-1$
addDependentsOf(packagePath, false);
return;
}
@@ -244,7 +262,7 @@
// see if the package still exists on the classpath
if (!nameEnvironment.isPackage(packageName)) {
if (JavaBuilder.DEBUG)
- System.out.println("Add dependents of removed package " + packageName); //$NON-NLS-1$
+ System.out.println("Found removed package " + packageName); //$NON-NLS-1$
addDependentsOf(packagePath, false);
return;
}
@@ -254,25 +272,25 @@
// fall thru & traverse the sub-packages and .class files
case IResourceDelta.CHANGED :
IResourceDelta[] children = binaryDelta.getAffectedChildren();
- for (int i = 0, length = children.length; i < length; i++)
+ for (int i = 0, l = children.length; i < l; i++)
findAffectedSourceFiles(children[i], segmentCount);
}
return;
case IResource.FILE :
- if (JavaBuilder.CLASS_EXTENSION.equalsIgnoreCase(location.getFileExtension())) {
- IPath typePath = location.removeFirstSegments(segmentCount).removeFileExtension().makeRelative().setDevice(null);
+ if (Util.isClassFileName(resource.getName())) {
+ IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
switch (binaryDelta.getKind()) {
case IResourceDelta.ADDED :
case IResourceDelta.REMOVED :
if (JavaBuilder.DEBUG)
- System.out.println("Add dependents of added/removed class file " + typePath); //$NON-NLS-1$
+ System.out.println("Found added/removed class file " + typePath); //$NON-NLS-1$
addDependentsOf(typePath, false);
return;
case IResourceDelta.CHANGED :
if ((binaryDelta.getFlags() & IResourceDelta.CONTENT) == 0)
return; // skip it since it really isn't changed
if (JavaBuilder.DEBUG)
- System.out.println("Add dependents of changed class file " + typePath); //$NON-NLS-1$
+ System.out.println("Found changed class file " + typePath); //$NON-NLS-1$
addDependentsOf(typePath, false);
}
return;
@@ -281,119 +299,137 @@
}
protected boolean findSourceFiles(IResourceDelta delta) throws CoreException {
- for (int i = 0, length = sourceFolders.length; i < length; i++) {
- IResourceDelta sourceDelta = delta.findMember(sourceFolders[i].getProjectRelativePath());
- if (sourceDelta != null) {
- if (sourceDelta.getKind() == IResourceDelta.REMOVED) {
- if (JavaBuilder.DEBUG)
- System.out.println("ABORTING incremental build... found removed source folder"); //$NON-NLS-1$
- return false; // removed source folder should not make it here, but handle anyways (ADDED is supported)
+ for (int i = 0, l = sourceLocations.length; i < l; i++) {
+ ClasspathMultiDirectory md = sourceLocations[i];
+ if (md.sourceFolder.equals(javaBuilder.currentProject)) {
+ // skip nested source & output folders when the project is a source folder
+ int segmentCount = delta.getFullPath().segmentCount();
+ IResourceDelta[] children = delta.getAffectedChildren();
+ for (int j = 0, m = children.length; j < m; j++)
+ if (!isExcludedFromProject(children[i].getFullPath()))
+ findSourceFiles(children[j], md, segmentCount);
+ } else {
+ IResourceDelta sourceDelta = delta.findMember(md.sourceFolder.getProjectRelativePath());
+
+ if (sourceDelta != null) {
+ if (sourceDelta.getKind() == IResourceDelta.REMOVED) {
+ if (JavaBuilder.DEBUG)
+ System.out.println("ABORTING incremental build... found removed source folder"); //$NON-NLS-1$
+ return false; // removed source folder should not make it here, but handle anyways (ADDED is supported)
+ }
+ int segmentCount = sourceDelta.getFullPath().segmentCount();
+ IResourceDelta[] children = sourceDelta.getAffectedChildren();
+ for (int j = 0, m = children.length; j < m; j++)
+ findSourceFiles(children[j], md, segmentCount);
}
- int segmentCount = sourceFolders[i].getLocation().segmentCount();
- IResourceDelta[] children = sourceDelta.getAffectedChildren();
- for (int c = 0, clength = children.length; c < clength; c++)
- findSourceFiles(children[c], segmentCount);
- notifier.checkCancel();
}
+ notifier.checkCancel();
}
return true;
}
-protected void findSourceFiles(IResourceDelta sourceDelta, int segmentCount) throws CoreException {
+protected void findSourceFiles(IResourceDelta sourceDelta, ClasspathMultiDirectory md, int segmentCount) throws CoreException {
// When a package becomes a type or vice versa, expect 2 deltas,
// one on the folder & one on the source file
IResource resource = sourceDelta.getResource();
- IPath location = resource.getLocation();
+ if (md.exclusionPatterns != null && Util.isExcluded(resource, md.exclusionPatterns)) return;
switch(resource.getType()) {
- case IResource.PROJECT :
case IResource.FOLDER :
switch (sourceDelta.getKind()) {
case IResourceDelta.ADDED :
- IPath addedPackagePath = location.removeFirstSegments(segmentCount).makeRelative().setDevice(null);
- getOutputFolder(addedPackagePath); // ensure package exists in the output folder
+ IPath addedPackagePath = resource.getFullPath().removeFirstSegments(segmentCount);
+ createFolder(addedPackagePath, md.binaryFolder); // ensure package exists in the output folder
// add dependents even when the package thinks it exists to be on the safe side
if (JavaBuilder.DEBUG)
- System.out.println("Add dependents of added package " + addedPackagePath); //$NON-NLS-1$
+ System.out.println("Found added package " + addedPackagePath); //$NON-NLS-1$
addDependentsOf(addedPackagePath, true);
// fall thru & collect all the source files
case IResourceDelta.CHANGED :
IResourceDelta[] children = sourceDelta.getAffectedChildren();
- for (int i = 0, length = children.length; i < length; i++)
- findSourceFiles(children[i], segmentCount);
+ for (int i = 0, l = children.length; i < l; i++)
+ findSourceFiles(children[i], md, segmentCount);
return;
case IResourceDelta.REMOVED :
- IPath removedPackagePath = location.removeFirstSegments(segmentCount).makeRelative().setDevice(null);
- for (int i = 0, length = sourceFolders.length; i < length; i++) {
- if (sourceFolders[i].findMember(removedPackagePath) != null) {
- // only a package fragment was removed, same as removing multiple source files
- getOutputFolder(removedPackagePath); // ensure package exists in the output folder
- IResourceDelta[] removedChildren = sourceDelta.getAffectedChildren();
- for (int j = 0, rlength = removedChildren.length; j < rlength; j++)
- findSourceFiles(removedChildren[j], segmentCount);
- return;
+ IPath removedPackagePath = resource.getFullPath().removeFirstSegments(segmentCount);
+ if (sourceLocations.length > 1) {
+ for (int i = 0, l = sourceLocations.length; i < l; i++) {
+ if (sourceLocations[i].sourceFolder.getFolder(removedPackagePath).exists()) {
+ // only a package fragment was removed, same as removing multiple source files
+ createFolder(removedPackagePath, md.binaryFolder); // ensure package exists in the output folder
+ IResourceDelta[] removedChildren = sourceDelta.getAffectedChildren();
+ for (int j = 0, m = removedChildren.length; j < m; j++)
+ findSourceFiles(removedChildren[j], md, segmentCount);
+ return;
+ }
}
}
- IFolder removedPackageFolder = outputFolder.getFolder(removedPackagePath);
+ IFolder removedPackageFolder = md.binaryFolder.getFolder(removedPackagePath);
if (removedPackageFolder.exists())
removedPackageFolder.delete(IResource.FORCE, null);
// add dependents even when the package thinks it does not exist to be on the safe side
if (JavaBuilder.DEBUG)
- System.out.println("Add dependents of removed package " + removedPackagePath); //$NON-NLS-1$
+ System.out.println("Found removed package " + removedPackagePath); //$NON-NLS-1$
addDependentsOf(removedPackagePath, true);
newState.removePackage(sourceDelta);
}
return;
case IResource.FILE :
- String extension = location.getFileExtension();
- if (JavaBuilder.JAVA_EXTENSION.equalsIgnoreCase(extension)) {
- IPath typePath = location.removeFirstSegments(segmentCount).removeFileExtension().makeRelative().setDevice(null);
- String sourceLocation = location.toString();
+ String resourceName = resource.getName();
+ if (Util.isJavaFileName(resourceName)) {
+ IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
+ String typeLocator = resource.getProjectRelativePath().toString();
switch (sourceDelta.getKind()) {
case IResourceDelta.ADDED :
if (JavaBuilder.DEBUG)
- System.out.println("Compile this added source file " + sourceLocation); //$NON-NLS-1$
- locations.add(sourceLocation);
+ System.out.println("Compile this added source file " + typeLocator); //$NON-NLS-1$
+ sourceFiles.add(new SourceFile((IFile) resource, md, encoding));
String typeName = typePath.toString();
- typeNames.add(typeName);
- if (!newState.isDuplicateLocation(typeName, sourceLocation)) { // adding dependents results in 2 duplicate errors
+ if (!newState.isDuplicateLocator(typeName, typeLocator)) { // adding dependents results in 2 duplicate errors
if (JavaBuilder.DEBUG)
- System.out.println("Add dependents of added source file " + typeName); //$NON-NLS-1$
+ System.out.println("Found added source file " + typeName); //$NON-NLS-1$
addDependentsOf(typePath, true);
}
return;
case IResourceDelta.REMOVED :
- char[][] definedTypeNames = newState.getDefinedTypeNamesFor(sourceLocation);
+ char[][] definedTypeNames = newState.getDefinedTypeNamesFor(typeLocator);
if (definedTypeNames == null) { // defined a single type matching typePath
- removeClassFile(typePath);
+ removeClassFile(typePath, md.binaryFolder);
+ if ((sourceDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
+ // remove problems and tasks for a compilation unit that is being moved (to another package or renamed)
+ // if the target file is a compilation unit, the new cu will be recompiled
+ // if the target file is a non-java resource, then markers are removed
+ // see bug 2857
+ IResource movedFile = javaBuilder.workspaceRoot.getFile(sourceDelta.getMovedToPath());
+ JavaBuilder.removeProblemsAndTasksFor(movedFile);
+ }
} else {
if (JavaBuilder.DEBUG)
- System.out.println("Add dependents of removed source file " + typePath.toString()); //$NON-NLS-1$
+ System.out.println("Found removed source file " + typePath.toString()); //$NON-NLS-1$
addDependentsOf(typePath, true); // add dependents of the source file since it may be involved in a name collision
if (definedTypeNames.length > 0) { // skip it if it failed to successfully define a type
IPath packagePath = typePath.removeLastSegments(1);
- for (int i = 0, length = definedTypeNames.length; i < length; i++)
- removeClassFile(packagePath.append(new String(definedTypeNames[i])));
+ for (int i = 0, l = definedTypeNames.length; i < l; i++)
+ removeClassFile(packagePath.append(new String(definedTypeNames[i])), md.binaryFolder);
}
}
- newState.remove(sourceLocation);
+ newState.removeLocator(typeLocator);
return;
case IResourceDelta.CHANGED :
if ((sourceDelta.getFlags() & IResourceDelta.CONTENT) == 0)
return; // skip it since it really isn't changed
if (JavaBuilder.DEBUG)
- System.out.println("Compile this changed source file " + sourceLocation); //$NON-NLS-1$
- locations.add(sourceLocation);
- typeNames.add(typePath.toString());
+ System.out.println("Compile this changed source file " + typeLocator); //$NON-NLS-1$
+ sourceFiles.add(new SourceFile((IFile) resource, md, encoding));
}
return;
- } else if (JavaBuilder.CLASS_EXTENSION.equalsIgnoreCase(extension)) {
+ } else if (Util.isClassFileName(resourceName)) {
return; // skip class files
- } else if (hasSeparateOutputFolder) {
- if (javaBuilder.filterResource(resource)) return;
+ } else if (md.hasIndependentOutputFolder) {
+ if (javaBuilder.filterExtraResource(resource)) return;
// copy all other resource deltas to the output folder
- IPath resourcePath = location.removeFirstSegments(segmentCount).makeRelative();
- IResource outputFile = outputFolder.getFile(resourcePath);
+ IPath resourcePath = resource.getFullPath().removeFirstSegments(segmentCount);
+ IResource outputFile = md.binaryFolder.getFile(resourcePath);
switch (sourceDelta.getKind()) {
case IResourceDelta.ADDED :
if (outputFile.exists()) {
@@ -403,7 +439,7 @@
}
if (JavaBuilder.DEBUG)
System.out.println("Copying added file " + resourcePath); //$NON-NLS-1$
- getOutputFolder(resourcePath.removeLastSegments(1)); // ensure package exists in the output folder
+ createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure package exists in the output folder
resource.copy(outputFile.getFullPath(), IResource.FORCE, null);
outputFile.setDerived(true);
return;
@@ -424,7 +460,7 @@
}
if (JavaBuilder.DEBUG)
System.out.println("Copying changed file " + resourcePath); //$NON-NLS-1$
- getOutputFolder(resourcePath.removeLastSegments(1)); // ensure package exists in the output folder
+ createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure package exists in the output folder
resource.copy(outputFile.getFullPath(), IResource.FORCE, null);
outputFile.setDerived(true);
}
@@ -433,32 +469,39 @@
}
}
-protected void finishedWith(String sourceLocation, CompilationResult result, char[] mainTypeName, ArrayList definedTypeNames, ArrayList duplicateTypeNames) throws CoreException {
- char[][] previousTypeNames = newState.getDefinedTypeNamesFor(sourceLocation);
+protected void finishedWith(String sourceLocator, CompilationResult result, char[] mainTypeName, ArrayList definedTypeNames, ArrayList duplicateTypeNames) throws CoreException {
+ char[][] previousTypeNames = newState.getDefinedTypeNamesFor(sourceLocator);
if (previousTypeNames == null)
previousTypeNames = new char[][] {mainTypeName};
IPath packagePath = null;
- next : for (int i = 0, x = previousTypeNames.length; i < x; i++) {
+ next : for (int i = 0, l = previousTypeNames.length; i < l; i++) {
char[] previous = previousTypeNames[i];
- for (int j = 0, y = definedTypeNames.size(); j < y; j++)
+ for (int j = 0, m = definedTypeNames.size(); j < m; j++)
if (CharOperation.equals(previous, (char[]) definedTypeNames.get(j)))
continue next;
- if (packagePath == null)
- packagePath = new Path(extractTypeNameFrom(sourceLocation)).removeLastSegments(1);
+ SourceFile sourceFile = (SourceFile) result.getCompilationUnit();
+ if (packagePath == null) {
+ int count = sourceFile.sourceLocation.sourceFolder.getFullPath().segmentCount();
+ packagePath = sourceFile.resource.getFullPath().removeFirstSegments(count).removeLastSegments(1);
+ }
if (secondaryTypesToRemove == null)
- this.secondaryTypesToRemove = new ArrayList();
- secondaryTypesToRemove.add(packagePath.append(new String(previous)));
+ this.secondaryTypesToRemove = new SimpleLookupTable();
+ ArrayList types = (ArrayList) secondaryTypesToRemove.get(sourceFile.sourceLocation.binaryFolder);
+ if (types == null)
+ types = new ArrayList(definedTypeNames.size());
+ types.add(packagePath.append(new String(previous)));
+ secondaryTypesToRemove.put(sourceFile.sourceLocation.binaryFolder, types);
}
- super.finishedWith(sourceLocation, result, mainTypeName, definedTypeNames, duplicateTypeNames);
+ super.finishedWith(sourceLocator, result, mainTypeName, definedTypeNames, duplicateTypeNames);
}
-protected void removeClassFile(IPath typePath) throws CoreException {
+protected void removeClassFile(IPath typePath, IContainer outputFolder) throws CoreException {
if (typePath.lastSegment().indexOf('$') == -1) { // is not a nested type
- newState.removeTypeLocation(typePath.toString());
+ newState.removeQualifiedTypeName(typePath.toString());
// add dependents even when the type thinks it does not exist to be on the safe side
if (JavaBuilder.DEBUG)
- System.out.println("Add dependents of removed type " + typePath); //$NON-NLS-1$
+ System.out.println("Found removed type " + typePath); //$NON-NLS-1$
addDependentsOf(typePath, true); // when member types are removed, their enclosing type is structurally changed
}
IFile classFile = outputFolder.getFile(typePath.addFileExtension(JavaBuilder.CLASS_EXTENSION));
@@ -471,61 +514,94 @@
protected void removeSecondaryTypes() throws CoreException {
if (secondaryTypesToRemove != null) { // delayed deleting secondary types until the end of the compile loop
- for (int i = 0, length = secondaryTypesToRemove.size(); i < length; i++)
- removeClassFile((IPath) secondaryTypesToRemove.get(i));
+ Object[] keyTable = secondaryTypesToRemove.keyTable;
+ Object[] valueTable = secondaryTypesToRemove.valueTable;
+ for (int i = 0, l = keyTable.length; i < l; i++) {
+ IContainer outputFolder = (IContainer) keyTable[i];
+ if (outputFolder != null) {
+ ArrayList paths = (ArrayList) valueTable[i];
+ for (int j = 0, m = paths.size(); j < m; j++)
+ removeClassFile((IPath) paths.get(j), outputFolder);
+ }
+ }
this.secondaryTypesToRemove = null;
- if (previousLocations != null && previousLocations.size() > 1)
- this.previousLocations = null; // cannot optimize recompile case when a secondary type is deleted
+ if (previousSourceFiles != null && previousSourceFiles.size() > 1)
+ this.previousSourceFiles = null; // cannot optimize recompile case when a secondary type is deleted
}
}
protected void resetCollections() {
- previousLocations = locations.isEmpty() ? null : (ArrayList) locations.clone();
+ previousSourceFiles = sourceFiles.isEmpty() ? null : (ArrayList) sourceFiles.clone();
- locations.clear();
- typeNames.clear();
+ sourceFiles.clear();
qualifiedStrings.clear();
simpleStrings.clear();
workQueue.clear();
}
-protected void updateProblemsFor(String sourceLocation, CompilationResult result) throws CoreException {
- IResource resource = resourceForLocation(sourceLocation);
- IMarker[] markers = JavaBuilder.getProblemsFor(resource);
+protected void updateProblemsFor(SourceFile sourceFile, CompilationResult result) throws CoreException {
+ IMarker[] markers = JavaBuilder.getProblemsFor(sourceFile.resource);
IProblem[] problems = result.getProblems();
- if (problems == null || problems.length == 0)
- if (markers.length == 0) return;
+ if (problems == null && markers.length == 0) return;
notifier.updateProblemCounts(markers, problems);
- JavaBuilder.removeProblemsFor(resource);
- storeProblemsFor(resource, problems);
+ JavaBuilder.removeProblemsFor(sourceFile.resource);
+ storeProblemsFor(sourceFile, problems);
}
-protected boolean writeClassFileCheck(IFile file, String fileName, byte[] newBytes, boolean isSecondaryType) throws CoreException {
+protected void updateTasksFor(SourceFile sourceFile, CompilationResult result) throws CoreException {
+ IMarker[] markers = JavaBuilder.getTasksFor(sourceFile.resource);
+ IProblem[] tasks = result.getTasks();
+ if (tasks == null && markers.length == 0) return;
+
+ JavaBuilder.removeTasksFor(sourceFile.resource);
+ storeTasksFor(sourceFile, tasks);
+}
+
+protected void writeClassFileBytes(byte[] bytes, IFile file, String qualifiedFileName, boolean isSecondaryType) throws CoreException {
// Before writing out the class file, compare it to the previous file
// If structural changes occured then add dependent source files
if (file.exists()) {
- try {
- byte[] oldBytes = Util.getResourceContentsAsByteArray(file);
+ if (writeClassFileCheck(file, qualifiedFileName, bytes)) {
+ if (JavaBuilder.DEBUG)
+ System.out.println("Writing changed class file " + file.getName());//$NON-NLS-1$
+ file.setContents(new ByteArrayInputStream(bytes), true, false, null);
+ if (!file.isDerived())
+ file.setDerived(true);
+ } else if (JavaBuilder.DEBUG) {
+ System.out.println("Skipped over unchanged class file " + file.getName());//$NON-NLS-1$
+ }
+ } else {
+ if (isSecondaryType)
+ addDependentsOf(new Path(qualifiedFileName), true); // new secondary type
+ if (JavaBuilder.DEBUG)
+ System.out.println("Writing new class file " + file.getName());//$NON-NLS-1$
+ file.create(new ByteArrayInputStream(bytes), IResource.FORCE, null);
+ file.setDerived(true);
+ }
+}
+
+protected boolean writeClassFileCheck(IFile file, String fileName, byte[] newBytes) throws CoreException {
+ try {
+ byte[] oldBytes = Util.getResourceContentsAsByteArray(file);
+ if (this.compileLoop > 1) { // only optimize files which were recompiled during the dependent pass, see 33990
notEqual : if (newBytes.length == oldBytes.length) {
for (int i = newBytes.length; --i >= 0;)
if (newBytes[i] != oldBytes[i]) break notEqual;
return false; // bytes are identical so skip them
}
- ClassFileReader reader = new ClassFileReader(oldBytes, file.getLocation().toString().toCharArray());
- // ignore local types since they're only visible inside a single method
- if (!(reader.isLocal() || reader.isAnonymous()) && reader.hasStructuralChanges(newBytes)) {
- if (JavaBuilder.DEBUG)
- System.out.println("Type has structural changes " + fileName); //$NON-NLS-1$
- addDependentsOf(new Path(fileName), true);
- }
- } catch (ClassFormatException e) {
+ }
+ IPath location = file.getLocation();
+ if (location == null) return false; // unable to determine location of this class file
+ ClassFileReader reader = new ClassFileReader(oldBytes, location.toString().toCharArray());
+ // ignore local types since they're only visible inside a single method
+ if (!(reader.isLocal() || reader.isAnonymous()) && reader.hasStructuralChanges(newBytes)) {
+ if (JavaBuilder.DEBUG)
+ System.out.println("Type has structural changes " + fileName); //$NON-NLS-1$
addDependentsOf(new Path(fileName), true);
}
-
- file.delete(IResource.FORCE, null);
- } else if (isSecondaryType) {
- addDependentsOf(new Path(fileName), true); // new secondary type
+ } catch (ClassFormatException e) {
+ addDependentsOf(new Path(fileName), true);
}
return true;
}
@@ -562,8 +638,8 @@
buffer.append(path);
System.out.println(buffer.toString());
IResourceDelta[] children = delta.getAffectedChildren();
- for (int i = 0, length = children.length; i < length; ++i)
+ for (int i = 0, l = children.length; i < l; i++)
dump(children[i]);
}
*/
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java
index 2539f29..8ecfd09 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java
@@ -1,21 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.core.*;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
import java.io.*;
import java.util.*;
@@ -23,25 +24,19 @@
public class JavaBuilder extends IncrementalProjectBuilder {
IProject currentProject;
-IJavaProject javaProject;
+JavaProject javaProject;
IWorkspaceRoot workspaceRoot;
-ClasspathLocation[] classpath;
-IContainer outputFolder;
-IContainer[] sourceFolders;
-SimpleLookupTable binaryResources; // maps a project to its binary resources (output folder, class folders, zip/jar files)
+NameEnvironment nameEnvironment;
+SimpleLookupTable binaryLocationsPerProject; // maps a project to its binary resources (output folders, class folders, zip/jar files)
State lastState;
BuildNotifier notifier;
-char[][] fileFilters;
-String[] folderFilters;
+char[][] extraResourceFileFilters;
+String[] extraResourceFolderFilters;
-public static final String JAVA_EXTENSION = "java"; //$NON-NLS-1$
public static final String CLASS_EXTENSION = "class"; //$NON-NLS-1$
-public static final String JAR_EXTENSION = "jar"; //$NON-NLS-1$
-public static final String ZIP_EXTENSION = "zip"; //$NON-NLS-1$
public static boolean DEBUG = false;
-static final String ProblemMarkerTag = IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER;
/**
* A list of project names that have been built.
* This list is used to reset the JavaModel.existingExternalFiles cache when a build cycle begins
@@ -52,20 +47,48 @@
public static IMarker[] getProblemsFor(IResource resource) {
try {
if (resource != null && resource.exists())
- return resource.findMarkers(ProblemMarkerTag, false, IResource.DEPTH_INFINITE);
+ return resource.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
} catch (CoreException e) {} // assume there are no problems
return new IMarker[0];
}
+public static IMarker[] getTasksFor(IResource resource) {
+ try {
+ if (resource != null && resource.exists())
+ return resource.findMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
+ } catch (CoreException e) {} // assume there are no tasks
+ return new IMarker[0];
+}
+
+public static void finishedBuilding(IResourceChangeEvent event) {
+ BuildNotifier.resetProblemCounters();
+}
+
public static void removeProblemsFor(IResource resource) {
try {
if (resource != null && resource.exists())
- resource.deleteMarkers(ProblemMarkerTag, false, IResource.DEPTH_INFINITE);
+ resource.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
} catch (CoreException e) {} // assume there were no problems
}
-public static State readState(DataInputStream in) throws IOException {
- return State.read(in);
+public static void removeTasksFor(IResource resource) {
+ try {
+ if (resource != null && resource.exists())
+ resource.deleteMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
+ } catch (CoreException e) {} // assume there were no problems
+}
+
+public static void removeProblemsAndTasksFor(IResource resource) {
+ try {
+ if (resource != null && resource.exists()) {
+ resource.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
+ resource.deleteMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
+ }
+ } catch (CoreException e) {} // assume there were no problems
+}
+
+public static State readState(IProject project, DataInputStream in) throws IOException {
+ return State.read(project, in);
}
public static void writeState(Object state, DataOutputStream out) throws IOException {
@@ -97,11 +120,12 @@
if (DEBUG)
System.out.println("Performing full build since last saved state was not found"); //$NON-NLS-1$
buildAll();
- } else if (hasClasspathChanged() || hasOutputLocationChanged()) {
+ } else if (hasClasspathChanged()) {
// if the output location changes, do not delete the binary files from old location
// the user may be trying something
buildAll();
- } else if (sourceFolders.length > 0) { // if there is no source to compile & no classpath changes then we are done
+ } else if (nameEnvironment.sourceLocations.length > 0) {
+ // if there is no source to compile & no classpath changes then we are done
SimpleLookupTable deltas = findDeltas();
if (deltas == null)
buildAll();
@@ -110,12 +134,12 @@
else if (DEBUG)
System.out.println("Nothing to build since deltas were empty"); //$NON-NLS-1$
} else {
- if (hasBinaryDelta()) { // double check that a jar file didn't get replaced
+ if (hasStructuralDelta()) { // double check that a jar file didn't get replaced in a binary project
buildAll();
} else {
if (DEBUG)
System.out.println("Nothing to build since there are no source folders and no deltas"); //$NON-NLS-1$
- this.lastState.tagAsNoopBuild();
+ lastState.tagAsNoopBuild();
}
}
}
@@ -123,27 +147,27 @@
}
} catch (CoreException e) {
Util.log(e, "JavaBuilder handling CoreException"); //$NON-NLS-1$
- IMarker marker = currentProject.createMarker(ProblemMarkerTag);
- marker.setAttribute(IMarker.MESSAGE, Util.bind("build.inconsistentProject")); //$NON-NLS-1$
+ IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
+ marker.setAttribute(IMarker.MESSAGE, Util.bind("build.inconsistentProject", e.getLocalizedMessage())); //$NON-NLS-1$
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
} catch (ImageBuilderInternalException e) {
Util.log(e.getThrowable(), "JavaBuilder handling ImageBuilderInternalException"); //$NON-NLS-1$
- IMarker marker = currentProject.createMarker(ProblemMarkerTag);
- marker.setAttribute(IMarker.MESSAGE, Util.bind("build.inconsistentProject")); //$NON-NLS-1$
+ IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
+ marker.setAttribute(IMarker.MESSAGE, Util.bind("build.inconsistentProject", e.coreException.getLocalizedMessage())); //$NON-NLS-1$
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
} catch (MissingClassFileException e) {
// do not log this exception since its thrown to handle aborted compiles because of missing class files
if (DEBUG)
System.out.println(Util.bind("build.incompleteClassPath", e.missingClassFile)); //$NON-NLS-1$
- IMarker marker = currentProject.createMarker(ProblemMarkerTag);
+ IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
marker.setAttribute(IMarker.MESSAGE, Util.bind("build.incompleteClassPath", e.missingClassFile)); //$NON-NLS-1$
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
} catch (MissingSourceFileException e) {
// do not log this exception since its thrown to handle aborted compiles because of missing source files
if (DEBUG)
System.out.println(Util.bind("build.missingSourceFile", e.missingSourceFile)); //$NON-NLS-1$
- removeProblemsFor(currentProject); // make this the only problem for this project
- IMarker marker = currentProject.createMarker(ProblemMarkerTag);
+ removeProblemsAndTasksFor(currentProject); // make this the only problem for this project
+ IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
marker.setAttribute(IMarker.MESSAGE, Util.bind("build.missingSourceFile", e.missingSourceFile)); //$NON-NLS-1$
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
} finally {
@@ -163,8 +187,8 @@
private void buildAll() {
notifier.checkCancel();
notifier.subTask(Util.bind("build.preparingBuild")); //$NON-NLS-1$
- if (DEBUG && this.lastState != null)
- System.out.println("Clearing last state : " + this.lastState); //$NON-NLS-1$
+ if (DEBUG && lastState != null)
+ System.out.println("Clearing last state : " + lastState); //$NON-NLS-1$
clearLastState();
BatchImageBuilder imageBuilder = new BatchImageBuilder(this);
imageBuilder.build();
@@ -174,8 +198,8 @@
private void buildDeltas(SimpleLookupTable deltas) {
notifier.checkCancel();
notifier.subTask(Util.bind("build.preparingBuild")); //$NON-NLS-1$
- if (DEBUG && this.lastState != null)
- System.out.println("Clearing last state : " + this.lastState); //$NON-NLS-1$
+ if (DEBUG && lastState != null)
+ System.out.println("Clearing last state : " + lastState); //$NON-NLS-1$
clearLastState(); // clear the previously built state so if the build fails, a full build will occur next time
IncrementalImageBuilder imageBuilder = new IncrementalImageBuilder(this);
if (imageBuilder.build(deltas))
@@ -185,42 +209,34 @@
}
private void cleanup() {
- this.classpath = null;
- this.outputFolder = null;
- this.sourceFolders = null;
+ this.nameEnvironment = null;
+ this.binaryLocationsPerProject = null;
this.lastState = null;
this.notifier = null;
+ this.extraResourceFileFilters = null;
+ this.extraResourceFolderFilters = null;
}
private void clearLastState() {
JavaModelManager.getJavaModelManager().setLastBuiltState(currentProject, null);
}
-private void createFolder(IContainer folder) throws CoreException {
- if (!folder.exists()) {
- IContainer parent = folder.getParent();
- if (currentProject.getFullPath() != parent.getFullPath())
- createFolder(parent);
- ((IFolder) folder).create(true, true, null);
- }
-}
-
-boolean filterResource(IResource resource) {
- if (fileFilters != null) {
+boolean filterExtraResource(IResource resource) {
+ if (extraResourceFileFilters != null) {
char[] name = resource.getName().toCharArray();
- for (int i = 0, length = fileFilters.length; i < length; i++)
- if (CharOperation.match(fileFilters[i], name, true))
+ for (int i = 0, l = extraResourceFileFilters.length; i < l; i++)
+ if (CharOperation.match(extraResourceFileFilters[i], name, true))
return true;
}
- if (folderFilters != null) {
+ if (extraResourceFolderFilters != null) {
IPath path = resource.getProjectRelativePath();
String pathName = path.toString();
int count = path.segmentCount();
if (resource.getType() == IResource.FILE) count--;
- for (int i = 0, l = folderFilters.length; i < l; i++)
- if (pathName.indexOf(folderFilters[i]) != -1)
+ for (int i = 0, l = extraResourceFolderFilters.length; i < l; i++)
+ if (pathName.indexOf(extraResourceFolderFilters[i]) != -1)
for (int j = 0; j < count; j++)
- if (folderFilters[i].equals(path.segment(j)))
+ if (extraResourceFolderFilters[i].equals(path.segment(j)))
return true;
}
return false;
@@ -243,8 +259,8 @@
return null;
}
- Object[] keyTable = binaryResources.keyTable;
- Object[] valueTable = binaryResources.valueTable;
+ Object[] keyTable = binaryLocationsPerProject.keyTable;
+ Object[] valueTable = binaryLocationsPerProject.valueTable;
nextProject : for (int i = 0, l = keyTable.length; i < l; i++) {
IProject p = (IProject) keyTable[i];
if (p != null && p != currentProject) {
@@ -252,10 +268,15 @@
if (!lastState.wasStructurallyChanged(p, s)) { // see if we can skip its delta
if (s.wasNoopBuild())
continue nextProject; // project has no source folders and can be skipped
- IResource[] classFoldersAndJars = (IResource[]) valueTable[i];
- if (classFoldersAndJars.length <= 1)
- continue nextProject; // project has no structural changes in its output folder
- classFoldersAndJars[0] = null; // skip the output folder
+ ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[]) valueTable[i];
+ boolean canSkip = true;
+ for (int j = 0, m = classFoldersAndJars.length; j < m; j++) {
+ if (classFoldersAndJars[j].isOutputFolder())
+ classFoldersAndJars[j] = null; // can ignore output folder since project was not structurally changed
+ else
+ canSkip = false;
+ }
+ if (canSkip) continue nextProject; // project has no structural changes in its output folders
}
notifier.subTask(Util.bind("build.readingDelta", p.getName())); //$NON-NLS-1$
@@ -293,27 +314,25 @@
ArrayList projects = new ArrayList();
try {
- IClasspathEntry[] entries = ((JavaProject) javaProject).getExpandedClasspath(true);
- for (int i = 0, length = entries.length; i < length; i++) {
- IClasspathEntry entry = JavaCore.getResolvedClasspathEntry(entries[i]);
- if (entry != null) {
- IPath path = entry.getPath();
- IProject p = null;
- switch (entry.getEntryKind()) {
- case IClasspathEntry.CPE_PROJECT :
- p = workspaceRoot.getProject(path.lastSegment());
- break;
- case IClasspathEntry.CPE_LIBRARY :
- if (includeBinaryPrerequisites && path.segmentCount() > 1) {
- // some binary resources on the class path can come from projects that are not included in the project references
- IResource resource = workspaceRoot.findMember(path.segment(0));
- if (resource instanceof IProject)
- p = (IProject) resource;
- }
- }
- if (p != null && !projects.contains(p))
- projects.add(p);
+ IClasspathEntry[] entries = javaProject.getExpandedClasspath(true);
+ for (int i = 0, l = entries.length; i < l; i++) {
+ IClasspathEntry entry = entries[i];
+ IPath path = entry.getPath();
+ IProject p = null;
+ switch (entry.getEntryKind()) {
+ case IClasspathEntry.CPE_PROJECT :
+ p = workspaceRoot.getProject(path.lastSegment()); // missing projects are considered too
+ break;
+ case IClasspathEntry.CPE_LIBRARY :
+ if (includeBinaryPrerequisites && path.segmentCount() > 1) {
+ // some binary resources on the class path can come from projects that are not included in the project references
+ IResource resource = workspaceRoot.findMember(path.segment(0));
+ if (resource instanceof IProject)
+ p = (IProject) resource;
+ }
}
+ if (p != null && !projects.contains(p))
+ projects.add(p);
}
} catch(JavaModelException e) {
return new IProject[0];
@@ -324,70 +343,73 @@
}
private boolean hasClasspathChanged() {
- ClasspathLocation[] oldClasspathLocations = lastState.classpathLocations;
- int newLength = classpath.length;
- int oldLength = oldClasspathLocations.length;
- int diff = newLength - oldLength;
- if (diff == 0) {
- for (int i = 0; i < newLength; i++) {
- if (classpath[i].equals(oldClasspathLocations[i])) continue;
- if (DEBUG)
- System.out.println(classpath[i] + " != " + oldClasspathLocations[i]); //$NON-NLS-1$
- return true;
- }
- return false;
- } else if (diff == 1) {
- ClasspathMultiDirectory newSourceDirectory = null;
- int n = 0, o = 0;
- for (; n < newLength && o < oldLength; n++, o++) {
- if (classpath[n].equals(oldClasspathLocations[o])) continue;
- if (diff == 1 && classpath[n] instanceof ClasspathMultiDirectory) { // added a new source folder
- newSourceDirectory = (ClasspathMultiDirectory) classpath[n];
+ ClasspathMultiDirectory[] newSourceLocations = nameEnvironment.sourceLocations;
+ ClasspathMultiDirectory[] oldSourceLocations = lastState.sourceLocations;
+ int newLength = newSourceLocations.length;
+ int oldLength = oldSourceLocations.length;
+ int n, o;
+ for (n = o = 0; n < newLength && o < oldLength; n++, o++) {
+ if (newSourceLocations[n].equals(oldSourceLocations[o])) continue; // checks source & output folders
+ try {
+ if (newSourceLocations[n].sourceFolder.members().length == 0) { // added new empty source folder
o--;
- diff = 0; // found new element
continue;
}
- if (DEBUG)
- System.out.println(classpath[n] + " != " + oldClasspathLocations[o]); //$NON-NLS-1$
- return true;
- }
-
- if (diff == 1 && classpath[n] instanceof ClasspathMultiDirectory) // added a new source folder at the end
- newSourceDirectory = (ClasspathMultiDirectory) classpath[n];
- if (newSourceDirectory != null) {
- IContainer sourceFolder = workspaceRoot.getContainerForLocation(new Path(newSourceDirectory.sourcePath));
- if (sourceFolder != null && sourceFolder.exists()) {
- try {
- if (sourceFolder.members().length == 0) return false; // added a new empty source folder
- } catch (CoreException ignore) {}
+ } catch (CoreException ignore) {}
+ if (DEBUG)
+ System.out.println(newSourceLocations[n] + " != " + oldSourceLocations[o]); //$NON-NLS-1$
+ return true;
+ }
+ while (n < newLength) {
+ try {
+ if (newSourceLocations[n].sourceFolder.members().length == 0) { // added new empty source folder
+ n++;
+ continue;
}
- }
+ } catch (CoreException ignore) {}
+ if (DEBUG)
+ System.out.println("Added non-empty source folder"); //$NON-NLS-1$
+ return true;
+ }
+ if (o < oldLength) {
+ if (DEBUG)
+ System.out.println("Removed source folder"); //$NON-NLS-1$
+ return true;
}
- if (DEBUG)
- System.out.println("Class path size changed"); //$NON-NLS-1$
- return true;
+ ClasspathLocation[] newBinaryLocations = nameEnvironment.binaryLocations;
+ ClasspathLocation[] oldBinaryLocations = lastState.binaryLocations;
+ newLength = newBinaryLocations.length;
+ oldLength = oldBinaryLocations.length;
+ for (n = o = 0; n < newLength && o < oldLength; n++, o++) {
+ if (newBinaryLocations[n].equals(oldBinaryLocations[o])) continue;
+ if (DEBUG)
+ System.out.println(newBinaryLocations[n] + " != " + oldBinaryLocations[o]); //$NON-NLS-1$
+ return true;
+ }
+ if (n < newLength || o < oldLength) {
+ if (DEBUG)
+ System.out.println("Number of binary folders/jar files has changed"); //$NON-NLS-1$
+ return true;
+ }
+ return false;
}
-private boolean hasOutputLocationChanged() {
- if (outputFolder.getLocation().toString().equals(lastState.outputLocationString))
- return false;
-
- if (DEBUG)
- System.out.println(outputFolder.getLocation().toString() + " != " + lastState.outputLocationString); //$NON-NLS-1$
- return true;
-}
-
-private boolean hasBinaryDelta() {
+private boolean hasStructuralDelta() {
+ // handle case when currentProject has only .class file folders and/or jar files... no source/output folders
IResourceDelta delta = getDelta(currentProject);
if (delta != null && delta.getKind() != IResourceDelta.NO_CHANGE) {
- IResource[] classFoldersAndJars = (IResource[]) binaryResources.get(currentProject);
+ ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[]) binaryLocationsPerProject.get(currentProject);
if (classFoldersAndJars != null) {
for (int i = 0, l = classFoldersAndJars.length; i < l; i++) {
- IResource binaryResource = classFoldersAndJars[i]; // either a .class file folder or a zip/jar file
- if (binaryResource != null) {
- IResourceDelta binaryDelta = delta.findMember(binaryResource.getProjectRelativePath());
- if (binaryDelta != null) return true;
+ ClasspathLocation classFolderOrJar = classFoldersAndJars[i]; // either a .class file folder or a zip/jar file
+ if (classFolderOrJar != null) {
+ IPath p = classFolderOrJar.getProjectRelativePath();
+ if (p != null) {
+ IResourceDelta binaryDelta = delta.findMember(p);
+ if (binaryDelta != null && binaryDelta.getKind() != IResourceDelta.NO_CHANGE)
+ return true;
+ }
}
}
}
@@ -396,96 +418,98 @@
}
private void initializeBuilder() throws CoreException {
- this.javaProject = JavaCore.create(currentProject);
+ this.javaProject = (JavaProject) JavaCore.create(currentProject);
this.workspaceRoot = currentProject.getWorkspace().getRoot();
- this.outputFolder = (IContainer) workspaceRoot.findMember(javaProject.getOutputLocation());
- if (this.outputFolder == null) {
- this.outputFolder = workspaceRoot.getFolder(javaProject.getOutputLocation());
- createFolder(this.outputFolder);
- }
// Flush the existing external files cache if this is the beginning of a build cycle
- String projectName = this.currentProject.getName();
+ String projectName = currentProject.getName();
if (builtProjects == null || builtProjects.contains(projectName)) {
JavaModel.flushExternalFileCache();
builtProjects = new ArrayList();
}
builtProjects.add(projectName);
- ArrayList sourceList = new ArrayList();
- this.binaryResources = new SimpleLookupTable(3);
- this.classpath = NameEnvironment.computeLocations(
- workspaceRoot,
- javaProject,
- outputFolder.getLocation().toString(),
- sourceList,
- binaryResources);
- this.sourceFolders = new IContainer[sourceList.size()];
- sourceList.toArray(this.sourceFolders);
+ this.binaryLocationsPerProject = new SimpleLookupTable(3);
+ this.nameEnvironment = new NameEnvironment(workspaceRoot, javaProject, binaryLocationsPerProject);
- String filterSequence = JavaCore.getOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
+ String filterSequence = javaProject.getOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true);
char[][] filters = filterSequence != null && filterSequence.length() > 0
? CharOperation.splitAndTrimOn(',', filterSequence.toCharArray())
: null;
if (filters == null) {
- this.fileFilters = null;
- this.folderFilters = null;
+ this.extraResourceFileFilters = null;
+ this.extraResourceFolderFilters = null;
} else {
int fileCount = 0, folderCount = 0;
- for (int i = 0, length = filters.length; i < length; i++) {
+ for (int i = 0, l = filters.length; i < l; i++) {
char[] f = filters[i];
if (f.length == 0) continue;
if (f[f.length - 1] == '/') folderCount++; else fileCount++;
}
- this.fileFilters = new char[fileCount][];
- this.folderFilters = new String[folderCount];
- for (int i = 0, length = filters.length; i < length; i++) {
+ this.extraResourceFileFilters = new char[fileCount][];
+ this.extraResourceFolderFilters = new String[folderCount];
+ for (int i = 0, l = filters.length; i < l; i++) {
char[] f = filters[i];
if (f.length == 0) continue;
if (f[f.length - 1] == '/')
- folderFilters[--folderCount] = new String(CharOperation.subarray(f, 0, f.length - 1));
+ extraResourceFolderFilters[--folderCount] = new String(CharOperation.subarray(f, 0, f.length - 1));
else
- fileFilters[--fileCount] = f;
+ extraResourceFileFilters[--fileCount] = f;
}
}
}
+private boolean isClasspathBroken(IClasspathEntry[] classpath, IProject p) throws CoreException {
+ if (classpath == JavaProject.INVALID_CLASSPATH) // the .classpath file could not be read
+ return true;
+
+ IMarker[] markers = p.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
+ for (int i = 0, l = markers.length; i < l; i++)
+ if (((Integer) markers[i].getAttribute(IMarker.SEVERITY)).intValue() == IMarker.SEVERITY_ERROR)
+ return true;
+ return false;
+}
+
private boolean isWorthBuilding() throws CoreException {
- boolean abortBuilds = JavaCore.ABORT.equals(JavaCore.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH));
+ boolean abortBuilds =
+ JavaCore.ABORT.equals(javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true));
if (!abortBuilds) return true;
- IMarker[] markers =
- currentProject.findMarkers(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, false, IResource.DEPTH_ONE);
- if (markers.length > 0) {
+ // Abort build only if there are classpath errors
+ if (isClasspathBroken(javaProject.getRawClasspath(), currentProject)) {
if (DEBUG)
- System.out.println("Aborted build because project is involved in a cycle or has classpath problems"); //$NON-NLS-1$
+ System.out.println("Aborted build because project has classpath errors (incomplete or involved in cycle)"); //$NON-NLS-1$
- // remove all existing class files... causes all dependent projects to do the same
- new BatchImageBuilder(this).scrubOutputFolder();
+ JavaModelManager.getJavaModelManager().deltaProcessor.addForRefresh(javaProject);
- removeProblemsFor(currentProject); // remove all compilation problems
+ removeProblemsAndTasksFor(currentProject); // remove all compilation problems
- IMarker marker = currentProject.createMarker(ProblemMarkerTag);
+ IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
marker.setAttribute(IMarker.MESSAGE, Util.bind("build.abortDueToClasspathProblems")); //$NON-NLS-1$
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
return false;
}
// make sure all prereq projects have valid build states... only when aborting builds since projects in cycles do not have build states
+ // except for projects involved in a 'warning' cycle (see below)
IProject[] requiredProjects = getRequiredProjects(false);
- next : for (int i = 0, length = requiredProjects.length; i < length; i++) {
+ next : for (int i = 0, l = requiredProjects.length; i < l; i++) {
IProject p = requiredProjects[i];
if (getLastState(p) == null) {
+ // The prereq project has no build state: if this prereq project has a 'warning' cycle marker then allow build (see bug id 23357)
+ JavaProject prereq = (JavaProject) JavaCore.create(p);
+ if (prereq.hasCycleMarker() && JavaCore.WARNING.equals(javaProject.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true)))
+ continue;
if (DEBUG)
System.out.println("Aborted build because prereq project " + p.getName() //$NON-NLS-1$
+ " was not built"); //$NON-NLS-1$
- // remove all existing class files... causes all dependent projects to do the same
- new BatchImageBuilder(this).scrubOutputFolder();
-
- removeProblemsFor(currentProject); // make this the only problem for this project
- IMarker marker = currentProject.createMarker(ProblemMarkerTag);
- marker.setAttribute(IMarker.MESSAGE, Util.bind("build.prereqProjectWasNotBuilt", p.getName())); //$NON-NLS-1$
+ removeProblemsAndTasksFor(currentProject); // make this the only problem for this project
+ IMarker marker = currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
+ marker.setAttribute(IMarker.MESSAGE,
+ isClasspathBroken(prereq.getRawClasspath(), p)
+ ? Util.bind("build.prereqProjectHasClasspathProblems", p.getName()) //$NON-NLS-1$
+ : Util.bind("build.prereqProjectMustBeRebuilt", p.getName())); //$NON-NLS-1$
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
return false;
}
@@ -493,8 +517,29 @@
return true;
}
+/*
+ * Instruct the build manager that this project is involved in a cycle and
+ * needs to propagate structural changes to the other projects in the cycle.
+ */
+void mustPropagateStructuralChanges() {
+ HashSet cycleParticipants = new HashSet(3);
+ javaProject.updateCycleParticipants(null, new ArrayList(), cycleParticipants, workspaceRoot);
+
+ Iterator i= cycleParticipants.iterator();
+ while (i.hasNext()) {
+ IJavaProject p = (IJavaProject) i.next();
+ if (p != javaProject && hasBeenBuilt(p.getProject())) {
+ if (DEBUG)
+ System.out.println("Requesting another build iteration since cycle participant " + p.getProject().getName() //$NON-NLS-1$
+ + " has not yet seen some structural changes"); //$NON-NLS-1$
+ needRebuild();
+ return;
+ }
+ }
+}
+
private void recordNewState(State state) {
- Object[] keyTable = binaryResources.keyTable;
+ Object[] keyTable = binaryLocationsPerProject.keyTable;
for (int i = 0, l = keyTable.length; i < l; i++) {
IProject prereqProject = (IProject) keyTable[i];
if (prereqProject != null && prereqProject != currentProject)
@@ -511,6 +556,8 @@
* String representation for debugging purposes
*/
public String toString() {
- return "JavaBuilder for " + currentProject.getName(); //$NON-NLS-1$
+ return currentProject == null
+ ? "JavaBuilder for unknown project" //$NON-NLS-1$
+ : "JavaBuilder for " + currentProject.getName(); //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/MissingClassFileException.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/MissingClassFileException.java
index d55f226..69ec46c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/MissingClassFileException.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/MissingClassFileException.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
/**
@@ -21,4 +21,4 @@
public MissingClassFileException(String missingClassFile) {
this.missingClassFile = missingClassFile;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/MissingSourceFileException.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/MissingSourceFileException.java
index c7fc6ab..3aeb2ee 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/MissingSourceFileException.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/MissingSourceFileException.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
/**
@@ -20,4 +20,4 @@
public MissingSourceFileException(String missingSourceFile) {
this.missingSourceFile = missingSourceFile;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
index a56bb2f..d9b7216 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/NameEnvironment.java
@@ -1,59 +1,52 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.*;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.*;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
import java.io.*;
import java.util.*;
public class NameEnvironment implements INameEnvironment {
-ClasspathLocation[] classpathLocations;
-String[] initialTypeNames; // assumed that each name is of the form "a/b/ClassName"
-String[] additionalSourceFilenames; // assumed that each name is of the form "d:/eclipse/Test/a/b/ClassName.java"
-
boolean isIncrementalBuild;
-
-ClasspathLocation[] binaryLocations;
ClasspathMultiDirectory[] sourceLocations;
+ClasspathLocation[] binaryLocations;
-public NameEnvironment(ClasspathLocation[] classpathLocations) {
- this.classpathLocations = classpathLocations;
+String[] initialTypeNames; // assumed that each name is of the form "a/b/ClassName"
+SourceFile[] additionalUnits;
+
+NameEnvironment(IWorkspaceRoot root, JavaProject javaProject, SimpleLookupTable binaryLocationsPerProject) throws CoreException {
this.isIncrementalBuild = false;
- splitLocations();
- setNames(new String[0], new String[0]);
+ computeClasspathLocations(root, javaProject, binaryLocationsPerProject);
+ setNames(null, null);
}
public NameEnvironment(IJavaProject javaProject) {
+ this.isIncrementalBuild = false;
try {
- IWorkspaceRoot workspaceRoot = javaProject.getProject().getWorkspace().getRoot();
- IResource outputFolder = workspaceRoot.findMember(javaProject.getOutputLocation());
- String outputFolderLocation = null;
- if (outputFolder != null && outputFolder.exists())
- outputFolderLocation = outputFolder.getLocation().toString();
- this.classpathLocations = computeLocations(workspaceRoot, javaProject, outputFolderLocation, null, null);
- this.isIncrementalBuild = false;
- } catch(JavaModelException e) {
- this.classpathLocations = new ClasspathLocation[0];
+ computeClasspathLocations(javaProject.getProject().getWorkspace().getRoot(), (JavaProject) javaProject, null);
+ } catch(CoreException e) {
+ this.sourceLocations = new ClasspathMultiDirectory[0];
+ this.binaryLocations = new ClasspathLocation[0];
}
- splitLocations();
- setNames(new String[0], new String[0]);
+ setNames(null, null);
}
/* Some examples of resolved class path entries.
@@ -78,110 +71,176 @@
* /Test[CPE_PROJECT][K_SOURCE] -> D:/eclipse.test/Test
* ALWAYS want to append the output folder & ONLY search for .class files
*/
-public static ClasspathLocation[] computeLocations(
- IWorkspaceRoot workspaceRoot,
- IJavaProject javaProject,
- String outputFolderLocation,
- ArrayList sourceFolders,
- SimpleLookupTable binaryResources) throws JavaModelException {
+private void computeClasspathLocations(
+ IWorkspaceRoot root,
+ JavaProject javaProject,
+ SimpleLookupTable binaryLocationsPerProject) throws CoreException {
- IClasspathEntry[] classpathEntries = ((JavaProject) javaProject).getExpandedClasspath(true, true);
- int cpCount = 0;
- int max = classpathEntries.length;
- ClasspathLocation[] classpathLocations = new ClasspathLocation[max];
+ /* Update incomplete classpath marker */
+ IClasspathEntry[] classpathEntries = javaProject.getExpandedClasspath(true, true);
- boolean firstSourceFolder = true;
- nextEntry : for (int i = 0; i < max; i++) {
- IClasspathEntry entry = classpathEntries[i];
+ /* Update cycle marker */
+ IMarker cycleMarker = javaProject.getCycleMarker();
+ if (cycleMarker != null) {
+ int severity = JavaCore.ERROR.equals(javaProject.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))
+ ? IMarker.SEVERITY_ERROR
+ : IMarker.SEVERITY_WARNING;
+ if (severity != ((Integer) cycleMarker.getAttribute(IMarker.SEVERITY)).intValue())
+ cycleMarker.setAttribute(IMarker.SEVERITY, severity);
+ }
+
+ ArrayList sLocations = new ArrayList(classpathEntries.length);
+ ArrayList bLocations = new ArrayList(classpathEntries.length);
+ nextEntry : for (int i = 0, l = classpathEntries.length; i < l; i++) {
+ ClasspathEntry entry = (ClasspathEntry) classpathEntries[i];
IPath path = entry.getPath();
- Object target = JavaModel.getTarget(workspaceRoot, path, true);
+ Object target = JavaModel.getTarget(root, path, true);
if (target == null) continue nextEntry;
- if (target instanceof IResource) {
- IResource resource = (IResource) target;
- switch(entry.getEntryKind()) {
- case IClasspathEntry.CPE_SOURCE :
- if (outputFolderLocation == null || !(resource instanceof IContainer)) continue nextEntry;
- if (sourceFolders != null) { // normal builder mode
- sourceFolders.add(resource);
- classpathLocations[cpCount++] =
- ClasspathLocation.forSourceFolder(resource.getLocation().toString(), outputFolderLocation);
- } else if (firstSourceFolder) { // add the output folder only once
- firstSourceFolder = false;
- classpathLocations[cpCount++] = ClasspathLocation.forBinaryFolder(outputFolderLocation);
- }
- continue nextEntry;
-
- case IClasspathEntry.CPE_PROJECT :
- if (!(resource instanceof IProject)) continue nextEntry;
- IProject prereqProject = (IProject) resource;
- if (!prereqProject.isAccessible()) continue nextEntry;
- IPath outputLocation = JavaCore.create(prereqProject).getOutputLocation();
- IResource prereqOutputFolder;
- if (prereqProject.getFullPath().equals(outputLocation)) {
- prereqOutputFolder = prereqProject;
- } else {
- prereqOutputFolder = workspaceRoot.findMember(outputLocation);
- if (prereqOutputFolder == null || !prereqOutputFolder.exists() || !(prereqOutputFolder instanceof IFolder))
- continue nextEntry;
- }
- if (prereqOutputFolder.getLocation() == null) // sanity check
- continue nextEntry;
- if (binaryResources != null) { // normal builder mode
- IResource[] existingResources = (IResource[]) binaryResources.get(prereqProject);
- if (existingResources == null)
- binaryResources.put(prereqProject, new IResource[] {prereqOutputFolder});
- else
- existingResources[0] = prereqOutputFolder; // project's output folder is always first
- }
- classpathLocations[cpCount++] = ClasspathLocation.forBinaryFolder(prereqOutputFolder.getLocation().toString());
- continue nextEntry;
-
- case IClasspathEntry.CPE_LIBRARY :
- if (resource.getLocation() == null) // sanity check
- continue nextEntry;
- if (resource instanceof IFile) {
- String extension = path.getFileExtension();
- if (!(JavaBuilder.JAR_EXTENSION.equalsIgnoreCase(extension) || JavaBuilder.ZIP_EXTENSION.equalsIgnoreCase(extension)))
- continue nextEntry;
- classpathLocations[cpCount++] = ClasspathLocation.forLibrary(resource.getLocation().toString());
- } else if (resource instanceof IFolder) {
- classpathLocations[cpCount++] = ClasspathLocation.forBinaryFolder(resource.getLocation().toString());
- }
- if (binaryResources != null) { // normal builder mode
- IProject p = resource.getProject(); // can be the project being built
- IResource[] existingResources = (IResource[]) binaryResources.get(p);
- if (existingResources == null) {
- existingResources = new IResource[] {null, resource}; // project's output folder is always first, null if not included
- } else {
- int size = existingResources.length;
- System.arraycopy(existingResources, 0, existingResources = new IResource[size + 1], 0, size);
- existingResources[size] = resource;
- }
- binaryResources.put(p, existingResources);
- }
- continue nextEntry;
- }
- } else if (target instanceof File) {
- String extension = path.getFileExtension();
- if (!(JavaBuilder.JAR_EXTENSION.equalsIgnoreCase(extension) || JavaBuilder.ZIP_EXTENSION.equalsIgnoreCase(extension)))
+ switch(entry.getEntryKind()) {
+ case IClasspathEntry.CPE_SOURCE :
+ if (!(target instanceof IContainer)) continue nextEntry;
+ IPath outputPath = entry.getOutputLocation() != null
+ ? entry.getOutputLocation()
+ : javaProject.getOutputLocation();
+ IContainer outputFolder;
+ if (outputPath.segmentCount() == 1) {
+ outputFolder = javaProject.getProject();
+ } else {
+ outputFolder = root.getFolder(outputPath);
+ if (!outputFolder.exists())
+ createFolder(outputFolder);
+ }
+ sLocations.add(
+ ClasspathLocation.forSourceFolder((IContainer) target, outputFolder, entry.fullExclusionPatternChars()));
continue nextEntry;
- classpathLocations[cpCount++] = ClasspathLocation.forLibrary(path.toString());
+
+ case IClasspathEntry.CPE_PROJECT :
+ if (!(target instanceof IProject)) continue nextEntry;
+ IProject prereqProject = (IProject) target;
+ if (!JavaProject.hasJavaNature(prereqProject)) continue nextEntry; // if project doesn't have java nature or is not accessible
+
+ JavaProject prereqJavaProject = (JavaProject) JavaCore.create(prereqProject);
+ IClasspathEntry[] prereqClasspathEntries = prereqJavaProject.getRawClasspath();
+ ArrayList seen = new ArrayList();
+ nextPrereqEntry: for (int j = 0, m = prereqClasspathEntries.length; j < m; j++) {
+ IClasspathEntry prereqEntry = (IClasspathEntry) prereqClasspathEntries[j];
+ if (prereqEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
+ Object prereqTarget = JavaModel.getTarget(root, prereqEntry.getPath(), true);
+ if (!(prereqTarget instanceof IContainer)) continue nextPrereqEntry;
+ IPath prereqOutputPath = prereqEntry.getOutputLocation() != null
+ ? prereqEntry.getOutputLocation()
+ : prereqJavaProject.getOutputLocation();
+ IContainer binaryFolder = prereqOutputPath.segmentCount() == 1
+ ? (IContainer) prereqProject
+ : (IContainer) root.getFolder(prereqOutputPath);
+ if (binaryFolder.exists() && !seen.contains(binaryFolder)) {
+ seen.add(binaryFolder);
+ ClasspathLocation bLocation = ClasspathLocation.forBinaryFolder(binaryFolder, true);
+ bLocations.add(bLocation);
+ if (binaryLocationsPerProject != null) { // normal builder mode
+ ClasspathLocation[] existingLocations = (ClasspathLocation[]) binaryLocationsPerProject.get(prereqProject);
+ if (existingLocations == null) {
+ existingLocations = new ClasspathLocation[] {bLocation};
+ } else {
+ int size = existingLocations.length;
+ System.arraycopy(existingLocations, 0, existingLocations = new ClasspathLocation[size + 1], 0, size);
+ existingLocations[size] = bLocation;
+ }
+ binaryLocationsPerProject.put(prereqProject, existingLocations);
+ }
+ }
+ }
+ }
+ continue nextEntry;
+
+ case IClasspathEntry.CPE_LIBRARY :
+ if (target instanceof IResource) {
+ IResource resource = (IResource) target;
+ ClasspathLocation bLocation = null;
+ if (resource instanceof IFile) {
+ if (!(Util.isArchiveFileName(path.lastSegment())))
+ continue nextEntry;
+ bLocation = ClasspathLocation.forLibrary((IFile) resource);
+ } else if (resource instanceof IContainer) {
+ bLocation = ClasspathLocation.forBinaryFolder((IContainer) target, false); // is library folder not output folder
+ }
+ bLocations.add(bLocation);
+ if (binaryLocationsPerProject != null) { // normal builder mode
+ IProject p = resource.getProject(); // can be the project being built
+ ClasspathLocation[] existingLocations = (ClasspathLocation[]) binaryLocationsPerProject.get(p);
+ if (existingLocations == null) {
+ existingLocations = new ClasspathLocation[] {bLocation};
+ } else {
+ int size = existingLocations.length;
+ System.arraycopy(existingLocations, 0, existingLocations = new ClasspathLocation[size + 1], 0, size);
+ existingLocations[size] = bLocation;
+ }
+ binaryLocationsPerProject.put(p, existingLocations);
+ }
+ } else if (target instanceof File) {
+ if (!(Util.isArchiveFileName(path.lastSegment())))
+ continue nextEntry;
+ bLocations.add(ClasspathLocation.forLibrary(path.toString()));
+ }
+ continue nextEntry;
}
}
- if (cpCount < max)
- System.arraycopy(classpathLocations, 0, (classpathLocations = new ClasspathLocation[cpCount]), 0, cpCount);
- return classpathLocations;
+
+ // now split the classpath locations... place the output folders ahead of the other .class file folders & jars
+ ArrayList outputFolders = new ArrayList(1);
+ this.sourceLocations = new ClasspathMultiDirectory[sLocations.size()];
+ if (!sLocations.isEmpty()) {
+ sLocations.toArray(this.sourceLocations);
+
+ // collect the output folders, skipping duplicates
+ next : for (int i = 0, l = sourceLocations.length; i < l; i++) {
+ ClasspathMultiDirectory md = sourceLocations[i];
+ IPath outputPath = md.binaryFolder.getFullPath();
+ for (int j = 0; j < i; j++) { // compare against previously walked source folders
+ if (outputPath.equals(sourceLocations[j].binaryFolder.getFullPath())) {
+ md.hasIndependentOutputFolder = sourceLocations[j].hasIndependentOutputFolder;
+ continue next;
+ }
+ }
+ outputFolders.add(md);
+
+ // also tag each source folder whose output folder is an independent folder & is not also a source folder
+ for (int j = 0, m = sourceLocations.length; j < m; j++)
+ if (outputPath.equals(sourceLocations[j].sourceFolder.getFullPath()))
+ continue next;
+ md.hasIndependentOutputFolder = true;
+ }
+ }
+
+ // combine the output folders with the binary folders & jars... place the output folders before other .class file folders & jars
+ this.binaryLocations = new ClasspathLocation[outputFolders.size() + bLocations.size()];
+ int index = 0;
+ for (int i = 0, l = outputFolders.size(); i < l; i++)
+ this.binaryLocations[index++] = (ClasspathLocation) outputFolders.get(i);
+ for (int i = 0, l = bLocations.size(); i < l; i++)
+ this.binaryLocations[index++] = (ClasspathLocation) bLocations.get(i);
}
public void cleanup() {
- for (int i = 0, length = classpathLocations.length; i < length; i++)
- classpathLocations[i].cleanup();
+ this.initialTypeNames = null;
+ this.additionalUnits = null;
+ for (int i = 0, l = sourceLocations.length; i < l; i++)
+ sourceLocations[i].cleanup();
+ for (int i = 0, l = binaryLocations.length; i < l; i++)
+ binaryLocations[i].cleanup();
+}
+
+private void createFolder(IContainer folder) throws CoreException {
+ if (!folder.exists()) {
+ createFolder(folder.getParent());
+ ((IFolder) folder).create(true, true, null);
+ }
}
private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeName) {
if (initialTypeNames != null) {
- for (int i = 0, length = initialTypeNames.length; i < length; i++) {
+ for (int i = 0, l = initialTypeNames.length; i < l; i++) {
if (qualifiedTypeName.equals(initialTypeNames[i])) {
if (isIncrementalBuild)
// catch the case that a type inside a source file has been renamed but other class files are looking for it
@@ -191,6 +250,25 @@
}
}
+ if (additionalUnits != null && sourceLocations.length > 0) {
+ // if an additional source file is waiting to be compiled, answer it BUT not if this is a secondary type search
+ // if we answer X.java & it no longer defines Y then the binary type looking for Y will think the class path is wrong
+ // let the recompile loop fix up dependents when the secondary type Y has been deleted from X.java
+ IPath qSourceFilePath = new Path(qualifiedTypeName + ".java"); //$NON-NLS-1$
+ int qSegmentCount = qSourceFilePath.segmentCount();
+ next : for (int i = 0, l = additionalUnits.length; i < l; i++) {
+ SourceFile additionalUnit = additionalUnits[i];
+ IPath fullPath = additionalUnit.resource.getFullPath();
+ int prefixCount = additionalUnit.sourceLocation.sourceFolder.getFullPath().segmentCount();
+ if (qSegmentCount == fullPath.segmentCount() - prefixCount) {
+ for (int j = 0; j < qSegmentCount; j++)
+ if (!qSourceFilePath.segment(j).equals(fullPath.segment(j + prefixCount)))
+ continue next;
+ return new NameEnvironmentAnswer(additionalUnit);
+ }
+ }
+ }
+
String qBinaryFileName = qualifiedTypeName + ".class"; //$NON-NLS-1$
String binaryFileName = qBinaryFileName;
String qPackageName = ""; //$NON-NLS-1$
@@ -200,19 +278,8 @@
binaryFileName = qBinaryFileName.substring(typeNameStart);
}
- if (sourceLocations != null && sourceLocations[0].isPackage(qPackageName)) { // looks in common output folder
- if (additionalSourceFilenames != null) {
- String qSourceFileName = qualifiedTypeName + ".java"; //$NON-NLS-1$
- for (int i = 0, length = sourceLocations.length; i < length; i++) {
- NameEnvironmentAnswer answer =
- sourceLocations[i].findSourceFile(qSourceFileName, qPackageName, typeName, additionalSourceFilenames);
- if (answer != null) return answer;
- }
- }
- NameEnvironmentAnswer answer = sourceLocations[0].findClass(binaryFileName, qPackageName, qBinaryFileName);
- if (answer != null) return answer;
- }
- for (int i = 0, length = binaryLocations.length; i < length; i++) {
+ // NOTE: the output folders are added at the beginning of the binaryLocations
+ for (int i = 0, l = binaryLocations.length; i < l; i++) {
NameEnvironmentAnswer answer = binaryLocations[i].findClass(binaryFileName, qPackageName, qBinaryFileName);
if (answer != null) return answer;
}
@@ -240,44 +307,19 @@
}
public boolean isPackage(String qualifiedPackageName) {
- if (sourceLocations != null && sourceLocations[0].isPackage(qualifiedPackageName)) // looks in common output folder
- return true;
- for (int i = 0, length = binaryLocations.length; i < length; i++)
+ // NOTE: the output folders are added at the beginning of the binaryLocations
+ for (int i = 0, l = binaryLocations.length; i < l; i++)
if (binaryLocations[i].isPackage(qualifiedPackageName))
return true;
return false;
}
-public void setNames(String[] initialTypeNames, String[] additionalSourceFilenames) {
+void setNames(String[] initialTypeNames, SourceFile[] additionalUnits) {
this.initialTypeNames = initialTypeNames;
- this.additionalSourceFilenames = additionalSourceFilenames;
- for (int i = 0, length = classpathLocations.length; i < length; i++)
- classpathLocations[i].reset();
+ this.additionalUnits = additionalUnits;
+ for (int i = 0, l = sourceLocations.length; i < l; i++)
+ sourceLocations[i].reset();
+ for (int i = 0, l = binaryLocations.length; i < l; i++)
+ binaryLocations[i].reset();
}
-
-private void splitLocations() {
- int length = classpathLocations.length;
- ArrayList sLocations = new ArrayList(length);
- ArrayList bLocations = new ArrayList(length);
- for (int i = 0; i < length; i++) {
- ClasspathLocation classpath = classpathLocations[i];
- if (classpath instanceof ClasspathMultiDirectory)
- sLocations.add(classpath);
- else
- bLocations.add(classpath);
- }
-
- if (sLocations.isEmpty()) {
- this.sourceLocations = null;
- } else {
- this.sourceLocations = new ClasspathMultiDirectory[sLocations.size()];
- sLocations.toArray(this.sourceLocations);
- }
- this.binaryLocations = new ClasspathLocation[bLocations.size()];
- bLocations.toArray(this.binaryLocations);
}
-
-void tagAsIncrementalBuild() {
- this.isIncrementalBuild = true;
-}
-}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ProblemFactory.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ProblemFactory.java
index 3251b24..6e2d2d0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ProblemFactory.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ProblemFactory.java
@@ -1,16 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
import java.util.*;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ReferenceCollection.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ReferenceCollection.java
index 77ab325..96130e4 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ReferenceCollection.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ReferenceCollection.java
@@ -1,17 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import java.util.*;
@@ -42,13 +42,13 @@
if (simpleNames == null || qualifiedNames == null) {
if (simpleNames == null && qualifiedNames == null) {
if (JavaBuilder.DEBUG)
- System.out.println(" found well known match"); //$NON-NLS-1$
+ System.out.println("Found well known match"); //$NON-NLS-1$
return true;
} else if (qualifiedNames == null) {
for (int i = 0, l = simpleNames.length; i < l; i++) {
if (includes(simpleNames[i])) {
if (JavaBuilder.DEBUG)
- System.out.println(" found match in well known package to " + new String(simpleNames[i])); //$NON-NLS-1$
+ System.out.println("Found match in well known package to " + new String(simpleNames[i])); //$NON-NLS-1$
return true;
}
}
@@ -57,7 +57,7 @@
char[][] qualifiedName = qualifiedNames[i];
if (qualifiedName.length == 1 ? includes(qualifiedName[0]) : includes(qualifiedName)) {
if (JavaBuilder.DEBUG)
- System.out.println(" found well known match in " + CharOperation.toString(qualifiedName)); //$NON-NLS-1$
+ System.out.println("Found well known match in " + CharOperation.toString(qualifiedName)); //$NON-NLS-1$
return true;
}
}
@@ -69,7 +69,7 @@
char[][] qualifiedName = qualifiedNames[j];
if (qualifiedName.length == 1 ? includes(qualifiedName[0]) : includes(qualifiedName)) {
if (JavaBuilder.DEBUG)
- System.out.println(" found match in " + CharOperation.toString(qualifiedName) //$NON-NLS-1$
+ System.out.println("Found match in " + CharOperation.toString(qualifiedName) //$NON-NLS-1$
+ " to " + new String(simpleNames[i])); //$NON-NLS-1$
return true;
}
@@ -94,7 +94,7 @@
new char[][] {TypeConstants.JAVA},
new char[][] {new char[] {'o', 'r', 'g'}},
new char[][] {new char[] {'c', 'o', 'm'}},
- TypeConstants.NoCharChar}; // default package
+ CharOperation.NO_CHAR_CHAR}; // default package
static final char[][] WellKnownSimpleNames = new char[][] {
TypeConstants.JAVA_LANG_RUNTIMEEXCEPTION[2],
TypeConstants.JAVA_LANG_THROWABLE[2],
@@ -105,7 +105,7 @@
new char[] {'c', 'o', 'm'}};
static final char[][][] EmptyQualifiedNames = new char[0][][];
-static final char[][] EmptySimpleNames = new char[0][];
+static final char[][] EmptySimpleNames = CharOperation.NO_CHAR_CHAR;
// each array contains qualified char[][], one for size 2, 3, 4, 5, 6, 7 & the rest
static final int MaxQualifiedNames = 7;
@@ -118,7 +118,7 @@
InternedQualifiedNames[i] = new ArrayList(37);
for (int i = 0; i < MaxSimpleNames; i++)
InternedSimpleNames[i] = new ArrayList(11);
-};
+}
static char[][][] internQualifiedNames(ArrayList qualifiedStrings) {
if (qualifiedStrings == null) return EmptyQualifiedNames;
@@ -141,7 +141,7 @@
next : for (int i = 0; i < length; i++) {
char[][] qualifiedName = qualifiedNames[i];
int qLength = qualifiedName.length;
- for (int j = 0, k = WellKnownQualifiedNames.length; j < k; j++) {
+ for (int j = 0, m = WellKnownQualifiedNames.length; j < m; j++) {
char[][] wellKnownName = WellKnownQualifiedNames[j];
if (qLength > wellKnownName.length)
break; // all remaining well known names are shorter
@@ -153,7 +153,7 @@
// InternedQualifiedNames[1] is for size 2...
// InternedQualifiedNames[6] is for size 7
ArrayList internedNames = InternedQualifiedNames[qLength <= MaxQualifiedNames ? qLength - 1 : 0];
- for (int j = 0, k = internedNames.size(); j < k; j++) {
+ for (int j = 0, m = internedNames.size(); j < m; j++) {
char[][] internedName = (char[][]) internedNames.get(j);
if (CharOperation.equals(qualifiedName, internedName)) {
keepers[index++] = internedName;
@@ -192,7 +192,7 @@
next : for (int i = 0; i < length; i++) {
char[] name = simpleNames[i];
int sLength = name.length;
- for (int j = 0, k = WellKnownSimpleNames.length; j < k; j++) {
+ for (int j = 0, m = WellKnownSimpleNames.length; j < m; j++) {
char[] wellKnownName = WellKnownSimpleNames[j];
if (sLength > wellKnownName.length)
break; // all remaining well known names are shorter
@@ -207,7 +207,7 @@
// InternedSimpleNames[1] is for size 1...
// InternedSimpleNames[29] is for size 29
ArrayList internedNames = InternedSimpleNames[sLength < MaxSimpleNames ? sLength : 0];
- for (int j = 0, k = internedNames.size(); j < k; j++) {
+ for (int j = 0, m = internedNames.size(); j < m; j++) {
char[] internedName = (char[]) internedNames.get(j);
if (CharOperation.equals(name, internedName)) {
keepers[index++] = internedName;
@@ -223,4 +223,4 @@
}
return keepers;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SourceFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SourceFile.java
index ea13b27..e4746cd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SourceFile.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SourceFile.java
@@ -1,105 +1,102 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
-import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-
-import java.io.*;
+import org.eclipse.jdt.internal.core.Util;
public class SourceFile implements ICompilationUnit {
-public char[] fileName;
-public char[] mainTypeName;
-public char[][] packageName;
+IFile resource;
+ClasspathMultiDirectory sourceLocation;
+String initialTypeName;
String encoding;
-public SourceFile(String fileName, String initialTypeName) {
- this.fileName = fileName.toCharArray();
- CharOperation.replace(this.fileName, '\\', '/');
-
- char[] typeName = initialTypeName.toCharArray();
- int lastIndex = CharOperation.lastIndexOf('/', typeName);
- this.mainTypeName = CharOperation.subarray(typeName, lastIndex + 1, -1);
- this.packageName = CharOperation.splitOn('/', typeName, 0, lastIndex - 1);
-
- this.encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
+public SourceFile(IFile resource, ClasspathMultiDirectory sourceLocation, String encoding) {
+ this.resource = resource;
+ this.sourceLocation = sourceLocation;
+ this.initialTypeName = extractTypeName();
+ this.encoding = encoding;
}
-public SourceFile(String fileName, char[] mainTypeName, char[][] packageName) {
- this.fileName = fileName.toCharArray();
- CharOperation.replace(this.fileName, '\\', '/');
+public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof SourceFile)) return false;
- this.mainTypeName = mainTypeName;
- this.packageName = packageName;
+ SourceFile f = (SourceFile) o;
+ return sourceLocation == f.sourceLocation && resource.getFullPath().equals(f.resource.getFullPath());
+}
- this.encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
+String extractTypeName() {
+ // answer a String with the qualified type name for the source file in the form: 'p1/p2/A'
+ IPath fullPath = resource.getFullPath();
+ int resourceSegmentCount = fullPath.segmentCount();
+ int sourceFolderSegmentCount = sourceLocation.sourceFolder.getFullPath().segmentCount();
+ int charCount = (resourceSegmentCount - sourceFolderSegmentCount - 1) - 5; // length of ".java"
+ for (int i = sourceFolderSegmentCount; i < resourceSegmentCount; i++)
+ charCount += fullPath.segment(i).length();
+
+ char[] result = new char[charCount];
+ int offset = 0;
+ resourceSegmentCount--; // deal with the last segment separately
+ for (int i = sourceFolderSegmentCount; i < resourceSegmentCount; i++) {
+ String segment = fullPath.segment(i);
+ int size = segment.length();
+ segment.getChars(0, size, result, offset);
+ offset += size;
+ result[offset++] = '/';
+ }
+ String segment = fullPath.segment(resourceSegmentCount);
+ int size = segment.length() - 5; // length of ".java"
+ segment.getChars(0, size, result, offset);
+ return new String(result);
}
public char[] getContents() {
- // otherwise retrieve it
- BufferedReader reader = null;
- try {
- File file = new File(new String(fileName));
- InputStreamReader streamReader =
- this.encoding == null
- ? new InputStreamReader(new FileInputStream(file))
- : new InputStreamReader(new FileInputStream(file), this.encoding);
- reader = new BufferedReader(streamReader);
- int length = (int) file.length();
- char[] contents = new char[length];
- int len = 0;
- int readSize = 0;
- while ((readSize != -1) && (len != length)) {
- // See PR 1FMS89U
- // We record first the read size. In this case len is the actual read size.
- len += readSize;
- readSize = reader.read(contents, len, length - len);
- }
- reader.close();
- // See PR 1FMS89U
- // Now we need to resize in case the default encoding used more than one byte for each
- // character
- if (len != length)
- System.arraycopy(contents, 0, (contents = new char[len]), 0, len);
- return contents;
- } catch (FileNotFoundException e) {
- throw new AbortCompilation(true, new MissingSourceFileException(new String(fileName)));
- } catch (IOException e) {
- if (reader != null) {
- try {
- reader.close();
- } catch(IOException ioe) {
- }
- }
- throw new AbortCompilation(true, new MissingSourceFileException(new String(fileName)));
+
+ try {
+ return Util.getResourceContentsAsCharArray(resource, this.encoding);
+ } catch (CoreException e) {
+ throw new AbortCompilation(true, new MissingSourceFileException(resource.getFullPath().toString()));
}
}
public char[] getFileName() {
- return fileName;
+ return resource.getFullPath().toString().toCharArray(); // do not know what you want to return here
}
public char[] getMainTypeName() {
- return mainTypeName;
+ char[] typeName = initialTypeName.toCharArray();
+ int lastIndex = CharOperation.lastIndexOf('/', typeName);
+ return CharOperation.subarray(typeName, lastIndex + 1, -1);
}
public char[][] getPackageName() {
- return packageName;
+ char[] typeName = initialTypeName.toCharArray();
+ int lastIndex = CharOperation.lastIndexOf('/', typeName);
+ return CharOperation.splitOn('/', typeName, 0, lastIndex);
+}
+
+String typeLocator() {
+ return resource.getProjectRelativePath().toString();
}
public String toString() {
return "SourceFile[" //$NON-NLS-1$
- + new String(fileName) + "]"; //$NON-NLS-1$
+ + resource.getFullPath() + "]"; //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java
index 697c181..00ab0fc 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/State.java
@@ -1,32 +1,35 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.core.Util;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
import java.io.*;
import java.util.*;
public class State {
+// NOTE: this state cannot contain types that are not defined in this project
String javaProjectName;
-ClasspathLocation[] classpathLocations;
-String outputLocationString;
-// keyed by location (the full filesystem path "d:/xyz/eclipse/Test/p1/p2/A.java"), value is a ReferenceCollection or an AdditionalTypeCollection
+ClasspathMultiDirectory[] sourceLocations;
+ClasspathLocation[] binaryLocations;
+// keyed by the project relative path of the type (ie. "src1/p1/p2/A.java"), value is a ReferenceCollection or an AdditionalTypeCollection
SimpleLookupTable references;
-// keyed by qualified type name "p1/p2/A", value is the full filesystem path which defines this type "d:/xyz/eclipse/Test/p1/p2/A.java"
-SimpleLookupTable typeLocations;
+// keyed by qualified type name "p1/p2/A", value is the project relative path which defines this type "src1/p1/p2/A.java"
+SimpleLookupTable typeLocators;
int buildNumber;
long lastStructuralBuildTime;
@@ -34,7 +37,12 @@
private String[] knownPackageNames; // of the form "p1/p2"
-static final byte VERSION = 0x0004;
+static final byte VERSION = 0x0007;
+
+static final byte SOURCE_FOLDER = 1;
+static final byte BINARY_FOLDER = 2;
+static final byte EXTERNAL_JAR = 3;
+static final byte INTERNAL_JAR = 4;
State() {
}
@@ -42,10 +50,10 @@
protected State(JavaBuilder javaBuilder) {
this.knownPackageNames = null;
this.javaProjectName = javaBuilder.currentProject.getName();
- this.classpathLocations = javaBuilder.classpath;
- this.outputLocationString = javaBuilder.outputFolder.getLocation().toString();
+ this.sourceLocations = javaBuilder.nameEnvironment.sourceLocations;
+ this.binaryLocations = javaBuilder.nameEnvironment.binaryLocations;
this.references = new SimpleLookupTable(7);
- this.typeLocations = new SimpleLookupTable(7);
+ this.typeLocators = new SimpleLookupTable(7);
this.buildNumber = 0; // indicates a full build
this.lastStructuralBuildTime = System.currentTimeMillis();
@@ -58,7 +66,7 @@
this.buildNumber = lastState.buildNumber + 1;
this.lastStructuralBuildTime = lastState.lastStructuralBuildTime;
this.references = (SimpleLookupTable) lastState.references.clone();
- this.typeLocations = (SimpleLookupTable) lastState.typeLocations.clone();
+ this.typeLocators = (SimpleLookupTable) lastState.typeLocators.clone();
} catch (CloneNotSupportedException e) {
this.references = new SimpleLookupTable(lastState.references.elementSize);
Object[] keyTable = lastState.references.keyTable;
@@ -67,31 +75,31 @@
if (keyTable[i] != null)
this.references.put(keyTable[i], valueTable[i]);
- this.typeLocations = new SimpleLookupTable(lastState.typeLocations.elementSize);
- keyTable = lastState.typeLocations.keyTable;
- valueTable = lastState.typeLocations.valueTable;
+ this.typeLocators = new SimpleLookupTable(lastState.typeLocators.elementSize);
+ keyTable = lastState.typeLocators.keyTable;
+ valueTable = lastState.typeLocators.valueTable;
for (int i = 0, l = keyTable.length; i < l; i++)
if (keyTable[i] != null)
- this.typeLocations.put(keyTable[i], valueTable[i]);
+ this.typeLocators.put(keyTable[i], valueTable[i]);
}
}
-char[][] getDefinedTypeNamesFor(String location) {
- Object c = references.get(location);
+char[][] getDefinedTypeNamesFor(String typeLocator) {
+ Object c = references.get(typeLocator);
if (c instanceof AdditionalTypeCollection)
return ((AdditionalTypeCollection) c).definedTypeNames;
return null; // means only one type is defined with the same name as the file... saves space
}
-boolean isDuplicateLocation(String qualifiedName, String location) {
- String existingLocation = (String) typeLocations.get(qualifiedName);
- return existingLocation != null && !existingLocation.equals(location);
+boolean isDuplicateLocator(String qualifiedTypeName, String typeLocator) {
+ String existing = (String) typeLocators.get(qualifiedTypeName);
+ return existing != null && !existing.equals(typeLocator);
}
boolean isKnownPackage(String qualifiedPackageName) {
if (knownPackageNames == null) {
- ArrayList names = new ArrayList(typeLocations.elementSize);
- Object[] keyTable = typeLocations.keyTable;
+ ArrayList names = new ArrayList(typeLocators.elementSize);
+ Object[] keyTable = typeLocators.keyTable;
for (int i = 0, l = keyTable.length; i < l; i++) {
if (keyTable[i] != null) {
String packageName = (String) keyTable[i]; // is a type name of the form p1/p2/A
@@ -107,25 +115,25 @@
knownPackageNames = new String[names.size()];
names.toArray(knownPackageNames);
}
- for (int i = 0, length = knownPackageNames.length; i < length; i++)
+ for (int i = 0, l = knownPackageNames.length; i < l; i++)
if (knownPackageNames[i].equals(qualifiedPackageName))
return true;
return false;
}
-void record(String location, char[][][] qualifiedRefs, char[][] simpleRefs, char[] mainTypeName, ArrayList typeNames) {
+void record(String typeLocator, char[][][] qualifiedRefs, char[][] simpleRefs, char[] mainTypeName, ArrayList typeNames) {
if (typeNames.size() == 1 && CharOperation.equals(mainTypeName, (char[]) typeNames.get(0))) {
- references.put(location, new ReferenceCollection(qualifiedRefs, simpleRefs));
+ references.put(typeLocator, new ReferenceCollection(qualifiedRefs, simpleRefs));
} else {
char[][] definedTypeNames = new char[typeNames.size()][]; // can be empty when no types are defined
typeNames.toArray(definedTypeNames);
- references.put(location, new AdditionalTypeCollection(definedTypeNames, qualifiedRefs, simpleRefs));
+ references.put(typeLocator, new AdditionalTypeCollection(definedTypeNames, qualifiedRefs, simpleRefs));
}
}
-void recordLocationForType(String qualifiedName, String location) {
+void recordLocatorForType(String qualifiedTypeName, String typeLocator) {
this.knownPackageNames = null;
- typeLocations.put(qualifiedName, location);
+ typeLocators.put(qualifiedTypeName, typeLocator);
}
void recordStructuralDependency(IProject prereqProject, State prereqState) {
@@ -133,10 +141,10 @@
structuralBuildTimes.put(prereqProject.getName(), new Long(prereqState.lastStructuralBuildTime));
}
-void remove(String locationToRemove) {
+void removeLocator(String typeLocatorToRemove) {
this.knownPackageNames = null;
- references.removeKey(locationToRemove);
- typeLocations.removeValue(locationToRemove);
+ references.removeKey(typeLocatorToRemove);
+ typeLocators.removeValue(typeLocatorToRemove);
}
void removePackage(IResourceDelta sourceDelta) {
@@ -144,22 +152,22 @@
switch(resource.getType()) {
case IResource.FOLDER :
IResourceDelta[] children = sourceDelta.getAffectedChildren();
- for (int i = 0, length = children.length; i < length; ++i)
+ for (int i = 0, l = children.length; i < l; i++)
removePackage(children[i]);
return;
case IResource.FILE :
- IPath location = resource.getLocation();
- if (JavaBuilder.JAVA_EXTENSION.equalsIgnoreCase(location.getFileExtension()))
- remove(location.toString());
+ IPath typeLocatorPath = resource.getProjectRelativePath();
+ if (Util.isJavaFileName(typeLocatorPath.lastSegment()))
+ removeLocator(typeLocatorPath.toString());
}
}
-void removeTypeLocation(String locationToRemove) {
+void removeQualifiedTypeName(String qualifiedTypeNameToRemove) {
this.knownPackageNames = null;
- typeLocations.removeKey(locationToRemove);
+ typeLocators.removeKey(qualifiedTypeNameToRemove);
}
-static State read(DataInputStream in) throws IOException {
+static State read(IProject project, DataInputStream in) throws IOException {
if (JavaBuilder.DEBUG)
System.out.println("About to read state..."); //$NON-NLS-1$
if (VERSION != in.readByte()) {
@@ -170,22 +178,48 @@
State newState = new State();
newState.javaProjectName = in.readUTF();
+ if (!project.getName().equals(newState.javaProjectName)) {
+ if (JavaBuilder.DEBUG)
+ System.out.println("Project's name does not match... answered null"); //$NON-NLS-1$
+ return null;
+ }
newState.buildNumber = in.readInt();
newState.lastStructuralBuildTime = in.readLong();
- newState.outputLocationString = in.readUTF();
int length = in.readInt();
- newState.classpathLocations = new ClasspathLocation[length];
- for (int i = 0; i < length; ++i) {
+ newState.sourceLocations = new ClasspathMultiDirectory[length];
+ for (int i = 0; i < length; i++) {
+ IContainer sourceFolder = project, outputFolder = project;
+ String folderName;
+ if ((folderName = in.readUTF()).length() > 0) sourceFolder = project.getFolder(folderName);
+ if ((folderName = in.readUTF()).length() > 0) outputFolder = project.getFolder(folderName);
+ ClasspathMultiDirectory md =
+ (ClasspathMultiDirectory) ClasspathLocation.forSourceFolder(sourceFolder, outputFolder, readNames(in));
+ if (in.readBoolean())
+ md.hasIndependentOutputFolder = true;
+ newState.sourceLocations[i] = md;
+ }
+
+ length = in.readInt();
+ newState.binaryLocations = new ClasspathLocation[length];
+ IWorkspaceRoot root = project.getWorkspace().getRoot();
+ for (int i = 0; i < length; i++) {
switch (in.readByte()) {
- case 1 :
- newState.classpathLocations[i] = ClasspathLocation.forSourceFolder(in.readUTF(), in.readUTF());
+ case SOURCE_FOLDER :
+ newState.binaryLocations[i] = newState.sourceLocations[in.readInt()];
break;
- case 2 :
- newState.classpathLocations[i] = ClasspathLocation.forBinaryFolder(in.readUTF());
+ case BINARY_FOLDER :
+ IPath path = new Path(in.readUTF());
+ IContainer outputFolder = path.segmentCount() == 1
+ ? (IContainer) root.getProject(path.toString())
+ : (IContainer) root.getFolder(path);
+ newState.binaryLocations[i] = ClasspathLocation.forBinaryFolder(outputFolder, in.readBoolean());
break;
- case 3 :
- newState.classpathLocations[i] = ClasspathLocation.forLibrary(in.readUTF());
+ case EXTERNAL_JAR :
+ newState.binaryLocations[i] = ClasspathLocation.forLibrary(in.readUTF());
+ break;
+ case INTERNAL_JAR :
+ newState.binaryLocations[i] = ClasspathLocation.forLibrary(root.getFile(new Path(in.readUTF())));
}
}
@@ -193,13 +227,13 @@
for (int i = 0; i < length; i++)
newState.structuralBuildTimes.put(in.readUTF(), new Long(in.readLong()));
- String[] internedLocations = new String[length = in.readInt()];
+ String[] internedTypeLocators = new String[length = in.readInt()];
for (int i = 0; i < length; i++)
- internedLocations[i] = in.readUTF();
+ internedTypeLocators[i] = in.readUTF();
- newState.typeLocations = new SimpleLookupTable(length = in.readInt());
+ newState.typeLocators = new SimpleLookupTable(length = in.readInt());
for (int i = 0; i < length; i++)
- newState.typeLocations.put(in.readUTF(), internedLocations[in.readInt()]);
+ newState.typeLocators.put(in.readUTF(), internedTypeLocators[in.readInt()]);
char[][] internedSimpleNames = ReferenceCollection.internSimpleNames(readNames(in), false);
char[][][] internedQualifiedNames = new char[length = in.readInt()][][];
@@ -214,29 +248,29 @@
newState.references = new SimpleLookupTable(length = in.readInt());
for (int i = 0; i < length; i++) {
- String location = internedLocations[in.readInt()];
+ String typeLocator = internedTypeLocators[in.readInt()];
ReferenceCollection collection = null;
switch (in.readByte()) {
case 1 :
char[][] additionalTypeNames = readNames(in);
char[][][] qualifiedNames = new char[in.readInt()][][];
- for (int j = 0, qLength = qualifiedNames.length; j < qLength; j++)
+ for (int j = 0, m = qualifiedNames.length; j < m; j++)
qualifiedNames[j] = internedQualifiedNames[in.readInt()];
char[][] simpleNames = new char[in.readInt()][];
- for (int j = 0, sLength = simpleNames.length; j < sLength; j++)
+ for (int j = 0, m = simpleNames.length; j < m; j++)
simpleNames[j] = internedSimpleNames[in.readInt()];
collection = new AdditionalTypeCollection(additionalTypeNames, qualifiedNames, simpleNames);
break;
case 2 :
char[][][] qNames = new char[in.readInt()][][];
- for (int j = 0, qLength = qNames.length; j < qLength; j++)
+ for (int j = 0, m = qNames.length; j < m; j++)
qNames[j] = internedQualifiedNames[in.readInt()];
char[][] sNames = new char[in.readInt()][];
- for (int j = 0, sLength = sNames.length; j < sLength; j++)
+ for (int j = 0, m = sNames.length; j < m; j++)
sNames[j] = internedSimpleNames[in.readInt()];
collection = new ReferenceCollection(qNames, sNames);
}
- newState.references.put(location, collection);
+ newState.references.put(typeLocator, collection);
}
if (JavaBuilder.DEBUG)
System.out.println("Successfully read state for " + newState.javaProjectName); //$NON-NLS-1$
@@ -287,35 +321,56 @@
* String project name
* int build number
* int last structural build number
- * String output location
*/
out.writeByte(VERSION);
out.writeUTF(javaProjectName);
out.writeInt(buildNumber);
out.writeLong(lastStructuralBuildTime);
- out.writeUTF(outputLocationString);
/*
- * Class path locations[]
+ * ClasspathMultiDirectory[]
* int id
* String path(s)
- *
- * NOTE: Cannot have portable build states while classpath directories are full filesystem paths
*/
- out.writeInt(length = classpathLocations.length);
- for (int i = 0; i < length; ++i) {
- ClasspathLocation c = classpathLocations[i];
+ out.writeInt(length = sourceLocations.length);
+ for (int i = 0; i < length; i++) {
+ ClasspathMultiDirectory md = sourceLocations[i];
+ out.writeUTF(md.sourceFolder.getProjectRelativePath().toString());
+ out.writeUTF(md.binaryFolder.getProjectRelativePath().toString());
+ writeNames(md.exclusionPatterns, out);
+ out.writeBoolean(md.hasIndependentOutputFolder);
+ }
+
+/*
+ * ClasspathLocation[]
+ * int id
+ * String path(s)
+*/
+ out.writeInt(length = binaryLocations.length);
+ next : for (int i = 0; i < length; i++) {
+ ClasspathLocation c = binaryLocations[i];
if (c instanceof ClasspathMultiDirectory) {
- out.writeByte(1);
- ClasspathMultiDirectory md = (ClasspathMultiDirectory) c;
- out.writeUTF(md.sourcePath);
- out.writeUTF(md.binaryPath);
+ out.writeByte(SOURCE_FOLDER);
+ for (int j = 0, m = sourceLocations.length; j < m; j++) {
+ if (sourceLocations[j] == c) {
+ out.writeInt(j);
+ continue next;
+ }
+ }
} else if (c instanceof ClasspathDirectory) {
- out.writeByte(2);
- out.writeUTF(((ClasspathDirectory) c).binaryPath);
- } else if (c instanceof ClasspathJar) {
- out.writeByte(3);
- out.writeUTF(((ClasspathJar) c).zipFilename);
+ out.writeByte(BINARY_FOLDER);
+ ClasspathDirectory cd = (ClasspathDirectory) c;
+ out.writeUTF(cd.binaryFolder.getFullPath().toString());
+ out.writeBoolean(cd.isOutputFolder);
+ } else {
+ ClasspathJar jar = (ClasspathJar) c;
+ if (jar.resource == null) {
+ out.writeByte(EXTERNAL_JAR);
+ out.writeUTF(jar.zipFilename);
+ } else {
+ out.writeByte(INTERNAL_JAR);
+ out.writeUTF(jar.resource.getFullPath().toString());
+ }
}
}
@@ -340,10 +395,10 @@
}
/*
- * String[] Interned locations
+ * String[] Interned type locators
*/
out.writeInt(length = references.elementSize);
- ArrayList internedLocations = new ArrayList(length);
+ ArrayList internedTypeLocators = new ArrayList(length);
if (length > 0) {
keyTable = references.keyTable;
for (int i = 0, l = keyTable.length; i < l; i++) {
@@ -351,7 +406,7 @@
length--;
String key = (String) keyTable[i];
out.writeUTF(key);
- internedLocations.add(key);
+ internedTypeLocators.add(key);
}
}
if (JavaBuilder.DEBUG && length != 0)
@@ -359,23 +414,23 @@
}
/*
- * Type locations table
+ * Type locators table
* String type name
- * int interned location id
+ * int interned locator id
*/
- out.writeInt(length = typeLocations.elementSize);
+ out.writeInt(length = typeLocators.elementSize);
if (length > 0) {
- keyTable = typeLocations.keyTable;
- valueTable = typeLocations.valueTable;
+ keyTable = typeLocators.keyTable;
+ valueTable = typeLocators.valueTable;
for (int i = 0, l = keyTable.length; i < l; i++) {
if (keyTable[i] != null) {
length--;
out.writeUTF((String) keyTable[i]);
- out.writeInt(internedLocations.indexOf((String) valueTable[i]));
+ out.writeInt(internedTypeLocators.indexOf((String) valueTable[i]));
}
}
if (JavaBuilder.DEBUG && length != 0)
- System.out.println("typeLocations table is inconsistent"); //$NON-NLS-1$
+ System.out.println("typeLocators table is inconsistent"); //$NON-NLS-1$
}
/*
@@ -389,11 +444,11 @@
if (valueTable[i] != null) {
ReferenceCollection collection = (ReferenceCollection) valueTable[i];
char[][][] qNames = collection.qualifiedNameReferences;
- for (int j = 0, qLength = qNames.length; j < qLength; j++) {
+ for (int j = 0, m = qNames.length; j < m; j++) {
char[][] qName = qNames[j];
if (!internedQualifiedNames.contains(qName)) { // remember the names have been interned
internedQualifiedNames.add(qName);
- for (int k = 0, sLength = qName.length; k < sLength; k++) {
+ for (int k = 0, n = qName.length; k < n; k++) {
char[] sName = qName[k];
if (!internedSimpleNames.contains(sName)) // remember the names have been interned
internedSimpleNames.add(sName);
@@ -401,7 +456,7 @@
}
}
char[][] sNames = collection.simpleNameReferences;
- for (int j = 0, sLength = sNames.length; j < sLength; j++) {
+ for (int j = 0, m = sNames.length; j < m; j++) {
char[] sName = sNames[j];
if (!internedSimpleNames.contains(sName)) // remember the names have been interned
internedSimpleNames.add(sName);
@@ -423,7 +478,7 @@
/*
* References table
- * int interned location id
+ * int interned locator id
* ReferenceCollection
*/
out.writeInt(length = references.elementSize);
@@ -432,7 +487,7 @@
for (int i = 0, l = keyTable.length; i < l; i++) {
if (keyTable[i] != null) {
length--;
- out.writeInt(internedLocations.indexOf((String) keyTable[i]));
+ out.writeInt(internedTypeLocators.indexOf((String) keyTable[i]));
ReferenceCollection collection = (ReferenceCollection) valueTable[i];
if (collection instanceof AdditionalTypeCollection) {
out.writeByte(1);
@@ -459,7 +514,7 @@
}
private void writeNames(char[][] names, DataOutputStream out) throws IOException {
- int length = names.length;
+ int length = names == null ? 0 : names.length;
out.writeInt(length);
for (int i = 0; i < length; i++) {
char[] name = names[i];
@@ -483,11 +538,12 @@
/* Debug helper
void dump() {
System.out.println("State for " + javaProjectName + " (" + buildNumber + " @ " + new Date(lastStructuralBuildTime) + ")");
- System.out.println("\tClass path locations:");
- for (int i = 0, length = classpathLocations.length; i < length; ++i)
- System.out.println("\t\t" + classpathLocations[i]);
- System.out.println("\tOutput location:");
- System.out.println("\t\t" + outputLocationString);
+ System.out.println("\tClass path source locations:");
+ for (int i = 0, l = sourceLocations.length; i < l; i++)
+ System.out.println("\t\t" + sourceLocations[i]);
+ System.out.println("\tClass path binary locations:");
+ for (int i = 0, l = binaryLocations.length; i < l; i++)
+ System.out.println("\t\t" + binaryLocations[i]);
System.out.print("\tStructural build numbers table:");
if (structuralBuildTimes.elementSize == 0) {
@@ -500,12 +556,12 @@
System.out.print("\n\t\t" + keyTable[i].toString() + " -> " + valueTable[i].toString());
}
- System.out.print("\tType locations table:");
- if (typeLocations.elementSize == 0) {
+ System.out.print("\tType locators table:");
+ if (typeLocators.elementSize == 0) {
System.out.print(" <empty>");
} else {
- Object[] keyTable = typeLocations.keyTable;
- Object[] valueTable = typeLocations.valueTable;
+ Object[] keyTable = typeLocators.keyTable;
+ Object[] valueTable = typeLocators.valueTable;
for (int i = 0, l = keyTable.length; i < l; i++)
if (keyTable[i] != null)
System.out.print("\n\t\t" + keyTable[i].toString() + " -> " + valueTable[i].toString());
@@ -525,18 +581,18 @@
System.out.print("\n\t\t\tqualified:");
if (qRefs.length == 0)
System.out.print(" <empty>");
- else for (int j = 0, k = qRefs.length; j < k; j++)
- System.out.print(" '" + org.eclipse.jdt.internal.compiler.util.CharOperation.toString(qRefs[j]) + "'");
+ else for (int j = 0, m = qRefs.length; j < m; j++)
+ System.out.print(" '" + CharOperation.toString(qRefs[j]) + "'");
char[][] sRefs = c.simpleNameReferences;
System.out.print("\n\t\t\tsimple:");
if (sRefs.length == 0)
System.out.print(" <empty>");
- else for (int j = 0, k = sRefs.length; j < k; j++)
+ else for (int j = 0, m = sRefs.length; j < m; j++)
System.out.print(" " + new String(sRefs[j]));
if (c instanceof AdditionalTypeCollection) {
char[][] names = ((AdditionalTypeCollection) c).definedTypeNames;
System.out.print("\n\t\t\tadditional type names:");
- for (int j = 0, k = names.length; j < k; j++)
+ for (int j = 0, m = names.length; j < m; j++)
System.out.print(" " + new String(names[j]));
}
}
@@ -545,4 +601,4 @@
System.out.print("\n\n");
}
*/
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/WorkQueue.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/WorkQueue.java
index ad850c4..1265eaa 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/WorkQueue.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/WorkQueue.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.builder;
import java.util.*;
@@ -22,12 +22,12 @@
this.compiledList = new ArrayList(11);
}
-public void add(String element) {
+public void add(SourceFile element) {
needsCompileList.add(element);
}
-public void addAll(String[] elements) {
- for (int i = 0, length = elements.length; i < length; i++)
+public void addAll(SourceFile[] elements) {
+ for (int i = 0, l = elements.length; i < l; i++)
add(elements[i]);
}
@@ -36,20 +36,20 @@
this.compiledList.clear();
}
-public void finished(String element) {
+public void finished(SourceFile element) {
needsCompileList.remove(element);
compiledList.add(element);
}
-public boolean isCompiled(String element) {
+public boolean isCompiled(SourceFile element) {
return compiledList.contains(element);
}
-public boolean isWaiting(String element) {
+public boolean isWaiting(SourceFile element) {
return needsCompileList.contains(element);
}
public String toString() {
return "WorkQueue: " + needsCompileList; //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java
index 2d8eca3..fb61cf2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/EvaluationContextWrapper.java
Binary files differ
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/GlobalVariableWrapper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/GlobalVariableWrapper.java
index 8b0f0a4..ca48c0e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/GlobalVariableWrapper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/GlobalVariableWrapper.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.eval;
import org.eclipse.jdt.core.eval.IGlobalVariable;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java
index a828a16..35ffdfd 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/eval/RequestorWrapper.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.eval;
import org.eclipse.core.resources.IMarker;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java
index 8e25b94..f2e4cc8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBinaryType.java
@@ -1,21 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.hierarchy;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.IBinaryField;
import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
import org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.IConstants;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
public class HierarchyBinaryType implements IBinaryType {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java
index 55c20d9..b6895a5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyBuilder.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.hierarchy;
import java.util.ArrayList;
@@ -82,7 +82,7 @@
this.hierarchyResolver =
new HierarchyResolver(
this.searchableEnvironment,
- JavaCore.getOptions(),
+ project.getOptions(true),
this,
new DefaultProblemFactory());
this.infoToHandle = new HashMap(5);
@@ -100,7 +100,7 @@
// get generic type from focus type
IGenericType type;
try {
- type = (IGenericType) ((JavaElement) focusType).getRawInfo();
+ type = (IGenericType) ((JavaElement) focusType).getElementInfo();
} catch (JavaModelException e) {
// if the focus type is not present, or if cannot get workbench path
// we cannot create the hierarchy
@@ -150,7 +150,7 @@
IGenericType suppliedType,
IGenericType superclass,
IGenericType[] superinterfaces) {
- this.worked(1);
+
// convert all infos to handles
IType typeHandle = getHandle(suppliedType);
/*
@@ -222,7 +222,7 @@
this.hierarchy.addInterface(typeHandle);
}
if (interfaceHandles == null) {
- interfaceHandles = this.hierarchy.NO_TYPE;
+ interfaceHandles = TypeHierarchy.NO_TYPE;
}
this.hierarchy.cacheSuperInterfaces(typeHandle, interfaceHandles);
@@ -275,21 +275,20 @@
int flag;
String qualifiedName;
if (typeInfo.isClass()) {
- flag = this.nameLookup.ACCEPT_CLASSES;
+ flag = NameLookup.ACCEPT_CLASSES;
} else {
- flag = this.nameLookup.ACCEPT_INTERFACES;
+ flag = NameLookup.ACCEPT_INTERFACES;
}
char[] bName = typeInfo.getName();
qualifiedName = new String(ClassFile.translatedName(bName));
return this.nameLookup.findType(qualifiedName, false, flag);
}
- protected void worked(int work) {
- IProgressMonitor progressMonitor = this.hierarchy.progressMonitor;
- if (progressMonitor != null) {
- if (progressMonitor.isCanceled()) {
+ protected void worked(IProgressMonitor monitor, int work) {
+ if (monitor != null) {
+ if (monitor.isCanceled()) {
throw new OperationCanceledException();
} else {
- progressMonitor.worked(work);
+ monitor.worked(work);
}
}
}
@@ -297,7 +296,7 @@
* Create an ICompilationUnit info from the given compilation unit on disk.
*/
protected ICompilationUnit createCompilationUnitFromPath(Openable handle, String osPath) throws JavaModelException {
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
+ String encoding = handle.getJavaProject().getOption(JavaCore.CORE_ENCODING, true);
return
new BasicCompilationUnit(
null,
@@ -404,7 +403,7 @@
* Add the type info from the given CU to the given list of infos.
*/
protected void addInfoFromOpenSourceType(SourceType type, ArrayList infos) throws JavaModelException {
- IGenericType info = (IGenericType)type.getRawInfo();
+ IGenericType info = (IGenericType)type.getElementInfo();
infos.add(info);
this.infoToHandle.put(info, type);
IType[] members = type.getTypes();
@@ -418,7 +417,7 @@
*/
protected void addInfoFromOpenClassFile(ClassFile classFile, ArrayList infos) throws JavaModelException {
IType type = classFile.getType();
- IGenericType info = (IGenericType) ((BinaryType) type).getRawInfo();
+ IGenericType info = (IGenericType) ((BinaryType) type).getElementInfo();
infos.add(info);
this.infoToHandle.put(info, classFile);
}
@@ -439,4 +438,4 @@
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java
index 9efe68c..85f4b3f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyResolver.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.hierarchy;
/**
@@ -25,6 +25,9 @@
import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
@@ -40,6 +43,7 @@
import org.eclipse.jdt.internal.compiler.env.ISourceType;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.ITypeRequestor;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
@@ -49,7 +53,6 @@
import org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.Util;
public class HierarchyResolver implements ITypeRequestor {
@@ -61,6 +64,7 @@
private ReferenceBinding[] typeBindings;
private ReferenceBinding focusType;
private CompilerOptions options;
+ private boolean hasMissingSuperClass;
/**
* A wrapper around the simple name of a type that is missing.
@@ -113,30 +117,18 @@
}
-public HierarchyResolver(
- INameEnvironment nameEnvironment,
- IErrorHandlingPolicy policy,
- Map settings,
- IHierarchyRequestor requestor,
- IProblemFactory problemFactory) {
-
- // create a problem handler given a handling policy
- options = settings == null ? new CompilerOptions() : new CompilerOptions(settings);
- ProblemReporter problemReporter = new ProblemReporter(policy, options, problemFactory);
- this.lookupEnvironment = new LookupEnvironment(this, options, problemReporter, nameEnvironment);
- this.requestor = requestor;
-
- this.typeIndex = -1;
- this.typeModels = new IGenericType[5];
- this.typeBindings = new ReferenceBinding[5];
-}
public HierarchyResolver(INameEnvironment nameEnvironment, Map settings, IHierarchyRequestor requestor, IProblemFactory problemFactory) {
- this(
- nameEnvironment,
- DefaultErrorHandlingPolicies.exitAfterAllProblems(),
- settings,
- requestor,
- problemFactory);
+ // create a problem handler with the 'exit after all problems' handling policy
+ options = settings == null ? new CompilerOptions() : new CompilerOptions(settings);
+ IErrorHandlingPolicy policy = DefaultErrorHandlingPolicies.exitAfterAllProblems();
+ ProblemReporter problemReporter = new ProblemReporter(policy, options, problemFactory);
+
+ this.initialize(
+ new LookupEnvironment(this, options, problemReporter, nameEnvironment),
+ requestor);
+}
+public HierarchyResolver(LookupEnvironment lookupEnvironment, IHierarchyRequestor requestor) {
+ this.initialize(lookupEnvironment, requestor);
}
/**
* Add an additional binary type
@@ -173,7 +165,13 @@
// build corresponding compilation unit
CompilationResult result = new CompilationResult(sourceType.getFileName(), 1, 1, this.options.maxProblemsPerUnit);
CompilationUnitDeclaration unit =
- SourceTypeConverter.buildCompilationUnit(new ISourceType[] {sourceType}, false, true, lookupEnvironment.problemReporter, result);
+ SourceTypeConverter.buildCompilationUnit(
+ new ISourceType[] {sourceType}, // ignore secondary types, to improve laziness
+ false, // no need for field and methods
+ true, // need member types
+ false, // no need for field initialization
+ lookupEnvironment.problemReporter,
+ result);
// build bindings
if (unit != null) {
@@ -209,17 +207,21 @@
} else {
return null;
}
- if (superclassName == null) return null;
- int lastSeparator = CharOperation.lastIndexOf(separator, superclassName);
- char[] simpleName = lastSeparator == -1 ? superclassName : CharOperation.subarray(superclassName, lastSeparator+1, superclassName.length);
- return new MissingType(new String(simpleName));
- } else {
- for (int t = typeIndex; t >= 0; t--) {
- if (typeBindings[t] == superBinding) {
- return typeModels[t];
+
+ if (superclassName != null) { // check whether subclass of Object due to broken hierarchy (as opposed to explicitly extending it)
+ int lastSeparator = CharOperation.lastIndexOf(separator, superclassName);
+ char[] simpleName = lastSeparator == -1 ? superclassName : CharOperation.subarray(superclassName, lastSeparator+1, superclassName.length);
+ if (!CharOperation.equals(simpleName, TypeConstants.OBJECT)) {
+ this.hasMissingSuperClass = true;
+ return new MissingType(new String(simpleName));
}
}
}
+ for (int t = typeIndex; t >= 0; t--) {
+ if (typeBindings[t] == superBinding) {
+ return typeModels[t];
+ }
+ }
}
return null;
}
@@ -270,6 +272,14 @@
}
return superinterfaces;
}
+private void initialize(LookupEnvironment lookupEnvironment, IHierarchyRequestor requestor) {
+ this.lookupEnvironment = lookupEnvironment;
+ this.requestor = requestor;
+
+ this.typeIndex = -1;
+ this.typeModels = new IGenericType[5];
+ this.typeBindings = new ReferenceBinding[5];
+}
private void remember(IGenericType suppliedType, ReferenceBinding typeBinding) {
if (typeBinding == null) return;
@@ -342,10 +352,18 @@
}
}
private void reportHierarchy() {
+ int objectIndex = -1;
for (int current = typeIndex; current >= 0; current--) {
- IGenericType suppliedType = typeModels[current];
ReferenceBinding typeBinding = typeBindings[current];
+ // java.lang.Object treated at the end
+ if (typeBinding.id == TypeIds.T_JavaLangObject) {
+ objectIndex = current;
+ continue;
+ }
+
+ IGenericType suppliedType = typeModels[current];
+
if (!subOrSuperOfFocus(typeBinding)) {
continue; // ignore types outside of hierarchy
}
@@ -360,6 +378,10 @@
requestor.connect(suppliedType, superclass, superinterfaces);
}
+ // add java.lang.Object only if the super class is not missing
+ if (!this.hasMissingSuperClass && objectIndex > -1) {
+ requestor.connect(typeModels[objectIndex], null, null);
+ }
}
private void reset(){
lookupEnvironment.reset();
@@ -379,8 +401,8 @@
* instead of a binary type.
*/
-public void resolve(IGenericType[] suppliedTypes) {
- resolve(suppliedTypes, null);
+public void resolve(IGenericType[] suppliedTypes, IProgressMonitor monitor) {
+ resolve(suppliedTypes, null, monitor);
}
/**
* Resolve the supertypes for the supplied source types.
@@ -393,7 +415,7 @@
* instead of a binary type.
*/
-public void resolve(IGenericType[] suppliedTypes, ICompilationUnit[] sourceUnits) {
+public void resolve(IGenericType[] suppliedTypes, ICompilationUnit[] sourceUnits, IProgressMonitor monitor) {
try {
int suppliedLength = suppliedTypes == null ? 0 : suppliedTypes.length;
int sourceLength = sourceUnits == null ? 0 : sourceUnits.length;
@@ -428,7 +450,14 @@
while (topLevelType.getEnclosingType() != null)
topLevelType = topLevelType.getEnclosingType();
CompilationResult result = new CompilationResult(topLevelType.getFileName(), i, suppliedLength, this.options.maxProblemsPerUnit);
- units[i] = SourceTypeConverter.buildCompilationUnit(new ISourceType[]{topLevelType}, false, true, lookupEnvironment.problemReporter, result);
+ units[i] =
+ SourceTypeConverter.buildCompilationUnit(
+ new ISourceType[]{topLevelType},
+ false, // no need for field and methods
+ true, // need member types
+ false, // no need for field initialization
+ lookupEnvironment.problemReporter,
+ result);
if (units[i] != null) {
try {
lookupEnvironment.buildTypeBindings(units[i]);
@@ -437,16 +466,18 @@
}
}
}
+ worked(monitor, 1);
}
+ Parser parser = new Parser(lookupEnvironment.problemReporter, true, options.sourceLevel >= CompilerOptions.JDK1_4);
for (int i = 0; i < sourceLength; i++){
ICompilationUnit sourceUnit = sourceUnits[i];
CompilationResult unitResult = new CompilationResult(sourceUnit, suppliedLength+i, suppliedLength+sourceLength, this.options.maxProblemsPerUnit);
- Parser parser = new Parser(lookupEnvironment.problemReporter, true, options.assertMode);
CompilationUnitDeclaration parsedUnit = parser.dietParse(sourceUnit, unitResult);
if (parsedUnit != null) {
units[suppliedLength+i] = parsedUnit;
lookupEnvironment.buildTypeBindings(parsedUnit);
}
+ worked(monitor, 1);
}
// complete type bindings (ie. connect super types) and remember them
@@ -467,6 +498,7 @@
}
}
}
+ worked(monitor, 1);
}
for (int i = 0; i < sourceLength; i++) {
CompilationUnitDeclaration parsedUnit = units[suppliedLength+i];
@@ -479,6 +511,7 @@
rememberWithMemberTypes(parsedUnit.types[j], null, sourceUnit);
}
}
+ worked(monitor, 1);
}
reportHierarchy();
@@ -506,7 +539,13 @@
topLevelType = topLevelType.getEnclosingType();
CompilationResult result = new CompilationResult(topLevelType.getFileName(), 1, 1, this.options.maxProblemsPerUnit);
CompilationUnitDeclaration unit =
- SourceTypeConverter.buildCompilationUnit(new ISourceType[]{topLevelType}, false, true, lookupEnvironment.problemReporter, result);
+ SourceTypeConverter.buildCompilationUnit(
+ new ISourceType[]{topLevelType},
+ false, // no need for field and methods
+ true, // need member types
+ false, // no need for field initialization
+ lookupEnvironment.problemReporter,
+ result);
if (unit != null) {
lookupEnvironment.buildTypeBindings(unit);
@@ -527,10 +566,13 @@
*/
public ReferenceBinding setFocusType(char[][] compoundName) {
if (compoundName == null || this.lookupEnvironment == null) return null;
- this.focusType = this.lookupEnvironment.askForType(compoundName);
+ this.focusType = this.lookupEnvironment.getCachedType(compoundName);
+ if (this.focusType == null) {
+ this.focusType = this.lookupEnvironment.askForType(compoundName);
+ }
return this.focusType;
}
-private boolean subOrSuperOfFocus(ReferenceBinding typeBinding) {
+public boolean subOrSuperOfFocus(ReferenceBinding typeBinding) {
if (this.focusType == null) return true; // accept all types (case of hierarchy in a region)
if (this.subTypeOfType(this.focusType, typeBinding)) return true;
if (this.subTypeOfType(typeBinding, this.focusType)) return true;
@@ -540,7 +582,7 @@
if (typeBinding == null || subType == null) return false;
if (subType == typeBinding) return true;
ReferenceBinding superclass = subType.superclass();
- if (superclass != null && superclass.id == TypeIds.T_JavaLangObject && subType.isHierarchyInconsistent()) return false;
+// if (superclass != null && superclass.id == TypeIds.T_JavaLangObject && subType.isHierarchyInconsistent()) return false;
if (this.subTypeOfType(superclass, typeBinding)) return true;
ReferenceBinding[] superInterfaces = subType.superInterfaces();
if (superInterfaces != null) {
@@ -550,4 +592,13 @@
}
return false;
}
+protected void worked(IProgressMonitor monitor, int work) {
+ if (monitor != null) {
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ } else {
+ monitor.worked(work);
+ }
+ }
+}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyType.java
index 81eb0d8..fb21984 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/HierarchyType.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.hierarchy;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IHierarchyRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IHierarchyRequestor.java
index 9f4c3a0..2352827 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IHierarchyRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IHierarchyRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.hierarchy;
import org.eclipse.jdt.internal.compiler.env.IGenericType;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java
index b5fa909..54ec30f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/IndexBasedHierarchyBuilder.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.hierarchy;
import java.util.ArrayList;
@@ -17,7 +17,6 @@
import java.util.Map;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -26,8 +25,8 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.IWorkingCopy;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
@@ -35,18 +34,8 @@
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
-import org.eclipse.jdt.internal.core.ClassFile;
-import org.eclipse.jdt.internal.core.CompilationUnit;
-import org.eclipse.jdt.internal.core.HandleFactory;
-import org.eclipse.jdt.internal.core.IPathRequestor;
-import org.eclipse.jdt.internal.core.JavaModelManager;
-import org.eclipse.jdt.internal.core.JavaProject;
-import org.eclipse.jdt.internal.core.Openable;
-import org.eclipse.jdt.internal.core.SearchableEnvironment;
-import org.eclipse.jdt.internal.core.Util;
-import org.eclipse.jdt.internal.core.WorkingCopy;
+import org.eclipse.jdt.internal.core.*;
import org.eclipse.jdt.internal.core.search.IIndexSearchRequestor;
import org.eclipse.jdt.internal.core.search.IInfoConstants;
import org.eclipse.jdt.internal.core.search.IndexSearchAdapter;
@@ -57,6 +46,7 @@
import org.eclipse.jdt.internal.core.search.matching.SuperTypeReferencePattern;
public class IndexBasedHierarchyBuilder extends HierarchyBuilder {
+ public static final int MAXTICKS = 800; // heuristic so that there still progress for deep hierachies
/**
* A temporary cache of compilation units to handles to speed info
* to handle translation - it only contains the entries
@@ -158,10 +148,21 @@
manager.cacheZipFiles();
if (computeSubtypes) {
- String[] allPossibleSubtypes = this.determinePossibleSubTypes();
+ // Note by construction there always is a focus type here
+ boolean focusIsObject = getType().getElementName().equals(new String(IIndexConstants.OBJECT));
+ int amountOfWorkForSubtypes = focusIsObject ? 5 : 80; // percentage of work needed to get possible subtypes
+ IProgressMonitor possibleSubtypesMonitor =
+ this.hierarchy.progressMonitor == null ?
+ null :
+ new SubProgressMonitor(this.hierarchy.progressMonitor, amountOfWorkForSubtypes);
+ String[] allPossibleSubtypes = this.determinePossibleSubTypes(possibleSubtypesMonitor);
if (allPossibleSubtypes != null) {
+ IProgressMonitor buildMonitor =
+ this.hierarchy.progressMonitor == null ?
+ null :
+ new SubProgressMonitor(this.hierarchy.progressMonitor, 100 - amountOfWorkForSubtypes);
this.hierarchy.initialize(allPossibleSubtypes.length);
- buildFromPotentialSubtypes(allPossibleSubtypes);
+ buildFromPotentialSubtypes(allPossibleSubtypes, buildMonitor);
}
} else {
this.hierarchy.initialize(1);
@@ -171,7 +172,7 @@
manager.flushZipFiles();
}
}
-private void buildForProject(JavaProject project, ArrayList infos, ArrayList units, IWorkingCopy[] workingCopies) throws JavaModelException {
+private void buildForProject(JavaProject project, ArrayList infos, ArrayList units, IWorkingCopy[] workingCopies, IProgressMonitor monitor) throws JavaModelException {
// copy vectors into arrays
IGenericType[] genericTypes;
int infosSize = infos.size();
@@ -216,7 +217,7 @@
}
try {
this.hierarchyResolver =
- new HierarchyResolver(this.searchableEnvironment, JavaCore.getOptions(), this, new DefaultProblemFactory());
+ new HierarchyResolver(this.searchableEnvironment, project.getOptions(true), this, new DefaultProblemFactory());
if (focusType != null) {
char[] fullyQualifiedName = focusType.getFullyQualifiedName().toCharArray();
ReferenceBinding focusTypeBinding = this.hierarchyResolver.setFocusType(CharOperation.splitOn('.', fullyQualifiedName));
@@ -226,7 +227,7 @@
return;
}
}
- this.hierarchyResolver.resolve(genericTypes, compilationUnits);
+ this.hierarchyResolver.resolve(genericTypes, compilationUnits, monitor);
} finally {
if (inProjectOfFocusType) {
this.nameLookup.setUnitsToLookInside(null);
@@ -238,7 +239,7 @@
/**
* Configure this type hierarchy based on the given potential subtypes.
*/
-private void buildFromPotentialSubtypes(String[] allPotentialSubTypes) {
+private void buildFromPotentialSubtypes(String[] allPotentialSubTypes, IProgressMonitor monitor) {
IType focusType = this.getType();
// substitute compilation units with working copies
@@ -266,18 +267,7 @@
Openable focusCU = (Openable)focusType.getCompilationUnit();
String focusPath = null;
if (focusCU != null) {
- try {
- IResource underlyingResource;
- if (focusCU instanceof WorkingCopy) {
- underlyingResource = ((WorkingCopy)focusCU).getOriginalElement().getUnderlyingResource();
- } else {
- underlyingResource = focusCU.getUnderlyingResource();
- }
- focusPath = underlyingResource.getFullPath().toString();
- } catch (JavaModelException e) {
- // type does not exist
- return;
- }
+ focusPath = focusCU.getPath().toString();
if (length > 0) {
System.arraycopy(allPotentialSubTypes, 0, allPotentialSubTypes = new String[length+1], 0, length);
allPotentialSubTypes[length] = focusPath;
@@ -299,75 +289,78 @@
ArrayList infos = new ArrayList();
ArrayList units = new ArrayList();
- // create element infos for subtypes
- HandleFactory factory = new HandleFactory(ResourcesPlugin.getWorkspace());
- IJavaProject currentProject = null;
- for (int i = 0; i < length; i++) {
- try {
- String resourcePath = allPotentialSubTypes[i];
-
- // skip duplicate paths (e.g. if focus path was injected when it was already a potential subtype)
- if (i > 0 && resourcePath.equals(allPotentialSubTypes[i-1])) continue;
-
- Openable handle;
- IWorkingCopy workingCopy = (IWorkingCopy)wcPaths.get(resourcePath);
- if (workingCopy != null) {
- handle = (Openable)workingCopy;
- } else {
- handle =
- resourcePath.equals(focusPath) ?
- focusCU :
- factory.createOpenable(resourcePath);
- if (handle == null) continue; // match is outside classpath
- }
-
- IJavaProject project = handle.getJavaProject();
- if (currentProject == null) {
- currentProject = project;
- infos = new ArrayList(5);
- units = new ArrayList(5);
- } else if (!currentProject.equals(project)) {
- // build current project
- this.buildForProject((JavaProject)currentProject, infos, units, workingCopies);
- currentProject = project;
- infos = new ArrayList(5);
- units = new ArrayList(5);
- }
-
- this.addInfoFromElement(handle, infos, units, resourcePath);
-
- worked(1);
- } catch (JavaModelException e) {
- continue;
- }
- }
-
- // build last project
try {
- if (currentProject == null) {
- // case of no potential subtypes
- currentProject = focusType.getJavaProject();
- this.addInfosFromType(focusType, infos);
+ // create element infos for subtypes
+ HandleFactory factory = new HandleFactory(ResourcesPlugin.getWorkspace());
+ IJavaProject currentProject = null;
+ if (monitor != null) monitor.beginTask("", length*2 /* 1 for build binding, 1 for connect hierarchy*/); //$NON-NLS-1$
+ for (int i = 0; i < length; i++) {
+ try {
+ String resourcePath = allPotentialSubTypes[i];
+
+ // skip duplicate paths (e.g. if focus path was injected when it was already a potential subtype)
+ if (i > 0 && resourcePath.equals(allPotentialSubTypes[i-1])) continue;
+
+ Openable handle;
+ IWorkingCopy workingCopy = (IWorkingCopy)wcPaths.get(resourcePath);
+ if (workingCopy != null) {
+ handle = (Openable)workingCopy;
+ } else {
+ handle =
+ resourcePath.equals(focusPath) ?
+ focusCU :
+ factory.createOpenable(resourcePath, this.scope);
+ if (handle == null) continue; // match is outside classpath
+ }
+
+ IJavaProject project = handle.getJavaProject();
+ if (currentProject == null) {
+ currentProject = project;
+ infos = new ArrayList(5);
+ units = new ArrayList(5);
+ } else if (!currentProject.equals(project)) {
+ // build current project
+ this.buildForProject((JavaProject)currentProject, infos, units, workingCopies, monitor);
+ currentProject = project;
+ infos = new ArrayList(5);
+ units = new ArrayList(5);
+ }
+
+ this.addInfoFromElement(handle, infos, units, resourcePath);
+ } catch (JavaModelException e) {
+ continue;
+ }
}
- this.buildForProject((JavaProject)currentProject, infos, units, workingCopies);
- } catch (JavaModelException e) {
- }
-
- // Compute hierarchy of focus type if not already done (case of a type with potential subtypes that are not real subtypes)
- if (!this.hierarchy.contains(focusType)) {
+
+ // build last project
try {
- currentProject = focusType.getJavaProject();
- infos = new ArrayList();
- units = new ArrayList();
- this.addInfosFromType(focusType, infos);
- this.buildForProject((JavaProject)currentProject, infos, units, workingCopies);
+ if (currentProject == null) {
+ // case of no potential subtypes
+ currentProject = focusType.getJavaProject();
+ this.addInfosFromType(focusType, infos);
+ }
+ this.buildForProject((JavaProject)currentProject, infos, units, workingCopies, monitor);
} catch (JavaModelException e) {
}
- }
-
- // Add focus if not already in (case of a type with no explicit super type)
- if (!this.hierarchy.contains(focusType)) {
- this.hierarchy.addRootClass(focusType);
+
+ // Compute hierarchy of focus type if not already done (case of a type with potential subtypes that are not real subtypes)
+ if (!this.hierarchy.contains(focusType)) {
+ try {
+ currentProject = focusType.getJavaProject();
+ infos = new ArrayList();
+ units = new ArrayList();
+ this.addInfosFromType(focusType, infos);
+ this.buildForProject((JavaProject)currentProject, infos, units, workingCopies, monitor);
+ } catch (JavaModelException e) {
+ }
+ }
+
+ // Add focus if not already in (case of a type with no explicit super type)
+ if (!this.hierarchy.contains(focusType)) {
+ this.hierarchy.addRootClass(focusType);
+ }
+ } finally {
+ if (monitor != null) monitor.done();
}
}
protected ICompilationUnit createCompilationUnitFromPath(Openable handle,String osPath) throws JavaModelException {
@@ -379,7 +372,7 @@
* Returns all of the possible subtypes of this type hierarchy.
* Returns null if they could not be determine.
*/
-private String[] determinePossibleSubTypes() throws JavaModelException, CoreException {
+private String[] determinePossibleSubTypes(IProgressMonitor monitor) throws JavaModelException, CoreException {
class PathCollector implements IPathRequestor {
HashSet paths = new HashSet(10);
@@ -390,14 +383,19 @@
PathCollector collector = new PathCollector();
IProject project = this.hierarchy.javaProject().getProject();
- searchAllPossibleSubTypes(
- project.getWorkspace(),
- this.getType(),
- this.scope,
- this.binariesFromIndexMatches,
- collector,
- IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
- this.hierarchy.progressMonitor);
+ try {
+ if (monitor != null) monitor.beginTask("", MAXTICKS); //$NON-NLS-1$
+ searchAllPossibleSubTypes(
+ project.getWorkspace(),
+ this.getType(),
+ this.scope,
+ this.binariesFromIndexMatches,
+ collector,
+ IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
+ monitor);
+ } finally {
+ if (monitor != null) monitor.done();
+ }
HashSet paths = collector.paths;
int length = paths.size();
@@ -506,7 +504,7 @@
/* initialize entry result cache */
pattern.entryResults = new HashMap();
/* iterate all queued names */
- int ticks = 50;
+ int ticks = 0;
awaitings.add(type.getElementName().toCharArray());
while (awaitings.start <= awaitings.end){
if (progressMonitor != null && progressMonitor.isCanceled()) return;
@@ -522,10 +520,12 @@
indexManager.performConcurrentJob(
job,
waitingPolicy,
- progressMonitor == null ? null : new SubProgressMonitor(progressMonitor, ticks));
+ null); // don't pass a sub progress monitor as this is too costly for deep hierarchies
+ if (progressMonitor != null && ++ticks <= MAXTICKS) {
+ progressMonitor.worked(1);
+ }
/* in case, we search all subtypes, no need to search further */
if (currentTypeName == null) break;
- ticks = ticks / 2;
}
/* close all cached index inputs */
job.closeAll();
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/RegionBasedHierarchyBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/RegionBasedHierarchyBuilder.java
index 37b996c..0c743d5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/RegionBasedHierarchyBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/RegionBasedHierarchyBuilder.java
@@ -1,18 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.hierarchy;
import java.util.ArrayList;
import java.util.HashMap;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
@@ -45,9 +47,17 @@
manager.cacheZipFiles();
if (this.hierarchy.type == null || computeSubtypes) {
- ArrayList allTypesInRegion = determineTypesInRegion();
+ IProgressMonitor typeInRegionMonitor =
+ this.hierarchy.progressMonitor == null ?
+ null :
+ new SubProgressMonitor(this.hierarchy.progressMonitor, 30);
+ ArrayList allTypesInRegion = determineTypesInRegion(typeInRegionMonitor);
this.hierarchy.initialize(allTypesInRegion.size());
- createTypeHierarchyBasedOnRegion(allTypesInRegion);
+ IProgressMonitor buildMonitor =
+ this.hierarchy.progressMonitor == null ?
+ null :
+ new SubProgressMonitor(this.hierarchy.progressMonitor, 70);
+ createTypeHierarchyBasedOnRegion(allTypesInRegion, buildMonitor);
((RegionBasedTypeHierarchy)this.hierarchy).pruneDeadBranches();
} else {
this.hierarchy.initialize(1);
@@ -60,7 +70,7 @@
/**
* Configure this type hierarchy that is based on a region.
*/
-private void createTypeHierarchyBasedOnRegion(ArrayList allTypesInRegion) {
+private void createTypeHierarchyBasedOnRegion(ArrayList allTypesInRegion, IProgressMonitor monitor) {
int size = allTypesInRegion.size();
if (size != 0) {
@@ -94,7 +104,6 @@
try {
IType type = types[i];
this.addInfoFromElement((Openable)type.getOpenable(), infos, units, type.getPath().toString());
- worked(1);
} catch (JavaModelException npe) {
continue types;
}
@@ -118,69 +127,81 @@
compilationUnits = new org.eclipse.jdt.internal.compiler.env.ICompilationUnit[0];
}
- // resolve
- if (infosSize > 0 || unitsSize > 0) {
- IType focusType = this.getType();
- CompilationUnit unitToLookInside = null;
- if (focusType != null) {
- unitToLookInside = (CompilationUnit)focusType.getCompilationUnit();
- }
- if (this.nameLookup != null && unitToLookInside != null) {
- synchronized(this.nameLookup) { // prevent 2 concurrent accesses to name lookup while the working copies are set
- try {
- nameLookup.setUnitsToLookInside(new IWorkingCopy[] {unitToLookInside});
- this.hierarchyResolver.resolve(genericTypes, compilationUnits);
- } finally {
- nameLookup.setUnitsToLookInside(null);
- }
+ try {
+ // resolve
+ if (monitor != null) monitor.beginTask("", (infosSize+unitsSize) * 2/* 1 for build binding, 1 for connect hierarchy*/); //$NON-NLS-1$
+ if (infosSize > 0 || unitsSize > 0) {
+ IType focusType = this.getType();
+ CompilationUnit unitToLookInside = null;
+ if (focusType != null) {
+ unitToLookInside = (CompilationUnit)focusType.getCompilationUnit();
}
- } else {
- this.hierarchyResolver.resolve(genericTypes, compilationUnits);
+ if (this.nameLookup != null && unitToLookInside != null) {
+ synchronized(this.nameLookup) { // prevent 2 concurrent accesses to name lookup while the working copies are set
+ try {
+ nameLookup.setUnitsToLookInside(new IWorkingCopy[] {unitToLookInside});
+ this.hierarchyResolver.resolve(genericTypes, compilationUnits, monitor);
+ } finally {
+ nameLookup.setUnitsToLookInside(null);
+ }
+ }
+ } else {
+ this.hierarchyResolver.resolve(genericTypes, compilationUnits, monitor);
+ }
}
+ } finally {
+ if (monitor != null) monitor.done();
}
}
/**
* Returns all of the types defined in the region of this type hierarchy.
*/
- private ArrayList determineTypesInRegion() {
+ private ArrayList determineTypesInRegion(IProgressMonitor monitor) {
- ArrayList types = new ArrayList();
- IJavaElement[] roots =
- ((RegionBasedTypeHierarchy) this.hierarchy).fRegion.getElements();
- for (int i = 0; i < roots.length; i++) {
- try {
- IJavaElement root = roots[i];
- switch (root.getElementType()) {
- case IJavaElement.JAVA_PROJECT :
- injectAllTypesForJavaProject((IJavaProject) root, types);
- break;
- case IJavaElement.PACKAGE_FRAGMENT_ROOT :
- injectAllTypesForPackageFragmentRoot((IPackageFragmentRoot) root, types);
- break;
- case IJavaElement.PACKAGE_FRAGMENT :
- injectAllTypesForPackageFragment((IPackageFragment) root, types);
- break;
- case IJavaElement.CLASS_FILE :
- types.add(((IClassFile) root).getType());
- break;
- case IJavaElement.COMPILATION_UNIT :
- IType[] cuTypes = ((ICompilationUnit) root).getAllTypes();
- for (int j = 0; j < cuTypes.length; j++) {
- types.add(cuTypes[j]);
- }
- break;
- case IJavaElement.TYPE :
- types.add(root);
- break;
- default :
- break;
+ try {
+ ArrayList types = new ArrayList();
+ IJavaElement[] roots =
+ ((RegionBasedTypeHierarchy) this.hierarchy).fRegion.getElements();
+ int length = roots.length;
+ if (monitor != null) monitor.beginTask("", length); //$NON-NLS-1$
+ for (int i = 0; i <length; i++) {
+ try {
+ IJavaElement root = roots[i];
+ switch (root.getElementType()) {
+ case IJavaElement.JAVA_PROJECT :
+ injectAllTypesForJavaProject((IJavaProject) root, types);
+ break;
+ case IJavaElement.PACKAGE_FRAGMENT_ROOT :
+ injectAllTypesForPackageFragmentRoot((IPackageFragmentRoot) root, types);
+ break;
+ case IJavaElement.PACKAGE_FRAGMENT :
+ injectAllTypesForPackageFragment((IPackageFragment) root, types);
+ break;
+ case IJavaElement.CLASS_FILE :
+ types.add(((IClassFile) root).getType());
+ break;
+ case IJavaElement.COMPILATION_UNIT :
+ IType[] cuTypes = ((ICompilationUnit) root).getAllTypes();
+ for (int j = 0; j < cuTypes.length; j++) {
+ types.add(cuTypes[j]);
+ }
+ break;
+ case IJavaElement.TYPE :
+ types.add(root);
+ break;
+ default :
+ break;
+ }
+ } catch (JavaModelException e) {
+ // just continue
}
- } catch (JavaModelException e) {
- // just continue
+ worked(monitor, 1);
}
+ return types;
+ } finally {
+ if (monitor != null) monitor.done();
}
- return types;
}
/**
@@ -258,7 +279,6 @@
for (int i = 0; i < containers.length; i++) {
IClassFile cf = containers[i];
types.add(cf.getType());
- this.worked(1);
}
} catch (JavaModelException e) {
}
@@ -278,9 +298,8 @@
for (int j = 0; j < cuTypes.length; j++) {
types.add(cuTypes[j]);
}
- this.worked(1);
}
} catch (JavaModelException e) {
}
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/RegionBasedTypeHierarchy.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/RegionBasedTypeHierarchy.java
index 9cd6daf..988415f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/RegionBasedTypeHierarchy.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/RegionBasedTypeHierarchy.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.hierarchy;
import org.eclipse.core.runtime.CoreException;
@@ -18,6 +18,7 @@
import org.eclipse.jdt.core.IRegion;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.core.CompilationUnit;
import org.eclipse.jdt.internal.core.JavaElement;
import org.eclipse.jdt.internal.core.Openable;
@@ -42,7 +43,7 @@
* contain the branch including the specified type.
*/
public RegionBasedTypeHierarchy(IRegion region, IJavaProject project, IType type, boolean computeSubtypes) throws JavaModelException {
- super(type, null, computeSubtypes);
+ super(type, (IJavaSearchScope)null, computeSubtypes);
fRegion = region;
fProject = project;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java
index fd32ebc..c43fc1a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/hierarchy/TypeHierarchy.java
@@ -1,17 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.hierarchy;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
@@ -21,6 +25,7 @@
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IElementChangedListener;
@@ -35,10 +40,12 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.internal.core.CompilationUnit;
import org.eclipse.jdt.internal.core.ImportContainer;
import org.eclipse.jdt.internal.core.JavaElement;
import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.internal.core.JavaModelStatus;
import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jdt.internal.core.Openable;
import org.eclipse.jdt.internal.core.Region;
@@ -50,6 +57,32 @@
*/
public class TypeHierarchy implements ITypeHierarchy, IElementChangedListener {
public static boolean DEBUG = false;
+
+ static final byte VERSION = 0x0000;
+ // SEPARATOR
+ static final byte SEPARATOR1 = '\n';
+ static final byte SEPARATOR2 = ',';
+ static final byte SEPARATOR3 = '>';
+ static final byte SEPARATOR4 = '\r';
+ // general info
+ static final byte COMPUTE_SUBTYPES = 0x0001;
+
+ // type info
+ static final byte CLASS = 0x0000;
+ static final byte INTERFACE = 0x0001;
+ static final byte COMPUTED_FOR = 0x0002;
+ static final byte ROOT = 0x0004;
+
+ // cst
+ static final byte[] NO_FLAGS = new byte[]{};
+ static final int SIZE = 10;
+
+ /**
+ * The Java Project in which the hierarchy is being built - this
+ * provides the context (i.e. classpath and namelookup rules)
+ * Possibly null.
+ */
+ protected IJavaProject project;
/**
* The type the hierarchy was specifically computed for,
* possibly null.
@@ -125,6 +158,18 @@
IJavaSearchScope scope;
/**
+ * Creates an empty TypeHierarchy
+ */
+public TypeHierarchy() throws JavaModelException {
+}
+/**
+ * Creates a TypeHierarchy on the given type.
+ */
+public TypeHierarchy(IType type, IJavaProject project, boolean computeSubtypes) throws JavaModelException {
+ this(type, SearchEngine.createJavaSearchScope(new IJavaElement[] {project}), computeSubtypes);
+ this.project = project;
+}
+/**
* Creates a TypeHierarchy on the given type.
*/
public TypeHierarchy(IType type, IJavaSearchScope scope, boolean computeSubtypes) throws JavaModelException {
@@ -216,6 +261,13 @@
this.changeListeners.add(listener);
}
}
+private static Integer bytesToFlags(byte[] bytes){
+ if(bytes != null && bytes.length > 0) {
+ return new Integer(new String(bytes));
+ } else {
+ return null;
+ }
+}
/**
* cacheFlags.
*/
@@ -382,6 +434,13 @@
}
}
}
+private static byte[] flagsToBytes(Integer flags){
+ if(flags != null) {
+ return flags.toString().getBytes();
+ } else {
+ return NO_FLAGS;
+ }
+}
/**
* @see ITypeHierarchy
*/
@@ -524,7 +583,7 @@
*/
public IType[] getExtendingInterfaces(IType type) {
try {
- if (type.isClass()) {
+ if (!this.isInterface(type)) {
return new IType[] {};
}
} catch (JavaModelException npe) {
@@ -542,7 +601,7 @@
while (iter.hasNext()) {
IType type = (IType) iter.next();
try {
- if (type.isClass()) {
+ if (!this.isInterface(type)) {
continue;
}
} catch (JavaModelException npe) {
@@ -567,7 +626,7 @@
*/
public IType[] getImplementingClasses(IType type) {
try {
- if (type.isClass()) {
+ if (!this.isInterface(type)) {
return NO_TYPE;
}
} catch (JavaModelException npe) {
@@ -586,7 +645,7 @@
while (iter.hasNext()) {
IType type = (IType) iter.next();
try {
- if (type.isInterface()) {
+ if (this.isInterface(type)) {
continue;
}
} catch (JavaModelException npe) {
@@ -634,7 +693,7 @@
*/
public IType[] getSubclasses(IType type) {
try {
- if (type.isInterface()) {
+ if (this.isInterface(type)) {
return NO_TYPE;
}
} catch (JavaModelException npe) {
@@ -667,7 +726,7 @@
*/
public IType getSuperclass(IType type) {
try {
- if (type.isInterface()) {
+ if (this.isInterface(type)) {
return null;
}
return (IType) this.classToSuperclass.get(type);
@@ -877,7 +936,7 @@
IClasspathEntry[] classpath = ((JavaProject)this.javaProject()).getExpandedClasspath(true);
for (int i = 0; i < classpath.length; i++) {
if (classpath[i].getEntryKind() == IClasspathEntry.CPE_PROJECT
- && classpath[i].getPath().equals(element.getUnderlyingResource().getFullPath())) {
+ && classpath[i].getPath().equals(element.getPath())) {
return true;
}
}
@@ -1091,12 +1150,177 @@
}
return false;
}
+private boolean isInterface(IType type) throws JavaModelException {
+ int flags = this.getCachedFlags(type);
+ if (flags == -1) {
+ return type.isInterface();
+ } else {
+ return Flags.isInterface(flags);
+ }
+}
/**
* Returns the java project this hierarchy was created in.
*/
public IJavaProject javaProject() {
return this.type.getJavaProject();
}
+protected static byte[] readUntil(InputStream input, byte separator) throws JavaModelException, IOException{
+ return readUntil(input, separator, 0);
+}
+protected static byte[] readUntil(InputStream input, byte separator, int offset) throws IOException, JavaModelException{
+ int length = 0;
+ byte[] bytes = new byte[SIZE];
+ byte b;
+ while((b = (byte)input.read()) != separator && b != -1) {
+ if(bytes.length == length) {
+ System.arraycopy(bytes, 0, bytes = new byte[length*2], 0, length);;
+ }
+ bytes[length++]=(byte)b;
+ }
+ if(b == -1) {
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatus.ERROR));
+ }
+ System.arraycopy(bytes, 0, bytes = new byte[length + offset], offset, length);
+ return bytes;
+}
+public static ITypeHierarchy load(IType type, InputStream input) throws JavaModelException {
+ try {
+ TypeHierarchy typeHierarchy = new TypeHierarchy();
+ typeHierarchy.initialize(1);
+
+ IType[] types = new IType[SIZE];
+ int typeCount = 0;
+
+ byte version = (byte)input.read();
+
+ if(version != VERSION) {
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatus.ERROR));
+ }
+ byte generalInfo = (byte)input.read();
+ if((generalInfo & COMPUTE_SUBTYPES) != 0) {
+ typeHierarchy.computeSubtypes = true;
+ }
+
+ byte b;
+ byte[] bytes;
+
+ // read project
+ bytes = readUntil(input, SEPARATOR1);
+ if(bytes.length > 0) {
+ typeHierarchy.project = (IJavaProject)JavaCore.create(new String(bytes));
+ typeHierarchy.scope = SearchEngine.createJavaSearchScope(new IJavaElement[] {typeHierarchy.project});
+ } else {
+ typeHierarchy.project = null;
+ typeHierarchy.scope = SearchEngine.createWorkspaceScope();
+ }
+
+ // read missing type
+ {
+ bytes = readUntil(input, SEPARATOR1);
+ byte[] missing;
+ int j = 0;
+ int length = bytes.length;
+ for (int i = 0; i < length; i++) {
+ b = bytes[i];
+ if(b == SEPARATOR2) {
+ missing = new byte[i - j];
+ System.arraycopy(bytes, j, missing, 0, i - j);
+ typeHierarchy.missingTypes.add(new String(missing));
+ j = i + 1;
+ }
+ }
+ System.arraycopy(bytes, j, missing = new byte[length - j], 0, length - j);
+ typeHierarchy.missingTypes.add(new String(missing));
+ }
+
+ // read types
+ while((b = (byte)input.read()) != SEPARATOR1 && b != -1) {
+ bytes = readUntil(input, SEPARATOR4, 1);
+ bytes[0] = b;
+ IType element = (IType)JavaCore.create(new String(bytes));
+
+ if(types.length == typeCount) {
+ System.arraycopy(types, 0, types = new IType[typeCount * 2], 0, typeCount);
+ }
+ types[typeCount++] = element;
+
+ // read flags
+ bytes = readUntil(input, SEPARATOR4);
+ Integer flags = bytesToFlags(bytes);
+ if(flags != null) {
+ typeHierarchy.cacheFlags(element, flags.intValue());
+ }
+
+ // read info
+ byte info = (byte)input.read();
+
+ if((info & INTERFACE) != 0) {
+ typeHierarchy.addInterface(element);
+ }
+ if((info & COMPUTED_FOR) != 0) {
+ if(!element.equals(type)) {
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatus.ERROR));
+ }
+ typeHierarchy.type = element;
+ }
+ if((info & ROOT) != 0) {
+ typeHierarchy.addRootClass(element);
+ }
+ }
+
+ // read super class
+ while((b = (byte)input.read()) != SEPARATOR1 && b != -1) {
+ bytes = readUntil(input, SEPARATOR3, 1);
+ bytes[0] = b;
+ int subClass = new Integer(new String(bytes)).intValue();
+
+ // read super type
+ bytes = readUntil(input, SEPARATOR1);
+ int superClass = new Integer(new String(bytes)).intValue();
+
+ typeHierarchy.cacheSuperclass(
+ types[subClass],
+ types[superClass]);
+ }
+
+ // read super interface
+ while((b = (byte)input.read()) != SEPARATOR1 && b != -1) {
+ bytes = readUntil(input, SEPARATOR3, 1);
+ bytes[0] = b;
+ int subClass = new Integer(new String(bytes)).intValue();
+
+ // read super interface
+ bytes = readUntil(input, SEPARATOR1);
+ IType[] superInterfaces = new IType[(bytes.length / 2) + 1];
+ int interfaceCount = 0;
+
+ int j = 0;
+ byte[] b2;
+ for (int i = 0; i < bytes.length; i++) {
+ if(bytes[i] == SEPARATOR2){
+ b2 = new byte[i - j];
+ System.arraycopy(bytes, j, b2, 0, i - j);
+ j = i + 1;
+ superInterfaces[interfaceCount++] = types[new Integer(new String(b2)).intValue()];
+ }
+ }
+ b2 = new byte[bytes.length - j];
+ System.arraycopy(bytes, j, b2, 0, bytes.length - j);
+ superInterfaces[interfaceCount++] = types[new Integer(new String(b2)).intValue()];
+ System.arraycopy(superInterfaces, 0, superInterfaces = new IType[interfaceCount], 0, interfaceCount);
+
+ typeHierarchy.cacheSuperInterfaces(
+ types[subClass],
+ superInterfaces);
+ }
+ if(b == -1) {
+ throw new JavaModelException(new JavaModelStatus(IJavaModelStatus.ERROR));
+ }
+ return typeHierarchy;
+ } catch(IOException e){
+ throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
+ }
+}
/**
* Returns <code>true</code> if an equivalent package fragment is included in the package
* region. Package fragments are equivalent if they both have the same name.
@@ -1123,7 +1347,11 @@
}
this.progressMonitor = monitor;
if (monitor != null) {
- monitor.beginTask(Util.bind("hierarchy.creating"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ if (this.type != null) {
+ monitor.beginTask(Util.bind("hierarchy.creatingOnType", type.getFullyQualifiedName()), 100); //$NON-NLS-1$
+ } else {
+ monitor.beginTask(Util.bind("hierarchy.creating"), 100); //$NON-NLS-1$
+ }
}
long start = -1;
if (DEBUG) {
@@ -1142,10 +1370,6 @@
activate();
this.changeListeners = listeners;
}
- if (monitor != null) {
- monitor.done();
- }
- this.progressMonitor = null;
if (DEBUG) {
if (this.computeSubtypes) {
System.out.println("CREATED TYPE HIERARCHY in " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -1162,6 +1386,11 @@
throw new JavaModelException(e);
} catch (OperationCanceledException oce) {
refreshCancelled(oce);
+ } finally {
+ if (monitor != null) {
+ monitor.done();
+ }
+ this.progressMonitor = null;
}
}
/**
@@ -1187,6 +1416,140 @@
}
}
/**
+ * @see ITypeHierarchy
+ */
+public void store(OutputStream output, IProgressMonitor monitor) throws JavaModelException {
+ try {
+ // compute types in hierarchy
+ Hashtable hashtable = new Hashtable();
+ Hashtable hashtable2 = new Hashtable();
+ int count = 0;
+
+ if(type != null) {
+ Integer index = new Integer(count++);
+ hashtable.put(type, index);
+ hashtable2.put(index, type);
+ }
+ Object[] types = classToSuperclass.keySet().toArray();
+ for (int i = 0; i < types.length; i++) {
+ Object t = types[i];
+ if(hashtable.get(t) == null) {
+ Integer index = new Integer(count++);
+ hashtable.put(t, index);
+ hashtable2.put(index, t);
+ }
+ Object superClass = classToSuperclass.get(t);
+ if(superClass != null && hashtable.get(superClass) == null) {
+ Integer index = new Integer(count++);
+ hashtable.put(superClass, index);
+ hashtable2.put(index, superClass);
+ }
+ }
+ types = typeToSuperInterfaces.keySet().toArray();
+ for (int i = 0; i < types.length; i++) {
+ Object t = types[i];
+ if(hashtable.get(t) == null) {
+ Integer index = new Integer(count++);
+ hashtable.put(t, index);
+ hashtable2.put(index, t);
+ }
+ Object[] sp = (Object[])typeToSuperInterfaces.get(t);
+ if(sp != null) {
+ for (int j = 0; j < sp.length; j++) {
+ Object superInterface = sp[j];
+ if(sp[j] != null && hashtable.get(superInterface) == null) {
+ Integer index = new Integer(count++);
+ hashtable.put(superInterface, index);
+ hashtable2.put(index, superInterface);
+ }
+ }
+ }
+ }
+ // save version of the hierarchy format
+ output.write(VERSION);
+
+ // save general info
+ byte generalInfo = 0;
+ if(computeSubtypes) {
+ generalInfo |= COMPUTE_SUBTYPES;
+ }
+ output.write(generalInfo);
+
+ // save project
+ if(project != null) {
+ output.write(project.getHandleIdentifier().getBytes());
+ }
+ output.write(SEPARATOR1);
+
+ // save missing types
+ for (int i = 0; i < missingTypes.size(); i++) {
+ if(i != 0) {
+ output.write(SEPARATOR2);
+ }
+ output.write(((String)missingTypes.get(i)).getBytes());
+
+ }
+ output.write(SEPARATOR1);
+
+ // save types
+ for (int i = 0; i < count ; i++) {
+ IType t = (IType)hashtable2.get(new Integer(i));
+
+ // n bytes
+ output.write(t.getHandleIdentifier().getBytes());
+ output.write(SEPARATOR4);
+ output.write(flagsToBytes((Integer)typeFlags.get(t)));
+ output.write(SEPARATOR4);
+ byte info = CLASS;
+ if(type != null && type.equals(t)) {
+ info |= COMPUTED_FOR;
+ }
+ if(interfaces.contains(t)) {
+ info |= INTERFACE;
+ }
+ if(rootClasses.contains(t)) {
+ info |= ROOT;
+ }
+ output.write(info);
+ }
+ output.write(SEPARATOR1);
+
+ // save superclasses
+ types = classToSuperclass.keySet().toArray();
+ for (int i = 0; i < types.length; i++) {
+ IJavaElement key = (IJavaElement)types[i];
+ IJavaElement value = (IJavaElement)classToSuperclass.get(key);
+
+ output.write(((Integer)hashtable.get(key)).toString().getBytes());
+ output.write('>');
+ output.write(((Integer)hashtable.get(value)).toString().getBytes());
+ output.write(SEPARATOR1);
+ }
+ output.write(SEPARATOR1);
+
+ // save superinterfaces
+ types = typeToSuperInterfaces.keySet().toArray();
+ for (int i = 0; i < types.length; i++) {
+ IJavaElement key = (IJavaElement)types[i];
+ IJavaElement[] values = (IJavaElement[])typeToSuperInterfaces.get(key);
+
+ if(values.length > 0) {
+ output.write(((Integer)hashtable.get(key)).toString().getBytes());
+ output.write(SEPARATOR3);
+ for (int j = 0; j < values.length; j++) {
+ IJavaElement value = values[j];
+ if(j != 0) output.write(SEPARATOR2);
+ output.write(((Integer)hashtable.get(value)).toString().getBytes());
+ }
+ output.write(SEPARATOR1);
+ }
+ }
+ output.write(SEPARATOR1);
+ } catch(IOException e) {
+ throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
+ }
+}
+/**
* Returns whether the simple name of a supertype of the given type is
* the simple name of one of the subtypes in this hierarchy or the
* simple name of this type.
@@ -1260,6 +1623,9 @@
IType type = roots[i];
toString(buffer, type, 1, false);
}
+ } else if (this.rootClasses.size == 0) {
+ // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=24691
+ buffer.append("No root classes"); //$NON-NLS-1$
}
} else {
buffer.append("(Hierarchy became stale)"); //$NON-NLS-1$
@@ -1308,5 +1674,4 @@
checkCanceled();
}
}
-
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/AbstractDOMBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/AbstractDOMBuilder.java
index 56e6b99..b3fbba5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/AbstractDOMBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/AbstractDOMBuilder.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import java.util.Stack;
@@ -116,7 +116,7 @@
/**
* Does nothing.
*/
-public void acceptProblem(IProblem problem) {}
+public void acceptProblem(IProblem problem) {} //TODO: (olivier) unused?
/**
* Adds the given node to the current enclosing scope, building the JDOM
* tree. Nodes are only added to an enclosing scope when a compilation unit or type
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/CompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/CompilationUnit.java
index 705875e..225874c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/CompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/CompilationUnit.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMBuilder.java
index 67acd61..d53054a 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMBuilder.java
@@ -1,27 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import java.util.ArrayList;
+import java.util.Map;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.compiler.IProblem;
-import org.eclipse.jdt.core.jdom.IDOMCompilationUnit;
-import org.eclipse.jdt.core.jdom.IDOMField;
-import org.eclipse.jdt.core.jdom.IDOMImport;
-import org.eclipse.jdt.core.jdom.IDOMInitializer;
-import org.eclipse.jdt.core.jdom.IDOMMethod;
-import org.eclipse.jdt.core.jdom.IDOMNode;
-import org.eclipse.jdt.core.jdom.IDOMPackage;
-import org.eclipse.jdt.core.jdom.IDOMType;
+import org.eclipse.jdt.core.jdom.*;
import org.eclipse.jdt.internal.compiler.DocumentElementParser;
import org.eclipse.jdt.internal.compiler.IDocumentElementRequestor;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
@@ -56,6 +50,7 @@
*/
protected ArrayList fFields;
+ Map options = JavaCore.getOptions();
/**
* Creates a new DOMBuilder
@@ -154,7 +149,7 @@
*/
public IDOMCompilationUnit createCompilationUnit(ICompilationUnit compilationUnit) {
initializeBuild(compilationUnit.getContents(), true, true, false);
- getParser().parseCompilationUnit(compilationUnit);
+ getParser(options).parseCompilationUnit(compilationUnit);
return super.createCompilationUnit(compilationUnit);
}
/**
@@ -162,7 +157,7 @@
*/
public IDOMField createField(char[] sourceCode) {
initializeBuild(sourceCode, false, false, true);
- getParser().parseField(sourceCode);
+ getParser(options).parseField(sourceCode);
if (fAbort || fNode == null) {
return null;
}
@@ -181,7 +176,7 @@
public IDOMField[] createFields(char[] sourceCode) {
initializeBuild(sourceCode, false, false, false);
fFields= new ArrayList();
- getParser().parseField(sourceCode);
+ getParser(options).parseField(sourceCode);
if (fAbort) {
return null;
}
@@ -209,7 +204,7 @@
*/
public IDOMImport createImport(char[] sourceCode) {
initializeBuild(sourceCode, false, false, true);
- getParser().parseImport(sourceCode);
+ getParser(options).parseImport(sourceCode);
if (fAbort || fNode == null) {
return null;
}
@@ -223,7 +218,7 @@
*/
public IDOMInitializer createInitializer(char[] sourceCode) {
initializeBuild(sourceCode, false, false, true);
- getParser().parseInitializer(sourceCode);
+ getParser(options).parseInitializer(sourceCode);
if (fAbort || fNode == null || !(fNode instanceof IDOMInitializer)) {
return null;
}
@@ -235,7 +230,7 @@
*/
public IDOMMethod createMethod(char[] sourceCode) {
initializeBuild(sourceCode, false, false, true);
- getParser().parseMethod(sourceCode);
+ getParser(options).parseMethod(sourceCode);
if (fAbort || fNode == null) {
return null;
}
@@ -253,7 +248,7 @@
*/
public IDOMPackage createPackage(char[] sourceCode) {
initializeBuild(sourceCode, false, false, true);
- getParser().parsePackage(sourceCode);
+ getParser(options).parsePackage(sourceCode);
if (fAbort || fNode == null) {
return null;
}
@@ -265,7 +260,7 @@
*/
public IDOMType createType(char[] sourceCode) {
initializeBuild(sourceCode, false, true, false);
- getParser().parseType(sourceCode);
+ getParser(options).parseType(sourceCode);
if (fAbort) {
return null;
}
@@ -690,8 +685,8 @@
/**
* Creates a new parser.
*/
-protected DocumentElementParser getParser() {
- return new DocumentElementParser(this, new DefaultProblemFactory(), new CompilerOptions(JavaCore.getOptions()));
+protected DocumentElementParser getParser(Map settings) {
+ return new DocumentElementParser(this, new DefaultProblemFactory(), new CompilerOptions(settings));
}
/**
* Initializes the builder to create a document fragment.
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMCompilationUnit.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMCompilationUnit.java
index 48522ad..ce87f38 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMCompilationUnit.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMCompilationUnit.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import org.eclipse.jdt.core.Flags;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMField.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMField.java
index fb9853e..81f0637 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMField.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMField.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import java.util.Enumeration;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMImport.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMImport.java
index 2079f29..6278d94 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMImport.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMImport.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import org.eclipse.jdt.core.ICompilationUnit;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMInitializer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMInitializer.java
index d70d43f..0422b25 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMInitializer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMInitializer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import org.eclipse.jdt.core.IJavaElement;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMember.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMember.java
index 6d645eb..f983b7c 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMember.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMember.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import org.eclipse.jdt.core.Flags;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java
index cdd4405..c3897fa 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMMethod.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import org.eclipse.jdt.core.IJavaElement;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java
index 2569598..31eb0d6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMNode.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import java.util.Enumeration;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMPackage.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMPackage.java
index 4a1633a..870cbc2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMPackage.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMPackage.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import org.eclipse.jdt.core.ICompilationUnit;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMType.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMType.java
index e91e4cf..d5cb508 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMType.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/DOMType.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import java.util.Enumeration;
@@ -15,12 +15,12 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.core.jdom.IDOMMethod;
import org.eclipse.jdt.core.jdom.IDOMNode;
import org.eclipse.jdt.core.jdom.IDOMType;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
import org.eclipse.jdt.internal.core.Util;
import org.eclipse.jdt.internal.core.util.CharArrayBuffer;
import org.eclipse.jdt.internal.core.util.CharArrayOps;
@@ -475,11 +475,11 @@
try {
int currentToken = scanner.getNextToken();
- while(currentToken != ITerminalSymbols.TokenNameLBRACE &&
- currentToken != ITerminalSymbols.TokenNameEOF) {
+ while(currentToken != TerminalTokens.TokenNameLBRACE &&
+ currentToken != TerminalTokens.TokenNameEOF) {
currentToken = scanner.getNextToken();
}
- if(currentToken == ITerminalSymbols.TokenNameLBRACE) {
+ if(currentToken == TerminalTokens.TokenNameLBRACE) {
openBodyEnd = scanner.currentPosition - 1;
openBodyStart = scanner.startPosition;
} else {
@@ -509,11 +509,11 @@
scanner.resetTo(lastNode.getEndPosition() + 1, fDocument.length);
try {
int currentToken = scanner.getNextToken();
- while(currentToken != ITerminalSymbols.TokenNameRBRACE &&
- currentToken != ITerminalSymbols.TokenNameEOF) {
+ while(currentToken != TerminalTokens.TokenNameRBRACE &&
+ currentToken != TerminalTokens.TokenNameEOF) {
currentToken = scanner.getNextToken();
}
- if(currentToken == ITerminalSymbols.TokenNameRBRACE) {
+ if(currentToken == TerminalTokens.TokenNameRBRACE) {
closeBodyStart = scanner.startPosition;
closeBodyEnd = scanner.currentPosition - 1;
} else {
@@ -528,11 +528,11 @@
scanner.resetTo(openBodyEnd, fDocument.length);
try {
int currentToken = scanner.getNextToken();
- while(currentToken != ITerminalSymbols.TokenNameRBRACE &&
- currentToken != ITerminalSymbols.TokenNameEOF) {
+ while(currentToken != TerminalTokens.TokenNameRBRACE &&
+ currentToken != TerminalTokens.TokenNameEOF) {
currentToken = scanner.getNextToken();
}
- if(currentToken == ITerminalSymbols.TokenNameRBRACE) {
+ if(currentToken == TerminalTokens.TokenNameRBRACE) {
closeBodyStart = scanner.startPosition;
closeBodyEnd = scanner.currentPosition - 1;
} else {
@@ -553,7 +553,7 @@
if (lastNode != null && fInsertionPosition < lastNode.getEndPosition()) {
fInsertionPosition = getCloseBodyPosition();
}
- if (fInsertionPosition < openBodyEnd) {
+ if (fInsertionPosition <= openBodyEnd) {
fInsertionPosition = getCloseBodyPosition();
}
super.normalize(finder);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/ILineStartFinder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/ILineStartFinder.java
index 67b1faf..4e9da50 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/ILineStartFinder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/ILineStartFinder.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SiblingEnumeration.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SiblingEnumeration.java
index 4e8f9ec..62ed3bc 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SiblingEnumeration.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SiblingEnumeration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
import java.util.Enumeration;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java
index b058022..8fe0627 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java
@@ -1,15 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.jdom;
+import java.util.Map;
+
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.jdom.IDOMCompilationUnit;
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
@@ -50,7 +52,7 @@
*/
public IDOMCompilationUnit createCompilationUnit(ICompilationUnit compilationUnit) {
initializeBuild(compilationUnit.getContents(), true, true);
- getParser().parseCompilationUnit(compilationUnit, false);
+ getParser(JavaCore.getOptions()).parseCompilationUnit(compilationUnit, false);
return super.createCompilationUnit(compilationUnit);
}
/**
@@ -170,7 +172,7 @@
}
/**
*/
-public void exitField(int declarationEnd) {
+public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
exitMember(declarationEnd);
}
/**
@@ -211,7 +213,7 @@
/**
* Creates a new parser.
*/
-protected SourceElementParser getParser() {
- return new SourceElementParser(this, new DefaultProblemFactory(), new CompilerOptions(JavaCore.getOptions()));
+protected SourceElementParser getParser(Map settings) {
+ return new SourceElementParser(this, new DefaultProblemFactory(), new CompilerOptions(settings));
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/messages.properties b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/messages.properties
index 66b54c6..347a008 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/messages.properties
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/messages.properties
@@ -1,15 +1,21 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
### JavaModel messages.
-### assertion
-assert.nullArgument = null argument; {0}
-assert.failed = Assertion failed; {0}.
-assert.shouldNotImplement = Should not be called
-
### hierarchy
hierarchy.nullProject = Project argument cannot be null.
hierarchy.nullRegion = Region cannot be null.
hierarchy.nullFocusType = Type focus cannot be null.
hierarchy.creating = Creating type hierarchy...
+hierarchy.creatingOnType = Creating type hierarchy on {0}...
### java element
element.doesNotExist = {0} does not exist.
@@ -21,7 +27,6 @@
element.classpathCycle = A cycle was detected in the project''s classpath.
element.onlyOneJavaModel = Cannot instantiate more than one Java Model.
element.projectDoesNotExist = Project {0} not present
-element.cannotLocate = Failed to locate {0} in {1}
element.invalidResourceForProject = Illegal argument - must be one of IProject, IFolder, or IFile
element.nullName = Name cannot be null.
element.nullType = Type cannot be null.
@@ -32,7 +37,7 @@
operation.needElements = Operation requires one or more elements.
operation.needName = Operation requires a name.
operation.needPath = Operation requires a path.
-operation.needAbsolutePath = Operation requires an absolute path. Relative path specified was: {0}
+operation.needAbsolutePath = Operation requires an absolute path. Relative path specified was: ''{0}''
operation.needString = Operation requires a String.
operation.notSupported = Operation not supported for specified element type(s):
operation.cancelled = Operation cancelled.
@@ -55,117 +60,112 @@
operation.deleteElementProgress = Deleting elements...
operation.deleteResourceProgress = Deleting resources...
operation.cannotRenameDefaultPackage = Default package cannot be renamed.
-operation.pathOutsideProject = Path {0} must denote location inside project {1}
+operation.pathOutsideProject = Path ''{0}'' must denote location inside project {1}
+operation.sortelements = Sorting elements...
### working copy
workingCopy.commit = Committing working copy...
-### build
-build.readStateProgress = Reading saved built state for project {0}.
-build.saveStateProgress = Saving built state for project {0}.
+### build status messages
+build.preparingBuild = Preparing for build
+build.readStateProgress = Reading saved built state for project {0}
+build.saveStateProgress = Saving built state for project {0}
build.saveStateComplete = Saved in {0} ms
+build.readingDelta = Reading resource change information for {0}
+build.analyzingDeltas = Analyzing deltas
+build.analyzingSources = Analyzing sources
+build.cleaningOutput = Cleaning output folder
+build.copyingResources = Copying resources to the output folder
+build.compiling = Compiling {0}
+build.foundHeader = Found
+build.fixedHeader = Fixed
+build.oneError = 1 error
+build.oneWarning = 1 warning
+build.multipleErrors = {0} errors
+build.multipleWarnings = {0} warnings
+build.done = Build done
+
+### build errors
build.wrongFileFormat = Wrong file format.
-build.unhandledVersionFormat = Unhandled version of file format.
-build.cannotRestoreState = Failed to restore state
build.cannotSaveState = Error saving last build state for project {0}.
-build.cannotSaveStates = Error saving builder states
+build.cannotSaveStates = Error saving build states.
build.initializationError = Builder initialization error.
build.serializationError = Builder serialization error.
-build.analyzingPackages = Analyzing packages
-build.analyzingSources = Analyzing sources
-build.analyzingDeltas = Analyzing deltas
-build.analyzing = Analyzing {0}
-build.preparingBuild = Preparing for build
-build.compiling = Compiling {0}
-build.readingDelta = Reading resource change information for {0}
-build.completed = Java build completed
-build.builderName = Java Builder
-build.compilingContent = Compiling content of {0}
-build.scrubbingOutput = Scrubbing output folder
-build.duplicateType = Type {0} already provided by {1}
-build.errorParsingBinary = Error parsing class file for {0}
-build.packageMismatch = Package declaration does not match folder. Expected folder is {0}.
-build.errorBuildingType = Unable to build type {0}.
-build.missingFile = Missing file for {0}
-build.beginBatch = Begin batch build
-build.beginIncremental = Begin incremental build
-build.done = Build done.
-build.endBatch = End batch build
-build.endIncremental = End incremental build
-build.oneProblemFound = {0} problem found
-build.problemsFound = {0} problems found
-build.oneProblemFixed = {0} problem fixed
-build.problemsFixed = {0} problems fixed
-build.packageName = package {0}
-build.defaultPackageName = default package for {0}
-build.noPackagePath = Attempt to access packages for non-existent path: {0}
-build.ambiguousPackage = Didn''t get exactly one package for {0}
-build.copyingResources = Copying all resources on the classpath
-build.updatingResources = Updating resources on the classpath
### build inconsistencies
-build.duplicateClassFile = The type {0} is already defined
-build.duplicateResource = This resource is a duplicate and was not copied to the output folder
-build.inconsistentClassFile = A class file was not written. The project may be inconsistent, if so try refreshing this project and rebuilding it
-build.inconsistentProject = The project was not built. It may be inconsistent, if so ensure no other tool is browsing the output directory, then try refreshing this project and rebuilding it
-build.incompleteClassPath = The project was not built since its classpath is incomplete. Can not find the class file for {0}. Fix the classpath then try rebuilding this project
+build.duplicateClassFile = The type {0} is already defined.
+build.duplicateResource = The resource is a duplicate and was not copied to the output folder.
+build.inconsistentClassFile = A class file was not written. The project may be inconsistent, if so try refreshing this project and rebuilding it.
+build.inconsistentProject = The project was not built due to "{0}". Fix the problem, then try refreshing this project and rebuilding it since it may be inconsistent.
+build.incompleteClassPath = The project was not built since its classpath is incomplete. Cannot find the class file for {0}. Fix the classpath then try rebuilding this project.
build.missingSourceFile = The project was not built since the source file {0} could not be read.
-build.prereqProjectWasNotBuilt = The project was not built since it depends on {0}, which failed to build.
-build.abortDueToClasspathProblems = The project was not built since it is involved in a cycle or has classpath problems.
+build.prereqProjectHasClasspathProblems = The project was not built since it depends on {0}, which has classpath problems.
+build.prereqProjectMustBeRebuilt = The project cannot be built until {0} is rebuilt. Rebuilding all projects is recommended.
+build.abortDueToClasspathProblems = The project was not built due to classpath errors (incomplete or involved in cycle).
### status
-status.coreException = Core exception.
-status.IOException = I/O exception.
-status.targetException = Target exception.
status.cannotUseDeviceOnPath = Operation requires a path with no device. Path specified was: {0}
-status.JDOMError = JDOM error.
-status.indexOutOfBounds = Index out of bounds.
+status.coreException = Core exception.
+status.defaultPackeReadOnly = Default package is read-only.
status.evaluationError = Evaluation error: {0}.
+status.JDOMError = JDOM error.
+status.IOException = I/O exception.
+status.indexOutOfBounds = Index out of bounds.
status.invalidContents = Invalid contents specified.
-status.invalidDestination = Invalid destination: {0}.
+status.invalidDestination = Invalid destination: ''{0}''.
status.invalidName = Invalid name specified: {0}.
status.invalidPackage = Invalid package: {0}.
-status.invalidPath = Invalid path: {0}.
+status.invalidPath = Invalid path: ''{0}''.
status.invalidProject = Invalid project: {0}.
status.invalidResource = Invalid resource: {0}.
status.invalidResourceType = Invalid resource type for {0}.
status.invalidSibling = Invalid sibling: {0}.
-status.nameCollision = Name collision.
-status.defaultPackeReadOnly = Default package is read-only.
-status.readOnly = {0} is read-only.
-status.updateConflict = Update conflict.
+status.nameCollision = {0} already exists in target.
status.noLocalContents = Cannot find local contents for resource: {0}
+status.OK = OK
+status.readOnly = {0} is read-only.
+status.targetException = Target exception.
+status.updateConflict = Update conflict.
### classpath
-classpath.cycle = A cycle was detected in the project''s classpath.
classpath.buildPath = Build path
-classpath.cannotNestEntryInEntry = Cannot nest entry {0} inside entry {1}.
-classpath.cannotNestEntryInOutput = Cannot nest entry {0} inside output location {1}.
-classpath.cannotNestOutputInEntry = Cannot nest output location {0} inside entry {1}.
-classpath.duplicateEntryPath = Classpath contains duplicate entry: {0}
+classpath.cannotNestEntryInEntry = Cannot nest ''{0}'' inside ''{1}''. To enable the nesting exclude ''{2}'' from ''{1}''.
+classpath.cannotNestEntryInLibrary = Cannot nest ''{0}'' inside library ''{1}''.
+classpath.cannotNestEntryInOutput = Cannot nest ''{0}'' inside output folder ''{1}''.
+classpath.cannotNestOutputInEntry = Cannot nest output folder ''{0}'' inside ''{1}''.
+classpath.cannotNestOutputInOutput = Cannot nest output folder ''{0}'' inside output folder ''{1}''.
+classpath.cannotReadClasspathFile = Unable to read ''{0}/.classpath'' file.
classpath.cannotReferToItself = Project cannot reference itself: {0}
-classpath.unboundContainerPath = Unbound classpath container path: {0}.
-classpath.illegalContainerPath = Illegal classpath container path: {0}, must have at least one segment (containerID+hints).
-classpath.unboundVariablePath = Unbound classpath variable path: {0}.
-classpath.illegalVariablePath = Illegal classpath variable path: {0}, must have at least one segment.
-classpath.nullVariablePath = Variable path cannot be null.
-classpath.mismatchNamePath = Variable names and paths collections should have the same size.
-classpath.mismatchProjectsContainers = Projects and containers collections should have the same size.
-classpath.unboundSourceAttachment = Invalid source attachment: {0} for required library {1}.
-classpath.unboundLibrary = Missing required library: {0}.
-classpath.illegalLibraryPath = Illegal path for required library: {0}.
-classpath.unboundProject = Missing required Java project: {0}.
+classpath.cannotUseDistinctSourceFolderAsOutput = Source folder ''{0}'' cannot output to distinct source folder ''{1}''.
+classpath.cannotUseLibraryAsOutput = Source folder ''{0}'' cannot output to library ''{1}''.
classpath.closedProject = Required project: {0} needs to be open.
-classpath.illegalProjectPath = Illegal path for required project: {0}.
-classpath.unboundSourceFolder = Missing required source folder: {0}.
-classpath.illegalSourceFolderPath = Illegal path for required source folder: {0}.
+classpath.couldNotWriteClasspathFile = Could not write ''{0}/.classpath'': {1}
+classpath.cycle = A cycle was detected in the classpath of project: {0}
+classpath.duplicateEntryPath = Classpath contains duplicate entry: {0}
+classpath.illegalContainerPath = Illegal classpath container path: ''{0}'', must have at least one segment (containerID+hints).
+classpath.illegalEntryInClasspathFile = Illegal entry in ''{0}/.classpath'' file: {1}
+classpath.illegalLibraryPath = Illegal path for required library: ''{0}''.
+classpath.illegalProjectPath = Illegal path for required project: ''{0}''.
+classpath.illegalSourceFolderPath = Illegal path for required source folder: ''{0}''.
+classpath.illegalVariablePath = Illegal classpath variable path: ''{0}'', must have at least one segment.
+classpath.invalidClasspathInClasspathFile = Invalid classpath in ''{0}/.classpath'' file: {1}
+classpath.invalidContainer = Invalid classpath container: {0}
+classpath.mustEndWithSlash = End exclusion filter ''{0}'' with / to fully exclude ''{1}''.
+classpath.unboundContainerPath = Unbound classpath container: ''{0}''.
+classpath.unboundLibrary = Missing required library: ''{0}''.
+classpath.unboundProject = Missing required Java project: {0}.
+classpath.settingOutputLocationProgress = Setting output location for: ''{0}''
classpath.settingProgress = Setting classpath for: {0}
-classpath.settingOutputLocationProgress = Setting output location for: {0}
-classpath.needAbsolutePath = Path for IClasspathEntry must be absolute.
-classpath.cannotReadClasspathFile = Unable to read {0}/.classpath file.
+classpath.unboundSourceAttachment = Invalid source attachment: ''{0}'' for required library ''{1}''.
+classpath.unboundSourceFolder = Missing required source folder: ''{0}''.
+classpath.unboundVariablePath = Unbound classpath variable: ''{0}''.
+classpath.unknownKind = Unknown kind: {0}
+classpath.xmlFormatError = XML format error in ''{0}/.classpath'' file: {1}
+classpath.disabledExclusionPatterns = Exclusion patterns are disabled, cannot exclude from entry: ''{0}''.
+classpath.disabledMultipleOutputLocations = Multiple output locations are disabled, cannot associate entry: ''{0}'' with a specific output.
### miscellaneous
-file.notFound = File not found.
+file.notFound = File not found: ''{0}''.
file.badFormat = Bad format.
variable.badFormat = Bad format for variables.
option.badFormat = Bad format for options.
@@ -181,14 +181,14 @@
convention.unit.notJavaName = Compilation unit name must end with .java.
convention.classFile.nullName = .class file name must not be null.
convention.classFile.notJavaName = .class file name must end with .class.
-convention.illegalIdentifier = {0} is not a valid Java identifier.
+convention.illegalIdentifier = ''{0}'' is not a valid Java identifier.
convention.import.nullImport = An import declaration must not be null.
convention.import.unqualifiedImport = An import declaration must not end with an unqualified *.
convention.type.nullName = A Java type name must not be null.
convention.type.nameWithBlanks = A Java type name must not start or end with a blank.
convention.type.dollarName = By convention, Java type names usually don''t contain the $ character.
convention.type.lowercaseName = By convention, Java type names usually start with an uppercase letter.
-convention.type.invalidName = The type name {0} is not a valid identifier.
+convention.type.invalidName = The type name ''{0}'' is not a valid identifier.
convention.package.nullName = A package name must not be null.
convention.package.emptyName = A package name must not be empty.
convention.package.dotName = A package name cannot start or end with a dot.
@@ -226,4 +226,7 @@
### JDT Adapter
ant.jdtadapter.info.usingJdtCompiler = Using JDT compiler
ant.jdtadapter.error.missingJDTCompiler = Cannot find the JDT compiler
-ant.jdtadapter.error.missingJRELIB = Cannot bind the JRE_LIB variable. To solve this problem, you can either set the JRE_LIB variable or use the bootclasspath parameter in your ant javac task
\ No newline at end of file
+ant.jdtadapter.error.missingJRELIB = Cannot bind the JRE_LIB variable. To solve this problem, you can either set the JRE_LIB variable or use the bootclasspath parameter in your ant javac task
+ant.jdtadapter.error.ignoringMemoryInitialSize= Since fork is false, ignoring memoryInitialSize setting
+ant.jdtadapter.error.ignoringMemoryMaximumSize= Since fork is false, ignoring memoryMaximumSize setting
+ant.jdtadapter.error.compilationFailed = Compilation failed. Compiler errors are available in {0}
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnonymousFileSource.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnonymousFileSource.java
index e8aba02..f65fdf5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnonymousFileSource.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/AnonymousFileSource.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import java.io.File;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CharArrayBuffer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CharArrayBuffer.java
index c843b24..ed8bb41 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CharArrayBuffer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CharArrayBuffer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
/**
@@ -112,16 +112,12 @@
* @throws ArrayIndexOutOfBoundsException - if arguments specify an array index out of bounds.
*/
public CharArrayBuffer append(char[] src, int start, int length) {
- if (start < 0)
- throw new ArrayIndexOutOfBoundsException();
- if (length < 0)
- throw new ArrayIndexOutOfBoundsException();
+ if (start < 0) throw new ArrayIndexOutOfBoundsException();
+ if (length < 0) throw new ArrayIndexOutOfBoundsException();
if (src != null) {
int srcLength = src.length;
- if (start > srcLength)
- throw new ArrayIndexOutOfBoundsException();
- if (length + start > srcLength)
- throw new ArrayIndexOutOfBoundsException();
+ if (start > srcLength) throw new ArrayIndexOutOfBoundsException();
+ if (length + start > srcLength) throw new ArrayIndexOutOfBoundsException();
/** do length check here to allow exceptions to be thrown */
if (length > 0) {
if (fEnd == fSize) {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CharArrayOps.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CharArrayOps.java
index 1fcbe9d..2ab34c5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CharArrayOps.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CharArrayOps.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileAttribute.java
index 5955848..f003e94 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileReader.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileReader.java
index 1e72a5a..ca800ef 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileReader.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileReader.java
@@ -1,18 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
/**
* Default implementation of IClassFileReader.
*/
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.util.ClassFormatException;
import org.eclipse.jdt.core.util.IAttributeNamesConstants;
import org.eclipse.jdt.core.util.IClassFileAttribute;
@@ -29,7 +30,7 @@
private static final IFieldInfo[] NO_FIELD_INFOS = new IFieldInfo[0];
private static final IMethodInfo[] NO_METHOD_INFOS = new IMethodInfo[0];
private static final int[] NO_INTERFACE_INDEXES = new int[0];
- private static final char[][] NO_INTERFACES_NAMES = new char[0][0];
+ private static final char[][] NO_INTERFACES_NAMES = CharOperation.NO_CHAR_CHAR;
private IConstantPool constantPool;
private int magicNumber;
@@ -51,7 +52,6 @@
private int majorVersion;
private int minorVersion;
private int superclassNameIndex;
- private int classIndex;
private int attributesCount;
private IClassFileAttribute[] attributes;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileStruct.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileStruct.java
index c2d5a6b..2ce66b4 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileStruct.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileStruct.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
/**
@@ -106,4 +106,4 @@
return false;
return true;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeAttribute.java
index 77d42a8..6bdd9b7 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPool.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPool.java
index a830f41..046b5ea 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPool.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPool.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.IConstantPool;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPoolEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPoolEntry.java
index 94cf7ed..eb5a010 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPoolEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPoolEntry.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.IConstantPoolEntry;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantValueAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantValueAttribute.java
index 9fbb7e4..b56e9f5 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantValueAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantValueAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java
index a6a6bc6..c29fdab 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java
@@ -1,29 +1,29 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.util.IBytecodeVisitor;
import org.eclipse.jdt.core.util.IConstantPoolConstant;
import org.eclipse.jdt.core.util.IConstantPoolEntry;
import org.eclipse.jdt.core.util.IOpcodeMnemonics;
import org.eclipse.jdt.core.util.OpcodeStringValues;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* Default implementation of ByteCodeVisitor
*/
public class DefaultBytecodeVisitor implements IBytecodeVisitor {
private static final char[] INIT = "<init>".toCharArray(); //$NON-NLS-1$
- private static final char[] EMPTY_NAME = new char[0];
+ private static final char[] EMPTY_NAME = CharOperation.NO_CHAR;
private static final int T_BOOLEAN = 4;
private static final int T_CHAR = 5;
private static final int T_FLOAT = 6;
@@ -1084,6 +1084,7 @@
.append(returnDeclaringClassName(constantFieldref))
.append(Util.bind("disassembler.classmemberseparator")) //$NON-NLS-1$
.append(constantFieldref.getFieldName())
+ .append(Util.bind("disassembler.space")) //$NON-NLS-1$
.append(returnFieldrefDescriptor(constantFieldref))
.append(Util.bind("classformat.getstaticclose")); //$NON-NLS-1$
writeNewLine();
@@ -1686,7 +1687,9 @@
char[] methodDescriptor = constantInterfaceMethodref.getMethodDescriptor();
CharOperation.replace(methodDescriptor, '/', '.');
-
+ char[] returnType = Signature.getReturnType(methodDescriptor);
+ CharOperation.replace(returnType, '/', '.');
+
writeTabs();
buffer
.append(pc)
@@ -1705,7 +1708,9 @@
constantInterfaceMethodref.getMethodName(),
getParameterNames(methodDescriptor),
true,
- true))
+ false))
+ .append(Util.bind("disassembler.space")) //$NON-NLS-1$
+ .append(Signature.toCharArray(returnType))
.append(Util.bind("classformat.invokeinterfacemethodclose")); //$NON-NLS-1$
writeNewLine();
}
@@ -1714,10 +1719,13 @@
* @see IBytecodeVisitor#_invokespecial(int, int, IConstantPoolEntry)
*/
public void _invokespecial(int pc, int index, IConstantPoolEntry constantMethodref) {
+
char[] methodDescriptor = constantMethodref.getMethodDescriptor();
CharOperation.replace(methodDescriptor, '/', '.');
char[] methodName = constantMethodref.getMethodName();
-
+ char[] returnType = Signature.getReturnType(methodDescriptor);
+ CharOperation.replace(returnType, '/', '.');
+
if (CharOperation.equals(INIT, methodName)) {
methodName = EMPTY_NAME;
writeTabs();
@@ -1739,12 +1747,11 @@
.append(Util.bind("classformat.invokespecialconstructorclose")); //$NON-NLS-1$
writeNewLine();
} else {
- methodName = EMPTY_NAME;
writeTabs();
buffer
.append(pc)
.append(Util.bind("disassembler.tab")) //$NON-NLS-1$
- .append(OpcodeStringValues.BYTECODE_NAMES[IOpcodeMnemonics.ALOAD_0])
+ .append(OpcodeStringValues.BYTECODE_NAMES[IOpcodeMnemonics.INVOKESPECIAL])
.append(Util.bind("disassembler.constantpoolindex")) //$NON-NLS-1$
.append(index)
.append(Util.bind("classformat.invokespecialmethod")) //$NON-NLS-1$
@@ -1753,10 +1760,12 @@
.append(
Signature.toCharArray(
methodDescriptor,
- methodName,
+ constantMethodref.getMethodName(),
getParameterNames(methodDescriptor),
true,
- true))
+ false))
+ .append(Util.bind("disassembler.space")) //$NON-NLS-1$
+ .append(Signature.toCharArray(returnType))
.append(Util.bind("classformat.invokespecialmethodclose")); //$NON-NLS-1$
writeNewLine();
}
@@ -1766,8 +1775,12 @@
* @see IBytecodeVisitor#_invokestatic(int, int, IConstantPoolEntry)
*/
public void _invokestatic(int pc, int index, IConstantPoolEntry constantMethodref) {
+
char[] methodDescriptor = constantMethodref.getMethodDescriptor();
CharOperation.replace(methodDescriptor, '/', '.');
+ char[] returnType = Signature.getReturnType(methodDescriptor);
+ CharOperation.replace(returnType, '/', '.');
+
writeTabs();
buffer
.append(pc)
@@ -1784,7 +1797,9 @@
constantMethodref.getMethodName(),
getParameterNames(methodDescriptor),
true,
- true))
+ false))
+ .append(Util.bind("disassembler.space")) //$NON-NLS-1$
+ .append(Signature.toCharArray(returnType))
.append(Util.bind("classformat.invokestaticmethodclose")); //$NON-NLS-1$
writeNewLine();
}
@@ -1793,8 +1808,12 @@
* @see IBytecodeVisitor#_invokevirtual(int, int, IConstantPoolEntry)
*/
public void _invokevirtual(int pc, int index, IConstantPoolEntry constantMethodref) {
+
char[] methodDescriptor = constantMethodref.getMethodDescriptor();
CharOperation.replace(methodDescriptor, '/', '.');
+ char[] returnType = Signature.getReturnType(methodDescriptor);
+ CharOperation.replace(returnType, '/', '.');
+
writeTabs();
buffer
.append(pc)
@@ -1811,7 +1830,9 @@
constantMethodref.getMethodName(),
getParameterNames(methodDescriptor),
true,
- true))
+ false))
+ .append(Util.bind("disassembler.space")) //$NON-NLS-1$
+ .append(Signature.toCharArray(returnType))
.append(Util.bind("classformat.invokevirtualmethodclose")); //$NON-NLS-1$
writeNewLine();
}
@@ -2301,15 +2322,15 @@
.append(pc)
.append(Util.bind("disassembler.tab")) //$NON-NLS-1$
.append(OpcodeStringValues.BYTECODE_NAMES[IOpcodeMnemonics.LOOKUPSWITCH])
- .append(Util.bind("classfileformat.default")) //$NON-NLS-1$
+ .append("default:") //$NON-NLS-1$
.append(defaultoffset + pc);
writeNewLine();
for (int i = 0; i < npairs; i++) {
writeExtraTabs(1);
buffer
- .append(Util.bind("classfileformat.case")) //$NON-NLS-1$
+ .append("case") //$NON-NLS-1$
.append(offset_pairs[i][0])
- .append(Util.bind("disassembler.colon")) //$NON-NLS-1$
+ .append(":") //$NON-NLS-1$
.append(offset_pairs[i][1] + pc);
writeNewLine();
}
@@ -2725,15 +2746,15 @@
.append(pc)
.append(Util.bind("disassembler.tab")) //$NON-NLS-1$
.append(OpcodeStringValues.BYTECODE_NAMES[IOpcodeMnemonics.TABLESWITCH])
- .append(Util.bind("classfileformat.default")) //$NON-NLS-1$
+ .append("default:") //$NON-NLS-1$
.append(defaultoffset + pc);
writeNewLine();
for (int i = low; i < high + 1; i++) {
writeExtraTabs(1);
buffer
- .append(Util.bind("classfileformat.case")) //$NON-NLS-1$
+ .append("case") //$NON-NLS-1$
.append(i)
- .append(Util.bind("disassembler.colon")) //$NON-NLS-1$
+ .append(":") //$NON-NLS-1$
.append(jump_offsets[i - low] + pc);
writeNewLine();
}
@@ -2843,28 +2864,28 @@
private void appendGetArrayType(int atype) {
switch(atype) {
case T_BOOLEAN :
- this.buffer.append(Util.bind("classfileformat.newarrayboolean")); //$NON-NLS-1$
+ this.buffer.append("boolean"); //$NON-NLS-1$
break;
case T_CHAR :
- this.buffer.append(Util.bind("classfileformat.newarraychar")); //$NON-NLS-1$
+ this.buffer.append("char"); //$NON-NLS-1$
break;
case T_FLOAT :
- this.buffer.append(Util.bind("classfileformat.newarrayfloat")); //$NON-NLS-1$
+ this.buffer.append("float"); //$NON-NLS-1$
break;
case T_DOUBLE :
- this.buffer.append(Util.bind("classfileformat.newarraydouble")); //$NON-NLS-1$
+ this.buffer.append("double"); //$NON-NLS-1$
break;
case T_BYTE :
- this.buffer.append(Util.bind("classfileformat.newarraybyte")); //$NON-NLS-1$
+ this.buffer.append("byte"); //$NON-NLS-1$
break;
case T_SHORT :
- this.buffer.append(Util.bind("classfileformat.newarrayshort")); //$NON-NLS-1$
+ this.buffer.append("short"); //$NON-NLS-1$
break;
case T_INT :
- this.buffer.append(Util.bind("classfileformat.newarrayint")); //$NON-NLS-1$
+ this.buffer.append("int"); //$NON-NLS-1$
break;
case T_LONG :
- this.buffer.append(Util.bind("classfileformat.newarraylong")); //$NON-NLS-1$
+ this.buffer.append("long"); //$NON-NLS-1$
}
}
@@ -2887,37 +2908,37 @@
private void appendOutputForConstantDouble(IConstantPoolEntry constantPoolEntry) {
this.buffer
- .append(Util.bind("disassembler.constantdouble")) //$NON-NLS-1$
+ .append("<Double ") //$NON-NLS-1$
.append(constantPoolEntry.getDoubleValue())
- .append(Util.bind("disassembler.closeconstant")); //$NON-NLS-1$
+ .append(">"); //$NON-NLS-1$
}
private void appendOutputForConstantLong(IConstantPoolEntry constantPoolEntry) {
this.buffer
- .append(Util.bind("disassembler.constantlong")) //$NON-NLS-1$
+ .append("<Long ") //$NON-NLS-1$
.append(constantPoolEntry.getLongValue())
- .append(Util.bind("disassembler.closeconstant")); //$NON-NLS-1$
+ .append(">"); //$NON-NLS-1$
}
private void appendOutputForConstantString(IConstantPoolEntry constantPoolEntry) {
this.buffer
- .append(Util.bind("disassembler.constantstring")) //$NON-NLS-1$
+ .append("<String \"") //$NON-NLS-1$
.append(constantPoolEntry.getStringValue())
- .append(Util.bind("disassembler.closeconstant")); //$NON-NLS-1$
+ .append("\">"); //$NON-NLS-1$
}
private void appendOutputforConstantInteger(IConstantPoolEntry constantPoolEntry) {
this.buffer
- .append(Util.bind("disassembler.constantinteger")) //$NON-NLS-1$
+ .append("<Integer ") //$NON-NLS-1$
.append(constantPoolEntry.getIntegerValue())
- .append(Util.bind("disassembler.closeconstant")); //$NON-NLS-1$
+ .append(">"); //$NON-NLS-1$
}
private void appendOutputforConstantFloat(IConstantPoolEntry constantPoolEntry) {
this.buffer
- .append(Util.bind("disassembler.constantfloat")) //$NON-NLS-1$
+ .append("<Float ") //$NON-NLS-1$
.append(constantPoolEntry.getFloatValue())
- .append(Util.bind("disassembler.closeconstant")); //$NON-NLS-1$
+ .append(">"); //$NON-NLS-1$
}
private void writeNewLine() {
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java
index 1654bec..af7e0c0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java
@@ -1,19 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.util.*;
import org.eclipse.jdt.core.util.ClassFormatException;
import org.eclipse.jdt.core.util.IClassFileAttribute;
-import org.eclipse.jdt.core.util.IClassFileDisassembler;
import org.eclipse.jdt.core.util.IClassFileReader;
import org.eclipse.jdt.core.util.ICodeAttribute;
import org.eclipse.jdt.core.util.IConstantPoolConstant;
@@ -30,49 +31,370 @@
import org.eclipse.jdt.core.util.IMethodInfo;
import org.eclipse.jdt.core.util.IModifierConstants;
import org.eclipse.jdt.core.util.ISourceAttribute;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
/**
* Disassembler of .class files. It generates an output in the Writer that looks close to
* the javap output.
*/
-public class Disassembler implements IClassFileDisassembler {
+public class Disassembler extends ClassFileBytesDisassembler {
private static final char[] ANY_EXCEPTION = Util.bind("classfileformat.anyexceptionhandler").toCharArray(); //$NON-NLS-1$
private static final String EMPTY_OUTPUT = ""; //$NON-NLS-1$
- /**
- * Answers back the disassembled string of the classfile bytes according to the
- * mode.
- * This is an output quite similar to the javap tool.
- *
- * @param classFileBytes The bytes of the classfile to disassemble
- * @param lineSeparator the line separator to use.
- * @param mode the mode used to disassemble the classfile
- *
- * @return the disassembled string of the classfile according to the mode
- * @exception ClassFormatException if the classfile bytes are ill-formed
- */
- public String disassemble(byte[] classfileBytes, String lineSeparator, int mode) throws ClassFormatException {
- return disassemble(new ClassFileReader(classfileBytes, IClassFileReader.ALL), lineSeparator, mode);
+ private void checkSuperFlags(StringBuffer buffer, int accessFlags, String lineSeparator, int tabNumber ) {
+ if ((accessFlags & IModifierConstants.ACC_SUPER) == 0) {
+ writeNewLine(buffer, lineSeparator, tabNumber);
+ buffer
+ .append(Util.bind("disassembler.commentstart")) //$NON-NLS-1$
+ .append(Util.bind("classfileformat.superflagnotset")) //$NON-NLS-1$
+ .append(Util.bind("disassembler.commentend")); //$NON-NLS-1$
+ }
+ }
+
+ private void decodeModifiersForField(StringBuffer buffer, int accessFlags) {
+ boolean firstModifier = true;
+ if ((accessFlags & IModifierConstants.ACC_FINAL) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("final"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_PRIVATE) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("private"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_PROTECTED) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("protected"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_PUBLIC) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("public"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_STATIC) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("static"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_TRANSIENT) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("transient"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_VOLATILE) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("volatile"); //$NON-NLS-1$
+ }
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ }
+
+ private final void decodeModifiersForInnerClasses(StringBuffer buffer, int accessFlags) {
+ boolean firstModifier = true;
+ if ((accessFlags & IModifierConstants.ACC_PUBLIC) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("public"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_PRIVATE) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("private"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_PROTECTED) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("protected"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_STATIC) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("static"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_FINAL) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("final"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_ABSTRACT) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("abstract"); //$NON-NLS-1$
+ }
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ }
+
+ private final void decodeModifiersForMethod(StringBuffer buffer, int accessFlags) {
+ boolean firstModifier = true;
+ if ((accessFlags & IModifierConstants.ACC_ABSTRACT) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("abstract"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_FINAL) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("final"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_NATIVE) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("native"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_PRIVATE) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("private"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_PROTECTED) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("protected"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_PUBLIC) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("public"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_STATIC) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("static"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_STRICT) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("strictfp"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_SYNCHRONIZED) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("synchronized"); //$NON-NLS-1$
+ }
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ }
+
+ private final void decodeModifiersForType(StringBuffer buffer, int accessFlags) {
+ boolean firstModifier = true;
+ if ((accessFlags & IModifierConstants.ACC_ABSTRACT) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("abstract"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_FINAL) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("final"); //$NON-NLS-1$
+ }
+ if ((accessFlags & IModifierConstants.ACC_PUBLIC) != 0) {
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ if (firstModifier) {
+ firstModifier = false;
+ }
+ buffer.append("public"); //$NON-NLS-1$
+ }
+ if (!firstModifier) {
+ buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
+ }
+ }
+
+ private String decodeStringValue(String s) {
+ StringBuffer buffer = new StringBuffer();
+ char[] chars = s.toCharArray();
+ for (int i = 0, max = chars.length; i < max; i++) {
+ char c = chars[i];
+ switch(c) {
+ case '\b' :
+ buffer.append("\\b"); //$NON-NLS-1$
+ break;
+ case '\t' :
+ buffer.append("\\t"); //$NON-NLS-1$
+ break;
+ case '\n' :
+ buffer.append("\\n"); //$NON-NLS-1$
+ break;
+ case '\f' :
+ buffer.append("\\f"); //$NON-NLS-1$
+ break;
+ case '\r' :
+ buffer.append("\\r"); //$NON-NLS-1$
+ break;
+ case '\"':
+ buffer.append("\\\""); //$NON-NLS-1$
+ break;
+ case '\'':
+ buffer.append("\\\'"); //$NON-NLS-1$
+ break;
+ case '\\':
+ buffer.append("\\\\"); //$NON-NLS-1$
+ break;
+ case '\0' :
+ buffer.append("\\0"); //$NON-NLS-1$
+ break;
+ case '\1' :
+ buffer.append("\\1"); //$NON-NLS-1$
+ break;
+ case '\2' :
+ buffer.append("\\2"); //$NON-NLS-1$
+ break;
+ case '\3' :
+ buffer.append("\\3"); //$NON-NLS-1$
+ break;
+ case '\4' :
+ buffer.append("\\4"); //$NON-NLS-1$
+ break;
+ case '\5' :
+ buffer.append("\\5"); //$NON-NLS-1$
+ break;
+ case '\6' :
+ buffer.append("\\6"); //$NON-NLS-1$
+ break;
+ case '\7' :
+ buffer.append("\\7"); //$NON-NLS-1$
+ break;
+ default:
+ buffer.append(c);
+ }
+ }
+ return buffer.toString();
}
/**
- * Disassemble the class file reader.
+ * @see org.eclipse.jdt.core.util.ClassFileBytesDisassembler#disassemble(byte[], java.lang.String)
+ */
+ public String disassemble(byte[] classFileBytes, String lineSeparator) throws ClassFormatException {
+ return disassemble(new ClassFileReader(classFileBytes, IClassFileReader.ALL), lineSeparator, ClassFileBytesDisassembler.DEFAULT);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.util.ClassFileBytesDisassembler#disassemble(byte[], java.lang.String, int)
+ */
+ public String disassemble(byte[] classFileBytes, String lineSeparator, int mode) throws ClassFormatException {
+ return disassemble(new ClassFileReader(classFileBytes, IClassFileReader.ALL), lineSeparator, mode);
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.util.IClassFileDisassembler#disassemble(org.eclipse.jdt.core.util.IClassFileReader, java.lang.String)
*/
public String disassemble(IClassFileReader classFileReader, String lineSeparator) {
- return disassemble(classFileReader, lineSeparator, IClassFileDisassembler.DEFAULT);
+ return disassemble(classFileReader, lineSeparator, ClassFileBytesDisassembler.DEFAULT);
}
/**
- * Disassemble the class file reader.
+ * @see org.eclipse.jdt.core.util.IClassFileDisassembler#disassemble(org.eclipse.jdt.core.util.IClassFileReader, java.lang.String, int)
*/
public String disassemble(IClassFileReader classFileReader, String lineSeparator, int mode) {
if (classFileReader == null) return EMPTY_OUTPUT;
StringBuffer buffer = new StringBuffer();
- if (mode == IClassFileDisassembler.DETAILED) {
+ if (mode == ClassFileBytesDisassembler.DETAILED) {
int minorVersion = classFileReader.getMinorVersion();
int majorVersion = classFileReader.getMajorVersion();
buffer.append(Util.bind("disassembler.commentstart")); //$NON-NLS-1$
@@ -114,25 +436,42 @@
// incomplete initialization. We cannot go further.
return buffer.toString();
}
- decodeModifiersForType(buffer, classFileReader.getAccessFlags());
- if (classFileReader.isClass()) {
- buffer.append(Util.bind("classfileformat.class")); //$NON-NLS-1$
+
+ IInnerClassesAttribute innerClassesAttribute = classFileReader.getInnerClassesAttribute();
+
+ if (innerClassesAttribute != null) {
+ // search the right entry
+ IInnerClassesAttributeEntry[] entries = innerClassesAttribute.getInnerClassAttributesEntries();
+ for (int i = 0, max = entries.length; i < max ; i++) {
+ IInnerClassesAttributeEntry entry = entries[i];
+ char[] innerClassName = entry.getInnerClassName();
+ if (innerClassName != null) {
+ if (CharOperation.equals(classFileReader.getClassName(), innerClassName)) {
+ decodeModifiersForInnerClasses(buffer, entry.getAccessFlags());
+ }
+ }
+ }
} else {
- buffer.append(Util.bind("classfileformat.interface")); //$NON-NLS-1$
+ decodeModifiersForType(buffer, classFileReader.getAccessFlags());
+ }
+ if (classFileReader.isClass()) {
+ buffer.append("class "); //$NON-NLS-1$
+ } else {
+ buffer.append("interface "); //$NON-NLS-1$
}
CharOperation.replace(className, '/', '.');
buffer.append(className);
char[] superclassName = classFileReader.getSuperclassName();
if (superclassName != null) {
- buffer.append(Util.bind("classfileformat.extends")); //$NON-NLS-1$
+ buffer.append(" extends "); //$NON-NLS-1$
CharOperation.replace(superclassName, '/', '.');
buffer.append(superclassName);
}
char[][] superclassInterfaces = classFileReader.getInterfaceNames();
int length = superclassInterfaces.length;
if (length != 0) {
- buffer.append(Util.bind("classfileformat.implements")); //$NON-NLS-1$
+ buffer.append(" implements "); //$NON-NLS-1$
for (int i = 0; i < length - 1; i++) {
char[] superinterface = superclassInterfaces[i];
CharOperation.replace(superinterface, '/', '.');
@@ -147,8 +486,7 @@
buffer.append(Util.bind("disassembler.opentypedeclaration")); //$NON-NLS-1$
checkSuperFlags(buffer, classFileReader.getAccessFlags(), lineSeparator, 1);
disassembleTypeMembers(classFileReader, buffer, lineSeparator, 1, mode);
- if (mode == IClassFileDisassembler.DETAILED) {
- IInnerClassesAttribute innerClassesAttribute = classFileReader.getInnerClassesAttribute();
+ if (mode == ClassFileBytesDisassembler.DETAILED) {
if (innerClassesAttribute != null) {
disassemble(innerClassesAttribute, buffer, lineSeparator, 1);
}
@@ -183,8 +521,10 @@
outerClassNameIndex = innerClassesAttributeEntry.getOuterClassNameIndex();
innerNameIndex = innerClassesAttributeEntry.getInnerNameIndex();
accessFlags = innerClassesAttributeEntry.getAccessFlags();
+ buffer.append(Util.bind("disassembler.openinnerclassentry")); //$NON-NLS-1$
+ writeNewLine(buffer, lineSeparator, tabNumber);
+ dumpTab(tabNumber + 1, buffer);
buffer
- .append(Util.bind("disassembler.openinnerclassentry")) //$NON-NLS-1$
.append(Util.bind("disassembler.inner_class_info_name")) //$NON-NLS-1$
.append(Util.bind("disassembler.constantpoolindex")) //$NON-NLS-1$
.append(innerClassNameIndex);
@@ -193,7 +533,7 @@
.append(Util.bind("disassembler.space")) //$NON-NLS-1$
.append(innerClassesAttributeEntry.getInnerClassName());
}
- writeNewLine(buffer, lineSeparator, tabNumber + 1);
+ writeNewLine(buffer, lineSeparator, tabNumber);
dumpTab(tabNumber + 1, buffer);
buffer
.append(Util.bind("disassembler.outer_class_info_name")) //$NON-NLS-1$
@@ -204,7 +544,7 @@
.append(Util.bind("disassembler.space")) //$NON-NLS-1$
.append(innerClassesAttributeEntry.getOuterClassName());
}
- writeNewLine(buffer, lineSeparator, tabNumber + 1);
+ writeNewLine(buffer, lineSeparator, tabNumber);
dumpTab(tabNumber + 1, buffer);
buffer
.append(Util.bind("disassembler.inner_name")) //$NON-NLS-1$
@@ -215,7 +555,7 @@
.append(Util.bind("disassembler.space")) //$NON-NLS-1$
.append(innerClassesAttributeEntry.getInnerName());
}
- writeNewLine(buffer, lineSeparator, tabNumber + 1);
+ writeNewLine(buffer, lineSeparator, tabNumber);
dumpTab(tabNumber + 1, buffer);
buffer
.append(Util.bind("disassembler.inner_accessflags")) //$NON-NLS-1$
@@ -233,8 +573,10 @@
outerClassNameIndex = innerClassesAttributeEntry.getOuterClassNameIndex();
innerNameIndex = innerClassesAttributeEntry.getInnerNameIndex();
accessFlags = innerClassesAttributeEntry.getAccessFlags();
+ buffer.append(Util.bind("disassembler.openinnerclassentry")); //$NON-NLS-1$
+ writeNewLine(buffer, lineSeparator, tabNumber);
+ dumpTab(tabNumber + 1, buffer);
buffer
- .append(Util.bind("disassembler.openinnerclassentry")) //$NON-NLS-1$
.append(Util.bind("disassembler.inner_class_info_name")) //$NON-NLS-1$
.append(Util.bind("disassembler.constantpoolindex")) //$NON-NLS-1$
.append(innerClassNameIndex);
@@ -243,7 +585,7 @@
.append(Util.bind("disassembler.space")) //$NON-NLS-1$
.append(innerClassesAttributeEntry.getInnerClassName());
}
- writeNewLine(buffer, lineSeparator, tabNumber + 1);
+ writeNewLine(buffer, lineSeparator, tabNumber);
dumpTab(tabNumber + 1, buffer);
buffer
.append(Util.bind("disassembler.outer_class_info_name")) //$NON-NLS-1$
@@ -254,7 +596,7 @@
.append(Util.bind("disassembler.space")) //$NON-NLS-1$
.append(innerClassesAttributeEntry.getOuterClassName());
}
- writeNewLine(buffer, lineSeparator, tabNumber + 1);
+ writeNewLine(buffer, lineSeparator, tabNumber);
dumpTab(tabNumber + 1, buffer);
buffer
.append(Util.bind("disassembler.inner_name")) //$NON-NLS-1$
@@ -265,7 +607,7 @@
.append(Util.bind("disassembler.space")) //$NON-NLS-1$
.append(innerClassesAttributeEntry.getInnerName());
}
- writeNewLine(buffer, lineSeparator, tabNumber + 1);
+ writeNewLine(buffer, lineSeparator, tabNumber);
dumpTab(tabNumber + 1, buffer);
buffer
.append(Util.bind("disassembler.inner_accessflags")) //$NON-NLS-1$
@@ -275,40 +617,6 @@
buffer.append(Util.bind("disassembler.closeinnerclassentry")); //$NON-NLS-1$
}
- private void checkSuperFlags(StringBuffer buffer, int accessFlags, String lineSeparator, int tabNumber ) {
- if ((accessFlags & IModifierConstants.ACC_SUPER) == 0) {
- writeNewLine(buffer, lineSeparator, tabNumber);
- buffer
- .append(Util.bind("disassembler.commentstart")) //$NON-NLS-1$
- .append(Util.bind("classfileformat.superflagnotset")) //$NON-NLS-1$
- .append(Util.bind("disassembler.commentend")); //$NON-NLS-1$
- }
- }
-
-
- private final void dumpTab(int tabNumber, StringBuffer buffer) {
- for (int i = 0; i < tabNumber; i++) {
- buffer.append(Util.bind("disassembler.tab")); //$NON-NLS-1$
- }
- }
-
- private void disassembleTypeMembers(IClassFileReader classFileReader, StringBuffer buffer, String lineSeparator, int tabNumber, int mode) {
- writeNewLine(buffer, lineSeparator, tabNumber);
- IFieldInfo[] fields = classFileReader.getFieldInfos();
- for (int i = 0, max = fields.length; i < max; i++) {
- disassemble(fields[i], buffer, lineSeparator, tabNumber, mode);
- }
- IMethodInfo[] methods = classFileReader.getMethodInfos();
- for (int i = 0, max = methods.length; i < max; i++) {
- disassemble(classFileReader, methods[i], buffer, lineSeparator, tabNumber, mode);
- }
- }
-
- private void writeNewLine(StringBuffer buffer, String lineSeparator, int tabNumber) {
- buffer.append(lineSeparator);
- dumpTab(tabNumber, buffer);
- }
-
/**
* Disassemble a field info
*/
@@ -367,7 +675,7 @@
}
}
}
- if (mode == IClassFileDisassembler.DETAILED) {
+ if (mode == ClassFileBytesDisassembler.DETAILED) {
writeNewLine(buffer, lineSeparator, tabNumber);
CharOperation.replace(fieldDescriptor, '.', '/');
buffer
@@ -386,6 +694,8 @@
* Disassemble a method info header
*/
private void disassemble(IClassFileReader classFileReader, IMethodInfo methodInfo, StringBuffer buffer, String lineSeparator, int tabNumber, int mode) {
+ ICodeAttribute codeAttribute = methodInfo.getCodeAttribute();
+
writeNewLine(buffer, lineSeparator, tabNumber);
int accessFlags = methodInfo.getAccessFlags();
decodeModifiersForMethod(buffer, accessFlags);
@@ -394,17 +704,17 @@
char[] methodName = null;
if (methodInfo.isConstructor()) {
methodName = classFileReader.getClassName();
- buffer.append(Signature.toCharArray(methodDescriptor, methodName, getParameterNames(methodDescriptor) , true, false));
+ buffer.append(Signature.toCharArray(methodDescriptor, methodName, getParameterNames(methodDescriptor, codeAttribute, accessFlags) , true, false));
} else if (methodInfo.isClinit()) {
methodName = Util.bind("classfileformat.clinitname").toCharArray(); //$NON-NLS-1$
buffer.append(methodName);
} else {
methodName = methodInfo.getName();
- buffer.append(Signature.toCharArray(methodDescriptor, methodName, getParameterNames(methodDescriptor) , false, true));
+ buffer.append(Signature.toCharArray(methodDescriptor, methodName, getParameterNames(methodDescriptor, codeAttribute, accessFlags) , false, true));
}
IExceptionAttribute exceptionAttribute = methodInfo.getExceptionAttribute();
if (exceptionAttribute != null) {
- buffer.append(Util.bind("classfileformat.throws")); //$NON-NLS-1$
+ buffer.append(" throws "); //$NON-NLS-1$
char[][] exceptionNames = exceptionAttribute.getExceptionNames();
int length = exceptionNames.length;
for (int i = 0; i < length - 1; i++) {
@@ -421,7 +731,7 @@
}
buffer.append(Util.bind("disassembler.endofmethodheader")); //$NON-NLS-1$
writeNewLine(buffer, lineSeparator, tabNumber);
- if (mode == IClassFileDisassembler.DETAILED) {
+ if (mode == ClassFileBytesDisassembler.DETAILED) {
CharOperation.replace(methodDescriptor, '.', '/');
buffer
.append(Util.bind("disassembler.commentstart")) //$NON-NLS-1$
@@ -433,7 +743,6 @@
.append(Util.bind("disassembler.commentend")); //$NON-NLS-1$
writeNewLine(buffer, lineSeparator, tabNumber);
}
- ICodeAttribute codeAttribute = methodInfo.getCodeAttribute();
IClassFileAttribute[] attributes = methodInfo.getAttributes();
int length = attributes.length;
if (length != 0) {
@@ -452,8 +761,9 @@
}
private void disassemble(IClassFileAttribute classFileAttribute, StringBuffer buffer, String lineSeparator, int tabNumber) {
- buffer.append(Util.bind("disassembler.genericattributeheader")); //$NON-NLS-1$
writeNewLine(buffer, lineSeparator, tabNumber + 1);
+ buffer.append(Util.bind("disassembler.genericattributeheader")); //$NON-NLS-1$
+ writeNewLine(buffer, lineSeparator, tabNumber + 2);
buffer
.append(Util.bind("disassembler.genericattributename")) //$NON-NLS-1$
.append(classFileAttribute.getAttributeName())
@@ -567,327 +877,83 @@
.append(Signature.toCharArray(localVariableTableEntry.getDescriptor()));
}
}
+
+ private void disassembleTypeMembers(IClassFileReader classFileReader, StringBuffer buffer, String lineSeparator, int tabNumber, int mode) {
+ writeNewLine(buffer, lineSeparator, tabNumber);
+ IFieldInfo[] fields = classFileReader.getFieldInfos();
+ for (int i = 0, max = fields.length; i < max; i++) {
+ disassemble(fields[i], buffer, lineSeparator, tabNumber, mode);
+ }
+ IMethodInfo[] methods = classFileReader.getMethodInfos();
+ for (int i = 0, max = methods.length; i < max; i++) {
+ disassemble(classFileReader, methods[i], buffer, lineSeparator, tabNumber, mode);
+ }
+ }
+
+ private final void dumpTab(int tabNumber, StringBuffer buffer) {
+ for (int i = 0; i < tabNumber; i++) {
+ buffer.append(Util.bind("disassembler.tab")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @see org.eclipse.jdt.core.util.ClassFileBytesDisassembler#getDescription()
+ */
+ public String getDescription() {
+ return Util.bind("disassembler.description"); //$NON-NLS-1$
+ }
- private char[][] getParameterNames(char[] methodDescriptor) {
+
+ private char[][] getParameterNames(char[] methodDescriptor, ICodeAttribute codeAttribute, int accessFlags) {
int paramCount = Signature.getParameterCount(methodDescriptor);
char[][] parameterNames = new char[paramCount][];
- for (int i = 0; i < paramCount; i++) {
- parameterNames[i] = Util.bind("disassembler.parametername").toCharArray(); //$NON-NLS-1$
+ // check if the code attribute has debug info for this method
+ if (codeAttribute != null) {
+ ILocalVariableAttribute localVariableAttribute = codeAttribute.getLocalVariableAttribute();
+ if (localVariableAttribute != null) {
+ ILocalVariableTableEntry[] entries = localVariableAttribute.getLocalVariableTable();
+ int startingIndex = (accessFlags & IModifierConstants.ACC_STATIC) != 0 ? 0 : 1;
+ for (int i = 0; i < paramCount; i++) {
+ ILocalVariableTableEntry searchedEntry = getEntryFor(startingIndex + i, entries);
+ if (searchedEntry != null) {
+ parameterNames[i] = searchedEntry.getName();
+ } else {
+ parameterNames[i] = Util.bind("disassembler.parametername").toCharArray(); //$NON-NLS-1$
+ }
+ }
+ } else {
+ for (int i = 0; i < paramCount; i++) {
+ parameterNames[i] = Util.bind("disassembler.parametername").toCharArray(); //$NON-NLS-1$
+ }
+ }
+ } else {
+ for (int i = 0; i < paramCount; i++) {
+ parameterNames[i] = Util.bind("disassembler.parametername").toCharArray(); //$NON-NLS-1$
+ }
}
return parameterNames;
}
+ /**
+ * Method getEntryFor.
+ * @param localIndex
+ * @param entries
+ * @return ILocalVariableTableEntry
+ */
+ private ILocalVariableTableEntry getEntryFor(
+ int localIndex,
+ ILocalVariableTableEntry[] entries) {
+
+ for (int i = 0, max = entries.length; i < max; i++) {
+ ILocalVariableTableEntry entry = entries[i];
+ if (localIndex == entry.getIndex()) {
+ return entry;
+ }
+ }
+ return null;
+ }
- private final void decodeModifiersForType(StringBuffer buffer, int accessFlags) {
- boolean firstModifier = true;
- if ((accessFlags & IModifierConstants.ACC_ABSTRACT) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_abstract")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_FINAL) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_final")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_PUBLIC) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_public")); //$NON-NLS-1$
- }
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- }
-
- private final void decodeModifiersForInnerClasses(StringBuffer buffer, int accessFlags) {
- boolean firstModifier = true;
- if ((accessFlags & IModifierConstants.ACC_PUBLIC) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_public")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_PRIVATE) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_private")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_PROTECTED) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_protected")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_STATIC) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_static")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_FINAL) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_final")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_ABSTRACT) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_abstract")); //$NON-NLS-1$
- }
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- }
-
- private final void decodeModifiersForMethod(StringBuffer buffer, int accessFlags) {
- boolean firstModifier = true;
- if ((accessFlags & IModifierConstants.ACC_ABSTRACT) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_abstract")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_FINAL) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_final")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_NATIVE) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_native")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_PRIVATE) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_private")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_PROTECTED) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_protected")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_PUBLIC) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_public")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_STATIC) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_static")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_STRICT) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_strict")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_SYNCHRONIZED) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_synchronized")); //$NON-NLS-1$
- }
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- }
-
- private void decodeModifiersForField(StringBuffer buffer, int accessFlags) {
- boolean firstModifier = true;
- if ((accessFlags & IModifierConstants.ACC_FINAL) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_final")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_PRIVATE) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_private")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_PROTECTED) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_protected")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_PUBLIC) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_public")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_STATIC) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_static")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_TRANSIENT) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_transient")); //$NON-NLS-1$
- }
- if ((accessFlags & IModifierConstants.ACC_VOLATILE) != 0) {
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- if (firstModifier) {
- firstModifier = false;
- }
- buffer.append(Util.bind("classfileformat.acc_volatile")); //$NON-NLS-1$
- }
- if (!firstModifier) {
- buffer.append(Util.bind("disassembler.space")); //$NON-NLS-1$
- }
- }
-
- private String decodeStringValue(String s) {
- StringBuffer buffer = new StringBuffer();
- char[] chars = s.toCharArray();
- for (int i = 0, max = chars.length; i < max; i++) {
- char c = chars[i];
- switch(c) {
- case '\b' :
- buffer.append("\\b"); //$NON-NLS-1$
- break;
- case '\t' :
- buffer.append("\\t"); //$NON-NLS-1$
- break;
- case '\n' :
- buffer.append("\\n"); //$NON-NLS-1$
- break;
- case '\f' :
- buffer.append("\\f"); //$NON-NLS-1$
- break;
- case '\r' :
- buffer.append("\\r"); //$NON-NLS-1$
- break;
- case '\"':
- buffer.append("\\\""); //$NON-NLS-1$
- break;
- case '\'':
- buffer.append("\\\'"); //$NON-NLS-1$
- break;
- case '\\':
- buffer.append("\\\\"); //$NON-NLS-1$
- break;
- case '\0' :
- buffer.append("\\0"); //$NON-NLS-1$
- break;
- case '\1' :
- buffer.append("\\1"); //$NON-NLS-1$
- break;
- case '\2' :
- buffer.append("\\2"); //$NON-NLS-1$
- break;
- case '\3' :
- buffer.append("\\3"); //$NON-NLS-1$
- break;
- case '\4' :
- buffer.append("\\4"); //$NON-NLS-1$
- break;
- case '\5' :
- buffer.append("\\5"); //$NON-NLS-1$
- break;
- case '\6' :
- buffer.append("\\6"); //$NON-NLS-1$
- break;
- case '\7' :
- buffer.append("\\7"); //$NON-NLS-1$
- break;
- default:
- buffer.append(c);
- }
- }
- return buffer.toString();
+ private void writeNewLine(StringBuffer buffer, String lineSeparator, int tabNumber) {
+ buffer.append(lineSeparator);
+ dumpTab(tabNumber, buffer);
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Dumper.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Dumper.java
index d2b0476..74c40e4 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Dumper.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Dumper.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import java.io.*;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionAttribute.java
index e11521f..92bde34 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionAttribute.java
@@ -1,15 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.util.ClassFormatException;
import org.eclipse.jdt.core.util.IAttributeNamesConstants;
import org.eclipse.jdt.core.util.IConstantPool;
@@ -22,7 +23,7 @@
*/
public class ExceptionAttribute extends ClassFileAttribute implements IExceptionAttribute {
private static final int[] NO_EXCEPTION_INDEXES = new int[0];
- private static final char[][] NO_EXCEPTION_NAMES = new char[0][0];
+ private static final char[][] NO_EXCEPTION_NAMES = CharOperation.NO_CHAR_CHAR;
private int exceptionsNumber;
private char[][] exceptionNames;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionTableEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionTableEntry.java
index 4613f00..128aca6 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionTableEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ExceptionTableEntry.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/FieldInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/FieldInfo.java
index 13dfcef..8fd7dee 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/FieldInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/FieldInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
@@ -168,4 +168,4 @@
return this.attributes;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ICacheEnumeration.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ICacheEnumeration.java
index 29b604d..42a69f8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ICacheEnumeration.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ICacheEnumeration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import java.util.Enumeration;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/IDumpable.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/IDumpable.java
index 6908c26..9ef7372 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/IDumpable.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/IDumpable.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ILRUCacheable.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ILRUCacheable.java
index 30888bc..9120d5f 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ILRUCacheable.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ILRUCacheable.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttribute.java
index dbe696d..0c24221 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
@@ -63,4 +63,4 @@
return this.numberOfClasses;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttributeEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttributeEntry.java
index d6ac66a..0f37fa0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttributeEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/InnerClassesAttributeEntry.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LRUCache.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LRUCache.java
index ad44c89..9f2e83e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LRUCache.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LRUCache.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import java.util.Enumeration;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LineNumberAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LineNumberAttribute.java
index 905ee29..dc76f55 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LineNumberAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LineNumberAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableAttribute.java
index 99818c4..8b83fb9 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTableEntry.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTableEntry.java
index 6bdbe7a..0f2ea5d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTableEntry.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/LocalVariableTableEntry.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MethodInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MethodInfo.java
index e486876..ac77bcf 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MethodInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MethodInfo.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
@@ -20,6 +20,7 @@
import org.eclipse.jdt.core.util.IConstantPoolEntry;
import org.eclipse.jdt.core.util.IExceptionAttribute;
import org.eclipse.jdt.core.util.IMethodInfo;
+import org.eclipse.jdt.core.util.IModifierConstants;
/**
* Default implementation of IMethodInfo.
@@ -67,7 +68,7 @@
this.attributesCount = u2At(classFileBytes, 6, offset);
this.attributes = ClassFileAttribute.NO_ATTRIBUTES;
if (this.attributesCount != 0) {
- if (no_code_attribute) {
+ if (no_code_attribute && !isAbstract() && !isNative()) {
if (this.attributesCount != 1) {
this.attributes = new IClassFileAttribute[this.attributesCount - 1];
}
@@ -198,4 +199,11 @@
return this.attributes;
}
-}
\ No newline at end of file
+ private boolean isAbstract() {
+ return (this.accessFlags & IModifierConstants.ACC_ABSTRACT) != 0;
+ }
+
+ private boolean isNative() {
+ return (this.accessFlags & IModifierConstants.ACC_NATIVE) != 0;
+ }
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PerThreadObject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PerThreadObject.java
index 08f50eb..511db25 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PerThreadObject.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PerThreadObject.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import java.util.Hashtable;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java
new file mode 100644
index 0000000..f5a4942
--- /dev/null
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/PublicScanner.java
@@ -0,0 +1,3230 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.util;
+
+import java.util.Iterator;
+
+import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.compiler.ITerminalSymbols;
+import org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
+import org.eclipse.jdt.internal.compiler.parser.NLSLine;
+
+public class PublicScanner implements IScanner, ITerminalSymbols {
+
+ /* APIs ares
+ - getNextToken() which return the current type of the token
+ (this value is not memorized by the scanner)
+ - getCurrentTokenSource() which provides with the token "REAL" source
+ (aka all unicode have been transformed into a correct char)
+ - sourceStart gives the position into the stream
+ - currentPosition-1 gives the sourceEnd position into the stream
+ */
+
+ // 1.4 feature
+ private boolean assertMode = false;
+ public boolean useAssertAsAnIndentifier = false;
+ //flag indicating if processed source contains occurrences of keyword assert
+ public boolean containsAssertKeyword = false;
+
+ public boolean recordLineSeparator = false;
+ public char currentCharacter;
+ public int startPosition;
+ public int currentPosition;
+ public int initialPosition, eofPosition;
+ // after this position eof are generated instead of real token from the source
+
+ public boolean tokenizeComments = false;
+ public boolean tokenizeWhiteSpace = false;
+
+ //source should be viewed as a window (aka a part)
+ //of a entire very large stream
+ public char source[];
+
+ //unicode support
+ public char[] withoutUnicodeBuffer;
+ public int withoutUnicodePtr; //when == 0 ==> no unicode in the current token
+ public boolean unicodeAsBackSlash = false;
+
+ public boolean scanningFloatLiteral = false;
+
+ //support for /** comments
+ public int[] commentStops = new int[10];
+ public int[] commentStarts = new int[10];
+ public int commentPtr = -1; // no comment test with commentPtr value -1
+
+ // task tag support
+ public char[][] foundTaskTags = null;
+ public char[][] foundTaskMessages;
+ public char[][] foundTaskPriorities = null;
+ public int[][] foundTaskPositions;
+ public int foundTaskCount = 0;
+ public char[][] taskTags = null;
+ public char[][] taskPriorities = null;
+
+ //diet parsing support - jump over some method body when requested
+ public boolean diet = false;
+
+ //support for the poor-line-debuggers ....
+ //remember the position of the cr/lf
+ public int[] lineEnds = new int[250];
+ public int linePtr = -1;
+ public boolean wasAcr = false;
+
+ public static final String END_OF_SOURCE = "End_Of_Source"; //$NON-NLS-1$
+
+ public static final String INVALID_HEXA = "Invalid_Hexa_Literal"; //$NON-NLS-1$
+ public static final String INVALID_OCTAL = "Invalid_Octal_Literal"; //$NON-NLS-1$
+ public static final String INVALID_CHARACTER_CONSTANT = "Invalid_Character_Constant"; //$NON-NLS-1$
+ public static final String INVALID_ESCAPE = "Invalid_Escape"; //$NON-NLS-1$
+ public static final String INVALID_INPUT = "Invalid_Input"; //$NON-NLS-1$
+ public static final String INVALID_UNICODE_ESCAPE = "Invalid_Unicode_Escape"; //$NON-NLS-1$
+ public static final String INVALID_FLOAT = "Invalid_Float_Literal"; //$NON-NLS-1$
+
+ public static final String NULL_SOURCE_STRING = "Null_Source_String"; //$NON-NLS-1$
+ public static final String UNTERMINATED_STRING = "Unterminated_String"; //$NON-NLS-1$
+ public static final String UNTERMINATED_COMMENT = "Unterminated_Comment"; //$NON-NLS-1$
+ public static final String INVALID_CHAR_IN_STRING = "Invalid_Char_In_String"; //$NON-NLS-1$
+
+ //----------------optimized identifier managment------------------
+ static final char[] charArray_a = new char[] {'a'},
+ charArray_b = new char[] {'b'},
+ charArray_c = new char[] {'c'},
+ charArray_d = new char[] {'d'},
+ charArray_e = new char[] {'e'},
+ charArray_f = new char[] {'f'},
+ charArray_g = new char[] {'g'},
+ charArray_h = new char[] {'h'},
+ charArray_i = new char[] {'i'},
+ charArray_j = new char[] {'j'},
+ charArray_k = new char[] {'k'},
+ charArray_l = new char[] {'l'},
+ charArray_m = new char[] {'m'},
+ charArray_n = new char[] {'n'},
+ charArray_o = new char[] {'o'},
+ charArray_p = new char[] {'p'},
+ charArray_q = new char[] {'q'},
+ charArray_r = new char[] {'r'},
+ charArray_s = new char[] {'s'},
+ charArray_t = new char[] {'t'},
+ charArray_u = new char[] {'u'},
+ charArray_v = new char[] {'v'},
+ charArray_w = new char[] {'w'},
+ charArray_x = new char[] {'x'},
+ charArray_y = new char[] {'y'},
+ charArray_z = new char[] {'z'};
+
+ static final char[] initCharArray =
+ new char[] {'\u0000', '\u0000', '\u0000', '\u0000', '\u0000', '\u0000'};
+ static final int TableSize = 30, InternalTableSize = 6; //30*6 = 180 entries
+ public static final int OptimizedLength = 6;
+ public /*static*/ final char[][][][] charArray_length =
+ new char[OptimizedLength][TableSize][InternalTableSize][];
+ // support for detecting non-externalized string literals
+ int currentLineNr= -1;
+ int previousLineNr= -1;
+ NLSLine currentLine= null;
+ public static final String TAG_PREFIX= "//$NON-NLS-"; //$NON-NLS-1$
+ public static final int TAG_PREFIX_LENGTH= TAG_PREFIX.length();
+ public static final String TAG_POSTFIX= "$"; //$NON-NLS-1$
+ public static final int TAG_POSTFIX_LENGTH= TAG_POSTFIX.length();
+ public StringLiteral[] nonNLSStrings = null;
+ public boolean checkNonExternalizedStringLiterals = false;
+ public boolean wasNonExternalizedStringLiteral = false;
+
+ /*static*/ {
+ for (int i = 0; i < 6; i++) {
+ for (int j = 0; j < TableSize; j++) {
+ for (int k = 0; k < InternalTableSize; k++) {
+ charArray_length[i][j][k] = initCharArray;
+ }
+ }
+ }
+ }
+ static int newEntry2 = 0,
+ newEntry3 = 0,
+ newEntry4 = 0,
+ newEntry5 = 0,
+ newEntry6 = 0;
+
+ public static final int RoundBracket = 0;
+ public static final int SquareBracket = 1;
+ public static final int CurlyBracket = 2;
+ public static final int BracketKinds = 3;
+
+public PublicScanner() {
+ this(false /*comment*/, false /*whitespace*/, false /*nls*/, false /*assert*/, null/*taskTag*/, null/*taskPriorities*/);
+}
+public PublicScanner(
+ boolean tokenizeComments,
+ boolean tokenizeWhiteSpace,
+ boolean checkNonExternalizedStringLiterals,
+ boolean assertMode,
+ char[][] taskTags,
+ char[][] taskPriorities) {
+
+ this.eofPosition = Integer.MAX_VALUE;
+ this.tokenizeComments = tokenizeComments;
+ this.tokenizeWhiteSpace = tokenizeWhiteSpace;
+ this.checkNonExternalizedStringLiterals = checkNonExternalizedStringLiterals;
+ this.assertMode = assertMode;
+ this.taskTags = taskTags;
+ this.taskPriorities = taskPriorities;
+}
+
+
+public final boolean atEnd() {
+ // This code is not relevant if source is
+ // Only a part of the real stream input
+
+ return source.length == currentPosition;
+}
+
+private void checkNonExternalizeString() throws InvalidInputException {
+ if (currentLine == null)
+ return;
+ parseTags(currentLine);
+}
+
+// chech presence of task: tags
+public void checkTaskTag(int commentStart, int commentEnd) {
+
+ // only look for newer task: tags
+ if (this.foundTaskCount > 0 && this.foundTaskPositions[this.foundTaskCount-1][0] >= commentStart) {
+ return;
+ }
+ int foundTaskIndex = this.foundTaskCount;
+ nextChar: for (int i = commentStart; i < commentEnd && i < this.eofPosition; i++) {
+
+ int nextPos = -1;
+ char[] tag = null;
+ char[] priority = null;
+
+ // check for tag occurrence
+ nextTag: for (int itag = 0; itag < this.taskTags.length; itag++){
+ tag = this.taskTags[itag];
+ priority =
+ this.taskPriorities != null && itag < this.taskPriorities.length ?
+ this.taskPriorities[itag] :
+ null;
+ int tagLength = tag.length;
+ for (int t = 0; t < tagLength; t++){
+ if (this.source[i+t] != tag[t]) continue nextTag;
+ }
+ nextPos = i + tagLength;
+
+ if (this.foundTaskTags == null){
+ this.foundTaskTags = new char[5][];
+ this.foundTaskMessages = new char[5][];
+ this.foundTaskPriorities = new char[5][];
+ this.foundTaskPositions = new int[5][];
+ } else if (this.foundTaskCount == this.foundTaskTags.length) {
+ System.arraycopy(this.foundTaskTags, 0, this.foundTaskTags = new char[this.foundTaskCount*2][], 0, this.foundTaskCount);
+ System.arraycopy(this.foundTaskMessages, 0, this.foundTaskMessages = new char[this.foundTaskCount*2][], 0, this.foundTaskCount);
+ System.arraycopy(this.foundTaskPriorities, 0, this.foundTaskPriorities = new char[this.foundTaskCount*2][], 0, this.foundTaskCount);
+ System.arraycopy(this.foundTaskPositions, 0, this.foundTaskPositions = new int[this.foundTaskCount*2][], 0, this.foundTaskCount);
+ }
+ this.foundTaskTags[this.foundTaskCount] = tag;
+ this.foundTaskPriorities[this.foundTaskCount] = priority;
+ this.foundTaskPositions[this.foundTaskCount] = new int[]{ i, -1 };
+ this.foundTaskCount++;
+
+ i = nextPos;
+ }
+ }
+
+ for (int i = foundTaskIndex; i < this.foundTaskCount; i++) {
+ // retrieve message start and end positions
+ int msgStart = this.foundTaskPositions[i][0] + this.foundTaskTags[i].length;
+ int end;
+ char c;
+ int max_value = i + 1 < this.foundTaskCount ? this.foundTaskPositions[i + 1][0] - 1 : Integer.MAX_VALUE;
+
+ end = -1;
+ for (int j = msgStart; j < commentEnd; j++){
+ if ((c = this.source[j]) == '\n' || c == '\r'){
+ end = j - 1;
+ break;
+ }
+ }
+ end = end < max_value ? end : max_value;
+
+ if (end < 0){
+ for (int j = commentEnd-1; j >= msgStart; j--){
+ if ((c = this.source[j]) == '*') {
+ end = j-1;
+ break;
+ }
+ }
+ if (end < 0) end = commentEnd-1;
+ }
+
+ // trim the message
+ while (CharOperation.isWhitespace(source[end]) && msgStart <= end) end--;
+ while (CharOperation.isWhitespace(source[msgStart]) && msgStart <= end) msgStart++;
+
+ // update the end position of the task
+ this.foundTaskPositions[i][1] = end;
+
+ // get the message source
+ final int messageLength = end-msgStart+1;
+ char[] message = new char[messageLength];
+
+ System.arraycopy(source, msgStart, message, 0, messageLength);
+ this.foundTaskMessages[i] = message;
+ }
+}
+
+public char[] getCurrentIdentifierSource() {
+ //return the token REAL source (aka unicodes are precomputed)
+
+ char[] result;
+ if (withoutUnicodePtr != 0)
+ //0 is used as a fast test flag so the real first char is in position 1
+ System.arraycopy(
+ withoutUnicodeBuffer,
+ 1,
+ result = new char[withoutUnicodePtr],
+ 0,
+ withoutUnicodePtr);
+ else {
+ int length = currentPosition - startPosition;
+ switch (length) { // see OptimizedLength
+ case 1 :
+ return optimizedCurrentTokenSource1();
+ case 2 :
+ return optimizedCurrentTokenSource2();
+ case 3 :
+ return optimizedCurrentTokenSource3();
+ case 4 :
+ return optimizedCurrentTokenSource4();
+ case 5 :
+ return optimizedCurrentTokenSource5();
+ case 6 :
+ return optimizedCurrentTokenSource6();
+ }
+ //no optimization
+ System.arraycopy(source, startPosition, result = new char[length], 0, length);
+ }
+ return result;
+}
+public int getCurrentTokenEndPosition(){
+ return this.currentPosition - 1;
+}
+public final char[] getCurrentTokenSource() {
+ // Return the token REAL source (aka unicodes are precomputed)
+
+ char[] result;
+ if (withoutUnicodePtr != 0)
+ // 0 is used as a fast test flag so the real first char is in position 1
+ System.arraycopy(
+ withoutUnicodeBuffer,
+ 1,
+ result = new char[withoutUnicodePtr],
+ 0,
+ withoutUnicodePtr);
+ else {
+ int length;
+ System.arraycopy(
+ source,
+ startPosition,
+ result = new char[length = currentPosition - startPosition],
+ 0,
+ length);
+ }
+ return result;
+}
+public final char[] getCurrentTokenSourceString() {
+ //return the token REAL source (aka unicodes are precomputed).
+ //REMOVE the two " that are at the beginning and the end.
+
+ char[] result;
+ if (withoutUnicodePtr != 0)
+ //0 is used as a fast test flag so the real first char is in position 1
+ System.arraycopy(withoutUnicodeBuffer, 2,
+ //2 is 1 (real start) + 1 (to jump over the ")
+ result = new char[withoutUnicodePtr - 2], 0, withoutUnicodePtr - 2);
+ else {
+ int length;
+ System.arraycopy(
+ source,
+ startPosition + 1,
+ result = new char[length = currentPosition - startPosition - 2],
+ 0,
+ length);
+ }
+ return result;
+}
+
+public final char[] getRawTokenSource() {
+ int length = this.currentPosition - this.startPosition;
+ char[] tokenSource = new char[length];
+ System.arraycopy(source, this.startPosition, tokenSource, 0, length);
+ return tokenSource;
+}
+
+public int getCurrentTokenStartPosition(){
+ return this.startPosition;
+}
+/*
+ * Search the source position corresponding to the end of a given line number
+ *
+ * Line numbers are 1-based, and relative to the scanner initialPosition.
+ * Character positions are 0-based.
+ *
+ * In case the given line number is inconsistent, answers -1.
+ */
+public final int getLineEnd(int lineNumber) {
+
+ if (lineEnds == null) return -1;
+ if (lineNumber >= lineEnds.length) return -1;
+ if (lineNumber <= 0) return -1;
+
+ if (lineNumber == lineEnds.length - 1) return eofPosition;
+ return lineEnds[lineNumber-1]; // next line start one character behind the lineEnd of the previous line
+}
+
+public final int[] getLineEnds() {
+ //return a bounded copy of this.lineEnds
+
+ int[] copy;
+ System.arraycopy(lineEnds, 0, copy = new int[linePtr + 1], 0, linePtr + 1);
+ return copy;
+}
+
+/**
+ * Search the source position corresponding to the beginning of a given line number
+ *
+ * Line numbers are 1-based, and relative to the scanner initialPosition.
+ * Character positions are 0-based.
+ *
+ * e.g. getLineStart(1) --> 0 i.e. first line starts at character 0.
+ *
+ * In case the given line number is inconsistent, answers -1.
+ */
+public final int getLineStart(int lineNumber) {
+
+ if (lineEnds == null) return -1;
+ if (lineNumber >= lineEnds.length) return -1;
+ if (lineNumber <= 0) return -1;
+
+ if (lineNumber == 1) return initialPosition;
+ return lineEnds[lineNumber-2]+1; // next line start one character behind the lineEnd of the previous line
+}
+public final boolean getNextChar(char testedChar) {
+ //BOOLEAN
+ //handle the case of unicode.
+ //when a unicode appears then we must use a buffer that holds char internal values
+ //At the end of this method currentCharacter holds the new visited char
+ //and currentPosition points right next after it
+ //Both previous lines are true if the currentCharacter is == to the testedChar
+ //On false, no side effect has occured.
+
+ //ALL getNextChar.... ARE OPTIMIZED COPIES
+
+ int temp = currentPosition;
+ try {
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ int c1, c2, c3, c4;
+ int unicodeSize = 6;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ unicodeSize++;
+ }
+
+ if (((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[currentPosition++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[currentPosition++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[currentPosition++])) > 15 || c4 < 0)) {
+ currentPosition = temp;
+ return false;
+ }
+
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ if (currentCharacter != testedChar) {
+ currentPosition = temp;
+ return false;
+ }
+ unicodeAsBackSlash = currentCharacter == '\\';
+
+ //need the unicode buffer
+ if (withoutUnicodePtr == 0) {
+ //buffer all the entries that have been left aside....
+ withoutUnicodePtr = currentPosition - unicodeSize - startPosition;
+ System.arraycopy(
+ source,
+ startPosition,
+ withoutUnicodeBuffer,
+ 1,
+ withoutUnicodePtr);
+ }
+ //fill the buffer with the char
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ return true;
+
+ } //-------------end unicode traitement--------------
+ else {
+ if (currentCharacter != testedChar) {
+ currentPosition = temp;
+ return false;
+ }
+ unicodeAsBackSlash = false;
+ if (withoutUnicodePtr != 0)
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ return true;
+ }
+ } catch (IndexOutOfBoundsException e) {
+ unicodeAsBackSlash = false;
+ currentPosition = temp;
+ return false;
+ }
+}
+public final int getNextChar(char testedChar1, char testedChar2) {
+ //INT 0 : testChar1 \\\\///\\\\ 1 : testedChar2 \\\\///\\\\ -1 : others
+ //test can be done with (x==0) for the first and (x>0) for the second
+ //handle the case of unicode.
+ //when a unicode appears then we must use a buffer that holds char internal values
+ //At the end of this method currentCharacter holds the new visited char
+ //and currentPosition points right next after it
+ //Both previous lines are true if the currentCharacter is == to the testedChar1/2
+ //On false, no side effect has occured.
+
+ //ALL getNextChar.... ARE OPTIMIZED COPIES
+
+ int temp = currentPosition;
+ try {
+ int result;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ int c1, c2, c3, c4;
+ int unicodeSize = 6;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ unicodeSize++;
+ }
+
+ if (((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[currentPosition++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[currentPosition++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[currentPosition++])) > 15 || c4 < 0)) {
+ currentPosition = temp;
+ return 2;
+ }
+
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ if (currentCharacter == testedChar1)
+ result = 0;
+ else
+ if (currentCharacter == testedChar2)
+ result = 1;
+ else {
+ currentPosition = temp;
+ return -1;
+ }
+
+ //need the unicode buffer
+ if (withoutUnicodePtr == 0) {
+ //buffer all the entries that have been left aside....
+ withoutUnicodePtr = currentPosition - unicodeSize - startPosition;
+ System.arraycopy(
+ source,
+ startPosition,
+ withoutUnicodeBuffer,
+ 1,
+ withoutUnicodePtr);
+ }
+ //fill the buffer with the char
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ return result;
+ } //-------------end unicode traitement--------------
+ else {
+ if (currentCharacter == testedChar1)
+ result = 0;
+ else
+ if (currentCharacter == testedChar2)
+ result = 1;
+ else {
+ currentPosition = temp;
+ return -1;
+ }
+
+ if (withoutUnicodePtr != 0)
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ return result;
+ }
+ } catch (IndexOutOfBoundsException e) {
+ currentPosition = temp;
+ return -1;
+ }
+}
+public final boolean getNextCharAsDigit() {
+ //BOOLEAN
+ //handle the case of unicode.
+ //when a unicode appears then we must use a buffer that holds char internal values
+ //At the end of this method currentCharacter holds the new visited char
+ //and currentPosition points right next after it
+ //Both previous lines are true if the currentCharacter is a digit
+ //On false, no side effect has occured.
+
+ //ALL getNextChar.... ARE OPTIMIZED COPIES
+
+ int temp = currentPosition;
+ try {
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ int c1, c2, c3, c4;
+ int unicodeSize = 6;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ unicodeSize++;
+ }
+
+ if (((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[currentPosition++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[currentPosition++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[currentPosition++])) > 15 || c4 < 0)) {
+ currentPosition = temp;
+ return false;
+ }
+
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ if (!Character.isDigit(currentCharacter)) {
+ currentPosition = temp;
+ return false;
+ }
+
+ //need the unicode buffer
+ if (withoutUnicodePtr == 0) {
+ //buffer all the entries that have been left aside....
+ withoutUnicodePtr = currentPosition - unicodeSize - startPosition;
+ System.arraycopy(
+ source,
+ startPosition,
+ withoutUnicodeBuffer,
+ 1,
+ withoutUnicodePtr);
+ }
+ //fill the buffer with the char
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ return true;
+ } //-------------end unicode traitement--------------
+ else {
+ if (!Character.isDigit(currentCharacter)) {
+ currentPosition = temp;
+ return false;
+ }
+ if (withoutUnicodePtr != 0)
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ return true;
+ }
+ } catch (IndexOutOfBoundsException e) {
+ currentPosition = temp;
+ return false;
+ }
+}
+public final boolean getNextCharAsDigit(int radix) {
+ //BOOLEAN
+ //handle the case of unicode.
+ //when a unicode appears then we must use a buffer that holds char internal values
+ //At the end of this method currentCharacter holds the new visited char
+ //and currentPosition points right next after it
+ //Both previous lines are true if the currentCharacter is a digit base on radix
+ //On false, no side effect has occured.
+
+ //ALL getNextChar.... ARE OPTIMIZED COPIES
+
+ int temp = currentPosition;
+ try {
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ int c1, c2, c3, c4;
+ int unicodeSize = 6;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ unicodeSize++;
+ }
+
+ if (((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[currentPosition++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[currentPosition++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[currentPosition++])) > 15 || c4 < 0)) {
+ currentPosition = temp;
+ return false;
+ }
+
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ if (Character.digit(currentCharacter, radix) == -1) {
+ currentPosition = temp;
+ return false;
+ }
+
+ //need the unicode buffer
+ if (withoutUnicodePtr == 0) {
+ //buffer all the entries that have been left aside....
+ withoutUnicodePtr = currentPosition - unicodeSize - startPosition;
+ System.arraycopy(
+ source,
+ startPosition,
+ withoutUnicodeBuffer,
+ 1,
+ withoutUnicodePtr);
+ }
+ //fill the buffer with the char
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ return true;
+ } //-------------end unicode traitement--------------
+ else {
+ if (Character.digit(currentCharacter, radix) == -1) {
+ currentPosition = temp;
+ return false;
+ }
+ if (withoutUnicodePtr != 0)
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ return true;
+ }
+ } catch (IndexOutOfBoundsException e) {
+ currentPosition = temp;
+ return false;
+ }
+}
+public boolean getNextCharAsJavaIdentifierPart() {
+ //BOOLEAN
+ //handle the case of unicode.
+ //when a unicode appears then we must use a buffer that holds char internal values
+ //At the end of this method currentCharacter holds the new visited char
+ //and currentPosition points right next after it
+ //Both previous lines are true if the currentCharacter is a JavaIdentifierPart
+ //On false, no side effect has occured.
+
+ //ALL getNextChar.... ARE OPTIMIZED COPIES
+
+ int temp = currentPosition;
+ try {
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ int c1, c2, c3, c4;
+ int unicodeSize = 6;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ unicodeSize++;
+ }
+
+ if (((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[currentPosition++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[currentPosition++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[currentPosition++])) > 15 || c4 < 0)) {
+ currentPosition = temp;
+ return false;
+ }
+
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ if (!Character.isJavaIdentifierPart(currentCharacter)) {
+ currentPosition = temp;
+ return false;
+ }
+
+ //need the unicode buffer
+ if (withoutUnicodePtr == 0) {
+ //buffer all the entries that have been left aside....
+ withoutUnicodePtr = currentPosition - unicodeSize - startPosition;
+ System.arraycopy(
+ source,
+ startPosition,
+ withoutUnicodeBuffer,
+ 1,
+ withoutUnicodePtr);
+ }
+ //fill the buffer with the char
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ return true;
+ } //-------------end unicode traitement--------------
+ else {
+ if (!Character.isJavaIdentifierPart(currentCharacter)) {
+ currentPosition = temp;
+ return false;
+ }
+
+ if (withoutUnicodePtr != 0)
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ return true;
+ }
+ } catch (IndexOutOfBoundsException e) {
+ currentPosition = temp;
+ return false;
+ }
+}
+public int getNextToken() throws InvalidInputException {
+
+ this.wasAcr = false;
+ if (diet) {
+ jumpOverMethodBody();
+ diet = false;
+ return currentPosition > source.length ? TokenNameEOF : TokenNameRBRACE;
+ }
+ int whiteStart = 0;
+ try {
+ while (true) { //loop for jumping over comments
+ withoutUnicodePtr = 0;
+ //start with a new token (even comment written with unicode )
+
+ // ---------Consume white space and handles startPosition---------
+ whiteStart = currentPosition;
+ boolean isWhiteSpace, hasWhiteSpaces = false;
+ int offset = 0;
+ do {
+ startPosition = currentPosition;
+ boolean checkIfUnicode = false;
+ try {
+ checkIfUnicode = ((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u');
+ } catch(IndexOutOfBoundsException e) {
+ if (tokenizeWhiteSpace && (whiteStart != currentPosition - 1)) {
+ // reposition scanner in case we are interested by spaces as tokens
+ currentPosition--;
+ startPosition = whiteStart;
+ return TokenNameWHITESPACE;
+ }
+ if (currentPosition > eofPosition)
+ return TokenNameEOF;
+ }
+ if (checkIfUnicode) {
+ isWhiteSpace = jumpOverUnicodeWhiteSpace();
+ offset = 6;
+ } else {
+ offset = 1;
+ if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+ checkNonExternalizeString();
+ if (recordLineSeparator) {
+ pushLineSeparator();
+ } else {
+ currentLine = null;
+ }
+ }
+ isWhiteSpace =
+ (currentCharacter == ' ') || CharOperation.isWhitespace(currentCharacter);
+ }
+ if (isWhiteSpace) {
+ hasWhiteSpaces = true;
+ }
+ } while (isWhiteSpace);
+ if (tokenizeWhiteSpace && hasWhiteSpaces) {
+ // reposition scanner in case we are interested by spaces as tokens
+ currentPosition-=offset;
+ startPosition = whiteStart;
+ return TokenNameWHITESPACE;
+ }
+ //little trick to get out in the middle of a source compuation
+ if (currentPosition > eofPosition)
+ return TokenNameEOF;
+
+ // ---------Identify the next token-------------
+
+ switch (currentCharacter) {
+ case '(' :
+ return TokenNameLPAREN;
+ case ')' :
+ return TokenNameRPAREN;
+ case '{' :
+ return TokenNameLBRACE;
+ case '}' :
+ return TokenNameRBRACE;
+ case '[' :
+ return TokenNameLBRACKET;
+ case ']' :
+ return TokenNameRBRACKET;
+ case ';' :
+ return TokenNameSEMICOLON;
+ case ',' :
+ return TokenNameCOMMA;
+ case '.' :
+ if (getNextCharAsDigit())
+ return scanNumber(true);
+ return TokenNameDOT;
+ case '+' :
+ {
+ int test;
+ if ((test = getNextChar('+', '=')) == 0)
+ return TokenNamePLUS_PLUS;
+ if (test > 0)
+ return TokenNamePLUS_EQUAL;
+ return TokenNamePLUS;
+ }
+ case '-' :
+ {
+ int test;
+ if ((test = getNextChar('-', '=')) == 0)
+ return TokenNameMINUS_MINUS;
+ if (test > 0)
+ return TokenNameMINUS_EQUAL;
+ return TokenNameMINUS;
+ }
+ case '~' :
+ return TokenNameTWIDDLE;
+ case '!' :
+ if (getNextChar('='))
+ return TokenNameNOT_EQUAL;
+ return TokenNameNOT;
+ case '*' :
+ if (getNextChar('='))
+ return TokenNameMULTIPLY_EQUAL;
+ return TokenNameMULTIPLY;
+ case '%' :
+ if (getNextChar('='))
+ return TokenNameREMAINDER_EQUAL;
+ return TokenNameREMAINDER;
+ case '<' :
+ {
+ int test;
+ if ((test = getNextChar('=', '<')) == 0)
+ return TokenNameLESS_EQUAL;
+ if (test > 0) {
+ if (getNextChar('='))
+ return TokenNameLEFT_SHIFT_EQUAL;
+ return TokenNameLEFT_SHIFT;
+ }
+ return TokenNameLESS;
+ }
+ case '>' :
+ {
+ int test;
+ if ((test = getNextChar('=', '>')) == 0)
+ return TokenNameGREATER_EQUAL;
+ if (test > 0) {
+ if ((test = getNextChar('=', '>')) == 0)
+ return TokenNameRIGHT_SHIFT_EQUAL;
+ if (test > 0) {
+ if (getNextChar('='))
+ return TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL;
+ return TokenNameUNSIGNED_RIGHT_SHIFT;
+ }
+ return TokenNameRIGHT_SHIFT;
+ }
+ return TokenNameGREATER;
+ }
+ case '=' :
+ if (getNextChar('='))
+ return TokenNameEQUAL_EQUAL;
+ return TokenNameEQUAL;
+ case '&' :
+ {
+ int test;
+ if ((test = getNextChar('&', '=')) == 0)
+ return TokenNameAND_AND;
+ if (test > 0)
+ return TokenNameAND_EQUAL;
+ return TokenNameAND;
+ }
+ case '|' :
+ {
+ int test;
+ if ((test = getNextChar('|', '=')) == 0)
+ return TokenNameOR_OR;
+ if (test > 0)
+ return TokenNameOR_EQUAL;
+ return TokenNameOR;
+ }
+ case '^' :
+ if (getNextChar('='))
+ return TokenNameXOR_EQUAL;
+ return TokenNameXOR;
+ case '?' :
+ return TokenNameQUESTION;
+ case ':' :
+ return TokenNameCOLON;
+ case '\'' :
+ {
+ int test;
+ if ((test = getNextChar('\n', '\r')) == 0) {
+ throw new InvalidInputException(INVALID_CHARACTER_CONSTANT);
+ }
+ if (test > 0) {
+ // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed
+ for (int lookAhead = 0; lookAhead < 3; lookAhead++) {
+ if (currentPosition + lookAhead == source.length)
+ break;
+ if (source[currentPosition + lookAhead] == '\n')
+ break;
+ if (source[currentPosition + lookAhead] == '\'') {
+ currentPosition += lookAhead + 1;
+ break;
+ }
+ }
+ throw new InvalidInputException(INVALID_CHARACTER_CONSTANT);
+ }
+ }
+ if (getNextChar('\'')) {
+ // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed
+ for (int lookAhead = 0; lookAhead < 3; lookAhead++) {
+ if (currentPosition + lookAhead == source.length)
+ break;
+ if (source[currentPosition + lookAhead] == '\n')
+ break;
+ if (source[currentPosition + lookAhead] == '\'') {
+ currentPosition += lookAhead + 1;
+ break;
+ }
+ }
+ throw new InvalidInputException(INVALID_CHARACTER_CONSTANT);
+ }
+ if (getNextChar('\\'))
+ scanEscapeCharacter();
+ else { // consume next character
+ unicodeAsBackSlash = false;
+ boolean checkIfUnicode = false;
+ try {
+ checkIfUnicode = ((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u');
+ } catch(IndexOutOfBoundsException e) {
+ if (currentPosition > eofPosition)
+ return TokenNameEOF;
+ throw new InvalidInputException(INVALID_CHARACTER_CONSTANT);
+ }
+ if (checkIfUnicode) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+ }
+ if (getNextChar('\''))
+ return TokenNameCharacterLiteral;
+ // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed
+ for (int lookAhead = 0; lookAhead < 20; lookAhead++) {
+ if (currentPosition + lookAhead == source.length)
+ break;
+ if (source[currentPosition + lookAhead] == '\n')
+ break;
+ if (source[currentPosition + lookAhead] == '\'') {
+ currentPosition += lookAhead + 1;
+ break;
+ }
+ }
+ throw new InvalidInputException(INVALID_CHARACTER_CONSTANT);
+ case '"' :
+ try {
+ // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+
+ while (currentCharacter != '"') {
+ /**** \r and \n are not valid in string literals ****/
+ if ((currentCharacter == '\n') || (currentCharacter == '\r')) {
+ // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed
+ for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
+ if (currentPosition + lookAhead == source.length)
+ break;
+ if (source[currentPosition + lookAhead] == '\n')
+ break;
+ if (source[currentPosition + lookAhead] == '\"') {
+ currentPosition += lookAhead + 1;
+ break;
+ }
+ }
+ throw new InvalidInputException(INVALID_CHAR_IN_STRING);
+ }
+ if (currentCharacter == '\\') {
+ int escapeSize = currentPosition;
+ boolean backSlashAsUnicodeInString = unicodeAsBackSlash;
+ //scanEscapeCharacter make a side effect on this value and we need the previous value few lines down this one
+ scanEscapeCharacter();
+ escapeSize = currentPosition - escapeSize;
+ if (withoutUnicodePtr == 0) {
+ //buffer all the entries that have been left aside....
+ withoutUnicodePtr = currentPosition - escapeSize - 1 - startPosition;
+ System.arraycopy(
+ source,
+ startPosition,
+ withoutUnicodeBuffer,
+ 1,
+ withoutUnicodePtr);
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ } else { //overwrite the / in the buffer
+ withoutUnicodeBuffer[withoutUnicodePtr] = currentCharacter;
+ if (backSlashAsUnicodeInString) { //there are TWO \ in the stream where only one is correct
+ withoutUnicodePtr--;
+ }
+ }
+ }
+ // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+
+ }
+ } catch (IndexOutOfBoundsException e) {
+ throw new InvalidInputException(UNTERMINATED_STRING);
+ } catch (InvalidInputException e) {
+ if (e.getMessage().equals(INVALID_ESCAPE)) {
+ // relocate if finding another quote fairly close: thus unicode '/u000D' will be fully consumed
+ for (int lookAhead = 0; lookAhead < 50; lookAhead++) {
+ if (currentPosition + lookAhead == source.length)
+ break;
+ if (source[currentPosition + lookAhead] == '\n')
+ break;
+ if (source[currentPosition + lookAhead] == '\"') {
+ currentPosition += lookAhead + 1;
+ break;
+ }
+ }
+
+ }
+ throw e; // rethrow
+ }
+ if (checkNonExternalizedStringLiterals){ // check for presence of NLS tags //$NON-NLS-?$ where ? is an int.
+ if (currentLine == null) {
+ currentLine = new NLSLine();
+ }
+ currentLine.add(
+ new StringLiteral(
+ getCurrentTokenSourceString(),
+ startPosition,
+ currentPosition - 1));
+ }
+ return TokenNameStringLiteral;
+ case '/' :
+ {
+ int test;
+ if ((test = getNextChar('/', '*')) == 0) { //line comment
+ try { //get the next char
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ }
+ if ((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0
+ || (c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c2 < 0
+ || (c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c3 < 0
+ || (c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c4 < 0) {
+ throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
+ } else {
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ }
+
+ //handle the \\u case manually into comment
+ if (currentCharacter == '\\') {
+ if (source[currentPosition] == '\\')
+ currentPosition++;
+ } //jump over the \\
+ boolean isUnicode = false;
+ while (currentCharacter != '\r' && currentCharacter != '\n') {
+ //get the next char
+ isUnicode = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ isUnicode = true;
+ //-------------unicode traitement ------------
+ int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ }
+ if ((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0
+ || (c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c2 < 0
+ || (c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c3 < 0
+ || (c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c4 < 0) {
+ throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
+ } else {
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ }
+ //handle the \\u case manually into comment
+ if (currentCharacter == '\\') {
+ if (source[currentPosition] == '\\')
+ currentPosition++;
+ } //jump over the \\
+ }
+ /*
+ * We need to completely consume the line break
+ */
+ if (currentCharacter == '\r'
+ && source.length > currentPosition) {
+ if (source[currentPosition] == '\n') {
+ currentPosition++;
+ currentCharacter = '\n';
+ } else if ((source[currentPosition] == '\\')
+ && (source[currentPosition + 1] == 'u')) {
+ isUnicode = true;
+ char unicodeChar;
+ int index = currentPosition + 1;
+ index++;
+ while (source[index] == 'u') {
+ index++;
+ }
+ //-------------unicode traitement ------------
+ int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
+ if ((c1 = Character.getNumericValue(source[index++])) > 15
+ || c1 < 0
+ || (c2 = Character.getNumericValue(source[index++])) > 15
+ || c2 < 0
+ || (c3 = Character.getNumericValue(source[index++])) > 15
+ || c3 < 0
+ || (c4 = Character.getNumericValue(source[index++])) > 15
+ || c4 < 0) {
+ currentPosition = index;
+ throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
+ } else {
+ unicodeChar = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ if (unicodeChar == '\n') {
+ currentPosition = index;
+ currentCharacter = '\n';
+ }
+ }
+ }
+ recordComment(false);
+ if (this.taskTags != null) checkTaskTag(this.startPosition, this.currentPosition);
+ if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+ checkNonExternalizeString();
+ if (recordLineSeparator) {
+ if (isUnicode) {
+ pushUnicodeLineSeparator();
+ } else {
+ pushLineSeparator();
+ }
+ } else {
+ currentLine = null;
+ }
+ }
+ if (tokenizeComments) {
+ return TokenNameCOMMENT_LINE;
+ }
+ } catch (IndexOutOfBoundsException e) {
+ recordComment(false);
+ if (this.taskTags != null) checkTaskTag(this.startPosition, this.currentPosition-1);
+ if (tokenizeComments) {
+ this.currentPosition--; // reset one character behind
+ return TokenNameCOMMENT_LINE;
+ }
+ }
+ break;
+ }
+ if (test > 0) { //traditional and annotation comment
+ try { //get the next char
+ boolean isJavadoc = false, star = false;
+ boolean isUnicode = false;
+ // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ isUnicode = true;
+ } else {
+ isUnicode = false;
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+
+ if (currentCharacter == '*') {
+ isJavadoc = true;
+ star = true;
+ }
+ if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+ checkNonExternalizeString();
+ if (recordLineSeparator) {
+ if (!isUnicode) {
+ pushLineSeparator();
+ }
+ } else {
+ currentLine = null;
+ }
+ }
+ isUnicode = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ getNextUnicodeChar();
+ isUnicode = true;
+ } else {
+ isUnicode = false;
+ }
+ //handle the \\u case manually into comment
+ if (currentCharacter == '\\') {
+ if (source[currentPosition] == '\\')
+ currentPosition++; //jump over the \\
+ }
+ //loop until end of comment */
+ while ((currentCharacter != '/') || (!star)) {
+ if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+ checkNonExternalizeString();
+ if (recordLineSeparator) {
+ if (!isUnicode) {
+ pushLineSeparator();
+ }
+ } else {
+ currentLine = null;
+ }
+ }
+ star = currentCharacter == '*';
+ //get next char
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ getNextUnicodeChar();
+ isUnicode = true;
+ } else {
+ isUnicode = false;
+ }
+ //handle the \\u case manually into comment
+ if (currentCharacter == '\\') {
+ if (source[currentPosition] == '\\')
+ currentPosition++;
+ } //jump over the \\
+ }
+ recordComment(isJavadoc);
+ if (this.taskTags != null) checkTaskTag(this.startPosition, this.currentPosition);
+ if (tokenizeComments) {
+ if (isJavadoc)
+ return TokenNameCOMMENT_JAVADOC;
+ return TokenNameCOMMENT_BLOCK;
+ }
+ } catch (IndexOutOfBoundsException e) {
+ throw new InvalidInputException(UNTERMINATED_COMMENT);
+ }
+ break;
+ }
+ if (getNextChar('='))
+ return TokenNameDIVIDE_EQUAL;
+ return TokenNameDIVIDE;
+ }
+ case '\u001a' :
+ if (atEnd())
+ return TokenNameEOF;
+ //the atEnd may not be <currentPosition == source.length> if source is only some part of a real (external) stream
+ throw new InvalidInputException("Ctrl-Z"); //$NON-NLS-1$
+
+ default :
+ if (Character.isJavaIdentifierStart(currentCharacter))
+ return scanIdentifierOrKeyword();
+ if (Character.isDigit(currentCharacter))
+ return scanNumber(false);
+ return TokenNameERROR;
+ }
+ }
+ } //-----------------end switch while try--------------------
+ catch (IndexOutOfBoundsException e) {
+ if (tokenizeWhiteSpace && (whiteStart != currentPosition - 1)) {
+ // reposition scanner in case we are interested by spaces as tokens
+ currentPosition--;
+ startPosition = whiteStart;
+ return TokenNameWHITESPACE;
+ }
+ }
+ return TokenNameEOF;
+}
+public final void getNextUnicodeChar()
+ throws IndexOutOfBoundsException, InvalidInputException {
+ //VOID
+ //handle the case of unicode.
+ //when a unicode appears then we must use a buffer that holds char internal values
+ //At the end of this method currentCharacter holds the new visited char
+ //and currentPosition points right next after it
+
+ //ALL getNextChar.... ARE OPTIMIZED COPIES
+
+ int c1 = 0, c2 = 0, c3 = 0, c4 = 0, unicodeSize = 6;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ unicodeSize++;
+ }
+
+ if ((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0
+ || (c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c2 < 0
+ || (c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c3 < 0
+ || (c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c4 < 0){
+ throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
+ } else {
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ //need the unicode buffer
+ if (withoutUnicodePtr == 0) {
+ //buffer all the entries that have been left aside....
+ withoutUnicodePtr = currentPosition - unicodeSize - startPosition;
+ System.arraycopy(
+ source,
+ startPosition,
+ withoutUnicodeBuffer,
+ 1,
+ withoutUnicodePtr);
+ }
+ //fill the buffer with the char
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ unicodeAsBackSlash = currentCharacter == '\\';
+}
+
+public char[] getSource(){
+ return this.source;
+}
+
+/* Tokenize a method body, assuming that curly brackets are properly balanced.
+ */
+public final void jumpOverMethodBody() {
+
+ this.wasAcr = false;
+ int found = 1;
+ try {
+ while (true) { //loop for jumping over comments
+ // ---------Consume white space and handles startPosition---------
+ boolean isWhiteSpace;
+ do {
+ startPosition = currentPosition;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ isWhiteSpace = jumpOverUnicodeWhiteSpace();
+ } else {
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n')))
+ pushLineSeparator();
+ isWhiteSpace = CharOperation.isWhitespace(currentCharacter);
+ }
+ } while (isWhiteSpace);
+
+ // -------consume token until } is found---------
+ switch (currentCharacter) {
+ case '{' :
+ found++;
+ break;
+ case '}' :
+ found--;
+ if (found == 0)
+ return;
+ break;
+ case '\'' :
+ {
+ boolean test;
+ test = getNextChar('\\');
+ if (test) {
+ try {
+ scanEscapeCharacter();
+ } catch (InvalidInputException ex) {
+ };
+ } else {
+ try { // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+ } catch (InvalidInputException ex) {
+ };
+ }
+ getNextChar('\'');
+ break;
+ }
+ case '"' :
+ try {
+ try { // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+ } catch (InvalidInputException ex) {
+ };
+ while (currentCharacter != '"') {
+ if (currentCharacter == '\r'){
+ if (source[currentPosition] == '\n') currentPosition++;
+ break; // the string cannot go further that the line
+ }
+ if (currentCharacter == '\n'){
+ break; // the string cannot go further that the line
+ }
+ if (currentCharacter == '\\') {
+ try {
+ scanEscapeCharacter();
+ } catch (InvalidInputException ex) {
+ };
+ }
+ try { // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+ } catch (InvalidInputException ex) {
+ };
+ }
+ } catch (IndexOutOfBoundsException e) {
+ return;
+ }
+ break;
+ case '/' :
+ {
+ int test;
+ boolean isUnicode;
+ if ((test = getNextChar('/', '*')) == 0) { //line comment
+ try {
+ //get the next char
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ isUnicode = true;
+ int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ }
+ if ((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0
+ || (c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c2 < 0
+ || (c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c3 < 0
+ || (c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c4 < 0) { //error don't care of the value
+ currentCharacter = 'A';
+ } //something different from \n and \r
+ else {
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ } else {
+ isUnicode = false;
+ }
+
+ while (currentCharacter != '\r' && currentCharacter != '\n') {
+ //get the next char
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
+ currentPosition++;
+ isUnicode = true;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ }
+ if ((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0
+ || (c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c2 < 0
+ || (c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c3 < 0
+ || (c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c4 < 0) { //error don't care of the value
+ currentCharacter = 'A';
+ } //something different from \n and \r
+ else {
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ } else {
+ isUnicode = false;
+ }
+ }
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n'))) {
+ if (!isUnicode) {
+ pushLineSeparator();
+ }
+ }
+ } catch (IndexOutOfBoundsException e) {
+ } //an eof will them be generated
+ break;
+ }
+ if (test > 0) { //traditional and annotation comment
+ isUnicode = false;
+ boolean star = false;
+ try { // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ isUnicode = true;
+ } else {
+ isUnicode = false;
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ };
+ } catch (InvalidInputException ex) {
+ };
+ if (currentCharacter == '*') {
+ star = true;
+ }
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n'))) {
+ if (!isUnicode) {
+ pushLineSeparator();
+ }
+ }
+ try { //get the next char
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ isUnicode = true;
+ int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ }
+ if ((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0
+ || (c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c2 < 0
+ || (c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c3 < 0
+ || (c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c4 < 0) { //error don't care of the value
+ currentCharacter = 'A';
+ } //something different from * and /
+ else {
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ } else {
+ isUnicode = false;
+ }
+ //loop until end of comment */
+ while ((currentCharacter != '/') || (!star)) {
+ if (recordLineSeparator
+ && ((currentCharacter == '\r') || (currentCharacter == '\n'))) {
+ if (!isUnicode) {
+ pushLineSeparator();
+ }
+ }
+ star = currentCharacter == '*';
+ //get next char
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ //-------------unicode traitement ------------
+ isUnicode = true;
+ int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ }
+ if ((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0
+ || (c2 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c2 < 0
+ || (c3 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c3 < 0
+ || (c4 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c4 < 0) { //error don't care of the value
+ currentCharacter = 'A';
+ } //something different from * and /
+ else {
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ }
+ } else {
+ isUnicode = false;
+ }
+ }
+ } catch (IndexOutOfBoundsException e) {
+ return;
+ }
+ break;
+ }
+ break;
+ }
+
+ default :
+ if (Character.isJavaIdentifierStart(currentCharacter)) {
+ try {
+ scanIdentifierOrKeyword();
+ } catch (InvalidInputException ex) {
+ };
+ break;
+ }
+ if (Character.isDigit(currentCharacter)) {
+ try {
+ scanNumber(false);
+ } catch (InvalidInputException ex) {
+ };
+ break;
+ }
+ }
+ }
+ //-----------------end switch while try--------------------
+ } catch (IndexOutOfBoundsException e) {
+ } catch (InvalidInputException e) {
+ }
+ return;
+}
+public final boolean jumpOverUnicodeWhiteSpace() throws InvalidInputException {
+ //BOOLEAN
+ //handle the case of unicode. Jump over the next whiteSpace
+ //making startPosition pointing on the next available char
+ //On false, the currentCharacter is filled up with a potential
+ //correct char
+
+ try {
+ this.wasAcr = false;
+ int c1, c2, c3, c4;
+ int unicodeSize = 6;
+ currentPosition++;
+ while (source[currentPosition] == 'u') {
+ currentPosition++;
+ unicodeSize++;
+ }
+
+ if (((c1 = Character.getNumericValue(source[currentPosition++])) > 15
+ || c1 < 0)
+ || ((c2 = Character.getNumericValue(source[currentPosition++])) > 15 || c2 < 0)
+ || ((c3 = Character.getNumericValue(source[currentPosition++])) > 15 || c3 < 0)
+ || ((c4 = Character.getNumericValue(source[currentPosition++])) > 15 || c4 < 0)) {
+ throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
+ }
+
+ currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
+ if (CharOperation.isWhitespace(currentCharacter))
+ return true;
+
+ //buffer the new char which is not a white space
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ //withoutUnicodePtr == 1 is true here
+ return false;
+ } catch (IndexOutOfBoundsException e){
+ throw new InvalidInputException(INVALID_UNICODE_ESCAPE);
+ }
+}
+
+final char[] optimizedCurrentTokenSource1() {
+ //return always the same char[] build only once
+
+ //optimization at no speed cost of 99.5 % of the singleCharIdentifier
+ char charOne = source[startPosition];
+ switch (charOne) {
+ case 'a' :
+ return charArray_a;
+ case 'b' :
+ return charArray_b;
+ case 'c' :
+ return charArray_c;
+ case 'd' :
+ return charArray_d;
+ case 'e' :
+ return charArray_e;
+ case 'f' :
+ return charArray_f;
+ case 'g' :
+ return charArray_g;
+ case 'h' :
+ return charArray_h;
+ case 'i' :
+ return charArray_i;
+ case 'j' :
+ return charArray_j;
+ case 'k' :
+ return charArray_k;
+ case 'l' :
+ return charArray_l;
+ case 'm' :
+ return charArray_m;
+ case 'n' :
+ return charArray_n;
+ case 'o' :
+ return charArray_o;
+ case 'p' :
+ return charArray_p;
+ case 'q' :
+ return charArray_q;
+ case 'r' :
+ return charArray_r;
+ case 's' :
+ return charArray_s;
+ case 't' :
+ return charArray_t;
+ case 'u' :
+ return charArray_u;
+ case 'v' :
+ return charArray_v;
+ case 'w' :
+ return charArray_w;
+ case 'x' :
+ return charArray_x;
+ case 'y' :
+ return charArray_y;
+ case 'z' :
+ return charArray_z;
+ default :
+ return new char[] {charOne};
+ }
+}
+final char[] optimizedCurrentTokenSource2() {
+ //try to return the same char[] build only once
+
+ char c0, c1;
+ int hash =
+ (((c0 = source[startPosition]) << 6) + (c1 = source[startPosition + 1]))
+ % TableSize;
+ char[][] table = charArray_length[0][hash];
+ int i = newEntry2;
+ while (++i < InternalTableSize) {
+ char[] charArray = table[i];
+ if ((c0 == charArray[0]) && (c1 == charArray[1]))
+ return charArray;
+ }
+ //---------other side---------
+ i = -1;
+ int max = newEntry2;
+ while (++i <= max) {
+ char[] charArray = table[i];
+ if ((c0 == charArray[0]) && (c1 == charArray[1]))
+ return charArray;
+ }
+ //--------add the entry-------
+ if (++max >= InternalTableSize) max = 0;
+ char[] r;
+ table[max] = (r = new char[] {c0, c1});
+ newEntry2 = max;
+ return r;
+}
+final char[] optimizedCurrentTokenSource3() {
+ //try to return the same char[] build only once
+
+ char c0, c1, c2;
+ int hash =
+ (((c0 = source[startPosition]) << 12)
+ + ((c1 = source[startPosition + 1]) << 6)
+ + (c2 = source[startPosition + 2]))
+ % TableSize;
+ char[][] table = charArray_length[1][hash];
+ int i = newEntry3;
+ while (++i < InternalTableSize) {
+ char[] charArray = table[i];
+ if ((c0 == charArray[0]) && (c1 == charArray[1]) && (c2 == charArray[2]))
+ return charArray;
+ }
+ //---------other side---------
+ i = -1;
+ int max = newEntry3;
+ while (++i <= max) {
+ char[] charArray = table[i];
+ if ((c0 == charArray[0]) && (c1 == charArray[1]) && (c2 == charArray[2]))
+ return charArray;
+ }
+ //--------add the entry-------
+ if (++max >= InternalTableSize) max = 0;
+ char[] r;
+ table[max] = (r = new char[] {c0, c1, c2});
+ newEntry3 = max;
+ return r;
+}
+final char[] optimizedCurrentTokenSource4() {
+ //try to return the same char[] build only once
+
+ char c0, c1, c2, c3;
+ long hash =
+ ((((long) (c0 = source[startPosition])) << 18)
+ + ((c1 = source[startPosition + 1]) << 12)
+ + ((c2 = source[startPosition + 2]) << 6)
+ + (c3 = source[startPosition + 3]))
+ % TableSize;
+ char[][] table = charArray_length[2][(int) hash];
+ int i = newEntry4;
+ while (++i < InternalTableSize) {
+ char[] charArray = table[i];
+ if ((c0 == charArray[0])
+ && (c1 == charArray[1])
+ && (c2 == charArray[2])
+ && (c3 == charArray[3]))
+ return charArray;
+ }
+ //---------other side---------
+ i = -1;
+ int max = newEntry4;
+ while (++i <= max) {
+ char[] charArray = table[i];
+ if ((c0 == charArray[0])
+ && (c1 == charArray[1])
+ && (c2 == charArray[2])
+ && (c3 == charArray[3]))
+ return charArray;
+ }
+ //--------add the entry-------
+ if (++max >= InternalTableSize) max = 0;
+ char[] r;
+ table[max] = (r = new char[] {c0, c1, c2, c3});
+ newEntry4 = max;
+ return r;
+
+}
+final char[] optimizedCurrentTokenSource5() {
+ //try to return the same char[] build only once
+
+ char c0, c1, c2, c3, c4;
+ long hash =
+ ((((long) (c0 = source[startPosition])) << 24)
+ + (((long) (c1 = source[startPosition + 1])) << 18)
+ + ((c2 = source[startPosition + 2]) << 12)
+ + ((c3 = source[startPosition + 3]) << 6)
+ + (c4 = source[startPosition + 4]))
+ % TableSize;
+ char[][] table = charArray_length[3][(int) hash];
+ int i = newEntry5;
+ while (++i < InternalTableSize) {
+ char[] charArray = table[i];
+ if ((c0 == charArray[0])
+ && (c1 == charArray[1])
+ && (c2 == charArray[2])
+ && (c3 == charArray[3])
+ && (c4 == charArray[4]))
+ return charArray;
+ }
+ //---------other side---------
+ i = -1;
+ int max = newEntry5;
+ while (++i <= max) {
+ char[] charArray = table[i];
+ if ((c0 == charArray[0])
+ && (c1 == charArray[1])
+ && (c2 == charArray[2])
+ && (c3 == charArray[3])
+ && (c4 == charArray[4]))
+ return charArray;
+ }
+ //--------add the entry-------
+ if (++max >= InternalTableSize) max = 0;
+ char[] r;
+ table[max] = (r = new char[] {c0, c1, c2, c3, c4});
+ newEntry5 = max;
+ return r;
+
+}
+final char[] optimizedCurrentTokenSource6() {
+ //try to return the same char[] build only once
+
+ char c0, c1, c2, c3, c4, c5;
+ long hash =
+ ((((long) (c0 = source[startPosition])) << 32)
+ + (((long) (c1 = source[startPosition + 1])) << 24)
+ + (((long) (c2 = source[startPosition + 2])) << 18)
+ + ((c3 = source[startPosition + 3]) << 12)
+ + ((c4 = source[startPosition + 4]) << 6)
+ + (c5 = source[startPosition + 5]))
+ % TableSize;
+ char[][] table = charArray_length[4][(int) hash];
+ int i = newEntry6;
+ while (++i < InternalTableSize) {
+ char[] charArray = table[i];
+ if ((c0 == charArray[0])
+ && (c1 == charArray[1])
+ && (c2 == charArray[2])
+ && (c3 == charArray[3])
+ && (c4 == charArray[4])
+ && (c5 == charArray[5]))
+ return charArray;
+ }
+ //---------other side---------
+ i = -1;
+ int max = newEntry6;
+ while (++i <= max) {
+ char[] charArray = table[i];
+ if ((c0 == charArray[0])
+ && (c1 == charArray[1])
+ && (c2 == charArray[2])
+ && (c3 == charArray[3])
+ && (c4 == charArray[4])
+ && (c5 == charArray[5]))
+ return charArray;
+ }
+ //--------add the entry-------
+ if (++max >= InternalTableSize) max = 0;
+ char[] r;
+ table[max] = (r = new char[] {c0, c1, c2, c3, c4, c5});
+ newEntry6 = max;
+ return r;
+}
+private void parseTags(NLSLine line) throws InvalidInputException {
+ String s = new String(getCurrentTokenSource());
+ int pos = s.indexOf(TAG_PREFIX);
+ int lineLength = line.size();
+ while (pos != -1) {
+ int start = pos + TAG_PREFIX_LENGTH;
+ int end = s.indexOf(TAG_POSTFIX, start);
+ if (end != -1) {
+ String index = s.substring(start, end);
+ int i = 0;
+ try {
+ i = Integer.parseInt(index) - 1; // Tags are one based not zero based.
+ } catch (NumberFormatException e) {
+ i = -1; // we don't want to consider this as a valid NLS tag
+ }
+ if (line.exists(i)) {
+ line.set(i, null);
+ }
+ }
+ pos = s.indexOf(TAG_PREFIX, start);
+ }
+
+ this.nonNLSStrings = new StringLiteral[lineLength];
+ int nonNLSCounter = 0;
+ for (Iterator iterator = line.iterator(); iterator.hasNext(); ) {
+ StringLiteral literal = (StringLiteral) iterator.next();
+ if (literal != null) {
+ this.nonNLSStrings[nonNLSCounter++] = literal;
+ }
+ }
+ if (nonNLSCounter == 0) {
+ this.nonNLSStrings = null;
+ currentLine = null;
+ return;
+ }
+ this.wasNonExternalizedStringLiteral = true;
+ if (nonNLSCounter != lineLength) {
+ System.arraycopy(this.nonNLSStrings, 0, (this.nonNLSStrings = new StringLiteral[nonNLSCounter]), 0, nonNLSCounter);
+ }
+ currentLine = null;
+}
+
+public final void pushLineSeparator() throws InvalidInputException {
+ //see comment on isLineDelimiter(char) for the use of '\n' and '\r'
+ final int INCREMENT = 250;
+
+ if (this.checkNonExternalizedStringLiterals) {
+ // reinitialize the current line for non externalize strings purpose
+ currentLine = null;
+ }
+ //currentCharacter is at position currentPosition-1
+
+ // cr 000D
+ if (currentCharacter == '\r') {
+ int separatorPos = currentPosition - 1;
+ if ((linePtr > 0) && (lineEnds[linePtr] >= separatorPos)) return;
+ //System.out.println("CR-" + separatorPos);
+ try {
+ lineEnds[++linePtr] = separatorPos;
+ } catch (IndexOutOfBoundsException e) {
+ //linePtr value is correct
+ int oldLength = lineEnds.length;
+ int[] old = lineEnds;
+ lineEnds = new int[oldLength + INCREMENT];
+ System.arraycopy(old, 0, lineEnds, 0, oldLength);
+ lineEnds[linePtr] = separatorPos;
+ }
+ // look-ahead for merged cr+lf
+ try {
+ if (source[currentPosition] == '\n') {
+ //System.out.println("look-ahead LF-" + currentPosition);
+ lineEnds[linePtr] = currentPosition;
+ currentPosition++;
+ wasAcr = false;
+ } else {
+ wasAcr = true;
+ }
+ } catch(IndexOutOfBoundsException e) {
+ wasAcr = true;
+ }
+ } else {
+ // lf 000A
+ if (currentCharacter == '\n') { //must merge eventual cr followed by lf
+ if (wasAcr && (lineEnds[linePtr] == (currentPosition - 2))) {
+ //System.out.println("merge LF-" + (currentPosition - 1));
+ lineEnds[linePtr] = currentPosition - 1;
+ } else {
+ int separatorPos = currentPosition - 1;
+ if ((linePtr > 0) && (lineEnds[linePtr] >= separatorPos)) return;
+ // System.out.println("LF-" + separatorPos);
+ try {
+ lineEnds[++linePtr] = separatorPos;
+ } catch (IndexOutOfBoundsException e) {
+ //linePtr value is correct
+ int oldLength = lineEnds.length;
+ int[] old = lineEnds;
+ lineEnds = new int[oldLength + INCREMENT];
+ System.arraycopy(old, 0, lineEnds, 0, oldLength);
+ lineEnds[linePtr] = separatorPos;
+ }
+ }
+ wasAcr = false;
+ }
+ }
+}
+public final void pushUnicodeLineSeparator() {
+ if (this.checkNonExternalizedStringLiterals) {
+ // reinitialize the current line for non externalize strings purpose
+ currentLine = null;
+ }
+
+ // cr 000D
+ if (currentCharacter == '\r') {
+ if (source[currentPosition] == '\n') {
+ wasAcr = false;
+ } else {
+ wasAcr = true;
+ }
+ } else {
+ // lf 000A
+ if (currentCharacter == '\n') { //must merge eventual cr followed by lf
+ wasAcr = false;
+ }
+ }
+}
+public final void recordComment(boolean isJavadoc) {
+
+ // a new annotation comment is recorded
+ try {
+ this.commentStops[++this.commentPtr] = isJavadoc ? this.currentPosition : -this.currentPosition;
+ } catch (IndexOutOfBoundsException e) {
+ int oldStackLength = this.commentStops.length;
+ int[] oldStack = this.commentStops;
+ this.commentStops = new int[oldStackLength + 30];
+ System.arraycopy(oldStack, 0, this.commentStops, 0, oldStackLength);
+ this.commentStops[this.commentPtr] = isJavadoc ? this.currentPosition : -this.currentPosition;
+ //grows the positions buffers too
+ int[] old = this.commentStarts;
+ this.commentStarts = new int[oldStackLength + 30];
+ System.arraycopy(old, 0, this.commentStarts, 0, oldStackLength);
+ }
+
+ //the buffer is of a correct size here
+ this.commentStarts[this.commentPtr] = this.startPosition;
+}
+
+public void resetTo(int begin, int end) {
+ //reset the scanner to a given position where it may rescan again
+
+ diet = false;
+ initialPosition = startPosition = currentPosition = begin;
+ eofPosition = end < Integer.MAX_VALUE ? end + 1 : end;
+ commentPtr = -1; // reset comment stack
+ foundTaskCount = 0;
+
+}
+
+public final void scanEscapeCharacter() throws InvalidInputException {
+ // the string with "\\u" is a legal string of two chars \ and u
+ //thus we use a direct access to the source (for regular cases).
+
+ if (unicodeAsBackSlash) {
+ // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\') && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+ } else
+ currentCharacter = source[currentPosition++];
+ switch (currentCharacter) {
+ case 'b' :
+ currentCharacter = '\b';
+ break;
+ case 't' :
+ currentCharacter = '\t';
+ break;
+ case 'n' :
+ currentCharacter = '\n';
+ break;
+ case 'f' :
+ currentCharacter = '\f';
+ break;
+ case 'r' :
+ currentCharacter = '\r';
+ break;
+ case '\"' :
+ currentCharacter = '\"';
+ break;
+ case '\'' :
+ currentCharacter = '\'';
+ break;
+ case '\\' :
+ currentCharacter = '\\';
+ break;
+ default :
+ // -----------octal escape--------------
+ // OctalDigit
+ // OctalDigit OctalDigit
+ // ZeroToThree OctalDigit OctalDigit
+
+ int number = Character.getNumericValue(currentCharacter);
+ if (number >= 0 && number <= 7) {
+ boolean zeroToThreeNot = number > 3;
+ if (Character.isDigit(currentCharacter = source[currentPosition++])) {
+ int digit = Character.getNumericValue(currentCharacter);
+ if (digit >= 0 && digit <= 7) {
+ number = (number * 8) + digit;
+ if (Character.isDigit(currentCharacter = source[currentPosition++])) {
+ if (zeroToThreeNot) {// has read \NotZeroToThree OctalDigit Digit --> ignore last character
+ currentPosition--;
+ } else {
+ digit = Character.getNumericValue(currentCharacter);
+ if (digit >= 0 && digit <= 7){ // has read \ZeroToThree OctalDigit OctalDigit
+ number = (number * 8) + digit;
+ } else {// has read \ZeroToThree OctalDigit NonOctalDigit --> ignore last character
+ currentPosition--;
+ }
+ }
+ } else { // has read \OctalDigit NonDigit--> ignore last character
+ currentPosition--;
+ }
+ } else { // has read \OctalDigit NonOctalDigit--> ignore last character
+ currentPosition--;
+ }
+ } else { // has read \OctalDigit --> ignore last character
+ currentPosition--;
+ }
+ if (number > 255)
+ throw new InvalidInputException(INVALID_ESCAPE);
+ currentCharacter = (char) number;
+ } else
+ throw new InvalidInputException(INVALID_ESCAPE);
+ }
+}
+public int scanIdentifierOrKeyword() throws InvalidInputException {
+ //test keywords
+
+ //first dispatch on the first char.
+ //then the length. If there are several
+ //keywors with the same length AND the same first char, then do another
+ //dispatch on the second char
+ useAssertAsAnIndentifier = false;
+ while (getNextCharAsJavaIdentifierPart()) {};
+
+ int index, length;
+ char[] data;
+ char firstLetter;
+ if (withoutUnicodePtr == 0)
+
+ //quick test on length == 1 but not on length > 12 while most identifier
+ //have a length which is <= 12...but there are lots of identifier with
+ //only one char....
+
+ {
+ if ((length = currentPosition - startPosition) == 1)
+ return TokenNameIdentifier;
+ data = source;
+ index = startPosition;
+ } else {
+ if ((length = withoutUnicodePtr) == 1)
+ return TokenNameIdentifier;
+ data = withoutUnicodeBuffer;
+ index = 1;
+ }
+
+ firstLetter = data[index];
+ switch (firstLetter) {
+
+ case 'a' :
+ switch(length) {
+ case 8: //abstract
+ if ((data[++index] == 'b')
+ && (data[++index] == 's')
+ && (data[++index] == 't')
+ && (data[++index] == 'r')
+ && (data[++index] == 'a')
+ && (data[++index] == 'c')
+ && (data[++index] == 't')) {
+ return TokenNameabstract;
+ } else {
+ return TokenNameIdentifier;
+ }
+ case 6: // assert
+ if ((data[++index] == 's')
+ && (data[++index] == 's')
+ && (data[++index] == 'e')
+ && (data[++index] == 'r')
+ && (data[++index] == 't')) {
+ if (assertMode) {
+ containsAssertKeyword = true;
+ return TokenNameassert;
+ } else {
+ useAssertAsAnIndentifier = true;
+ return TokenNameIdentifier;
+ }
+ } else {
+ return TokenNameIdentifier;
+ }
+ default:
+ return TokenNameIdentifier;
+ }
+ case 'b' : //boolean break byte
+ switch (length) {
+ case 4 :
+ if ((data[++index] == 'y') && (data[++index] == 't') && (data[++index] == 'e'))
+ return TokenNamebyte;
+ else
+ return TokenNameIdentifier;
+ case 5 :
+ if ((data[++index] == 'r')
+ && (data[++index] == 'e')
+ && (data[++index] == 'a')
+ && (data[++index] == 'k'))
+ return TokenNamebreak;
+ else
+ return TokenNameIdentifier;
+ case 7 :
+ if ((data[++index] == 'o')
+ && (data[++index] == 'o')
+ && (data[++index] == 'l')
+ && (data[++index] == 'e')
+ && (data[++index] == 'a')
+ && (data[++index] == 'n'))
+ return TokenNameboolean;
+ else
+ return TokenNameIdentifier;
+ default :
+ return TokenNameIdentifier;
+ }
+
+ case 'c' : //case char catch const class continue
+ switch (length) {
+ case 4 :
+ if (data[++index] == 'a')
+ if ((data[++index] == 's') && (data[++index] == 'e'))
+ return TokenNamecase;
+ else
+ return TokenNameIdentifier;
+ else
+ if ((data[index] == 'h') && (data[++index] == 'a') && (data[++index] == 'r'))
+ return TokenNamechar;
+ else
+ return TokenNameIdentifier;
+ case 5 :
+ if (data[++index] == 'a')
+ if ((data[++index] == 't') && (data[++index] == 'c') && (data[++index] == 'h'))
+ return TokenNamecatch;
+ else
+ return TokenNameIdentifier;
+ else
+ if ((data[index] == 'l')
+ && (data[++index] == 'a')
+ && (data[++index] == 's')
+ && (data[++index] == 's'))
+ return TokenNameclass;
+ else
+ if ((data[index] == 'o')
+ && (data[++index] == 'n')
+ && (data[++index] == 's')
+ && (data[++index] == 't'))
+ return TokenNameERROR; //const is not used in java ???????
+ else
+ return TokenNameIdentifier;
+ case 8 :
+ if ((data[++index] == 'o')
+ && (data[++index] == 'n')
+ && (data[++index] == 't')
+ && (data[++index] == 'i')
+ && (data[++index] == 'n')
+ && (data[++index] == 'u')
+ && (data[++index] == 'e'))
+ return TokenNamecontinue;
+ else
+ return TokenNameIdentifier;
+ default :
+ return TokenNameIdentifier;
+ }
+
+ case 'd' : //default do double
+ switch (length) {
+ case 2 :
+ if ((data[++index] == 'o'))
+ return TokenNamedo;
+ else
+ return TokenNameIdentifier;
+ case 6 :
+ if ((data[++index] == 'o')
+ && (data[++index] == 'u')
+ && (data[++index] == 'b')
+ && (data[++index] == 'l')
+ && (data[++index] == 'e'))
+ return TokenNamedouble;
+ else
+ return TokenNameIdentifier;
+ case 7 :
+ if ((data[++index] == 'e')
+ && (data[++index] == 'f')
+ && (data[++index] == 'a')
+ && (data[++index] == 'u')
+ && (data[++index] == 'l')
+ && (data[++index] == 't'))
+ return TokenNamedefault;
+ else
+ return TokenNameIdentifier;
+ default :
+ return TokenNameIdentifier;
+ }
+ case 'e' : //else extends
+ switch (length) {
+ case 4 :
+ if ((data[++index] == 'l') && (data[++index] == 's') && (data[++index] == 'e'))
+ return TokenNameelse;
+ else
+ return TokenNameIdentifier;
+ case 7 :
+ if ((data[++index] == 'x')
+ && (data[++index] == 't')
+ && (data[++index] == 'e')
+ && (data[++index] == 'n')
+ && (data[++index] == 'd')
+ && (data[++index] == 's'))
+ return TokenNameextends;
+ else
+ return TokenNameIdentifier;
+ default :
+ return TokenNameIdentifier;
+ }
+
+ case 'f' : //final finally float for false
+ switch (length) {
+ case 3 :
+ if ((data[++index] == 'o') && (data[++index] == 'r'))
+ return TokenNamefor;
+ else
+ return TokenNameIdentifier;
+ case 5 :
+ if (data[++index] == 'i')
+ if ((data[++index] == 'n')
+ && (data[++index] == 'a')
+ && (data[++index] == 'l')) {
+ return TokenNamefinal;
+ } else
+ return TokenNameIdentifier;
+ else
+ if ((data[index] == 'l')
+ && (data[++index] == 'o')
+ && (data[++index] == 'a')
+ && (data[++index] == 't'))
+ return TokenNamefloat;
+ else
+ if ((data[index] == 'a')
+ && (data[++index] == 'l')
+ && (data[++index] == 's')
+ && (data[++index] == 'e'))
+ return TokenNamefalse;
+ else
+ return TokenNameIdentifier;
+ case 7 :
+ if ((data[++index] == 'i')
+ && (data[++index] == 'n')
+ && (data[++index] == 'a')
+ && (data[++index] == 'l')
+ && (data[++index] == 'l')
+ && (data[++index] == 'y'))
+ return TokenNamefinally;
+ else
+ return TokenNameIdentifier;
+
+ default :
+ return TokenNameIdentifier;
+ }
+ case 'g' : //goto
+ if (length == 4) {
+ if ((data[++index] == 'o')
+ && (data[++index] == 't')
+ && (data[++index] == 'o')) {
+ return TokenNameERROR;
+ }
+ } //no goto in java are allowed, so why java removes this keyword ???
+ return TokenNameIdentifier;
+
+ case 'i' : //if implements import instanceof int interface
+ switch (length) {
+ case 2 :
+ if (data[++index] == 'f')
+ return TokenNameif;
+ else
+ return TokenNameIdentifier;
+ case 3 :
+ if ((data[++index] == 'n') && (data[++index] == 't'))
+ return TokenNameint;
+ else
+ return TokenNameIdentifier;
+ case 6 :
+ if ((data[++index] == 'm')
+ && (data[++index] == 'p')
+ && (data[++index] == 'o')
+ && (data[++index] == 'r')
+ && (data[++index] == 't'))
+ return TokenNameimport;
+ else
+ return TokenNameIdentifier;
+ case 9 :
+ if ((data[++index] == 'n')
+ && (data[++index] == 't')
+ && (data[++index] == 'e')
+ && (data[++index] == 'r')
+ && (data[++index] == 'f')
+ && (data[++index] == 'a')
+ && (data[++index] == 'c')
+ && (data[++index] == 'e'))
+ return TokenNameinterface;
+ else
+ return TokenNameIdentifier;
+ case 10 :
+ if (data[++index] == 'm')
+ if ((data[++index] == 'p')
+ && (data[++index] == 'l')
+ && (data[++index] == 'e')
+ && (data[++index] == 'm')
+ && (data[++index] == 'e')
+ && (data[++index] == 'n')
+ && (data[++index] == 't')
+ && (data[++index] == 's'))
+ return TokenNameimplements;
+ else
+ return TokenNameIdentifier;
+ else
+ if ((data[index] == 'n')
+ && (data[++index] == 's')
+ && (data[++index] == 't')
+ && (data[++index] == 'a')
+ && (data[++index] == 'n')
+ && (data[++index] == 'c')
+ && (data[++index] == 'e')
+ && (data[++index] == 'o')
+ && (data[++index] == 'f'))
+ return TokenNameinstanceof;
+ else
+ return TokenNameIdentifier;
+
+ default :
+ return TokenNameIdentifier;
+ }
+
+ case 'l' : //long
+ if (length == 4) {
+ if ((data[++index] == 'o')
+ && (data[++index] == 'n')
+ && (data[++index] == 'g')) {
+ return TokenNamelong;
+ }
+ }
+ return TokenNameIdentifier;
+
+ case 'n' : //native new null
+ switch (length) {
+ case 3 :
+ if ((data[++index] == 'e') && (data[++index] == 'w'))
+ return TokenNamenew;
+ else
+ return TokenNameIdentifier;
+ case 4 :
+ if ((data[++index] == 'u') && (data[++index] == 'l') && (data[++index] == 'l'))
+ return TokenNamenull;
+ else
+ return TokenNameIdentifier;
+ case 6 :
+ if ((data[++index] == 'a')
+ && (data[++index] == 't')
+ && (data[++index] == 'i')
+ && (data[++index] == 'v')
+ && (data[++index] == 'e')) {
+ return TokenNamenative;
+ } else
+ return TokenNameIdentifier;
+ default :
+ return TokenNameIdentifier;
+ }
+
+ case 'p' : //package private protected public
+ switch (length) {
+ case 6 :
+ if ((data[++index] == 'u')
+ && (data[++index] == 'b')
+ && (data[++index] == 'l')
+ && (data[++index] == 'i')
+ && (data[++index] == 'c')) {
+ return TokenNamepublic;
+ } else
+ return TokenNameIdentifier;
+ case 7 :
+ if (data[++index] == 'a')
+ if ((data[++index] == 'c')
+ && (data[++index] == 'k')
+ && (data[++index] == 'a')
+ && (data[++index] == 'g')
+ && (data[++index] == 'e'))
+ return TokenNamepackage;
+ else
+ return TokenNameIdentifier;
+ else
+ if ((data[index] == 'r')
+ && (data[++index] == 'i')
+ && (data[++index] == 'v')
+ && (data[++index] == 'a')
+ && (data[++index] == 't')
+ && (data[++index] == 'e')) {
+ return TokenNameprivate;
+ } else
+ return TokenNameIdentifier;
+ case 9 :
+ if ((data[++index] == 'r')
+ && (data[++index] == 'o')
+ && (data[++index] == 't')
+ && (data[++index] == 'e')
+ && (data[++index] == 'c')
+ && (data[++index] == 't')
+ && (data[++index] == 'e')
+ && (data[++index] == 'd')) {
+ return TokenNameprotected;
+ } else
+ return TokenNameIdentifier;
+
+ default :
+ return TokenNameIdentifier;
+ }
+
+ case 'r' : //return
+ if (length == 6) {
+ if ((data[++index] == 'e')
+ && (data[++index] == 't')
+ && (data[++index] == 'u')
+ && (data[++index] == 'r')
+ && (data[++index] == 'n')) {
+ return TokenNamereturn;
+ }
+ }
+ return TokenNameIdentifier;
+
+ case 's' : //short static super switch synchronized strictfp
+ switch (length) {
+ case 5 :
+ if (data[++index] == 'h')
+ if ((data[++index] == 'o') && (data[++index] == 'r') && (data[++index] == 't'))
+ return TokenNameshort;
+ else
+ return TokenNameIdentifier;
+ else
+ if ((data[index] == 'u')
+ && (data[++index] == 'p')
+ && (data[++index] == 'e')
+ && (data[++index] == 'r'))
+ return TokenNamesuper;
+ else
+ return TokenNameIdentifier;
+
+ case 6 :
+ if (data[++index] == 't')
+ if ((data[++index] == 'a')
+ && (data[++index] == 't')
+ && (data[++index] == 'i')
+ && (data[++index] == 'c')) {
+ return TokenNamestatic;
+ } else
+ return TokenNameIdentifier;
+ else
+ if ((data[index] == 'w')
+ && (data[++index] == 'i')
+ && (data[++index] == 't')
+ && (data[++index] == 'c')
+ && (data[++index] == 'h'))
+ return TokenNameswitch;
+ else
+ return TokenNameIdentifier;
+ case 8 :
+ if ((data[++index] == 't')
+ && (data[++index] == 'r')
+ && (data[++index] == 'i')
+ && (data[++index] == 'c')
+ && (data[++index] == 't')
+ && (data[++index] == 'f')
+ && (data[++index] == 'p'))
+ return TokenNamestrictfp;
+ else
+ return TokenNameIdentifier;
+ case 12 :
+ if ((data[++index] == 'y')
+ && (data[++index] == 'n')
+ && (data[++index] == 'c')
+ && (data[++index] == 'h')
+ && (data[++index] == 'r')
+ && (data[++index] == 'o')
+ && (data[++index] == 'n')
+ && (data[++index] == 'i')
+ && (data[++index] == 'z')
+ && (data[++index] == 'e')
+ && (data[++index] == 'd')) {
+ return TokenNamesynchronized;
+ } else
+ return TokenNameIdentifier;
+ default :
+ return TokenNameIdentifier;
+ }
+
+ case 't' : //try throw throws transient this true
+ switch (length) {
+ case 3 :
+ if ((data[++index] == 'r') && (data[++index] == 'y'))
+ return TokenNametry;
+ else
+ return TokenNameIdentifier;
+ case 4 :
+ if ((data[++index] == 'h') && (data[++index] == 'i') && (data[++index] == 's'))
+ return TokenNamethis;
+ else
+ if ((data[index] == 'r') && (data[++index] == 'u') && (data[++index] == 'e'))
+ return TokenNametrue;
+ else
+ return TokenNameIdentifier;
+ case 5 :
+ if ((data[++index] == 'h')
+ && (data[++index] == 'r')
+ && (data[++index] == 'o')
+ && (data[++index] == 'w'))
+ return TokenNamethrow;
+ else
+ return TokenNameIdentifier;
+ case 6 :
+ if ((data[++index] == 'h')
+ && (data[++index] == 'r')
+ && (data[++index] == 'o')
+ && (data[++index] == 'w')
+ && (data[++index] == 's'))
+ return TokenNamethrows;
+ else
+ return TokenNameIdentifier;
+ case 9 :
+ if ((data[++index] == 'r')
+ && (data[++index] == 'a')
+ && (data[++index] == 'n')
+ && (data[++index] == 's')
+ && (data[++index] == 'i')
+ && (data[++index] == 'e')
+ && (data[++index] == 'n')
+ && (data[++index] == 't')) {
+ return TokenNametransient;
+ } else
+ return TokenNameIdentifier;
+
+ default :
+ return TokenNameIdentifier;
+ }
+
+ case 'v' : //void volatile
+ switch (length) {
+ case 4 :
+ if ((data[++index] == 'o') && (data[++index] == 'i') && (data[++index] == 'd'))
+ return TokenNamevoid;
+ else
+ return TokenNameIdentifier;
+ case 8 :
+ if ((data[++index] == 'o')
+ && (data[++index] == 'l')
+ && (data[++index] == 'a')
+ && (data[++index] == 't')
+ && (data[++index] == 'i')
+ && (data[++index] == 'l')
+ && (data[++index] == 'e')) {
+ return TokenNamevolatile;
+ } else
+ return TokenNameIdentifier;
+
+ default :
+ return TokenNameIdentifier;
+ }
+
+ case 'w' : //while widefp
+ switch (length) {
+ case 5 :
+ if ((data[++index] == 'h')
+ && (data[++index] == 'i')
+ && (data[++index] == 'l')
+ && (data[++index] == 'e'))
+ return TokenNamewhile;
+ else
+ return TokenNameIdentifier;
+ //case 6:if ( (data[++index] =='i') && (data[++index]=='d') && (data[++index]=='e') && (data[++index]=='f')&& (data[++index]=='p'))
+ //return TokenNamewidefp ;
+ //else
+ //return TokenNameIdentifier;
+ default :
+ return TokenNameIdentifier;
+ }
+
+ default :
+ return TokenNameIdentifier;
+ }
+}
+public int scanNumber(boolean dotPrefix) throws InvalidInputException {
+
+ //when entering this method the currentCharacter is the firt
+ //digit of the number , i.e. it may be preceeded by a . when
+ //dotPrefix is true
+
+ boolean floating = dotPrefix;
+ if ((!dotPrefix) && (currentCharacter == '0')) {
+ if (getNextChar('x', 'X') >= 0) { //----------hexa-----------------
+ //force the first char of the hexa number do exist...
+ // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+ if (Character.digit(currentCharacter, 16) == -1)
+ throw new InvalidInputException(INVALID_HEXA);
+ //---end forcing--
+ while (getNextCharAsDigit(16)) {};
+ if (getNextChar('l', 'L') >= 0)
+ return TokenNameLongLiteral;
+ else
+ return TokenNameIntegerLiteral;
+ }
+
+ //there is x or X in the number
+ //potential octal ! ... some one may write 000099.0 ! thus 00100 < 00078.0 is true !!!!! crazy language
+ if (getNextCharAsDigit()) { //-------------potential octal-----------------
+ while (getNextCharAsDigit()) {};
+
+ if (getNextChar('l', 'L') >= 0) {
+ return TokenNameLongLiteral;
+ }
+
+ if (getNextChar('f', 'F') >= 0) {
+ return TokenNameFloatingPointLiteral;
+ }
+
+ if (getNextChar('d', 'D') >= 0) {
+ return TokenNameDoubleLiteral;
+ } else { //make the distinction between octal and float ....
+ boolean isInteger = true;
+ if (getNextChar('.')) {
+ isInteger = false;
+ while (getNextCharAsDigit()) {};
+ }
+ if (getNextChar('e', 'E') >= 0) { // consume next character
+ isInteger = false;
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+
+ if ((currentCharacter == '-')
+ || (currentCharacter == '+')) { // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+ }
+ if (!Character.isDigit(currentCharacter))
+ throw new InvalidInputException(INVALID_FLOAT);
+ while (getNextCharAsDigit()) {};
+ }
+ if (getNextChar('f', 'F') >= 0)
+ return TokenNameFloatingPointLiteral;
+ if (getNextChar('d', 'D') >= 0 || !isInteger)
+ return TokenNameDoubleLiteral;
+ return TokenNameIntegerLiteral;
+ }
+ } else {
+ /* carry on */
+ }
+ }
+
+ while (getNextCharAsDigit()) {};
+
+ if ((!dotPrefix) && (getNextChar('l', 'L') >= 0))
+ return TokenNameLongLiteral;
+
+ if ((!dotPrefix) && (getNextChar('.'))) { //decimal part that can be empty
+ while (getNextCharAsDigit()) {};
+ floating = true;
+ }
+
+ //if floating is true both exponant and suffix may be optional
+
+ if (getNextChar('e', 'E') >= 0) {
+ floating = true;
+ // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+
+ if ((currentCharacter == '-')
+ || (currentCharacter == '+')) { // consume next character
+ unicodeAsBackSlash = false;
+ if (((currentCharacter = source[currentPosition++]) == '\\')
+ && (source[currentPosition] == 'u')) {
+ getNextUnicodeChar();
+ } else {
+ if (withoutUnicodePtr != 0) {
+ withoutUnicodeBuffer[++withoutUnicodePtr] = currentCharacter;
+ }
+ }
+ }
+ if (!Character.isDigit(currentCharacter))
+ throw new InvalidInputException(INVALID_FLOAT);
+ while (getNextCharAsDigit()) {};
+ }
+
+ if (getNextChar('d', 'D') >= 0)
+ return TokenNameDoubleLiteral;
+ if (getNextChar('f', 'F') >= 0)
+ return TokenNameFloatingPointLiteral;
+
+ //the long flag has been tested before
+
+ return floating ? TokenNameDoubleLiteral : TokenNameIntegerLiteral;
+}
+/**
+ * Search the line number corresponding to a specific position
+ *
+ */
+public final int getLineNumber(int position) {
+
+ if (lineEnds == null)
+ return 1;
+ int length = linePtr+1;
+ if (length == 0)
+ return 1;
+ int g = 0, d = length - 1;
+ int m = 0;
+ while (g <= d) {
+ m = (g + d) /2;
+ if (position < lineEnds[m]) {
+ d = m-1;
+ } else if (position > lineEnds[m]) {
+ g = m+1;
+ } else {
+ return m + 1;
+ }
+ }
+ if (position < lineEnds[m]) {
+ return m+1;
+ }
+ return m+2;
+}
+public final void setSource(char[] source){
+ //the source-buffer is set to sourceString
+
+ if (source == null) {
+ this.source = CharOperation.NO_CHAR;
+ } else {
+ this.source = source;
+ }
+ startPosition = -1;
+ eofPosition = source.length;
+ initialPosition = currentPosition = 0;
+ containsAssertKeyword = false;
+ withoutUnicodeBuffer = new char[this.source.length];
+
+}
+
+public String toString() {
+ if (startPosition == source.length)
+ return "EOF\n\n" + new String(source); //$NON-NLS-1$
+ if (currentPosition > source.length)
+ return "behind the EOF :-( ....\n\n" + new String(source); //$NON-NLS-1$
+
+ char front[] = new char[startPosition];
+ System.arraycopy(source, 0, front, 0, startPosition);
+
+ int middleLength = (currentPosition - 1) - startPosition + 1;
+ char middle[];
+ if (middleLength > -1) {
+ middle = new char[middleLength];
+ System.arraycopy(
+ source,
+ startPosition,
+ middle,
+ 0,
+ middleLength);
+ } else {
+ middle = CharOperation.NO_CHAR;
+ }
+
+ char end[] = new char[source.length - (currentPosition - 1)];
+ System.arraycopy(
+ source,
+ (currentPosition - 1) + 1,
+ end,
+ 0,
+ source.length - (currentPosition - 1) - 1);
+
+ return new String(front)
+ + "\n===============================\nStarts here -->" //$NON-NLS-1$
+ + new String(middle)
+ + "<-- Ends here\n===============================\n" //$NON-NLS-1$
+ + new String(end);
+}
+public final String toStringAction(int act) {
+ switch (act) {
+ case TokenNameIdentifier :
+ return "Identifier(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ case TokenNameabstract :
+ return "abstract"; //$NON-NLS-1$
+ case TokenNameboolean :
+ return "boolean"; //$NON-NLS-1$
+ case TokenNamebreak :
+ return "break"; //$NON-NLS-1$
+ case TokenNamebyte :
+ return "byte"; //$NON-NLS-1$
+ case TokenNamecase :
+ return "case"; //$NON-NLS-1$
+ case TokenNamecatch :
+ return "catch"; //$NON-NLS-1$
+ case TokenNamechar :
+ return "char"; //$NON-NLS-1$
+ case TokenNameclass :
+ return "class"; //$NON-NLS-1$
+ case TokenNamecontinue :
+ return "continue"; //$NON-NLS-1$
+ case TokenNamedefault :
+ return "default"; //$NON-NLS-1$
+ case TokenNamedo :
+ return "do"; //$NON-NLS-1$
+ case TokenNamedouble :
+ return "double"; //$NON-NLS-1$
+ case TokenNameelse :
+ return "else"; //$NON-NLS-1$
+ case TokenNameextends :
+ return "extends"; //$NON-NLS-1$
+ case TokenNamefalse :
+ return "false"; //$NON-NLS-1$
+ case TokenNamefinal :
+ return "final"; //$NON-NLS-1$
+ case TokenNamefinally :
+ return "finally"; //$NON-NLS-1$
+ case TokenNamefloat :
+ return "float"; //$NON-NLS-1$
+ case TokenNamefor :
+ return "for"; //$NON-NLS-1$
+ case TokenNameif :
+ return "if"; //$NON-NLS-1$
+ case TokenNameimplements :
+ return "implements"; //$NON-NLS-1$
+ case TokenNameimport :
+ return "import"; //$NON-NLS-1$
+ case TokenNameinstanceof :
+ return "instanceof"; //$NON-NLS-1$
+ case TokenNameint :
+ return "int"; //$NON-NLS-1$
+ case TokenNameinterface :
+ return "interface"; //$NON-NLS-1$
+ case TokenNamelong :
+ return "long"; //$NON-NLS-1$
+ case TokenNamenative :
+ return "native"; //$NON-NLS-1$
+ case TokenNamenew :
+ return "new"; //$NON-NLS-1$
+ case TokenNamenull :
+ return "null"; //$NON-NLS-1$
+ case TokenNamepackage :
+ return "package"; //$NON-NLS-1$
+ case TokenNameprivate :
+ return "private"; //$NON-NLS-1$
+ case TokenNameprotected :
+ return "protected"; //$NON-NLS-1$
+ case TokenNamepublic :
+ return "public"; //$NON-NLS-1$
+ case TokenNamereturn :
+ return "return"; //$NON-NLS-1$
+ case TokenNameshort :
+ return "short"; //$NON-NLS-1$
+ case TokenNamestatic :
+ return "static"; //$NON-NLS-1$
+ case TokenNamesuper :
+ return "super"; //$NON-NLS-1$
+ case TokenNameswitch :
+ return "switch"; //$NON-NLS-1$
+ case TokenNamesynchronized :
+ return "synchronized"; //$NON-NLS-1$
+ case TokenNamethis :
+ return "this"; //$NON-NLS-1$
+ case TokenNamethrow :
+ return "throw"; //$NON-NLS-1$
+ case TokenNamethrows :
+ return "throws"; //$NON-NLS-1$
+ case TokenNametransient :
+ return "transient"; //$NON-NLS-1$
+ case TokenNametrue :
+ return "true"; //$NON-NLS-1$
+ case TokenNametry :
+ return "try"; //$NON-NLS-1$
+ case TokenNamevoid :
+ return "void"; //$NON-NLS-1$
+ case TokenNamevolatile :
+ return "volatile"; //$NON-NLS-1$
+ case TokenNamewhile :
+ return "while"; //$NON-NLS-1$
+
+ case TokenNameIntegerLiteral :
+ return "Integer(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ case TokenNameLongLiteral :
+ return "Long(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ case TokenNameFloatingPointLiteral :
+ return "Float(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ case TokenNameDoubleLiteral :
+ return "Double(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ case TokenNameCharacterLiteral :
+ return "Char(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ case TokenNameStringLiteral :
+ return "String(" + new String(getCurrentTokenSource()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+
+ case TokenNamePLUS_PLUS :
+ return "++"; //$NON-NLS-1$
+ case TokenNameMINUS_MINUS :
+ return "--"; //$NON-NLS-1$
+ case TokenNameEQUAL_EQUAL :
+ return "=="; //$NON-NLS-1$
+ case TokenNameLESS_EQUAL :
+ return "<="; //$NON-NLS-1$
+ case TokenNameGREATER_EQUAL :
+ return ">="; //$NON-NLS-1$
+ case TokenNameNOT_EQUAL :
+ return "!="; //$NON-NLS-1$
+ case TokenNameLEFT_SHIFT :
+ return "<<"; //$NON-NLS-1$
+ case TokenNameRIGHT_SHIFT :
+ return ">>"; //$NON-NLS-1$
+ case TokenNameUNSIGNED_RIGHT_SHIFT :
+ return ">>>"; //$NON-NLS-1$
+ case TokenNamePLUS_EQUAL :
+ return "+="; //$NON-NLS-1$
+ case TokenNameMINUS_EQUAL :
+ return "-="; //$NON-NLS-1$
+ case TokenNameMULTIPLY_EQUAL :
+ return "*="; //$NON-NLS-1$
+ case TokenNameDIVIDE_EQUAL :
+ return "/="; //$NON-NLS-1$
+ case TokenNameAND_EQUAL :
+ return "&="; //$NON-NLS-1$
+ case TokenNameOR_EQUAL :
+ return "|="; //$NON-NLS-1$
+ case TokenNameXOR_EQUAL :
+ return "^="; //$NON-NLS-1$
+ case TokenNameREMAINDER_EQUAL :
+ return "%="; //$NON-NLS-1$
+ case TokenNameLEFT_SHIFT_EQUAL :
+ return "<<="; //$NON-NLS-1$
+ case TokenNameRIGHT_SHIFT_EQUAL :
+ return ">>="; //$NON-NLS-1$
+ case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL :
+ return ">>>="; //$NON-NLS-1$
+ case TokenNameOR_OR :
+ return "||"; //$NON-NLS-1$
+ case TokenNameAND_AND :
+ return "&&"; //$NON-NLS-1$
+ case TokenNamePLUS :
+ return "+"; //$NON-NLS-1$
+ case TokenNameMINUS :
+ return "-"; //$NON-NLS-1$
+ case TokenNameNOT :
+ return "!"; //$NON-NLS-1$
+ case TokenNameREMAINDER :
+ return "%"; //$NON-NLS-1$
+ case TokenNameXOR :
+ return "^"; //$NON-NLS-1$
+ case TokenNameAND :
+ return "&"; //$NON-NLS-1$
+ case TokenNameMULTIPLY :
+ return "*"; //$NON-NLS-1$
+ case TokenNameOR :
+ return "|"; //$NON-NLS-1$
+ case TokenNameTWIDDLE :
+ return "~"; //$NON-NLS-1$
+ case TokenNameDIVIDE :
+ return "/"; //$NON-NLS-1$
+ case TokenNameGREATER :
+ return ">"; //$NON-NLS-1$
+ case TokenNameLESS :
+ return "<"; //$NON-NLS-1$
+ case TokenNameLPAREN :
+ return "("; //$NON-NLS-1$
+ case TokenNameRPAREN :
+ return ")"; //$NON-NLS-1$
+ case TokenNameLBRACE :
+ return "{"; //$NON-NLS-1$
+ case TokenNameRBRACE :
+ return "}"; //$NON-NLS-1$
+ case TokenNameLBRACKET :
+ return "["; //$NON-NLS-1$
+ case TokenNameRBRACKET :
+ return "]"; //$NON-NLS-1$
+ case TokenNameSEMICOLON :
+ return ";"; //$NON-NLS-1$
+ case TokenNameQUESTION :
+ return "?"; //$NON-NLS-1$
+ case TokenNameCOLON :
+ return ":"; //$NON-NLS-1$
+ case TokenNameCOMMA :
+ return ","; //$NON-NLS-1$
+ case TokenNameDOT :
+ return "."; //$NON-NLS-1$
+ case TokenNameEQUAL :
+ return "="; //$NON-NLS-1$
+ case TokenNameEOF :
+ return "EOF"; //$NON-NLS-1$
+ default :
+ return "not-a-token"; //$NON-NLS-1$
+ }
+}
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ReferenceInfoAdapter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ReferenceInfoAdapter.java
index 28c8075..888d238 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ReferenceInfoAdapter.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ReferenceInfoAdapter.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SimpleLookupTable.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SimpleLookupTable.java
similarity index 89%
rename from org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SimpleLookupTable.java
rename to org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SimpleLookupTable.java
index 89e6c20..9ac45d7 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/SimpleLookupTable.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SimpleLookupTable.java
@@ -1,14 +1,14 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.internal.core.builder;
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.util;
/**
* A simple lookup table is a non-synchronized Hashtable, whose keys
@@ -18,8 +18,8 @@
public final class SimpleLookupTable implements Cloneable {
// to avoid using Enumerations, walk the individual tables skipping nulls
-public Object keyTable[];
-public Object valueTable[];
+public Object[] keyTable;
+public Object[] valueTable;
public int elementSize; // number of elements in the table
public int threshold;
@@ -73,6 +73,14 @@
return null;
}
+public Object keyForValue(Object valueToMatch) {
+ if (valueToMatch != null)
+ for (int i = 0, l = valueTable.length; i < l; i++)
+ if (valueToMatch.equals(valueTable[i]))
+ return keyTable[i];
+ return null;
+}
+
public Object put(Object key, Object value) {
int length = keyTable.length;
int index = (key.hashCode() & 0x7FFFFFFF) % length;
@@ -137,9 +145,9 @@
public String toString() {
String s = ""; //$NON-NLS-1$
Object object;
- for (int i = 0, length = valueTable.length; i < length; i++)
+ for (int i = 0, l = valueTable.length; i < l; i++)
if ((object = valueTable[i]) != null)
s += keyTable[i].toString() + " -> " + object.toString() + "\n"; //$NON-NLS-2$ //$NON-NLS-1$
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SourceFileAttribute.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SourceFileAttribute.java
index 122efcc..a2f3b41 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SourceFileAttribute.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/SourceFileAttribute.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import org.eclipse.jdt.core.util.ClassFormatException;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringHashtableOfInt.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringHashtableOfInt.java
deleted file mode 100644
index 7be34a3..0000000
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/StringHashtableOfInt.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.internal.core.util;
-
-/**
- * A hash table keyed by strings and with int values.
- */
-public class StringHashtableOfInt {
- // to avoid using Enumerations, walk the individual tables skipping nulls
- public String[] keyTable;
- public int[] valueTable;
-
- int elementSize; // number of elements in the table
- int threshold;
-public StringHashtableOfInt() {
- this(13);
-}
-public StringHashtableOfInt(int size) {
- this.elementSize = 0;
- this.threshold = size; // size represents the expected number of elements
- int extraRoom = (int) (size * 1.75f);
- if (this.threshold == extraRoom)
- extraRoom++;
- this.keyTable = new String[extraRoom];
- this.valueTable = new int[extraRoom];
-}
-public boolean containsKey(String key) {
- int index = (key.hashCode() & 0x7FFFFFFF) % valueTable.length;
- String currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.equals(key))
- return true;
- index = (index + 1) % keyTable.length;
- }
- return false;
-}
-/**
- * Returns the value at the given key.
- * Returns -1 if not found.
- */
-public int get(String key) {
- int index = (key.hashCode() & 0x7FFFFFFF) % valueTable.length;
- String currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.equals(key))
- return valueTable[index];
- index = (index + 1) % keyTable.length;
- }
- return -1;
-}
-public int put(String key, int value) {
- int index = (key.hashCode() & 0x7FFFFFFF) % valueTable.length;
- String currentKey;
- while ((currentKey = keyTable[index]) != null) {
- if (currentKey.equals(key))
- return valueTable[index] = value;
- index = (index + 1) % keyTable.length;
- }
- keyTable[index] = key;
- valueTable[index] = value;
-
- // assumes the threshold is never equal to the size of the table
- if (++elementSize > threshold)
- rehash();
- return value;
-}
-private void rehash() {
- StringHashtableOfInt newHashtable = new StringHashtableOfInt(elementSize * 2); // double the number of expected elements
- String currentKey;
- for (int i = keyTable.length; --i >= 0;)
- if ((currentKey = keyTable[i]) != null)
- newHashtable.put(currentKey, valueTable[i]);
-
- this.keyTable = newHashtable.keyTable;
- this.valueTable = newHashtable.valueTable;
- this.threshold = newHashtable.threshold;
-}
-public int size() {
- return elementSize;
-}
-/**
- * Return the keys sorted by their values.
- */
-public String[] sortedKeys(int maxValue) {
- String[] result = new String[this.elementSize];
-
- // compute a list of the end positions of each layer in result
- int[] endPos = new int[maxValue+1];
- int length = this.keyTable.length;
- for (int i = 0; i < length; i++) {
- String key = this.keyTable[i];
- if (key != null) {
- for (int j = this.valueTable[i]; j <= maxValue; j++) {
- endPos[j]++;
- }
- }
- }
-
- // store the keys in order of their values
- for (int i = 0; i < length; i++) {
- String key = this.keyTable[i];
- if (key != null) {
- int value = this.valueTable[i];
- int index = --endPos[value];
- result[index] = key;
- }
- }
-
- return result;
-}
-public String toString() {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0, length = this.valueTable.length; i < length; i++) {
- String key = this.keyTable[i];
- if (key != null) {
- buffer.append(key);
- buffer.append(" -> "); //$NON-NLS-1$
- buffer.append(this.valueTable[i]);
- buffer.append("\n"); //$NON-NLS-1$
- }
- }
- return buffer.toString();
-}
-}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ToStringSorter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ToStringSorter.java
index 599e956..a69e341 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ToStringSorter.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ToStringSorter.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
/**
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
index cd0c73a..653ae83 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
@@ -1,20 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.util;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
/**
* Provides convenient utility methods to other types in this package.
@@ -29,10 +29,15 @@
"org.eclipse.jdt.internal.core.util.messages"; //$NON-NLS-1$
static {
- /**
- * Creates a NLS catalog for the given locale.
- */
+ /**
+ * Creates a NLS catalog for the given locale.
+ */
+ try {
bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+ } catch(MissingResourceException e) {
+ System.out.println("Missing resource : " + bundleName.replace('.', '/') + ".properties for locale " + Locale.getDefault()); //$NON-NLS-1$//$NON-NLS-2$
+ throw e;
+ }
}
/**
@@ -114,4 +119,4 @@
return output.toString();
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties
index fadae6a..6983661 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties
@@ -1,7 +1,18 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
### Disassembler messages
### disassembler
classfileformat.targetoption = Version (target {0})
+disassembler.description = Default classfile disassembler
disassembler.opentypedeclaration =\ {
disassembler.closetypedeclaration = }
disassembler.parametername = arg
@@ -18,12 +29,6 @@
disassembler.arraydimensions = []
disassembler.constructor_method_name =
disassembler.parameternameinmethodinvocation =
-disassembler.constantstring = <String
-disassembler.constantinteger = <Integer
-disassembler.constantfloat = <Float
-disassembler.constantdouble = <Double
-disassembler.constantlong = <Long
-disassembler.closeconstant = >
disassembler.innerattributesheader = Inner classes attributes:
disassembler.inner_class_info_name = inner class info name:
disassembler.outer_class_info_name = outer class info name:
@@ -35,7 +40,7 @@
disassembler.codeattributeheader = Code attribute:
disassembler.tab = \t
disassembler.constantpoolindex =\ #
-disassembler.classmemberseparator = >
+disassembler.classmemberseparator = #
disassembler.space = \
disassembler.comma = ,
disassembler.openinnerclassentry = [
@@ -46,22 +51,6 @@
classfileformat.magicnumber = - magic:\
classfileformat.minorversion = - minor:\
classfileformat.majorversion = - major:\
-classfileformat.acc_abstract = abstract
-classfileformat.acc_final = final
-classfileformat.acc_native = native
-classfileformat.acc_private = private
-classfileformat.acc_protected = protected
-classfileformat.acc_public = public
-classfileformat.acc_static = static
-classfileformat.acc_strict = strict
-classfileformat.acc_synchronized = synchronized
-classfileformat.acc_transient = transient
-classfileformat.acc_volatile = volatile
-classfileformat.class = class
-classfileformat.interface = interface
-classfileformat.extends =\ extends
-classfileformat.implements =\ implements
-classfileformat.throws =\ throws
classfileformat.methoddescriptor =\ Method descriptor
classfileformat.fieldddescriptor =\ Field descriptor
classfileformat.maxStack = Stack:
@@ -69,17 +58,6 @@
classfileformat.superflagnotset = The ACC_SUPER bit is not set
classfileformat.clinitname = {}
### string displayed for each opcode
-classfileformat.case = case
-disassembler.colon = :
-classfileformat.default =\ default:
-classfileformat.newarrayboolean = boolean
-classfileformat.newarraychar = char
-classfileformat.newarrayfloat = float
-classfileformat.newarraydouble = double
-classfileformat.newarraybyte = byte
-classfileformat.newarrayshort = short
-classfileformat.newarrayint = int
-classfileformat.newarraylong = long
classformat.invokeinterfacemethod =\ <Interface method
classformat.invokeinterfacemethodclose = >
classformat.invokespecialconstructor =\ <Constructor
diff --git a/org.eclipse.jdt.core/notes/R20_buildnotes_jdt-core.html b/org.eclipse.jdt.core/notes/R20_buildnotes_jdt-core.html
new file mode 100644
index 0000000..238480c
--- /dev/null
+++ b/org.eclipse.jdt.core/notes/R20_buildnotes_jdt-core.html
@@ -0,0 +1,4366 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
+ <title>JDT/Core Release Notes</title>
+
+</head>
+<body>
+
+<body text="#000000" bgcolor="#FFFFFF">
+
+
+<table border=0 cellspacing=5 cellpadding=2 width="100%" >
+ <tr>
+ <td align=left width="72%">
+ <font face="Verdana, Arial, Helvetica" size="+3"><b>jdt core - build notes R2.0</font>
+ <br><font face="Arial, Helvetica, sans-serif" size="-2" color="#8080ff">java development tooling core</font></td>
+ </tr>
+ <tr><td> </td></tr>
+ <tr>
+ <td>
+ <font face="Arial, Helvetica, sans-serif" size="-1">
+ Here are the build notes for the Eclipse JDT/Core plug-in project
+ <a href="http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/jdt-core-home/main.html"><b>org.eclipse.jdt.core</b></a>,
+ describing bug resolution and substantial changes in the <a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core"><b>HEAD</b></a> branch.
+ Most recent information is listed first.
+ <br>
+ This present document covers all changes up to Release 2.0, changes which occurred since then in 2.1
+ stream are described in <a href="../buildnotes_jdt-core.html">build notes 2.1 stream</a>.
+
+ </font>
+ </td>
+ </tr>
+</table>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build GM5 - 27th June 2002 - RELEASE 2.0 (R2_0)
+<br>Project org.eclipse.jdt.core v_264
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Changed ASCII/binary property for 'about.html' file to ASCII.</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build GM4 - 26th June 2002
+<br>Project org.eclipse.jdt.core v_263
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20553">20553</a>
+Doc - Javadocs of 2.0 classes must specify if the class is intended to be instantiated or subclassed by client.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20442">20442</a>
+Doc - Javadoc missing in ICodeSnippetRequestor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20550">20550</a>
+Doc - fields of CorrectionEngine should not be API
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20872">20872</a>
+Doc - the javadoc is not correct for ICodeAssist#codeSelect
+<br>
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20936">20936</a>
+nullpointer exception in org.eclipse.jdt.internal.core.builder.JavaBuilder
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020624 - 24th June 2002
+<br>Project org.eclipse.jdt.core v_262
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Updated about.html file.
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020621 - 21st June 2002
+<br>Project org.eclipse.jdt.core v_261
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20693">20693</a>
+Finding references to variables does not find all occurances
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20011">20011</a>
+Searching for Inner Classes gives bad search results
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20520">20520</a>
+Refactor - expression detection incorrect
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20643">20643</a>
+Java Projects disappear
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020620 - 20th June 2002
+<br>Project org.eclipse.jdt.core v_260
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20532">20532</a>
+Declaration of member binary type not found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19799">19799</a>
+More problems with importing.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16140">16140</a>
+Non-java project gets .classpath
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20659">20659</a>
+Compile/rebuild analysis: white space causes large rebuild
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020618 - 18th June 2002
+<br>Project org.eclipse.jdt.core v_259
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Updated about.html file with reference to CPL 1.0.
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020617 - 17th June 2002
+<br>Project org.eclipse.jdt.core v_258
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Removed deprecated 2.0 temporary API: <code>IWorkingCopy#findSharedWorkingCopy()</code> which was no longer used anyway. Proper API is taking
+a <code>IBufferFactory</code> in argument.</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20427">20427</a>
+J9c needs internal batch compiler methods to be public
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20309">20309</a>
+cannot code resolve on binary method with member type arguments
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20158">20158</a>
+Close and reopen a project does not remove errors
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20325">20325</a>
+CP Variable - should not persist "initialization in progress" value
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20173">20173</a>
+Open type from a jar located inside a closed project.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20135">20135</a>
+2.0 deprecated method
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20359">20359</a>
+classpath variable ECLIPSE_HOME not initialized on startup
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20261">20261</a>
+cycle in classpath detection seems overzealous
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19826">19826</a>
+livelock during indexing?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20048">20048</a>
+Minimize recompilation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=20053">20053</a>
+interface with same-named method generates compile error
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020612 - 12th June 2002 - FREEZE 3
+<br>Project org.eclipse.jdt.core v_257
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19537">19537</a>
+Internal error saving file (jzentry == 0)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19917">19917</a>
+Code Assist incorrect for hidden interface fields
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19916">19916</a>
+Error accessing value from uninitialized localvariable
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19566">19566</a>
+Invalid ClassCastException thrown at runtime
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3306">3306</a>
+Can't compile JDK src
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19851">19851</a>
+IllegalArgumentException in refactor-extract method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7272">7272</a>
+Open on selection not working in external JARs
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14219">14219</a>
+EOF exception after building in imported plugin with extracted source
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18290">18290</a>
+Incorrect errors reported during reconciling
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020611 - 11th June 2002
+<br>Project org.eclipse.jdt.core v_256
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> Added protection around listener callback invocations (using <code>ISafeRunnable</code>). </li>
+<li> Removed 2 unused deprecated constants on <code>IJavaSearchConstants</code>: READ_REFERENCES and WRITE_REFERENCES.
+They were annoted with intention to discard before 2.0 since were temporarily introduced and deprecated (due to bad naming).
+<pre>
+ /**
+ * @deprecated - use WRITE_ACCESSES instead (will be discarded before 2.0)
+ * @since 2.0
+ */
+ int WRITE_REFERENCES = WRITE_ACCESSES;
+ </pre></li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19714">19714</a>
+Eclipse crashes: Drag & Drop
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19794">19794</a>
+Method body change may result in massive recompilation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18983">18983</a>
+Replacing binary project doesn't trigger build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18953">18953</a>
+Package disapears when disconnected from CVS repopsitory
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19638">19638</a>
+Open Type Hierarchy can start infinite progress monitor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19687">19687</a>
+Preferences not working with import/export
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19512">19512</a>
+ArrayIndexOutOfBound during incremental build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18922">18922</a>
+Scrapbook does not come back when errors in snippet
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19808">19808</a>
+core ClassCastException exception in log
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19882">19882</a>
+maybe a cu's single type can be its proimary type too
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19586">19586</a>
+Java project removed from Projects view
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15972">15972</a>
+JAR file from classpath not indexed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18680">18680</a>
+Classpath Loop
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020606 - 6th June 2002
+<br>Project org.eclipse.jdt.core v_255
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Removed deprecated API on <code>IJavaProject</code>. These were not in 1.0, and shouldn't have been
+introduced (incorrectly resurrected from 0.9).
+ <ul>
+ <li><code>IJavaProject#getClasspath(...) --> IJavaProject#getRawClasspath(...) </code></li>
+ <li><code>IJavaProject#setClasspath(...) --> IJavaProject#setRawClasspath(...) </code></li>
+ <li><code>IJavaProject#newProjectEntry(...) --> JavaCore#newProjectEntry(...) </code></li>
+ <li><code>IJavaProject#newLibraryEntry(...) --> JavaCore#newLibraryEntry(...) </code></li>
+ <li><code>IJavaProject#newSourceEntry(...) --> JavaCore#newSourceEntry(...) </code></li>
+ </ul>
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19303">19303</a>
+Open type does not show all type.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14109">14109</a>
+Deadlock between ProblemTreeViewer refresh and reconciler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19254">19254</a>
+Some local variable completion proposals are missed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19131">19131</a>
+NPE when removing a project containing missing classfile folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19058">19058</a>
+Closing non-java project doesn't remove root from java project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18584">18584</a>
+New 2.0 APIs marked as deprecated should be removed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18698">18698</a>
+Seeing non-java projects in package view
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18920">18920</a>
+NPE searching for references to a message
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18749">18749</a>
+Missing java doc for IConstantPoolEntry
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18583">18583</a>
+New constants not tagged with @since 2.0
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18708">18708</a>
+DOM AST - IllegalArgumentException organizing imports
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18039">18039</a>
+Opening .class file fails
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18621">18621</a>
+Query all types when project is closed prevents reindexing when project is open
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19271">19271</a>
+IOException when searching for packages
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7916">7916</a>
+Code assist does not find class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19424">19424</a>
+JDT processing deltas for non-java files in non-java projects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18633">18633</a>
+Build failed: Can not find the class file for org.eclipse.jdt.core.jdom.IDOMInitializer
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18175">18175</a>
+Quickfix false positives for non-public classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=19293">19293</a>
+cancelling compiling does not always cancel
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18539">18539</a>
+unable to run JDBC program, class not found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3292">3292</a>
+Adding new class takes very long (>20s) (1GEUGFQ)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3333">3333</a>
+JavaCore does not recognize dot notation for inner classes (1GI7GZG)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18507">18507</a>
+overwritting exiting file does not work
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18414">18414</a>
+NLS Tools: Find strings and compiler warning out of synch
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5605">5605</a>
+NPE restarting workspace
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3252">3252</a>
+Code assist list could be narrower in throws completion (1GD074C)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18724">18724</a>
+Code for the static initializer is exceeding the 65535 bytes limit
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3272">3272</a>
+CodeCompletion - should only resolve interfaces (1GE5B8X)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6259">6259</a>
+DCR: IClasspathEntry with JavaDoc location
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10007">10007</a>
+NPE and ClassCastException when renaming class name
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3222">3222</a>
+JM - Reminder - re-enable transient reconciling marker (1GAJ9FQ)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3267">3267</a>
+Deadlock while refreshing form local (1GDTUSD)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5583">5583</a>
+getNonJavaResources does not return .class files for source folders
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16371">16371</a>
+Java Model Exception using code assist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17626">17626</a>
+Auto-format source removed newline at end of range
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8863">8863</a>
+.classpath gets overwritten if there's an XML error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3335">3335</a>
+Java Element Deltas: Performance issues with deltas from Working Copy (1GIE36J)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3253">3253</a>
+SEVERE: Not all external JARs show up in packages view (1GD0JZO)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=1834">1834</a>
+Cancel build with 10000+ problems takes forever to update (1G2Q9YZ)
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020601 - 1st June 2002 - FREEZE 2
+<br>Project org.eclipse.jdt.core v_254
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>The resource copy exclusion filter now tolerates whitespaces inside the filter pattern, they will be trimmed
+when used. e.g. " .* , foo/ " is now accepted.</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18446">18446</a>
+JavaCore.getClasspathContainer on not yest created project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18411">18411</a>
+External JAR refresh - caching problem
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18453">18453</a>
+Deleting project doesn't remove pkg fragment root in another project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18331">18331</a>
+Java Model not flushed when upgrading binary projects
+
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020531 - 31st May 2002
+<br>Project org.eclipse.jdt.core v_253
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Changing 2.0 API for refreshing external JARs so as to pass in a collection of *elements* to restrain the scope
+of the update (see <code>IJavaModel#refreshExternalArchives(IJavaElement[],IProgressMonitor)</code>. Elements
+can either be package fragment roots, projects or Java model.</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18418">18418</a>
+ search: searchDeclarationsOfReferencedTypes reports import declarations
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18287">18287</a>
+<Clinit> change is treated as a structural change by incremental builder
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17766">17766</a>
+Strange error when launching Eclipse from inside Eclipse
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18396">18396</a>
+ant javac target ignores source="1.4" setting inside eclipse
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14187">14187</a>
+error rebuilding project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14607">14607</a>
+Refactor: rename isn't updating references
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16172">16172</a>
+Namelookup slow to retrieve package fragments
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18157">18157</a>
+Internal Error when deleting project
+ <br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18259">18259</a>
+changing classpath causes significant recompilation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10394">10394</a>
+symbolic links upset JRE path
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9302">9302</a>
+An unexpected exception has been detected in native code outside the VM
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020530 - 30th May 2002
+<br>Project org.eclipse.jdt.core v_252
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Compiler can now optionally report unused imports. See option named "" on <code>JavaCore#getDefaultOptions</code> comment
+<pre>
+ * COMPILER / Reporting Unused Import
+ * When enabled, the compiler will issue an error or a warning for unused import
+ * reference
+ * - option id: "org.eclipse.jdt.core.compiler.problem.unusedImport"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "ignore"
+</pre>
+Note that if import problems (separate settings) are disabled, unused imports will not be reported either.
+This option is also available to the batch compiler ("-warn:unusedImports"). Implementations of <code>IProblemRequestor</code>
+can identify this new problem through its ID <code>IProblem#UnusedImport</code>.
+</li>
+<li>Added API on IType so as to tell whether a type is anonymous, local or member.</li>
+<li>Changing 2.0 API for refreshing external JARs so as to pass in a collection of projects to restrain the scope
+of the update (see <code>IJavaModel#refreshExternalJARs(IJavaProject[],IProgressMonitor)</code>. </li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17906">17906</a>
+Rename package fails when inner classes are imported
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18255">18255</a>
+NPE during Organize imports.... See test5 in UI tests
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18169">18169</a>
+ast: incorrect length of SingleVariableDeclaration for some array declarations
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18138">18138</a>
+Resolving failure in variable declaration
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18135">18135</a>
+importing plugins resulted in 9MB of errors added to log
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18190">18190</a>
+add a new PackageFragmentRoot does not update the name lookup of dependent projects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15441">15441</a>
+Important: Problem highlight is out of sync with compiler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12649">12649</a>
+Missing import after move
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18042">18042</a>
+AST: Resolving failes with semicolon while loop body
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020529 - 29th May 2002
+<br>Project org.eclipse.jdt.core v_251
+<h2>
+What's new in this drop</h2>
+<ul>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18078">18078</a>
+memory leak - destroy a WorkingCopy remove and re-add his buffer
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16187">16187</a>
+Problems occured building seleted resources. MemberTypeBinding
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18029">18029</a>
+disassembled code viewer handles \n incorrectly
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17922">17922</a>
+ClassCastException on rename temp
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18054">18054</a>
+JDT/Core is using the platform encoding instead of the encoding set in the UI
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17923">17923</a>
+Can't find refs to binary fields
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11823">11823</a>
+npe when trying to set source to rt.jar
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17609">17609</a>
+deleting a resource results does not change local history
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16120">16120</a>
+SelectionParser build wrong AST for instanceof statement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14468">14468</a>
+F3 doesn't work on DefaultExceptionHandler
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14373">14373</a>
+Number of spaces representing a tab is alway 4
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6169">6169</a>
+Creating the tasks view hangs the UI thread
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=18070">18070</a>
+NullPointerException during build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9173">9173</a>
+Exception about missing org.eclipse.core.boot\.classpath file?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15602">15602</a>
+OutOfMemoryError
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15311">15311</a>
+Importing external plug-ins from file system fails
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13852">13852</a>
+Cannot generate EJB inheritance deployed code without debug info
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17046">17046</a>
+Inner class reference to Outer class method not recognized
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17953">17953</a>
+NullPointerException when compiling cocoon2
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17930">17930</a>
+Moving secondary types is fooling the java incremental builder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17873">17873</a>
+Synchronize Comparison does poor job on .classpath files
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16736">16736</a>
+Comment before package statement not associated with it
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12551">12551</a>
+Search finds some but not all method refs
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17254">17254</a>
+Could not find .classpath.
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020527 - 27th May 2002
+<br>Project org.eclipse.jdt.core v_250
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Added API to retrieve cached flags on type hierarchies (see <code>ITypeHierarchy#getCachedFlags(IType)</code>). Note that these
+flags can help answering both isClass/isInterface queries as well (see <code>Flags.isInterface(int)</code></li>
+<li>Added API to trigger a Java model refresh with respect to external JARs: <code>IJavaModel#refreshExternalJARs</code>. </li>
+<pre>
+/**
+ * Triggers an update of the JavaModel with respect to the referenced external JARs.
+ * This operation will issue a JavaModel delta describing the discovered changes, in term
+ * of Java element package fragment roots added, removed or changed.
+ *
+ * @param monitor - a progress monitor used to report progress
+ * @exception JavaModelException in one of the corresponding situation:
+ * - an exception occurs while accessing project resources
+ *
+ * @see IJavaElementDelta
+ * @since 2.0
+ */
+void refreshExternalJARs(IProgressMonitor monitor) throws JavaModelException;
+</pre>
+<li>Added flag for notifying a JAR content change during Java delta notification: <code>IJavaElementDelta#F_ARCHIVE_CONTENT_CHANGED</code></li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17097">17097</a>
+Searching for "*" in java gives a cryptic error message dialog.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15162">15162</a>
+Assertion failure during shutdown
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17145">17145</a>
+NPE while compiling
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17807">17807</a>
+Incremental build problems deleting secondary types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17564">17564</a>
+Register java file types with the team plugin
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17422">17422</a>
+JDT Compiler Adapter and compatibility with Ant 1.5
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17101">17101</a>
+Assertion failure during shutdown
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17562">17562</a>
+Race condition on startup leads to 2 JavaModel instances
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15395">15395</a>
+AssertionFailedException when creating new Java project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17797">17797</a>
+NullPointerException while building
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17827">17827</a>
+NullPointerException at CompilationResult.computePriority
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16761">16761</a>
+NPE when doing Project -> Rebuild All
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3329">3329</a>
+Specification for IJavaElementDelta needed (1GHVW5M)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16753">16753</a>
+Exception while building
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12159">12159</a>
+Code Format is generating bogus output
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16751">16751</a>
+Renaming a class doesn't update all references
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16789">16789</a>
+Incomplete project element if .classpath file isn't readable
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16279">16279</a>
+compiler creates code that causes verifier error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14113">14113</a>
+Should listen to F_SOURCEATTACHED and F_SOURCEDETACHED java deltas
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15250">15250</a>
+Need a better mapping for the method free return opcode
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16091">16091</a>
+Need way to refresh JAR files
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16354">16354</a>
+Code Assist has too many items after throws
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16863">16863</a>
+type hierarchy misses types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14892">14892</a>
+Failed package import leads to OutOfMemory errors at compile time
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17197">17197</a>
+F1 - "Add Jars" to build path locks up eclipse - win2k
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15211">15211</a>
+NPE while searching for a field
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16494">16494</a>
+newSuperTypeHierarchy on binary type returns empty hierarchy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=17127">17127</a>
+IllegalArgumentException in SimpleName.setIdentifier(SimpleName.java:136) in M5
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16857">16857</a>
+Empty folder creation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16209">16209</a>
+Support declared packages that are different from directory location
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6068">6068</a>
+Walkback during plugin import
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12985">12985</a>
+Unexpected full build in incremental mode
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11022">11022</a>
+Unexpected full build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16436">16436</a>
+CoreException importing org.eclipse.ui.win32
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12520">12520</a>
+JDTCompilerAdapter does not understand -extdirs
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10047">10047</a>
+JDTCompilerAdapter ignores -nowarn and deprecation off.
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020521 - 21st May 2002
+<br>Project org.eclipse.jdt.core v_249 - MILESTONE 6 / FREEZE 1
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>'.classpath' file is now written using platform line delimiters (used to be only using LFs). It is recommanded to convert it to 'text' format
+so as to avoid surfacing delimiter differences in between incompatible platforms. </li>
+<li>The setting allowing for filtering resource copy now also supports folder filtering. Folder names are
+recognized by their '/' suffix, e.g. "META-INF/" specifies filtering out all folder named 'META-INF' (and their contents)</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3244">3244</a>
+Classpath is not saved using UTF8 (1GCV467)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13878">13878</a>
+Request to support folders for resource copy filters
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16135">16135</a>
+Unexpected errors while reconciling
+
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020518 - 18th May 2002
+<br>Project org.eclipse.jdt.core v_248
+<h2>
+What's new in this drop</h2>
+<ul><li>Added <code>ToolFactory.createDefaultClassFileReader(IClassFile classfile, int decodingFlag)</code> as an helper method to
+ create a classfile reader for classfile elements.</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16130">16130</a>
+build xerces/plugin.properties slow
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16175">16175</a>
+NPE in IndexManager#checkIndexConsistency
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15563">15563</a>
+CompletionEngine does not report type packages of local variables
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12374">12374</a>
+NPE in ResultCollector
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15977">15977</a>
+NPE in Code Assist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14037">14037</a>
+Internal Error doing java search
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16126">16126</a>
+ArrayIndexOutOfBoundsException during compilation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16132">16132</a>
+Error on Extract Method Refactoring
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16052">16052</a>
+NPE when search reference of a constructor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15945">15945</a>
+Creating new class causes most projects to be recompiled
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9244">9244</a>
+Search Generates OutOfMemoryError
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15423">15423</a>
+JRE_LIB source attachment via properties does not work
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15931">15931</a>
+Proposed results to limited/invalid
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16131">16131</a>
+Java search fails to find all references to static final MB_ADDITIONS
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15192">15192</a>
+PackageFragment::copy never overwrites
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020515 - 15th May 2002
+<br>Project org.eclipse.jdt.core v_247
+<h2>
+What's new in this drop</h2>
+<ul>
+ <li> New compiler option added to control max number of problems reported on a unit. Default is 100. See <code>JavaCore#getDefaultOptions()</code> </li>
+ <pre>
+ * COMPILER / Maximum number of problems reported per compilation unit
+ * Specify the maximum number of problems reported on each compilation unit.
+ * - option id: "org.eclipse.jdt.core.compiler.maxProblemPerUnit"
+ * - possible values: "<n>" where <n> is zero or a positive integer (if zero then all problems are reported).
+ * - default: "100"
+ </pre>
+ <li>By default, the Java builder is now aborting build process on projects with classpath problems. This option can be disabled through the Java preferences:
+ Window>Preferences>Java>Builder></li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16051">16051</a>
+DOM/AST: wrong position in if statement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15788">15788</a>
+Walkbacks at startup
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16021">16021</a>
+Infinite loop in JavaCore.isReferencedBy(...)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14467">14467</a>
+Outliner doesn't highlight method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16017">16017</a>
+JavaBuilder reports build failures on dependencies onto internal JARs
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15568">15568</a>
+Watchpoints, method breakpoints in interesting locations not showing in editor ruler
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16801">16801</a>
+Compiler problem when */ appears in commented String.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12955">12955</a>
+Problem with Type Dialog and HierarchyScopes - build 20020214
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16016">16016</a>
+Opening a project after starting Eclipse misses project indexes (or other internal stuff)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15190">15190</a>
+Java Build errors after save
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=16008">16008</a>
+Hang during shutdown
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12392">12392</a>
+Problems to add Project from repository
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15103">15103</a>
+Search results are missing qualification
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020514 - 14th May 2002
+<br>Project org.eclipse.jdt.core v_246
+<h2>
+What's new in this drop</h2>
+<ul>
+ <li>Java compiler never record more than 100 markers for compilation problems. All APIs using IProblemRequestor still
+ see them all. This change is intended to prevent the task list from being overhelmed with tons of secondary problems. </li>
+ <li>Added APIs that allow to create a type hierarchy with a set of working copies that take precendence
+ over their original compilation unit:
+ <ul>
+ <li><code>IType.newSuperTypeHierarchy(IWorkingCopy[], IProgressMonitor)</code></li>
+ <li><code>IType.newTypeHierarchy(IWorkingCopy[], IProgressMonitor)</code></li>
+ </ul>
+ Note that change notification and refreshing is not supported on these hierarchies.
+ </li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14051">14051</a>
+The implementation for IType.resolveType(String) is not implemented as noted in the JavaDoc specs
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15322">15322</a>
+need a way to create a type hierarchy that considers working copies
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15142">15142</a>
+CCE in SourceConstructorDeclaration
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15349">15349</a>
+JavaModelException out of Content assist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15677">15677</a>
+Exception calling sourceType.getFields on working copy of new class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15657">15657</a>
+IDOMMethod.getReturnType returns null for all methods
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15804">15804</a>
+DOM/AST: wrong Length in cascading if/then/else
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15400">15400</a>
+Compiler generates way too many errors
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15857">15857</a>
+Deadlock in the indexer.shutdown()
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15756">15756</a>
+Organizing imports doesn't pick up the right type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15430">15430</a>
+hang up eclipse
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14965">14965</a>
+Search results in .class files don't select reference
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15690">15690</a>
+Classpath being set in wrong notification lifecycle
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15810">15810</a>
+ClasspathContainer question
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15717">15717</a>
+I cant hold JDK Compiler Compliance level setting.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15448">15448</a>
+i keep loosing preferences
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15113">15113</a>
+extract method: assertion failure
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8137">8137</a>
+Code assist for anonymous inner type too late
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15761">15761</a>
+Log message after importing plugins fails
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15852">15852</a>
+need set api on IClasspathEntry
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15579">15579</a>
+Incomplete Java Error Message
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13756">13756</a>
+Code Completion + Type Introspection
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3198">3198</a>
+Caller of Signature.toString(String) should be aware that it won't work for '$' separated top-level types (1G4QB2S)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15332">15332</a>
+Problem with "\\" in editor/compiler
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020507 - 7th May 2002
+<br>Project org.eclipse.jdt.core v_245
+<h2>
+What's new in this drop</h2>
+<ul>
+ <li>Added org.eclipse.jdt.core.dom.Message#Message(String, int, int). This new constructor allows to set the length field. The constructor
+ org.eclipse.jdt.core.dom.Message#Message(String, int) still exists and set the length to 0. There is no need to use the new constructor if the length
+ is never used.</li>
+ <li>Renamed org.eclipse.jdt.core.dom.Message#getSourcePosition() to org.eclipse.jdt.core.dom.Message#getStartPosition(). This
+ is more consistent with the DOM/AST API. The old method has been deprecated and will be removed in a close future.</li>
+ <li>Added org.eclipse.jdt.core.dom.Message#getLength() allowing to retrieve the length of the node on which
+ the message has been reported.</li>
+ <li> Added <code>JavaCore#getSharedWorkingCopies(IBufferFactory)</code> allowing to retrieve all registered working
+ copies for a given buffer factory. </li>
+ <li> JavaBuilder no longer build projects for which prerequisite projects aborted the build process. This considerably
+ reduces the number of secondary errors when dealing with workspace setup problems.</li>
+ <li> Added <code>IWorkingCopy#reconcile(boolean forceProblemDetection, IProgressMonitor monitor)</code> allowing to force
+ problem refresh even if working copy was already consistent.
+ <li> Added <code>IClasspathContainer</code> new kind constant <code>K_DEFAULT_SYSTEM</code> to denote system libraries implicitely contributed
+ by a runtime. </li>
+ <li> Classpath container path can have more than 2 segments. First one is still the container ID, the remaining ones are forming the hints
+ passed to the resolution phase (<code>ClasspathContainerInitializer</code> </li>
+ <li> Classpath containers can no longer contain variable entries </li>
+ <li>JavaCore now persists its options (<code>JavaCore#getOptions</code>) using its plugin property store. Clients no longer need to save them. </li>
+ <li>JavaCore now provides constants for all supported option IDs and values.</li>
+ <li>JavaCore option added, to allow build to abort in presence of invalid classpath.
+ <li>Leveraged new encoding support from Platform/Core. The JavaCore option "org.eclipse.jdt.core.encoding" is now equivalent to <code>ResourcesPlugin.getEncoding()</code>.
+ <pre>
+ * BUILDER / Abort if Invalid Classpath
+ * Allow to toggle the builder to abort if the classpath is invalid
+ * - option id: "org.eclipse.jdt.core.builder.invalidClasspath"
+ * - possible values: { "abort", "ignore" }
+ * - default: "ignore"
+ </pre>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15416">15416</a>
+Classpath container - need to set value even if not referenced
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15418">15418</a>
+Classpath container - may get the init-in-progress value back
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15334">15334</a>
+ast: Message should have length
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15364">15364</a>
+search for references of DebugUIPlugin.setAttributes(...) fails
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15175">15175</a>
+Need API to retrieve all shared working copies for a buffer factory
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15254">15254</a>
+JavaModelManager thinks JavaProject is closed when it is open
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3356">3356</a>
+API - should provide API for running batch compiler (1GJIWDP)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15244">15244</a>
+NPE in JDTCompilerAdapter
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15289">15289</a>
+Why is an incorrect package declaration not reported during reconciling
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13225">13225</a>
+quick fix: shows up only after I save
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15081">15081</a>
+JavaConventions.validateClasspath allows nesting source folders
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15044">15044</a>
+Unable to view some non-java files in external jars
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15177">15177</a>
+Classpath markers not correctly updated
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15168">15168</a>
+circular errors not reported
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13957">13957</a>
+LaunchingPlugin specification of resourceCopyExclusionFilter
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12977">12977</a>
+Adding Java nature to a project does not bring it to like in package view
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15107">15107</a>
+Internal Error organizing imports
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15030">15030</a>
+NPE trying to open or edit source files that reference jbuilder.jar
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14838">14838</a>
+Scrapbook editor: bad handling of // comment
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12543">12543</a>
+Code assist to insert method does not work when there are extra top-level statements
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15061">15061</a>
+IllegalArgumentException in ASTNode.setSourceRange
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15036">15036</a>
+ASTVisitor.preVisit and ASTVisitor.postVisit not called correctly
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3193">3193</a>
+JM - ISourceManipulation.delete send replace-BufferChangedEvent (1FYE8XI)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15091">15091</a>
+Too many cycle markers generated when cycle is detected
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14754">14754</a>
+CodeAssist - Duplicate method declaration proposal inside anonymous type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15051">15051</a>
+Synthetic access methods are not reported to be synthetic
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3059">3059</a>
+JRE_LIB not appended to buildPath (1GF7TAZ)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15050">15050</a>
+Cleanup Javadoc @exception tags in DOM/AST
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14151">14151</a>
+The code formatter does not respect the "maximum line length" property when the indentation is set to tabulation.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14974">14974</a>
+Bad generated code for '+=' and '-=' operators
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15719">15719</a>
+Errors during build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=15087">15087</a>
+NPE when methods from the outermost enclosing class is invoked in a anonymous class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13057">13057</a>
+NPE in JavaElementRequestor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11155">11155</a>
+ArrayIndexOutOfBounds exception that caused workbench to freeze
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12921">12921</a>
+Build sometimes builds files that have not changed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14962">14962</a>
+JDT Search returning improper type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14929">14929</a>
+External Locations for Output Files
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020430 - 30th April 2002
+<br>Project org.eclipse.jdt.core v_243
+<h2>
+What's new in this drop</h2>
+<ul>
+ <li>Priority of the background indexer has been lowered so that
+ it doesn't interfer with other threads (e.g. when switching JRE
+ the indexing will not start before the switch has completed)
+ </li>
+ <li>Revised Classpath Container proposal (also see <a href="http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.eclipse.jdt.core/notes/r2.0/classpath%20container/classpathContainer.html">notes</a>):
+ <ul>
+ <li><code>classpathContainerChanged()</code> got replaced with setter method <code>JavaCore.setClasspathContainer(IPath containerPath, IJavaProject[] affectedProjects, IClasspathContainer respectiveContainers) </code></li>
+ <li><code>ClasspathContainerResolver</code> got renamed into <code>ClasspathContainerInitializer</code></li>
+ <li> Container can no longer contain any <code>CPE_SOURCE</code> entry.
+ <li> added container interface <code> IClasspathContainer </code> in order to allow containers to be presented in a UI.
+ <ul>
+ <li>IClasspathEntry[] getClasspathEntries() </li>
+ <li>String getDescription() </li>
+ <li>int getKind() </li>
+ <li>Path getPath() </li>
+ </ul>
+ </ul>
+ </li>
+ <li>If the completion is inside a super type in type declaration header then the relevance grow
+ when the type have the correct nature :
+ <ul>
+ <li> After <code>extends</code> keyword of a class header the relevance grow if the type is a class.
+ </li>
+ <li> After <code>implements</code> keyword of a class header the relevance grow if the type is an interface.
+ </li>
+ <li> After <code>extends</code> keyword of an interface header the relevance grow if the type is an interface.
+ </li>
+ </ul>
+ </li>
+ <li> If the completion is inside a type in a catch or throws clause the relevance grow when the type is an exception
+ (if the name of the type contain <code>exception</code> or <code>error</code>).
+ </li>
+ <li> If the completion is inside a throw statement the relevance grow when the proposal is an exception.
+ </li>
+ <li>The background indexer now recovers from internal crash. If this happens,
+ a new thread is created and a consistency check is done on all indexes.
+ </li>
+ <li>An internal buffer factory is now used to create buffers when
+ clients don't provide one.
+ </li>
+ <li>Special handling in the formatter for //$NON-NLS- comments in the source. When a line contains such comments
+ it is not formatted anymore. The user will need to manually format it. See <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14387">14387</a> and
+ <a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=12540">12540</a>.
+ </li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14933">14933</a>
+AST: No error message generated for unreachable code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14921">14921</a>
+No error message from inner type instantiation in static context
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13919">13919</a>
+Declaration for package not found if scope is not project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14852">14852</a>
+Organize Import: missing import
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13531">13531</a>
+Java indexing thread finds "Bonjour, le monde!" too interesting
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14878">14878</a>
+static final char NegThree= (char)-3, -3 == NegThree returns true
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14331">14331</a>
+ICompilationUnit.getElementAt dos not find import decl
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14038">14038</a>
+ClassCastException during JavaReconciling
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14011">14011</a>
+ASTNode.checkNewChild(ASTNode, ASTNode, boolean, Class)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13577">13577</a>
+Problem highlighter is unable to import from Java3D library.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14831">14831</a>
+NPE with hierarchy search of a local variable
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14243">14243</a>
+Applet Viewer Integration
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14140">14140</a>
+ClassCastException when trying to open Java editor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14834">14834</a>
+smalltalk-ish error message
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11651">11651</a>
+Auto-complete shows all Object subclasses after "throws" keyword
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=4970">4970</a>
+Automatic Code Assist needs to be smarter #6
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8651">8651</a>
+Code assist should offer exception instead of any class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14767">14767</a>
+bug in IJavaProject.findType(String, String)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14642">14642</a>
+StringIndexOutOfBoundsException when attempting to view some classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14558">14558</a>
+Adding binary project doesn't fix classpath problems.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14588">14588</a>
+NullPointerException in Util.equalArraysOrNull
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13492">13492</a>
+Should handle JavaModelExceptions that contains CoreException more gracefully
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12540">12540</a>
+Code formatter should leave comments at end of line
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14387">14387</a>
+Formatter isn't //$NON-NLS-1$ aware
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14313">14313</a>
+DCR: AST in methods with missing return type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14094">14094</a>
+Indexer: Deadlock on delete project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14594">14594</a>
+"Open type" doesn't find types in project with Java nature added
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14602">14602</a>
+ast: length of variable declaration fragment
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14592">14592</a>
+IType#getTypes and IType#getDeclaringType are not coherent with Hastable
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13868">13868</a>
+Java Model not updated properly
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13234">13234</a>
+Can't open type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9296">9296</a>
+Hang on open type during indexing
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13916">13916</a>
+api: IScanner - Scanner.linePtr
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14526">14526</a>
+NPE when resolving a SimpleName
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11529">11529</a>
+ast: missing (?) binding on simpleName in VariableDeclaration
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14453">14453</a>
+Remove InfixExpression.Operator.INSTANCEOF operator
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14490">14490</a>
+Possible concurrency hole when saving index before query
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14844">14844</a>
+NPE creating binary projects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14908">14908</a>
+100% CPU utilization, hang
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14733">14733</a>
+NPE setting marker attributes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13743">13743</a>
+(NPE) Eclipse froze during "open type"
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14074">14074</a>
+Search: Not all refs to TwoPaneElementSelector constructor found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14889">14889</a>
+bug in IJavaProject.findType(String, String)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12439">12439</a>
+auto completion doesn't consistently work
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14818">14818</a>
+no message for uncaught exception in try block when return in finally
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13810">13810</a>
+ClassCastException in indexer
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13527">13527</a>
+NPE + GP switching JRE
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14096">14096</a>
+IWorkingCopy.findElements should not return null
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13943">13943</a>
+Eclipse crashes when doing a "rebuild all"
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14440">14440</a>
+Possible bug in compiling inner classes
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020508-M5patch" - 8th May 2002
+<br>Project org.eclipse.jdt.core v_242b
+<h2>
+What's new in this drop</h2>
+<ul>
+ <li>Java builder is logging its internal errors </li>
+</ul>
+<h3>Problem Reports Fixed</h3>
+
+<h3>Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020423 - 23rd April 2002
+<br>Project org.eclipse.jdt.core v_242a
+<h2>
+What's new in this drop</h2>
+<ul>
+ <li>Java model API additions:
+ <ul>
+ <li><code>IJavaProject.findType(String)</code></li>
+ <li><code>IJavaProject.findType(String, String)</code></li>
+ <li><code>IMethod.isMainMethod()</code></li>
+ <li><code>IMethod.isSimilar(IMethod)</code></li>
+ <li><code>IType.getFullyQualifiedName(char)</code></li>
+ <li><code>IType.getTypeQualifiedName(char)</code></li>
+ </ul>
+ </li>
+ <li>API change: <code>IWorkingCopy.findSharedWorkingCopy()</code> is now taking an extra argument: the buffer factory it is associated with. This ensures that
+ working copies can only be reused for the same buffer factories.
+ </li>
+ <li> JavaModelOperations now guarantee the JavaModel is up to date when notifying the Java model change listeners. In particular,
+ a builder running after the Java builder will be able to query the Java model with respect to the changes introduced through Java model
+ operations (except for index queries). This was never guaranteed in 1.0, but indirectly occurred due to the fact that the previous Java
+ builder implementation did force to refresh the Java model while building. </li>
+ <li>Classpath Container Enhancement (also see <a href="http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.eclipse.jdt.core/notes/r2.0/classpath%20container/classpathContainer.html">notes</a>):
+ <br>Added new type of classpath entry (<code>CPE_CONTAINER</code>), (see proposal here) so as to better encapsulate client defined libraries.
+ Typically, VM installs would use classpath containers instead of classpath variables (<code>JRE_LIB</code>) so as to better describe the corresponding
+ set of libraries (including extension dirs) to be placed on the build path.
+ <p>New APIs added to reflect this addition:
+ <ul>
+ <li><code>JavaCore.newContainerEntry(IPath containerPath)</code></li>
+ <li><code>JavaCore.newContainerEntry(IPath containerPath, boolean isExported)</code></li>
+ <li><code>JavaCore.classpathContainerChanged(IPath containerPath, IJavaElement scope) </code></li>
+ <li><code>ClasspathContainerResolver </code></li>
+ </ul>
+ </li>
+ <li>DOM/AST:<br>A new type of node has been added to handle properly the instanceof expression. So the new InstanceofExpression node
+ replaced the usage of InfixExpression with the operator InfixExpression.Operator.INSTANCEOF. This operator has been
+ deprecated and is expected to be removed for the next integration build. See bug <A HREF="http://dev.eclipse.org/bugs/show_bug.cgi?id=14453">14453</a>.</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13807">13807</a>
+null binding returned for fully qualified array declaration
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14403">14403</a>
+ast: exception on creation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14229">14229</a>
+Failure writing to a read only .project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13905">13905</a>
+changes to read-only .classpath file are not thrown out
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6165">6165</a>
+handle read-only class path file in a graceful way
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14322">14322</a>
+AST/DOM : IVariableBinding.getDeclaringClass() for 'length' field of an array return null
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14343">14343</a>
+ClassFileReader.getEnclosingTypeName() should return null for anonymous types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12363">12363</a>
+Better integration of the batch compiler with ant javac task option -extdirs
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14217">14217</a>
+DOM/AST: wrong start position for expression statement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14106">14106</a>
+Declarations in Hierarchy does not find declarations in hierarchy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13060">13060</a>
+Type hierarchy on region populates Java Model cache for types in the region
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14117">14117</a>
+NPE importing binary projects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14172">14172</a>
+Builder is setting source resources as derived!
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3266">3266</a>
+Changing kind of classpath entry reports 1 delta (1GDTRTP)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13231">13231</a>
+Quick Fix: wrong proposal
+
+<h3>Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14141">14141</a>
+NullPointerException during search
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13831">13831</a>
+NPE in RegionBasedTypeHierarchy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12914">12914</a>
+Compiler cannot resolve javax.net
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13964">13964</a>
+Exception on startup
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14198">14198</a>
+AST: CastExpression.getType().resolveBinding() is null
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13939">13939</a>
+DBCS: no error message to invalid character in java source
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020418 - 18th April 2002
+<br>Project org.eclipse.jdt.core v_241a
+<h2>
+What's new in this drop</h2>
+<ul>
+ <li>Changing the source attachement of a jar will now correctly fire source
+ attachment java deltas. The flags of these deltas are:
+ <ul>
+ <li><code>IJavaElementDelta.F_SOURCEATTACHED</code> if a source
+ has been attached to a jar and no source previously existed.
+ </li>
+ <li><code>IJavaElementDelta.F_SOURCEDETACHED</code> if a source
+ has been detached from a jar and no other source has been attached.
+ </li>
+ <li><code>IJavaElementDelta.F_SOURCEDETACHED | JavaElementDelta.F_SOURCEATTACHED</code>
+ if an attached source has been changed.
+ </li>
+ </ul>
+ </li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14023">14023</a>
+NPE in build notifier
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14115">14115</a>
+Changing source attachment should not fire a F_REMOVED_FROM_CLASSPATH delta
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14055">14055</a>
+NPE in JavaModelManager.getVariableAsXMLString
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14007">14007</a>
+StringLiteral.setLiteralValue does not do Unicode escaping
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14013">14013</a>
+Compiler should not consider 'this.CONST' as constant expression
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14008">14008</a>
+VariableBinding.getVariableId contains suspicious code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13989">13989 </a>
+Package view doesn't refresh after JRE switching
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12588">12588</a>
+Good match marked as potential
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13143">13143</a>
+Binary constructor search does not work (ref & decl)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13807">13807</a>
+null binding returned for fully qualified array declaration
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14103">14103</a>
+Too many dependents found when incrementally recompiling
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=4384">4384</a>
+Setting classpath variables does two builds
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3285">3285</a>
+Why does change the source attachment trigger a build (1GEHXW3)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13906">13906</a>
+Compiler did not detect uncaught exception
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=14019">14019</a>
+NPE with code assist working in an anonymous inner class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9263">9263</a>
+Code assist can't see other project's class folders
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020416 - 16th April 2002 - MILESTONE 5
+<br>Project org.eclipse.jdt.core v_240
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> Changed the package fragment caching policy so as to accomodate large workspaces. It used to be an overflowing LRU cache of size 1000
+package fragments. It now is a simple table, which is never emptied implicitly any longer. Memory overhead looks negligeable, and it allows to
+deal much better with very large workspaces. Other similar improvements were made on the same front so as to improve JRE switching with such
+workspaces.
+
+</li>
+<li> ElementChangedEvent got added notion of type (similar to IResourceChangeEvent), so as to better
+allow clients to react to JavaModel changes:
+ <ul>
+ <li> ElementChangedEvent.POST_CHANGE :
+<pre>
+ /**
+ * Event type constant (bit mask) indicating an after-the-fact
+ * report of creations, deletions, and modifications
+ * to one or more Java element(s) expressed as a hierarchical
+ * java element delta as returned by <code>getDelta</code>.
+ *
+ * Note: this notification occurs during the corresponding POST_CHANGE
+ * resource change notification, and contains a full delta accounting for
+ * any JavaModel operation and/or resource change.
+ *
+ * @see IJavaElementDelta
+ * @see IResourceChangeEvent
+ * @see #getDelta
+ * @since 2.0
+ */
+ public static final int POST_CHANGE = 1;
+</pre>
+ </li>
+
+ <li> ElementChangedEvent.PRE_AUTO_BUILD
+<pre>
+ /**
+ * Event type constant (bit mask) indicating an after-the-fact
+ * report of creations, deletions, and modifications
+ * to one or more Java element(s) expressed as a hierarchical
+ * java element delta as returned by <code>getDelta</code>.
+ *
+ * Note: this notification occurs during the corresponding PRE_AUTO_BUILD
+ * resource change notification. The delta which is notified here only contains
+ * information relative to the previous JavaModel operations (i.e. ignores the
+ * possible resources which have changed outside Java operations). In
+ * particular, it is possible that the JavaModel be inconsistent with respect to
+ * resources which got modified outside JavaModel operations (it will only be
+ * fully consistent once the POST_CHANGE notification has occured).
+ *
+ * @see IJavaElementDelta
+ * @see IResourceChangeEvent
+ * @see #getDelta
+ * @since 2.0
+ */
+ public static final int PRE_AUTO_BUILD = 2;
+</pre>
+ </li>
+
+ <li> ElementChangedEvent.RECONCILE
+<pre>
+ /**
+ * Event type constant (bit mask) indicating an after-the-fact
+ * report of creations, deletions, and modifications
+ * to one or more Java element(s) expressed as a hierarchical
+ * java element delta as returned by <code>getDelta</code>.
+ *
+ * Note: this notification occurs as a result of a working copy reconcile
+ * operation.
+ *
+ * @see IJavaElementDelta
+ * @see IResourceChangeEvent
+ * @see #getDelta
+ * @since 2.0
+ */
+ public static final int POST_RECONCILE = 4;
+</pre>
+ </li>
+ </ul>
+</li>
+<li>
+ Also added a corresponding API on JavaCore so as to allow registering a listener for a given type of event.
+ <pre>
+ /**
+ * Adds the given listener for changes to Java elements.
+ * Has no effect if an identical listener is already registered.
+ * After completion of this method, the given listener will be registered for exactly the
+ * the specified events. If they were previously registered for other events, they
+ * will be deregistered.
+ *
+ * Once registered, a listener starts receiving notification of changes to
+ * java elements in the model. The listener continues to receive
+ * notifications until it is replaced or removed.
+ *
+ * Listeners can listen for several types of event as defined in <code>ElementChangeEvent</code>.
+ * Clients are free to register for any number of event types however if they register
+ * for more than one, it is their responsibility to ensure they correctly handle the
+ * case where the same java element change shows up in multiple notifications.
+ * Clients are guaranteed to receive only the events for which they are registered.
+ *
+ *
+ * @param listener the listener
+ * @param eventMask the bit-wise OR of all event types of interest to the listener
+ * @see IElementChangeListener
+ * @see ElementChangeEvent
+ * @see #removeElementChangeListener
+ * @since 2.0
+ */
+ public static void addElementChangedListener(IElementChangedListener listener, int eventMask)
+ </pre>
+
+</li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12353">12353</a>
+DocumentAdapter can never be closed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9628">9628</a>
+Switching JRE is slow
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11585">11585</a>
+Large # of projects lock essential operations in the Workspace
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13393">13393</a>
+Extremely poor java editor performance in 2002040x
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13233">13233</a>
+IllegalArgumentException on variable declaration in evaluation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13625">13625</a>
+Remove deprecated method from AST/DOM
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13593">13593</a>
+Code Formatter formats synchronized incorrectly.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12921">12921</a>
+Build sometimes builds files that have not changed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13522">13522</a>
+NPE on anonymous class code assist.
+
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020411 - 11th April 2002
+<br>Project org.eclipse.jdt.core v_239
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Added a first proposal for .class file reading APIs. This is still experimental and might change slightly.
+See new API in org.eclipse.jdt.core.util.
+<ul>
+<li>ByteCodeVisitorAdapter</li>
+<li>ClassFormatException</li>
+<li>DecodingFlag</li>
+<li>IAttributeNamesConstants</li>
+<li>IBytecodeVisitor</li>
+<li>IClassFileAttribute</li>
+<li>IClassFileDisassembler and ToolFactory#createDefaultClassFileDisassembler</li>
+<li>IClassFileReader</li>
+<li>ICodeAttribute</li>
+<li>IConstantPool</li>
+<li>IConstantPoolConstant</li>
+<li>IConstantPoolEntry</li>
+<li>IConstantValueAttribute</li>
+<li>IExceptionAttribute</li>
+<li>IExceptionTableEntry</li>
+<li>IFieldInfo</li>
+<li>IInnerClassesAttribute</li>
+<li>IInnerClassesAttributeEntry</li>
+<li>ILineNumberAttribute</li>
+<li>ILocalVariableAttribute</li>
+<li>ILocalVariableTableEntry</li>
+<li>IMethodInfo</li>
+<li>IModifierConstants</li>
+<li>IOpcodeMnemonics</li>
+<li>ISourceAttribute</li>
+<li>OpcodeStringValues</li>
+</ul>
+The default implementations are in org.eclipse.jdt.internal.core.util. Any comment is welcome and related bugs
+should be entered in JDT/Core.
+<li>Added char array based APIs on Signature. This APIs avoid creating needless Strings and
+ are thus much more performant than their String based equivalent.
+ <ul>
+ <li><code>createArraySignature(char[], int arrayCount)</code></li>
+ <li><code>createCharArrayTypeSignature(char[], boolean)</code></li>
+ <li><code>createMethodSignature(char[][], char[]) </code></li>
+ <li><code>getArrayCount(char[])</code></li>
+ <li><code>getElementType(char[])</code></li>
+ <li><code>getParameterCount(char[])</code></li>
+ <li><code>getParameterTypes(char[])</code></li>
+ <li><code>getQualifier(char[])</code></li>
+ <li><code>getReturnType(char[])</code></li>
+ <li><code>getSimpleName(char[])</code></li>
+ <li><code>getSimpleNames(char[])</code></li>
+ <li><code>toCharArray(char[], char[], char[][], boolean, boolean)</code></li>
+ <li><code>toCharArray(char[])</code></li>
+ <li><code>toQualifiedName(char[][])</code></li>
+ </ul>
+</li>
+<li>Removed temporary 2.0 API which were deprecated in previous builds:
+ <ul>
+ <li><code>IWorkingCopy#getSharedWorkingCopy(IProgressMonitor, IBufferFactory)</code>, use API with extra <code>IProblemRequestor</code></li>
+ <li><code>IWorkingCopy#getWorkingCopy(IProgressMonitor, IBufferFactory)</code>, use API with extra <code>IProblemRequestor</code></li>
+ <li><code>IWorkingCopy#reconcile(IProblemRequestor)</code>, use API with no <code>IProblemRequestor</code></li>
+ </ul>
+</li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12762">12762</a>
+Performance - Signature#createTypeSignature should be implemented in term of char[]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12688">12688</a>
+NPE with code assist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13408">13408</a>
+Subfolders of build folder are not marked as derived
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13355">13355</a>
+NPE during code completion
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13391">13391</a>
+NPE doing code assist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13487">13487</a>
+NPE in CompletionEnige
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13395">13395</a>
+loading swt+examples with auto-build on causes deadlock (or takes a very long time)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13063">13063</a>
+NPE in extract method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13247">13247</a>
+IllegalArgumentException while creating AST
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13386">13386</a>
+'not implemented yet' surfaced on Display in debug
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12617">12617</a>
+code assist: Proposals inside method parameters
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12338">12338</a>
+Unnecessary recompilation when adding packages
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12262">12262</a>
+Compiler Bug with import Statement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7082">7082</a>
+NPE during build
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020409 - 9th April 2002
+<br>Project org.eclipse.jdt.core v_238a
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Adding a new empty source folder no longer causes a full build. Only an incremental build is needed now.
+</li>
+<li>Java model API additions:
+ <ul>
+ <li><code>IJavaElement.getAncestor(int)</code></li>
+ <li><code>IJavaElement.getOpenable()</code></li>
+ <li><code>IJavaElement.getPath()</code></li>
+ <li><code>IJavaElement.getResource()</code></li>
+ <li><code>IJavaProject.isOnClasspath(IJavaElement)</code></li>
+ <li><code>IPackageFragmentRoot.getRawClasspathEntry()</code></li>
+ <li><code>IType.findMethods(IMethod)</code></li>
+ <li><code>IWorkingCopy.findElements(IJavaElement)</code></li>
+ <li><code>IWorkingCopy.findPrimaryType()</code></li>
+ </ul>
+</li>
+<li>ICompletionRequestor API change :
+ <ul>
+ <li> Added #beginReporting() and #endReporting() API on <code>IProblemRequestor</code>. #beginReporting is always called before restarting error detection. #endReporting is always called at the
+ end of detection.
+ </li>
+ <li> Added API for setting multiple classpath variables at once (<code>JavaCore#setClasspathVariables</code>, this allows to update
+ all affected projects exactly once, instead of iterating multiple times on each project (if it references the variable). This can improve performance
+ when setting JRE variables.
+ </li>
+ <li> Added a new parameter <code>relevance</code> to be able to sort proposal by degree of relevance.
+ <code>relevance</code> is a positive integer which are used for determine if this proposal is more relevant than another proposal.
+ This value can only be used for compare relevance. A proposal is more relevant than another if his relevance
+ value is higher.
+ <br>
+ <br><tt>ICompletionRequestor{</tt>
+ <br><tt> void acceptAnonymousType(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptClass(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptError(...);</tt>
+ <br><tt> void acceptField(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptInterface(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptKeyword(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptLabel(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptLocalVariable(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptMethod(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptMethodDeclaration(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptModifier(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptPackage(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptType(..., <b>int relevance</b>);</tt>
+ <br><tt> void acceptVariableName(..., <b>int relevance</b>);</tt>
+ <br><tt>}</tt>
+ <br>
+ <br>
+ </li>
+ <li>
+ If the completion identifier and proposal are equal and the case match then the proposal relevance grow. Note that this isn't a 1.0 breaking API change, it
+ only affects the 2.0 new code assist API (i.e. still backward compatible with 1.0 clients) which hasn't yet reached stability, though it should be close to now.
+ </li>
+ </ul>
+</li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12614">12614</a>
+Initializing JRE variables slow on plug-in activation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12986">12986</a>
+Creating a working copy does not involve the problem requestor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12858">12858</a>
+Compiler Bug : Invalid Byte Code:
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11739">11739</a>
+Dead branches in package/project Hierarchy View
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12873">12873</a>
+CodeAssist : missing proposal of method declaration
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12007">12007</a>
+Source folder ending with .jar considered as JAR archive
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12908">12908</a>
+Build and save attempt fail with NPE and trying it many times crashs Eclipse
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12246">12246</a>
+Packages view shows .class and .java files when JAR has source
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3349">3349</a>
+Need a IJavaElement.getUnderlyingResource that does not do the exists test (1GJ69GP)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12975">12975</a>
+jacks - qualified assignment to final field should be rejected
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12969">12969</a>
+jacks - synchronized (void expression) should be rejected
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12705">12705</a>
+Progress monitor cuts off package name
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12767">12767</a>
+AST MethodBinding question
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9179">9179</a>
+DCR: Need IJavaSearchScope equals or encloses
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12444">12444</a>
+strange types names in ReorderParameters error dialog
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12781">12781</a>
+AST instanceof-InfixExpression: Cant resolve type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12778">12778</a>
+Typo in comment: InfixExpression.RIGHT_SHIFT_UNSIGNED
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12768">12768</a>
+IScanner doesn't let user state whether line separators are to be recorded
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12651">12651</a>
+NPE out of the CompletionEngine
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12761">12761</a>
+Closing a top level binary type doesn't close the class files of its inner types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12760">12760</a>
+Type hierarchy missing anonymous binary type if closed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12674">12674</a>
+Too many problems while reconciling
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12373">12373</a>
+Assert$AssertionFailedException error while reconciling
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=13059">13059</a>
+incorrect (?) code compiles
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12880">12880</a>
+SQLJ Support
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12603">12603</a>
+Could not delete empty java file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9600">9600</a>
+Field reference in working copy not found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12995">12995</a>
+ToolFactory::createScanner - incorrect javadoc
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12933">12933</a>
+"Never used" variable warnings can't detect across scope
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5135">5135</a>
+Open Java editor on IResource.class do an error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12809">12809</a>
+Unimplemented methods should not prevent class from running
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10421">10421</a>
+WSAD hang while setting buildpath
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12590">12590</a>
+Returning the type when local var is selected breaks refactoring
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12710">12710</a>
+Inconsistent behavior for the method IType.createField()
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020402 - 2nd April 2002
+<br>Project org.eclipse.jdt.core v_237
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Improved specification of <code>IBuffer</code> by saying that:
+ <ul>
+ <li> Java model operations that manipulate an <code>IBuffer</code> (e.g.
+ <code>IType.createMethod(...)</code>) ensures that the same line delimiter
+ (i.e. either <code>"\n"</code> or <code>"\r"</code> or <code>"\r\n"</code>) is
+ used accross the whole buffer. Thus these operations may change the line delimiter(s)
+ included in the string to be append, or replaced.
+ However implementors of this interface should be aware that other clients of <code>IBuffer</code>
+ might not do such transformations beforehand.</li>
+ <li> <code>addBufferChangedListener</code> and <code>removeBufferChangedListener</code>
+ have no effect if the buffer is already closed.</li>
+ <li> Other operations that manipulate the buffer (like <code>setContent</code>
+ might throw a <code>RuntimeException</code> if called after the buffer
+ has been closed.</li>
+ </ul>
+</li>
+<li> IScanner API :
+ <ul>
+ <li> added <code>IScanner#getSource</code> so as to retrieve the scanner original source
+ <li> renamed <code>IScanner#setSourceBuffer</code> into <code>IScanner#setSource</code>
+ </ul>
+</li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12454">12454</a>
+AST/DOM: IllegalArgumentException generated by bad source
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12431">12431</a>
+Unclear compiler error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12416">12416</a>
+Separate caching of project and pkg fragment root from caching of openables
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12457">12457</a>
+Need to synchronize JobManager.discardJobs(...)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12445">12445</a>
+Compiler Failure on reference to abstract interface method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12417">12417</a>
+api: IScanner, ITerminalSymbols - no way to get some tokens
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12419">12419</a>
+Weird secondary error in constructor reconciliation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12419">12419</a>
+api: IScanner - missing (?) getSourceBuffer
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12380">12380</a>
+AST/DOM: resolveTypeBinding() on the second operand of a instanceof expression return null
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9790">9790</a>
+Add constructors from superclass inserts in wrong place
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12387">12387</a>
+Out Of Memory error importing file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3423">3423</a>
+Need IConstants (1GKM51O)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11583">11583</a>
+Infinite loop in OverflowingLRUCache
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12346">12346</a>
+Leaking closed buffers
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11431">11431</a>
+Stepping from one case statement's break ends up in next case
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12326">12326</a>
+Bad line number information returned from CompilationUnit with no trailing newline
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3313">3313</a>
+Severe - Performance - Java Model redundancies (1GFKTUN)
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12470">12470</a>
+0214 - Walkback during encapsulate method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9179">9179</a>
+DCR: Need IJavaSearchScope equals or encloses
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10307">10307</a>
+Code assist failed to search whole class path
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7079">7079</a>
+Code formatting fails with java.lang.Error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3255">3255</a>
+Reminder - re-enable transient marker generation during code-assist (1GDCXLB)
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020426 - 26th April 2002
+<br>Project org.eclipse.jdt.core v_236
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> Reconciling with errors provide type errors in addition to syntax ones. This is still experimental,
+ and can be disabled by unchecking the editor preference for transient problems.
+</li>
+<li>Performance improvement of index queries with the <code>WaitUntilReady</code> policy.
+ The background indexer now takes all the CPU when another thread is waiting for it to
+ finish indexing.
+ User will notice this improvement when doing a search or opening a type and there are
+ still files to index.
+</li>
+<li>Scanner API
+ <ul>
+ <li>defined scanner API (see <code>org.eclipse.jdt.core.compiler.IScanner</code>). </li>
+ <li>added tool factory API (see <code>org.eclipse.jdt.core.ToolFactory#createScanner</code>), allowing to obtain
+ a scanner (implementing <code>IScanner</code> API). </li>
+ </ul>
+</li>
+<li> Code formatter API
+ <ul>
+ <li>defined code formatter API (see <code>org.eclipse.jdt.core.ICodeFormatter</code>). </li>
+ <li>added tool factory API (see <code>org.eclipse.jdt.core.ToolFactory#createCodeFormatter</code>), allowing to obtain
+ a code formatter (implementing <code>ICodeFormatter</code> API). Note that an extension point was also added
+ to allow client code to contribute a code formatter implementation. The code formatter extension point is named
+ <code>org.eclipse.jdt.core.codeFormatter</code>, also see associate comment in plugin.xml.</li>
+ <li>added tool factory API (see <code>org.eclipse.jdt.core.ToolFactory#createDefaultCodeFormatter</code>), allowing to obtain
+ a default code formatter (implementing <code>ICodeFormatter</code> API). </li>
+ </ul>
+</li>
+<li> Working Copy API : instead of passing a problem requestor (<code>org.eclipse.jdt.core.IProblemRequestor</code>) to working copy #reconcile(...)
+operation. The problem requestor is passed along at creation time.
+ <ul>
+ <li>added IWorkingCopy.getWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)</li>
+ <li>added IWorkingCopy.getSharedWorkingCopy(IProgressMonitor, IBufferFactory, IProblemRequestor)</li>
+ </ul>
+ Previous API taking <code>IBufferFactory</code> got deprecated, they will be removed in a subsequent build.
+</li>
+<li>Some internal classes got deprecated (as client code relies on them), since being surfaced:
+ <ul>
+ <li> <code>org.eclipse.jdt.internal.core.parser.InvalidInputException</code> <br>==> <code>org.eclipse.jdt.core.compiler.InvalidInputException</code> </li>
+ <li> <code>org.eclipse.jdt.internal.core.parser.TerminalSymbols</code> <br>==> <code>org.eclipse.jdt.core.compiler.ITerminalSymbols</code> </li>
+ </ul>
+ They will be removed in a subsequent build.
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3353">3353</a>
+API - Should provide api for formatting source (1GJIWCF)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3179">3179</a>
+Compiler - LF cannot run classes that miss implementations of an interface (1FNFVY8)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12199">12199</a>
+Generated classfiles should be tagged as derived resources
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11640">11640</a>
+Bug in the code formatter
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10544">10544</a>
+Internal error creating long package name
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12140">12140</a>
+typo in IPackageFragmentRoot::createPackageFragment javadoc
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11422">11422</a>
+Attaching source when using variables to point to jars very unintuitive
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12000">12000</a>
+Main.compile does not close log file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6558">6558</a>
+Missing class path entries should be displayed as an error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3354">3354</a>
+API - should provide api for Scanning (1GJIWCT)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7496">7496</a>
+Interface shows as class under content assist
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11475">11475</a>
+Code resolve reports types in security package
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10899">10899</a>
+Can't open on selection for member type in binary class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12013">12013</a>
+JavaCore.getClasspathVariable fails on empty variables
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11845">11845</a>
+Internal Compiler Error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11922">11922</a>
+is this code reachable or not?
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12119">12119</a>
+Eclipse build slow on network
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7881">7881</a>
+IType.move() clobbers editing buffer of destination element
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10703">10703</a>
+ast: no API to figure out the source range of 'super' keywords
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10983">10983</a>
+NullPointerException in JavaBuilder during Save
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3355">3355</a>
+API - should provide API for source element parsing (1GJIWD8)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10955">10955</a>
+DCR - search: too limiting api of IJavaSearchScope
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8819">8819</a>
+Self hosting tool doesn't update search index
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11497">11497</a>
+Renaming project failed with Java Model Exception: Java Model Status [Name collision.]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12059">12059</a>
+api: JavaCore::getOptions should return Map, not Hashtable
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12044">12044</a>
+Search for field reference broken
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11905">11905</a>
+DCR - provide scanning API
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020321 - 21st March 2002 - MILESTONE 4
+<br>Project org.eclipse.jdt.core v_235a
+<h2>
+What's new in this drop</h2>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=12014">12014</a>
+No delta when adding package where src=bin and src!=proj
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11755">11755</a>
+resource copy filter and duplicated resource error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11640">11640</a>
+Bug in the code formatter
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11860">11860</a>
+Cannot move a compilation unit
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11627">11627</a>
+Refactoring: CCE in Pullup method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11735">11735</a>
+NPE selecting F3 in editor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11854">11854</a>
+NPE on save
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11805">11805</a>
+build output filter is ignored
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11568">11568</a>
+Code resolve does not work for changed constructor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11656">11656</a>
+Please add a ICompletionRequestorAdapter
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9271">9271</a>
+NPE inspecting "null" in the expressions view
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11638">11638</a>
+ast: CompilationUnit::findDeclaringNode fails
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11272">11272</a>
+slow context assist on method/field-rich classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11340">11340</a>
+open on selection does not work for binary types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11654">11654</a>
+NPE during build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11659">11659</a>
+ast: CompilationUnit::findDeclaringNode fails #2
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11086">11086</a>
+ClassFileCompilationUnit should implement IClassFile
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020319 - 19th March 2002
+<br>Project org.eclipse.jdt.core v_234
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> New API on IType for complete snippet in current type context. Code complete is performed against
+ source (if available) or against type structure
+<br> <tt>void codeComplete(</tt>
+<br><tt> char[] snippet,</tt>
+<br><tt> int insertion,</tt>
+<br><tt> int position,</tt>
+<br><tt> char[][] localVariableTypeNames,</tt>
+<br><tt> char[][] localVariableNames,</tt>
+<br><tt> int[] localVariableModifiers,</tt>
+<br><tt> boolean isStatic,</tt>
+<br><tt> ICompletionRequestor requestor) throws JavaModelException;</tt>
+<br>
+</li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10318">10318</a>
+Feature Request: new Code Assist API required
+
+<h3>
+Problem Reports Closed</h3>
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020318 - 18th March 2002
+<br>Project org.eclipse.jdt.core v_233
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> Added option to trace java search activity.
+ To enable it, see the following line in the org.eclipse.jdt.core/.options file:
+ <code>org.eclipse.jdt.core/debug/search=true</code>
+</li>
+<li>Added API <code>CorrectionEngine#computeCorrections(IProblem, ICompilationUnit, ICorrectionRequestor)</code>, allowing.
+to compute replacement corrections for IProblem(s) detected while reconciling.</li>
+<li>Added API <code>ISourceReference#exists()</code>, allowing.
+to check existency before invoking <code>ISourceReference</code> behavior. All implementations did already provide
+an <code>exists()</code> method since they also are implementing <code>IJavaElement</code>.</li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11524">11524</a>
+api: IWorkingCopy:: getWorkingCopy() javadoc
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11511">11511</a>
+Compiler 1.4 fooled by extra interface methods
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11389">11389</a>
+Unused parameters not showing up as compiler warnings
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11410">11410</a>
+Exception in Java Builder when debug options turned off
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11285">11285</a>
+Potential NPE in CopyResourceElementsOperation.processPackageFragmentResource
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11440">11440</a>
+npe in rename temp
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11468">11468</a>
+NPE deleting project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11435">11435</a>
+compiler bug: overwriting implicitely abstract method in anonymous inner class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11250">11250</a>
+NPE in log after importing plugins
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11271">11271</a>
+Unable to delete a binary project in Java perspective
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11210">11210</a>
+ResourceDeltas are lost when merging deltas
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11371">11380</a>
+ast: missing binding for ConditionalExpression
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11371">11371</a>
+DOM/AST: node missing for super constructor call
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6243">6243</a>
+an ISourceReference API issue
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11296">11296</a>
+NPE during build
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3438">3438</a>
+OpenOnSelection - should be able to locate missing method by guessing (1GL186P)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11406">11406</a>
+ActionPerformed() method in AbstractAction not found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3221">3221</a>
+JM - Deadlock while saving in Editor (1GAJ67W)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11201">11201</a>
+ClassCastException during build process
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020314 - 14th March 2002
+<br>Project org.eclipse.jdt.core v_232
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Added API <code>IDOMFactory.createInterface()</code> and <code>IDOMFactory.createClass()</code>.
+See <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10980">10980</a> for details.</li>
+</ul>
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11355">11355</a>
+OpenOnSelection unable to perform in single-type import
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9232">9232</a>
+ICompilationUnit.delete() fails
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11176">11176</a>
+Organize imports misses org.eclipse.core.resources
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3224">3224</a>
+Tests - Re-enable reconciler tests (1GAKXZM)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10980">10980</a>
+JDT / factory for new interfaces would be nice
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10996">10996</a>
+createCompilationUnit doesn't behave as described in the documentation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11125">11125</a>
+DOM/AST: API request <br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11277">11277</a>
+Difference in between outliner content and unit content
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10833">10833</a>
+Open type doesn't propose all type after a checkout
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11067">11067</a>
+Adding useful toString() method for each new DOM/AST nodes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9933">9933</a>
+Format does not handle synchronized keyword correctly
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8675">8675</a>
+DCR - Code correction could suggest new element creation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11341">11341</a>
+incorrect outline (i see only imports)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11217">11217</a>
+is double "; " on a return statement an error?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10031">10031</a>
+SEF ClassCastException
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020312 - 12th March 2002
+<br>Project org.eclipse.jdt.core v_231
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> Performance improvement:
+ <ul>
+ <li> Search doesn't populate the Java Model any longer. Thus the memory
+ used by a search operation can be reclaimed at the end. </li>
+ <li> Access to zip and jar files has been improved, which should result
+ in better performance on a slow network. </li>
+ </ul>
+ </li>
+<li> Added flag <code>IJavaElementDelta.F_FINE_GRAINED</code> that indicates
+ that a fine-grained delta was computed for a given delta.
+ Clients can use this flag to find out if a compilation unit
+ that have a <code>F_CONTENT</code> change should assume that there are
+ no finer grained changes (<code>F_FINE_GRAINED</code> is set) or if
+ finer grained changes were not considered (<code>F_FINE_GRAINED</code>
+ is not set).
+ </li>
+<li> Surfacing IProblem (<code>org.eclipse.jdt.core.compiler.IProblem</code>)
+ <br>This allows some Java API to report failures in a lighter way than generating markers. Marker based API have been
+ deprecated (note that due to some deadlock in client code, some of these API did not even produce markers, e.g. reconciling). In addition to
+ surfacing problem descriptions, IProblem exposes all the IDs for the Java problem markers (attribute "id" on markers of type "org.eclipse.jdt.core.problem")</li>
+<li> Changed error reporting method for <code>ICompletionRequestor</code> to surface IProblems instead of IMarkers.</li>
+</ul>
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11191">11191</a>
+Strange anonymous types in outline structure
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11151">11151</a>
+ast: IllegalArgumentException on AST creation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10538">10538</a>
+Possible memory leak?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10616">10616</a>
+StringIndexOutOfBoundsException opening type selection dialog
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11152">11152</a>
+Code Select - does not work with empty selection
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11129">11129</a>
+DOM/AST: Call resolveTypeBinding() on a CastExpression object throws a NullPoitnerException
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3256">3256</a>
+SearchableEnvironment - converts char[] to String, which affects performance
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10984">10984</a>
+DOM/AST: CU with syntax errors
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11106">11106</a>
+DOM/AST: do statement doesn't contain trailing semicolon
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11104">11104</a>
+DOM/AST: NumberLiteral contains leading and trailing comments
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10213">10213</a>
+SearchEngine.createJavaSearchScope((IJavaElement[]) does not work for binary elements
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9240">9240</a>
+Search finds deleted classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11011">11011</a>
+incorrect 'variable never used' warning
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11025">11025</a>
+extract method: incorrectly disallowed on some boolean expressions
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10697">10697</a>
+Performance - Binary model should not cache the classfile bytes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11037">11037</a>
+DOM/AST: IllegalArgumentException when creatin AST
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10635">10635</a>
+Override methods not showing missing methods
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7930">7930</a>
+Code Assist - No completion in switch statement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10979">10979</a>
+JDOM/add superinterface format problem
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10986">10986</a>
+DOM/AST: NPE when trying to resolve a binding
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10580">10580</a>
+type hierarchy incorrect for nested types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10935">10935</a>
+DOM/AST: wrong length of variable declaration fragment
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6111">6111</a>
+Missing completion
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10898">10898</a>
+DOM/AST: NullPointerException
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3261">3261</a>
+Search - Memory peak during search (1GEN17L)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6667">6667</a>
+Search: OutOfMemoryError searching wildcarded field ref
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10874">10874</a>
+DOM/AST: ClassInstanceCreation contains trailing comment
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10881">10881</a>
+DOM/AST: SwitchCase.isDefault always returns false
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10865">10865</a>
+DOM/AST; AST.resolveWellKnownType("void") returns null
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10861">10861</a>
+DOM/AST: TypeLiteral.resolveTypeBinding doesn't return class Class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10819">10819</a>
+Incomplete task description after build with incomplete classpath
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10468">10468</a>
+DOM/AST: TypeDeclaration#isLocalTypeDeclaration doesn't consider anonymous types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10499">10499</a>
+DOM/AST: need a way to access the IMethodBinding of a ClassInstanceCreation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10496">10496</a>
+DOM/AST: need for a node that holds the body statements of a ClassInstanceCreation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10781">10781</a>
+ast: incorrect position and length for AnonymousClassDeclaration
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10843">10843</a>
+DOM/AST: wrong structure for for statements
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10663">10663</a>
+ast: exception in AST converter
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10759">10759</a>
+ast: incorrect length of SimpleName (subsubnode of ArrayType)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10500">10500</a>
+Shouldn't ignore inherited method with wrong argument types
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10627">10627</a>
+Rebuild Deletes non-Class Resources
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3233">3233</a>
+JM - CreateElementInCuOperation should not save working copy (1GBEKAW)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3445">3445</a>
+search: type hierarchy scope incorrect (1GLC8VS)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10954">10954</a>
+IMember::getFlags semantics on interface members
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3195">3195</a>
+Unnecessary proposals in Open on selection whith syntax error (1G0EIBB)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10933">10933</a>
+DOM/AST: position of AnonymousTypeDeclaration is [-1,0]
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10815">10815</a>
+Error message for "incomplete path" lacks details
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10913">10913</a>
+DOM/AST: resolveBinding() for static field access
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10698">10698</a>
+DOM/AST: exception when creating AST
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=4946">4946</a>
+Cross-project builder efficiency issues
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3213">3213</a>
+No compile error for bad interface (1G7G6M1)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10667">10667</a>
+NPE in self encapsulate field
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10389">10389</a>
+Editing non-Java files causes a recompile
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10313">10313</a>
+Can not create Java project from existing source (1000+ Java files)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10794">10794</a>
+NPE from search during refactor, pull up method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10699">10699</a>
+ast: nothing in anonymous inner classes is created
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020305 - 5th March 2002
+<br>Project org.eclipse.jdt.core v_230
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> Added API <code>IClassFile.getWorkingCopy(IProgressMonitor, IBufferFactory)</code>
+ for consistence with <code>IWorkingCopy</code>.
+ The returned working copy is just a wrapper on the class file's buffer.
+ Thus only the <code>getBuffer()</code> operation is valid on this working
+ copy.
+</li>
+<li> Added the notion of shared working copies. This allows clients to always
+ get the same <code>IWorkingCopy</code> instance when asking for a working copy.
+ See <code>IWorkingCopy.getSharedWorkingCopy(IProgressMonitor, IBufferFactory)</code>,
+ <code>IWorkingCopy.findSharedWorkingCopy()</code>
+ and <code>IWorkingCopy.destroy()</code> for more detail.
+</li>
+<li> Added option to trace use of shared working copies.
+ To enable it, see the following line in the org.eclipse.jdt.core/.options file:
+ <code>org.eclipse.jdt.core/debug/sharedworkingcopy=true</code>
+</li>
+<li> Added extension point to jdtcore so as to allow client plugins to register classpath variable initializers.
+ Extension point is "org.eclipse.jdt.core.classpathVariableInitializer".
+ (also see <a href="http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.eclipse.jdt.core/notes/r2.0/variable%20init/uninit-classpath-vars.html">design notes</a>)
+ Note that each classpath variable, if unbound, will trigger its registered initializer exactly once per session. If unsuccessful, it will stay unbound.
+
+</li>
+<li> Added option to trace classpath variable initializations.
+ To enable it, see the following line in the org.eclipse.jdt.core/.options file:
+ <code>org.eclipse.jdt.core/debug/cpvariable=true</code>
+</li>
+<li>Added option to trace access to zip and jar files from the Java model.
+ To enable it, see the following line in the org.eclipse.jdt.core/.options file:
+ <code>org.eclipse.jdt.core/debug/zipaccess=true</code>
+</li>
+<li>Resurrect some code for backport 1.0 internal functionality
+ <ul>
+ <li> org.eclipse.jdt.internal.compiler.ConfigurableOption (all the class).
+ <li> org.eclipse.jdt.internal.formatter.CodeFormatter (some methods) :
+ <ul>
+ <li> public CodeFormatter(ConfigurableOption[] settings)
+ <li> private static Map convertConfigurableOptions(ConfigurableOption[] settings)
+ <li> public static ConfigurableOption[] getDefaultOptions(Locale locale)
+ <li> public static String format(String sourceString, int initialIndentationLevel, ConfigurableOption[] options)
+ </ul>
+ <li> org.eclipse.jdt.internal.formatter.Options.properties (all the file)
+ </ul>
+</li>
+</ul>
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3303">3303</a>
+Many errors when adding projects from repository in a fresh install (1GF5PU7)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5285">5285</a>
+Compile errors on load when Java Perspective not open
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7085">7085</a>
+Build errors when adding the JUnit example project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10700">10700</a>
+ast: resolveBinding returns null on parameter reference
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10676">10676</a>
+StringLiteral.resolveTypeBinding() return null
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10679">10679</a>
+ClassCastException when calling resolveTypeBinding() with an error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10634">10634</a>
+Problem with compiling some java classes; class not visible
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10340">10340</a>
+NPE when selecting multiple methods to "Pull up"
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10662">10662</a>
+Casting to Buffer makes it impossible for clients to implement IBuffer
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10592">10592</a>
+ast: NPE in SingleVariableDeclaration::resolveBinding
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9583">9583</a>
+DOM : Self encapsulate field: NPE
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10570">10570</a>
+ast: CatchClause has incorrect startingPoint
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10587">10587</a>
+ast: missing node for a variable binding
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9588">9588</a>
+Invalid delta when replacing jar and proj=src=bin
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10495">10495</a>
+typo in ASTNode::MALFORMED javadoc
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10472">10472</a>
+CodeAssist - No completion between dot and number
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3323">3323</a>
+OpenOnSelection - no selection inside CodeFormatterPreferencePage.fTextListener initializer (1GGND3S)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10466">10466</a>
+"Cannot reference a field before it is defined" - compiler bug?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10386">10386</a>
+NPE in MatchLocator.lookupType
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10378">10378</a>
+perf problem with external JARs
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9593">9593</a>
+SelectionEngine give more results than expected
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9969">9969</a>
+CodeFormatter: Bug when formatting try/catch Block
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3231">3231</a>
+1.4 - target is now 1.2 (1GHW0DF)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9998">9998</a>
+Performance - Better pruning meaningless AST nodes upon completion
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10240">10240</a>
+JDTCompilerAdapter doesn't understand "deprecation" from Ant
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10274">10274</a>
+DOM/AST: wrong implementation of TypeDeclaration.getFields
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10241">10241</a>
+Remaining references to com.ibm
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10753">10753</a>
+Compiler barfs on c:\ubizen with invalid unicode
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10749">10749</a>
+Bug is code formatter
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10701">10701</a>
+Undefined method when compiling using JDK 1.4
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10674">10674</a>
+AST API request : method binding for ClassInstanceCreation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10583">10583</a>
+Can not save any java file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10275">10275</a>
+Search: reference to class not found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3437">3437</a>
+Code Assist fails when method has unknown return type (1GL12EG)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9579">9579</a>
+Search: declaration in hierarchy - wrong matches
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10460">10460</a>
+The Compiler can not resolve package level class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10244">10244</a>
+DOM/AST: MethodInvocation should have resolveBinding() method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9157">9157</a>
+My existing .class files are deleted!
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020226 - 26th February 2002
+<br>Project org.eclipse.jdt.core v_229
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Java tooling now performs normally inside method bodies whose signature could not
+be resolved.
+</li>
+<li> Specified that when an <code>IBuffer</code> is created through an
+ <code>IBufferFactory</code>, its content is set with the original
+ element's content.
+</ul>
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10110">10110</a>
+Project not build since it was inconsistent
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9642">9642</a>
+Search - missing inaccurate type matches
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9992">9992</a>
+Member class declaration not found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10221">10221</a>
+No variable name suggestion on array type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10166">10166</a>
+Interface hides Object methods
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7934">7934</a>
+Builder always rebuilds when workbench restarted
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7456">7456</a>
+Error message with overloaded methods is confusing
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10152">10152</a>
+Computing hierarchy of IResource is slow
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8809">8809</a>
+Code assist with class folders does not work
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9763">9763</a>
+Code assist failure due to error in method signature:1GRVN5R
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9985">9985</a>
+Built in compiler will sometimes not allow Object method calls on Interfaces
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10008">10008</a>
+Internal compiler error when compiling switch statement
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9912">9912</a>
+Batch compiler doesn't put binaries in the right folder when -d is missing
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6059">6059</a>
+NPE in JavaModelStatus
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9351">9351</a>
+Copying a compilation unit onto itself destroys compilation unit
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9813">9813</a>
+VerifyError with Inner Class having private constructor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9492">9492</a>
+Walkback while searching
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9837">9837</a>
+Inconsistent behavior when compiling from source or using binaries for constant expressions
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6951">6951</a>
+DCR - Builder should ignore filtered out resources
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5809">5809</a>
+Duplicate class names in separate package imports cause compile error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9888">9888</a>
+JAR exorter problems with META-INF in projects with no source folder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=10104">10104</a>
+Calculated serialVersionID's are incompatible with Sun's JDK
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020214 - 14th February 2002 - MILESTONE 3
+<br>Project org.eclipse.jdt.core v_228
+<h2>
+What's new in this drop</h2>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9479">9479</a>
+exception on package creation (discouraged name)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5999">5999</a>
+IType.resolveType returns multiple matches also the type is unambigious
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7485">7485</a>
+IType resolve fails
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9785">9785</a>
+Problem in IType.resolveType()
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9239">9239</a>
+search for method declaration - strange behavior
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5647">5647</a>
+Search results differ when using outliner context menu vs. dialog
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5239">5239</a>
+outliner gets out of synch
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5029">5029</a>
+Internal Error saving java file
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9586">9586</a>
+Java 1.4 feature assert does not throw any exception
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9504">9504</a>
+1GRU1L3:Search reference works only in outline view and not in editor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9476">9476</a>
+ArrayIndexOutOfBounds in JavaBuilder
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3262">3262</a>
+Strange output file deletion (1GDS2IX)
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020212 - 12th February 200
+<br>Project org.eclipse.jdt.core v_227
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Resource copy filters : A new setting allows to specify exclusion filters for resource being copied to the output folder..
+ <ul>
+ <li>option id: "org.eclipse.jdt.core.builder.resourceCopyExclusionFilters"
+ <li>possible values: { "<name>[,<name>]* } where <name> is a file name pattern (only * wild-cards allowed)
+ <li>default: ""
+ </ul>
+</li>
+<li>Encoding support : Batch compiler can be specified the source encoding format using '-encoding myEncoding' command line option.
+In case of necessity, each individual file specified on the command line can be associated with a custom encoding
+by suffixing its name with '[myEncoding]' (if applied to a folder, then all files in it will be sharing the custom
+encoding). When no encoding is specified, then the platform default is used (as before). Similarily, a JavaCore option got added to
+control the default encoding (no support yet for per file custom encoding).
+ <ul>
+ <li>option id: "org.eclipse.jdt.core.encoding"
+ <li>possible values: { "" for platform default, or any of the supported encoding name }.
+ <li>default: ""
+ </ul>
+</li>
+<li> Fix for <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9183">9183</a> required to increment the index signature
+version so as to trigger automatic reindexing on workspace startup (and thus add somme type references that were previously
+missing from the binary index files). Subsequent startups will not reindex any further (only if inconsistency is detected,
+e.g. signature version is different).
+</li>
+<li> The <code>IBufferFactory</code> used when creating an <code>IWorkingCopy</code>
+(see <code>ICompilationUnit.getWorkingCopy(IProgressMonitor monitor, IBufferFactory factory)</code>)
+is now remembered and will be reused if the working copy is closed then reopen.
+</li>
+<li>Old Java builder implementation got removed</li>
+<li>Project dependency cycle detection reenabled</li>
+<li> Open on selection no longer need a non-empty selection to perform (when empty it will use the token
+in which the selection start position is located).
+<li>Improved progress reporting while searching all types in the workspace.</li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9452">9452</a>
+IllegalArgumentException when creating an AST for TestCase.java
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7390">7390</a>
+Editing and saving read-only .java source file may cause lost of data
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7926">7926</a>
+Code Assist - No completion for class instance creation after inner class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7636">7636</a>
+Can't do code assist after field with local class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8369">8369</a>
+Code assist stops to work after anonymous class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9398">9398</a>
+Compiler error with double array
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9395">9395</a>
+ClassCastException during build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9185">9185</a>
+Severe shutdown performance problem
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6167">6167</a>
+Indexer not stoped on exit
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7362">7362</a>
+Override Methods doesn't handle unicodes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7295">7295</a>
+Indendation in generated getters/setters of inner classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6678">6678</a>
+Incorrect output after Add Unimplemented Method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8758">8758</a>
+null pointer exception in eclipse core while compiling Java code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6236">6236</a>
+Renamed file is not excluded from project build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8696">8696</a>
+Code assist doesn't work in initializer of anonymous inner class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6064">6064</a>
+Open on selection shouldn't require selection.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9223">9223</a>
+CodeAssist failure in inner type from class file.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6847">6847</a>
+DCR - Filtering output to build directory
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9309">9309</a>
+DOM/AST: NPE when trying to resolve a binding
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9308">9308</a>
+DOM/AST: two equal hash table accesses
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9101">9101</a>
+Parse error while typing in Java editor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9031">9031</a>
+NPE in AbstractMethodDeclaration.compilationResult during search
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9084">9084</a>
+NPE in parser during build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9008">9008</a>
+Code assist on method declaration gives wrong throw exception
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8878">8878</a>
+Code assist provides arbitrary, invalid choice after a space
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9198">9128</a>
+NegativeArraySizeException starting workbench
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9035">9035</a>
+I got an NPE
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9183">9183</a>
+BinaryIndexer doesn't index all type references
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3321">3321</a>
+Adding missing source folder doesn't remove warning (1GGCC4P)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3219">3219</a>
+JM - 'Cycle detected' should not be a marker attribute (1G8VTSA)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9169">9169</a>
+Wrong code generation for comparison of string constants
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8685">8685</a>
+Exception while deleting a method
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=4021">4021</a>
+jdt: Java elements and resources: error in source code (1GG87S9)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7878">7878</a>
+On Package creation: No warning for unconventional names
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9041">9041</a>
+search: cannot create a sub-cu scope
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9088">9088</a>
+Unreachable catch block when error in referenced class's fields
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3299">3299</a>
+Autobuild produces errors when renaming source folders
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9009">9009</a>
+ClassCastException creating an invalid method
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3190">3190</a>
+JM - use of "open" in java model inconsistent with core (1FW2EYQ)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3268">3268</a>
+create(IProject) strange for normal projects (1GDVTER)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8527">8527</a>
+Delete inner class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3037">3037</a>
+Core error compiling a java class (1GEJK8Q)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9386">9386</a>
+cannot import jar files into project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7976">7976</a>
+JDT misses the new Java files created by PDE
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5713">5713</a>
+NPE when searching for references in a JAR
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9177">9177</a>
+Builder treats build errors as JavaErrors
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8040">8040</a>
+java source with $ in reference won't compile
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5036">5036</a>
+assertion fails on build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8498">8498</a>
+deprecated methods are not displayed in the task console
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3371">3371</a>
+Assertion failed exception during build (1GK183O)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3419">3419</a>
+asserion failed in build (1GKB9CH)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7895">7895</a>
+Wierd state: Project not built because inconsistent.
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7830">7830</a>
+Deleting more than one method consecutively from the hierarchy view causes unexpected corruption of othe methods
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9190">9190</a>
+Removing a library from classpath gives not a remove delta
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9104">9104</a>
+copy package progress dialog has missing string
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5706">5706</a>
+Cannot add two folders w/ same name but diff projects to build path of Java project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9103">9103</a>
+Search reports no references to SWT.Help
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6418">6418</a>
+Scrapbook: "Unexpected End Of File" expected
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3191">3191</a>
+JM - non-existing external jars will not come to life when created (1FWI5C4)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8980">8980</a>
+Unpredictable error catching on overridden methods with less visibility
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9024">9024</a>
+Do not find reference to an interface in JAR
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9040">9040</a>
+DOM/AST: why is the left hand side of an assignment an expression
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020205 - 5th February 2002
+<br>Project org.eclipse.jdt.core v_226
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> The JavaModel no longer notifies changes for generated classfiles in the output folder, these
+were never supposed to be signaled. </li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3448">3448</a>
+No error for package and type collision in default package
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9016">9016</a>
+DOM/AST: Problems with array.length access
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9014">9014</a>
+DOM/AST: NullPointerException when resolving System.err.println
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=9018">9018</a>
+DOM/AST: why does the key of a variable binding include the type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5355">5355</a>
+search: NPE in searchDeclarationsOfReferencedTypes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8928">8928</a>
+Unable to find references or declarations of methods that use static inner classes in the signature
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3291">3291</a>
+Exception adding .class file to folder in package view (1GEUF3I)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8900">8900</a>
+Search causing internal error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8812">8812</a>
+Changing export state not propagated
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8856">8856</a>
+DOM AST: positions and bindings missing on QualifiedName
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3446">3446</a>
+type hierarchy: incorrect behavior wrt working copies (1GLDHOA)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3210">3210</a>
+Search - method declarations within TypeHierarchy gives no matches (1G54BMR)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8145">8145</a>
+TypeDeclaration sourceEnd contains trailing comment
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8832">8832</a>
+Sanity check error (internal error) when unused variables inside initializers
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8078">8078</a>
+Missing resource in copy CU dialog
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8764">8764</a>
+NPE while closing projects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8359">8359</a>
+Index out of date when replacing a JAR
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8773">8773</a>
+VerifyError : A .class file exported from VAJ does not run in JDK 1.2.2 (1GPPET0)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8697">8697</a>
+2 compiler bugs: the operator unkown operator is undefined and defined in an inherited type and an enclosing scope
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8706">8706</a>
+Compile error when compiling an anonymous class which extends java.awt.Frame
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8709">8709</a>
+Error compiling JDK1.4 classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8340">8340</a>
+inaccurate error message when dependent project is closed
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3344">3344</a>
+JavaElementDelta reports changed class files (1GIV8IK)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8384">8384</a>
+Unexpected compile errors when abstract method missing return type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8789">8789</a>
+Compiler incorrectly reports that abstract method has a body
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7987">7987</a>
+Field reference search should do lookup in 1.4 mode
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8863">8863</a>
+.classpath gets overwritten if there's an XML error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7162">7162</a>
+Java Model Exceptions in log from TypeHierarchyLifeCycle
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8699">8699</a>
+Compiler error message incomplete: Syntax error on token ''
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3324">3324</a>
+Bad compiler error (1GHF25P)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3441">3441</a>
+Internal error renaming a class (1GL2XCW)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7841">7841</a>
+Overriden methods inserted past the end of source
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020129 - 29th January 2002
+<br>Project org.eclipse.jdt.core v_225
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> Java compiler is JCK 1.4 compliant. When toggled in 1.4 mode (batch: -1.4 -source 1.4), the Java compiler is fully JCK 1.4 compliant
+as of JCK 1.4 2001-10-01 update. When in 1.3 mode (default), it is JCK 1.3a compliant.
+</li>
+<li> By default, when toggled into 1.4 mode, the batch compiler will enable assertion support (e.g. -source 1.4). It can still manually
+be toggled for 1.3 source level compatibility (-source 1.3).
+</li>
+<li> Added constructor <code>SearchEngine(IWorkingCopy[])</code>
+ which takes a list of working copies that will take precedence
+ over their original compilation units in the subsequent search
+ operations on this search engine.
+ <br>
+ Note that this functionality is still under development and some
+ parts may not work as expected. Feedback is welcome.
+</li>
+<li> New feature to achieve problems corrections : org.eclipse.jdt.core.CorrectionEngine.
+ Correction results are answered through a requestor (org.eclipse.jdt.core.ICorrectionRequestor).
+</li>
+<li> JavaCore will no longer add indirectly prereq'ed project amongst project references.
+</li>
+<li> New JDOM AST API available (also see <a href="http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/org.eclipse.jdt.core/notes/r2.0/dom%20ast/ast.html?rev=1.1&content-type=text/html">design
+note</a>). This API has not yet reached full stability, and feedback is very welcome.
+</li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8641">8641</a>
+Can't find references in hierarchy in binary projects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8659">8659</a>
+Unexpected changes in project references (.vcm-meta)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8358">8358</a>
+Search: doesn't find reference although there are
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6799">6799</a>
+Duplicate type collisions
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8414">8414</a>
+Incorrect "unused variable" warning?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8484">8484</a>
+Internal error searching for write access to a variable
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8536">8536</a>
+Bug on "Open type hierarchy"
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8575">8575</a>
+Variable name code completion should handle arrays
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8530">8530</a>
+Internal error using assertions (1.4 feature)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8531">8531</a>
+VerifyError in code containing assertions
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7509">7509</a>
+1GQ6DUC: WSWB:WIN2000 - Ctrl-space Code Completion does not work
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8060">8060</a>
+Hierarchy only shows Object when opening type in binary project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3408">3408</a>
+JCK 1.4 - NAME - qualified AmbiguousName and an ExpressionName (1GK7M9B)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8584">8584</a>
+Invalid syntax error generated by compiler
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020124 - 24th January 2002 - MILESTONE 2
+<br>Project org.eclipse.jdt.core v_224
+<h2>
+What's new in this drop</h2>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=11354">11354</a>
+Unable to edit Java code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8016">8016</a>
+getter/setter outliner reconciling broken
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8352">8352</a>
+No hierarchy when using HierachyType
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8042">8042</a>
+ClassCastException hovering in java editor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8216">8216</a>
+Incomplete super type hierarchy for binaries
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8125">8125</a>
+'Could not uniquely map the type name' message opening type
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7221">7221</a>
+IllegalArgumentException renaming package
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5341">5341</a>
+Error message shouldn't expose exception class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8038">8038</a>
+Null Pointer Exception Adding Unimplemented
+
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020123 - 23rd January 2002
+<br>Project org.eclipse.jdt.core v_223
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>Added workaround for <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7764">7764</a>
+UI Dead Lock - IDE frozen
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3200">3200</a>
+JavaBuilder - Build progress message could be shortened
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=8087">8087</a>
+NPE when hierarchy verbose on and hierarchy on a region
+
+<h3>
+Problem Reports Closed</h3>
+
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020122 - 22nd January 2002
+<br>Project org.eclipse.jdt.core v_222
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> The selection engine now only selects identifier between selection start and selection end.
+Previous behaviour was to select identifier between selection start and identifier end.
+(e.g. if you select <b>File</b> in <b>File</b>Input, now the selection engine select the class File and not FileInput)
+<li> Fix for <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6839">6839</a> required to increment the index signature
+version so as to trigger automatic reindexing on workspace startup (and thus get rid of undesired anonymous type entries
+in the index files). Subsequent startups will not reindex any further (only if inconsistency is detected, e.g. signature version
+is different).
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7993">7993</a>
+NPE when creating type hierarchy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3417">3417</a>
+JCK 1.4 - BINC - the new method is a static (respectively instance) method. (1GK7WCP)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3416">3416</a>
+JCK 1.4 - BINC - the new method is less accessible than the old one (1GK7VXD)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3415">3415</a>
+JCK 1.4 - BINC - the new field is a static (respectively instance) field (1GK7VSN)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3414">3414</a>
+JCK 1.4 - BINC - the new field is less accessible than the old one (1GK7VMD)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3413">3413</a>
+JCK 1.4 - BINC - detection of an IncompatibleClassChangeError (1GK7VCA)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3412">3412</a>
+JCK 1.4 - BINC - Invoke overriding class methods (1GK7UGQ)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3410">3410</a>
+JCK 1.4 - BINC - Adding a String field that has the same name as a String field of a superclass (1GK7MHO)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7920">7920</a>
+JavaProject.canonicalizedPath
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7597">7597</a>
+PackageFragmentRoot which are archives loose associated resource
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7827">7827</a>
+null returned from getOriginal(IJavaElement workingCopyElement) for IMPORT_CONTAINER
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7144">7144</a>
+Hierarchy incorrect when using binary projects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3411">3411</a>
+JCK 1.4 - BINC - Overriding instance and class methods (1GK7U6C)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3418">3418</a>
+JCK 1.4 - EXPR - a NullPointerException is raised in run time (1GK7WHA) <br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7441">7441</a>
+Open a type is extremely slow
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7616">7616</a>
+Unnecessary indexing when project is opened
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3229">3229</a>
+OpenOnSelection - strange behaviour of code resolve (1GAVL08)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6953">6953</a>
+No code assist proposals for interface constructor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7583">7583</a>
+DOMNode#getChild(String) needs to handle children with null names
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7584">7584</a>
+Comments on IDOMMethod#getReturnType()
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3247">3247</a>
+SelectionEngine moves selection to enclosing token (1GCSD8D)
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7956">7956</a>
+No reference found to BlockScope.analysisIndex
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3283">3283</a>
+OpenOnSelection - Code resolve doesn't work in some situations (1GEI5QT)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5453">5453</a>
+DCR: Code Assist for anonymous types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7617">7617</a>
+NPE in Builder with duplicated type names
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6466">6466</a>
+Code Formatter
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020115 - 15th January 2002
+<br>Project org.eclipse.jdt.core v_221
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> The compiler will now follow JLS 8.6 with respect to anonymous class
+constructors (i.e. allow them to throw any exceptions).
+<li> The compiler now enforces that interface methods be compatible with Object ones.
+<li> The batch compiler will no longer create package directory structure anymore when the command line
+argument '-d' <tt><destination></tt> is omitted (compliant with standard batch compilers).
+<li> A type hierarchy that misses a super type is not rooted at Object any longer,
+ but the subtype (of the missing type) will be a root (this is the behavior of
+ VA/Java and VAME.)
+<li> Adding a type that was missing from a hierarchy will update the hierarchy correctly.
+<li> New API on ICompletionRequestor for suggest anonymous type declaration:</li>
+<br> <tt>void acceptAnonymousType(</tt>
+<br><tt> char[] superTypePackageName,</tt>
+<br><tt> char[] superTypeName,</tt>
+<br><tt> char[][] parameterPackageNames,</tt>
+<br><tt> char[][] parameterNames,</tt>
+<br><tt> char[][] parameterNames,</tt>
+<br><tt> char[] completionName,</tt>
+<br><tt> int modifiers,</tt>
+<br><tt> int completionStart,</tt>
+<br><tt> int completionEnd);</tt>
+<br>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7625">7625</a>
+No typehierarchy in working copy
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7595">7595</a>
+New builder performs intempestive full build on method body changes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7528">7528</a>
+IlegalArgumentException in path canonicalisation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7034">7034</a>
+code assist performance problem in scrapbook
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7119">7119</a>
+Content Assist does not complete some code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7000">7000</a>
+Switch and Try statement doesn't include trailing }
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6932">6932</a>
+Increment statement in for loop contains trailing comments
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6342">6342</a>
+Code assist on Intreface-'Constructors' incomplete
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7344">7344</a>
+Search - write acces give wrong result
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7455">7455</a>
+Build problems when instance variable name matches constructor parameter name and assignment to this.name in try block
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6839">6839</a>
+AllTypesSearchEngine returns anonymous classes
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7445">7445</a>
+char/string concat bug
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3192">3192</a>
+Invalid type hierarchy when missing type(s) in hierarchy (1GF5RN4)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3304">3304</a>
+Hierarchy not updated when changing classpath (1GF5QSW)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7422">7422</a>
+Missing project references on some imported Java projects
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5067">5067</a>
+CodeAssist - no variable name suggestion for base type
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7363">7363</a>
+Rebuild Project action is not compiling all Java source files
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7325">7325</a>
+Build collisions should be non-fatal?
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7324">7324</a>
+Ambiguous multiple problem descriptions when collision of build files
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3385">3385</a>
+JCK 1.4 - INTF - illegal method declaration for interface (1GK2AWS)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3318">3318</a>
+JDOM - IDomNode redefines clone() with different signature (1GFVU2V)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6101">6101</a>
+Unexpected error in inner class
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7333">7333</a>
+typo in type name: ResetSateForCodeGenerationVisitor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7354">7354</a>
+Compatibility with javac when no output directory is specified
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6473">6473</a>
+JavaConventions should use IWorkspace validate methods
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7129">7129</a>
+Problems with replacing a project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3386">3386</a>
+JCK 1.4 - EXCP - checked exception in variable initializer of anonymous class (1GK7B5L)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3367">3367</a>
+JCK 1.4 - ICLS - An instance initializer in an anonymous class may throw any exception (1GK7LYF)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7184">7184</a>
+Built in compiler does not allow anonymous class initializers to throw exceptions
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6504">6504</a>
+Type hierarchy: Subtypes in jar of another project not found
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3334">3334</a>
+Types hierarchy view does not show all subclasses. (1GI901Q)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6866">6866</a>
+Code-Assist (ctrl+space) to slow with jre-src
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7071">7071</a>
+ArrayStoreException getting hoverhelp in Java editor
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7165">7165</a>
+erroneous warning of unused variables
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3217">3217</a>
+JM - deleting default package (1G8417Z)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7375">7375</a>
+new classes with funny names don't appear in package view
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7302">7302</a>
+Need visibility in search results
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7305">7305</a>
+interface methods are marked abstract
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7290">7290</a>
+Project size limitation
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6232">6232</a>
+Build problems: Internal error: null when compiling JDK source code
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7380">7380</a>
+Wrong scope for traverse methods
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7137">7137</a>
+Invalid type not flagged by compiler
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6924">6924</a>
+ArrayIndexOutOfBoundsException when setting the build path.
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20020108 - 8th January 2002
+<br>Project org.eclipse.jdt.core v_220a
+<h2>
+What's new in this drop</h2>
+<ul>
+<li>
+Added new compiler option to toggle compliance level (can be either
+"1.3" or "1.4" - 1.3 being the default), and it will affect the behavior
+of the compiler with respect to JLS 8.1.5 (inherited member shadows enclosing
+one). Option is located on <tt>JavaCore#getOptions()</tt> and named <tt>"org.eclipse.jdt.core.compiler.compliance"</tt>
+Accordingly, the batch compiler accepts an extra command line argument
+"-1.3" or "-1.4" (1.3 compliance being the default).</li>
+</ul>
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3330">3330</a>
+JCK 1.4 - illegal simple name imports (1GHW0G1)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7070">7070</a>
+moved classes lost!
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6785">6785</a>
+NPE in IType.resolve
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6779">6779</a>
+searchDeclarationsOfReferencedTyped - missing exception types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7035">7035</a>
+New builder - builder does not close all JARs
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7033">7033</a>
+Stale packages view after moving compilation units
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6927">6927</a>
+Static inner class won't compile (doesn't match JDK behavior)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7030">7030</a>
+IllegalArgumentException renaming project
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7029">7029</a>
+Renaming a Java project doesn't refresh the packages view
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7027">7027</a>
+project gone after renaming in the navigator
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=7026">7026</a>
+walkback on rename project - could not reproduce
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6889">6889</a>
+No typehierarchy for inner types
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3343">3343</a>
+Missing java.lang.Object should produce a more prominent compiler error
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6948">6948</a>
+New builder - builder does not reuse opened JARs
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3314">3314</a>
+Resources not appearing in Java perspective or Jar export wizard (1GFL0QT)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6890">6890</a>
+META-INF hidden
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6993">6993</a>
+JavaModel inconsistencies with units outside classpath
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3360">3360</a>
+Code assist does not work in inner classes (1GJOVT6)
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6893">6893</a>
+LocalTypeDeclaration includes preceeding comment even if there are statements in between
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=3372">3372</a>
+Markers for build path not updated on (re-) build
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=5413">5413</a>
+incorrect class source range
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6429">6429</a>
+declaration source start incorrect on local variable
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=6433">6433</a>
+declaration source start incorrect on local variable #2
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3235">3235</a>
+PackageFragmentRoot existency check need to be revisited (1GCUNO7)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6865">6865</a>
+open on selection in BuildNotifier only finds contents of rt.jar
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6037">6037</a>
+JarPackageFragmentRoot.getUnderlyingResource() always returns null
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6750">6750</a>
+Batch compiler - Classpath handling is too strict
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3409">3409</a>
+JCK 1.4 - STMT - null literal in throw statement (1GK7MEQ)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4915">4915</a>
+JCK 1.4 - need a major compiler switch for 1.3 / 1.4 mode
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6678">6678</a>
+Incorrect output after Add Unimplemented Method
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3361">3361</a>
+JCK 1.4 - ICLS - field from outer class and inherited public field in nested class (1GK7LAA)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3350">3350</a>
+JCK 1.4 - ICLS - static class from outer and class from superclass in top-level nested class (1GK7DVJ)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3351">3351</a>
+JCK 1.4 - ICLS - static class from outer and protected static class from superclass in nested class (1GK7DZV)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3352">3352</a>
+JCK 1.4 - ICLS - static class from outer and public static class from superclass in nested class (1GK7EB9)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3362">3362</a>
+JCK 1.4 - ICLS - field from outer class and inherited field in nested class (1GK7LCX)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3363">3363</a>
+JCK 1.4 - ICLS - An inherited variable that shadows a name from an enclosing non-package scope (1GK7LHR)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3364">3364</a>
+JCK 1.4 - ICLS - An inherited method that shadows a name from an enclosing non-package scope (1GK7LKV)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3365">3365</a>
+JCK 1.4 - ICLS - An inherited class that shadows a name from an enclosing non-package scope (1GK7LTA)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3366">3366</a>
+JCK 1.4 - ICLS - An inherited interface that shadows a name from an enclosing non-package scope (1GK7LW2)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3375">3375</a>
+JCK 1.4 - ICLS - class from outer and protected class from superclass in top-level nested class (1GK7FLC)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3376">3376</a>
+JCK 1.4 - ICLS - class from outer and public class from superclass in top-level nested class (1GK7FOT)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3377">3377</a>
+JCK 1.4 - ICLS - class from outer and class from superclass in top-level nested class (1GK7FTA)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3378">3378</a>
+JCK 1.4 - ICLS - class from outer and protected static class from superclass in nested class (1GK7FX7)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3379">3379</a>
+JCK 1.4 - ICLS - class from outer and public static class from superclass in nested class (1GK7G2A)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3380">3380</a>
+JCK 1.4 - ICLS - class from outer and static class from superclass in nested class (1GK7G5A)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3381">3381</a>
+JCK 1.4 - ICLS - class from outer and protected class from superclass in nested class (1GK7G8E)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3382">3382</a>
+JCK 1.4 - ICLS - class from outer and public class from superclass in nested class (1GK7GC1)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3383">3383</a>
+JCK 1.4 - ICLS - class from outer and class from superclass in nested class (1GK7GQA)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3384">3384</a>
+JCK 1.4 - ICLS - static class from outer and public static class from superclass in top-level nested class. (1GK7CTV)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3387">3387</a>
+JCK 1.4 - ICLS - static field from outer class and inherited public field in top-level nested class (1GK7H0B)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3388">3388</a>
+JCK 1.4 - ICLS - static class from outer and protected static class from superclass in top-level nested class (1GK7BGP)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3389">3389</a>
+JCK 1.4 - ICLS - static class from outer and static class from superclass in top-level nested class (1GK7D2P)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3390">3390</a>
+JCK 1.4 - ICLS - static class from outer and protected class from superclass in top-level nested class (1GK7D7Q)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3391">3391</a>
+JCK 1.4 - ICLS - static class from outer and public class from superclass in top-level nested class (1GK7DBD)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3392">3392</a>
+JCK 1.4 - ICLS - static class from outer and static class from superclass in nested class (1GK7ERE)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3393">3393</a>
+JCK 1.4 - ICLS - static class from outer and protected class from superclass in nested class (1GK7EVB)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3394">3394</a>
+JCK 1.4 - ICLS - static class from outer and public class from superclass in nested class (1GK7EZB)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3395">3395</a>
+JCK 1.4 - ICLS - static class from outer and class from superclass in nested class (1GK7F4S)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3396">3396</a>
+JCK 1.4 - ICLS - class from outer and protected static class from superclass in top-level nested class (1GK7F8L)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3397">3397</a>
+JCK 1.4 - ICLS - class from outer and public static class from superclass in top-level nested class (1GK7FCN)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3398">3398</a>
+JCK 1.4 - ICLS - class from outer and static class from superclass in top-level nested class (1GK7FHB)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3399">3399</a>
+JCK 1.4 - ICLS - static field from outer class and inherited field in top-level nested class (1GK7H2Z)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3400">3400</a>
+JCK 1.4 - ICLS - static field from outer class and inherited protected field in top-level nested class (1GK7GW6)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3401">3401</a>
+JCK 1.4 - ICLS - field from outer class and inherited field in top-level nested class (1GK7HEF)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3402">3402</a>
+JCK 1.4 - ICLS - static field from outer class and inherited protected field in nested class (1GK7HH1)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3403">3403</a>
+JCK 1.4 - ICLS - field from outer class and inherited protected field in top-level nested class (1GK7H5X)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3404">3404</a>
+JCK 1.4 - ICLS - field from outer class and inherited public field in top-level nested class (1GK7HBJ)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3405">3405</a>
+JCK 1.4 - ICLS - static field from outer class and inherited public field in nested class (1GK7HKE)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3406">3406</a>
+JCK 1.4 - ICLS - static field from outer class and inherited field in nested class (1GK7HMN)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3407">3407</a>
+JCK 1.4 - ICLS - field from outer class and inherited protected field in nested class (1GK7L79)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6061">6061</a>
+unreachable code/unused temp ?
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6443">6443</a>
+Incremental java builder doesn't handle folder create/delete nicely
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5317">5317</a>
+Reparenting class should refresh hierarchy
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6740">6740</a>
+Problems with deleting project
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6491">6491</a>
+Non-java resource folder doesn't appear under pkg fragment root
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3245">3245</a>
+sub folders with dot not visible in packages view (1GCOH17)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6806">6806</a>
+NullPointerException moving enpty cu out of default package
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=7065">7065</a>
+NPE when saving a Java source
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6956">6956</a>
+incorrect compiler error reported on extract method
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=7072">7072</a>
+Protected member in superclass not visible in subclass
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=7066">7066</a>
+Subclass can't see protected inner class of superclass
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3284">3284</a>
+Project doesn't always rebuild after changing the Java build path
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6957">6957</a>
+CCE in AnonymousLocalTypeDeclaration::traverse
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6958">6958</a>
+NPE in DeltaProcessor
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6900">6900</a>
+Rebuild project fails with error "1000
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4382">4382</a>
+NullPointerException in JavaBuilder
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3199">3199</a>
+Missing classpath variables
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6848">6848</a>
+Index out of range exception with New builder
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4913">4913</a>
+null argument in IncrementalImageBuilder.getBuilderType
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6760">6760</a>
+package names truncated in compilation dialog
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3295">3295</a>
+Errors from missing reference to a jar do not go away
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3450">3450</a>
+Bug in JavaSearchScope (1GLE1GC)
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20011218 - 18th December 2001 - MILESTONE 1
+<br>Project org.eclipse.jdt.core v_219a
+<h2>
+What's new in this drop</h2>
+
+<h3>
+Problem Reports Fixed</h3>
+
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6117">6117</a>
+CodeFormatter - impossible to set indentation level and position mapping w/o deprecated methods
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6719">6719</a>
+LocalTypeDeclaration::traverse
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5432">5432</a>
+compiler syntax error is incorrect
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20011211 - 11th December 2001
+<br>Project org.eclipse.jdt.core v_218
+<h2>
+What's new in this drop</h2>
+
+<ul>
+<li> Java element deltas are batched. If the java model operation modifies
+ a resource, then the java element deltas are merged and fired during
+ the resource delta processing. If the java model operation doesn't
+ modify any resource (e.g. IWorkingCopy.reconcile()), then the java
+ element delta is fired right away.
+</ul>
+<h3>
+Problem Reports Fixed</h3>
+
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3215">3215</a>
+JM - Creating a new class sends out many notifications (1GD2GT0)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6695">6695</a>
+Changing Java preference in build 20011206 throws a NullPointerException in org.eclipse.jdt.internal.core.DeltaProcessor.initializeRoots
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6761">6761</a>
+NullPointerException during replace
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3290">3290</a>
+JavaBuilder - Old class files remain after change of output location
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3188">3188</a>
+JavaBuilder - Deleting source doesn't delete binary folders (1FVPTTK)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3185">3185</a>
+JavaBuilder - Errors don't disappear
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3189">3189</a>
+JavaBuilder - Missing libraries results in insufficient dependency info
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3204">3204</a>
+ImageBuilder should show error count in the progress
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3227">3227</a>
+JCL dev - Builder did not refresh problems in exception hierarchy
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3228">3228</a>
+Discarding rt.jar from build path triggers too many recompilation
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3232">3232</a>
+Incremental builder unable to handle efficiently missing rt.jar scenario
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3234">3234</a>
+Incremental builder does not notice addition of java.lang.Object inside same project
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3241">3241</a>
+Build doesn't honor cancel
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3260">3260</a>
+NPE when doing incremental project build
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3278">3278</a>
+JavaBuilder - Problem Count rarely updated
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3287">3287</a>
+Built state does not remember old pkg fragment roots
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3301">3301</a>
+Incremental build doesn't detect disappearance of field
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3305">3305</a>
+Incremental build doesn't detect abstract method to implements
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3311">3311</a>
+performance: task list still does not scale at all
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3312">3312</a>
+Internal errors in image builder due to duplicate package fragment
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3317">3317</a>
+Fullbuild after startup
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3322">3322</a>
+NullPointerException during build in StateImpl.getSourceElementEntries
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3326">3326</a>
+Incremental build doesn't work if bin deleted
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3370">3370</a>
+Incremental compiler is compiling project when it should not
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3422">3422</a>
+NPE in Java builder during catchup
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3429">3429</a>
+Incremental compilation bug on namespace change in private local class
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3444">3444</a>
+Build problems: Marker set on Folder?
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5007">5007</a>
+Project classpath references do not follow class folders
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5109">5109</a>
+Adding project doesn't fix build errors
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5320">5320</a>
+NPE during catchup
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5641">5641</a>
+NPE on rebuild when replacing internal jar
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6538">6538</a>
+searchDeclarationsOf* incorrect
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6690">6690</a>
+CodeAssist finds types outside the classpath
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6687">6687</a>
+Wrong JavaModel refresh after drag and drop outside folder with dot in name
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6693">6693</a>
+AbstractImageBuilder.compile throws an ArrayIndexOutOfBoundsException on line 166 in build 20011206
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6670">6670</a>
+Code Assist: Cannot resolve in method body
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6674">6674</a>
+Cannot add unimplemented methods
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6629">6629</a>
+Open On Selection does not work on Linux
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5542">5542</a>
+Too many deltas are fired on each JavaModel operation
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3269">3269</a>
+Updating the Java packages view on project creation (1GDW0U9)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3202">3202</a>
+DCR - JM - Merge Java Element Deltas with Resource Deltas (1G2B60Z)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6621">6621</a>
+NPE in Delta Processor
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3368">3368</a>
+JCK 1.4 - INTF - The field of protected interface is used in other package (1GK7M25)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6596">6596</a>
+Java compiler can generate invalid bytecode
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6586">6586</a>
+NullPointerException when resource modification done before java model is open
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6542">6542</a>
+extract method: incorrect error message
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6645">6645</a>
+Build/Rebuild does not recompile code
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6669">6669</a>
+Search doesn't find reference to a field that is only used in an initialization
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5385">5385</a>
+search: name searchDeclarationsOfSentMessages is not good
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3183">3183</a>
+JM - Builders and nested operations using Java model can get inconsistent results (1FUBV90)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3250">3250</a>
+JavaProject.retrieveResource picks first removed child delta (1GCV7PQ)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6378">6378</a>
+ClassCastException in inner class emulation
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6677">6677</a>
+\u in comment gives Invalid unicode error
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20011206 - 06th December 2001
+<br>Project org.eclipse.jdt.core v_217
+<h2>
+What's new in this drop</h2>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6564">6564</a>
+New builder - Incremental recompilation detected package problems incorrectly
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6563">6563</a>
+Package view does not refresh ok when adding both package and unit at once
+
+<h3>
+Problem Reports Closed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3242">3242</a>
+TypeRef.getType does not work for inner types (1GCFUNT)
+
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20011204 - 4th December 2001
+<br>Project org.eclipse.jdt.core v_216c
+<h2>
+What's new in this drop</h2>
+<ul>
+<li> New incremental builder implementation enabled by default (can reenable the
+old implementation by changing the builder extension in the plugin.xml)
+<li> Delta processing improvement:
+ <ul>
+ <li> No longer creates unnecessary Java elements when traversing the resource delta.
+ <li> Handles changes in binary folder libraries.
+ <li> Projects that share libraries are notified individually.
+ <li> Doesn't notify empty deltas any longer.
+ </ul>
+<li> Source folder resource copying no longer perfom any copies as soon as
+one source folder coincidates with the output location.
+<li> Open on selection is more fault-tolerant: will now try to locate a
+selected method for which argument types are incorrect.
+<li> Compiler no longer rejects correct code with respect to access to protected
+members defined in enclosing types (was only accepting a subset of correct scenarii).
+</ul>
+<h3>
+Problem Reports Fixed</h3>
+
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6528">6528</a>:
+InvocationTargetException trying to search
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6494">6494</a>:
+New builder: Invalid error found (The declared package does not match the expected package)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6461">6461</a>:
+NewBuilder - doesn't detect incorrectly located compilation units
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6456">6456</a>:
+Invalid error when compiling access to protected member inside innerclass
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3358">3358</a>:
+Performance: indexer doing too much work? (1GJLDN7)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5471">5471</a>:
+CodeFormatter mapped positions broken for multi-line comments
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6431">6431</a>:
+ArrayIndexOutOfBoundsException in the SourceIndexer requestor
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6422">6422</a>:
+Resource copy should not occur as soon as one source folder overlap the
+binary output
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6416">6416</a>:
+Code resolve doesn't work on message send when parameters are not correct
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5705">5705</a>:
+Wrong positions for ClassCastLiteral
+<h3>
+Problem Reports Closed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6423">6423</a>:
+Search - does not find declarations of method "to*String"
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3246">3246</a>:
+CodeCompletion - No completion on member access on anonymous class (1GD3OGA)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5454">5454</a>:
+Code Assist adds qualified code inside inner classes
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5837">5837</a>:
+ArrayIndexOutOfBoundsException in index merging
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20011127 - 27th November 2001
+<br>Project org.eclipse.jdt.core v_215a
+<h2>
+What's new in this drop</h2>
+
+<ul>
+<li>
+Better highlighting of multi-line message sending</li>
+
+<li>
+Code assist only qualifies implicit members when necessary</li>
+
+<li>
+New API for setting both classpath and output location at the same time
+(allowing to avoid classpath validation failures in case there is no way
+to change both independantly):</li>
+
+<br><tt>IJavaProject.setRawClasspath(IClasspathEntry[] newClasspath, IPath
+newOutputLocation, IProgressMonitor monitor)</tt></ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6339">6339</a> Assertion
+failed in SourceType
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5618">5618</a>
+Uncaught CompletionNodeFound exception doing code assist
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6294">6294</a>
+Exception during setting the classpath
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6302">6302</a>
+AssertionFailure in open on selection
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6094">6094</a>
+Search - does not find references to JavaProject.setProject(...)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3320">3320</a>"
+Search - Match through super type not found if in different project (1GGAOFT)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6158">6158</a>"
+Search - Prefix and postfix expression not found as write reference
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4974">4974</a>:
+Set classpath / output location should be one operation
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6176">6176</a>:
+Eclipse tools index out of bounds
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6160">6160</a>:
+Index out of bounds in update references
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6151">6151</a>:
+ArrayIndexOutOfBoundsException in ObjectSet
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5943">5943</a>:
+internal error in setting buildpath (name collsion)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5471">5471</a>:
+CodeFormatter mapped positions broken for multi-line comments
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5907">5907</a>:
+Indexer errors when disk full
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5884">5884</a>:
+Code assist should only fully qualify if needed
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5514">5514</a>:
+Select a declaration does not work in unsaved working copies
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5414">5414</a>:
+ArrayIndexOutOfBoundsException in Signature
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5384">5384</a>:
+search engine: behavior different than expected
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6104">6104</a>:
+Unoptimal debugger highlight for multi-line message expression
+<h3>
+Problem Reports Closed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6210">6210</a>: Creation
+failed error when creating a source folder
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3425">3425</a>:
+JavaCore.create(String handle) looses information (1GLA0QG)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6127">6127</a>:
+Reference by local class not found when searching for interface refs
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4990">4990</a>:
+Error starting Eclipse
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3471">3471</a>:
+Leading '/' in src page of Java wizard is misleading (1G842TH)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3619">3619</a>:
+inconsistent search for method declarations (1GCZZS1)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5557">5557</a>:
+Incorrect hierarchy shown (not rooted at Object)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6100">6100</a>:
+Bug in ObjectSet.Enumeration.nextElement
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20011120 - 20th November 2001
+<br>Project org.eclipse.jdt.core v_213
+<h2>
+What's new in this drop</h2>
+
+<ul>
+<li>
+CodeAssist no longer find synthetic completions.</li>
+
+<li>
+Reduced startup time of Java perspective</li>
+
+<li>
+CodeAssist option added to force full qualification of implicit field/method
+references (see JavaCore option: "org.eclipse.jdt.core.codeComplete.forceImplicitQualification").</li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5982">5982</a>: content
+assist displays accessors
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5955">5955</a>:
+NPE in LookupEnvironment
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5923">5923</a>:
+Search for "length" field refs finds [].length
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5916">5916</a>:
+Search - too many matches for refs to NameLookup.findPackageFragmentRoot
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5957">5957</a>:
+Internal error in RecoveredMethod.add
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5972">5972</a>:
+Incremental builder (new) recompiling dependents of Parser for no apparent
+reason
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5940">5940</a>:
+Instance initializer in anon inner class generates errors
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5913">5913</a>:
+Performance - creating tons of classfile elements at startup
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5862">5862</a>:
+search : too many matches on search with OrPattern
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=6070">6070</a>:
+New Builder: Builder order problem
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5852">5852</a>:
+Project references not updated according to buildpath
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5471">5471</a>:
+CodeFormatter mapped positions broken for multi-line comments
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5563">5563</a>:
+Write reference on declaration not reported
+<h3>
+Problem Reports Closed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3257">3257</a>: IMethod.getParameterNames
+for ClassFiles should use names from source (1GDGN3G)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3245">3245</a>:
+sub folders with dot not visible in packages view (1GCOH17)
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20011113 - 13th November 2001
+<br>Project org.eclipse.jdt.core v_211b
+<h2>
+What's new in this drop</h2>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5821">5821</a>: Refactor
+Rename renames local variable instead of member in case of name clash
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5003>5003</a>: Review JavaBuilder cancelation handling <br><a href=" http://dev.eclipse.org/bugs/show_bug.cgi?id="5790">5790</a>:
+IJavaProject.hasBuildState() fails with new builder
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5794">5794</a>:
+Polymorphic search doesn't work in dependent projects
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5781">5781</a>:
+NPE using new image builder
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5834">5834</a>:
+Incremental build recompiled unrelated project
+<h3>
+Problem Reports Closed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5215">5215</a>: search:
+missing field reference
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20011112 - 12th November 2001
+<br>Project org.eclipse.jdt.core v_210_01
+<h2>
+What's new in this drop</h2>
+
+<ul>
+<li>
+Project references are maintained by the JavaCore, in parallel with build
+path.</li>
+
+<li>
+Resurrected deprecated APIs from 0.9 which were discarded previously.</li>
+
+<li>
+ICodeCompletion reverted to 1.0 version, and got deprecated. Use ICompletionRequestor
+instead.</li>
+
+<li>
+Cross-project incremental recompilation in presence of structural changes
+in produced binaries.</li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5362">5362</a>: Deeper
+than necessary JavaElementDelta when package added
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5525">5525</a>:
+ICodeCompletionRequestor isn't 1.0 compatible
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5616">5616</a>:
+NPE when compiling invalid code defining a array of strings
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5217">5217</a>:
+java search scope: missing enclosing project
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5527">5527</a>:
+Unexpected inaccurate matches for #close() declarations
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5522">5522</a>:
+Type hierarchy - missing subtypes of JavaElement
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5508">5508</a>:
+JDT cannot support periods in the folders above the package name
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5541">5541</a>:
+No refresh when adding a compilation unit inside a dot named source folder
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5532">5532</a>:
+Incremental compile missed a return type change
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5515">5515</a>:
+AbortCompilation during polymorphic search
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5275">5275</a>:
+Cross-project recompilation Defect 186249 - OTI PR# 1GLEYT1
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5267">5267</a>:
+Dependent Projects not compiled when project is saved
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5425">5425</a>:
+Exception on CodeAssist
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3194">3194</a>:
+DCR - JM - Buffer contents is duplicated (1G03HCP)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5430">5430</a>:
+Must resurrect 0.9 deprecated APIs
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4923">4923</a>:
+IJavaProject.getPackageFragmentRoots returns roots from other projects
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3308">3308</a>:
+Projects not build in correct order after load (1GF60TN)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3435">3435</a>:
+keeping the project references and required project in synch (1GL0L34)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5203">5203</a>:
+Project indexing does not restrain to source files on the classpath
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3293">3293</a>:
+search does not work in inner class (1GEUQHJ)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3249">3249</a>:
+Error message is confusing: using token instead of identifier (1GCTDYM)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5214">5214</a>:
+TVT: Apostrophe shows up multiple times in Java error messages in some
+translations (italian)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5263">5263</a>:
+TVT: Compiler error messages are hard for translators to understand
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3251">3251</a>:
+Types not included in code assist list for import (1GD06W9)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5277">5277</a>:
+Code assist on assert method do an AbortException
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5070">5070</a>:
+search: missing interface method reference
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5069">5069</a>:
+search: method reference in super missing
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5068">5068</a>:
+search: missing method reference
+<h3>
+Problem Reports Closed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5526">5526</a>: NullPointerException
+searching declarations of #close()
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5498">5498</a>:
+Java Compile - code does not compile correctly in JDT, but does with javac
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5493">5493</a>:
+Adding project references doesn't update the classpath
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5426">5426</a>:
+CodeAssist returns empty completion
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=1690">1690</a>:
+Local variables not always displayed when in scope (1GJ8PX4)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4368">4368</a>:
+Wrong match in Java Search
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3238">3238</a>:
+CodeAssist - no completion if cursor at string beginning (1GI3BYO)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3271">3271</a>:
+Unable to delete attached internal source jar (1GDX215)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3209">3209</a>:
+DCR - JM -Invalid references to IPath.getDevice() potentially breaking
+on Linux (1G4U1R7)
+<br>
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20011025 - 25th October 2001
+<br>Project org.eclipse.jdt.core v_206
+<h2>
+What's new in this drop</h2>
+
+<ul>
+<li>
+JavaModel is no longer performing smart classpath updates when Java package
+fragment roots are either moved or removed.</li>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3568">3568</a>: no
+hoverhelp over constructor referrences (1GAJ0KP)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5218">5218</a>:
+AccSuper is not set properly
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5200">5200</a>:
+SetClasspathOperation must close root only when root is removed
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3449">3449</a>:
+CodeAssist - two type with same name must be qualified (1GLDN3Z)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4973">4973</a>:
+Rename package removes first letter of import statements
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3279">3279</a>:
+Severe - JM - Source found, even though sourcepath is false (1GELAVB)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3434">3434</a>:
+Deleting a project from the ws removes it from the buildpath! (1GKZNBS)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5021">5021</a>:
+Refactoring trashed my code
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5136">5136</a>:
+ArrayIndexOutOfBoundsException when a field declaration is an anonymous
+class
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3440">3440</a>:
+Classfile comparator should be able to ignore order (1GL2I7E)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3439">3439</a>:
+Classfile comparator should be able to ignore synthetics (1GL2I3N)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3442">3442</a>:
+NPE in SourceElementParser (1GL496I)
+<h3>
+Problem Reports Closed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3369">3369</a>: Classpath
+gets out of sync (1GJU853)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3281">3281</a>:
+change java project binary output create new package (1GEHK07)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3298">3298</a>:
+Incorrect compile error on valid case statement (1GEYWET)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3562">3562</a>:
+Outliner bug for initializers (1G93CS3)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3447">3447</a>:
+search: could automatically narrow down scope (1GLDJVN)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3288">3288</a>:
+CodeAssist - Code assist doesn't work in some methods (1GELEBH)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5073">5073</a>:
+delete does not work on default package
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3443">3443</a>:
+Unused argument/variable warnings shown twice (1GL4OW7)
+<br>
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20011018 - 18th October 2001
+<br>Project org.eclipse.jdt.core v_205
+<h2>
+What's new in this drop</h2>
+
+<ul>
+<li>
+CodeAssist provides variable name suggestions.</li>
+
+<br> (breaking) API Changes on <tt>ICompletionRequestor</tt>
+<br> <b>+</b> <u>Added</u> API for suggest variable name:
+<br> <tt>void acceptVariableName(</tt>
+<br><tt> char[] typePackageName,</tt>
+<br><tt> char[] typeName,</tt>
+<br><tt> char[] name,</tt>
+<br><tt> char[] completionName,</tt>
+<br><tt> int completionStart,</tt>
+<br><tt> int completionEnd);</tt>
+<br>
+<li>
+Helper method for computing a resolved and expanded path (all exports from
+prerequisites) which was introduced in 204, got <u>removed</u>. This is
+not an API change, it never made it out officially.</li>
+
+<br> <b>-</b> <tt>IJavaProject.getExpandedClasspath(boolean)</tt>
+<p><tt>SearchEngine.createJavaSearchScope(IResource[])</tt> has been deprecated.
+Use <tt>SearchEngine.createJavaSearchScope(IJavaElement[])</tt> instead.
+The rational is that <tt>createJavaSearchScope(IResource[])</tt> was not
+well defined for projects, and it could not define a search scope for java
+elements that didn't have a corresponding resource (e.g. external jars).
+This deprecated API's behavior has also reverted to the 1.0 state for backward
+compatibility. The specification of <tt>createJavaSearchScope(IJavaElement[])</tt>
+is as follows:
+<ul>
+<li>
+If an element is an <tt>IJavaProject</tt>, then the project's source folders,
+its jars (external and internal) and its references projects (with their
+source folders and jars, recursively) will be included.</li>
+
+<li>
+If an element is an <tt>IPackageFragmentRoot</tt>, then only the package
+fragments of this package fragment root will be included.</li>
+
+<li>
+If an element is an <tt>IPackageFragment</tt>, then only the compilation
+unit and class files of this package fragment will be included. Subpackages
+will NOT be included.</li>
+</ul>
+</ul>
+
+<h3>
+Problem Reports Fixed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=5065">5065</a>: NullPointerException
+in Code Assist
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4921">4921</a>:
+Serach does not find types in internal jar
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4917">4917</a>:
+Latest build fails updating TypeHierarchy
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3296">3296</a>:
+CodeAssist - should filter out duplicates if any (1GEWDL7)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3325">3325</a>:
+Too much codeassist match on interface (1GH0GV1)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3424">3424</a>:
+DCR: code assist support for variable name suggestions (1GKM6OQ)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3282">3282</a>:
+JCK 1.4 - DASG - assigned variable before catch block after return statement
+(1GK2AHX)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3452">3452</a>:
+NPE doing Display from Binary (1GLEG5K)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3374">3374</a>:
+SearchPatter.createPattern(...) doesn't work with unicodes (1GJYBRY)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3309">3309</a>:
+DCR - JM - could ICompilationUnit::getType throw JME? (1GF9AL9)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3310">3310</a>:
+Smoke 124: Compile errors introduced with rename refactoring (1GFBK2G)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3436">3436</a>:
+NPW in TypeHierarchy (1GL0L8D)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4919">4919</a>:
+Cannot duplicate local variable in finally block
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4943">4943</a>:
+Verification error
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=4385">4385</a>:
+QualifiedAllocationExpression.sourceEnd incorrect if type is an AnonymousLocalTypeDeclaration
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3230">3230</a>:
+Search - Too many type references for query ending with * (1GAZVGI)
+<h3>
+Problem Reports Closed</h3>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3174">3174</a>: Open-on-selection
+doesn't work on MouseAdapter (1GF69TH)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3337">3337</a>:
+Open on selection failed with double message (1GIFA80)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3207">3207</a>:
+JM - Smart save when empty CU (1G4EVHM)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=1672">1672</a>:
+Cannot evaluate classes in a sealed jar (1GHU6YK)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3220">3220</a>:
+Formatter tests refer to hardcoded path on disk (1G9R5G4)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3258">3258</a>:
+exception doing import assist (1GDIJ9D)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3240">3240</a>:
+need to find method declarations in anonymous inner types (1GCBPRI)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3254">3254</a>:
+Indexer - Should nest index source retrieval in IWorkspaceRunnable (1GD7J6F)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3225">3225</a>:
+IJavaProject.findPackageFragment strange semantic (1GAOLWQ)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3218">3218</a>:
+No interface to polymorphically acess ICompilationUnit (1G8D2ZP)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3205">3205</a>:
+Problems with IJavaModel.findPackageFragment (1G456DO)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3197">3197</a>:
+DCR - OpenOnSelection - Code resolve doesn't work on declarations (1G0UX9V)
+<br><a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=3177">3177</a>:
+64kb method should be a configurable problem (1FJHGVF)
+<br>
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 20011011 - October 11th, 2001
+<br>Project org.eclipse.jdt.core v_204
+<h2>
+What's new in this drop</h2>
+
+<ul>
+<li>
+Classpath entries (except for source folders) can be tagged as exported
+upon creation. When exported, an entry is contributed to dependent projects
+along with its output location.</li>
+
+<li>
+Added APIs:</li>
+
+<br> Testing status of a given entry
+<br> + IClasspathEntry.isExported()</ul>
+ Creating
+entries with export flag
+<br>
++ JavaCore.newProjectEntry(IPath, boolean)
+<br>
++ JavaCore.newLibraryEntry(IPath, IPath, IPath, boolean)
+<br>
++ JavaCore.newVariableEntry(IPath, boolean)
+<p> Helper
+method computing a resolved and expanded path (all exports from prerequisites)
+<br>
++ IJavaProject.getExpandedClasspath(boolean)
+<ul>
+<li>
+CodeAssist inserts qualification on field/method references in case of
+ambiguities.</li>
+
+<li>
+CodeAssist provides parameter names on method completions.</li>
+
+<br> API Changes on ICompletionRequestor
+<br> + Added API for answering method declaration completions:
+<br> void acceptMethodDeclaration(
+<br> char[] declaringTypePackageName,
+<br> char[] declaringTypeName,
+<br> char[] selector,
+<br> char[][] parameterPackageNames,
+<br> char[][] parameterTypeNames,
+<br> char[][] parameterNames,
+<br> char[] returnTypePackageName,
+<br> char[] returnTypeName,
+<br> char[] completionName,
+<br> int modifiers,
+<br> int completionStart,
+<br> int completionEnd);
+<br> + Added parameterNames to normal method results
+API:
+<br> void acceptMethod(
+<br> char[] declaringTypePackageName,
+<br> char[] declaringTypeName,
+<br> char[] selector,
+<br> char[][] parameterPackageNames,
+<br> char[][] parameterTypeNames,
+<br> char[][] parameterNames,<<<<<<<<<<<<<<<<
+ADDED
+<br> char[] returnTypePackageName,
+<br> char[] returnTypeName,
+<br> char[] completionName,
+<br> int modifiers,
+<br> int completionStart,
+<br> int completionEnd);
+<br>
+<li>
+CodeAssist optionally performs visibility checks (see JavaCore option:
+"org.eclipse.jdt.core.codeComplete.visibilityCheck").</li>
+
+<li>
+Search for field read and field write references. Two new constants have
+been added</li>
+
+<br> on IJavaSearchConstants to be used when creating
+a field reference search pattern:
+<br> - READ_REFERENCES: the search results contain *only*
+read access to a field.
+<br> - WRITE_REFERENCES: the search results contain *only*
+write access to a field.
+<br> Note that if REFERENCES is used, then search results
+contain both read and write
+<br> accesss to a field.
+<li>
+OpenOnSelection can now locate selected declarations which have a corresponding</li>
+
+<br> Java element (i.e. no local declaration is found),
+and is more tolerant of
+<br> incorrect code.</ul>
+
+<h2>
+Problem Reports Fixed</h2>
+ 3430 usability: parameter hints (1GKYXK5)
+<br> 3431 Unreachable code in JCore
+(1GL2V6K)
+<br> 3175 JCK1.3a - ICLS - Comparing
+current instance against enclosing instance inside of anonymous class.
+(1GLDSBS)
+<br> 1GLBOJZ: ITPJCORE:WIN2000 - UnaryExpression doesn't store
+expression type in bit mask
+<br> 1GDS7IP: ITPJCORE:WIN2000 - VerifyError related to a local
+index computation
+<br> 1GLABQ7: ITPJCORE:WIN2000 - JavaCore.create(String) throws an
+unexpected exception
+<br> 1GL0PGV: ITPJCORE:WINNT - Batch compiler leaving JARs open
+<br> 5268 ITPJCORE:ALL - VerifyError when running app (1GL4QKI)
+<br> 1GLBP65: ITPJCORE:WIN2000 - search: type refs - incorrect match
+<br> 1GKXCOM: ITPJCORE:WIN2000 - ClassCastException during inner
+class emulation
+<br> 1GD07GK: ITPJUI:WIN98 - Code assist should qualify methods if
+needed.
+<br> 1GL1HF8: ITPJCORE:WIN2000 - Missing implementation in the compiler
+compiling invalid code
+<br> 1GL13OT: ITPJCORE:ALL - INameLookup should be removed
+<br> 1GL1I9F: ITPJCORE:WIN2000 - Wrong source mapping for binary
+methods with parameters with identical simple names
+<br> 1G4CIP0: ITPJUI:WIN - Source for binaries doesn't work for anonymous
+inner classes
+<br> 1GD79XM: ITPJCORE:WINNT - Search - search for field references
+- not all found
+<br> 1GLA60W: ITPJCORE:WINNT - CodeAssist - should not propose declarations
+of method already locally implemented
+<br> 1GLAEZB: ITPJCORE:WINNT - CodeAssist does not disambiguate method
+references
+<br> 1GL4F3J: ITPJCORE:WINNT - Completion on declaration should also
+provide thrown exceptions
+<br> 1GL11J6: ITPJCORE:WIN2000 - search: missing field references
+(nested types)
+<br> 1GL12XE: ITPJCORE:WIN2000 - search: missing field references
+in inner class
+<br> 1GL0X82: ITPJCORE:ALL - ClassCastException setting args on class
+file
+<br> 1GKAQJS: ITPJCORE:WIN2000 - search: incorrect results for nested
+types
+<br> 1GKZ8VZ: ITPJCORE:WINNT - Search - did not find references to
+member constructor
+<br> 1GKYS7Y: ITPJCORE:WINNT - Main not found
+<br> 1GELSDQ: ITPJUI:WINNT - JDOM: IType.createMethod does not insert
+nicely for inner types
+<br> 1GF67VL: ITPJUI:WIN98 - DCR - CodeCompletion - Code-assist for
+listener methods
+<br> 1GFK8YT: ITPJUI:ALL - Rename CU A.B.java to AB.java fails (NPE)
+<br> 1GD06J6: ITPJUI:WIN98 - Code assist should qualify fields if
+needed.
+<br> 1FZWGMG: ITPCOM:WIN98 - DCR - CodeAssist - code assist should
+provide method signature completions
+<br> 1GHVOQE: ITPJCORE:WINNT - Ambiguous completion in CodeAssist
+<br> 1G8DEAB: ITPJUI:WINNT - DCR: code assist super methods when
+defining method
+<br> 1GGNNDZ: ITPJCORE:WINNT - OpenOnSelection - non visible target
+is equivalent to no target
+<br> 1GE14NN: ITPJUI:WINNT - Unable to find/search for .class files
+<br> 1GJYFUO: ITPDUI:ALL - Evaluation hangs, evaluation thread is
+suspended
+<br> 1FWG453: ITPJCORE:WIN98 - OpenOnSelection - fails for default
+constructors
+<br> 1GDQD37: ITPJUI:WIN2000 - OpenOnSelection - Open on selection
+failure
+<br> 1GGZ2R7: ITPJUI:WIN2000 - Search for method refs failed
+<br> 1GKNXX6: ITPJCORE:WINNT - OpenOnSelection - no selection if
+targeting member type in default package
+<br> 1GE34EE: ITPJUI:WIN2000 - OpenOnSelection - initial selection
+wrong
+<br> 1GKEG73: ITPJCORE:WIN2000 - search (136): missing field declaration
+<br> 1GKB9YH: ITPJCORE:WIN2000 - search for field refs - incorrect
+results
+<br> 1GJL6EJ: ITPJCORE:WINNT - JavaConventions.validateClasspath:
+Compares against variable name
+<br> 1GDQEAS: ITPJUI:ALL - Indexer - delete unused indexes on Java
+core plug-in shutdown
+<br> 1GKM4M9: ITPJCORE:WINNT - DCR: code select should work on declarations
+<br> 1G2NZVT: ITPJUI:WIN2000 - DCR - OpenOnSelection - Code resolve
+doesn't work for declarations
+<h3>
+Problem Reports Closed</h3>
+ 3223 Search from editor's context
+menu doesn't work (1GAJCD8)
+<br> 3433 search: missing field occurrecnces (1GKZ8J6)
+<br> 3176 JCK1.3a - STMT - Single declaration
+in try block (1GLDSH9)
+<br> 1GL0MN9: ITPJCORE:WIN2000 - search: not consistent results for
+nested types
+<br> 1GL9UMH: ITPJCORE:WIN2000 - search: missing type occurrences
+<br> 1GKYXK5: ITPJUI:WIN2000 - usability: parameter hints
+<br> 1GEV78E: ITPJUI:WIN2000 - Code assist: private superclass methods
+show up, but others don't
+<br> 1GDKKTS: ITPJUI:WINNT - CodeCompletion - import assist shows
+invisible types
+<br> 1G7317O: ITPJCORE:WIN2000 - DCR - CodeAssist - code assist shows
+invisible members
+<br> 1GKK930: ITPJCORE:WINNT - No code assist for Inner type
+<br> 1GIIDGX: ITPJUI:WINNT - open on type: does not work on some
+types
+<br> 1GKOFO6: ITPJCORE:WINNT - Internal error searching for class
+references
+<br> 1GK96A0: ITPJCORE:WINNT - NPE during search operation
+<br> 1GK9B5Q: ITPJCORE:WINNT - Class reference search broken
+<br> 1GBOFK5: ITPJUI:ALL - "References to" on methods in jars
+<br> 1GKECWC: ITPJCORE:WINNT - Organize Imports fails: Typerefs not
+complete
+<br> 1GKCH3N: ITPJCORE:WIN2000 - search: method refs - super call
+not found
+<br> 1GKB475: ITPJCORE:WINNT - StringIndexOutOfBoundsException on
+searchfor methods
+<br> 1GJL6V0: ITPJCORE:WINNT - JavaConventions.validateClasspath:
+IStatus usage
+<br> 1GKM1MU: ITPJCORE:WINNT - Classpath validation: Overlapping
+accepted
+<br> 1GJL7RS: ITPJCORE:WINNT - JavaConventions.validateClasspath:
+nested sourcefolders
+<br> 1GK9NB0: ITPJCORE:WIN2000 - Another core dump - sorry
+<br> 1GJYG33: ITPJUI:WIN2000 - Core dump in run time workbench in
+Search
+<br> 1GK9S59: ITPJUI:WIN2000 - Internal error when synchronizing
+<br> 1GL2TZY: ITPJUI:WIN2000 - Code Completion should only show visible
+items
+<br> 1GKRLZ4: ITPJCORE:WIN2000 - Compiler overzealous with commas
+<br> 1GF98R4: ITPJUI:WINNT - JM - why is a file A.B.java seen as
+a compilation unit?
+<br> 1G98XR7: ITPJCORE:WIN2000 - Feature Request for JavaDoc CodeAssist
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Eclipse SDK Build 0.202 - Spetember 27th, 2001
+<br>Project org.eclipse.jdt.core v_202
+<h2>
+What's new in this drop</h2>
+
+<ul>
+<li>
+New AST node for empty statements (org.eclipse.jdt.internal.compiler.ast.EmptyStatement)</li>
+
+<br> i.e. 2 more APIs on the AST visitor. Note: this was not
+an official API
+<li>
+ISourceElementRequestor notifies enter/exit initializers instead of just
+acceptInitializer. Note: this was not an official API</li>
+
+<li>
+Search in inner-classes now works. Indexes are recomputed automatically
+on start-up.</li>
+
+<li>
+ Removed CodeAssist option for hungry mode (org.eclipse.jdt.core.codeComplete.entireWordReplacement)</li>
+
+<br> Client code can decide whether using inferred end position
+(hungry behavior) or original cursor location (insert behavior)
+<br> based on the keystroke (enter/insert?).
+<li>
+ org.eclipse.jdt.core.search.IJavaSearchResultCollector now clearly
+states that</li>
+
+<br> the order of the search result is unspecified.</ul>
+
+<h2>
+Problem reports fixed</h2>
+ 1GK2A45: ITPJCORE:WIN2000 - JCK 1.4 - possibly assigned variable
+after assignment expression when true
+<br> 1GK29Q8: ITPJCORE:WIN2000 - JCK 1.4 - possibly assigned value
+of a final instance variable after a constant boolean expression when false
+<br> 1G52F7P: ITPJCORE:WINNT - Search - finds bogus references to
+class
+<br> 1G4TNX1: ITPJCORE:WINNT - Search - No search anonymous results
+in inner classes
+<br> 1GHW0AZ: ITPJCORE:WINNT - JCK 1.4 - unreachable empty statements
+<br> 1GK2BLM: ITPJCORE:WIN2000 - JCK 1.4 - definitely assigned value
+after the boolean operator ? : when true
+<br> 1GKB28A: ITPJCORE:WIN2000 - Compiler accepts incorrect code
+<br> 1FL4T1Q: LFCOM:WINNT - JCK 1.4 - VerifyError due to an illegal
+jump
+<br> 1GK2B6D: ITPJCORE:WIN2000 - JCK 1.4 - definitely assigned value
+before the second operand of the boolean operator &&
+<br> 1GK2AOF: ITPJCORE:WIN2000 - JCK 1.4 - assigned variable before
+finally block after return statement
+<br> 1GK6WD3: ITPJCORE:WIN2000 - search:no fully qualified references
+are found
+<br> 1GK7231: ITPJCORE:WIN2000 - typos in comments
+<br> 1GK77HA: ITPJCORE:WINNT - Search - missing base type references
+<br> 1GJY2XN: ITPJUI:WIN2000 - rename type: error when with reference
+<br> 1GK1I2J: ITPJCORE:WIN2000 - Broken SourceEnd in ForStatement
+and WhileStatement
+<br> 1GK1HWY: ITPJCORE:WIN2000 - Broken sourceEnd in for Assignment
+and CompoundAssignment
+<br> 1GIIBC3: ITPJCORE:WINNT - search for method references - missing
+matches
+<br> 1GGNOTF: ITPJCORE:WINNT - Search doesn't find method referenced
+in anonymous inner class
+<br> 1GK1GJE: ITPJCORE:ALL - Search - StringOutBoundsException when
+searching references in JAR
+<h3>
+Problem Reports Closed</h3>
+ 1GJY3KG: ITPJUI:WIN2000 - NPE in jdt.internal.core.ClassFileInfo
+<br> 1GK90H4: ITPJCORE:WIN2000 - search: missing package reference
+<br> 1GK8TXE: ITPJCORE:WIN2000 - search: missing field reference
+<br> 1GK7K17: ITPJCORE:WIN2000 - search: missing type reference
+<br> 1GKCJIL: ITPJCORE:WIN2000 - build exception in 135
+<br> 1GK6WP9: ITPJCORE:WIN2000 - seach: missing type reference
+<br> 1GJZSBE: ITPJCORE:WINNT - ArrayIndexOutOfBoundsException during
+rebuild
+<br> 1GK7E6S: ITPJCORE:WIN2000 - search: StringIndexOufOfBound
+<br> 1GIT857: ITPJCORE:WIN2000 - Performance - Ctrl+S triggers five
+parser runs
+<br> 1GEHCYL: ITPUI:WINNT - Minor: Colon at wrong place in build
+dialog
+<br> 1FLUBRR: JRIDE:WINNT - Problems: instantiating inner classes
+<br> 1FLUOJI: JRIDE:WINNT - Problems: vague error message with illegal
+constructor invocation
+<br> 1FLZUG5: JRIDE:WINNT - Problems: invalid expression as statement
+is not reported
+<br> 1FLZV4M: JRIDE:WINNT - Problems: invalid hexa literal number
+not reported
+<br> 1FLZYES: JRIDE:WINNT - Problems: the interface cannot define
+an initializer is not reported
+<br> 1FQVTI1: LFCOM:WINNT - Compiler - No implicit conversion should
+not generate aconstnull
+<br> 1FUZYXT: ITPJCORE:WINNT - JM - Source for Binaries issue
+<br> 1FX0LZ0: ITPCOM:ALL - Request for comments preceeding imports
+& package decls
+<br> 1FW8ENP: ITPJUI:WIN98 - JDOM - Deleting import statements from
+Outline obliterates intervening comments
+<br> 1G4PWC7: ITPJCORE:WINNT - Search - No matches with class files
+<br> 1G83ZKL: ITPJUI:WINNT - Compiler - unclear error message for
+a reserved word used as an identifier
+<br> 1GF5W1S: ITPJUI:WIN2000 - ClassCastException in LookupEnvironment
+<br> 1GKF01S: ITPJCORE:WINNT - Severe: internal error during search
+<br> 1GDVFRX: ITPJUI:WIN2000 - CodeCompletion - eats the following
+word
+<br> 1GF67JM: ITPJUI:WIN98 - CodeCompletion - Code-assist consumes
+next token
+<br> 1GCSHAC: ITPJCORE:Inconsistent codeassist behavior
+<br> 1GCNBTL: ITPJCORE:ALL - DCR - JM - Provide a way to read JavaCore
+default options from the plugin.xml file
+<br> 1GAJBOU: ITPJUI:WINNT - Code Assist shows matches after ()
+<br> 1FW8NV6: ITPJCORE:ALL - DCR - JM - Need API for compiler options
+<p><hr><h1>
+Eclipse Platform Build Notes <br>
+Java Development Tooling Core</h1>
+Build 0.200 - September 13th, 2001
+<br>Project org.eclipse.jdt.core v_200
+<h2>
+What is new in this drop</h2>
+
+<ul>
+<li>
+JCK1.3a compliant.</li>
+
+<li>
+Added 2 new APIs on JavaConventions for classpath validation.</li>
+
+<ul>
+<li>
+IJavaModelStatus validateClasspath(IJavaProject project, IClasspathEntry[]
+classpath, IPath outputLocation)</li>
+
+<li>
+IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry
+entry, boolean checkSourceAttachment)</li>
+</ul>
+
+<li>
+Ant Eclipse compiler task added (org.eclipse.jdt.core.ant.Jdtcom)</li>
+
+<li>
+Assertions support enabled: by default the compiler is 1.3 compliant, but
+it can optionally be turned into source 1.4 mode cf. JavaCore options.</li>
+
+<li>
+More options are surfaced on JavaCore. See JavaCore.getDefaultOptions()
+for description.</li>
+
+<ul>
+<li>
+...internal...ConfigurableOption has disappeared.</li>
+
+<li>
+Evaluation in binaries is functional</li>
+</ul>
+
+<li>
+Search for references now finds results in binaries. Indexes in old workspaces
+are recomputed when restarted which may result in longer startup times.</li>
+</ul>
+
+<h2>
+Problem Reports Fixed</h2>
+1GEKKUO: ITPJCORE:ALL - JM - Util.readContentsAsBytes(InputStream) doesn't
+allow for size hint
+<br>1GBRPSJ: ITPJCORE:Options - should surface the code formatter options
+on JavaCore
+<br>1GJU3YV: ITPJCORE:ALL - ArrayIndexOutOfBoundsException in scanner
+<br>1GJL1R5: ITPJCORE:ALL - NPE in ClassFile.getSourceRange
+<br>1GH49XR: ITPJUI:WIN2000 - Organize Imports inserts bogus import
+<br>1GJU3O8: ITPJCORE:WINNT - type hierarchy: NPE
+<br>1GJIYKP: ITPJCORE:WINNT - type hierarchy - contains unrelated types
+<br>1GITFQR: IVJIDT:WIN2000 - Wrong byte code generation, Inconsistent
+stack height 1 != 0 error
+<br>1GIHUQP: ITPJCORE:WINNT - search for static field should be more accurate
+<br>1GIT66X: ITPJCORE:WINNT - ClassCastException when calling CodeAssist
+<br>1GJA0WG: ITPJCORE:WINNT - AbortCompilationUnit when doing a Search
+<br>1GH49HW: ITPJUI:WINNT - Search functionality is misleading when viewing
+source from jar
+<br>1GFXPE5: ITPJUI:ALL - Search for method references broken
+<br>1GFM3X3: ITPJUI:WINNT - Wrong code formatter default for keeping else
+on same line
+<br>1GHSM7B: ITPJUI:ALL - formatting of anonymous classes
+<br>1GGPVHN: ITPJUI:WIN2000 - Not getting hover Javadoc for ISelection
+<br>1GE2LO2: ITPJCORE:WIN2000 - SourceStart and SourceEnd of synchronized
+statement
+<br>1GIUTIZ: ITPJCORE:WIN2000 - AST: case statement doesn't cover case
+keyword
+<br>1GITCCY: ITPJCORE:WIN2000 - AST: strange LocalDeclaration.declarationSourceEnd
+<br>1GIRQFW: ITPJCORE:WIN2000 - AST: wrong source end if subnode is of
+type AnnonymousTypeDeclaration
+<br>1GIRHRP: ITPJCORE:WIN2000 - AST: wrong sourceStart and sourceEnd in
+SynchronizedStatement
+<br>1GHUAUO: ITPJCORE:ALL - Renaming an element in a working copy corrupts
+the working copy
+<br>1GHUAM1: ITPJCORE:ALL - NPE when renaming an element in a working copy
+<br>1GHDA2V: ITPJCORE:WINNT - ClassCastException when doing a search
+<br>1GFY02B: ITPJUI:ALL - Delete a method and saving introduces extra lines
+<br>1GFOFMD: ITPJUI:WIN2000 - New class should have space between package
+and class decls
+<br>1GI3R1I: ITPJCORE:WIN2000 - Compilation error evaluating super expression
+in debugger
+<br>1GII07V: ITPJCORE:WIN2000 - CompilationUnitDeclaration.traverse doesn't
+call visitor.endVisit
+<br>1GIR345: ITPJCORE:ALL - Indexer: NegativeArraySizeException
+<br>1GIRC23: ITPJCORE:ALL - CodeFormatter brace on new line problem
+<br>1GIT8SA: ITPJCORE:WIN2000 - AST: wrong sourceEnd if action is Block
+<br>1GIUQVL: ITPJCORE:WINNT - IClassPathEntry: java doc incorrect
+<br>1GIVGMH: ITPJUI:ALL - EC: Javadoc hoverhelp incorrectly uses first
+of multiple comments
+<br>1GIYKSR: ITPJCORE:WIN2000 - Ast: FieldDeclaration.traverse implemeted
+differently
+<br>1GI3ND5: ITPJCORE:WINNT - Potential optimization during IB problem
+generation
+<br>1GFBVZH: ITPUI:WIN2000 - ArrayIndexOutOfBoundsException: Java editor
+<br>1GI509E: ITPJCORE:WINNT - IJavaProject.getNonJavaResources returns
+java and class files
+<br>1GI2WAW: ITPJCORE:WINNT - Too many results for default package
+<br>1GHQZ9H: ITPJUI:ALL - Walkback doing a search
+<br>1GGYT3S: ITPJCORE:WINNT - javaconventions::validatePackageName and
+default package
+<br>1GF9856: ITPJCORE:WINNT - JM - JavaConventions::validateCompilationUnitName
+<br>1GF822P: ITPJCORE:WIN2000 - NegativeArraySizeException in Parser
+<br>1GI6T4Y: ITPJCORE:WINNT - NPE in JavaModeManager retrieving workspace
+options
+<br>1GE4ILR: ITPJCORE:ALL - Eval - Evaluation in Binary Project fails
+<br>1GI3LLC: ITPJCORE:ALL - Incorrect formatting for the new keyword
+<br>1GHU6O5: ITPJCORE:WINNT - RMIC test fail
+<br>1GHH6O7: ITPJCORE:ALL - Need to tune the exception analysis for AssertStatement
+<br>1GHUW7T: ITPJCORE:WIN2000 - Build Problem
+<br>1GI3IG9: ITPJCORE:ALL - internal compiler error involving bogus method/field
+declaration
+<br>1GHU4PK: ITPJCORE:WINNT - NoSuchMethodError when running program
+<br>1GHONAX: ITPJCORE:WIN2000 - Compiler uses different name lookup for
+refactoring
+<br>1GEJYAJ: ITPJCORE:WIN2000 - Compiler - Binding of QualifiedNameReference
+is null
+<br>1GHFHWR: ITPJCORE:ALL - Assertions: CodeAssist and Selection need to
+be updated
+<br>1GHFHXG: ITPJCORE:ALL - Assertions: Add optional warning on assert
+identifier
+<br>1GCZ9VM: ITPJCORE:WIN2000 - DCR - Compiler - Batch compiler should
+be API
+<br>1GHO6QR: ITPJCORE:WINNT - Code Assist - no method completion when return
+type is secondary one
+<br>1GH0AU7: ITPJCORE:ALL - Eval - VerifyError in scrapbook page
+<br>1GH2R62: ITPJCORE:WIN2000 - Typo in progress message
+<br>1GGYL32: ITPJCORE:ALL - Default supertypes are not visible when qualified
+<br>1GDFJK0: IVJIDT:WIN2000 - Using 'synchronized' produces invalid exception
+table values in class, causes "Illegal exception table range" exception,
+VAJ 3.5+
+<br>1GGAK6G: ITPJCORE:ALL - Incorrect javadoc comment in JavaElement
+<br>1GF9L3K: ITPDUI:ALL - Eval - Private array resolution failure
+<br>1GF8KHX: ITPJUI:ALL - Invalid project build path should be warning,
+not error
+<br>1GF7JIH: ITPJCORE:ALL - Exception when removing network drive
+<br>1GEYBL9: ITPJUI:WINNT - Adding source folders on CP is very confusing
+<br>1GEJAOT: ITPJUI:WINNT - JRE Source attachment set to path to does not
+exist
+<br>1GEHZNB: ITPJUI:WINNT - smoke 114: formatter inserts extra tab in first
+line
+<br>1GCZZT4: ITPJCORE:Fault-tolerance - missing constructor invocation
+could still answer the allocated type
+<br>1GAU96P: ITPJCORE:WINNT - DCR - JM - JavaProject should provide a class
+path validation method
+<br>1G7A1TL: ITPJCORE:WINNT - DCR - JM - Rules for classpath not specified
+<br>1FVVWZT: ITPJCORE:ALL - JM - IBinaryType should implement getSourceFileName()
+<br>
+</body>
+</html>
diff --git a/org.eclipse.jdt.core/notes/howto/batch compile/batchCompile.html b/org.eclipse.jdt.core/notes/howto/batch compile/batchCompile.html
deleted file mode 100644
index 71dd4b3..0000000
--- a/org.eclipse.jdt.core/notes/howto/batch compile/batchCompile.html
+++ /dev/null
@@ -1,270 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]">
- <title>How to: Run batch compiler</title>
-<link rel="stylesheet" href="http://dev.eclipse.org/default_style.css" type="text/css">
-</head>
-<body text="#000000" bgcolor="#FFFFFF">
-
-<table BORDER=0 CELLSPACING=5 CELLPADDING=2 WIDTH="100%" >
-<tr>
-<td ALIGN=LEFT VALIGN=TOP COLSPAN="2" BGCOLOR="#0080C0"><b><font color="#FFFFFF">JDT
-Core / HowTo: Run the Batch Compiler </font></b></td>
-</tr>
-
-<tr>
-<td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
-
-<td WIDTH="98%"><b>Finding the batch compiler</b>
-<br>The batch compiler class is located in the internal classes of the
-JDT/Core plugin. So it is in the <i>jdtcore.jar</i> file in the directory
-<i>plugins/org.eclipse.jdt.core</i>.
-The name of the class is <i>org.eclipse.jdt.internal.compiler.batch.Main</i>. </td>
-</tr>
-
-<tr>
-<td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
-
-<td WIDTH="98%"><b>Running the batch compiler</b>
-<ul>
-<li>
-Using the main method.</li>
-
-<blockquote>Using the main method. The Main class has a main method. This
-is the classical way to invoke the batch compiler on a command-line.
-<ul>
-<li>
-For example on a command-line:</li>
-
-<br><font color="#3366FF">java -classpath jdtcore.jar org.eclipse.jdt.internal.compiler.batch.Main
--classpath rt.jar A.java</font>
-<li>
-For example in a java source:</li>
-
-<br><font color="#3366FF">org.eclipse.jdt.internal.compiler.batch.Main.main(new
-String[] {"-classpath", "rt.jar", "A.java"});</font></ul>
-</blockquote>
-
-<li>
-Using the static compile(String) method.</li>
-
-<blockquote>The compile(String) method is a convenient method to invoke
-the batch compiler in a java application.
-<br>Instead of:
-<ul>
-<li>
-<font color="#3366FF">org.eclipse.jdt.internal.compiler.batch.Main.main(new
-String[] {"-classpath", "rt.jar", "A.java"});</font></li>
-
-<li>
-you can simply write: <font color="#3366FF">org.eclipse.jdt.internal.compiler.batch.Main.compile("-classpath
-rt.jar A.java");</font></li>
-</ul>
-</blockquote>
-</ul>
-</td>
-</tr>
-
-<tr>
-<td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
-
-<td WIDTH="98%"><b>Which options are available?</b>
-<p>
-With the yellow background, these are required options.<br>
-With the orange background, these are suggested options.
-</p>
-<blockquote>
-<table BORDER CELLSPACING=2 CELLPADDING=2 COLS=2 WIDTH="100%" >
-<tr>
-<th>Name</th>
-<th>Usage</th>
-</tr>
-<tr>
-<td>-help</td>
-<td valign=top>Display the help message</td>
-</tr>
-<tr>
-<td valign=top>-version</td>
-<td>Display the build number of the compiler. This is very useful to report a bug.</td>
-</tr>
-<tr>
-<td valign=top bgcolor="#FFFFCC">-classpath <dir 1>;<dir 2>;...;<dir P></td>
-<td valign=top bgcolor="#FFFFCC">This is a list of directory or jar files used to compile the source files. There is no default classpath. So this option
-is always required to compile source files.</td>
-</tr>
-<tr>
-<td valign=top bgcolor="#FFCCAA">-d <dir 1>|none</td>
-<td bgcolor="#FFCCAA">This is used to specify in which directory the generated .class files should be dumped. If it is omitted, no package directory structure is created.<br>
-If you don't want to generate .class files, use <font color="#3366FF">-d none</font>.</td>
-</tr>
-<tr>
-<td valign=top>-target 1.1|1.2</td>
-<td>This specifies the classfile target setting. The possible value are <font color="#3366FF">1.1</font> or <font color="#3366FF">1.2</font>, default is <font color="#3366FF">1.1</font></td>
-</tr>
-<tr>
-<td valign=top>-1.3</td>
-<td>Set compliance level to <font color="#3366FF">1.3</font> (default)</td>
-</tr>
-<tr>
-<td valign=top>-1.4</td>
-<td>Set compliance level to <font color="#3366FF">1.4</font>.</td>
-</tr>
-<tr>
-<td valign=top>-source 1.3|1.4</td>
-<td>This is used to enable the assertion support of the compiler. The possible value are: <font color="#3366FF">1.3</font> or <font color="#3366FF">1.4</font>, default is <font color="#3366FF">1.3</font> in <font color="#3366FF">-1.3</font> mode and <font color="#3366FF">1.4</font> in <font color="#3366FF">-1.4</font> mode.
-In <font color="#3366FF">1.4</font>, <font color="#3366FF"><I>assert</I></font> is treated as a keyword.</td>
-</tr>
-<tr>
-<td valign=top>-warn: <blockquote>constructorName<br>|packageDefaultMethod<br>|deprecation<br>|maskedCatchBlocks<br>|unusedLocals<br>|unusedArguments<br>|unusedImports<br>|syntheticAccess<br>|assertIdentifier</blockquote>
-</td>
-<td>Set warning level.<br>e.g. <font color="#3366FF">-warn:unusedLocals,deprecation</font><br>
-<table>
-<tr>
-<th align=left>constructorName</th>
-<td>warn method with constructor name</td>
-</tr>
-<tr>
-<th align=left>packageDefaultMethod</th>
-<td>warn attempt to override package-default method</td>
-</tr>
-<tr>
-<th align=left>deprecation</th>
-<td>warn usage of deprecated type or member</td>
-</tr>
-<tr>
-<th align=left>maskedCatchBlocks</th>
-<td>warn hidden catch block</td>
-</tr>
-<tr>
-<th align=left>unusedLocals</th>
-<td>warn unused local variable</td>
-</tr>
-<tr>
-<th align=left>unusedArguments</th>
-<td>warn unused method argument</td>
-</tr>
-<tr>
-<th align=left>unusedImports</th>
-<td>When enabled, the compiler will issue an error or a warning for unused import reference
-</td>
-</tr>
-<tr>
-<th align=left>syntheticAccess</th>
-<td>warn when performing synthetic access for innerclass</td>
-</tr>
-<tr>
-<th align=left>assertIdentifier</th>
-<td>warn occurrence of <i>assert</i> used as identifier</td>
-</tr>
-</table>
-</td>
-</tr>
-<tr>
-<td valign=top>-nowarn</td>
-<td>No warning (equivalent to <font color="#3366FF">-warn:none</font>)</td>
-</tr>
-<tr>
-<td valign=top>-deprecation</td>
-<td>Equivalent to <font color="#3366FF">-warn:deprecation</font>.</td>
-</tr>
-<tr>
-<td valign=top>-g[:none|:lines,vars,source]
-</td>
-<td>Set the debug attributes level<br>
-<table>
-<tr>
-<th align=left>-g</th>
-<td>All debug info (equivalent to <font color="#3366FF">-g:lines,vars,source</font>)
-</td>
-</tr>
-<th align=left>-g:none</th>
-<td>No debug info</td>
-</tr>
-<tr>
-<th align=left>-g:[lines,vars,source]</th>
-<td>Selective debug info</td>
-</tr>
-</table>
-</tr>
-<tr>
-<td valign=top>-preserveAllLocals</td>
-<td>Explicitly request the compiler to preserve all local variables (for debug purpose). If omitted, the compiler will removed unused locals.</td>
-</tr>
-<tr>
-<td valign=top>-noImportError</td>
-<td>The compiler won't report an error for unresolved imports. A warning is issued instead.</td>
-</tr>
-<tr>
-<td valign=top>-encoding <encoding name></td>
-<td>Specify default source encoding format (custom encoding can also be specifed on a per file basis by suffixing each input source file/folder name with <font color="#3366FF">[encoding <encoding name>]</font>).</td>
-</tr>
-<tr>
-<td valign=top>-log <filename></td>
-<td>Specify a log file in which all output from the compiler will be dumped. This is really useful if you want to debug the batch
-compiler or get a file which contains all errors and warnings from a batch build.</td>
-</tr>
-<tr>
-<td valign=top>-proceedOnError</td>
-<td>Keep compiling when error, dumping class files with problem methods or problem types. This is recommanded only if you want
-to be able to run your application even if you have remaining errors.</td>
-</tr>
-<tr>
-<td valign=top>-verbose</td>
-<td>Print accessed/processed compilation units in the console or the log file if specified.</td>
-</tr>
-<tr>
-<td valign=top>-referenceInfo</td>
-<td>Compute reference info. This is useful only if connected to the builder. The reference infos are useless otherwise.</td>
-</tr>
-<tr>
-<td valign=top>-progress</td>
-<td>Show progress (only in -log mode)</td>
-</tr>
-<tr>
-<td valign=top>-time
-</td>
-<td>Display speed information</td>
-</tr>
-<tr>
-<td valign=top>-noExit</td>
-<td>Do not call <font color="#3366FF">System.exit(n)</font> at end of compilation (<font color="#3366FF">n=0</font> if no error)</td>
-</tr>
-<tr>
-<td valign=top>-repeat <n>
-</td>
-<td>Repeat compilation process <font color="#3366FF"><n></font> times (perf analysis).</td>
-</tr>
-</table>
-</blockquote>
-</td>
-</tr>
-<tr>
-<td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
-
-<td WIDTH="98%"><b>Examples</b>
-<blockquote>
-<table>
-<td valign=top><font color="#3366FF">d:\temp -classpath rt.jar -time -g -d d:/tmp</font>
-</td>
-<td valign=top>It compiles all source files in d:\temp and its subfolders. The classpath is simply rt.jar. It generates all debug
-attributes and all generated .class files are dumped in d:\tmp. The speed of the compiler will be displayed once the batch process
-is completed.</td>
-</tr>
-<tr>
-<td valign=top><font color="#3366FF">d:\temp\Test.java -classpath d:\temp;rt.jar -g:none</font>
-</td>
-<td valign=top>It compiles only Test.java and it will retrieve any dependant files from d:\temp. The classpath is rt.jar and d:\temp, which means that all necessary classes
-are searched first in d:\temp and then in rt.jar. It generates no debug attributes and all generated .class files are dumped in d:\tmp.</td>
-</table>
-</blockquote>
-</td>
-</tr>
-
-</table>
-
-
-
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/howto/flush metadata/flushMetadata.html b/org.eclipse.jdt.core/notes/howto/flush metadata/flushMetadata.html
deleted file mode 100644
index f7208fe..0000000
--- a/org.eclipse.jdt.core/notes/howto/flush metadata/flushMetadata.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
- <head>
- <title>How to: Flush the Metadata</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <link rel="stylesheet" href="http://dev.eclipse.org/default_style.css" type="text/css">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <table border=0 cellspacing=5 cellpadding=2 width="100%" >
-
-<tr>
- <td align=LEFT valign=TOP colspan="2" bgcolor="#0080C0"><b><font color="#FFFFFF">
- JDT Core / HowTo: Flush the Metadata </font></b></td>
-</tr>
-
-<tr>
- <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
- <td WIDTH="98%"><b>Topic1</b><br>
- This is the first topic
- <ul>
- Blabla1
- </ul>
- </td>
-</tr>
-
-</table>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/howto/generate parser/UpdateParserFiles.java b/org.eclipse.jdt.core/notes/howto/generate parser/UpdateParserFiles.java
deleted file mode 100644
index 92f11fb..0000000
--- a/org.eclipse.jdt.core/notes/howto/generate parser/UpdateParserFiles.java
+++ /dev/null
@@ -1,18 +0,0 @@
-import java.io.IOException;
-import org.eclipse.jdt.internal.compiler.parser.Parser;
-
-public class UpdateParserFiles {
-
- public static void main(String[] args) throws IOException {
- if (args.length != 1) {
- printUsage();
- return;
- }
- Parser.buildFilesFromLPG(args[0]);
- }
-
- public static void printUsage() {
- System.out.println("Usage: UpdateParserFiles <path to javadcl.java>");
- System.out.println("e.g. UpdateParserFiles c:/javadcl.java");
- }
-}
diff --git a/org.eclipse.jdt.core/notes/howto/generate parser/generateParser.html b/org.eclipse.jdt.core/notes/howto/generate parser/generateParser.html
deleted file mode 100644
index 2b43775..0000000
--- a/org.eclipse.jdt.core/notes/howto/generate parser/generateParser.html
+++ /dev/null
@@ -1,214 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
- <head>
- <title>How to: Generate the Parser</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <link rel="stylesheet" href="http://dev.eclipse.org/default_style.css" type="text/css">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <table border=0 cellspacing=5 cellpadding=2 width="100%" >
-
-<tr>
- <td align=LEFT valign=TOP colspan="2" bgcolor="#0080C0"><b><font color="#FFFFFF">
- JDT Core / HowTo: Generate the Parser </font></b></td>
-</tr>
-
-<tr>
- <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
- <td WIDTH="98%"><b>Where to get the parser generator</b><br>
- <blockquote>The parser files and resources are automatically generated using the LPG parser generator. This tools has
- been renamed Jikes Parser generator. You can find more information and latest releases at this <A HREF="http://www-124.ibm.com/developerworks/projects/jikes/">link</A>.
- The latest tool is provided in source format. We don't provide any help for compiling these
- source files. Refer to the link above if you have trouble to get binaries.
- <br>Our grammar is generated using the version 2.30 of LPG. If newer versions fail to generate resources from our
- grammar, please send request to the Jikes Parser Generator team.
- </blockquote>
- </p>
- </td>
-</tr>
-<tr>
- <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
- <td WIDTH="98%"><b>Where to get the grammar</b><br>
- <blockquote>The latest grammar is always located in the <code>grammar()</code> method of the <code>Parser</code> class. Go to the org.eclipse.jdt.core plugins
- directory (<font color="#3366FF">eclipse\plugins\org.eclipse.jdt.core</font> where eclipse is the root of your eclipse installation) and open the
- <font color="#3366FF">jdtcoresrc.zip</font> file. Then search for the <font color="#3366FF">Parser.java</font> inside the
- folder <font color="#3366FF">org\eclipse\jdt\internal\compiler\parser\</font>. You need to look for the method named
- <code>grammar()</code>. Then copy its contents from:
-<PRE>--main options
-%options ACTION, AN=JavaAction.java, GP=java,
-....
-$end
--- need a carriage return after the $end
-</PRE>
- into a file called <font color="#3366FF">java.g</font>. It is important to add a carriage return at the end of the last line.
- You can save this file where you want, we will assume from thereon you saved it in <code>d:\temp\</code>.
- </blockquote>
- </p>
- </td>
-</tr>
-<tr>
- <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
- <td WIDTH="98%"><b>What to do with these files and update the parser class...</b><br>
- <blockquote>
-Assuming, the LPG executable (<code>lpg.exe</code> or <code>jikespg.exe</code>) is located inside <code>d:\lpg</code>.
- <ol>
- <li>First in a console, run:
- <PRE>
- d:
- cd \temp
- d:\lpg\lpg.exe java.g
- </PRE>
- </li>
- <li>You will get an output that looks like this:
- <PRE>
- LPG Parser Generator (V2.30) Tue Apr 02 12:49:13 2002
-%OPTIONS ACTION, AN=JavaAction.java, GP=java,
-%OPTIONS FILE-PREFIX=java, ESCAPE=$, PREFIX=TokenName, OUTPUT-SIZE=125 ,
-%OPTIONS NOGOTO-DEFAULT, SINGLE-PRODUCTIONS, LALR=1 , TABLE=TIME ,
-%OPTIONS ERROR_MAPS
-%OPTIONS first follow
-%OPTIONS TRACE=FULL ,
-%OPTIONS VERBOSE
-Options in effect:
- ACTION ACTFILE-NAME=JavaAction.java BLOCKB=/. BLOCKE=./ BYTE CONFLIC
- DEFAULT=5 NODEBUG DEFERRED NOEDIT ERROR-MAPS ESCAPE=$
- FILE-PREFIX=java FIRST FOLLOW GENERATE-PARSER=JAVA NOGOTO-DEFAULT
- HACTFILE-NAME=javahdr.java HBLOCKB=/: HBLOCKE=:/ LALR=1 LIST
- MAX-DISTANCE=30 MIN-DISTANCE=3 NAMES=OPTIMIZED NONT-CHECK ORMARK=|
- OUTPUT-SIZE=125 PREFIX=TokenName READ-REDUCE NOSCOPES NOSHIFT-DEFAULT
- SINGLE-PRODUCTIONS STACK-SIZE=128 STATES SUFFIX= TABLE=TIME TRACE=FU
- VERBOSE WARNINGS XREF
-
-
-This grammar is LALR(1).
-
-Number of Terminals: 105
-Number of Nonterminals: 202
-Number of Productions: 437
-Number of Single Productions: 162
-Number of Items: 1265
-Number of States: 591
-Number of Shift actions: 3482
-Number of Goto actions: 4061
-Number of Shift/Reduce actions: 369
-Number of Goto/Reduce actions: 687
-Number of Reduce actions: 7736
-Number of Shift-Reduce conflicts: 0
-Number of Reduce-Reduce conflicts: 0
-Number of Reductions saved by default: 4913
-Reallocating storage for TIME table, adding 3603 entries
-
-Length of Check table: 16836
-Length of Action table: 16608
-Number of entries in Action Table: 12013
-Percentage of increase: 38.2%
-Highest symbol in Check Table: 307
-Storage Required for Tables: 66888 Bytes, 66K
-Storage Required for Rules: 1308 Bytes
-
-
-Actions in Compressed Tables:
- Number of Shifts: 3482
- Number of Shift/Reduces: 369
- Number of Gotos: 4061
- Number of Goto/Reduces: 687
- Number of Reduces: 2823
- Number of Defaults: 390
-
-Error maps storage:
- Storage required for ACTION_SYMBOLS_BASE map: 1182 Bytes
- Storage required for ACTION_SYMBOLS_RANGE map: 1007 Bytes
- Storage required for NACTION_SYMBOLS_BASE map: 1182 Bytes
- Storage required for NACTION_SYMBOLS_RANGE map: 630 Bytes
- Storage required for SYMBOL_INDEX map: 616 Bytes
- Storage required for STRING_BUFFER map: 4652 Bytes
-
-***Warning: Base Check vector contains value > 127. 16-bit words used.
-***Warning: Terminal symbol > 127. 16-bit words used.
-Escaped symbol $eof is an invalid C variable.
-
-Escaped symbol $error is an invalid C variable.
- </PRE>
- It can be quite different if the output changed since the version 2.30 of lpg. The important part is:<br>
- <blockquote><b>This grammar is LALR(1).</b></blockquote>
- This creates in the current directory some java source files and information files.
- <blockquote><table BORDER=1 CELLSPACING=2 CELLPADDING=10>
- <tr>
- <th VALIGN=top align=left>java.l</th>
- <td VALIGN=top>Information generated by lpg/jikespg. Enumarate all the states created for the automaton, etc.</td>
- </tr>
- <tr>
- <th VALIGN=top align=left>JavaAction.java</th>
- <td>It contains the method consumeRule(int) of the class org.eclipse.jdt.internal.compiler.parser.Parser that handles all semantic actions dispatches.</td>
- </tr>
- <tr>
-<th VALIGN=top align=left>javahdr.java</th>
- <td>You don't need this file. It is actually empty.</td>
- </tr>
- <tr>
-<th VALIGN=top align=left>javadcl.java</th>
- <td>This files is used to generate the resources files.</td>
- </tr>
- <tr>
-<th VALIGN=top align=left>javasym.java</th>
- <td>This is the contents of the class org.eclipse.jdt.core.compiler.ITerminalSymbols. You need to replace:<br>
- <ul>
- <li>TokenName$eof with TokenNameEOF</li>
- <li>TokenName$error with TokenNameERROR</li>
- </ul></td>
- </tr>
- <tr>
-<th VALIGN=top align=left>javadef.java</th>
- <td>This is the contents of the class org.eclipse.jdt.internal.compiler.parser.ParserBasicInformation.</td>
- </tr>
- <tr>
-<th VALIGN=top align=left>javaprs.java</th>
- <td>You don't need this file. Its contents is already inlined in the Parser class.</td>
- </tr>
- </table></blockquote>
- </li>
- <li><blockquote>Now we need to update the different classes and resource files.
- </blockquote>
- <ol>
- <li>Copy the contents of the <font color="#3366FF">JavaAction.java</font> file into the <font color="#3366FF">consumeRule(int)</font> method of the org.eclipse.jdt.internal.compiler.parser.Parser class.
- </li>
- <li>The definition of the Parser needs to be updated with two tables from <font color="#3366FF">javadcl.java</font>. Those are <font color="#3366FF">rhs[]</font> and <font color="#3366FF">name[]</font>.
- The following entries in name[] need to be replaced:
- <ul>
- <li><font color="#3366FF">$eof</font> with <font color="#3366FF">UNEXPECTED_EOF</font></li>
- <li><font color="#3366FF">$error</font> with <font color="#3366FF">"Invalid Character"</font></li>
- </ul>
-The previous definition of name[] will guide you.
- </li>
- <li>The class <font color="#3366FF">org.eclipse.jdt.internal.compiler.parser.ParserBasicInformation</font> needs to be updated with the content of the file <font color="#3366FF">javadef.java</font>. Don't copy the
- interface name. Simply copy the field declarations. The actual source of this class will guide you.</li>
- <li>This is the contents of the class org.eclipse.jdt.internal.compiler.parser.TerminalSymbols. You need to replace:<br>
- <ul>
- <li><font color="#3366FF">TokenName$eof</font> with <font color="#3366FF">TokenNameEOF</font></li>
- <li><font color="#3366FF">TokenName$error</font> with <font color="#3366FF">TokenNameERROR</font></li>
- </ul>
- </li>
- <li>The last step is to update the resource files:<br>
- Copy the jdtcore.jar file in d:\temp. Compile this <A HREF="UpdateParserFiles.java">source</A> inside d:\temp. You will have a file UpdateParserFiles.class.
- Then run the following command-line:
- <PRE>
- D:\temp>java -classpath jdtcore.jar;. UpdateParserFiles javadcl.java
- </PRE>
-Once this done, you will end up with 5 new files inside d:\temp. They are called parser<n>.rsc, with n equals to 1..5.
-All these files need to be moved to the org\eclipse\jdt\internal\compiler\parser folder. Now you are ready to execute and test
-the new parser.
- </li>
- </ol>
- </li>
- </ol>
- <P>
- <b>NOTE:</b> <blockquote>Changing the parser is a risky operation if you miss one of the steps above. The resulting parser can be completely
- unpredictable. It can go from crashing to reporting invalid errors. Be sure that you followed all the steps and that all the
- files are updated and recompiled before you run it. </blockquote>
- </P>
- </blockquote>
-</td>
-</tr>
-</table>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/howto/patch jdtcore/patchJdtcore.html b/org.eclipse.jdt.core/notes/howto/patch jdtcore/patchJdtcore.html
deleted file mode 100644
index 7d42931..0000000
--- a/org.eclipse.jdt.core/notes/howto/patch jdtcore/patchJdtcore.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
- <head>
- <title>How to: Patch Jdt/Core</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <link rel="stylesheet" href="http://dev.eclipse.org/default_style.css" type="text/css">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <table border=0 cellspacing=5 cellpadding=2 width="100%" >
-
-<tr>
- <td align=LEFT valign=TOP colspan="2" bgcolor="#0080C0"><b><font color="#FFFFFF">
- JDT Core / HowTo: Patch Jdt/Core</font></b></td>
-</tr>
-
-<tr>
- <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
- <td WIDTH="98%"><b>Topic1</b><br>
- This is the first topic
- <ul>
- Blabla1
- </ul>
- </td>
-</tr>
-
-</table>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/howto/set classpath/setClasspath.html b/org.eclipse.jdt.core/notes/howto/set classpath/setClasspath.html
deleted file mode 100644
index d90ec7e..0000000
--- a/org.eclipse.jdt.core/notes/howto/set classpath/setClasspath.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
- <head>
- <title>How to: Set the Classpath</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <link rel="stylesheet" href="http://dev.eclipse.org/default_style.css" type="text/css">
- </head>
- <body bgcolor="#FFFFFF" text="#000000">
- <table border=0 cellspacing=5 cellpadding=2 width="100%" >
-
-<tr>
- <td align=LEFT valign=TOP colspan="2" bgcolor="#0080C0"><b><font color="#FFFFFF">
- JDT Core / HowTo: Set the Classpath </font></b></td>
-</tr>
-
-<tr>
- <td ALIGN=RIGHT VALIGN=TOP WIDTH="2%"><img SRC="http://dev.eclipse.org/images/Adarrow.gif" NOSAVE BORDER=0 height=16 width=16></td>
- <td WIDTH="98%"><b>Topic1</b><br>
- This is the first topic
- <ul>
- Blabla1
- </ul>
- </td>
-</tr>
-
-</table>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/classpath container/classpathContainer.html b/org.eclipse.jdt.core/notes/r2.0/classpath container/classpathContainer.html
deleted file mode 100644
index 47b0357..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/classpath container/classpathContainer.html
+++ /dev/null
@@ -1,308 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta http-equiv="Content-Language" content="en-us">
- <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
- <meta name="ProgId" content="FrontPage.Editor.Document">
- <title>Class Path Container Enhancement</title>
-</head>
-<body>
-
-<h1>Class Path Container Enhancement</h1>
-<span style="FONT-SIZE: 10pt">Last Modified April 23, 2002</span>
-
-
-<h2>
-Background</h2>
-JDT supports to switch the JDK that is used for building. It is currently
-implemented as follows:
-<ul>
-<li>
-org.eclipse.jdt.launching maintains the following JDK/VM information in
-its plugin metadata:</li>
-
-<ul>
-<li>
-a set of <i>VM install types</i>: a description of a VM install. It knows
-how to find the location of the binary JAR and the source JARs.</li>
-
-<li>
-<i>VM installs: </i>the location/home of a VM install on the file system.
-A VM install has an internal ID that is not visible to the user.</li>
-
-<li>
-one of the VM installs is marked as the <i>default VM install</i>.</li>
-</ul>
-
-<li>
-org.eclipse.jdt.launching defines a JRE_LIB, JRE_SRC, JRE_SRCROOT variables
-that binds to the default VM install:</li>
-
-<ul>
-<li>
-JRE_LIB: the binary JAR (e.g. rt.jar)</li>
-
-<li>
-JRE_SRC: the source JAR/zip (e.g. src.jar)</li>
-
-<li>
-JRE_SRCROOT: the prefix in the source JAR (e.g. "src")</li>
-</ul>
-
-<li>
-The Java project creation wizard adds a JRE_LIB classpath variable on a
-project's build class path.</li>
-
-<li>
-org.eclipse.jdt.debug.ui contributes a preference page to define new VM
-installs and to set the default VM install. When the default VM install
-changes, then the bindings of the JRE_* variables are changed accordingly.</li>
-
-<li>
-org.eclipse.jdt.ui contributes a class path variable preference page. It
-"knows" that the JRE_* variables are reserved and doesn't allow the user
-to edit them.</li>
-
-<li>
-The packages view shows the resolved JRE_LIB contents as a referenced library.</li>
-</ul>
-Characteristics of the current implementation:
-<ul>
-<li>
-Class path stability: changing the default JRE/VM install doesn't affect
-the build class path since the JRE_LIB variable is not affected by this
-change. In other words, when a user changes the JRE for building then the
-.classpath file is not affected.</li>
-
-<li>
-JDK switching at the workspace level for all projects is straightforward
-by the user, only the default VM install needs to be changed and all projects
-in the workspace switch to use this VM install.</li>
-
-<li>
-Since class path variables can only bind to a single JAR, the JRE_LIB variable
-can only bind to a single JAR (for the standard SUN JRE this is rt.jar).</li>
-
-<li>
-There is some magic involved with regard to the handling of JRE_* variables
-that is not obvious to the user:</li>
-
-<ul>
-<li>
-on the build class path the user sees JRE_LIB but when defining a launch
-configuration then the user sees VM Installs. The user has to know that
-JRE_LIB is indirectly bound to the VM install via the JRE installed preference
-settings.</li>
-
-<li>
-The user also has to understand that the reserved variables cannot be edited
-like the other class path variables, etc.</li>
-</ul>
-
-<li>
-Build class path ordering - users can control the order of the build class
-path in a simple way. For example, to do JCL development, to do so users
-can put their source folders in front of the JRE_LIB class path entry.</li>
-
-<li>
-Java Core is not affected by the JDK switching support and is independent
-of launching concerns.</li>
-</ul>
-
-<h2>
-Motivation for enhancing the current implementation</h2>
-
-<h3>
-New Requirements</h3>
-There are new requirements with regard to the handling of the JRE/JDK on
-the build class path that need to be addressed by 2.0:
-<ul>
-<li>
-Multiple JARs per JDK</li>
-
-<br>The JRE_LIB class path variable can only bind to a single JAR file
-typically the rt.jar. However, there are JDK installs that have split the
-rt.jar into multiple JARs. For example, the JDK on the MacOS X has split
-the rt.jar into: classes.jar and ui.jar (contains AWT and Swing).
-<br>
-<li>
-Workspaces with a different JDK per project</li>
-
-<br>WSDD needs support for having a workspace where different projects
-build against different JDKs. The JRE_LIB variable is global and there
-is no infrastructure and UI support to have different JDKs for different
-projects. WSDD defined their own build description mechanism that bypasses
-the JRE_LIB support. This results in a problematic user experience when
-switching from WSAD or vanilla Eclipse Java development to WSDD.</ul>
-
-<h3>
-Existing characteristics to be preserved in the new implementation</h3>
-
-<ul>
-<li>
-Class path stability, it has to be possible to switch a JDK locally in
-a workspace without affecting the .classpath file.</li>
-
-<li>
-Easy JDK switching at the workspace level, i.e., a single setting can be
-changed to change the build class path of all projects.</li>
-
-<li>
-Java Core is independent of the VM install infrastructure</li>
-</ul>
-
-<h2>
-Proposal</h2>
-The proposal affects core, launching, java debug UI, and the Java UI components.
-<h3>
-JavaCore</h3>
-JavaCore provides a new type of classpath entry "CPE_CONTAINER",
-which is just a named reference to a set of other classpath entries.
-A container entry refers to a container path, which can be resolved by
-a <code>ClasspathContainerInitializer</code> through an extension point,
-or explicitly assigned using a setter method.
-
-The actual binding from the CPE_Container entry to
-the target classpath entries is implemented in term of an extension point
-to keep Java Core independent of VM install concerns:
-<p><tt> <!ELEMENT classpathContainerInitializer
-EMPTY></tt>
-<br><tt> <!ATTLIST classpathContainerInitializer</tt>
-<br><tt> id
-CDATA #REQUIRED</tt>
-<br><tt> class
-CDATA #REQUIRED</tt>
-<br><tt> ></tt>
-<ul>
-<li><b>id</b> - the container unique name for which this resolver will be activated.</li>
-<li><b>class</b> - the class that implements this container initializer.
-The class must implement a public subclass of <code>org.eclipse.jdt.core.ClasspathContainerInitializer</code>
-with a public 0-argument constructor.</li>
-</ul>
-<tt> abstract class ClasspathContainerResolver
-{</tt>
-<br><tt>
-void initialize(IPath containerPath, IJavaProject project) throws CoreException;</tt>
-<br> }
-<p>The initialize call passes in a project, this enables
-to resolve a classpath container in the context of a particular project.
-The initialize method should only be called once to resolve the class path
-entry (in case of failure, the container will not be considered as having been
-resolved).
-
-<p>It is possible to register an initializer per container ID. The full container path
-being passed along to the initializer. Its first segment is
-the container ID for which an initializer should be registered. The remaining segments
-can be used to provide additional hints for the container expansion.
-In case multiple resolvers are registered on the same container ID, the first
-registered one will be used).
-
-<p>JavaCore provides a method to perform explicit modifications of a container:
-<pre>
-JavaCore#setClasspathContainer(
- IPath containerPath,
- IJavaProject[] affectedProjects,
- IClasspathContainer[] respectiveContainers,
- IProgressMonitor monitor)
-</pre>
-In particular, this method is to be used in the context of a classpath initializer so as to perform
-the actual initialization. Note that it allows to modify the value of a container for a set of projects
-at once. In reaction to invoking this method, the JavaModel will be refreshed and corresponding Java element
-changes will be notified.
-
-<p> A classpath container implements <code>org.eclipse.jdt.core.IClasspathContainer</code> and can be queried
-through a JavaCore API: <code>JavaCore#getClasspathContainer(IPath containerPath, IJavaProject project) </code>.
-
-There is no assumption that the returned container must answer the exact same containerPath
-when requested <code>IClasspathContainer#getPath</code>.
-Indeed, the containerPath is just an indication for resolving it to an actual container object.
-<p>
-Classpath container values are persisted locally to the workspace, but
-are not preserved from a session to another. It is thus highly recommended to register a
-<code>ClasspathContainerInitializer</code> for each referenced container
-(through the extension point "org.eclipse.jdt.core.ClasspathContainerInitializer").
-
-<pre>
-public interface IClasspathContainer {
-
- /**
- * Kind for a container mapping to an application library
- */
- int K_APPLICATION = 1;
-
- /**
- * Kind for a container mapping to a system library
- */
- int K_SYSTEM = 2;
-
- /**
- * Kind for a container mapping to a default system library, implicitly contributed by the runtime
- */
- int K_DEFAULT_SYSTEM = 3;
-
- /**
- * Answers the set of classpath entries this container is mapping to.
- * The set of entries associated with a classpath container may contain any of the following:
- * - library entries (<code>CPE_LIBRARY</code>)
- * - project entries (<code>CPE_PROJECT</code>)
- * A classpath container can neither reference further classpath containers or classpath variables.
- */
- IClasspathEntry[] getClasspathEntries();
-
- /**
- * Answers a readable description of this container
- */
- String getDescription();
-
- /**
- * Answers the kind of this container. Can be either:
- * - K_APPLICATION if this container maps to an application library
- * - K_SYSTEM if this container maps to a system library
- * Typically, system containers should be placed first on a build path.
- */
- int getKind();
-
- /**
- * Answers the container path identifying this container.
- * A container path is formed by a first ID segment followed with extra segments.
- * which can provide additional hint for resolving.
- * This container ID is used in conjunction with the hints for resolving to this container.
- * The container ID is also used to identify a ClasspathContainerInitializer
- * registered on the extension point "org.eclipse.jdt.core.classpathContainerInitializer", which can
- * be invoked if needing to resolve the container before it is explicitely set.
- */
- IPath getPath();
-}
-</pre>
-
-<p><font color="#FF0000"><b>Issue</b>: The Mac OS X JDK install is
-an interesting case. There the rt.jar is split into two binary JARs (classes.jar,
-ui.jar), but there is still a single src.jar. This cases needs to be handled by </font><font color="#FF0000">the
-source lookup. For example, when src.jar is attached to classes.jar then when
-looking up java.awt.Frame out of ui.jar, the source attachment of classes.jar
-needs to searched as well.</font>
-
-<h2>
-Example</h2>
-The class path of a project will look as follows:
-<p>
-<classpath>
-<br>
-<classpathentry kind="src" path="/src"/>
-<br>
-<classpathentry kind="container" path="JDK/1.3"/>
-<br>
-<classpathentry kind="output" path="bin"/>
-<br>
-</classpath>
-<p>In the case where the user didn't override the
-VM install at the project level. Then the Java launching contributed container
-resolver (registered for container prefixes: "JDK") would resolve "JDK/1.3" using the default
-VM install, using "1.3" as an hint, and may expand it into the following:
-<p>
-<classpathentry kind="lib" path="d:/jdk/1.3.1/jre/lib/rt.jar"
-rootpath="d:/jdk1.3.1/lib/src.jar" sourcepath="/src"/>
-
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/dom ast/ASTPositions.html b/org.eclipse.jdt.core/notes/r2.0/dom ast/ASTPositions.html
deleted file mode 100644
index ae0413a..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/dom ast/ASTPositions.html
+++ /dev/null
@@ -1,148 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
-</head>
-<body>
-Hi,
-<p>Here are my thoughts regarding positions and AST. The major goal was
-to come up with a consistent view, even though this causes some more work
-for refactoring and for the implementation of the new AST. But I think
-it might be worth if we can come up with a consistent story for positions.
-<h3>
-Some general statements</h3>
-
-<ol>
-<li>
-sourceStart and sourceEnd should always cover the whole node. This is different
-to the current implementation where for some nodes declarationSourceStart
-and declararionSourcEnd covers the whole node and sourceStart and sourceEnd
-only covers the name (examples are: LocalVariableDeclaration, TypeDeclararion,
-...)</li>
-
-<li>
-sourceStart and sourceEnd should also cover all subnodes</li>
-
-<li>
-whenever possible we should follow the grammar as defined in The Java Language
-Specification book. So if the grammar says that a production includes the
-semicolon then the AST node should include it too. For example the grammar
-defines a return statement like</li>
-
-<br> return (expression) ;
-<br>So the corresponding AST node should include the ;</ol>
-
-<h3>
-Some statements from earlier discussions (mainly between Jim, Philippe,
-and me)</h3>
-
-<ul>
-<li>
-There will be an ExpressionStatement node for expressions used as statements.
-For example "if (isChecked()) {}" versus "isCheck();". We agreed that the
-expression will not include the semicolon and the ExpressionStatement will.
-For the isCheck() example this will look like [[isChecked()];]. This is
-consistent with the grammer defined in (3). This together with the general
-statement (2) leads to the conclusion that statements that have child statements
-will include the semicolon if the child statement has one. For the example</li>
-
-<p><br>for (int i= 0; i < 10; i++)
-<br> foo();
-<p>sourceEnd of the for statement will include the semicolon of the expression
-statement.</ul>
-
-<h3>
-Open issues</h3>
-
-<h4>
-Multiple local declarations</h4>
-Currently multiple local declarations appear in the AST as n separate local
-declarations without any relationship to each others. This raises various
-questions:
-<ul>
-<li>
-what are the positions of those local declarations</li>
-
-<li>
-how is a visitor of that AST able to figure out that he deals with multiple
-local declaration.</li>
-</ul>
-Since the new AST isn't a 1:1 mapping of the compiler's AST anyway (we
-have the ExpressionStatement node) I opt to introduce new nodes as defined
-in the grammar. Since the semicolon doesn't belong to the variable declaration,
-it should be managed by the parent node that ties together multiple declarations.
-Here is an example:
-<p>int x= 10, x[]= null, i;
-<p>LocalVariableDeclaration node manages:
-<br> the type (e.g. int)
-<br> the positions of the commas (if needed)
-<br> the actual variable declarators
-<br> sourceStart= start of the type
-<br> sourceEnd= ;
-<p>VariableDeclarator node manages:
-<br> the variable name and its positions
-<br> the initialization
-<br> sourceStart= start of variable name
-<br> sourceEnd= end of initialization. Doesn't include
-the comma.
-<p>If we want to do some optimization we could also have a node SingleLocalVariableDeclaration
-for declaration like int x; or int y= 10; The node would have the following
-fields:
-<br> the type
-<br> the variable name and its positions
-<br> the initialization
-<br> sourceStart= start of type
-<br> sourceEnd= ;
-<h4>
-Updates in for statements</h4>
-Analogous to the local variable declaration, the comma to separate the
-update expressions can not be part of the expression (expressions don't
-contain a semicolon so they can't contain a comma either). To know the
-positions of the commas the for statement should manage them in a separate
-array.
-<p><i>The general rule is, that whenever language elements are separate
-using a comma (for example an interface list in the implements statement,
-arguments of a method declaration, ...) the node containing the separated
-nodes should manage the positions of the comma, if they are of any interest.
-In a first implementation we could leave these positions out and use the
-scanner to find them if they are of interest.</i>
-<h4>
-Treatment of semicolon</h4>
-From our experiences with refactoring it is helpful in some cases to know
-where the position of the semicolon is. For example if the user extract
-a for statement and he doesn't select the action's semicolon we allow the
-extraction. So what can we do in these cases:
-<ul>
-<li>
-simple don't allow the case. To support better selection we can offer some
-actions to extend the text selection to spawn valid AST nodes. We have
-a running prototype for this.</li>
-
-<li>
-do some parsing of the source code to find the position of the semicolon.
-We could use the scanner for this.</li>
-</ul>
-
-<h4>
-Answers to explicit questions from Olivier</h4>
-
-<ul>
-<li>
-for (;;); : in this case the for statement should cover the semicolon.
-The best way to achieve this is to have an empty statement as defined in
-the grammar.</li>
-
-<li>
-declaration source start of an argument: yes, Adam uses argument.type.sourceStart
-as the start not declarationSourceStart.</li>
-
-<li>
-test: the test we have are the refactoring test. We don't have special
-test to check if the AST positions are correct.</li>
-</ul>
-
-<br>
-<br>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/dom ast/NodeTypeNames b/org.eclipse.jdt.core/notes/r2.0/dom ast/NodeTypeNames
deleted file mode 100644
index d1ed983..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/dom ast/NodeTypeNames
+++ /dev/null
@@ -1,62 +0,0 @@
-&start;AnonymousClassDeclaration&end;
-&start;ArrayAccess&end;
-&start;ArrayCreation&end;
-&start;ArrayInitializer&end;
-&start;ArrayType&end;
-&start;AssertStatement&end;
-&start;Assignment&end;
-&start;Block&end;
-&start;BooleanLiteral&end;
-&start;BreakStatement&end;
-&start;CastExpression&end;
-&start;CatchClause&end;
-&start;CharacterLiteral&end;
-&start;ClassInstanceCreation&end;
-&start;CompilationUnit&end;
-&start;ConditionalExpression&end;
-&start;ConstructorInvocation&end;
-&start;ContinueStatement&end;
-&start;DoStatement&end;
-&start;EmptyStatement&end;
-&start;ExpressionStatement&end;
-&start;FieldAccess&end;
-&start;FieldDeclaration&end;
-&start;ForStatement&end;
-&start;IfStatement&end;
-&start;ImportDeclaration&end;
-&start;InfixExpression&end;
-&start;InstanceofExpression&end;
-&start;Initializer&end;
-&start;Javadoc&end;
-&start;LabeledStatement&end;
-&start;MethodDeclaration&end;
-&start;MethodInvocation&end;
-&start;NullLiteral&end;
-&start;NumberLiteral&end;
-&start;PackageDeclaration&end;
-&start;ParenthesizedExpression&end;
-&start;PostfixExpression&end;
-&start;PrefixExpression&end;
-&start;PrimitiveType&end;
-&start;QualifiedName&end;
-&start;ReturnStatement&end;
-&start;SimpleName&end;
-&start;SimpleType&end;
-&start;SingleVariableDeclaration&end;
-&start;StringLiteral&end;
-&start;SuperConstructorInvocation&end;
-&start;SuperFieldAccess&end;
-&start;SuperMethodInvocation&end;
-&start;SwitchCase&end;
-&start;SwitchStatement&end;
-&start;SynchronizedStatement&end;
-&start;ThisExpression&end;
-&start;ThrowStatement&end;
-&start;TryStatement&end;
-&start;TypeDeclaration&end;
-&start;TypeDeclarationStatement&end;
-&start;TypeLiteral&end;
-&start;VariableDeclarationExpression&end;
-&start;VariableDeclarationFragment&end;
-&start;VariableDeclarationStatement&end;
-&start;WhileStatement&end;
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/notes/r2.0/dom ast/ast.html b/org.eclipse.jdt.core/notes/r2.0/dom ast/ast.html
deleted file mode 100644
index cd2b9ad..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/dom ast/ast.html
+++ /dev/null
@@ -1,2091 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win98; I) [Netscape]">
- <title>JDT - Abstract Syntax Trees</title>
-</head>
-<body>
-
-<h2>
-Abstract Syntax Trees</h2>
-<font color="#3366FF">Last revised 14:00 Friday October 26, 2001 (most
-recent change in blue)</font>
-<p>Original work item: "Exposing the AST API."
-<p>Related work item: "Improved Java code manipulation support, address
-JDOM limitations; JDOM doesn't preserve markers and isn't document aware;
-JDOM finer grained update support (e.g. change method name, type name);
-buffer contents is duplicated in Java UI document and needs to be manually
-synchronized."
-<h3>
-Background</h3>
-
-<ul>
-<li>refactoring is a key customer (Dirk B.)</li>
-<li>for 2.0: have good support in place so that refactoring can be made an
-open API; would need corresponding core APIs for abstract syntax trees</li>
-<li>current refactoring appoach uses AST visitor which runs post-resolve on
-designated compilation unit</li>
-<li>visitor collects info (parent stack) including source positions</li>
-<li>uses name environment (bindings, scopes) to validate/locate</li>
-<li>all changes are formulated as reified undoable edits in a source buffer</li>
-<li>a batch of changes are made at a time</li>
-<li>refactoring does not reason hypothetically (changes are undoable)</li>
-<li>JDOM is not used by refactoring, but potentially could be (JDOM is used
-inside Java Model)</li>
-</ul>
-Dirk's wish list with regard to the AST support:
-<ul>
-<li>
-consistent positions in AST (e.g. sourceStart and sourceEnd should always
-cover the whole node).</li>
-
-<li>
-comment handling in AST. Some node contain preceding comments other don't</li>
-
-<li>
-Parent pointer in AST node.</li>
-
-<li>
-Data pointer in AST node.</li>
-
-<li>
-Expression should provide getType method (cached value of resolveType(Scope)).</li>
-</ul>
-
-<h3>
-Summary from Sept. 10-11 meetings</h3>
-Dirk travelled to SNZ to discuss refactoring requirements and possible
-solutions with Philippe M. and Jeem.
-<p>Some of the forms of solutions discussed, but ultimately abandoned:
-<ul>
-<li>
-A vanilla DOM.</li>
-
-<ul>
-<li>
-too limiting: difficult to provide for pre-computing bindings.</li>
-
-<li>
-clumsy for clients to use without AST node types represented by different
-Java types</li>
-</ul>
-
-<li>
-AST plus resolves info in form of Java model elements.</li>
-
-<ul>
-<li>
-Java model methods are unsuitable canonical representation for resolved
-methods because parameter types are as per source.</li>
-
-<li>
-It is hard to map a type back to a Java element (need to remember package
-fragment).</li>
-
-<li>
-Would need additional Java model elements to represent variable declarations.</li>
-
-<li>
-Would need special Java element implementations for local types, methods,
-and fields.</li>
-</ul>
-</ul>
-In the end, we agreed on AST plus bindings:
-<ul>
-<li>
-AST is simple tree of typed nodes as determined by parser.</li>
-
-<li>
-A different Java type for each AST node type.</li>
-
-<li>
-TBD: are node types API classes, API interfaces, or both?</li>
-
-<li>
-Simple case: no bindings.</li>
-
-<li>
-Basic AST Lifecycle: client requests AST; compilation unit is parsed and
-nodes are created; root is handed back to client; AST is garbage collected
-after client lets go of all AST nodes. AST is not affected if underlying
-compilation unit is changed (i.e., eager parse, with no residual dependence
-on state of file in workspace).</li>
-
-<li>
-Any syntax errors detected need to be reported to client. Problems are
-opaque: source character position plus human-readable message. Clients
-needs to determine whether an AST is only partial (e.g., busted flags).</li>
-
-<li>
-Predicatable trees with simple correspondence to source code (parser should
-not optimize ASTs).</li>
-
-<li>
-Reliable source position information for all nodes.</li>
-
-<li>
-Scratch "data" field on each AST node for client to record an Object.</li>
-
-<li>
-Navigate AST upwards as well as downwards. Parent link.</li>
-
-<li>
-AST walker for convenient traversal.</li>
-
-<li>
-ASTs can be read-only or read-write.</li>
-
-<li>
-Read-write ASTs can be modified in terms of ASTs. AST node factories (no
-Java parser required). Cut/copy/paste.</li>
-
-<li>
-Cut/copy/paste between separate ASTs requires fragment cloning to preserve
-independence of storage.</li>
-
-<li>
-Client may be interested in cut/copy/pasting comments too.</li>
-
-<li>
-New nodes would not carry source positions.</li>
-
-<li>
-Read-write AST can be serialized back to compilation unit char[].</li>
-
-<ul>
-<li>
-Preserve existing comments, whitespace, and use of \u.</li>
-
-<li>
-Control whitespace and use of \u for insertions.</li>
-
-<li>
-Provide edit map for updating markers.</li>
-</ul>
-
-<li>
-Resolved ASTs: basic AST annotated with bindings (non-syntactic information).</li>
-
-<li>
-Binding information is derived from AST plus the Java model (relative to
-some project).</li>
-
-<li>
-Availability/validity of bindings ceases when Java model changes.</li>
-
-<li>
-Client must request up front that bindings be created.</li>
-
-<li>
-Certain AST nodes get decorated with bindings.</li>
-
-<li>
-Client should have ways to communicate up front what kind of bindings are
-required and where.</li>
-
-<li>
-Availability/validity of bindings for a read-write AST ceases when it is
-first modified.</li>
-
-<li>
-Bindings (non-syntactic information) includes things such as the following:</li>
-
-<ul>
-<li>
-Resolved names - which type, field, method, or local variable does a AST
-name refernce resolve to.</li>
-
-<li>
-Resolved types - what is the resolved type of an AST expression or type
-reference.</li>
-
-<li>
-Resolved supertypes - what are the resolved supertypes of a resolved type.</li>
-
-<li>
-Resolved declarations - what resolved type, field, method, or local variable
-does an AST declaration map to.</li>
-
-<li>
-Thrown exceptions - what are the resolved types of the exceptions thrown
-by a given expression or statement.</li>
-
-<li>
-Resolved members - what are the resolved members of a resolved type.</li>
-</ul>
-
-<li>
-Problems also should be reported with resolving. Problems are opaque: source
-character position plus human-readable message.</li>
-
-<li>
-Space for bindings storage is significant; increases monotonically as more
-bindings are accessed.</li>
-
-<li>
-Space for bindings is for lifetime of the AST.</li>
-
-<li>
-Advanced AST Lifecycle: client requests AST with bindings; compilation
-unit is parsed, nodes created, and perhaps some bindings created and annotated
-on nodes; root is handed back to client; AST is garbage collected after
-client lets go of all AST nodes and bindings. AST itself is not affected
-if underlying compilation unit is changed (i.e., eager parse, with no residual
-dependence on state of file in workspace). Bindings may become stale or
-invalid if workspace changes (i.e., possibly lazy and incremental construction
-of bindings using Java model).</li>
-
-<li>
-<font color="#000000">Bindings from two ASTs are not generally comparable.</font></li>
-
-<ul>
-<li>
-<font color="#000000">For bindings with stable global names, API provides
-strings that can be compared between ASTs.</font></li>
-</ul>
-</ul>
-AST will either extend or replace JDOM. In the latter case, JDOM would
-be deprecated.
-<p>AST will exist along side Java model.
-<h3>
-API Design Issue: AST Node Types - Classes, interface, or both</h3>
-There are on the order of 87 node types for Java ASTs. Bindings will add
-some more. There are a couple of way this can be mapped to Java types.
-<p>(1) Use org.w3c.DOM interfaces as API. Provide a private concrete implementation
-of the DOM.
-<p>Pro: Very small, and standard API for read-write documents.
-<br>Con: API is not convenient for clients.
-<br>Con: API is not amenable to exposing bindings and other non-structural
-information.
-<p>(2) Concrete API class per AST node type.
-<p>Pro: API as small as possible.
-<br>Pro: Client can create nodes directly.
-<p>Con: Cannot easily hide implementation details; e.g. representation
-and mechanism for reassembling compilation unit text after editing; lazy
-binding creation.
-<p>Clients who create node from scratch only ever need basic constructors
-(the nodes they create do not have source positions, bindings, or other
-decorations). On the other hand, the parser needs to remember more info
-including fine-grained source positions.
-<p>(3) API interface per AST node type, along with node factory methods.
-Provide a private concrete implementation. Allow clients to reimplement
-node types (from scratch) and supply a factory.
-<p>Like JDOM (except JDOM does not permit client to reimplement) and org.w3c.dom.
-<p>Pro: API as small as possible.
-<br>Pro: Easy to tailor different kinds of representation: read-write vs.
-read-only ASTs; raw ASTs vs. AST+bindings.
-<p>Con: Hidden concrete implementation classes takes more space.
-<br>Con: Using factory methods is a bit less direct than using constructors.
-<p>We will use API interfaces for bindings, and exposed API classes for
-AST nodes.
-<h3>
-API Design Issue: Statement vs. Statement Lists</h3>
-For structured statements, like while, the child statement is grammatically
-a single statement. However, since a block is one type of statement, it
-is possible to have a list of statements underneath. There are options
-for rendering this:
-<p>(1) Child is a single statement.
-<p>(Like current compiler's internal ASTs.)
-<p>Pro: As per the Java grammar.
-<br>Con: A client wanting to insert an additional statement into the child
-must be prepared to replace by a block if there isn't one.
-<p>(2) Child is a list of statements.
-<p>(Like the .net codeDOM.)
-<p>Pro: More convenient for clients that edit ASTs. Uniform mechanism for
-inserting and removing statements from child.
-<br>Con: Muddies scopes (enclosing braces around statements introduce a
-scope and make declarations syntactically legal).
-<p>We will go with (1) and stick closely to the grammar.
-<h3>
-Usage</h3>
-There are a couple different usage scenarios for ASTs:
-<ul>
-<li>
-Analyze an existing compilation unit to discover syntactic structure.</li>
-
-<li>
-Discover relationship between syntactic structure and original text.</li>
-
-<li>
-Discover relationship between syntactic structure and resolved world.</li>
-
-<li>
-Create a new compilation unit from scratch.</li>
-
-<li>
-Edit an existing compilation unit.</li>
-</ul>
-
-<h3>
-Source Construct Normalization</h3>
-
-<ul>
-<li>
-Most syntactic constructions are rendered in one and only one way.</li>
-
-<li>
-When this is not the case, the AST construction is "lossy".</li>
-
-<li>
-Some forms cannot be distinguised in input (if one cares).</li>
-
-<li>
-Some forms cannot be produced in output.</li>
-
-<li>
-Copying the construct normalizes it.</li>
-
-<li>
-Example: Modifier order</li>
-
-<ul>
-<li>
-final static public int X = 1;</li>
-
-<li>
-public static final int X = 1; // preferred form</li>
-</ul>
-
-<li>
-Example: Compound variable declarations</li>
-
-<ul>
-<li>
-int i = 1, j = 2;</li>
-
-<li>
-int i = 1; int j = 2; // preferred form</li>
-</ul>
-
-<li>
-Example: Array type declarators</li>
-
-<ul>
-<li>
-int[] x[];</li>
-
-<li>
-int[][] x; // preferred form</li>
-</ul>
-
-<li>
-Example: Short ifs</li>
-
-<ul>
-<li>
-if (a) f(); else ;</li>
-
-<li>
-if (a) f(); // preferred form</li>
-</ul>
-
-<li>
-Can only be done for syntactic nuances that are have no semantic import.</li>
-
-<li>
-Normalization is generally acceptable where unimportant syntactic nuances
-are involved.</li>
-
-<li>
-Normal form should follow JLS recommendations and Java coding standards.</li>
-
-<li>
-Note that parentheses and blocks are important to user and should not be
-normalized.</li>
-</ul>
-
-<h3>
-Source Positions</h3>
-
-<ul>
-<li>
-When AST is obtained by parsing a text string, exposing source ranges for
-nodes allows clients to navigate back into original string; e.g., for making
-text editor selections.</li>
-
-<li>
-AST supports only character-oriented position information; mapping character
-positions to lines are handled elsewhere (e.g., text editor).</li>
-
-<li>
-Source ranges are irrelevant for nodes created by other means.</li>
-
-<li>
-Source ranges give original position in original string.</li>
-
-<ul>
-<li>
-Editing the AST does not alter positions or anything clever.</li>
-</ul>
-
-<li>
-Most constructs occupy contiguous character positions, or ranges.</li>
-
-<li>
-Ranges are represented by 0-based start position and length.</li>
-
-<li>
-Start position begins at first significant character of construct corresponding
-to AST node.</li>
-
-<ul>
-<li>
-First significant character.</li>
-
-<li>
-Does not include leading whitespace.</li>
-
-<li>
-Does not include preceding comment (except the javadoc comment preceding
-a declaration, or the comment preceding a statement - see below).</li>
-</ul>
-
-<li>
-End position includes last significant character of construct corresponding
-to AST node.</li>
-
-<ul>
-<li>
-Last significant character.</li>
-
-<li>
-Includes trailing terminators that are part of construct; e.g., include
-trailing semicolon at end of local variable declaration.</li>
-
-<li>
-Does not include separators; e.g., exclude trailing comma in parameter
-list.</li>
-
-<li>
-Does not include trailing whitespace.</li>
-
-<li>
-Does not include trailing comment.</li>
-
-<li>
-Statement end-of-line comments are not encompassed by statement.</li>
-
-<ul>
-<li>
-<tt>System.out.println("hello"); // $non-nls$</tt></li>
-</ul>
-
-<li>
-<font color="#000000">Embedded comments are encompassed if they occur before
-end position.</font></li>
-
-<ul>
-<li>
-<tt><font color="#000000">System.out.println("hello") /* comment */;</font></tt></li>
-</ul>
-</ul>
-
-<li>
-Some node types would have source ranges for significant contiguous subconstructs
-not readily gleanable from source ranges of the subnodes.</li>
-
-<ul>
-<li>
-Additional source ranges would be specified for each node type.</li>
-
-<li>
-E.g., method declaration has additional source range for the method name
-and for the method declaration excluding its javadoc comment.</li>
-
-<li>
-Use start and length arrays rather than proliferate API methods for additional
-source ranges.</li>
-</ul>
-</ul>
-
-<h3>
-Unicode Escapes</h3>
-
-<ul>
-<li>
-Original source text might contain Unicode escapes (JLS 3.2, 3.3).</li>
-
-<li>
-E.g., void\u0040\u005a(); declares a method named Z.</li>
-
-<li>
-Scanner removes all Unicode escapes and returns a Unicode token stream.</li>
-
-<li>
-Newly created AST nodes are "post" Unicode escaping.</li>
-
-<li>
-Output options:</li>
-
-<ul>
-<li>
-Preserve existing Unicode escapes (default); remove all existing Unicode
-escapes.</li>
-
-<li>
-Do not introduce Unicode escapes (default); introduce Unicode escapes for
-characters in a specified set (e.g., all non-ASCII).</li>
-</ul>
-
-<li>
-Initial implementation: support default behavior only.</li>
-</ul>
-
-<h3>
-Comments</h3>
-
-<ul>
-<li>
-Comments are problematic for ASTs; these lexical items are normally filtered
-out of token stream.</li>
-
-<li>
-Comments are significant to user.</li>
-
-<li>
-Editing an existing compilation unit should generally preserve existing
-comments.</li>
-
-<li>
-Should be able to include comments for newly created subtrees.</li>
-
-<li>
-Copying a subtree from one place to another should include relevant comments.</li>
-
-<li>
-Most common forms of comments:</li>
-
-<ul>
-<li>
-Javadoc comments - on one or more lines preceding field, method, and type
-declarations.</li>
-
-<li>
-Boilerplace comments (copyright notices) - one or more lines preceding
-the package declaration, or between the package declaration and first import
-or type declaration.</li>
-
-<li>
-Statement comments - one or more lines between statements in a block.</li>
-
-<li>
-Statement end-of-line comments.</li>
-</ul>
-
-<li>
-VA/ST experience: not worth bending over backwards to accomodate all comments.</li>
-
-<li>
-Determined clients can rescan original string to get at all comments.</li>
-
-<li>
-Expose high value comments:</li>
-
-<li>
-Javadoc comments - treat as attribute of the field, method, and type declarations.</li>
-
-<ul>
-<li>
-Clients can extract Javadoc attributes (including @deprecated).</li>
-
-<li>
-Clients can create declarations with Javadoc.</li>
-</ul>
-
-<li>
-Statement comments within blocks</li>
-
-<ul>
-<li>
-Approach 1: Treat as pseudo-statements with a special AST node type.</li>
-
-<ul>
-<li>
-Pro: Clients can include comments with blocks.</li>
-
-<li>
-Con: Only works for comments within genuine blocks. E.g., can't handle</li>
-
-<li>
-<tt>if (test)</tt></li>
-
-<li>
-<tt> // should not happen</tt></li>
-
-<li>
-<tt> throw new RuntimeException();</tt></li>
-
-<li>
-Would work better if we were using statement lists in more places.</li>
-</ul>
-
-<li>
-Approach 2: Treat as a property of following statment node.</li>
-
-<ul>
-<li>
-Pro: Clients can include comments before any statement.</li>
-
-<li>
-Con: Does not handle trailing comments in blocks. E.g.,</li>
-
-<li>
-<tt>{</tt></li>
-
-<li>
-<tt> throw new RuntimeException();</tt></li>
-
-<li>
-<tt> // can't reach here</tt></li>
-
-<li>
-<tt>}</tt></li>
-</ul>
-
-<li>
-Recommend approach 2 since it covers most cases.</li>
-</ul>
-
-<li>
-Boilerplate comments would not be exposed, but would be preserved through
-edit and output.</li>
-</ul>
-
-<h3>
-Whitespace</h3>
-
-<ul>
-<li>
-Whitespace (JLS 3.6) includes ASCII SP, HT, and FF characters, and line
-terminators.</li>
-
-<li>
-Like comments, whitespace is significant to user.</li>
-
-<li>
-Editing an existing compilation unit should generally preserve whitespace.</li>
-
-<li>
-Whitespace for newly created subtrees automatically generated to produce
-output that follows common conventions and blends in with surrounding text
-(use the same leading whitespace).</li>
-
-<li>
-Copying a subtree from one place to another should should generally preserve
-whitespace.</li>
-</ul>
-
-<h3>
-AST Parent Backpointer</h3>
-
-<ul>
-<li>
-Each AST node will carry a backpointer to its parent node.</li>
-
-<li>
-ASTNode.getParent() returns ASTNode</li>
-
-<li>
-This permits clients to traverse ASTs in upward as well as downward direction.</li>
-
-<li>
-Bidirectional links must be maintained during editing.</li>
-
-<li>
-Deletion API must unlink child from parent.</li>
-
-<li>
-Insertion API must link child to parent.</li>
-
-<ul>
-<li>
-To preserve treeness, automatically clone child subtree if child already
-has parent.</li>
-</ul>
-
-<li>
-Replace API must unlink old child before inserting new child.</li>
-
-<li>
-Parent backlinks means that hanging on to <i>any</i> node in an AST instance
-will prevent any part of the AST instance from being garbage collected.</li>
-</ul>
-
-<h3>
-Multiple ASTs</h3>
-
-<ul>
-<li>
-Muliple ASTs can exist side by side (and ASTs are potentially for same
-compilation unit).</li>
-
-<li>
-Allow insertion of nodes from one AST into another AST.</li>
-
-<ul>
-<li>
-Automatically clones child subtree (forgetting source positions and binding
-decorations).</li>
-
-<li>
-Ensure memory representation of ASTs remain completely independent.</li>
-</ul>
-</ul>
-
-<h3>
-<font color="#3366FF">Structural Equality</font></h3>
-
-<ul>
-<li>
-<font color="#3366FF">Structural equality predicate on AST nodes.</font></li>
-
-<li>
-<font color="#3366FF">Isomorphic subtrees.</font></li>
-
-<li>
-<font color="#3366FF">Belonging to same or different AST.</font></li>
-
-<li>
-<font color="#3366FF">Considers structural info only; ignores source positions,
-bindings, etc.</font></li>
-
-<li>
-<font color="#3366FF">Named something other than "equals" to avoid having
-to reimplement hashCode too.</font></li>
-</ul>
-
-<h3>
-Syntactic Correctness of Parser-built ASTs</h3>
-
-<ul>
-<li>
-For ASTs built by a Java parser, there are issues of syntactic correctness.</li>
-
-<li>
-Syntactic correctness is judged by the Syntactic Grammar (as defined in
-JLS2 section 2.3).</li>
-
-<li>
-Java parser <b>must</b> guarantee to produce a faithful AST for any syntactically
-correct compilation unit.</li>
-
-<li>
-Java parser <b>may</b> also build ASTs for syntactically incorrect compilation
-units.</li>
-
-<li>
-Complicant Java compilers must reject syntactically incorrect compilation
-units.</li>
-
-<li>
-What principle do we apply to Java parsers and the ASTs they return?</li>
-
-<li>
-Real Java parsers are invariably more liberal than the Syntactic Grammar,
-and rely on post-parse checks to report errors for any syntactically incorrect
-constructs that makes it past the parser.</li>
-
-<ul>
-<li>
-E.g., conflicting modifiers: public private</li>
-
-<li>
-E.g., field declared with no initializer occurs in an interface</li>
-
-<li>
-E.g., void foo() [];</li>
-</ul>
-
-<li>
-In the current Eclipse compiler, many of these checks are done in the course
-of type and name resolution. If client only wants AST, we want to avoid
-doing expensive name and type analysis.</li>
-
-<li>
-Approach 1: Guarantee that no ASTs are built for syntactically incorrect
-compilation units.</li>
-
-<ul>
-<li>
-You do not get an AST at all for compilation units with syntax errors.</li>
-
-<li>
-Pro: Client can trust parser to distinguish syntactically correct from
-incorrect.</li>
-
-<li>
-Con: Client cannot manipulate syntactically incorrect compilation units
-at all.</li>
-
-<li>
-Con: Requires post-parse check to detect residual syntax errors.</li>
-</ul>
-
-<li>
-Approach 2: Provide no guarantee about the ASTs for syntactically incorrect
-compilation units.</li>
-
-<ul>
-<li>
-You might not get a useful AST at all.</li>
-
-<li>
-You might get an AST that had pieces missing; e.g., a malformed method
-was excised</li>
-
-<li>
-You might get an AST that is incoherent or self-contradictory; e.g., a
-transient class!?</li>
-
-<li>
-Pro: Maximum flexibility for implementation.</li>
-
-<li>
-Pro: Client can get useful ASTs for some syntactically incorrect programs.</li>
-
-<li>
-Con: Client cannot trust parser to distinguish syntactically correct from
-incorrect.</li>
-</ul>
-
-<li>
-Approach 3: Guarantee that the client examining the resulting AST has some
-way to determine whether the compilation units is incorrect.</li>
-
-<ul>
-<li>
-Priniciple: Syntactic errors must not be suppressed.</li>
-
-<li>
-AST nodes could carry flags indicating certain syntax problem; e.g., duplicate
-modifiers public public</li>
-
-<li>
-A bit on root node could say "unspecified syntax errors".</li>
-
-<li>
-Could be special AST nodes types indicating major problems; e.g., bogus
-method body</li>
-
-<li>
-Could be representable configurations of AST node types that are recognizable
-as syntactially incorrect; e.g., conflicting modifiers public private;
-missing field initializer in interface</li>
-
-<li>
-Pro: Client can trust parser to not hide any syntax errors that are in
-the source.</li>
-
-<li>
-Pro: Client can get useful ASTs for syntactically incorrect programs.</li>
-
-<li>
-Con: Client must do extra work to determine whether there are syntax errors.</li>
-
-<li>
-Con: Extra work to include this information if no client really cares about
-the difference between syntactically correct and incorrect.</li>
-</ul>
-
-<li>
-The first approach is too harsh. It is much more reasonable, and interesting,
-to be able to work with some syntactically incorrect compilation units.</li>
-
-<li>
-The second approach feels reasonable if clients never care whether the
-source is syntactically correct or not.</li>
-
-<li>
-The third approach feels reasonable if some clients would care whether
-the source is syntactically correct or not.</li>
-
-<li>
-The principle difference between the second and third appoaches is that
-the former sanctions quietly suppressing syntax errors whereas the latter
-precludes it.</li>
-
-<li>
-The nature of the AST nodes inherently makes room to express a wide range
-of syntactically malformed programs.</li>
-
-<li>
-An extra flag per node for "unspecified syntax errors" should cover the
-bases.</li>
-
-<li>
-The existing compiler's ASTs already carry enough information to enable
-the compiler to do thorough post-parse detecting of residual syntax errors.</li>
-
-<li>
-Therefore the third approach is within easy reach.</li>
-
-<li>
-The third approach gives clients more than the second approach.</li>
-
-<li>
-Recommendation: we adopt the third approach.</li>
-</ul>
-
-<h3>
-Syntactic Correctness of Non-parser-built ASTs</h3>
-
-<ul>
-<li>
-ASTs do not just come from a parser.</li>
-
-<ul>
-<li>
-They can be created from scratch.</li>
-
-<li>
-A parser-build AST can be edited.</li>
-</ul>
-
-<li>
-These ASTs will need to be serialized to a source compilation unit (why
-else would they exist?).</li>
-
-<li>
-What kinds of support and guarantees are in place to ensure that such a
-suitable source compilation unit can be generated?</li>
-
-<li>
-Basic guarantee: any AST that could have come from parsing a syntactically
-correct compilation unit will serialize to a compilation unit that is</li>
-
-<ul>
-<li>
-(a) syntactically correct</li>
-
-<li>
-(b) strongly semantically equivalent to the original compilation unit.</li>
-
-<li>
-and possibly (c) normalized; that is, parse(serialize(x)) is isomorphic
-to x</li>
-</ul>
-
-<li>
-There are likely many ways to get ASTs that do not correspond to any syntactically
-correct compilation unit.</li>
-
-<ul>
-<li>
-E.g., use illegal identifiers ("1abc" or "try" or "//").</li>
-
-<li>
-E.g., use illegal modifier combinations with modifier bit masks.</li>
-</ul>
-
-<li>
-Post-screening the AST for syntactic correctness would be misguided.</li>
-
-<li>
-Should just go ahead and generate the obvious, syntactically incorrect,
-compilation unit.</li>
-
-<li>
-More importantly: ensure semantic equivalence.</li>
-
-<li>
-Operator precedence creates issues:</li>
-
-<ul>
-<li>
-E.g., given AST for expression <tt>v1*v2</tt>, replace <tt>v1</tt> node
-by expression <tt>v1+v3</tt>.</li>
-
-<li>
-Naive serialization yields <tt>v1+v3*v2</tt> which is not semantically
-equivalent to the AST.</li>
-
-<li>
-Result should be (<tt>v1+v3)*v2</tt>.</li>
-
-<li>
-Parentheses may need to be introduced during serialization.</li>
-</ul>
-
-<li>
-Nested if statement creates issues:</li>
-
-<ul>
-<li>
-E.g., given AST for statement <tt>if (a) f(); else g();</tt>, replace <tt>f();</tt>
-by <tt>if (b) h();</tt></li>
-
-<li>
-Naive serialization yields <tt>if (a) if (b) h(); else g();</tt></li>
-
-<li>
-Result should be <tt>if (a) if (b) h(); <b>else </b>; else g();</tt></li>
-
-<li>
-Extra verbiage may need to be introduced during serialization.</li>
-</ul>
-</ul>
-
-<h3>
-Deep Constructs</h3>
-
-<ul>
-<li>
-Some programs involve impossibly deep constructs.</li>
-
-<li>
-Multi-line string concatenation expressions are the main offender.</li>
-
-<ul>
-<li>
-For example, <tt>"Line 1\\n"+"Line 2\\n"+...+"Line 5000"</tt></li>
-</ul>
-
-<li>
-Runtime stacks blow when recursing over deep ASTs.</li>
-
-<li>
-AST node types should be designed to keep trees reasonably shallow for
-reasonably typical programs.</li>
-
-<li>
-Introduce N-ary operator expression node type to deal with multi-line string
-concatenation expressions.</li>
-
-<li>
-N.B. Current compiler performs compile-time concatenations during parse
-phase to deal with this problem.</li>
-</ul>
-
-<h3>
-Editing Protocol</h3>
-
-<ul>
-<li>
-What general form should the editing API take?</li>
-
-<li>
-Setters on receiver to manipulate its children (parent never affected)</li>
-
-<ul>
-<li>
-E.g., whileStatement.setCondition(newExpression)</li>
-
-<li>
-Use null for optional children</li>
-</ul>
-
-<li>
-Treat lists as an array-valued property.</li>
-
-<ul>
-<li>
-E.g., block.getStatements() returns Statement[]</li>
-
-<li>
-E.g., block.setStatements(Statement[] statements)</li>
-
-<li>
-Use empty list for no children (rather than null)</li>
-</ul>
-
-<li>
-Alternative approach for lists: use Collection-like protocol</li>
-
-<ul>
-<li>
-E.g., block.addStatement(pos, newChildStatement)</li>
-
-<li>
-E.g., block.removeStatement(oldChildStatement)</li>
-
-<li>
-Con: Increased number of methods on API; bad when a node type has several
-list properties.</li>
-</ul>
-
-<li>
-Alternative approach for delete/replace: use parent backpointers to implement
-generic delete and replace operation which affect the receiver's relationship
-to its parent</li>
-
-<ul>
-<li>
-E.g., oldChildStatement.delete()</li>
-
-<li>
-Con: semantics of deletion ugly when node occurs outside of any list</li>
-</ul>
-</ul>
-
-<h3>
-User Data Field</h3>
-
-<ul>
-<li>
-Each AST node has a user data slot reserved for client use.</li>
-
-<li>
-ASTNode.getClientData() returns Object</li>
-
-<li>
-ASTNode.setClientData(Object data)</li>
-
-<li>
-The initial value is null.</li>
-
-<li>
-Client may use for decorations, or whatever.</li>
-
-<li>
-AST nodes created by parser carry no data initially.</li>
-
-<li>
-AST nodes created explicitly carry no data initially.</li>
-
-<li>
-Even read-only ASTs have read-write data slots.</li>
-
-<li>
-Cloning an AST node creates a new node (does <b>not</b> copy or clone data).</li>
-</ul>
-
-<h3>
-Lists of Members</h3>
-
-<ul>
-<li>
-List of field, method, and type members of a type declaration.</li>
-
-<li>
-This list is syntactically and semantically heterogenous.</li>
-
-<li>
-No syntactic constraints on number and order.</li>
-
-<li>
-Order is significant to user.</li>
-
-<li>
-Within field declarations, relative order is semantically significant.</li>
-
-<li>
-Standard practices:</li>
-
-<ul>
-<li>
-Place field declarations before member methods and types.</li>
-
-<li>
-Place types before methods.</li>
-</ul>
-
-<li>
-Option (1): expose separate lists for field, methods, and types.</li>
-
-<li>
-Pro: This is way internal AST works.</li>
-
-<li>
-Pro: Convenient for clients to locate member fields, methods, and types.</li>
-
-<li>
-Con: Not flexible for editing; editing will mangle member order.</li>
-
-<li>
-Option (2): expose a single list of members</li>
-
-<li>
-Pro: parser does not normalize; client controls order of members.</li>
-
-<li>
-Con: More work for clients to locate member fields, methods, and types.</li>
-
-<li>
-Option (3): expose a single list of members, with extra getters for locating
-member fields, methods, and types.</li>
-
-<li>
-Pro: Combines advantage of (2) with convenience of (1).</li>
-
-<li>
-Recommended approach: (3).</li>
-
-<li>
-For class declarations, treat initializers and constructors as members.</li>
-
-<ul>
-<li>
-Lump instance and static initializers in with field declarations.</li>
-
-<li>
-Lump constructor declarations in with method declarations.</li>
-</ul>
-</ul>
-
-<h3>
-Serialization</h3>
-
-<ul>
-<li>
-Clients of read-write ASTs will generally want to serialize to a Java compilation
-unit.</li>
-
-<li>
-Serialization via simple AST tree walk.</li>
-
-<ul>
-<li>
-Straightforward.</li>
-
-<li>
-Introduce line breaks and whitespace to make it look pretty.</li>
-
-<li>
-Or post-process it with the Java formatter.</li>
-
-<li>
-If AST originated by parsing, the result is likely unacceptable to user:</li>
-
-<ul>
-<li>
-Completely reformatted.</li>
-
-<li>
-Constructs are normalized.</li>
-
-<li>
-Some comments may have be lost.</li>
-</ul>
-
-<li>
-Could be provided by API that makes use of regular AST API only.</li>
-
-<li>
-Could be written by clients.</li>
-</ul>
-
-<li>
-Serialization via source reconstruction.</li>
-
-<ul>
-<li>
-Only applicable to ASTs initially constructed by parser.</li>
-
-<li>
-Use source position information in modified AST to reconstruct compilation
-unit.</li>
-
-<li>
-Retain passages of original text corresponding to unchanged AST trees.</li>
-
-<li>
-Generates new text only where required.</li>
-
-<li>
-Produce a result that a user will recognize and accept.</li>
-
-<ul>
-<li>
-Preserve formatting wherever possible.</li>
-
-<li>
-Preserve source construct normalization wherever possible.</li>
-
-<li>
-Preserve arbitrarily-placed comments wherever possible.</li>
-</ul>
-
-<li>
-Requires retaining the original compilation unit, and likely recording
-additional information in nodes to allow reconstruction.</li>
-
-<li>
-This is the way the current JDOM implementation works.</li>
-
-<li>
-Could be provided by API that has privileged access to AST nodes and parser-recorded
-information.</li>
-
-<li>
-Should also return a list of edit instructions so that markers can be adjusted,
-etc.</li>
-
-<li>
-Clients would have a hard time doing this themselves.</li>
-</ul>
-
-<li>
-<font color="#000000">Recommend deferring implementation of serializer
-that does source reconstruction.</font></li>
-
-<ul>
-<li>
-<font color="#000000">In interim, refactoring can apply edits to original
-compilation unit text directly.</font></li>
-</ul>
-</ul>
-
-<h3>
-Node types</h3>
-The AST node types are based on the standard grammar for the Java language
-given in the JLS2.
-<p>Every AST node belongs to a single AST instance. (In DOM terminology,
-the AST is the document and the AST nodes are the elements). The AST instance
-can serve as a factory for creating new nodes. Nodes point to their owning
-AST (fixed for the node's lifetime). The AST points directly to the root
-node (a compilation unit).
-<p>The AST node types do not define their own notion of equality; they
-just inherit the object identity based implementation from Object.
-<p>Note: Grammar rules (in comments) are expressed in the Pascal-style
-extended BNF used in <tt>section 18</tt> of JLS2. We use C# style property
-declarations as a convenient abbreviation for a standard matched pair of
-get and set methods.
-<p><tt>public class AST</tt>
-<br><tt> public AST();</tt>
-<br><tt> public property CompilationUnit root;</tt>
-<br><tt> public void loadFromSource(char[] source);</tt>
-<br><tt> public void setOptions(...);</tt>
-<br><tt> public char[] serialize();</tt>
-<p><tt>public abstract class ASTNode</tt>
-<br><tt> protected ASTNode(AST ast);</tt>
-<br><tt> public AST getOwner();</tt>
-<br><tt> public property int[] startPositions;</tt>
-<br><tt> public property int[] lengths;</tt>
-<br><tt> public property boolean isWholeLine;</tt>
-<br><tt> public property Object clientData;</tt>
-<br><tt> public ASTNode getParent();</tt>
-<br><tt> ... other protocol common to all AST node types</tt>
-<h4>
-Names</h4>
-As explained in JLS2 section 6.5, the grammar does not allow names to be
-resolved more finely than the following 6 categories by syntactic means
-alone:
-<p><tt>PackageName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-PackageName . Identifier</tt>
-<br><tt>TypeName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-PackageOrTypeName . Identifier</tt>
-<p><tt>ExpressionName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-AmbiguousName . Identifier</tt>
-<p><tt>MethodName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-AmbiguousName . Identifier</tt>
-<p><tt>PackageOrTypeName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-PackageOrTypeName . Identifier</tt>
-<p><tt>AmbiguousName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-AmbiguousName . Identifier</tt>
-<p>Given that names cannot be resolved definitively to a package, type,
-field, or variable at AST node construction time, an open question is how
-much of the categorization that could be done should be reflected in the
-AST. More categories means more information flow from the parser to the
-AST client; on the other hand, a variety of categories is not necessarily
-convenient for clients. For example, in <tt>import a.b.c</tt> the name
-is a <tt>TypeName</tt> whereas in <tt>import a.b.c.*</tt> the name <tt>a.b.c</tt>
-is a <tt>PackageOrTypeName</tt>. If the name category was to be reflected
-in the type of the AST nodes, the client would need to know to create the
-appropriate type of name nodes when editing the AST.
-<p>Proposal: Use two AST node types for names: simple names, and qualified
-names. Qualified names are expressed recursively, to facilitate clients
-discovering how the qualifier part of a name resolves. Use these for everything
-but <tt>MethodName</tt>; for <tt>MethodName</tt>, which can appear only
-in a method invocation expression, separate the selector identifier from
-any preceding qualifier.
-<p>(Note: The current internal AST nodes go beyond making the simple/qualified
-distinction: they also have simple & qualified type names (classes
-<tt>SimpleTypeReference</tt>
-and <tt>QualifiedTypeReference</tt>) in additional to simple & qualified
-named (classes <tt>SimpleNameReference</tt> and
-<tt>QualifiedNameReference</tt>).)
-<p><tt>// Name:</tt>
-<br><tt>//
-SimpleName</tt>
-<br><tt>//
-QualifiedName</tt>
-<br><tt>// SimpleName:</tt>
-<br><tt>//
-Identifier</tt>
-<br><tt>// QualifiedName:</tt>
-<br><tt>//
-Name <b><u>.</u></b> Identifier</tt>
-<br><tt>public interface IName // "marker" interface</tt>
-<br><tt> public IBinding resolvedBinding(); //
-optional</tt>
-<p><tt>public class SimpleName extends ASTNode implements IName, IExpression</tt>
-<br><tt> public SimpleName(AST ast);</tt>
-<br><tt> public property char[] identifier;</tt>
-<p><tt>public class QualifiedName extends ASTNode implements IName, IExpression</tt>
-<br><tt> public QualifiedName(AST ast);</tt>
-<br><tt> public property IName qualifier;</tt>
-<br><tt> public property char[] identifier;</tt>
-<h3>
-Compilation Units and Major Declarations</h3>
-<tt>// CompilationUnit:</tt>
-<br><tt>//
-[<b><u>package</u></b> Identifier { <b><u>.</u></b> Identifier } <b><u>;</u></b>
-]</tt>
-<br><tt>//
-{ImportDeclaration}</tt>
-<br><tt>//
-{TypeDeclaration | <b><u>;</u></b>}</tt>
-<br><tt>public class CompilationUnit extends ASTNode</tt>
-<br><tt> public CompilationUnit(AST ast);</tt>
-<br><tt> public property Name packageName; // optional</tt>
-<br><tt> public property ImportDeclaration[] imports;</tt>
-<br><tt> public property TypeDeclaration[] types;</tt>
-<p><tt>// ImportDeclaration:</tt>
-<br><tt>// <b><u>import</u></b>
-Identifier { <b><u>.</u></b> Identifier } [ <b><u>.</u></b> <b><u>*</u></b>
-]
-<b><u>;</u></b></tt>
-<br><tt>public class ImportDeclaration extends ASTNode</tt>
-<br><tt> public ImportDeclaration(AST ast);</tt>
-<br><tt> public property Name importName;</tt>
-<br><tt> public property boolean onDemand;</tt>
-<br><tt> public IBinding resolveBinding();</tt>
-<p><tt>// TypeDeclaration:</tt>
-<br><tt>//
-{Modifier} <b><u>class</u></b> Identifier</tt>
-<br><tt>//
-[<b><u>extends</u></b> Type]</tt>
-<br><tt>//
-[<b><u>implements</u></b> Type { <b><u>,</u></b> Type}]</tt>
-<br><tt>//
-<b><u>{</u></b> {ClassBodyDeclaration | <b><u>;</u></b> } <b><u>}</u></b></tt>
-<br><tt>//
-{Modifier} <b><u>interface</u></b> Identifier</tt>
-<br><tt>//
-[<b><u>extends</u></b> Type { <b><u>,</u></b> Type}]</tt>
-<br><tt>//
-<b><u>{</u></b> {InterfaceBodyDeclaration | <b><u>;</u></b> } <b><u>}</u></b></tt>
-<br><tt>// Modifier:</tt>
-<br><tt>// <b><u>public</u></b></tt>
-<br><tt>// <b><u>protected</u></b></tt>
-<br><tt>// <b><u>private</u></b></tt>
-<br><tt>// <b><u>static</u></b></tt>
-<br><tt>// <b><u>abstract</u></b></tt>
-<br><tt>// <b><u>final</u></b></tt>
-<br><tt>// <b><u>native</u></b></tt>
-<br><tt>// <b><u>synchronized</u></b></tt>
-<br><tt>// <b><u>transient</u></b></tt>
-<br><tt>// <b><u>volatile</u></b></tt>
-<br><tt>// <b><u>strictfp</u></b></tt>
-<br><tt>// ClassBodyDeclaration:</tt>
-<br><tt>//
-MethodDeclaration</tt>
-<br><tt>//
-ConstructorDeclaration</tt>
-<br><tt>//
-FieldDeclaration</tt>
-<br><tt>//
-ClassDeclaration</tt>
-<br><tt>//
-TypeDeclaration</tt>
-<br><tt>//
-Initializer</tt>
-<br><tt>// InterfaceBodyDeclaration:</tt>
-<br><tt>//
-MethodDeclaration</tt>
-<br><tt>//
-FieldDeclaration</tt>
-<br><tt>//
-TypeDeclaration</tt>
-<br><tt>public class TypeDeclaration extends ASTNode implements IStatement,
-IMember</tt>
-<br><tt> public TypeDeclaration(AST ast);</tt>
-<br><tt> public property int modifiers;</tt>
-<br><tt> public property char[] name;</tt>
-<br><tt> public property Name superclass; // optional</tt>
-<br><tt> public property Name[] superInterfaces;</tt>
-<br><tt> public property IMember[] members;</tt>
-<br><tt> public property char[][] javadocComment; //
-optional</tt>
-<br><tt> // convenience methods</tt>
-<br><tt> public FieldDeclaration[] getFields; // includes
-constants; excludes initializers</tt>
-<br><tt> public AbstractMethodDeclaration[] getMethods;
-// includes constructors</tt>
-<br><tt> public TypeDeclaration[] getTypes;</tt>
-<br><tt> public ITypeBinding resolveBinding();</tt>
-<p><tt>// MethodDeclaration:</tt>
-<br><tt>//
-{Modifier} (Type | <b><u>void</u></b>) Identifier <b><u>(</u></b></tt>
-<br><tt>//
-[FormalParameter { <b><u>,</u></b> FormalParameter}] <b><u>)</u></b>
-{<b><u>[</u></b> <b><u>]</u></b>}</tt>
-<br><tt>//
-[<b><u>throws</u></b> QualifiedIdentifierList] ( MethodBody | <b><u>;</u></b>
-)</tt>
-<br><tt>// ConstructorDeclaration:</tt>
-<br><tt>//
-{Modifier} Identifier <b><u>(</u></b> [FormalParameter { <b><u>,</u></b>
-FormalParameter}] <b><u>)</u></b></tt>
-<br><tt>//
-[<b><u>throws</u></b> QualifiedIdentifierList] MethodBody</tt>
-<br><tt>// FormalParameter:</tt>
-<br><tt>//
-[<b><u>final</u></b>] Type Identifier {<b><u>[</u></b> <b><u>]</u></b>}</tt>
-<br><tt>public abstract class AbstractMethodDeclaration extends ASTNode
-implements IMember</tt>
-<br><tt> protected AbstractMethodDeclaration(AST ast);</tt>
-<br><tt> public property int modifiers;</tt>
-<br><tt> public property char[] selector;</tt>
-<br><tt> public property FormalParameter[] parameters;</tt>
-<br><tt> public property Name[] thrownExceptions;</tt>
-<br><tt> public property char[][] javadocComment; //
-optional</tt>
-<br><tt> public property Block body; // optional</tt>
-<br><tt> public IMethodBinding resolveBinding();</tt>
-<p><tt>public class MethodDeclaration extends AbstractMethodDeclaration</tt>
-<br><tt> public MethodDeclaration(AST ast);</tt>
-<br><tt> public property Type returnType; // includes
-void</tt>
-<p><tt>public class ConstructorDeclaration extends AbstractMethodDeclaration</tt>
-<br><tt> public ConstructorDeclaration(AST ast);</tt>
-<p><tt>// FieldDeclaration:</tt>
-<br><tt>//
-{Modifier} Type Identifier {<b><u>[</u></b> <b><u>]</u></b>} [ <b><u>=</u></b>
-Expression]</tt>
-<br><tt>//
-{ <b><u>,</u></b> Identifier {<b><u>[</u></b> <b><u>]</u></b>} [ <b><u>=</u></b>
-Expression] }</tt>
-<br><tt>public class FieldDeclaration extends ASTNode implements IMember</tt>
-<br><tt> public AbstractMethodDeclaration(AST ast);</tt>
-<br><tt> public property int modifiers;</tt>
-<br><tt> public property char[] name;</tt>
-<br><tt> public property Type type;</tt>
-<br><tt> public property char[][] javadocComment; //
-optional</tt>
-<br><tt> public property IExpression initializer; //
-optional</tt>
-<br><tt> public IFieldBinding resolveBinding();</tt>
-<p><tt>// Initializer:</tt>
-<br><tt>//
-[<b><u>static</u></b>] Block</tt>
-<br><tt>public final class Initializer extends ASTNode implements IMember</tt>
-<br><tt> public Initializer(AST ast);</tt>
-<br><tt> public property int modifiers;</tt>
-<br><tt> public property Block body;</tt>
-<p><tt>// LocalVariableDeclaration:</tt>
-<br><tt>//
-[<b><u>final</u></b>] Type Identifier {<b><u>[]</u></b>} [ <b><u>=</u></b>
-Expression ]</tt>
-<br><tt>//
-{ <b><u>,</u></b> Identifier {<b><u>[]</u></b>} [ <b><u>=</u></b> Expression]
-} <b><u>;</u></b></tt>
-<br><tt>public class LocalVariableDeclaration extends ASTNode implements
-IStatement</tt>
-<br><tt> public LocalVariableDeclaration(AST ast);</tt>
-<br><tt> public property int modifiers;</tt>
-<br><tt> public property char[] name;</tt>
-<br><tt> public property Type type;</tt>
-<br><tt> public property IExpression initializer; //
-optional</tt>
-<br><tt> public ILocalVariableBinding resolveBinding();</tt>
-<br>
-<h4>
-Types</h4>
-The Type node (= TypeReference) represents a reference to a base type,
-a named type, or an array thereof.
-<p><tt>// Type:</tt>
-<br><tt>//
-(BasicType | TypeName ) {<b><u>[]</u></b>}</tt>
-<br><tt>// BasicType:</tt>
-<br><tt>// <b><u>byte</u></b></tt>
-<br><tt>// <b><u>short</u></b></tt>
-<br><tt>// <b><u>char</u></b></tt>
-<br><tt>// <b><u>int</u></b></tt>
-<br><tt>// <b><u>long</u></b></tt>
-<br><tt>// <b><u>float</u></b></tt>
-<br><tt>// <b><u>double</u></b></tt>
-<br><tt>// <b><u>boolean</u></b></tt>
-<br><tt>public class Type extends ASTNode implements IExpression</tt>
-<br><tt> public Type (AST ast);</tt>
-<br><tt> public property int baseType; // either</tt>
-<br><tt> public property Name typeName; // or</tt>
-<br><tt> public property int dimensions;</tt>
-<br><tt> public IBinding resolvedType();</tt>
-<h4>
-Statements</h4>
-There is a different AST node type for each different kind of statement.
-Use a "marker" interface (<tt>IStatement</tt>) to bring all constructs
-that can appear within a block (nonterminal <tt>BlockStatement</tt>, which
-includes local variable and type declarations).
-<p><tt>// Block:</tt>
-<br><tt>// <b><u>{</u></b>
-BlockStatement <b><u>}</u></b></tt>
-<br><tt>// BlockStatement :</tt>
-<br><tt>// LocalVariableDeclaration</tt>
-<br><tt>// TypeDeclaration</tt>
-<br><tt>// [Identifier
-<b><u>:</u></b>
-] Statement</tt>
-<br><tt>//Statement:</tt>
-<br><tt>// Block</tt>
-<br><tt>// <b><u>if
-(</u></b>Expression <b><u>)</u></b> Statement [<b><u>else</u></b> Statement]</tt>
-<br><tt>// <b><u>for
-(</u></b> ForInitOpt <b><u>;</u></b> [Expression]
-<b><u>;</u></b>
-ForUpdateOpt <b><u>)</u></b> Statement</tt>
-<br><tt>// <b><u>while
-(</u></b> Expression <b><u>)</u></b> Statement</tt>
-<br><tt>// <b><u>do</u></b>
-Statement <b><u>while</u></b> <b><u>(</u></b> Expression
-<b><u>);</u></b></tt>
-<br><tt>// <b><u>try</u></b>
-Block [Catches] [ <b><u>finally</u></b> Block ]</tt>
-<br><tt>// <b><u>switch
-(</u></b> Expression <b><u>)</u></b> <b><u>{</u></b> SwitchBlockStatementGroups
-<b><u>}</u></b></tt>
-<br><tt>// <b><u>synchronized
-(</u></b> Expression <b><u>)</u></b> Block</tt>
-<br><tt>// <b><u>return</u></b>
-[Expression] <b><u>;</u></b></tt>
-<br><tt>// <b><u>throw</u></b>
-Expression <b><u>;</u></b></tt>
-<br><tt>// <b><u>break</u></b>
-[Identifier] <b><u>;</u></b></tt>
-<br><tt>// <b><u>continue</u></b>
-[Identifier] <b><u>;</u></b></tt>
-<br><tt>// <b><u>;</u></b></tt>
-<br><tt>// ExpressionStatement</tt>
-<br><tt>// Identifier
-<b><u>:</u></b>
-Statement</tt>
-<br><tt>public interface IStatement // "marker" interface</tt>
-<p><tt>public class Block extends ASTNode implements IStatement</tt>
-<br><tt> public Block(AST ast);</tt>
-<br><tt> public property IStatement[] statements;</tt>
-<br><tt>public class IfStatement extends ASTNode implements IStatement</tt>
-<br><tt> public IfStatement(AST ast);</tt>
-<br><tt> public property IExpression test;</tt>
-<br><tt> public property IStatement thenPart;</tt>
-<br><tt> public property IStatement elsePart; //
-optional</tt>
-<br><tt>public class WhileStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class ForStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class DoStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class TryStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class SwitchStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class SynchronizedStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class ReturnStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class ThrowStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class BreakStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class ContinueStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class NullStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class LabeledStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class AssertStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<h4>
-<font color="#000000">Expression Statements</font></h4>
-<font color="#000000">Certain types of expressions can also appear as statements.
-The ExpressionStatement node wraps an expression up as a statement. The
-source range for the ExpressionStatement includes the trailing semicolon.</font><font color="#000000"></font>
-<p><tt><font color="#000000">public class ExpressionStatement extends ASTNode
-implements IStatement</font></tt>
-<br><tt><font color="#000000"> public ExpressionStatement(AST
-ast);</font></tt>
-<br><tt><font color="#000000"> public property IExpression
-expression;</font></tt>
-<h4>
-Expressions</h4>
-There is a different AST node type for each different kind of expression.
-Use a "marker" interface (<tt>IExpression</tt>) to bring all constructs
-that can appear as expressions.
-<p>(Many details TBD).
-<p><tt>// Expression:</tt>
-<br><tt>//
-Identifier</tt>
-<br><tt>//
-ArrayAllocationExpression</tt>
-<br><tt>//
-StringLiteral</tt>
-<br><tt>//
-FloatingPointLiteral</tt>
-<br><tt>//
-BooleanLiteral</tt>
-<br><tt>//
-CharacterLiteral</tt>
-<br><tt>//
-StringLiteral</tt>
-<br><tt>//
-NullLiteral</tt>
-<br><tt>//
-( Type | <b><u>void</u></b> ) <b><u>.</u></b> class</tt>
-<br><tt>//
-[ ClassName <b><u>.</u></b> ] <b><u>this</u></b></tt>
-<br><tt>// <b><u>(</u></b>
-Expression <b><u>)</u></b></tt>
-<br><tt>//
-[ Expression <b><u>.</u></b> ] <b><u>new</u></b> Type <b><u>(</u></b></tt>
-<br><tt>//
-[ Expression { <b><u>,</u></b> Expression } ] <b><u>)</u></b> [ ClassBody
-]</tt>
-<br><tt>//
-Expression <b><u>.</u></b> Identifier</tt>
-<br><tt>//
-[ ClassName <b><u>.</u></b> ] <b><u>super .</u></b> Identifier</tt>
-<br><tt>//
-MethodName <b>(</b> [ Expression { <b><u>,</u></b> Expression } ] <b><u>)</u></b></tt>
-<br><tt>//
-Expression <b><u>.</u></b> Identifier <b>(</b> [ Expression { <b><u>,</u></b>
-Expression } ] <b><u>)</u></b></tt>
-<br><tt>//
-[ ClassName <b><u>.</u></b> ] <b><u>super .</u></b> Identifier <b>(</b></tt>
-<br><tt>//
-[ Expression { <b><u>,</u></b> Expression } ] <b><u>)</u></b></tt>
-<br><tt>//
-Expression <b><u>[</u></b> Expression <b><u>]</u></b></tt>
-<br><tt>//
-Expression InfixOperator Expression</tt>
-<br><tt>//
-Expression <b><u>instanceof</u></b> Type</tt>
-<br><tt>//
-Expression PostfixOperator</tt>
-<br><tt>//
-PrefixOperator Expression</tt>
-<br><tt>// <b><u>(</u></b>
-Type <b><u>)</u></b> Expression</tt>
-<br><tt>//
-Expression <b><u>?</u></b> Expression <b><u>:</u></b> Expression</tt>
-<br><tt>//
-Expression AssignmentOperator Expression</tt>
-<br><tt>// ArrayInitializer</tt>
-<br><tt>public interface IExpression // "marker" interface</tt>
-<br><tt> public IBinding resolvedType(); // optional</tt>
-<p><tt>// ArrayAllocationExpression:</tt>
-<br><tt>// <b><u>new</u></b>
-PrimitiveType <b><u>[</u></b> Expression <b><u>]</u></b> { <b><u>[</u></b>
-Expression <b><u>]</u></b> } { <b><u>[</u></b> <b><u>]</u></b> }</tt>
-<br><tt>// <b><u>new</u></b>
-TypeName <b><u>[</u></b> Expression <b><u>]</u></b> {
-<b><u>[</u></b> Expression
-<b><u>]</u></b>
-} { <b><u>[</u></b> <b><u>]</u></b> }</tt>
-<br><tt>// <b><u>new</u></b>
-PrimitiveType <b><u>[</u></b> <b><u>]</u></b> { <b><u>[]</u></b> } ArrayInitializer</tt>
-<br><tt>// <b><u>new</u></b>
-TypeName <b><u>[</u></b> <b><u>]</u></b> { <b><u>[]</u></b> } ArrayInitializer</tt>
-<br><tt>public class ArrayAllocationExpression</tt>
-<br><tt> extends ASTNode implements IExpression</tt>
-<br><tt> public ArrayAllocationExpression(AST ast);</tt>
-<br><tt> public property Type type;</tt>
-<br><tt> public property Expression[] dimensions; //
-optional</tt>
-<br><tt> public property Expression arrayInitializer;
-// optional</tt>
-<p><tt>public class StringLiteral extends ASTNode implements IExpression</tt>
-<br><tt> public StringLiteral(AST ast);</tt>
-<br><tt> public property String value;</tt>
-<p><tt>public class CastExpression extends ASTNode implements IExpression</tt>
-<br><tt> public CastExpression(AST ast);</tt>
-<br><tt> public property Type type;</tt>
-<br><tt> public property IExpression value;</tt>
-<p><tt>public class InfixExpression extends ASTNode implements IExpression</tt>
-<br><tt> public InfixExpression(AST ast);</tt>
-<br><tt> public property int infixOperator;</tt>
-<br><tt> public property IExpression leftOperand;</tt>
-<br><tt> public property IExpression rightOperand;</tt>
-<br><tt> public property IExpression[] extendedOperands;
-// L op R op R2 op R3...</tt>
-<h3>
-Bindings</h3>
-The "world of bindings" is an integrated picture of the structure of the
-program as seen from the compiler's point of view. The bindings correspond
-to named entities (packages, types, fields, methods, local variables).
-<p>Clients navigate from AST nodes into the world of bindings to discover
-things like:
-<ul>
-<li>
-the entity an identifier resolves to</li>
-
-<li>
-the resolved type of an expression node</li>
-
-<li>
-the resolved binding of a declaration node</li>
-
-<li>
-others?</li>
-</ul>
-Once in the world of bindings, the client can navigate the web of bindings:
-<ul>
-<li>
-from array type to its component type, and vice versa</li>
-
-<li>
-from field or variable to its declared type</li>
-
-<li>
-from method to its parameter and return types</li>
-
-<li>
-from type to its constructors and its declared method, field, and type
-members</li>
-
-<li>
-from constructor, method, or field to its declaring type</li>
-
-<li>
-from nested type to its enclosing type</li>
-
-<li>
-from type to declaring package</li>
-
-<li>
-from type to its supertypes (but, significantly, <i>not</i> to its subtypes)</li>
-
-<li>
-directly to the binding for any base type (int, float, char, etc.)</li>
-
-<li>
-directly to the binding for a handful of well-known types (java.lang.Object,
-etc.)</li>
-</ul>
-Some of the navigations that are not supported (quite intentionally):
-<ul>
-<li>
-from package to its (known) types - very expensive</li>
-
-<li>
-from package to one of its types by name - very expensive</li>
-
-<li>
-from type to its (known) subtypes - very expensive</li>
-
-<li>
-from type or method to the local types it encloses - binding for local
-types are only of interest to those with the enclosing type's AST in their
-hand</li>
-
-<li>
-from method to the variables declared within it - binding for variables
-are only of interest to those with the method's AST in their hand</li>
-</ul>
-There are no links from the world of bindings back to the world of ASTs.
-<p>Other things dealt with in the world of bindings:
-<ul>
-<li>
-synthetic entities stemming from default constructors, abstract method
-copy-down from interfaces, and inner class emulation</li>
-
-<li>
-missing bindings for entities that are required (mentioned by name) but
-were not found</li>
-
-<li>
-type hierachy circularities</li>
-
-<li>
-internal inconsistencies</li>
-</ul>
-Other issues:
-<ul>
-<li>
-Compile-time-computed values for constants (public static final fields
-with compile-time computable values)</li>
-</ul>
-
-<h4>
-Existing Binding classes</h4>
-To give an idea of the scope of the existing binding infrastructure, below
-is a dump of the type hierarchy of the compiler's binding classes from
-package <tt>rg.eclipse.jdt.internal.compiler.lookup</tt>.
-<p><tt>public abstract class Binding</tt>
-<br><tt> public abstract class TypeBinding</tt>
-<br><tt> public final class ArrayBinding</tt>
-<br><tt> public final class BaseTypeBinding</tt>
-<br><tt> public abstract class
-ReferenceBinding</tt>
-<br><tt>
-public class SourceTypeBinding</tt>
-<br><tt>
-public class NestedTypeBinding</tt>
-<br><tt>
-public final class LocalTypeBinding</tt>
-<br><tt>
-public final class MemberTypeBinding</tt>
-<br><tt>
-public class ProblemReferenceBinding</tt>
-<br><tt>
-public class UnresolvedReferenceBinding</tt>
-<br><tt> public class PackageBinding</tt>
-<br><tt> public class ProblemPackageBinding</tt>
-<br><tt> public abstract class VariableBinding</tt>
-<br><tt> public class LocalVariableBinding</tt>
-<br><tt>
-public class SyntheticArgumentBinding</tt>
-<br><tt> public class FieldBinding</tt>
-<br><tt>
-public class SyntheticFieldBinding</tt>
-<br><tt>
-public class ProblemFieldBinding</tt>
-<br><tt> public class MethodBinding</tt>
-<br><tt> public class ProblemMethodBinding</tt>
-<br><tt> public class SyntheticAccessMethodBinding</tt>
-<br><tt> public class ImportBinding</tt>
-<br><tt> public class ProblemBinding</tt>
-<h4>
-Binding API</h4>
-The existing binding classes are not immediately suitable for exposing
-as a binding API.
-<p>However, the Java builder does have an API for the built "image", in
-package <tt>org.eclipse.jdt.internal.core.builder</tt>. (This API is a
-hold-over from Leapfrog era, and is not exposed in the Eclipse code base).
-This API was designed to expose the same kind of integrated picture of
-the structure of the program as seen from the compiler's point of view.
-This API has a detailed specification that does not expose implementation
-details, so the proposal is to use it as the basis for the new binding
-API.
-<p>Re-purposing this API would entail:
-<ul>
-<li>
-introducing entities for local variables</li>
-
-<li>
-removing protocol for navigations that are not supported (e.g., from package
-to its known types)</li>
-
-<li>
-removing unneeded protocol; including states, non-state-specific handles,
-deltas, report cards, dependency graph, package references</li>
-</ul>
-Below is a dump of the relevant interfaces from package <tt>org.eclipse.jdt.internal.core.builder</tt>.
-Unnecessary protocol has been omitted. (Note that NotPresentException is
-an unchecked exception, and would not be required.)
-<p><tt>public interface IHandle</tt>
-<br><tt> int K_JAVA_IMAGE = 1;</tt>
-<br><tt> int K_JAVA_PACKAGE = 2;</tt>
-<br><tt> int K_JAVA_TYPE = 3;</tt>
-<br><tt> int K_JAVA_FIELD = 4;</tt>
-<br><tt> int K_JAVA_METHOD = 5;</tt>
-<br><tt> int K_JAVA_CONSTRUCTOR = 6;</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> int hashCode();</tt>
-<br><tt> boolean isFictional() throws NotPresentException;</tt>
-<br><tt> boolean isPresent();</tt>
-<br><tt> int kind();</tt>
-<p><tt>public interface IMember extends IHandle</tt>
-<br><tt> IType getDeclaringClass();</tt>
-<br><tt> int getModifiers() throws NotPresentException;</tt>
-<br><tt> String getName();</tt>
-<br><tt> boolean isBinary() throws NotPresentException;</tt>
-<br><tt> boolean isDeprecated() throws NotPresentException;</tt>
-<br><tt> boolean isSynthetic() throws NotPresentException;</tt>
-<p><tt>public interface IPackage extends IHandle</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType getClassHandle(String name);</tt>
-<br><tt> String getName();</tt>
-<br><tt> boolean isUnnamed();</tt>
-<p><tt>public interface IType extends IMember</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType getArrayHandle();</tt>
-<br><tt> IType getComponentType();</tt>
-<br><tt> IConstructor getConstructorHandle(IType[] parameterTypes);</tt>
-<br><tt> IType[] getDeclaredClasses() throws NotPresentException;</tt>
-<br><tt> IConstructor[] getDeclaredConstructors() throws
-NotPresentException;</tt>
-<br><tt> IField[] getDeclaredFields() throws NotPresentException;</tt>
-<br><tt> IMethod[] getDeclaredMethods() throws NotPresentException;</tt>
-<br><tt> int getDeclaredModifiers() throws NotPresentException;</tt>
-<br><tt> String getDeclaredName() throws NotPresentException;</tt>
-<br><tt> IType getDeclaringClass() throws NotPresentException;</tt>
-<br><tt> IField getFieldHandle(String name);</tt>
-<br><tt> IType[] getInterfaces() throws NotPresentException;</tt>
-<br><tt> IMethod getMethodHandle(String name, IType[]
-parameterTypes);</tt>
-<br><tt> int getModifiers() throws NotPresentException;</tt>
-<br><tt> String getName();</tt>
-<br><tt> IPackage getPackage();</tt>
-<br><tt> String getSimpleName();</tt>
-<br><tt> IType getSuperclass() throws NotPresentException;</tt>
-<br><tt> boolean isAnonymous() throws NotPresentException;</tt>
-<br><tt> boolean isArray();</tt>
-<br><tt> boolean isBinary() throws NotPresentException;</tt>
-<br><tt> boolean isClass() throws NotPresentException;</tt>
-<br><tt> boolean isDeprecated() throws NotPresentException;</tt>
-<br><tt> boolean isInnerClass() throws NotPresentException;</tt>
-<br><tt> boolean isInterface() throws NotPresentException;</tt>
-<br><tt> boolean isLocal() throws NotPresentException;</tt>
-<br><tt> boolean isPackageMember() throws NotPresentException;</tt>
-<br><tt> boolean isPresent();</tt>
-<br><tt> boolean isPrimitive();</tt>
-<br><tt> boolean isSynthetic() throws NotPresentException;</tt>
-<br><tt> boolean isTopLevel() throws NotPresentException;</tt>
-<p><tt>public interface IMethod extends IMember</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType[] getExceptionTypes() throws NotPresentException;</tt>
-<br><tt> IType[] getParameterTypes();</tt>
-<br><tt> IType getReturnType() throws NotPresentException;</tt>
-<br><tt> boolean isPresent();</tt>
-<p><tt>public interface IConstructor extends IMember</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType[] getExceptionTypes() throws NotPresentException;</tt>
-<br><tt> IType[] getParameterTypes();</tt>
-<br><tt> boolean isPresent();</tt>
-<p><tt>public interface IField extends IMember</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType getType() throws NotPresentException;</tt>
-<br><tt> boolean isPresent();</tt>
-<p>In this vein, the interface for local variables would look something
-like:
-<p><tt>public interface IVariable extends IHandle</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType getDeclaringClass();</tt>
-<br><tt> int getModifiers() throws NotPresentException;</tt>
-<br><tt> String getName();</tt>
-<br><tt> boolean isSynthetic() throws NotPresentException;</tt>
-<br><tt> IType getType() throws NotPresentException;</tt>
-<br><tt> boolean isPresent();</tt>
-<p>Also will need to add:
-<ul>
-<li>
-Pseudo-bindings for base types: boolean, int, float, etc.</li>
-
-<li>
-Access to well-known java.lang bindings: Object, String, Throwable, Exception,
-RuntimeException, Error, Class.</li>
-</ul>
-
-<h3>
-Document History</h3>
-18:30 Thursday September 27, 2001 - incorporated first round comments from
-PM and DB.
-<br><font color="#000000">10:45 Monday October 1, 2001 - incorporated comments
-from DB.</font>
-<br><font color="#000000">10:45 Tuesday October 2, 2001 - clarify handing
-of ExpressionStatement.</font>
-<br><font color="#3366FF">14:00 Friday October 26, 2001 - add subtree structural
-equality.</font>
-<br>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/dom ast/example-ast.txt b/org.eclipse.jdt.core/notes/r2.0/dom ast/example-ast.txt
deleted file mode 100644
index d8714fc..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/dom ast/example-ast.txt
+++ /dev/null
@@ -1,110 +0,0 @@
-Example AST
-===========
-
-The Java program shown in source form first is followed by a representation
-of of its AST.
-
-================
-package com.example;
-
-import java.util.*;
-
-public class HelloWorld {
- public static void main(String[] args) {
- System.out.println("Hello" + " world");
- }
-}
-================
-<CompilationUnit
- package:
- <PackageDeclaration
- name:
- <QualifiedName
- qualifier: <SimpleName identifier: "com">
- name: <SimpleName identifier: "example">
- >
- >
- imports:
- [
- <ImportDeclaration
- name:
- <QualifiedName
- qualifier: <SimpleName identifier: "java">
- name: <SimpleName identifier: "util">
- >
- isOnDemand: true
- >
- ]
- types:
- [
- <TypeDeclaration
- isInterface: false
- modifiers: IModifier.PUBLIC
- name:
- <SimpleName identifier: "HelloWorld">
- superclass: null
- superInterfaces: []
- bodyDeclarations:
- [
- <MethodDeclaration
- isConstructor: false
- modifiers: IModifier.PUBLIC | IModifier.STATIC
- selector: <SimpleName identifier: "main">
- returnType:
- <PrimitiveType primitiveTypeCode: PrimitiveType.VOID>
- parameters:
- [
- <SingleVariableDeclaration
- modifiers: IModifier.NONE
- type:
- <ArrayType
- componentType:
- <SimpleType
- name:
- <SimpleName identifier: "String">
- >
- >
- >
- name:
- <SimpleName identifier: "args">
- initializer: null
- >
- ]
- thrownExceptions: []
- body:
- <Block
- statements:
- [
- <ExpressionStatement
- expression:
- <MethodInvocation
- expression:
- <QualifiedName
- qualifier:
- <SimpleName identifier: "System">
- name:
- <SimpleName identifier: "out">
- >
- name:
- <SimpleName identifier: "println">
- arguments:
- [
- <InfixExpression
- operator: InfixExpression.Operator.PLUS
- leftOperand:
- <StringLiteral escapedValue: "\"Hello\"">
- rightOperand:
- <StringLiteral escapedValue: "\" world\"">
- extendedOperands: []
- >
- ]
- >
- ]
- >
- ]
- >
- >
- ]
- ]
-
-
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/notes/r2.0/dom ast/knowProblems.txt b/org.eclipse.jdt.core/notes/r2.0/dom ast/knowProblems.txt
deleted file mode 100644
index 2bfa663..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/dom ast/knowProblems.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-- setLeadingComment is a problem. The parser doesn't store the comment
-
-TODO:
-
-getDeclaredModifiers()
-
-check that we filter out synthetic methods, fields and parameters.
-
-SimpleType
diff --git a/org.eclipse.jdt.core/notes/r2.0/element deltas/java-element-deltas.html b/org.eclipse.jdt.core/notes/r2.0/element deltas/java-element-deltas.html
deleted file mode 100644
index 73b60d3..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/element deltas/java-element-deltas.html
+++ /dev/null
@@ -1,207 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
- <title>JDT - Java Element Deltas</title>
-</head>
-<body>
-
-<h2>
-Java Element Deltas</h2>
-Last revised 12:00 Thursday September 6, 2001
-<p>Original work item: "IJavaElementDelta should carry information about
-marker changes (ProblemMarkers)."
-<h3>
-Markers and Java Elements</h3>
-The workspace allows markers to be associated with resources. The Java
-compiler associates Java problem markers with Java source files; these
-markers locate the error within the compilation unit by source character
-position.
-<p>The Java model does not directly support markers on Java elements. It
-does provide a means (<tt>ICompilationUnit.getElementAt</tt>) for mapping
-from a source character position within a compilation unit resource to
-the nearest enclosing Java element. Since all Java problem markers carry
-a source character position, any Java problem marker can be mapped to the
-nearest enclosing Java element. In most cases, this element will be a fine-grained
-Java element corresponding to a declaration of a Java method, field, type,
-or import. In the worst case, it maps to the compilation unit element itself.
-Thus it is always possible in principle to associate markers with Java
-elements.
-<p>The Java UI visually annotates Java elements that have problems (with
-a red X).
-<p>The cost of mapping from a marker position to a fine-grained Java element
-requires opening (and parsing) the compilation unit. Once opened, additional
-markers within the same compilation unit can be mapped with negligible
-additional cost.
-<h3>
-Java Element Deltas</h3>
-Unlike workspace resource deltas, Java element deltas do not currently
-include information about marker changes.
-<p>The Java UI needs to maintain the visual annotations on Java elements
-that have problems.
-<p>There are three kinds of Java element deltas issued:
-<ol>
-<li>
-By the Java model when <tt>IWorkingCopy.commit</tt> is called to save a
-compilation unit working copy.</li>
-
-<li>
-By the Java model when <tt>IWorkingCopy.reconcile</tt> is called during
-editing.</li>
-
-<li>
-By the Java model in response to notification of a workspace resource delta
-affecting a compilation unit resource.</li>
-</ol>
-The first two kinds of Java element delta are always issued against fine-grained
-Java elements. The previous fine-grained structure of the compilation unit
-is compared to the current fine-grained structure. These deltas are recognizable
-as kind <tt>CHANGED</tt> at the compilation unit level with <tt>F_CHILDREN</tt>
-flag set and <tt>F_CONTENT</tt> flag <i>not</i> set.
-<p>The last kind of Java element delta is never fine-grained; it goes no
-finer than the compilation unit element itself. This is because the fine-grained
-structure of the previous state of the compilation unit is not available
-(the Java model does not necessarily have a record of the previous structure
-(although it <i>might </i>be in an internal cache), and cannot compute
-it since it does not a copy of the previous state of the compilation unit).
-These deltas are recognizable as kind <tt>CHANGED</tt> at the compilation
-unit level with <tt>F_CHILDREN</tt> flag <i>not </i>set and with <tt>F_CONTENT</tt>
-flag set.
-<h3>
-Markers and Java Element Deltas</h3>
-Java problems markers on Java compilation units originate when the Java
-builder is called. These markers are associated with Java compilation unit
-files, and come to the attention of the Java model via a problem delta
-associated with the resource delta that follows the build. The Java builder
-only deletes or adds Java problem markers; it never changes existing ones.
-The Java builder does not decorate Java problem markers with information
-other than the source character position.
-<p><tt>(IWorkingCopy.reconcile</tt> also returns a set of tranisent markers.)
-<p>When the user opens a compilation unit, the Java editor creates and
-locates visual markers corresponding to the Java problem markers. These
-visual markers are sticky, and move around as the text is edited.
-<p>When the user navigates into an already open compilatation unit from
-a problem marker in the Tasks view, the Java editor automatically adjusts
-the positions to account for recent edits.
-<p>When the Java editor saves a compilation unit, it permanently adjusts
-the source positions of Java problem markers associated with the corresponding
-compilation unit. This is done because the next build may be a ways off
-and these markers show up in the Tasks view (the Java editor might be closed).
-<p>Java element deltas also carry information about non-Java resources;
-this is surfaced by <tt>IJavaElementDelta.getResourceDeltas</tt>. This
-works as follows: when a non-Java resource is affected, the corresponding
-resource delta is exposed on the nearest parent Java element. For files
-directly under the project, the resource delta will be associated with
-Java element delta for the <tt>IJavaProject</tt>; for files sitting in
-the same folder as a Java source file, the resource delta will be associated
-with Java element delta for the <tt>IPackageFragment</tt>; for files sitting
-inside a source folder but not in any package fragment, the resource delta
-will be associated with Java element delta for the <tt>IPackageFragmentRoot</tt>
-(this includes the case where the project itself is a package fragment
-root. Thus the <tt>IJavaElementDelta.getResourceDeltas</tt> mechanism is
-only of use for discovering non-resource deltas; it is not useful for discovering
-marker changes to resources corresponding to Java elements.
-<p>Thus the only way a client can find out about most marker deltas is
-to register its own resource change listener with the workspace. Since
-the client would still need to register a Java model change listener, having
-to do raises the question of relative ordering of these two notifications
-(there is no guarantee which will comes first).
-<h3>
-Proposal: Expose corresponding resource deltas on Java element delta</h3>
-The proposed change is to improve the Java element delta to expose the
-corresponding resource deltas whenever they are available. This would be
-done via the following new method on <tt>IJavaElementDelta</tt>:
-<p><tt>/**</tt>
-<br><tt> * Returns the workspace resource delta for the resource that
-corresponds directly to the</tt>
-<br><tt> * Java element, or <code>null</code> if either there
-is no resource that corresponds</tt>
-<br><tt> * to the Java element, or there is a corresponding resource
-but there is no resource delta</tt>
-<br><tt> * for it.</tt>
-<br><tt> * <p></tt>
-<br><tt> * Note that a Java element delta that does not arise from
-a workspace resource delta will always</tt>
-<br><tt> * return <code>null</code>.</tt>
-<br><tt> * </p></tt>
-<br><tt> * <p></tt>
-<br><tt> * If the result is non-<code>null</code>, then</tt>
-<br><tt> * <code>getCorrespondingResourceDelta().getResource()</code>
-is the same resource as</tt>
-<br><tt> * <code>getElement().getCorrespondingResource()</code>.</tt>
-<br><tt> * </p></tt>
-<br><tt> *</tt>
-<br><tt> * @return the corresponding workspace resource delta, or
-<code>null</code> if not applicable or none</tt>
-<br><tt> */</tt>
-<br><tt>public IResourceDelta getCorrespondingResourceDelta();</tt>
-<p>Resource deltas will be available when the Java element delta results
-from the Java model receiving a resource change notification. When this
-happens, the resource delta for the corresponding will be made available
-from the Java element delta for the Java element:
-<ul>
-<li>
-Java project: expose resource delta for the corresponding project resource.</li>
-
-<li>
-Java compilation unit: expose resource delta for the corresponding Java
-source file.</li>
-
-<li>
-Java class file: expose resource delta for the corresponding Java class
-file.</li>
-
-<li>
-Java package fragment root: expose resource delta for the corresponding
-source folder, jar or zip file.</li>
-
-<li>
-Java package fragment: expose resource delta for the corresponding package
-folder under a source package fragment root.</li>
-</ul>
-Note that the proposed API change would not break compatibility with Eclipse
-1.0. It adds a new method to an interface that is not intended to be implemented
-by clients.
-<p>With the proposed change, a client of the Java model would be able to
-discover marker changes to both Java and non-Java resource by registering
-for Java model changes and composing <tt>IJavaElementDelta.getCorrespondingResourceDelta</tt>
-and <tt>IResourceDelta.getMarkerDeltas</tt>. These marker changes will
-only be present on Java element deltas stemming from workspace resource
-deltas. They are no marker deltas associated with fine-grained Java element
-deltas arising from working copy reconciliation or saving (no markers have
-changes).
-<p>Other things we considered:
-<ul>
-<li>
-For the case where a coarse-grained Java element deltas is issued, add
-marker delta information to Java elements finer than the compilation unit.
-This is not feasible because there would be no way to compute fine-grained
-Java element or marker deltas since the Java model has no "before" state
-to compare against.</li>
-
-<li>
-For the cases where a fine-grained Java element deltas is issued, add marker
-delta information to Java elements finer than the compilation unit. This
-is not feasible because the markers aren't changing in this case, and the
-Java model itself is not in the business of adjusting markers.</li>
-</ul>
-
-<h3>
-Document History</h3>
-
-<ul>
-<li>
-13:45 Thursday August 31, 2001 - First proposal send to Erich and Philippe</li>
-
-<li>
-16:30 Wednesday Sepember 5, 2001 - Modified after discussion with Erich
-and Martin.</li>
-
-<li>
-12:00 Thursday September 6, 2001 - Modified after discussion with Jerome
-who clarified how <tt>IJavaElementDelta.getResourceDeltas</tt> works.</li>
-</ul>
-
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/extension dir/ext-dirs.html b/org.eclipse.jdt.core/notes/r2.0/extension dir/ext-dirs.html
deleted file mode 100644
index 36a9f4a..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/extension dir/ext-dirs.html
+++ /dev/null
@@ -1,233 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="Author" content="Build">
- <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win98; I) [Netscape]">
- <title>JDT - Extension Directories</title>
-</head>
-<body>
-
-<h2>
-Extension Directories</h2>
-Last revised 17:10 Thursday October 25, 2001
-<p>Work item: Add support to Java model for JDK 1.2-style extension directories
-(aka optional packages)
-<p>An extension directory is a folder containing any number of JAR files
-(including 0). Extension directories were originally added in JDK 1.2,
-and are described in <a href="http://java.sun.com/j2se/1.3/docs/guide/extensions/index.html">http://java.sun.com/j2se/1.3/docs/guide/extensions/index.html</a>.
-<p>The proposal is to allow a library classpath entry to refer to an extension
-directory. A library classpath entry (<tt>CPE_LIBRARY</tt>) with a path
-whose last segment is "*" indicates an extension directory; for example,
-a library entry with the path "D:/jdk1.4/jre/lib/ext/*" means the extension
-directory "D:/jdk1.4/jre/lib/ext". Like all library entries, extension
-directories can be in folders inside the workspace or in directories in
-the local file system outside the workspace. A variable classpath entry
-may also resolve to an extension directory following the same rule about
-ending in "*". Thus a variable classpath entry like "JRE_LIB/ext/*" would
-resolve to an extension directory; and a simple one like "FOO" could resolve
-to either a JAR library, a library folder, an extension directory, or a
-project.
-<p>Each of the JARs in an extension directory on a project's class path
-would give rise to a separate <tt>IPackageFragmentRoot</tt> (kind <tt>K_BINARY</tt>);
-these package fragment roots are all child elements of the <tt>IJavaProject</tt>.
-The Java model would not have a Java element corresponding to the extension
-directory itself. A classpath entry that identifies a extension folder
-internal to the workspace gives rise to 0, 1, or more binary package fragment
-roots for JAR file resources internal to the workspace; similarly, a classpath
-entry that identifies a extension folder external to the workspace gives
-rise to binary package fragment roots for JAR files outside the workspace.
-<p>Every package fragment root that is a child of a project element stems
-from some entry on that project's original classpath. Given a package fragment
-root, how does one trace it back to the classpath entry that gave rise
-to it? In the presence of variable classpath entries and extension directories,
-the answer is not obvious. Having a simple answer is important to some
-clients. For instance, the Java UI includes the names of classpath variables
-in items in its Packages view.
-<p><tt>IPackageFragmentRoot</tt>
-<br><tt>/**</tt>
-<br><tt> * Returns the classpath entry that gives rise to this package
-fragment root.</tt>
-<br><tt> * This package fragment root must exist. The returned classpath
-entry is</tt>
-<br><tt> * equivalent to one of the classpath entries of this package
-fragment</tt>
-<br><tt> * root's project.</tt>
-<br><tt> *</tt>
-<br><tt> * @return the originating classpath entry</tt>
-<br><tt> * @exception JavaModelException if this element does not
-exist</tt>
-<br><tt> */</tt>
-<br><tt>IClasspathEntry getOriginatingClasspathEntry() throws JavaModelException;</tt>
-<p>This method would replace <tt>IJavaProject.getPackageFragmentRoots(IClasspathEntry
-entry)</tt>, which has problems and would be removed from the API (via
-deprecation).
-<h3>
-Packages View Clutter</h3>
-The packages view would show all the JARs from an extension directory as
-children of a project. Packages view clutter exists for anyone with a large
-number of JAR libraries on their build classpath. Extension directories
-exacerbate the problem by making it easy to include a whole set of JAR
-libraries with a single classpath entry (WSAD reputedly has 70+ JARs in
-its extension directory).
-<p>The packages view supports filtering out JAR libraries, meaning they
-could be hidden. However, the filter is off by default and not all users
-are aware that the filter even exists.
-<p>Note that extension folders typically contain a bunch of unrelated JARs,
-making it likely that a user will be interested in a particular subset
-and uninterested in the rest. The IBM 1.3.0 JRE jre\lib\ext contains indicim.jar
-and JawBridge.jar. The Sun JDK 1.4.0-beta jre\lib\ext contains dnsns.jar,
-ldapsec.jar, and sunjre_provider.jar. All these JARs are likely pure noise
-and do not contain API that a client would write to. In a J2EE JRE,
-there would be a diverse collection of JARs in the jre\lib\ext extension
-directory (e.g., Java Telephony, JavaMail, Java 2D, Java 3D, Java Media
-Frameworks), only a handful of which would be used within any given project.
-<p>One idea is to allow a new JavaElement "ExtensionFolder". This would
-allow to group the extension JARs and would avoid some clutter. Although
-an extension folder element could avoid clutter, it may not provide enough
-of an improvement over the existing filtering mechanism to warrant complicating
-the Java model API.
-<p>[This problem is still open. I recommend living with the currently supported
-filtering for now. We could come back later and look at ways to reduce
-clutter as a separate work item.]
-<h3>
-Default Build Classpath</h3>
-The standard JRE implicitly has the jre/lib/ext extension directory on
-its runtime classpath. By default, the build classpath for a typical project
-should include entries for both the standard class library (jre/lib/rt.jar)
-and the standard extension directory (jre/lib/ext/*).
-<p>These defaults should be a function of the VM launcher for the project.
-It should always be possible for the user to override the defaults and
-set up their build classpath as they see fit.
-<h3>
-Build Classpath Ordering</h3>
-The UI currently allows users to freely reorder package fragment roots
-for the project. This does not really make sense for package fragments
-roots that arise from extension directories.
-<p>Indeed, the addition of extension directories means that there is no
-longer a 1-1 correspondence between package fragment roots and classpath
-entries. The UI should allow the user to determine the order of classpath
-entries. Here are the guidelines and restrictions on the build classpath
-for a project (N.B., these apply to the raw classpath, not necessarily
-to a partially or fully "resolved" classpath):
-<ul>
-<li>
-There may be 0, 1, or more source folders on the classpath. The relative
-ordering of multiple source folders is significant to the user. Source
-code in an earlier source folder hides a source file of the same name in
-a later folder. This flexibility is rarely used: multiple source folders
-is rare enough, and duplicated source files, even rarer.</li>
-
-<li>
-Source folders must precede all other types of classpath entries. Nothing
-should hide source (except another source). This property is implicitly
-relied on whenever a source code patch is being applied to a binary library.</li>
-
-<li>
-The relative ordering of non-source classpath entries (library folders,
-library JARs, extension folders, required projects, and ones involving
-variables) is significant to the user. The main reason it is significant
-is to deal with conflicting library versions, where the user needs to control
-which version wins. The ones earlier in the list should take precedence
-over ones later in the list.</li>
-
-<li>
-For a standard Java runtime, all libraries on the boot classpath (usually
-just the standard JRE class library) are consulted, in the order specified,
-and before other libraries). Placing the standard JRE class library as
-the first non-source entry on the build classpath mirrors the most common
-configuration.</li>
-
-<li>
-For a standard Java runtime, all extension directories (usually just the
-standard JRE extension directory) are consulted, in the order specified,
-after libraries on the boot classpath but before other libraries. Within
-an extension directory, the various library JARs are consulted in unspecified
-order. Placing the standard JRE extension directory as the second non-source
-entry on the build classpath mirrors the most common configuration.</li>
-</ul>
-
-<h3>
-Build Classpath Duplicates</h3>
-How are duplicates libraries on the build classpath handled? For instance,
-if there are two classpath entries on a project's build classpath for exactly
-the same JAR, should there be one or two package fragment roots? What if
-a JAR classpath entry explicitly mentions a JAR that is included in an
-extension folder also on the build classpath?
-<p>At the Java model API, package fragment roots are handle objects with
-well-known identity criteria. It turns out that this dictates the answer
-to how dupicates are handled.
-<p>For library package fragment roots based on a resource in the workspace,
-the identity criteria includes the resource handle (handle constructor
-isJavaProject.getPackageFragmentRoot(IResource)) For library package fragment
-roots based on files outside the workspace, the identity criteria includes
-the path (handle constructor isJavaProject.getPackageFragmentRoot(String)).
-<p>This means the answer is forced: any duplication in the build classpath
-necessarily washes out in the mapping to package fragment roots. Two classpath
-entries for exactly the same JAR must map to a single package fragment
-root. JARs from an extension directory gives rise to the same package fragment
-roots one would get if each JAR was mentioned explicitly.
-<p>In the case of duplicates, we do have a choice for which classpath entry
-is considered the originating one. <tt>IPackageFragmentRoot.getOriginatingClasspathEntry()</tt>,
-described above, will be used to locate an entry in the build classpath
-carring important source attachment information. A specific classpath entry
-should always be preferred to a generic classpath entry (extension folders
-entries carry no source attahment info), and an earlier entry should be
-preferred over a later one.
-<p>For example, given the following (unusual) build classpath:
-<br><classpath>
-<br> <classpathentry kind="lib" path="/jre/lib/ext/*">
-<br> <classpathentry kind="lib"
-<br> path="/jre/lib/ext/servlet.jar"
-<br> sourcepath="/src/servletsrc.zip">
-<br> <classpathentry kind="lib"
-<br> path="/jre/lib/ext/servlet.jar"
-<br> sourcepath="/backup/servletsrc.zip">
-<br></classpath>
-<br>the package fragment root for "/jre/lib/ext/servlet.jar" is considered
-to originate from the second classpath entry: the second is more specific
-that the first, and is equally specific to, but ordered earlier than, the
-third.
-<h3>
-Extension Directories and the Runtime Classpath</h3>
-By default, jre/lib/ext is the extension directory at runtime. Overriding
-this default entails specifying a command line argument to set the value
-of the <tt>java.ext.dirs</tt> system property. This system property specifies
-one or more directories to search for installed extensions, each separated
-by <tt>File.pathSeparatorChar</tt>.
-<p>We need to determine whether the JAR needs to be added to the runtime
-class path or not. Since the launcher is JVM-install-type-specific, it
-feels like the right place to hardcode the knowledge of how to map a build
-classpath to a runtime classpath. The JAR for the standard class library
-does not need to be included in the runtime classpath because it is implicitly
-on the boot classpath. Similarly, any JAR that is included in an extension
-directory does not need to be mentioned explicitly.
-<h3>
-Attaching Source to Library JARs in an Extension Folder</h3>
-JARs from extension directories are not really any different from other
-class libraries. It would make debugging difficult if there were no way
-to attached source code to a JAR in a extension directory.
-<p>How does one attach source to JARs in an extension directory? As you
-recall from R0.9, we consciously opted to put the source attachment information
-in a place where it would be sharable, rather than leave this information
-local to the workspace. The API for attaching source is on the classpath
-entry; this allows this information to be shared between developers. Clearly,
-this would not work for extension directories, where the names of the JARs
-in the directory might not even be known in advance. There is no general
-naming scheme for locating the source code for a given JAR (we do not proposing
-to invent one).
-<p>As discussed in the section on package view clutter, it will be common
-for an extension directory to contain a diverse set of JARs, only a handful
-of which would be used within any given project. The proposal is to provide
-no direct support for attaching source via an extension folder classpath
-entry. If the user needs to see source code for a JAR in an extension folder,
-they would need to create an additional explicit classpath entry for that
-JAR. As discussed above, this would not result in a new package fragment
-root; however, it would effectively change the originating classpath entry
-to the explicit one where the source attachment information would be found.
-This would allow the user to attach source code to JARs on an as-needed
-basis. The bet is that this will suffice (and finesses the issue of where
-one might find the source for a JAR in an extension folder).
-<br>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/extension dir/extensionDir.html b/org.eclipse.jdt.core/notes/r2.0/extension dir/extensionDir.html
deleted file mode 100644
index 52fc49b..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/extension dir/extensionDir.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.75 [en] (Win98; U) [Netscape]">
-</head>
-<body>
-
-<h1>
-Extension Directory Support</h1>
-The WSAD effort has exposed the need for extension directories so as to
-simplify their classpath setup. Interestingly enough, the classpath rework
-(make classpath less sensitive to project change from source to binary
-form) has some nice connections with this project.
-<p>The direction followed would allow to contribute all JARs contained
-inside a given project to dependent projects. Thus such a project could
-act as an extension directory relatively to its dependent projects. This
-would however require to materialize such extension directories with true
-projects, and could be considered as one way to achieve this, but a true
-extension directory support should also exist, in a similar way as we allow
-users to directly refer to external JARs if they want.
-<p>We could add a new classpath entry kind for these. Now the next issue
-is: do we allow classpath variables to denote extension directories ? Presumably,
-this would be expected.
-<p>A classpath variable is not bound to a particular classpath entry, but
-rather to an IPath which is then resolved when the variable is substituted
-with a resolved classpath entry. The resolution process can either bind
-a variable to a project or a library, depending to what the IPath maps
-to.
-<p>In the library case, it can either be an archive file (*.jar, *.zip)
-or a binary folder (*.class files). The distinction is made again depending
-on the nature of what the IPath maps to, is it a JAR/ZIP file or a folder.
-Now, if we want to fit the extension directory support in this, it will
-be hard to distinguish in between a folder containing JARs or .class files...
-<p>We could however imagine that the syntax of the IPath would tell which
-one is expected to be resolved. For example, a path of the form "/SomeDirectory"
-would continue to indicate a binary folder, whereas "/SomeDirectory/*"
-would mean an extension directory. The benefit for this is that we actually
-do not need to add a new type of entry. We just add a third flavor of a
-library entry, the one mapping to an extension directory.
-<p>Thus, extension directories would just be particular cases of library
-ones, and be eligible in classpath variables.
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/jdom ast/ast.html b/org.eclipse.jdt.core/notes/r2.0/jdom ast/ast.html
deleted file mode 100644
index 7296e67..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/jdom ast/ast.html
+++ /dev/null
@@ -1,2108 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win98; I) [Netscape]">
- <title>JDT - Abstract Syntax Trees</title>
-</head>
-<body>
-
-<h2>
-Abstract Syntax Trees</h2>
-<font color="#3366FF">Last revised 14:00 Friday October 26, 2001 (most
-recent change in blue)</font>
-<p>Original work item: "Exposing the AST API."
-<p>Related work item: "Improved Java code manipulation support, address
-JDOM limitations; JDOM doesn't preserve markers and isn't document aware;
-JDOM finer grained update support (e.g. change method name, type name);
-buffer contents is duplicated in Java UI document and needs to be manually
-synchronized."
-<h3>
-Background</h3>
-
-<ul>
-<li>
-refactoring is a key customer (Dirk B.)</li>
-
-<li>
-for 2.0: have good support in place so that refactoring can be made an
-open API; would need corresponding core APIs for abstract syntax trees</li>
-
-<li>
-current refactoring appoach uses AST visitor which runs post-resolve on
-designated compilation unit</li>
-
-<li>
-visitor collects info (parent stack) including source positions</li>
-
-<li>
-uses name environment (bindings, scopes) to validate/locate</li>
-
-<li>
-all changes are formulated as reified undoable edits in a source buffer</li>
-
-<li>
-a batch of changes are made at a time</li>
-
-<li>
-refactoring does not reason hypothetically (changes are undoable)</li>
-
-<li>
-JDOM is not used by refactoring, but potentially could be (JDOM is used
-inside Java Model)</li>
-</ul>
-Dirk's wish list with regard to the AST support:
-<ul>
-<li>
-consistent positions in AST (e.g. sourceStart and sourceEnd should always
-cover the whole node).</li>
-
-<li>
-comment handling in AST. Some node contain preceding comments other don't</li>
-
-<li>
-Parent pointer in AST node.</li>
-
-<li>
-Data pointer in AST node.</li>
-
-<li>
-Expression should provide getType method (cached value of resolveType(Scope)).</li>
-</ul>
-
-<h3>
-Summary from Sept. 10-11 meetings</h3>
-Dirk travelled to SNZ to discuss refactoring requirements and possible
-solutions with Philippe M. and Jeem.
-<p>Some of the forms of solutions discussed, but ultimately abandoned:
-<ul>
-<li>
-A vanilla DOM.</li>
-
-<ul>
-<li>
-too limiting: difficult to provide for pre-computing bindings.</li>
-
-<li>
-clumsy for clients to use without AST node types represented by different
-Java types</li>
-</ul>
-
-<li>
-AST plus resolves info in form of Java model elements.</li>
-
-<ul>
-<li>
-Java model methods are unsuitable canonical representation for resolved
-methods because parameter types are as per source.</li>
-
-<li>
-It is hard to map a type back to a Java element (need to remember package
-fragment).</li>
-
-<li>
-Would need additional Java model elements to represent variable declarations.</li>
-
-<li>
-Would need special Java element implementations for local types, methods,
-and fields.</li>
-</ul>
-</ul>
-In the end, we agreed on AST plus bindings:
-<ul>
-<li>
-AST is simple tree of typed nodes as determined by parser.</li>
-
-<li>
-A different Java type for each AST node type.</li>
-
-<li>
-TBD: are node types API classes, API interfaces, or both?</li>
-
-<li>
-Simple case: no bindings.</li>
-
-<li>
-Basic AST Lifecycle: client requests AST; compilation unit is parsed and
-nodes are created; root is handed back to client; AST is garbage collected
-after client lets go of all AST nodes. AST is not affected if underlying
-compilation unit is changed (i.e., eager parse, with no residual dependence
-on state of file in workspace).</li>
-
-<li>
-Any syntax errors detected need to be reported to client. Problems are
-opaque: source character position plus human-readable message. Clients
-needs to determine whether an AST is only partial (e.g., busted flags).</li>
-
-<li>
-Predicatable trees with simple correspondence to source code (parser should
-not optimize ASTs).</li>
-
-<li>
-Reliable source position information for all nodes.</li>
-
-<li>
-Scratch "data" field on each AST node for client to record an Object.</li>
-
-<li>
-Navigate AST upwards as well as downwards. Parent link.</li>
-
-<li>
-AST walker for convenient traversal.</li>
-
-<li>
-ASTs can be read-only or read-write.</li>
-
-<li>
-Read-write ASTs can be modified in terms of ASTs. AST node factories (no
-Java parser required). Cut/copy/paste.</li>
-
-<li>
-Cut/copy/paste between separate ASTs requires fragment cloning to preserve
-independence of storage.</li>
-
-<li>
-Client may be interested in cut/copy/pasting comments too.</li>
-
-<li>
-New nodes would not carry source positions.</li>
-
-<li>
-Read-write AST can be serialized back to compilation unit char[].</li>
-
-<ul>
-<li>
-Preserve existing comments, whitespace, and use of \u.</li>
-
-<li>
-Control whitespace and use of \u for insertions.</li>
-
-<li>
-Provide edit map for updating markers.</li>
-</ul>
-
-<li>
-Resolved ASTs: basic AST annotated with bindings (non-syntactic information).</li>
-
-<li>
-Binding information is derived from AST plus the Java model (relative to
-some project).</li>
-
-<li>
-Availability/validity of bindings ceases when Java model changes.</li>
-
-<li>
-Client must request up front that bindings be created.</li>
-
-<li>
-Certain AST nodes get decorated with bindings.</li>
-
-<li>
-Client should have ways to communicate up front what kind of bindings are
-required and where.</li>
-
-<li>
-Availability/validity of bindings for a read-write AST ceases when it is
-first modified.</li>
-
-<li>
-Bindings (non-syntactic information) includes things such as the following:</li>
-
-<ul>
-<li>
-Resolved names - which type, field, method, or local variable does a AST
-name refernce resolve to.</li>
-
-<li>
-Resolved types - what is the resolved type of an AST expression or type
-reference.</li>
-
-<li>
-Resolved supertypes - what are the resolved supertypes of a resolved type.</li>
-
-<li>
-Resolved declarations - what resolved type, field, method, or local variable
-does an AST declaration map to.</li>
-
-<li>
-Thrown exceptions - what are the resolved types of the exceptions thrown
-by a given expression or statement.</li>
-
-<li>
-Resolved members - what are the resolved members of a resolved type.</li>
-</ul>
-
-<li>
-Problems also should be reported with resolving. Problems are opaque: source
-character position plus human-readable message.</li>
-
-<li>
-Space for bindings storage is significant; increases monotonically as more
-bindings are accessed.</li>
-
-<li>
-Space for bindings is for lifetime of the AST.</li>
-
-<li>
-Advanced AST Lifecycle: client requests AST with bindings; compilation
-unit is parsed, nodes created, and perhaps some bindings created and annotated
-on nodes; root is handed back to client; AST is garbage collected after
-client lets go of all AST nodes and bindings. AST itself is not affected
-if underlying compilation unit is changed (i.e., eager parse, with no residual
-dependence on state of file in workspace). Bindings may become stale or
-invalid if workspace changes (i.e., possibly lazy and incremental construction
-of bindings using Java model).</li>
-
-<li>
-<font color="#000000">Bindings from two ASTs are not generally comparable.</font></li>
-
-<ul>
-<li>
-<font color="#000000">For bindings with stable global names, API provides
-strings that can be compared between ASTs.</font></li>
-</ul>
-</ul>
-AST will either extend or replace JDOM. In the latter case, JDOM would
-be deprecated.
-<p>AST will exist along side Java model.
-<h3>
-API Design Issue: AST Node Types - Classes, interface, or both</h3>
-There are on the order of 87 node types for Java ASTs. Bindings will add
-some more. There are a couple of way this can be mapped to Java types.
-<p>(1) Use org.w3c.DOM interfaces as API. Provide a private concrete implementation
-of the DOM.
-<p>Pro: Very small, and standard API for read-write documents.
-<br>Con: API is not convenient for clients.
-<br>Con: API is not amenable to exposing bindings and other non-structural
-information.
-<p>(2) Concrete API class per AST node type.
-<p>Pro: API as small as possible.
-<br>Pro: Client can create nodes directly.
-<p>Con: Cannot easily hide implementation details; e.g. representation
-and mechanism for reassembling compilation unit text after editing; lazy
-binding creation.
-<p>Clients who create node from scratch only ever need basic constructors
-(the nodes they create do not have source positions, bindings, or other
-decorations). On the other hand, the parser needs to remember more info
-including fine-grained source positions.
-<p>(3) API interface per AST node type, along with node factory methods.
-Provide a private concrete implementation. Allow clients to reimplement
-node types (from scratch) and supply a factory.
-<p>Like JDOM (except JDOM does not permit client to reimplement) and org.w3c.dom.
-<p>Pro: API as small as possible.
-<br>Pro: Easy to tailor different kinds of representation: read-write vs.
-read-only ASTs; raw ASTs vs. AST+bindings.
-<p>Con: Hidden concrete implementation classes takes more space.
-<br>Con: Using factory methods is a bit less direct than using constructors.
-<p>We will use API interfaces for bindings, and exposed API classes for
-AST nodes.
-<h3>
-API Design Issue: Statement vs. Statement Lists</h3>
-For structured statements, like while, the child statement is grammatically
-a single statement. However, since a block is one type of statement, it
-is possible to have a list of statements underneath. There are options
-for rendering this:
-<p>(1) Child is a single statement.
-<p>(Like current compiler's internal ASTs.)
-<p>Pro: As per the Java grammar.
-<br>Con: A client wanting to insert an additional statement into the child
-must be prepared to replace by a block if there isn't one.
-<p>(2) Child is a list of statements.
-<p>(Like the .net codeDOM.)
-<p>Pro: More convenient for clients that edit ASTs. Uniform mechanism for
-inserting and removing statements from child.
-<br>Con: Muddies scopes (enclosing braces around statements introduce a
-scope and make declarations syntactically legal).
-<p>We will go with (1) and stick closely to the grammar.
-<h3>
-Usage</h3>
-There are a couple different usage scenarios for ASTs:
-<ul>
-<li>
-Analyze an existing compilation unit to discover syntactic structure.</li>
-
-<li>
-Discover relationship between syntactic structure and original text.</li>
-
-<li>
-Discover relationship between syntactic structure and resolved world.</li>
-
-<li>
-Create a new compilation unit from scratch.</li>
-
-<li>
-Edit an existing compilation unit.</li>
-</ul>
-
-<h3>
-Source Construct Normalization</h3>
-
-<ul>
-<li>
-Most syntactic constructions are rendered in one and only one way.</li>
-
-<li>
-When this is not the case, the AST construction is "lossy".</li>
-
-<li>
-Some forms cannot be distinguised in input (if one cares).</li>
-
-<li>
-Some forms cannot be produced in output.</li>
-
-<li>
-Copying the construct normalizes it.</li>
-
-<li>
-Example: Modifier order</li>
-
-<ul>
-<li>
-final static public int X = 1;</li>
-
-<li>
-public static final int X = 1; // preferred form</li>
-</ul>
-
-<li>
-Example: Compound variable declarations</li>
-
-<ul>
-<li>
-int i = 1, j = 2;</li>
-
-<li>
-int i = 1; int j = 2; // preferred form</li>
-</ul>
-
-<li>
-Example: Array type declarators</li>
-
-<ul>
-<li>
-int[] x[];</li>
-
-<li>
-int[][] x; // preferred form</li>
-</ul>
-
-<li>
-Example: Short ifs</li>
-
-<ul>
-<li>
-if (a) f(); else ;</li>
-
-<li>
-if (a) f(); // preferred form</li>
-</ul>
-
-<li>
-Can only be done for syntactic nuances that are have no semantic import.</li>
-
-<li>
-Normalization is generally acceptable where unimportant syntactic nuances
-are involved.</li>
-
-<li>
-Normal form should follow JLS recommendations and Java coding standards.</li>
-
-<li>
-Note that parentheses and blocks are important to user and should not be
-normalized.</li>
-</ul>
-
-<h3>
-Source Positions</h3>
-
-<ul>
-<li>
-When AST is obtained by parsing a text string, exposing source ranges for
-nodes allows clients to navigate back into original string; e.g., for making
-text editor selections.</li>
-
-<li>
-AST supports only character-oriented position information; mapping character
-positions to lines are handled elsewhere (e.g., text editor).</li>
-
-<li>
-Source ranges are irrelevant for nodes created by other means.</li>
-
-<li>
-Source ranges give original position in original string.</li>
-
-<ul>
-<li>
-Editing the AST does not alter positions or anything clever.</li>
-</ul>
-
-<li>
-Most constructs occupy contiguous character positions, or ranges.</li>
-
-<li>
-Ranges are represented by 0-based start position and length.</li>
-
-<li>
-Start position begins at first significant character of construct corresponding
-to AST node.</li>
-
-<ul>
-<li>
-First significant character.</li>
-
-<li>
-Does not include leading whitespace.</li>
-
-<li>
-Does not include preceding comment (except the javadoc comment preceding
-a declaration, or the comment preceding a statement - see below).</li>
-</ul>
-
-<li>
-End position includes last significant character of construct corresponding
-to AST node.</li>
-
-<ul>
-<li>
-Last significant character.</li>
-
-<li>
-Includes trailing terminators that are part of construct; e.g., include
-trailing semicolon at end of local variable declaration.</li>
-
-<li>
-Does not include separators; e.g., exclude trailing comma in parameter
-list.</li>
-
-<li>
-Does not include trailing whitespace.</li>
-
-<li>
-Does not include trailing comment.</li>
-
-<li>
-Statement end-of-line comments are not encompassed by statement.</li>
-
-<ul>
-<li>
-<tt>System.out.println("hello"); // $non-nls$</tt></li>
-</ul>
-
-<li>
-<font color="#000000">Embedded comments are encompassed if they occur before
-end position.</font></li>
-
-<ul>
-<li>
-<tt><font color="#000000">System.out.println("hello") /* comment */;</font></tt></li>
-</ul>
-</ul>
-
-<li>
-Some node types would have source ranges for significant contiguous subconstructs
-not readily gleanable from source ranges of the subnodes.</li>
-
-<ul>
-<li>
-Additional source ranges would be specified for each node type.</li>
-
-<li>
-E.g., method declaration has additional source range for the method name
-and for the method declaration excluding its javadoc comment.</li>
-
-<li>
-Use start and length arrays rather than proliferate API methods for additional
-source ranges.</li>
-</ul>
-</ul>
-
-<h3>
-Unicode Escapes</h3>
-
-<ul>
-<li>
-Original source text might contain Unicode escapes (JLS 3.2, 3.3).</li>
-
-<li>
-E.g., void\u0040\u005a(); declares a method named Z.</li>
-
-<li>
-Scanner removes all Unicode escapes and returns a Unicode token stream.</li>
-
-<li>
-Newly created AST nodes are "post" Unicode escaping.</li>
-
-<li>
-Output options:</li>
-
-<ul>
-<li>
-Preserve existing Unicode escapes (default); remove all existing Unicode
-escapes.</li>
-
-<li>
-Do not introduce Unicode escapes (default); introduce Unicode escapes for
-characters in a specified set (e.g., all non-ASCII).</li>
-</ul>
-
-<li>
-Initial implementation: support default behavior only.</li>
-</ul>
-
-<h3>
-Comments</h3>
-
-<ul>
-<li>
-Comments are problematic for ASTs; these lexical items are normally filtered
-out of token stream.</li>
-
-<li>
-Comments are significant to user.</li>
-
-<li>
-Editing an existing compilation unit should generally preserve existing
-comments.</li>
-
-<li>
-Should be able to include comments for newly created subtrees.</li>
-
-<li>
-Copying a subtree from one place to another should include relevant comments.</li>
-
-<li>
-Most common forms of comments:</li>
-
-<ul>
-<li>
-Javadoc comments - on one or more lines preceding field, method, and type
-declarations.</li>
-
-<li>
-Boilerplace comments (copyright notices) - one or more lines preceding
-the package declaration, or between the package declaration and first import
-or type declaration.</li>
-
-<li>
-Statement comments - one or more lines between statements in a block.</li>
-
-<li>
-Statement end-of-line comments.</li>
-</ul>
-
-<li>
-VA/ST experience: not worth bending over backwards to accomodate all comments.</li>
-
-<li>
-Determined clients can rescan original string to get at all comments.</li>
-
-<li>
-Expose high value comments:</li>
-
-<li>
-Javadoc comments - treat as attribute of the field, method, and type declarations.</li>
-
-<ul>
-<li>
-Clients can extract Javadoc attributes (including @deprecated).</li>
-
-<li>
-Clients can create declarations with Javadoc.</li>
-</ul>
-
-<li>
-Statement comments within blocks</li>
-
-<ul>
-<li>
-Approach 1: Treat as pseudo-statements with a special AST node type.</li>
-
-<ul>
-<li>
-Pro: Clients can include comments with blocks.</li>
-
-<li>
-Con: Only works for comments within genuine blocks. E.g., can't handle</li>
-
-<li>
-<tt>if (test)</tt></li>
-
-<li>
-<tt> // should not happen</tt></li>
-
-<li>
-<tt> throw new RuntimeException();</tt></li>
-
-<li>
-Would work better if we were using statement lists in more places.</li>
-</ul>
-
-<li>
-Approach 2: Treat as a property of following statment node.</li>
-
-<ul>
-<li>
-Pro: Clients can include comments before any statement.</li>
-
-<li>
-Con: Does not handle trailing comments in blocks. E.g.,</li>
-
-<li>
-<tt>{</tt></li>
-
-<li>
-<tt> throw new RuntimeException();</tt></li>
-
-<li>
-<tt> // can't reach here</tt></li>
-
-<li>
-<tt>}</tt></li>
-</ul>
-
-<li>
-Recommend approach 2 since it covers most cases.</li>
-</ul>
-
-<li>
-Boilerplate comments would not be exposed, but would be preserved through
-edit and output.</li>
-</ul>
-
-<h3>
-Whitespace</h3>
-
-<ul>
-<li>
-Whitespace (JLS 3.6) includes ASCII SP, HT, and FF characters, and line
-terminators.</li>
-
-<li>
-Like comments, whitespace is significant to user.</li>
-
-<li>
-Editing an existing compilation unit should generally preserve whitespace.</li>
-
-<li>
-Whitespace for newly created subtrees automatically generated to produce
-output that follows common conventions and blends in with surrounding text
-(use the same leading whitespace).</li>
-
-<li>
-Copying a subtree from one place to another should should generally preserve
-whitespace.</li>
-</ul>
-
-<h3>
-AST Parent Backpointer</h3>
-
-<ul>
-<li>
-Each AST node will carry a backpointer to its parent node.</li>
-
-<li>
-ASTNode.getParent() returns ASTNode</li>
-
-<li>
-This permits clients to traverse ASTs in upward as well as downward direction.</li>
-
-<li>
-Bidirectional links must be maintained during editing.</li>
-
-<li>
-Deletion API must unlink child from parent.</li>
-
-<li>
-Insertion API must link child to parent.</li>
-
-<ul>
-<li>
-To preserve treeness, automatically clone child subtree if child already
-has parent.</li>
-</ul>
-
-<li>
-Replace API must unlink old child before inserting new child.</li>
-
-<li>
-Parent backlinks means that hanging on to <i>any</i> node in an AST instance
-will prevent any part of the AST instance from being garbage collected.</li>
-</ul>
-
-<h3>
-Multiple ASTs</h3>
-
-<ul>
-<li>
-Muliple ASTs can exist side by side (and ASTs are potentially for same
-compilation unit).</li>
-
-<li>
-Allow insertion of nodes from one AST into another AST.</li>
-
-<ul>
-<li>
-Automatically clones child subtree (forgetting source positions and binding
-decorations).</li>
-
-<li>
-Ensure memory representation of ASTs remain completely independent.</li>
-</ul>
-</ul>
-
-<h3>
-<font color="#3366FF">Structural Equality</font></h3>
-
-<ul>
-<li>
-<font color="#3366FF">Structural equality predicate on AST nodes.</font></li>
-
-<li>
-<font color="#3366FF">Isomorphic subtrees.</font></li>
-
-<li>
-<font color="#3366FF">Belonging to same or different AST.</font></li>
-
-<li>
-<font color="#3366FF">Considers structural info only; ignores source positions,
-bindings, etc.</font></li>
-
-<li>
-<font color="#3366FF">Named something other than "equals" to avoid having
-to reimplement hashCode too.</font></li>
-</ul>
-
-<h3>
-Syntactic Correctness of Parser-built ASTs</h3>
-
-<ul>
-<li>
-For ASTs built by a Java parser, there are issues of syntactic correctness.</li>
-
-<li>
-Syntactic correctness is judged by the Syntactic Grammar (as defined in
-JLS2 section 2.3).</li>
-
-<li>
-Java parser <b>must</b> guarantee to produce a faithful AST for any syntactically
-correct compilation unit.</li>
-
-<li>
-Java parser <b>may</b> also build ASTs for syntactically incorrect compilation
-units.</li>
-
-<li>
-Complicant Java compilers must reject syntactically incorrect compilation
-units.</li>
-
-<li>
-What principle do we apply to Java parsers and the ASTs they return?</li>
-
-<li>
-Real Java parsers are invariably more liberal than the Syntactic Grammar,
-and rely on post-parse checks to report errors for any syntactically incorrect
-constructs that makes it past the parser.</li>
-
-<ul>
-<li>
-E.g., conflicting modifiers: public private</li>
-
-<li>
-E.g., field declared with no initializer occurs in an interface</li>
-
-<li>
-E.g., void foo() [];</li>
-</ul>
-
-<li>
-In the current Eclipse compiler, many of these checks are done in the course
-of type and name resolution. If client only wants AST, we want to avoid
-doing expensive name and type analysis.</li>
-
-<li>
-Approach 1: Guarantee that no ASTs are built for syntactically incorrect
-compilation units.</li>
-
-<ul>
-<li>
-You do not get an AST at all for compilation units with syntax errors.</li>
-
-<li>
-Pro: Client can trust parser to distinguish syntactically correct from
-incorrect.</li>
-
-<li>
-Con: Client cannot manipulate syntactically incorrect compilation units
-at all.</li>
-
-<li>
-Con: Requires post-parse check to detect residual syntax errors.</li>
-</ul>
-
-<li>
-Approach 2: Provide no guarantee about the ASTs for syntactically incorrect
-compilation units.</li>
-
-<ul>
-<li>
-You might not get a useful AST at all.</li>
-
-<li>
-You might get an AST that had pieces missing; e.g., a malformed method
-was excised</li>
-
-<li>
-You might get an AST that is incoherent or self-contradictory; e.g., a
-transient class!?</li>
-
-<li>
-Pro: Maximum flexibility for implementation.</li>
-
-<li>
-Pro: Client can get useful ASTs for some syntactically incorrect programs.</li>
-
-<li>
-Con: Client cannot trust parser to distinguish syntactically correct from
-incorrect.</li>
-</ul>
-
-<li>
-Approach 3: Guarantee that the client examining the resulting AST has some
-way to determine whether the compilation units is incorrect.</li>
-
-<ul>
-<li>
-Priniciple: Syntactic errors must not be suppressed.</li>
-
-<li>
-AST nodes could carry flags indicating certain syntax problem; e.g., duplicate
-modifiers public public</li>
-
-<li>
-A bit on root node could say "unspecified syntax errors".</li>
-
-<li>
-Could be special AST nodes types indicating major problems; e.g., bogus
-method body</li>
-
-<li>
-Could be representable configurations of AST node types that are recognizable
-as syntactially incorrect; e.g., conflicting modifiers public private;
-missing field initializer in interface</li>
-
-<li>
-Pro: Client can trust parser to not hide any syntax errors that are in
-the source.</li>
-
-<li>
-Pro: Client can get useful ASTs for syntactically incorrect programs.</li>
-
-<li>
-Con: Client must do extra work to determine whether there are syntax errors.</li>
-
-<li>
-Con: Extra work to include this information if no client really cares about
-the difference between syntactically correct and incorrect.</li>
-</ul>
-
-<li>
-The first approach is too harsh. It is much more reasonable, and interesting,
-to be able to work with some syntactically incorrect compilation units.</li>
-
-<li>
-The second approach feels reasonable if clients never care whether the
-source is syntactically correct or not.</li>
-
-<li>
-The third approach feels reasonable if some clients would care whether
-the source is syntactically correct or not.</li>
-
-<li>
-The principle difference between the second and third appoaches is that
-the former sanctions quietly suppressing syntax errors whereas the latter
-precludes it.</li>
-
-<li>
-The nature of the AST nodes inherently makes room to express a wide range
-of syntactically malformed programs.</li>
-
-<li>
-An extra flag per node for "unspecified syntax errors" should cover the
-bases.</li>
-
-<li>
-The existing compiler's ASTs already carry enough information to enable
-the compiler to do thorough post-parse detecting of residual syntax errors.</li>
-
-<li>
-Therefore the third approach is within easy reach.</li>
-
-<li>
-The third approach gives clients more than the second approach.</li>
-
-<li>
-Recommendation: we adopt the third approach.</li>
-</ul>
-
-<h3>
-Syntactic Correctness of Non-parser-built ASTs</h3>
-
-<ul>
-<li>
-ASTs do not just come from a parser.</li>
-
-<ul>
-<li>
-They can be created from scratch.</li>
-
-<li>
-A parser-build AST can be edited.</li>
-</ul>
-
-<li>
-These ASTs will need to be serialized to a source compilation unit (why
-else would they exist?).</li>
-
-<li>
-What kinds of support and guarantees are in place to ensure that such a
-suitable source compilation unit can be generated?</li>
-
-<li>
-Basic guarantee: any AST that could have come from parsing a syntactically
-correct compilation unit will serialize to a compilation unit that is</li>
-
-<ul>
-<li>
-(a) syntactically correct</li>
-
-<li>
-(b) strongly semantically equivalent to the original compilation unit.</li>
-
-<li>
-and possibly (c) normalized; that is, parse(serialize(x)) is isomorphic
-to x</li>
-</ul>
-
-<li>
-There are likely many ways to get ASTs that do not correspond to any syntactically
-correct compilation unit.</li>
-
-<ul>
-<li>
-E.g., use illegal identifiers ("1abc" or "try" or "//").</li>
-
-<li>
-E.g., use illegal modifier combinations with modifier bit masks.</li>
-</ul>
-
-<li>
-Post-screening the AST for syntactic correctness would be misguided.</li>
-
-<li>
-Should just go ahead and generate the obvious, syntactically incorrect,
-compilation unit.</li>
-
-<li>
-More importantly: ensure semantic equivalence.</li>
-
-<li>
-Operator precedence creates issues:</li>
-
-<ul>
-<li>
-E.g., given AST for expression <tt>v1*v2</tt>, replace <tt>v1</tt> node
-by expression <tt>v1+v3</tt>.</li>
-
-<li>
-Naive serialization yields <tt>v1+v3*v2</tt> which is not semantically
-equivalent to the AST.</li>
-
-<li>
-Result should be (<tt>v1+v3)*v2</tt>.</li>
-
-<li>
-Parentheses may need to be introduced during serialization.</li>
-</ul>
-
-<li>
-Nested if statement creates issues:</li>
-
-<ul>
-<li>
-E.g., given AST for statement <tt>if (a) f(); else g();</tt>, replace <tt>f();</tt>
-by <tt>if (b) h();</tt></li>
-
-<li>
-Naive serialization yields <tt>if (a) if (b) h(); else g();</tt></li>
-
-<li>
-Result should be <tt>if (a) if (b) h(); <b>else </b>; else g();</tt></li>
-
-<li>
-Extra verbiage may need to be introduced during serialization.</li>
-</ul>
-</ul>
-
-<h3>
-Deep Constructs</h3>
-
-<ul>
-<li>
-Some programs involve impossibly deep constructs.</li>
-
-<li>
-Multi-line string concatenation expressions are the main offender.</li>
-
-<ul>
-<li>
-For example, <tt>"Line 1\\n"+"Line 2\\n"+...+"Line 5000"</tt></li>
-</ul>
-
-<li>
-Runtime stacks blow when recursing over deep ASTs.</li>
-
-<li>
-AST node types should be designed to keep trees reasonably shallow for
-reasonably typical programs.</li>
-
-<li>
-Introduce N-ary operator expression node type to deal with multi-line string
-concatenation expressions.</li>
-
-<li>
-N.B. Current compiler performs compile-time concatenations during parse
-phase to deal with this problem.</li>
-</ul>
-
-<h3>
-Editing Protocol</h3>
-
-<ul>
-<li>
-What general form should the editing API take?</li>
-
-<li>
-Setters on receiver to manipulate its children (parent never affected)</li>
-
-<ul>
-<li>
-E.g., whileStatement.setCondition(newExpression)</li>
-
-<li>
-Use null for optional children</li>
-</ul>
-
-<li>
-Treat lists as an array-valued property.</li>
-
-<ul>
-<li>
-E.g., block.getStatements() returns Statement[]</li>
-
-<li>
-E.g., block.setStatements(Statement[] statements)</li>
-
-<li>
-Use empty list for no children (rather than null)</li>
-</ul>
-
-<li>
-Alternative approach for lists: use Collection-like protocol</li>
-
-<ul>
-<li>
-E.g., block.addStatement(pos, newChildStatement)</li>
-
-<li>
-E.g., block.removeStatement(oldChildStatement)</li>
-
-<li>
-Con: Increased number of methods on API; bad when a node type has several
-list properties.</li>
-</ul>
-
-<li>
-Alternative approach for delete/replace: use parent backpointers to implement
-generic delete and replace operation which affect the receiver's relationship
-to its parent</li>
-
-<ul>
-<li>
-E.g., oldChildStatement.delete()</li>
-
-<li>
-Con: semantics of deletion ugly when node occurs outside of any list</li>
-</ul>
-</ul>
-
-<h3>
-User Data Field</h3>
-
-<ul>
-<li>
-Each AST node has a user data slot reserved for client use.</li>
-
-<li>
-ASTNode.getClientData() returns Object</li>
-
-<li>
-ASTNode.setClientData(Object data)</li>
-
-<li>
-The initial value is null.</li>
-
-<li>
-Client may use for decorations, or whatever.</li>
-
-<li>
-AST nodes created by parser carry no data initially.</li>
-
-<li>
-AST nodes created explicitly carry no data initially.</li>
-
-<li>
-Even read-only ASTs have read-write data slots.</li>
-
-<li>
-Cloning an AST node creates a new node (does <b>not</b> copy or clone data).</li>
-</ul>
-
-<h3>
-Lists of Members</h3>
-
-<ul>
-<li>
-List of field, method, and type members of a type declaration.</li>
-
-<li>
-This list is syntactically and semantically heterogenous.</li>
-
-<li>
-No syntactic constraints on number and order.</li>
-
-<li>
-Order is significant to user.</li>
-
-<li>
-Within field declarations, relative order is semantically significant.</li>
-
-<li>
-Standard practices:</li>
-
-<ul>
-<li>
-Place field declarations before member methods and types.</li>
-
-<li>
-Place types before methods.</li>
-</ul>
-
-<li>
-Option (1): expose separate lists for field, methods, and types.</li>
-
-<li>
-Pro: This is way internal AST works.</li>
-
-<li>
-Pro: Convenient for clients to locate member fields, methods, and types.</li>
-
-<li>
-Con: Not flexible for editing; editing will mangle member order.</li>
-
-<li>
-Option (2): expose a single list of members</li>
-
-<li>
-Pro: parser does not normalize; client controls order of members.</li>
-
-<li>
-Con: More work for clients to locate member fields, methods, and types.</li>
-
-<li>
-Option (3): expose a single list of members, with extra getters for locating
-member fields, methods, and types.</li>
-
-<li>
-Pro: Combines advantage of (2) with convenience of (1).</li>
-
-<li>
-Recommended approach: (3).</li>
-
-<li>
-For class declarations, treat initializers and constructors as members.</li>
-
-<ul>
-<li>
-Lump instance and static initializers in with field declarations.</li>
-
-<li>
-Lump constructor declarations in with method declarations.</li>
-</ul>
-</ul>
-
-<h3>
-Serialization</h3>
-
-<ul>
-<li>
-Clients of read-write ASTs will generally want to serialize to a Java compilation
-unit.</li>
-
-<li>
-Serialization via simple AST tree walk.</li>
-
-<ul>
-<li>
-Straightforward.</li>
-
-<li>
-Introduce line breaks and whitespace to make it look pretty.</li>
-
-<li>
-Or post-process it with the Java formatter.</li>
-
-<li>
-If AST originated by parsing, the result is likely unacceptable to user:</li>
-
-<ul>
-<li>
-Completely reformatted.</li>
-
-<li>
-Constructs are normalized.</li>
-
-<li>
-Some comments may have be lost.</li>
-</ul>
-
-<li>
-Could be provided by API that makes use of regular AST API only.</li>
-
-<li>
-Could be written by clients.</li>
-</ul>
-
-<li>
-Serialization via source reconstruction.</li>
-
-<ul>
-<li>
-Only applicable to ASTs initially constructed by parser.</li>
-
-<li>
-Use source position information in modified AST to reconstruct compilation
-unit.</li>
-
-<li>
-Retain passages of original text corresponding to unchanged AST trees.</li>
-
-<li>
-Generates new text only where required.</li>
-
-<li>
-Produce a result that a user will recognize and accept.</li>
-
-<ul>
-<li>
-Preserve formatting wherever possible.</li>
-
-<li>
-Preserve source construct normalization wherever possible.</li>
-
-<li>
-Preserve arbitrarily-placed comments wherever possible.</li>
-</ul>
-
-<li>
-Requires retaining the original compilation unit, and likely recording
-additional information in nodes to allow reconstruction.</li>
-
-<li>
-This is the way the current JDOM implementation works.</li>
-
-<li>
-Could be provided by API that has privileged access to AST nodes and parser-recorded
-information.</li>
-
-<li>
-Should also return a list of edit instructions so that markers can be adjusted,
-etc.</li>
-
-<li>
-Clients would have a hard time doing this themselves.</li>
-</ul>
-
-<li>
-<font color="#000000">Recommend deferring implementation of serializer
-that does source reconstruction.</font></li>
-
-<ul>
-<li>
-<font color="#000000">In interim, refactoring can apply edits to original
-compilation unit text directly.</font></li>
-</ul>
-</ul>
-
-<h3>
-Node types</h3>
-The AST node types are based on the standard grammar for the Java language
-given in the JLS2.
-<p>Every AST node belongs to a single AST instance. (In DOM terminology,
-the AST is the document and the AST nodes are the elements). The AST instance
-can serve as a factory for creating new nodes. Nodes point to their owning
-AST (fixed for the node's lifetime). The AST points directly to the root
-node (a compilation unit).
-<p>The AST node types do not define their own notion of equality; they
-just inherit the object identity based implementation from Object.
-<p>Note: Grammar rules (in comments) are expressed in the Pascal-style
-extended BNF used in <tt>section 18</tt> of JLS2. We use C# style property
-declarations as a convenient abbreviation for a standard matched pair of
-get and set methods.
-<p><tt>public class AST</tt>
-<br><tt> public AST();</tt>
-<br><tt> public property CompilationUnit root;</tt>
-<br><tt> public void loadFromSource(char[] source);</tt>
-<br><tt> public void setOptions(...);</tt>
-<br><tt> public char[] serialize();</tt>
-<p><tt>public abstract class ASTNode</tt>
-<br><tt> protected ASTNode(AST ast);</tt>
-<br><tt> public AST getOwner();</tt>
-<br><tt> public property int[] startPositions;</tt>
-<br><tt> public property int[] lengths;</tt>
-<br><tt> public property boolean isWholeLine;</tt>
-<br><tt> public property Object clientData;</tt>
-<br><tt> public ASTNode getParent();</tt>
-<br><tt> ... other protocol common to all AST node types</tt>
-<h4>
-Names</h4>
-As explained in JLS2 section 6.5, the grammar does not allow names to be
-resolved more finely than the following 6 categories by syntactic means
-alone:
-<p><tt>PackageName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-PackageName . Identifier</tt>
-<br><tt>TypeName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-PackageOrTypeName . Identifier</tt>
-<p><tt>ExpressionName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-AmbiguousName . Identifier</tt>
-<p><tt>MethodName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-AmbiguousName . Identifier</tt>
-<p><tt>PackageOrTypeName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-PackageOrTypeName . Identifier</tt>
-<p><tt>AmbiguousName:</tt>
-<br><tt>
-Identifier</tt>
-<br><tt>
-AmbiguousName . Identifier</tt>
-<p>Given that names cannot be resolved definitively to a package, type,
-field, or variable at AST node construction time, an open question is how
-much of the categorization that could be done should be reflected in the
-AST. More categories means more information flow from the parser to the
-AST client; on the other hand, a variety of categories is not necessarily
-convenient for clients. For example, in <tt>import a.b.c</tt> the name
-is a <tt>TypeName</tt> whereas in <tt>import a.b.c.*</tt> the name <tt>a.b.c</tt>
-is a <tt>PackageOrTypeName</tt>. If the name category was to be reflected
-in the type of the AST nodes, the client would need to know to create the
-appropriate type of name nodes when editing the AST.
-<p>Proposal: Use two AST node types for names: simple names, and qualified
-names. Qualified names are expressed recursively, to facilitate clients
-discovering how the qualifier part of a name resolves. Use these for everything
-but <tt>MethodName</tt>; for <tt>MethodName</tt>, which can appear only
-in a method invocation expression, separate the selector identifier from
-any preceding qualifier.
-<p>(Note: The current internal AST nodes go beyond making the simple/qualified
-distinction: they also have simple & qualified type names (classes
-<tt>SimpleTypeReference</tt>
-and <tt>QualifiedTypeReference</tt>) in additional to simple & qualified
-named (classes <tt>SimpleNameReference</tt> and
-<tt>QualifiedNameReference</tt>).)
-<p><tt>// Name:</tt>
-<br><tt>//
-SimpleName</tt>
-<br><tt>//
-QualifiedName</tt>
-<br><tt>// SimpleName:</tt>
-<br><tt>//
-Identifier</tt>
-<br><tt>// QualifiedName:</tt>
-<br><tt>//
-Name <b><u>.</u></b> Identifier</tt>
-<br><tt>public interface IName // "marker" interface</tt>
-<br><tt> public IBinding resolvedBinding(); //
-optional</tt>
-<p><tt>public class SimpleName extends ASTNode implements IName, IExpression</tt>
-<br><tt> public SimpleName(AST ast);</tt>
-<br><tt> public property char[] identifier;</tt>
-<p><tt>public class QualifiedName extends ASTNode implements IName, IExpression</tt>
-<br><tt> public QualifiedName(AST ast);</tt>
-<br><tt> public property IName qualifier;</tt>
-<br><tt> public property char[] identifier;</tt>
-<h3>
-Compilation Units and Major Declarations</h3>
-<tt>// CompilationUnit:</tt>
-<br><tt>//
-[<b><u>package</u></b> Identifier { <b><u>.</u></b> Identifier } <b><u>;</u></b>
-]</tt>
-<br><tt>//
-{ImportDeclaration}</tt>
-<br><tt>//
-{TypeDeclaration | <b><u>;</u></b>}</tt>
-<br><tt>public class CompilationUnit extends ASTNode</tt>
-<br><tt> public CompilationUnit(AST ast);</tt>
-<br><tt> public property Name packageName; // optional</tt>
-<br><tt> public property ImportDeclaration[] imports;</tt>
-<br><tt> public property TypeDeclaration[] types;</tt>
-<p><tt>// ImportDeclaration:</tt>
-<br><tt>// <b><u>import</u></b>
-Identifier { <b><u>.</u></b> Identifier } [ <b><u>.</u></b> <b><u>*</u></b>
-]
-<b><u>;</u></b></tt>
-<br><tt>public class ImportDeclaration extends ASTNode</tt>
-<br><tt> public ImportDeclaration(AST ast);</tt>
-<br><tt> public property Name importName;</tt>
-<br><tt> public property boolean onDemand;</tt>
-<br><tt> public IBinding resolveBinding();</tt>
-<p><tt>// TypeDeclaration:</tt>
-<br><tt>//
-{Modifier} <b><u>class</u></b> Identifier</tt>
-<br><tt>//
-[<b><u>extends</u></b> Type]</tt>
-<br><tt>//
-[<b><u>implements</u></b> Type { <b><u>,</u></b> Type}]</tt>
-<br><tt>//
-<b><u>{</u></b> {ClassBodyDeclaration | <b><u>;</u></b> } <b><u>}</u></b></tt>
-<br><tt>//
-{Modifier} <b><u>interface</u></b> Identifier</tt>
-<br><tt>//
-[<b><u>extends</u></b> Type { <b><u>,</u></b> Type}]</tt>
-<br><tt>//
-<b><u>{</u></b> {InterfaceBodyDeclaration | <b><u>;</u></b> } <b><u>}</u></b></tt>
-<br><tt>// Modifier:</tt>
-<br><tt>// <b><u>public</u></b></tt>
-<br><tt>// <b><u>protected</u></b></tt>
-<br><tt>// <b><u>private</u></b></tt>
-<br><tt>// <b><u>static</u></b></tt>
-<br><tt>// <b><u>abstract</u></b></tt>
-<br><tt>// <b><u>final</u></b></tt>
-<br><tt>// <b><u>native</u></b></tt>
-<br><tt>// <b><u>synchronized</u></b></tt>
-<br><tt>// <b><u>transient</u></b></tt>
-<br><tt>// <b><u>volatile</u></b></tt>
-<br><tt>// <b><u>strictfp</u></b></tt>
-<br><tt>// ClassBodyDeclaration:</tt>
-<br><tt>//
-MethodDeclaration</tt>
-<br><tt>//
-ConstructorDeclaration</tt>
-<br><tt>//
-FieldDeclaration</tt>
-<br><tt>//
-ClassDeclaration</tt>
-<br><tt>//
-TypeDeclaration</tt>
-<br><tt>//
-Initializer</tt>
-<br><tt>// InterfaceBodyDeclaration:</tt>
-<br><tt>//
-MethodDeclaration</tt>
-<br><tt>//
-FieldDeclaration</tt>
-<br><tt>//
-TypeDeclaration</tt>
-<br><tt>public class TypeDeclaration extends ASTNode implements IStatement,
-IMember</tt>
-<br><tt> public TypeDeclaration(AST ast);</tt>
-<br><tt> public property int modifiers;</tt>
-<br><tt> public property char[] name;</tt>
-<br><tt> public property Name superclass; // optional</tt>
-<br><tt> public property Name[] superInterfaces;</tt>
-<br><tt> public property IMember[] members;</tt>
-<br><tt> public property char[][] javadocComment; //
-optional</tt>
-<br><tt> // convenience methods</tt>
-<br><tt> public FieldDeclaration[] getFields; // includes
-constants; excludes initializers</tt>
-<br><tt> public AbstractMethodDeclaration[] getMethods;
-// includes constructors</tt>
-<br><tt> public TypeDeclaration[] getTypes;</tt>
-<br><tt> public ITypeBinding resolveBinding();</tt>
-<p><tt>// MethodDeclaration:</tt>
-<br><tt>//
-{Modifier} (Type | <b><u>void</u></b>) Identifier <b><u>(</u></b></tt>
-<br><tt>//
-[FormalParameter { <b><u>,</u></b> FormalParameter}] <b><u>)</u></b>
-{<b><u>[</u></b> <b><u>]</u></b>}</tt>
-<br><tt>//
-[<b><u>throws</u></b> QualifiedIdentifierList] ( MethodBody | <b><u>;</u></b>
-)</tt>
-<br><tt>// ConstructorDeclaration:</tt>
-<br><tt>//
-{Modifier} Identifier <b><u>(</u></b> [FormalParameter { <b><u>,</u></b>
-FormalParameter}] <b><u>)</u></b></tt>
-<br><tt>//
-[<b><u>throws</u></b> QualifiedIdentifierList] MethodBody</tt>
-<br><tt>// FormalParameter:</tt>
-<br><tt>//
-[<b><u>final</u></b>] Type Identifier {<b><u>[</u></b> <b><u>]</u></b>}</tt>
-<br><tt>public abstract class AbstractMethodDeclaration extends ASTNode
-implements IMember</tt>
-<br><tt> protected AbstractMethodDeclaration(AST ast);</tt>
-<br><tt> public property int modifiers;</tt>
-<br><tt> public property char[] selector;</tt>
-<br><tt> public property FormalParameter[] parameters;</tt>
-<br><tt> public property Name[] thrownExceptions;</tt>
-<br><tt> public property char[][] javadocComment; //
-optional</tt>
-<br><tt> public property Block body; // optional</tt>
-<br><tt> public IMethodBinding resolveBinding();</tt>
-<p><tt>public class MethodDeclaration extends AbstractMethodDeclaration</tt>
-<br><tt> public MethodDeclaration(AST ast);</tt>
-<br><tt> public property Type returnType; // includes
-void</tt>
-<p><tt>public class ConstructorDeclaration extends AbstractMethodDeclaration</tt>
-<br><tt> public ConstructorDeclaration(AST ast);</tt>
-<p><tt>// FieldDeclaration:</tt>
-<br><tt>//
-{Modifier} Type Identifier {<b><u>[</u></b> <b><u>]</u></b>} [ <b><u>=</u></b>
-Expression]</tt>
-<br><tt>//
-{ <b><u>,</u></b> Identifier {<b><u>[</u></b> <b><u>]</u></b>} [ <b><u>=</u></b>
-Expression] }</tt>
-<br><tt>public class FieldDeclaration extends ASTNode implements IMember</tt>
-<br><tt> public AbstractMethodDeclaration(AST ast);</tt>
-<br><tt> public property int modifiers;</tt>
-<br><tt> public property char[] name;</tt>
-<br><tt> public property Type type;</tt>
-<br><tt> public property char[][] javadocComment; //
-optional</tt>
-<br><tt> public property IExpression initializer; //
-optional</tt>
-<br><tt> public IFieldBinding resolveBinding();</tt>
-<p><tt>// Initializer:</tt>
-<br><tt>//
-[<b><u>static</u></b>] Block</tt>
-<br><tt>public final class Initializer extends ASTNode implements IMember</tt>
-<br><tt> public Initializer(AST ast);</tt>
-<br><tt> public property int modifiers;</tt>
-<br><tt> public property Block body;</tt>
-<p><tt>// LocalVariableDeclaration:</tt>
-<br><tt>//
-[<b><u>final</u></b>] Type Identifier {<b><u>[]</u></b>} [ <b><u>=</u></b>
-Expression ]</tt>
-<br><tt>//
-{ <b><u>,</u></b> Identifier {<b><u>[]</u></b>} [ <b><u>=</u></b> Expression]
-} <b><u>;</u></b></tt>
-<br><tt>public class LocalVariableDeclaration extends ASTNode implements
-IStatement</tt>
-<br><tt> public LocalVariableDeclaration(AST ast);</tt>
-<br><tt> public property int modifiers;</tt>
-<br><tt> public property char[] name;</tt>
-<br><tt> public property Type type;</tt>
-<br><tt> public property IExpression initializer; //
-optional</tt>
-<br><tt> public ILocalVariableBinding resolveBinding();</tt>
-<br>
-<h4>
-Types</h4>
-The Type node (= TypeReference) represents a reference to a base type,
-a named type, or an array thereof.
-<p><tt>// Type:</tt>
-<br><tt>//
-(BasicType | TypeName ) {<b><u>[]</u></b>}</tt>
-<br><tt>// BasicType:</tt>
-<br><tt>// <b><u>byte</u></b></tt>
-<br><tt>// <b><u>short</u></b></tt>
-<br><tt>// <b><u>char</u></b></tt>
-<br><tt>// <b><u>int</u></b></tt>
-<br><tt>// <b><u>long</u></b></tt>
-<br><tt>// <b><u>float</u></b></tt>
-<br><tt>// <b><u>double</u></b></tt>
-<br><tt>// <b><u>boolean</u></b></tt>
-<br><tt>public class Type extends ASTNode implements IExpression</tt>
-<br><tt> public Type (AST ast);</tt>
-<br><tt> public property int baseType; // either</tt>
-<br><tt> public property Name typeName; // or</tt>
-<br><tt> public property int dimensions;</tt>
-<br><tt> public IBinding resolvedType();</tt>
-<h4>
-Statements</h4>
-There is a different AST node type for each different kind of statement.
-Use a "marker" interface (<tt>IStatement</tt>) to bring all constructs
-that can appear within a block (nonterminal <tt>BlockStatement</tt>, which
-includes local variable and type declarations).
-<p><tt>// Block:</tt>
-<br><tt>// <b><u>{</u></b>
-BlockStatement <b><u>}</u></b></tt>
-<br><tt>// BlockStatement :</tt>
-<br><tt>// LocalVariableDeclaration</tt>
-<br><tt>// TypeDeclaration</tt>
-<br><tt>// [Identifier
-<b><u>:</u></b>
-] Statement</tt>
-<br><tt>//Statement:</tt>
-<br><tt>// Block</tt>
-<br><tt>// <b><u>if
-(</u></b>Expression <b><u>)</u></b> Statement [<b><u>else</u></b> Statement]</tt>
-<br><tt>// <b><u>for
-(</u></b> ForInitOpt <b><u>;</u></b> [Expression]
-<b><u>;</u></b>
-ForUpdateOpt <b><u>)</u></b> Statement</tt>
-<br><tt>// <b><u>while
-(</u></b> Expression <b><u>)</u></b> Statement</tt>
-<br><tt>// <b><u>do</u></b>
-Statement <b><u>while</u></b> <b><u>(</u></b> Expression
-<b><u>);</u></b></tt>
-<br><tt>// <b><u>try</u></b>
-Block [Catches] [ <b><u>finally</u></b> Block ]</tt>
-<br><tt>// <b><u>switch
-(</u></b> Expression <b><u>)</u></b> <b><u>{</u></b> SwitchBlockStatementGroups
-<b><u>}</u></b></tt>
-<br><tt>// <b><u>synchronized
-(</u></b> Expression <b><u>)</u></b> Block</tt>
-<br><tt>// <b><u>return</u></b>
-[Expression] <b><u>;</u></b></tt>
-<br><tt>// <b><u>throw</u></b>
-Expression <b><u>;</u></b></tt>
-<br><tt>// <b><u>break</u></b>
-[Identifier] <b><u>;</u></b></tt>
-<br><tt>// <b><u>continue</u></b>
-[Identifier] <b><u>;</u></b></tt>
-<br><tt>// <b><u>;</u></b></tt>
-<br><tt>// ExpressionStatement</tt>
-<br><tt>// Identifier
-<b><u>:</u></b>
-Statement</tt>
-<br><tt>public interface IStatement // "marker" interface</tt>
-<p><tt>public class Block extends ASTNode implements IStatement</tt>
-<br><tt> public Block(AST ast);</tt>
-<br><tt> public property IStatement[] statements;</tt>
-<br><tt>public class IfStatement extends ASTNode implements IStatement</tt>
-<br><tt> public IfStatement(AST ast);</tt>
-<br><tt> public property IExpression test;</tt>
-<br><tt> public property IStatement thenPart;</tt>
-<br><tt> public property IStatement elsePart; //
-optional</tt>
-<br><tt>public class WhileStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class ForStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class DoStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class TryStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class SwitchStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class SynchronizedStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class ReturnStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class ThrowStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class BreakStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class ContinueStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class NullStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class LabeledStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<br><tt>public class AssertStatement extends ASTNode implements IStatement</tt>
-<br><tt> ...</tt>
-<h4>
-<font color="#000000">Expression Statements</font></h4>
-<font color="#000000">Certain types of expressions can also appear as statements.
-The ExpressionStatement node wraps an expression up as a statement. The
-source range for the ExpressionStatement includes the trailing semicolon.</font><font color="#000000"></font>
-<p><tt><font color="#000000">public class ExpressionStatement extends ASTNode
-implements IStatement</font></tt>
-<br><tt><font color="#000000"> public ExpressionStatement(AST
-ast);</font></tt>
-<br><tt><font color="#000000"> public property IExpression
-expression;</font></tt>
-<h4>
-Expressions</h4>
-There is a different AST node type for each different kind of expression.
-Use a "marker" interface (<tt>IExpression</tt>) to bring all constructs
-that can appear as expressions.
-<p>(Many details TBD).
-<p><tt>// Expression:</tt>
-<br><tt>//
-Identifier</tt>
-<br><tt>//
-ArrayAllocationExpression</tt>
-<br><tt>//
-StringLiteral</tt>
-<br><tt>//
-FloatingPointLiteral</tt>
-<br><tt>//
-BooleanLiteral</tt>
-<br><tt>//
-CharacterLiteral</tt>
-<br><tt>//
-StringLiteral</tt>
-<br><tt>//
-NullLiteral</tt>
-<br><tt>//
-( Type | <b><u>void</u></b> ) <b><u>.</u></b> class</tt>
-<br><tt>//
-[ ClassName <b><u>.</u></b> ] <b><u>this</u></b></tt>
-<br><tt>// <b><u>(</u></b>
-Expression <b><u>)</u></b></tt>
-<br><tt>//
-[ Expression <b><u>.</u></b> ] <b><u>new</u></b> Type <b><u>(</u></b></tt>
-<br><tt>//
-[ Expression { <b><u>,</u></b> Expression } ] <b><u>)</u></b> [ ClassBody
-]</tt>
-<br><tt>//
-Expression <b><u>.</u></b> Identifier</tt>
-<br><tt>//
-[ ClassName <b><u>.</u></b> ] <b><u>super .</u></b> Identifier</tt>
-<br><tt>//
-MethodName <b>(</b> [ Expression { <b><u>,</u></b> Expression } ] <b><u>)</u></b></tt>
-<br><tt>//
-Expression <b><u>.</u></b> Identifier <b>(</b> [ Expression { <b><u>,</u></b>
-Expression } ] <b><u>)</u></b></tt>
-<br><tt>//
-[ ClassName <b><u>.</u></b> ] <b><u>super .</u></b> Identifier <b>(</b></tt>
-<br><tt>//
-[ Expression { <b><u>,</u></b> Expression } ] <b><u>)</u></b></tt>
-<br><tt>//
-Expression <b><u>[</u></b> Expression <b><u>]</u></b></tt>
-<br><tt>//
-Expression InfixOperator Expression</tt>
-<br><tt>//
-Expression <b><u>instanceof</u></b> Type</tt>
-<br><tt>//
-Expression PostfixOperator</tt>
-<br><tt>//
-PrefixOperator Expression</tt>
-<br><tt>// <b><u>(</u></b>
-Type <b><u>)</u></b> Expression</tt>
-<br><tt>//
-Expression <b><u>?</u></b> Expression <b><u>:</u></b> Expression</tt>
-<br><tt>//
-Expression AssignmentOperator Expression</tt>
-<br><tt>// ArrayInitializer</tt>
-<br><tt>public interface IExpression // "marker" interface</tt>
-<br><tt> public IBinding resolvedType(); // optional</tt>
-<p><tt>// ArrayAllocationExpression:</tt>
-<br><tt>// <b><u>new</u></b>
-PrimitiveType <b><u>[</u></b> Expression <b><u>]</u></b> { <b><u>[</u></b>
-Expression <b><u>]</u></b> } { <b><u>[</u></b> <b><u>]</u></b> }</tt>
-<br><tt>// <b><u>new</u></b>
-TypeName <b><u>[</u></b> Expression <b><u>]</u></b> {
-<b><u>[</u></b> Expression
-<b><u>]</u></b>
-} { <b><u>[</u></b> <b><u>]</u></b> }</tt>
-<br><tt>// <b><u>new</u></b>
-PrimitiveType <b><u>[</u></b> <b><u>]</u></b> { <b><u>[]</u></b> } ArrayInitializer</tt>
-<br><tt>// <b><u>new</u></b>
-TypeName <b><u>[</u></b> <b><u>]</u></b> { <b><u>[]</u></b> } ArrayInitializer</tt>
-<br><tt>public class ArrayAllocationExpression</tt>
-<br><tt> extends ASTNode implements IExpression</tt>
-<br><tt> public ArrayAllocationExpression(AST ast);</tt>
-<br><tt> public property Type type;</tt>
-<br><tt> public property Expression[] dimensions; //
-optional</tt>
-<br><tt> public property Expression arrayInitializer;
-// optional</tt>
-<p><tt>public class StringLiteral extends ASTNode implements IExpression</tt>
-<br><tt> public StringLiteral(AST ast);</tt>
-<br><tt> public property String value;</tt>
-<p><tt>public class CastExpression extends ASTNode implements IExpression</tt>
-<br><tt> public CastExpression(AST ast);</tt>
-<br><tt> public property Type type;</tt>
-<br><tt> public property IExpression value;</tt>
-<p><tt>public class InfixExpression extends ASTNode implements IExpression</tt>
-<br><tt> public InfixExpression(AST ast);</tt>
-<br><tt> public property int infixOperator;</tt>
-<br><tt> public property IExpression leftOperand;</tt>
-<br><tt> public property IExpression rightOperand;</tt>
-<br><tt> public property IExpression[] extendedOperands;
-// L op R op R2 op R3...</tt>
-<h3>
-Bindings</h3>
-The "world of bindings" is an integrated picture of the structure of the
-program as seen from the compiler's point of view. The bindings correspond
-to named entities (packages, types, fields, methods, local variables).
-<p>Clients navigate from AST nodes into the world of bindings to discover
-things like:
-<ul>
-<li>
-the entity an identifier resolves to</li>
-
-<li>
-the resolved type of an expression node</li>
-
-<li>
-the resolved binding of a declaration node</li>
-
-<li>
-others?</li>
-</ul>
-Once in the world of bindings, the client can navigate the web of bindings:
-<ul>
-<li>
-from array type to its component type, and vice versa</li>
-
-<li>
-from field or variable to its declared type</li>
-
-<li>
-from method to its parameter and return types</li>
-
-<li>
-from type to its constructors and its declared method, field, and type
-members</li>
-
-<li>
-from constructor, method, or field to its declaring type</li>
-
-<li>
-from nested type to its enclosing type</li>
-
-<li>
-from type to declaring package</li>
-
-<li>
-from type to its supertypes (but, significantly, <i>not</i> to its subtypes)</li>
-
-<li>
-directly to the binding for any base type (int, float, char, etc.)</li>
-
-<li>
-directly to the binding for a handful of well-known types (java.lang.Object,
-etc.)</li>
-</ul>
-Some of the navigations that are not supported (quite intentionally):
-<ul>
-<li>
-from package to its (known) types - very expensive</li>
-
-<li>
-from package to one of its types by name - very expensive</li>
-
-<li>
-from type to its (known) subtypes - very expensive</li>
-
-<li>
-from type or method to the local types it encloses - binding for local
-types are only of interest to those with the enclosing type's AST in their
-hand</li>
-
-<li>
-from method to the variables declared within it - binding for variables
-are only of interest to those with the method's AST in their hand</li>
-</ul>
-There are no links from the world of bindings back to the world of ASTs.
-<p>Other things dealt with in the world of bindings:
-<ul>
-<li>
-synthetic entities stemming from default constructors, abstract method
-copy-down from interfaces, and inner class emulation</li>
-
-<li>
-missing bindings for entities that are required (mentioned by name) but
-were not found</li>
-
-<li>
-type hierachy circularities</li>
-
-<li>
-internal inconsistencies</li>
-</ul>
-Other issues:
-<ul>
-<li>
-Compile-time-computed values for constants (public static final fields
-with compile-time computable values)</li>
-</ul>
-
-<h4>
-Existing Binding classes</h4>
-To give an idea of the scope of the existing binding infrastructure, below
-is a dump of the type hierarchy of the compiler's binding classes from
-package <tt>rg.eclipse.jdt.internal.compiler.lookup</tt>.
-<p><tt>public abstract class Binding</tt>
-<br><tt> public abstract class TypeBinding</tt>
-<br><tt> public final class ArrayBinding</tt>
-<br><tt> public final class BaseTypeBinding</tt>
-<br><tt> public abstract class
-ReferenceBinding</tt>
-<br><tt>
-public class SourceTypeBinding</tt>
-<br><tt>
-public class NestedTypeBinding</tt>
-<br><tt>
-public final class LocalTypeBinding</tt>
-<br><tt>
-public final class MemberTypeBinding</tt>
-<br><tt>
-public class ProblemReferenceBinding</tt>
-<br><tt>
-public class UnresolvedReferenceBinding</tt>
-<br><tt> public class PackageBinding</tt>
-<br><tt> public class ProblemPackageBinding</tt>
-<br><tt> public abstract class VariableBinding</tt>
-<br><tt> public class LocalVariableBinding</tt>
-<br><tt>
-public class SyntheticArgumentBinding</tt>
-<br><tt> public class FieldBinding</tt>
-<br><tt>
-public class SyntheticFieldBinding</tt>
-<br><tt>
-public class ProblemFieldBinding</tt>
-<br><tt> public class MethodBinding</tt>
-<br><tt> public class ProblemMethodBinding</tt>
-<br><tt> public class SyntheticAccessMethodBinding</tt>
-<br><tt> public class ImportBinding</tt>
-<br><tt> public class ProblemBinding</tt>
-<h4>
-Binding API</h4>
-The existing binding classes are not immediately suitable for exposing
-as a binding API.
-<p>However, the Java builder does have an API for the built "image", in
-package <tt>org.eclipse.jdt.internal.core.builder</tt>. (This API is a
-hold-over from Leapfrog era, and is not exposed in the Eclipse code base).
-This API was designed to expose the same kind of integrated picture of
-the structure of the program as seen from the compiler's point of view.
-This API has a detailed specification that does not expose implementation
-details, so the proposal is to use it as the basis for the new binding
-API.
-<p>Re-purposing this API would entail:
-<ul>
-<li>
-introducing entities for local variables</li>
-
-<li>
-removing protocol for navigations that are not supported (e.g., from package
-to its known types)</li>
-
-<li>
-removing unneeded protocol; including states, non-state-specific handles,
-deltas, report cards, dependency graph, package references</li>
-</ul>
-Below is a dump of the relevant interfaces from package <tt>org.eclipse.jdt.internal.core.builder</tt>.
-Unnecessary protocol has been omitted. (Note that NotPresentException is
-an unchecked exception, and would not be required.)
-<p><tt>public interface IHandle</tt>
-<br><tt> int K_JAVA_IMAGE = 1;</tt>
-<br><tt> int K_JAVA_PACKAGE = 2;</tt>
-<br><tt> int K_JAVA_TYPE = 3;</tt>
-<br><tt> int K_JAVA_FIELD = 4;</tt>
-<br><tt> int K_JAVA_METHOD = 5;</tt>
-<br><tt> int K_JAVA_CONSTRUCTOR = 6;</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> int hashCode();</tt>
-<br><tt> boolean isFictional() throws NotPresentException;</tt>
-<br><tt> boolean isPresent();</tt>
-<br><tt> int kind();</tt>
-<p><tt>public interface IMember extends IHandle</tt>
-<br><tt> IType getDeclaringClass();</tt>
-<br><tt> int getModifiers() throws NotPresentException;</tt>
-<br><tt> String getName();</tt>
-<br><tt> boolean isBinary() throws NotPresentException;</tt>
-<br><tt> boolean isDeprecated() throws NotPresentException;</tt>
-<br><tt> boolean isSynthetic() throws NotPresentException;</tt>
-<p><tt>public interface IPackage extends IHandle</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType getClassHandle(String name);</tt>
-<br><tt> String getName();</tt>
-<br><tt> boolean isUnnamed();</tt>
-<p><tt>public interface IType extends IMember</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType getArrayHandle();</tt>
-<br><tt> IType getComponentType();</tt>
-<br><tt> IConstructor getConstructorHandle(IType[] parameterTypes);</tt>
-<br><tt> IType[] getDeclaredClasses() throws NotPresentException;</tt>
-<br><tt> IConstructor[] getDeclaredConstructors() throws
-NotPresentException;</tt>
-<br><tt> IField[] getDeclaredFields() throws NotPresentException;</tt>
-<br><tt> IMethod[] getDeclaredMethods() throws NotPresentException;</tt>
-<br><tt> int getDeclaredModifiers() throws NotPresentException;</tt>
-<br><tt> String getDeclaredName() throws NotPresentException;</tt>
-<br><tt> IType getDeclaringClass() throws NotPresentException;</tt>
-<br><tt> IField getFieldHandle(String name);</tt>
-<br><tt> IType[] getInterfaces() throws NotPresentException;</tt>
-<br><tt> IMethod getMethodHandle(String name, IType[]
-parameterTypes);</tt>
-<br><tt> int getModifiers() throws NotPresentException;</tt>
-<br><tt> String getName();</tt>
-<br><tt> IPackage getPackage();</tt>
-<br><tt> String getSimpleName();</tt>
-<br><tt> IType getSuperclass() throws NotPresentException;</tt>
-<br><tt> boolean isAnonymous() throws NotPresentException;</tt>
-<br><tt> boolean isArray();</tt>
-<br><tt> boolean isBinary() throws NotPresentException;</tt>
-<br><tt> boolean isClass() throws NotPresentException;</tt>
-<br><tt> boolean isDeprecated() throws NotPresentException;</tt>
-<br><tt> boolean isInnerClass() throws NotPresentException;</tt>
-<br><tt> boolean isInterface() throws NotPresentException;</tt>
-<br><tt> boolean isLocal() throws NotPresentException;</tt>
-<br><tt> boolean isPackageMember() throws NotPresentException;</tt>
-<br><tt> boolean isPresent();</tt>
-<br><tt> boolean isPrimitive();</tt>
-<br><tt> boolean isSynthetic() throws NotPresentException;</tt>
-<br><tt> boolean isTopLevel() throws NotPresentException;</tt>
-<p><tt>public interface IMethod extends IMember</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType[] getExceptionTypes() throws NotPresentException;</tt>
-<br><tt> IType[] getParameterTypes();</tt>
-<br><tt> IType getReturnType() throws NotPresentException;</tt>
-<br><tt> boolean isPresent();</tt>
-<p><tt>public interface IConstructor extends IMember</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType[] getExceptionTypes() throws NotPresentException;</tt>
-<br><tt> IType[] getParameterTypes();</tt>
-<br><tt> boolean isPresent();</tt>
-<p><tt>public interface IField extends IMember</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType getType() throws NotPresentException;</tt>
-<br><tt> boolean isPresent();</tt>
-<p>In this vein, the interface for local variables would look something
-like:
-<p><tt>public interface IVariable extends IHandle</tt>
-<br><tt> boolean equals(Object obj);</tt>
-<br><tt> IType getDeclaringClass();</tt>
-<br><tt> int getModifiers() throws NotPresentException;</tt>
-<br><tt> String getName();</tt>
-<br><tt> boolean isSynthetic() throws NotPresentException;</tt>
-<br><tt> IType getType() throws NotPresentException;</tt>
-<br><tt> boolean isPresent();</tt>
-<p>Also will need to add:
-<ul>
-<li>
-Pseudo-bindings for base types: boolean, int, float, etc.</li>
-
-<li>
-Access to well-known java.lang bindings: Object, String, Throwable, Exception,
-RuntimeException, Error, Class.</li>
-</ul>
-
-<h3>
-Document History</h3>
-18:30 Thursday September 27, 2001 - incorporated first round comments from
-PM and DB.
-<br><font color="#000000">10:45 Monday October 1, 2001 - incorporated comments
-from DB.</font>
-<br><font color="#000000">10:45 Tuesday October 2, 2001 - clarify handing
-of ExpressionStatement.</font>
-<br><font color="#3366FF">14:00 Friday October 26, 2001 - add subtree structural
-equality.</font>
-<br>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/output folder/output-folder.html b/org.eclipse.jdt.core/notes/r2.0/output folder/output-folder.html
deleted file mode 100644
index 3cc29d2..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/output folder/output-folder.html
+++ /dev/null
@@ -1,1228 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win98; I) [Netscape]">
- <meta name="Author" content="Build">
- <title>JDT - Java Output Folder</title>
-</head>
-<body>
-
-<h2>
-Java Output Folder</h2>
-Last revised 17:30 Tuesday October 30, 2001 <font color="#3333FF">(recent
-changes in blue;</font><font color="#CC0000"> latest in red</font><font color="#3333FF">)</font>
-<p>Work item: "Support for dealing with class files generated by external
-Java compilers like javac and jikes from an Ant script."
-<p>Here's the crux of one problem (from WSAD, via John W.):
-<p>In some environments the client has limited flexibility in how they
-structure their Java projects. Sources must go here; resource files here;
-mixed resource and class files here; etc.
-<ul>
-<li>
-There are situations where the client needs to place additional class files
-and resource files in the output directory.</li>
-
-<li>
-There are situations where the client needs to generate class files into
-an existing folder filled with their class files and resource files (e.g.,
-an exploded WAR file).</li>
-</ul>
-When clients attempts either, they discover that (a) the Java model and
-builder ignore any class files in the output folder, and (b) from time
-to time these files in the output folder get deleted without warning.
-<p>The Java builder was designed under the assumption that it "owns" the
-output folder. The work item, therefore, is to change the Java builder
-to give clients and users more flexiblility as to where they place their
-source, resource, library class, and generated class files.
-<h3>
-Current Functionality</h3>
-Eclipse 1.0 Java builder has the following characteristics (and inconsistencies):
-<ul>
-<li>
-The class files generated by the Java builder go in a single output folder.
-Java source files go in one or more source folders. Any other kind of files
-can be included in the source folder too; this includes pre-compiled class
-files. All these other files will be automatically mirrored to the binary
-output directory when a build is done. The mirror is maintained as the
-source folder changes; damage made directly to the output folder gets repaired
-no later than the next full build.</li>
-
-<li>
-The output folder belongs to the Java builder. It summarily deletes files
-from the output folder that it does not think belong there. It is not possible
-to get away with adding files directly to the output folder. So you cannot
-even mate the extra resource files with the class files manually.</li>
-
-<li>
-When the project source and output folder coincide (perhaps at the project
-itself), the builder behaves differently. It grants that source files belong
-there, so it never deletes them. It also grants that non-class files belong
-there, so it never deletes them either. But it assumes that all class files
-are generated, and so it summarily deletes them on every full build, including
-class files that were explicitly put there. This is different from the
-way things work out when the output folder and the source folder do not
-coincide. And it is not what you want if you need to mate other class files
-with the generated ones.</li>
-</ul>
-
-<h3>
-<font color="#3366FF">WSAD usecase - for the record</font></h3>
-<font color="#3366FF">The </font><font color="#CC0000">(proposed)</font><font color="#3366FF">
-WSAD scenario is that they have a src/ folder for source code, a classes/
-folder for pre-existing class files (extracted from a WAR file), and a
-bin/ folder for generated classes.</font>
-<ul>
-<li>
-<font color="#3366FF">The typical case is where the source and output folders
-are distinct. In this case, the classes/ folder may or may contain class
-files.</font></li>
-
-<li>
-<font color="#3366FF">The source code must be compiled against the classes
-in classes/ folder.</font></li>
-
-<li>
-<font color="#3366FF">The source and output folders may coincide. The classes/
-folder is always separate from either.</font></li>
-
-<li>
-<font color="#3366FF">In order to be executable, all class files must end
-up in the output folder.</font></li>
-
-<li>
-<font color="#3366FF">The client would like a way to delete class files
-from the classes/ folder for which there is corresponding source.</font></li>
-
-<li>
-<font color="#3366FF">The client would like to keep resource files in the
-output folder on an ongoing basis.</font></li>
-</ul>
-
-<h3>
-<font color="#3366FF">Proposal</font></h3>
-<font color="#3366FF">The Java builder compiles source files found in the
-source folders specified on the build classpath and generates class files
-into the output folder. The Java builder also copies "resource" files from
-source folders to the output folder (provided that source and output do
-not coincide). Once in the output folder, the resource files are available
-at runtime because the output folder is always present on the runtime class
-path. The proposal is to extend this mechanism.</font><font color="#3366FF"></font>
-<p><font color="#3366FF">The following proposal involves:</font>
-<ul>
-<li>
-<font color="#3366FF">Clarifying ownership of files in the output folder.</font></li>
-
-<li>
-<font color="#FF0000">Clarifying semantics of resource file copying from
-source folders to output folder.</font></li>
-
-<li>
-<font color="#FF0000">Making resource file copying from source folders
-to output folder optional, rather than mandatory.</font></li>
-
-<li>
-<font color="#FF0000">Providing class file copying from library folders
-to output folder, also on an optional basis.</font></li>
-
-<li>
-<font color="#FF0000">Providing and promoting useful alternatives to file
-copying.</font></li>
-
-<li>
-<font color="#FF0000">Prohibiting cases where expendable copies would end
-up mixed with important user data.</font></li>
-</ul>
-
-<h4>
-<font color="#3366FF">Output folder ownership</font></h4>
-<font color="#3366FF">When the output folder does not coincide with a source
-folder, the Java builder owns the output folder and everything in it. The
-output folder is taken to contain only files that are "expendable" - either
-generated class files or copies of files that live in a source or library
-folder.</font><font color="#3366FF"></font>
-<p><font color="#3366FF">Users or clients that add, remove, or replace
-files in the output folder can expect unpredicatable results. If the user
-or client does tamper with files in the output folder, the Java builder
-does not attempt to repair the damage. It is the responsibility of the
-user or client to clean up their mess (by manually requesting a full build).</font><font color="#3366FF"></font>
-<p><font color="#3366FF">When the output folder coincides with a source
-folder, the Java builder only owns the class files in the output folder.
-Only the class files in the output folder are considered expendable. Users
-or clients that add, remove, or replace class files in the output folder
-can expect unpredictable results.</font><font color="#3366FF"></font>
-<p><font color="#3366FF">(N.B. This is a restatement of the current behavior.
-[Verify that damage to output folder is not triggering builds.])</font>
-<h4>
-<font color="#FF0000">Output folder resource file consolidation</font></h4>
-<font color="#FF0000">The Java builder provides resource file consolidation,
-for resource files stored in source folders.</font><font color="#FF0000"></font>
-<p><font color="#FF0000">When the output folder does not coincide with
-a source folder, the Java builder can also be used to consolidate resources
-files needed at runtime in the output folder. In some cases, this consolidation
-may be preferred over the alternative of including additional runtime classpath
-entries for source folders containing resources files.</font><font color="#FF0000"></font>
-<p><font color="#FF0000">By flagging a source folder as copied, all non-source,
-non-class files become eligible to be copied to the output folder. When
-there are multiple entries on the build classpath specifying copying, eligible
-files for earlier classpath entries take precedence over ones for later
-entries.</font><font color="#FF0000"></font>
-<p><font color="#FF0000">When the output folder coincides with a source
-folder, the Java builder cannot perform any resource file consolidation
-(resource files in the output folder belong to the user, not to the Java
-builder). It is considered an error to specify copying from other source
-folders.</font><font color="#FF0000"></font>
-<p><font color="#FF0000">(N.B. This is different from current behavior
-in a couple of regards:</font>
-<ul>
-<li>
-<font color="#FF0000">Resource file copying for source folders is currently
-mandatory. It would become optional.</font></li>
-
-<li>
-<font color="#FF0000">Class files are currently copied from source folders.
-This would stop.</font></li>
-</ul>
-<font color="#FF0000">)</font>
-<h4>
-<font color="#FF0000">Output folder class file consolidation</font></h4>
-<font color="#FF0000">The Java builder also provides class file consolidation,
-for class files stored in library folders.</font><font color="#FF0000"></font>
-<p><font color="#FF0000">The Java builder can also be used to consolidate
-class in the output folder, regardless of whether the output folder coincides
-with a source folder. In some cases, this consolidation may be preferred
-over the alternative of including additional runtime classpath entries
-for library folders. Note, however, that this works only when the library
-folder contains no important resource files needed at runtime (resource
-files are not copied from library folders, because resource files in the
-output folder belong to the user rather than to the Java builder).</font><font color="#FF0000"></font>
-<p><font color="#FF0000">By flagging a library folder as copied, all class
-files become eligible to be copied to the output folder.
-Class files generated
-in the output folder always take precedence over class files copied from
-library folders.</font><font color="#FF0000"></font>
-<p><font color="#FF0000">(N.B. This new behavior. Files are not copied
-from library folders by the current Java builder.)</font>
-<h4>
-<font color="#3366FF">Semantics</font></h4>
-
-<ul>
-<li>
-<font color="#3366FF">Add a "copy" flag to source and library (and variable)
-classpath entries.</font></li>
-
-<ul>
-<li>
-<font color="#3366FF">For a source folder, copy flag means that </font><font color="#FF0000">resource
-(i.e, non-source, non-class) files </font><font color="#3366FF">in the
-source folder are copied to the output folder.</font></li>
-
-<ul>
-<li>
-<font color="#3366FF">Primary use is to consolidate </font><font color="#FF0000">resource
-files</font><font color="#3366FF"> in output folder so that source folder
-does not need to be included on runtime classpath.</font></li>
-</ul>
-
-<li>
-<font color="#3366FF">For a library folder (but not a library JAR), copy
-flag means that </font><font color="#FF0000">all class files</font><font color="#3366FF">
-in the library folder are copied to the output folder.</font></li>
-
-<ul>
-<li>
-<font color="#3366FF">Primary use is to consolidate </font><font color="#FF0000">class
-files</font><font color="#3366FF"> in output folder so that library folder
-does not need to be included on runtime classpath.</font></li>
-
-<li>
-<font color="#FF0000">N.B. Resource files in the library folder are not
-copied.</font></li>
-</ul>
-
-<li>
-<font color="#3366FF">The copy flag should be off by default for both types
-of folder; i.e., no file copying.</font></li>
-
-<li>
-<font color="#3366FF">Source folder copy flag on describes current behavior.</font></li>
-
-<li>
-<font color="#3366FF">For backward compatibility, existing projects should
-have copying on for source folders that might contain resource files.</font></li>
-
-<li>
-<font color="#FF0000">Library folder copy flag off describes current behavior.</font></li>
-
-<li>
-<font color="#FF0000">Error if any source folder copying specified when
-a source folder and output folder coincide.</font></li>
-
-<li>
-<font color="#3366FF">API on JavaCore for creating classpath entries with
-copy bit set.</font></li>
-
-<li>
-<font color="#3366FF">API on IClasspathEntry for reading copy bit.</font></li>
-</ul>
-
-<li>
-<font color="#3366FF">Generated class files in the output folder take precedence
-over class files copied from library folders.</font></li>
-
-<li>
-<font color="#3366FF">Files copied from earlier classpath entries take
-precedence over ones for later entries.</font></li>
-
-<li>
-<font color="#FF0000">UI provides the user with control over resource file
-consolidation.</font></li>
-
-<ul>
-<li>
-<font color="#FF0000">For source folder: "Copy resource (non-source, non-class)
-files to output folder"</font></li>
-</ul>
-
-<li>
-<font color="#FF0000">UI does not provide the user with control over class
-file consolidation.</font></li>
-
-<ul>
-<li>
-<font color="#FF0000">This feature would be enabled programmatically by
-clients that need it.</font></li>
-</ul>
-
-<li>
-<font color="#3366FF">Consolidation functionality is built in to Java builder.</font></li>
-
-<li>
-<font color="#3366FF">Pro: Puts us in a position where resource copying
-is no longer mandatory.</font></li>
-
-<li>
-<font color="#3366FF">Pro: Gives us an opportunity to improve resource
-copying implementation.</font></li>
-</ul>
-<font color="#FF0000">Summary: Resource files (non-source, non-class) may
-be copied from either source folders. Class files may be copied from library
-folders, but never override generated files. Source files never get copied.</font><font color="#3366FF"></font>
-<p><font color="#3366FF">Output folder invariant:</font>
-<ul>
-<li>
-<font color="#3366FF">For a class file X.class in the output folder O</font></li>
-
-<ul>
-<li>
-<font color="#3366FF">if exists a Y.java in a source folder that compiles
-to X.class then the X.class in O is the one that results from compiling
-Y.java</font></li>
-
-<li>
-<font color="#3366FF">if exists an X.class </font><font color="#FF0000">in
-some library folder with copying on </font><font color="#3366FF">then a
-copy of the X.class from the earliest such </font><font color="#FF0000">library
-folder</font></li>
-
-<li>
-<font color="#3366FF">otherwise no X.class should be present</font></li>
-</ul>
-
-<li>
-<font color="#3366FF">For a </font><font color="#FF0000">resource (i.e.,
-non-source, non-class) </font><font color="#3366FF">file X.other in the
-output folder O</font></li>
-
-<ul>
-<li>
-<font color="#3366FF">if O is also a source folder then any X.other that
-lives there</font></li>
-
-<li>
-<font color="#3366FF">if exists an X.other </font><font color="#FF0000">in
-some source folder with copying on</font><font color="#3366FF"> then a
-copy of the X.other from the earliest such </font><font color="#FF0000">source
-folder</font></li>
-
-<li>
-<font color="#3366FF">otherwise no X.other should be present</font></li>
-</ul>
-
-<li>
-<font color="#3366FF">For a source file X.java in the output folder O</font></li>
-
-<ul>
-<li>
-<font color="#3366FF">if O is also a source folder then any X.java that
-lives there</font></li>
-
-<li>
-<font color="#FF0000">otherwise no X.java should be present</font></li>
-</ul>
-</ul>
-<font color="#3366FF">A full builds must achieve the output folder invariant
-from <i>arbitrary</i> initial conditions. When output and source folders
-do not coincide, a full build should scrub all existing files from the
-output folder, regardless of how they got there. When output and source
-folders do coincide, a full build should scrub all existing class files
-from the output folder, but leave all other files alone.</font><font color="#3366FF"></font>
-<p><font color="#3366FF">Assuming that a user or client is only adding,
-removing, or changing files in source or library folders, but not tampering
-with any of the files in the output folder that the Java builder owns,
-then an incremental build should re-achieve the output folder invariant.</font><font color="#3366FF"></font>
-<p><font color="#3366FF">Algorithm:</font><font color="#3366FF"></font>
-<p><font color="#FF0000">Full build:</font>
-<br><font color="#FF0000"> Scrub all class files from
-the output folder.</font>
-<br><font color="#FF0000"> if performing resource consolidation
-(requires output folder != source folder)</font>
-<br><font color="#FF0000"> Scrub
-all resource files from the output folder.</font>
-<br><font color="#FF0000"> Compile all source files into
-class files in the output folder.</font>
-<br><font color="#FF0000"> Infill/copy eligible class
-files from library folders into the output folder (no overwriting).</font>
-<br><font color="#FF0000"> if performing resource consolidation
-(requires output folder != source folder)</font>
-<br><font color="#FF0000"> Infill/copy
-eligible resource files from source folders into the output folder.</font><font color="#FF0000"></font>
-<p><font color="#FF0000">Incremental build:</font>
-<br><font color="#FF0000"> (phase 1) process changes
-to library folders:</font>
-<br><font color="#FF0000"> for
-add or remove or change file p/x.class in one of the library folders</font>
-<br><font color="#FF0000">
-if p/x.class in the output folder was not generated by compiler then</font>
-<br><font color="#FF0000">
-scrub p/x.class from the output folder</font>
-<br><font color="#FF0000">
-remember to compile source files that depend on p/x</font>
-<br><font color="#FF0000">
-remember to infill p/x.class</font>
-<br><font color="#FF0000"> (phase 2) process changes
-to source folders:</font>
-<br><font color="#FF0000"> for
-add p/y.java in one of the source folders</font>
-<br><font color="#FF0000">
-remember to compile source file at path p/y.java</font>
-<br><font color="#FF0000"> for
-remove or change p/y.java in one of the source folders</font>
-<br><font color="#FF0000">
-scrub any class file p/x.class from the output folder that some p/y.java
-compiled into last time</font>
-<br><font color="#FF0000">
-remember to infill p/x.class</font>
-<br><font color="#FF0000">
-remember to compile source file at path p/y.java</font>
-<br><font color="#FF0000"> for
-add or remove or change resource p/x.other in one of the source folders</font>
-<br><font color="#FF0000">
-if performing resource consolidation (requires output folder != source
-folder)</font>
-<br><font color="#FF0000">
-scrub p/x.other from the output folder</font>
-<br><font color="#FF0000">
-remember to infill p/x.other</font>
-<br><font color="#FF0000"> (phase 3) recompile:</font>
-<br><font color="#FF0000"> compile
-all remembered source files into the output folder (and any dependent source
-files)</font>
-<br><font color="#FF0000"> (phase 4) infill:</font>
-<br><font color="#FF0000"> for
-each hole p/x.class to infill</font>
-<br><font color="#FF0000">
-copy first-found file p/x.class in a library folder to p/x.class in the
-output folder (no overwriting)</font>
-<br><font color="#FF0000"> if
-performing resource consolidation (requires output folder != source folder)</font>
-<br><font color="#FF0000">
-for each hole p/x.other to infill</font>
-<br><font color="#FF0000">
-copy first-found file p/x.other in a source folder to p/x.other in the
-output folder</font>
-<h4>
-<font color="#3366FF">How These Changes Solve WSAD's Problem</font></h4>
-<font color="#3366FF">WSAD would include their classes/ folder on the build
-classpath as a library folder with class file copying turned on. Doing
-so means that the pre-compiled class files in the library are available
-to build against, and will be used whenever there is no corresponding source
-code in a source folder. </font><font color="#FF0000">By turning class
-file copying on for that library folder (programatically - there is no
-UI), the class files in the library folder are automatically consolidated
-with the generated class files.</font><font color="#3366FF"></font>
-<p><font color="#FF0000">Resource files can always be kept in the same
-folder as the source files. When the source and output folders do not coincide,
-the source folder on the classpath could have copying turned on to ensure
-that resource files were copied to the output folder. When the source and
-output folders do coincide, further resource file consolidation is not
-required (or possible) and the source folder on the classpath would have
-copying turned off. The resource files that normally live in the source
-folder would automatically be included in the output folder (without copying).</font>
-<h3>
-<font color="#3366FF">Minimizing Class Files</font></h3>
-<font color="#3366FF">(This problem is not really an output folder issue.)</font><font color="#3366FF"></font>
-<p><font color="#3366FF">WSAD has a special problem. They have class files
-in a classes/ folder which they obtain from unzipping a WAR file. They
-have a folder of source code; some of the source code may be brand new;
-some of the source code may correspond to class files in the classes/ folder.
-They need to prune from the classes/ directory those class files for which
-corresponding source is available. This allows them to save only those
-class files which they actually need.</font><font color="#3366FF"></font>
-<p><font color="#3366FF">The heart of this operation is identifying the
-class files which could have come from a given source file. A source file
-can be lightly parsed to obtain fully qualified names for all top-level
-types declared within; e.g., a source file com/example/acme/app/Foo.java
-might contain types named com.example.acme.app.Foo and com.example.acme.app.FooHelper.
-Such type names map directly to corresponding class file name patterns;
-e.g., com.example.acme.app.FooHelper would compile to com/example/acme/app/FooHelper.class
-and possibly other class files matching com/example/acme/app/FooHelper$*.class.</font><font color="#3366FF"></font>
-<p><font color="#3366FF">This basic operation can be implemented with the
-existing JDOM API (or the proposed AST API): simply open the compilation
-unit and read off the names from the package declaration and and top-level
-type declarations.</font><font color="#3366FF"></font>
-<p><font color="#3366FF">Given this basic operation, it is straightforward
-to walk any set of source files and use it to prune a given set of class
-files. Source files in some folder in the workspace can be monitored with
-a resource change listener. It is trivial to delete corresponding class
-files incrementally as new source files are added.</font><font color="#3366FF"></font>
-<p><font color="#3366FF">Conclusion: New API is not required.</font>
-<h2>
-Notes Leftover from Earlier Proposals</h2>
-The following notes are retained as background material. They include some
-of the other approaches we tried, and problems we ran into.
-<p>The Java model has 2 primitive kinds of inputs: Java source files, and
-Java library class files. The Java builder produces one primary output:
-generated Java class files. Each Java project has a build classpath listing
-what kinds of inputs it has and where they can be found, and a designated
-output folder where generated class files are to be placed. The runtime
-classpath is computed from the build classpath by substituting the output
-folder in place of the source folders.
-<p>Java "resource" files, defined to be files other than Java sources and
-class files, are of no particular interest to the Java model for compiling
-purposes. However, these resource files are very important to the user,
-and to the program when it runs. Resource files are routinely co-located
-with library class files. But it is also convenient for the user if resource
-files can be either co-located with source code, or segregated in a separate
-folder.
-<p>Ideally, the Java model should not introduce constraints on where inputs
-and outputs are located. This would give clients and users maximum flexibility
-with where they locate their files.
-<p>The proposal here has 4 separate parts. Taken in conjunction they remove
-the current constraints that make it difficult for some clients to place
-their files where they need to be.
-<ul>
-<li>
-<a href="#Java Builder Attitude Adjustment">Change the Java builder's attitude
-towards the output folder.</a></li>
-
-<li>
-<a href="#Allowing Folders to Play Multiple Roles">Allow folders to play
-multiple roles on the same build classpath.</a></li>
-
-<li>
-<a href="#Completely eliminate resource file copying behavior">Completely
-eliminate the resource copying behavior of current Java builder.</a></li>
-
-<li>
-<a href="#Minimize the opportunity for obsolete class files to have bad effects">Minimize
-the opportunity for obsolete class files to have bad effects.</a></li>
-</ul>
-[Revised proposal: Rather than write a completely new proposal, I've added
-a note like to the end of each subsequent section describing a revised
-proposal.]
-<h3>
-<a NAME="Java Builder Attitude Adjustment"></a>Java Builder Attitude Adjustment</h3>
-To appreciate the difficulties inherent with the Java builder sharing its
-output folder with other folk, consider the following workspace containing
-a Java project. Assume that this project has not been built in quite a
-while, and the user has been manually inserting and deleting class files
-in the project's output folder.
-<p>Java project p1/
-<br> src/com/example/ (source folder on build classpath)
-<br> Bar.java
-<br> Foo.java
-<br> Quux.java
-<br> bin/com/example/ (output folder)
-<br> Bar.class {SourceFile="Bar.java"}
-<br> Foo.class {SourceFile="Foo.java"}
-<br> Foo$1.class {SourceFile="Foo.java"}
-<br> Internal.class {SourceFile="Foo.java"}
-<br> Main.class {SourceFile="Main.java"}
-<p>From this arrangement of files (and looking at the SourceFile attributed
-embedded in class files), we can infer that:
-<ul>
-<li>
-Bar.class came from compiling a source file named "Bar.java".</li>
-
-<li>
-Foo.class, Foo$1.class, and Internal.class all came from compiling a "Foo.java".
-(A single source file will compile to multiple separate class files if
-it has nested classes or secondary non-public classes.)</li>
-
-<li>
-There are no existing class files corresponding to "Quux.java".</li>
-
-<li>
-Main.class came from compiling a source file named "Main.java", which the
-workspace does't have.</li>
-</ul>
-
-<h4>
-Java Builder - Obsolete Class File Deletion</h4>
-If the user was to request a full build of this project, how would the
-Java builder proceed? Before it compile any source files, it begins by
-deleting existing class files that correspond to source files it is about
-to recompile. Why? Because obsolete class files left around (a) waste storage
-and (b) would be available at runtime where they could cause the program
-to run incorrectly.
-<p>In this situation, the Java builder deletes the class files corresponding
-to Bar.java (i.e., Bar.class), to Foo.java (i.e., Foo.class, Foo$1.class,
-and Internal.class), and to Quux.java (none, in this case). The remaining
-class files (Main.class) must be retained because it is irreplaceable.
-<p>The Java builder takes responsibility for deleting obsolete class files
-in order to support automated incremental recompilation of entire folders
-of source files. Note that standard Java compilers like javac never ever
-delete class files; they simply write (or overwrite) class files to the
-output folder for the source files that they are given to compile. Standard
-Java compilers do not support incremental recompilation: the user is responsible
-for deleting any obsolete class files that they bring about.
-<p>If the Java builder is free to assume that all class files in the output
-folder are ones that correspond to source files, then it can simply delete
-all class files in the output folder at the start of a full build. If it
-cannot assume this, the builder is forced to look at class files in the
-output folder to determine whether it has source code for them. This is
-clearly more expensive that not having to do so. By declaring that it "owns"
-the output folder, the current builder is able to makes this simplifying
-assumption. Allowing users and clients to place additional class files
-in the output folder requires throwing out this assumption.
-<p>If the user or client is free to manipulate class files in the output
-folder without the Java builder's involvement, then the builder cannot
-perform full or incremental builds without looking at and deleting the
-obsolete class files from the output folder corresponding to source files
-being compiling.
-<p>Under the proposed change, the Java builder would need to look at the
-class files in the output folder to determine whether it should delete
-them. <i>The only files in the output folder that the Java builder would
-be entitled to overwrite or delete are class files which the Java builder
-would reasonably generate, or did generate, while compiling that project.</i>
-<ul>
-<li>
-The Java builder is entitled to overwrite class files in the output folder
-that correspond to current source files. Any class file at such a path
-is the Java builder's. Even when the actual contents of the class file
-came from elsewhere, the builder is always entitled to delete them or overwrite
-them with its contents.</li>
-
-<li>
-The only files in the output folder that the Java model/builder would be
-entitled to delete outright are ones that had been generated by the Java
-builder when compiling this project but which no longer correspond to a
-current source file. This permits the Java builder to clean up obsolete
-class files that it knows it generated, or would have generated, on an
-earlier build. It does not have the right to delete other class files,
-even ones which do not correspond to a current source file. (Otherwise
-the Java builder could justify deleting any class file that it does not
-have corresponding source for.) Even for a full build, the Java builder
-is not allowed to scrub all class files from the output folder (unless
-it happens to know for a fact that the only class files in there ones it
-generated).</li>
-
-<li>
-The source file is an optional attribute of class files that is not generated
-when debug info is suppressed (javac -g:none). Class files in the output
-folder without the SourceFile attribute should be treated as if there was
-no corresponding source file. This means they never get deleted outright,
-although they may still be overwritten as required.</li>
-
-<li>
-Note: changing a project to give it a different output folder should absolve
-the Java builder of responsibility for any generated class files in the
-former output folder. This means the Java builder does not need to perform
-cleanup or track anything outside the current output folder.</li>
-
-<li>
-Note: adding a source entry to the build classpath causes a bunch of new
-source files to enter the frame. Some of the existing class files in the
-output folder might now map to these source files, possibly in preference
-to where they mapped before. Removing a source entry from the build classpath
-causes a bunch of source files to leave the picture. Some of the existing
-class files in the output folder might now map to other source files, or
-not map to any soure file at all. [We need to decide whether obsolete class
-files need to be tracked across the additional and/or removal of source
-entries from the build classpath.]</li>
-</ul>
-This change is not a breaking API change. The old spec said that the Java
-model/builder owned the output folder, but didn't further specify what
-all that entailed. The new spec will modify this position to allow clients
-to store files in the output folder; it will promise that these files are
-perfectly safe unless they are in the Java builder's direct line of fire.
-<h4>
-Java Model - Obsolete Class File Deletion</h4>
-There is another facet of the obsolete class file problem that the Java
-builder is not in a position to help with.
-<p>If the source file Foo.java were to be deleted, its three class files
-become obsolete and need to be deleted <i>immediately</i>. Why immediately?
-Consider what happens if the class files are not deleted immediately. If
-the user requests a full build, the Java builder is presented with the
-following workspace:
-<p>Java project p1/
-<br> src/com/example/ (source folder on build classpath)
-<br> Bar.java
-<br> Quux.java
-<br> bin/com/example/ (output folder)
-<br> Bar.class {SourceFile="Bar.java"}
-<br> Foo.class {SourceFile="Foo.java"}
-<br> Foo$1.class {SourceFile="Foo.java"}
-<br> Internal.class {SourceFile="Foo.java"}
-<br> Main.class {SourceFile="Main.java"}
-<p>Since a full build is requested, the Java builder is not passed a resource
-delta tree for the project. This means that the Java builder has no way
-of knowing that Foo.java was just deleted. The Java builder has no choice
-but to retain the three class files Foo.class, Foo$1.class, and Internal.class,
-just as it retains Main.class. This too is a consequence of allowing the
-Java builder to share the output folder with the user's class files.
-<p>If the obsolete class files are not deleted in response to the deletion
-of a source file, these class files will linger around. The Java builder
-will be unable to get rid of them.
-<p>The proposal is to have the Java model monitor source file deletions
-on an ongoing basis and identify and delete any corresponding obsolete
-class files in the output folder. This clean up activity must handle the
-case of source files that disappear while the Java Core plug-in is not
-activated (this entails registering a Core save participant).
-<p>Since deleting (including renaming and moving) a source file is a relatively
-uncommon thing for a developer to do, the implementation should bet it
-does not have to do this very often. When a source file in deleted, its
-package name gives us exactly which subfolder of the output folder might
-contain corresponding class files that might now be obsolete. In the worst
-case, the implementation would need to access all class files in that subfolder
-to determine whether any of them have become obsolete. In cases where there
-is more than one source folder on the builder classpath, and there is therefore
-the possibility of one source file hiding another by the same name, it
-is necessary to consult the build classpath to see whether the deleted
-source file was exposed or buried.
-<h4>
-Implementation Tricks</h4>
-Some observations and implementation tricks that should help reduce the
-space and time impact of doing this.
-<ul>
-<li>
-When one or more source files are deleted from a single source folder,
-their position under the source package fragment root gives us the package
-name. This package name tells us exactly which subfolder of the output
-folder might contain corresponding class files that might now be obsolete.
-In the worst case, the implementation would need to access all class files
-in that subfolder to determine whether any of them have become obsolete.
-This shows that you only need information about a small portion of the
-output folder in order to process one or more deletions within a single
-source folder.</li>
-
-<li>
-A source file named Foo.java typically compiles to a single class file
-named Foo.class. There might be more class files (for nested classes and/or
-secondary non-public types); and there might be less (when the source file
-contains only non-public types with names other than "Foo"). When recording
-the extracted source file name information, only the exceptional cases
-need to be represented explicitly. For example, only Foo$1.class (derived
-from Foo.java) and Internal.class (derived from Foo.java) are unusual;
-Bar.class, Foo.class, and Main.class are all derived from source files
-with the expected name. This means you can store the information extracted
-from class files much more compactly that a simple class file name to SourceFile
-string mapping.</li>
-
-<li>
-There is often only one source folder on the builder classpath. In this
-case, all source files in the source folder get compiled; there is no possibility
-of one source file "hiding" another by the same name. This observation
-can be used to avoid checking for source file hiding.</li>
-</ul>
-
-<h3>
-When all else fails</h3>
-A special concern is that the user must be able to recover from crashes
-or other problems that result in obsolete class files being left behind
-in the output folder. It can be very bad when this kind of thing happens
-(and it does happen, despite our best efforts), and can undercut the user's
-confidence in the Java compiler and IDE. In a large output folder that
-contains important user files, the user can't just delete the output folder
-and do a full build. The user has no easy way to distinguish class files
-with corresponding source from ones without. A simple way to address this
-need would be to have a command (somewhere in the UI) that would delete
-all class files in the output folder for which source code is available
-("Delete Generated Class Files"). This would at least give the user some
-help in recovering from these minor disasters.
-<p>[Revised proposal: The Java builder remembers the names of the class
-files it has generated. On full builds, it cleans out all class files that
-it has on record as having generated; all other class files are left in
-place. On incremental builds, it selectively cleans out the class files
-that it has on record as having generated corresponding to the source files
-that it is going to recompile. There is no need to monitor source file
-deletions: corresponding generated class files will be deleted on the next
-full build (because it nukes them all) or next incremental build (because
-it sees the source file deletion in the delta). The Java builder never
-looks at class files for their SourceFile attributes. A full build always
-deletes generated class files, so there's no need to a special UI action.]
-<h3>
-<a NAME="Allowing Folders to Play Multiple Roles"></a>Allowing Folders
-to Play Multiple Roles</h3>
-The proposed change is to consistently allow the same folder to be used
-in multiple ways on the same build classpath.
-<ul>
-<li>
-As source folder and as output folder.</li>
-
-<ul>
-<li>
-N.B. This is currently supported (e.g., when folder is the project root).</li>
-
-<li>
-Allows generated class files to be co-located with Java source files.</li>
-
-<li>
-Since output folder is automatically included on runtime classpath, this
-arrangement would automatically make any class files or resource files
-available at runtime.</li>
-
-<ul>
-<li>
-However, these class files would not be seen at compile time library folder.</li>
-
-<li>
-Recommendation: when class files or resources are present in a folder,
-there should always be a library folder entry on the build classpath for
-it.</li>
-</ul>
-</ul>
-
-<li>
-As source folder and as library folder.</li>
-
-<ul>
-<li>
-N.B. This is currently disallowed.</li>
-
-<li>
-Allows library class files to be co-located with Java source files.</li>
-
-<li>
-Allows resource files to be co-located with Java source files.</li>
-
-<li>
-In virtue of being a library entry on the build classpath, the folder is
-used at compile time for library class files and is included on the runtime
-classpath.</li>
-</ul>
-
-<li>
-As library folder and as output folder.</li>
-
-<ul>
-<li>
-N.B. This is currently disallowed.</li>
-
-<li>
-Allows library class files to be co-located with generated class files.</li>
-
-<li>
-Allows resource files to be co-located with generated class files.</li>
-
-<li>
-Remove duplicate entry when forming the runtime class path.</li>
-
-<li>
-Note that the generated class files in this library folder are ignored
-by the builder because it has source for all these by definition.</li>
-</ul>
-
-<li>
-As source folder and as output folder and as library folder.</li>
-
-<ul>
-<li>
-This is just a combination of all of above.</li>
-
-<li>
-Allows library class files, generated class files, and resource files to
-be co-located with Java source files.</li>
-
-<li>
-Simple "one folder Java development" setup for someone with library class
-files and possibly resources.</li>
-</ul>
-</ul>
-This change is not a breaking change; it would simply allow some classpath
-configurations that are currently disallowed to be considered legitimate.
-The API would not need to change.
-<p>[Revised proposal: Many parts of the Java model assume that library
-folders are relatively quiet. Allow a library folder to coincide with the
-output folder would invalidate this assumption, which would tend to degrade
-performance. For instance, the indexer indexes libraries and source folders,
-but completely ignores the output folder. If the output folder was also
-a library, it would repeatedly extract indexes for class files generated
-by the builder.
-<p><i>N.B. This means that the original scenario of library class files
-in the output folder is cannot be done this way. It will need to be addressed
-in some other way (discussed later on).</i>
-<p><font color="#3366FF">The identity criteria for package fragment root
-handles are based on resources/paths and do not take kind (source vs. binary)
-into account. This means that a source folder and a library folder at the
-same path map to the same package fragment root handle! Thus allowing a
-source folder to coincide with a library folder cannot be supported without
-revising Java element identity criteria (which is due for an overhaul,
-but that's a different, and bigger, work item).</font>
-<br>]
-<h3>
-<a NAME="Completely eliminate resource file copying behavior"></a>Completely
-eliminate resource file copying behavior</h3>
-The current Java builder copies "resource" files from source folders to
-the output folder (provided that source and output do not coincide). Once
-in the output folder, the resource files are available at runtime because
-the output folder is always present on the runtime class path.
-<p>This copying is problematic:
-<ul>
-<li>
-Copying creates duplicates of resource files.</li>
-
-<ul>
-<li>
-Takes up extra disk space.</li>
-
-<li>
-Copying resources takes extra time.</li>
-
-<li>
-Increases risk of user confusion (modify the copy).</li>
-</ul>
-
-<li>
-Copying is out of character for Java builder.</li>
-
-<ul>
-<li>
-Java builder should compile Java source files to binary class files.</li>
-</ul>
-
-<li>
-Copying behavior is quirky.</li>
-
-<ul>
-<li>
-Resources are never copied from a source folder that coincides with the
-output folder.</li>
-
-<li>
-Resources are copied from a source folder that does not coincide with the
-output folder, even if the output folder happens to be another source folder.</li>
-
-<li>
-Modifying the copy and building causes the file to be deleted (!); it is
-replaced by a fresh copy on the next full build.</li>
-
-<li>
-When there are several resource files with same name, it is impossible
-to reliably control which one ends up in the output folder.</li>
-
-<li>
-When the project source is the project itself, and the output is in a folder
-under the project, the builder copies the .classpath file into the output
-folder too.</li>
-</ul>
-</ul>
-The proposal is to eliminate this copying behavior. The proper way to handle
-this is to include an additional library entry on the build classpath for
-any source folders that contain resources. Since library entries are also
-included on the runtime classpath, the resource files contained therein
-will be available at runtime.
-<p>We would beef up the API specification to explain how the build classpath
-and the runtime classpath are related, and suggests that one deals with
-resource files in source folders using library entries. This would be a
-breaking change for clients or users that rely on the current resource
-file copying behavior.
-<p>The clients that would be most affected are ones that co-locate their
-resource files with their source files in a folder separate from their
-output folder. This is a fairly large base of customers that would need
-to add an additional library entry for their source folder.
-<p>It would be simple to write a plug-in that detected and fixed up the
-Java projects in the workspace as required. By the same token, the same
-mechanism could be built in to the Java UI. If the user introduces a resource
-files into a source folder that had none and there is no library entry
-for that folder on the build classpath, ask the user whether they intend
-this resource file to be available at runtime.
-<p>(JW believes that WSAD will be able to roll with this punch.)
-<p>[Revised proposal: Retain copying from source to output folder where
-necessary.
-<ul>
-<li>
-Source folder different from output folder, no additional source folders:
-copy resources from source folder to output folder (current behavior).</li>
-
-<li>
-Source folder different from output folder, additional source folders:
-copy resources from all source folders to output folder honoring build
-classpath ordering (current behavior).</li>
-
-<li>
-Source folder same as output folder, and no additional source folders:
-no copying (current behavior).</li>
-
-<li>
-Source folder same as output folder, and additional source folders: error
-(new behavior).</li>
-</ul>
-This eliminates the screw case where resources get copied from one source
-folder into another source folder, possibly overwriting client data.]
-<h3>
-<a NAME="Minimize the opportunity for obsolete class files to have bad effects"></a>Minimize
-the opportunity for obsolete class files to have bad effects</h3>
-The Java compiler should minimize the opportunity for obsolete class files
-to have bad effects.
-<p>Consider the following workspace:
-<p>Java project p1/
-<br> src/com/example/ (source folder on build classpath)
-<br> C1.java {package com.example;
-public class C1 {}}
-<br> C2.java {package com.example;
-public class C2 extends Secondary {})
-<br> lib/com/example/ (library folder on build classpath)
-<br> C1.class {from compiling
-an old version of C1.java
-<br> that read
-package com.example; public class C1 {}; class Secondary {}}
-<br> C2.class {from compiling
-an old but unchanged version of C2.java}
-<br> Secondary.class {from compiling
-an old but unchanged version of C2.java}
-<br> Quux.class {from compiling
-Quux.java}
-<p>Assume the source folder precedes the library folder on the build classpath
-(sources should always precede libraries).
-<p>When the compiler is compiling both C1.java and C2.java, it should not
-satisfy the reference to the class com.example.Secondary using the existing
-Secondary.class because the SourceFile attributes shows that Secondary.class
-is clearly an output from compiling C1.java, not an input. In general,
-the compiler should ignore library class files that correspond to source
-files which are in the process of being recompiled. (In this case, only
-Quux.class is available to satisfy references.) The Java builder does not
-do this.
-<p>Arguably, the current behavior should be considered a bug. (javac 1.4
-(beta) has this bug too.) Fixing this bug should not be a breaking change.
-<p>When the SourceFile attribute is not present in a class file, there
-is no choice but to use it.
-<p>[Revised proposal: Maintain current behavior.]
-<h3>
-<font color="#000000">Library Copying Proposal</font></h3>
-<font color="#000000">The proposal is to arrange to copy class files from
-a certain library folder into the output folder. The library folder would
-have to be represented by a library classpath entry so that the compiler
-can find any class files it needs to compile source files. Copying the
-class files to the output folder would unite them with the class files
-generated by the compiler. Since there may be source code in the source
-folder corresponding to some of the classes in the library folder, the
-builder should only use a class file when source is available.</font>
-<p><font color="#000000">Desired semantics:</font>
-<p><font color="#000000">S (source folder)</font>
-<br><font color="#000000">L (library folder)</font>
-<br><font color="#000000">O (output folder)</font>
-<p><font color="#000000">Invariant:</font>
-<p><font color="#000000">x.class in O =</font>
-<br><font color="#000000"> if some y.java in S generates
-x.class then</font>
-<br><font color="#000000"> x.class
-from compiling x.java in S</font>
-<br><font color="#000000"> else</font>
-<br><font color="#000000"> if
-x.class in L then</font>
-<br><font color="#000000">
-x.class in L</font>
-<br><font color="#000000"> else</font>
-<br><font color="#000000">
-none</font>
-<br><font color="#000000"> endif</font>
-<br><font color="#000000"> endif</font>
-<p><font color="#000000">Full builds achieve invariant.</font>
-<br><font color="#000000">Incremental builds maintain invariant.</font>
-<p><font color="#000000">Full build:</font>
-<br><font color="#000000"> Scrub all class files from
-O.</font>
-<br><font color="#000000"> Compile all source files in
-S into class files in O.</font>
-<br><font color="#000000"> Infill/copy all class files
-from L to O (no overwriting).</font>
-<p><font color="#000000">Incremental build:</font>
-<br><font color="#000000"> (phase 1) process all changes
-to L:</font>
-<br><font color="#000000"> for
-delete or change x.class in L</font>
-<br><font color="#000000"> if
-x.class in O was not generated by compiler then scrub x.class from O</font>
-<br><font color="#000000"> for
-add or change x.class to L</font>
-<br><font color="#000000">
-remember to infill x.class</font>
-<br><font color="#000000"> (phase 2) process negative
-changes to S:</font>
-<br><font color="#000000"> for
-delete or change y.java from S</font>
-<br><font color="#000000">
-scrub any class file x.class from O that y.java compiled into</font>
-<br><font color="#000000">
-remember to infill x.class</font>
-<br><font color="#000000"> (phase 3) process positive
-changes to S:</font>
-<br><font color="#000000"> for
-add or change y.java from S</font>
-<br><font color="#000000">
-compile y.java into O</font>
-<br><font color="#000000"> (phase 4) Infill/copy indicated
-class files from L to O (no overwriting).</font>
-<p><font color="#000000">We will look at ways to implement the above behavior
-that do not involve changing the Java builder. This would mean that a customer
-(such as WSAD) that requires library copying would be able to add it themselves;
-otherwise, we will need to complicate the Java builder (which is complex
-enough as it is) and integrate the mechanism into JDT Core.</font>
-<h4>
-<font color="#000000">Copying pre-builder</font></h4>
-<font color="#000000">Could the copying of class files from the library
-folder L to the output folder O be accomplished in a separate incremental
-project builder that would run <i>before</i> the Java builder?</font>
-<p><font color="#000000">Assume the Java builder manages its own class
-files in the output folder and knows nothing of the pre-builder. Conversely,
-assume that the pre-builder has no access to the insides of the Java builder.</font>
-<p><font color="#000000">Pre-copying of class files to the output folder
-cannot handle the case where a source file gets deleted and a pre-existing
-class file in the library folder should now take its place. The Java builder,
-which runs last, deletes the class file; the pre-builder has missed its
-chance and does not get an opportunity to fill that hole. When this happens
-on a full build, the full build does not achieve the invariant. This is
-unacceptable.</font>
-<p><font color="#000000">Here's the nasty case:</font>
-<br><font color="#000000"> S (source folder): Bar.java
-(but recently has Foo.java as well)</font>
-<br><font color="#000000"> L (library folder): Foo.class</font>
-<p><font color="#000000">On a full build</font>
-<br><font color="#000000"> Pre-builder runs first:</font>
-<br><font color="#000000"> Scrubs
-Foo.class and Bar.class from O.</font>
-<br><font color="#000000"> Copies
-in Foo.class from L to O.</font>
-<br><font color="#000000"> Java Builder runs second:</font>
-<br><font color="#000000"> Scrubs
-Foo.class from O (generated by Java builder from Foo.java on last build).</font>
-<br><font color="#000000"> Compile
-Bar.java into Bar.class O (Foo.java is no longer around).</font>
-<p><font color="#000000">The output folder should contain a copy of Foo.class
-from L since there is no equivalent source file that compiles to Foo.class.
-It doesn't.</font>
-<h4>
-<font color="#000000">Copying post-builder</font></h4>
-<font color="#000000">Could the copying of class files from the library
-folder to the output folder be accomplished in a separate incremental project
-builder that would run <i>after</i> the Java builder?</font>
-<p><font color="#000000">Again, assume the Java builder manages its own
-class files in the output folder and knows nothing of the post-builder,
-and conversely.</font>
-<p><font color="#000000">Post-copying of class files to the output folder
-(no overwriting) cannot handle the case where library class files are changed
-or deleted since the last build, because the post-builder is never in a
-position to delete or overwrite class files in the output folder (they
-might have been generated by the Java builder). Once lost, the invariant
-cannot be reachieved no matter how many full builds you do (you're stuck
-with stale or obsolete class files). This is unacceptable.</font>
-<h4>
-<font color="#000000">Combination of pre- and post-builder</font></h4>
-<font color="#000000">Could the copying of class files from the library
-folder to the output folder be accomplished by a pair of separate incremental
-project builders that run on either side of the Java builder?</font>
-<p><font color="#000000">Assume the Java builder manages its own class
-files in the output folder and knows nothing of the pre-builder and post-builder,
-and the pre- and post-builders have no access to the insides of the Java
-builder.</font>
-<p><font color="#000000">Full build:</font>
-<br><font color="#000000"> Pre-builder runs first:</font>
-<br><font color="#000000"> Scrubs
-all class files from O.</font>
-<br><font color="#000000"> Java Builder runs second:</font>
-<br><font color="#000000"> Scrubs
-all class files from O generated by Java builder.</font>
-<br><font color="#000000"> Compiles
-all source files into O.</font>
-<br><font color="#000000"> Post-builder runs third:</font>
-<br><font color="#000000"> Infill/copy
-class files from L to O (no overwriting).</font>
-<p><font color="#000000">Incremental build when L changes:</font>
-<br><font color="#000000"> Pre-builder runs first:</font>
-<br><font color="#000000"> For
-delete or change x.class in L</font>
-<br><font color="#000000">
-Does nothing (FAILs if no corresponding source file)</font>
-<br><font color="#000000"> For
-add x.class to L</font>
-<br><font color="#000000">
-Infill/copy Foo.class from L to O (no overwriting).</font>
-<br><font color="#000000"> Java Builder runs second:</font>
-<br><font color="#000000"> Recompiles
-classes that depend on affected class files in L.</font>
-<br><font color="#000000"> Post-builder runs third:</font>
-<br><font color="#000000"> Infill/copy
-class files from L to O (no overwriting).</font>
-<p><font color="#000000">Incremental build - changes to source folder:</font>
-<br><font color="#000000"> Pre-builder runs first:</font>
-<br><font color="#000000"> Does
-nothing since library did not change.</font>
-<br><font color="#000000"> Java Builder runs second:</font>
-<br><font color="#000000"> Compiles
-source files into O.</font>
-<br><font color="#000000"> Post-builder runs third:</font>
-<br><font color="#000000"> Infill/copy
-class files from L to O (no overwriting).</font>
-<p><font color="#000000">An incremental build may fail in the case of a
-library class file being changed or deleted, leading to stale or obsolete
-class files in the output folder. Fortunately, a full build always achieves
-the invariant, and can be used to repair the damage due to changes to the
-library.</font>
-<p><font color="#000000">So while the combination of pre- and post-builders
-is not perfect, it does work in many cases. If the user could do a full
-build after making changes to the library folder, they would avoid all
-the problems. The solution has the advantage of not requiring anything
-special from the Java Core (i.e., WSAD should be able to implement it themselves).</font>
-<h3>
-<font color="#000000">Resources in Output Folder</font></h3>
-<font color="#000000">When the source folder and output folder coincide,
-there is no problem keeping resource files in the output folder since they
-are not at risk of being overwritten (no with the proposed change to disable
-resource copying when the source folder and output folder coincide).</font>
-<p><font color="#000000">When the source folder and output folder do not
-coincide, keeping resource files in the output folder on a permanent basis
-encounters two issues:</font>
-<p><font color="#000000">(1) The first issue is that output folder has
-no presence in the packages view. Any resources that permanently resided
-in the output folder would therefore be invisible during regular Java development.
-One would have to switch to the resource navigator view to access them.</font>
-<p><font color="#000000">The packages view only shows resource files in
-source and library folders. Changing the packages view to show resources
-in the output folder is infeasible. Including the output folder on the
-classpath as a library folder was discussed at length above and is out
-of the question. Including the output folder on the classpath as a source
-folder is an option (in fact, it's exactly what you get when your source
-and output folders coincide).</font>
-<p><font color="#000000">(2) The second issue is that resource files in
-the output folder are in harm's way of resources of the same name being
-copied from a source folder.</font>
-<p><font color="#000000">If resources existing in the output folder are
-given precedence over the ones in source folders, then the ones from source
-folders would only be copied once and nevermore overwritten. Copies in
-the output folder would get stale or obsolete; automatic cleanup would
-not be possible.</font>
-<p><font color="#000000">On the other hand, if resources existing in source
-folders are given precedence over the ones in the output folders, then
-one that exists only in the output folders would be permanently lost if
-a resource by the same name was ever to be created in a source folder.
-It is a dangerous practice to allow the user to store important data in
-a place that could be clobbered by an automatic mechanism that usually
-operates unseen to the user.</font>
-<p><font color="#000000">Conclusion: Keeping resource files in the output
-folder on a permanent basis is not well supported at the UI, and should
-only be done if the resource files can be considered expendable.</font>
-<br>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/pluggable jdks/pluggable-jdks.html b/org.eclipse.jdt.core/notes/r2.0/pluggable jdks/pluggable-jdks.html
deleted file mode 100644
index ed16382..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/pluggable jdks/pluggable-jdks.html
+++ /dev/null
@@ -1,225 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win98; I) [Netscape]">
- <meta name="Author" content="Build">
- <title>JDT - Pluggable JDKs</title>
-</head>
-<body>
-
-<h2>
-Pluggable JDKs</h2>
-Last revised 11:45 Friday October 19, 2001
-<p>Work item: pluggable JDKs
-<p>Related work item: "Support for dealing with class files generated by
-external Java compilers like javac and jikes from an Ant script."
-<p>Related issue: remote builds
-<p>Other IDEs can claim that when Sun or IBM releases a new JDK, a developer
-can just "plug it in" to their IDE. We would like Eclipse to be similarly
-flexible, and be able to make a similar claim.
-<p>In practice, what does this mean? There are several different aspects.
-<ol>
-<li>
-The ablility to run Java programs with the JDK's JRE.</li>
-
-<li>
-The ablility to compile Java source code against the JDK's class libraries.</li>
-
-<li>
-The ablility to compile Java source code with the JDK's javac compiler.</li>
-
-<li>
-The ablility to debug Java programs with the JDK's JDPA and JVM.</li>
-
-<li>
-The ablility to browse the JDK's class library API javadoc (or perhaps
-other release doc).</li>
-
-<li>
-The ablility to run the JDK's utility programs like javap, javadoc, javah.</li>
-</ol>
-We will take the first four as the most important ones for Eclipse to address,
-and look at each in turn.
-<h3>
-Pluggable JREs</h3>
-This is supported in Eclipse 1.0.
-<p>The org.eclipse.jdt.launching plug-in provides pluggable support ("vmInstallTypes"
-extension point) for describing installed Java2-style Java runtime environments
-and launching particular configurations of a Java virtual machine.
-<p>JDT defines a workbench preference ("Installed Java Runtime Environments")
-so that the user can create, remove, and edit JRE definitions (i.e., instances
-of the known VM installed types). The user chooses which one of the JRE
-definitions is the default.
-<p>JDT also defines a JRE property for each Java project to control which
-JRE is used to run programs in that project. By default, each project shares
-the workspace-wide default. The user can elect to specify a JRE for that
-project, which overrides the workspace-wide default.
-<h3>
-Pluggable JDK class libraries</h3>
-This is supported in Eclipse 1.0.
-<p>JDT Core provides a reserved build classpath variable, named "JRE_LIB",
-which gets bound to the JAR library (and associated source code ZIP) of
-the current workspace-wide default JRE (e.g., "D:\jdk1.4\jre\lib\rt.jar"
-with source in "D:\jdk1.4\src.zip"). By default, a classpath entry is included
-on the build classpath of a newly created project. This library would ordinarily
-supply the compile-time definitions of the standard class libraries used
-when browsing and building a Java project.
-<p>The client that is not satisfied with this variable is free to remove
-the classpath entry from the build classpath and replace it with something
-else. The client could declare their own build classpath variable, bind
-it to a suitable value, and include that on the build classpath instead
-(For instance, VAME/WSDD declares a classpath variable named "IVJ_HOME"
-and references various class libraries relative to it; e.g., "IVJ_HOME/lib/jclmax.jar".)
-Or they could just hard-wire a library entry for a particular JRE library.
-<p>While the basic mechanism is reasonable, it is unfortunate that it is
-tied so tightly to the default JRE. It might be more convenient if selecting
-a different workspace-wide default JRE definition would prompt the user
-to change the JRE_LIB classpath variable as well.
-<p>Paralleling the workbench JRE mechanism, we could consider allowing
-the user to specify classpath variable bindings at the project level that
-override the workspace-wide default. This would allow the user to change
-the binding to affect just that project. Something similar can already
-be achieved by using distinctly-named classpath variables for each project
-(e.g., "P1_JRE_LIB" for project P1's "JRE_LIB"). So it's unclear whether
-any interesting new usecases would be supported by this.
-<h3>
-Pluggable Java compilers</h3>
-Java compilers can differ along many axes:
-<ul>
-<li>
-supported Java language level</li>
-
-<li>
-Java bytecode version</li>
-
-<li>
-quality of generated code</li>
-
-<li>
-helpfulness of error messages</li>
-
-<li>
-performance</li>
-
-<li>
-robustness</li>
-
-<li>
-product support for compiler</li>
-</ul>
-In the simple world of the command line compiler, it's easy to use whatever
-Java compiler you choose to use. The command lines are substantially the
-same, and the overt compiler behavior of translating .java source files
-to .class files is utterly standard.
-<p>In additional to the basic compiler functionality, there are usually
-a number of IDE features that also need to be "language aware" (to some
-extent), including:
-<ul>
-<li>
-source code editing (syntax highlighting)</li>
-
-<li>
-code assist (completion, selection)</li>
-
-<li>
-code reformatter</li>
-
-<li>
-search</li>
-</ul>
-The language aware features require compiler infrastructure (e.g., a scanner).
-<p>The standard Sun Java compiler has no official APIs; the compiler infrastructure
-is not available outside the compiler. This means that Java IDEs have no
-choice but to reimplement whatever compiler infrastructure they might need.
-Without standard Java compiler APIs, no Java IDE can be truely pluggable
-in these regards. The best that a Java IDE can do in the circumstances
-is to use a pluggable Java compiler for its basic compiler functionality.
-<p>In Eclipse 1.0, the IDE's basic Java compiler functionality is provided
-by the built-in Eclipse compiler. What would it take to make this part
-pluggable?
-<p>In Eclipse, the basic Java compiler functionality is provided through
-the Java builder. The Java builder is activated when its build method is
-called. This happens when (a) an explicit Build commands requested by the
-user, (b) the workspace performs an auto build, or (c) some plug-in instigated
-a build programmatically.
-<p>So the first idea is that the Java builder's build method should invoke
-a pluggable Java compiler to do a build.
-<h4>
-Calling a pluggable javac from within the Java builder</h4>
-For a full build, this is clearly doable. The source folders mentioned
-on the build classpath can be walked to identify all Java source files.
-The corresponding class files in the output folder are deleted, and Java
-problem markers are removed. The names of these source files are then passed
-to javac as the ones to compile (large file sets perhaps broken up into
-reasonable sized batches); the classpath passed is computed from the project's
-build classpath; the output folder is passed as the target for the generated
-class files. The compiler will generate class files into the target folder
-and print text error messages to its output stream. Depending on how "standard"
-the format of the output stream was, the Java builder might be able to
-analyze the stream of text error messages and convert these into Java problem
-markers associated with the offending source files (the complete stream
-could also be saved and made available to user through some other mechanism).
-Otherwise the net result is close to that of running the Eclipse compiler.
-One other difference is that the Java builder would not be able to produce
-anything resembling its current internal built state (i.e., no dependency
-graph).
-<p>For an incremental build, it is impossible to do anything more than
-a cursory job without proper dependency information. The Java builder is
-passed a resource delta for the project showing which source files have
-changed. The delta would also show that the build classpath had changed
-(the Java builder could easily remember some classpaths between builds).
-<p>How to do an incremental build:
-<ul>
-<li>
-delete a source file => identify and delete the corresponding class files</li>
-
-<li>
-add a source file => identify and delete corresponding class files (just
-in case); include source file in list to be recompiled</li>
-
-<li>
-change a source file => identify and delete corresponding class files;
-include source file in list to be recompiled</li>
-</ul>
-The compiler is called to recompile the identified list of source files.
-The Java builder might be able to analyze the -verbose output stream to
-discover which source files were actually compiled and update their Java
-problem markers.
-<p>This kind of simple-minded incremental build handles many simple cases
-(e.g., changing the body of a method, fixing javadoc comments, reformatting).
-The results would usually be less satisfactory when the principal structure
-of class is changed because any dependent source files do not get recompiled,
-which may lead to incompatible sets of binaries class files. The developer
-would need to be educated about when to be asking for a full build. Many
-will already be familiar with these rules from using other Java IDEs. With
-a Java compiler that does not produce dependency information, it is hard
-for an IDE with pluggable Java compilers to do any better.
-<p>Autobuild is just an incremental build that is triggered automatically.
-Note that the user may find it intolerable to run with autobuild enabled
-if the overhead for invoking the pluggable compiler is high (which it is
-likely to be if a separate JVM would need to be launched).
-<p>The conclusion is that this is feasible, although autobuilding may be
-intolerable. As long as the pluggable Java compiler was very javac-like
-in terms of command line options and format of generated error messages,
-it should be possible to use it to build a Java project.
-<h4>
-Calling an Ant script instead of the Java builder</h4>
-An even more flexible approach would be to allow a Java project to be configured
-with a generic Ant-based incremental project builder instead of the standard
-Java builder. The Ant-based builder is described in a separate 2.0 Platform
-Core feature proposal.
-<p>All of the above considerations would still apply; the only real difference
-is that everything is implemented in Ant terms.
-<h3>
-Pluggable JDPA Debuggers</h3>
-Eclipse reimplements the JPDA debugger front end; it does not use the JDI
-implementation supplied by Sun. Even if it did use Sun JDI, it still would
-be work for the Eclipse debugger to capitalize on any new debugger functionality
-thereby introduced. So the debugger front end is upgradeable, but not pluggable.
-<p>The JDPA debugger back end is logically part of the Java runtime environment,
-and ships with the IBM and Sun J2SE JDKs since 1.3. So this part is already
-pluggable.
-<br>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/release notes/change_summary.txt b/org.eclipse.jdt.core/notes/r2.0/release notes/change_summary.txt
deleted file mode 100644
index efdc1bb..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/release notes/change_summary.txt
+++ /dev/null
@@ -1,128 +0,0 @@
-**********************************************************
-* BREAKING API CHANGES ***********************************
-**********************************************************
- None
-
-**********************************************************
-* NON-BREAKING API CHANGES *******************************
-**********************************************************
-
- * Added API to set both the classpath and the output location at once.
- IJavaProject.setRawClasspath(
- IClasspathEntry[] newClasspath,
- IPath newOutputLocation,
- IProgressMonitor monitor)
-
- * ICodeCompletionRequestor got deprecated, should use ICompletionRequestor
- instead to obtain:
- (1) - local variable name suggestions
- (2) - parameter name hints
- (3) - method declaration suggestions.
-
- ICompletionRequestor is equivalent to ICodeCompletionRequestor except for
- the following API changes:
-
- (1) + Added API for suggest variable name:
- void acceptVariableName(
- char[] typePackageName,
- char[] typeName,
- char[] name,
- char[] completionName,
- int completionStart,
- int completionEnd);
-
- (2) + Added parameterNames to normal method results API:
- void acceptMethod(
- char[] declaringTypePackageName,
- char[] declaringTypeName,
- char[] selector,
- char[][] parameterPackageNames,
- char[][] parameterTypeNames,
- char[][] parameterNames,<<<<<<<<<<<<<<<< ADDED
- char[] returnTypePackageName,
- char[] returnTypeName,
- char[] completionName,
- int modifiers,
- int completionStart,
- int completionEnd);
-
- (3) + Added API for answering method declaration completions:
- void acceptMethodDeclaration(
- char[] declaringTypePackageName,
- char[] declaringTypeName,
- char[] selector,
- char[][] parameterPackageNames,
- char[][] parameterTypeNames,
- char[][] parameterNames,
- char[] returnTypePackageName,
- char[] returnTypeName,
- char[] completionName,
- int modifiers,
- int completionStart,
- int completionEnd);
-
- * SearchEngine.createJavaSearchScope(IResource[]) has been deprecated.
- Use SearchEngine.createJavaSearchScope(IJavaElement[]) instead.
- The rational is that createJavaSearchScope(IResource[]) was not well
- defined for projects, and it could not define a search scope for java
- elements that didn't have a corresponding resource (e.g. external jars).
-
- The specification of createJavaSearchScope(IJavaElement[]) is as follows:
- - If an element is an IJavaProject, then the project's source folders,
- its jars (external and internal) and its references projects (with their
- source folders and jars, recursively) will be included.
- - If an element is an IPackageFragmentRoot, then only the package fragments of
- this package fragment root will be included.
- - If an element is an IPackageFragment, then only the compilation unit and class
- files of this package fragment will be included. Subpackages will NOT be
- included.
-
- * Classpath entries (except for source folders) can be tagged as exported upon
- creation. When exported, an entry is contributed to dependent projects along
- with its output location.
- Added APIs:
-
- Testing status of a given entry
- + IClasspathEntry.isExported()
-
- Creating entries with export flag
- + JavaCore.newProjectEntry(IPath, boolean)
- + JavaCore.newLibraryEntry(IPath, IPath, IPath, boolean)
- + JavaCore.newVariableEntry(IPath, boolean)
-
- * Search for field read and field write accesses. Two new constants have been added
- on IJavaSearchConstants to be used when creating a field reference search pattern:
- - READ_ACCESSES: the search results contain *only* read access to a field.
- - WRITE_ACCESSES: the search results contain *only* write access to a field.
- Note that if REFERENCES is used, then search results contain both read and write
- accesss to a field.
-
- * org.eclipse.jdt.core.search.IJavaSearchResultCollector now clearly states that
- the order of the search result is unspecified.
-
- * Added 2 new APIs on JavaConventions for classpath validation.
- - IJavaModelStatus validateClasspath(IJavaProject project, IClasspathEntry[] classpath, IPath outputLocation)
- - IJavaModelStatus validateClasspathEntry(IJavaProject project, IClasspathEntry entry, boolean checkSourceAttachment)
-
-
-**********************************************************
-* FUNCTIONALITY CHANGES **********************************
-**********************************************************
-
- * CodeAssist provides variable name suggestions.
- * CodeAssist provides argument names in method completions.
- * CodeAssist completes on method declarations (just enter selector prefix)
- * Project can contribute more than their output folder, using exported classpath entries.
- * CodeAssist inserts qualification on field/method/type references in case of ambiguities (optionally these
- qualification can be forced to occur).
- * CodeAssist optionally performs visibility checks (see JavaCore option: "org.eclipse.jdt.core.codeComplete.visibilityCheck").
- * OpenOnSelection can now locate selected declarations.
- * Search can narrow field read/write access.
- * Assertions support enabled: by default the compiler is 1.3 compliant, but it can
- optionally be turned into source 1.4 mode cf. JavaCore options.
- * Evaluation in binaries is functional
- * Search for references now finds results in binaries. Indexes in old workspaces are recomputed when restarted
- which may result in longer startup times.
- * Search in inner-classes now works. Indexes are recomputed automatically on start-up.
-
-
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/notes/r2.0/variable init/ClasspathVariableInitializer.java b/org.eclipse.jdt.core/notes/r2.0/variable init/ClasspathVariableInitializer.java
deleted file mode 100644
index 94db6e8..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/variable init/ClasspathVariableInitializer.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.eclipse.jdt.core;
-
-/**
- * Abstract base implementation of all classpath variable initializers.
- * Classpath variable initializers are used in conjunction with the
- * "org.eclipse.jdt.core.classpathVariableInitializer" extension point.
- * <p>
- * Clients should subclass this class to implement a specific classpath
- * variable initializer. The subclass must have a public 0-argument
- * constructor and a concrete implementation of <code>initialize</code>.
- * </p>
- */
-public abstract class ClasspathVariableInitializer {
-
- /**
- * Creates a new classpath variable initializer.
- */
- protected ClasspathVariableInitializer() {
- }
-
- /**
- * Binds a value to the workspace classpath variable with the given name,
- * or fails silently if this cannot be done.
- *
- * @param variable the name of the workspace classpath variable
- * that requires a binding
- * @see JavaCore#setClasspathVariable
- */
- protected abstract void initialize(String variable);
-}
diff --git a/org.eclipse.jdt.core/notes/r2.0/variable init/classpathVariableInitializer.html b/org.eclipse.jdt.core/notes/r2.0/variable init/classpathVariableInitializer.html
deleted file mode 100644
index 1a5f6c0..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/variable init/classpathVariableInitializer.html
+++ /dev/null
@@ -1,47 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win98; I) [Netscape]">
- <title>Workbench Extension Point - Classpath Variable Initializer</title>
-</head>
-<body link="#0000FF" vlink="#800080">
-
-<center>
-<h1>
-Classpath Variable Initializer</h1></center>
-<b><i>Identifier: </i></b>org.eclipse.jdt.core.classpathVariableInitializer
-<p><b><i>Description: </i></b>This extension point allows a plug-in to
-register code for programmatically initializing a particular named classpath
-variable.
-<p><b><i>Configuration Markup:</i></b>
-<p><tt> <!ELEMENT classpathVariableInitializer></tt>
-<br><tt> <!ATTLIST classpathVariableInitializer</tt>
-<br><tt> variable CDATA #REQUIRED</tt>
-<br><tt> class
-CDATA #REQUIRED</tt>
-<br><tt> ></tt>
-<ul>
-<li>
-<b>variable</b> - the name of the classpath variable</li>
-
-<li>
-<b>class</b> - the class that implements this classpath variable initializer.
-The class must implement a public subclass of <tt>org.eclipse.jdt.core.ClasspathVariableInitializer</tt>
-with a public 0-argument constructor and an implementation of the <tt>initialize(String)</tt>
-method.</li>
-</ul>
-<b><i>Examples:</i></b>
-<br>The following is an example of an IClasspathVariableInitializer for
-a classpath variable named "FOO":
-<p><tt><extension</tt>
-<br><tt> point="org.eclipse.jdt.core.classpathVariableInitializer"></tt>
-<br><tt> <classpathVariableInitializer</tt>
-<br><tt> variable="FOO"</tt>
-<br><tt> class="com.example.CPVInitializer"/></tt>
-<br><tt></extension></tt>
-<p><b><i>Supplied Implementation:</i></b>
-<br>None.
-<br>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/variable init/uninit-classpath-vars.html b/org.eclipse.jdt.core/notes/r2.0/variable init/uninit-classpath-vars.html
deleted file mode 100644
index 6684fb0..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/variable init/uninit-classpath-vars.html
+++ /dev/null
@@ -1,80 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win98; I) [Netscape]">
- <title>JDT - Uninitialized Classpath Variables</title>
-</head>
-<body>
-
-<h2>
-Uninitialized Classpath Variables</h2>
-Last revised 11:30 Monday November 19, 2001
-<p>Original work item: "Building with uninitialized class path variables.
-You can add a project from the repository that gets built without having
-the JavaUI that initializes the JRE_ variables is activated."
-<p>The general problem is that a classpath variable can show up in a project's
-classpath quite early (for example, when a project is loaded from a repository),
-and well before the activation of a plug-in that might willingly initialize
-the workspace's binding for that variable. Without a binding for all the
-variables mentioned on its build classpath, the project cannot be successfully
-built. However, there is currently no mechanism by which these variables
-can get initialized.
-<p>For variables that the developer (or his team mates) introduces explicitly,
-this is not a particular problem. The developer's corrective action is
-to explicitly establish a binding for the variable, and then rebuild.
-<p>However, there is a problem for variables that are introduced and ordinalrily
-initialized by some tool. For these, the developer may not be in a position
-to explicitly establish a binding for the variable, and might not even
-know which plug-in needs to be activated.
-<p>This problem is a symptom of a more widespread problem. For example,
-PDE suffers this problem with the "ECLIPSE_HOME" variable.
-<h3>
-Proposal</h3>
-We introduce a JDT Core extension point <tt><a href="classpathVariableInitializer.html">org.eclipse.jdt.core.classpathVariableInitializer</a></tt>
-through which plug-ins can supply initializer code for named classpath
-variables.
-<p>Examples of how this would be used:
-<p><tt><extension</tt>
-<br><tt> point = "org.eclipse.jdt.core.classpathVariableInitializer"></tt>
-<br><tt> <classpathVariableInitializer</tt>
-<br><tt> variable="ECLIPSE_HOME"</tt>
-<br><tt> class="org.eclipse.pde.internal.core.EclipseHomeInitializer"/></tt>
-<br><tt></extension></tt>
-<p><tt><extension</tt>
-<br><tt> point = "org.eclipse.jdt.core.classpathVariableInitializer"></tt>
-<br><tt> <classpathVariableInitializer</tt>
-<br><tt> variable="JRE_LIB"</tt>
-<br><tt> class="org.eclipse.jdt.internal.ui.CPVInitializer"/></tt>
-<br><tt></extension></tt>
-<p>The mechanism would work as follows:
-<ul>
-<li>
-It applies automatically each time a classpath containing an unbound classpath
-variable is being resolved (e.g., by JavaCore.getResolvedClasspathEntry
-or IJavaProject.getResolvedClasspath).</li>
-
-<li>
-If classpath variable is unbound in the workspace, it ask if there is a
-registered initializer for that variable.</li>
-
-<li>
-If there is an initializer, it is invoked (it is passed the name of the
-classpath variable that needs to be initialized).</li>
-
-<li>
-The initializer returns no result; it simply has the side effect initializing
-the variable if it can.</li>
-
-<li>
-After the initializer is invoked, the resolution process proceeds whether
-or not the variable is bound or unbound.</li>
-
-<li>
-If there are multiple initializers registered for the same variable, only
-the first one is used (this mechanims does not support alternate or hierarchical
-classpath variable initializers).</li>
-</ul>
-
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/workspace structure/ws-structure-notes.html b/org.eclipse.jdt.core/notes/r2.0/workspace structure/ws-structure-notes.html
deleted file mode 100644
index 5221489..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/workspace structure/ws-structure-notes.html
+++ /dev/null
@@ -1,874 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win98; I) [Netscape]">
- <title>JDT - Notes on Workspace structure</title>
-</head>
-<body>
-
-<h2>
-Notes on Workspace Structure</h2>
-Last revised 17:00 Wednesday September 26, 2001
-<p>In large Java development efforts, it is not uncommon for several inter-related
-projects to be under development at the same time. For the purposes of
-this discussion, assume teams, projects, and components align. All teams
-are working in the same repository, sharing a set of projects via a single
-stream; each project contains the source code for a single component.
-<p>Our example scenario has 4 projects: P1, P2, P3, and P4, with components
-C1 through C4, respectively. C1 is the only component that does not depend
-on any others; C2 depends on C1; C3 depends on C1 and C2; C4 depends on
-C2 (N.B., but not on C1 or C3).
-<p>We assume that there is a single CVS repository that contains all 4
-projects in source code form. In addition, we assume that centralized builds
-are done periodically and posted to a web server where they can be downloaded
-as a unit. These downloads take the form of a zipped directory which includes
-a binary jar for each component, along with corresponding source jars to
-aid debugging.
-<p>We assume that each developer can download builds from the web server
-and install them on their local machine. To do their work, they set up
-Eclipse workspaces on their local machine and load one or more projects
-from the CVS repository. They also upgrade their workspace from time to
-time as new builds become available.
-<p>These assumptions are a plausible abstraction of what goes on in open
-source projects. (It is an open question as to how closely the Eclipse
-project with follow this work model.)
-<h3>
-Developing, Using, and Patching Components</h3>
-The following things are the norm for someone actively <b>developing</b>
-a component:
-<ul>
-<li>
-source code is available for entire component</li>
-
-<li>
-source code is being browsed and changed</li>
-
-<li>
-source code is being compiled regularly</li>
-
-<li>
-source code changes are shared occasionally with other team members</li>
-</ul>
-At the other end of the spectrum are components that are passively <b>used</b>:
-<ul>
-<li>
-component is available as pre-compiled binary library</li>
-
-<li>
-source code is available for browsing but not for editing</li>
-
-<li>
-since used component is static, no changes to share with other team members</li>
-</ul>
-Components that are being <b>patched</b> are one step from being a used
-component in the direction of being a component being developed:
-<ul>
-<li>
-component is available as pre-compiled binary library</li>
-
-<li>
-source code is selectively available for editing (patching)</li>
-
-<li>
-patched source code is compiled and used instead of pre-compiled binary</li>
-
-<li>
-patched source code is for local consumption (not shared with other team
-members)</li>
-</ul>
-The general problem can be stated as follows: each developer needs their
-own workspace so that they can <i>develop</i> their assigned component.
-To to do, they will need to <i>use</i> the components that their component
-depends on, and perhaps use some of the other components that depend on
-theirs. In order to do their work, a developer may need to <i>patch</i>
-a component that they would ordinarily just <i>use</i>; in some cases,
-they might even need to actively develop a component that they would ordinarily
-just <i>use</i>. How can the developers structure their workspaces so that
-they retain sufficient flexibly to switch between using and patching (or
-developing) these other components?
-<p>The various scenarios presented below are all plausible workspace setups,
-each with certain advantages and disadvantages:
-<ul>
-<li>
-<a href="#Component plus libraries">Component plus libraries</a></li>
-
-<li>
-<a href="#Source for everything">Source for everything</a></li>
-
-<li>
-<a href="#Classpath variables to switch between libraries and sources">Classpath
-variables to switch between libraries and sources</a></li>
-
-<li>
-<a href="#Unshared Proxy library projects">Unshared proxy library projects</a></li>
-
-<li>
-<a href="#Shared proxy library projects">Shared proxy library projects</a></li>
-
-<li>
-<a href="#Stub projects">Stub projects</a></li>
-
-<li>
-<a href="#Other Scenarios">Assorted Other Scenarios</a></li>
-</ul>
-
-<h3>
-<a NAME="Component plus libraries"></a>Component plus libraries</h3>
-
-<ul>
-<li>
-Team member's workspace contains just the project for their component.</li>
-
-<li>
-Each team members downloads latest binary build to c:\temp\build\ or some
-such and sets classpath variable BUILD = c:\temp\build\</li>
-
-<li>
-Build classpath references individual libraries relative to BUILD classpath
-variable.</li>
-
-<li>
-Use of classpath variable allows each developer to choose where to install
-the build.</li>
-
-<li>
-Classpath includes libraries for all prerequisite components.</li>
-
-<li>
-Pro: simple workspace setup (load a single shared project from repository
-and set single classpath variable).</li>
-
-<li>
-Pro: no restiction on number of jars per project.</li>
-
-<li>
-Pro: easy to upgrade to another binary build (unzip build in place, and
-close and reopen project in workspace to force a refresh).</li>
-
-<li>
-Con: unable to view code for a component that is not a prerequisite (requires
-loading an additional project).</li>
-
-<li>
-Con: unable to browse code for prerequiste components in proper content
-(code completion).</li>
-
-<li>
-Con: switching to developing another component involves loading another
-project and changing classpaths on dependent components (bad, because these
-are shared).</li>
-
-<li>
-Con: patching only via switching to active development.</li>
-
-<li>
-Note: uses classpath variables whose value is a library jar (works in R1.0).</li>
-
-<li>
-Note: this is roughly the way PDE 1.0 works.</li>
-</ul>
-project P1 (shared)
-<br> build classpath = source /P1/C1
-<br> output folder /P1/bin
-<br>|
-<br>project P2 (shared)
-<br> build classpath = source /P2/C2; BUILD/c1.jar+BUILD/c1src.zip
-<br> output folder /P2/bin
-<br>|
-<br>project P3 (shared)
-<br> build classpath = source /P3/C3; BUILD/c1.jar+BUILD/c1src.zip;
-BUILD/c2.jar+BUILD/c2src.zip
-<br> output folder /P3/bin
-<br>|
-<br>project P4 (shared)
-<br> build classpath = source /P4/C4; BUILD/c2.jar+BUILD/c2src.zip
-<br> output folder /P4/bin
-<h3>
-<a NAME="Source for everything"></a>Source for everything</h3>
-
-<ul>
-<li>
-Team member's workspace contains all four projects and works entirely from
-source code.</li>
-
-<li>
-Build classpath references individual dependent projects by name.</li>
-
-<li>
-Classpath includes projects for all prerequisite components.</li>
-
-<li>
-Pro: able to browse code for all components.</li>
-
-<li>
-Pro: able to develop any component.</li>
-
-<li>
-Pro: easy to notice downstream impact of any changes made since all components
-are present.</li>
-
-<li>
-Pro: easy to keep current (by catching up with stream in repository).</li>
-
-<li>
-Con: Very slow workspace startup and large footprint because entails recompiling
-source code for all components.</li>
-
-<li>
-Con: Initial workspace setup involving multiple shared projects (automation
-possible).</li>
-
-<li>
-Con: difficulty handling projects with precompiled library jars that must
-be exported but do not exist in source (e.g., the Eclipse debugger's JDI
-jar)</li>
-
-<li>
-Note: uses required projects (works in R1.0).</li>
-</ul>
-project P1 (shared)
-<br> build classpath = source /P1/C1
-<br> output folder /P1/bin
-<br>&
-<br>project P2 (shared)
-<br> build classpath = source /P2/C2; project P1
-<br> output folder /P2/bin
-<br>&
-<br>project P3 (shared)
-<br> build classpath = source /P3/C3; project P1; project
-P2
-<br> output folder /P3/bin
-<br>&
-<br>project P4 (shared)
-<br> build classpath = source /P4/C4; project P2
-<br> output folder /P4/bin
-<h3>
-<a NAME="Classpath variables to switch between libraries and sources"></a>Classpath
-variables to switch between libraries and sources</h3>
-
-<ul>
-<li>
-Team member's workspace contains just the project for their component.</li>
-
-<li>
-Each team members downloads latest binary build to c:\temp\build\ or some
-such and sets family of classpath variables, one per component:</li>
-
-<ul>
-<li>
-P1_LIB = c:\temp\build\c1.jar</li>
-
-<li>
-P2_LIB = c:\temp\build\c2.jar</li>
-
-<li>
-P3_LIB = c:\temp\build\c3.jar</li>
-
-<li>
-P4_LIB = c:\temp\build\c4.jar</li>
-</ul>
-
-<li>
-Build classpath references an individual component via a classpath variable.</li>
-
-<li>
-Use of classpath variable allows each developer to choose where to install
-the build.</li>
-
-<li>
-Classpath includes entries for all prerequisite components.</li>
-
-<li>
-Pro: switch to development involves loading an additional project into
-workspace and rebinding a single classpath variable to refer to that project.
-For example, load project P2 and rebind P2_LIB = /P2.</li>
-
-<li>
-Pro: easy to upgrade to another binary build (unzip build in place, and
-close and reopen project in workspace to force a refresh).</li>
-
-<li>
-Con: difficuly attaching debug source to library jar</li>
-
-<li>
-Con: only works if there is exactly one library jar per project.</li>
-
-<li>
-Con: initial workspace setup involving a single shared project and multiple
-variable bindings (automation required).</li>
-
-<li>
-Con: classpath variable names must be agreed on across components.</li>
-
-<li>
-Con: unable to view code for a component that is not a prerequisite (requires
-loading an additional project).</li>
-
-<li>
-Con: unable to browse code for prerequiste components in proper content
-(code completion).</li>
-
-<li>
-Note: uses classpath variables whose value is either a project or a library
-(in R1.0, JDT core supports these but JDT UI does not expose).</li>
-</ul>
-project P1 (shared)
-<br> build classpath = source /P1/C1
-<br> output folder /P1/bin
-<br>|
-<br>project P2 (shared)
-<br> build classpath = source /P2/C2; P1_LIB
-<br> output folder /P2/bin
-<br>|
-<br>project P3 (shared)
-<br> build classpath = source /P3/C3; P1_LIB; P2_LIB
-<br> output folder /P3/bin
-<br>|
-<br>project P4 (shared)
-<br> build classpath = source /P4/C4; P2_LIB
-<br> output folder /P4/bin
-<h3>
-<a NAME="Unshared Proxy library projects"></a>Unshared Proxy library projects</h3>
-
-<ul>
-<li>
-Team member's workspace contains a project for each component.</li>
-
-<li>
-Main project is in source and is shared via the repository.</li>
-
-<li>
-All other projects in workspace are proxy library projects (same name as
-source project; contains no source code; not shared via repository).</li>
-
-<li>
-Each team members downloads latest binary build to c:\temp\build\ or some
-such and sets classpath variable BUILD = c:\temp\build\</li>
-
-<li>
-Build classpath exports libraries relative to BUILD classpath variable.</li>
-
-<li>
-Use of classpath variable allows each developer to choose where to install
-the build.</li>
-
-<li>
-Build classpath references individual dependent projects by name.</li>
-
-<li>
-Pro: able to browse code for all components in context.</li>
-
-<li>
-Pro: easy to switch to another binary build.</li>
-
-<li>
-Pro: switch to patching involves adding source and output folders to non-shared
-project, populating with selected source files, and building; no other
-classpaths need to be changed.</li>
-
-<li>
-Pro: switch to development involves loading an additional shared project
-into workspace over top of non-shared proxy library project; no classpaths
-need to be changed.</li>
-
-<li>
-Pro: easy to upgrade to another binary build (unzip build in place, and
-close and reopen project in workspace to force a refresh).</li>
-
-<li>
-Con: initial workspace setup involving multiple non-shared and shared projects
-(automation required; e.g., preconstructed base workspace).</li>
-
-<li>
-Con: project holding component under development is lost in sea of proxy
-library projects.</li>
-
-<li>
-Pro: no restriction on number of jars per project.</li>
-
-<li>
-Note: the exported libraries are external to the project.</li>
-
-<li>
-Note: uses library projects (proposed for R2.0).</li>
-</ul>
-The base workspace for developers on all teams looks like:
-<p>project P1 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c1.jar+BUILD/c1src.zip
-<br>&
-<br>project P2 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c2.jar+BUILD/c2src.zip;
-project P1
-<br>&
-<br>project P3 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c3.jar+BUILD/c3src.zip;
-project P1; project P2
-<br>&
-<br>project P4 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c4.jar+BUILD/c3src.zip;
-project P2
-<p>None of these projects are shared; however, they have the same names
-as the source projects in repository. This means that any of the library
-projects can be replaced by loading the corresponding source project from
-the repository. (None of the other projects in the workspace need to change.)
-<p>project P1 (shared)
-<br> build classpath = source /P1/C1
-<br> output folder /P1/bin
-<br>|
-<br>project P2 (shared)
-<br> build classpath = source /P2/C2; project P1
-<br> output folder /P2/bin
-<br>|
-<br>project P3 (shared)
-<br> build classpath = source /P3/C3; project P1; project
-P2
-<br> output folder /P3/bin
-<br>|
-<br>project P4 (shared)
-<br> build classpath = source /P4/C4; project P2
-<br> output folder /P4/bin
-<p>Regarding automation, the centralized build could create a simple XML
-document describing the collection of proxy library projects for the workspace.
-Given this document, a special purpose plug-in could be written that would
-create (or modify existing) unshared proxy library projects in the workspace.
-<p><tt><projects></tt>
-<br><tt> <project name="P1"></tt>
-<br><tt> <natures</tt>
-<br><tt>
-<nature id="org.eclipse.jdt.core.javanature"/></tt>
-<br><tt> </natures></tt>
-<br><tt> <libraries></tt>
-<br><tt>
-<classpathentry kind="var" path="BUILD/c1.jar" sourcepath="BUILD/c1src.zip"
-export="true"/></tt>
-<br><tt> </libraries></tt>
-<br><tt> </project></tt>
-<br><tt> <project name="P2"></tt>
-<br><tt> <natures</tt>
-<br><tt>
-<nature id="org.eclipse.jdt.core.javanature"/></tt>
-<br><tt> </natures></tt>
-<br><tt> <libraries></tt>
-<br><tt>
-<classpathentry kind="var" path="BUILD/c2.jar" sourcepath="BUILD/c2src.zip"
-export="true"/></tt>
-<br><tt>
-<classpathentry kind="project" path="/P1"/></tt>
-<br><tt> </libraries></tt>
-<br><tt> </project></tt>
-<br><tt> <project name="P3"></tt>
-<br><tt> <natures</tt>
-<br><tt>
-<nature id="org.eclipse.jdt.core.javanature"/></tt>
-<br><tt> </natures></tt>
-<br><tt> <libraries></tt>
-<br><tt>
-<classpathentry kind="var" path="BUILD/c3.jar" sourcepath="BUILD/c3src.zip"
-export="true"/></tt>
-<br><tt>
-<classpathentry kind="project" path="/P1"/></tt>
-<br><tt>
-<classpathentry kind="project" path="/P2"/></tt>
-<br><tt> </libraries></tt>
-<br><tt> </project></tt>
-<br><tt> <project name="P4"></tt>
-<br><tt> <natures</tt>
-<br><tt>
-<nature id="org.eclipse.jdt.core.javanature"/></tt>
-<br><tt> </natures></tt>
-<br><tt> <libraries></tt>
-<br><tt>
-<classpathentry kind="var" path="BUILD/c4.jar" sourcepath="BUILD/c4src.zip"
-export="true"/></tt>
-<br><tt>
-<classpathentry kind="project" path="/P2"/></tt>
-<br><tt> </libraries></tt>
-<br><tt> </project></tt>
-<br><tt></projects></tt>
-<h3>
-<a NAME="Shared proxy library projects"></a>Shared proxy library projects</h3>
-In the previous approach to using proxy library projects, these projects
-were not under VCM. In this variant of it, the proxy library projects are
-obtained from a repository as well. We will assume that the proxy library
-projects are stored in a different repository from the source projects.
-By assuming they're in a separate binary repository, it is easy to use
-the same project names for both source and binary forms (doing so in the
-same repository would required introducing non-standard binary-only and
-source-only branches in the project version histories).
-<ul>
-<li>
-Team member's workspace contains a project for each component.</li>
-
-<li>
-Main project is in source and is shared via the repository.</li>
-
-<li>
-All other projects in workspace are proxy library projects; same name as
-source project, but in a different repository.</li>
-
-<li>
-Each proxy library project contains and exports one or more binary jar
-libraries (plus attached source zips) equivalent to the source.</li>
-
-<li>
-Build classpath references individual dependent projects by name.</li>
-
-<li>
-Pro: able to browse code for all components.</li>
-
-<li>
-Pro: easy to switch to another binary build.</li>
-
-<li>
-Pro: switch to patching involves adding source and output folders to shared
-proxy library project, populating with selected source files, and building;
-no other classpaths need to be changed.</li>
-
-<li>
-Pro: switch to development involves loading shared source project into
-workspace over top of shared proxy library project with the same name;
-no classpaths need to be changed.</li>
-
-<li>
-Pro: easy to upgrade to another binary build (by catching up with binary
-stream in repository).</li>
-
-<li>
-Pro: no restriction on number of jars per project.</li>
-
-<li>
-Pro: Proxy library projects are also under VCM.</li>
-
-<li>
-Con: initial workspace setup involving multiple shared projects (automation
-possible).</li>
-
-<li>
-Con: Additional effort of building and maintained proxy library projects
-in a separate repository (automation possible, perhaps as part of centralized
-build process).</li>
-
-<li>
-Con: project holding component under development is lost in sea of proxy
-library projects.</li>
-
-<li>
-Note: the exported libraries are internal to the project.</li>
-
-<li>
-Note: uses library projects (proposed for R2.0).</li>
-</ul>
-The base workspace for developers on all teams looks like:
-<p>project P1 (shared via binary repository)
-<br> library project
-<br> build classpath = export /P1/c1.jar+BUILD/c1src.zip
-<br>&
-<br>project P2 (shared via binary repository)
-<br> library project
-<br> build classpath = export /P2/c2.jar+BUILD/c2src.zip;
-project P1
-<br>&
-<br>project P3 (shared via binary repository)
-<br> library project
-<br> build classpath = export /P3/c3.jar+BUILD/c3src.zip;
-project P1; project P2
-<br>&
-<br>project P4 (shared via binary repository)
-<br> library project
-<br> build classpath = export /P4/c4.jar+BUILD/c4src.zip;
-project P2
-<p>The proxy library projects have the same names as the source projects,
-but are stored in a separate repository.
-<p>project P1 (shared via source repository)
-<br> build classpath = source /P1/C1
-<br> output folder /P1/bin
-<br>|
-<br>project P2 (shared via source repository)
-<br> build classpath = source /P2/C2; project P1
-<br> output folder /P2/bin
-<br>|
-<br>project P3 (shared via source repository)
-<br> build classpath = source /P3/C3; project P1; project
-P2
-<br> output folder /P3/bin
-<br>|
-<br>project P4 (shared via source repository)
-<br> build classpath = source /P4/C4; project P2
-<br> output folder /P4/bin
-<h3>
-<a NAME="Stub projects"></a>Stub projects</h3>
-This is a variation on unshared proxy library projects that makes different
-tradeoffs. We call these <i>stub projects</i>. In particular, the ability
-to browse a prereqisite component is traded for the ability to have only
-a minimal set of extra library projects in the workspace. The only difference
-is that stub projects do not require other projects (whereas proxy library
-projects did require other projects). This allow a workspace to get by
-with a less than complete set of stub projects. Creating a stub project
-never forces you to create other stub projects.
-<ul>
-<li>
-Main project is in source and is shared via the repository.</li>
-
-<li>
-That project's required projects are represented in workspace by stub projects
-(same name as source project; not shared via repository).</li>
-
-<li>
-Stub projects are library projects (no source code).</li>
-
-<li>
-A stub project only represents a project's outward appearance to other
-projects.</li>
-
-<li>
-Stub projects never require any other projects.</li>
-
-<li>
-Each team members downloads latest binary build to c:\temp\build\ or some
-such and sets classpath variable BUILD = c:\temp\build\</li>
-
-<li>
-Build classpath exports libraries relative to BUILD classpath variable.</li>
-
-<li>
-Use of classpath variable allows each developer to choose where to install
-the build.</li>
-
-<li>
-Build classpath references individual dependent projects by name.</li>
-
-<li>
-Pro: stub projects are needed only for immediate prerequisites of main
-project.</li>
-
-<li>
-Con: unable to view code for a component that is not a prerequisite (requires
-loading an additional project).</li>
-
-<li>
-Con: unable to browse code for prerequiste components in proper content
-(code completion) because stub does not provide sufficient context.</li>
-
-<li>
-Con: patching only via switching to active development.</li>
-
-<li>
-Pro: switch to development involves loading an additional shared project
-into workspace, possibly over top of stub project; no classpaths need to
-be changed.</li>
-
-<li>
-Pro: easy to upgrade to another binary build (unzip build in place, and
-close and reopen project in workspace to force a refresh).</li>
-
-<li>
-Con: initial workspace setup involving multiple shared projects and stub
-projects; ongoing need for additional stub projects when new source projects
-are loaded (automation required).</li>
-
-<li>
-Pro: no restriction on number of jars per project.</li>
-
-<li>
-Fatal flaw (!): limited able to compile against a stub project due to lack
-of sufficient context Note: the exported libraries are external to the
-project.</li>
-
-<li>
-Note: uses library projects (proposed for R2.0).</li>
-</ul>
-The source projects:
-<p>project P1 (shared)
-<br> build classpath = source /P1/C1
-<br> output folder /P1/bin
-<br>|
-<br>project P2 (shared)
-<br> build classpath = source /P2/C2; project P1
-<br> output folder /P2/bin
-<br>|
-<br>project P3 (shared)
-<br> build classpath = source /P3/C3; project P1; project
-P2
-<br> output folder /P3/bin
-<br>|
-<br>project P4 (shared)
-<br> build classpath = source /P4/C4; project P2
-<br> output folder /P4/bin
-<p>The corresponding stub projects (note the absence of required projects):
-<p>project P1 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c1.jar+BUILD/c1src.zip
-<p>project P2 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c2.jar+BUILD/c2src.zip
-<p>project P3 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c3.jar+BUILD/c3src.zip
-<p>project P4 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c4.jar+BUILD/c3src.zip
-<p>For example, a developer working on P3 would need stub projects for
-P1 and P2.
-<p>project P3 (shared)
-<br> build classpath = source /P3/C3; project P1; project
-P2
-<br> output folder /P3/bin
-<br>&
-<br>project P2 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c2.jar+BUILD/c2src.zip
-<br>&
-<br>project P1 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c1.jar+BUILD/c1src.zip
-<p>If they then decided to develop P1 as well, they would replace P1 by
-the souce project. Their workspace would now look like:
-<p>project P3 (shared)
-<br> build classpath = source /P3/C3; project P1; project
-P2
-<br> output folder /P3/bin
-<br>&
-<br>project P2 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c2.jar+BUILD/c2src.zip
-<br>&
-<br>project P1 (shared)
-<br> build classpath = source /P1/C1
-<br> output folder /P1/bin
-<p>The fatal flaw is clear in the case of a workspace containing P4 and
-a stub for P2.
-<p>project P4 (shared)
-<br> build classpath = source /P4/C4; project P2
-<br> output folder /P4/bin
-<br>&
-<br>project P2 (not shared)
-<br> library project
-<br> build classpath = export BUILD/c2.jar+BUILD/c2src.zip
-<p>If, for example, a class in C4 subclasses a class in C2 which subclasses
-a class in C1, then the compiler will need to get its hands on the class
-in C1. Unfortunately, neither the source code nor binary for C1 is anywhere
-to be found.
-<h3>
-<a NAME="Other Scenarios"></a>Assorted Other Scenarios</h3>
-A couple of other scenarios can be constructed using a combination of the
-techniques employed above:
-<ul>
-<li>
-Unshared proxy library projects with different project names.</li>
-
-<br>Use a classpath variable per component; bind it initially to the name
-of the proxy library project; rebind to name of the source project.
-<ul>
-<li>
-Pro: Allows side-by-side proxy library project and source project.</li>
-
-<li>
-Con: Uses both classpath variables and proxy library projects.</li>
-</ul>
-
-<li>
-Shared proxy library projects with different project names.</li>
-
-<br>Same as preceding except the proxy library projects can be shared.
-Use a classpath variable per component; bind it initially to the name of
-the proxy library project; rebind to name of the source project. Since
-the proxy library project and source projects have different names, there
-are no VCM anomalies.
-<ul>
-<li>
-Pro: Allows side-by-side proxy library project and source project.</li>
-
-<li>
-Pro: Proxy library projects are also under VCM.</li>
-
-<li>
-Con: Uses both classpath variables and proxy library projects.</li>
-</ul>
-
-<li>
-Shared proxy library projects with same project names and same repository.</li>
-
-<br>The proxy library projects can use the same name as the source project
-and be maintained under VCM in the same repository as the source projects.
-Note that this is a non-standard arrangement for a VCM project. The source
-and binary versions of a project need to be thought of as two permanently
-separate branches in the version history: the source versions contains
-source code but no binaries, whereas the binary versions contains binaries
-but no source code. The differences are also reflected in the project's
-.classpath file. In Eclipse, this can be achieved through the use of a
-binaries-only stream separate from the usual stream in which the source
-is maintained. In order to avoid generating unwanted outgoing or incoming
-changes when switching from binary to source, proceed as follows: unshare
-from binary stream; delete from workspace; load and share from source stream.
-<ul>
-<li>
-Pro: Proxy library projects are also under VCM.</li>
-
-<li>
-Pro: One repository holds everything.</li>
-
-<li>
-Con: Project has non-standard dual version history.</li>
-
-<li>
-Con: Separate binaries-only stream means separate branch in version history.</li>
-</ul>
-</ul>
-
-<h3>
-Discussion</h3>
-Of the various workspace setups discussed, the "Component plus libraries"
-approach is the most straightforward, but also the weakest. It should work
-well in cases where developers work on exactly the component they are assigned.
-But it is not recommended in cases where developers assigned to one component
-would need to patch or develop another component in the same workspace.
-<p>The "Source for everything" approach is best for developers who are
-all involved in the joint active development of all of the components.
-There is a limit to how large it will scale, since the cost of recompiling
-everything from source increases method the number and size of components.
-It is not recommended in situations where many of the components are not
-under active development; it will be more efficient to use pre-compiled
-binary libraries for the static components.
-<p>Approaches involving classpath variables do not have much to recommend
-them. They share most of the disadvantages (and none of the advantages)
-of using proxy library projects.
-<p>The "Proxy Library Projects" workspace setup allows each developer to
-work on their assigned component while providing ready access to all other
-components. The arrangement is flexible in allowing easy switching from
-using a component to patching it (or to actively developing it). The two
-setups outlined in detail show how the proxy binary projects can be constructed
-from a downloadable binary build or obtained from a version-managed repository.
-Each has there pluses and minuses. The main drawback of using unshared
-proxy library projects is the significant task of setting up a workspace
-in the first place. This task would have to be automated by some means;
-it would too tedious and error prone to have each developer create a workspace
-from scratch. For shared proxy library projects, the tedium is in creating
-new versions of the projects in their repository. This task could be automated
-as part of the centralized build process.
-<p>The "Stub Projects" workspace setup allows each developer to work on
-their assigned component while providing placeholders for other components
-that it depends on. The arrangement is flexible in allowing easy switching
-from using a component to actively developing it by replacing the placeholder.
-Unfortunately, this approach is fatally flawed because a compiler might
-not have enough information to compile. The other drawbacks are their limited
-useful of the stub projects (can't browse the component; can't patch the
-component), and the ongoing need to create additional proxy projects to
-fill in for the missing prerequisites as real source projects get added
-to the workspace.
-<h3>
-Document History</h3>
-15:45 Wednesday September 5, 2001 - first version sent for comments
-<br>13:30 Thursday September 6, 2001 - revised for first round of comments
-<br>19:40 Wednesday September 12, 2001 - automation for unshared proxy
-library projects
-<br>10:15 Wednesday September 26, 2001 - added stub projects
-<br>17:00 Wednesday September 26, 2001 - documented fatal flaw with stub
-projects
-<br>
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/notes/r2.0/workspace structure/ws-structure.html b/org.eclipse.jdt.core/notes/r2.0/workspace structure/ws-structure.html
deleted file mode 100644
index dd0c806..0000000
--- a/org.eclipse.jdt.core/notes/r2.0/workspace structure/ws-structure.html
+++ /dev/null
@@ -1,448 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
- <title>JDT - Workspace structure</title>
-</head>
-<body>
-
-<h2>
-Workspace Structure</h2>
-Last revised 11:15 Saturday September 8, 2001
-<p>Original work item: "Make the build path less sensitive with regard
-to whether a project is a source or a binary project. This is also related
-to patching (i.e., adding a source folder to a binary project)."
-<p>Related issue: support for extension directories containing many jars.
-<p>There was much discussion. The underlying issue is how to structure
-workspaces for significant Java development efforts. The Eclipse Project
-is an example of such an effort, so the question is not merely of passing
-interest. Since much of what is being developed in the Eclipse Project
-are plug-ins, the question also touches on PDE's domain. However, some
-aspects of the problem affect all significant Java development efforts
-and not just ones for developing plug-ins. So we begin to investigating
-those.
-<h3>
-Problem: Close Collaboration between Adjacent Teams</h3>
-The following is an attempt to capture a familiar problem in a general
-way that does not presume exactly how developers' workspaces are to be
-structured. Consider the case of two components, with PUI dependent on
-Core (imagine that Core is the core component, and UI is the corresponding
-UI component built atop it). Now imagine that Core and UI are under active
-development by two teams, with ownership split along component lines. For
-maximum convenience to both teams, the teams would like to be able to do
-the following:
-<ul>
-<li>
-Each team would like to be able to work in a workspace that contains the
-source code for their component and the binary equivalent (with attached
-source) for all other components.</li>
-
-<li>
-Occasionally (e.g., during debugging) each team would like an easy way
-to workaround (or perhaps induce) problems in another component.</li>
-
-<li>
-Occasionally each team would like an easy way for members to "join the
-other team" and more actively work on another component.</li>
-</ul>
-Generalize from 2 to N the number of teams and components to get the full
-extent of the problem.
-<h3>
-Problem: Large Numbers of Libraries</h3>
-The following Eclipse Corner posting (Jon Skeet <skeet@pobox.com> on
-20.8.2001) describes one concern well:
-<blockquote><i>Referencing a project's libraries in another project: The
-project I'm working on uses a fairly large number of libraries (about 20
-jar files, IIRC). I had hoped I'd be able to create one project which used
-these libraries, and make all other projects have that project on their
-build-paths to bring in the libraries - that way I wouldn't need to change
-*every* project every time I added or removed a library. (It's not a common
-operation, but even so...) Unfortunately, I can't get this to work - putting
-project A on the classpath of project B only seems to put project A's individual
-source/class files on the classpath for project B. I've tried adding as
-an external jar and importing the jar file into the project, and had no
-joy with either :(</i></blockquote>
-Here is the arrangement:
-<blockquote>project P1
-<br> build classpath = source /P1/src; library lib1.jar;
-library lib2.jar; ...; library lib20.jar
-<br> output /P1/bin
-<br>project P2
-<br> build classpath = source /P2/src; library lib1.jar;
-library lib2.jar; ...; library lib20.jar
-<br> output /P2/bin</blockquote>
-It is clear that the customer is looking for a way to deal with a set of
-libraries that would be required by several projects, and was hoping that
-required projects would give him that.
-<h3>
-Review: Required Projects</h3>
-In Eclipse 1.0, the build classpath for a project P can contain an entry
-for another project R, called a <b>required project</b>. Required projects
-work as follows:
-<ul>
-<li>
-The class files in the binary output directory of R are included, like
-a library, on the effective build classpath of P. P's build classpath indicates
-the order of this library relative to others. Other library (and project)
-entries on the build classpath of R have no bearing on P; they are only
-consulted to browse or build R.</li>
-
-<li>
-The names of required projects are recorded in the .classpath file, which
-is under VCM. They are therefore shareable with other developers.</li>
-
-<li>
-Projects are presented as top level elements in the standard packages view.
-A required project is not presented in the packages view as a child of
-the project(s) that requires it.</li>
-
-<li>
-A project's list of required projects (a JDT core notion) is used to computed
-the default value for the project's list of project references (a workspace
-notion).</li>
-
-<li>
-Missing required projects and libraries, and unbound classpath variables,
-generate problems reported against the project resource itself. These kind
-of problems are detected by the Java model (rather than the Java builder).</li>
-</ul>
-
-<h3>
-Review: Classpath Entries</h3>
-In Eclipse 1.0, a classpath is expressed as an array of classpath entries
-(<tt>IClasspathEntry</tt>). There are four kinds of classpath entries:
-<ul>
-<li>
-Source folder entry: denotes a project folder containing .java files. The
-source folder must be contained inside the project where this classpath
-entry is used. Source folder entries are generally used to componentize
-the content of a given project (e.g. org.eclipse.jdt.core/Eclipse Java
-Compiler/). The action of building a Java project will lead to populating
-the project output folder with .class files corresponding to the .java
-files which are contained in all the source folders present on this project
-classpath. Note that the project root can itself be used as a source folder
-(in which case the output folder is also the project itself).</li>
-
-<li>
-Library entry: denotes a binary JAR archive or binary folder. In case of
-pointing at a JAR, the entry can also define a source attachment recommendation
-(path to source archive, and path of source root inside this archive, e.g.
-"c:/jre/src.jar" + "/src").</li>
-
-<li>
-Project entry: denotes a required project. When building, the required
-project is built before the dependent project, and contributes its entire
-output folder (i.e. all its produced .class files). Thus a project never
-directly contributes its source files when building. However, for all source-based
-functionalities (code assist, search, ...), a required project directly
-contributes its sources (i.e. all of its source folders are exposed) so
-that a build action is not mandatory to obtain accurate information; in
-particular, when doing intensive code reorganization, code assist and search
-will still perform accurately even if auto-build is turned off.</li>
-
-<li>
-Variable entry: indirect reference to either a library or a required project.
-A variable entry uses a variable path of the form %variableName%[%pathSuffix%].
-The variable name will be substituted with its actual value, which is a
-workspace defined constant. The path suffix is an optional suffix which
-can be appended to the variable value. PDE uses a global variable to represent
-the Eclipse home directory, and path suffixes to reach the well-known libraries
-(e.g. "ECLIPSE_HOME/org.eclipse.jdt.core/jdtcore.jar").
-Note that in a consistent manner with library entries, variable entries
-can be provided with a variable source attachment recommendation.</li>
-</ul>
-
-<h3>
-Investigation: Make Classpath Variables More Powerful</h3>
-Would making classpath variables more powerful address some the problems
-facing large scale Java development efforts?
-<p>One idea would be to allow variables to be bound to a list of paths
-instead of a single path. This would allow, for example, a single classpath
-variable "BASE_LIBS" to be bound to the list of the paths of the library
-jars lib1.jar; lib2.jar; ...; lib20.jar. Each project referencing this
-classpath variable would thereby gain access to all the libraries:
-<blockquote>project P1
-<br> build classpath = source /P1/src; BASE_LIBS
-<br> output /P1/bin
-<br>project P2
-<br> build classpath = source /P2/src; BASE_LIBS
-<br> output /P2/bin</blockquote>
-Changing the workspace binding of the classpath variable affects all projects
-that reference the variable. This makes it easy to change the set of libraries
-without having to change the projects individually.
-<p>Since classpath variable bindings are local to the workspace, there
-is no obvious automatic way by which these classpath variables would get
-their bindings. The bindings would have to be configured for each workspace;
-loading bindings from a file, or initializing them via a script, are feasible
-options..
-<p>The classpath variables currently bind to paths, and classpath entries
-can contains paths that begin in a variable. Changing variables to bind
-to a list of paths would be a major change, and would likely require reworking
-much of existing API. We generally agreed that we would not pursue this
-approach since it seems somewhat unlikely to solve much of the problem.
-<h3>
-Proposal: Explicitly Export Libraries from Required Projects</h3>
-The proposal is to extend the required projects mechanism to allow a required
-project to contribute more than just its binary output folder. Rather,
-a project would be able to indicate that any of its libraries are to be
-<b>exported</b>.
-Exported libraries also become available to other projects in the workspace
-that list this project as a required project.
-<p>In the above example, the customer could instead have an arrangement
-like:
-<blockquote>project P1
-<br> build classpath = source /P1/source; project PLib
-<br> output /P1/bin
-<br>project P2
-<br> build classpath = source /P2/source; project PLib
-<br> output /P2/bin
-<br>project PLib
-<br> build classpath = source /PLib/source; <b>export</b>
-library lib1.jar; ...; <b>export</b> library lib20.jar
-<br> output /PLib/bin</blockquote>
-What this means is that when P1 (similarly, P2) is built, the libraries
-on its build classpath consists of /PLib/bin, lib1.jar, ..., lib20.jar.
-<p>The modified semantics of a project P with a required project R are
-as follows:
-<ul>
-<li>
-There is an export flag associated with each library explicitly included
-on the build classpath of a project. This flag is meaningful for both library
-classpath entries (both internal and external), and required projects (it
-is not associated with source and output entries.) The export flags are
-recorded in the .classpath file, which is under VCM. These flags are therefore
-shareable with other developers. (These flags can be added in a way that
-does not invalidate existing R1.0 .classpath files.)</li>
-
-<li>
-The class files in the binary output directory of R, along with any libraries
-explicitly exported on R's build classpath, are included as libraries on
-the build classpath of P. P's build classpath indicates the placement of
-this library relative to others; the output folder is always first, with
-the exported libraries and projects included in the user-specified order.
-Exported required projects are expanded inline. This ordering supports
-scenarios where the output folder contains patches to the libraries. Non-exported
-library entries and project entries on the build classpath of R have no
-bearing on P.</li>
-
-<li>
-The names of required projects are recorded in the .classpath file, which
-is under VCM. They are therefore shareable with other developers. (Unchanged.)</li>
-
-<li>
-Projects are presented as top level elements in the standard packages view.
-A required project is not presented in the packages view as a child of
-the project(s) that requires it; nor are the required project's exported
-libraries.</li>
-
-<li>
-A project's list of required projects (a JDT core notion) is used to compute
-the default value for the project's list of project references (a workspace
-notion). (Unchanged.)</li>
-
-<li>
-Missing required projects and libraries, and unbound classpath variables,
-generate problems reported against the project resource itself. These kind
-of problems are detected by the Java model (rather than the Java builder).
-(Unchanged.)</li>
-
-<li>
-Classpath problems pertaining to libraries exported from a required project
-are reported only once, against the project closest to the problem. The
-problematic entries are elided from the effective classpath of dependent
-projects.</li>
-</ul>
-Example:
-<blockquote>project P
-<br> build classpath = source /P/source; project R; library
-plib.jar
-<br> output /P/bin
-<br>project R
-<br> build classpath = source /R/source; <b>export</b>
-library rlib1.jar; library rlib2.jar; <b>export</b> project Q; <b>export</b>
-library rlib3.jar
-<br> output /R/bin
-<br>project Q
-<br> build classpath = source /Q/source
-<br> output /Q/bin</blockquote>
-Effective build classpath of P:
-<blockquote> build classpath = source /P/source; library
-/R/bin; library rlib1.jar; library /Q/bin; library rlib3.jar; library plib.jar</blockquote>
-
-<h4>
-Exporting External Libraries</h4>
-Relative to a given project, a library is internal iff the path to the
-jar or folder lies inside the project's resource tree. Other libraries
-are considered external to the project.
-<p>Should projects be allowed to export arbitrary libraries, or should
-exported libraries always be internal to the project?
-<p>Restricting exports to internal libraries ensures that a project that
-is to be used by other projects is somewhat self contained. If you load
-such a project from a repository, you are guaranteed all the libraries
-it exports will be contained therein.
-<p>On the other hand, unrestricted exports are more flexible, and allow
-a project to export a collection of libraries that are not necessarily
-contained within the project's resource tree. (However, it is unclear whether
-this additional flexibility would be useful.)
-<p>We opted to allow unrestricted imports, but decided to simplify the
-error processing by only reporting problems against the project with the
-missing library (or required project) explicitly on its classpath. Any
-missing entries would simply be omitted from the effective classpath calculation.for
-dependent projects.
-<h4>
-Classpath Variables</h4>
-A project's build classpath may include references to classpath variables
-that get bound to libraries (or other projects). How do exports and variables
-interact?
-<p>The export flag could be associated either with the variable reference
-or with the variable binding. If the export flag is associated with the
-variable reference, it would indicate exporting whatever library the classpath
-variable happened to be bound to on a given occasion. If the export flag
-is associated with the variable binding itself, the library the classpath
-variable happened to be bound to on a given occasion would be exported
-conditionally on the flag in the binding. The proposal is to go with the
-former (export flag with variable reference) since its semantics are somewhat
-simpler and allow the export flag to be shared with other team members
-(the bindings of classpath variables are not shareable).
-<h4>
-Exporting Auxillary Libraries</h4>
-Note that explicit exports also address another problem that arises when
-a project needs to export a pre-built library in addition to the results
-of compiling its source files (the Eclipse debugger's jdi.jar is a fine
-instance of this). In Eclipse 1.0, only the class files in the project's
-binary output folder are exported to dependent projects. This proposal
-allows a project to export any number of additional libraries as required.
-<h4>
-Exporting Projects</h4>
-By exporting other projects, a project can consolidate and concentrate
-the outputs from several other projects:..
-<blockquote>project P1
-<br> build classpath = source /P/source; export library
-/P1/lib1.jar
-<br> output /P1/bin
-<br>project P2
-<br> build classpath = source /P2/source; export library /P2/lib2.jar
-<br> output /P2/bin
-<br>project P1andP2
-<br> build classpath = source /P1andP2/source; export project
-P1; export project P2
-<br> output /P1andP2/bin</blockquote>
-Effective build classpath of P1andP2 includes everything exported from
-both P1 and P2:
-<blockquote>build classpath = library /P1andP2/source; library /P1/bin;
-library /P1/lib1.jar; library /P2/bin; library /P2/lib2.jar
-<br>output /P1andP2/bin</blockquote>
-
-<h3>
-Proposal: Admit Library Projects which Contain No Source Code</h3>
-One objection to this whole approach is that the Java project is being
-hijacked. In the original design, a Java project is a buildable container
-of Java source code. The addition of exported libraries starts to turn
-the project into something more general. If we are comfortable with this
-general trend, there are ways that the design can embrace it more whole-heartedly.
-<p>The above proposal to expand the semantics of required project creates
-a new role for a Java project as a container of libraries. This notion
-of <b>library project</b> is rounded out by allowing Java projects without
-source or output folders. The build classpath of a library project orders
-the list of exported libraries and projects (and provides the additional
-context required for browsing the project itself).
-<p>In our example, the library project could be expressed more directly
-without having to postulate source and output folders which are completely
-unmotivated in this case:
-<p>project PLib
-<br> build classpath = <b>export</b> library lib1.jar;
-...; <b>export</b> library lib20.jar
-<p>A library project is recognizable simply by the absence of source folders
-on the build classpath. (We considered adding a new flag to the project
-to explicitly mark library projects, but decided this was not necessary
-and would be confusing.)
-<p>Note that library projects are not "buildable" in any meaningful sense
-since they lack source code to compile (and without source code there is
-no pressing need for a binary output folder). However, there still needs
-to be a mechanism for detecting and reporting errors in the build classpath
-for library projects. Except for such checks, the Java incremental project
-builder should ignore library projects.
-<p>The following kinds of entries on the build classpath of a library project
-would serve these purposes:
-<ul>
-<li>
-Source folders - a library project has no source folders, by definition.</li>
-
-<li>
-Output folders - not needed for a library project.</li>
-
-<li>
-Unexported libraries - provides context when browsing this project.</li>
-
-<li>
-Unexported required projects - provides context when browsing this project.</li>
-</ul>
-However, the API (and UI?) should allow the information in all fields to
-be maintained even for library projects, possibly to facilitate switching
-a project between a regular and a library project.
-<p>The workspace must compute an input delta even for incremental project
-builders that ignore the delta they are handed. We considered whether we
-should go one step further and remove the Java builder from a library project's
-list of incremental project builders. This would make it crystal clear
-that there is no Java building going on, and it would reduce workspace
-memory footprint because the workspace would not need to remember the shape
-of the resource tree at the time of the last build. However, if the builder
-was removed for library projects, there would need to be mechanism to add
-it if the classpath was changed to include a source project. We decided
-that we should simply avoid the additional hassles and leave the Java builder
-installed for all Java projects.
-<h3>
-Background</h3>
-From Philippe Mulet 08/31/2001 12:13 PM
-<p>I also think this has to be a basic mechanism at the JavaCore level,
-which the PDE can then surface to plugin writers.
-<br>I would like to see this one addressed asap, so that it is possible
-to share projects transparently at least amongst us.
-<p>=======
-<p>From Erich Gamma on 08/31/2001 12:43 PM
-<p>Here is some more input on our favorite topic "make the build class
-path less sensitive
-<br>with regard to whether a project is a source or binary project".
-<p>Our conclusion in SNZ was that this boils down to a PDE project layout
-issue (binary
-<br>projects etc). However, the EC discussion from below illustrates a
-use case for allowing to export
-<br>JARs in addition to the output folder from a project, that is independent
-of PDE.
-<br>The scenario is similar to the WSAD scenario with extension dirs. If
-we support to
-<br>contribute contained JARs from a project then this problem would be
-addressed.
-<p>We should therefore reconsider the solution independent of the PDE issue.
-<br>If I do that then I come to the conclusion that the proposed mechanism
-is valuable
-<br>and I suggest to go ahead with specifying it in detail.
-<p>Thoughts?
-<p>=======
-<br>From Jon Skeet <skeet@pobox.com> on Eclipse Corner 20.8.2001
-<p>Referencing a project's libraries in another project:
-<br>The project I'm working on uses a fairly large number of libraries
-<br>(about 20 jar files, IIRC). I had hoped I'd be able to create one
-<br>project which used these libraries, and make all other projects have
-<br>that project on their build-paths to bring in the libraries - that
-way I
-<br>wouldn't need to change *every* project every time I added or removed
-a
-<br>library. (It's not a common operation, but even so...) Unfortunately,
-I
-<br>can't get this to work - putting project A on the classpath of project
-B
-<br>only seems to put project A's individual source/class files on the
-<br>classpath for project B. I've tried adding as an external jar and
-<br>importing the jar file into the project, and had no joy with either
-:(
-<h3>
-Document History</h3>
-[...]
-<br>Revised 10:40 Wednesday September 5, 2001 - Library projects not explicitly
-marked.
-<br>Revised 11:15 Saturday September 8, 2001 - Allow exporting external
-libraries and projects.
-</body>
-</html>
diff --git a/org.eclipse.jdt.core/plugin.jars b/org.eclipse.jdt.core/plugin.jars
index 5ecd897..b47c1c8 100644
--- a/org.eclipse.jdt.core/plugin.jars
+++ b/org.eclipse.jdt.core/plugin.jars
@@ -1,9 +1,9 @@
-jdtcore.jar=\
- batch,\
- codeassist,\
- compiler,\
- eval,\
- formatter,\
- dom,\
- model, \
- search
+jdtcore.jar=\
+ batch,\
+ codeassist,\
+ compiler,\
+ eval,\
+ formatter,\
+ dom,\
+ model, \
+ search
diff --git a/org.eclipse.jdt.core/plugin.properties b/org.eclipse.jdt.core/plugin.properties
index 96ff6d1..c22753d 100644
--- a/org.eclipse.jdt.core/plugin.properties
+++ b/org.eclipse.jdt.core/plugin.properties
@@ -1,3 +1,13 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
providerName=Eclipse.org
pluginName=Java Development Tools Core
javaNatureName=Java
@@ -7,4 +17,5 @@
transientJavaProblemName=Transient Java Problem
classpathVariableInitializersName=Classpath Variable Initializers
classpathContainerInitializersName=Classpath Container Initializers
-codeFormatterName=Code Formatter
\ No newline at end of file
+codeFormattersName=Source Code Formatters
+javaTaskName=Java Task
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/plugin.xml b/org.eclipse.jdt.core/plugin.xml
index 557066d..3984254 100644
--- a/org.eclipse.jdt.core/plugin.xml
+++ b/org.eclipse.jdt.core/plugin.xml
@@ -7,7 +7,7 @@
<plugin
name = "%pluginName"
id = "org.eclipse.jdt.core"
- version = "2.0.0"
+ version = "2.1.0"
provider-name = "%providerName"
class="org.eclipse.jdt.core.JavaCore">
@@ -19,6 +19,7 @@
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.apache.xerces"/>
<import plugin="org.eclipse.ant.core" optional="true"/>
+ <import plugin="org.eclipse.team.core" optional="true"/>
</requires>
<!-- =================================================================================== -->
@@ -27,7 +28,8 @@
<runtime>
<library name="jdtcore.jar">
- <export name = "*"/>
+ <export name="*"/>
+ <packages prefixes="org.eclipse.jdt.core,org.eclipse.jdt.internal"/>
</library>
</runtime>
@@ -56,7 +58,9 @@
<!-- -->
<!-- =================================================================================== -->
-<extension-point name="%classpathVariableInitializersName" id="classpathVariableInitializer"/>
+<extension-point name="%classpathVariableInitializersName"
+ id="classpathVariableInitializer"
+ schema="schema/classpathVariableInitializer.exsd"/>
<!-- =================================================================================== -->
<!-- Extension Point: Initializers of Classpath Containers -->
@@ -67,9 +71,9 @@
<!-- class CDATA #REQUIRED -->
<!-- > -->
<!-- where: -->
-<!-- - id - an unique name identifying all containers for which this resolver will -->
+<!-- - id - a unique name identifying all containers for which this initializer will -->
<!-- be activated. -->
-<!-- - class - the class that implements this container resolver. -->
+<!-- - class - the class that implements this container initializer. -->
<!-- The class must implement a public subclass of -->
<!-- org.eclipse.jdt.core.ClasspathContainerResolver with a public -->
<!-- 0-argument constructor. -->
@@ -77,7 +81,7 @@
<!-- Example of an ClasspathContainerInitializer for a classpath container named -->
<!-- "JDK/1.2": -->
<!-- <extension -->
-<!-- point="org.eclipse.jdt.core.containerResolver"> -->
+<!-- point="org.eclipse.jdt.core.classpathContainerInitializer"> -->
<!-- <classpathContainerInitializer -->
<!-- id="JDK" -->
<!-- class="com.example.MyInitializer"/> -->
@@ -85,7 +89,9 @@
<!-- -->
<!-- =================================================================================== -->
-<extension-point name="%classpathContainerInitializersName" id="classpathContainerInitializer"/>
+<extension-point name="%classpathContainerInitializersName"
+ id="classpathContainerInitializer"
+ schema="schema/classpathContainerInitializer.exsd"/>
<!-- =================================================================================== -->
<!-- Extension Point: Formatter of Source Code -->
@@ -109,7 +115,9 @@
<!-- -->
<!-- =================================================================================== -->
-<extension-point name="%codeFormatterName" id="codeFormatter"/>
+<extension-point name="%codeFormattersName"
+ id="codeFormatter"
+ schema="schema/codeFormatter.exsd"/>
<!-- =================================================================================== -->
@@ -164,6 +172,8 @@
<super type="org.eclipse.core.resources.textmarker"/>
<persistent value="true"/>
<attribute name ="cycleDetected"/>
+ <attribute name="id"/>
+ <attribute name="arguments"/>
</extension>
<!-- Java transient problems -->
@@ -175,6 +185,13 @@
<attribute name="flags"/>
<attribute name="arguments"/>
</extension>
+
+<!-- Java tasks -->
+
+<extension id="task" name="%javaTaskName" point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.core.resources.taskmarker"/>
+ <persistent value="true"/>
+</extension>
<!-- =================================================================================== -->
<!-- Extension: Javac Ant Adapter -->
diff --git a/org.eclipse.jdt.core/schema/classpathContainerInitializer.exsd b/org.eclipse.jdt.core/schema/classpathContainerInitializer.exsd
new file mode 100644
index 0000000..4012cfe
--- /dev/null
+++ b/org.eclipse.jdt.core/schema/classpathContainerInitializer.exsd
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.jdt.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.jdt.core" id="classpathContainerInitializer" name="Classpath Container Initializers"/>
+ </appInfo>
+ <documentation>
+ This extension point allows clients to contribute custom classpath container initializers,
+ which are used to lazily bind classpath containers to instances of org.eclipse.jdt.core.IClasspathContainer.
+ </documentation>
+</annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="classpathContainerInitializer" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="classpathContainerInitializer">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique name identifying all containers for which this initializer will be activated.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the class that implements this container initializer.
+ This class must implement a public subclass of <code>org.eclipse.jdt.core.ClasspathContainerInitializer</code> with a public 0-argument constructor.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ Example of a declaration of a <code>ClasspathContainerInitializer</code> for a classpath container named "JDK/1.2": <pre>
+<extension point="org.eclipse.jdt.core.classpathContainerInitializer">
+ <classpathContainerInitializer
+ id="JDK"
+ class="com.example.MyInitializer"/>
+</extension>
+</pre>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ <p>
+<a href="hglegal.htm">
+ <img SRC="ngibmcpy.gif"
+ ALT="Copyright IBM Corp. 2000, 2003. All Rights Reserved."
+ BORDER=0 height=14 width=324></a>
+</p>
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.jdt.core/schema/classpathVariableInitializer.exsd b/org.eclipse.jdt.core/schema/classpathVariableInitializer.exsd
new file mode 100644
index 0000000..6e20b2a
--- /dev/null
+++ b/org.eclipse.jdt.core/schema/classpathVariableInitializer.exsd
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.jdt.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.jdt.core" id="classpathVariableInitializer" name="Classpath Variable Initializers"/>
+ </appInfo>
+ <documentation>
+ This extension point allows clients to contribute custom classpath variable initializers,
+ which are used to lazily bind classpath variables.
+ </documentation>
+</annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="classpathVariableInitializer" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="classpathVariableInitializer">
+ <complexType>
+ <attribute name="variable" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique name identifying the variable for which this initializer will be activated.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the class that implements this variable initializer.
+ This class must implement a public subclass of <code>org.eclipse.jdt.core.ClasspathVariableInitializer</code> with a public 0-argument constructor.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ Example of a declaration of a <code>ClasspathVariableInitializer</code> for a classpath variable named "FOO": <pre>
+<extension point="org.eclipse.jdt.core.classpathVariableInitializer">
+ <classpathVariableInitializer
+ variable="FOO"
+ class="com.example.CPVInitializer"/>
+</extension>
+</pre>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ <p>
+<a href="hglegal.htm">
+ <img SRC="ngibmcpy.gif"
+ ALT="Copyright IBM Corp. 2000, 2003. All Rights Reserved."
+ BORDER=0 height=14 width=324></a>
+</p>
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.jdt.core/schema/codeFormatter.exsd b/org.eclipse.jdt.core/schema/codeFormatter.exsd
new file mode 100644
index 0000000..3ab4666
--- /dev/null
+++ b/org.eclipse.jdt.core/schema/codeFormatter.exsd
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.jdt.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.jdt.core" id="codeFormatter" name="Code Formatters"/>
+ </appInfo>
+ <documentation>
+ This extension point allows clients to contribute new source code formatter implementations.
+ </documentation>
+</annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="codeFormatter" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="codeFormatter">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the class that defines the code formatter implementation. This class must be a public implementation of <code>org.eclipse.jdt.core.ICodeFormatter</code> with a public 0-argument constructor.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 2.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ Example of an implementation of <code>ICodeFormatter</code>: <pre>
+<extension point="org.eclipse.jdt.core.codeFormatter">
+ <codeFormatter
+ class="com.example.MyCodeFormatter"/>
+</extension>
+</pre>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ <p>
+<a href="hglegal.htm">
+ <img SRC="ngibmcpy.gif"
+ ALT="Copyright IBM Corp. 2000, 2003. All Rights Reserved."
+ BORDER=0 height=14 width=324></a>
+</p>
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.jdt.core/scripts/buildExtraJars.xml b/org.eclipse.jdt.core/scripts/buildExtraJars.xml
new file mode 100644
index 0000000..363b77b
--- /dev/null
+++ b/org.eclipse.jdt.core/scripts/buildExtraJars.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="org.eclipse.core.resources" default="main" basedir="..">
+
+ <property name="bootclasspath" value=""/>
+
+ <target name="main">
+ <available file="${basedir}/jdtCompilerAdapter.jar" property="do.not.rebuild"/>
+ <antcall target="build"/>
+ </target>
+
+ <target name="build" unless="do.not.rebuild">
+ <antcall target="clean"/>
+ <antcall target="jdtCompilerAdapter.jar"/>
+ <antcall target="refresh"/>
+ </target>
+
+ <target name="init" depends="properties">
+ <property name="plugin" value="org.eclipse.jdt.core"/>
+ <property name="temp.folder" value="${basedir}/temp.folder"/>
+ <property name="plugin.destination" value="${basedir}"/>
+ <property name="build.result.folder" value="${basedir}"/>
+ </target>
+
+ <target name="properties" if="eclipse.running">
+ <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
+ </target>
+
+ <target name="jdtCompilerAdapter.jar" depends="init">
+ <property name="destdir" value="${temp.folder}/jdtCompilerAdapter.jar.bin"/>
+ <delete dir="${temp.folder}/jdtCompilerAdapter.jar.bin"/>
+ <mkdir dir="${temp.folder}/jdtCompilerAdapter.jar.bin"/>
+ <!-- compile the source code -->
+ <javac destdir="${temp.folder}/jdtCompilerAdapter.jar.bin" failonerror="false" target="1.1" source="1.3" verbose="false" debug="on" includeAntRuntime="no" bootclasspath="${bootclasspath}" classpath="../org.eclipse.core.runtime/bin;../org.eclipse.core.runtime/runtime.jar;../org.eclipse.core.resources/bin;../org.eclipse.core.resources/resources.jar;../org.apache.ant/ant.jar;../org.eclipse.jdt.core/bin;../org.eclipse.jdt.core/jdtcore.jar;">
+ <src path="antadapter/"/>
+ </javac>
+ <!-- copy necessary resources activate when we
+ <copy todir="${temp.folder}/jdtCompilerAdapter.jar.bin">
+ <fileset dir="antadapter/" excludes="**/*.java"/>
+ </copy> -->
+ <jar jarfile="${build.result.folder}/jdtCompilerAdapter.jar" basedir="${temp.folder}/jdtCompilerAdapter.jar.bin"/>
+ <delete dir="${temp.folder}"/>
+ </target>
+
+ <target name="clean" depends="init">
+ <delete file="${build.result.folder}/jdtCompilerAdapter.jar"/>
+ <delete dir="${temp.folder}"/>
+ </target>
+
+ <target name="refresh" depends="init" if="eclipse.running">
+ <eclipse.refreshLocal resource="${plugin}" depth="infinite"/>
+ </target>
+
+</project>
\ No newline at end of file
diff --git a/org.eclipse.jdt.core/scripts/exportplugin.xml b/org.eclipse.jdt.core/scripts/exportplugin.xml
index 6dbbbf7..4be92cb 100644
--- a/org.eclipse.jdt.core/scripts/exportplugin.xml
+++ b/org.eclipse.jdt.core/scripts/exportplugin.xml
@@ -1,28 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- build script to create a plugin from org.eclipse.jdt.core -->
-<project name="org.eclipse.jdt.core" default="export plug-in [_2.0.0]" basedir="..">
+<project name="org.eclipse.jdt.core" default="export plug-in [_2.1.0]" basedir="..">
<target name="zz_init">
<tstamp/>
<property name="export-dir" value="../../plugin-export" />
</target>
+<target name="export plug-in [_2.1.0]" depends="zz_init">
+ <antcall target="zz_internal_export">
+ <param name="dest" value="${export-dir}/org.eclipse.jdt.core_2.1.0"/>
+ </antcall>
+</target>
+
+<target name="export plug-in [_2.1.0] (directory structure)" depends="zz_init">
+ <antcall target="zz_internal_export_structure">
+ <param name="bin_dest" value="${export-dir}/eclipse/plugins/org.eclipse.jdt.core_2.1.0"/>
+ <param name="src_dest" value="${export-dir}/eclipse/plugins/org.eclipse.jdt.source_2.1.0/src/org.eclipse.jdt.core_2.1.0"/>
+ </antcall>
+</target>
+
+<target name="export plug-in [_2.0.1]" depends="zz_init">
+ <antcall target="zz_internal_export">
+ <param name="dest" value="${export-dir}/org.eclipse.jdt.core_2.0.1"/>
+ </antcall>
+</target>
+
<target name="export plug-in [_2.0.0]" depends="zz_init">
<antcall target="zz_internal_export">
- <param name="dest" value="${export-dir}/org.eclipse.jdt.core_2.0.0"/>
+ <param name="dest" value="${export-dir}/org.eclipse.jdt.core_2.0.0"/>
</antcall>
</target>
<target name="export plug-in [_1.9.0]" depends="zz_init">
<antcall target="zz_internal_export">
- <param name="dest" value="${export-dir}/org.eclipse.jdt.core_1.9.0"/>
+ <param name="dest" value="${export-dir}/org.eclipse.jdt.core_1.9.0"/>
</antcall>
</target>
<target name="export plug-in [no version]" depends="zz_init">
<antcall target="zz_internal_export">
- <param name="dest" value="${export-dir}/org.eclipse.jdt.core"/>
+ <param name="dest" value="${export-dir}/org.eclipse.jdt.core"/>
</antcall>
</target>
@@ -60,6 +79,57 @@
<echo message="UPDATE jdtcoresrc.zip" />
<zip zipfile="${dest}/jdtcoresrc.zip">
+ <zipfileset dir="batch" />
+ <zipfileset dir="codeassist" />
+ <zipfileset dir="compiler" />
+ <zipfileset dir="dom" />
+ <zipfileset dir="eval" />
+ <zipfileset dir="formatter" />
+ <zipfileset dir="model" />
+ <zipfileset dir="search" />
+ </zip>
+ <echo message="UPDATE jdtCompilerAdaptersrc.zip" />
+ <zip zipfile="${dest}/jdtCompilerAdaptersrc.zip">
+ <zipfileset dir="antadapter" />
+ </zip>
+</target>
+
+<target name="zz_internal_export_structure">
+
+ <tstamp/>
+
+ <echo message="TARGET: ${export-dir}" />
+ <mkdir dir="${export-dir}" />
+ <delete dir="${bin_dest}" />
+ <delete dir="${src_dest}" />
+ <mkdir dir="${bin_dest}" />
+ <mkdir dir="${src_dest}" />
+
+ <echo message="UPDATE jdtcore.jar" />
+ <jar
+ jarfile="${bin_dest}/jdtcore.jar"
+ basedir="bin"
+ excludes="**/JDTCompilerAdapter.class"/>
+
+ <echo message="UPDATE jdtCompilerAdapter.jar" />
+ <jar
+ jarfile="${bin_dest}/jdtCompilerAdapter.jar"
+ basedir="bin"
+ includes="**/JDTCompilerAdapter.class"/>
+
+ <echo message="UPDATE plugin.xml" />
+ <copy file="plugin.xml" todir="${bin_dest}" />
+ <echo message="UPDATE plugin.properties" />
+ <copy file="plugin.properties" todir="${bin_dest}" />
+
+ <echo message="UPDATE .options" />
+ <copy file=".options" todir="${bin_dest}" />
+
+ <echo message="UPDATE about.html" />
+ <copy file="about.html" todir="${bin_dest}" />
+
+ <echo message="UPDATE jdtcoresrc.zip" />
+ <zip zipfile="${src_dest}/jdtcoresrc.zip">
<zipfileset dir="antadapter" />
<zipfileset dir="batch" />
<zipfileset dir="codeassist" />
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchConstants.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchConstants.java
index bb04da3..e95342d 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchConstants.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchConstants.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.search;
import org.eclipse.jdt.internal.core.search.processing.*;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchResultCollector.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchResultCollector.java
index 1fc2414..7e94ccb 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchResultCollector.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchResultCollector.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.search;
import org.eclipse.core.resources.IResource;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchScope.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchScope.java
index 8da06d7..067fa56 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchScope.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/IJavaSearchScope.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.search;
import org.eclipse.core.runtime.IPath;
@@ -44,15 +44,28 @@
/**
* Checks whether this scope encloses the given element.
*
- * @param element the element
+ * @param element the given element
* @return <code>true</code> if the element is in this scope
*/
public boolean encloses(IJavaElement element);
/**
* Returns the paths to the enclosing projects and JARs for this search scope.
+ * <ul>
+ * <li> If the path is a project path, this is the full path of the project
+ * (see <code>IResource.getFullPath()</code>).
+ * E.g. /MyProject
+ * </li>
+ * <li> If the path is a JAR path and this JAR is internal to the workspace,
+ * this is the full path of the JAR file (see <code>IResource.getFullPath()</code>).
+ * E.g. /MyProject/mylib.jar
+ * </li>
+ * <li> If the path is a JAR path and this JAR is external to the workspace,
+ * this is the full OS path to the JAR file on the file system.
+ * E.g. d:\libs\mylib.jar
+ * </li>
+ * </ul>
*
- * @return an array of paths to the enclosing projects and JARS. A project path is
- * the full path to the project. A JAR path is the full OS path to the JAR file.
+ * @return an array of paths to the enclosing projects and JARS.
*/
IPath[] enclosingProjectsAndJars();
/**
@@ -60,7 +73,8 @@
* in folders or within JARs).
*
* @return whether this scope contains any <code>.class</code> files
- * @deprecated
+ * @deprecated Use SearchEngine.createJavaSearchScope(IJavaElement[]) with the package fragment
+ * roots that correspond to the binaries instead
*/
boolean includesBinaries();
/**
@@ -68,7 +82,8 @@
* the projects of the resources of this search scope.
*
* @return whether this scope includes classpaths
- * @deprecated
+ * @deprecated Use SearchEngine.createJavaSearchScope(IJavaElement[])
+ * with a java project instead
*/
boolean includesClasspaths();
/**
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/ISearchPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/ISearchPattern.java
index 27839ce..b63f89f 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/ISearchPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/ISearchPattern.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.search;
/**
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/ITypeNameRequestor.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/ITypeNameRequestor.java
index d3809e2..fa4e0c2 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/ITypeNameRequestor.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/ITypeNameRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.search;
/**
@@ -32,7 +32,11 @@
* is a top-level type.
* @param path the full path to the resource containing the class. If the resource is a .class file
* or a .java file, this is the full path in the workspace to this resource. If the
- * resource is a .zip or .jar file, this is the full OS path to this file.
+ * resource is an archive (i.e. a .zip or .jar file), the path is composed of 2 paths separated
+ * by <code>IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR</code>:
+ * the first path is the full OS path to the archive (if it is an external archive),
+ * or the workspace relative <code>IPath</code> to the archive (if it is an internal archive),
+ * the second path is the path to the resource inside the archive.
*/
void acceptClass(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path);
/**
@@ -47,7 +51,11 @@
* is a top-level type.
* @param path the full path to the resource containing the interface. If the resource is a .class file
* or a .java file, this is the full path in the workspace to this resource. If the
- * resource is a .zip or .jar file, this is the full OS path to this file.
- */
+ * resource is an archive (i.e. a .zip or .jar file), the path is composed of 2 paths separated
+ * by <code>IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR</code>:
+ * the first path is the full OS path to the archive (if it is an external archive),
+ * or the workspace relative <code>IPath</code> to the archive (if it is an internal archive),
+ * the second path is the path to the resource inside the archive.
+ * */
void acceptInterface(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path);
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java
index d5dee9b..8d1081d 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.core.search;
import org.eclipse.core.resources.*;
@@ -15,6 +15,7 @@
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.internal.core.*;
+import org.eclipse.jdt.internal.core.search.*;
import org.eclipse.jdt.internal.core.search.HierarchyScope;
import org.eclipse.jdt.internal.core.search.IndexSearchAdapter;
import org.eclipse.jdt.internal.core.search.IIndexSearchRequestor;
@@ -46,13 +47,16 @@
*/
public class SearchEngine {
- /**
- * A list of working copies that take precedence over their original
- * compilation units.
- */
- private IWorkingCopy[] workingCopies = null;
-
- public static boolean VERBOSE = false;
+/**
+ * A list of working copies that take precedence over their original
+ * compilation units.
+ */
+private IWorkingCopy[] workingCopies = null;
+
+/**
+ * For tracing purpose.
+ */
+public static boolean VERBOSE = false;
/**
* Creates a new search engine.
@@ -72,6 +76,39 @@
public SearchEngine(IWorkingCopy[] workingCopies) {
this.workingCopies = workingCopies;
}
+/*
+ * Removes from the given list of working copies the ones that cannot see the given focus.
+ */
+private IWorkingCopy[] filterWorkingCopies(IWorkingCopy[] workingCopies, IJavaElement focus, boolean isPolymorphicSearch) {
+ if (focus == null || workingCopies == null) return workingCopies;
+ while (!(focus instanceof IJavaProject) && !(focus instanceof JarPackageFragmentRoot)) {
+ focus = focus.getParent();
+ }
+ int length = workingCopies.length;
+ IWorkingCopy[] result = null;
+ int index = -1;
+ for (int i=0; i<length; i++) {
+ IWorkingCopy workingCopy = workingCopies[i];
+ IPath projectOrJar = IndexSelector.getProjectOrJar((IJavaElement)workingCopy).getPath();
+ if (!IndexSelector.canSeeFocus(focus, isPolymorphicSearch, projectOrJar)) {
+ if (result == null) {
+ result = new IWorkingCopy[length-1];
+ System.arraycopy(workingCopies, 0, result, 0, i);
+ index = i;
+ }
+ } else if (result != null) {
+ result[index++] = workingCopy;
+ }
+ }
+ if (result != null) {
+ if (result.length != index) {
+ System.arraycopy(result, 0, result = new IWorkingCopy[index], 0, index);
+ }
+ return result;
+ } else {
+ return workingCopies;
+ }
+}
/**
* Returns a java search scope limited to the hierarchy of the given type.
* The java elements resulting from a search with this scope will
@@ -98,11 +135,10 @@
* @deprecated Use createJavaSearchScope(IJavaElement[]) instead
*/
public static IJavaSearchScope createJavaSearchScope(IResource[] resources) {
- JavaCore javaCore = JavaCore.getJavaCore();
int length = resources.length;
IJavaElement[] elements = new IJavaElement[length];
for (int i = 0; i < length; i++) {
- elements[i] = javaCore.create(resources[i]);
+ elements[i] = JavaCore.create(resources[i]);
}
return createJavaSearchScope(elements);
}
@@ -133,7 +169,7 @@
* Returns a java search scope limited to the given java elements.
* The java elements resulting from a search with this scope will
* be children of the given elements.
- * <p>
+ *
* If an element is an IJavaProject, then the project's source folders,
* its jars (external and internal) and - if specified - its referenced projects
* (with their source folders and jars, recursively) will be included.
@@ -183,7 +219,7 @@
* Returns a search pattern based on a given string pattern. The string patterns support '*' wild-cards.
* The remaining parameters are used to narrow down the type of expected results.
*
- * <p>
+ * <br>
* Examples:
* <ul>
* <li>search for case insensitive references to <code>Object</code>:
@@ -193,6 +229,7 @@
* <li>search for implementers of <code>java.lang.Runnable</code>:
* <code>createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true);</code></li>
* </ul>
+ * @param stringPattern the given pattern
* @param searchFor determines the nature of the searched elements
* <ul>
* <li><code>IJavaSearchConstants.CLASS</code>: only look for classes</li>
@@ -221,8 +258,13 @@
* @return a search pattern on the given string pattern, or <code>null</code> if the string pattern is ill-formed.
*/
public static ISearchPattern createSearchPattern(String stringPattern, int searchFor, int limitTo, boolean isCaseSensitive) {
-
- return SearchPattern.createPattern(stringPattern, searchFor, limitTo, IJavaSearchConstants.PATTERN_MATCH, isCaseSensitive);
+ int matchMode;
+ if (stringPattern.indexOf('*') != -1 || stringPattern.indexOf('?') != -1) {
+ matchMode = IJavaSearchConstants.PATTERN_MATCH;
+ } else {
+ matchMode = IJavaSearchConstants.EXACT_MATCH;
+ }
+ return SearchPattern.createPattern(stringPattern, searchFor, limitTo, matchMode, isCaseSensitive);
}
/**
* Returns a search pattern based on a given Java element.
@@ -233,14 +275,14 @@
* <ul>
* <li><code>IJavaSearchConstants.DECLARATIONS</code>: will search declarations matching with the corresponding
* element. In case the element is a method, declarations of matching methods in subtypes will also
- * be found, allowing to find declarations of abstract methods, etc.
+ * be found, allowing to find declarations of abstract methods, etc.</li>
*
- * <li><code>IJavaSearchConstants.REFERENCES</code>: will search references to the given element.
+ * <li><code>IJavaSearchConstants.REFERENCES</code>: will search references to the given element.</li>
*
* <li><code>IJavaSearchConstants.ALL_OCCURRENCES</code>: will search for either declarations or references as specified
- * above.
+ * above.</li>
*
- * <li><code>IJavaSearchConstants.IMPLEMENTORS</code>: for interface, will find all types which implements a given interface.
+ * <li><code>IJavaSearchConstants.IMPLEMENTORS</code>: for interface, will find all types which implements a given interface.</li>
* </ul>
* @return a search pattern for a java element or <code>null</code> if the given element is ill-formed
*/
@@ -259,18 +301,18 @@
/**
* Returns the underlying resource of the given element.
*/
-private IResource getResource(IJavaElement element) throws JavaModelException {
+private IResource getResource(IJavaElement element) {
if (element instanceof IMember) {
ICompilationUnit cu = ((IMember)element).getCompilationUnit();
if (cu != null) {
if (cu.isWorkingCopy()) {
- return cu.getOriginalElement().getUnderlyingResource();
+ return cu.getOriginalElement().getResource();
} else {
- return cu.getUnderlyingResource();
+ return cu.getResource();
}
}
}
- return element.getUnderlyingResource();
+ return element.getResource();
}
/**
* Returns the list of working copies used to do the search on the given java element.
@@ -315,13 +357,13 @@
* for both declarations and all references </li>
* <li><code>IJavaSearchConstants.IMPLEMENTORS</code>: search for
* all implementors of an interface; the value is only valid if
- * the Java element represents an interface
+ * the Java element represents an interface</li>
* </ul>
* @param scope the search result has to be limited to the given scope
* @param resultCollector a callback object to which each match is reported
* @exception JavaModelException if the search failed. Reasons include:
* <ul>
- * <li>the classpath is incorrectly set
+ * <li>the classpath is incorrectly set</li>
* </ul>
*/
public void search(IWorkspace workspace, String patternString, int searchFor, int limitTo, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) throws JavaModelException {
@@ -343,14 +385,14 @@
* for both declarations and all references </li>
* <li><code>IJavaSearchConstants.IMPLEMENTORS</code>: search for
* all implementors of an interface; the value is only valid if
- * the Java element represents an interface
+ * the Java element represents an interface</li>
* </ul>
* @param scope the search result has to be limited to the given scope
* @param resultCollector a callback object to which each match is reported
* @exception JavaModelException if the search failed. Reasons include:
* <ul>
- * <li>the element doesn't exist
- * <li>the classpath is incorrectly set
+ * <li>the element doesn't exist</li>
+ * <li>the classpath is incorrectly set</li>
* </ul>
*/
public void search(IWorkspace workspace, IJavaElement element, int limitTo, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) throws JavaModelException {
@@ -368,7 +410,7 @@
* @param resultCollector a callback object to which each match is reported
* @exception JavaModelException if the search failed. Reasons include:
* <ul>
- * <li>the classpath is incorrectly set
+ * <li>the classpath is incorrectly set</li>
* </ul>
*/
public void search(IWorkspace workspace, ISearchPattern searchPattern, IJavaSearchScope scope, IJavaSearchResultCollector resultCollector) throws JavaModelException {
@@ -391,16 +433,33 @@
/* index search */
PathCollector pathCollector = new PathCollector();
+
+ // In the case of a hierarchy scope make sure that the hierarchy is not computed.
+ // MatchLocator will filter out elements not in the hierarchy
+ SearchPattern pattern = (SearchPattern)searchPattern;
+ if (scope instanceof HierarchyScope) {
+ ((HierarchyScope)scope).needsRefresh = false;
+ pattern.needsResolve = true; // force resolve to compute type bindings
+ }
IndexManager indexManager = ((JavaModelManager)JavaModelManager.getJavaModelManager())
.getIndexManager();
int detailLevel = IInfoConstants.PathInfo | IInfoConstants.PositionInfo;
- MatchLocator matchLocator = new MatchLocator((SearchPattern)searchPattern, detailLevel, resultCollector, scope);
+ MatchLocator matchLocator =
+ new MatchLocator2(
+ pattern,
+ detailLevel,
+ resultCollector,
+ scope,
+ progressMonitor == null ? null : new SubProgressMonitor(progressMonitor, 95)
+ );
indexManager.performConcurrentJob(
new PatternSearchJob(
- (SearchPattern)searchPattern,
+ pattern,
scope,
+ pattern.focus,
+ pattern.isPolymorphicSearch(),
detailLevel,
pathCollector,
indexManager),
@@ -412,8 +471,7 @@
matchLocator.locateMatches(
pathCollector.getPaths(),
workspace,
- this.workingCopies,
- progressMonitor == null ? null : new SubProgressMonitor(progressMonitor, 95)
+ filterWorkingCopies(this.workingCopies, pattern.focus, pattern.isPolymorphicSearch())
);
@@ -443,33 +501,33 @@
* @param matchMode one of
* <ul>
* <li><code>IJavaSearchConstants.EXACT_MATCH</code> if the package name and type name are the full names
- * of the searched types.
+ * of the searched types.</li>
* <li><code>IJavaSearchConstants.PREFIX_MATCH</code> if the package name and type name are prefixes of the names
- * of the searched types.
- * <li><code>IJavaSearchConstants.PATTERN_MATCH</code> if the package name and type name contain wild-cards.
+ * of the searched types.</li>
+ * <li><code>IJavaSearchConstants.PATTERN_MATCH</code> if the package name and type name contain wild-cards.</li>
* </ul>
* @param isCaseSensitive whether the search should be case sensitive
* @param searchFor one of
* <ul>
- * <li><code>IJavaSearchConstants.CLASS</code> if searching for classes only
- * <li><code>IJavaSearchConstants.INTERFACE</code> if searching for interfaces only
- * <li><code>IJavaSearchConstants.TYPE</code> if searching for both classes and interfaces
+ * <li><code>IJavaSearchConstants.CLASS</code> if searching for classes only</li>
+ * <li><code>IJavaSearchConstants.INTERFACE</code> if searching for interfaces only</li>
+ * <li><code>IJavaSearchConstants.TYPE</code> if searching for both classes and interfaces</li>
* </ul>
* @param scope the scope to search in
* @param nameRequestor the requestor that collects the results of the search
* @param waitingPolicy one of
* <ul>
- * <li><code>IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH</code> if the search should start immediately
+ * <li><code>IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH</code> if the search should start immediately</li>
* <li><code>IJavaSearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH</code> if the search should be cancelled if the
- * underlying indexer has not finished indexing the workspace
+ * underlying indexer has not finished indexing the workspace</li>
* <li><code>IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH</code> if the search should wait for the
- * underlying indexer to finish indexing the workspace
+ * underlying indexer to finish indexing the workspace</li>
* </ul>
* @param progressMonitor the progress monitor to report progress to, or <code>null</code> if no progress
* monitor is provided
* @exception JavaModelException if the search failed. Reasons include:
* <ul>
- * <li>the classpath is incorrectly set
+ * <li>the classpath is incorrectly set</li>
* </ul>
*/
public void searchAllTypeNames(
@@ -565,8 +623,8 @@
* @param resultCollector a callback object to which each match is reported
* @exception JavaModelException if the search failed. Reasons include:
* <ul>
- * <li>the element doesn't exist
- * <li>the classpath is incorrectly set
+ * <li>the element doesn't exist</li>
+ * <li>the classpath is incorrectly set</li>
* </ul>
*/
public void searchDeclarationsOfAccessedFields(IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException {
@@ -577,16 +635,16 @@
if (VERBOSE) {
System.out.println("Searching for " + pattern + " in " + resource.getFullPath()); //$NON-NLS-1$//$NON-NLS-2$
}
- MatchLocator locator = new MatchLocator(
+ MatchLocator locator = new MatchLocator2(
pattern,
IInfoConstants.DeclarationInfo,
resultCollector,
- scope);
+ scope,
+ resultCollector.getProgressMonitor());
locator.locateMatches(
new String[] {resource.getFullPath().toString()},
workspace,
- this.getWorkingCopies(enclosingElement),
- resultCollector.getProgressMonitor());
+ this.getWorkingCopies(enclosingElement));
} else {
search(workspace, pattern, scope, resultCollector);
}
@@ -613,7 +671,7 @@
* };
* }
* </pre>
- * <code>
+ * </code>
* then searching for declarations of referenced types in method <code>X.test()</code>
* would collect the class <code>B</code> and the interface <code>I</code>.
* </p>
@@ -623,8 +681,8 @@
* @param resultCollector a callback object to which each match is reported
* @exception JavaModelException if the search failed. Reasons include:
* <ul>
- * <li>the element doesn't exist
- * <li>the classpath is incorrectly set
+ * <li>the element doesn't exist</li>
+ * <li>the classpath is incorrectly set</li>
* </ul>
*/
public void searchDeclarationsOfReferencedTypes(IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException {
@@ -635,16 +693,16 @@
if (VERBOSE) {
System.out.println("Searching for " + pattern + " in " + resource.getFullPath()); //$NON-NLS-1$//$NON-NLS-2$
}
- MatchLocator locator = new MatchLocator(
+ MatchLocator locator = new MatchLocator2(
pattern,
IInfoConstants.DeclarationInfo,
resultCollector,
- scope);
+ scope,
+ resultCollector.getProgressMonitor());
locator.locateMatches(
new String[] {resource.getFullPath().toString()},
workspace,
- this.getWorkingCopies(enclosingElement),
- resultCollector.getProgressMonitor());
+ this.getWorkingCopies(enclosingElement));
} else {
search(workspace, pattern, scope, resultCollector);
}
@@ -684,8 +742,8 @@
* @param resultCollector a callback object to which each match is reported
* @exception JavaModelException if the search failed. Reasons include:
* <ul>
- * <li>the element doesn't exist
- * <li>the classpath is incorrectly set
+ * <li>the element doesn't exist</li>
+ * <li>the classpath is incorrectly set</li>
* </ul>
*/
public void searchDeclarationsOfSentMessages(IWorkspace workspace, IJavaElement enclosingElement, IJavaSearchResultCollector resultCollector) throws JavaModelException {
@@ -696,16 +754,16 @@
if (VERBOSE) {
System.out.println("Searching for " + pattern + " in " + resource.getFullPath()); //$NON-NLS-1$//$NON-NLS-2$
}
- MatchLocator locator = new MatchLocator(
+ MatchLocator locator = new MatchLocator2(
pattern,
IInfoConstants.DeclarationInfo,
resultCollector,
- scope);
+ scope,
+ resultCollector.getProgressMonitor());
locator.locateMatches(
new String[] {resource.getFullPath().toString()},
workspace,
- this.getWorkingCopies(enclosingElement),
- resultCollector.getProgressMonitor());
+ this.getWorkingCopies(enclosingElement));
} else {
search(workspace, pattern, scope, resultCollector);
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DocumentFactory.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DocumentFactory.java
index 690a491..06db9c3 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DocumentFactory.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/DocumentFactory.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index;
import java.io.File;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IDocument.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IDocument.java
index f086463..e167210 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IDocument.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IDocument.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index;
import java.io.IOException;
@@ -16,10 +16,6 @@
* An <code>IDocument</code> represent a data source, e.g. a <code>File</code> (<code>FileDocument</code>),
* an <code>IFile</code> (<code>IFileDocument</code>),
* or other kinds of data sources (URL, ...). An <code>IIndexer</code> indexes an<code>IDocument</code>.
- * <br>
- * A document has a set of properties, saved in the index file (so one does not need to open the document
- * to obtain basic information as: date of creation of the document, sum up, ...). A property is a String
- * (called property) associated to a value (String). Example: "date_creation"->"02/08/2000".
*/
public interface IDocument {
@@ -32,20 +28,15 @@
*/
char[] getCharContent() throws IOException;
/**
+ * Returns the encoding for this document
+ */
+ String getEncoding();
+ /**
* returns the name of the document (e.g. its path for a <code>File</code>, or its relative path
* in the workbench for an <code>IFile</code>).
*/
String getName();
/**
- * returns the value of the given property, or null if this document does not have
- * such a property.
- */
- String getProperty(String property);
- /**
- * Returns an enumeration of the names of the properties the document has.
- */
- java.util.Enumeration getPropertyNames();
- /**
* Returns the content of the document, as a String.
*/
public String getStringContent() throws IOException;
@@ -53,8 +44,4 @@
* Returns the type of the document.
*/
String getType();
- /**
- * Sets the given property of the document to the given value.
- */
- void setProperty(String attribute, String value);
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IEntryResult.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IEntryResult.java
index 9c82384..74f405b 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IEntryResult.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IEntryResult.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index;
public interface IEntryResult {
public int[] getFileReferences();
public char[] getWord();
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndex.java
index 603caf0..8fbba99 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndex.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index;
import java.io.File;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndexer.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndexer.java
index 1f6995a..eadc92b 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndexer.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndexer.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index;
/**
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndexerOutput.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndexerOutput.java
index d2013bf..0c9f152 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndexerOutput.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IIndexerOutput.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index;
/**
* This class represents the output from an indexer to an index
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IQueryResult.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IQueryResult.java
index b2f16b2..41d7c4f 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IQueryResult.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/IQueryResult.java
@@ -1,18 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index;
public interface IQueryResult {
String getPath();
- String getProperty(String propertyName);
- java.util.Enumeration getPropertyNames();
- String propertiesToString();
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Block.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Block.java
index f3fb4e0..ba4c569 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Block.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Block.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.IOException;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexInput.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexInput.java
index 4b67fc0..f9b995b 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexInput.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexInput.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.File;
@@ -15,7 +15,7 @@
import java.io.RandomAccessFile;
import java.util.ArrayList;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.core.index.IDocument;
import org.eclipse.jdt.internal.core.index.IEntryResult;
import org.eclipse.jdt.internal.core.index.IQueryResult;
@@ -51,9 +51,10 @@
*/
public void close() throws IOException {
if (opened) {
- raf.close();
summary= null;
opened= false;
+ if (raf != null)
+ raf.close();
}
}
/**
@@ -268,7 +269,7 @@
}
return entries;
}
- public IEntryResult[] queryEntriesPrefixedBy(char[] prefix/*, boolean isCaseSensitive*/) throws IOException {
+ public IEntryResult[] queryEntriesPrefixedBy(char[] prefix) throws IOException {
open();
int blockLoc = summary.getFirstBlockLocationForPrefix(prefix);
@@ -282,7 +283,7 @@
boolean found = false;
WordEntry entry = new WordEntry();
while (block.nextEntry(entry)) {
- if (CharOperation.prefixEquals(prefix, entry.getWord()/*, isCaseSensitive*/)) {
+ if (CharOperation.prefixEquals(prefix, entry.getWord())) {
if (count == entries.length){
System.arraycopy(entries, 0, entries = new IEntryResult[count*2], 0, count);
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexOutput.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexOutput.java
index 0f49c89..501955f 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexOutput.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/BlocksIndexOutput.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.File;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/CodeByteStream.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/CodeByteStream.java
index 073b979..54704f4 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/CodeByteStream.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/CodeByteStream.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.UTFDataFormatException;
@@ -113,8 +113,14 @@
int numBits= readUnary();
return readBits(numBits - 1) | (1 << (numBits - 1));
}
- public char[] readSmallUTF() throws UTFDataFormatException {
+ public char[] readUTF() throws UTFDataFormatException {
int utflen= readByte();
+ if (utflen == 255) {
+ // long UTF
+ int high = readByte();
+ int low = readByte();
+ utflen = (high << 8) + low;
+ }
char str[]= new char[utflen];
int count= 0;
int strlen= 0;
@@ -271,10 +277,7 @@
writeUnary(numBits);
writeBits(value, numBits - 1);
}
- public void writeSmallUTF(char[] str) {
- writeSmallUTF(str, 0, str.length);
- }
- public void writeSmallUTF(char[] str, int start, int end) {
+ public void writeUTF(char[] str, int start, int end) {
int utflen= 0;
for (int i= start; i < end; i++) {
int c= str[i];
@@ -286,9 +289,15 @@
utflen += 2;
}
}
- if (utflen > 255)
+ if (utflen < 255) {
+ writeByte(utflen & 0xFF);
+ } else if (utflen > 65535) {
throw new IllegalArgumentException();
- writeByte(utflen & 0xFF);
+ } else {
+ writeByte(255); // marker for long UTF
+ writeByte((utflen >>> 8) & 0xFF); // high byte
+ writeByte((utflen >>> 0) & 0xFF); // low byte
+ }
for (int i= start; i < end; i++) {
int c= str[i];
if ((c >= 0x0001) && (c <= 0x007F)) {
@@ -330,35 +339,4 @@
grow();
}
}
- public void writeUTF(char[] str) {
- int strlen= str.length;
- int utflen= 0;
- for (int i= 0; i < strlen; i++) {
- int c= str[i];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- utflen++;
- } else if (c > 0x07FF) {
- utflen += 3;
- } else {
- utflen += 2;
- }
- }
- if (utflen > 65535)
- throw new IllegalArgumentException();
- writeByte((utflen >>> 8) & 0xFF);
- writeByte((utflen >>> 0) & 0xFF);
- for (int i= 0; i < strlen; i++) {
- int c= str[i];
- if ((c >= 0x0001) && (c <= 0x007F)) {
- writeByte(c);
- } else if (c > 0x07FF) {
- writeByte(0xE0 | ((c >> 12) & 0x0F));
- writeByte(0x80 | ((c >> 6) & 0x3F));
- writeByte(0x80 | ((c >> 0) & 0x3F));
- } else {
- writeByte(0xC0 | ((c >> 6) & 0x1F));
- writeByte(0x80 | ((c >> 0) & 0x3F));
- }
- }
- }
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/EntryResult.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/EntryResult.java
index 8a9c896..284a8d7 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/EntryResult.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/EntryResult.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.core.index.IEntryResult;
public class EntryResult implements IEntryResult {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Field.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Field.java
index af61de5..cef7dc6 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Field.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Field.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.UTFDataFormatException;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileDocument.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileDocument.java
index aca2566..f02bd5a 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileDocument.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileDocument.java
@@ -1,18 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.File;
import java.io.IOException;
+import org.eclipse.jdt.core.JavaCore;
+
/**
* A <code>FileDocument</code> represents a java.io.File.
*/
@@ -37,6 +39,13 @@
return org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(file, null);
}
/**
+ * @see org.eclipse.jdt.internal.core.index.IDocument#getEncoding()
+ */
+ public String getEncoding() {
+ return JavaCore.getOption(JavaCore.CORE_ENCODING); // no custom encoding
+ }
+
+ /**
* @see IDocument#getName
*/
public String getName() {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileListBlock.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileListBlock.java
index 1178681..bb16e9c 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileListBlock.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/FileListBlock.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.IOException;
@@ -33,7 +33,7 @@
field.putInt4(offset, indexedFile.getFileNumber());
offset += 4;
}
- String path= indexedFile.getPath() + indexedFile.propertiesToString();
+ String path= indexedFile.getPath();
int prefixLen= prevPath == null ? 0 : Util.prefixLength(prevPath, path);
int sizeEstimate= 2 + 2 + (path.length() - prefixLen) * 3;
if (offset + sizeEstimate > blockSize - 2)
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/GammaCompressedIndexBlock.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/GammaCompressedIndexBlock.java
index ca43aa5..627b9ca 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/GammaCompressedIndexBlock.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/GammaCompressedIndexBlock.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.UTFDataFormatException;
@@ -44,7 +44,7 @@
char[] word= entry.getWord();
int prefixLen= prevWord == null ? 0 : Util.prefixLength(prevWord, word);
codeStream.writeByte(prefixLen);
- codeStream.writeSmallUTF(word, prefixLen, word.length);
+ codeStream.writeUTF(word, prefixLen, word.length);
int n= entry.getNumRefs();
codeStream.writeGamma(n);
int prevRef= 0;
@@ -79,7 +79,7 @@
try {
readCodeStream.reset(field.buffer(), offset);
int prefixLength= readCodeStream.readByte();
- char[] word= readCodeStream.readSmallUTF();
+ char[] word= readCodeStream.readUTF();
if (prevWord != null && prefixLength > 0) {
char[] temp= new char[prefixLength + word.length];
System.arraycopy(prevWord, 0, temp, 0, prefixLength);
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ICacheEnumeration.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ICacheEnumeration.java
index 5086a91..7e2eeb5 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ICacheEnumeration.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ICacheEnumeration.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.util.Enumeration;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IFileDocument.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IFileDocument.java
index 6fad887..cad1c5c 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IFileDocument.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IFileDocument.java
@@ -1,19 +1,21 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.IOException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.compiler.CharOperation;
/**
* An <code>IFileDocument</code> represents an IFile.
@@ -60,8 +62,16 @@
public char[] getCharContent() throws IOException {
if (charContents != null) return charContents;
IPath location = file.getLocation();
- if (location == null) return new char[0];
- return charContents = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(location.toFile(), null);
+ if (location == null) return CharOperation.NO_CHAR;
+ return charContents = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(
+ location.toFile(),
+ getEncoding());
+ }
+ /**
+ * @see org.eclipse.jdt.internal.core.index.IDocument#getEncoding()
+ */
+ public String getEncoding() {
+ return JavaCore.create(file.getProject()).getOption(JavaCore.CORE_ENCODING, true);
}
/**
* @see org.eclipse.jdt.internal.core.index.IDocument#getName()
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IIndexConstants.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IIndexConstants.java
index a356a8b..efd0567 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IIndexConstants.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IIndexConstants.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
/**
@@ -17,9 +17,9 @@
/**
* The signature of the index file.
*/
- public static final String SIGNATURE= "INDEX FILE 0.007"; //$NON-NLS-1$
+ public static final String SIGNATURE= "INDEX FILE 0.012"; //$NON-NLS-1$
/**
- * The signature of the index file.
+ * The separator for files in the index file.
*/
public static final char FILE_SEPARATOR= '/';
/**
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ILRUCacheable.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ILRUCacheable.java
index 9fb4bb3..f5eb42b 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ILRUCacheable.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/ILRUCacheable.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
/**
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/InMemoryIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/InMemoryIndex.java
index 9fc1297..6e3272f 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/InMemoryIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/InMemoryIndex.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.File;
@@ -66,7 +66,6 @@
* If the word does not exist, it adds it in the index.
*/
protected void addRef(char[] word, int fileNum) {
- word= preprocessWord(word);
WordEntry entry= (WordEntry) this.words.get(word);
if (entry == null) {
entry= new WordEntry(word);
@@ -153,12 +152,6 @@
sortedWordEntries= null;
sortedFiles= null;
}
- protected char[] preprocessWord(char[] word) {
- if (word.length > 255) {
- System.arraycopy(word, 0, word= new char[255], 0, 255);
- }
- return word;
- }
/**
* Saves the index in the given file.
* Structure of the saved Index :
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Index.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Index.java
index fdcbe62..74a4675 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Index.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Index.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.File;
@@ -64,7 +64,7 @@
/**
* String representation of this index.
*/
- private String toString;
+ public String toString;
public Index(File indexDirectory, boolean reuseExistingFile) throws IOException {
this(indexDirectory,".index", reuseExistingFile); //$NON-NLS-1$
}
@@ -211,14 +211,8 @@
input.opened = false;
}
indexFile.delete();
- if (org.eclipse.jdt.internal.core.search.Util.bind("exception.wrongFormat").equals(e.getMessage())) { //$NON-NLS-1$
- InMemoryIndex mainIndex= new InMemoryIndex();
- IndexOutput mainIndexOutput= new BlocksIndexOutput(indexFile);
- mainIndex.save(mainIndexOutput);
- } else {
- mainIndexInput = null;
- throw e;
- }
+ mainIndexInput = null;
+ throw e;
}
mainIndexInput.close();
} else {
@@ -361,7 +355,9 @@
return (addsIndex.getFootprint() >= MAX_FOOTPRINT);
}
public String toString() {
- if (this.toString == null) return super.toString();
- return this.toString;
+ String str = this.toString;
+ if (str == null) str = super.toString();
+ str += "(length: "+ getIndexFile().length() +")"; //$NON-NLS-1$ //$NON-NLS-2$
+ return str;
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexBlock.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexBlock.java
index cb69d6b..8384ac9 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexBlock.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexBlock.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
/**
* An indexBlock stores wordEntries.
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexInput.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexInput.java
index 0b3234f..cecdb76 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexInput.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexInput.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.IOException;
@@ -115,8 +115,8 @@
* Returns the list of the files containing the given word in the index.
*/
public abstract IQueryResult[] query(String word) throws IOException;
- public abstract IEntryResult[] queryEntriesPrefixedBy(char[] prefix /*, boolean isCaseSensitive*/) throws IOException;
-public abstract IQueryResult[] queryFilesReferringToPrefix(char[] prefix) throws IOException;
+ public abstract IEntryResult[] queryEntriesPrefixedBy(char[] prefix) throws IOException;
+ public abstract IQueryResult[] queryFilesReferringToPrefix(char[] prefix) throws IOException;
/**
* Returns the list of the files whose name contain the given word in the index.
*/
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexOutput.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexOutput.java
index 15f1f49..4b9e94f 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexOutput.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexOutput.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.IOException;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexSummary.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexSummary.java
index 9fd36fa..f1db4fe 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexSummary.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexSummary.java
@@ -1,20 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
/**
* An indexSummary is used when saving an index into a BlocksIndexOuput or
@@ -147,7 +147,7 @@
while (min <= max && match < 0) {
int mid= (min + max) / 2;
FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(mid);
- int compare= Util.startsWith(entry.word, prefix);
+ int compare= CharOperation.compareWith(entry.word, prefix);
if (compare == 0) {
match= mid;
break;
@@ -167,7 +167,7 @@
// Look if previous blocks are affected
for (; firstBlock >= 0; firstBlock--) {
FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(firstBlock);
- if (!CharOperation.startsWith(entry.word, prefix))
+ if (!CharOperation.prefixEquals(prefix, entry.word))
break;
}
if (firstBlock < 0)
@@ -177,7 +177,7 @@
int firstNotIncludedBlock= match + 1;
for (; firstNotIncludedBlock < size; firstNotIncludedBlock++) {
FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(firstNotIncludedBlock);
- if (!CharOperation.startsWith(entry.word, prefix))
+ if (!CharOperation.prefixEquals(prefix, entry.word))
break;
}
@@ -198,7 +198,7 @@
while (min <= max) {
int mid = (min + max) / 2;
FirstWordInBlock entry = (FirstWordInBlock) firstWordsInBlocks.get(mid);
- int compare = Util.startsWith(entry.word, prefix);
+ int compare = CharOperation.compareWith(entry.word, prefix);
if (compare == 0) {
match = mid;
break;
@@ -219,9 +219,8 @@
// look for possible matches inside previous blocks
while (match > 0){
FirstWordInBlock entry = (FirstWordInBlock) firstWordsInBlocks.get(match);
- if (!CharOperation.startsWith(entry.word, prefix)){
+ if (!CharOperation.prefixEquals(prefix, entry.word))
break;
- }
match--;
}
}
@@ -240,7 +239,7 @@
public int getNextBlockLocationForPrefix(char[] prefix, int blockLoc) {
if (++blockLoc < firstWordsInBlocks.size()){
FirstWordInBlock entry= (FirstWordInBlock) firstWordsInBlocks.get(blockLoc);
- if (CharOperation.startsWith(entry.word, prefix)) return blockLoc;
+ if (CharOperation.prefixEquals(prefix, entry.word)) return blockLoc;
}
return -1;
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFile.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFile.java
index 26541dd..f12ba7f 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFile.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFile.java
@@ -1,19 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.StringTokenizer;
-
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.internal.core.index.IDocument;
import org.eclipse.jdt.internal.core.index.IQueryResult;
@@ -26,50 +22,18 @@
public class IndexedFile implements IQueryResult {
protected String path;
protected int fileNumber;
- protected static final String INFO_BEGIN= "("; //$NON-NLS-1$
- protected static final String INFO_END= ")"; //$NON-NLS-1$
- protected static final String INFO_SEPARATOR= ","; //$NON-NLS-1$
- protected static final String INFO_VALUE_SEPARATOR= ":"; //$NON-NLS-1$
- protected static final int MAX_PROPERTIES_SIZE= 2 * 1024;
- protected Hashtable properties;
- protected int propertiesSize= 2 * (INFO_BEGIN.length() + INFO_END.length());
- public IndexedFile(String pathOrInfo, int fileNum) {
+ public IndexedFile(String path, int fileNum) {
if (fileNum < 1)
throw new IllegalArgumentException();
this.fileNumber= fileNum;
- this.properties= null; // initialized when needed
- int dp= pathOrInfo.indexOf(INFO_BEGIN);
- if (dp == -1)
- path= pathOrInfo;
- else {
- String fileInfo= pathOrInfo;
- path= fileInfo.substring(0, dp);
- String props= fileInfo.substring(dp, fileInfo.length());
- StringTokenizer t= new StringTokenizer(props.substring(1, props.length() - 1), INFO_SEPARATOR);
- while (t.hasMoreTokens()) {
- String g= t.nextToken();
- try {
- int dpt= g.indexOf(INFO_VALUE_SEPARATOR);
- setProperty(g.substring(0, dpt), g.substring(dpt + 1, g.length()));
- } catch (Exception e) {
- }
- }
- }
+ this.path= path;
}
public IndexedFile(IDocument document, int fileNum) {
if (fileNum < 1)
throw new IllegalArgumentException();
this.path= document.getName();
this.fileNumber= fileNum;
- this.properties= null; // initialized when needed
- computeProperties(document);
- }
- protected void computeProperties(IDocument document) {
- for (Enumeration e= document.getPropertyNames(); e.hasMoreElements();) {
- String property= (String) e.nextElement();
- setProperty(property, document.getProperty(property));
- }
}
/**
* Returns the path represented by pathString converted back to a path relative to the local file system.
@@ -124,49 +88,12 @@
public String getPath() {
return path;
}
- public String getProperty(String propertyName) {
- if (properties == null) return null;
- return (String) properties.get(propertyName);
- }
- /**
- * getPropertyNames method comment.
- */
- public Enumeration getPropertyNames() {
- if (properties == null) return new Hashtable().keys();
- return properties.keys();
- }
- public String propertiesToString() {
- if (properties == null || properties.isEmpty())
- return ""; //$NON-NLS-1$
- StringBuffer prop= new StringBuffer(INFO_BEGIN);
- for (Enumeration e= getPropertyNames(); e.hasMoreElements();) {
- String property= (String) e.nextElement();
- String value= getProperty(property);
- prop.append(property);
- prop.append(INFO_VALUE_SEPARATOR);
- prop.append(value);
- if (e.hasMoreElements())
- prop.append(INFO_SEPARATOR);
- }
- prop.append(INFO_END);
- return prop.toString();
- }
/**
* Sets the file number.
*/
public void setFileNumber(int fileNumber) {
this.fileNumber= fileNumber;
}
- /**
- * getPropertyNames method comment.
- */
- public void setProperty(String propertyName, String value) {
- if (properties == null)
- properties = new Hashtable(3);
- propertiesSize += (INFO_SEPARATOR.length() + propertyName.length() + INFO_VALUE_SEPARATOR.length() + value.length()) * 2;
- if (propertiesSize < MAX_PROPERTIES_SIZE)
- properties.put(propertyName, value);
- }
public String toString() {
return "IndexedFile(" + fileNumber + ": " + path + ")"; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFileHashedArray.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFileHashedArray.java
index fc9982a..3cbbba5 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFileHashedArray.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexedFileHashedArray.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.util.ArrayList;
@@ -105,4 +105,4 @@
s += files[i].toString() + "\n"; //$NON-NLS-1$
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexerOutput.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexerOutput.java
index 49701b5..107911b 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexerOutput.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/IndexerOutput.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import org.eclipse.jdt.internal.core.index.IDocument;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Int.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Int.java
index 426ee71..20a048c 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Int.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Int.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
public class Int {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileDocument.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileDocument.java
index 5570c6a..31bd467 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileDocument.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileDocument.java
@@ -1,19 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.File;
import java.io.IOException;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
/**
* An <code>JarFileDocument</code> represents an jar file.
@@ -41,8 +42,20 @@
public char[] getCharContent() throws IOException {
return null;
}
+ /**
+ * @see org.eclipse.jdt.internal.core.index.IDocument#getEncoding()
+ */
+ public String getEncoding() {
+ return null;
+ }
+
public File getFile() {
- return file.getLocation().toFile();
+ IPath location = file.getLocation();
+ if (location == null) {
+ return null;
+ } else {
+ return location.toFile();
+ }
}
/**
* @see org.eclipse.jdt.internal.core.index.IDocument#getName()
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileEntryDocument.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileEntryDocument.java
index f39924f..c83c6db 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileEntryDocument.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/JarFileEntryDocument.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.IOException;
@@ -47,6 +47,13 @@
public char[] getCharContent() throws IOException {
return null;
}
+/**
+ * @see org.eclipse.jdt.internal.core.index.IDocument#getEncoding()
+ */
+public String getEncoding() {
+ return null;
+}
+
/**
* @see org.eclipse.jdt.internal.core.index.IDocument#getName()
*/
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/LRUCache.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/LRUCache.java
index 13bd5aa..fc56375 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/LRUCache.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/LRUCache.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.util.Hashtable;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/MergeFactory.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/MergeFactory.java
index 5b6f8e1..5492779 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/MergeFactory.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/MergeFactory.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.IOException;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/PropertyDocument.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/PropertyDocument.java
index 0fa29c4..9564c68 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/PropertyDocument.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/PropertyDocument.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.util.Enumeration;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SafeRandomAccessFile.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SafeRandomAccessFile.java
index 85243b7..bf8d4b1 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SafeRandomAccessFile.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SafeRandomAccessFile.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.IOException;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SimpleIndexBlock.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SimpleIndexBlock.java
index 7678ea5..65dffd7 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SimpleIndexBlock.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SimpleIndexBlock.java
@@ -1,18 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.UTFDataFormatException;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
/**
* Does no compression of words, and uses 4-byte ints for file numbers and number of files.
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SimpleIndexInput.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SimpleIndexInput.java
index b81f079..0066e09 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SimpleIndexInput.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/SimpleIndexInput.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.IOException;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Util.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Util.java
index 9d197b7..8626007 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Util.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/Util.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
import java.io.DataInput;
@@ -291,23 +291,6 @@
if (list.length > 1)
quickSort(list, 0, list.length - 1);
}
- public static int startsWith(char[] str, char[] prefix) {
- int len1= str.length;
- int len2= prefix.length;
- int n= Math.min(len1, len2);
- int i= 0;
- while (n-- != 0) {
- char c1= str[i];
- char c2= prefix[i++];
- if (c1 != c2) {
- return c1 - c2;
- }
- }
- if (len2 == i)
- return 0;
-
- return 1;
- }
/**
* Writes a string to the given output stream using UTF-8
* encoding in a machine-independent manner.
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/WordEntry.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/WordEntry.java
index 472c696..4626a36 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/WordEntry.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/WordEntry.java
@@ -1,21 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
+import org.eclipse.jdt.core.compiler.CharOperation;
+
public class WordEntry {
protected char[] fWord;
protected int fNumRefs;
protected int[] fRefs;
public WordEntry() {
- this(new char[0]);
+ this(CharOperation.NO_CHAR);
}
public WordEntry(char[] word) {
fWord= word;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/WordEntryHashedArray.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/WordEntryHashedArray.java
index d939285..7d5887a 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/WordEntryHashedArray.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/index/impl/WordEntryHashedArray.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.index.impl;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
public final class WordEntryHashedArray {
@@ -80,4 +80,4 @@
s += entries[i].toString() + "\n"; //$NON-NLS-1$
return s;
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/AbstractSearchScope.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/AbstractSearchScope.java
index a339773..3125844 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/AbstractSearchScope.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/AbstractSearchScope.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
import org.eclipse.jdt.core.IJavaElementDelta;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/HierarchyScope.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/HierarchyScope.java
index 6f0291a..c8b0e22 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/HierarchyScope.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/HierarchyScope.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
import java.io.File;
@@ -15,18 +15,10 @@
import java.util.HashSet;
import java.util.Iterator;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeHierarchy;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.internal.core.*;
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
import org.eclipse.jdt.internal.core.JavaElement;
import org.eclipse.jdt.internal.core.JavaModel;
@@ -37,15 +29,18 @@
*/
public class HierarchyScope extends AbstractSearchScope {
- private ITypeHierarchy fHierarchy;
- private IType[] fTypes;
+ public IType focusType;
+ private String focusPath;
+
+ private ITypeHierarchy hierarchy;
+ private IType[] types;
private HashSet resourcePaths;
private IPath[] enclosingProjectsAndJars;
protected IResource[] elements;
protected int elementCount;
- protected boolean needsRefresh;
+ public boolean needsRefresh;
/* (non-Javadoc)
* Adds the given resource to this search scope.
@@ -66,9 +61,35 @@
* Creates a new hiearchy scope for the given type.
*/
public HierarchyScope(IType type) throws JavaModelException {
- this.initialize();
- fHierarchy = type.newTypeHierarchy(null);
- buildResourceVector();
+ this.focusType = type;
+
+ this.enclosingProjectsAndJars = this.computeProjectsAndJars(type);
+
+ // resource path
+ IPackageFragmentRoot root = (IPackageFragmentRoot)type.getPackageFragment().getParent();
+ if (root.isArchive()) {
+ IPath jarPath = root.getPath();
+ Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), jarPath, true);
+ String zipFileName;
+ if (target instanceof IFile) {
+ // internal jar
+ zipFileName = jarPath.toString();
+ } else if (target instanceof File) {
+ // external jar
+ zipFileName = ((File)target).getPath();
+ } else {
+ return; // unknown target
+ }
+ this.focusPath =
+ zipFileName
+ + JAR_FILE_ENTRY_SEPARATOR
+ + type.getFullyQualifiedName().replace('.', '/')
+ + ".class";//$NON-NLS-1$
+ } else {
+ this.focusPath = type.getPath().toString();
+ }
+
+ this.needsRefresh = true;
//disabled for now as this could be expensive
//JavaModelManager.getJavaModelManager().rememberScope(this);
@@ -76,11 +97,11 @@
private void buildResourceVector() throws JavaModelException {
HashMap resources = new HashMap();
HashMap paths = new HashMap();
- fTypes = fHierarchy.getAllTypes();
+ this.types = this.hierarchy.getAllTypes();
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- for (int i = 0; i < fTypes.length; i++) {
- IType type = fTypes[i];
- IResource resource = type.getUnderlyingResource();
+ for (int i = 0; i < this.types.length; i++) {
+ IType type = this.types[i];
+ IResource resource = type.getResource();
if (resource != null && resources.get(resource) == null) {
resources.put(resource, resource);
add(resource);
@@ -121,10 +142,102 @@
this.enclosingProjectsAndJars[i++] = (IPath) iter.next();
}
}
+ /*
+ * Computes the paths of projects and jars that the hierarchy on the given type could contain.
+ * This is a super set of the project and jar paths once the hierarchy is computed.
+ */
+ private IPath[] computeProjectsAndJars(IType type) throws JavaModelException {
+ HashSet set = new HashSet();
+ IPackageFragmentRoot root = (IPackageFragmentRoot)type.getPackageFragment().getParent();
+ if (root.isArchive()) {
+ // add the root
+ set.add(root.getPath());
+ // add all projects that reference this archive and their dependents
+ IPath rootPath = root.getPath();
+ IJavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
+ IJavaProject[] projects = model.getJavaProjects();
+ HashSet visited = new HashSet();
+ for (int i = 0; i < projects.length; i++) {
+ IJavaProject project = projects[i];
+ IClasspathEntry[] classpath = project.getResolvedClasspath(true);
+ for (int j = 0; j < classpath.length; j++) {
+ if (rootPath.equals(classpath[j].getPath())) {
+ // add the project and its binary pkg fragment roots
+ IPackageFragmentRoot[] roots = project.getAllPackageFragmentRoots();
+ set.add(project.getPath());
+ for (int k = 0; k < roots.length; k++) {
+ IPackageFragmentRoot pkgFragmentRoot = roots[k];
+ if (pkgFragmentRoot.getKind() == IPackageFragmentRoot.K_BINARY) {
+ set.add(pkgFragmentRoot.getPath());
+ }
+ }
+ // add the dependent projects
+ this.computeDependents(project, set, visited);
+ break;
+ }
+ }
+ }
+ } else {
+ // add all the project's pkg fragment roots
+ IJavaProject project = (IJavaProject)root.getParent();
+ IPackageFragmentRoot[] roots = project.getAllPackageFragmentRoots();
+ for (int i = 0; i < roots.length; i++) {
+ IPackageFragmentRoot pkgFragmentRoot = roots[i];
+ if (pkgFragmentRoot.getKind() == IPackageFragmentRoot.K_BINARY) {
+ set.add(pkgFragmentRoot.getPath());
+ } else {
+ set.add(pkgFragmentRoot.getParent().getPath());
+ }
+ }
+ // add the dependent projects
+ this.computeDependents(project, set, new HashSet());
+ }
+ IPath[] result = new IPath[set.size()];
+ set.toArray(result);
+ return result;
+ }
+ private void computeDependents(IJavaProject project, HashSet set, HashSet visited) {
+ if (visited.contains(project)) return;
+ visited.add(project);
+ IProject[] dependents = project.getProject().getReferencingProjects();
+ for (int i = 0; i < dependents.length; i++) {
+ try {
+ IJavaProject dependent = JavaCore.create(dependents[i]);
+ IPackageFragmentRoot[] roots = dependent.getPackageFragmentRoots();
+ set.add(dependent.getPath());
+ for (int j = 0; j < roots.length; j++) {
+ IPackageFragmentRoot pkgFragmentRoot = roots[j];
+ if (pkgFragmentRoot.isArchive()) {
+ set.add(pkgFragmentRoot.getPath());
+ }
+ }
+ this.computeDependents(dependent, set, visited);
+ } catch (JavaModelException e) {
+ // project is not a java project
+ }
+ }
+ }
/* (non-Javadoc)
* @see IJavaSearchScope#encloses(String)
*/
public boolean encloses(String resourcePath) {
+ if (this.hierarchy == null) {
+ if (resourcePath.equals(this.focusPath)) {
+ return true;
+ } else {
+ if (this.needsRefresh) {
+ try {
+ this.initialize();
+ } catch (JavaModelException e) {
+ return false;
+ }
+ } else {
+ // the scope is used only to find enclosing projects and jars
+ // clients is responsible for filtering out elements not in the hierarchy (see SearchEngine)
+ return true;
+ }
+ }
+ }
if (this.needsRefresh) {
try {
this.refresh();
@@ -148,6 +261,23 @@
* @see IJavaSearchScope#encloses(IJavaElement)
*/
public boolean encloses(IJavaElement element) {
+ if (this.hierarchy == null) {
+ if (this.focusType.equals(element.getAncestor(IJavaElement.TYPE))) {
+ return true;
+ } else {
+ if (this.needsRefresh) {
+ try {
+ this.initialize();
+ } catch (JavaModelException e) {
+ return false;
+ }
+ } else {
+ // the scope is used only to find enclosing projects and jars
+ // clients is responsible for filtering out elements not in the hierarchy (see SearchEngine)
+ return true;
+ }
+ }
+ }
if (this.needsRefresh) {
try {
this.refresh();
@@ -162,32 +292,20 @@
type = ((IMember) element).getDeclaringType();
}
if (type != null) {
- if (fHierarchy.contains(type)) {
+ if (this.hierarchy.contains(type)) {
return true;
} else {
// be flexible: look at original element (see bug 14106 Declarations in Hierarchy does not find declarations in hierarchy)
IType original;
if (!type.isBinary()
&& (original = (IType)type.getCompilationUnit().getOriginal(type)) != null) {
- return fHierarchy.contains(original);
+ return this.hierarchy.contains(original);
}
}
}
return false;
}
/* (non-Javadoc)
- * Returns whether this search scope encloses the given resource.
- */
- protected boolean encloses(IResource element) {
- IPath elementPath = element.getFullPath();
- for (int i = 0; i < elementCount; i++) {
- if (this.elements[i].getFullPath().isPrefixOf(elementPath)) {
- return true;
- }
- }
- return false;
- }
- /* (non-Javadoc)
* @see IJavaSearchScope#enclosingProjectsAndJars()
* @deprecated
*/
@@ -201,26 +319,32 @@
}
return this.enclosingProjectsAndJars;
}
- protected void initialize() {
+ protected void initialize() throws JavaModelException {
this.resourcePaths = new HashSet();
this.elements = new IResource[5];
this.elementCount = 0;
- this.needsRefresh = false;
+ this.needsRefresh = false;
+ if (this.hierarchy == null) {
+ this.hierarchy = this.focusType.newTypeHierarchy(null);
+ } else {
+ this.hierarchy.refresh(null);
+ }
+ this.buildResourceVector();
}
/*
* @see AbstractSearchScope#processDelta(IJavaElementDelta)
*/
public void processDelta(IJavaElementDelta delta) {
if (this.needsRefresh) return;
- this.needsRefresh = ((TypeHierarchy)fHierarchy).isAffected(delta);
+ this.needsRefresh = this.hierarchy == null ? false : ((TypeHierarchy)this.hierarchy).isAffected(delta);
}
protected void refresh() throws JavaModelException {
- this.initialize();
- fHierarchy.refresh(null);
- this.buildResourceVector();
+ if (this.hierarchy != null) {
+ this.initialize();
+ }
}
public String toString() {
- return "HierarchyScope on " + ((JavaElement)fHierarchy.getType()).toStringWithAncestors(); //$NON-NLS-1$
+ return "HierarchyScope on " + ((JavaElement)this.focusType).toStringWithAncestors(); //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IIndexSearchRequestor.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IIndexSearchRequestor.java
index ad8cf96..5b703be 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IIndexSearchRequestor.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IIndexSearchRequestor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
public interface IIndexSearchRequestor {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IInfoConstants.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IInfoConstants.java
index e69210b..95c5510 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IInfoConstants.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IInfoConstants.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
public interface IInfoConstants {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSearchAdapter.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSearchAdapter.java
index 72070b4..45b0782 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSearchAdapter.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSearchAdapter.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
public class IndexSearchAdapter implements IIndexSearchRequestor {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSelector.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSelector.java
index 3e0be1e..5b6f9dc 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSelector.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/IndexSelector.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
import java.util.ArrayList;
@@ -34,66 +34,77 @@
IJavaSearchScope searchScope;
IJavaElement focus;
IndexManager indexManager;
- IIndex[] indexes;
+ IPath[] indexKeys; // cache of the keys for looking index up
+ boolean isPolymorphicSearch;
public IndexSelector(
IJavaSearchScope searchScope,
IJavaElement focus,
+ boolean isPolymorphicSearch,
IndexManager indexManager) {
this.searchScope = searchScope;
this.focus = focus;
this.indexManager = indexManager;
+ this.isPolymorphicSearch = isPolymorphicSearch;
}
/**
- * Returns whether elements of the given project or jar can see the focus element
- * either because the focus is part of the project or the jar, or because it is
+ * Returns whether elements of the given project or jar can see the given focus (an IJavaProject or
+ * a JarPackageFragmentRot) either because the focus is part of the project or the jar, or because it is
* accessible throught the project's classpath
*/
-private boolean canSeeFocus(IPath projectOrJarPath) {
- // if it is a workspace scope, focus is visible from everywhere
- if (this.searchScope instanceof JavaWorkspaceScope) return true;
-
+public static boolean canSeeFocus(IJavaElement focus, boolean isPolymorphicSearch, IPath projectOrJarPath) {
try {
- while (!(this.focus instanceof IJavaProject) && !(this.focus instanceof JarPackageFragmentRoot)) {
- this.focus = this.focus.getParent();
- }
- IJavaModel model = this.focus.getJavaModel();
- IJavaProject project = this.getJavaProject(projectOrJarPath, model);
- if (this.focus instanceof JarPackageFragmentRoot) {
- // focus is part of a jar
- JarPackageFragmentRoot jar = (JarPackageFragmentRoot)this.focus;
- IPath jarPath = jar.getPath();
- if (project == null) {
- // consider that a jar can see another jar only they are both referenced by the same project
- return this.haveSameParent(projectOrJarPath, jarPath, model);
- } else {
- IClasspathEntry[] entries = ((JavaProject)project).getExpandedClasspath(true);
- for (int i = 0, length = entries.length; i < length; i++) {
- IClasspathEntry entry = entries[i];
+ IJavaModel model = focus.getJavaModel();
+ IJavaProject project = getJavaProject(projectOrJarPath, model);
+ if (project == null) {
+ // projectOrJarPath is a jar
+ // it can see the focus only if it is on the classpath of a project that can see the focus
+ IJavaProject[] allProjects = model.getJavaProjects();
+ for (int i = 0, length = allProjects.length; i < length; i++) {
+ IJavaProject otherProject = allProjects[i];
+ IClasspathEntry[] entries = otherProject.getResolvedClasspath(true);
+ for (int j = 0, length2 = entries.length; j < length2; j++) {
+ IClasspathEntry entry = entries[j];
if ((entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY)
- && entry.getPath().equals(jarPath)) {
- return true;
+ && entry.getPath().equals(projectOrJarPath)) {
+ if (canSeeFocus(focus, isPolymorphicSearch, otherProject.getPath())) {
+ return true;
+ }
}
}
- return false;
}
+ return false;
} else {
- // focus is part of a project
- IJavaProject focusProject = (IJavaProject)this.focus;
- if (project == null) {
- // consider that a jar can see a project only if it is referenced by this project
- IClasspathEntry[] entries = ((JavaProject)focusProject).getExpandedClasspath(true);
+ // projectOrJarPath is a project
+ JavaProject focusProject = focus instanceof JarPackageFragmentRoot ? (JavaProject)focus.getParent() : (JavaProject)focus;
+ if (isPolymorphicSearch) {
+ // look for refering project
+ IClasspathEntry[] entries = focusProject.getExpandedClasspath(true);
for (int i = 0, length = entries.length; i < length; i++) {
IClasspathEntry entry = entries[i];
- if ((entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY)
+ if ((entry.getEntryKind() == IClasspathEntry.CPE_PROJECT)
&& entry.getPath().equals(projectOrJarPath)) {
return true;
}
}
+ }
+ if (focus instanceof JarPackageFragmentRoot) {
+ // focus is part of a jar
+ IPath focusPath = focus.getPath();
+ IClasspathEntry[] entries = ((JavaProject)project).getExpandedClasspath(true);
+ for (int i = 0, length = entries.length; i < length; i++) {
+ IClasspathEntry entry = entries[i];
+ if ((entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY)
+ && entry.getPath().equals(focusPath)) {
+ return true;
+ }
+ }
return false;
} else {
- if (focusProject.equals(project)) {
+ // focus is part of a project
+ if (focus.equals(project)) {
return true;
} else {
+ // look for dependent projects
IPath focusPath = focusProject.getProject().getFullPath();
IClasspathEntry[] entries = ((JavaProject)project).getExpandedClasspath(true);
for (int i = 0, length = entries.length; i < length; i++) {
@@ -111,10 +122,15 @@
return false;
}
}
-private void computeIndexes() {
- ArrayList indexesInScope = new ArrayList();
+/*
+ * Compute the list of paths which are keying index files.
+ */
+private void initializeIndexKeys() {
+
+ ArrayList requiredIndexKeys = new ArrayList();
IPath[] projectsAndJars = this.searchScope.enclosingProjectsAndJars();
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace() .getRoot();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IJavaElement projectOrJarFocus = this.focus == null ? null : getProjectOrJar(this.focus);
for (int i = 0; i < projectsAndJars.length; i++) {
IPath location;
IPath path = projectsAndJars[i];
@@ -125,27 +141,33 @@
&& !new java.io.File(path.toOSString()).exists()) { // and external jar file does not exist
continue;
}
- if (this.focus == null || this.canSeeFocus(path)) {
- IIndex index = this.indexManager.getIndex(path, true /*reuse index file*/, false /*do not create if none*/);
- if (index != null && indexesInScope.indexOf(index) == -1) {
- indexesInScope.add(index);
+ if (projectOrJarFocus == null || canSeeFocus(projectOrJarFocus, this.isPolymorphicSearch, path)) {
+ if (requiredIndexKeys.indexOf(path) == -1) {
+ requiredIndexKeys.add(path);
}
}
}
- this.indexes = new IIndex[indexesInScope.size()];
- indexesInScope.toArray(this.indexes);
+ this.indexKeys = new IPath[requiredIndexKeys.size()];
+ requiredIndexKeys.toArray(this.indexKeys);
}
public IIndex[] getIndexes() {
- if (this.indexes == null) {
- this.computeIndexes();
+ if (this.indexKeys == null) {
+ this.initializeIndexKeys();
}
- return this.indexes;
+ // acquire the in-memory indexes on the fly
+ int length = this.indexKeys.length;
+ IIndex[] indexes = new IIndex[length];
+ for (int i = 0; i < length; i++){
+ // may trigger some index recreation work
+ indexes[i] = indexManager.getIndex(indexKeys[i], true /*reuse index file*/, false /*do not create if none*/);
+ }
+ return indexes;
}
/**
* Returns the java project that corresponds to the given path.
* Returns null if the path doesn't correspond to a project.
*/
-private IJavaProject getJavaProject(IPath path, IJavaModel model) {
+private static IJavaProject getJavaProject(IPath path, IJavaModel model) {
IJavaProject project = model.getJavaProject(path.lastSegment());
if (project.exists()) {
return project;
@@ -153,40 +175,10 @@
return null;
}
}
-/**
- * Returns whether the given jars are referenced in the classpath of the same project.
- */
-private boolean haveSameParent(IPath jarPath1, IPath jarPath2, IJavaModel model) {
- if (jarPath1.equals(jarPath2)) {
- return true;
+public static IJavaElement getProjectOrJar(IJavaElement element) {
+ while (!(element instanceof IJavaProject) && !(element instanceof JarPackageFragmentRoot)) {
+ element = element.getParent();
}
- try {
- IJavaProject[] projects = model.getJavaProjects();
- for (int i = 0, length = projects.length; i < length; i++) {
- IJavaProject project = projects[i];
- IClasspathEntry[] entries = ((JavaProject)project).getExpandedClasspath(true);
- boolean referencesJar1 = false;
- boolean referencesJar2 = false;
- for (int j = 0, length2 = entries.length; j < length2; j++) {
- IClasspathEntry entry = entries[j];
- if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- IPath entryPath = entry.getPath();
- if (entryPath.equals(jarPath1)) {
- referencesJar1 = true;
- } else if (entryPath.equals(jarPath2)) {
- referencesJar2 = true;
- }
- }
- }
- if (referencesJar1 && referencesJar2) {
- return true;
- }
-
- }
- } catch (JavaModelException e) {
- e.printStackTrace();
- }
- return false;
+ return element;
}
-
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java
index 9e1173e..20a544a 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
import java.util.ArrayList;
@@ -111,7 +111,7 @@
if (root.isArchive()) {
this.add(root.getPath().append(new Path(element.getElementName().replace('.', '/'))), false);
} else {
- IResource resource = element.getUnderlyingResource();
+ IResource resource = element.getResource();
if (resource != null && resource.isAccessible()) {
this.add(resource.getFullPath(), false);
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaWorkspaceScope.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaWorkspaceScope.java
index ce257f7..b08d41c 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaWorkspaceScope.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaWorkspaceScope.java
@@ -1,25 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
import java.util.HashSet;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.core.IJavaProject;
/**
* A Java-specific scope for searching the entire workspace.
@@ -72,20 +70,13 @@
public int hashCode() {
return JavaWorkspaceScope.class.hashCode();
}
-
-
public void initialize() {
super.initialize();
- JavaCore javaCore = JavaCore.getJavaCore();
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0, length = projects.length; i < length; i++) {
- IProject project = projects[i];
- if (project.isAccessible()) {
- try {
- this.add(javaCore.create(project), false, new HashSet(2));
- } catch (JavaModelException e) {
- }
- }
+ try {
+ IJavaProject[] projects = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProjects();
+ for (int i = 0, length = projects.length; i < length; i++)
+ this.add(projects[i], false, new HashSet(2));
+ } catch (JavaModelException ignored) {
}
this.needsInitialize = false;
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PathCollector.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PathCollector.java
index d37ef15..4e799f1 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PathCollector.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PathCollector.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
import java.util.HashSet;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java
index 5cb8862..c1b4f92 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/PatternSearchJob.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
import java.io.IOException;
@@ -32,6 +32,7 @@
protected IndexManager indexManager;
protected int detailLevel;
protected IndexSelector indexSelector;
+ protected boolean isPolymorphicSearch;
protected long executionTime = 0;
public PatternSearchJob(
@@ -45,15 +46,16 @@
pattern,
scope,
null,
+ false,
detailLevel,
requestor,
indexManager);
}
-
public PatternSearchJob(
SearchPattern pattern,
IJavaSearchScope scope,
IJavaElement focus,
+ boolean isPolymorphicSearch,
int detailLevel,
IIndexSearchRequestor requestor,
IndexManager indexManager) {
@@ -61,18 +63,16 @@
this.pattern = pattern;
this.scope = scope;
this.focus = focus;
+ this.isPolymorphicSearch = isPolymorphicSearch;
this.detailLevel = detailLevel;
this.requestor = requestor;
this.indexManager = indexManager;
}
-
public boolean belongsTo(String jobFamily) {
return true;
}
-
- /**
- * execute method comment.
- */
+ public void cancel() {
+ }
public boolean execute(IProgressMonitor progressMonitor) {
if (progressMonitor != null && progressMonitor.isCanceled())
@@ -81,7 +81,7 @@
executionTime = 0;
if (this.indexSelector == null) {
this.indexSelector =
- new IndexSelector(this.scope, this.focus, this.indexManager);
+ new IndexSelector(this.scope, this.focus, this.isPolymorphicSearch, this.indexManager);
}
IIndex[] searchIndexes = this.indexSelector.getIndexes();
try {
@@ -109,15 +109,23 @@
}
}
}
-
- /**
- * execute method comment.
- */
+ public boolean isReadyToRun() {
+ if (this.indexSelector == null) { // only check once, i.e. as long as this job is used, it will keep the same index picture
+ this.indexSelector = new IndexSelector(this.scope, this.focus, this.isPolymorphicSearch, this.indexManager);
+ this.indexSelector.getIndexes(); // will only cache answer if all indexes were available originally
+ }
+ return true;
+ }
public boolean search(IIndex index, IProgressMonitor progressMonitor) {
if (progressMonitor != null && progressMonitor.isCanceled())
throw new OperationCanceledException();
+// IIndex inMemIndex = indexManager.peekAtIndex(new Path(((Index)index).toString.substring("Index for ".length()).replace('\\','/')));
+// if (inMemIndex != index) {
+// System.out.println("SANITY CHECK: search job using obsolete index: ["+index+ "] instead of: ["+inMemIndex+"]");
+// }
+
if (index == null)
return COMPLETE;
ReadWriteMonitor monitor = indexManager.getMonitorFor(index);
@@ -131,9 +139,7 @@
try {
monitor.exitRead(); // free read lock
monitor.enterWrite(); // ask permission to write
- if (IndexManager.VERBOSE)
- JobManager.verbose("-> merging index " + index.getIndexFile()); //$NON-NLS-1$
- index.save();
+ this.indexManager.saveIndex(index);
} catch (IOException e) {
return FAILED;
} finally {
@@ -155,14 +161,7 @@
monitor.exitRead(); // finished reading
}
}
-
public String toString() {
return "searching " + pattern.toString(); //$NON-NLS-1$
}
- /*
- * @see IJob#cancel()
- */
- public void cancel() {
- }
-
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/SubTypeSearchJob.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/SubTypeSearchJob.java
index a677af2..f02b353 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/SubTypeSearchJob.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/SubTypeSearchJob.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
import java.io.IOException;
@@ -25,7 +25,6 @@
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
import org.eclipse.jdt.internal.core.search.indexing.ReadWriteMonitor;
import org.eclipse.jdt.internal.core.search.matching.SearchPattern;
-import org.eclipse.jdt.internal.core.search.processing.JobManager;
public class SubTypeSearchJob extends PatternSearchJob {
@@ -33,8 +32,15 @@
public SubTypeSearchJob(SearchPattern pattern, IJavaSearchScope scope, int detailLevel, IIndexSearchRequestor requestor, IndexManager indexManager) {
super(pattern, scope, detailLevel, requestor, indexManager);
}
-public SubTypeSearchJob(SearchPattern pattern, IJavaSearchScope scope, IJavaElement focus, int detailLevel, IIndexSearchRequestor requestor, org.eclipse.jdt.internal.core.search.indexing.IndexManager indexManager) {
- super(pattern, scope, focus, detailLevel, requestor, indexManager);
+public SubTypeSearchJob(SearchPattern pattern, IJavaSearchScope scope, IJavaElement focus, int detailLevel, IIndexSearchRequestor requestor, IndexManager indexManager) {
+ super(
+ pattern,
+ scope,
+ focus,
+ false/*not a polymorphic search*/,
+ detailLevel,
+ requestor,
+ indexManager);
}
public void closeAll(){
@@ -65,9 +71,7 @@
try {
monitor.exitRead(); // free read lock
monitor.enterWrite(); // ask permission to write
- if (IndexManager.VERBOSE)
- JobManager.verbose("-> merging index " + index.getIndexFile()); //$NON-NLS-1$
- index.save();
+ this.indexManager.saveIndex(index);
} catch(IOException e){
return FAILED;
} finally {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/Util.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/Util.java
index 77e20d1..b5987ed 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/Util.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/Util.java
@@ -1,20 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
public class Util {
@@ -101,7 +101,12 @@
* Creates a NLS catalog for the given locale.
*/
public static void relocalize() {
- bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+ try {
+ bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+ } catch(MissingResourceException e) {
+ System.out.println("Missing resource : " + bundleName.replace('.', '/') + ".properties for locale " + Locale.getDefault()); //$NON-NLS-1$//$NON-NLS-2$
+ throw e;
+ }
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java
index 2b4caa0..3ebe753 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AbstractIndexer.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
import java.io.IOException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IDocument;
import org.eclipse.jdt.internal.core.index.IIndexer;
import org.eclipse.jdt.internal.core.index.IIndexerOutput;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddClassFileToIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddClassFileToIndex.java
index a3074ca..68c0b73 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddClassFileToIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddClassFileToIndex.java
@@ -1,87 +1,42 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
import java.io.IOException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.internal.core.index.IIndex;
import org.eclipse.jdt.internal.core.index.impl.IFileDocument;
-import org.eclipse.jdt.internal.core.search.processing.JobManager;
-class AddClassFileToIndex extends IndexRequest {
- IFile resource;
- IndexManager manager;
- IPath indexedContainer;
+class AddClassFileToIndex extends AddFileToIndex {
byte[] contents;
- public AddClassFileToIndex(
- IFile resource,
- IndexManager manager,
- IPath indexedContainer) {
- this.resource = resource;
- this.manager = manager;
- this.indexedContainer = indexedContainer;
+
+ public AddClassFileToIndex(IFile resource, IPath indexedContainer, IndexManager manager) {
+ super(resource, indexedContainer, manager);
}
- public boolean belongsTo(String jobFamily) {
- return jobFamily.equals(this.indexedContainer.segment(0));
+ protected boolean indexDocument(IIndex index) throws IOException {
+ if (!initializeContents()) return false;
+ index.add(new IFileDocument(resource, this.contents), new BinaryIndexer(true));
+ return true;
}
- public boolean execute(IProgressMonitor progressMonitor) {
-
- if (progressMonitor != null && progressMonitor.isCanceled()) return COMPLETE;
-
- try {
- IIndex index = manager.getIndex(this.indexedContainer, true /*reuse index file*/, true /*create if none*/);
- /* ensure no concurrent write access to index */
- if (index == null)
- return COMPLETE;
- ReadWriteMonitor monitor = manager.getMonitorFor(index);
- if (monitor == null)
- return COMPLETE; // index got deleted since acquired
+ public boolean initializeContents() {
+ if (this.contents == null) {
try {
- monitor.enterWrite(); // ask permission to write
- byte[] contents = this.getContents();
- if (contents == null)
- return FAILED;
- index.add(new IFileDocument(resource, contents), new BinaryIndexer(true));
- } finally {
- monitor.exitWrite(); // free write lock
+ IPath location = resource.getLocation();
+ if (location != null)
+ this.contents = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(location.toFile());
+ } catch (IOException e) {
}
- } catch (IOException e) {
- if (JobManager.VERBOSE) {
- JobManager.verbose("-> failed to index " + this.resource + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
- e.printStackTrace();
- }
- return FAILED;
}
- return COMPLETE;
+ return this.contents != null;
}
- private byte[] getContents() {
- if (this.contents == null)
- this.initializeContents();
- return this.contents;
- }
- public void initializeContents() {
- try {
- IPath location = resource.getLocation();
- if (location != null) {
- this.contents =
- org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(
- resource.getLocation().toFile());
- }
- } catch (IOException e) {
- }
- }
- public String toString() {
- return "indexing " + resource.getFullPath(); //$NON-NLS-1$
- }
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddCompilationUnitToIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddCompilationUnitToIndex.java
index 7c5a6ce..151f257 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddCompilationUnitToIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddCompilationUnitToIndex.java
@@ -1,88 +1,42 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
import java.io.IOException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.internal.core.index.IIndex;
import org.eclipse.jdt.internal.core.index.impl.IFileDocument;
-import org.eclipse.jdt.internal.core.search.processing.JobManager;
-class AddCompilationUnitToIndex extends IndexRequest {
- IFile resource;
- IndexManager manager;
- IPath indexedContainer;
+class AddCompilationUnitToIndex extends AddFileToIndex {
char[] contents;
- public AddCompilationUnitToIndex(
- IFile resource,
- IndexManager manager,
- IPath indexedContainer) {
- this.resource = resource;
- this.manager = manager;
- this.indexedContainer = indexedContainer;
- }
- public boolean belongsTo(String jobFamily) {
- return jobFamily.equals(this.indexedContainer.segment(0));
- }
- public boolean execute(IProgressMonitor progressMonitor) {
- if (progressMonitor != null && progressMonitor.isCanceled()) return COMPLETE;
- try {
- IIndex index = manager.getIndex(this.indexedContainer, true /*reuse index file*/, true /*create if none*/);
-
- /* ensure no concurrent write access to index */
- if (index == null)
- return COMPLETE;
- ReadWriteMonitor monitor = manager.getMonitorFor(index);
- if (monitor == null)
- return COMPLETE; // index got deleted since acquired
+ public AddCompilationUnitToIndex(IFile resource, IPath indexedContainer, IndexManager manager) {
+ super(resource, indexedContainer, manager);
+ }
+ protected boolean indexDocument(IIndex index) throws IOException {
+ if (!initializeContents()) return false;
+ index.add(new IFileDocument(resource, this.contents), new SourceIndexer(resource));
+ return true;
+ }
+ public boolean initializeContents() {
+ if (this.contents == null) {
try {
- monitor.enterWrite(); // ask permission to write
- char[] contents = this.getContents();
- if (contents == null)
- return FAILED;
- index.add(new IFileDocument(resource, contents), new SourceIndexer());
- } finally {
- monitor.exitWrite(); // free write lock
+ IPath location = resource.getLocation();
+ if (location != null)
+ this.contents = org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(location.toFile(), null);
+ } catch (IOException e) {
}
- } catch (IOException e) {
- if (JobManager.VERBOSE) {
- JobManager.verbose("-> failed to index " + this.resource + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
- e.printStackTrace();
- }
- return FAILED;
}
- return COMPLETE;
+ return this.contents != null;
}
- private char[] getContents() {
- if (this.contents == null)
- this.initializeContents();
- return contents;
- }
- public void initializeContents() {
-
- try {
- IPath location = resource.getLocation();
- if (location != null) {
- this.contents =
- org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(
- location.toFile(), null);
- }
- } catch (IOException e) {
- }
- }
- public String toString() {
- return "indexing " + resource.getFullPath(); //$NON-NLS-1$
- }
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddFileToIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddFileToIndex.java
new file mode 100644
index 0000000..85b3308
--- /dev/null
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddFileToIndex.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.search.indexing;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.internal.core.index.IIndex;
+import org.eclipse.jdt.internal.core.search.processing.JobManager;
+
+abstract class AddFileToIndex extends IndexRequest {
+ IFile resource;
+
+ public AddFileToIndex(IFile resource, IPath indexPath, IndexManager manager) {
+ super(indexPath, manager);
+ this.resource = resource;
+ }
+ public boolean execute(IProgressMonitor progressMonitor) {
+
+ if (progressMonitor != null && progressMonitor.isCanceled()) return true;
+
+ /* ensure no concurrent write access to index */
+ IIndex index = manager.getIndex(this.indexPath, true, /*reuse index file*/ true /*create if none*/);
+ if (index == null) return true;
+ ReadWriteMonitor monitor = manager.getMonitorFor(index);
+ if (monitor == null) return true; // index got deleted since acquired
+
+ try {
+ monitor.enterWrite(); // ask permission to write
+ if (!indexDocument(index)) return false;
+ } catch (IOException e) {
+ if (JobManager.VERBOSE) {
+ JobManager.verbose("-> failed to index " + this.resource + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
+ e.printStackTrace();
+ }
+ return false;
+ } finally {
+ monitor.exitWrite(); // free write lock
+ }
+ return true;
+ }
+ protected abstract boolean indexDocument(IIndex index) throws IOException;
+ public String toString() {
+ return "indexing " + this.resource.getFullPath(); //$NON-NLS-1$
+ }
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddFolderToIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddFolderToIndex.java
new file mode 100644
index 0000000..9038772
--- /dev/null
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddFolderToIndex.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.search.indexing;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.internal.core.Util;
+import org.eclipse.jdt.internal.core.index.IIndex;
+import org.eclipse.jdt.internal.core.search.processing.JobManager;
+
+class AddFolderToIndex extends IndexRequest {
+ IPath folderPath;
+ IProject project;
+ char[][] exclusionPattern;
+
+ public AddFolderToIndex(IPath folderPath, IProject project, char[][] exclusionPattern, IndexManager manager) {
+ super(project.getFullPath(), manager);
+ this.folderPath = folderPath;
+ this.project = project;
+ this.exclusionPattern = exclusionPattern;
+ }
+ public boolean execute(IProgressMonitor progressMonitor) {
+
+ if (progressMonitor != null && progressMonitor.isCanceled()) return true;
+ if (!project.isAccessible()) return true; // nothing to do
+ IResource folder = this.project.getParent().findMember(this.folderPath);
+ if (folder == null || folder.getType() == IResource.FILE) return true; // nothing to do, source folder was removed
+
+ /* ensure no concurrent write access to index */
+ IIndex index = manager.getIndex(this.indexPath, true, /*reuse index file*/ true /*create if none*/);
+ if (index == null) return true;
+ ReadWriteMonitor monitor = manager.getMonitorFor(index);
+ if (monitor == null) return true; // index got deleted since acquired
+
+ try {
+ monitor.enterRead(); // ask permission to read
+
+ final IPath container = this.indexPath;
+ final IndexManager indexManager = this.manager;
+ final char[][] pattern = exclusionPattern;
+ folder.accept(
+ new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ switch(proxy.getType()) {
+ case IResource.FILE :
+ if (Util.isJavaFileName(proxy.getName())) {
+ IResource resource = proxy.requestResource();
+ if (pattern == null || !Util.isExcluded(resource, pattern))
+ indexManager.addSource((IFile)resource, container);
+ }
+ return false;
+ case IResource.FOLDER :
+ if (pattern != null && Util.isExcluded(proxy.requestResource(), pattern))
+ return false;
+ }
+ return true;
+ }
+ },
+ IResource.NONE
+ );
+ } catch (CoreException e) {
+ if (JobManager.VERBOSE) {
+ JobManager.verbose("-> failed to add " + this.folderPath + " to index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
+ e.printStackTrace();
+ }
+ return false;
+ } finally {
+ monitor.exitRead(); // free read lock
+ }
+ return true;
+ }
+ public String toString() {
+ return "adding " + this.folderPath + " to index " + this.indexPath; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java
index 0e4d825..a0228bd 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/AddJarFileToIndex.java
@@ -1,18 +1,17 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
import java.io.IOException;
import java.util.Enumeration;
-import java.util.HashSet;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -21,75 +20,71 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.internal.compiler.util.Util;
+import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.index.IIndex;
import org.eclipse.jdt.internal.core.index.IQueryResult;
import org.eclipse.jdt.internal.core.index.impl.JarFileEntryDocument;
import org.eclipse.jdt.internal.core.search.processing.JobManager;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
class AddJarFileToIndex extends IndexRequest {
-
- IndexManager manager;
- String projectName;
IFile resource;
- private String toString;
- IPath path;
- public AddJarFileToIndex(
- IFile resource,
- IndexManager manager,
- String projectName) {
+ public AddJarFileToIndex(IFile resource, IndexManager manager) {
+ super(resource.getFullPath(), manager);
this.resource = resource;
- this.path = resource.getFullPath();
- this.manager = manager;
- this.projectName = projectName;
}
- // can be found either by project name or JAR path name
- public boolean belongsTo(String jobFamily) {
- return jobFamily.equals(projectName) || this.path.toString().equals(jobFamily);
+ public AddJarFileToIndex(IPath indexPath, IndexManager manager) {
+ // external JAR scenario - no resource
+ super(indexPath, manager);
}
-public boolean equals(Object o) {
- if (!(o instanceof AddJarFileToIndex)) return false;
- if (this.resource != null) {
- return this.resource.equals(((AddJarFileToIndex)o).resource);
+ public boolean belongsTo(String projectNameOrJarPath) {
+ // used to remove pending jobs because the project was deleted... not to delete index files
+ // can be found either by project name or JAR path name
+ return super.belongsTo(projectNameOrJarPath)
+ || projectNameOrJarPath.equals(this.indexPath.toString());
}
- if (this.path != null) {
- return this.path.equals(((AddJarFileToIndex)o).path);
+ public boolean equals(Object o) {
+ if (o instanceof AddJarFileToIndex) {
+ if (this.resource != null)
+ return this.resource.equals(((AddJarFileToIndex) o).resource);
+ if (this.indexPath != null)
+ return this.indexPath.equals(((AddJarFileToIndex) o).indexPath);
+ }
+ return false;
}
- return false;
-}
-public int hashCode() {
- if (this.resource != null) {
- return this.resource.hashCode();
+ public int hashCode() {
+ if (this.resource != null)
+ return this.resource.hashCode();
+ if (this.indexPath != null)
+ return this.indexPath.hashCode();
+ return -1;
}
- if (this.path != null) {
- return this.path.hashCode();
- }
- return -1;
-}
public boolean execute(IProgressMonitor progressMonitor) {
-
- if (progressMonitor != null && progressMonitor.isCanceled()) return COMPLETE;
+
+ if (progressMonitor != null && progressMonitor.isCanceled()) return true;
+
try {
- IPath indexedPath = this.path;
- // if index already cached, then do not perform any check
- IIndex index = (IIndex) manager.getIndex(indexedPath, false /*do not reuse index file*/, false /*do not create if none*/);
+ // if index is already cached, then do not perform any check
+ // MUST reset the IndexManager if a jar file is changed
+ IIndex index = (IIndex) manager.getIndex(this.indexPath, false, /*do not reuse index file*/ false /*do not create if none*/);
if (index != null) {
- if (JobManager.VERBOSE)
- JobManager.verbose("-> no indexing required (index already exists) for " + this.path); //$NON-NLS-1$
- return COMPLETE;
+ if (JobManager.VERBOSE)
+ JobManager.verbose("-> no indexing required (index already exists) for " + this.indexPath); //$NON-NLS-1$
+ return true;
}
- index = manager.getIndex(indexedPath, true /*reuse index file*/, true /*create if none*/);
+ index = manager.getIndex(this.indexPath, true, /*reuse index file*/ true /*create if none*/);
if (index == null) {
- if (JobManager.VERBOSE)
- JobManager.verbose("-> index could not be created for " + this.path); //$NON-NLS-1$
- return COMPLETE;
+ if (JobManager.VERBOSE)
+ JobManager.verbose("-> index could not be created for " + this.indexPath); //$NON-NLS-1$
+ return true;
}
ReadWriteMonitor monitor = manager.getMonitorFor(index);
if (monitor == null) {
- if (JobManager.VERBOSE)
- JobManager.verbose("-> index for " + this.path + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$
- return COMPLETE; // index got deleted since acquired
+ if (JobManager.VERBOSE)
+ JobManager.verbose("-> index for " + this.indexPath + " just got deleted"); //$NON-NLS-1$//$NON-NLS-2$
+ return true; // index got deleted since acquired
}
ZipFile zip = null;
try {
@@ -100,14 +95,17 @@
monitor.enterWrite(); // ask permission to write
if (resource != null) {
IPath location = this.resource.getLocation();
- if (location == null)
- return FAILED;
+ if (location == null) return false;
+ if (JavaModelManager.ZIP_ACCESS_VERBOSE)
+ System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + location); //$NON-NLS-1$ //$NON-NLS-2$
zip = new ZipFile(location.toFile());
zipFilePath = (Path) this.resource.getFullPath().makeRelative();
// absolute path relative to the workspace
} else {
- zip = new ZipFile(this.path.toFile());
- zipFilePath = (Path) this.path;
+ if (JavaModelManager.ZIP_ACCESS_VERBOSE)
+ System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Creating ZipFile on " + this.indexPath); //$NON-NLS-1$ //$NON-NLS-2$
+ zip = new ZipFile(this.indexPath.toFile());
+ zipFilePath = (Path) this.indexPath;
// path is already canonical since coming from a library classpath entry
}
@@ -115,110 +113,95 @@
JobManager.verbose("-> indexing " + zip.getName()); //$NON-NLS-1$
long initialTime = System.currentTimeMillis();
- final HashSet indexedFileNames = new HashSet(100);
IQueryResult[] results = index.queryInDocumentNames(""); // all file names //$NON-NLS-1$
- int resultLength = results == null ? 0 : results.length;
- if (resultLength != 0) {
+ int max = results == null ? 0 : results.length;
+ if (max != 0) {
/* check integrity of the existing index file
* if the length is equal to 0, we want to index the whole jar again
* If not, then we want to check that there is no missing entry, if
- * one entry is missing then we
+ * one entry is missing then we recreate the index
*/
- for (int i = 0; i < resultLength; i++) {
- String fileName = results[i].getPath();
- indexedFileNames.add(fileName);
- }
- boolean needToReindex = false;
+ String EXISTS = "OK"; //$NON-NLS-1$
+ String DELETED = "DELETED"; //$NON-NLS-1$
+ SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11);
+ for (int i = 0; i < max; i++)
+ indexedFileNames.put(results[i].getPath(), DELETED);
for (Enumeration e = zip.entries(); e.hasMoreElements();) {
// iterate each entry to index it
ZipEntry ze = (ZipEntry) e.nextElement();
if (Util.isClassFileName(ze.getName())) {
- JarFileEntryDocument entryDocument =
- new JarFileEntryDocument(ze, null, zipFilePath);
- if (!indexedFileNames.remove(entryDocument.getName())) {
- needToReindex = true;
+ JarFileEntryDocument entryDocument = new JarFileEntryDocument(ze, null, zipFilePath);
+ indexedFileNames.put(entryDocument.getName(), EXISTS);
+ }
+ }
+ boolean needToReindex = indexedFileNames.elementSize != max; // a new file was added
+ if (!needToReindex) {
+ Object[] valueTable = indexedFileNames.valueTable;
+ for (int i = 0, l = valueTable.length; i < l; i++) {
+ if (valueTable[i] == DELETED) {
+ needToReindex = true; // a file was deleted so re-index
break;
}
}
- }
- if (!needToReindex && indexedFileNames.size() == 0) {
- if (JobManager.VERBOSE)
- JobManager.verbose(
- "-> no indexing required (index is consistent with library) for " //$NON-NLS-1$
+ if (!needToReindex) {
+ if (JobManager.VERBOSE)
+ JobManager.verbose("-> no indexing required (index is consistent with library) for " //$NON-NLS-1$
+ zip.getName() + " (" //$NON-NLS-1$
+ (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$
- return COMPLETE;
+ return true;
+ }
}
}
/*
* Index the jar for the first time or reindex the jar in case the previous index file has been corrupted
*/
- if (index != null) {
- // index already existed: recreate it so that we forget about previous entries
- index = manager.recreateIndex(indexedPath);
- }
+ // index already existed: recreate it so that we forget about previous entries
+ index = manager.recreateIndex(this.indexPath);
for (Enumeration e = zip.entries(); e.hasMoreElements();) {
if (this.isCancelled) {
- if (JobManager.VERBOSE) {
- JobManager.verbose(
- "-> indexing of " //$NON-NLS-1$
- + zip.getName()
- + " has been cancelled"); //$NON-NLS-1$
- }
- return FAILED;
+ if (JobManager.VERBOSE)
+ JobManager.verbose("-> indexing of " + zip.getName() + " has been cancelled"); //$NON-NLS-1$ //$NON-NLS-2$
+ return false;
}
-
+
// iterate each entry to index it
ZipEntry ze = (ZipEntry) e.nextElement();
if (Util.isClassFileName(ze.getName())) {
- byte[] classFileBytes =
- org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
// Add the name of the file to the index
index.add(
new JarFileEntryDocument(ze, classFileBytes, zipFilePath),
new BinaryIndexer(true));
}
}
+ this.manager.saveIndex(index);
if (JobManager.VERBOSE)
- JobManager.verbose(
- "-> done indexing of " //$NON-NLS-1$
+ JobManager.verbose("-> done indexing of " //$NON-NLS-1$
+ zip.getName() + " (" //$NON-NLS-1$
+ (System.currentTimeMillis() - initialTime) + "ms)"); //$NON-NLS-1$
} finally {
- if (zip != null)
+ if (zip != null) {
+ if (JavaModelManager.ZIP_ACCESS_VERBOSE)
+ System.out.println("(" + Thread.currentThread() + ") [AddJarFileToIndex.execute()] Closing ZipFile " + zip); //$NON-NLS-1$ //$NON-NLS-2$
zip.close();
+ }
monitor.exitWrite(); // free write lock
}
} catch (IOException e) {
if (JobManager.VERBOSE) {
- JobManager.verbose("-> failed to index " + this.path + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
+ JobManager.verbose("-> failed to index " + this.indexPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
- manager.removeIndex(this.path);
- return FAILED;
+ manager.removeIndex(this.indexPath);
+ return false;
}
- return COMPLETE;
+ return true;
}
- /**
- * Insert the method's description here.
- * Creation date: (10/10/00 1:27:18 PM)
- * @return java.lang.String
- */
+ protected Integer updatedIndexState() {
+ return IndexManager.REBUILDING_STATE;
+ }
public String toString() {
- if (toString == null) {
- toString = "indexing " + this.path.toString(); //$NON-NLS-1$
- }
- return toString;
+ return "indexing " + this.indexPath.toString(); //$NON-NLS-1$
}
-
- public AddJarFileToIndex(
- IPath path,
- IndexManager manager,
- String projectName) {
- // external JAR scenario - no resource
- this.path = path;
- this.manager = manager;
- this.projectName = projectName;
- }
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
index b3245ea..e6d8cf5 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
@@ -1,23 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
import java.io.IOException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileStruct;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.classfmt.FieldInfo;
import org.eclipse.jdt.internal.compiler.classfmt.MethodInfo;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IDocument;
public class BinaryIndexer extends AbstractIndexer {
@@ -413,8 +413,16 @@
}
break;
case ClassFileStruct.ClassTag :
+ // add a type reference
name = replace('/', '.', extractClassReference(constantPoolOffsets, reader, i)); // so that it looks like java.lang.String
addTypeReference(name);
+
+ // also add a simple reference on each segment of the qualification (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=24741)
+ char[][] qualification = CharOperation.splitOn('.', name);
+ for (int j = 0, length = qualification.length; j < length; j++) {
+ addNameReference(qualification[j]);
+ }
+ break;
}
}
}
@@ -448,7 +456,7 @@
char[] enclosingTypeName = null;
if (reader.isNestedType()) {
if (reader.isAnonymous()) {
- name = NO_CHAR;
+ name = CharOperation.NO_CHAR;
} else {
name = reader.getInnerSourceName();
}
@@ -546,4 +554,4 @@
* setFileTypes method comment.
*/
public void setFileTypes(String[] fileTypes) {}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IIndexConstants.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IIndexConstants.java
index c15b8e9..81f1f9d 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IIndexConstants.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IIndexConstants.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
public interface IIndexConstants {
@@ -37,8 +37,6 @@
char[] ONE_STAR = new char[] {'*'};
char[][] ONE_STAR_CHAR = new char[][] {ONE_STAR};
- char[] NO_CHAR = new char[0];
- char[][] NO_CHAR_CHAR = new char[0][];
// used as special marker for enclosing type name of local and anonymous classes
char[] ONE_ZERO = new char[] {'0'};
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java
index c6f1511..a9db7f7 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexAllProject.java
@@ -1,24 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
-import java.io.File;
import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashSet;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -26,152 +25,191 @@
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.core.ClasspathEntry;
+import org.eclipse.jdt.internal.core.Util;
import org.eclipse.jdt.internal.core.index.IIndex;
import org.eclipse.jdt.internal.core.index.IQueryResult;
import org.eclipse.jdt.internal.core.index.impl.IFileDocument;
import org.eclipse.jdt.internal.core.search.processing.JobManager;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
-public class IndexAllProject extends IndexRequest implements IResourceVisitor {
+public class IndexAllProject extends IndexRequest {
IProject project;
- IndexManager manager;
- Hashtable indexedFileNames;
- final String OK = "OK"; //$NON-NLS-1$
- final String DELETED = "DELETED"; //$NON-NLS-1$
- long indexLastModified;
+
public IndexAllProject(IProject project, IndexManager manager) {
+ super(project.getFullPath(), manager);
this.project = project;
- this.manager = manager;
}
- public boolean belongsTo(String jobFamily) {
- return jobFamily.equals(project.getName());
+ public boolean equals(Object o) {
+ if (o instanceof IndexAllProject)
+ return this.project.equals(((IndexAllProject) o).project);
+ return false;
}
-public boolean equals(Object o) {
- if (!(o instanceof IndexAllProject)) return false;
- return this.project.equals(((IndexAllProject)o).project);
-}
-public int hashCode() {
- return this.project.hashCode();
-}
/**
* Ensure consistency of a project index. Need to walk all nested resources,
* and discover resources which have either been changed, added or deleted
* since the index was produced.
*/
public boolean execute(IProgressMonitor progressMonitor) {
-
- if (progressMonitor != null && progressMonitor.isCanceled()) return COMPLETE;
- if (!project.isOpen())
- return COMPLETE; // nothing to do
+ if (progressMonitor != null && progressMonitor.isCanceled()) return true;
+ if (!project.isAccessible()) return true; // nothing to do
- IIndex index = manager.getIndex(project.getFullPath(), true /*reuse index file*/, true /*create if none*/);
- if (index == null)
- return COMPLETE;
- ReadWriteMonitor monitor = manager.getMonitorFor(index);
- if (monitor == null)
- return COMPLETE; // index got deleted since acquired
+ IIndex index = this.manager.getIndex(this.indexPath, true, /*reuse index file*/ true /*create if none*/);
+ if (index == null) return true;
+ ReadWriteMonitor monitor = this.manager.getMonitorFor(index);
+ if (monitor == null) return true; // index got deleted since acquired
+
try {
monitor.enterRead(); // ask permission to read
+ saveIfNecessary(index, monitor);
- /* if index has changed, commit these before querying */
- if (index.hasChanged()) {
- try {
- monitor.exitRead(); // free read lock
- monitor.enterWrite(); // ask permission to write
- if (IndexManager.VERBOSE)
- JobManager.verbose("-> merging index " + index.getIndexFile()); //$NON-NLS-1$
- index.save();
- } catch (IOException e) {
- return FAILED;
- } finally {
- monitor.exitWriteEnterRead(); // finished writing and reacquire read permission
- }
- }
- this.indexLastModified = index.getIndexFile().lastModified();
-
- this.indexedFileNames = new Hashtable(100);
IQueryResult[] results = index.queryInDocumentNames(""); // all file names //$NON-NLS-1$
- for (int i = 0, max = results == null ? 0 : results.length; i < max; i++) {
- String fileName = results[i].getPath();
- this.indexedFileNames.put(fileName, DELETED);
- }
- JavaCore javaCore = JavaCore.getJavaCore();
- IJavaProject javaProject = javaCore.create(this.project);
- IClasspathEntry[] entries = javaProject.getRawClasspath(); //only interested in source folders
+ int max = results == null ? 0 : results.length;
+ final SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11);
+ final String OK = "OK"; //$NON-NLS-1$
+ final String DELETED = "DELETED"; //$NON-NLS-1$
+ for (int i = 0; i < max; i++)
+ indexedFileNames.put(results[i].getPath(), DELETED);
+ final long indexLastModified = max == 0 ? 0L : index.getIndexFile().lastModified();
+
+ IJavaProject javaProject = JavaCore.create(this.project);
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
IWorkspaceRoot root = this.project.getWorkspace().getRoot();
for (int i = 0, length = entries.length; i < length; i++) {
- if (this.isCancelled) return FAILED;
-
+ if (this.isCancelled) return false;
+
IClasspathEntry entry = entries[i];
- // Index only the project's source folders.
- // Indexing of libraries is done in a separate job
- if ((entry.getEntryKind() == IClasspathEntry.CPE_SOURCE)) {
- IPath entryPath = entry.getPath();
- IResource sourceFolder = root.findMember(entryPath);
+ if ((entry.getEntryKind() == IClasspathEntry.CPE_SOURCE)) { // Index only source folders. Libraries are done as a separate job
+ IResource sourceFolder = root.findMember(entry.getPath());
if (sourceFolder != null) {
- sourceFolder.accept(this);
+
+ // collect output locations if source is project (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32041)
+ final HashSet outputs = new HashSet();
+ if (sourceFolder.getType() == IResource.PROJECT) {
+ outputs.add(javaProject.getOutputLocation());
+ for (int j = 0; j < length; j++) {
+ IPath output = entries[j].getOutputLocation();
+ if (output != null) {
+ outputs.add(output);
+ }
+ }
+ }
+ final boolean hasOutputs = !outputs.isEmpty();
+
+ final char[][] patterns = ((ClasspathEntry) entry).fullExclusionPatternChars();
+ if (max == 0) {
+ sourceFolder.accept(
+ new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) {
+ if (isCancelled) return false;
+ switch(proxy.getType()) {
+ case IResource.FILE :
+ if (Util.isJavaFileName(proxy.getName())) {
+ IResource resource = proxy.requestResource();
+ if (resource.getLocation() != null && (patterns == null || !Util.isExcluded(resource, patterns))) {
+ String name = new IFileDocument((IFile) resource).getName();
+ indexedFileNames.put(name, resource);
+ }
+ }
+ return false;
+ case IResource.FOLDER :
+ if (patterns != null && Util.isExcluded(proxy.requestResource(), patterns))
+ return false;
+ if (hasOutputs && outputs.contains(proxy.requestFullPath())) {
+ return false;
+ }
+ }
+ return true;
+ }
+ },
+ IResource.NONE
+ );
+ } else {
+ sourceFolder.accept(
+ new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) {
+ if (isCancelled) return false;
+ switch(proxy.getType()) {
+ case IResource.FILE :
+ if (Util.isJavaFileName(proxy.getName())) {
+ IResource resource = proxy.requestResource();
+ IPath path = resource.getLocation();
+ if (path != null && (patterns == null || !Util.isExcluded(resource, patterns))) {
+ String name = new IFileDocument((IFile) resource).getName();
+ indexedFileNames.put(name,
+ indexedFileNames.get(name) == null || indexLastModified < path.toFile().lastModified()
+ ? (Object) resource
+ : (Object) OK);
+ }
+ }
+ return false;
+ case IResource.FOLDER :
+ if (patterns != null && Util.isExcluded(proxy.requestResource(), patterns))
+ return false;
+ if (hasOutputs && outputs.contains(proxy.requestFullPath())) {
+ return false;
+ }
+ }
+ return true;
+ }
+ },
+ IResource.NONE
+ );
+ }
}
}
}
-
- Enumeration names = indexedFileNames.keys();
- while (names.hasMoreElements()) {
- if (this.isCancelled) return FAILED;
- String name = (String) names.nextElement();
- Object value = indexedFileNames.get(name);
- if (value instanceof IFile) {
- manager.addSource((IFile) value, this.project.getFullPath());
- } else if (value == DELETED) {
- manager.remove(name, this.project.getFullPath());
+ Object[] names = indexedFileNames.keyTable;
+ Object[] values = indexedFileNames.valueTable;
+ boolean shouldSave = false;
+ for (int i = 0, length = names.length; i < length; i++) {
+ String name = (String) names[i];
+ if (name != null) {
+ if (this.isCancelled) return false;
+
+ Object value = values[i];
+ if (value != OK) {
+ shouldSave = true;
+ if (value == DELETED)
+ this.manager.remove(name, this.indexPath);
+ else
+ this.manager.addSource((IFile) value, this.indexPath);
+ }
}
}
+
+ // request to save index when all cus have been indexed
+ if (shouldSave)
+ this.manager.request(new SaveIndex(this.indexPath, this.manager));
+
} catch (CoreException e) {
if (JobManager.VERBOSE) {
JobManager.verbose("-> failed to index " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
- manager.removeIndex(project.getFullPath());
- return FAILED;
+ this.manager.removeIndex(this.indexPath);
+ return false;
} catch (IOException e) {
if (JobManager.VERBOSE) {
JobManager.verbose("-> failed to index " + this.project + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
- manager.removeIndex(project.getFullPath());
- return FAILED;
+ this.manager.removeIndex(this.indexPath);
+ return false;
} finally {
monitor.exitRead(); // free read lock
}
- return COMPLETE;
- }
- public String toString() {
- return "indexing project " + project.getFullPath(); //$NON-NLS-1$
- }
- public boolean visit(IResource resource) {
- if (this.isCancelled) return false;
-
- if (resource.getType() == IResource.FILE) {
- String extension = resource.getFileExtension();
- if ("java".equalsIgnoreCase(extension)) { //$NON-NLS-1$
- IPath path = resource.getLocation();
- if (path != null) {
- File resourceFile = path.toFile();
- String name = new IFileDocument((IFile) resource).getName();
- if (this.indexedFileNames.get(name) == null) {
- this.indexedFileNames.put(name, resource);
- } else {
- this.indexedFileNames.put(
- name,
- resourceFile.lastModified() > this.indexLastModified
- ? (Object) resource
- : (Object) OK);
- }
- }
- }
- return false;
- }
return true;
}
-
-}
\ No newline at end of file
+ public int hashCode() {
+ return this.project.hashCode();
+ }
+ protected Integer updatedIndexState() {
+ return IndexManager.REBUILDING_STATE;
+ }
+ public String toString() {
+ return "indexing project " + this.project.getFullPath(); //$NON-NLS-1$
+ }
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java
index 6773649..6585fb3 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexBinaryFolder.java
@@ -1,55 +1,44 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
-import java.io.File;
import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Hashtable;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.internal.core.Util;
import org.eclipse.jdt.internal.core.index.IIndex;
import org.eclipse.jdt.internal.core.index.IQueryResult;
import org.eclipse.jdt.internal.core.index.impl.IFileDocument;
import org.eclipse.jdt.internal.core.search.processing.JobManager;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
public class IndexBinaryFolder extends IndexRequest {
IFolder folder;
- IndexManager manager;
- IProject project;
- public IndexBinaryFolder(
- IFolder folder,
- IndexManager manager,
- IProject project) {
+
+ public IndexBinaryFolder(IFolder folder, IndexManager manager) {
+ super(folder.getFullPath(), manager);
this.folder = folder;
- this.manager = manager;
- this.project = project;
}
- public boolean belongsTo(String jobFamily) {
- return jobFamily.equals(this.project.getName());
+ public boolean equals(Object o) {
+ if (o instanceof IndexBinaryFolder)
+ return this.folder.equals(((IndexBinaryFolder) o).folder);
+ return false;
}
-public boolean equals(Object o) {
- if (!(o instanceof IndexBinaryFolder)) return false;
- return this.folder.equals(((IndexBinaryFolder)o).folder);
-}
-public int hashCode() {
- return this.folder.hashCode();
-}
/**
* Ensure consistency of a folder index. Need to walk all nested resources,
* and discover resources which have either been changed, added or deleted
@@ -57,103 +46,119 @@
*/
public boolean execute(IProgressMonitor progressMonitor) {
- if (progressMonitor != null && progressMonitor.isCanceled()) return COMPLETE;
+ if (progressMonitor != null && progressMonitor.isCanceled()) return true;
+ if (!this.folder.isAccessible()) return true; // nothing to do
- if (!this.folder.isAccessible())
- return COMPLETE; // nothing to do
+ IIndex index = this.manager.getIndex(this.indexPath, true, /*reuse index file*/ true /*create if none*/);
+ if (index == null) return true;
+ ReadWriteMonitor monitor = this.manager.getMonitorFor(index);
+ if (monitor == null) return true; // index got deleted since acquired
- IIndex index = manager.getIndex(this.folder.getFullPath(), true /*reuse index file*/, true /*create if none*/);
- if (index == null)
- return COMPLETE;
- ReadWriteMonitor monitor = manager.getMonitorFor(index);
- if (monitor == null)
- return COMPLETE; // index got deleted since acquired
try {
monitor.enterRead(); // ask permission to read
+ saveIfNecessary(index, monitor);
- /* if index has changed, commit these before querying */
- if (index.hasChanged()) {
- try {
- monitor.exitRead(); // free read lock
- monitor.enterWrite(); // ask permission to write
- if (IndexManager.VERBOSE)
- JobManager.verbose("-> merging index " + index.getIndexFile()); //$NON-NLS-1$
- index.save();
- } catch (IOException e) {
- return FAILED;
- } finally {
- monitor.exitWriteEnterRead(); // finished writing and reacquire read permission
- }
- }
+ IQueryResult[] results = index.queryInDocumentNames(""); // all file names //$NON-NLS-1$
+ int max = results == null ? 0 : results.length;
+ final SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11);
final String OK = "OK"; //$NON-NLS-1$
final String DELETED = "DELETED"; //$NON-NLS-1$
- final long indexLastModified = index.getIndexFile().lastModified();
-
- final Hashtable indexedFileNames = new Hashtable(100);
- IQueryResult[] results = index.queryInDocumentNames("");// all file names //$NON-NLS-1$
- for (int i = 0, max = results == null ? 0 : results.length; i < max; i++) {
- String fileName = results[i].getPath();
- indexedFileNames.put(fileName, DELETED);
- }
- this.folder.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) {
- if (isCancelled) return false;
- if (resource.getType() == IResource.FILE) {
- String extension = resource.getFileExtension();
- if ((extension != null)
- && extension.equalsIgnoreCase("class")) { //$NON-NLS-1$
- IPath path = resource.getLocation();
- if (path != null) {
- File resourceFile = path.toFile();
- String name = new IFileDocument((IFile) resource).getName();
- if (indexedFileNames.get(name) == null) {
+ if (max == 0) {
+ this.folder.accept(new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) {
+ if (isCancelled) return false;
+ if (proxy.getType() == IResource.FILE) {
+ if (Util.isClassFileName(proxy.getName())) {
+ IResource resource = proxy.requestResource();
+ if (resource.getLocation() != null) {
+ String name = new IFileDocument((IFile) resource).getName();
indexedFileNames.put(name, resource);
- } else {
- indexedFileNames.put(
- name,
- resourceFile.lastModified() > indexLastModified
- ? (Object) resource
- : (Object) OK);
}
}
+ return false;
}
- return false;
+ return true;
}
- return true;
- }
- });
- Enumeration names = indexedFileNames.keys();
- while (names.hasMoreElements()) {
- if (this.isCancelled) return FAILED;
-
- String name = (String) names.nextElement();
- Object value = indexedFileNames.get(name);
- if (value instanceof IFile) {
- manager.addBinary((IFile) value, this.folder.getFullPath());
- } else if (value == DELETED) {
- manager.remove(name, this.project.getFullPath());
+ }, IResource.NONE);
+ } else {
+ for (int i = 0; i < max; i++)
+ indexedFileNames.put(results[i].getPath(), DELETED);
+
+ final long indexLastModified = index.getIndexFile().lastModified();
+ this.folder.accept(
+ new IResourceProxyVisitor() {
+ public boolean visit(IResourceProxy proxy) {
+ if (isCancelled) return false;
+ if (proxy.getType() == IResource.FILE) {
+ if (Util.isClassFileName(proxy.getName())) {
+ IResource resource = proxy.requestResource();
+ IPath path = resource.getLocation();
+ if (path != null) {
+ String name = new IFileDocument((IFile) resource).getName();
+ indexedFileNames.put(name,
+ indexedFileNames.get(name) == null || indexLastModified < path.toFile().lastModified()
+ ? (Object) resource
+ : (Object) OK);
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+ },
+ IResource.NONE
+ );
+ }
+
+ Object[] names = indexedFileNames.keyTable;
+ Object[] values = indexedFileNames.valueTable;
+ boolean shouldSave = false;
+ for (int i = 0, length = names.length; i < length; i++) {
+ String name = (String) names[i];
+ if (name != null) {
+ if (this.isCancelled) return false;
+
+ Object value = values[i];
+ if (value != OK) {
+ shouldSave = true;
+ if (value == DELETED)
+ this.manager.remove(name, this.indexPath);
+ else
+ this.manager.addBinary((IFile) value, this.indexPath);
+ }
}
}
+
+ // request to save index when all class files have been indexed
+ if (shouldSave)
+ this.manager.request(new SaveIndex(this.indexPath, this.manager));
+
} catch (CoreException e) {
if (JobManager.VERBOSE) {
JobManager.verbose("-> failed to index " + this.folder + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
- manager.removeIndex(this.folder.getFullPath());
- return FAILED;
+ this.manager.removeIndex(this.indexPath);
+ return false;
} catch (IOException e) {
if (JobManager.VERBOSE) {
JobManager.verbose("-> failed to index " + this.folder + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
- manager.removeIndex(this.folder.getFullPath());
- return FAILED;
+ this.manager.removeIndex(this.indexPath);
+ return false;
} finally {
monitor.exitRead(); // free read lock
}
- return COMPLETE;
+ return true;
+ }
+ public int hashCode() {
+ return this.folder.hashCode();
+ }
+ protected Integer updatedIndexState() {
+ return IndexManager.REBUILDING_STATE;
}
public String toString() {
return "indexing binary folder " + this.folder.getFullPath(); //$NON-NLS-1$
}
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java
index 603069d..4f6933a 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexManager.java
@@ -1,16 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
+import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -18,22 +20,17 @@
import java.util.Map;
import java.util.zip.CRC32;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaModel;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.core.DeltaProcessor;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.core.JavaModel;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.JavaProject;
@@ -41,18 +38,17 @@
import org.eclipse.jdt.internal.core.index.impl.Index;
import org.eclipse.jdt.internal.core.search.IndexSelector;
import org.eclipse.jdt.internal.core.search.JavaWorkspaceScope;
-import org.eclipse.jdt.internal.core.search.Util;
import org.eclipse.jdt.internal.core.search.processing.IJob;
import org.eclipse.jdt.internal.core.search.processing.JobManager;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
public class IndexManager extends JobManager implements IIndexConstants {
/* number of file contents in memory */
public static int MAX_FILES_IN_MEMORY = 0;
-
- public IWorkspace workspace;
- /* indexes */
- Map indexes = new HashMap(5);
+ public IWorkspace workspace;
+ public SimpleLookupTable indexNames = new SimpleLookupTable();
+ private Map indexes = new HashMap(5);
/* read write monitors */
private Map monitors = new HashMap(5);
@@ -61,32 +57,32 @@
private boolean needToSave = false;
private static final CRC32 checksumCalculator = new CRC32();
private IPath javaPluginLocation = null;
-
- /* projects to check consistency for */
- IProject[] projectsToCheck = null;
-
-/**
- * Before processing all jobs, need to ensure that the indexes are up to date.
- */
-public void activateProcessing() {
- try {
- Thread.currentThread().sleep(10000); // wait 10 seconds so as not to interfere with plugin startup
- } catch (InterruptedException ie) {
- }
- checkIndexConsistency();
- super.activateProcessing();
-}
-/**
- * Trigger addition of a resource to an index
- * Note: the actual operation is performed in background
- */
-public void addSource(IFile resource, IPath indexedContainer){
- if (JavaCore.getPlugin() == null) return;
- AddCompilationUnitToIndex job = new AddCompilationUnitToIndex(resource, this, indexedContainer);
- if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
- job.initializeContents();
+
+ /* can only replace a current state if its less than the new one */
+ private SimpleLookupTable indexStates = null;
+ private File savedIndexNamesFile =
+ new File(getJavaPluginWorkingLocation().append("savedIndexNames.txt").toOSString()); //$NON-NLS-1$
+ public static Integer SAVED_STATE = new Integer(0);
+ public static Integer UPDATING_STATE = new Integer(1);
+ public static Integer UNKNOWN_STATE = new Integer(2);
+ public static Integer REBUILDING_STATE = new Integer(3);
+
+public synchronized void aboutToUpdateIndex(IPath path, Integer newIndexState) {
+ // newIndexState is either UPDATING_STATE or REBUILDING_STATE
+ // must tag the index as inconsistent, in case we exit before the update job is started
+ String indexName = computeIndexName(path);
+ Object state = getIndexStates().get(indexName);
+ Integer currentIndexState = state == null ? UNKNOWN_STATE : (Integer) state;
+ if (currentIndexState.equals(REBUILDING_STATE)) return; // already rebuilding the index
+
+ int compare = newIndexState.compareTo(currentIndexState);
+ if (compare > 0) {
+ // so UPDATING_STATE replaces SAVED_STATE and REBUILDING_STATE replaces everything
+ updateIndexState(indexName, newIndexState);
+ } else if (compare < 0 && this.indexes.get(path) == null) {
+ // if already cached index then there is nothing more to do
+ rebuildIndex(indexName, path);
}
- request(job);
}
/**
* Trigger addition of a resource to an index
@@ -94,93 +90,41 @@
*/
public void addBinary(IFile resource, IPath indexedContainer){
if (JavaCore.getPlugin() == null) return;
- AddClassFileToIndex job = new AddClassFileToIndex(resource, this, indexedContainer);
+ AddClassFileToIndex job = new AddClassFileToIndex(resource, indexedContainer, this);
if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
- job.initializeContents();
+ // reduces the chance that the file is open later on, preventing it from being deleted
+ if (!job.initializeContents()) return;
}
request(job);
}
/**
- * Index the content of the given source folder.
+ * Trigger addition of a resource to an index
+ * Note: the actual operation is performed in background
*/
-public void indexSourceFolder(JavaProject javaProject, IPath sourceFolder) {
- IProject project = javaProject.getProject();
- final IPath container = project.getFullPath();
- IContainer folder;
- if (container.equals(sourceFolder)) {
- folder = project;
- } else {
- folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(sourceFolder);
+public void addSource(IFile resource, IPath indexedContainer){
+ if (JavaCore.getPlugin() == null) return;
+ AddCompilationUnitToIndex job = new AddCompilationUnitToIndex(resource, indexedContainer, this);
+ if (this.awaitingJobsCount() < MAX_FILES_IN_MEMORY) {
+ // reduces the chance that the file is open later on, preventing it from being deleted
+ if (!job.initializeContents()) return;
}
- try {
- folder.accept(new IResourceVisitor() {
- /*
- * @see IResourceVisitor#visit(IResource)
- */
- public boolean visit(IResource resource) throws CoreException {
- if (resource instanceof IFile) {
- if ("java".equalsIgnoreCase(resource.getFileExtension())) { //$NON-NLS-1$
- addSource((IFile)resource, container);
- }
- return false;
- } else {
- return true;
- }
- }
- });
- } catch (CoreException e) {
- // Folder does not exist.
- // It will be indexed only when DeltaProcessor detects its addition
+ request(job);
+}
+String computeIndexName(IPath path) {
+ String name = (String) indexNames.get(path);
+ if (name == null) {
+ String pathString = path.toOSString();
+ checksumCalculator.reset();
+ checksumCalculator.update(pathString.getBytes());
+ String fileName = Long.toString(checksumCalculator.getValue()) + ".index"; //$NON-NLS-1$
+ if (VERBOSE)
+ JobManager.verbose("-> index name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
+ name = getJavaPluginWorkingLocation().append(fileName).toOSString();
+ indexNames.put(path, name);
}
+ return name;
}
/**
- * Ensures that indexes are up to date with workbench content. Typically
- * it is invoked in background when activate the job processing.
- */
-public void checkIndexConsistency() {
-
- if (VERBOSE) JobManager.verbose("STARTING ensuring consistency"); //$NON-NLS-1$
-
- boolean wasEnabled = isEnabled();
- try {
- disable();
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- if (workspace == null) return; // NB: workspace can be null if it has shut down (see http://dev.eclipse.org/bugs/show_bug.cgi?id=16175)
- if (this.projectsToCheck != null){
- IProject[] projects = this.projectsToCheck;
- this.projectsToCheck = null;
- for (int i = 0, max = projects.length; i < max; i++){
- IProject project = projects[i];
- // not only java project, given at startup nature may not have been set yet
- if (project.isOpen()) {
- indexAll(project);
- }
- }
- }
- } finally {
- if (wasEnabled) enable();
- if (VERBOSE) JobManager.verbose("DONE ensuring consistency"); //$NON-NLS-1$
- }
-}
-private String computeIndexName(IPath path) {
-
- String pathString = path.toOSString();
- byte[] pathBytes = pathString.getBytes();
- checksumCalculator.reset();
- checksumCalculator.update(pathBytes);
- String fileName = Long.toString(checksumCalculator.getValue()) + ".index"; //$NON-NLS-1$
- if (VERBOSE) JobManager.verbose("-> index name for " + pathString + " is " + fileName); //$NON-NLS-1$ //$NON-NLS-2$
- IPath indexPath = getJavaPluginWorkingLocation();
- String indexDirectory = indexPath.toOSString();
- if (indexDirectory.endsWith(File.separator)) {
- return indexDirectory + fileName;
- } else {
- return indexDirectory + File.separator + fileName;
- }
-}
-
-/**
* Returns the index for a given project, according to the following algorithm:
* - if index is already in memory: answers this one back
* - if (reuseExistingFile) then read it and return this index and record it in memory
@@ -192,45 +136,81 @@
// Path is already canonical per construction
IIndex index = (IIndex) indexes.get(path);
if (index == null) {
- try {
- String indexPath = null;
-
- // index isn't cached, consider reusing an existing index file
- if (reuseExistingFile){
- indexPath = computeIndexName(path);
- File indexFile = new File(indexPath);
- if (indexFile.exists()){ // check before creating index so as to avoid creating a new empty index if file is missing
- index = new Index(indexPath, "Index for " + path.toOSString(), true /*reuse index file*/); //$NON-NLS-1$
- if (index != null){
- indexes.put(path, index);
- monitors.put(index, new ReadWriteMonitor());
- return index;
- }
- }
- }
- // index wasn't found on disk, consider creating an empty new one
- if (createIfMissing){
- if (indexPath == null) indexPath = computeIndexName(path);
- index = new Index(indexPath, "Index for " + path.toOSString(), false /*do not reuse index file*/); //$NON-NLS-1$
- if (index != null){
+ String indexName = computeIndexName(path);
+ Object state = getIndexStates().get(indexName);
+ Integer currentIndexState = state == null ? UNKNOWN_STATE : (Integer) state;
+ if (currentIndexState == UNKNOWN_STATE) {
+ // should only be reachable for query jobs
+ // IF you put an index in the cache, then AddJarFileToIndex fails because it thinks there is nothing to do
+ rebuildIndex(indexName, path);
+ return null;
+ }
+
+ // index isn't cached, consider reusing an existing index file
+ if (reuseExistingFile) {
+ File indexFile = new File(indexName);
+ if (indexFile.exists()) { // check before creating index so as to avoid creating a new empty index if file is missing
+ try {
+ index = new Index(indexName, "Index for " + path.toOSString(), true /*reuse index file*/); //$NON-NLS-1$
indexes.put(path, index);
monitors.put(index, new ReadWriteMonitor());
return index;
+ } catch (IOException e) {
+ // failed to read the existing file or its no longer compatible
+ if (currentIndexState != REBUILDING_STATE) { // rebuild index if existing file is corrupt, unless the index is already being rebuilt
+ if (VERBOSE)
+ JobManager.verbose("-> cannot reuse existing index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
+ rebuildIndex(indexName, path);
+ return null;
+ } else {
+ index = null; // will fall thru to createIfMissing & create a empty index for the rebuild all job to populate
+ }
}
}
- } catch (IOException e) {
- // The file could not be created. Possible reason: the project has been deleted.
- return null;
+ if (currentIndexState == SAVED_STATE) { // rebuild index if existing file is missing
+ rebuildIndex(indexName, path);
+ return null;
+ }
+ }
+ // index wasn't found on disk, consider creating an empty new one
+ if (createIfMissing) {
+ try {
+ if (VERBOSE)
+ JobManager.verbose("-> create empty index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
+ index = new Index(indexName, "Index for " + path.toOSString(), false /*do not reuse index file*/); //$NON-NLS-1$
+ indexes.put(path, index);
+ monitors.put(index, new ReadWriteMonitor());
+ return index;
+ } catch (IOException e) {
+ if (VERBOSE)
+ JobManager.verbose("-> unable to create empty index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
+ // The file could not be created. Possible reason: the project has been deleted.
+ return null;
+ }
}
}
//System.out.println(" index name: " + path.toOSString() + " <----> " + index.getIndexFile().getName());
return index;
}
-private IPath getJavaPluginWorkingLocation() {
- if (javaPluginLocation == null) {
- javaPluginLocation = JavaCore.getPlugin().getStateLocation();
+private SimpleLookupTable getIndexStates() {
+ if (indexStates != null) return indexStates;
+
+ this.indexStates = new SimpleLookupTable();
+ char[] savedIndexNames = readIndexState();
+ if (savedIndexNames.length > 0) {
+ char[][] names = CharOperation.splitOn('\n', savedIndexNames);
+ for (int i = 0, l = names.length; i < l; i++) {
+ char[] name = names[i];
+ if (name.length > 0)
+ this.indexStates.put(new String(name), SAVED_STATE);
+ }
}
- return javaPluginLocation;
+ return this.indexStates;
+}
+private IPath getJavaPluginWorkingLocation() {
+ if (this.javaPluginLocation != null) return this.javaPluginLocation;
+
+ return this.javaPluginLocation = JavaCore.getPlugin().getStateLocation();
}
/**
* Index access is controlled through a read-write monitor so as
@@ -238,8 +218,7 @@
* (only concurrent reading is allowed).
*/
public ReadWriteMonitor getMonitorFor(IIndex index){
-
- return (ReadWriteMonitor)monitors.get(index);
+ return (ReadWriteMonitor) monitors.get(index);
}
/**
* Trigger addition of the entire content of a project
@@ -251,30 +230,78 @@
// Also request indexing of binaries on the classpath
// determine the new children
try {
- IJavaModel model = JavaModelManager.getJavaModelManager().getJavaModel();
- IJavaProject javaProject = ((JavaModel) model).getJavaProject(project);
+ JavaModel model = (JavaModel) JavaModelManager.getJavaModelManager().getJavaModel();
+ IJavaProject javaProject = model.getJavaProject(project);
// only consider immediate libraries - each project will do the same
// NOTE: force to resolve CP variables before calling indexer - 19303, so that initializers
// will be run in the current thread.
IClasspathEntry[] entries = javaProject.getResolvedClasspath(true);
for (int i = 0; i < entries.length; i++) {
IClasspathEntry entry= entries[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+ if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY)
this.indexLibrary(entry.getPath(), project);
- }
}
} catch(JavaModelException e){ // cannot retrieve classpath info
- }
- this.request(new IndexAllProject(project, this));
+ }
+
+ // check if the same request is not already in the queue
+ IndexRequest request = new IndexAllProject(project, this);
+ for (int i = this.jobEnd; i > this.jobStart; i--) // NB: don't check job at jobStart, as it may have already started (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32488)
+ if (request.equals(this.awaitingJobs[i])) return;
+ this.request(request);
}
+/**
+ * Trigger addition of a library to an index
+ * Note: the actual operation is performed in background
+ */
+public void indexLibrary(IPath path, IProject requestingProject) {
+ // requestingProject is no longer used to cancel jobs but leave it here just in case
+ if (JavaCore.getPlugin() == null) return;
+ Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
+ IndexRequest request = null;
+ if (target instanceof IFile) {
+ request = new AddJarFileToIndex((IFile)target, this);
+ } else if (target instanceof java.io.File) {
+ request = new AddJarFileToIndex(path, this);
+ } else if (target instanceof IFolder) {
+ request = new IndexBinaryFolder((IFolder)target, this);
+ } else {
+ return;
+ }
+ // check if the same request is not already in the queue
+ for (int i = this.jobEnd; i > this.jobStart; i--) // NB: don't check job at jobStart, as it may have already started (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32488)
+ if (request.equals(this.awaitingJobs[i])) return;
+ this.request(request);
+}
+/**
+ * Index the content of the given source folder.
+ */
+public void indexSourceFolder(JavaProject javaProject, IPath sourceFolder, final char[][] exclusionPattern) {
+ IProject project = javaProject.getProject();
+ if (this.jobEnd > this.jobStart) {
+ // check if a job to index the project is not already in the queue
+ IndexRequest request = new IndexAllProject(project, this);
+ for (int i = this.jobEnd; i > this.jobStart; i--) // NB: don't check job at jobStart, as it may have already started (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32488)
+ if (request.equals(this.awaitingJobs[i])) return;
+ }
+
+ this.request(new AddFolderToIndex(sourceFolder, project, exclusionPattern, this));
+}
+public void jobWasCancelled(IPath path) {
+ Object o = this.indexes.get(path);
+ if (o instanceof IIndex) {
+ this.monitors.remove(o);
+ this.indexes.remove(path);
+ }
+ updateIndexState(computeIndexName(path), UNKNOWN_STATE);
+}
/**
* Advance to the next available job, once the current one has been completed.
* Note: clients awaiting until the job count is zero are still waiting at this point.
*/
protected synchronized void moveToNextJob() {
-
// remember that one job was executed, and we will need to save indexes at some point
needToSave = true;
super.moveToNextJob();
@@ -285,36 +312,68 @@
protected void notifyIdle(long idlingTime){
if (idlingTime > 1000 && needToSave) saveIndexes();
}
+/*
+ * For debug purpose
+ */
+public IIndex peekAtIndex(IPath path) {
+ return (IIndex) indexes.get(path);
+}
/**
* Name of the background process
*/
public String processName(){
- return Util.bind("process.name"); //$NON-NLS-1$
+ return org.eclipse.jdt.internal.core.search.Util.bind("process.name"); //$NON-NLS-1$
}
+private void rebuildIndex(String indexName, IPath path) {
+ Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
+ if (target == null) return;
+ if (VERBOSE)
+ JobManager.verbose("-> request to rebuild index: "+indexName+" path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
+
+ updateIndexState(indexName, REBUILDING_STATE);
+ IndexRequest request = null;
+ if (target instanceof IProject) {
+ IProject p = (IProject) target;
+ if (JavaProject.hasJavaNature(p))
+ request = new IndexAllProject(p, this);
+ } else if (target instanceof IFolder) {
+ request = new IndexBinaryFolder((IFolder) target, this);
+ } else if (target instanceof IFile) {
+ request = new AddJarFileToIndex((IFile) target, this);
+ } else if (target instanceof java.io.File) {
+ request = new AddJarFileToIndex(path, this);
+ }
+ if (request != null)
+ request(request);
+}
/**
* Recreates the index for a given path, keeping the same read-write monitor.
* Returns the new empty index or null if it didn't exist before.
* Warning: Does not check whether index is consistent (not being used)
*/
public synchronized IIndex recreateIndex(IPath path) {
- IIndex index = (IIndex) indexes.get(path);
- if (index != null) {
- try {
- // Path is already canonical
- String indexPath = computeIndexName(path);
- ReadWriteMonitor monitor = (ReadWriteMonitor)monitors.remove(index);
- index = new Index(indexPath, "Index for " + path.toOSString(), true /*reuse index file*/); //$NON-NLS-1$
- index.empty();
- indexes.put(path, index);
- monitors.put(index, monitor);
- } catch (IOException e) {
- // The file could not be created. Possible reason: the project has been deleted.
- return null;
+ // only called to over write an existing cached index...
+ try {
+ IIndex index = (IIndex) this.indexes.get(path);
+ ReadWriteMonitor monitor = (ReadWriteMonitor) this.monitors.remove(index);
+
+ // Path is already canonical
+ String indexPath = computeIndexName(path);
+ if (VERBOSE)
+ JobManager.verbose("-> recreating index: "+indexPath+" for path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
+ index = new Index(indexPath, "Index for " + path.toOSString(), false /*reuse index file*/); //$NON-NLS-1$
+ indexes.put(path, index);
+ monitors.put(index, monitor);
+ return index;
+ } catch (IOException e) {
+ // The file could not be created. Possible reason: the project has been deleted.
+ if (VERBOSE) {
+ JobManager.verbose("-> failed to recreate index for path: "+path.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
+ e.printStackTrace();
}
+ return null;
}
- //System.out.println(" index name: " + path.toOSString() + " <----> " + index.getIndexFile().getName());
- return index;
}
/**
* Trigger removal of a resource to an index
@@ -328,97 +387,112 @@
* This is a no-op if the index did not exist.
*/
public synchronized void removeIndex(IPath path) {
- IIndex index = (IIndex)this.indexes.get(path);
- if (index == null) return;
- index.getIndexFile().delete();
+ if (VERBOSE)
+ JobManager.verbose("removing index " + path); //$NON-NLS-1$
+ String indexName = computeIndexName(path);
+ File indexFile = new File(indexName);
+ if (indexFile.exists())
+ indexFile.delete();
+ Object o = this.indexes.get(path);
+ if (o instanceof IIndex)
+ this.monitors.remove(o);
this.indexes.remove(path);
- this.monitors.remove(index);
+ updateIndexState(indexName, null);
}
/**
* Removes all indexes whose paths start with (or are equal to) the given path.
*/
public synchronized void removeIndexFamily(IPath path) {
+ // only finds cached index files... shutdown removes all non-cached index files
ArrayList toRemove = null;
Iterator iterator = this.indexes.keySet().iterator();
while (iterator.hasNext()) {
- IPath indexPath = (IPath)iterator.next();
+ IPath indexPath = (IPath) iterator.next();
if (path.isPrefixOf(indexPath)) {
- if (toRemove == null) {
+ if (toRemove == null)
toRemove = new ArrayList();
- }
toRemove.add(indexPath);
}
}
- if (toRemove != null) {
- for (int i = 0, length = toRemove.size(); i < length; i++) {
- this.removeIndex((IPath)toRemove.get(i));
- }
- }
+ if (toRemove != null)
+ for (int i = 0, length = toRemove.size(); i < length; i++)
+ this.removeIndex((IPath) toRemove.get(i));
}
/**
* Remove the content of the given source folder from the index.
*/
-public void removeSourceFolderFromIndex(JavaProject javaProject, IPath sourceFolder) {
- this.request(new RemoveFolderFromIndex(sourceFolder.toString(), javaProject.getProject().getFullPath(), this));
-}
+public void removeSourceFolderFromIndex(JavaProject javaProject, IPath sourceFolder, char[][] exclusionPatterns) {
+ IProject project = javaProject.getProject();
+ if (this.jobEnd > this.jobStart) {
+ // check if a job to index the project is not already in the queue
+ IndexRequest request = new IndexAllProject(project, this);
+ for (int i = this.jobEnd; i > this.jobStart; i--) // NB: don't check job at jobStart, as it may have already started (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32488)
+ if (request.equals(this.awaitingJobs[i])) return;
+ }
+ this.request(new RemoveFolderFromIndex(sourceFolder, exclusionPatterns, project, this));
+}
/**
* Flush current state
*/
-public void reset(){
-
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- if (workspace != null){
- // force to resolve classpaths for projects to check, so as to avoid running CP variable initializers in the background thread
- this.projectsToCheck = workspace.getRoot().getProjects();
- for (int i = 0, max = this.projectsToCheck == null ? 0 : this.projectsToCheck.length; i < max; i++){
- IJavaProject project = JavaCore.create(this.projectsToCheck[i]);
- try {
- // force to resolve CP variables before calling indexer - 19303 (indirectly through consistency check)
- project.getResolvedClasspath(true);
- } catch (JavaModelException e) {
- }
- }
- }
+public void reset() {
super.reset();
- if (indexes != null){
- indexes = new HashMap(5);
- monitors = new HashMap(5);
+ if (this.indexes != null) {
+ this.indexes = new HashMap(5);
+ this.monitors = new HashMap(5);
+ this.indexStates = null;
}
- javaPluginLocation = null;
+ this.indexNames = new SimpleLookupTable();
+ this.javaPluginLocation = null;
+}
+public void saveIndex(IIndex index) throws IOException {
+ // must have permission to write from the write monitor
+ if (index.hasChanged()) {
+ if (VERBOSE)
+ JobManager.verbose("-> saving index " + index.getIndexFile()); //$NON-NLS-1$
+ index.save();
+ }
+ String indexName = index.getIndexFile().getPath();
+ if (this.jobEnd > this.jobStart) {
+ Object indexPath = indexNames.keyForValue(indexName);
+ if (indexPath != null) {
+ for (int i = this.jobEnd; i > this.jobStart; i--) { // skip the current job
+ IJob job = this.awaitingJobs[i];
+ if (job instanceof IndexRequest)
+ if (((IndexRequest) job).indexPath.equals(indexPath)) return;
+ }
+ }
+ }
+ updateIndexState(indexName, SAVED_STATE);
}
/**
* Commit all index memory changes to disk
*/
-public void saveIndexes(){
-
- ArrayList indexList = new ArrayList();
- synchronized(this){
- for (Iterator iter = indexes.values().iterator(); iter.hasNext();){
- indexList.add(iter.next());
+public void saveIndexes() {
+ // only save cached indexes... the rest were not modified
+ ArrayList toSave = new ArrayList();
+ synchronized(this) {
+ for (Iterator iter = this.indexes.values().iterator(); iter.hasNext();) {
+ Object o = iter.next();
+ if (o instanceof IIndex)
+ toSave.add(o);
}
}
- for (Iterator iter = indexList.iterator(); iter.hasNext();){
- IIndex index = (IIndex)iter.next();
- if (index == null) continue; // index got deleted since acquired
+ for (int i = 0, length = toSave.size(); i < length; i++) {
+ IIndex index = (IIndex) toSave.get(i);
ReadWriteMonitor monitor = getMonitorFor(index);
if (monitor == null) continue; // index got deleted since acquired
try {
monitor.enterWrite();
- if (IndexManager.VERBOSE){
- if (index.hasChanged()){
- JobManager.verbose("-> merging index " + index.getIndexFile()); //$NON-NLS-1$
- }
- }
try {
- index.save();
+ saveIndex(index);
} catch(IOException e){
- if (IndexManager.VERBOSE) {
- JobManager.verbose("-> got the following exception while merging:"); //$NON-NLS-1$
+ if (VERBOSE) {
+ JobManager.verbose("-> got the following exception while saving:"); //$NON-NLS-1$
e.printStackTrace();
}
- //org.eclipse.jdt.internal.core.Util.log(e);
+ //Util.log(e);
}
} finally {
monitor.exitWrite();
@@ -426,65 +500,103 @@
}
needToSave = false;
}
-
public void shutdown() {
-
- HashMap keepingIndexesPaths = new HashMap();
- IndexSelector indexSelector = new IndexSelector(new JavaWorkspaceScope(), null, this);
+ if (VERBOSE)
+ JobManager.verbose("Shutdown"); //$NON-NLS-1$
+
+ IndexSelector indexSelector = new IndexSelector(new JavaWorkspaceScope(), null, false, this);
IIndex[] selectedIndexes = indexSelector.getIndexes();
+ SimpleLookupTable knownPaths = new SimpleLookupTable();
for (int i = 0, max = selectedIndexes.length; i < max; i++) {
String path = selectedIndexes[i].getIndexFile().getAbsolutePath();
- keepingIndexesPaths.put(path, path);
+ knownPaths.put(path, path);
}
- File indexesDirectory = new File(this.getJavaPluginWorkingLocation().toOSString());
+
+ if (indexStates != null) {
+ Object[] indexNames = indexStates.keyTable;
+ for (int i = 0, l = indexNames.length; i < l; i++) {
+ String key = (String) indexNames[i];
+ if (key != null && !knownPaths.containsKey(key))
+ updateIndexState(key, null);
+ }
+ }
+
+ File indexesDirectory = new File(getJavaPluginWorkingLocation().toOSString());
if (indexesDirectory.isDirectory()) {
File[] indexesFiles = indexesDirectory.listFiles();
- for (int i = 0, indexesFilesLength = indexesFiles.length; i < indexesFilesLength; i++) {
- String fileName = indexesFiles[i].getAbsolutePath();
- if (fileName.toLowerCase().endsWith(".index") && keepingIndexesPaths.get(fileName) == null) { //$NON-NLS-1$
- if (VERBOSE) {
- JobManager.verbose("Deleting index file " + indexesFiles[i]); //$NON-NLS-1$
+ if (indexesFiles != null) {
+ for (int i = 0, indexesFilesLength = indexesFiles.length; i < indexesFilesLength; i++) {
+ String fileName = indexesFiles[i].getAbsolutePath();
+ if (!knownPaths.containsKey(fileName) && fileName.toLowerCase().endsWith(".index")) { //$NON-NLS-1$
+ if (VERBOSE)
+ JobManager.verbose("Deleting index file " + indexesFiles[i]); //$NON-NLS-1$
+ indexesFiles[i].delete();
}
- indexesFiles[i].delete();
}
}
-
}
- super.shutdown();
+
+ super.shutdown();
}
-/**
- * Trigger addition of a library to an index
- * Note: the actual operation is performed in background
- */
-public void indexLibrary(IPath path, IProject referingProject) {
- if (JavaCore.getPlugin() == null) return;
-
- Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
-
- IndexRequest request = null;
- if (target instanceof IFile) {
- request = new AddJarFileToIndex((IFile)target, this, referingProject.getName());
- } else if (target instanceof java.io.File) {
- // remember the timestamp of this library
- long timestamp = DeltaProcessor.getTimeStamp((java.io.File)target);
- JavaModelManager.getJavaModelManager().deltaProcessor.externalTimeStamps.put(path, new Long(timestamp));
- request = new AddJarFileToIndex(path, this, referingProject.getName());
- } else if (target instanceof IFolder) {
- request = new IndexBinaryFolder((IFolder)target, this, referingProject);
- } else {
- return;
+public String toString() {
+ StringBuffer buffer = new StringBuffer(10);
+ buffer.append(super.toString());
+ buffer.append("In-memory indexes:\n"); //$NON-NLS-1$
+ int count = 0;
+ for (Iterator iter = this.indexes.values().iterator(); iter.hasNext();) {
+ buffer.append(++count).append(" - ").append(iter.next().toString()).append('\n'); //$NON-NLS-1$
}
-
- // check if the same request is not already in the queue
- for (int i = this.jobEnd; i >= this.jobStart; i--) {
- IJob awaiting = this.awaitingJobs[i];
- if (awaiting != null && request.equals(awaiting)) {
- return;
+ return buffer.toString();
+}
+
+private char[] readIndexState() {
+ try {
+ return org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(savedIndexNamesFile, null);
+ } catch (IOException ignored) {
+ if (VERBOSE)
+ JobManager.verbose("Failed to read saved index file names"); //$NON-NLS-1$
+ return new char[0];
+ }
+}
+private void updateIndexState(String indexName, Integer indexState) {
+ getIndexStates(); // ensure the states are initialized
+ if (indexState != null) {
+ if (indexState.equals(indexStates.get(indexName))) return; // not changed
+ indexStates.put(indexName, indexState);
+ } else {
+ if (!indexStates.containsKey(indexName)) return; // did not exist anyway
+ indexStates.removeKey(indexName);
+ }
+
+ BufferedWriter writer = null;
+ try {
+ writer = new BufferedWriter(new FileWriter(savedIndexNamesFile));
+ Object[] indexNames = indexStates.keyTable;
+ Object[] states = indexStates.valueTable;
+ for (int i = 0, l = states.length; i < l; i++) {
+ if (states[i] == SAVED_STATE) {
+ writer.write((String) indexNames[i]);
+ writer.write('\n');
+ }
+ }
+ } catch (IOException ignored) {
+ if (VERBOSE)
+ JobManager.verbose("Failed to write saved index file names"); //$NON-NLS-1$
+ } finally {
+ if (writer != null) {
+ try {
+ writer.close();
+ } catch (IOException e) {}
}
}
-
- this.request(request);
+ if (VERBOSE) {
+ String state = "?"; //$NON-NLS-1$
+ if (indexState == SAVED_STATE) state = "SAVED"; //$NON-NLS-1$
+ else if (indexState == UPDATING_STATE) state = "UPDATING"; //$NON-NLS-1$
+ else if (indexState == UNKNOWN_STATE) state = "UNKNOWN"; //$NON-NLS-1$
+ else if (indexState == REBUILDING_STATE) state = "REBUILDING"; //$NON-NLS-1$
+ JobManager.verbose("-> index state updated to: " + state + " for: "+indexName); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
}
-
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexRequest.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexRequest.java
index 642a986..b37a50d 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexRequest.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/IndexRequest.java
@@ -1,28 +1,58 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.internal.core.index.IIndex;
import org.eclipse.jdt.internal.core.search.processing.IJob;
public abstract class IndexRequest implements IJob {
-
-
-
protected boolean isCancelled = false;
+ protected IPath indexPath;
+ protected IndexManager manager;
- /*
- * @see IJob#cancel()
- */
+ public IndexRequest(IPath indexPath, IndexManager manager) {
+ this.indexPath = indexPath;
+ this.manager = manager;
+ }
+ public boolean belongsTo(String projectName) {
+ return projectName.equals(this.indexPath.segment(0));
+ }
public void cancel() {
+ this.manager.jobWasCancelled(this.indexPath);
this.isCancelled = true;
}
-
+ public boolean isReadyToRun() {
+ // tag the index as inconsistent
+ this.manager.aboutToUpdateIndex(indexPath, updatedIndexState());
+ return true;
+ }
+ /*
+ * This code is assumed to be invoked while monitor has read lock
+ */
+ protected void saveIfNecessary(IIndex index, ReadWriteMonitor monitor) throws IOException {
+ /* if index has changed, commit these before querying */
+ if (index.hasChanged()) {
+ try {
+ monitor.exitRead(); // free read lock
+ monitor.enterWrite(); // ask permission to write
+ this.manager.saveIndex(index);
+ } finally {
+ monitor.exitWriteEnterRead(); // finished writing and reacquire read permission
+ }
+ }
+ }
+ protected Integer updatedIndexState() {
+ return IndexManager.UPDATING_STATE;
+ }
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/ReadWriteMonitor.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/ReadWriteMonitor.java
index c156eac..1d7575c 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/ReadWriteMonitor.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/ReadWriteMonitor.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
/**
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFolderFromIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFolderFromIndex.java
index 81675cf..eb8ff5d 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFolderFromIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFolderFromIndex.java
@@ -1,78 +1,69 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
import java.io.IOException;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.internal.core.Util;
import org.eclipse.jdt.internal.core.index.IIndex;
import org.eclipse.jdt.internal.core.index.IQueryResult;
-import org.eclipse.jdt.internal.core.search.processing.IJob;
import org.eclipse.jdt.internal.core.search.processing.JobManager;
-class RemoveFolderFromIndex implements IJob {
- String folderPath;
- IPath indexedContainer;
- IndexManager manager;
- public RemoveFolderFromIndex(
- String folderPath,
- IPath indexedContainer,
- IndexManager manager) {
+class RemoveFolderFromIndex extends IndexRequest {
+ IPath folderPath;
+ char[][] exclusionPatterns;
+ IProject project;
+
+ public RemoveFolderFromIndex(IPath folderPath, char[][] exclusionPatterns, IProject project, IndexManager manager) {
+ super(project.getFullPath(), manager);
this.folderPath = folderPath;
- this.indexedContainer = indexedContainer;
- this.manager = manager;
- }
- public boolean belongsTo(String jobFamily) {
- return jobFamily.equals(indexedContainer.segment(0));
+ this.exclusionPatterns = exclusionPatterns;
+ this.project = project;
}
public boolean execute(IProgressMonitor progressMonitor) {
-
- if (progressMonitor != null && progressMonitor.isCanceled()) return COMPLETE;
-
- try {
- IIndex index = manager.getIndex(this.indexedContainer, true /*reuse index file*/, true /*create if none*/);
- if (index == null)
- return COMPLETE;
- /* ensure no concurrent write access to index */
- ReadWriteMonitor monitor = manager.getMonitorFor(index);
- if (monitor == null)
- return COMPLETE; // index got deleted since acquired
- try {
- monitor.enterRead(); // ask permission to read
- IQueryResult[] results = index.queryInDocumentNames(this.folderPath); // all file names beonlonging to the folder or its subfolders
- for (int i = 0, max = results == null ? 0 : results.length; i < max; i++) {
- String fileName = results[i].getPath();
- manager.remove(fileName, this.indexedContainer); // write lock will be acquired by the remove operation
+ if (progressMonitor != null && progressMonitor.isCanceled()) return true;
+
+ /* ensure no concurrent write access to index */
+ IIndex index = manager.getIndex(this.indexPath, true, /*reuse index file*/ false /*create if none*/);
+ if (index == null) return true;
+ ReadWriteMonitor monitor = manager.getMonitorFor(index);
+ if (monitor == null) return true; // index got deleted since acquired
+
+ try {
+ monitor.enterRead(); // ask permission to read
+ IQueryResult[] results = index.queryInDocumentNames(this.folderPath.toString());
+ // all file names belonging to the folder or its subfolders and that are not excluded (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32607)
+ for (int i = 0, max = results == null ? 0 : results.length; i < max; i++) {
+ String documentPath = results[i].getPath();
+ if (this.exclusionPatterns == null || !Util.isExcluded(new Path(documentPath), this.exclusionPatterns)) {
+ manager.remove(documentPath, this.indexPath); // write lock will be acquired by the remove operation
}
- } finally {
- monitor.exitRead(); // free read lock
}
} catch (IOException e) {
if (JobManager.VERBOSE) {
JobManager.verbose("-> failed to remove " + this.folderPath + " from index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
- return FAILED;
+ return false;
+ } finally {
+ monitor.exitRead(); // free read lock
}
- return COMPLETE;
+ return true;
}
public String toString() {
- return "removing from index " + this.folderPath; //$NON-NLS-1$
+ return "removing " + this.folderPath + " from index " + this.indexPath; //$NON-NLS-1$ //$NON-NLS-2$
}
- /*
- * @see IJob#cancel()
- */
- public void cancel() {
- }
-
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFromIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFromIndex.java
index 9227f42..b4c4e50 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFromIndex.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/RemoveFromIndex.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
import java.io.IOException;
@@ -15,59 +15,40 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.internal.core.index.IIndex;
-import org.eclipse.jdt.internal.core.search.processing.IJob;
import org.eclipse.jdt.internal.core.search.processing.JobManager;
-class RemoveFromIndex implements IJob {
+class RemoveFromIndex extends IndexRequest {
String resourceName;
- IPath indexedContainer;
- IndexManager manager;
- public RemoveFromIndex(
- String resourceName,
- IPath indexedContainer,
- IndexManager manager) {
+
+ public RemoveFromIndex(String resourceName, IPath indexPath, IndexManager manager) {
+ super(indexPath, manager);
this.resourceName = resourceName;
- this.indexedContainer = indexedContainer;
- this.manager = manager;
- }
- public boolean belongsTo(String jobFamily) {
- return jobFamily.equals(indexedContainer.segment(0));
}
public boolean execute(IProgressMonitor progressMonitor) {
-
- if (progressMonitor != null && progressMonitor.isCanceled()) return COMPLETE;
-
- try {
- IIndex index = manager.getIndex(this.indexedContainer, true /*reuse index file*/, true /*create if none*/);
- if (index == null)
- return COMPLETE;
- /* ensure no concurrent write access to index */
- ReadWriteMonitor monitor = manager.getMonitorFor(index);
- if (monitor == null)
- return COMPLETE; // index got deleted since acquired
- try {
- monitor.enterWrite(); // ask permission to write
- index.remove(resourceName);
- } finally {
- monitor.exitWrite(); // free write lock
- }
+ if (progressMonitor != null && progressMonitor.isCanceled()) return true;
+
+ /* ensure no concurrent write access to index */
+ IIndex index = manager.getIndex(this.indexPath, true, /*reuse index file*/ false /*create if none*/);
+ if (index == null) return true;
+ ReadWriteMonitor monitor = manager.getMonitorFor(index);
+ if (monitor == null) return true; // index got deleted since acquired
+
+ try {
+ monitor.enterWrite(); // ask permission to write
+ index.remove(resourceName);
} catch (IOException e) {
if (JobManager.VERBOSE) {
JobManager.verbose("-> failed to remove " + this.resourceName + " from index because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
e.printStackTrace();
}
- return FAILED;
+ return false;
+ } finally {
+ monitor.exitWrite(); // free write lock
}
- return COMPLETE;
+ return true;
}
public String toString() {
- return "removing from index " + resourceName; //$NON-NLS-1$
+ return "removing " + this.resourceName + " from index " + this.indexPath; //$NON-NLS-1$ //$NON-NLS-2$
}
- /*
- * @see IJob#cancel()
- */
- public void cancel() {
- }
-
-}
\ No newline at end of file
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SaveIndex.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SaveIndex.java
new file mode 100644
index 0000000..af6cdad
--- /dev/null
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SaveIndex.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.search.indexing;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.internal.core.index.IIndex;
+import org.eclipse.jdt.internal.core.search.processing.JobManager;
+
+/*
+ * Save the index of a project.
+ */
+public class SaveIndex extends IndexRequest {
+ public SaveIndex(IPath indexPath, IndexManager manager) {
+ super(indexPath, manager);
+ }
+ public boolean execute(IProgressMonitor progressMonitor) {
+
+ if (progressMonitor != null && progressMonitor.isCanceled()) return true;
+
+ /* ensure no concurrent write access to index */
+ IIndex index = this.manager.getIndex(this.indexPath, true /*reuse index file*/, false /*don't create if none*/);
+ if (index == null) return true;
+ ReadWriteMonitor monitor = this.manager.getMonitorFor(index);
+ if (monitor == null) return true; // index got deleted since acquired
+
+ try {
+ monitor.enterWrite(); // ask permission to write
+ this.manager.saveIndex(index);
+ } catch (IOException e) {
+ if (JobManager.VERBOSE) {
+ JobManager.verbose("-> failed to save index " + this.indexPath + " because of the following exception:"); //$NON-NLS-1$ //$NON-NLS-2$
+ e.printStackTrace();
+ }
+ return false;
+ } finally {
+ monitor.exitWrite(); // free write lock
+ }
+ return true;
+ }
+ public String toString() {
+ return "saving index for " + this.indexPath; //$NON-NLS-1$
+ }
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java
index 7e0af58..f7dbaf4 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexer.java
@@ -1,18 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
import java.io.IOException;
import java.util.Locale;
+import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.compiler.SourceElementParser;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
@@ -37,7 +38,12 @@
public static final String[] FILE_TYPES= new String[] {"java"}; //$NON-NLS-1$
protected DefaultProblemFactory problemFactory= new DefaultProblemFactory(Locale.getDefault());
+ IFile resourceFile;
+SourceIndexer(IFile resourceFile) {
+ this.resourceFile = resourceFile;
+}
+
/**
* Returns the file types the <code>IIndexer</code> handles.
*/
@@ -52,7 +58,11 @@
// Create a new Parser
SourceIndexerRequestor requestor = new SourceIndexerRequestor(this, document);
- SourceElementParser parser = new SourceElementParser(requestor, problemFactory, new CompilerOptions(JavaCore.getOptions()), true); // index local declarations
+ SourceElementParser parser = new SourceElementParser(
+ requestor,
+ problemFactory,
+ new CompilerOptions(JavaCore.create(this.resourceFile.getProject()).getOptions(true)),
+ true); // index local declarations
// Launch the parser
char[] source = null;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java
index f3e316e..8446d56 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java
@@ -1,18 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.indexing;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.compiler.ISourceElementRequestor;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IDocument;
/**
@@ -135,6 +135,9 @@
// eliminate possible qualifications, given they need to be fully resolved again
if (superclass != null){
superclass = CharOperation.lastSegment(superclass, '.');
+
+ // add implicit constructor reference to default constructor
+ this.indexer.addConstructorReference(superclass, 0);
}
if (superinterfaces != null){
for (int i = 0, length = superinterfaces.length; i < length; i++){
@@ -221,7 +224,7 @@
/**
* exitField method comment.
*/
-public void exitField(int declarationEnd) {
+public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
this.methodDepth--;
}
/**
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/AndPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/AndPattern.java
index 43096e0..2ae7193 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/AndPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/AndPattern.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClasspathSourceDirectory.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClasspathSourceDirectory.java
new file mode 100644
index 0000000..82781d1
--- /dev/null
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ClasspathSourceDirectory.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.search.matching;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
+import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
+import org.eclipse.jdt.internal.core.Util;
+import org.eclipse.jdt.internal.core.builder.ClasspathLocation;
+import org.eclipse.jdt.internal.core.util.SimpleLookupTable;
+
+public class ClasspathSourceDirectory extends ClasspathLocation {
+
+ IContainer sourceFolder;
+ String sourceLocation;
+ String encoding;
+ SimpleLookupTable directoryCache;
+ String[] missingPackageHolder = new String[1];
+
+ClasspathSourceDirectory(IContainer sourceFolder, String encoding) {
+ this.sourceFolder = sourceFolder;
+ IPath location = sourceFolder.getLocation();
+ this.sourceLocation = location != null ? location.addTrailingSeparator().toString() : ""; //$NON-NLS-1$
+ this.encoding = encoding;
+ this.directoryCache = new SimpleLookupTable(5);
+}
+
+public void cleanup() {
+ this.directoryCache = null;
+}
+
+String[] directoryList(String qualifiedPackageName) {
+ String[] dirList = (String[]) directoryCache.get(qualifiedPackageName);
+ if (dirList == missingPackageHolder) return null; // package exists in another classpath directory or jar
+ if (dirList != null) return dirList;
+
+ try {
+ IResource container = sourceFolder.findMember(qualifiedPackageName); // this is a case-sensitive check
+ if (container instanceof IContainer) {
+ IResource[] members = ((IContainer) container).members();
+ dirList = new String[members.length];
+ int index = 0;
+ for (int i = 0, l = members.length; i < l; i++) {
+ IResource m = members[i];
+ String name;
+ if (m.getType() == IResource.FILE && Util.isJavaFileName(name = m.getName()))
+ dirList[index++] = name;
+ }
+ if (index < dirList.length)
+ System.arraycopy(dirList, 0, dirList = new String[index], 0, index);
+ directoryCache.put(qualifiedPackageName, dirList);
+ return dirList;
+ }
+ } catch(CoreException ignored) {
+ }
+ directoryCache.put(qualifiedPackageName, missingPackageHolder);
+ return null;
+}
+
+boolean doesFileExist(String fileName, String qualifiedPackageName) {
+ String[] dirList = directoryList(qualifiedPackageName);
+ if (dirList == null) return false; // most common case
+
+ for (int i = dirList.length; --i >= 0;)
+ if (fileName.equals(dirList[i]))
+ return true;
+ return false;
+}
+
+public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof ClasspathSourceDirectory)) return false;
+
+ return sourceFolder.equals(((ClasspathSourceDirectory) o).sourceFolder);
+}
+
+public NameEnvironmentAnswer findClass(String sourceFileName, String qualifiedPackageName, String qualifiedSourceFileName) {
+ if (!doesFileExist(sourceFileName, qualifiedPackageName)) return null; // most common case
+
+ String fullSourcePath = this.sourceLocation + qualifiedSourceFileName;
+ return new NameEnvironmentAnswer(new CompilationUnit(null, fullSourcePath, this.encoding));
+}
+
+public IPath getProjectRelativePath() {
+ return sourceFolder.getProjectRelativePath();
+}
+
+public boolean isPackage(String qualifiedPackageName) {
+ return directoryList(qualifiedPackageName) != null;
+}
+
+public void reset() {
+ this.directoryCache = new SimpleLookupTable(5);
+}
+
+public String toString() {
+ return "Source classpath directory " + sourceFolder.getFullPath().toString(); //$NON-NLS-1$
+}
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java
index 41c17b1..ab3b91e 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorDeclarationPattern.java
@@ -1,18 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
@@ -21,7 +22,6 @@
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IEntryResult;
import org.eclipse.jdt.internal.core.index.impl.IndexInput;
import org.eclipse.jdt.internal.core.index.impl.IndexedFile;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorReferencePattern.java
index f3f379d..6c3143e 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/ConstructorReferencePattern.java
@@ -1,26 +1,27 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IEntryResult;
import org.eclipse.jdt.internal.core.index.impl.IndexInput;
import org.eclipse.jdt.internal.core.index.impl.IndexedFile;
@@ -88,6 +89,16 @@
isCaseSensitive);
}
/**
+ * @see SearchPattern#matchContainer()
+ */
+protected int matchContainer() {
+ return
+ COMPILATION_UNIT // implicit constructor call: case of Y extends X and Y doesn't define any constructor
+ | CLASS // implicit constructor call: case of constructor declaration with no explicit super call
+ | METHOD // reference in another constructor
+ | FIELD; // anonymous in a field initializer
+}
+/**
* @see SearchPattern#matchIndexEntry
*/
protected boolean matchIndexEntry() {
@@ -188,17 +199,33 @@
return this.matchLevel((AllocationExpression)node, resolve);
} else if (node instanceof ExplicitConstructorCall) {
return this.matchLevel((ExplicitConstructorCall)node, resolve);
+ } else if (node instanceof ConstructorDeclaration) {
+ return this.matchLevel((ConstructorDeclaration)node, resolve);
+ } else if (node instanceof TypeDeclaration) {
+ return this.matchLevel((TypeDeclaration)node, resolve);
}
return IMPOSSIBLE_MATCH;
}
+/**
+ * Returns whether the given constructor declaration has an implicit constructor reference that matches
+ * this constructor pattern.
+ * Look at resolved information only if specified.
+ */
+private int matchLevel(ConstructorDeclaration constructor, boolean resolve) {
+ ExplicitConstructorCall constructorCall = constructor.constructorCall;
+ if (constructorCall != null && constructorCall.accessMode == ExplicitConstructorCall.ImplicitSuper) {
+ return this.matchLevel(constructorCall, resolve);
+ } else {
+ // Eliminate explicit super call as it will be treated with matchLevel(ExplicitConstructorCall, boolean)
+ return IMPOSSIBLE_MATCH;
+ }
+}
/**
* Returns whether this constructor pattern matches the given explicit constructor call.
* Look at resolved information only if specified.
*/
private int matchLevel(ExplicitConstructorCall call, boolean resolve) {
- // TBD: constructor name is super simple type name
-
if (resolve) {
return this.matchLevel(call.binding);
} else {
@@ -212,6 +239,30 @@
return this.needsResolve ? POSSIBLE_MATCH : ACCURATE_MATCH;
}
}
+/**
+ * Returns whether the given type declaration has an implicit constructor reference that matches
+ * this constructor pattern.
+ * Look at resolved information only if specified.
+ */
+private int matchLevel(TypeDeclaration type, boolean resolve) {
+ if (resolve) {
+ // find default constructor
+ AbstractMethodDeclaration[] methods = type.methods;
+ if (methods != null) {
+ for (int i = 0, length = methods.length; i < length; i++) {
+ AbstractMethodDeclaration method = methods[i];
+ if (method.isDefaultConstructor()
+ && method.sourceStart < type.bodyStart) { // if synthetic
+ return this.matchLevel((ConstructorDeclaration)method, true);
+ }
+ }
+ }
+ return IMPOSSIBLE_MATCH;
+ } else {
+ // Need to wait for all the constructor bodies to have been parsed
+ return this.needsResolve ? POSSIBLE_MATCH : ACCURATE_MATCH;
+ }
+}
/**
* @see SearchPattern#matchLevel(Binding binding).
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfAccessedFieldsPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfAccessedFieldsPattern.java
index 8629403..001a1ac 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfAccessedFieldsPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfAccessedFieldsPattern.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.util.HashSet;
@@ -17,6 +17,7 @@
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
@@ -30,7 +31,6 @@
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class DeclarationOfAccessedFieldsPattern extends FieldReferencePattern {
HashSet knownFields;
@@ -93,7 +93,7 @@
IField field = type.getField(new String(name));
if (this.knownFields.contains(field)) return;
this.knownFields.add(field);
- IResource resource = type.getUnderlyingResource();
+ IResource resource = type.getResource();
boolean isBinary = type.isBinary();
IBinaryType info = null;
if (isBinary) {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedMethodsPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedMethodsPattern.java
index d3045e3..98fd5c4 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedMethodsPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedMethodsPattern.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.util.HashSet;
@@ -18,6 +18,7 @@
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
@@ -28,7 +29,6 @@
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class DeclarationOfReferencedMethodsPattern extends MethodReferencePattern {
HashSet knownMethods;
@@ -80,7 +80,7 @@
IMethod method = type.getMethod(new String(selector), parameterTypes);
if (this.knownMethods.contains(method)) return;
this.knownMethods.add(method);
- IResource resource = type.getUnderlyingResource();
+ IResource resource = type.getResource();
boolean isBinary = type.isBinary();
IBinaryType info = null;
if (isBinary) {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedTypesPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedTypesPattern.java
index 502b4a0..c1fe4c7 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedTypesPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/DeclarationOfReferencedTypesPattern.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.util.HashSet;
@@ -16,6 +16,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
@@ -33,7 +34,6 @@
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
public class DeclarationOfReferencedTypesPattern extends TypeReferencePattern {
HashSet knownTypes;
@@ -51,6 +51,12 @@
// need accurate match to be able to open on type ref
if (accuracy == IJavaSearchResultCollector.POTENTIAL_MATCH) return;
+ // element that references the type must be included in the enclosing element
+ while (element != null && !this.enclosingElement.equals(element)) {
+ element = element.getParent();
+ }
+ if (element == null) return;
+
while (binding instanceof ReferenceBinding) {
ReferenceBinding typeBinding = (ReferenceBinding)binding;
this.reportDeclaration(typeBinding, 1, locator);
@@ -74,7 +80,7 @@
int maxType = -1;
TypeBinding typeBinding = null;
if (reference instanceof TypeReference) {
- typeBinding = ((TypeReference)reference).binding;
+ typeBinding = ((TypeReference)reference).resolvedType;
maxType = Integer.MAX_VALUE;
} else if (reference instanceof QualifiedNameReference) {
QualifiedNameReference qNameRef = (QualifiedNameReference)reference;
@@ -114,7 +120,7 @@
private void reportDeclaration(TypeBinding typeBinding, int maxType, MatchLocator locator) throws CoreException {
IType type = locator.lookupType(typeBinding);
if (type == null) return; // case of a secondary type
- IResource resource = type.getUnderlyingResource();
+ IResource resource = type.getResource();
boolean isBinary = type.isBinary();
IBinaryType info = null;
if (isBinary) {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldDeclarationPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldDeclarationPattern.java
index 46b4422..a2f4d33 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldDeclarationPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldDeclarationPattern.java
@@ -1,18 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
@@ -22,7 +23,6 @@
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IEntryResult;
import org.eclipse.jdt.internal.core.index.impl.IndexInput;
import org.eclipse.jdt.internal.core.index.impl.IndexedFile;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldReferencePattern.java
index 60ece42..240bd3b 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FieldReferencePattern.java
@@ -1,19 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.compiler.ast.Assignment;
@@ -29,7 +30,6 @@
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IEntryResult;
import org.eclipse.jdt.internal.core.index.impl.IndexInput;
import org.eclipse.jdt.internal.core.index.impl.IndexedFile;
@@ -79,7 +79,7 @@
this.readAccess = readAccess;
this.writeAccess = writeAccess;
- this.needsResolve = this.needsResolve();
+ this.needsResolve = true; // always resolve (in case of a simple name reference being a potential match)
}
/**
* Either decode ref/name, fieldRef/name
@@ -268,20 +268,6 @@
}
}
/**
- * Returns whether a field reference or name reference will need to be resolved to
- * find out if this method pattern matches it.
- */
-private boolean needsResolve() {
-
- // declaring type
- if (declaringSimpleName != null || declaringQualification != null) return true;
-
- // return type
- if (typeSimpleName != null || typeQualification != null) return true;
-
- return false;
-}
-/**
* @see AndPattern#resetQuery
*/
protected void resetQuery() {
@@ -432,20 +418,27 @@
} else { // QualifiedNameReference
QualifiedNameReference qNameRef = (QualifiedNameReference)nameRef;
FieldBinding fieldBinding = null;
- if (binding instanceof FieldBinding && this.matchesName(this.name, (fieldBinding = (FieldBinding)binding).name)) {
- return this.matchLevel(fieldBinding);
- } else {
- int otherLevel = IMPOSSIBLE_MATCH;
- int otherMax = qNameRef.otherBindings == null ? 0 : qNameRef.otherBindings.length;
- for (int i = 0; i < otherMax && (otherLevel == IMPOSSIBLE_MATCH); i++){
- char[] token = qNameRef.tokens[i + qNameRef.indexOfFirstFieldBinding];
- if (this.matchesName(this.name, token)) {
- FieldBinding otherBinding = qNameRef.otherBindings[i];
- otherLevel = this.matchLevel(otherBinding);
- }
+ if (binding instanceof FieldBinding) {
+ fieldBinding = (FieldBinding)binding;
+ char[] name = fieldBinding.name;
+ int lastDot = CharOperation.lastIndexOf('.', name);
+ if (lastDot > -1) {
+ name = CharOperation.subarray(name, lastDot+1, name.length);
}
- return otherLevel;
+ if (this.matchesName(this.name, name)) {
+ return this.matchLevel(fieldBinding);
+ }
+ }
+ int otherLevel = IMPOSSIBLE_MATCH;
+ int otherMax = qNameRef.otherBindings == null ? 0 : qNameRef.otherBindings.length;
+ for (int i = 0; i < otherMax && (otherLevel == IMPOSSIBLE_MATCH); i++){
+ char[] token = qNameRef.tokens[i + qNameRef.indexOfFirstFieldBinding];
+ if (this.matchesName(this.name, token)) {
+ FieldBinding otherBinding = qNameRef.otherBindings[i];
+ otherLevel = this.matchLevel(otherBinding);
+ }
}
+ return otherLevel;
}
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FileNameEnvironment.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FileNameEnvironment.java
deleted file mode 100644
index a73002b..0000000
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/FileNameEnvironment.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jdt.internal.core.search.matching;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.zip.ZipFile;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.internal.compiler.batch.ClasspathJar;
-import org.eclipse.jdt.internal.compiler.batch.FileSystem;
-import org.eclipse.jdt.internal.core.JavaModelManager;
-
-public class FileNameEnvironment extends FileSystem {
-
-public FileNameEnvironment(String[] classpathNames, String encoding, int[] classpathDirectoryModes) {
- super(classpathNames, new String[0], encoding, classpathDirectoryModes);
-}
-
-public ClasspathJar getClasspathJar(File file) throws IOException {
- try {
- ZipFile zipFile = JavaModelManager.getJavaModelManager().getZipFile(new Path(file.getPath()));
- return new ClasspathJar(zipFile, false);
- } catch (CoreException e) {
- return super.getClasspathJar(file);
- }
-}
-}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java
new file mode 100644
index 0000000..2072bb9
--- /dev/null
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.search.matching;
+
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
+import org.eclipse.jdt.internal.core.JavaModel;
+import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.jdt.internal.core.builder.ClasspathJar;
+import org.eclipse.jdt.internal.core.builder.ClasspathLocation;
+
+// TODO: (jerome) Remove when switching to JavaSearchNameEnvironment2
+public class JavaSearchNameEnvironment implements INameEnvironment {
+
+ ClasspathLocation[] locations;
+
+public JavaSearchNameEnvironment(IJavaProject javaProject) {
+ try {
+ computeClasspathLocations(javaProject.getProject().getWorkspace().getRoot(), (JavaProject) javaProject);
+ } catch(CoreException e) {
+ this.locations = new ClasspathLocation[0];
+ }
+}
+
+public void cleanup() {
+ for (int i = 0, length = this.locations.length; i < length; i++) {
+ this.locations[i].cleanup();
+ }
+}
+
+private void computeClasspathLocations(
+ IWorkspaceRoot workspaceRoot,
+ JavaProject javaProject) throws CoreException {
+
+ String encoding = null;
+ IPackageFragmentRoot[] roots = javaProject.getAllPackageFragmentRoots();
+ int length = roots.length;
+ ClasspathLocation[] locations = new ClasspathLocation[length];
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ for (int i = 0; i < length; i++) {
+ IPackageFragmentRoot root = roots[i];
+ IPath path = root.getPath();
+ if (root.isArchive()) {
+ ZipFile zipFile = manager.getZipFile(path);
+ locations[i] = new ClasspathJar(zipFile);
+ } else {
+ Object target = JavaModel.getTarget(workspaceRoot, path, false);
+ if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
+ if (encoding == null) {
+ encoding = javaProject.getOption(JavaCore.CORE_ENCODING, true);
+ }
+ locations[i] = new ClasspathSourceDirectory((IContainer)target, encoding);
+ } else {
+ locations[i] = ClasspathLocation.forBinaryFolder((IContainer) target, false);
+ }
+ }
+ }
+ this.locations = locations;
+}
+
+private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeName) {
+ String
+ binaryFileName = null, qBinaryFileName = null,
+ sourceFileName = null, qSourceFileName = null,
+ qPackageName = null;
+ for (int i = 0, length = this.locations.length; i < length; i++) {
+ ClasspathLocation location = this.locations[i];
+ NameEnvironmentAnswer answer;
+ if (location instanceof ClasspathSourceDirectory) {
+ if (sourceFileName == null) {
+ qSourceFileName = qualifiedTypeName + ".java"; //$NON-NLS-1$
+ sourceFileName = qSourceFileName;
+ qPackageName = ""; //$NON-NLS-1$
+ if (qualifiedTypeName.length() > typeName.length) {
+ int typeNameStart = qSourceFileName.length() - typeName.length - 5; // size of ".java"
+ qPackageName = qSourceFileName.substring(0, typeNameStart - 1);
+ sourceFileName = qSourceFileName.substring(typeNameStart);
+ }
+ }
+ answer = location.findClass(
+ sourceFileName,
+ qPackageName,
+ qSourceFileName);
+ } else {
+ if (binaryFileName == null) {
+ qBinaryFileName = qualifiedTypeName + ".class"; //$NON-NLS-1$
+ binaryFileName = qBinaryFileName;
+ qPackageName = ""; //$NON-NLS-1$
+ if (qualifiedTypeName.length() > typeName.length) {
+ int typeNameStart = qBinaryFileName.length() - typeName.length - 6; // size of ".class"
+ qPackageName = qBinaryFileName.substring(0, typeNameStart - 1);
+ binaryFileName = qBinaryFileName.substring(typeNameStart);
+ }
+ }
+ answer =
+ location.findClass(
+ binaryFileName,
+ qPackageName,
+ qBinaryFileName);
+ }
+ if (answer != null) return answer;
+ }
+ return null;
+}
+
+public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
+ if (typeName != null)
+ return findClass(
+ new String(CharOperation.concatWith(packageName, typeName, '/')),
+ typeName);
+ return null;
+}
+
+public NameEnvironmentAnswer findType(char[][] compoundName) {
+ if (compoundName != null)
+ return findClass(
+ new String(CharOperation.concatWith(compoundName, '/')),
+ compoundName[compoundName.length - 1]);
+ return null;
+}
+
+public boolean isPackage(char[][] compoundName, char[] packageName) {
+ return isPackage(new String(CharOperation.concatWith(compoundName, packageName, '/')));
+}
+
+public boolean isPackage(String qualifiedPackageName) {
+ for (int i = 0, length = this.locations.length; i < length; i++)
+ if (this.locations[i].isPackage(qualifiedPackageName))
+ return true;
+ return false;
+}
+
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment2.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment2.java
new file mode 100644
index 0000000..6bb6fc2
--- /dev/null
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment2.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.search.matching;
+
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
+import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
+import org.eclipse.jdt.internal.core.JavaModel;
+import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.jdt.internal.core.builder.ClasspathJar;
+import org.eclipse.jdt.internal.core.builder.ClasspathLocation;
+
+/*
+ * A name environment based on the classpath of a Java project.
+ */
+public class JavaSearchNameEnvironment2 implements INameEnvironment {
+
+ ClasspathLocation[] locations;
+
+public JavaSearchNameEnvironment2(IJavaProject javaProject) {
+ try {
+ computeClasspathLocations(javaProject.getProject().getWorkspace().getRoot(), (JavaProject) javaProject);
+ } catch(CoreException e) {
+ this.locations = new ClasspathLocation[0];
+ }
+}
+
+public void cleanup() {
+ for (int i = 0, length = this.locations.length; i < length; i++) {
+ this.locations[i].cleanup();
+ }
+}
+
+private void computeClasspathLocations(
+ IWorkspaceRoot workspaceRoot,
+ JavaProject javaProject) throws CoreException {
+
+ String encoding = null;
+ IPackageFragmentRoot[] roots = javaProject.getAllPackageFragmentRoots();
+ int length = roots.length;
+ ClasspathLocation[] locations = new ClasspathLocation[length];
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ for (int i = 0; i < length; i++) {
+ IPackageFragmentRoot root = roots[i];
+ IPath path = root.getPath();
+ if (root.isArchive()) {
+ ZipFile zipFile = manager.getZipFile(path);
+ locations[i] = new ClasspathJar(zipFile);
+ } else {
+ Object target = JavaModel.getTarget(workspaceRoot, path, false);
+ if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
+ if (encoding == null) {
+ encoding = javaProject.getOption(JavaCore.CORE_ENCODING, true);
+ }
+ locations[i] = new ClasspathSourceDirectory((IContainer)target, encoding);
+ } else {
+ locations[i] = ClasspathLocation.forBinaryFolder((IContainer) target, false);
+ }
+ }
+ }
+ this.locations = locations;
+}
+
+private NameEnvironmentAnswer findClass(String qualifiedTypeName, char[] typeName) {
+ String
+ binaryFileName = null, qBinaryFileName = null,
+ sourceFileName = null, qSourceFileName = null,
+ qPackageName = null;
+ for (int i = 0, length = this.locations.length; i < length; i++) {
+ ClasspathLocation location = this.locations[i];
+ NameEnvironmentAnswer answer;
+ if (location instanceof ClasspathSourceDirectory) {
+ if (sourceFileName == null) {
+ qSourceFileName = qualifiedTypeName + ".java"; //$NON-NLS-1$
+ sourceFileName = qSourceFileName;
+ qPackageName = ""; //$NON-NLS-1$
+ if (qualifiedTypeName.length() > typeName.length) {
+ int typeNameStart = qSourceFileName.length() - typeName.length - 5; // size of ".java"
+ qPackageName = qSourceFileName.substring(0, typeNameStart - 1);
+ sourceFileName = qSourceFileName.substring(typeNameStart);
+ }
+ }
+ answer = location.findClass(
+ sourceFileName,
+ qPackageName,
+ qSourceFileName);
+ } else {
+ if (binaryFileName == null) {
+ qBinaryFileName = qualifiedTypeName + ".class"; //$NON-NLS-1$
+ binaryFileName = qBinaryFileName;
+ qPackageName = ""; //$NON-NLS-1$
+ if (qualifiedTypeName.length() > typeName.length) {
+ int typeNameStart = qBinaryFileName.length() - typeName.length - 6; // size of ".class"
+ qPackageName = qBinaryFileName.substring(0, typeNameStart - 1);
+ binaryFileName = qBinaryFileName.substring(typeNameStart);
+ }
+ }
+ answer =
+ location.findClass(
+ binaryFileName,
+ qPackageName,
+ qBinaryFileName);
+ }
+ if (answer != null) return answer;
+ }
+ return null;
+}
+
+public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
+ if (typeName != null)
+ return findClass(
+ new String(CharOperation.concatWith(packageName, typeName, '/')),
+ typeName);
+ return null;
+}
+
+public NameEnvironmentAnswer findType(char[][] compoundName) {
+ if (compoundName != null)
+ return findClass(
+ new String(CharOperation.concatWith(compoundName, '/')),
+ compoundName[compoundName.length - 1]);
+ return null;
+}
+
+public boolean isPackage(char[][] compoundName, char[] packageName) {
+ return isPackage(new String(CharOperation.concatWith(compoundName, packageName, '/')));
+}
+
+public boolean isPackage(String qualifiedPackageName) {
+ for (int i = 0, length = this.locations.length; i < length; i++)
+ if (this.locations[i].isPackage(qualifiedPackageName))
+ return true;
+ return false;
+}
+
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
index 5fb372d..ee2dd4f 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
@@ -1,101 +1,47 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
import java.util.HashMap;
import java.util.zip.ZipFile;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IInitializer;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaModelStatusConstants;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IOpenable;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.ISourceRange;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.IWorkingCopy;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.AstNode;
-import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ImportReference;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeReference;
-import org.eclipse.jdt.internal.compiler.batch.ClasspathDirectory;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
-import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
-import org.eclipse.jdt.internal.compiler.env.IBinaryType;
+import org.eclipse.jdt.internal.compiler.env.*;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
-import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
-import org.eclipse.jdt.internal.compiler.env.ISourceType;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.impl.ITypeRequestor;
-import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
-import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
import org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
-import org.eclipse.jdt.internal.core.BinaryType;
-import org.eclipse.jdt.internal.core.ClassFile;
-import org.eclipse.jdt.internal.core.CompilationUnit;
-import org.eclipse.jdt.internal.core.HandleFactory;
-import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
-import org.eclipse.jdt.internal.core.JavaElement;
-import org.eclipse.jdt.internal.core.JavaModel;
-import org.eclipse.jdt.internal.core.JavaModelManager;
-import org.eclipse.jdt.internal.core.JavaProject;
-import org.eclipse.jdt.internal.core.NameLookup;
-import org.eclipse.jdt.internal.core.Openable;
-import org.eclipse.jdt.internal.core.PackageFragmentRoot;
-import org.eclipse.jdt.internal.core.SourceMapper;
-import org.eclipse.jdt.internal.core.SourceTypeElementInfo;
-import org.eclipse.jdt.internal.core.Util;
-
+import org.eclipse.jdt.internal.core.*;
+import org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver;
+import org.eclipse.jdt.internal.core.search.HierarchyScope;
/**
* Locate matches in compilation units.
*/
@@ -106,7 +52,7 @@
public IJavaSearchScope scope;
public MatchLocatorParser parser;
- private INameEnvironment nameEnvironment;
+ public INameEnvironment nameEnvironment;
public NameLookup nameLookup;
public LookupEnvironment lookupEnvironment;
public HashtableOfObject parsedUnits;
@@ -114,19 +60,25 @@
private MatchingOpenable currentMatchingOpenable;
public HandleFactory handleFactory;
public IWorkingCopy[] workingCopies;
+ public HierarchyResolver hierarchyResolver;
+
+ public IProgressMonitor progressMonitor;
- private static char[] EMPTY_FILE_NAME = new char[0];
+ final static char[] EMPTY_FILE_NAME = CharOperation.NO_CHAR;
+ boolean compilationAborted;
public MatchLocator(
SearchPattern pattern,
int detailLevel,
IJavaSearchResultCollector collector,
- IJavaSearchScope scope) {
+ IJavaSearchScope scope,
+ IProgressMonitor progressMonitor) {
this.pattern = pattern;
this.detailLevel = detailLevel;
this.collector = collector;
this.scope = scope;
+ this.progressMonitor = progressMonitor;
}
/**
@@ -172,19 +124,17 @@
// get source
SourceTypeElementInfo elementInfo = (SourceTypeElementInfo) sourceType;
IType type = elementInfo.getHandle();
- try {
- this.buildBindings(type.getCompilationUnit());
- } catch (JavaModelException e) {
- // nothing we can do here: ignore
- }
+ ICompilationUnit sourceUnit = (ICompilationUnit)type.getCompilationUnit();
+ this.accept(sourceUnit);
} else {
CompilationResult result =
new CompilationResult(sourceType.getFileName(), 0, 0, 0);
CompilationUnitDeclaration unit =
SourceTypeConverter.buildCompilationUnit(
- sourceTypes,
- true,
- true,
+ sourceTypes,//sourceTypes[0] is always toplevel here
+ true, // need field and methods
+ true, // need member types
+ false, // no need for field initialization
lookupEnvironment.problemReporter,
result);
this.lookupEnvironment.buildTypeBindings(unit);
@@ -193,57 +143,7 @@
}
}
-/*
- * Parse the given compiation unit and build its type bindings.
- * Remember the parsed unit.
- */
-public CompilationUnitDeclaration buildBindings(org.eclipse.jdt.core.ICompilationUnit compilationUnit) throws JavaModelException {
- final IFile file =
- compilationUnit.isWorkingCopy() ?
- (IFile)compilationUnit.getOriginalElement().getUnderlyingResource() :
- (IFile)compilationUnit.getUnderlyingResource();
- CompilationUnitDeclaration unit = null;
-
- // get main type name
- final String fileName = file.getFullPath().lastSegment();
- final char[] mainTypeName =
- fileName.substring(0, fileName.length() - 5).toCharArray();
-
- // find out if unit is already known
- char[] qualifiedName = compilationUnit.getType(new String(mainTypeName)).getFullyQualifiedName().toCharArray();
- unit = (CompilationUnitDeclaration)this.parsedUnits.get(qualifiedName);
- if (unit != null) return unit;
- // source unit
- IBuffer buffer;
- final char[] source =
- compilationUnit.isWorkingCopy() ?
- (buffer = compilationUnit.getBuffer()) == null ? null : buffer.getCharacters() :
- Util.getResourceContentsAsCharArray(file);
- ICompilationUnit sourceUnit = new ICompilationUnit() {
- public char[] getContents() {
- return source;
- }
- public char[] getFileName() {
- return fileName.toCharArray();
- }
- public char[] getMainTypeName() {
- return mainTypeName;
- }
- public char[][] getPackageName() {
- return null;
- }
- };
-
- // diet parse
- unit = this.parser.dietParse(sourceUnit, this, file, (CompilationUnit)compilationUnit);
- if (unit != null) {
- this.lookupEnvironment.buildTypeBindings(unit);
- this.lookupEnvironment.completeTypeBindings(unit, true);
- this.parsedUnits.put(qualifiedName, unit);
- }
- return unit;
-}
/**
* Creates an IField from the given field declaration and type.
@@ -371,9 +271,13 @@
IPackageFragmentRoot root = (IPackageFragmentRoot)pkg.getParent();
try {
if (root.isArchive()) {
- IPath zipPath = root.isExternal() ? root.getPath() : root.getUnderlyingResource().getLocation();
+ IPath zipPath = root.isExternal() ? root.getPath() : root.getResource().getLocation();
+ if (zipPath == null) return null; // location is null
ZipFile zipFile = null;
try {
+ if (JavaModelManager.ZIP_ACCESS_VERBOSE) {
+ System.out.println("(" + Thread.currentThread() + ") [MatchLocator.classFileReader()] Creating ZipFile on " + zipPath); //$NON-NLS-1$ //$NON-NLS-2$
+ }
zipFile = new ZipFile(zipPath.toOSString());
char[] pkgPath = pkg.getElementName().toCharArray();
CharOperation.replace(pkgPath, '.', '/');
@@ -389,10 +293,8 @@
}
}
} else {
- return ClassFileReader.read(type.getUnderlyingResource().getLocation().toOSString());
+ return ClassFileReader.read(type.getPath().toOSString());
}
- } catch (JavaModelException e) {
- return null;
} catch (ClassFormatException e) {
return null;
} catch (IOException e) {
@@ -420,12 +322,7 @@
return null;
}
// ensure this is a top level type (see bug 20011 Searching for Inner Classes gives bad search results)
- IType declaringType = type.getDeclaringType();
- while (declaringType != null) {
- type = declaringType;
- declaringType = type.getDeclaringType();
- }
- return type;
+ return MatchingOpenable.getTopLevelType(type);
}
}
/**
@@ -442,6 +339,42 @@
return this.parser == null ? null : this.parser.scanner;
}
+ /**
+ * Create a new parser for the given project, as well as a lookup environment.
+ */
+ public void initialize(JavaProject project) throws JavaModelException {
+ // create lookup environment
+ CompilerOptions options = new CompilerOptions(project.getOptions(true));
+ ProblemReporter problemReporter =
+ new ProblemReporter(
+ DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+ options,
+ new DefaultProblemFactory());
+ this.lookupEnvironment =
+ new LookupEnvironment(this, options, problemReporter, this.nameEnvironment);
+
+ // create parser
+ this.parser = new MatchLocatorParser(problemReporter, options.sourceLevel >= CompilerOptions.JDK1_4);
+
+ // reset parsed units (they could hold onto obsolete bindings: see bug 16052)
+ MatchingOpenable[] openables = this.matchingOpenables.getMatchingOpenables(project.getPackageFragmentRoots());
+ for (int i = 0, length = openables.length; i < length; i++) {
+ MatchingOpenable matchingOpenable = openables[i];
+ matchingOpenable.reset();
+ }
+ this.parsedUnits = new HashtableOfObject(10);
+
+ // remember project's name lookup
+ this.nameLookup = project.getNameLookup();
+ }
+
+ public void initializeNameEnvironment(JavaProject project) throws JavaModelException {
+ // cleanup and recreate file name environment
+ if (this.nameEnvironment != null) {
+ this.nameEnvironment.cleanup();
+ }
+ this.nameEnvironment = this.getNameEnvironment(project);
+ }
/**
* Locate the matches in the given files and report them using the search requestor.
@@ -449,8 +382,7 @@
public void locateMatches(
String[] filePaths,
IWorkspace workspace,
- IWorkingCopy[] workingCopies,
- IProgressMonitor progressMonitor)
+ IWorkingCopy[] workingCopies)
throws JavaModelException {
if (SearchEngine.VERBOSE) {
@@ -530,7 +462,7 @@
if (workingCopy != null) {
openable = (Openable)workingCopy;
} else {
- openable = this.handleFactory.createOpenable(pathString);
+ openable = this.handleFactory.createOpenable(pathString, this.scope);
if (openable == null)
continue; // match is outside classpath
}
@@ -541,9 +473,9 @@
try {
javaProject = (JavaProject) openable.getJavaProject();
if (workingCopy != null) {
- resource = workingCopy.getOriginalElement().getUnderlyingResource();
+ resource = workingCopy.getOriginalElement().getResource();
} else {
- resource = openable.getUnderlyingResource();
+ resource = openable.getResource();
}
if (resource == null) { // case of a file in an external jar
resource = javaProject.getProject();
@@ -552,7 +484,7 @@
// locate matches in previous project
if (previousJavaProject != null) {
try {
- this.locateMatches(previousJavaProject, progressMonitor);
+ this.locateMatches(previousJavaProject);
} catch (JavaModelException e) {
if (e.getException() instanceof CoreException) {
throw e;
@@ -563,8 +495,19 @@
this.matchingOpenables = new MatchingOpenableSet();
}
- // create parser for this project
- this.createParser(javaProject);
+ // initialization for this project
+ if (length == 1) {
+ // if only one potential match, a file name environment costs too much,
+ // so use the existing searchable environment wich will populate the java model
+ // only for this potential match and its required types.
+ if (this.nameEnvironment != null) { // cleanup
+ this.nameEnvironment.cleanup();
+ }
+ this.nameEnvironment = javaProject.getSearchableNameEnvironment();
+ } else {
+ this.initializeNameEnvironment(javaProject);
+ }
+ this.initialize(javaProject);
previousJavaProject = javaProject;
}
} catch (JavaModelException e) {
@@ -573,7 +516,7 @@
}
// add matching openable
- this.addMatchingOpenable(resource, openable);
+ this.addMatchingOpenable(resource, openable, null/*no CompilationUnitDeclaration yet*/, null/*no Matchset yet*/);
if (progressMonitor != null) {
progressMonitor.worked(1);
@@ -583,7 +526,7 @@
// last project
if (previousJavaProject != null) {
try {
- this.locateMatches(previousJavaProject, progressMonitor);
+ this.locateMatches(previousJavaProject);
} catch (JavaModelException e) {
if (e.getException() instanceof CoreException) {
throw e;
@@ -640,11 +583,11 @@
IPackageFragment pkg = (IPackageFragment)pkgs[k];
if (pkg.getChildren().length > 0
&& pkgPattern.matchesName(pkgPattern.pkgName, pkg.getElementName().toCharArray())) {
- IResource resource = pkg.getUnderlyingResource();
+ IResource resource = pkg.getResource();
if (resource == null) { // case of a file in an external jar
resource = javaProject.getProject();
}
- this.currentMatchingOpenable = new MatchingOpenable(this, resource, null);
+ this.currentMatchingOpenable = new MatchingOpenable(this, resource, null, null, null);
try {
this.report(-1, -2, pkg, IJavaSearchResultCollector.EXACT_MATCH);
} catch (CoreException e) {
@@ -763,9 +706,12 @@
SourceMapper mapper = classFile.getSourceMapper();
if (mapper != null) {
IType type = classFile.getType();
- char[] contents = mapper.findSource(type, info);
- if (contents != null) {
- range = mapper.mapSource(type, contents, binaryMember);
+ String sourceFileName = mapper.findSourceFileName(type, info);
+ if (sourceFileName != null) {
+ char[] contents = mapper.findSource(type, sourceFileName);
+ if (contents != null) {
+ range = mapper.mapSource(type, contents, binaryMember);
+ }
}
}
}
@@ -893,9 +839,9 @@
token = scanner.getNextToken();
} catch (InvalidInputException e) {
}
- } while (token != ITerminalSymbols.TokenNameIdentifier && token != ITerminalSymbols.TokenNameEOF);
+ } while (token != TerminalTokens.TokenNameIdentifier && token != TerminalTokens.TokenNameEOF);
- if (token != ITerminalSymbols.TokenNameEOF) {
+ if (token != TerminalTokens.TokenNameEOF) {
char[] currentTokenSource = scanner.getCurrentTokenSource();
boolean equals = false;
while (i < tokenNumber
@@ -927,7 +873,7 @@
}
return;
}
- } while (token != ITerminalSymbols.TokenNameEOF);
+ } while (token != TerminalTokens.TokenNameEOF);
}
/**
@@ -962,7 +908,7 @@
token = scanner.getNextToken();
} catch (InvalidInputException e) {
}
- if (token != ITerminalSymbols.TokenNameEOF) {
+ if (token != TerminalTokens.TokenNameEOF) {
char[] currentTokenSource = scanner.getCurrentTokenSource();
boolean equals = false;
while (i < length
@@ -999,7 +945,7 @@
if (accuracyIndex < accuracies.length-1) {
accuracyIndex++;
}
- } while (token != ITerminalSymbols.TokenNameEOF);
+ } while (token != TerminalTokens.TokenNameEOF);
}
@@ -1106,90 +1052,46 @@
accuracy);
}
-private MatchingOpenable newMatchingOpenable(IResource resource, Openable openable) {
- MatchingOpenable matchingOpenable;
- try {
- matchingOpenable = new MatchingOpenable(this, resource, openable);
- } catch (AbortCompilation e) {
- // problem with class path: ignore this matching openable
- return null;
- }
- return matchingOpenable;
-}
-
-private void addMatchingOpenable(IResource resource, Openable openable)
- throws JavaModelException {
+void addMatchingOpenable(
+ IResource resource,
+ Openable openable,
+ CompilationUnitDeclaration parsedUnit,
+ MatchSet matchSet) {
- MatchingOpenable matchingOpenable = this.newMatchingOpenable(resource, openable);
+ MatchingOpenable matchingOpenable = new MatchingOpenable(this, resource, openable, parsedUnit, matchSet);
if (matchingOpenable != null) {
this.matchingOpenables.add(matchingOpenable);
}
}
-
-
- /**
- * Create a new parser for the given project, as well as a lookup environment.
- * Asks the pattern to initialize itself for polymorphic search.
- */
- public void createParser(JavaProject project) throws JavaModelException {
- // cleaup and recreate file name environment
- if (this.nameEnvironment != null) {
- this.nameEnvironment.cleanup();
- }
- this.nameEnvironment = this.getNameEnvironment(project);
-
- // create lookup environment
- CompilerOptions options = new CompilerOptions(JavaCore.getOptions());
- ProblemReporter problemReporter =
- new ProblemReporter(
- DefaultErrorHandlingPolicies.proceedWithAllProblems(),
- options,
- new DefaultProblemFactory());
- this.lookupEnvironment =
- new LookupEnvironment(this, options, problemReporter, this.nameEnvironment);
-
- // create parser
- this.parser = new MatchLocatorParser(problemReporter, options.assertMode);
-
- // reset parsed units (they could hold onto obsolete bindings: see bug 16052)
- MatchingOpenable[] openables = this.matchingOpenables.getMatchingOpenables(project.getPackageFragmentRoots());
- for (int i = 0, length = openables.length; i < length; i++) {
- MatchingOpenable matchingOpenable = openables[i];
- matchingOpenable.reset();
- }
- this.parsedUnits = new HashtableOfObject(10);
-
- // remember project's name lookup
- this.nameLookup = project.getNameLookup();
+/*
+ * Caches the given binary type in the lookup environment and returns it.
+ * Returns the existing one if already cached.
+ * Returns null if source type binding was cached.
+ */
+BinaryTypeBinding cacheBinaryType(IType type) throws JavaModelException {
+ IType enclosingType = type.getDeclaringType();
+ if (enclosingType != null) {
+ // force caching of enclosing types first, so that binary type can be found in lookup enviroment
+ this.cacheBinaryType(enclosingType);
}
+ IBinaryType binaryType = (IBinaryType)((BinaryType)type).getElementInfo();
+ BinaryTypeBinding binding = this.lookupEnvironment.cacheBinaryType(binaryType);
+ if (binding == null) { // it was already cached as a result of a previous query
+ char[][] compoundName = CharOperation.splitOn('.', type.getFullyQualifiedName().toCharArray());
+ ReferenceBinding referenceBinding = this.lookupEnvironment.getCachedType(compoundName);
+ if (referenceBinding != null && (referenceBinding instanceof BinaryTypeBinding)) {
+ // if the binding could be found and if it comes from a binary type,
+ binding = (BinaryTypeBinding)referenceBinding;
+ }
+ }
+ return binding;
+}
+
private INameEnvironment getNameEnvironment(JavaProject project) throws JavaModelException {
//return project.getSearchableNameEnvironment();
- IPackageFragmentRoot[] roots = project.getAllPackageFragmentRoots();
- int length = roots.length;
- String[] classpathNames = new String[length];
- int rootModes[] = new int[length];
- IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- for (int i = 0; i < length; i++) {
- IPackageFragmentRoot root = roots[i];
- IPath path = root.getPath();
- rootModes[i] = (root.getKind() == IPackageFragmentRoot.K_SOURCE) ? ClasspathDirectory.SOURCE : ClasspathDirectory.BINARY;
- if (root.isArchive()) {
- // pass in a relative path (for internal jar) as this is what is needed by FileNamewEnviroment.getZipFile(File)
- classpathNames[i] = path.toOSString();
- } else {
- Object target = JavaModel.getTarget(workspaceRoot, path, false);
- if (target instanceof IResource) {
- classpathNames[i] = ((IResource)target).getLocation().toOSString();
- } else {
- classpathNames[i] = path.toOSString();
- }
- }
- }
- String encoding = JavaCore.getOption(JavaCore.CORE_ENCODING);
- return new FileNameEnvironment(classpathNames, encoding, rootModes);
-
+ return new JavaSearchNameEnvironment(project);
}
public CompilationUnitDeclaration dietParse(final char[] source) {
@@ -1225,7 +1127,10 @@
} else {
ClassFileReader reader = this.classFileReader(type);
if (reader != null) {
- source = sourceMapper.findSource(type, reader);
+ String sourceFileName = sourceMapper.findSourceFileName(type, reader);
+ if (sourceFileName != null) {
+ source = sourceMapper.findSource(type, sourceFileName);
+ }
}
}
}
@@ -1237,7 +1142,7 @@
BinaryType binaryType = (BinaryType)classFile.getType();
if (classFile.isOpen()) {
// reuse the info from the java model cache
- return (IBinaryType)binaryType.getRawInfo();
+ return (IBinaryType)binaryType.getElementInfo();
} else {
// create a temporary info
IBinaryType info;
@@ -1281,32 +1186,35 @@
/**
* Locate the matches amongst the matching openables.
*/
- private void locateMatches(JavaProject javaProject, IProgressMonitor progressMonitor) throws JavaModelException {
+ private void locateMatches(JavaProject javaProject) throws JavaModelException {
MatchingOpenable[] openables = this.matchingOpenables.getMatchingOpenables(javaProject.getPackageFragmentRoots());
- boolean compilationAborted = false;
+ this.compilationAborted = false;
if (this.pattern.needsResolve) {
- // binding creation
- for (int i = 0, length = openables.length; i < length; i++) {
- openables[i].buildTypeBindings();
- if (progressMonitor != null) {
- if (progressMonitor.isCanceled()) {
- throw new OperationCanceledException();
- } else {
- progressMonitor.worked(6);
- }
+ this.createAndResolveBindings(openables);
+ }
+
+ // create hierarchy resolver if scope is a hierarchy scope
+ if (this.scope instanceof HierarchyScope) {
+ IType focusType = ((HierarchyScope)this.scope).focusType;
+ if (focusType != null) {
+ if (!focusType.isBinary()) {
+ // cache all types in the focus' compilation unit (even secondary types)
+ this.accept((ICompilationUnit)focusType.getCompilationUnit());
}
+
+ char[] fullyQualifiedName = focusType.getFullyQualifiedName().toCharArray();
+ this.hierarchyResolver = new HierarchyResolver(this.lookupEnvironment, null/*hierarchy is not going to be computed*/);
+ if (this.hierarchyResolver.setFocusType(CharOperation.splitOn('.', fullyQualifiedName)) == null) {
+ // focus type is not visible from this project
+ return;
+ }
+ } else {
+ this.hierarchyResolver = null;
}
-
- // binding resolution
- try {
- this.lookupEnvironment.completeTypeBindings();
- } catch (AbortCompilation e) {
- // problem with class path: it could not find base classes
- // continue reporting innacurate matches (since bindings will be null)
- compilationAborted = true;
- }
+ } else {
+ this.hierarchyResolver = null;
}
// matching openable resolution
@@ -1319,7 +1227,6 @@
this.currentMatchingOpenable = openables[i];
if (!this.currentMatchingOpenable.hasAlreadyDefinedType()) {
- this.currentMatchingOpenable.shouldResolve = !compilationAborted;
this.currentMatchingOpenable.locateMatches();
} // else skip type has it is hidden so not visible
} catch (AbortCompilation e) {
@@ -1344,4 +1251,27 @@
}
this.currentMatchingOpenable = null;
}
-}
\ No newline at end of file
+
+ void createAndResolveBindings(MatchingOpenable[] openables) {
+ // binding creation
+ for (int i = 0, length = openables.length; i < length; i++) {
+ openables[i].buildTypeBindings();
+ if (this.progressMonitor != null) {
+ if (this.progressMonitor.isCanceled()) {
+ throw new OperationCanceledException();
+ } else {
+ this.progressMonitor.worked(6);
+ }
+ }
+ }
+
+ // binding resolution
+ try {
+ this.lookupEnvironment.completeTypeBindings();
+ } catch (AbortCompilation e) {
+ // problem with class path: it could not find base classes
+ // continue reporting innacurate matches (since bindings will be null)
+ this.compilationAborted = true;
+ }
+ }
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator2.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator2.java
new file mode 100644
index 0000000..8d5a476
--- /dev/null
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator2.java
@@ -0,0 +1,1387 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.search.matching;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
+import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
+import org.eclipse.jdt.internal.compiler.env.*;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.eclipse.jdt.internal.compiler.impl.ITypeRequestor;
+import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.parser.Scanner;
+import org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
+import org.eclipse.jdt.internal.compiler.problem.*;
+import org.eclipse.jdt.internal.core.*;
+import org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver;
+import org.eclipse.jdt.internal.core.search.HierarchyScope;
+
+// TODO: (jerome) remove extends
+public class MatchLocator2 extends MatchLocator implements ITypeRequestor {
+ public static final int MAX_AT_ONCE = 500;
+ public static final PotentialMatch[] NO_POTENTIAL_MATH = new PotentialMatch[0];
+
+/* // permanent state
+ public SearchPattern pattern;
+ public int detailLevel;
+ public IJavaSearchResultCollector collector;
+ public IJavaSearchScope scope;
+ public IProgressMonitor progressMonitor;
+
+ public IWorkingCopy[] workingCopies;
+ public HandleFactory handleFactory;
+
+ // the following is valid for the current project
+ public MatchLocatorParser parser;
+ public INameEnvironment nameEnvironment;
+ public NameLookup nameLookup;
+ public LookupEnvironment lookupEnvironment;
+ public HierarchyResolver hierarchyResolver;
+ boolean compilationAborted;
+*/
+ public PotentialMatchSet potentialMatches;
+
+ public int parseThreshold = -1;
+ public CompilerOptions options;
+
+ // management of unit to be processed
+ public CompilationUnitDeclaration[] unitsToProcess;
+ public PotentialMatch[] matchesToProcess;
+ public int totalUnits; // (totalUnits-1) gives the last unit in unitToProcess
+
+ public PotentialMatch currentPotentialMatch;
+
+ public MatchLocator2(
+ SearchPattern pattern,
+ int detailLevel,
+ IJavaSearchResultCollector collector,
+ IJavaSearchScope scope,
+ IProgressMonitor progressMonitor) {
+
+ super(pattern, detailLevel, collector, scope, progressMonitor);
+
+ this.pattern = pattern;
+ this.detailLevel = detailLevel;
+ this.collector = collector;
+ this.scope = scope;
+ this.progressMonitor = progressMonitor;
+ }
+ /**
+ * Add an additional binary type
+ */
+ public void accept(IBinaryType binaryType, PackageBinding packageBinding) {
+ this.lookupEnvironment.createBinaryTypeFrom(binaryType, packageBinding);
+ }
+ /**
+ * Add an additional compilation unit into the loop
+ * -> build compilation unit declarations, their bindings and record their results.
+ */
+ public void accept(ICompilationUnit sourceUnit) {
+ // Switch the current policy and compilation result for this unit to the requested one.
+ CompilationResult unitResult =
+ new CompilationResult(sourceUnit, totalUnits, totalUnits, this.options.maxProblemsPerUnit);
+ try {
+ // diet parsing for large collection of unit
+ CompilationUnitDeclaration parsedUnit;
+ MatchSet originalMatchSet = this.parser.matchSet;
+ try {
+ this.parser.matchSet = new MatchingNodeSet(this);
+ if (totalUnits < parseThreshold) {
+ parsedUnit = parser.parse(sourceUnit, unitResult);
+ } else {
+ parsedUnit = parser.dietParse(sourceUnit, unitResult);
+ }
+ } finally {
+ this.parser.matchSet = originalMatchSet;
+ }
+
+ // initial type binding creation
+ lookupEnvironment.buildTypeBindings(parsedUnit);
+ this.addCompilationUnit(sourceUnit, parsedUnit);
+
+ // binding resolution
+ lookupEnvironment.completeTypeBindings(parsedUnit);
+ } catch (AbortCompilationUnit e) {
+ // at this point, currentCompilationUnitResult may not be sourceUnit, but some other
+ // one requested further along to resolve sourceUnit.
+ if (unitResult.compilationUnit == sourceUnit) { // only report once
+ //requestor.acceptResult(unitResult.tagAsAccepted());
+ } else {
+ throw e; // want to abort enclosing request to compile
+ }
+ }
+ }
+ /**
+ * Add additional source types
+ */
+ public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding) {
+ // case of SearchableEnvironment of an IJavaProject is used
+ ISourceType sourceType = sourceTypes[0];
+ while (sourceType.getEnclosingType() != null)
+ sourceType = sourceType.getEnclosingType();
+ if (sourceType instanceof SourceTypeElementInfo) {
+ // get source
+ SourceTypeElementInfo elementInfo = (SourceTypeElementInfo) sourceType;
+ IType type = elementInfo.getHandle();
+ ICompilationUnit sourceUnit = (ICompilationUnit)type.getCompilationUnit();
+ this.accept(sourceUnit);
+ } else {
+ CompilationResult result =
+ new CompilationResult(sourceType.getFileName(), 0, 0, 0);
+ CompilationUnitDeclaration unit =
+ SourceTypeConverter.buildCompilationUnit(
+ sourceTypes,
+ true, // need field and methods
+ true, // need member types
+ false, // no need for field initialization
+ lookupEnvironment.problemReporter,
+ result);
+ this.lookupEnvironment.buildTypeBindings(unit);
+ this.lookupEnvironment.completeTypeBindings(unit, true);
+ }
+ }
+ protected void addCompilationUnit(
+ ICompilationUnit sourceUnit,
+ CompilationUnitDeclaration parsedUnit) {
+
+ // append the unit to the list of ones to process later on
+ int size = this.unitsToProcess.length;
+ if (this.totalUnits == size) {
+ // when growing reposition units starting at position 0
+ int newSize = size == 0 ? 1 : size * 2;
+ System.arraycopy(
+ this.unitsToProcess,
+ 0,
+ (this.unitsToProcess = new CompilationUnitDeclaration[newSize]),
+ 0,
+ this.totalUnits);
+ System.arraycopy(
+ this.matchesToProcess,
+ 0,
+ (this.matchesToProcess = new PotentialMatch[newSize]),
+ 0,
+ this.totalUnits);
+ }
+ if (sourceUnit instanceof PotentialMatch) {
+ this.matchesToProcess[this.totalUnits] = (PotentialMatch)sourceUnit;
+ }
+ this.unitsToProcess[this.totalUnits] = parsedUnit;
+ this.totalUnits++;
+ }
+ void addPotentialMatch(IResource resource, Openable openable) {
+ PotentialMatch potentialMatch = new PotentialMatch(this, resource, openable);
+ this.potentialMatches.add(potentialMatch);
+ }
+ /*
+ * Caches the given binary type in the lookup environment and returns it.
+ * Returns the existing one if already cached.
+ * Returns null if source type binding was cached.
+ */
+ BinaryTypeBinding cacheBinaryType(IType type) throws JavaModelException {
+ IType enclosingType = type.getDeclaringType();
+ if (enclosingType != null) {
+ // force caching of enclosing types first, so that binary type can be found in lookup enviroment
+ this.cacheBinaryType(enclosingType);
+ }
+ IBinaryType binaryType = (IBinaryType)((BinaryType)type).getElementInfo();
+ BinaryTypeBinding binding = this.lookupEnvironment.cacheBinaryType(binaryType);
+ if (binding == null) { // it was already cached as a result of a previous query
+ char[][] compoundName = CharOperation.splitOn('.', type.getFullyQualifiedName().toCharArray());
+ ReferenceBinding referenceBinding = this.lookupEnvironment.getCachedType(compoundName);
+ if (referenceBinding != null && (referenceBinding instanceof BinaryTypeBinding)) {
+ // if the binding could be found and if it comes from a binary type,
+ binding = (BinaryTypeBinding)referenceBinding;
+ }
+ }
+ return binding;
+ }
+ public ClassFileReader classFileReader(IType type) {
+ IClassFile classFile = type.getClassFile();
+ if (((IOpenable)classFile).isOpen()) {
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ synchronized(manager){
+ return (ClassFileReader)manager.getInfo(type);
+ }
+ } else {
+ IPackageFragment pkg = type.getPackageFragment();
+ IPackageFragmentRoot root = (IPackageFragmentRoot)pkg.getParent();
+ try {
+ if (root.isArchive()) {
+ IPath zipPath = root.isExternal() ? root.getPath() : root.getResource().getLocation();
+ if (zipPath == null) return null; // location is null
+ ZipFile zipFile = null;
+ try {
+ if (JavaModelManager.ZIP_ACCESS_VERBOSE) {
+ System.out.println("(" + Thread.currentThread() + ") [MatchLocator.classFileReader()] Creating ZipFile on " + zipPath); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ // TODO: (jerome) should use JavaModelManager.getZipFile(...) instead
+ zipFile = new ZipFile(zipPath.toOSString());
+ char[] pkgPath = pkg.getElementName().toCharArray();
+ CharOperation.replace(pkgPath, '.', '/');
+ char[] classFileName = classFile.getElementName().toCharArray();
+ char[] path = pkgPath.length == 0 ? classFileName : CharOperation.concat(pkgPath, classFileName, '/');
+ return ClassFileReader.read(zipFile, new String(path));
+ } finally {
+ if (zipFile != null) {
+ try {
+ zipFile.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ } else {
+ return ClassFileReader.read(type.getPath().toOSString());
+ }
+ } catch (ClassFormatException e) {
+ return null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+ }
+ /**
+ * Add the initial set of compilation units into the loop
+ * -> build compilation unit declarations, their bindings and record their results.
+ */
+ protected void createAndResolveBindings(PotentialMatch[] potentialMatches, int start, int length) {
+
+ for (int i = start, maxUnits = start+length; i < maxUnits; i++) {
+ if (this.progressMonitor != null && this.progressMonitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ PotentialMatch potentialMatch = potentialMatches[i];
+ try {
+ if (potentialMatch != null) {
+ this.parser.matchSet = potentialMatch.matchingNodeSet;
+ }
+ CompilationResult unitResult =
+ new CompilationResult(potentialMatch, i, maxUnits, this.options.maxProblemsPerUnit);
+
+ if (SearchEngine.VERBOSE) {
+ System.out.println("Parsing " + potentialMatch.openable.toStringWithAncestors()); //$NON-NLS-1$
+ }
+
+ // diet parsing for large collection of units
+ CompilationUnitDeclaration parsedUnit;
+ if (totalUnits < parseThreshold) {
+ parsedUnit = this.parser.parse(potentialMatch, unitResult);
+ } else {
+ parsedUnit = this.parser.dietParse(potentialMatch, unitResult);
+ }
+
+ // initial type binding creation
+ if (parsedUnit != null && !parsedUnit.isEmpty()) {
+ this.lookupEnvironment.buildTypeBindings(parsedUnit);
+ }
+
+ this.addCompilationUnit(potentialMatch, parsedUnit);
+
+ // progress reporting
+ if (this.progressMonitor != null) {
+ this.progressMonitor.worked(4);
+ }
+ } finally {
+ this.parser.matchSet = null;
+ potentialMatches[i] = null; // no longer hold onto the unit
+ }
+ }
+ // binding resolution
+ lookupEnvironment.completeTypeBindings();
+ }
+ /**
+ * Creates an IField from the given field declaration and type.
+ */
+ public IField createFieldHandle(
+ FieldDeclaration field,
+ IType type) {
+ if (type == null) return null;
+ return type.getField(new String(field.name));
+ }
+ /*
+ * Creates hierarchy resolver if needed.
+ * Returns whether focus is visible.
+ */
+ protected boolean createHierarchyResolver(PotentialMatch[] potentialMatches) {
+ // create hierarchy resolver if scope is a hierarchy scope
+ IType focusType = getFocusType();
+ if (focusType != null) {
+ // cache focus type if not a potential match
+ char[][] compoundName = CharOperation.splitOn('.', focusType.getFullyQualifiedName().toCharArray());
+ boolean isPotentialMatch = false;
+ for (int i = 0, length = potentialMatches.length; i < length; i++) {
+ if (CharOperation.equals(potentialMatches[i].compoundName, compoundName)) {
+ isPotentialMatch = true;
+ break;
+ }
+ }
+ if (!isPotentialMatch) {
+ if (focusType.isBinary()) {
+ // cache binary type
+ try {
+ this.cacheBinaryType(focusType);
+ } catch (JavaModelException e) {
+ return false;
+ }
+ } else {
+ // cache all types in the focus' compilation unit (even secondary types)
+ this.accept((ICompilationUnit)focusType.getCompilationUnit());
+ }
+ }
+
+ // resolve focus type
+ this.hierarchyResolver = new HierarchyResolver(this.lookupEnvironment, null/*hierarchy is not going to be computed*/);
+ if (this.hierarchyResolver.setFocusType(compoundName) == null) {
+ // focus type is not visible from this project
+ return false;
+ }
+ } else {
+ this.hierarchyResolver = null;
+ }
+ return true;
+ }
+ /**
+ * Creates an IImportDeclaration from the given import statement
+ */
+ public IJavaElement createImportHandle(ImportReference importRef) {
+ char[] importName = CharOperation.concatWith(importRef.getImportName(), '.');
+ if (importRef.onDemand) {
+ importName = CharOperation.concat(importName, ".*" .toCharArray()); //$NON-NLS-1$
+ }
+ Openable currentOpenable = this.getCurrentOpenable();
+ if (currentOpenable instanceof CompilationUnit) {
+ return ((CompilationUnit)currentOpenable).getImport(
+ new String(importName));
+ } else {
+ try {
+ return ((org.eclipse.jdt.internal.core.ClassFile)currentOpenable).getType();
+ } catch (JavaModelException e) {
+ return null;
+ }
+ }
+ }
+ /**
+ * Creates an IInitializer from the given field declaration and type.
+ */
+ public IInitializer createInitializerHandle(
+ TypeDeclaration typeDecl,
+ FieldDeclaration initializer,
+ IType type) {
+ if (type == null) return null;
+
+ // find occurence count of the given initializer in its type declaration
+ int occurrenceCount = 0;
+ FieldDeclaration[] fields = typeDecl.fields;
+ for (int i = 0, length = fields.length; i < length; i++) {
+ FieldDeclaration field = fields[i];
+ if (!field.isField()) {
+ occurrenceCount++;
+ if (field.equals(initializer)) {
+ break;
+ }
+ }
+ }
+
+ return type.getInitializer(occurrenceCount);
+ }
+ /**
+ * Creates an IMethod from the given method declaration and type.
+ */
+ public IMethod createMethodHandle(
+ AbstractMethodDeclaration method,
+ IType type) {
+ if (type == null) return null;
+ Argument[] arguments = method.arguments;
+ int length = arguments == null ? 0 : arguments.length;
+ if (type.isBinary()) {
+ // don't cache the methods of the binary type
+ ClassFileReader reader = this.classFileReader(type);
+ if (reader == null) return null;
+ IBinaryMethod[] methods = reader.getMethods();
+
+ if (methods != null) {
+ for (int i = 0, methodsLength = methods.length; i < methodsLength; i++) {
+ IBinaryMethod binaryMethod = methods[i];
+ char[] selector = binaryMethod.isConstructor() ? type.getElementName().toCharArray() : binaryMethod.getSelector();
+ if (CharOperation.equals(selector, method.selector)) {
+ String[] parameterTypes = Signature.getParameterTypes(new String(binaryMethod.getMethodDescriptor()));
+ if (length != parameterTypes.length) continue;
+ boolean sameParameters = true;
+ for (int j = 0; j < length; j++) {
+ TypeReference parameterType = arguments[j].type;
+ char[] typeName = CharOperation.concatWith(parameterType.getTypeName(), '.');
+ for (int k = 0; k < parameterType.dimensions(); k++) {
+ typeName = CharOperation.concat(typeName, "[]" .toCharArray()); //$NON-NLS-1$
+ }
+ String parameterTypeName = parameterTypes[j].replace('/', '.');
+ if (!Signature.toString(parameterTypeName).endsWith(new String(typeName))) {
+ sameParameters = false;
+ break;
+ } else {
+ parameterTypes[j] = parameterTypeName;
+ }
+ }
+ if (sameParameters) {
+ return type.getMethod(new String(selector), parameterTypes);
+ }
+ }
+ }
+ }
+ return null;
+ } else {
+ String[] parameterTypeSignatures = new String[length];
+ for (int i = 0; i < length; i++) {
+ TypeReference parameterType = arguments[i].type;
+ char[] typeName = CharOperation.concatWith(parameterType.getTypeName(), '.');
+ for (int j = 0; j < parameterType.dimensions(); j++) {
+ typeName = CharOperation.concat(typeName, "[]" .toCharArray()); //$NON-NLS-1$
+ }
+ parameterTypeSignatures[i] = Signature.createTypeSignature(typeName, false);
+ }
+ return type.getMethod(new String(method.selector), parameterTypeSignatures);
+ }
+ }
+ /**
+ * Creates an IType from the given simple top level type name.
+ */
+ public IType createTypeHandle(char[] simpleTypeName) {
+ Openable currentOpenable = this.getCurrentOpenable();
+ if (currentOpenable instanceof CompilationUnit) {
+ // creates compilation unit
+ CompilationUnit unit = (CompilationUnit)currentOpenable;
+
+ // create type
+ return unit.getType(new String(simpleTypeName));
+ } else {
+ IType type;
+ try {
+ type = ((org.eclipse.jdt.internal.core.ClassFile)currentOpenable).getType();
+ } catch (JavaModelException e) {
+ return null;
+ }
+ // ensure this is a top level type (see bug 20011 Searching for Inner Classes gives bad search results)
+ return MatchingOpenable.getTopLevelType(type);
+ }
+ }
+ /**
+ * Creates an IType from the given simple inner type name and parent type.
+ */
+ public IType createTypeHandle(IType parent, char[] simpleTypeName) {
+ return parent.getType(new String(simpleTypeName));
+ }
+ protected Openable getCurrentOpenable() {
+ return this.currentPotentialMatch.openable;
+ }
+ protected IResource getCurrentResource() {
+ return this.currentPotentialMatch.resource;
+ }
+ protected IType getFocusType() {
+ return this.scope instanceof HierarchyScope ? ((HierarchyScope)this.scope).focusType : null;
+ }
+ public IBinaryType getBinaryInfo(org.eclipse.jdt.internal.core.ClassFile classFile, IResource resource) throws CoreException {
+ BinaryType binaryType = (BinaryType)classFile.getType();
+ if (classFile.isOpen()) {
+ // reuse the info from the java model cache
+ return (IBinaryType)binaryType.getElementInfo();
+ } else {
+ // create a temporary info
+ IBinaryType info;
+ try {
+ IJavaElement pkg = classFile.getParent();
+ PackageFragmentRoot root = (PackageFragmentRoot)pkg.getParent();
+ if (root.isArchive()) {
+ // class file in a jar
+ String pkgPath = pkg.getElementName().replace('.', '/');
+ String classFilePath =
+ (pkgPath.length() > 0) ?
+ pkgPath + "/" + classFile.getElementName() : //$NON-NLS-1$
+ classFile.getElementName();
+ ZipFile zipFile = null;
+ try {
+ zipFile = ((JarPackageFragmentRoot)root).getJar();
+ info = org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.read(
+ zipFile,
+ classFilePath);
+ } finally {
+ JavaModelManager.getJavaModelManager().closeZipFile(zipFile);
+ }
+ } else {
+ // class file in a directory
+ String osPath = resource.getFullPath().toOSString();
+ info = org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.read(osPath);
+ }
+ return info;
+ } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException e) {
+ //e.printStackTrace();
+ return null;
+ } catch (java.io.IOException e) {
+ throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
+ }
+ }
+ }
+ protected void getMethodBodies(CompilationUnitDeclaration unit, int place) {
+ //fill the methods bodies in order for the code to be generated
+
+ if (unit.ignoreMethodBodies) {
+ unit.ignoreFurtherInvestigation = true;
+ return;
+ // if initial diet parse did not work, no need to dig into method bodies.
+ }
+
+ if (place < parseThreshold)
+ return; //work already done ...
+
+ //real parse of the method....
+ this.parser.scanner.setSource(unit.compilationResult.compilationUnit.getContents());
+ this.parser.parseBodies(unit);
+ }
+ /**
+ * Create a new parser for the given project, as well as a lookup environment.
+ */
+ public void initialize(JavaProject project) throws JavaModelException {
+ initialize(project, NO_POTENTIAL_MATH);
+ }
+ /**
+ * Create a new parser for the given project, as well as a lookup environment.
+ */
+ public void initialize(JavaProject project, PotentialMatch[] potentialMatches) throws JavaModelException {
+ // create name environment
+ if (this.nameEnvironment != null) { // cleanup
+ this.nameEnvironment.cleanup();
+ }
+ if (potentialMatches.length == 1) {
+ // if only one potential match, a file name environment costs too much,
+ // so use the existing searchable environment which will populate the java model
+ // only for this potential match and its required types.
+ this.nameEnvironment = project.getSearchableNameEnvironment();
+ } else {
+ this.nameEnvironment = new JavaSearchNameEnvironment2(project);
+ }
+
+ // create lookup environment
+ this.options = new CompilerOptions(project.getOptions(true));
+ ProblemReporter problemReporter =
+ new ProblemReporter(
+ DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+ this.options,
+ new DefaultProblemFactory());
+ this.lookupEnvironment =
+ new LookupEnvironment(this, this.options, problemReporter, this.nameEnvironment);
+
+ // create parser
+ this.parser = new MatchLocatorParser(problemReporter, this.options.sourceLevel >= CompilerOptions.JDK1_4);
+
+ // remember project's name lookup
+ this.nameLookup = project.getNameLookup();
+
+ // initialize queue of units
+ this.totalUnits = 0;
+ int maxUnits = potentialMatches.length;
+ this.unitsToProcess = new CompilationUnitDeclaration[maxUnits];
+ this.matchesToProcess = new PotentialMatch[maxUnits];
+
+ }
+ public boolean hasAlreadyDefinedType(CompilationUnitDeclaration parsedUnit) {
+ if (parsedUnit == null) return false;
+ CompilationResult result = parsedUnit.compilationResult;
+ if (result == null) return false;
+ for (int i = 0; i < result.problemCount; i++) {
+ IProblem problem = result.problems[i];
+ if (problem.getID() == IProblem.DuplicateTypes) {
+ return true;
+ }
+ }
+ return false;
+ }
+ /**
+ * Locate the matches amongst the potential matches.
+ */
+ private void locateMatches(JavaProject javaProject) throws JavaModelException {
+ PotentialMatch[] potentialMatches =
+ this.potentialMatches.getPotentialMatches(
+ getFocusType() == null ?
+ javaProject.getPackageFragmentRoots() :
+ javaProject.getAllPackageFragmentRoots()); // all potential matches are resolved in the focus' project context
+
+ int length = potentialMatches.length;
+ int index = 0;
+ while (index < length) {
+ int max = Math.min(MAX_AT_ONCE, length-index);
+ locateMatches(javaProject, potentialMatches, index, max);
+ index += max;
+ }
+ }
+ private void locateMatches(JavaProject javaProject, PotentialMatch[] potentialMatches, int start, int length) throws JavaModelException {
+
+ // copy array because elements from the original are removed below
+ PotentialMatch[] copy = new PotentialMatch[length];
+ System.arraycopy(potentialMatches, start, copy, 0, length);
+ this.initialize(javaProject, copy);
+
+ this.compilationAborted = false;
+
+ // create and resolve binding (equivalent to beginCompilation() in Compiler)
+ try {
+ this.createAndResolveBindings(potentialMatches, start, length);
+ } catch (AbortCompilation e) {
+ this.compilationAborted = true;
+ }
+
+ // create hierarchy resolver if needed
+ try {
+ if (!this.compilationAborted && !this.createHierarchyResolver(copy)) {
+ return;
+ }
+ } catch (AbortCompilation e) {
+ this.compilationAborted = true;
+ }
+
+ // free memory
+ copy = null;
+ potentialMatches = null;
+
+ // potential match resolution
+ try {
+ CompilationUnitDeclaration unit = null;
+ for (int i = 0; i < this.totalUnits; i++) {
+ if (this.progressMonitor != null && this.progressMonitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ unit = this.unitsToProcess[i];
+ try {
+ process(unit, i);
+ } catch (AbortCompilation e) {
+ // problem with class path: it could not find base classes
+ // continue and try next matching openable reporting innacurate matches (since bindings will be null)
+ this.compilationAborted = true;
+ } catch (CoreException e) {
+ if (e instanceof JavaModelException) {
+ // problem with class path: it could not find base classes
+ // continue and try next matching openable reporting innacurate matches (since bindings will be null)
+ this.compilationAborted = true;
+ } else {
+ // core exception thrown by client's code: let it through
+ throw new JavaModelException(e);
+ }
+ } finally {
+ // cleanup compilation unit result
+ unit.cleanUp();
+ if (this.options.verbose)
+ System.out.println(Util.bind("compilation.done", //$NON-NLS-1$
+ new String[] {
+ String.valueOf(i + 1),
+ String.valueOf(totalUnits),
+ new String(unitsToProcess[i].getFileName())}));
+ }
+ this.unitsToProcess[i] = null; // release reference to processed unit declaration
+ this.matchesToProcess[i] = null; // release reference to processed potential match
+ if (this.progressMonitor != null) {
+ this.progressMonitor.worked(5);
+ }
+ }
+ } catch (AbortCompilation e) {
+ this.compilationAborted = true;
+ }
+ }
+
+ /**
+ * Locate the matches in the given files and report them using the search requestor.
+ */
+ public void locateMatches(
+ String[] filePaths,
+ IWorkspace workspace,
+ IWorkingCopy[] workingCopies)
+ throws JavaModelException {
+
+ if (SearchEngine.VERBOSE) {
+ System.out.println("Locating matches in files ["); //$NON-NLS-1$
+ for (int i = 0, length = filePaths.length; i < length; i++) {
+ String path = filePaths[i];
+ System.out.println("\t" + path); //$NON-NLS-1$
+ }
+ System.out.println("]"); //$NON-NLS-1$
+ if (workingCopies != null) {
+ System.out.println("and working copies ["); //$NON-NLS-1$
+ for (int i = 0, length = workingCopies.length; i < length; i++) {
+ IWorkingCopy wc = workingCopies[i];
+ System.out.println("\t" + ((JavaElement)wc).toStringWithAncestors()); //$NON-NLS-1$
+ }
+ System.out.println("]"); //$NON-NLS-1$
+ }
+ }
+
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ try {
+ // optimize access to zip files during search operation
+ manager.cacheZipFiles();
+
+ // initialize handle factory (used as a cache of handles so as to optimize space)
+ if (this.handleFactory == null) {
+ this.handleFactory = new HandleFactory(workspace);
+ }
+
+ // initialize locator with working copies
+ this.workingCopies = workingCopies;
+
+ // substitute compilation units with working copies
+ HashMap wcPaths = new HashMap(); // a map from path to working copies
+ int wcLength;
+ if (workingCopies != null && (wcLength = workingCopies.length) > 0) {
+ String[] newPaths = new String[wcLength];
+ for (int i = 0; i < wcLength; i++) {
+ IWorkingCopy workingCopy = workingCopies[i];
+ String path = workingCopy.getOriginalElement().getPath().toString();
+ wcPaths.put(path, workingCopy);
+ newPaths[i] = path;
+ }
+ int filePathsLength = filePaths.length;
+ System.arraycopy(filePaths, 0, filePaths = new String[filePathsLength+wcLength], 0, filePathsLength);
+ System.arraycopy(newPaths, 0, filePaths, filePathsLength, wcLength);
+ }
+
+ int length = filePaths.length;
+ if (progressMonitor != null) {
+ if (this.pattern.needsResolve) {
+ progressMonitor.beginTask("", length * 10); // 1 for file path, 4 for parsing and binding creation, 5 for binding resolution //$NON-NLS-1$
+ } else {
+ progressMonitor.beginTask("", length * 5); // 1 for file path, 4 for parsing and binding creation //$NON-NLS-1$
+ }
+ }
+
+ // sort file paths projects
+ Util.sort(filePaths);
+
+ // initialize pattern for polymorphic search (ie. method reference pattern)
+ this.potentialMatches = new PotentialMatchSet();
+ this.pattern.initializePolymorphicSearch(this, progressMonitor);
+
+ IType focusType = getFocusType();
+ JavaProject previousJavaProject = focusType == null ? null : (JavaProject)focusType.getJavaProject();
+ for (int i = 0; i < length; i++) {
+ if (progressMonitor != null && progressMonitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
+ String pathString = filePaths[i];
+
+ // skip duplicate paths
+ if (i > 0 && pathString.equals(filePaths[i-1])) continue;
+
+ Openable openable;
+ IWorkingCopy workingCopy = (IWorkingCopy)wcPaths.get(pathString);
+ if (workingCopy != null) {
+ openable = (Openable)workingCopy;
+ } else {
+ openable = this.handleFactory.createOpenable(pathString, this.scope);
+ if (openable == null)
+ continue; // match is outside classpath
+ }
+
+ // create new parser and lookup environment if this is a new project
+ IResource resource = null;
+ JavaProject javaProject = null;
+ try {
+ javaProject = (JavaProject) openable.getJavaProject();
+ if (workingCopy != null) {
+ resource = workingCopy.getOriginalElement().getResource();
+ } else {
+ resource = openable.getResource();
+ }
+ if (resource == null) { // case of a file in an external jar
+ resource = javaProject.getProject();
+ }
+ if (focusType == null // when searching in hierarchy, all potential matches are resolved in the focus project context
+ && !javaProject.equals(previousJavaProject)) {
+ // locate matches in previous project
+ if (previousJavaProject != null) {
+ try {
+ this.locateMatches(previousJavaProject);
+ } catch (JavaModelException e) {
+ if (e.getException() instanceof CoreException) {
+ throw e;
+ } else {
+ // problem with classpath in this project -> skip it
+ }
+ }
+ this.potentialMatches = new PotentialMatchSet();
+ }
+
+ previousJavaProject = javaProject;
+ }
+ } catch (JavaModelException e) {
+ // file doesn't exist -> skip it
+ continue;
+ }
+
+ // add potential match
+ this.addPotentialMatch(resource, openable);
+
+ if (progressMonitor != null) {
+ progressMonitor.worked(1);
+ }
+ }
+
+ // last project
+ if (previousJavaProject != null) {
+ try {
+ this.locateMatches(previousJavaProject);
+ } catch (JavaModelException e) {
+ if (e.getException() instanceof CoreException) {
+ throw e;
+ } else {
+ // problem with classpath in last project -> skip it
+ }
+ }
+ this.potentialMatches = new PotentialMatchSet();
+ }
+
+ if (progressMonitor != null) {
+ progressMonitor.done();
+ }
+ } finally {
+ if (this.nameEnvironment != null) {
+ this.nameEnvironment.cleanup();
+ }
+ manager.flushZipFiles();
+ }
+ }
+ /**
+ * Locates the package declarations corresponding to this locator's pattern.
+ */
+ public void locatePackageDeclarations(IWorkspace workspace)
+ throws JavaModelException {
+ this.locatePackageDeclarations(this.pattern, workspace);
+ }
+
+ /**
+ * Locates the package declarations corresponding to the search pattern.
+ */
+ private void locatePackageDeclarations(
+ SearchPattern searchPattern,
+ IWorkspace workspace)
+ throws JavaModelException {
+ if (searchPattern instanceof OrPattern) {
+ OrPattern orPattern = (OrPattern) searchPattern;
+ this.locatePackageDeclarations(orPattern.leftPattern, workspace);
+ this.locatePackageDeclarations(orPattern.rightPattern, workspace);
+ } else
+ if (searchPattern instanceof PackageDeclarationPattern) {
+ PackageDeclarationPattern pkgPattern =
+ (PackageDeclarationPattern) searchPattern;
+ IJavaProject[] projects =
+ JavaModelManager.getJavaModelManager().getJavaModel().getJavaProjects();
+ for (int i = 0, length = projects.length; i < length; i++) {
+ IJavaProject javaProject = projects[i];
+ IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
+ for (int j = 0, rootsLength = roots.length; j < rootsLength; j++) {
+ IJavaElement[] pkgs = roots[j].getChildren();
+ for (int k = 0, pksLength = pkgs.length; k < pksLength; k++) {
+ IPackageFragment pkg = (IPackageFragment)pkgs[k];
+ if (pkg.getChildren().length > 0
+ && pkgPattern.matchesName(pkgPattern.pkgName, pkg.getElementName().toCharArray())) {
+ IResource resource = pkg.getResource();
+ if (resource == null) { // case of a file in an external jar
+ resource = javaProject.getProject();
+ }
+ this.currentPotentialMatch = new PotentialMatch(this, resource, null);
+ try {
+ this.report(-1, -2, pkg, IJavaSearchResultCollector.EXACT_MATCH);
+ } catch (CoreException e) {
+ if (e instanceof JavaModelException) {
+ throw (JavaModelException) e;
+ } else {
+ throw new JavaModelException(e);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ /*
+ * Process a compilation unit already parsed and build.
+ */
+ public void process(CompilationUnitDeclaration unit, int i) throws CoreException {
+ MatchingNodeSet matchingNodeSet = null;
+ try {
+ this.currentPotentialMatch = this.matchesToProcess[i];
+ if (this.currentPotentialMatch == null) return;
+ matchingNodeSet = this.currentPotentialMatch.matchingNodeSet;
+
+ if (unit == null || unit.isEmpty()) {
+ if (this.currentPotentialMatch.openable instanceof org.eclipse.jdt.internal.core.ClassFile) {
+ this.currentPotentialMatch.locateMatchesInClassFile();
+ }
+ return;
+ }
+ if (hasAlreadyDefinedType(unit)) {
+ // skip type has it is hidden so not visible
+ return;
+ }
+
+ this.parser.matchSet = this.currentPotentialMatch.matchingNodeSet;
+ getMethodBodies(unit, i);
+
+ // report matches that don't need resolve
+ matchingNodeSet.cuHasBeenResolved = this.compilationAborted;
+ matchingNodeSet.reportMatching(unit);
+
+ if ((this.pattern.needsResolve || matchingNodeSet.needsResolve()/* TODO: do not need this check any longer */)
+ && unit.types != null
+ && !this.compilationAborted) {
+
+ if (SearchEngine.VERBOSE) {
+ System.out.println("Resolving " + this.currentPotentialMatch.openable.toStringWithAncestors()); //$NON-NLS-1$
+ }
+
+ // fault in fields & methods
+ if (unit.scope != null)
+ unit.scope.faultInTypes();
+
+ // verify inherited methods
+ if (unit.scope != null)
+ unit.scope.verifyMethods(this.lookupEnvironment.methodVerifier());
+
+ // type checking
+ unit.resolve();
+
+ // refresh the total number of units known at this stage
+ unit.compilationResult.totalUnitsKnown = totalUnits;
+
+ // report matches that needed resolve
+ matchingNodeSet.cuHasBeenResolved = true;
+ matchingNodeSet.reportMatching(unit);
+ }
+ } catch (AbortCompilation e) {
+ // could not resolve: report innacurate matches
+ if (matchingNodeSet != null) {
+ matchingNodeSet.cuHasBeenResolved = true;
+ matchingNodeSet.reportMatching(unit);
+ }
+ if (!(e instanceof AbortCompilationUnit)) {
+ // problem with class path
+ throw e;
+ }
+ } finally {
+ this.parser.matchSet = null;
+ this.currentPotentialMatch = null;
+ }
+ }
+ public void report(
+ int sourceStart,
+ int sourceEnd,
+ IJavaElement element,
+ int accuracy)
+ throws CoreException {
+
+ if (this.scope.encloses(element)) {
+ if (SearchEngine.VERBOSE) {
+ IResource res = this.getCurrentResource();
+ System.out.println("Reporting match"); //$NON-NLS-1$
+ System.out.println("\tResource: " + (res == null ? " <unknown> " : res.getFullPath().toString())); //$NON-NLS-2$//$NON-NLS-1$
+ System.out.println("\tPositions: [" + sourceStart + ", " + sourceEnd + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ System.out.println("\tJava element: " + ((JavaElement)element).toStringWithAncestors()); //$NON-NLS-1$
+ if (accuracy == IJavaSearchResultCollector.EXACT_MATCH) {
+ System.out.println("\tAccuracy: EXACT_MATCH"); //$NON-NLS-1$
+ } else {
+ System.out.println("\tAccuracy: POTENTIAL_MATCH"); //$NON-NLS-1$
+ }
+ }
+ this.report(
+ this.getCurrentResource(),
+ sourceStart,
+ sourceEnd,
+ element,
+ accuracy);
+ }
+ }
+ public void report(
+ IResource resource,
+ int sourceStart,
+ int sourceEnd,
+ IJavaElement element,
+ int accuracy)
+ throws CoreException {
+
+ this.collector.accept(
+ resource,
+ sourceStart,
+ sourceEnd + 1,
+ element,
+ accuracy);
+ }
+ /**
+ * Finds the accurate positions of the sequence of tokens given by qualifiedName
+ * in the source and reports a reference to this this qualified name
+ * to the search requestor.
+ */
+ public void reportAccurateReference(
+ int sourceStart,
+ int sourceEnd,
+ char[][] qualifiedName,
+ IJavaElement element,
+ int accuracy)
+ throws CoreException {
+
+ if (accuracy == -1) return;
+
+ // compute source positions of the qualified reference
+ Scanner scanner = this.parser.scanner;
+ scanner.setSource(
+ this.currentPotentialMatch.getContents());
+ scanner.resetTo(sourceStart, sourceEnd);
+
+ int refSourceStart = -1, refSourceEnd = -1;
+ int tokenNumber = qualifiedName.length;
+ int token = -1;
+ int previousValid = -1;
+ int i = 0;
+ int currentPosition;
+ do {
+ // find first token that is an identifier (parenthesized expressions include parenthesises in source range - see bug 20693 - Finding references to variables does not find all occurrences )
+ do {
+ currentPosition = scanner.currentPosition;
+ try {
+ token = scanner.getNextToken();
+ } catch (InvalidInputException e) {
+ }
+ } while (token != TerminalTokens.TokenNameIdentifier && token != TerminalTokens.TokenNameEOF);
+
+ if (token != TerminalTokens.TokenNameEOF) {
+ char[] currentTokenSource = scanner.getCurrentTokenSource();
+ boolean equals = false;
+ while (i < tokenNumber
+ && !(equals = this.pattern.matchesName(qualifiedName[i++], currentTokenSource))) {
+ }
+ if (equals && (previousValid == -1 || previousValid == i - 2)) {
+ previousValid = i - 1;
+ if (refSourceStart == -1) {
+ refSourceStart = currentPosition;
+ }
+ refSourceEnd = scanner.currentPosition - 1;
+ } else {
+ i = 0;
+ refSourceStart = -1;
+ previousValid = -1;
+ }
+ // read '.'
+ try {
+ token = scanner.getNextToken();
+ } catch (InvalidInputException e) {
+ }
+ }
+ if (i == tokenNumber) {
+ // accept reference
+ if (refSourceStart != -1) {
+ this.report(refSourceStart, refSourceEnd, element, accuracy);
+ } else {
+ this.report(sourceStart, sourceEnd, element, accuracy);
+ }
+ return;
+ }
+ } while (token != TerminalTokens.TokenNameEOF);
+
+ }
+ /**
+ * Finds the accurate positions of each valid token in the source and
+ * reports a reference to this token to the search requestor.
+ * A token is valid if it has an accurracy which is not -1.
+ */
+ public void reportAccurateReference(
+ int sourceStart,
+ int sourceEnd,
+ char[][] tokens,
+ IJavaElement element,
+ int[] accuracies)
+ throws CoreException {
+
+ // compute source positions of the qualified reference
+ Scanner scanner = this.parser.scanner;
+ scanner.setSource(
+ this.currentPotentialMatch.getContents());
+ scanner.resetTo(sourceStart, sourceEnd);
+
+ int refSourceStart = -1, refSourceEnd = -1;
+ int length = tokens.length;
+ int token = -1;
+ int previousValid = -1;
+ int i = 0;
+ int accuracyIndex = 0;
+ do {
+ int currentPosition = scanner.currentPosition;
+ // read token
+ try {
+ token = scanner.getNextToken();
+ } catch (InvalidInputException e) {
+ }
+ if (token != TerminalTokens.TokenNameEOF) {
+ char[] currentTokenSource = scanner.getCurrentTokenSource();
+ boolean equals = false;
+ while (i < length
+ && !(equals = this.pattern.matchesName(tokens[i++], currentTokenSource))) {
+ }
+ if (equals && (previousValid == -1 || previousValid == i - 2)) {
+ previousValid = i - 1;
+ if (refSourceStart == -1) {
+ refSourceStart = currentPosition;
+ }
+ refSourceEnd = scanner.currentPosition - 1;
+ } else {
+ i = 0;
+ refSourceStart = -1;
+ previousValid = -1;
+ }
+ // read '.'
+ try {
+ token = scanner.getNextToken();
+ } catch (InvalidInputException e) {
+ }
+ }
+ if (accuracies[accuracyIndex] != -1) {
+ // accept reference
+ if (refSourceStart != -1) {
+ this.report(refSourceStart, refSourceEnd, element, accuracies[accuracyIndex]);
+ } else {
+ this.report(sourceStart, sourceEnd, element, accuracies[accuracyIndex]);
+ }
+ i = 0;
+ }
+ refSourceStart = -1;
+ previousValid = -1;
+ if (accuracyIndex < accuracies.length-1) {
+ accuracyIndex++;
+ }
+ } while (token != TerminalTokens.TokenNameEOF);
+
+ }
+ public void reportBinaryMatch(
+ IMember binaryMember,
+ IBinaryType info,
+ int accuracy)
+ throws CoreException, JavaModelException {
+
+ this.reportBinaryMatch(null, binaryMember, info, accuracy);
+ }
+ public void reportBinaryMatch(
+ IResource resource,
+ IMember binaryMember,
+ IBinaryType info,
+ int accuracy)
+ throws CoreException, JavaModelException {
+ ISourceRange range = binaryMember.getNameRange();
+ if (range.getOffset() == -1) {
+ ClassFile classFile = (ClassFile) binaryMember.getClassFile();
+ SourceMapper mapper = classFile.getSourceMapper();
+ if (mapper != null) {
+ IType type = classFile.getType();
+ String sourceFileName = mapper.findSourceFileName(type, info);
+ if (sourceFileName != null) {
+ char[] contents = mapper.findSource(type, sourceFileName);
+ if (contents != null) {
+ range = mapper.mapSource(type, contents, binaryMember);
+ }
+ }
+ }
+ }
+ int startIndex = range.getOffset();
+ int endIndex = startIndex + range.getLength() - 1;
+ if (resource == null) {
+ this.report(startIndex, endIndex, binaryMember, accuracy);
+ } else {
+ this.report(resource, startIndex, endIndex, binaryMember, accuracy);
+ }
+ }
+ /**
+ * Reports the given field declaration to the search requestor.
+ */
+ public void reportFieldDeclaration(
+ FieldDeclaration fieldDeclaration,
+ IJavaElement parent,
+ int accuracy)
+ throws CoreException {
+
+ // accept field declaration
+ this.report(
+ fieldDeclaration.sourceStart,
+ fieldDeclaration.sourceEnd,
+ (parent instanceof IType) ?
+ ((IType)parent).getField(new String(fieldDeclaration.name)) :
+ parent,
+ accuracy);
+ }
+ /**
+ * Reports the given import to the search requestor.
+ */
+ public void reportImport(ImportReference reference, int accuracy)
+ throws CoreException {
+
+ // create defining import handle
+ IJavaElement importHandle = this.createImportHandle(reference);
+
+ // accept reference
+ this.pattern.matchReportImportRef(reference, null, importHandle, accuracy, this);
+ }
+ /**
+ * Reports the given method declaration to the search requestor.
+ */
+ public void reportMethodDeclaration(
+ AbstractMethodDeclaration methodDeclaration,
+ IJavaElement parent,
+ int accuracy)
+ throws CoreException {
+
+ IJavaElement enclosingElement;
+ if (parent instanceof IType) {
+ // create method handle
+ enclosingElement = this.createMethodHandle(methodDeclaration, (IType)parent);
+ if (enclosingElement == null) return;
+ } else {
+ enclosingElement = parent;
+ }
+
+ // compute source positions of the selector
+ Scanner scanner = parser.scanner;
+ int nameSourceStart = methodDeclaration.sourceStart;
+ scanner.setSource(
+ this.currentPotentialMatch.getContents());
+ scanner.resetTo(nameSourceStart, methodDeclaration.sourceEnd);
+ try {
+ scanner.getNextToken();
+ } catch (InvalidInputException e) {
+ }
+ int nameSourceEnd = scanner.currentPosition - 1;
+
+ // accept method declaration
+ this.report(nameSourceStart, nameSourceEnd, enclosingElement, accuracy);
+ }
+ /**
+ * Reports the given package declaration to the search requestor.
+ */
+ public void reportPackageDeclaration(ImportReference node) {
+ // TBD
+ }
+ /**
+ * Reports the given reference to the search requestor.
+ * It is done in the given method and the method's defining types
+ * have the given simple names.
+ */
+ public void reportReference(
+ AstNode reference,
+ AbstractMethodDeclaration methodDeclaration,
+ IJavaElement parent,
+ int accuracy)
+ throws CoreException {
+
+ IJavaElement enclosingElement;
+ if (parent instanceof IType) {
+ // create defining method handle
+ enclosingElement = this.createMethodHandle(methodDeclaration, (IType)parent);
+ if (enclosingElement == null) return; // case of a match found in a type other than the current class file
+ } else {
+ enclosingElement = parent;
+ }
+
+ // accept reference
+ this.pattern.matchReportReference(reference, enclosingElement, accuracy, this);
+ }
+ /**
+ * Reports the given reference to the search requestor.
+ * It is done in the given field and given type.
+ * The field's defining types have the given simple names.
+ */
+ public void reportReference(
+ AstNode reference,
+ TypeDeclaration typeDeclaration,
+ FieldDeclaration fieldDeclaration,
+ IJavaElement parent,
+ int accuracy)
+ throws CoreException {
+
+ IJavaElement enclosingElement;
+ if (fieldDeclaration.isField()) {
+ if (parent instanceof IType) {
+ // create defining field handle
+ enclosingElement = this.createFieldHandle(fieldDeclaration, (IType)parent);
+ if (enclosingElement == null) return;
+ } else {
+ enclosingElement = parent;
+ }
+
+ // accept reference
+ this.pattern.matchReportReference(reference, enclosingElement, accuracy, this);
+ } else { // initializer
+ if (parent instanceof IType) {
+ // create defining initializer
+ enclosingElement =
+ this.createInitializerHandle(
+ typeDeclaration,
+ fieldDeclaration,
+ (IType)parent);
+ if (enclosingElement == null) return;
+ } else {
+ enclosingElement = parent;
+ }
+
+ // accept reference
+ this.pattern.matchReportReference(reference, enclosingElement, accuracy, this);
+ }
+ }
+ /**
+ * Reports the given super type reference to the search requestor.
+ * It is done in the given defining type (with the given simple names).
+ */
+ public void reportSuperTypeReference(
+ TypeReference typeRef,
+ IJavaElement type,
+ int accuracy)
+ throws CoreException {
+
+ // accept type reference
+ this.pattern.matchReportReference(typeRef, type, accuracy, this);
+ }
+ /**
+ * Reports the given type declaration to the search requestor.
+ */
+ public void reportTypeDeclaration(
+ TypeDeclaration typeDeclaration,
+ IJavaElement parent,
+ int accuracy)
+ throws CoreException {
+
+ // accept class or interface declaration
+ this.report(
+ typeDeclaration.sourceStart,
+ typeDeclaration.sourceEnd,
+ (parent == null) ?
+ this.createTypeHandle(typeDeclaration.name) :
+ (parent instanceof IType) ?
+ this.createTypeHandle((IType)parent, typeDeclaration.name) :
+ parent,
+ accuracy);
+ }
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
index c31dafd..ffbc36e 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocatorParser.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import org.eclipse.core.resources.IFile;
@@ -145,6 +145,12 @@
this.matchSet.checkMatching(this.expressionStack[this.expressionPtr]);
}
}
+protected void consumePrimaryNoNewArray() {
+ // pop parenthesis positions (and don't update expression positions
+ // (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=23329)
+ intPtr--;
+ intPtr--;
+}
protected void consumeSingleTypeImportDeclarationName() {
super.consumeSingleTypeImportDeclarationName();
if (this.matchSet != null) {
@@ -187,14 +193,7 @@
&& unit != null && file != null) {
// potential matches were found while initializing the search pattern
// from the lookup environment: add the corresponding openable in the list
- MatchingOpenable matchingOpenable =
- new MatchingOpenable(
- locator,
- file,
- compilationUnit,
- unit,
- this.matchSet);
- locator.matchingOpenables.add(matchingOpenable);
+ locator.addMatchingOpenable(file, compilationUnit, unit, this.matchSet);
}
this.matchSet = null;
} else {
@@ -273,7 +272,9 @@
this.parse(constructorDeclaration, unit);
constructorDeclaration.traverse(localDeclarationVisitor, (ClassScope)null);
}
- }
+ } else if (method.isDefaultConstructor()) {
+ method.parseStatements(this, unit);
+ }
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchSet.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchSet.java
index 4c99f28..f443643 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchSet.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchSet.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.util.ArrayList;
@@ -18,6 +18,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
import org.eclipse.jdt.internal.compiler.AbstractSyntaxTreeVisitorAdapter;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
@@ -33,28 +34,32 @@
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
+import org.eclipse.jdt.internal.compiler.util.HashtableOfLong;
import org.eclipse.jdt.internal.core.Util;
/**
* A set of matches and potential matches.
*/
+// TODO: (jerome) Remove when switching to MatchLocator2
public class MatchSet {
- private MatchLocator locator;
+ MatchLocator locator;
int matchContainer;
boolean cuHasBeenResolved = false;
/**
* Set of matching ast nodes that don't need to be resolved.
*/
- private Map matchingNodes = new HashMap(5);
+ Map matchingNodes = new HashMap(5);
+ HashtableOfLong matchingNodesKeys = new HashtableOfLong(5);
/**
* Set of potential matching ast nodes. They need to be resolved
* to determine if they really match the search pattern.
*/
- private Map potentialMatchingNodes = new HashMap(5);
+ Map potentialMatchingNodes = new HashMap(5);
+ HashtableOfLong potentialMatchingNodesKeys = new HashtableOfLong(5);
/**
* An ast visitor that visits local type declarations.
@@ -73,7 +78,20 @@
}
public boolean visit(LocalTypeDeclaration typeDeclaration, BlockScope scope) {
try {
+ // check type declaration
+ Integer level;
+ if ((level = (Integer)matchingNodes.remove(typeDeclaration)) != null) {
+ locator.reportTypeDeclaration(
+ typeDeclaration,
+ enclosingElement,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+
+ // check inside type declaration
reportMatching(typeDeclaration, enclosingElement);
+
return false; // don't visit members as this was done during reportMatching(...)
} catch (CoreException e) {
throw new WrappedCoreException(e);
@@ -102,10 +120,34 @@
this.matchContainer = locator.pattern.matchContainer();
}
public void addPossibleMatch(AstNode node) {
+
+ // remove existing node at same position from set
+ // (case of recovery that created the same node several time
+ // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366)
+ long key = (((long) node.sourceStart) << 32) + node.sourceEnd;
+ AstNode existing = (AstNode)this.potentialMatchingNodesKeys.get(key);
+ if (existing != null && existing.getClass().equals(node.getClass())) {
+ this.potentialMatchingNodes.remove(existing);
+ }
+
+ // add node to set
this.potentialMatchingNodes.put(node, new Integer(SearchPattern.POSSIBLE_MATCH));
+ this.potentialMatchingNodesKeys.put(key, node);
}
public void addTrustedMatch(AstNode node) {
+
+ // remove existing node at same position from set
+ // (case of recovery that created the same node several time
+ // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366)
+ long key = (((long) node.sourceStart) << 32) + node.sourceEnd;
+ AstNode existing = (AstNode)this.matchingNodesKeys.get(key);
+ if (existing != null && existing.getClass().equals(node.getClass())) {
+ this.matchingNodes.remove(existing);
+ }
+
+ // add node to set
this.matchingNodes.put(node, new Integer(SearchPattern.ACCURATE_MATCH));
+ this.matchingNodesKeys.put(key, node);
}
public void checkMatching(AstNode node) {
this.locator.pattern.matchCheck(node, this);
@@ -158,9 +200,13 @@
return this.nodesInRange(start, end, this.potentialMatchingNodes);
}
public Integer removePossibleMatch(AstNode node) {
+ long key = (((long) node.sourceStart) << 32) + node.sourceEnd;
+ this.potentialMatchingNodesKeys.put(key, null);
return (Integer)this.potentialMatchingNodes.remove(node);
}
public Integer removeTrustedMatch(AstNode node) {
+ long key = (((long) node.sourceStart) << 32) + node.sourceEnd;
+ this.matchingNodesKeys.put(key, null);
return (Integer)this.matchingNodes.remove(node);
}
/**
@@ -168,23 +214,9 @@
* search pattern (ie. the ones in the matching nodes set)
* Note that the method declaration has already been checked.
*/
-private void reportMatching(AbstractMethodDeclaration method, IJavaElement parent) throws CoreException {
- // references in this method
- AstNode[] nodes = this.matchingNodes(method.declarationSourceStart, method.declarationSourceEnd);
- for (int i = 0; i < nodes.length; i++) {
- AstNode node = nodes[i];
- Integer level = (Integer)this.matchingNodes.get(node);
- if ((this.matchContainer & SearchPattern.METHOD) != 0) {
- this.locator.reportReference(
- node,
- method,
- parent,
- level.intValue() == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
- this.matchingNodes.remove(node);
- }
- }
+private void reportMatching(AbstractMethodDeclaration method, IJavaElement parent, boolean typeInHierarchy) throws CoreException {
+ // declaration in this method
+ // (NB: declarations must be searched first (see bug 20631 Declaration of local binary type not found)
if ((method.bits & AstNode.HasLocalTypeMASK) != 0) {
LocalDeclarationVisitor localDeclarationVisitor = new LocalDeclarationVisitor();
localDeclarationVisitor.enclosingElement =
@@ -197,6 +229,25 @@
throw e.coreException;
}
}
+
+ // references in this method
+ if (typeInHierarchy) {
+ AstNode[] nodes = this.matchingNodes(method.declarationSourceStart, method.declarationSourceEnd);
+ for (int i = 0; i < nodes.length; i++) {
+ AstNode node = nodes[i];
+ Integer level = (Integer)this.matchingNodes.get(node);
+ if ((this.matchContainer & SearchPattern.METHOD) != 0) {
+ this.locator.reportReference(
+ node,
+ method,
+ parent,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.matchingNodes.remove(node);
+ }
+ }
+ }
if (this.potentialMatchingNodes(method.declarationSourceStart, method.declarationSourceEnd).length == 0) {
// no need to resolve the statements in the method
method.statements = null;
@@ -214,6 +265,10 @@
int level;
if (node instanceof ImportReference) {
// special case for import refs: they don't know their binding
+
+ // import ref cannot be in the hirarchy of a type
+ if (this.locator.hierarchyResolver != null) continue;
+
ImportReference importRef = (ImportReference)node;
Binding binding;
if (importRef.onDemand) {
@@ -297,21 +352,23 @@
* search pattern (ie. the ones in the matching nodes set)
* Note that the field declaration has already been checked.
*/
-private void reportMatching(FieldDeclaration field, IJavaElement parent, TypeDeclaration type) throws CoreException {
- AstNode[] nodes = this.matchingNodes(field.declarationSourceStart, field.declarationSourceEnd);
- for (int i = 0; i < nodes.length; i++) {
- AstNode node = nodes[i];
- Integer level = (Integer)this.matchingNodes.get(node);
- if ((this.matchContainer & SearchPattern.FIELD) != 0) {
- this.locator.reportReference(
- node,
- type,
- field,
- parent,
- level.intValue() == SearchPattern.ACCURATE_MATCH ?
- IJavaSearchResultCollector.EXACT_MATCH :
- IJavaSearchResultCollector.POTENTIAL_MATCH);
- this.matchingNodes.remove(node);
+private void reportMatching(FieldDeclaration field, IJavaElement parent, TypeDeclaration type, boolean typeInHierarchy) throws CoreException {
+ if (typeInHierarchy) {
+ AstNode[] nodes = this.matchingNodes(field.declarationSourceStart, field.declarationSourceEnd);
+ for (int i = 0; i < nodes.length; i++) {
+ AstNode node = nodes[i];
+ Integer level = (Integer)this.matchingNodes.get(node);
+ if ((this.matchContainer & SearchPattern.FIELD) != 0) {
+ this.locator.reportReference(
+ node,
+ type,
+ field,
+ parent,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.matchingNodes.remove(node);
+ }
}
}
if ((field.bits & AstNode.HasLocalTypeMASK) != 0) {
@@ -323,7 +380,7 @@
(IJavaElement)this.locator.createInitializerHandle(type, field, (IType)parent)) :
parent;
try {
- field.traverse(localDeclarationVisitor, (BlockScope)null);
+ field.traverse(localDeclarationVisitor, (MethodScope)null);
} catch (WrappedCoreException e) {
throw e.coreException;
}
@@ -335,6 +392,14 @@
* Note that the type declaration has already been checked.
*/
public void reportMatching(TypeDeclaration type, IJavaElement parent) throws CoreException {
+
+ // filter out element not in hierarchy scope
+ boolean typeInHierarchy =
+ this.locator.hierarchyResolver == null
+ || type.binding == null
+ || this.locator.hierarchyResolver.subOrSuperOfFocus(type.binding);
+
+ // create type handle
IJavaElement enclosingElement;
if (parent == null) {
enclosingElement = this.locator.createTypeHandle(type.name);
@@ -351,17 +416,17 @@
if (fields != null) {
for (int i = 0; i < fields.length; i++) {
FieldDeclaration field = fields[i];
- if ((level = (Integer)this.matchingNodes.remove(field)) != null) {
- if ((this.matchContainer & SearchPattern.CLASS) != 0) {
+ if ((level = (Integer)this.matchingNodes.remove(field)) != null
+ && typeInHierarchy
+ && (this.matchContainer & SearchPattern.CLASS) != 0) {
this.locator.reportFieldDeclaration(
field,
enclosingElement,
level.intValue() == SearchPattern.ACCURATE_MATCH ?
IJavaSearchResultCollector.EXACT_MATCH :
IJavaSearchResultCollector.POTENTIAL_MATCH);
- }
}
- this.reportMatching(field, enclosingElement, type);
+ this.reportMatching(field, enclosingElement, type, typeInHierarchy);
}
}
@@ -370,17 +435,17 @@
if (methods != null) {
for (int i = 0; i < methods.length; i++) {
AbstractMethodDeclaration method = methods[i];
- if ((level = (Integer)this.matchingNodes.remove(method)) != null) {
- if ((this.matchContainer & SearchPattern.CLASS) != 0) {
+ if ((level = (Integer)this.matchingNodes.remove(method)) != null
+ && typeInHierarchy
+ && (this.matchContainer & SearchPattern.CLASS) != 0) {
this.locator.reportMethodDeclaration(
method,
enclosingElement,
level.intValue() == SearchPattern.ACCURATE_MATCH ?
IJavaSearchResultCollector.EXACT_MATCH :
IJavaSearchResultCollector.POTENTIAL_MATCH);
- }
}
- this.reportMatching(method, enclosingElement);
+ this.reportMatching(method, enclosingElement, typeInHierarchy);
}
}
@@ -389,15 +454,15 @@
if (memberTypes != null) {
for (int i = 0; i < memberTypes.length; i++) {
MemberTypeDeclaration memberType = memberTypes[i];
- if ((level = (Integer)this.matchingNodes.remove(memberType)) != null) {
- if ((this.matchContainer & SearchPattern.CLASS) != 0) {
+ if ((level = (Integer)this.matchingNodes.remove(memberType)) != null
+ && typeInHierarchy
+ && (this.matchContainer & SearchPattern.CLASS) != 0) {
this.locator.reportTypeDeclaration(
memberType,
enclosingElement,
level.intValue() == SearchPattern.ACCURATE_MATCH ?
IJavaSearchResultCollector.EXACT_MATCH :
IJavaSearchResultCollector.POTENTIAL_MATCH);
- }
}
this.reportMatching(memberType, enclosingElement);
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchingNodeSet.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchingNodeSet.java
new file mode 100644
index 0000000..e51afaa
--- /dev/null
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchingNodeSet.java
@@ -0,0 +1,568 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.search.matching;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
+import org.eclipse.jdt.internal.compiler.AbstractSyntaxTreeVisitorAdapter;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.AnonymousLocalTypeDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.AstNode;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
+import org.eclipse.jdt.internal.compiler.ast.LocalTypeDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.MemberTypeDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
+import org.eclipse.jdt.internal.compiler.util.HashtableOfLong;
+import org.eclipse.jdt.internal.core.Util;
+
+/**
+ * A set of matches and potential matches.
+ */
+public class MatchingNodeSet extends MatchSet { // TODO: (jerome) remove extends
+
+ MatchLocator2 locator;
+ int matchContainer;
+ boolean cuHasBeenResolved = false;
+
+ /**
+ * Set of matching ast nodes that don't need to be resolved.
+ */
+ Map matchingNodes = new HashMap(5);
+ HashtableOfLong matchingNodesKeys = new HashtableOfLong(5);
+
+ /**
+ * Set of potential matching ast nodes. They need to be resolved
+ * to determine if they really match the search pattern.
+ */
+ Map potentialMatchingNodes = new HashMap(5);
+ HashtableOfLong potentialMatchingNodesKeys = new HashtableOfLong(5);
+
+/**
+ * An ast visitor that visits local type declarations.
+ */
+public class LocalDeclarationVisitor extends AbstractSyntaxTreeVisitorAdapter {
+ IJavaElement enclosingElement;
+ public boolean visit(
+ AnonymousLocalTypeDeclaration anonymousTypeDeclaration,
+ BlockScope scope) {
+ try {
+ reportMatching(anonymousTypeDeclaration, enclosingElement);
+ } catch (CoreException e) {
+ throw new WrappedCoreException(e);
+ }
+ return false; // don't visit members as this was done during reportMatching(...)
+ }
+ public boolean visit(LocalTypeDeclaration typeDeclaration, BlockScope scope) {
+ try {
+ // check type declaration
+ Integer level;
+ if ((level = (Integer)matchingNodes.remove(typeDeclaration)) != null) {
+ locator.reportTypeDeclaration(
+ typeDeclaration,
+ enclosingElement,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+
+ // check inside type declaration
+ reportMatching(typeDeclaration, enclosingElement);
+
+ return false; // don't visit members as this was done during reportMatching(...)
+ } catch (CoreException e) {
+ throw new WrappedCoreException(e);
+ }
+ }
+ public boolean visit(MemberTypeDeclaration typeDeclaration, ClassScope scope) {
+ try {
+ reportMatching(typeDeclaration, enclosingElement);
+ return false; // don't visit members as this was done during reportMatching(...)
+ } catch (CoreException e) {
+ throw new WrappedCoreException(e);
+ }
+ }
+
+}
+
+public class WrappedCoreException extends RuntimeException {
+ public CoreException coreException;
+ public WrappedCoreException(CoreException coreException) {
+ this.coreException = coreException;
+ }
+}
+
+public MatchingNodeSet(MatchLocator2 locator) {
+ super(locator);
+ this.locator = locator;
+ this.matchContainer = locator.pattern.matchContainer();
+}
+public void addPossibleMatch(AstNode node) {
+
+ // remove existing node at same position from set
+ // (case of recovery that created the same node several time
+ // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366)
+ long key = (((long) node.sourceStart) << 32) + node.sourceEnd;
+ AstNode existing = (AstNode)this.potentialMatchingNodesKeys.get(key);
+ if (existing != null && existing.getClass().equals(node.getClass())) {
+ this.potentialMatchingNodes.remove(existing);
+ }
+
+ // add node to set
+ this.potentialMatchingNodes.put(node, new Integer(SearchPattern.POSSIBLE_MATCH));
+ this.potentialMatchingNodesKeys.put(key, node);
+}
+public void addTrustedMatch(AstNode node) {
+
+ // remove existing node at same position from set
+ // (case of recovery that created the same node several time
+ // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366)
+ long key = (((long) node.sourceStart) << 32) + node.sourceEnd;
+ AstNode existing = (AstNode)this.matchingNodesKeys.get(key);
+ if (existing != null && existing.getClass().equals(node.getClass())) {
+ this.matchingNodes.remove(existing);
+ }
+
+ // add node to set
+ this.matchingNodes.put(node, new Integer(SearchPattern.ACCURATE_MATCH));
+ this.matchingNodesKeys.put(key, node);
+}
+public void checkMatching(AstNode node) {
+ this.locator.pattern.matchCheck(node, this);
+}
+public boolean isEmpty() {
+ return
+ this.potentialMatchingNodes.size() == 0
+ && this.matchingNodes.size() == 0;
+}
+/**
+ * Returns the matching nodes that are in the given range.
+ */
+private AstNode[] matchingNodes(int start, int end) {
+ return this.nodesInRange(start, end, this.matchingNodes);
+}
+public boolean needsResolve() {
+ return this.potentialMatchingNodes.size() > 0;
+}
+/**
+ * Returns the matching nodes that are in the given range in the source order.
+ */
+private AstNode[] nodesInRange(int start, int end, Map set) {
+ // collect nodes in the given range
+ ArrayList nodes = new ArrayList();
+ for (Iterator keys = set.keySet().iterator(); keys.hasNext();) {
+ AstNode node = (AstNode)keys.next();
+ if (start <= node.sourceStart && node.sourceEnd <= end) {
+ nodes.add(node);
+ }
+ }
+ AstNode[] result = new AstNode[nodes.size()];
+ nodes.toArray(result);
+
+ // sort nodes by source starts
+ Util.Comparer comparer = new Util.Comparer() {
+ public int compare(Object o1, Object o2) {
+ AstNode node1 = (AstNode) o1;
+ AstNode node2 = (AstNode) o2;
+ return node1.sourceStart - node2.sourceStart;
+ }
+ };
+ Util.sort(result, comparer);
+
+ return result;
+}
+/**
+ * Returns the potential matching nodes that are in the given range.
+ */
+private AstNode[] potentialMatchingNodes(int start, int end) {
+ return this.nodesInRange(start, end, this.potentialMatchingNodes);
+}
+public Integer removePossibleMatch(AstNode node) {
+ long key = (((long) node.sourceStart) << 32) + node.sourceEnd;
+ this.potentialMatchingNodesKeys.put(key, null);
+ return (Integer)this.potentialMatchingNodes.remove(node);
+}
+public Integer removeTrustedMatch(AstNode node) {
+ long key = (((long) node.sourceStart) << 32) + node.sourceEnd;
+ this.matchingNodesKeys.put(key, null);
+ return (Integer)this.matchingNodes.remove(node);
+}
+/**
+ * Visit the given method declaration and report the nodes that match exactly the
+ * search pattern (ie. the ones in the matching nodes set)
+ * Note that the method declaration has already been checked.
+ */
+private void reportMatching(AbstractMethodDeclaration method, IJavaElement parent, boolean typeInHierarchy) throws CoreException {
+ // declaration in this method
+ // (NB: declarations must be searched first (see bug 20631 Declaration of local binary type not found)
+ if ((method.bits & AstNode.HasLocalTypeMASK) != 0) {
+ LocalDeclarationVisitor localDeclarationVisitor = new LocalDeclarationVisitor();
+ localDeclarationVisitor.enclosingElement =
+ (parent instanceof IType) ?
+ this.locator.createMethodHandle(method, (IType)parent) :
+ parent;
+ try {
+ method.traverse(localDeclarationVisitor, (ClassScope)null);
+ } catch (WrappedCoreException e) {
+ throw e.coreException;
+ }
+ }
+
+ // references in this method
+ if (typeInHierarchy) {
+ AstNode[] nodes = this.matchingNodes(method.declarationSourceStart, method.declarationSourceEnd);
+ for (int i = 0; i < nodes.length; i++) {
+ AstNode node = nodes[i];
+ Integer level = (Integer)this.matchingNodes.get(node);
+ if ((this.matchContainer & SearchPattern.METHOD) != 0) {
+ this.locator.reportReference(
+ node,
+ method,
+ parent,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.matchingNodes.remove(node);
+ }
+ }
+ }
+ if (this.potentialMatchingNodes(method.declarationSourceStart, method.declarationSourceEnd).length == 0) {
+ // no need to resolve the statements in the method
+ method.statements = null;
+ }
+}
+/**
+ * Visit the given parse tree and report the nodes that match exactly the
+ * search pattern.
+ */
+public void reportMatching(CompilationUnitDeclaration unit) throws CoreException {
+ if (this.cuHasBeenResolved) {
+ // move the potential matching nodes that exactly match the search pattern to the matching nodes set
+ for (Iterator potentialMatches = this.potentialMatchingNodes.keySet().iterator(); potentialMatches.hasNext();) {
+ AstNode node = (AstNode) potentialMatches.next();
+ int level;
+ if (node instanceof ImportReference) {
+ // special case for import refs: they don't know their binding
+
+ // import ref cannot be in the hirarchy of a type
+ if (this.locator.hierarchyResolver != null) continue;
+
+ ImportReference importRef = (ImportReference)node;
+ Binding binding;
+ if (importRef.onDemand) {
+ binding = unit.scope.getTypeOrPackage(CharOperation.subarray(importRef.tokens, 0, importRef.tokens.length));
+ } else {
+ binding = unit.scope.getTypeOrPackage(importRef.tokens);
+ }
+ level = this.locator.pattern.matchLevel(binding);
+
+ if (level == SearchPattern.ACCURATE_MATCH || level == SearchPattern.INACCURATE_MATCH) {
+ // create defining import handle
+ IJavaElement importHandle = this.locator.createImportHandle(importRef);
+ this.locator.pattern.matchReportImportRef(
+ importRef,
+ binding,
+ importHandle,
+ level == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH,
+ this.locator);
+ }
+ } else {
+ level = this.locator.pattern.matchLevel(node, true);
+ if (level == SearchPattern.ACCURATE_MATCH || level == SearchPattern.INACCURATE_MATCH) {
+ this.matchingNodes.put(node, new Integer(level));
+ }
+ }
+ }
+ this.potentialMatchingNodes = new HashMap();
+ }
+
+ // package declaration
+ ImportReference pkg = unit.currentPackage;
+ Integer level;
+ if (pkg != null && (level = (Integer)this.matchingNodes.remove(pkg)) != null) {
+ if ((this.matchContainer & SearchPattern.COMPILATION_UNIT) != 0) {
+ this.locator.reportPackageDeclaration(pkg);
+ }
+ }
+
+ // import declarations
+ if (!this.cuHasBeenResolved) {
+ ImportReference[] imports = unit.imports;
+ if (imports != null) {
+ for (int i = 0; i < imports.length; i++) {
+ ImportReference importRef = imports[i];
+ if ((level = (Integer)this.matchingNodes.remove(importRef)) != null) {
+ if ((this.matchContainer & SearchPattern.COMPILATION_UNIT) != 0) {
+ this.locator.reportImport(
+ importRef,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+ }
+ }
+ }
+ } // else import declarations have already been processed above
+
+ // types
+ TypeDeclaration[] types = unit.types;
+ if (types != null) {
+ for (int i = 0; i < types.length; i++) {
+ TypeDeclaration type = types[i];
+ if ((level = (Integer)this.matchingNodes.remove(type)) != null) {
+ if ((this.matchContainer & SearchPattern.COMPILATION_UNIT) != 0) {
+ this.locator.reportTypeDeclaration(
+ type,
+ null,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+ }
+ this.reportMatching(type, null);
+ }
+ }
+}
+/**
+ * Visit the given field declaration and report the nodes that match exactly the
+ * search pattern (ie. the ones in the matching nodes set)
+ * Note that the field declaration has already been checked.
+ */
+private void reportMatching(FieldDeclaration field, IJavaElement parent, TypeDeclaration type, boolean typeInHierarchy) throws CoreException {
+ if (typeInHierarchy) {
+ AstNode[] nodes = this.matchingNodes(field.declarationSourceStart, field.declarationSourceEnd);
+ for (int i = 0; i < nodes.length; i++) {
+ AstNode node = nodes[i];
+ Integer level = (Integer)this.matchingNodes.get(node);
+ if ((this.matchContainer & SearchPattern.FIELD) != 0) {
+ this.locator.reportReference(
+ node,
+ type,
+ field,
+ parent,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ this.matchingNodes.remove(node);
+ }
+ }
+ }
+ if ((field.bits & AstNode.HasLocalTypeMASK) != 0) {
+ LocalDeclarationVisitor localDeclarationVisitor = new LocalDeclarationVisitor();
+ localDeclarationVisitor.enclosingElement =
+ (parent instanceof IType) ?
+ (field.isField() ?
+ (IJavaElement)this.locator.createFieldHandle(field, (IType)parent) :
+ (IJavaElement)this.locator.createInitializerHandle(type, field, (IType)parent)) :
+ parent;
+ try {
+ field.traverse(localDeclarationVisitor, (MethodScope)null);
+ } catch (WrappedCoreException e) {
+ throw e.coreException;
+ }
+ }
+}
+/**
+ * Visit the given type declaration and report the nodes that match exactly the
+ * search pattern (ie. the ones in the matching nodes set)
+ * Note that the type declaration has already been checked.
+ */
+public void reportMatching(TypeDeclaration type, IJavaElement parent) throws CoreException {
+
+ // filter out element not in hierarchy scope
+ boolean typeInHierarchy =
+ this.locator.hierarchyResolver == null
+ || type.binding == null
+ || this.locator.hierarchyResolver.subOrSuperOfFocus(type.binding);
+
+ // create type handle
+ IJavaElement enclosingElement;
+ if (parent == null) {
+ enclosingElement = this.locator.createTypeHandle(type.name);
+ } else if (parent instanceof IType) {
+ enclosingElement = this.locator.createTypeHandle((IType)parent, type.name);
+ if (enclosingElement == null) return;
+ } else {
+ enclosingElement = parent;
+ }
+ Integer level;
+
+ // fields
+ FieldDeclaration[] fields = type.fields;
+ if (fields != null) {
+ for (int i = 0; i < fields.length; i++) {
+ FieldDeclaration field = fields[i];
+ if ((level = (Integer)this.matchingNodes.remove(field)) != null
+ && typeInHierarchy
+ && (this.matchContainer & SearchPattern.CLASS) != 0) {
+ this.locator.reportFieldDeclaration(
+ field,
+ enclosingElement,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+ this.reportMatching(field, enclosingElement, type, typeInHierarchy);
+ }
+ }
+
+ // methods
+ AbstractMethodDeclaration[] methods = type.methods;
+ if (methods != null) {
+ for (int i = 0; i < methods.length; i++) {
+ AbstractMethodDeclaration method = methods[i];
+ if ((level = (Integer)this.matchingNodes.remove(method)) != null
+ && typeInHierarchy
+ && (this.matchContainer & SearchPattern.CLASS) != 0) {
+ this.locator.reportMethodDeclaration(
+ method,
+ enclosingElement,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+ this.reportMatching(method, enclosingElement, typeInHierarchy);
+ }
+ }
+
+ // member types
+ MemberTypeDeclaration[] memberTypes = type.memberTypes;
+ if (memberTypes != null) {
+ for (int i = 0; i < memberTypes.length; i++) {
+ MemberTypeDeclaration memberType = memberTypes[i];
+ if ((level = (Integer)this.matchingNodes.remove(memberType)) != null
+ && typeInHierarchy
+ && (this.matchContainer & SearchPattern.CLASS) != 0) {
+ this.locator.reportTypeDeclaration(
+ memberType,
+ enclosingElement,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+ this.reportMatching(memberType, enclosingElement);
+ }
+ }
+
+ // super types
+ if (type instanceof AnonymousLocalTypeDeclaration) {
+ TypeReference superType = ((AnonymousLocalTypeDeclaration)type).allocation.type;
+ if (superType != null && (level = (Integer)this.matchingNodes.remove(superType)) != null) {
+ if ((this.matchContainer & SearchPattern.CLASS) != 0) {
+ this.locator.reportSuperTypeReference(
+ superType,
+ enclosingElement,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+ }
+ } else {
+ TypeReference superClass = type.superclass;
+ if (superClass != null && (level = (Integer)this.matchingNodes.remove(superClass)) != null) {
+ if ((this.matchContainer & SearchPattern.CLASS) != 0) {
+ this.locator.reportSuperTypeReference(
+ superClass,
+ enclosingElement,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+ }
+ TypeReference[] superInterfaces = type.superInterfaces;
+ if (superInterfaces != null) {
+ for (int i = 0; i < superInterfaces.length; i++) {
+ TypeReference superInterface = superInterfaces[i];
+ if ((level = (Integer)this.matchingNodes.get(superInterface)) != null) {
+ if ((this.matchContainer & SearchPattern.CLASS) != 0) {
+ this.locator.reportSuperTypeReference(
+ superInterface,
+ enclosingElement,
+ level.intValue() == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+ }
+ }
+ }
+ }
+}
+public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append("Exact matches:"); //$NON-NLS-1$
+ for (Iterator iter = this.matchingNodes.keySet().iterator(); iter.hasNext();) {
+ result.append("\n"); //$NON-NLS-1$
+ AstNode node = (AstNode)iter.next();
+ Object value = this.matchingNodes.get(node);
+ if (value instanceof Integer) {
+ result.append('\t');
+ int accuracy = ((Integer)value).intValue();
+ switch (accuracy) {
+ case SearchPattern.IMPOSSIBLE_MATCH:
+ result.append("IMPOSSIBLE_MATCH: "); //$NON-NLS-1$
+ break;
+ case SearchPattern.POSSIBLE_MATCH:
+ result.append("POSSIBLE_MATCH: "); //$NON-NLS-1$
+ break;
+ case SearchPattern.INACCURATE_MATCH:
+ result.append("INACCURATE_MATCH: "); //$NON-NLS-1$
+ break;
+ case SearchPattern.ACCURATE_MATCH:
+ result.append("ACCURATE_MATCH: "); //$NON-NLS-1$
+ break;
+ }
+ }
+ result.append(node.toString(0));
+ }
+ result.append("\nPotential matches:"); //$NON-NLS-1$
+ for (Iterator iter = this.potentialMatchingNodes.keySet().iterator(); iter.hasNext();) {
+ result.append("\n"); //$NON-NLS-1$
+ AstNode node = (AstNode)iter.next();
+ Object value = this.potentialMatchingNodes.get(node);
+ if (value instanceof Integer) {
+ result.append("\t"); //$NON-NLS-1$
+ int accuracy = ((Integer)value).intValue();
+ switch (accuracy) {
+ case SearchPattern.IMPOSSIBLE_MATCH:
+ result.append("IMPOSSIBLE_MATCH: "); //$NON-NLS-1$
+ break;
+ case SearchPattern.POSSIBLE_MATCH:
+ result.append("POSSIBLE_MATCH: "); //$NON-NLS-1$
+ break;
+ case SearchPattern.INACCURATE_MATCH:
+ result.append("INACCURATE_MATCH: "); //$NON-NLS-1$
+ break;
+ case SearchPattern.ACCURATE_MATCH:
+ result.append("ACCURATE_MATCH: "); //$NON-NLS-1$
+ break;
+ }
+ }
+ result.append(node.toString(0));
+ }
+ return result.toString();
+}
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchingOpenable.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchingOpenable.java
index 5d545d0..c596508 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchingOpenable.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchingOpenable.java
@@ -1,57 +1,41 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IBuffer;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.env.IBinaryField;
import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
-import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
-import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-import org.eclipse.jdt.internal.core.BinaryType;
-import org.eclipse.jdt.internal.core.CompilationUnit;
-import org.eclipse.jdt.internal.core.Openable;
-import org.eclipse.jdt.internal.core.Util;
-import org.eclipse.jdt.internal.core.WorkingCopy;
+import org.eclipse.jdt.internal.core.*;
+// TODO: (jerome) Remove when switching to MatchLocator2
public class MatchingOpenable {
+ static final CompilationUnitDeclaration ALREADY_RESOLVED = new CompilationUnitDeclaration(null, null, 0);
private MatchLocator locator;
public IResource resource;
public Openable openable;
private CompilationUnitDeclaration parsedUnit;
+ private char[] source;
private MatchSet matchSet;
- public boolean shouldResolve = true;
-public MatchingOpenable(MatchLocator locator, IResource resource, Openable openable) {
- this.locator = locator;
- this.resource = resource;
- this.openable = openable;
-}
+
public MatchingOpenable(
MatchLocator locator,
IResource resource,
@@ -64,30 +48,44 @@
this.parsedUnit = parsedUnit;
this.matchSet = matchSet;
}
+public static IType getTopLevelType(IType binaryType) {
+
+ // ensure it is not a local or anoymous type (see bug 28752 J Search resports non-existent Java element)
+ String typeName = binaryType.getElementName();
+ int lastDollar = typeName.lastIndexOf('$');
+ int length = typeName.length();
+ if (lastDollar != -1 && lastDollar < length-1) {
+ if (Character.isDigit(typeName.charAt(lastDollar+1))) {
+ // local or anonymous type
+ typeName = typeName.substring(0, lastDollar);
+ IClassFile classFile = binaryType.getPackageFragment().getClassFile(typeName+".class"); //$NON-NLS-1$
+ try {
+ binaryType = classFile.getType();
+ } catch (JavaModelException e) {
+ // ignore as implementation of getType() cannot throw this exception
+ }
+ }
+ }
+
+ // ensure it is a top level type
+ IType declaringType = binaryType.getDeclaringType();
+ while (declaringType != null) {
+ binaryType = declaringType;
+ declaringType = binaryType.getDeclaringType();
+ }
+ return binaryType;
+}
public void buildTypeBindings() {
- // if a parsed unit exits, its bindings have already been built
- if (this.parsedUnit != null) return;
-
- char[] source = this.getSource();
- if (source == null) return;
- this.buildTypeBindings(source);
-
- if (this.openable instanceof org.eclipse.jdt.internal.core.ClassFile) {
- // try to use the main type's class file as the openable
- TypeDeclaration[] types = this.parsedUnit.types;
- if (types != null) {
- String classFileName = openable.getElementName();
- for (int i = 0, length = types.length; i < length; i++) {
- TypeDeclaration typeDeclaration = types[i];
- String simpleTypeName = new String(typeDeclaration.name);
- if (classFileName.startsWith(simpleTypeName)) {
- IPackageFragment parent = (IPackageFragment)openable.getParent();
- this.openable = (Openable)parent.getClassFile(simpleTypeName + ".class"); //$NON-NLS-1$
- break;
- }
- }
- }
+ if (this.parsedUnit == null) {
+ char[] source = this.getSource();
+ if (source == null) return;
+ this.buildTypeBindings(source);
+ } else {
+ // if a parsed unit's scope is set, its bindings have already been built
+ if (this.parsedUnit.scope != null) return;
+
+ this.locator.lookupEnvironment.buildTypeBindings(this.parsedUnit);
}
}
private void buildTypeBindings(final char[] source) {
@@ -108,14 +106,20 @@
// initial type binding creation
this.locator.lookupEnvironment.buildTypeBindings(this.parsedUnit);
- } else {
- // free memory
- this.locator.parsedUnits.put(qualifiedName, null);
- }
+ }
+
+ // free memory and remember that this unit as already been resolved
+ // (case of 2 matching openables on a binary type and its member type)
+ this.locator.parsedUnits.put(qualifiedName, ALREADY_RESOLVED);
+
} finally {
this.locator.parser.matchSet = null;
}
}
+public boolean equals(Object obj) {
+ if (!(obj instanceof MatchingOpenable)) return false;
+ return this.openable.equals(((MatchingOpenable)obj).openable);
+}
private char[] getQualifiedName() {
if (this.openable instanceof CompilationUnit) {
// get file name
@@ -127,29 +131,32 @@
} else {
org.eclipse.jdt.internal.core.ClassFile classFile = (org.eclipse.jdt.internal.core.ClassFile)this.openable;
try {
- return classFile.getType().getFullyQualifiedName().toCharArray();
+ IType type = getTopLevelType(classFile.getType());
+ return type.getFullyQualifiedName().toCharArray();
} catch (JavaModelException e) {
return null; // nothing we can do here
}
}
}
public char[] getSource() {
+ if (this.source != null) return source;
try {
if (this.openable instanceof WorkingCopy) {
IBuffer buffer = this.openable.getBuffer();
if (buffer == null) return null;
- return buffer.getCharacters();
+ this.source = buffer.getCharacters();
} else if (this.openable instanceof CompilationUnit) {
- return Util.getResourceContentsAsCharArray((IFile)this.resource);
+ this.source = Util.getResourceContentsAsCharArray((IFile)this.resource);
} else if (this.openable instanceof org.eclipse.jdt.internal.core.ClassFile) {
org.eclipse.jdt.internal.core.ClassFile classFile = (org.eclipse.jdt.internal.core.ClassFile)this.openable;
- return this.locator.findSource(classFile);
- } else {
- return null;
+ this.source = this.locator.findSource(classFile);
}
} catch (JavaModelException e) {
- return null;
}
+ return this.source;
+}
+public int hashCode() {
+ return this.openable.hashCode();
}
public boolean hasAlreadyDefinedType() {
if (this.parsedUnit == null) return false;
@@ -194,18 +201,15 @@
// resolve
BinaryTypeBinding binding = null;
try {
- binding = this.locator.lookupEnvironment.cacheBinaryType(info);
- if (binding == null) { // it was already cached as a result of a previous query
- char[][] compoundName = CharOperation.splitOn('.', binaryType.getFullyQualifiedName().toCharArray());
- ReferenceBinding referenceBinding = this.locator.lookupEnvironment.getCachedType(compoundName);
- if (referenceBinding != null && (referenceBinding instanceof BinaryTypeBinding)) {
- // if the binding could be found and if it comes from a source type,
- binding = (BinaryTypeBinding)referenceBinding;
- }
- }
-
- // check methods
+ binding = this.locator.cacheBinaryType(binaryType);
if (binding != null) {
+ // filter out element not in hierarchy scope
+ if (this.locator.hierarchyResolver != null
+ && !this.locator.hierarchyResolver.subOrSuperOfFocus(binding)) {
+ return;
+ }
+
+ // check methods
MethodBinding[] methods = binding.methods();
for (int i = 0; i < methods.length; i++) {
MethodBinding method = methods[i];
@@ -228,10 +232,8 @@
IJavaSearchResultCollector.POTENTIAL_MATCH);
}
}
- }
- // check fields
- if (binding != null) {
+ // check fields
FieldBinding[] fields = binding.fields();
for (int i = 0; i < fields.length; i++) {
FieldBinding field = fields[i];
@@ -302,7 +304,7 @@
this.parsedUnit = this.locator.dietParse(source);
}
}
- if (this.parsedUnit != null) {
+ if (this.parsedUnit != null && this.parsedUnit != ALREADY_RESOLVED) {
try {
this.locator.parser.matchSet = this.matchSet;
this.locator.parser.scanner.setSource(source);
@@ -312,38 +314,36 @@
this.matchSet.reportMatching(parsedUnit);
// resolve if needed
- if (this.matchSet.needsResolve()) {
- if (this.parsedUnit.types != null) {
- if (this.shouldResolve) {
- try {
- if (this.parsedUnit.scope == null) {
- // bindings were not created (case of a FieldReferencePattern that doesn't need resolve,
- // but we need to resolve because of a SingleNameReference being a potential match)
- this.locator.lookupEnvironment.buildTypeBindings(this.parsedUnit);
- this.locator.lookupEnvironment.completeTypeBindings(this.parsedUnit, true);
- }
- if (this.parsedUnit.scope != null) {
- this.parsedUnit.scope.faultInTypes();
- this.parsedUnit.resolve();
- }
- // report matches that needed resolve
- this.matchSet.cuHasBeenResolved = true;
- this.matchSet.reportMatching(this.parsedUnit);
- } catch (AbortCompilation e) {
- // could not resolve: report innacurate matches
- this.matchSet.cuHasBeenResolved = true;
- this.matchSet.reportMatching(this.parsedUnit);
- if (!(e instanceof AbortCompilationUnit)) {
- // problem with class path
- throw e;
- }
+ if (this.matchSet.needsResolve() && this.parsedUnit.types != null) {
+ if (!this.locator.compilationAborted) {
+ try {
+ if (this.parsedUnit.scope == null) {
+ // bindings were not created (case of a FieldReferencePattern that doesn't need resolve,
+ // but we need to resolve because of a SingleNameReference being a potential match)
+ MatchingOpenable[] openables = this.locator.matchingOpenables.getMatchingOpenables(this.openable.getJavaProject().getPackageFragmentRoots());
+ this.locator.createAndResolveBindings(openables);
}
- } else {
- // problem ocured while completing the bindings for the base classes
- // -> report innacurate matches
+ if (this.parsedUnit.scope != null) {
+ this.parsedUnit.scope.faultInTypes();
+ this.parsedUnit.resolve();
+ }
+ // report matches that needed resolve
this.matchSet.cuHasBeenResolved = true;
this.matchSet.reportMatching(this.parsedUnit);
+ } catch (AbortCompilation e) {
+ // could not resolve: report innacurate matches
+ this.matchSet.cuHasBeenResolved = true;
+ this.matchSet.reportMatching(this.parsedUnit);
+ if (!(e instanceof AbortCompilationUnit)) {
+ // problem with class path
+ throw e;
+ }
}
+ } else {
+ // problem ocured while completing the bindings for the base classes
+ // -> report innacurate matches
+ this.matchSet.cuHasBeenResolved = true;
+ this.matchSet.reportMatching(this.parsedUnit);
}
}
} finally {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchingOpenableSet.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchingOpenableSet.java
index aa30ea8..db2e9bd 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchingOpenableSet.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchingOpenableSet.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import org.eclipse.jdt.core.IPackageFragmentRoot;
@@ -17,6 +17,7 @@
/**
* A set of MatchingOPenables that is sorted by package fragment roots.
*/
+// TODO: (jerome) Remove when switching to MatchLocator2
public class MatchingOpenableSet {
private HashtableOfObject rootsToOpenable = new HashtableOfObject(5);
private int elementCount = 0;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodDeclarationPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodDeclarationPattern.java
index d696123..e4c513e 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodDeclarationPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodDeclarationPattern.java
@@ -1,18 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
@@ -22,7 +23,6 @@
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IEntryResult;
import org.eclipse.jdt.internal.core.index.impl.IndexInput;
import org.eclipse.jdt.internal.core.index.impl.IndexedFile;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java
index 23547a4..7ec1712 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodPattern.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
public abstract class MethodPattern extends SearchPattern {
@@ -70,6 +70,8 @@
*/
protected boolean needsResolve() {
+ // TODO: (jerome) should need resolve only if declaringSimpleName, declaringQualification, returnQualification or parameterQualifications[i] is not null
+
// declaring type
if (declaringSimpleName != null || declaringQualification != null) return true;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodReferencePattern.java
index 8574fa8..a925cc6 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MethodReferencePattern.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
@@ -17,6 +17,7 @@
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
@@ -24,7 +25,6 @@
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IEntryResult;
import org.eclipse.jdt.internal.core.index.impl.IndexInput;
import org.eclipse.jdt.internal.core.index.impl.IndexedFile;
@@ -120,6 +120,10 @@
}
}
+public boolean isPolymorphicSearch() {
+ return true;
+}
+
/**
* Returns whether the code gen will use an invoke virtual for
* this message send or not.
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MultipleSearchPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MultipleSearchPattern.java
index 3c29736..3eb43bc 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MultipleSearchPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MultipleSearchPattern.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrNameCombiner.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrNameCombiner.java
index d94fcd5..27a1173 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrNameCombiner.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrNameCombiner.java
@@ -1,16 +1,16 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
import org.eclipse.jdt.internal.core.search.IIndexSearchRequestor;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPathCombiner.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPathCombiner.java
index 09f18d9..aa0a817 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPathCombiner.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPathCombiner.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.util.HashSet;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPattern.java
index a24c0c6..84c6caa 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/OrPattern.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
@@ -123,6 +123,13 @@
}
/**
+ * see SearchPattern.isPolymorphicSearch
+ */
+public boolean isPolymorphicSearch() {
+ return this.leftPattern.isPolymorphicSearch() || this.rightPattern.isPolymorphicSearch();
+}
+
+/**
* @see SearchPattern#matchLevel(AstNode, boolean)
*/
public int matchLevel(AstNode node, boolean resolve) {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageDeclarationPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageDeclarationPattern.java
index fe71239..002c252 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageDeclarationPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageDeclarationPattern.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageReferencePattern.java
index 135aa04..20ead4a 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PackageReferencePattern.java
@@ -1,19 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.ImportReference;
@@ -28,8 +29,6 @@
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IEntryResult;
import org.eclipse.jdt.internal.core.index.impl.IndexInput;
import org.eclipse.jdt.internal.core.index.impl.IndexedFile;
@@ -46,9 +45,12 @@
public PackageReferencePattern(char[] pkgName, int matchMode, boolean isCaseSensitive) {
super(matchMode, isCaseSensitive);
+ if (!isCaseSensitive) {
+ pkgName = CharOperation.toLowerCase(pkgName);
+ }
this.pkgName = pkgName;
char[][] splittedName = CharOperation.splitOn('.', pkgName);
- this.segments = splittedName == TypeConstants.NoCharChar ? new char[][]{ pkgName } : splittedName;
+ this.segments = splittedName == CharOperation.NO_CHAR_CHAR ? new char[][]{ pkgName } : splittedName;
this.needsResolve = pkgName != null;
}
/**
@@ -182,7 +184,7 @@
}
} else if (reference instanceof QualifiedTypeReference) {
QualifiedTypeReference qTypeRef = (QualifiedTypeReference)reference;
- TypeBinding typeBinding = qTypeRef.binding;
+ TypeBinding typeBinding = qTypeRef.resolvedType;
if (typeBinding instanceof ArrayBinding) {
typeBinding = ((ArrayBinding)typeBinding).leafComponentType;
}
@@ -196,7 +198,7 @@
tokens = qTypeRef.tokens;
}
}
- if (tokens == null) tokens = NO_CHAR_CHAR;
+ if (tokens == null) tokens = CharOperation.NO_CHAR_CHAR;
locator.reportAccurateReference(reference.sourceStart, reference.sourceEnd, tokens, element, accuracy);
}
/**
@@ -389,7 +391,7 @@
}
}
} else {
- return this.matchLevel(typeRef.binding);
+ return this.matchLevel(typeRef.resolvedType);
}
}
/**
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PotentialMatch.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PotentialMatch.java
new file mode 100644
index 0000000..f78427a
--- /dev/null
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PotentialMatch.java
@@ -0,0 +1,284 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.search.matching;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.*;
+import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
+import org.eclipse.jdt.internal.compiler.env.*;
+import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
+import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
+import org.eclipse.jdt.internal.core.*;
+
+public class PotentialMatch implements ICompilationUnit {
+ public static final String NO_SOURCE_FILE_NAME = "NO SOURCE FILE NAME"; //$NON-NLS-1$
+
+ private MatchLocator2 locator;
+ public IResource resource;
+ public Openable openable;
+ public char[][] compoundName;
+ MatchingNodeSet matchingNodeSet;
+ private String sourceFileName;
+
+ public PotentialMatch(
+ MatchLocator2 locator,
+ IResource resource,
+ Openable openable) {
+ this.locator = locator;
+ this.resource = resource;
+ this.openable = openable;
+ this.matchingNodeSet = new MatchingNodeSet(locator);
+ char[] qualifiedName = getQualifiedName();
+ if (qualifiedName != null) {
+ this.compoundName = CharOperation.splitOn('.', qualifiedName);
+ }
+ }
+ public boolean equals(Object obj) {
+ if (this.compoundName == null) return super.equals(obj);
+ if (!(obj instanceof PotentialMatch)) return false;
+ return CharOperation.equals(this.compoundName, ((PotentialMatch)obj).compoundName);
+ }
+
+ /*
+ * Finds the source of this class file.
+ * Returns null if not found.
+ */
+ private char[] findClassFileSource() {
+ String sourceFileName = getSourceFileName();
+ if (sourceFileName == NO_SOURCE_FILE_NAME) return null;
+ char[] source = null;
+ try {
+ SourceMapper sourceMapper = this.openable.getSourceMapper();
+ if (sourceMapper != null) {
+ IType type = ((ClassFile)this.openable).getType();
+ source = sourceMapper.findSource(type, sourceFileName);
+ }
+ } catch (JavaModelException e) {
+ }
+ return source;
+ }
+ /*
+ * Returns the source file name of the class file.
+ * Returns NO_SOURCE_FILE_NAME if not found.
+ */
+ private String getSourceFileName() {
+ if (this.sourceFileName != null) return this.sourceFileName;
+ this.sourceFileName = NO_SOURCE_FILE_NAME;
+ try {
+ SourceMapper sourceMapper = this.openable.getSourceMapper();
+ if (sourceMapper != null) {
+ IType type = ((ClassFile)this.openable).getType();
+ ClassFileReader reader = this.locator.classFileReader(type);
+ if (reader != null) {
+ this.sourceFileName = sourceMapper.findSourceFileName(type, reader);
+ }
+ }
+ } catch (JavaModelException e) {
+ }
+ return this.sourceFileName;
+ }
+ public char[] getContents() {
+ char[] source = null;
+ try {
+ if (this.openable instanceof WorkingCopy) {
+ IBuffer buffer = this.openable.getBuffer();
+ if (buffer == null) return null;
+ source = buffer.getCharacters();
+ } else if (this.openable instanceof CompilationUnit) {
+ source = Util.getResourceContentsAsCharArray((IFile)this.resource);
+ } else if (this.openable instanceof ClassFile) {
+ source = findClassFileSource();
+ }
+ } catch (JavaModelException e) {
+ }
+ if (source == null) return CharOperation.NO_CHAR;
+ return source;
+ }
+ /*
+ * Returns the fully qualified name of the main type of the compilation unit
+ * or the main type of the .java file that defined the class file.
+ */
+ private char[] getQualifiedName() {
+ if (this.openable instanceof CompilationUnit) {
+ // get file name
+ String fileName = this.resource.getFullPath().lastSegment();
+ // get main type name
+ char[] mainTypeName = fileName.substring(0, fileName.length()-5).toCharArray();
+ CompilationUnit cu = (CompilationUnit)this.openable;
+ return cu.getType(new String(mainTypeName)).getFullyQualifiedName().toCharArray();
+ } else if (this.openable instanceof ClassFile) {
+ String sourceFileName = getSourceFileName();
+ if (sourceFileName == NO_SOURCE_FILE_NAME) {
+ try {
+ return ((ClassFile)this.openable).getType().getFullyQualifiedName('.').toCharArray();
+ } catch (JavaModelException e) {
+ return null;
+ }
+ }
+ String simpleName = sourceFileName.substring(0, sourceFileName.length()-5); // length-".java".length()
+ String pkgName = this.openable.getParent().getElementName();
+ if (pkgName.length() == 0) {
+ return simpleName.toCharArray();
+ } else {
+ return (pkgName + '.' + simpleName).toCharArray();
+ }
+ } else {
+ return null;
+ }
+ }
+ public int hashCode() {
+ if (this.compoundName == null) return super.hashCode();
+ int hashCode = 0;
+ for (int i = 0, length = this.compoundName.length; i < length; i++) {
+ hashCode += CharOperation.hashCode(this.compoundName[i]);
+ }
+ return hashCode;
+ }
+
+ public char[] getMainTypeName() {
+ return null; // cannot know the main type name without opening .java or .class file
+ // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=32182
+ }
+ public char[][] getPackageName() {
+ int length;
+ if ((length = this.compoundName.length) > 1) {
+ return CharOperation.subarray(this.compoundName, 0, length-1);
+ } else {
+ return CharOperation.NO_CHAR_CHAR;
+ }
+ }
+ /**
+ * Locate declaration in the current class file. This class file is always in a jar.
+ */
+ public void locateMatchesInClassFile() throws CoreException {
+ org.eclipse.jdt.internal.core.ClassFile classFile = (org.eclipse.jdt.internal.core.ClassFile)this.openable;
+ IBinaryType info = this.locator.getBinaryInfo(classFile, this.resource);
+ if (info == null)
+ return; // unable to go further
+
+ // check class definition
+ BinaryType binaryType = (BinaryType)classFile.getType();
+ if (this.locator.pattern.matchesBinary(info, null)) {
+ this.locator.reportBinaryMatch(binaryType, info, IJavaSearchResultCollector.EXACT_MATCH);
+ }
+
+ boolean compilationAborted = false;
+ if (this.locator.pattern.needsResolve) {
+ // resolve
+ BinaryTypeBinding binding = null;
+ try {
+ binding = this.locator.cacheBinaryType(binaryType);
+ if (binding != null) {
+ // filter out element not in hierarchy scope
+ if (this.locator.hierarchyResolver != null
+ && !this.locator.hierarchyResolver.subOrSuperOfFocus(binding)) {
+ return;
+ }
+
+ // check methods
+ MethodBinding[] methods = binding.methods();
+ for (int i = 0; i < methods.length; i++) {
+ MethodBinding method = methods[i];
+ int level = this.locator.pattern.matchLevel(method);
+ switch (level) {
+ case SearchPattern.IMPOSSIBLE_MATCH:
+ case SearchPattern.INACCURATE_MATCH:
+ break;
+ default:
+ IMethod methodHandle =
+ binaryType.getMethod(
+ new String(method.isConstructor() ? binding.compoundName[binding.compoundName.length-1] : method.selector),
+ Signature.getParameterTypes(new String(method.signature()).replace('/', '.'))
+ );
+ this.locator.reportBinaryMatch(
+ methodHandle,
+ info,
+ level == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+ }
+
+ // check fields
+ FieldBinding[] fields = binding.fields();
+ for (int i = 0; i < fields.length; i++) {
+ FieldBinding field = fields[i];
+ int level = this.locator.pattern.matchLevel(field);
+ switch (level) {
+ case SearchPattern.IMPOSSIBLE_MATCH:
+ case SearchPattern.INACCURATE_MATCH:
+ break;
+ default:
+ IField fieldHandle = binaryType.getField(new String(field.name));
+ this.locator.reportBinaryMatch(
+ fieldHandle,
+ info,
+ level == SearchPattern.ACCURATE_MATCH ?
+ IJavaSearchResultCollector.EXACT_MATCH :
+ IJavaSearchResultCollector.POTENTIAL_MATCH);
+ }
+ }
+ }
+ } catch (AbortCompilation e) {
+ binding = null;
+ }
+
+ // no need to check binary info if resolve was successful
+ compilationAborted = binding == null;
+ if (!compilationAborted) return;
+ }
+
+ // if compilation was aborted it is a problem with the class path:
+ // report as a potential match if binary info matches the pattern
+ int accuracy = compilationAborted ? IJavaSearchResultCollector.POTENTIAL_MATCH : IJavaSearchResultCollector.EXACT_MATCH;
+
+ // check methods
+ IBinaryMethod[] methods = info.getMethods();
+ int length = methods == null ? 0 : methods.length;
+ for (int i = 0; i < length; i++) {
+ IBinaryMethod method = methods[i];
+ if (this.locator.pattern.matchesBinary(method, info)) {
+ IMethod methodHandle =
+ binaryType.getMethod(
+ new String(method.isConstructor() ? info.getName() : method.getSelector()),
+ Signature.getParameterTypes(new String(method.getMethodDescriptor()).replace('/', '.'))
+ );
+ this.locator.reportBinaryMatch(methodHandle, info, accuracy);
+ }
+ }
+
+ // check fields
+ IBinaryField[] fields = info.getFields();
+ length = fields == null ? 0 : fields.length;
+ for (int i = 0; i < length; i++) {
+ IBinaryField field = fields[i];
+ if (this.locator.pattern.matchesBinary(field, info)) {
+ IField fieldHandle = binaryType.getField(new String(field.getName()));
+ this.locator.reportBinaryMatch(fieldHandle, info, accuracy);
+ }
+ }
+ }
+ public String toString() {
+ return this.openable == null ? "Fake PotentialMatch" : this.openable.toString(); //$NON-NLS-1$
+ }
+
+ public char[] getFileName() {
+ return this.openable.getPath().toString().toCharArray();
+ }
+
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PotentialMatchSet.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PotentialMatchSet.java
new file mode 100644
index 0000000..1818a46
--- /dev/null
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PotentialMatchSet.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.core.search.matching;
+
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.internal.compiler.util.HashtableOfObject;
+import org.eclipse.jdt.internal.compiler.util.ObjectVector;
+
+/**
+ * A set of PotentialMatches that is sorted by package fragment roots.
+ */
+public class PotentialMatchSet {
+ private HashtableOfObject rootsToPotentialMatches = new HashtableOfObject(5);
+ private int elementCount = 0;
+
+ public void add(PotentialMatch potentialMatch) {
+ IPackageFragmentRoot root = potentialMatch.openable.getPackageFragmentRoot();
+ char[] path = root.getPath().toString().toCharArray();
+ ObjectVector potentialMatches = (ObjectVector)this.rootsToPotentialMatches.get(path);
+ if (potentialMatches == null) {
+ potentialMatches = new ObjectVector();
+ this.rootsToPotentialMatches.put(path, potentialMatches);
+ potentialMatches.add(potentialMatch);
+ this.elementCount++;
+ } else if (!potentialMatches.contains(potentialMatch)) {
+ potentialMatches.add(potentialMatch);
+ this.elementCount++;
+ }
+ }
+
+ public PotentialMatch[] getPotentialMatches(IPackageFragmentRoot[] roots) {
+ PotentialMatch[] result = new PotentialMatch[this.elementCount];
+ int index = 0;
+ for (int i = 0, length = roots.length; i < length; i++) {
+ IPackageFragmentRoot root = roots[i];
+ char[] path = root.getPath().toString().toCharArray();
+ ObjectVector potentialMatches = (ObjectVector)this.rootsToPotentialMatches.get(path);
+ if (potentialMatches != null) {
+ potentialMatches.copyInto(result, index);
+ index += potentialMatches.size();
+ }
+ }
+ if (index < this.elementCount) {
+ System.arraycopy(
+ result,
+ 0,
+ result = new PotentialMatch[index],
+ 0,
+ index);
+ }
+ return result;
+ }
+}
+
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java
index 6524545..3f48503 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IEntryResult;
public class QualifiedTypeDeclarationPattern extends TypeDeclarationPattern {
@@ -47,7 +47,7 @@
int slash = CharOperation.indexOf(SEPARATOR, word, oldSlash+1);
char[] pkgName;
if (slash == oldSlash+1){
- pkgName = NO_CHAR;
+ pkgName = CharOperation.NO_CHAR;
} else {
pkgName = CharOperation.subarray(word, oldSlash+1, slash);
}
@@ -61,7 +61,7 @@
enclosingTypeNames = CharOperation.splitOn('/', CharOperation.subarray(word, slash+1, size-1));
}
} else {
- enclosingTypeNames = NO_CHAR_CHAR;
+ enclosingTypeNames = CharOperation.NO_CHAR_CHAR;
}
this.decodedQualification = CharOperation.concatWith(pkgName, enclosingTypeNames, '.');
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java
index b1597cf..79c2ad9 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
@@ -23,7 +23,7 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.core.compiler.ITerminalSymbols;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
@@ -36,19 +36,22 @@
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.compiler.parser.Scanner;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
+import org.eclipse.jdt.internal.compiler.parser.TerminalTokens;
import org.eclipse.jdt.internal.core.index.IEntryResult;
import org.eclipse.jdt.internal.core.index.IIndex;
import org.eclipse.jdt.internal.core.index.impl.BlocksIndexInput;
import org.eclipse.jdt.internal.core.index.impl.IndexInput;
import org.eclipse.jdt.internal.core.search.IIndexSearchRequestor;
-import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
+import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
public abstract class SearchPattern implements ISearchPattern, IIndexConstants, IJavaSearchConstants {
protected int matchMode;
protected boolean isCaseSensitive;
- protected boolean needsResolve = true;
+ public boolean needsResolve = true;
+
+ /* focus element (used for reference patterns*/
+ public IJavaElement focus;
/* match level */
public static final int IMPOSSIBLE_MATCH = 0;
@@ -62,8 +65,6 @@
public static final int FIELD = 4;
public static final int METHOD = 8;
-
-
public SearchPattern(int matchMode, boolean isCaseSensitive) {
this.matchMode = matchMode;
this.isCaseSensitive = isCaseSensitive;
@@ -75,7 +76,7 @@
*/
private static SearchPattern createConstructorPattern(String patternString, int limitTo, int matchMode, boolean isCaseSensitive) {
- Scanner scanner = new Scanner(false, true); // tokenize white spaces
+ Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, false /*assert*/, null /*taskTags*/, null/*taskPriorities*/);
scanner.setSource(patternString.toCharArray());
final int InsideName = 1;
final int InsideParameter = 2;
@@ -91,13 +92,13 @@
} catch (InvalidInputException e) {
return null;
}
- while (token != ITerminalSymbols.TokenNameEOF){
+ while (token != TerminalTokens.TokenNameEOF){
switch(mode){
// read declaring type and selector
case InsideName :
switch (token) {
- case ITerminalSymbols.TokenNameDOT:
+ case TerminalTokens.TokenNameDOT:
if (declaringQualification == null){
if (typeName == null) return null;
declaringQualification = typeName;
@@ -107,23 +108,19 @@
}
typeName = null;
break;
- case ITerminalSymbols.TokenNameLPAREN:
+ case TerminalTokens.TokenNameLPAREN:
parameterTypes = new String[5];
parameterCount = 0;
mode = InsideParameter;
break;
case Scanner.TokenNameWHITESPACE:
break;
- case ITerminalSymbols.TokenNameIdentifier:
- case ITerminalSymbols.TokenNameMULTIPLY:
+ default: // all other tokens are considered identifiers (see bug 21763 Problem in Java search [search])
if (typeName == null) {
typeName = new String(scanner.getCurrentTokenSource());
} else {
typeName += new String(scanner.getCurrentTokenSource());
}
- break;
- default:
- return null;
}
break;
// read parameter types
@@ -131,7 +128,7 @@
switch (token) {
case Scanner.TokenNameWHITESPACE:
break;
- case ITerminalSymbols.TokenNameCOMMA:
+ case TerminalTokens.TokenNameCOMMA:
if (parameterType == null) return null;
if (parameterTypes.length == parameterCount){
System.arraycopy(parameterTypes, 0, parameterTypes = new String[parameterCount*2], 0, parameterCount);
@@ -139,7 +136,7 @@
parameterTypes[parameterCount++] = parameterType;
parameterType = null;
break;
- case ITerminalSymbols.TokenNameRPAREN:
+ case TerminalTokens.TokenNameRPAREN:
foundClosingParenthesis = true;
if (parameterType != null){
if (parameterTypes.length == parameterCount){
@@ -148,28 +145,12 @@
parameterTypes[parameterCount++] = parameterType;
}
break;
- case ITerminalSymbols.TokenNameDOT:
- case ITerminalSymbols.TokenNameIdentifier:
- case ITerminalSymbols.TokenNameMULTIPLY:
- case ITerminalSymbols.TokenNameLBRACKET:
- case ITerminalSymbols.TokenNameRBRACKET:
- case ITerminalSymbols.TokenNameboolean:
- case ITerminalSymbols.TokenNamebyte:
- case ITerminalSymbols.TokenNamechar:
- case ITerminalSymbols.TokenNamedouble:
- case ITerminalSymbols.TokenNamefloat:
- case ITerminalSymbols.TokenNameint:
- case ITerminalSymbols.TokenNamelong:
- case ITerminalSymbols.TokenNameshort:
- case ITerminalSymbols.TokenNamevoid:
+ default: // all other tokens are considered identifiers (see bug 21763 Problem in Java search [search])
if (parameterType == null){
parameterType = new String(scanner.getCurrentTokenSource());
} else {
parameterType += new String(scanner.getCurrentTokenSource());
}
- break;
- default:
- return null;
}
break;
}
@@ -266,7 +247,7 @@
*/
private static SearchPattern createFieldPattern(String patternString, int limitTo, int matchMode, boolean isCaseSensitive) {
- Scanner scanner = new Scanner(false, true); // tokenize white spaces
+ Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, false /*assert*/, null /*taskTags*/, null/*taskPriorities*/);
scanner.setSource(patternString.toCharArray());
final int InsideDeclaringPart = 1;
final int InsideType = 2;
@@ -281,13 +262,13 @@
} catch (InvalidInputException e) {
return null;
}
- while (token != ITerminalSymbols.TokenNameEOF){
+ while (token != TerminalTokens.TokenNameEOF){
switch(mode){
// read declaring type and fieldName
case InsideDeclaringPart :
switch (token) {
- case ITerminalSymbols.TokenNameDOT:
+ case TerminalTokens.TokenNameDOT:
if (declaringType == null){
if (fieldName == null) return null;
declaringType = fieldName;
@@ -299,20 +280,16 @@
break;
case Scanner.TokenNameWHITESPACE:
if (!(Scanner.TokenNameWHITESPACE == lastToken
- || ITerminalSymbols.TokenNameDOT == lastToken)){
+ || TerminalTokens.TokenNameDOT == lastToken)){
mode = InsideType;
}
break;
- case ITerminalSymbols.TokenNameIdentifier:
- case ITerminalSymbols.TokenNameMULTIPLY:
+ default: // all other tokens are considered identifiers (see bug 21763 Problem in Java search [search])
if (fieldName == null) {
fieldName = new String(scanner.getCurrentTokenSource());
} else {
fieldName += new String(scanner.getCurrentTokenSource());
}
- break;
- default:
- return null;
}
break;
// read type
@@ -320,28 +297,12 @@
switch (token) {
case Scanner.TokenNameWHITESPACE:
break;
- case ITerminalSymbols.TokenNameDOT:
- case ITerminalSymbols.TokenNameIdentifier:
- case ITerminalSymbols.TokenNameMULTIPLY:
- case ITerminalSymbols.TokenNameLBRACKET:
- case ITerminalSymbols.TokenNameRBRACKET:
- case ITerminalSymbols.TokenNameboolean:
- case ITerminalSymbols.TokenNamebyte:
- case ITerminalSymbols.TokenNamechar:
- case ITerminalSymbols.TokenNamedouble:
- case ITerminalSymbols.TokenNamefloat:
- case ITerminalSymbols.TokenNameint:
- case ITerminalSymbols.TokenNamelong:
- case ITerminalSymbols.TokenNameshort:
- case ITerminalSymbols.TokenNamevoid:
+ default: // all other tokens are considered identifiers (see bug 21763 Problem in Java search [search])
if (type == null){
type = new String(scanner.getCurrentTokenSource());
} else {
type += new String(scanner.getCurrentTokenSource());
}
- break;
- default:
- return null;
}
break;
}
@@ -478,7 +439,7 @@
*/
private static SearchPattern createMethodPattern(String patternString, int limitTo, int matchMode, boolean isCaseSensitive) {
- Scanner scanner = new Scanner(false, true); // tokenize white spaces
+ Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, false /*assert*/, null /*taskTags*/, null/*taskPriorities*/);
scanner.setSource(patternString.toCharArray());
final int InsideSelector = 1;
final int InsideParameter = 2;
@@ -497,13 +458,13 @@
} catch (InvalidInputException e) {
return null;
}
- while (token != ITerminalSymbols.TokenNameEOF){
+ while (token != TerminalTokens.TokenNameEOF){
switch(mode){
// read declaring type and selector
case InsideSelector :
switch (token) {
- case ITerminalSymbols.TokenNameDOT:
+ case TerminalTokens.TokenNameDOT:
if (declaringType == null){
if (selector == null) return null;
declaringType = selector;
@@ -513,27 +474,24 @@
}
selector = null;
break;
- case ITerminalSymbols.TokenNameLPAREN:
+ case TerminalTokens.TokenNameLPAREN:
parameterTypes = new String[5];
parameterCount = 0;
mode = InsideParameter;
break;
case Scanner.TokenNameWHITESPACE:
if (!(Scanner.TokenNameWHITESPACE == lastToken
- || ITerminalSymbols.TokenNameDOT == lastToken)){
+ || TerminalTokens.TokenNameDOT == lastToken)){
mode = InsideReturnType;
}
break;
- case ITerminalSymbols.TokenNameIdentifier:
- case ITerminalSymbols.TokenNameMULTIPLY:
+ default: // all other tokens are considered identifiers (see bug 21763 Problem in Java search [search])
if (selector == null) {
selector = new String(scanner.getCurrentTokenSource());
} else {
selector += new String(scanner.getCurrentTokenSource());
}
break;
- default:
- return null;
}
break;
// read parameter types
@@ -541,7 +499,7 @@
switch (token) {
case Scanner.TokenNameWHITESPACE:
break;
- case ITerminalSymbols.TokenNameCOMMA:
+ case TerminalTokens.TokenNameCOMMA:
if (parameterType == null) return null;
if (parameterTypes.length == parameterCount){
System.arraycopy(parameterTypes, 0, parameterTypes = new String[parameterCount*2], 0, parameterCount);
@@ -549,7 +507,7 @@
parameterTypes[parameterCount++] = parameterType;
parameterType = null;
break;
- case ITerminalSymbols.TokenNameRPAREN:
+ case TerminalTokens.TokenNameRPAREN:
foundClosingParenthesis = true;
if (parameterType != null){
if (parameterTypes.length == parameterCount){
@@ -559,28 +517,12 @@
}
mode = InsideReturnType;
break;
- case ITerminalSymbols.TokenNameDOT:
- case ITerminalSymbols.TokenNameIdentifier:
- case ITerminalSymbols.TokenNameMULTIPLY:
- case ITerminalSymbols.TokenNameLBRACKET:
- case ITerminalSymbols.TokenNameRBRACKET:
- case ITerminalSymbols.TokenNameboolean:
- case ITerminalSymbols.TokenNamebyte:
- case ITerminalSymbols.TokenNamechar:
- case ITerminalSymbols.TokenNamedouble:
- case ITerminalSymbols.TokenNamefloat:
- case ITerminalSymbols.TokenNameint:
- case ITerminalSymbols.TokenNamelong:
- case ITerminalSymbols.TokenNameshort:
- case ITerminalSymbols.TokenNamevoid:
+ default: // all other tokens are considered identifiers (see bug 21763 Problem in Java search [search])
if (parameterType == null){
parameterType = new String(scanner.getCurrentTokenSource());
} else {
parameterType += new String(scanner.getCurrentTokenSource());
}
- break;
- default:
- return null;
}
break;
// read return type
@@ -588,28 +530,12 @@
switch (token) {
case Scanner.TokenNameWHITESPACE:
break;
- case ITerminalSymbols.TokenNameDOT:
- case ITerminalSymbols.TokenNameIdentifier:
- case ITerminalSymbols.TokenNameMULTIPLY:
- case ITerminalSymbols.TokenNameLBRACKET:
- case ITerminalSymbols.TokenNameRBRACKET:
- case ITerminalSymbols.TokenNameboolean:
- case ITerminalSymbols.TokenNamebyte:
- case ITerminalSymbols.TokenNamechar:
- case ITerminalSymbols.TokenNamedouble:
- case ITerminalSymbols.TokenNamefloat:
- case ITerminalSymbols.TokenNameint:
- case ITerminalSymbols.TokenNamelong:
- case ITerminalSymbols.TokenNameshort:
- case ITerminalSymbols.TokenNamevoid:
+ default: // all other tokens are considered identifiers (see bug 21763 Problem in Java search [search])
if (returnType == null){
returnType = new String(scanner.getCurrentTokenSource());
} else {
returnType += new String(scanner.getCurrentTokenSource());
}
- break;
- default:
- return null;
}
break;
}
@@ -798,7 +724,7 @@
String fullDeclaringName = field.getDeclaringType().getFullyQualifiedName().replace('$', '.');
lastDot = fullDeclaringName.lastIndexOf('.');
char[] declaringSimpleName = (lastDot != -1 ? fullDeclaringName.substring(lastDot + 1) : fullDeclaringName).toCharArray();
- char[] declaringQualification = lastDot != -1 ? fullDeclaringName.substring(0, lastDot).toCharArray() : NO_CHAR;
+ char[] declaringQualification = lastDot != -1 ? fullDeclaringName.substring(0, lastDot).toCharArray() : CharOperation.NO_CHAR;
char[] name = field.getElementName().toCharArray();
char[] typeSimpleName;
char[] typeQualification;
@@ -916,7 +842,7 @@
fullDeclaringName = method.getDeclaringType().getFullyQualifiedName().replace('$', '.');
lastDot = fullDeclaringName.lastIndexOf('.');
declaringSimpleName = (lastDot != -1 ? fullDeclaringName.substring(lastDot + 1) : fullDeclaringName).toCharArray();
- declaringQualification = lastDot != -1 ? fullDeclaringName.substring(0, lastDot).toCharArray() : NO_CHAR;
+ declaringQualification = lastDot != -1 ? fullDeclaringName.substring(0, lastDot).toCharArray() : CharOperation.NO_CHAR;
char[] selector = method.getElementName().toCharArray();
char[] returnSimpleName;
char[] returnQualification;
@@ -1058,6 +984,9 @@
searchPattern = createPackagePattern(element.getElementName(), limitTo, EXACT_MATCH, CASE_SENSITIVE);
break;
}
+ if (searchPattern != null) {
+ searchPattern.focus = element;
+ }
return searchPattern;
}
private static SearchPattern createTypePattern(char[] simpleName, char[] packageName, char[][] enclosingTypeNames, int limitTo) {
@@ -1115,7 +1044,7 @@
*/
private static SearchPattern createTypePattern(String patternString, int limitTo, int matchMode, boolean isCaseSensitive) {
- Scanner scanner = new Scanner(false, true); // tokenize white spaces
+ Scanner scanner = new Scanner(false /*comment*/, true /*whitespace*/, false /*nls*/, false /*assert*/, null /*taskTags*/, null/*taskPriorities*/);
scanner.setSource(patternString.toCharArray());
String type = null;
int token;
@@ -1124,32 +1053,16 @@
} catch (InvalidInputException e) {
return null;
}
- while (token != ITerminalSymbols.TokenNameEOF){
+ while (token != TerminalTokens.TokenNameEOF){
switch (token) {
case Scanner.TokenNameWHITESPACE:
break;
- case ITerminalSymbols.TokenNameDOT:
- case ITerminalSymbols.TokenNameIdentifier:
- case ITerminalSymbols.TokenNameMULTIPLY:
- case ITerminalSymbols.TokenNameLBRACKET:
- case ITerminalSymbols.TokenNameRBRACKET:
- case ITerminalSymbols.TokenNameboolean:
- case ITerminalSymbols.TokenNamebyte:
- case ITerminalSymbols.TokenNamechar:
- case ITerminalSymbols.TokenNamedouble:
- case ITerminalSymbols.TokenNamefloat:
- case ITerminalSymbols.TokenNameint:
- case ITerminalSymbols.TokenNamelong:
- case ITerminalSymbols.TokenNameshort:
- case ITerminalSymbols.TokenNamevoid:
+ default: // all other tokens are considered identifiers (see bug 21763 Problem in Java search [search])
if (type == null){
type = new String(scanner.getCurrentTokenSource());
} else {
type += new String(scanner.getCurrentTokenSource());
}
- break;
- default:
- return null;
}
try {
token = scanner.getNextToken();
@@ -1207,16 +1120,16 @@
// (see bug 20532 Declaration of member binary type not found)
IType declaringType = type.getDeclaringType();
if (declaringType == null) {
- return NO_CHAR_CHAR;
+ return CharOperation.NO_CHAR_CHAR;
} else {
return CharOperation.arrayConcat(
enclosingTypeNames(declaringType),
declaringType.getElementName().toCharArray());
}
case IJavaElement.COMPILATION_UNIT:
- return NO_CHAR_CHAR;
+ return CharOperation.NO_CHAR_CHAR;
case IJavaElement.TYPE:
- return CharOperation.arrayConcat(
+ return CharOperation.arrayConcat(
enclosingTypeNames((IType)parent),
parent.getElementName().toCharArray());
default:
@@ -1304,6 +1217,7 @@
* Returns whether the given name matches the given pattern.
*/
protected boolean matchesName(char[] pattern, char[] name) {
+ if (pattern == null) return true; // null is as if it was "*"
if (name != null){
switch (this.matchMode) {
case EXACT_MATCH :
@@ -1311,6 +1225,9 @@
case PREFIX_MATCH :
return CharOperation.prefixEquals(pattern, name, this.isCaseSensitive);
case PATTERN_MATCH :
+ if (!this.isCaseSensitive) {
+ pattern = CharOperation.toLowerCase(pattern);
+ }
return CharOperation.match(pattern, name, this.isCaseSensitive);
}
}
@@ -1335,6 +1252,9 @@
pattern = CharOperation.concat(qualificationPattern, simpleNamePattern, '.');
}
}
+ if (!this.isCaseSensitive) {
+ pattern = CharOperation.toLowerCase(pattern);
+ }
return
CharOperation.match(
pattern,
@@ -1379,12 +1299,6 @@
return "SearchPattern"; //$NON-NLS-1$
}
-
-
-
-
-
-
/**
* Initializes this search pattern so that polymorphic search can be performed.
*/
@@ -1392,6 +1306,13 @@
// default is to do nothing
}
+/*
+ * Returns whether this pattern is a polymorphic search pattern.
+ */
+public boolean isPolymorphicSearch() {
+ return false;
+}
+
/**
* Finds out whether the given ast node matches this search pattern.
* Returns IMPOSSIBLE_MATCH if it doesn't.
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperInterfaceReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperInterfaceReferencePattern.java
index 6d67f24..32e4790 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperInterfaceReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperInterfaceReferencePattern.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants;
public class SuperInterfaceReferencePattern extends SuperTypeReferencePattern {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java
index 7ac4dea..cb10fe4 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeNamesCollector.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import org.eclipse.core.resources.IFile;
@@ -19,6 +19,7 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
@@ -45,8 +46,6 @@
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.parser.SourceTypeConverter;
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
-import org.eclipse.jdt.internal.core.BinaryType;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jdt.internal.core.Openable;
@@ -139,8 +138,8 @@
private CompilationUnitDeclaration buildBindings(ICompilationUnit compilationUnit) throws JavaModelException {
final IFile file =
compilationUnit.isWorkingCopy() ?
- (IFile)compilationUnit.getOriginalElement().getUnderlyingResource() :
- (IFile)compilationUnit.getUnderlyingResource();
+ (IFile)compilationUnit.getOriginalElement().getResource() :
+ (IFile)compilationUnit.getResource();
// get main type name
final String fileName = file.getFullPath().lastSegment();
@@ -178,15 +177,7 @@
}
return unit;
}
-private BinaryTypeBinding cacheBinaryType(IType type) throws JavaModelException {
- IType enclosingType = type.getDeclaringType();
- if (enclosingType != null) {
- // force caching of enclosing types first, so that binary type can be found in lookup enviroment
- this.cacheBinaryType(enclosingType);
- }
- IBinaryType binaryType = (IBinaryType)((BinaryType)type).getRawInfo();
- return this.locator.lookupEnvironment.cacheBinaryType(binaryType);
-}
+
protected char[][][] collect() throws JavaModelException {
@@ -195,13 +186,16 @@
this.result = new char[1][][];
this.resultIndex = 0;
JavaProject javaProject = (JavaProject)this.type.getJavaProject();
- this.locator.createParser(javaProject);
+ this.locator.initializeNameEnvironment(javaProject);
+ this.locator.initialize(javaProject);
synchronized(this.locator.nameLookup) { // prevent 2 concurrent accesses to name lookup while the working copies are set
this.locator.nameLookup.setUnitsToLookInside(this.locator.workingCopies);
try {
if (this.type.isBinary()) {
- BinaryTypeBinding binding = this.cacheBinaryType(this.type);
- this.collectSuperTypeNames(binding);
+ BinaryTypeBinding binding = this.locator.cacheBinaryType(this.type);
+ if (binding != null) {
+ this.collectSuperTypeNames(binding);
+ }
} else {
ICompilationUnit unit = this.type.getCompilationUnit();
CompilationUnitDeclaration parsedUnit = this.buildBindings(unit);
@@ -232,7 +226,7 @@
try {
for (int i = 0, length = paths.length; i < length; i++) {
try {
- Openable openable = this.locator.handleFactory.createOpenable(paths[i]);
+ Openable openable = this.locator.handleFactory.createOpenable(paths[i], this.locator.scope);
if (openable == null)
continue; // outside classpath
IJavaProject project = openable.getJavaProject();
@@ -241,7 +235,8 @@
this.locator.nameLookup.setUnitsToLookInside(null);
}
previousProject = (JavaProject)project;
- this.locator.createParser(previousProject);
+ this.locator.initializeNameEnvironment(previousProject);
+ this.locator.initialize(previousProject);
this.locator.nameLookup.setUnitsToLookInside(this.locator.workingCopies);
}
if (openable instanceof ICompilationUnit) {
@@ -252,7 +247,7 @@
}
} else if (openable instanceof IClassFile) {
IClassFile classFile = (IClassFile)openable;
- BinaryTypeBinding binding = this.cacheBinaryType(classFile.getType());
+ BinaryTypeBinding binding = this.locator.cacheBinaryType(classFile.getType());
if (this.matches(binding)) {
this.collectSuperTypeNames(binding);
}
@@ -424,7 +419,13 @@
public void accept(ISourceType[] sourceTypes, PackageBinding packageBinding) {
CompilationResult result = new CompilationResult(sourceTypes[0].getFileName(), 1, 1, 0);
CompilationUnitDeclaration unit =
- SourceTypeConverter.buildCompilationUnit(sourceTypes, false, true, this.locator.lookupEnvironment.problemReporter, result);
+ SourceTypeConverter.buildCompilationUnit(
+ sourceTypes, //sourceTypes[0] is always toplevel here
+ false, // no need for field and methods
+ true, // need member types
+ false, // no need for field initialization
+ this.locator.lookupEnvironment.problemReporter,
+ result);
if (unit != null) {
this.locator.lookupEnvironment.buildTypeBindings(unit);
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferencePattern.java
index c9d38a5..c7bee16 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SuperTypeReferencePattern.java
@@ -1,22 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import org.eclipse.jdt.internal.compiler.ast.*;
-import org.eclipse.jdt.internal.compiler.util.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.core.index.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jdt.core.compiler.*;
import org.eclipse.jdt.core.search.*;
import org.eclipse.jdt.internal.core.search.indexing.*;
import org.eclipse.jdt.internal.core.index.impl.*;
@@ -132,7 +132,8 @@
}
this.entryResults.put(input, entries);
}
-
+ if (entries == NO_ENTRY_RESULT) return;
+
/* only select entries which actually match the entire search pattern */
int slash = SUPER_REF.length;
char[] simpleName = this.superSimpleName;
@@ -262,7 +263,7 @@
TypeReference typeRef = (TypeReference)node;
if (resolve) {
- TypeBinding binding = typeRef.binding;
+ TypeBinding binding = typeRef.resolvedType;
if (binding == null) {
return INACCURATE_MATCH;
} else {
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java
index c3e87c3..3985941 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeDeclarationPattern.java
@@ -1,24 +1,24 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IEntryResult;
import org.eclipse.jdt.internal.core.index.impl.IndexInput;
import org.eclipse.jdt.internal.core.index.impl.IndexedFile;
@@ -78,7 +78,7 @@
int oldSlash = TYPE_DECL_LENGTH+1;
int slash = CharOperation.indexOf(SEPARATOR, word, oldSlash+1);
if (slash == oldSlash+1){
- this.decodedPackage = NO_CHAR;
+ this.decodedPackage = CharOperation.NO_CHAR;
} else {
this.decodedPackage = CharOperation.subarray(word, oldSlash+1, slash);
}
@@ -91,7 +91,7 @@
this.decodedEnclosingTypeNames = CharOperation.splitOn('/', CharOperation.subarray(word, slash+1, size-1));
}
} else {
- this.decodedEnclosingTypeNames = NO_CHAR_CHAR;
+ this.decodedEnclosingTypeNames = CharOperation.NO_CHAR_CHAR;
}
}
/**
@@ -196,7 +196,7 @@
if (enclosingTypeNames != null){
// empty char[][] means no enclosing type, i.e. the decoded one is the empty char array
if (enclosingTypeNames.length == 0){
- if (decodedEnclosingTypeNames != NO_CHAR_CHAR) return false;
+ if (decodedEnclosingTypeNames != CharOperation.NO_CHAR_CHAR) return false;
} else {
if (!CharOperation.equals(enclosingTypeNames, decodedEnclosingTypeNames, isCaseSensitive)) return false;
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferencePattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferencePattern.java
index 805b048..0534e58 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferencePattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferencePattern.java
@@ -1,19 +1,20 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.matching;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
import org.eclipse.jdt.internal.compiler.ast.AstNode;
@@ -24,6 +25,7 @@
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BindingIds;
@@ -31,7 +33,6 @@
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
-import org.eclipse.jdt.internal.compiler.util.CharOperation;
import org.eclipse.jdt.internal.core.index.IEntryResult;
import org.eclipse.jdt.internal.core.index.impl.IndexInput;
import org.eclipse.jdt.internal.core.index.impl.IndexedFile;
@@ -43,7 +44,6 @@
private char[] qualification;
private char[] simpleName;
- private char[] decodedQualification;
private char[] decodedSimpleName;
private static char[][] TAGS = { TYPE_REF, SUPER_REF, REF, CONSTRUCTOR_REF };
@@ -66,10 +66,10 @@
this.simpleName = isCaseSensitive ? simpleName : CharOperation.toLowerCase(simpleName);
if (simpleName == null) {
- this.segments = qualification == null ? ONE_STAR_CHAR : CharOperation.splitOn('.', qualification);
+ this.segments = this.qualification == null ? ONE_STAR_CHAR : CharOperation.splitOn('.', this.qualification);
}
- this.needsResolve = qualification != null;
+ this.needsResolve = true; // always resolve (in case of a simple name reference being a potential match)
}
/**
* Either decode ref/name, typeRef/name or superRef/superName/name
@@ -278,7 +278,7 @@
*/
protected void matchReportReference(QualifiedTypeReference qTypeRef, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException {
char[][] tokens = null;
- TypeBinding typeBinding = qTypeRef.binding;
+ TypeBinding typeBinding = qTypeRef.resolvedType;
if (typeBinding instanceof ArrayBinding) {
typeBinding = ((ArrayBinding)typeBinding).leafComponentType;
}
@@ -372,8 +372,6 @@
*/
private int matchLevel(ImportReference importRef, boolean resolve) {
- if (importRef.onDemand) return IMPOSSIBLE_MATCH;
-
char[][] tokens = importRef.tokens;
int importLength = tokens.length;
@@ -446,12 +444,15 @@
Binding binding = nameRef.binding;
if (nameRef instanceof SingleNameReference) {
- if (binding == null || binding instanceof ProblemBinding){
+ if (binding instanceof ProblemReferenceBinding) {
+ binding = ((ProblemReferenceBinding)binding).original;
+ }
+ if (binding instanceof VariableBinding) {
+ return IMPOSSIBLE_MATCH;
+ } else if (!(binding instanceof TypeBinding)){
return INACCURATE_MATCH;
- } else if (binding instanceof TypeBinding) {
- return this.matchLevelForType(this.simpleName, this.qualification, (TypeBinding) binding);
} else {
- return IMPOSSIBLE_MATCH; // must be a type binding
+ return this.matchLevelForType(this.simpleName, this.qualification, (TypeBinding) binding);
}
} else { // QualifiedNameReference
TypeBinding typeBinding = null;
@@ -469,6 +470,12 @@
case BindingIds.LOCAL : // reading a local variable
return IMPOSSIBLE_MATCH; // no type match in it
case BindingIds.TYPE : //=============only type ==============
+ if (binding instanceof ProblemReferenceBinding) {
+ binding = ((ProblemReferenceBinding)binding).original;
+ }
+ if (!(binding instanceof TypeBinding)) {
+ return INACCURATE_MATCH;
+ }
typeBinding = (TypeBinding)binding;
break;
/*
@@ -483,6 +490,16 @@
char[] partialQualifiedName = pbBinding.name;
lastIndex = CharOperation.occurencesOf('.', partialQualifiedName) - 1; // index of last bound token is one before the pb token
if (typeBinding == null || lastIndex < 0) return INACCURATE_MATCH;
+ } else if (binding instanceof ProblemReferenceBinding) {
+ ProblemReferenceBinding pbBinding = (ProblemReferenceBinding)binding;
+ binding = pbBinding.original;
+ if (!(binding instanceof TypeBinding)) {
+ return INACCURATE_MATCH;
+ }
+ typeBinding = (TypeBinding)binding;
+ char[][] partialQualifiedName = pbBinding.compoundName;
+ lastIndex = partialQualifiedName == null ? -1 : partialQualifiedName.length - 1; // index of last bound token is one before the pb token
+ if (typeBinding == null || lastIndex < 0) return INACCURATE_MATCH;
}
break;
}
@@ -509,7 +526,7 @@
* Reports the match of the given array type reference.
*/
protected void matchReportReference(ArrayTypeReference arrayRef, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException {
- char[][] tokens = this.simpleName == null ? NO_CHAR_CHAR : new char[][] {this.simpleName};
+ char[][] tokens = this.simpleName == null ? CharOperation.NO_CHAR_CHAR : new char[][] {this.simpleName};
locator.reportAccurateReference(arrayRef.sourceStart, arrayRef.sourceEnd, tokens, element, accuracy);
}
@@ -541,35 +558,43 @@
}
}
} else {
- TypeBinding typeBinding = typeRef.binding;
+ TypeBinding typeBinding = typeRef.resolvedType;
+ if (typeBinding instanceof ArrayBinding) {
+ typeBinding = ((ArrayBinding)typeBinding).leafComponentType;
+ }
+ if (typeBinding instanceof ProblemReferenceBinding) {
+ Binding binding = ((ProblemReferenceBinding)typeBinding).original;
+ if (binding instanceof TypeBinding) {
+ typeBinding = (TypeBinding)binding;
+ } else if (binding == null) {
+ typeBinding = null;
+ }
+ }
if (typeBinding == null) {
return INACCURATE_MATCH;
- } else {
- if (typeBinding instanceof ArrayBinding) typeBinding = ((ArrayBinding)typeBinding).leafComponentType;
- if (typeBinding instanceof ProblemReferenceBinding) return INACCURATE_MATCH;
- if (typeRef instanceof SingleTypeReference){
- return this.matchLevelForType(this.simpleName, this.qualification, typeBinding);
- } else { // QualifiedTypeReference
- QualifiedTypeReference qTypeRef = (QualifiedTypeReference)typeRef;
- char[][] tokens = qTypeRef.tokens;
- int lastIndex = tokens.length-1;
- // try to match all enclosing types for which the token matches as well.
- while (typeBinding != null && lastIndex >= 0){
- if (matchesName(this.simpleName, tokens[lastIndex--])) {
- int level = this.matchLevelForType(this.simpleName, this.qualification, typeBinding);
- if (level != IMPOSSIBLE_MATCH) {
- return level;
- }
- }
- if (typeBinding instanceof ReferenceBinding){
- typeBinding = ((ReferenceBinding)typeBinding).enclosingType();
- } else {
- typeBinding = null;
+ }
+ if (typeRef instanceof SingleTypeReference){
+ return this.matchLevelForType(this.simpleName, this.qualification, typeBinding);
+ } else { // QualifiedTypeReference
+ QualifiedTypeReference qTypeRef = (QualifiedTypeReference)typeRef;
+ char[][] tokens = qTypeRef.tokens;
+ int lastIndex = tokens.length-1;
+ // try to match all enclosing types for which the token matches as well.
+ while (typeBinding != null && lastIndex >= 0){
+ if (matchesName(this.simpleName, tokens[lastIndex--])) {
+ int level = this.matchLevelForType(this.simpleName, this.qualification, typeBinding);
+ if (level != IMPOSSIBLE_MATCH) {
+ return level;
}
}
- return IMPOSSIBLE_MATCH;
- }
- }
+ if (typeBinding instanceof ReferenceBinding){
+ typeBinding = ((ReferenceBinding)typeBinding).enclosingType();
+ } else {
+ typeBinding = null;
+ }
+ }
+ return IMPOSSIBLE_MATCH;
+ }
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/messages.properties b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/messages.properties
index fee1842..15541ac 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/messages.properties
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/messages.properties
@@ -1,3 +1,13 @@
+###############################################################################
+# Copyright (c) 2000, 2003 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
### Eclipse Java Core Search messages.
engine.searching = Searching...
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/IJob.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/IJob.java
index 7f7d4e7..b53d454 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/IJob.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/IJob.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.processing;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -32,11 +32,12 @@
* can take an undertermined amount of time.
*/
public void cancel();
-
/**
- * Execute the current job, answering:
- * RESCHEDULE if the job should be rescheduled later on
- * COMPLETE if the job is over
+ * Execute the current job, answer whether it was successful.
*/
public boolean execute(IProgressMonitor progress);
-}
\ No newline at end of file
+ /**
+ * Answer whether the job is ready to run.
+ */
+ public boolean isReadyToRun();
+}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java
index f33a71d..f178548 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java
@@ -1,13 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
+ * are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
package org.eclipse.jdt.internal.core.search.processing;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -73,12 +73,18 @@
}
public synchronized void disable() {
enabled = false;
+ if (VERBOSE)
+ JobManager.verbose("DISABLING background indexing"); //$NON-NLS-1$
}
/**
* Remove the index from cache for a given project.
* Passing null as a job family discards them all.
*/
public void discardJobs(String jobFamily) {
+
+ if (VERBOSE)
+ JobManager.verbose("DISCARD background job family - " + jobFamily); //$NON-NLS-1$
+
boolean wasEnabled = isEnabled();
try {
IJob currentJob;
@@ -95,7 +101,9 @@
// wait until current active job has finished
while (thread != null && executing){
try {
- Thread.currentThread().sleep(50);
+ if (VERBOSE)
+ JobManager.verbose("-> waiting end of current background job - " + currentJob); //$NON-NLS-1$ //$NON-NLS-2$
+ Thread.sleep(50);
} catch(InterruptedException e){
}
}
@@ -111,6 +119,8 @@
|| currentJob.belongsTo(jobFamily))) { // copy down, compacting
awaitingJobs[++loc] = currentJob;
} else {
+ if (VERBOSE)
+ JobManager.verbose("-> discarding background job - " + currentJob); //$NON-NLS-1$
currentJob.cancel();
}
}
@@ -121,9 +131,13 @@
if (wasEnabled)
enable();
}
+ if (VERBOSE)
+ JobManager.verbose("DISCARD DONE with background job family - " + jobFamily); //$NON-NLS-1$
}
public synchronized void enable() {
enabled = true;
+ if (VERBOSE)
+ JobManager.verbose("ENABLING background indexing"); //$NON-NLS-1$
}
public synchronized boolean isEnabled() {
return enabled;
@@ -170,18 +184,23 @@
IProgressMonitor progress) {
if (VERBOSE)
- JobManager.verbose("STARTING concurrent job - " + searchJob); //$NON-NLS-1$
- int concurrentJobWork = 100;
- if (progress != null) {
- progress.beginTask("", concurrentJobWork); //$NON-NLS-1$
+ JobManager.verbose("STARTING concurrent job - " + searchJob); //$NON-NLS-1$
+ if (!searchJob.isReadyToRun()) {
+ if (VERBOSE)
+ JobManager.verbose("ABORTED concurrent job - " + searchJob); //$NON-NLS-1$
+ return IJob.FAILED;
}
+
+ int concurrentJobWork = 100;
+ if (progress != null)
+ progress.beginTask("", concurrentJobWork); //$NON-NLS-1$
boolean status = IJob.FAILED;
if (awaitingJobsCount() > 0) {
switch (waitingPolicy) {
case IJob.ForceImmediate :
if (VERBOSE)
- JobManager.verbose("-> NOT READY - Forcing immediate - " + searchJob);//$NON-NLS-1$
+ JobManager.verbose("-> NOT READY - forcing immediate - " + searchJob);//$NON-NLS-1$
boolean wasEnabled = isEnabled();
try {
disable(); // pause indexing
@@ -191,15 +210,16 @@
enable();
}
if (VERBOSE)
- JobManager.verbose("DONE concurrent job - " + searchJob); //$NON-NLS-1$
+ JobManager.verbose("FINISHED concurrent job - " + searchJob); //$NON-NLS-1$
return status;
+
case IJob.CancelIfNotReady :
if (VERBOSE)
- JobManager.verbose("-> NOT READY - Cancelling - " + searchJob); //$NON-NLS-1$
- progress.setCanceled(true);
+ JobManager.verbose("-> NOT READY - cancelling - " + searchJob); //$NON-NLS-1$
+ if (progress != null) progress.setCanceled(true);
if (VERBOSE)
- JobManager.verbose("CANCELLED concurrent job - " + searchJob); //$NON-NLS-1$
- break;
+ JobManager.verbose("CANCELED concurrent job - " + searchJob); //$NON-NLS-1$
+ throw new OperationCanceledException();
case IJob.WaitUntilReady :
int awaitingWork;
@@ -215,8 +235,11 @@
int originalPriority = this.thread.getPriority();
try {
synchronized(this) {
- if (this.thread != null) {
- this.thread.setPriority(Thread.currentThread().getPriority());
+
+ // use local variable to avoid potential NPE (see Bug 20435 NPE when searching java method)
+ Thread t = this.thread;
+ if (t != null) {
+ t.setPriority(Thread.currentThread().getPriority());
}
this.awaitingClients++;
}
@@ -227,7 +250,7 @@
// currentJob can be null when jobs have been added to the queue but job manager is not enabled
if (currentJob != null && currentJob != previousJob) {
if (VERBOSE)
- JobManager.verbose("-> NOT READY - Waiting until ready - " + searchJob);//$NON-NLS-1$
+ JobManager.verbose("-> NOT READY - waiting until ready - " + searchJob);//$NON-NLS-1$
if (subProgress != null) {
subProgress.subTask(
Util.bind("manager.filesToIndex", Integer.toString(awaitingWork))); //$NON-NLS-1$
@@ -243,8 +266,11 @@
} finally {
synchronized(this) {
this.awaitingClients--;
- if (this.thread != null) {
- this.thread.setPriority(originalPriority);
+
+ // use local variable to avoid potential NPE (see Bug 20435 NPE when searching java method)
+ Thread t = this.thread;
+ if (t != null) {
+ t.setPriority(originalPriority);
}
}
}
@@ -258,12 +284,17 @@
progress.done();
}
if (VERBOSE)
- JobManager.verbose("DONE concurrent job - " + searchJob); //$NON-NLS-1$
+ JobManager.verbose("FINISHED concurrent job - " + searchJob); //$NON-NLS-1$
return status;
}
public abstract String processName();
public synchronized void request(IJob job) {
+ if (!job.isReadyToRun()) {
+ if (VERBOSE)
+ JobManager.verbose("ABORTED request of background job - " + job); //$NON-NLS-1$
+ return;
+ }
// append the job to the list of ones to process later on
int size = awaitingJobs.length;
@@ -279,13 +310,15 @@
}
awaitingJobs[jobEnd] = job;
if (VERBOSE)
- JobManager.verbose("REQUESTING job - " + job); //$NON-NLS-1$
+ JobManager.verbose("REQUEST background job - " + job); //$NON-NLS-1$
}
/**
* Flush current state
*/
public void reset() {
+ if (VERBOSE)
+ JobManager.verbose("Reset"); //$NON-NLS-1$
if (thread != null) {
discardJobs(null); // discard all jobs
@@ -313,14 +346,14 @@
if (idlingStart < 0)
idlingStart = System.currentTimeMillis();
notifyIdle(System.currentTimeMillis() - idlingStart);
- Thread.currentThread().sleep(500);
+ Thread.sleep(500);
continue;
} else {
idlingStart = -1;
}
if (VERBOSE) {
JobManager.verbose(awaitingJobsCount() + " awaiting jobs"); //$NON-NLS-1$
- JobManager.verbose("STARTING to execute - " + job); //$NON-NLS-1$
+ JobManager.verbose("STARTING background job - " + job); //$NON-NLS-1$
}
try {
executing = true;
@@ -329,7 +362,7 @@
} finally {
executing = false;
if (VERBOSE) {
- JobManager.verbose("DONE executing - " + job); //$NON-NLS-1$
+ JobManager.verbose("FINISHED background job - " + job); //$NON-NLS-1$
}
moveToNextJob();
if (this.awaitingClients == 0) {
@@ -347,9 +380,20 @@
// keep job manager alive
this.discardJobs(null);
this.thread = null;
- this.reset(); // this will fork a new thread
- throw e;
+ this.reset(); // this will fork a new thread with no waiting jobs, some indexes will be inconsistent
}
+ throw e;
+ } catch (Error e) {
+ if (this.thread != null && !(e instanceof ThreadDeath)) {
+ // log exception
+ org.eclipse.jdt.internal.core.Util.log(e, "Background Indexer Crash Recovery"); //$NON-NLS-1$
+
+ // keep job manager alive
+ this.discardJobs(null);
+ this.thread = null;
+ this.reset(); // this will fork a new thread with no waiting jobs, some indexes will be inconsistent
+ }
+ throw e;
}
}
/**
@@ -362,8 +406,20 @@
Thread thread = this.thread;
this.thread = null; // mark the job manager as shutting down so that the thread will stop by itself
try {
- thread.join();
+ if (thread != null) { // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=31858
+ thread.join();
+ }
} catch (InterruptedException e) {
}
}
-}
\ No newline at end of file
+public String toString() {
+ StringBuffer buffer = new StringBuffer(10);
+ buffer.append("Enabled:").append(this.enabled).append('\n'); //$NON-NLS-1$
+ int numJobs = jobEnd - jobStart + 1;
+ buffer.append("Jobs in queue:").append(numJobs).append('\n'); //$NON-NLS-1$
+ for (int i = 0; i < numJobs && i < 15; i++) {
+ buffer.append(i).append(" - job["+i+"]: ").append(awaitingJobs[jobStart+i]).append('\n'); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return buffer.toString();
+}
+}