Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMikhail Sennikovsky2007-06-14 18:02:57 +0000
committerMikhail Sennikovsky2007-06-14 18:02:57 +0000
commit15620e0b892199da2452ef37ed25d4915f6a71b4 (patch)
tree097efc08dcf0475ccbdf644ae1b879e2eaa0fea7 /core
parentd8ba0d98a97b746eef57f15a3d16cda0a868349b (diff)
downloadorg.eclipse.cdt-15620e0b892199da2452ef37ed25d4915f6a71b4.tar.gz
org.eclipse.cdt-15620e0b892199da2452ef37ed25d4915f6a71b4.tar.xz
org.eclipse.cdt-15620e0b892199da2452ef37ed25d4915f6a71b4.zip
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
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java36
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java13
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java12
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java6
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java13
5 files changed, 66 insertions, 14 deletions
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java
index 3fa75087824..dfd1be0e12e 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionBasicTests.java
@@ -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();
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
index f01ea1e236c..9bfd5824abc 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java
@@ -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);
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java
index 17ccdf54b67..0d1800e5b65 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java
@@ -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);
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java
index d842ff4fb6f..9dbf94aa95a 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java
@@ -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{
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
index 3f3a8662365..7a40ab9b27e 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java
@@ -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);

Back to the top