private ArrayList<Debugger.Variable> collectVariables() {
    final ArrayList<Debugger.Variable> variables = new ArrayList<>();

    Iterable<PackageData> packages = myXPathContext.getController().getExecutable().getPackages();
    for (PackageData data : packages) {
      List<GlobalVariable> globalVariables = data.getGlobalVariableList();
      for (GlobalVariable globalVariable : globalVariables) {

        final Value value = createVariableValue(new GlobalVariableFacade(globalVariable));
        final int lineNumber = globalVariable.getLineNumber();
        final String systemId = globalVariable.getSystemId();
        variables.add(new VariableImpl(globalVariable.getVariableQName().getDisplayName(), value, true, Debugger.Variable.Kind.VARIABLE, systemId, lineNumber));
      }
    }

    XPathContext context = myXPathContext;
    while (context != null) {
      final StackFrame frame = context.getStackFrame();
      final SlotManager map = frame.getStackFrameMap();

      final Sequence[] values = frame.getStackFrameValues();

      outer:
      for (int i = 0, valuesLength = values.length; i < valuesLength; i++) {
        final Sequence value = values[i];
        if (value != null) {
          final String name = map.getVariableMap().get(i).getDisplayName();
          for (Debugger.Variable variable : variables) {
            if (name.equals(variable.getName())) {
              continue outer;
            }
          }

          GroundedValue groundedValue;
          try {
            groundedValue = value.materialize();
          }
          catch (XPathException e) {
            continue outer;
          }
          Value localValue = createVariableValue(new LocalVariableFacade(groundedValue));
          variables.add(new VariableImpl(name, localValue, false, Debugger.Variable.Kind.VARIABLE, "", -1));
        }
      }

      context = context.getCaller();
    }
    return variables;
  }
private ArrayList<Debugger.Variable> collectVariables()