1.1 --- a/dew4nb/src/org/netbeans/modules/dew4nb/services/debugger/DebugMessageType.java Thu Jan 30 15:46:45 2014 +0100
1.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/services/debugger/DebugMessageType.java Thu Jan 30 16:50:49 2014 +0100
1.3 @@ -53,6 +53,7 @@
1.4 stepOver,
1.5 stepIn,
1.6 stepOut,
1.7 + eval,
1.8 suspended,
1.9 disconnected
1.10 }
2.1 --- a/dew4nb/src/org/netbeans/modules/dew4nb/services/debugger/DebugerModels.java Thu Jan 30 15:46:45 2014 +0100
2.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/services/debugger/DebugerModels.java Thu Jan 30 16:50:49 2014 +0100
2.3 @@ -86,6 +86,15 @@
2.4 static final class SetBreakpointsResultModel {
2.5 }
2.6
2.7 + @Model(className = "EvalResult", properties = {
2.8 + @Property(name = "status", type = Status.class),
2.9 + @Property(name = "type", type = DebugMessageType.class),
2.10 + @Property(name = "state", type = String.class),
2.11 + @Property(name = "values", type = String.class, array = true)
2.12 + })
2.13 + static final class EvalResultModel {
2.14 + }
2.15 +
2.16 @Model(className = "ContinueResult", properties = {
2.17 @Property(name = "status", type = Status.class),
2.18 @Property(name = "type", type = DebugMessageType.class),
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/services/debugger/EvalHandler.java Thu Jan 30 16:50:49 2014 +0100
3.3 @@ -0,0 +1,98 @@
3.4 +/*
3.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3.6 + *
3.7 + * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
3.8 + *
3.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
3.10 + * Other names may be trademarks of their respective owners.
3.11 + *
3.12 + * The contents of this file are subject to the terms of either the GNU
3.13 + * General Public License Version 2 only ("GPL") or the Common
3.14 + * Development and Distribution License("CDDL") (collectively, the
3.15 + * "License"). You may not use this file except in compliance with the
3.16 + * License. You can obtain a copy of the License at
3.17 + * http://www.netbeans.org/cddl-gplv2.html
3.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
3.19 + * specific language governing permissions and limitations under the
3.20 + * License. When distributing the software, include this License Header
3.21 + * Notice in each file and include the License file at
3.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
3.23 + * particular file as subject to the "Classpath" exception as provided
3.24 + * by Oracle in the GPL Version 2 section of the License file that
3.25 + * accompanied this code. If applicable, add the following below the
3.26 + * License Header, with the fields enclosed by brackets [] replaced by
3.27 + * your own identifying information:
3.28 + * "Portions Copyrighted [year] [name of copyright owner]"
3.29 + *
3.30 + * If you wish your version of this file to be governed by only the CDDL
3.31 + * or only the GPL Version 2, indicate your decision by adding
3.32 + * "[Contributor] elects to include this software in this distribution
3.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
3.34 + * single choice of license, a recipient has the option to distribute
3.35 + * your version of this file under either the CDDL, the GPL Version 2 or
3.36 + * to extend the choice of license to its licensees as provided above.
3.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
3.38 + * Version 2 license, then the option applies only if the new code is
3.39 + * made subject to such option by the copyright holder.
3.40 + *
3.41 + * Contributor(s):
3.42 + *
3.43 + * Portions Copyrighted 2014 Sun Microsystems, Inc.
3.44 + */
3.45 +
3.46 +package org.netbeans.modules.dew4nb.services.debugger;
3.47 +
3.48 +import org.netbeans.api.debugger.Session;
3.49 +import org.netbeans.api.debugger.jpda.InvalidExpressionException;
3.50 +import org.netbeans.api.debugger.jpda.JPDADebugger;
3.51 +import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
3.52 +import org.netbeans.modules.dew4nb.endpoint.BasicRequestHandler;
3.53 +import org.netbeans.modules.dew4nb.endpoint.RequestHandler;
3.54 +import org.netbeans.modules.dew4nb.endpoint.Status;
3.55 +import org.netbeans.modules.dew4nb.spi.WorkspaceResolver;
3.56 +import org.openide.util.Parameters;
3.57 +import org.openide.util.lookup.ServiceProvider;
3.58 +
3.59 +/**
3.60 + *
3.61 + * @author Tomas Zezula
3.62 + */
3.63 +@ServiceProvider(service = RequestHandler.class)
3.64 +public class EvalHandler extends BasicRequestHandler<DebugAction, DebugMessageType, EvalResult> {
3.65 +
3.66 + public EvalHandler() {
3.67 + super(DebugerModels.END_POINT, DebugMessageType.eval, DebugAction.class, EvalResult.class);
3.68 + }
3.69 +
3.70 + @Override
3.71 + protected Status handle(DebugAction request, EvalResult response) {
3.72 + Parameters.notNull("request", request); //NOI18N
3.73 + Parameters.notNull("response", response); //NOI18N
3.74 + if (request.getType() != DebugMessageType.eval) {
3.75 + throw new IllegalStateException("Invalid message type: " + request.getType()); //NOI18N
3.76 + }
3.77 + Status status = Status.not_found;
3.78 + final int sessionId = request.getSession();
3.79 + final WorkspaceResolver.Context ctx = ActiveSessions.getInstance().getContext(sessionId);
3.80 + if (ctx != null) {
3.81 + final Session debugSession = ActiveSessions.getInstance().getDebugSession(sessionId);
3.82 + if (debugSession == null) {
3.83 + throw new IllegalStateException("No debugger session."); //NOI18N
3.84 + }
3.85 + final JPDADebugger jpda = debugSession.lookupFirst(null, JPDADebugger.class);
3.86 + if (!(jpda instanceof JPDADebuggerImpl)) {
3.87 + throw new IllegalStateException("Wrong debugger service."); //NOI18N
3.88 + }
3.89 + for (String toEval : request.getData()) {
3.90 + String value;
3.91 + try {
3.92 + value = jpda.evaluate(toEval).getValue();
3.93 + } catch (InvalidExpressionException ex) {
3.94 + value = null;
3.95 + }
3.96 + response.getValues().add(value);
3.97 + }
3.98 + }
3.99 + return status;
3.100 + }
3.101 +}