Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe2004-02-17 11:01:39 -0500
committerBogdan Gheorghe2004-02-17 11:01:39 -0500
commitfc47e17ed98b85d6ebd4811123ae98d3f3b50396 (patch)
treed52b97daf7896211bbe7a701f017694121c958e8
parent4823463798c65c93b26cb7243cc16629e894041f (diff)
downloadorg.eclipse.cdt-fc47e17ed98b85d6ebd4811123ae98d3f3b50396.tar.gz
org.eclipse.cdt-fc47e17ed98b85d6ebd4811123ae98d3f3b50396.tar.xz
org.eclipse.cdt-fc47e17ed98b85d6ebd4811123ae98d3f3b50396.zip
Patch for Thomas Fletcher: fix for Bug 52238 (NPE in UpdateDependancy). This patch makes sure that a resource has a location before it used in a dependency query.
-rw-r--r--core/org.eclipse.cdt.core.tests/ChangeLog3
-rw-r--r--core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java13
-rw-r--r--core/org.eclipse.cdt.core/dependency/ChangeLog4
-rw-r--r--core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java5
4 files changed, 24 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog
index 4b4c9541a7..8513b75687 100644
--- a/core/org.eclipse.cdt.core.tests/ChangeLog
+++ b/core/org.eclipse.cdt.core.tests/ChangeLog
@@ -1,3 +1,6 @@
+2004-02-17 Bogdan Gheorghe
+ -Added DependencyTests::testDependencyUpdateNPE from Thomas
+
2004-02-13 Bogdan Gheorghe
-Modified CompletionProposalsTest to reset the indexer thread at the
beginning of the test case - this means that the project will be indexed
diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java
index cbeb4e215e..3ecfff3e4b 100644
--- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java
+++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/DependencyTests.java
@@ -32,7 +32,9 @@ import org.eclipse.cdt.internal.core.search.PathCollector;
import org.eclipse.cdt.internal.core.search.PatternSearchJob;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
+import org.eclipse.cdt.internal.core.search.processing.IJob;
import org.eclipse.cdt.internal.core.sourcedependency.DependencyQueryJob;
+import org.eclipse.cdt.internal.core.sourcedependency.UpdateDependency;
import org.eclipse.cdt.internal.ui.search.CSearchResultCollector;
import org.eclipse.core.internal.resources.ResourceException;
import org.eclipse.core.resources.IFile;
@@ -73,6 +75,7 @@ import org.eclipse.core.runtime.Platform;
suite.addTest(new DependencyTests("testDepHeaderChangeReindex"));
suite.addTest(new DependencyTests("testDepSourceChangeTable"));
suite.addTest(new DependencyTests("testDepHeaderChangeTable"));
+ suite.addTest(new DependencyTests("testUpdateDependancyNPE"));
return suite;
}
/**
@@ -523,6 +526,16 @@ import org.eclipse.core.runtime.Platform;
compareArrays(iPath,beforeModel);
}
+
+ public void testUpdateDependancyNPE() {
+ IResource nonExistantResource = ResourcesPlugin.getWorkspace().getRoot().getProject("non-existant-project-aha");
+
+ assertFalse(nonExistantResource.exists());
+ assertNull(nonExistantResource.getLocation());
+
+ IJob job = new UpdateDependency(nonExistantResource);
+ assertFalse(job.execute(new NullProgressMonitor()));
+ }
public void testDepHeaderChangeReindex() throws Exception{
diff --git a/core/org.eclipse.cdt.core/dependency/ChangeLog b/core/org.eclipse.cdt.core/dependency/ChangeLog
index fc524c19ee..ad372ab13c 100644
--- a/core/org.eclipse.cdt.core/dependency/ChangeLog
+++ b/core/org.eclipse.cdt.core/dependency/ChangeLog
@@ -1,3 +1,7 @@
+2004-02-17 Bogdan Gheorghe
+ - Fix for Bug 52238 from Thomas Fletcher: Check to see if you can
+ get a location off the resource before attempting to use it
+
2003-11-10 Bogdan Gheorghe
- Added a null resource check in UpdateDependency to fix up
a potential NPE in the test suite
diff --git a/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java b/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java
index d3cc599589..fd66bda8bf 100644
--- a/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java
+++ b/core/org.eclipse.cdt.core/dependency/org/eclipse/cdt/internal/core/sourcedependency/UpdateDependency.java
@@ -60,11 +60,14 @@ public class UpdateDependency implements IJob {
*/
public boolean execute(IProgressMonitor progress) {
if (resource == null) return false;
+
+ IPath location = resource.getLocation();
+ if (location == null) return false;
PathCollector pathCollector = new PathCollector();
//SubProgressMonitor subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 5 );
ICSearchScope scope = SearchEngine.createWorkspaceScope();
- CSearchPattern pattern = CSearchPattern.createPattern(resource.getLocation().toOSString(),ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES,ICSearchConstants.EXACT_MATCH,true);
+ CSearchPattern pattern = CSearchPattern.createPattern(location.toOSString(),ICSearchConstants.INCLUDE, ICSearchConstants.REFERENCES,ICSearchConstants.EXACT_MATCH,true);
IndexManager indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
indexManager.performConcurrentJob(
new PatternSearchJob(

Back to the top