Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivian Kong2012-08-21 12:35:30 -0400
committerVivian Kong2012-08-21 12:35:30 -0400
commit05cae5beb4ff59e476cfecd3ed6dd21b2ddc0ba3 (patch)
tree7188b15417c28798b8e7ab42627312ba91047f49
parentb5c2b0ce158d3d6b8c4a2628e5815df34833b478 (diff)
downloadorg.eclipse.cdt-05cae5beb4ff59e476cfecd3ed6dd21b2ddc0ba3.tar.gz
org.eclipse.cdt-05cae5beb4ff59e476cfecd3ed6dd21b2ddc0ba3.tar.xz
org.eclipse.cdt-05cae5beb4ff59e476cfecd3ed6dd21b2ddc0ba3.zip
Bug 387428 - NPE in RefreshScopeManager
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java30
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java33
2 files changed, 52 insertions, 11 deletions
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
index 4bc8323db7..bbfc50bcb5 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/resources/tests/RefreshScopeTests.java
@@ -53,6 +53,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
public class RefreshScopeTests extends TestCase {
private IProject fProject;
+ private IProject fGeneralProject;
private IFolder fFolder1;
private IFolder fFolder2;
private IFolder fFolder3;
@@ -73,6 +74,20 @@ public class RefreshScopeTests extends TestCase {
public void run(IProgressMonitor monitor) throws CoreException {
ICProject cProject = CProjectHelper.createNewStileCProject("testRefreshScope", IPDOMManager.ID_NO_INDEXER, false);
fProject = cProject.getProject();
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ fGeneralProject = root.getProject("testRefreshScopeGeneral");
+ assertNotNull(fGeneralProject);
+
+ if (!fGeneralProject.exists()) {
+ fGeneralProject.create(null);
+ } else {
+ fGeneralProject.refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+
+ if (!fGeneralProject.isOpen()) {
+ fGeneralProject.open(null);
+ }
}
}, null);
@@ -662,6 +677,21 @@ public class RefreshScopeTests extends TestCase {
}
+ public void testNullProjectDescription_bug387428() {
+ final String CFG_NAME="empty_config";
+
+ CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
+ ICProjectDescription projectDescription = descriptionManager.getProjectDescription(fGeneralProject, false);
+ assertNull(projectDescription);
+
+ RefreshScopeManager manager = RefreshScopeManager.getInstance();
+ manager.clearAllData();
+
+ List<IResource> empty_config_resources = manager.getResourcesToRefresh(fGeneralProject, CFG_NAME);
+ assertEquals(1,empty_config_resources.size());
+ assertEquals(true,empty_config_resources.contains(fGeneralProject));
+ }
+
public static Test suite() {
return new TestSuite(RefreshScopeTests.class);
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
index 39cd795b69..577e79ea6e 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/resources/RefreshScopeManager.java
@@ -167,8 +167,7 @@ public class RefreshScopeManager {
});
} catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ CCorePlugin.log(e);
}
}
}
@@ -393,6 +392,16 @@ public class RefreshScopeManager {
getProjectToConfigurationToResourcesMap();
HashMap<IResource, List<RefreshExclusion>> resourceMap = getResourcesToExclusionsMap(project,configName);
+
+ //special case for bug 387428
+ CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
+ ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
+ if (projectDescription == null && resourceMap.keySet().isEmpty()) {
+ //return project itself as the default to refresh
+ ArrayList<IResource> resources = new ArrayList<IResource>();
+ resources.add(project);
+ return resources;
+ }
return new ArrayList<IResource>(resourceMap.keySet());
}
@@ -520,13 +529,16 @@ public class RefreshScopeManager {
// for each build configuration
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
- ICConfigurationDescription cfgDescs[] = projectDescription.getConfigurations();
- for (ICConfigurationDescription cfgDesc : cfgDescs) {
- String configName = cfgDesc.getName();
- HashMap<IResource, List<RefreshExclusion>> resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
- if (!fIsLoading || fIsNewProject) //config settings could be loading and detects a new project and if so, add the default refresh setting
- resourceMap.put(project, new LinkedList<RefreshExclusion>());
- configMap.put(configName, resourceMap);
+
+ if (projectDescription != null) {
+ ICConfigurationDescription cfgDescs[] = projectDescription.getConfigurations();
+ for (ICConfigurationDescription cfgDesc : cfgDescs) {
+ String configName = cfgDesc.getName();
+ HashMap<IResource, List<RefreshExclusion>> resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
+ if (!fIsLoading || fIsNewProject) //config settings could be loading and detects a new project and if so, add the default refresh setting
+ resourceMap.put(project, new LinkedList<RefreshExclusion>());
+ configMap.put(configName, resourceMap);
+ }
}
// and add this configMap to the project to config map.
@@ -609,8 +621,7 @@ public class RefreshScopeManager {
addExclusion(project, configName, resource, exclusion);
}
} catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ CCorePlugin.log(e);
}
}
}

Back to the top