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

Enable debug in development #310

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Ensure you have [Node.js and npm](https://docs.npmjs.com/downloading-and-install
- Navigate to the Extensions activity bar, or use the shortcut `Ctrl`-`Shift`-`X`
- Click the `...` dropdown menu and select `Install from VSIX` and choose the generated `liberty-tools-vscode-xxx.vsix` file

Step 5 downloads the JARs for Liberty Config Language Server and Eclipse LSP4Jakarta that are consumed by the VS Code client.
If you would like a different version of the language servers other than what is available to download, the following instructions explain how to build these JARs locally. Then rerun steps 6 and 7.
> Step 5 downloads the JARs for Liberty Config Language Server and Eclipse LSP4Jakarta that are consumed by the VS Code client.
If you would like a different version of the language servers other than what is available to download, the following instructions explain how to build these JARs locally.

## Language Servers

Expand All @@ -53,6 +53,17 @@ For more information on building Liberty Config Language Server, see the project

For more information on building Eclipse LSP4Jakarta, see the project documentation on [GitHub](https://github.com/eclipse/lsp4jakarta/blob/main/docs/BUILDING.md). Note that there are [prerequisites](https://github.com/eclipse/lsp4jakarta/blob/main/docs/BUILDING.md#prerequisites) to building this project locally.

### Debugging Language Servers
When running the extension with locally built language servers, a debugger can be attached to the language server process.
The debug ports are as follows:
> Liberty Config Language Server
> - Liberty-LemminX: `1054`
> - Liberty Language Server: `8002`
>
> Jakarta LS: `8003`

With the `liberty-language-server` project opened in VSCode, run `Debug attach liberty-ls` or `Debug attach liberty-lemminx` to attach the respective debugger to the running extension.

## Localization

### package.json
Expand Down
29 changes: 13 additions & 16 deletions src/util/javaServerStarter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import { workspace } from 'vscode';
import { Executable, ExecutableOptions } from 'vscode-languageclient/node';
import { RequirementsData } from './requirements';
import * as glob from 'glob';
import {LIBERTY_LS_JAR} from '../extension'
import {JAKARTA_LS_JAR, LIBERTY_LS_JAR} from '../extension'

// const DEBUG = startedInDebugMode();
const LIBERTY_LS_DEBUG_PORT = 1064;
const DEBUG = startedInDebugMode();
const LIBERTY_LS_DEBUG_PORT = 8002;
const JAKARTA_LS_DEBUG_PORT = 8003;

// Referenced:
// https://github.com/redhat-developer/vscode-microprofile/blob/master/src/languageServer/javaServerStarter.ts
Expand All @@ -42,19 +43,15 @@ export function prepareExecutable(jarName: string, requirements: RequirementsDat
function prepareParams(jarName: string): string[] {
const params: string[] = [];

// TODO: debug doesn't work yet
// if (DEBUG) {
// if (process.env.SUSPEND_SERVER === 'true') {
// params.push(`-agentlib:jdwp=transport=dt_socket,server=y,address=${DEBUG_PORT}`);
// } else {
// params.push(`-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${DEBUG_PORT},quiet=y`);
// }
// }

// uncomment to debug the Liberty Config Language Server
// if (jarName === LIBERTY_LS_JAR) {
// params.push(`-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=${LIBERTY_LS_DEBUG_PORT}`);
// }
// will only add debug args when run in development, not when run as an extension
if (DEBUG) {
if (jarName === LIBERTY_LS_JAR) {
params.push(`-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${LIBERTY_LS_DEBUG_PORT},quiet=y`);
}
else if (jarName === JAKARTA_LS_JAR) {
params.push(`-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${JAKARTA_LS_DEBUG_PORT},quiet=y`);
}
}

const jarHome = path.resolve(__dirname, "../jars");
params.push('-jar');
Expand Down