1 package net.sourceforge.phpeclipse.xdebug.php.launching;
4 import org.eclipse.core.resources.IProject;
5 import org.eclipse.core.resources.ResourcesPlugin;
6 import org.eclipse.core.runtime.CoreException;
7 import org.eclipse.core.runtime.IProgressMonitor;
8 import org.eclipse.debug.core.ILaunchConfiguration;
9 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
10 import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
11 import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
12 import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer;
14 public class PHPSourcePathComputerDelegate implements ISourcePathComputerDelegate {
16 public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
17 // String path = configuration.getAttribute(IXDebugConstants.ATTR_PHP_PROGRAM, (String)null);
18 // ISourceContainer sourceContainer = null;
19 // if (path != null) {
20 // IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path));
21 // if (resource != null) {
22 // IContainer container = resource.getParent();
23 // if (container.getType() == IResource.PROJECT) {
24 // sourceContainer = new ProjectSourceContainer((IProject)container, false);
25 // } else if (container.getType() == IResource.FOLDER) {
26 // sourceContainer = new FolderSourceContainer(container, false);
30 // if (sourceContainer == null) {
31 // sourceContainer = new WorkspaceSourceContainer();
33 // return new ISourceContainer[]{sourceContainer};
34 String project = configuration.getAttribute(IXDebugConstants.ATTR_PHP_PROJECT, (String)null);
35 ISourceContainer sourceContainer = null;
36 if (project != null) {
37 IProject resource = ResourcesPlugin.getWorkspace().getRoot().getProject(project);
38 if (resource != null) {
39 sourceContainer = new ProjectSourceContainer(resource, false);
42 if (sourceContainer == null) {
43 sourceContainer = new WorkspaceSourceContainer();
45 return new ISourceContainer[]{sourceContainer};