Skip to content

Commit

Permalink
start LS from jar file within the extension
Browse files Browse the repository at this point in the history
  • Loading branch information
hsd-dev committed Jan 30, 2024
1 parent cec4f63 commit 6ccf2eb
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
'use strict';

import * as net from 'net';
// import * as net from 'net';
import { spawn } from 'child_process';
import * as path from 'path';

//import {Trace} from 'vscode-jsonrpc';
//import { window, workspace, commands, ExtensionContext, Uri } from 'vscode';
import { workspace, ExtensionContext } from 'vscode';
import { LanguageClient, LanguageClientOptions, StreamInfo } from 'vscode-languageclient/node';
import { LanguageClient, LanguageClientOptions } from 'vscode-languageclient/node';

let lc: LanguageClient;

export function activate(context: ExtensionContext) {
// The server is a started as a separate app and listens on port 5007
let connectionInfo = {
host: "localhost",
port: 5008
};
let serverOptions = () => {
// Connect to language server via socket
let socket = net.connect(connectionInfo);
let result: StreamInfo = {
writer: socket,
reader: socket
};
return Promise.resolve(result);
// // The server is a started as a separate app and listens on port 5007
// let connectionInfo = {
// host: "localhost",
// port: 5008
// };
// let serverOptions = () => {
// // Connect to language server via socket
// let socket = net.connect(connectionInfo);
// let result: StreamInfo = {
// writer: socket,
// reader: socket
// };
// return Promise.resolve(result);
// };

var serverOptions = function () {
// Connect to the language server via a io channel
var jar = context.asAbsolutePath(path.join('resources', 'de.fraunhofer.ipa.ros.xtext.ide-3.0.0-SNAPSHOT-ls.jar'));
var child = spawn('java', ['-Xdebug', '-Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n,quiet=y', '-jar', jar, '-log debug']);
console.log(child.stdout.toString());
child.stdout.on('data', function (chunk) {
console.log(chunk.toString());
});
child.stderr.on('data', function (chunk) {
console.error(chunk.toString());
});
return Promise.resolve(child);
};

let clientOptions: LanguageClientOptions = {
Expand All @@ -31,7 +47,7 @@ export function activate(context: ExtensionContext) {
fileEvents: workspace.createFileSystemWatcher('**/*.*')
}
};

// Create the language client and start the client.
lc = new LanguageClient('Xtext Server', serverOptions, clientOptions);

Expand Down

0 comments on commit 6ccf2eb

Please sign in to comment.