Search in sources :

Example 1 with PerlXNamedValue

use of com.perl5.lang.perl.idea.run.debugger.values.PerlXNamedValue in project Perl5-IDEA by Camelcade.

the class PerlStackFrame method getEvaluator.

@Nullable
@Override
public XDebuggerEvaluator getEvaluator() {
    return new XDebuggerEvaluator() {

        @Override
        public void evaluate(@NotNull String expression, @NotNull final XEvaluationCallback callback, @Nullable XSourcePosition expressionPosition) {
            PerlDebugThread thread = myPerlExecutionStack.getSuspendContext().getDebugThread();
            thread.sendCommandAndGetResponse("e", new PerlEvalRequestDescriptor(expression), new PerlDebuggingTransactionHandler() {

                @Override
                public void run(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
                    PerlEvalResponseDescriptor descriptor = jsonDeserializationContext.deserialize(jsonObject.getAsJsonObject("data"), PerlEvalResponseDescriptor.class);
                    if (descriptor == null) {
                        callback.errorOccurred("Something bad happened on Perl side. Report to plugin devs.");
                    } else if (descriptor.isError()) {
                        callback.errorOccurred(descriptor.getResult().getValue());
                    } else {
                        callback.evaluated(new PerlXNamedValue(descriptor.getResult(), PerlStackFrame.this));
                    }
                }
            });
        }
    };
}
Also used : XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) JsonObject(com.google.gson.JsonObject) NotNull(org.jetbrains.annotations.NotNull) PerlXNamedValue(com.perl5.lang.perl.idea.run.debugger.values.PerlXNamedValue) JsonDeserializationContext(com.google.gson.JsonDeserializationContext) XSourcePosition(com.intellij.xdebugger.XSourcePosition) Nullable(org.jetbrains.annotations.Nullable) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with PerlXNamedValue

use of com.perl5.lang.perl.idea.run.debugger.values.PerlXNamedValue in project Perl5-IDEA by Camelcade.

the class PerlXValueGroup method computeChildren.

@Override
public void computeChildren(@NotNull XCompositeNode node) {
    if (myVariables.length == 0) {
        super.computeChildren(node);
    } else {
        XValueChildrenList list = new XValueChildrenList();
        for (PerlValueDescriptor descriptor : myVariables) {
            list.add(new PerlXNamedValue(descriptor, myStackFrame));
        }
        node.setAlreadySorted(true);
        node.addChildren(list, true);
    }
}
Also used : XValueChildrenList(com.intellij.xdebugger.frame.XValueChildrenList) PerlValueDescriptor(com.perl5.lang.perl.idea.run.debugger.protocol.PerlValueDescriptor)

Example 3 with PerlXNamedValue

use of com.perl5.lang.perl.idea.run.debugger.values.PerlXNamedValue in project Perl5-IDEA by Camelcade.

the class PerlDebugUtil method requestAndComputeChildren.

public static void requestAndComputeChildren(@NotNull final XCompositeNode node, final PerlStackFrame perlStackFrame, final int[] offset, final int size, String key) {
    PerlDebugThread thread = perlStackFrame.getPerlExecutionStack().getSuspendContext().getDebugThread();
    final int frameSize = XCompositeNode.MAX_CHILDREN_TO_SHOW;
    thread.sendCommandAndGetResponse("getchildren", new PerlValueRequestDescriptor(offset[0], frameSize, key), new PerlDebuggingTransactionHandler() {

        @Override
        public void run(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext) {
            PerlValueDescriptor[] descriptors = jsonDeserializationContext.deserialize(jsonObject.getAsJsonArray("data"), PerlValueDescriptor[].class);
            XValueChildrenList list = new XValueChildrenList();
            for (PerlValueDescriptor descriptor : descriptors) {
                list.add(new PerlXNamedValue(descriptor, perlStackFrame));
                offset[0]++;
            }
            boolean isLast = offset[0] >= size;
            node.addChildren(list, isLast);
            if (!isLast) {
                node.tooManyChildren(size - offset[0]);
            }
        }
    });
}
Also used : XValueChildrenList(com.intellij.xdebugger.frame.XValueChildrenList) PerlValueRequestDescriptor(com.perl5.lang.perl.idea.run.debugger.protocol.PerlValueRequestDescriptor) JsonDeserializationContext(com.google.gson.JsonDeserializationContext) PerlValueDescriptor(com.perl5.lang.perl.idea.run.debugger.protocol.PerlValueDescriptor) PerlDebuggingTransactionHandler(com.perl5.lang.perl.idea.run.debugger.protocol.PerlDebuggingTransactionHandler) PerlDebugThread(com.perl5.lang.perl.idea.run.debugger.PerlDebugThread) JsonObject(com.google.gson.JsonObject) PerlXNamedValue(com.perl5.lang.perl.idea.run.debugger.values.PerlXNamedValue) PerlDebuggingEventBreakpoint(com.perl5.lang.perl.idea.run.debugger.protocol.PerlDebuggingEventBreakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint)

Aggregations

JsonDeserializationContext (com.google.gson.JsonDeserializationContext)2 JsonObject (com.google.gson.JsonObject)2 XValueChildrenList (com.intellij.xdebugger.frame.XValueChildrenList)2 PerlValueDescriptor (com.perl5.lang.perl.idea.run.debugger.protocol.PerlValueDescriptor)2 PerlXNamedValue (com.perl5.lang.perl.idea.run.debugger.values.PerlXNamedValue)2 XSourcePosition (com.intellij.xdebugger.XSourcePosition)1 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)1 XDebuggerEvaluator (com.intellij.xdebugger.evaluation.XDebuggerEvaluator)1 PerlDebugThread (com.perl5.lang.perl.idea.run.debugger.PerlDebugThread)1 PerlDebuggingEventBreakpoint (com.perl5.lang.perl.idea.run.debugger.protocol.PerlDebuggingEventBreakpoint)1 PerlDebuggingTransactionHandler (com.perl5.lang.perl.idea.run.debugger.protocol.PerlDebuggingTransactionHandler)1 PerlValueRequestDescriptor (com.perl5.lang.perl.idea.run.debugger.protocol.PerlValueRequestDescriptor)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1