Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjarthanaree2011-04-20 09:18:13 +0000
committerjarthanaree2011-04-20 09:18:13 +0000
commit8deee5f9195b748608db7f7af21ba86e49a4e378 (patch)
tree3d2020031ef7080c2281cc5ebe75dfb5d183baed
parentafc138516d223c1d7995c8c0045825bb250d1778 (diff)
downloadorg.eclipse.jdt.core-8deee5f9195b748608db7f7af21ba86e49a4e378.tar.gz
org.eclipse.jdt.core-8deee5f9195b748608db7f7af21ba86e49a4e378.tar.xz
org.eclipse.jdt.core-8deee5f9195b748608db7f7af21ba86e49a4e378.zip
HEAD - Fixed bug 335986: No expected event fired when removing a JAR file from a classpath container
-rw-r--r--buildnotes_jdt-core.html4
-rw-r--r--model/org/eclipse/jdt/internal/core/ClasspathChange.java23
-rw-r--r--model/org/eclipse/jdt/internal/core/DeltaProcessor.java21
3 files changed, 40 insertions, 8 deletions
diff --git a/buildnotes_jdt-core.html b/buildnotes_jdt-core.html
index 3bbdf9b46..e99d730b2 100644
--- a/buildnotes_jdt-core.html
+++ b/buildnotes_jdt-core.html
@@ -51,7 +51,9 @@ Eclipse SDK 3.7M7 - %date% - 3.7.0 M7
<h2>What's new in this drop</h2>
<h3>Problem Reports Fixed</h3>
-<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=342671">342671</a>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=335986">335986</a>
+No expected event fired when removing a JAR file from a classpath container
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=342671">342671</a>
ClassCastException: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ArrayBinding
<a name="v_B48"></a>
diff --git a/model/org/eclipse/jdt/internal/core/ClasspathChange.java b/model/org/eclipse/jdt/internal/core/ClasspathChange.java
index ca00c9df6..34439d657 100644
--- a/model/org/eclipse/jdt/internal/core/ClasspathChange.java
+++ b/model/org/eclipse/jdt/internal/core/ClasspathChange.java
@@ -28,6 +28,7 @@ import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
+import org.eclipse.jdt.internal.core.DeltaProcessor.RootInfo;
import org.eclipse.jdt.internal.core.JavaModelManager.PerProjectInfo;
import org.eclipse.jdt.internal.core.search.indexing.IndexManager;
import org.eclipse.jdt.internal.core.util.Util;
@@ -304,7 +305,7 @@ public class ClasspathChange {
result |= HAS_LIBRARY_CHANGE;
}
- PackageFragmentRoot[] pkgFragmentRoots = null;
+ IPackageFragmentRoot[] pkgFragmentRoots = null;
if (removedRoots != null) {
PackageFragmentRoot oldRoot = (PackageFragmentRoot) removedRoots.get(this.oldResolvedClasspath[i].getPath());
if (oldRoot != null) { // use old root if any (could be none if entry wasn't bound)
@@ -323,6 +324,26 @@ public class ClasspathChange {
null, // inside original project
false, // don't retrieve exported roots
null); /*no reverse map*/
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=335986
+ // When a package fragment's corresponding resource is removed from the project,
+ // IJavaProject#computePackageFragmentRoots() doesn't include that entry. Hence
+ // the cache become necessary in such cases. Add the cache to the accumulatedRoots
+ // only when it's not already present.
+ RootInfo rootInfo = (RootInfo) state.oldRoots.get(this.oldResolvedClasspath[i].getPath());
+ if (rootInfo != null && rootInfo.cache != null) {
+ IPackageFragmentRoot oldRoot = rootInfo.cache;
+ boolean found = false;
+ for (int j = 0; j < accumulatedRoots.size(); j++) {
+ IPackageFragmentRoot root = (IPackageFragmentRoot) accumulatedRoots.elementAt(j);
+ if (!root.getPath().equals(oldRoot.getPath())) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ accumulatedRoots.add(oldRoot);
+ }
+
pkgFragmentRoots = new PackageFragmentRoot[accumulatedRoots.size()];
accumulatedRoots.copyInto(pkgFragmentRoots);
} catch (JavaModelException e) {
diff --git a/model/org/eclipse/jdt/internal/core/DeltaProcessor.java b/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
index 9d1aaf589..ac391143f 100644
--- a/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
+++ b/model/org/eclipse/jdt/internal/core/DeltaProcessor.java
@@ -105,26 +105,35 @@ public class DeltaProcessor {
IPath rootPath;
int entryKind;
IPackageFragmentRoot root;
+ IPackageFragmentRoot cache;
RootInfo(JavaProject project, IPath rootPath, char[][] inclusionPatterns, char[][] exclusionPatterns, int entryKind) {
this.project = project;
this.rootPath = rootPath;
this.inclusionPatterns = inclusionPatterns;
this.exclusionPatterns = exclusionPatterns;
this.entryKind = entryKind;
+ this.cache = getPackageFragmentRoot();
+ }
+ public IPackageFragmentRoot getPackageFragmentRoot() {
+ IPackageFragmentRoot tRoot = null;
+ Object target = JavaModel.getTarget(this.rootPath, false/*don't check existence*/);
+ if (target instanceof IResource) {
+ tRoot = this.project.getPackageFragmentRoot((IResource)target);
+ } else {
+ tRoot = this.project.getPackageFragmentRoot(this.rootPath.toOSString());
+ }
+ return tRoot;
}
public IPackageFragmentRoot getPackageFragmentRoot(IResource resource) {
if (this.root == null) {
if (resource != null) {
this.root = this.project.getPackageFragmentRoot(resource);
} else {
- Object target = JavaModel.getTarget(this.rootPath, false/*don't check existence*/);
- if (target instanceof IResource) {
- this.root = this.project.getPackageFragmentRoot((IResource)target);
- } else {
- this.root = this.project.getPackageFragmentRoot(this.rootPath.toOSString());
- }
+ this.root = getPackageFragmentRoot();
}
}
+ if (this.root != null)
+ this.cache = this.root;
return this.root;
}
boolean isRootOfProject(IPath path) {

Back to the top