1.1 --- a/dew4nb/src/org/netbeans/modules/dew4nb/services/javac/JavacMessageType.java Mon Jan 27 15:02:58 2014 +0100
1.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/services/javac/JavacMessageType.java Tue Jan 28 10:20:31 2014 +0100
1.3 @@ -43,12 +43,17 @@
1.4 package org.netbeans.modules.dew4nb.services.javac;
1.5
1.6 public enum JavacMessageType {
1.7 + //javac
1.8 autocomplete,
1.9 types,
1.10 symbols,
1.11 checkForErrors,
1.12 compile,
1.13 + //project
1.14 getfile,
1.15 isActionEnabled,
1.16 invokeAction,
1.17 + //debugger
1.18 + attach,
1.19 + breakpoints,
1.20 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/services/javac/debugger/AttachHandler.java Tue Jan 28 10:20:31 2014 +0100
2.3 @@ -0,0 +1,128 @@
2.4 +/*
2.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2.6 + *
2.7 + * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
2.8 + *
2.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
2.10 + * Other names may be trademarks of their respective owners.
2.11 + *
2.12 + * The contents of this file are subject to the terms of either the GNU
2.13 + * General Public License Version 2 only ("GPL") or the Common
2.14 + * Development and Distribution License("CDDL") (collectively, the
2.15 + * "License"). You may not use this file except in compliance with the
2.16 + * License. You can obtain a copy of the License at
2.17 + * http://www.netbeans.org/cddl-gplv2.html
2.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
2.19 + * specific language governing permissions and limitations under the
2.20 + * License. When distributing the software, include this License Header
2.21 + * Notice in each file and include the License file at
2.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
2.23 + * particular file as subject to the "Classpath" exception as provided
2.24 + * by Oracle in the GPL Version 2 section of the License file that
2.25 + * accompanied this code. If applicable, add the following below the
2.26 + * License Header, with the fields enclosed by brackets [] replaced by
2.27 + * your own identifying information:
2.28 + * "Portions Copyrighted [year] [name of copyright owner]"
2.29 + *
2.30 + * If you wish your version of this file to be governed by only the CDDL
2.31 + * or only the GPL Version 2, indicate your decision by adding
2.32 + * "[Contributor] elects to include this software in this distribution
2.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
2.34 + * single choice of license, a recipient has the option to distribute
2.35 + * your version of this file under either the CDDL, the GPL Version 2 or
2.36 + * to extend the choice of license to its licensees as provided above.
2.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
2.38 + * Version 2 license, then the option applies only if the new code is
2.39 + * made subject to such option by the copyright holder.
2.40 + *
2.41 + * Contributor(s):
2.42 + *
2.43 + * Portions Copyrighted 2014 Sun Microsystems, Inc.
2.44 + */
2.45 +
2.46 +package org.netbeans.modules.dew4nb.services.javac.debugger;
2.47 +
2.48 +import java.util.concurrent.ConcurrentHashMap;
2.49 +import java.util.concurrent.ConcurrentMap;
2.50 +import java.util.concurrent.Executor;
2.51 +import java.util.concurrent.atomic.AtomicInteger;
2.52 +import org.netbeans.api.annotations.common.NonNull;
2.53 +import org.netbeans.modules.dew4nb.endpoint.AsyncRequestHandler;
2.54 +import org.netbeans.modules.dew4nb.endpoint.EndPoint;
2.55 +import org.netbeans.modules.dew4nb.endpoint.RequestHandler;
2.56 +import org.netbeans.modules.dew4nb.endpoint.Status;
2.57 +import org.netbeans.modules.dew4nb.services.javac.Context;
2.58 +import org.netbeans.modules.dew4nb.services.javac.JavacMessageType;
2.59 +import org.netbeans.modules.dew4nb.services.javac.JavacQuery;
2.60 +import org.netbeans.modules.dew4nb.spi.WorkspaceResolver;
2.61 +import org.openide.filesystems.FileObject;
2.62 +import org.openide.util.Lookup;
2.63 +import org.openide.util.RequestProcessor;
2.64 +import org.openide.util.lookup.ServiceProvider;
2.65 +
2.66 +/**
2.67 + *
2.68 + * @author Tomas Zezula
2.69 + */
2.70 +@ServiceProvider(service = RequestHandler.class)
2.71 +public class AttachHandler extends AsyncRequestHandler<JavacQuery, JavacMessageType> {
2.72 +
2.73 + private static final Executor RP = new RequestProcessor(AttachHandler.class);
2.74 + private final AtomicInteger idSequencer;
2.75 + private final ConcurrentMap<Integer,WorkspaceResolver.Context> activeSessions;
2.76 +
2.77 +
2.78 + public AttachHandler() {
2.79 + super(DebugerModels.END_POINT, JavacMessageType.attach, JavacQuery.class);
2.80 + this.idSequencer = new AtomicInteger();
2.81 + this.activeSessions = new ConcurrentHashMap<>();
2.82 + }
2.83 +
2.84 + @Override
2.85 + @NonNull
2.86 + protected Status handle(@NonNull final JavacQuery request, @NonNull final EndPoint.Env env) {
2.87 + final JavacMessageType type = request.getType();
2.88 + if (type != JavacMessageType.attach) {
2.89 + throw new IllegalStateException("Wrong message type:" + type); //NOI18N
2.90 + }
2.91 + final Context ctx = request.getContext();
2.92 + if (ctx != null) {
2.93 + throw new IllegalArgumentException("Missing context"); //NOI18N
2.94 + }
2.95 + final String state = request.getState();
2.96 + if (state == null) {
2.97 + throw new IllegalArgumentException("Missing state"); //NOI18N
2.98 + }
2.99 + final WorkspaceResolver resolver = Lookup.getDefault().lookup(WorkspaceResolver.class);
2.100 + if (resolver == null) {
2.101 + throw new IllegalStateException("No WorkspaceResolver"); //NOI18N
2.102 + }
2.103 + RP.execute(new Runnable() {
2.104 + @Override
2.105 + public void run() {
2.106 + final WorkspaceResolver.Context serverCtx = new WorkspaceResolver.Context(
2.107 + ctx.getUser(),
2.108 + ctx.getWorkspace(),
2.109 + "" //NOI18N
2.110 + );
2.111 + final FileObject workspace = resolver.resolveFile(serverCtx);
2.112 + Status status = Status.not_found;
2.113 + int id = -1;
2.114 + if (workspace != null) {
2.115 + id = idSequencer.incrementAndGet();
2.116 + if (activeSessions.putIfAbsent(id, serverCtx) != null) {
2.117 + throw new IllegalStateException("Trying to reuse active session"); //NOI18N
2.118 + }
2.119 + status = Status.done;
2.120 + }
2.121 + final AttachResult attachResult = new AttachResult();
2.122 + attachResult.setId(id);
2.123 + attachResult.setType(type);
2.124 + attachResult.setState(state);
2.125 + attachResult.setStatus(status);
2.126 + env.sendObject(attachResult);
2.127 + }
2.128 + });
2.129 + return Status.accepted;
2.130 + }
2.131 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/services/javac/debugger/DebugerModels.java Tue Jan 28 10:20:31 2014 +0100
3.3 @@ -0,0 +1,81 @@
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.javac.debugger;
3.47 +
3.48 +import net.java.html.json.Model;
3.49 +import net.java.html.json.Property;
3.50 +import org.netbeans.modules.dew4nb.endpoint.Status;
3.51 +import org.netbeans.modules.dew4nb.services.javac.JavacMessageType;
3.52 +
3.53 +/**
3.54 + *
3.55 + * @author Tomas Zezula
3.56 + */
3.57 +public final class DebugerModels {
3.58 +
3.59 + static final String END_POINT = "javac"; //NOI18N
3.60 +
3.61 + private DebugerModels() {
3.62 + throw new IllegalStateException("No instance allowed."); //NOI18N
3.63 + }
3.64 +
3.65 +
3.66 + @Model(className = "AttachResult", properties = {
3.67 + @Property(name = "status", type = Status.class),
3.68 + @Property(name = "type", type = JavacMessageType.class),
3.69 + @Property(name = "state", type = String.class),
3.70 + @Property(name = "id", type = int.class)
3.71 + })
3.72 + static final class AttachResultModel {
3.73 + }
3.74 +
3.75 +
3.76 + @Model(className = "SetBreakpointsResult", properties = {
3.77 + @Property(name = "status", type = Status.class),
3.78 + @Property(name = "type", type = JavacMessageType.class),
3.79 + @Property(name = "state", type = String.class),
3.80 + })
3.81 + static final class SetBreakpointsResultModel {
3.82 + }
3.83 +
3.84 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/dew4nb/src/org/netbeans/modules/dew4nb/services/javac/debugger/SetBreakpointsHandler.java Tue Jan 28 10:20:31 2014 +0100
4.3 @@ -0,0 +1,76 @@
4.4 +/*
4.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4.6 + *
4.7 + * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
4.8 + *
4.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
4.10 + * Other names may be trademarks of their respective owners.
4.11 + *
4.12 + * The contents of this file are subject to the terms of either the GNU
4.13 + * General Public License Version 2 only ("GPL") or the Common
4.14 + * Development and Distribution License("CDDL") (collectively, the
4.15 + * "License"). You may not use this file except in compliance with the
4.16 + * License. You can obtain a copy of the License at
4.17 + * http://www.netbeans.org/cddl-gplv2.html
4.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
4.19 + * specific language governing permissions and limitations under the
4.20 + * License. When distributing the software, include this License Header
4.21 + * Notice in each file and include the License file at
4.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
4.23 + * particular file as subject to the "Classpath" exception as provided
4.24 + * by Oracle in the GPL Version 2 section of the License file that
4.25 + * accompanied this code. If applicable, add the following below the
4.26 + * License Header, with the fields enclosed by brackets [] replaced by
4.27 + * your own identifying information:
4.28 + * "Portions Copyrighted [year] [name of copyright owner]"
4.29 + *
4.30 + * If you wish your version of this file to be governed by only the CDDL
4.31 + * or only the GPL Version 2, indicate your decision by adding
4.32 + * "[Contributor] elects to include this software in this distribution
4.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
4.34 + * single choice of license, a recipient has the option to distribute
4.35 + * your version of this file under either the CDDL, the GPL Version 2 or
4.36 + * to extend the choice of license to its licensees as provided above.
4.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
4.38 + * Version 2 license, then the option applies only if the new code is
4.39 + * made subject to such option by the copyright holder.
4.40 + *
4.41 + * Contributor(s):
4.42 + *
4.43 + * Portions Copyrighted 2014 Sun Microsystems, Inc.
4.44 + */
4.45 +
4.46 +package org.netbeans.modules.dew4nb.services.javac.debugger;
4.47 +
4.48 +import org.netbeans.api.annotations.common.NonNull;
4.49 +import org.netbeans.modules.dew4nb.endpoint.BasicRequestHandler;
4.50 +import org.netbeans.modules.dew4nb.endpoint.RequestHandler;
4.51 +import org.netbeans.modules.dew4nb.endpoint.Status;
4.52 +import org.netbeans.modules.dew4nb.services.javac.JavacMessageType;
4.53 +import org.netbeans.modules.dew4nb.services.javac.JavacQuery;
4.54 +import org.openide.util.Parameters;
4.55 +import org.openide.util.lookup.ServiceProvider;
4.56 +
4.57 +/**
4.58 + *
4.59 + * @author Tomas Zezula
4.60 + */
4.61 +@ServiceProvider(service = RequestHandler.class)
4.62 +public class SetBreakpointsHandler extends BasicRequestHandler<JavacQuery, JavacMessageType, SetBreakpointsResult> {
4.63 +
4.64 + public SetBreakpointsHandler() {
4.65 + super(DebugerModels.END_POINT, JavacMessageType.breakpoints, JavacQuery.class, SetBreakpointsResult.class);
4.66 + }
4.67 +
4.68 + @Override
4.69 + protected Status handle(@NonNull final JavacQuery request, @NonNull final SetBreakpointsResult response) {
4.70 + Parameters.notNull("request", request); //NOI18N
4.71 + Parameters.notNull("response", response); //NOI18N;
4.72 + if (request.getType() != JavacMessageType.breakpoints) {
4.73 + throw new IllegalStateException("Wrong message type: " + request.getType()); //NOI18N
4.74 + }
4.75 + Status status = Status.done;
4.76 + return status;
4.77 + }
4.78 +
4.79 +}