Search in sources :

Example 1 with PMLineRef

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) {
    }
}
Also used : PMLineRef(org.eclipse.linuxtools.internal.perf.model.PMLineRef) ICProject(org.eclipse.cdt.core.model.ICProject) PMDso(org.eclipse.linuxtools.internal.perf.model.PMDso) PMSymbol(org.eclipse.linuxtools.internal.perf.model.PMSymbol) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CoreException(org.eclipse.core.runtime.CoreException) PMFile(org.eclipse.linuxtools.internal.perf.model.PMFile) Map(java.util.Map) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

Map (java.util.Map)1 ICProject (org.eclipse.cdt.core.model.ICProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 PMDso (org.eclipse.linuxtools.internal.perf.model.PMDso)1 PMFile (org.eclipse.linuxtools.internal.perf.model.PMFile)1 PMLineRef (org.eclipse.linuxtools.internal.perf.model.PMLineRef)1 PMSymbol (org.eclipse.linuxtools.internal.perf.model.PMSymbol)1