author | timkelly |
Thu, 11 Mar 2010 13:45:01 -0600 | |
changeset 1096 | 96e5879cd42d |
child 2039 | 250d6109c006 |
permissions | -rw-r--r-- |
1096
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
1 |
package com.nokia.cdt.debug.common.internal.source.lookup; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
2 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
3 |
import java.util.ArrayList; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
4 |
import java.util.Arrays; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
5 |
import java.util.Iterator; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
6 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
7 |
import org.eclipse.core.runtime.CoreException; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
8 |
import org.eclipse.core.runtime.Path; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
9 |
import org.eclipse.debug.core.DebugPlugin; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
10 |
import org.eclipse.debug.core.ILaunchConfiguration; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
11 |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
12 |
import org.eclipse.debug.core.ILaunchManager; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
13 |
import org.eclipse.debug.core.model.ISourceLocator; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
14 |
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
15 |
import org.eclipse.debug.core.sourcelookup.ISourceContainer; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
16 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
17 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
18 |
public class SourceMappingUtils { |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
19 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
20 |
/** Name kept for legacy launch config settings purposes */ |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
21 |
private static final String EPOCROOT_SETTING = "com.nokia.cdt.debug.cw.symbian.Epoc_Root" ; //$NON-NLS-1$ |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
22 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
23 |
/** |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
24 |
* Add the source mapping for the workign copy of the launch config. Clients should ensure to call doSave() after this call. |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
25 |
* @param configuration |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
26 |
* @throws CoreException |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
27 |
*/ |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
28 |
public static void addSourceMappingToLaunch(ILaunchConfigurationWorkingCopy configuration) throws CoreException { |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
29 |
String memento = null; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
30 |
String type = null; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
31 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
32 |
memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String) null); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
33 |
type = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String) null); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
34 |
if (type == null) { |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
35 |
type = configuration.getType().getSourceLocatorId(); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
36 |
} |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
37 |
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
38 |
ISourceLocator locator = launchManager.newSourceLocator(type); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
39 |
if (locator instanceof AbstractSourceLookupDirector) { |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
40 |
AbstractSourceLookupDirector director = (AbstractSourceLookupDirector) locator; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
41 |
if (memento == null) { |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
42 |
director.initializeDefaults(configuration); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
43 |
} else { |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
44 |
director.initializeFromMemento(memento, configuration); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
45 |
} |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
46 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
47 |
addSourceMappingToDirector(director, configuration); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
48 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
49 |
configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, director.getMemento()); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
50 |
configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, director.getId()); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
51 |
} |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
52 |
} |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
53 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
54 |
private static void addSourceMappingToDirector(AbstractSourceLookupDirector director, ILaunchConfiguration configuration) throws CoreException { |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
55 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
56 |
ArrayList containerList = new ArrayList(Arrays.asList(director.getSourceContainers())); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
57 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
58 |
boolean hasSymbianContainer = false; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
59 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
60 |
SymbianSourceContainer symbianContainer = null; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
61 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
62 |
for (Iterator iter = containerList.iterator(); iter.hasNext() && !hasSymbianContainer;) { |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
63 |
ISourceContainer container = (ISourceContainer) iter.next(); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
64 |
if (container instanceof SymbianSourceContainer) |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
65 |
{ |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
66 |
hasSymbianContainer = true; |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
67 |
} |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
68 |
} |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
69 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
70 |
if (!hasSymbianContainer) { |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
71 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
72 |
String epocRootPath = configuration.getAttribute( EPOCROOT_SETTING, (String)null ); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
73 |
if (epocRootPath != null) |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
74 |
{ |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
75 |
symbianContainer = new SymbianSourceContainer(new Path(epocRootPath)); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
76 |
symbianContainer.init(director); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
77 |
containerList.add(symbianContainer); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
78 |
} |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
79 |
} |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
80 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
81 |
director.setSourceContainers((ISourceContainer[]) containerList.toArray(new ISourceContainer[containerList.size()])); |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
82 |
} |
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
83 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
84 |
|
96e5879cd42d
Initial commit. Refactor out source mapping support into common plugin to be used with DE and EDC.
timkelly
parents:
diff
changeset
|
85 |
} |