Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome debugger integration #252

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion org.eclipse.wildwebdeveloper/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ bin.includes = META-INF/,\
.,\
plugin.xml,\
language-servers/package-lock.json,\
language-servers/node_modules/,\
language-servers/chrome-debug-adapter/extension/node_modules/,\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't have to do that if we can have the module treated as regular npm in node_modules.

language-servers/chrome-debug-adapter/extension/out/,\
language-configurations/,\
grammars/,\
snippets/,\
Expand Down
Binary file added org.eclipse.wildwebdeveloper/icons/ChromeIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions org.eclipse.wildwebdeveloper/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,24 @@
sourceLocatorId="org.eclipse.lsp4e.debug.sourceLocator"
sourcePathComputerId="org.eclipse.lsp4e.debug.sourcePathComputer">
</launchConfigurationType>
<launchConfigurationType
delegate="org.eclipse.wildwebdeveloper.debug.chrome.ChromeRunDAPDebugDelegate"
id="org.eclipse.wildwebdeveloper.launchConfiguration.chromeRunDebug"
modes="debug"
name="Chrome Debug"
public="true"
sourceLocatorId="org.eclipse.lsp4e.debug.sourceLocator"
sourcePathComputerId="org.eclipse.lsp4e.debug.sourcePathComputer">
</launchConfigurationType>
<launchConfigurationType
delegate="org.eclipse.wildwebdeveloper.debug.chrome.ChromeAttachDebugDelegate"
id="org.eclipse.wildwebdeveloper.launchConfiguration.chromeAttachDebug"
modes="debug"
name="Running Chrome Debug Instance"
public="true"
sourceLocatorId="org.eclipse.lsp4e.debug.sourceLocator"
sourcePathComputerId="org.eclipse.lsp4e.debug.sourcePathComputer">
</launchConfigurationType>
</extension>
<extension
point="org.eclipse.debug.ui.launchShortcuts">
Expand Down Expand Up @@ -554,6 +572,30 @@
</with></enablement>
</contextualLaunch>
</shortcut>
<shortcut
class="org.eclipse.wildwebdeveloper.debug.chrome.ChromeRunDebugLaunchShortcut"
icon="icons/ChromeIcon.png"
id="org.eclipse.wildwebdeveloper.chromeRunShortcut"
label="Chrome Debug "
modes="debug">
<configurationType
id="org.eclipse.wildwebdeveloper.launchConfiguration.chromeRunDebug"></configurationType>
<contextualLaunch>
<enablement>
<with
variable="selection">
<count
value="1">
</count>
<iterate>
<adapt
type="org.eclipse.core.resources.IResource">
</adapt>
</iterate>
</with>
</enablement>
</contextualLaunch>
</shortcut>
</extension>
<extension
point="org.eclipse.core.runtime.adapters">
Expand Down Expand Up @@ -604,6 +646,16 @@
icon="icons/firefoxIconSmall.png"
id="org.eclipse.wildwebdeveloper.firefoxImage">
</launchConfigurationTypeImage>
<launchConfigurationTypeImage
configTypeID="org.eclipse.wildwebdeveloper.launchConfiguration.chromeRunDebug"
icon="icons/ChromeIcon.png"
id="org.eclipse.wildwebdeveloper.chromeImage">
</launchConfigurationTypeImage>
<launchConfigurationTypeImage
configTypeID="org.eclipse.wildwebdeveloper.launchConfiguration.chromeAttachDebug"
icon="icons/ChromeIcon.png"
id="org.eclipse.wildwebdeveloper.chromeImage">
</launchConfigurationTypeImage>
</extension>
<extension
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
Expand All @@ -627,6 +679,16 @@
id="org.eclipse.wildwebdeveloper.launchConfigurationTabGroup1"
type="org.eclipse.wildwebdeveloper.launchConfiguration.firefoxDebug">
</launchConfigurationTabGroup>
<launchConfigurationTabGroup
class="org.eclipse.wildwebdeveloper.debug.chrome.ChromeRunDebugTabGroup"
id="org.eclipse.wildwebdeveloper.ChromeRunDebugTabGroup"
type="org.eclipse.wildwebdeveloper.launchConfiguration.chromeRunDebug">
</launchConfigurationTabGroup>
<launchConfigurationTabGroup
class="org.eclipse.wildwebdeveloper.debug.chrome.ChromeAttachDebugTabGroup"
id="org.eclipse.wildwebdeveloper.ChromeAttachDebugTabGroup"
type="org.eclipse.wildwebdeveloper.launchConfiguration.chromeAttachDebug">
</launchConfigurationTabGroup>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
Expand Down
20 changes: 20 additions & 0 deletions org.eclipse.wildwebdeveloper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,23 @@
<outputDirectory>${project.build.directory}/vscode</outputDirectory>
</configuration>
</execution>
<execution>
<id>fetch-chrome-debug-adapter</id>
<phase>generate-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://marketplace.visualstudio.com/_apis/public/gallery/publishers/msjsdiag/vsextensions/debugger-for-chrome/4.11.7/vspackage</url>
<outputFileName>chromeDebugAdapter.zip</outputFileName>
<unpack>true</unpack>
<outputDirectory>${project.build.directory}/chrome-debug-adapter</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>


