Search in sources :

Example 1 with ProbevarNodeData

use of org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData 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;
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) ProbevarNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData)

Example 2 with ProbevarNodeData

use of org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData in project linuxtools by eclipse.

the class TreeSettingsTest method testStapNodeData.

@Test
public void testStapNodeData() {
    TreeNode temp;
    TreeNode t1 = new TreeNode(new FunctionNodeData("function ftest(x:long)", null), true);
    t1.add(new TreeNode(new FuncparamNodeData("long"), "x", false));
    TreeNode t2 = new TreeNode(new ProbeNodeData("ptest"), true);
    t2.add(new TreeNode(new ProbevarNodeData("x:long"), false));
    TreeSettings.setTrees(t1, t2);
    temp = TreeSettings.getFunctionTree();
    assertTrue("Improper data type - expected FunctionNodeData but was " + temp.getData().getClass().getSimpleName(), temp.getData() instanceof FunctionNodeData);
    assertEquals("Function data not saved", t1.getData().toString(), temp.getData().toString());
    assertEquals("Funcs has children", t1.getChildCount(), temp.getChildCount());
    assertTrue("Improper data type", temp.getChildAt(0).getData() instanceof FuncparamNodeData);
    assertEquals("Function parameter data not saved", t1.getChildAt(0).getData().toString(), temp.getChildAt(0).getData().toString());
    temp = TreeSettings.getProbeTree();
    assertTrue("Improper data type", temp.getData() instanceof ProbeNodeData);
    assertEquals("Probe data not saved", t2.getData().toString(), temp.getData().toString());
    assertEquals("Probs has children", t2.getChildCount(), temp.getChildCount());
    assertTrue("Improper data type", temp.getChildAt(0).getData() instanceof ProbevarNodeData);
    assertEquals("Probe variable data not saved", t2.getChildAt(0).getData().toString(), temp.getChildAt(0).getData().toString());
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) FunctionNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData) FuncparamNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FuncparamNodeData) ProbeNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbeNodeData) ProbevarNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData) Test(org.junit.Test)

Example 3 with ProbevarNodeData

use of org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData in project linuxtools by eclipse.

the class TestCreateSystemtapScript method prepareTreeSettings.

/**
 * Load custom contents into the Function/Probe views.
 */
private static void prepareTreeSettings() {
    TapsetLibrary.stop();
    try {
        probeDef = File.createTempFile("probeDef", ".stp");
        funcDef = File.createTempFile("funcDef", ".stp");
        probeDef.deleteOnExit();
        funcDef.deleteOnExit();
    } catch (IOException e) {
    }
    // Leave one of the files blank to test token search failures.
    try (PrintWriter writer = new PrintWriter(probeDef)) {
        writer.print("test file\nptest\nlast line\n");
    } catch (FileNotFoundException e) {
    }
    TreeNode testProbNodeParent = new TreeNode(null, false);
    // Have static/alias folders to comply with convention (change this later).
    testProbNodeParent.add(new TreeNode(probeCategoryEmpty, true));
    testProbNodeParent.add(new TreeNode(probeCategoryFull, true));
    TreeNode testProbNodeGroup = new TreeNode(probeGroup, true);
    String innerProbe = "probegroup.inner";
    TreeNode testProbNode = new TreeDefinitionNode(new ProbeNodeData(innerProbe), innerProbe, probeDef.getPath(), true);
    testProbNode.add(new TreeNode(new ProbevarNodeData("s:string"), false));
    testProbNodeGroup.add(testProbNode);
    testProbNodeParent.getChildAt(1).add(testProbNodeGroup);
    TreeNode testProbNode2 = new TreeDefinitionNode(new ProbeNodeData(probeSingleWithoutDef), probeSingleWithoutDef, null, true);
    testProbNodeParent.getChildAt(1).add(testProbNode2);
    TreeNode testFuncNodeParent = new TreeNode(null, false);
    TreeNode testFuncNode = new TreeDefinitionNode(new FunctionNodeData("function ftest(x:long)", null), funcNodeName, funcDef.getPath(), true);
    testFuncNode.add(new TreeNode(new FuncparamNodeData("long"), "x", false));
    testFuncNodeParent.add(testFuncNode);
    TreeSettings.setTrees(testFuncNodeParent, testProbNodeParent);
    TapsetLibrary.readTreeFile();
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) FunctionNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData) TreeDefinitionNode(org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ProbeNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbeNodeData) FuncparamNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FuncparamNodeData) ProbevarNodeData(org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData) PrintWriter(java.io.PrintWriter)

Aggregations

ProbevarNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData)3 TreeNode (org.eclipse.linuxtools.systemtap.structures.TreeNode)3 FuncparamNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FuncparamNodeData)2 FunctionNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.FunctionNodeData)2 ProbeNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbeNodeData)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 TreeDefinitionNode (org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode)1 Test (org.junit.Test)1