Search in sources :

Example 21 with TreeNode

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());
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) Test(org.junit.Test)

Example 22 with TreeNode

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;
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) STPProbeCompletionProposal(org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPProbeCompletionProposal)

Example 23 with TreeNode

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;
    }
}
Also used : BadPartitioningException(org.eclipse.jface.text.BadPartitioningException) TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) STPProbevarCompletionProposal(org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPProbevarCompletionProposal) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 24 with TreeNode

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;
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) STPFunctionCompletionProposal(org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.proposals.STPFunctionCompletionProposal)

Example 25 with TreeNode

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;
}
Also used : Scanner(java.util.Scanner) TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode)

Aggregations

TreeNode (org.eclipse.linuxtools.systemtap.structures.TreeNode)34 Test (org.junit.Test)15 TreeDefinitionNode (org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode)4 Scanner (java.util.Scanner)3 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)3 ProbevarNodeData (org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.nodedata.ProbevarNodeData)3 ArrayList (java.util.ArrayList)2 IFileStore (org.eclipse.core.filesystem.IFileStore)2 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 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 StringTokenizer (java.util.StringTokenizer)1 Matcher (java.util.regex.Matcher)1 IStatus (org.eclipse.core.runtime.IStatus)1