01: package org.enhydra.kelp.eclipse.ui.launcher;
02:
03: import org.eclipse.core.runtime.CoreException;
04: import org.eclipse.core.runtime.IProgressMonitor;
05: import org.eclipse.debug.core.ILaunchConfiguration;
06: import org.eclipse.debug.core.sourcelookup.ISourceContainer;
07: import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
08: import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
09: import org.eclipse.jdt.launching.JavaRuntime;
10:
11: /**
12: * Computes a default source lookup path for Java applications.
13: * The source path provider associated with a launch configuration is consulted
14: * to compute a source lookup path. The source path provider is determined
15: * by the <code>ATTR_SOURCE_PATH_PROVIDER</code> launch configration attribute,
16: * which defaults to the <code>StandardSourcePathProvider</code> when unspecified.
17: * The source path provider computes a collection of <code>IRuntimeClasspathEntry</code>'s
18: * which are translated to source containers (<code>ISourceContainer</code>).
19: * <p>
20: * Clients may subclass this class.
21: * </p>
22: * @since 3.0
23: *
24: */
25: public class JavaSourcePathComputer implements
26: ISourcePathComputerDelegate {
27:
28: /**
29: * Unique identifier for the local Java source path computer
30: * (value <code>org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer</code>).
31: */
32: public static final String ID = "org.enhydra.kelp.eclipse.ui.launcher.JavaSourcePathComputer"; //$NON-NLS-1$
33:
34: /* (non-Javadoc)
35: * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputer#getId()
36: *
37: * No longer used.
38: */
39: public String getId() {
40: return ID;
41: }
42:
43: /* (non-Javadoc)
44: * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
45: */
46: public ISourceContainer[] computeSourceContainers(
47: ILaunchConfiguration configuration, IProgressMonitor monitor)
48: throws CoreException {
49: IRuntimeClasspathEntry[] entries = JavaRuntime
50: .computeUnresolvedSourceLookupPath(configuration);
51: IRuntimeClasspathEntry[] resolved = JavaRuntime
52: .resolveSourceLookupPath(entries, configuration);
53: return JavaRuntime.getSourceContainers(resolved);
54: }
55:
56: }
|