Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDavid Inglis2004-03-25 14:39:19 -0500
committerDavid Inglis2004-03-25 14:39:19 -0500
commitb173623edb4ba3885f893558fb18377ad78e88be (patch)
tree6cbf7c6ddcd7094cb44ab28c6e12d0f4c7a02453 /core
parentffde7d87bc108b6f7a7ff7876cc4c59cc15b8d4c (diff)
downloadorg.eclipse.cdt-b173623edb4ba3885f893558fb18377ad78e88be.tar.gz
org.eclipse.cdt-b173623edb4ba3885f893558fb18377ad78e88be.tar.xz
org.eclipse.cdt-b173623edb4ba3885f893558fb18377ad78e88be.zip
lets throw the exception so that we can get full back trace instead of asserting
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/testplugin/CProjectHelper.java102
2 files changed, 48 insertions, 56 deletions
diff --git a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java
index 27575d065b..7c63a50cf2 100644
--- a/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java
+++ b/core/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java
@@ -125,7 +125,7 @@ public class IndexManagerTests extends TestCase {
/*
* Utils
*/
- private IProject createProject(String projectName) {
+ private IProject createProject(String projectName) throws CoreException {
ICProject cPrj = CProjectHelper.createCCProject(projectName, "bin");
return cPrj.getProject();
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/testplugin/CProjectHelper.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/testplugin/CProjectHelper.java
index 9ff72c1a10..2fca7b9a9d 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/testplugin/CProjectHelper.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/testplugin/CProjectHelper.java
@@ -40,34 +40,31 @@ public class CProjectHelper {
/**
* Creates a ICProject.
*/
- public static ICProject createCProject(final String projectName, String binFolderName){
+ public static ICProject createCProject(final String projectName, String binFolderName) throws CoreException {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final IProject newProject[] = new IProject[1];
- try {
- ws.run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- IWorkspaceRoot root = ws.getRoot();
- IProject project = root.getProject(projectName);
- if (!project.exists()) {
- project.create(null);
- } else {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- if (!project.isOpen()) {
- project.open(null);
- }
- if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
- String projectId = CTestPlugin.PLUGIN_ID + ".TestProject";
- addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
- CCorePlugin.getDefault().mapCProjectOwner(project, projectId, false);
- }
- newProject[0] = project;
+ ws.run(new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ IWorkspaceRoot root = ws.getRoot();
+ IProject project = root.getProject(projectName);
+ if (!project.exists()) {
+ project.create(null);
+ } else {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
}
- }, null);
- } catch (CoreException e) {
- Assert.fail(getMessage(e.getStatus()));
- }
-
+ if (!project.isOpen()) {
+ project.open(null);
+ }
+ if (!project.hasNature(CProjectNature.C_NATURE_ID)) {
+ String projectId = CTestPlugin.PLUGIN_ID + ".TestProject";
+ addNatureToProject(project, CProjectNature.C_NATURE_ID, null);
+ CCorePlugin.getDefault().mapCProjectOwner(project, projectId, false);
+ }
+ newProject[0] = project;
+ }
+ }, null);
+
return CCorePlugin.getDefault().getCoreModel().create(newProject[0]);
}
@@ -84,22 +81,19 @@ public class CProjectHelper {
return message.toString();
}
- public static ICProject createCCProject(final String projectName, final String binFolderName) {
+ public static ICProject createCCProject(final String projectName, final String binFolderName) throws CoreException {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final ICProject newProject[] = new ICProject[1];
- try {
- ws.run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- ICProject cproject = createCProject(projectName, binFolderName);
- if (!cproject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
- addNatureToProject(cproject.getProject(), CCProjectNature.CC_NATURE_ID, null);
- }
- newProject[0] = cproject;
+ ws.run(new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) throws CoreException {
+ ICProject cproject = createCProject(projectName, binFolderName);
+ if (!cproject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
+ addNatureToProject(cproject.getProject(), CCProjectNature.CC_NATURE_ID, null);
}
- }, null);
- } catch (CoreException e) {
- Assert.fail(getMessage(e.getStatus()));
- }
+ newProject[0] = cproject;
+ }
+ }, null);
return newProject[0];
}
@@ -145,11 +139,10 @@ public class CProjectHelper {
}
/**
- * Adds a folder container to a ICProject and imports all files contained
- * in the given Zip file.
+ * Adds a folder container to a ICProject and imports all files contained in the given Zip file.
*/
public static ICContainer addCContainerWithImport(ICProject cproject, String containerName, ZipFile zipFile)
- throws InvocationTargetException, CoreException {
+ throws InvocationTargetException, CoreException {
ICContainer root = addCContainer(cproject, containerName);
importFilesFromZip(zipFile, root.getPath(), null);
return root;
@@ -170,11 +163,9 @@ public class CProjectHelper {
int x;
IArchive[] myArchives;
IArchiveContainer archCont;
- /***********************************************************************
- * Since ArchiveContainer.getArchives does not wait until all the
- * archives in the project have been parsed before returning the list,
- * we have to do a sync ArchiveContainer.getChildren first to make sure
- * we find all the archives.
+ /***************************************************************************************************************************
+ * Since ArchiveContainer.getArchives does not wait until all the archives in the project have been parsed before returning
+ * the list, we have to do a sync ArchiveContainer.getChildren first to make sure we find all the archives.
*/
archCont = testProject.getArchiveContainer();
myArchives = archCont.getArchives();
@@ -211,12 +202,12 @@ public class CProjectHelper {
public static IBinary findObject(ICProject testProject, String name) {
ICElement[] sourceRoots = testProject.getChildren();
for (int i = 0; i < sourceRoots.length; i++) {
- ISourceRoot root = (ISourceRoot)sourceRoots[i];
+ ISourceRoot root = (ISourceRoot) sourceRoots[i];
ICElement[] myElements = root.getChildren();
for (int x = 0; x < myElements.length; x++) {
if (myElements[x].getElementName().equals(name)) {
if (myElements[x] instanceof IBinary) {
- return ((IBinary)myElements[x]);
+ return ((IBinary) myElements[x]);
}
}
}
@@ -230,12 +221,12 @@ public class CProjectHelper {
public static ITranslationUnit findTranslationUnit(ICProject testProject, String name) {
ICElement[] sourceRoots = testProject.getChildren();
for (int i = 0; i < sourceRoots.length; i++) {
- ISourceRoot root = (ISourceRoot)sourceRoots[i];
+ ISourceRoot root = (ISourceRoot) sourceRoots[i];
ICElement[] myElements = root.getChildren();
for (int x = 0; x < myElements.length; x++) {
if (myElements[x].getElementName().equals(name)) {
if (myElements[x] instanceof ITranslationUnit) {
- return ((ITranslationUnit)myElements[x]);
+ return ((ITranslationUnit) myElements[x]);
}
}
}
@@ -249,7 +240,7 @@ public class CProjectHelper {
public static ICElement findElement(ICProject testProject, String name) {
ICElement[] sourceRoots = testProject.getChildren();
for (int i = 0; i < sourceRoots.length; i++) {
- ISourceRoot root = (ISourceRoot)sourceRoots[i];
+ ISourceRoot root = (ISourceRoot) sourceRoots[i];
ICElement[] myElements = root.getChildren();
for (int x = 0; x < myElements.length; x++) {
if (myElements[x].getElementName().equals(name)) {
@@ -271,11 +262,11 @@ public class CProjectHelper {
}
private static void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor)
- throws InvocationTargetException {
+ throws InvocationTargetException {
ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(srcZipFile);
try {
- ImportOperation op =
- new ImportOperation(destPath, structureProvider.getRoot(), structureProvider, new ImportOverwriteQuery());
+ ImportOperation op = new ImportOperation(destPath, structureProvider.getRoot(), structureProvider,
+ new ImportOverwriteQuery());
op.run(monitor);
} catch (InterruptedException e) {
// should not happen
@@ -283,8 +274,9 @@ public class CProjectHelper {
}
private static class ImportOverwriteQuery implements IOverwriteQuery {
+
public String queryOverwrite(String file) {
return ALL;
}
}
-}
+} \ No newline at end of file

Back to the top