Skip to content

Commit 823ce36

Browse files
committed
Add Language Server support for the ros (component level) DSLs
1 parent 8976943 commit 823ce36

File tree

6 files changed

+480
-9
lines changed

6 files changed

+480
-9
lines changed

plugins/de.fraunhofer.ipa.ros.xtext.ide/pom.xml

Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,124 @@
1212
<packaging>eclipse-plugin</packaging>
1313

1414
<build>
15+
<sourceDirectory>src</sourceDirectory>
16+
<resources>
17+
<resource>
18+
<directory>src</directory>
19+
<excludes>
20+
<exclude>**/*.java</exclude>
21+
<exclude>**/*.xtend</exclude>
22+
</excludes>
23+
</resource>
24+
</resources>
1525
<plugins>
1626
<plugin>
1727
<groupId>org.eclipse.xtend</groupId>
1828
<artifactId>xtend-maven-plugin</artifactId>
1929
</plugin>
30+
<plugin>
31+
<groupId>org.codehaus.mojo</groupId>
32+
<artifactId>build-helper-maven-plugin</artifactId>
33+
<version>3.3.0</version>
34+
<executions>
35+
<execution>
36+
<id>add-source</id>
37+
<phase>initialize</phase>
38+
<goals>
39+
<goal>add-source</goal>
40+
<goal>add-resource</goal>
41+
</goals>
42+
<configuration>
43+
<sources>
44+
<source>src-gen</source>
45+
</sources>
46+
<resources>
47+
<resource>
48+
<directory>src-gen</directory>
49+
<excludes>
50+
<exclude>**/*.java</exclude>
51+
<exclude>**/*.g</exclude>
52+
</excludes>
53+
</resource>
54+
</resources>
55+
</configuration>
56+
</execution>
57+
</executions>
58+
</plugin>
2059
<plugin>
2160
<groupId>org.apache.maven.plugins</groupId>
22-
<artifactId>maven-clean-plugin</artifactId>
61+
<artifactId>maven-shade-plugin</artifactId>
62+
<version>3.2.4</version>
63+
<configuration>
64+
<transformers>
65+
<transformer
66+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
67+
<mainClass>de.fraunhofer.ipa.ros.ide.launch.ServerLauncher</mainClass>
68+
</transformer>
69+
<transformer
70+
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
71+
<resource>plugin.properties</resource>
72+
</transformer>
73+
<transformer
74+
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer">
75+
</transformer>
76+
</transformers>
77+
<filters>
78+
<filter>
79+
<artifact>*:*</artifact>
80+
<excludes>
81+
<exclude>META-INF/INDEX.LIST</exclude>
82+
<exclude>META-INF/*.SF</exclude>
83+
<exclude>META-INF/*.DSA</exclude>
84+
<exclude>META-INF/*.RSA</exclude>
85+
<exclude>.options</exclude>
86+
<exclude>.api_description</exclude>
87+
<exclude>*.profile</exclude>
88+
<exclude>*.html</exclude>
89+
<exclude>about.*</exclude>
90+
<exclude>about_files/*</exclude>
91+
<exclude>plugin.xml</exclude>
92+
<exclude>systembundle.properties</exclude>
93+
<exclude>profile.list</exclude>
94+
<exclude>**/*._trace</exclude>
95+
<exclude>**/*.g</exclude>
96+
<exclude>**/*.mwe2</exclude>
97+
<exclude>**/*.xtext</exclude>
98+
</excludes>
99+
</filter>
100+
</filters>
101+
<shadedArtifactAttached>true</shadedArtifactAttached>
102+
<shadedClassifierName>ls</shadedClassifierName>
103+
<minimizeJar>false</minimizeJar>
104+
</configuration>
23105
<executions>
24106
<execution>
25-
<id>xtend-gen-clean</id>
26-
<phase>clean</phase>
107+
<phase>package</phase>
108+
<goals>
109+
<goal>shade</goal>
110+
</goals>
27111
</execution>
28112
</executions>
29113
</plugin>
30114
</plugins>
31115
</build>
32116

117+
<dependencies>
118+
<dependency>
119+
<groupId>${project.groupId}</groupId>
120+
<artifactId>de.fraunhofer.ipa.ros.xtext</artifactId>
121+
<version>${project.version}</version>
122+
</dependency>
123+
<dependency>
124+
<groupId>org.eclipse.xtext</groupId>
125+
<artifactId>org.eclipse.xtext.ide</artifactId>
126+
<version>${xtextVersion}</version>
127+
</dependency>
128+
<dependency>
129+
<groupId>org.eclipse.xtext</groupId>
130+
<artifactId>org.eclipse.xtext.xbase.ide</artifactId>
131+
<version>${xtextVersion}</version>
132+
</dependency>
133+
</dependencies>
33134
</project>
135+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package de.fraunhofer.ipa.ros.ide.launch;
2+
3+
import java.io.IOException;
4+
import java.net.InetSocketAddress;
5+
import java.net.SocketAddress;
6+
import java.nio.channels.AsynchronousServerSocketChannel;
7+
import java.nio.channels.AsynchronousSocketChannel;
8+
import java.nio.channels.Channels;
9+
import java.util.concurrent.ExecutionException;
10+
import java.util.concurrent.ExecutorService;
11+
import java.util.concurrent.Executors;
12+
import java.util.concurrent.Future;
13+
import java.util.function.Function;
14+
15+
import org.eclipse.lsp4j.jsonrpc.Launcher;
16+
import org.eclipse.lsp4j.jsonrpc.MessageConsumer;
17+
import org.eclipse.lsp4j.services.LanguageClient;
18+
import org.eclipse.xtext.ide.server.LanguageServerImpl;
19+
import org.eclipse.xtext.ide.server.ServerModule;
20+
21+
import com.google.inject.Guice;
22+
import com.google.inject.Injector;
23+
24+
public class ServerLauncher {
25+
public static void main(String[] args) throws InterruptedException, IOException {
26+
Injector injector = Guice.createInjector(new ServerModule());
27+
LanguageServerImpl languageServer = injector.getInstance(LanguageServerImpl.class);
28+
Function<MessageConsumer, MessageConsumer> wrapper = consumer -> {
29+
MessageConsumer result = consumer;
30+
return result;
31+
};
32+
Launcher<LanguageClient> launcher = createSocketLauncher(languageServer, LanguageClient.class,
33+
new InetSocketAddress("localhost", 5008), Executors.newCachedThreadPool(), wrapper);
34+
languageServer.connect(launcher.getRemoteProxy());
35+
Future<?> future = launcher.startListening();
36+
while (!future.isDone()) {
37+
Thread.sleep(10_000l);
38+
}
39+
}
40+
41+
static <T> Launcher<T> createSocketLauncher(Object localService, Class<T> remoteInterface,
42+
SocketAddress socketAddress, ExecutorService executorService,
43+
Function<MessageConsumer, MessageConsumer> wrapper) throws IOException {
44+
AsynchronousServerSocketChannel serverSocket = AsynchronousServerSocketChannel.open().bind(socketAddress);
45+
AsynchronousSocketChannel socketChannel;
46+
try {
47+
socketChannel = serverSocket.accept().get();
48+
return Launcher.createIoLauncher(localService, remoteInterface, Channels.newInputStream(socketChannel),
49+
Channels.newOutputStream(socketChannel), executorService, wrapper);
50+
} catch (InterruptedException | ExecutionException e) {
51+
e.printStackTrace();
52+
}
53+
return null;
54+
}
55+
}

plugins/de.fraunhofer.ipa.ros1.xtext.ide/pom.xml

Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,124 @@
1212
<packaging>eclipse-plugin</packaging>
1313

1414
<build>
15+
<sourceDirectory>src</sourceDirectory>
16+
<resources>
17+
<resource>
18+
<directory>src</directory>
19+
<excludes>
20+
<exclude>**/*.java</exclude>
21+
<exclude>**/*.xtend</exclude>
22+
</excludes>
23+
</resource>
24+
</resources>
1525
<plugins>
1626
<plugin>
1727
<groupId>org.eclipse.xtend</groupId>
1828
<artifactId>xtend-maven-plugin</artifactId>
1929
</plugin>
30+
<plugin>
31+
<groupId>org.codehaus.mojo</groupId>
32+
<artifactId>build-helper-maven-plugin</artifactId>
33+
<version>3.3.0</version>
34+
<executions>
35+
<execution>
36+
<id>add-source</id>
37+
<phase>initialize</phase>
38+
<goals>
39+
<goal>add-source</goal>
40+
<goal>add-resource</goal>
41+
</goals>
42+
<configuration>
43+
<sources>
44+
<source>src-gen</source>
45+
</sources>
46+
<resources>
47+
<resource>
48+
<directory>src-gen</directory>
49+
<excludes>
50+
<exclude>**/*.java</exclude>
51+
<exclude>**/*.g</exclude>
52+
</excludes>
53+
</resource>
54+
</resources>
55+
</configuration>
56+
</execution>
57+
</executions>
58+
</plugin>
2059
<plugin>
2160
<groupId>org.apache.maven.plugins</groupId>
22-
<artifactId>maven-clean-plugin</artifactId>
61+
<artifactId>maven-shade-plugin</artifactId>
62+
<version>3.2.4</version>
63+
<configuration>
64+
<transformers>
65+
<transformer
66+
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
67+
<mainClass>de.fraunhofer.ipa.ros1.ide.launch.ServerLauncher</mainClass>
68+
</transformer>
69+
<transformer
70+
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
71+
<resource>plugin.properties</resource>
72+
</transformer>
73+
<transformer
74+
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer">
75+
</transformer>
76+
</transformers>
77+
<filters>
78+
<filter>
79+
<artifact>*:*</artifact>
80+
<excludes>
81+
<exclude>META-INF/INDEX.LIST</exclude>
82+
<exclude>META-INF/*.SF</exclude>
83+
<exclude>META-INF/*.DSA</exclude>
84+
<exclude>META-INF/*.RSA</exclude>
85+
<exclude>.options</exclude>
86+
<exclude>.api_description</exclude>
87+
<exclude>*.profile</exclude>
88+
<exclude>*.html</exclude>
89+
<exclude>about.*</exclude>
90+
<exclude>about_files/*</exclude>
91+
<exclude>plugin.xml</exclude>
92+
<exclude>systembundle.properties</exclude>
93+
<exclude>profile.list</exclude>
94+
<exclude>**/*._trace</exclude>
95+
<exclude>**/*.g</exclude>
96+
<exclude>**/*.mwe2</exclude>
97+
<exclude>**/*.xtext</exclude>
98+
</excludes>
99+
</filter>
100+
</filters>
101+
<shadedArtifactAttached>true</shadedArtifactAttached>
102+
<shadedClassifierName>ls</shadedClassifierName>
103+
<minimizeJar>false</minimizeJar>
104+
</configuration>
23105
<executions>
24106
<execution>
25-
<id>xtend-gen-clean</id>
26-
<phase>clean</phase>
107+
<phase>package</phase>
108+
<goals>
109+
<goal>shade</goal>
110+
</goals>
27111
</execution>
28112
</executions>
29113
</plugin>
30114
</plugins>
31115
</build>
32116

117+
<dependencies>
118+
<dependency>
119+
<groupId>${project.groupId}</groupId>
120+
<artifactId>de.fraunhofer.ipa.ros.xtext</artifactId>
121+
<version>${project.version}</version>
122+
</dependency>
123+
<dependency>
124+
<groupId>org.eclipse.xtext</groupId>
125+
<artifactId>org.eclipse.xtext.ide</artifactId>
126+
<version>${xtextVersion}</version>
127+
</dependency>
128+
<dependency>
129+
<groupId>org.eclipse.xtext</groupId>
130+
<artifactId>org.eclipse.xtext.xbase.ide</artifactId>
131+
<version>${xtextVersion}</version>
132+
</dependency>
133+
</dependencies>
134+
33135
</project>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package de.fraunhofer.ipa.ros1.ide.launch;
2+
3+
import java.io.IOException;
4+
import java.net.InetSocketAddress;
5+
import java.net.SocketAddress;
6+
import java.nio.channels.AsynchronousServerSocketChannel;
7+
import java.nio.channels.AsynchronousSocketChannel;
8+
import java.nio.channels.Channels;
9+
import java.util.concurrent.ExecutionException;
10+
import java.util.concurrent.ExecutorService;
11+
import java.util.concurrent.Executors;
12+
import java.util.concurrent.Future;
13+
import java.util.function.Function;
14+
15+
import org.eclipse.lsp4j.jsonrpc.Launcher;
16+
import org.eclipse.lsp4j.jsonrpc.MessageConsumer;
17+
import org.eclipse.lsp4j.services.LanguageClient;
18+
import org.eclipse.xtext.ide.server.LanguageServerImpl;
19+
import org.eclipse.xtext.ide.server.ServerModule;
20+
21+
import com.google.inject.Guice;
22+
import com.google.inject.Injector;
23+
24+
public class ServerLauncher {
25+
public static void main(String[] args) throws InterruptedException, IOException {
26+
Injector injector = Guice.createInjector(new ServerModule());
27+
LanguageServerImpl languageServer = injector.getInstance(LanguageServerImpl.class);
28+
Function<MessageConsumer, MessageConsumer> wrapper = consumer -> {
29+
MessageConsumer result = consumer;
30+
return result;
31+
};
32+
Launcher<LanguageClient> launcher = createSocketLauncher(languageServer, LanguageClient.class,
33+
new InetSocketAddress("localhost", 5008), Executors.newCachedThreadPool(), wrapper);
34+
languageServer.connect(launcher.getRemoteProxy());
35+
Future<?> future = launcher.startListening();
36+
while (!future.isDone()) {
37+
Thread.sleep(10_000l);
38+
}
39+
}
40+
41+
static <T> Launcher<T> createSocketLauncher(Object localService, Class<T> remoteInterface,
42+
SocketAddress socketAddress, ExecutorService executorService,
43+
Function<MessageConsumer, MessageConsumer> wrapper) throws IOException {
44+
AsynchronousServerSocketChannel serverSocket = AsynchronousServerSocketChannel.open().bind(socketAddress);
45+
AsynchronousSocketChannel socketChannel;
46+
try {
47+
socketChannel = serverSocket.accept().get();
48+
return Launcher.createIoLauncher(localService, remoteInterface, Channels.newInputStream(socketChannel),
49+
Channels.newOutputStream(socketChannel), executorService, wrapper);
50+
} catch (InterruptedException | ExecutionException e) {
51+
e.printStackTrace();
52+
}
53+
return null;
54+
}
55+
}

0 commit comments

Comments
 (0)