Skip to content

Commit

Permalink
Add support for TransportKind.pipe through java.transport setting.
Browse files Browse the repository at this point in the history
- Do not expose java.transport setting to UI

Signed-off-by: Roland Grunberg <[email protected]>
  • Loading branch information
rgrunber committed Oct 25, 2023
1 parent ff5fcb3 commit c7cfca4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/javaServerStarter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as net from 'net';
import * as os from 'os';
import * as path from 'path';
import { ExtensionContext, version, workspace } from 'vscode';
import { Executable, ExecutableOptions, StreamInfo } from 'vscode-languageclient/node';
import { Executable, ExecutableOptions, StreamInfo, TransportKind } from 'vscode-languageclient/node';
import { logger } from './log';
import { addLombokParam, isLombokSupportEnabled } from './lombokSupport';
import { RequirementsData } from './requirements';
Expand Down Expand Up @@ -48,6 +48,21 @@ export function prepareExecutable(requirements: RequirementsData, workspacePath,
executable.options = options;
executable.command = path.resolve(`${requirements.tooling_jre}/bin/java`);
executable.args = prepareParams(requirements, workspacePath, context, isSyntaxServer);
const transportKind = getJavaConfiguration().get('transport');
switch (transportKind) {
case 'pipe':
executable.transport = TransportKind.pipe;
break;
case 'stdio':
executable.transport = TransportKind.stdio;
break;
default:
const isInsider: boolean = version.includes("insider");
const javaExtVersion = context.extension.packageJSON?.version;
const isPreReleaseVersion = /^\d+\.\d+\.\d{10}/.test(javaExtVersion);
executable.transport = (isInsider || isPreReleaseVersion) ? TransportKind.pipe : TransportKind.stdio;
break;
}
logger.info(`Starting Java server with: ${executable.command} ${executable.args.join(' ')}`);
return executable;
}
Expand Down
3 changes: 2 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ function hasJavaConfigChanged(oldConfig: WorkspaceConfiguration, newConfig: Work
|| hasConfigKeyChanged('home', oldConfig, newConfig)
|| hasConfigKeyChanged('jdt.ls.vmargs', oldConfig, newConfig)
|| hasConfigKeyChanged('server.launchMode', oldConfig, newConfig)
|| hasConfigKeyChanged('sharedIndexes.location', oldConfig, newConfig);;
|| hasConfigKeyChanged('sharedIndexes.location', oldConfig, newConfig)
|| hasConfigKeyChanged('transport', oldConfig, newConfig);
}

function hasConfigKeyChanged(key, oldConfig, newConfig) {
Expand Down

0 comments on commit c7cfca4

Please sign in to comment.