use of org.eclipse.debug.core.sourcelookup.containers.ArchiveSourceContainer in project bndtools by bndtools.
the class BndDependencySourceContainer method createSourceContainers.
@Override
protected ISourceContainer[] createSourceContainers() throws CoreException {
List<ISourceContainer> result = new LinkedList<ISourceContainer>();
ILaunchConfiguration config = getLaunchConfiguration();
Set<String> projectsAdded = new HashSet<>();
try {
if (lastRun != null) {
LaunchUtils.endRun(lastRun);
}
Run run = LaunchUtils.createRun(config);
if (run != null) {
Collection<Container> runbundles = run.getRunbundles();
for (Container runbundle : runbundles) {
if (runbundle.getType() == TYPE.PROJECT) {
String targetProjName = runbundle.getProject().getName();
if (projectsAdded.add(targetProjName)) {
IProject targetProj = ResourcesPlugin.getWorkspace().getRoot().getProject(targetProjName);
if (targetProj != null) {
IJavaProject targetJavaProj = JavaCore.create(targetProj);
result.add(new JavaProjectSourceContainer(targetJavaProj));
}
}
} else if (runbundle.getType() == TYPE.REPO) {
IPath bundlePath = Central.toPath(runbundle.getFile());
IFile bundleFile = null;
if (bundlePath != null) {
bundleFile = ResourcesPlugin.getWorkspace().getRoot().getFile(bundlePath);
}
if (bundleFile != null) {
ISourceContainer sourceContainer = null;
// check to see if this archive came from a repo that encodes the source project name
final String sourceProjectName = runbundle.getAttributes().get("sourceProjectName");
if (sourceProjectName != null) {
try {
IProject sourceProject = ResourcesPlugin.getWorkspace().getRoot().getProject(sourceProjectName);
if (sourceProject.exists()) {
IJavaProject javaSourceProject = JavaCore.create(sourceProject);
sourceContainer = new JavaProjectSourceContainer(javaSourceProject);
}
} catch (Exception e) {
logger.logError("Error getting source java project", e);
}
}
if (sourceContainer == null) {
// default to archive source container
sourceContainer = new ArchiveSourceContainer(bundleFile, false);
}
result.add(sourceContainer);
} else {
ExternalArchiveSourceContainer container = new ExternalArchiveSourceContainer(runbundle.getFile().toString(), false);
result.add(container);
}
}
}
lastRun = run;
}
} catch (Exception e) {
logger.logError("Error querying Bnd dependency source containers.", e);
}
return result.toArray(new ISourceContainer[0]);
}
Aggregations