mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
1. JavaDoc foxes for [Bug 191913] ICProjectDescriptionManager.getProjectDescription returns null
2. make the setProjectDescription throw CoreException instead of IllegalArgumentException in case of the inability to aquire the root rule
This commit is contained in:
parent
d8ba0d98a9
commit
15620e0b89
6 changed files with 86 additions and 35 deletions
|
@ -102,7 +102,6 @@ import org.eclipse.core.resources.IContainer;
|
|||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceRuleFactory;
|
||||
import org.eclipse.core.resources.IResourceStatus;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
|
@ -121,8 +120,6 @@ import org.eclipse.core.runtime.Platform;
|
|||
import org.eclipse.core.runtime.PluginVersionIdentifier;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.core.runtime.jobs.IJobManager;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
@ -1396,26 +1393,28 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
try {
|
||||
return updateBuildInfo(project, force);
|
||||
} catch (CoreException e) {
|
||||
Throwable cause = e.getStatus().getException();
|
||||
if(cause instanceof IllegalArgumentException){
|
||||
//can not acquire the root rule
|
||||
Job j = new Job("save build info job"){
|
||||
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
updateBuildInfo(project, force);
|
||||
} catch (CoreException e) {
|
||||
return e.getStatus();
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
};
|
||||
j.setRule(ResourcesPlugin.getWorkspace().getRoot());
|
||||
j.setSystem(true);
|
||||
j.schedule();
|
||||
return true;
|
||||
}
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
return false;
|
||||
} catch (IllegalArgumentException e){
|
||||
//can not acquire the root rule
|
||||
Job j = new Job("save build info job"){
|
||||
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
updateBuildInfo(project, force);
|
||||
} catch (CoreException e) {
|
||||
return e.getStatus();
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
};
|
||||
j.setRule(ResourcesPlugin.getWorkspace().getRoot());
|
||||
j.setSystem(true);
|
||||
j.schedule();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,12 @@ import org.eclipse.core.resources.IWorkspaceRoot;
|
|||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.jobs.IJobManager;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
public class CProjectDescriptionBasicTests extends BaseTestCase{
|
||||
private static final String PROJ_NAME_PREFIX = "CProjectDescriptionBasicTests_";
|
||||
IProject p1, p2, p3;
|
||||
IProject p1, p2, p3, p4;
|
||||
|
||||
public static TestSuite suite() {
|
||||
return suite(CProjectDescriptionBasicTests.class, "_");
|
||||
|
@ -159,6 +161,33 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
|
|||
mngr.setProjectDescription(p2, des);
|
||||
|
||||
}
|
||||
|
||||
public void testSetDescriptionWithRootIncompatibleRuleAquired() throws Exception {
|
||||
ICProject p = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "4", IPDOMManager.ID_NO_INDEXER);
|
||||
p4 = p.getProject();
|
||||
|
||||
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
|
||||
|
||||
ICProjectDescription des = mngr.getProjectDescription(p4);
|
||||
ICConfigurationDescription baseCfg = des.getConfigurations()[0];
|
||||
|
||||
baseCfg.setName("qwertyuiop");
|
||||
|
||||
IJobManager jm = Job.getJobManager();
|
||||
boolean failed = false;
|
||||
try {
|
||||
jm.beginRule(p4, null);
|
||||
|
||||
mngr.setProjectDescription(p4, des);
|
||||
} catch (CoreException e) {
|
||||
failed = true;
|
||||
assertTrue(e.getStatus().getException() instanceof IllegalArgumentException);
|
||||
} finally {
|
||||
jm.endRule(p4);
|
||||
}
|
||||
|
||||
assertTrue(failed);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
try {
|
||||
|
@ -176,6 +205,11 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
|
|||
p3.getProject().delete(true, null);
|
||||
} catch (CoreException e){
|
||||
}
|
||||
try {
|
||||
if(p4 != null)
|
||||
p4.getProject().delete(true, null);
|
||||
} catch (CoreException e){
|
||||
}
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
|||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
||||
import org.eclipse.cdt.internal.core.model.APathEntry;
|
||||
import org.eclipse.cdt.internal.core.model.BatchOperation;
|
||||
import org.eclipse.cdt.internal.core.model.CModel;
|
||||
|
@ -1340,14 +1341,16 @@ public class CoreModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* returns the project description associated with this project
|
||||
* returns the project description associated with this project or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
*
|
||||
* this is a convenience method fully equivalent to getProjectDescription(project, true)
|
||||
* see {@link #getProjectDescription(IProject, boolean)} for more detail
|
||||
* @param project
|
||||
* @return a writable copy of the ICProjectDescription or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
* Note: changes to the project description will not be reflected/used by the core
|
||||
* untill the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
|
||||
* until the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
|
||||
*
|
||||
* @see #getProjectDescription(IProject, boolean)
|
||||
*/
|
||||
|
@ -1376,7 +1379,8 @@ public class CoreModel {
|
|||
}
|
||||
|
||||
/**
|
||||
* returns the project description associated with this project
|
||||
* returns the project description associated with this project or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
*
|
||||
* @param project project for which the description is requested
|
||||
* @param write if true, the writable description copy is returned.
|
||||
|
@ -1398,7 +1402,8 @@ public class CoreModel {
|
|||
* i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension
|
||||
* This ensures the Core<->Build System settings integrity
|
||||
*
|
||||
* @return {@link ICProjectDescription}
|
||||
* @return {@link ICProjectDescription} or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
*/
|
||||
public ICProjectDescription getProjectDescription(IProject project, boolean write){
|
||||
return descriptionManager.getProjectDescription(project, write);
|
||||
|
|
|
@ -47,14 +47,16 @@ public interface ICProjectDescriptionManager {
|
|||
|
||||
|
||||
/**
|
||||
* returns the project description associated with this project
|
||||
* returns the project description associated with this project or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
*
|
||||
* this is a convenience method fully equivalent to getProjectDescription(project, true)
|
||||
* see {@link #getProjectDescription(IProject, boolean)} for more detail
|
||||
* @param project
|
||||
* @return a writable copy of the ICProjectDescription or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
* Note: changes to the project description will not be reflected/used by the core
|
||||
* untill the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
|
||||
* until the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
|
||||
*
|
||||
* @see #getProjectDescription(IProject, boolean)
|
||||
*/
|
||||
|
@ -79,7 +81,8 @@ public interface ICProjectDescriptionManager {
|
|||
void setProjectDescription(IProject project, ICProjectDescription des, int flags, IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
/**
|
||||
* returns the project description associated with this project
|
||||
* returns the project description associated with this project or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
*
|
||||
* @param project project for which the description is requested
|
||||
* @param write if true, the writable description copy is returned.
|
||||
|
@ -101,7 +104,8 @@ public interface ICProjectDescriptionManager {
|
|||
* i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension
|
||||
* This ensures the Core<->Build System settings integrity
|
||||
*
|
||||
* @return {@link ICProjectDescription}
|
||||
* @return {@link ICProjectDescription} or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
*/
|
||||
ICProjectDescription getProjectDescription(IProject project, boolean write);
|
||||
|
||||
|
|
|
@ -1198,7 +1198,11 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
ICProject cproject = manager.create(project);
|
||||
|
||||
SetCProjectDescriptionOperation op = new SetCProjectDescriptionOperation(cproject, (CProjectDescription)des, flags);
|
||||
op.runOperation(monitor);
|
||||
try {
|
||||
op.runOperation(monitor);
|
||||
} catch (IllegalArgumentException e){
|
||||
throw ExceptionFactory.createCoreException(e);
|
||||
}
|
||||
}
|
||||
|
||||
IWorkspaceRunnable createDesSerializationRunnable(CProjectDescription des) throws CoreException{
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
|||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||
import org.eclipse.cdt.internal.core.CContentTypes;
|
||||
import org.eclipse.cdt.internal.core.CDTLogWriter;
|
||||
|
@ -1125,14 +1126,16 @@ public class CCorePlugin extends Plugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* returns the project description associated with this project
|
||||
* returns the project description associated with this project or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
*
|
||||
* this is a convenience method fully equivalent to getProjectDescription(project, true)
|
||||
* see {@link #getProjectDescription(IProject, boolean)} for more detail
|
||||
* @param project
|
||||
* @return a writable copy of the ICProjectDescription or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
* Note: changes to the project description will not be reflected/used by the core
|
||||
* untill the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
|
||||
* until the {@link #setProjectDescription(IProject, ICProjectDescription)} is called
|
||||
*
|
||||
* @see #getProjectDescription(IProject, boolean)
|
||||
*/
|
||||
|
@ -1161,7 +1164,8 @@ public class CCorePlugin extends Plugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* returns the project description associated with this project
|
||||
* returns the project description associated with this project or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
*
|
||||
* @param project project for which the description is requested
|
||||
* @param write if true, the writable description copy is returned.
|
||||
|
@ -1183,7 +1187,8 @@ public class CCorePlugin extends Plugin {
|
|||
* i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension
|
||||
* This ensures the Core<->Build System settings integrity
|
||||
*
|
||||
* @return {@link ICProjectDescription}
|
||||
* @return {@link ICProjectDescription} or null if the project does not contain the
|
||||
* CDT data associated with it.
|
||||
*/
|
||||
public ICProjectDescription getProjectDescription(IProject project, boolean write){
|
||||
return fNewCProjectDescriptionManager.getProjectDescription(project, write);
|
||||
|
|
Loading…
Add table
Reference in a new issue