Skip to content

Commit bb8a729

Browse files
Merge branch 'master' into jinbo_bugfix
2 parents 54aa30c + 74f5663 commit bb8a729

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,36 @@ mvnw.cmd clean install
3535
./mvnw clean install
3636
```
3737

38+
39+
## Usage with eclipse.jdt.ls
40+
41+
To use `java-debug` as a [jdt.ls](https://github.com/eclipse/eclipse.jdt.ls) plugin, an [LSP client](https://langserver.org/) has to launch [jdt.ls](https://github.com/eclipse/eclipse.jdt.ls) with `initializationOptions` that contain the path to the built `java-debug` jar within a `bundles` array:
42+
43+
44+
```
45+
{
46+
"initializationOptions": {
47+
"bundles": [
48+
"path/to/microsoft/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-<version>.jar"
49+
]
50+
}
51+
}
52+
```
53+
54+
Editor extensions like [vscode-java](https://github.com/redhat-developer/vscode-java) take care of this.
55+
56+
57+
Once `eclipse.jdt.ls` launched, the client can send a [Command](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#command) to the server to start a debug session:
58+
59+
```
60+
{
61+
"command": "vscode.java.startDebugSession"
62+
}
63+
```
64+
65+
The response to this request will contain a port number on which the debug adapter is listening, and to which a client implementing the debug-adapter protocol can connect to.
66+
67+
3868
License
3969
-------
4070
EPL 1.0, See [LICENSE](LICENSE.txt) file.

com.microsoft.java.debug.plugin/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<command id="vscode.java.resolveBuildFiles"/>
1818
<command id="vscode.java.isOnClasspath"/>
1919
<command id="vscode.java.resolveJavaExecutable"/>
20+
<command id="vscode.java.fetchPlatformSettings"/>
2021
</delegateCommandHandler>
2122
</extension>
2223
</plugin>

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JavaDebugDelegateCommandHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class JavaDebugDelegateCommandHandler implements IDelegateCommandHandler
4444
public static final String RESOLVE_BUILD_FILES = "vscode.java.resolveBuildFiles";
4545
public static final String IS_ON_CLASSPATH = "vscode.java.isOnClasspath";
4646
public static final String RESOLVE_JAVA_EXECUTABLE = "vscode.java.resolveJavaExecutable";
47+
public static final String FETCH_PLATFORM_SETTINGS = "vscode.java.fetchPlatformSettings";
4748

4849
@Override
4950
public Object executeCommand(String commandId, List<Object> arguments, IProgressMonitor progress) throws Exception {
@@ -81,6 +82,8 @@ public Object executeCommand(String commandId, List<Object> arguments, IProgress
8182
return isOnClasspath(arguments);
8283
case RESOLVE_JAVA_EXECUTABLE:
8384
return ResolveJavaExecutableHandler.resolveJavaExecutable(arguments);
85+
case FETCH_PLATFORM_SETTINGS:
86+
return PlatformSettings.getPlatformSettings();
8487
default:
8588
break;
8689
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2020 Microsoft Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Microsoft Corporation - initial API and implementation
10+
*******************************************************************************/
11+
12+
package com.microsoft.java.debug.plugin.internal;
13+
14+
import java.util.HashMap;
15+
import java.util.Map;
16+
17+
import org.eclipse.jdt.core.JavaCore;
18+
19+
public class PlatformSettings {
20+
21+
/**
22+
* Resolve the JDT platform settings.
23+
*/
24+
public static Map<String, String> getPlatformSettings() {
25+
Map<String, String> result = new HashMap<>();
26+
result.put("latestSupportedJavaVersion", JavaCore.latestSupportedJavaVersion());
27+
return result;
28+
}
29+
}

0 commit comments

Comments
 (0)