mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 387428 - NPE in RefreshScopeManager
This commit is contained in:
parent
712d9b86d5
commit
21b42beb1f
2 changed files with 52 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue