Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2009-12-24 22:05:02 +0000
committerAndrew Gvozdev2009-12-24 22:05:02 +0000
commit474bd757db6896e20efc37eeb038a43907b28447 (patch)
tree14aa34cb1a3a9008ce714ce517c3a6ea615406c6
parent0ef32519a1acaabbf7416f5ad6de309775a799b6 (diff)
downloadorg.eclipse.cdt-474bd757db6896e20efc37eeb038a43907b28447.tar.gz
org.eclipse.cdt-474bd757db6896e20efc37eeb038a43907b28447.tar.xz
org.eclipse.cdt-474bd757db6896e20efc37eeb038a43907b28447.zip
bug 298509: Project description delta is not created for some events
Added ability to create multiple configurations while creating CDT project
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ResourceHelper.java115
1 files changed, 76 insertions, 39 deletions
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ResourceHelper.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ResourceHelper.java
index f122608c4e1..aa0a69e306d 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ResourceHelper.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ResourceHelper.java
@@ -27,8 +27,11 @@ import junit.framework.Assert;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.testplugin.CProjectHelper;
+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.TestCfgDataProvider;
+import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -66,37 +69,62 @@ public class ResourceHelper {
private final static Set<IResource> resourcesCreated = new HashSet<IResource>();
/**
- * Creates CDT project in a specific location and opens it.
+ * Creates CDT project in a specific path in workspace and opens it.
*
* @param projectName - project name.
- * @param locationInWorkspace - location relative to workspace root.
+ * @param pathInWorkspace - path relative to workspace root.
* @return - new {@link IProject}.
* @throws CoreException - if the project can't be created.
* @throws OperationCanceledException...
*/
- public static IProject createCDTProject(String projectName, String locationInWorkspace) throws OperationCanceledException, CoreException {
+ public static IProject createCDTProject(String projectName, String pathInWorkspace) throws OperationCanceledException, CoreException {
+ return createCDTProject(projectName, pathInWorkspace, null);
+ }
+
+ /**
+ * Creates CDT project in a specific path in workspace adding specified configurations and opens it.
+ *
+ * @param projectName - project name.
+ * @param pathInWorkspace - path relative to workspace root.
+ * @param configurationIds - array of configuration IDs.
+ * @return - new {@link IProject}.
+ * @throws CoreException - if the project can't be created.
+ * @throws OperationCanceledException...
+ */
+ public static IProject createCDTProject(String projectName, String pathInWorkspace, String[] configurationIds) throws OperationCanceledException, CoreException {
+ CCorePlugin cdtCorePlugin = CCorePlugin.getDefault();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
+
IProject project = root.getProject(projectName);
+ IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);
resourcesCreated.add(project);
- IProjectDescription description = workspace.newProjectDescription(projectName);
- if(locationInWorkspace != null) {
- IPath absoluteLocation = root.getLocation().append(locationInWorkspace);
- description.setLocation(absoluteLocation);
+
+ IProjectDescription prjDescription = workspace.newProjectDescription(projectName);
+ if(pathInWorkspace != null) {
+ IPath absoluteLocation = root.getLocation().append(pathInWorkspace);
+ prjDescription.setLocation(absoluteLocation);
}
- project = CCorePlugin.getDefault().createCDTProject(description, project, NULL_MONITOR);
- Assert.assertNotNull(project);
- project.open(null);
- try {
- // CDT opens the Project with BACKGROUND_REFRESH enabled which causes the
- // refresh manager to refresh the project 200ms later. This Job interferes
- // with the resource change handler firing see: bug 271264
- Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null);
- } catch (Exception e) {
- // Ignore
+ if (configurationIds!=null && configurationIds.length>0) {
+ ICProjectDescriptionManager prjDescManager = cdtCorePlugin.getProjectDescriptionManager();
+
+ project.create(NULL_MONITOR);
+ project.open(NULL_MONITOR);
+
+ ICProjectDescription icPrjDescription = prjDescManager.createProjectDescription(project, false);
+ ICConfigurationDescription baseConfiguration = cdtCorePlugin.getPreferenceConfiguration(TestCfgDataProvider.PROVIDER_ID);
+
+ for (String cfgId : configurationIds) {
+ icPrjDescription.createConfiguration(cfgId, cfgId+" Name", baseConfiguration);
+ }
+ prjDescManager.setProjectDescription(project, icPrjDescription);
}
+ project = cdtCorePlugin.createCDTProject(prjDescription, project, NULL_MONITOR);
+ waitForProjectRefreshToFinish();
+ Assert.assertNotNull(project);
+ project.open(null);
Assert.assertTrue(project.isOpen());
return project;
@@ -114,23 +142,18 @@ public class ResourceHelper {
public static IProject createCDTProject(String projectName, URI locationURI) throws OperationCanceledException, CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
+
IProject project = root.getProject(projectName);
+ IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER);
resourcesCreated.add(project);
+
IProjectDescription description = workspace.newProjectDescription(projectName);
description.setLocationURI(locationURI);
project = CCorePlugin.getDefault().createCDTProject(description, project, NULL_MONITOR);
+ waitForProjectRefreshToFinish();
Assert.assertNotNull(project);
- project.open(null);
-
- try {
- // CDT opens the Project with BACKGROUND_REFRESH enabled which causes the
- // refresh manager to refresh the project 200ms later. This Job interferes
- // with the resource change handler firing see: bug 271264
- Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null);
- } catch (Exception e) {
- // Ignore
- }
+ project.open(null);
Assert.assertTrue(project.isOpen());
return project;
@@ -145,19 +168,22 @@ public class ResourceHelper {
* @throws OperationCanceledException...
*/
public static IProject createCDTProject(String projectName) throws OperationCanceledException, CoreException {
- return createCDTProject(projectName, (String)null);
+ return createCDTProject(projectName, null, null);
}
/**
- * Create a new style cdt project with an 1 project description
- * @param projectName
- * @return IProject
- * @throws Exception
+ * Creates a project with 1 test configuration and opens it.
+ *
+ * @param projectName - project name.
+ * @return - new {@link IProject}.
+ * @throws CoreException - if the project can't be created.
+ * @throws OperationCanceledException...
*/
public static IProject createCDTProjectWithConfig(String projectName) throws Exception {
- ICProject proj = CProjectHelper.createNewStileCProject(projectName, IPDOMManager.ID_FAST_INDEXER);
- resourcesCreated.add(proj.getProject());
- return proj.getProject();
+ IProject project = createCDTProject(projectName, null,
+ new String[] {"org.eclipse.cdt.core.tests.configuration"});
+ resourcesCreated.add(project);
+ return project;
}
/**
@@ -530,7 +556,7 @@ public class ResourceHelper {
public static void cleanUp() throws CoreException, IOException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
root.refreshLocal(IResource.DEPTH_INFINITE, NULL_MONITOR);
-
+
// Delete all external files & folders created using ResourceHelper
for (String loc : externalFilesCreated) {
File f = new File(loc);
@@ -538,7 +564,7 @@ public class ResourceHelper {
deleteRecursive(f);
}
externalFilesCreated.clear();
-
+
// Remove IResources created by this helper
for (IResource r : resourcesCreated) {
if (r.exists())
@@ -551,6 +577,17 @@ public class ResourceHelper {
resourcesCreated.clear();
}
+ private static void waitForProjectRefreshToFinish() {
+ try {
+ // CDT opens the Project with BACKGROUND_REFRESH enabled which causes the
+ // refresh manager to refresh the project 200ms later. This Job interferes
+ // with the resource change handler firing see: bug 271264
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null);
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+
/**
* Recursively delete a directory / file
*

Back to the top