use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class STPMetadataSingleton method isVariableInProbe.
public boolean isVariableInProbe(String probe, String variable) {
TreeNode node = getProbeAlias(probe);
if (node == null) {
return false;
}
for (int i = 0, n = node.getChildCount(); i < n; i++) {
TreeNode child = node.getChildAt(i);
String nodeVar = ((ProbevarNodeData) child.getData()).getCompletionText();
if (nodeVar.equals(variable)) {
return true;
}
}
return false;
}
use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class STPMetadataSingleton method getMatchingChildren.
private TreeNode[] getMatchingChildren(TreeNode node, String prefix) {
ArrayList<TreeNode> matches = new ArrayList<>();
for (int i = 0, n = node.getChildCount(); i < n; i++) {
TreeNode childNode = node.getChildAt(i);
String childName;
if (childNode.getData() instanceof ICompletable) {
childName = ((ICompletable) childNode.getData()).getCompletionText();
} else {
childName = childNode.toString();
}
if (childName.startsWith(prefix)) {
matches.add(childNode);
}
}
return matches.toArray(new TreeNode[0]);
}
use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class KernelSourceTreeTest method testBuildKernelTree.
@Test
public void testBuildKernelTree() {
TreeNode t;
// Null
String direct = null;
String[] excluded = null;
kst.buildKernelTree(direct, excluded);
assertNull("Null directory", kst.getTree());
// Empty string for directory
direct = "";
kst.buildKernelTree(direct, excluded);
assertNull("Empty string directory", kst.getTree());
// Missing folder
direct = "/noSuchDirectory/";
kst.buildKernelTree(direct, excluded);
assertEquals("Missing directory", 0, kst.getTree().getChildCount());
// Inaccessible
direct = "/root/";
kst.buildKernelTree(direct, excluded);
assertEquals("Inaccessable directory", 0, kst.getTree().getChildCount());
// No .c or .h files
direct = "/bin/";
kst.buildKernelTree(direct, excluded);
t = kst.getTree();
assertEquals("Bin folder item count", 0, t.getChildCount());
assertTrue("Bin folder name", "bin".equals(t.toString()));
assertTrue("Bin has file", t.getData() instanceof IFileStore);
excluded = new String[] { ".git" };
// No .c or .h files
direct = "/tmp/";
kst.buildKernelTree(direct, excluded);
}
use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class TreeNodeTest method testTreeNode.
@Test
public void testTreeNode() {
String d1 = "One";
String d2 = "two";
String s1 = "one";
TreeNode t1 = new TreeNode(d1, s1, false);
assertEquals("Create child count", 0, t1.getChildCount());
assertEquals("Create child string", s1, t1.toString());
assertEquals("Create child data", d1, t1.getData());
assertFalse("Create child clickable", t1.isClickable());
TreeNode t2 = new TreeNode(d2, true);
assertEquals("Create child count", 0, t2.getChildCount());
assertTrue("Create child string", t2.toString().equals(d2));
assertEquals("Create child data", d2, t2.getData());
assertTrue("Create child clickable", t2.isClickable());
TreeNode t3 = new TreeNode(null, true);
assertEquals("Create child count", 0, t3.getChildCount());
assertEquals("Create child string", null, t3.toString());
assertEquals("Create child data", null, t3.getData());
assertTrue("Create child clickable", t3.isClickable());
TreeNode t4 = new TreeNode(d1, s1, false);
assertEquals("Create child count", 0, t4.getChildCount());
assertEquals("Create child string", s1, t4.toString());
assertEquals("Create child data", d1, t4.getData());
assertFalse("Create child clickable", t4.isClickable());
}
use of org.eclipse.linuxtools.systemtap.structures.TreeNode in project linuxtools by eclipse.
the class TreeNodeTest method testAddAt.
@Test
public void testAddAt() {
TreeNode test1 = new TreeNode("one", false);
t.addAt(test1, 0);
assertEquals("Child added to front", test1, t.getChildAt(0));
assertEquals("Child correctly added", 3, t.getChildCount());
TreeNode test2 = new TreeNode("two", false);
t.addAt(test2, 1);
assertEquals("Child added to middle", test2, t.getChildAt(1));
assertEquals("Child correctly added", 4, t.getChildCount());
TreeNode test3 = new TreeNode("three", false);
t.addAt(test3, 3);
assertEquals("Child added to end", test3, t.getChildAt(3));
assertEquals("Child correctly added", 5, t.getChildCount());
TreeNode test4 = new TreeNode("four", false);
t.addAt(test4, 30);
assertEquals("Child added to end", test4, t.getChildAt(5));
assertEquals("Child correctly added", 6, t.getChildCount());
}
Aggregations