mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
lets throw the exception so that we can get full back trace instead of asserting
This commit is contained in:
parent
ffde7d87bc
commit
b173623edb
2 changed files with 48 additions and 56 deletions
|
@ -125,7 +125,7 @@ public class IndexManagerTests extends TestCase {
|
||||||
/*
|
/*
|
||||||
* Utils
|
* Utils
|
||||||
*/
|
*/
|
||||||
private IProject createProject(String projectName) {
|
private IProject createProject(String projectName) throws CoreException {
|
||||||
ICProject cPrj = CProjectHelper.createCCProject(projectName, "bin");
|
ICProject cPrj = CProjectHelper.createCCProject(projectName, "bin");
|
||||||
return cPrj.getProject();
|
return cPrj.getProject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,11 +40,11 @@ public class CProjectHelper {
|
||||||
/**
|
/**
|
||||||
* Creates a ICProject.
|
* 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 IWorkspace ws = ResourcesPlugin.getWorkspace();
|
||||||
final IProject newProject[] = new IProject[1];
|
final IProject newProject[] = new IProject[1];
|
||||||
try {
|
|
||||||
ws.run(new IWorkspaceRunnable() {
|
ws.run(new IWorkspaceRunnable() {
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
IWorkspaceRoot root = ws.getRoot();
|
IWorkspaceRoot root = ws.getRoot();
|
||||||
IProject project = root.getProject(projectName);
|
IProject project = root.getProject(projectName);
|
||||||
|
@ -64,9 +64,6 @@ public class CProjectHelper {
|
||||||
newProject[0] = project;
|
newProject[0] = project;
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
} catch (CoreException e) {
|
|
||||||
Assert.fail(getMessage(e.getStatus()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return CCorePlugin.getDefault().getCoreModel().create(newProject[0]);
|
return CCorePlugin.getDefault().getCoreModel().create(newProject[0]);
|
||||||
}
|
}
|
||||||
|
@ -84,11 +81,11 @@ public class CProjectHelper {
|
||||||
return message.toString();
|
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 IWorkspace ws = ResourcesPlugin.getWorkspace();
|
||||||
final ICProject newProject[] = new ICProject[1];
|
final ICProject newProject[] = new ICProject[1];
|
||||||
try {
|
|
||||||
ws.run(new IWorkspaceRunnable() {
|
ws.run(new IWorkspaceRunnable() {
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
ICProject cproject = createCProject(projectName, binFolderName);
|
ICProject cproject = createCProject(projectName, binFolderName);
|
||||||
if (!cproject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
|
if (!cproject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
|
||||||
|
@ -97,9 +94,6 @@ public class CProjectHelper {
|
||||||
newProject[0] = cproject;
|
newProject[0] = cproject;
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
} catch (CoreException e) {
|
|
||||||
Assert.fail(getMessage(e.getStatus()));
|
|
||||||
}
|
|
||||||
return newProject[0];
|
return newProject[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,8 +139,7 @@ public class CProjectHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a folder container to a ICProject and imports all files contained
|
* Adds a folder container to a ICProject and imports all files contained in the given Zip file.
|
||||||
* in the given Zip file.
|
|
||||||
*/
|
*/
|
||||||
public static ICContainer addCContainerWithImport(ICProject cproject, String containerName, ZipFile zipFile)
|
public static ICContainer addCContainerWithImport(ICProject cproject, String containerName, ZipFile zipFile)
|
||||||
throws InvocationTargetException, CoreException {
|
throws InvocationTargetException, CoreException {
|
||||||
|
@ -170,11 +163,9 @@ public class CProjectHelper {
|
||||||
int x;
|
int x;
|
||||||
IArchive[] myArchives;
|
IArchive[] myArchives;
|
||||||
IArchiveContainer archCont;
|
IArchiveContainer archCont;
|
||||||
/***********************************************************************
|
/***************************************************************************************************************************
|
||||||
* Since ArchiveContainer.getArchives does not wait until all the
|
* Since ArchiveContainer.getArchives does not wait until all the archives in the project have been parsed before returning
|
||||||
* archives in the project have been parsed before returning the list,
|
* the list, we have to do a sync ArchiveContainer.getChildren first to make sure we find all the archives.
|
||||||
* we have to do a sync ArchiveContainer.getChildren first to make sure
|
|
||||||
* we find all the archives.
|
|
||||||
*/
|
*/
|
||||||
archCont = testProject.getArchiveContainer();
|
archCont = testProject.getArchiveContainer();
|
||||||
myArchives = archCont.getArchives();
|
myArchives = archCont.getArchives();
|
||||||
|
@ -211,12 +202,12 @@ public class CProjectHelper {
|
||||||
public static IBinary findObject(ICProject testProject, String name) {
|
public static IBinary findObject(ICProject testProject, String name) {
|
||||||
ICElement[] sourceRoots = testProject.getChildren();
|
ICElement[] sourceRoots = testProject.getChildren();
|
||||||
for (int i = 0; i < sourceRoots.length; i++) {
|
for (int i = 0; i < sourceRoots.length; i++) {
|
||||||
ISourceRoot root = (ISourceRoot)sourceRoots[i];
|
ISourceRoot root = (ISourceRoot) sourceRoots[i];
|
||||||
ICElement[] myElements = root.getChildren();
|
ICElement[] myElements = root.getChildren();
|
||||||
for (int x = 0; x < myElements.length; x++) {
|
for (int x = 0; x < myElements.length; x++) {
|
||||||
if (myElements[x].getElementName().equals(name)) {
|
if (myElements[x].getElementName().equals(name)) {
|
||||||
if (myElements[x] instanceof IBinary) {
|
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) {
|
public static ITranslationUnit findTranslationUnit(ICProject testProject, String name) {
|
||||||
ICElement[] sourceRoots = testProject.getChildren();
|
ICElement[] sourceRoots = testProject.getChildren();
|
||||||
for (int i = 0; i < sourceRoots.length; i++) {
|
for (int i = 0; i < sourceRoots.length; i++) {
|
||||||
ISourceRoot root = (ISourceRoot)sourceRoots[i];
|
ISourceRoot root = (ISourceRoot) sourceRoots[i];
|
||||||
ICElement[] myElements = root.getChildren();
|
ICElement[] myElements = root.getChildren();
|
||||||
for (int x = 0; x < myElements.length; x++) {
|
for (int x = 0; x < myElements.length; x++) {
|
||||||
if (myElements[x].getElementName().equals(name)) {
|
if (myElements[x].getElementName().equals(name)) {
|
||||||
if (myElements[x] instanceof ITranslationUnit) {
|
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) {
|
public static ICElement findElement(ICProject testProject, String name) {
|
||||||
ICElement[] sourceRoots = testProject.getChildren();
|
ICElement[] sourceRoots = testProject.getChildren();
|
||||||
for (int i = 0; i < sourceRoots.length; i++) {
|
for (int i = 0; i < sourceRoots.length; i++) {
|
||||||
ISourceRoot root = (ISourceRoot)sourceRoots[i];
|
ISourceRoot root = (ISourceRoot) sourceRoots[i];
|
||||||
ICElement[] myElements = root.getChildren();
|
ICElement[] myElements = root.getChildren();
|
||||||
for (int x = 0; x < myElements.length; x++) {
|
for (int x = 0; x < myElements.length; x++) {
|
||||||
if (myElements[x].getElementName().equals(name)) {
|
if (myElements[x].getElementName().equals(name)) {
|
||||||
|
@ -274,8 +265,8 @@ public class CProjectHelper {
|
||||||
throws InvocationTargetException {
|
throws InvocationTargetException {
|
||||||
ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(srcZipFile);
|
ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(srcZipFile);
|
||||||
try {
|
try {
|
||||||
ImportOperation op =
|
ImportOperation op = new ImportOperation(destPath, structureProvider.getRoot(), structureProvider,
|
||||||
new ImportOperation(destPath, structureProvider.getRoot(), structureProvider, new ImportOverwriteQuery());
|
new ImportOverwriteQuery());
|
||||||
op.run(monitor);
|
op.run(monitor);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// should not happen
|
// should not happen
|
||||||
|
@ -283,6 +274,7 @@ public class CProjectHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ImportOverwriteQuery implements IOverwriteQuery {
|
private static class ImportOverwriteQuery implements IOverwriteQuery {
|
||||||
|
|
||||||
public String queryOverwrite(String file) {
|
public String queryOverwrite(String file) {
|
||||||
return ALL;
|
return ALL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue