mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-15 08:18:55 +00:00
fix vscode extension, launch script, TestLangLSPExtension to actually work
Signed-off-by: Christian Dietrich <christian.dietrich@itemis.de>
This commit is contained in:
parent
81b88c9e54
commit
392d37f3fb
9 changed files with 71 additions and 61 deletions
|
@ -124,8 +124,7 @@ public abstract class AbstractIdeQuickfixTest {
|
|||
private <T> T createInMemoryFile(CharSequence content, EClass type) {
|
||||
InMemoryURIHandler fs = new InMemoryURIHandler();
|
||||
String fileName = "inmemory:/file1." + fileExtensionProvider.getPrimaryFileExtension();
|
||||
Pair<String, String> _mappedTo = Pair.of(fileName, content.toString());
|
||||
quickFixTestHelper.operator_add(fs, _mappedTo);
|
||||
quickFixTestHelper.operator_add(fs, Pair.of(fileName, content.toString()));
|
||||
ResourceSet rs = quickFixTestHelper.createResourceSet(fs);
|
||||
Map<String, ResourceDescriptionsData> dataMap = new HashMap<>();
|
||||
dataMap.put("project", ResourceDescriptionsData.ResourceSetAdapter.findResourceDescriptionsData(rs));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* Copyright (c) 2016, 2022 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
|
@ -88,7 +88,6 @@ public interface TestLangLSPExtension extends ILanguageServerExtension {
|
|||
public void initialize(ILanguageServerAccess access) {
|
||||
this.access = access;
|
||||
this.access.addBuildListener(this);
|
||||
this.client = ServiceEndpoints.toServiceObject((Endpoint) access.getLanguageClient(), CustomClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,6 +95,9 @@ public interface TestLangLSPExtension extends ILanguageServerExtension {
|
|||
BuildNotification buildNotification = new BuildNotification();
|
||||
buildNotification.message = "Built "
|
||||
+ Joiner.on(", ").join(Lists.transform(deltas, d -> d.getUri().toString()), ", ");
|
||||
if (client == null) {
|
||||
client = ServiceEndpoints.toServiceObject((Endpoint) access.getLanguageClient(), CustomClient.class);
|
||||
}
|
||||
client.buildHappened(buildNotification);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.lsp4j.CodeLens;
|
|||
import org.eclipse.lsp4j.CodeLensParams;
|
||||
import org.eclipse.lsp4j.Command;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.xtext.ide.server.Document;
|
||||
import org.eclipse.xtext.ide.server.codelens.ICodeLensResolver;
|
||||
import org.eclipse.xtext.ide.server.codelens.ICodeLensService;
|
||||
|
@ -35,8 +36,8 @@ public class CodeLensService implements ICodeLensService, ICodeLensResolver {
|
|||
command.setTitle("Do Awesome Stuff");
|
||||
command.setArguments(Lists.newArrayList("foo", Integer.valueOf(1), Boolean.valueOf(true)));
|
||||
codeLens.setCommand(command);
|
||||
Position _position = new Position(1, 2);
|
||||
codeLens.setData(_position);
|
||||
codeLens.setData(new Position(1, 2));
|
||||
codeLens.setRange(new Range(new Position(1,1), new Position(1,2)));
|
||||
return Lists.newArrayList(codeLens);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* Copyright (c) 2016, 2022 TypeFox GmbH (http://www.typefox.io) and others.
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0.
|
||||
|
@ -8,34 +8,17 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.xtext.ide.tests.testlanguage.server;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
import org.eclipse.lsp4j.jsonrpc.Launcher;
|
||||
import org.eclipse.lsp4j.launch.LSPLauncher;
|
||||
import org.eclipse.lsp4j.services.LanguageClient;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.eclipse.xtext.ide.server.ServerModule;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author kosyakov - Initial contribution and API
|
||||
*/
|
||||
public class SocketServerLauncher {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Injector injector = Guice.createInjector(new ServerModule());
|
||||
LanguageServer languageServer = injector.getInstance(LanguageServer.class);
|
||||
ServerSocketChannel serverSocket = ServerSocketChannel.open();
|
||||
serverSocket.bind(new InetSocketAddress("localhost", 5007));
|
||||
SocketChannel socketChannel = serverSocket.accept();
|
||||
Launcher<LanguageClient> launcher = LSPLauncher.createServerLauncher(languageServer, Channels.newInputStream(socketChannel), Channels.newOutputStream(socketChannel), true, new PrintWriter(System.out));
|
||||
launcher.startListening().get();
|
||||
org.eclipse.xtext.ide.server.SocketServerLauncher.main(new String[] {
|
||||
"-host", "localhost",
|
||||
"-port", "5007",
|
||||
"-trace"
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,17 +8,11 @@
|
|||
|
||||
// A task runner that calls a custom npm script that compiles the extension.
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"version": "2.0.0",
|
||||
|
||||
// we want to run npm
|
||||
"command": "npm",
|
||||
|
||||
// the command is a shell script
|
||||
"isShellCommand": true,
|
||||
|
||||
// show the output window only if unrecognized errors occur.
|
||||
"showOutput": "silent",
|
||||
|
||||
// we run the custom script "compile" as defined in package.json
|
||||
"args": ["run", "compile", "--loglevel", "silent"],
|
||||
|
||||
|
@ -26,5 +20,24 @@
|
|||
"isWatching": true,
|
||||
|
||||
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
|
||||
"problemMatcher": "$tsc-watch"
|
||||
"problemMatcher": "$tsc-watch",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "npm",
|
||||
"type": "shell",
|
||||
"command": "npm",
|
||||
"args": [
|
||||
"run",
|
||||
"compile",
|
||||
"--loglevel",
|
||||
"silent"
|
||||
],
|
||||
"isBackground": true,
|
||||
"problemMatcher": "$tsc-watch",
|
||||
"group": {
|
||||
"_id": "build",
|
||||
"isDefault": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
"version": "0.0.1",
|
||||
"publisher": "TypeFox",
|
||||
"engines": {
|
||||
"vscode": "^1.0.0"
|
||||
"vscode": "^1.64.0"
|
||||
},
|
||||
"categories": [
|
||||
"Languages"
|
||||
|
@ -13,7 +13,7 @@
|
|||
"activationEvents": [
|
||||
"onLanguage:testlang"
|
||||
],
|
||||
"main": "./out/src/extension",
|
||||
"main": "./out/extension",
|
||||
"contributes": {
|
||||
"languages": [{
|
||||
"id": "testlang",
|
||||
|
@ -28,15 +28,18 @@
|
|||
}]
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
|
||||
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./",
|
||||
"postinstall": "node ./node_modules/vscode/bin/install"
|
||||
"prepublish": "tsc -p ./src",
|
||||
"compile": "tsc -p ./src",
|
||||
"watch": "tsc -w -p ./src",
|
||||
"update-vscode": "node ./node_modules/vscode/bin/install"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^1.8.5",
|
||||
"vscode": "^0.11.0"
|
||||
"@types/node": "^17.0.18",
|
||||
"@types/vscode": "^1.64.0",
|
||||
"typescript": "^4.5.5",
|
||||
"vscode-test": "^1.5.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"vscode-languageclient": "^2.2.1"
|
||||
"vscode-languageclient": "^7.0.0"
|
||||
}
|
||||
}
|
|
@ -10,8 +10,9 @@
|
|||
|
||||
import * as net from 'net';
|
||||
|
||||
import { Disposable, ExtensionContext } from 'vscode';
|
||||
import { LanguageClient, LanguageClientOptions, StreamInfo } from 'vscode-languageclient';
|
||||
import {Trace} from 'vscode-jsonrpc';
|
||||
import { window, workspace, commands, ExtensionContext, Uri } from 'vscode';
|
||||
import { LanguageClient, LanguageClientOptions, StreamInfo, Position as LSPosition, Location as LSLocation } from 'vscode-languageclient/node';
|
||||
|
||||
export function activate(context: ExtensionContext) {
|
||||
let serverOptions = {
|
||||
|
@ -32,7 +33,15 @@ export function activate(context: ExtensionContext) {
|
|||
}
|
||||
|
||||
// Create the language client and start the client.
|
||||
let disposable = new LanguageClient('xtext.server', 'Xtext Server', serverInfo, clientOptions).start();
|
||||
|
||||
|
||||
let client = new LanguageClient('xtext.server', 'Xtext Server', serverInfo, clientOptions)
|
||||
client.onReady().then(() => {
|
||||
client.onNotification("buildHappened", (o: any) => {
|
||||
console.log(o);
|
||||
});
|
||||
});
|
||||
let disposable = client.start();
|
||||
|
||||
// Push the disposable to the context's subscriptions so that the
|
||||
// client can be deactivated on extension deactivation
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"sourceMap": false,
|
||||
"inlineSources": false,
|
||||
"declaration": true,
|
||||
"stripInternal": true,
|
||||
"lib": [ "es6" ],
|
||||
"outDir": "../out"
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"outDir": "out",
|
||||
"noLib": true,
|
||||
"sourceMap": true,
|
||||
"rootDir": "."
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue