Search in sources :

Example 1 with Variable

use of org.ballerinalang.plugins.idea.debugger.dto.Variable in project ballerina by ballerina-lang.

the class BallerinaStackFrame method computeChildren.

/**
 * Adds variables in the current stack to the node.
 */
@Override
public void computeChildren(@NotNull XCompositeNode node) {
    // We categorize variables according to the scope. But we get all the variables in the stack. So we need to
    // distinguish values in each scope. In this Map, key will be the scope name. Value will be the list of
    // variables in that scope.
    Map<String, List<Variable>> scopeMap = new HashMap<>();
    // Iterate through each variable.
    List<Variable> variables = myFrame.getVariables();
    for (Variable variable : variables) {
        // Get the scope.
        String scopeName = variable.getScope();
        // Check whether the scope is already available in the map.
        if (scopeMap.containsKey(scopeName)) {
            // If it is already in the map, add the variable to the corresponding list.
            List<Variable> list = scopeMap.get(scopeName);
            list.add(variable);
        } else {
            // If it is not available in the map, add it as a new entry.
            List<Variable> list = new LinkedList<>();
            list.add(variable);
            scopeMap.put(scopeName, list);
        }
    }
    // Iterate through each scope in the map.
    scopeMap.forEach((scopeName, variableList) -> {
        // Create a new XValueChildrenList to hold the XValues.
        XValueChildrenList xValueChildrenList = new XValueChildrenList();
        // Create a new variable to represent the scope.
        Variable scopeVariable = new Variable();
        // Set the variable name.
        scopeVariable.setName(scopeName);
        // Set the children.
        scopeVariable.setChildren(variableList);
        // Add the variables to the children list using a ValueGroup.
        xValueChildrenList.addBottomGroup(new BallerinaXValueGroup(myProcess, myFrame, scopeName, scopeVariable));
        // Add the list to the node as children.
        node.addChildren(xValueChildrenList, true);
    });
}
Also used : XValueChildrenList(com.intellij.xdebugger.frame.XValueChildrenList) Variable(org.ballerinalang.plugins.idea.debugger.dto.Variable) HashMap(java.util.HashMap) XValueChildrenList(com.intellij.xdebugger.frame.XValueChildrenList) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList)

Example 2 with Variable

use of org.ballerinalang.plugins.idea.debugger.dto.Variable in project ballerina by ballerina-lang.

the class BallerinaXValueGroup method computeChildren.

@Override
public void computeChildren(@NotNull XCompositeNode node) {
    List<Variable> children = myVariable.getChildren();
    if (children == null) {
        super.computeChildren(node);
    } else {
        XValueChildrenList list = new XValueChildrenList();
        for (Variable child : children) {
            list.add(child.getName(), new BallerinaXValue(myProcess, myFrame.getFrameName(), child, AllIcons.Nodes.Field));
        }
        node.addChildren(list, true);
    }
}
Also used : XValueChildrenList(com.intellij.xdebugger.frame.XValueChildrenList) Variable(org.ballerinalang.plugins.idea.debugger.dto.Variable)

Example 3 with Variable

use of org.ballerinalang.plugins.idea.debugger.dto.Variable in project ballerina by ballerina-lang.

the class BallerinaXValue method computeChildren.

@Override
public void computeChildren(@NotNull XCompositeNode node) {
    List<Variable> children = myVariable.getChildren();
    if (children == null) {
        super.computeChildren(node);
    } else {
        XValueChildrenList list = new XValueChildrenList();
        for (Variable child : children) {
            list.add(child.getName(), new BallerinaXValue(myProcess, myFrameName, child, AllIcons.Nodes.Field));
        }
        node.addChildren(list, true);
    }
}
Also used : XValueChildrenList(com.intellij.xdebugger.frame.XValueChildrenList) Variable(org.ballerinalang.plugins.idea.debugger.dto.Variable)

Aggregations

XValueChildrenList (com.intellij.xdebugger.frame.XValueChildrenList)3 Variable (org.ballerinalang.plugins.idea.debugger.dto.Variable)3 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1