diff --git a/DEVELOPING.md b/DEVELOPING.md index 36422fd0..5093dfb3 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -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 @@ -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-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 diff --git a/src/util/javaServerStarter.ts b/src/util/javaServerStarter.ts index 684c6e04..d510901e 100644 --- a/src/util/javaServerStarter.ts +++ b/src/util/javaServerStarter.ts @@ -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 @@ -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');