<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
Expand All @@ -65,6 +80,7 @@
<arg>../target/vscode/VSCode-linux-x64/resources/app/extensions/html-language-features/server</arg>
<arg>../target/vscode/VSCode-linux-x64/resources/app/extensions/css-language-features/server</arg>
<arg>../target/vscode/VSCode-linux-x64/resources/app/extensions/ms-vscode.node-debug2</arg>
<arg>../target/chrome-debug-adapter/extension/</arg>
</arguments>
<workingDirectory>language-servers/</workingDirectory>
</configuration>
Expand Down Expand Up @@ -92,12 +108,16 @@
<arg>vscode-json-languageserver@1.2.1</arg>
<arg>yaml-language-server@0.5.2</arg>
<arg>firefox-debugadapter@2.0.1</arg>
<arg>debugger-for-chrome-4.11.7.tgz</arg>
</arguments>
<workingDirectory>language-servers/</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for those extra lines.



<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class InitializeLaunchConfigurations {
.unmodifiableSet(new HashSet<>(Arrays.asList(8, 9, 10, 11, 12, 13)));

private static boolean alreadyWarned;

public static String getNodeJsLocation() {
{
String nodeJsLocation = System.getProperty("org.eclipse.wildwebdeveloper.nodeJSLocation");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
--- org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/InitializeLaunchConfigurations.java
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like some garbage file

+++ org.eclipse.wildwebdeveloper/src/org/eclipse/wildwebdeveloper/InitializeLaunchConfigurations.java
@@ -48,18 +48,9 @@ public static String getNodeJsLocation() {
}
}

- String res = "/path/to/node";
- String[] command = new String[] { "/bin/bash", "-c", "which node" };
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
- command = new String[] { "cmd", "/c", "where node" };
- }
-
- try (BufferedReader reader = new BufferedReader(
- new InputStreamReader(Runtime.getRuntime().exec(command).getInputStream()));) {
- res = reader.readLine();
- } catch (IOException e) {
- Activator.getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e));
+ String res = which("node");
+ if (res == null) {
+ res = "/path/to/node";
}

// Try default install path as last resort
@@ -79,6 +70,22 @@ public static String getNodeJsLocation() {
return null;
}

+ public static String which(String progrgam) {
+ String res = null;
+ String[] command = new String[] { "/bin/bash", "-c", "which " + progrgam};
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ command = new String[] { "cmd", "/c", "where " + progrgam };
+ }
+ try (BufferedReader reader = new BufferedReader(
+ new InputStreamReader(Runtime.getRuntime().exec(command).getInputStream()));) {
+ res = reader.readLine();
+ } catch (IOException e) {
+ Activator.getDefault().getLog().log(
+ new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), e.getMessage(), e));
+ }
+ return res;
+ }
+
private static void validateNodeVersion(String nodeJsLocation) {

String nodeVersion = null;
@@ -105,30 +112,30 @@ private static void validateNodeVersion(String nodeJsLocation) {
}

private static void warnNodeJSMissing() {
- Display.getDefault().asyncExec(() -> {
+ Display.getDefault().asyncExec(() ->
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Missing node.js",
"Could not find node.js. This will result in editors missing key features.\n"
- + "Please make sure node.js is installed and that your PATH environment variable contains the location to the `node` executable.");
- });
+ + "Please make sure node.js is installed and that your PATH environment variable contains the location to the `node` executable.")
+ );
}

