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