author | wpaul |
Fri, 07 Aug 2009 13:47:27 -0500 | |
changeset 60 | 3982fab6369e |
parent 37 | c2bce6dd59e7 |
permissions | -rw-r--r-- |
37 | 1 |
/******************************************************************************* |
2 |
* Copyright (c) 2008 Nokia and others. |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* Nokia - Initial API and implementation |
|
10 |
*******************************************************************************/ |
|
11 |
||
12 |
package org.eclipse.cdt.debug.internal.core.executables; |
|
13 |
||
14 |
import org.eclipse.cdt.debug.core.CDebugCorePlugin; |
|
15 |
import org.eclipse.cdt.debug.core.executables.ISourceFileRemapping; |
|
16 |
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; |
|
17 |
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector; |
|
18 |
import org.eclipse.core.runtime.CoreException; |
|
60
3982fab6369e
fixed executables view merge problems - bug #'s 9562, 9568, 9571.
wpaul
parents:
37
diff
changeset
|
19 |
import org.eclipse.core.runtime.IPath; |
37 | 20 |
import org.eclipse.debug.core.DebugPlugin; |
21 |
import org.eclipse.debug.core.ILaunch; |
|
22 |
import org.eclipse.debug.core.ILaunchManager; |
|
23 |
import org.eclipse.debug.core.model.ISourceLocator; |
|
24 |
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; |
|
25 |
||
26 |
public class StandardSourceFileRemapping implements ISourceFileRemapping { |
|
27 |
||
60
3982fab6369e
fixed executables view merge problems - bug #'s 9562, 9568, 9571.
wpaul
parents:
37
diff
changeset
|
28 |
public String remapSourceFile(IPath executable, String filePath) { |
37 | 29 |
|
30 |
try { |
|
31 |
Object[] foundElements = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().findSourceElements(filePath); |
|
32 |
||
33 |
if (foundElements.length == 0) { |
|
34 |
Object foundElement = null; |
|
35 |
ILaunchManager launchMgr = DebugPlugin.getDefault().getLaunchManager(); |
|
36 |
ILaunch[] launches = launchMgr.getLaunches(); |
|
37 |
for (ILaunch launch : launches) { |
|
38 |
ISourceLocator locator = launch.getSourceLocator(); |
|
39 |
if (locator instanceof ICSourceLocator || locator instanceof CSourceLookupDirector) { |
|
40 |
if (locator instanceof ICSourceLocator) |
|
41 |
foundElement = ((ICSourceLocator) locator).findSourceElement(filePath); |
|
42 |
else |
|
43 |
foundElement = ((CSourceLookupDirector) locator).getSourceElement(filePath); |
|
44 |
} |
|
45 |
} |
|
46 |
if (foundElement != null) |
|
47 |
foundElements = new Object[] { foundElement }; |
|
48 |
} |
|
49 |
||
50 |
if (foundElements.length == 1 && foundElements[0] instanceof LocalFileStorage) { |
|
51 |
LocalFileStorage newLocation = (LocalFileStorage) foundElements[0]; |
|
52 |
filePath = newLocation.getFullPath().toOSString(); |
|
53 |
} |
|
54 |
||
55 |
} catch (CoreException e) { |
|
56 |
} |
|
57 |
return filePath; |
|
58 |
} |
|
59 |
||
60 |
} |