mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 19:35:36 +02:00
Code cleanup.
This commit is contained in:
parent
f0e6a286fb
commit
dfacdf9d40
1 changed files with 30 additions and 53 deletions
|
@ -282,7 +282,7 @@ 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)
|
public static ICContainer addCContainerWithImport(ICProject cproject, String containerName, ZipFile zipFile)
|
||||||
throws InvocationTargetException, CoreException {
|
throws InvocationTargetException, CoreException {
|
||||||
|
@ -320,10 +320,8 @@ public class CProjectHelper {
|
||||||
ArrayList<IPathEntry> newEntries= new ArrayList<>(entries.length + 1);
|
ArrayList<IPathEntry> newEntries= new ArrayList<>(entries.length + 1);
|
||||||
|
|
||||||
for (IPathEntry entry : entries) {
|
for (IPathEntry entry : entries) {
|
||||||
if (entry.getEntryKind() == IPathEntry.CDT_SOURCE) {
|
if (entry.getEntryKind() == IPathEntry.CDT_SOURCE && rootPath.equals(entry.getPath())) {
|
||||||
if (rootPath.equals(entry.getPath())) {
|
return; // The source root exists already.
|
||||||
return; // The source root exists already.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
newEntries.add(entry);
|
newEntries.add(entry);
|
||||||
}
|
}
|
||||||
|
@ -342,20 +340,14 @@ public class CProjectHelper {
|
||||||
* Attempts to find an archive with the given name in the workspace
|
* Attempts to find an archive with the given name in the workspace
|
||||||
*/
|
*/
|
||||||
public static IArchive findArchive(ICProject testProject, String name) throws CModelException {
|
public static IArchive findArchive(ICProject testProject, String name) throws CModelException {
|
||||||
int x;
|
// Since ArchiveContainer.getArchives does not wait until all the archives in the project
|
||||||
IArchive[] myArchives;
|
// have been parsed before returning the list, we have to do a sync
|
||||||
IArchiveContainer archCont;
|
// ArchiveContainer.getChildren first to make sure we find all the archives.
|
||||||
/***************************************************************************************************************************
|
IArchiveContainer archCont = testProject.getArchiveContainer();
|
||||||
* Since ArchiveContainer.getArchives does not wait until all the archives in the project have been parsed before returning
|
IArchive[] myArchives = archCont.getArchives();
|
||||||
* the list, we have to do a sync ArchiveContainer.getChildren first to make sure we find all the archives.
|
for (IArchive archive : myArchives) {
|
||||||
*/
|
if (archive.getElementName().equals(name))
|
||||||
archCont = testProject.getArchiveContainer();
|
return archive;
|
||||||
myArchives = archCont.getArchives();
|
|
||||||
if (myArchives.length < 1)
|
|
||||||
return null;
|
|
||||||
for (x = 0; x < myArchives.length; x++) {
|
|
||||||
if (myArchives[x].getElementName().equals(name))
|
|
||||||
return (myArchives[x]);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -364,16 +356,10 @@ public class CProjectHelper {
|
||||||
* Attempts to find a binary with the given name in the workspace
|
* Attempts to find a binary with the given name in the workspace
|
||||||
*/
|
*/
|
||||||
public static IBinary findBinary(ICProject testProject, String name) throws CModelException {
|
public static IBinary findBinary(ICProject testProject, String name) throws CModelException {
|
||||||
IBinaryContainer binCont;
|
IBinaryContainer binCont = testProject.getBinaryContainer();
|
||||||
int x;
|
for (IBinary binary : binCont.getBinaries()) {
|
||||||
IBinary[] myBinaries;
|
if (binary.getElementName().equals(name))
|
||||||
binCont = testProject.getBinaryContainer();
|
return binary;
|
||||||
myBinaries = binCont.getBinaries();
|
|
||||||
if (myBinaries.length < 1)
|
|
||||||
return null;
|
|
||||||
for (x = 0; x < myBinaries.length; x++) {
|
|
||||||
if (myBinaries[x].getElementName().equals(name))
|
|
||||||
return (myBinaries[x]);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -383,14 +369,10 @@ public class CProjectHelper {
|
||||||
*/
|
*/
|
||||||
public static IBinary findObject(ICProject testProject, String name) throws CModelException {
|
public static IBinary findObject(ICProject testProject, String name) throws CModelException {
|
||||||
ICElement[] sourceRoots = testProject.getChildren();
|
ICElement[] sourceRoots = testProject.getChildren();
|
||||||
for (int i = 0; i < sourceRoots.length; i++) {
|
for (ICElement root : sourceRoots) {
|
||||||
ISourceRoot root = (ISourceRoot) sourceRoots[i];
|
for (ICElement element : ((ISourceRoot) root).getChildren()) {
|
||||||
ICElement[] myElements = root.getChildren();
|
if (element.getElementName().equals(name) && element instanceof IBinary) {
|
||||||
for (int x = 0; x < myElements.length; x++) {
|
return ((IBinary) element);
|
||||||
if (myElements[x].getElementName().equals(name)) {
|
|
||||||
if (myElements[x] instanceof IBinary) {
|
|
||||||
return ((IBinary) myElements[x]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,17 +382,14 @@ public class CProjectHelper {
|
||||||
/**
|
/**
|
||||||
* Attempts to find a TranslationUnit with the given name in the workspace.
|
* Attempts to find a TranslationUnit with the given name in the workspace.
|
||||||
*/
|
*/
|
||||||
public static ITranslationUnit findTranslationUnit(ICProject testProject, String name) throws CModelException, InterruptedException {
|
public static ITranslationUnit findTranslationUnit(ICProject testProject, String name)
|
||||||
|
throws CModelException, InterruptedException {
|
||||||
for (int j = 0; j < 20; j++) {
|
for (int j = 0; j < 20; j++) {
|
||||||
ICElement[] sourceRoots = testProject.getChildren();
|
ICElement[] sourceRoots = testProject.getChildren();
|
||||||
for (int i = 0; i < sourceRoots.length; i++) {
|
for (ICElement root : sourceRoots) {
|
||||||
ISourceRoot root = (ISourceRoot) sourceRoots[i];
|
for (ICElement element : ((ISourceRoot) root).getChildren()) {
|
||||||
ICElement[] myElements = root.getChildren();
|
if (element.getElementName().equals(name) && element instanceof ITranslationUnit) {
|
||||||
for (int x = 0; x < myElements.length; x++) {
|
return ((ITranslationUnit) element);
|
||||||
if (myElements[x].getElementName().equals(name)) {
|
|
||||||
if (myElements[x] instanceof ITranslationUnit) {
|
|
||||||
return ((ITranslationUnit) myElements[x]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,12 +403,10 @@ public class CProjectHelper {
|
||||||
*/
|
*/
|
||||||
public static ICElement findElement(ICProject testProject, String name) throws CModelException {
|
public static ICElement findElement(ICProject testProject, String name) throws CModelException {
|
||||||
ICElement[] sourceRoots = testProject.getChildren();
|
ICElement[] sourceRoots = testProject.getChildren();
|
||||||
for (int i = 0; i < sourceRoots.length; i++) {
|
for (ICElement root : sourceRoots) {
|
||||||
ISourceRoot root = (ISourceRoot) sourceRoots[i];
|
for (ICElement element : ((ISourceRoot) root).getChildren()) {
|
||||||
ICElement[] myElements = root.getChildren();
|
if (element.getElementName().equals(name)) {
|
||||||
for (int x = 0; x < myElements.length; x++) {
|
return element;
|
||||||
if (myElements[x].getElementName().equals(name)) {
|
|
||||||
return myElements[x];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,7 +431,7 @@ public class CProjectHelper {
|
||||||
OVERWRITE_QUERY);
|
OVERWRITE_QUERY);
|
||||||
op.run(monitor);
|
op.run(monitor);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// should not happen
|
// Should not happen.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue