Skip to content

Commit

Permalink
#13 Added VS Code support using LSP (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
arminzavada authored Nov 4, 2024
2 parents d47a671 + f74463c commit 6c9074c
Show file tree
Hide file tree
Showing 245 changed files with 9,152 additions and 546 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,30 @@ jobs:
# if: ${{ matrix.os == 'macos-13' }}
- name: Test Docker
run: docker run hello-world
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Checkout code
uses: actions/checkout@v4
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: subprojects/oxsts-vs-code/node_modules
key: ${{ matrix.os }}-node-${{ hashFiles('subprojects/oxsts-vs-code/package-lock.json') }}
restore-keys: |
${{ matrix.os }}-node-
- name: Gradle build
run: ./gradlew build
- name: Upload Artifacts
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
path: |
**/build/vscode/
**/build/distributions/
**/build/reports/
**/build/test-results/
Expand Down
12 changes: 12 additions & 0 deletions .run/Compile SimpleMission LeaderOperational_Unsafe.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Compile SimpleMission LeaderOperational_Unsafe" type="JetRunConfigurationType">
<option name="MAIN_CLASS_NAME" value="hu.bme.mit.semantifyr.oxsts.semantifyr.SemantifyrCliKt" />
<module name="semantifyr.semantifyr.main" />
<option name="PROGRAM_PARAMETERS" value="compile TestModels\Automated\Gamma\SimpleMission\model.oxsts TestModels\Automated\GammaSemanticLibrary LeaderOperational_Unsafe" />
<shortenClasspath name="NONE" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/subprojects/semantifyr" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors

SPDX-License-Identifier: EPL-2.0
12 changes: 12 additions & 0 deletions .run/Verify SimpleMission LeaderOperational_Unsafe.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Verify SimpleMission LeaderOperational_Unsafe" type="JetRunConfigurationType">
<option name="MAIN_CLASS_NAME" value="hu.bme.mit.semantifyr.oxsts.semantifyr.SemantifyrCliKt" />
<module name="semantifyr.semantifyr.main" />
<option name="PROGRAM_PARAMETERS" value="verify TestModels\Automated\Gamma\SimpleMission\model.oxsts TestModels\Automated\GammaSemanticLibrary LeaderOperational_Unsafe" />
<shortenClasspath name="NONE" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/subprojects/semantifyr" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors

SPDX-License-Identifier: EPL-2.0
12 changes: 12 additions & 0 deletions .run/Verify XSTS SimpleMission LeaderOperational_Unsafe.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Verify XSTS SimpleMission LeaderOperational_Unsafe" type="JetRunConfigurationType">
<option name="MAIN_CLASS_NAME" value="hu.bme.mit.semantifyr.oxsts.semantifyr.SemantifyrCliKt" />
<module name="semantifyr.semantifyr.main" />
<option name="PROGRAM_PARAMETERS" value="verify-xsts TestModels\Automated\Gamma\SimpleMission\model.xsts" />
<shortenClasspath name="NONE" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/subprojects/semantifyr" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors

SPDX-License-Identifier: EPL-2.0
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
#
# SPDX-License-Identifier: EPL-2.0

org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048M
org.gradle.cache=true
org.gradle.configuration-cache=true
org.gradle.parallel=true
thetaVersion=6.5.2
7 changes: 5 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ log4j = "2.24.1"
xtext = "2.36.0"
kotlin = "2.0.0"
kotlinxCoroutines = "1.9.0"
kotlinxCli = "0.3.6"
cliKt = "5.0.1"
viatra = "2.9.1"
dockerJava = "3.4.0"
guice = "7.0.0"
node = "7.1.0"

