@@ -4,13 +4,14 @@ import * as path from 'path';
44import * as os from 'os' ;
55import * as fs from 'fs' ;
66import { workspace , extensions , ExtensionContext , window , StatusBarAlignment , commands , ViewColumn , Uri , CancellationToken , TextDocumentContentProvider , TextEditor , WorkspaceConfiguration , languages , IndentAction , ProgressLocation , InputBoxOptions , Selection , Position } from 'vscode' ;
7- import { ExecuteCommandParams , ExecuteCommandRequest , LanguageClient , LanguageClientOptions , RevealOutputChannelOn , ServerOptions , Position as LSPosition , Location as LSLocation } from 'vscode-languageclient' ;
7+ import { ExecuteCommandParams , ExecuteCommandRequest , LanguageClient , LanguageClientOptions , RevealOutputChannelOn , ServerOptions , Position as LSPosition , Location as LSLocation , StreamInfo } from 'vscode-languageclient' ;
88import { collectionJavaExtensions } from './plugin' ;
99import { prepareExecutable , awaitServerConnection } from './javaServerStarter' ;
1010import * as requirements from './requirements' ;
1111import { Commands } from './commands' ;
1212import { StatusNotification , ClassFileContentsRequest , ProjectConfigurationUpdateRequest , MessageType , ActionableNotification , FeatureStatus , ActionableMessage , CompileWorkspaceRequest , CompileWorkspaceStatus , ProgressReportNotification , ExecuteClientCommandRequest , SendNotificationRequest } from './protocol' ;
1313import { ExtensionAPI } from './extension.api' ;
14+ import * as net from 'net' ;
1415
1516let oldConfig ;
1617let lastStatus ;
@@ -80,7 +81,22 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
8081 let serverOptions ;
8182 let port = process . env [ 'SERVER_PORT' ] ;
8283 if ( ! port ) {
83- serverOptions = prepareExecutable ( requirements , workspacePath , getJavaConfiguration ( ) ) ;
84+ let lsPort = process . env [ 'JDTLS_CLIENT_PORT' ] ;
85+ if ( ! lsPort ) {
86+ serverOptions = prepareExecutable ( requirements , workspacePath , getJavaConfiguration ( ) ) ;
87+ } else {
88+ let connectionInfo = {
89+ port : lsPort
90+ } ;
91+ serverOptions = ( ) => {
92+ let socket = net . connect ( connectionInfo ) ;
93+ let result : StreamInfo = {
94+ writer : socket ,
95+ reader : socket
96+ } ;
97+ return Promise . resolve ( result ) ;
98+ } ;
99+ }
84100 } else {
85101 // used during development
86102 serverOptions = awaitServerConnection . bind ( null , port ) ;
0 commit comments