use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class TreeSettingsTest method testGetProbeTree.
@Test
public void testGetProbeTree() {
TreeNode temp;
TreeNode t = new TreeNode("f", false);
TreeNode t1 = new TreeNode(null, false);
TreeNode t2 = new TreeNode(new StringBuilder("asfd"), true);
TreeSettings.setTrees(t, t);
temp = TreeSettings.getProbeTree();
assertEquals("Probs no children", 0, temp.getChildCount());
assertEquals("Probs object", t.getData().toString(), temp.getData().toString());
assertEquals("Probs display", t.toString(), temp.toString());
assertEquals("Probs clickable", t.isClickable(), temp.isClickable());
TreeSettings.setTrees(t, t1);
temp = TreeSettings.getProbeTree();
assertEquals("Probs no children", 0, temp.getChildCount());
assertEquals("Probs object", t1.getData(), temp.getData());
assertEquals("Probs display", t1.toString(), temp.toString());
assertEquals("Probs clickable", t1.isClickable(), temp.isClickable());
TreeSettings.setTrees(t, t2);
temp = TreeSettings.getProbeTree();
assertEquals("Probs no children", 0, temp.getChildCount());
assertEquals("Probs object", t2.getData().toString(), temp.getData());
assertEquals("Probs display", t2.toString(), temp.toString());
assertEquals("Probs clickable", t2.isClickable(), temp.isClickable());
t.add(t2);
t.add(t1);
TreeSettings.setTrees(t, t);
temp = TreeSettings.getProbeTree();
assertEquals("Probs has children", 2, temp.getChildCount());
assertEquals("Probs child object", t2.getData().toString(), temp.getChildAt(0).getData());
assertEquals("Probs child display", t2.toString(), temp.getChildAt(0).toString());
}
use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class STPCompletionProcessor method getProbeCompletionList.
private ICompletionProposal[] getProbeCompletionList(String prefix, int offset) {
prefix = canonicalizePrefix(prefix);
TreeNode[] completionData = stpMetadataSingleton.getProbeCompletions(prefix);
ICompletionProposal[] result = new ICompletionProposal[completionData.length];
for (int i = 0; i < completionData.length; i++) {
result[i] = new STPProbeCompletionProposal(completionData[i], prefix.length(), offset);
}
return result;
}
use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class STPCompletionProcessor method getProbeVariableCompletions.
private ICompletionProposal[] getProbeVariableCompletions(IDocument document, int offset, String prefix) {
try {
String probeName = getProbe(document, offset);
TreeNode[] completionData = stpMetadataSingleton.getProbeVariableCompletions(probeName, prefix);
ICompletionProposal[] result = new ICompletionProposal[completionData.length];
for (int i = 0; i < completionData.length; i++) {
result[i] = new STPProbevarCompletionProposal(completionData[i], prefix.length(), offset, probeName);
}
return result;
} catch (BadLocationException | BadPartitioningException e) {
return NO_COMPLETIONS;
}
}
use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class STPCompletionProcessor method getFunctionCompletions.
private ICompletionProposal[] getFunctionCompletions(int offset, String prefix) {
TreeNode[] completionData = stpMetadataSingleton.getFunctionCompletions(prefix);
ICompletionProposal[] result = new ICompletionProposal[completionData.length];
for (int i = 0; i < completionData.length; i++) {
result[i] = new STPFunctionCompletionProposal(completionData[i], prefix.length(), offset);
}
return result;
}
use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class ProbeParser method addProbeAliases.
/**
* Runs stap to obtain a log of all probe aliases & their variables,
* and populate the probe tree with them.
* @return An {@link IStatus} severity level for the result of the operation.
*/
private int addProbeAliases(IProgressMonitor monitor) {
TreeNode statics = tree.getChildByName(Messages.ProbeParser_staticProbes);
if (statics == null) {
return IStatus.ERROR;
}
TreeNode aliases = new TreeNode(Messages.ProbeParser_aliasProbes, false);
tree.add(aliases);
if (monitor.isCanceled()) {
return IStatus.CANCEL;
}
// $NON-NLS-1$ //$NON-NLS-2$
String probeDump = runStap(new String[] { "-L" }, "**", false);
int result = verifyRunResult(probeDump);
if (result != IStatus.OK) {
return result;
}
if (!doQuickErrorCheck(probeDump)) {
return IStatus.ERROR;
}
boolean canceled = false;
try (Scanner st = new Scanner(probeDump)) {
TreeNode groupNode = null;
while (st.hasNextLine()) {
if (monitor.isCanceled()) {
canceled = true;
break;
}
String tokenString = st.nextLine();
// skip it.
if (tokenString.startsWith("_")) {
// $NON-NLS-1$
continue;
}
// Only add this group if it is not a static probe group
String groupName = extractProbeGroupName(tokenString);
if (statics.getChildByName(groupName) != null) {
continue;
}
groupNode = addSingleProbeAlias(tokenString, aliases, groupNode, groupName, null);
}
}
aliases.sortTree();
return !canceled ? IStatus.OK : IStatus.CANCEL;
}
Aggregations