[libraries]
ecore = { group = "org.eclipse.emf", name = "org.eclipse.emf.ecore", version.ref = "ecore" }
Expand All @@ -32,11 +33,12 @@ slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" }
slf4j-log4j = { group = "org.apache.logging.log4j", name = "log4j-slf4j2-impl", version.ref = "log4j" }
xtext-bom = { group = "org.eclipse.xtext", name = "xtext-dev-bom", version.ref = "xtext" }
xtext-core = { group = "org.eclipse.xtext", name = "org.eclipse.xtext", version.ref = "xtext" }
xtext-ide = { group = "org.eclipse.xtext", name = "org.eclipse.xtext.ide", version.ref = "xtext" }
xtext-generator-antlr = { group = "org.eclipse.xtext", name = "xtext-antlr-generator", version = "2.1.1" }
xtext-generator = { group = "org.eclipse.xtext", name = "org.eclipse.xtext.xtext.generator", version.ref = "xtext" }
xtext-testing = { group = "org.eclipse.xtext", name = "org.eclipse.xtext.testing", version.ref = "xtext" }
xtext-xbase = { group = "org.eclipse.xtext", name = "org.eclipse.xtext.xbase", version.ref = "xtext" }
kotlinx-cli = { group = "org.jetbrains.kotlinx", name = "kotlinx-cli", version.ref = "kotlinxCli" }
clikt = { group = "com.github.ajalt.clikt", name = "clikt", version.ref = "cliKt" }
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
viatra-query-language = { group = "org.eclipse.viatra", name = "viatra-query-language", version.ref = "viatra" }
viatra-query-runtime = { group = "org.eclipse.viatra", name = "viatra-query-runtime", version.ref = "viatra" }
Expand All @@ -47,3 +49,4 @@ docker-java-transport = { group = "com.github.docker-java" , name = "docker-java

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
gradle-node = { id = "com.github.node-gradle.node", version.ref = "node" }
6 changes: 5 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
rootProject.name = "semantifyr"

include(
"compiler",
"semantifyr",
"xsts.lang",
"xsts.lang.ide",
"oxsts.model",
"oxsts.lang",
"oxsts.lang.ide",
"semantifyr-vscode",
)

rootProject.children.forEach { project ->
Expand Down
38 changes: 0 additions & 38 deletions subprojects/compiler/src/main/kotlin/EngineCli.kt

This file was deleted.

84 changes: 0 additions & 84 deletions subprojects/compiler/src/main/kotlin/reader/OxstsReader.kt

This file was deleted.

2 changes: 1 addition & 1 deletion subprojects/oxsts.lang.ide/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
#
# SPDX-License-Identifier: EPL-2.0

**
/src/main/xtext-gen/
!.gitignore
56 changes: 56 additions & 0 deletions subprojects/oxsts.lang.ide/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
*
* SPDX-License-Identifier: EPL-2.0
*/

plugins {
id("hu.bme.mit.semantifyr.gradle.xtext-generated")
id("hu.bme.mit.semantifyr.gradle.conventions.application")
}

val ideGeneratedClasspath by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
}

dependencies {
api(project(":oxsts.lang"))

implementation(libs.xtext.ide)
runtimeOnly(libs.slf4j.log4j)

ideGeneratedClasspath(project(":oxsts.lang", configuration = "ideGeneratedOutput"))
}

val distributionOutput by configurations.creating {
isCanBeConsumed = true
isCanBeResolved = false
}

artifacts {
add(distributionOutput.name, layout.buildDirectory.dir("install")) {
builtBy(tasks.installDist)
}
}

val cloneIdeGenerated by tasks.registering(Sync::class) {
inputs.files(ideGeneratedClasspath)

from(ideGeneratedClasspath.asFileTree)
into("src/main/xtext-gen")
}

listOf("compileJava", "processResources").forEach { task ->
tasks.named(task) {
inputs.files(cloneIdeGenerated.get().outputs)
}
}

tasks.clean {
delete("src/main/xtext-gen")
}

application {
mainClass = "hu.bme.mit.semantifyr.oxsts.lang.ide.OxstsIdeSetup"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
*
* SPDX-License-Identifier: EPL-2.0
*/

package hu.bme.mit.semantifyr.oxsts.lang.ide;

/**
* Use this class to register ide components.
*/
public class OxstsIdeModule extends AbstractOxstsIdeModule {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
*
* SPDX-License-Identifier: EPL-2.0
*/

package hu.bme.mit.semantifyr.oxsts.lang.ide;

import com.google.inject.Guice;
import com.google.inject.Injector;
import hu.bme.mit.semantifyr.oxsts.lang.OxstsRuntimeModule;
import hu.bme.mit.semantifyr.oxsts.lang.OxstsStandaloneSetup;
import hu.bme.mit.semantifyr.oxsts.model.oxsts.OxstsPackage;
import org.eclipse.lsp4j.jsonrpc.Launcher;
import org.eclipse.lsp4j.services.LanguageClient;
import org.eclipse.xtext.ide.server.LanguageServerImpl;
import org.eclipse.xtext.ide.server.ServerModule;
import org.eclipse.xtext.util.Modules2;

import java.io.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
* Initialization support for running Xtext languages as language servers.
*/
public class OxstsIdeSetup extends OxstsStandaloneSetup {

@Override
public Injector createInjector() {
return Guice.createInjector(Modules2.mixin(new OxstsRuntimeModule(), new OxstsIdeModule()));
}

public static void main(String[] args) throws InterruptedException, ExecutionException {
OxstsIdeSetup.doSetup();
OxstsPackage.eINSTANCE.getName();

Injector injector = Guice.createInjector(new ServerModule());
LanguageServerImpl languageServer = injector.getInstance(LanguageServerImpl.class);

Launcher<LanguageClient> launcher = Launcher.createLauncher(languageServer, LanguageClient.class, System.in, System.out);
languageServer.connect(launcher.getRemoteProxy());
launcher.startListening().get();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2023-2024 The Semantifyr Authors
#
# SPDX-License-Identifier: EPL-2.0

_UI_DiagnosticRoot_diagnostic=Specified, so the LSP server functions correctly
Loading

0 comments on commit 6c9074c

Please sign in to comment.