use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction in project linuxtools by eclipse.
the class CModelLabelsTest method testNestedMethodLabel.
@Test
public void testNestedMethodLabel() throws Exception {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testNestedMethodLabel");
CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
CachegrindOutput output = view.getOutputs()[0];
// $NON-NLS-1$
CachegrindFile file = getFileByName(output, "cpptest.cpp");
// $NON-NLS-1$
CachegrindFunction func = getFunctionByName(file, "A::B::e()");
assertTrue(func.getModel() instanceof IMethod);
checkLabelProvider(func, file);
}
use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction in project linuxtools by eclipse.
the class CachegrindViewPart method getHeaderListener.
private SelectionListener getHeaderListener() {
return SelectionListener.widgetSelectedAdapter(e -> {
TreeColumn column = (TreeColumn) e.widget;
Tree tree = viewer.getTree();
if (column.equals(tree.getSortColumn())) {
int direction = tree.getSortDirection() == SWT.UP ? SWT.DOWN : SWT.UP;
tree.setSortDirection(direction);
} else {
tree.setSortDirection(SWT.UP);
}
tree.setSortColumn(column);
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
Tree tree = ((TreeViewer) viewer).getTree();
int direction = tree.getSortDirection();
ICachegrindElement o1 = (ICachegrindElement) e1;
ICachegrindElement o2 = (ICachegrindElement) e2;
long result = 0;
int sortIndex = Arrays.asList(tree.getColumns()).indexOf(tree.getSortColumn());
if (sortIndex == 0) {
// use compareTo
result = o1.compareTo(o2);
} else {
long[] v1 = null;
long[] v2 = null;
if (o1 instanceof CachegrindFunction && o2 instanceof CachegrindFunction) {
v1 = ((CachegrindFunction) o1).getTotals();
v2 = ((CachegrindFunction) o2).getTotals();
} else if (o1 instanceof CachegrindLine && o2 instanceof CachegrindLine) {
v1 = ((CachegrindLine) o1).getValues();
v2 = ((CachegrindLine) o2).getValues();
} else if (o1 instanceof CachegrindOutput && o2 instanceof CachegrindOutput) {
v1 = ((CachegrindOutput) o1).getSummary();
v2 = ((CachegrindOutput) o2).getSummary();
}
if (v1 != null && v2 != null) {
result = v1[sortIndex - 1] - v2[sortIndex - 1];
}
}
// ascending or descending
result = direction == SWT.UP ? result : -result;
// overflow check
if (result > Integer.MAX_VALUE) {
result = Integer.MAX_VALUE;
} else if (result < Integer.MIN_VALUE) {
result = Integer.MIN_VALUE;
}
return (int) result;
}
});
});
}
use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction in project linuxtools by eclipse.
the class CModelLabelsTest method testMethodLabel.
@Test
public void testMethodLabel() throws Exception {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testMethodLabel");
CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
CachegrindOutput output = view.getOutputs()[0];
// $NON-NLS-1$
CachegrindFile file = getFileByName(output, "cpptest.cpp");
// $NON-NLS-1$
CachegrindFunction func = getFunctionByName(file, "A::A()");
assertTrue(func.getModel() instanceof IMethod);
checkLabelProvider(func, file);
}
use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction in project linuxtools by eclipse.
the class CModelLabelsTest method testFunctionLabel.
@Test
public void testFunctionLabel() throws Exception {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testFunctionLabel");
CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
CachegrindOutput output = view.getOutputs()[0];
// $NON-NLS-1$
CachegrindFile file = getFileByName(output, "cpptest.cpp");
// $NON-NLS-1$
CachegrindFunction func = getFunctionByName(file, "main");
assertTrue(func.getModel() instanceof IFunction);
checkLabelProvider(func, file);
}
use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction in project linuxtools by eclipse.
the class DoubleClickTest method testDoubleClickFunction.
@Test
public void testDoubleClickFunction() throws Exception {
ILaunchConfiguration config = createConfiguration(proj.getProject());
// $NON-NLS-1$
doLaunch(config, "testDoubleClickFunction");
CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
CachegrindOutput output = view.getOutputs()[0];
// $NON-NLS-1$
CachegrindFile file = getFileByName(output, "cpptest.cpp");
// $NON-NLS-1$
CachegrindFunction func = getFunctionByName(file, "main");
TreePath path = new TreePath(new Object[] { output, file, func });
doDoubleClick(path);
// check file in editor
IEditorPart editor = checkFile(file);
// check line number
ITextEditor textEditor = (ITextEditor) editor;
ISelection selection = textEditor.getSelectionProvider().getSelection();
TextSelection textSelection = (TextSelection) selection;
// zero-indexed
int line = textSelection.getStartLine() + 1;
int expectedLine = ((IFunction) func.getModel()).getSourceRange().getStartLine();
assertEquals(expectedLine, line);
}
Aggregations