private static void warnNodeJSVersionUnsupported(String version) {
- Display.getDefault().asyncExec(() -> {
+ Display.getDefault().asyncExec(() ->
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Node.js " + version + " is not supported",
"Node.js " + version + " is not supported. This will result in editors missing key features.\n"
+ "Please make sure a supported version of node.js is installed and that your PATH environment variable contains the location to the `node` executable.\n"
+ "Supported major versions are: " + SUPPORT_NODEJS_MAJOR_VERSIONS.stream()
- .map(i -> String.valueOf(i)).collect(Collectors.joining(", ")));
- });
+ .map(String::valueOf).collect(Collectors.joining(", ")))
+ );
}

private static void warnNodeJSVersionCouldNotBeDetermined() {
- Display.getDefault().asyncExec(() -> {
+ Display.getDefault().asyncExec(() ->
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Node.js version could not be determined",
"Node.js version could not be determined. Please make sure a supported version of node.js is installed, editors may be missing key features otherwise.\n"
+ "Supported major versions are: " + SUPPORT_NODEJS_MAJOR_VERSIONS.stream()
- .map(i -> String.valueOf(i)).collect(Collectors.joining(", ")));
- });
+ .map(String::valueOf).collect(Collectors.joining(", ")))
+ );
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2019 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Andrew Obuchowicz (Red Hat Inc.)
*******************************************************************************/
package org.eclipse.wildwebdeveloper.debug;

import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.lsp4e.debug.DSPPlugin;
import org.eclipse.lsp4e.debug.launcher.DSPLaunchDelegate;
import org.eclipse.swt.widgets.Display;
import org.eclipse.wildwebdeveloper.Activator;
import org.eclipse.wildwebdeveloper.InitializeLaunchConfigurations;

public class AbstractDebugDelegate extends DSPLaunchDelegate{
public static final String PROGRAM = "program"; //$NON-NLS-1$
public static final String ARGUMENTS = "runtimeArgs"; //$NON-NLS-1$
public static final String CWD = DebugPlugin.ATTR_WORKING_DIRECTORY; //$NON-NLS-1$
public static final String ENV = ILaunchManager.ATTR_ENVIRONMENT_VARIABLES;
public static final String SOURCE_MAPS = "sourceMaps";
public static final String PORT = "port"; //$NON-NLS-1$
public static final String REQUEST = "request"; //$NON-NLS-1$

public void launchWithParameters(ILaunchConfiguration configuration, String mode, ILaunch launch,
IProgressMonitor monitor, Map<String, Object> param, File debugAdapter) throws CoreException {
try {
List<String> debugCmdArgs = Collections.singletonList(debugAdapter.getAbsolutePath());

DSPLaunchDelegateLaunchBuilder builder = new DSPLaunchDelegateLaunchBuilder(configuration, mode, launch,
monitor);
builder.setLaunchDebugAdapter(InitializeLaunchConfigurations.getNodeJsLocation(), debugCmdArgs);
builder.setMonitorDebugAdapter(configuration.getAttribute(DSPPlugin.ATTR_DSP_MONITOR_DEBUG_ADAPTER, false));
builder.setDspParameters(param);

super.launch(builder);
} catch (Exception e) {
IStatus errorStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
Activator.getDefault().getLog().log(errorStatus);
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
ErrorDialog.openError(Display.getDefault().getActiveShell(), "Debug error", e.getMessage(), errorStatus); //$NON-NLS-1$
}
});

}
}

}