Skip to content

Commit

Permalink
[Code] Adjust GoLauncher to adapt to the running pattern of go server.
Browse files Browse the repository at this point in the history
This adjust will let the code plugin connect the go-langserver actively.
It should be noted that the `GoLauncher` is a semi-manufacture only
support the detach mode for now.
  • Loading branch information
Henry Wong committed Mar 2, 2019
1 parent 4bcbca9 commit c702457
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions x-pack/plugins/code/server/lsp/go_launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,21 @@ export class GoLauncher implements ILanguageServerLauncher {

const log = this.loggerFactory.getLogger(['code', `go@${this.targetHost}:${port}`]);
const proxy = new LanguageServerProxy(port, this.targetHost, log);
proxy.awaitServerConnection();
// detach mode

log.info('Detach mode, expected langserver launch externally');
proxy.onConnected(() => {
this.isRunning = true;
});
proxy.onDisconnected(() => {
this.isRunning = false;
if (!proxy.isClosed) {
proxy.awaitServerConnection();
log.warn('language server disconnected, reconnecting');
setTimeout(() => proxy.connect(), 1000);
}
});

proxy.listen();
return new Promise<RequestExpander>(resolve => {
proxy.onConnected(() => {
resolve(new RequestExpander(proxy, builtinWorkspace, maxWorkspace, this.options));
});
});
await proxy.connect();
return new RequestExpander(proxy, builtinWorkspace, maxWorkspace, this.options);
}
}

0 comments on commit c702457

Please sign in to comment.