use of org.eclipse.linuxtools.internal.perf.model.PMLineRef in project linuxtools by eclipse.
the class PerfDoubleClickAction method run.
@Override
public void run() {
IStructuredSelection selection = viewer.getStructuredSelection();
Object obj = selection.getFirstElement();
try {
if (obj instanceof PMLineRef) {
// Open in editor
PMLineRef line = (PMLineRef) obj;
PMFile file = (PMFile) ((PMSymbol) line.getParent()).getParent();
ProfileUIUtils.openEditorAndSelect(file.getPath(), Integer.parseInt(line.getName()), PerfPlugin.getDefault().getProfiledProject());
} else if (obj instanceof PMFile) {
PMFile file = (PMFile) obj;
ProfileUIUtils.openEditorAndSelect(file.getName(), 1);
} else if (obj instanceof PMSymbol) {
PMSymbol sym = (PMSymbol) obj;
PMFile file = (PMFile) sym.getParent();
PMDso dso = (PMDso) file.getParent();
if (file.getName().equals(PerfPlugin.STRINGS_UnfiledSymbols))
// Don't try to do anything if we don't know where or what the symbol is.
return;
String binaryPath = dso.getPath();
ICProject project;
project = ProfileUIUtils.findCProjectWithAbsolutePath(binaryPath);
Map<String, int[]> map = ProfileUIUtils.findFunctionsInProject(project, sym.getFunctionName(), -1, file.getPath(), true);
boolean bFound = false;
for (Map.Entry<String, int[]> entry : map.entrySet()) {
ProfileUIUtils.openEditorAndSelect(entry.getKey(), entry.getValue()[0], entry.getValue()[1]);
bFound = true;
}
if (!bFound) {
ProfileUIUtils.openEditorAndSelect(file.getPath(), 1, ResourcesPlugin.getWorkspace().getRoot().getProject(dso.getName()));
}
}
// if we encounter an exception, act as though no corresponding source exists
} catch (NumberFormatException | BadLocationException | CoreException e) {
}
}
Aggregations