909cb8d10eab9472f62e91ffad92224b9af12f69
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / launching / PHPSourcePathComputerDelegate.java
1 package net.sourceforge.phpeclipse.xdebug.php.launching;
2
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;
12
13 public class PHPSourcePathComputerDelegate implements
14                 ISourcePathComputerDelegate {
15
16         public ISourceContainer[] computeSourceContainers(
17                         ILaunchConfiguration configuration, IProgressMonitor monitor)
18                         throws CoreException {
19                 // String path =
20                 // configuration.getAttribute(IXDebugConstants.ATTR_PHP_PROGRAM,
21                 // (String)null);
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,
30                 // false);
31                 // } else if (container.getType() == IResource.FOLDER) {
32                 // sourceContainer = new FolderSourceContainer(container, false);
33                 // }
34                 // }
35                 // }
36                 // if (sourceContainer == null) {
37                 // sourceContainer = new WorkspaceSourceContainer();
38                 // }
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()
45                                         .getProject(project);
46                         if (resource != null) {
47                                 sourceContainer = new ProjectSourceContainer(resource, false);
48                         }
49                 }
50                 if (sourceContainer == null) {
51                         sourceContainer = new WorkspaceSourceContainer();
52                 }
53                 return new ISourceContainer[] { sourceContainer };
54
55         }
56
57 }