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
b5c2b0ce15
commit
05cae5beb4
2 changed files with 52 additions and 11 deletions
|
@ -53,6 +53,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
public class RefreshScopeTests extends TestCase {
|
public class RefreshScopeTests extends TestCase {
|
||||||
|
|
||||||
private IProject fProject;
|
private IProject fProject;
|
||||||
|
private IProject fGeneralProject;
|
||||||
private IFolder fFolder1;
|
private IFolder fFolder1;
|
||||||
private IFolder fFolder2;
|
private IFolder fFolder2;
|
||||||
private IFolder fFolder3;
|
private IFolder fFolder3;
|
||||||
|
@ -73,6 +74,20 @@ public class RefreshScopeTests extends TestCase {
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
ICProject cProject = CProjectHelper.createNewStileCProject("testRefreshScope", IPDOMManager.ID_NO_INDEXER, false);
|
ICProject cProject = CProjectHelper.createNewStileCProject("testRefreshScope", IPDOMManager.ID_NO_INDEXER, false);
|
||||||
fProject = cProject.getProject();
|
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);
|
}, 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() {
|
public static Test suite() {
|
||||||
return new TestSuite(RefreshScopeTests.class);
|
return new TestSuite(RefreshScopeTests.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,8 +167,7 @@ public class RefreshScopeManager {
|
||||||
|
|
||||||
});
|
});
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
// TODO Auto-generated catch block
|
CCorePlugin.log(e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,6 +392,16 @@ public class RefreshScopeManager {
|
||||||
getProjectToConfigurationToResourcesMap();
|
getProjectToConfigurationToResourcesMap();
|
||||||
|
|
||||||
HashMap<IResource, List<RefreshExclusion>> resourceMap = getResourcesToExclusionsMap(project,configName);
|
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());
|
return new ArrayList<IResource>(resourceMap.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,13 +529,16 @@ public class RefreshScopeManager {
|
||||||
// for each build configuration
|
// for each build configuration
|
||||||
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
|
CProjectDescriptionManager descriptionManager = CProjectDescriptionManager.getInstance();
|
||||||
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
|
ICProjectDescription projectDescription = descriptionManager.getProjectDescription(project, false);
|
||||||
ICConfigurationDescription cfgDescs[] = projectDescription.getConfigurations();
|
|
||||||
for (ICConfigurationDescription cfgDesc : cfgDescs) {
|
if (projectDescription != null) {
|
||||||
String configName = cfgDesc.getName();
|
ICConfigurationDescription cfgDescs[] = projectDescription.getConfigurations();
|
||||||
HashMap<IResource, List<RefreshExclusion>> resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
|
for (ICConfigurationDescription cfgDesc : cfgDescs) {
|
||||||
if (!fIsLoading || fIsNewProject) //config settings could be loading and detects a new project and if so, add the default refresh setting
|
String configName = cfgDesc.getName();
|
||||||
resourceMap.put(project, new LinkedList<RefreshExclusion>());
|
HashMap<IResource, List<RefreshExclusion>> resourceMap = new HashMap<IResource, List<RefreshExclusion>>();
|
||||||
configMap.put(configName, resourceMap);
|
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.
|
// and add this configMap to the project to config map.
|
||||||
|
@ -609,8 +621,7 @@ public class RefreshScopeManager {
|
||||||
addExclusion(project, configName, resource, exclusion);
|
addExclusion(project, configName, resource, exclusion);
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
// TODO Auto-generated catch block
|
CCorePlugin.log(e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue