Skip to content

Commit

Permalink
CHE-2214 NodeJs Debugger (eclipse-che#2625)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatoliy Bazko authored Sep 30, 2016
1 parent f8923af commit 4363d3f
Show file tree
Hide file tree
Showing 53 changed files with 3,257 additions and 7 deletions.
4 changes: 4 additions & 0 deletions assembly/assembly-ide-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-maven-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-nodejs-debugger-ide</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-nodejs-lang-ide</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<inherits name='org.eclipse.che.ide.ext.web.Web'/>
<inherits name='org.eclipse.che.plugin.debugger.Debugger'/>
<inherits name='org.eclipse.che.plugin.gdb.Gdb'/>
<inherits name='org.eclipse.che.plugin.nodejsdbg.NodeJsDebugger'/>
<inherits name='org.eclipse.che.plugin.jdb.JavaDebugger'/>
<inherits name='org.eclipse.che.ide.extension.machine.Machine'/>
<inherits name='org.eclipse.che.plugin.maven.Maven'/>
Expand Down
4 changes: 4 additions & 0 deletions assembly/assembly-wsagent-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-maven-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-nodejs-debugger-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-nodejs-lang-server</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,13 @@ public Promise<Void> start(String id, StartActionDto action) {
public Promise<Void> addBreakpoint(String id, BreakpointDto breakpointDto) {
final String requestUrl = getBaseUrl(id) + "/breakpoint";
return asyncRequestFactory.createPostRequest(requestUrl, breakpointDto)
.loader(loaderFactory.newLoader())
.send();
}

@Override
public Promise<List<BreakpointDto>> getAllBreakpoints(String id) {
final String requestUrl = getBaseUrl(id) + "/breakpoint";
return asyncRequestFactory.createGetRequest(requestUrl)
.loader(loaderFactory.newLoader())
.send(dtoUnmarshallerFactory.newListUnmarshaller(BreakpointDto.class));
}

Expand Down Expand Up @@ -148,15 +146,13 @@ public Promise<SimpleValueDto> getValue(String id, VariableDto variableDto) {
}

return asyncRequestFactory.createGetRequest(requestUrl + params)
.loader(loaderFactory.newLoader())
.send(dtoUnmarshallerFactory.newUnmarshaller(SimpleValueDto.class));
}

@Override
public Promise<Void> setValue(String id, VariableDto variableDto) {
final String requestUrl = getBaseUrl(id) + "/value";
return asyncRequestFactory.createPutRequest(requestUrl, variableDto)
.loader(loaderFactory.newLoader())
.send();
}

Expand Down Expand Up @@ -195,7 +191,6 @@ private String getBaseUrl(String id) {
protected Promise<Void> performAction(String id, ActionDto actionDto) {
final String requestUrl = getBaseUrl(id);
return asyncRequestFactory.createPostRequest(requestUrl, actionDto)
.loader(loaderFactory.newLoader())
.send();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public List<EditorPartPresenter> getOpenedEditorsBasedOn(EditorPartPresenter edi
@Override
public EditorPartPresenter getOpenedEditor(Path path) {
EditorPartStack editorPartStack = editorMultiPartStack.getPartStackByPart(activeEditor);
return (EditorPartPresenter)editorPartStack.getPartByPath(path);
return editorPartStack == null ? null : (EditorPartPresenter)editorPartStack.getPartByPath(path);
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,9 @@ public Void apply(Optional<Resource> resource) throws FunctionException {

protected Promise<Resource[]> search(final Container container, String fileMask, String contentMask) {
QueryExpression queryExpression = new QueryExpression();
queryExpression.setText(contentMask + '*');
if (!isNullOrEmpty(contentMask)) {
queryExpression.setText(contentMask + '*');
}
if (!isNullOrEmpty(fileMask)) {
queryExpression.setName(fileMask);
}
Expand Down
154 changes: 154 additions & 0 deletions plugins/plugin-nodejs-debugger/che-plugin-nodejs-debugger-ide/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2016 Codenvy, S.A.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Codenvy, S.A. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-plugin-nodejs-debugger-parent</artifactId>
<groupId>org.eclipse.che.plugin</groupId>
<version>5.0.0-M5-SNAPSHOT</version>
</parent>
<artifactId>che-plugin-nodejs-debugger-ide</artifactId>
<packaging>jar</packaging>
<name>Che Plugin :: NodeJs Debugger :: IDE</name>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-elemental</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt.inject</groupId>
<artifactId>gin</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-gwt</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-app</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-ui</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-debugger-ide</artifactId>
</dependency>
<dependency>
<groupId>org.vectomatic</groupId>
<artifactId>lib-gwt-svg</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.gwt.gwtmockito</groupId>
<artifactId>gwtmockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.gwt-test-utils</groupId>
<artifactId>gwt-test-utils</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*.png</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*******************************************************************************
* Copyright (c) 2012-2016 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.plugin.nodejsdbg.ide;

import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;

import org.eclipse.che.api.debug.shared.model.Location;
import org.eclipse.che.ide.api.debug.BreakpointManager;
import org.eclipse.che.ide.api.debug.DebuggerServiceClient;
import org.eclipse.che.ide.api.resources.VirtualFile;
import org.eclipse.che.ide.debug.DebuggerDescriptor;
import org.eclipse.che.ide.debug.DebuggerManager;
import org.eclipse.che.ide.dto.DtoFactory;
import org.eclipse.che.ide.util.storage.LocalStorageProvider;
import org.eclipse.che.ide.websocket.MessageBusProvider;
import org.eclipse.che.plugin.debugger.ide.debug.AbstractDebugger;

import javax.validation.constraints.NotNull;
import java.util.Map;

/**
* The NodeJs Debugger Client.
*
* @author Anatoliy Bazko
*/
public class NodeJsDebugger extends AbstractDebugger {

public static final String ID = "nodejsdbg";

@Inject
public NodeJsDebugger(DebuggerServiceClient service,
DtoFactory dtoFactory,
LocalStorageProvider localStorageProvider,
MessageBusProvider messageBusProvider,
EventBus eventBus,
NodeJsDebuggerFileHandler activeFileHandler,
DebuggerManager debuggerManager,
BreakpointManager breakpointManager) {

super(service,
dtoFactory,
localStorageProvider,
messageBusProvider,
eventBus,
activeFileHandler,
debuggerManager,
breakpointManager,
ID);
}

@Override
protected String fqnToPath(@NotNull Location location) {
return location.getResourcePath() == null ? location.getTarget() : location.getResourcePath();
}

@Override
protected String pathToFqn(VirtualFile file) {
return file.getLocation().toString();
}

@Override
protected DebuggerDescriptor toDescriptor(Map<String, String> connectionProperties) {
StringBuilder sb = new StringBuilder();

for (String propName : connectionProperties.keySet()) {
try {
ConnectionProperties prop = ConnectionProperties.valueOf(propName.toUpperCase());
String connectionInfo = prop.getConnectionInfo(connectionProperties.get(propName));
if (!connectionInfo.isEmpty()) {
if (sb.length() > 0) {
sb.append(',');
}
sb.append(connectionInfo);
}
} catch (IllegalArgumentException ignored) {
// unrecognized connection property
}
}

return new DebuggerDescriptor("", "{ " + sb.toString() + " }");
}

public enum ConnectionProperties {
SCRIPT {
@Override
public String getConnectionInfo(String value) {
return value;
}
};

public abstract String getConnectionInfo(String value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2012-2016 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.plugin.nodejsdbg.ide;

import com.google.inject.Inject;
import com.google.inject.Singleton;

import org.eclipse.che.ide.api.extension.Extension;
import org.eclipse.che.ide.debug.DebuggerManager;

/**
* Extension allows to debug NodeJs applications.
*
* @author Anatoliy Bazko
*/
@Singleton
@Extension(title = "NodeJs Debugger", version = "5.0.0")
public class NodeJsDebuggerExtension {

@Inject
public NodeJsDebuggerExtension(DebuggerManager debuggerManager, NodeJsDebugger nodeJsDebugger) {
debuggerManager.registeredDebugger(NodeJsDebugger.ID, nodeJsDebugger);
}
}
Loading

0 comments on commit 4363d3f

Please sign in to comment.