diff --git a/build.gradle b/build.gradle
index 6b11fcefdd..45bdaae265 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,14 +1,16 @@
buildscript {
+ ext.kotlinVersion = "1.4.10" // sync with pom.xml
repositories {
mavenCentral()
}
dependencies {
classpath 'org.xtext:xtext-gradle-plugin:2.0.8'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
plugins {
- id "com.github.johnrengelman.shadow" version "6.0.0"
+ id 'com.github.johnrengelman.shadow' version '6.0.0'
id 'java'
id 'jacoco'
}
@@ -19,19 +21,34 @@ subprojects {
mavenCentral()
}
- apply plugin: 'java'
+ apply plugin: 'kotlin'
+ compileKotlin {
+ destinationDir = compileJava.destinationDir
+ kotlinOptions {
+ jvmTarget = "1.8"
+ }
+ }
+
dependencies {
implementation platform("org.eclipse.xtext:xtext-dev-bom:${xtextVersion}")
// https://mvnrepository.com/artifact/com.google.inject/guice
implementation group: 'com.google.inject', name: 'guice', version: '5.0.1'
// https://mvnrepository.com/artifact/commons-cli/commons-cli
implementation group: 'commons-cli', name: 'commons-cli', version: '1.4'
- }
+ }
+ dependencies {
+ implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlinVersion
+ implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlinVersion
+ }
+
apply plugin: 'org.xtext.xtend'
apply from: "${rootDir}/gradle/source-layout.gradle"
apply plugin: 'eclipse'
-
+
+ // generate xtend sources before kotlin compilation
+ compileKotlin.dependsOn("generateXtext")
+
group = 'org.lflang'
version = '0.1.0-SNAPSHOT'
@@ -41,4 +58,11 @@ subprojects {
configurations.all {
exclude group: 'asm'
}
+
+ // Delete generated sources on `gradle clean`
+ clean.doFirst {
+ project.logger.info("Deleting ${projectDir}/xtend-gen, src-gen")
+ delete "${projectDir}/xtend-gen/"
+ delete "${projectDir}/src-gen/"
+ }
}
diff --git a/example/.gitignore b/example/.gitignore
index 62a9173771..f842b2dff2 100644
--- a/example/.gitignore
+++ b/example/.gitignore
@@ -6,4 +6,6 @@
/*/test-bin/
/*/src-gen/
my_trace
-
+include
+lib
+share
diff --git a/gradle/source-layout.gradle b/gradle/source-layout.gradle
index d0f730b2e3..32a778fef1 100644
--- a/gradle/source-layout.gradle
+++ b/gradle/source-layout.gradle
@@ -2,10 +2,12 @@ if (name.endsWith(".tests")) {
sourceSets {
main {
java.srcDirs = []
+ kotlin.srcDirs = []
resources.srcDirs = []
}
test {
java.srcDirs = ['src', 'src-gen']
+ kotlin.srcDirs = ['src', 'src-gen']
resources.srcDirs = ['src', 'src-gen']
xtendOutputDir = 'xtend-gen'
}
@@ -14,6 +16,7 @@ if (name.endsWith(".tests")) {
sourceSets {
main {
java.srcDirs = ['src', 'src-gen']
+ kotlin.srcDirs = ['src', 'src-gen', 'xtend-gen']
resources.srcDirs = ['src', 'src-gen']
xtendOutputDir = 'xtend-gen'
}
diff --git a/oomph/LinguaFranca.setup b/oomph/LinguaFranca.setup
index 278b62768a..532ab0d2a7 100644
--- a/oomph/LinguaFranca.setup
+++ b/oomph/LinguaFranca.setup
@@ -166,6 +166,19 @@
url="http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/"/>
Install the tools needed in the IDE to work with the source code for ${scope.project.label}
+
+
+
+
+
+
+
+
+
+
@@ -452,6 +471,8 @@
versionRange="2.25.0"/>
+
+
diff --git a/org.lflang.diagram/pom.xml b/org.lflang.diagram/pom.xml
index f5aa16a127..9296996d05 100644
--- a/org.lflang.diagram/pom.xml
+++ b/org.lflang.diagram/pom.xml
@@ -32,6 +32,10 @@
org.eclipse.xtend
xtend-maven-plugin
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+
diff --git a/org.lflang.ide/.classpath b/org.lflang.ide/.classpath
index 1aa5319633..f2f202a205 100644
--- a/org.lflang.ide/.classpath
+++ b/org.lflang.ide/.classpath
@@ -6,19 +6,15 @@
-
-
-
-
-
-
+
+
diff --git a/org.lflang.ide/.project b/org.lflang.ide/.project
index dd41def898..00d32931e3 100644
--- a/org.lflang.ide/.project
+++ b/org.lflang.ide/.project
@@ -20,6 +20,11 @@
+
+ org.jetbrains.kotlin.ui.kotlinBuilder
+
+
+
org.eclipse.pde.ManifestBuilder
@@ -36,5 +41,13 @@
org.eclipse.jdt.core.javanature
org.eclipse.pde.PluginNature
org.eclipse.buildship.core.gradleprojectnature
+ org.jetbrains.kotlin.core.kotlinNature
+
+
+ kotlin_bin
+ 2
+ org.jetbrains.kotlin.core.filesystem:/org.lflang.ide/kotlin_bin
+
+
diff --git a/org.lflang.ide/.settings/org.eclipse.jdt.core.prefs b/org.lflang.ide/.settings/org.eclipse.jdt.core.prefs
index f4d933e4eb..3056f74d3b 100644
--- a/org.lflang.ide/.settings/org.eclipse.jdt.core.prefs
+++ b/org.lflang.ide/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.kt
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
diff --git a/org.lflang.ide/pom.xml b/org.lflang.ide/pom.xml
index 15a7235744..4a36a678e6 100644
--- a/org.lflang.ide/pom.xml
+++ b/org.lflang.ide/pom.xml
@@ -31,6 +31,10 @@
org.eclipse.xtend
xtend-maven-plugin
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+
diff --git a/org.lflang.ide/src/org/lflang/ide/LFIdeModule.java b/org.lflang.ide/src/org/lflang/ide/LFIdeModule.java
new file mode 100644
index 0000000000..6c63d9c6e0
--- /dev/null
+++ b/org.lflang.ide/src/org/lflang/ide/LFIdeModule.java
@@ -0,0 +1,11 @@
+/*
+ * generated by Xtext 2.23.0
+ */
+package org.lflang.ide;
+
+
+/**
+ * Use this class to register ide components.
+ */
+public class LFIdeModule extends AbstractLFIdeModule {
+}
diff --git a/org.lflang.ide/src/org/lflang/ide/LFIdeModule.xtend b/org.lflang.ide/src/org/lflang/ide/LFIdeModule.xtend
deleted file mode 100644
index 15294b401d..0000000000
--- a/org.lflang.ide/src/org/lflang/ide/LFIdeModule.xtend
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * generated by Xtext 2.17.0
- */
-package org.lflang.ide
-
-
-/**
- * Use this class to register ide components.
- */
-class LFIdeModule extends AbstractLFIdeModule {
-}
diff --git a/org.lflang.ide/src/org/lflang/ide/LFIdeSetup.java b/org.lflang.ide/src/org/lflang/ide/LFIdeSetup.java
new file mode 100644
index 0000000000..034154d4f8
--- /dev/null
+++ b/org.lflang.ide/src/org/lflang/ide/LFIdeSetup.java
@@ -0,0 +1,22 @@
+/*
+ * generated by Xtext 2.23.0
+ */
+package org.lflang.ide;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import org.eclipse.xtext.util.Modules2;
+import org.lflang.LFRuntimeModule;
+import org.lflang.LFStandaloneSetup;
+
+/**
+ * Initialization support for running Xtext languages as language servers.
+ */
+public class LFIdeSetup extends LFStandaloneSetup {
+
+ @Override
+ public Injector createInjector() {
+ return Guice.createInjector(Modules2.mixin(new LFRuntimeModule(), new LFIdeModule()));
+ }
+
+}
diff --git a/org.lflang.ide/src/org/lflang/ide/LFIdeSetup.xtend b/org.lflang.ide/src/org/lflang/ide/LFIdeSetup.xtend
deleted file mode 100644
index 2dd67890f5..0000000000
--- a/org.lflang.ide/src/org/lflang/ide/LFIdeSetup.xtend
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * generated by Xtext 2.17.0
- */
-package org.lflang.ide
-
-import com.google.inject.Guice
-import org.eclipse.xtext.util.Modules2
-import org.lflang.LFRuntimeModule
-import org.lflang.LFStandaloneSetup
-
-/**
- * Initialization support for running Xtext languages as language servers.
- */
-class LFIdeSetup extends LFStandaloneSetup {
-
- override createInjector() {
- Guice.createInjector(Modules2.mixin(new LFRuntimeModule, new LFIdeModule))
- }
-
-}
diff --git a/org.lflang.rca/pom.xml b/org.lflang.rca/pom.xml
index b63bd8639e..1c7d8d65cb 100644
--- a/org.lflang.rca/pom.xml
+++ b/org.lflang.rca/pom.xml
@@ -18,6 +18,14 @@
+
+ org.eclipse.tycho
+ tycho-p2-repository-plugin
+ ${tycho-version}
+
+ true
+
+
org.eclipse.tycho
tycho-p2-director-plugin
diff --git a/org.lflang.targetplatform/org.lflang.targetplatform.target b/org.lflang.targetplatform/org.lflang.targetplatform.target
index 852991b151..99647fad7d 100644
--- a/org.lflang.targetplatform/org.lflang.targetplatform.target
+++ b/org.lflang.targetplatform/org.lflang.targetplatform.target
@@ -1,6 +1,6 @@
-
+
@@ -19,6 +19,7 @@
+
@@ -46,6 +47,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.lflang.tests/.classpath b/org.lflang.tests/.classpath
index 9c7e040c0a..90e203fa3a 100644
--- a/org.lflang.tests/.classpath
+++ b/org.lflang.tests/.classpath
@@ -23,5 +23,6 @@
+
diff --git a/org.lflang.tests/.gitignore b/org.lflang.tests/.gitignore
deleted file mode 100644
index 3fcdf48338..0000000000
--- a/org.lflang.tests/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-src/org/lflang/tests/LFParsingTest.xtend
\ No newline at end of file
diff --git a/org.lflang.tests/.project b/org.lflang.tests/.project
index b17de320d9..ec198a5045 100644
--- a/org.lflang.tests/.project
+++ b/org.lflang.tests/.project
@@ -20,6 +20,11 @@
+
+ org.jetbrains.kotlin.ui.kotlinBuilder
+
+
+
org.eclipse.pde.ManifestBuilder
@@ -36,5 +41,13 @@
org.eclipse.jdt.core.javanature
org.eclipse.pde.PluginNature
org.eclipse.buildship.core.gradleprojectnature
+ org.jetbrains.kotlin.core.kotlinNature
+
+
+ kotlin_bin
+ 2
+ org.jetbrains.kotlin.core.filesystem:/org.lflang.tests/kotlin_bin
+
+
diff --git a/org.lflang.tests/.settings/org.eclipse.jdt.core.prefs b/org.lflang.tests/.settings/org.eclipse.jdt.core.prefs
index f4d933e4eb..3056f74d3b 100644
--- a/org.lflang.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/org.lflang.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.kt
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
diff --git a/org.lflang.tests/build.gradle b/org.lflang.tests/build.gradle
index 090f9acef5..0fc1bc0249 100644
--- a/org.lflang.tests/build.gradle
+++ b/org.lflang.tests/build.gradle
@@ -9,13 +9,14 @@ dependencies {
testImplementation "org.eclipse.xtext:org.eclipse.xtext.xbase.testing:${xtextVersion}"
}
+apply plugin: 'java'
+apply plugin: 'jacoco'
+
jacoco {
toolVersion = "0.8.7"
reportsDir = file("$buildDir/reports/jacoco") //default directory where jacoco generates test reports
}
-apply plugin: 'java'
-apply plugin: 'jacoco'
jacocoTestReport {
reports {
diff --git a/org.lflang.tests/pom.xml b/org.lflang.tests/pom.xml
index 82a97024f4..2a8ae18507 100644
--- a/org.lflang.tests/pom.xml
+++ b/org.lflang.tests/pom.xml
@@ -35,6 +35,15 @@
+
+ org.eclipse.xtend
+ xtend-maven-plugin
+
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+
+
org.eclipse.tycho
@@ -47,56 +56,6 @@
-
-
-
-
-
-
-
- org.eclipse.xtend
- xtend-maven-plugin
-
-
org.eclipse.tycho
tycho-surefire-plugin
@@ -147,4 +106,5 @@
+
diff --git a/org.lflang.tests/src/org/lflang/tests/LFParsingTest.java b/org.lflang.tests/src/org/lflang/tests/LFParsingTest.java
new file mode 100644
index 0000000000..4b8b2340d7
--- /dev/null
+++ b/org.lflang.tests/src/org/lflang/tests/LFParsingTest.java
@@ -0,0 +1,31 @@
+/*
+ * generated by Xtext 2.23.0
+ */
+package org.lflang.tests;
+
+import com.google.inject.Inject;
+import java.util.List;
+import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
+import org.eclipse.xtext.testing.InjectWith;
+import org.eclipse.xtext.testing.extensions.InjectionExtension;
+import org.eclipse.xtext.testing.util.ParseHelper;
+import org.eclipse.xtext.xbase.lib.IterableExtensions;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.lflang.lf.Model;
+
+@ExtendWith(InjectionExtension.class)
+@InjectWith(LFInjectorProvider.class)
+public class LFParsingTest {
+ @Inject
+ private ParseHelper parseHelper;
+
+ @Test
+ public void loadModel() throws Exception {
+ Model result = parseHelper.parse("Hello Xtext!");
+ Assertions.assertNotNull(result);
+ List errors = result.eResource().getErrors();
+ Assertions.assertTrue(errors.isEmpty(), "Unexpected errors: " + IterableExtensions.join(errors, ", "));
+ }
+}
diff --git a/org.lflang.tests/src/org/lflang/tests/compiler/LinguaFrancaValidationTest.xtend b/org.lflang.tests/src/org/lflang/tests/compiler/LinguaFrancaValidationTest.xtend
index 81f482d921..bb8fe0d144 100644
--- a/org.lflang.tests/src/org/lflang/tests/compiler/LinguaFrancaValidationTest.xtend
+++ b/org.lflang.tests/src/org/lflang/tests/compiler/LinguaFrancaValidationTest.xtend
@@ -46,8 +46,8 @@ import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.^extension.ExtendWith
-import static org.junit.Assert.assertNotNull
-import static org.junit.Assert.assertTrue
+import static org.junit.jupiter.api.Assertions.assertNotNull
+import static org.junit.jupiter.api.Assertions.assertTrue
import static extension org.lflang.ASTUtils.*
import org.lflang.TargetProperty.UnionType
diff --git a/org.lflang.tests/src/org/lflang/tests/runtime/TestBase.xtend b/org.lflang.tests/src/org/lflang/tests/runtime/TestBase.xtend
index 2dcbd77068..3ce30badf6 100644
--- a/org.lflang.tests/src/org/lflang/tests/runtime/TestBase.xtend
+++ b/org.lflang.tests/src/org/lflang/tests/runtime/TestBase.xtend
@@ -30,7 +30,7 @@ import org.lflang.tests.TestRegistry.TestCategory
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.^extension.ExtendWith
-import static extension org.junit.Assert.assertTrue
+import static extension org.junit.jupiter.api.Assertions.assertTrue
@ExtendWith(InjectionExtension)
@InjectWith(LFInjectorProvider)
diff --git a/org.lflang.ui.tests/.classpath b/org.lflang.ui.tests/.classpath
index 116a47ac18..5c18ede0c1 100644
--- a/org.lflang.ui.tests/.classpath
+++ b/org.lflang.ui.tests/.classpath
@@ -10,11 +10,6 @@
-
-
-
-
-
diff --git a/org.lflang.ui.tests/pom.xml b/org.lflang.ui.tests/pom.xml
index 0dcdb286f1..1869ad1438 100644
--- a/org.lflang.ui.tests/pom.xml
+++ b/org.lflang.ui.tests/pom.xml
@@ -27,22 +27,14 @@
-
-
- org.eclipse.tycho
- tycho-compiler-plugin
- ${tycho-version}
-
- -err:-forbidden
- false
-
-
-
-
org.eclipse.xtend
xtend-maven-plugin
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+
org.eclipse.tycho
tycho-surefire-plugin
diff --git a/org.lflang.ui/pom.xml b/org.lflang.ui/pom.xml
index e5e83d4f9d..f51c5d4df6 100644
--- a/org.lflang.ui/pom.xml
+++ b/org.lflang.ui/pom.xml
@@ -1,6 +1,6 @@
-
+
4.0.0
@@ -31,6 +31,10 @@
org.eclipse.xtend
xtend-maven-plugin
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+
diff --git a/org.lflang.ui/src/org/lflang/ui/LFUiModule.java b/org.lflang.ui/src/org/lflang/ui/LFUiModule.java
new file mode 100644
index 0000000000..4c94e74f2d
--- /dev/null
+++ b/org.lflang.ui/src/org/lflang/ui/LFUiModule.java
@@ -0,0 +1,16 @@
+/*
+ * generated by Xtext 2.23.0
+ */
+package org.lflang.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * Use this class to register components to be used within the Eclipse IDE.
+ */
+public class LFUiModule extends LFUiModuleImpl {
+
+ public LFUiModule(AbstractUIPlugin plugin) {
+ super(plugin);
+ }
+}
diff --git a/org.lflang.ui/src/org/lflang/ui/LFUiModule.xtend b/org.lflang.ui/src/org/lflang/ui/LFUiModuleImpl.xtend
similarity index 99%
rename from org.lflang.ui/src/org/lflang/ui/LFUiModule.xtend
rename to org.lflang.ui/src/org/lflang/ui/LFUiModuleImpl.xtend
index 004c1113b3..b0e86994b9 100644
--- a/org.lflang.ui/src/org/lflang/ui/LFUiModule.xtend
+++ b/org.lflang.ui/src/org/lflang/ui/LFUiModuleImpl.xtend
@@ -34,7 +34,7 @@ import java.io.PrintStream
* subclassing, and the code has no comments in it at all.
*/
@FinalFieldsConstructor
-class LFUiModule extends AbstractLFUiModule {
+class LFUiModuleImpl extends AbstractLFUiModule {
static var consoleInitialized = false
diff --git a/org.lflang.ui/src/org/lflang/ui/contentassist/LFProposalProvider.java b/org.lflang.ui/src/org/lflang/ui/contentassist/LFProposalProvider.java
new file mode 100644
index 0000000000..9e10038905
--- /dev/null
+++ b/org.lflang.ui/src/org/lflang/ui/contentassist/LFProposalProvider.java
@@ -0,0 +1,12 @@
+/*
+ * generated by Xtext 2.23.0
+ */
+package org.lflang.ui.contentassist;
+
+
+/**
+ * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#content-assist
+ * on how to customize the content assistant.
+ */
+public class LFProposalProvider extends AbstractLFProposalProvider {
+}
diff --git a/org.lflang.ui/src/org/lflang/ui/contentassist/LFProposalProvider.xtend b/org.lflang.ui/src/org/lflang/ui/contentassist/LFProposalProvider.xtend
deleted file mode 100644
index 0076cea5ef..0000000000
--- a/org.lflang.ui/src/org/lflang/ui/contentassist/LFProposalProvider.xtend
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * generated by Xtext 2.17.0
- */
-package org.lflang.ui.contentassist
-
-
-/**
- * See https://www.eclipse.org/Xtext/documentation/304_ide_concepts.html#content-assist
- * on how to customize the content assistant.
- */
-class LFProposalProvider extends AbstractLFProposalProvider {
-}
diff --git a/org.lflang.ui/src/org/lflang/ui/labeling/LFDescriptionLabelProvider.xtend b/org.lflang.ui/src/org/lflang/ui/labeling/LFDescriptionLabelProvider.java
similarity index 50%
rename from org.lflang.ui/src/org/lflang/ui/labeling/LFDescriptionLabelProvider.xtend
rename to org.lflang.ui/src/org/lflang/ui/labeling/LFDescriptionLabelProvider.java
index 047124fff4..cbb042511a 100644
--- a/org.lflang.ui/src/org/lflang/ui/labeling/LFDescriptionLabelProvider.xtend
+++ b/org.lflang.ui/src/org/lflang/ui/labeling/LFDescriptionLabelProvider.java
@@ -1,24 +1,25 @@
/*
* generated by Xtext 2.23.0
*/
-package org.lflang.ui.labeling
+package org.lflang.ui.labeling;
-import org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider
+import org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider;
/**
* Provides labels for IEObjectDescriptions and IResourceDescriptions.
*
* See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#label-provider
*/
-class LFDescriptionLabelProvider extends DefaultDescriptionLabelProvider {
+public class LFDescriptionLabelProvider extends DefaultDescriptionLabelProvider {
// Labels and icons can be computed like this:
-
-// override text(IEObjectDescription ele) {
-// ele.name.toString
+// @Override
+// public String text(IEObjectDescription ele) {
+// return ele.getName().toString();
// }
-//
-// override image(IEObjectDescription ele) {
-// ele.EClass.name + '.gif'
+//
+// @Override
+// public String image(IEObjectDescription ele) {
+// return ele.getEClass().getName() + ".gif";
// }
}
diff --git a/org.lflang.ui/src/org/lflang/ui/labeling/LFLabelProvider.java b/org.lflang.ui/src/org/lflang/ui/labeling/LFLabelProvider.java
new file mode 100644
index 0000000000..568b19120d
--- /dev/null
+++ b/org.lflang.ui/src/org/lflang/ui/labeling/LFLabelProvider.java
@@ -0,0 +1,31 @@
+/*
+ * generated by Xtext 2.23.0
+ */
+package org.lflang.ui.labeling;
+
+import com.google.inject.Inject;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider;
+
+/**
+ * Provides labels for EObjects.
+ *
+ * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#label-provider
+ */
+public class LFLabelProvider extends DefaultEObjectLabelProvider {
+
+ @Inject
+ public LFLabelProvider(AdapterFactoryLabelProvider delegate) {
+ super(delegate);
+ }
+
+ // Labels and icons can be computed like this:
+
+// String text(Greeting ele) {
+// return "A greeting to " + ele.getName();
+// }
+//
+// String image(Greeting ele) {
+// return "Greeting.gif";
+// }
+}
diff --git a/org.lflang.ui/src/org/lflang/ui/labeling/LFLabelProvider.xtend b/org.lflang.ui/src/org/lflang/ui/labeling/LFLabelProvider.xtend
deleted file mode 100644
index 75c75822e6..0000000000
--- a/org.lflang.ui/src/org/lflang/ui/labeling/LFLabelProvider.xtend
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * generated by Xtext 2.23.0
- */
-package org.lflang.ui.labeling
-
-import com.google.inject.Inject
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider
-import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider
-
-/**
- * Provides labels for EObjects.
- *
- * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#label-provider
- */
-class LFLabelProvider extends DefaultEObjectLabelProvider {
-
- @Inject
- new(AdapterFactoryLabelProvider delegate) {
- super(delegate);
- }
-
- // Labels and icons can be computed like this:
-
-// def text(Greeting ele) {
-// 'A greeting to ' + ele.name
-// }
-//
-// def image(Greeting ele) {
-// 'Greeting.gif'
-// }
-}
diff --git a/org.lflang.ui/src/org/lflang/ui/outline/LFOutlineTreeProvider.xtend b/org.lflang.ui/src/org/lflang/ui/outline/LFOutlineTreeProvider.java
similarity index 68%
rename from org.lflang.ui/src/org/lflang/ui/outline/LFOutlineTreeProvider.xtend
rename to org.lflang.ui/src/org/lflang/ui/outline/LFOutlineTreeProvider.java
index 2f81586eef..5a141e7a8e 100644
--- a/org.lflang.ui/src/org/lflang/ui/outline/LFOutlineTreeProvider.xtend
+++ b/org.lflang.ui/src/org/lflang/ui/outline/LFOutlineTreeProvider.java
@@ -1,15 +1,15 @@
/*
* generated by Xtext 2.23.0
*/
-package org.lflang.ui.outline
+package org.lflang.ui.outline;
-import org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider
+import org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider;
/**
* Customization of the default outline structure.
*
* See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#outline
*/
-class LFOutlineTreeProvider extends DefaultOutlineTreeProvider {
+public class LFOutlineTreeProvider extends DefaultOutlineTreeProvider {
}
diff --git a/org.lflang.ui/src/org/lflang/ui/quickfix/LFQuickfixProvider.java b/org.lflang.ui/src/org/lflang/ui/quickfix/LFQuickfixProvider.java
new file mode 100644
index 0000000000..a9dd0ae481
--- /dev/null
+++ b/org.lflang.ui/src/org/lflang/ui/quickfix/LFQuickfixProvider.java
@@ -0,0 +1,26 @@
+/*
+ * generated by Xtext 2.23.0
+ */
+package org.lflang.ui.quickfix;
+
+import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider;
+
+/**
+ * Custom quickfixes.
+ *
+ * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#quick-fixes
+ */
+public class LFQuickfixProvider extends DefaultQuickfixProvider {
+
+// @Fix(LFValidator.INVALID_NAME)
+// public void capitalizeName(final Issue issue, IssueResolutionAcceptor acceptor) {
+// acceptor.accept(issue, "Capitalize name", "Capitalize the name.", "upcase.png", new IModification() {
+// public void apply(IModificationContext context) throws BadLocationException {
+// IXtextDocument xtextDocument = context.getXtextDocument();
+// String firstLetter = xtextDocument.get(issue.getOffset(), 1);
+// xtextDocument.replace(issue.getOffset(), 1, firstLetter.toUpperCase());
+// }
+// });
+// }
+
+}
diff --git a/org.lflang.ui/src/org/lflang/ui/quickfix/LFQuickfixProvider.xtend b/org.lflang.ui/src/org/lflang/ui/quickfix/LFQuickfixProvider.xtend
deleted file mode 100644
index 5473c6fcef..0000000000
--- a/org.lflang.ui/src/org/lflang/ui/quickfix/LFQuickfixProvider.xtend
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * generated by Xtext 2.23.0
- */
-package org.lflang.ui.quickfix
-
-import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider
-
-/**
- * Custom quickfixes.
- *
- * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#quick-fixes
- */
-class LFQuickfixProvider extends DefaultQuickfixProvider {
-
-// @Fix(LFValidator.INVALID_NAME)
-// def capitalizeName(Issue issue, IssueResolutionAcceptor acceptor) {
-// acceptor.accept(issue, 'Capitalize name', 'Capitalize the name.', 'upcase.png') [
-// context |
-// val xtextDocument = context.xtextDocument
-// val firstLetter = xtextDocument.get(issue.offset, 1)
-// xtextDocument.replace(issue.offset, 1, firstLetter.toUpperCase)
-// ]
-// }
-}
diff --git a/org.lflang.web/.classpath b/org.lflang.web/.classpath
index 36bc8839a7..a082f9a6ec 100644
--- a/org.lflang.web/.classpath
+++ b/org.lflang.web/.classpath
@@ -12,12 +12,6 @@
-
-
-
-
-
-
@@ -25,5 +19,6 @@
+
diff --git a/org.lflang.web/.project b/org.lflang.web/.project
index 023d4957f4..ca368bbe6f 100644
--- a/org.lflang.web/.project
+++ b/org.lflang.web/.project
@@ -30,6 +30,11 @@
+
+ org.jetbrains.kotlin.ui.kotlinBuilder
+
+
+
org.eclipse.jdt.core.javanature
@@ -37,5 +42,13 @@
org.eclipse.wst.common.project.facet.core.nature
org.eclipse.wst.common.modulecore.ModuleCoreNature
org.eclipse.buildship.core.gradleprojectnature
+ org.jetbrains.kotlin.core.kotlinNature
+
+
+ kotlin_bin
+ 2
+ org.jetbrains.kotlin.core.filesystem:/org.lflang.web/kotlin_bin
+
+
diff --git a/org.lflang.web/.settings/org.eclipse.jdt.core.prefs b/org.lflang.web/.settings/org.eclipse.jdt.core.prefs
index f4d933e4eb..3056f74d3b 100644
--- a/org.lflang.web/.settings/org.eclipse.jdt.core.prefs
+++ b/org.lflang.web/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.kt
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
diff --git a/org.lflang.web/.settings/org.eclipse.wst.common.component b/org.lflang.web/.settings/org.eclipse.wst.common.component
index cdf8a7cee1..e93ed3ca81 100644
--- a/org.lflang.web/.settings/org.eclipse.wst.common.component
+++ b/org.lflang.web/.settings/org.eclipse.wst.common.component
@@ -4,6 +4,7 @@
+
uses
diff --git a/org.lflang.web/src-gen/org/lflang/web/AbstractLinguaFrancaWebModule.java b/org.lflang.web/src/org/lflang/web/AbstractLinguaFrancaWebModule.java
similarity index 100%
rename from org.lflang.web/src-gen/org/lflang/web/AbstractLinguaFrancaWebModule.java
rename to org.lflang.web/src/org/lflang/web/AbstractLinguaFrancaWebModule.java
diff --git a/org.lflang/.classpath b/org.lflang/.classpath
index 1aa5319633..1b604e5af8 100644
--- a/org.lflang/.classpath
+++ b/org.lflang/.classpath
@@ -20,5 +20,6 @@
+
diff --git a/org.lflang/.project b/org.lflang/.project
index 947290c99e..3b22ebf011 100644
--- a/org.lflang/.project
+++ b/org.lflang/.project
@@ -20,6 +20,11 @@
+
+ org.jetbrains.kotlin.ui.kotlinBuilder
+
+
+
org.eclipse.pde.ManifestBuilder
@@ -36,5 +41,13 @@
org.eclipse.jdt.core.javanature
org.eclipse.pde.PluginNature
org.eclipse.buildship.core.gradleprojectnature
+ org.jetbrains.kotlin.core.kotlinNature
+
+
+ kotlin_bin
+ 2
+ org.jetbrains.kotlin.core.filesystem:/org.lflang/kotlin_bin
+
+
diff --git a/org.lflang/.settings/org.eclipse.jdt.core.prefs b/org.lflang/.settings/org.eclipse.jdt.core.prefs
index 519596a625..9d92e3c736 100644
--- a/org.lflang/.settings/org.eclipse.jdt.core.prefs
+++ b/org.lflang/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.kt
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
diff --git a/org.lflang/META-INF/MANIFEST.MF b/org.lflang/META-INF/MANIFEST.MF
index 781becbe42..4725e9f337 100644
--- a/org.lflang/META-INF/MANIFEST.MF
+++ b/org.lflang/META-INF/MANIFEST.MF
@@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.xtext,
org.antlr.runtime;bundle-version="[3.2.0,3.2.1)",
com.google.guava,
org.eclipse.xtend.lib.macro,
- org.apache.commons.cli;bundle-version="1.4"
+ org.apache.commons.cli;bundle-version="1.4",
+ org.jetbrains.kotlin.bundled-compiler
Bundle-RequiredExecutionEnvironment: JavaSE-11
Export-Package: org.lflang,
org.lflang.generator,
diff --git a/org.lflang/build.gradle b/org.lflang/build.gradle
index d23b97eeed..442fc15984 100644
--- a/org.lflang/build.gradle
+++ b/org.lflang/build.gradle
@@ -29,6 +29,34 @@ task generateXtextLanguage(type: JavaExec) {
args += "src/org/lflang/GenerateLinguaFranca.mwe2"
args += "-p"
args += "rootPath=/${projectDir}/.."
+
+ // Currently we don't need to delete any generated files because we use the
+ // Java/Xtend implementations. However, if we commit to porting such files
+ // to Kotlin, we might to reintroduce the deletion mechanism below.
+ /*doLast {
+ def filesToDelete = [
+ "org.lflang.validation.LFValidator",
+ "org.lflang.LFRuntimeModule",
+ "org.lflang.LFStandaloneSetup",
+ "org.lflang.generator.LFGenerator",
+ "org.lflang.scoping.LFScopeProvider"
+ ]
+
+ filesToDelete.each { qname ->
+ def path = qname.replace('.', '/')
+ def ktFile = file("src/${path}.kt")
+ def javaFile = file("src/${path}.java")
+ def xtendFile = file("src/${path}.xtend")
+
+ if (ktFile.exists() || xtendFile.exists()) {
+ def chosenLang = ktFile.exists() ? "Kotlin" : "Xtend"
+ project.logger.info("deleting ${projectDir.relativePath(javaFile)}, the ${chosenLang} file prevails")
+ project.delete(javaFile) // generated by Xtend
+ } else {
+ project.logger.info("no ${projectDir.relativePath(ktFile)}, leaving the Java implementation in")
+ }
+ }
+ }*/
}
generateXtext.dependsOn(generateXtextLanguage)
@@ -36,7 +64,6 @@ clean.dependsOn(cleanGenerateXtextLanguage)
eclipse.classpath.plusConfigurations += [configurations.mwe2]
task generateStandaloneCompiler() {
- apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
mainClassName = 'org.lflang.generator.Main'
@@ -51,10 +78,16 @@ task generateStandaloneCompiler() {
resource = 'plugin.properties'
}
}
-
- compileJava {
- options.compilerArgs << '-Xlint:unchecked'
- }
}
generateStandaloneCompiler.finalizedBy shadowJar
+
+task runLfc(type: JavaExec) {
+ // Note: when you use --args, you need to escape cli flags which start with --
+ // For instance --args ' --help'
+ // Otherwise they're parsed as arguments to the Gradle CLI, not LFC.
+ description = "Build and run LFC, use --args to pass arguments"
+ group = "application"
+ classpath = sourceSets.main.runtimeClasspath
+ mainClass = 'org.lflang.generator.Main'
+}
diff --git a/org.lflang/pom.xml b/org.lflang/pom.xml
index e782be5a07..c666a8bde2 100644
--- a/org.lflang/pom.xml
+++ b/org.lflang/pom.xml
@@ -86,6 +86,45 @@
org.eclipse.xtend
xtend-maven-plugin
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+
+
+ org.eclipse.tycho
+ tycho-compiler-plugin
+
org.apache.maven.plugins
@@ -166,4 +205,3 @@
-
diff --git a/org.lflang/src/org/lflang/AstExtensions.kt b/org.lflang/src/org/lflang/AstExtensions.kt
new file mode 100644
index 0000000000..66ed2d643f
--- /dev/null
+++ b/org.lflang/src/org/lflang/AstExtensions.kt
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2021, The University of California at Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.lflang
+
+import org.lflang.lf.*
+
+/**
+ * If this reactor declaration is an import, then
+ * return the imported reactor class definition.
+ * Otherwise, just return the argument.
+ */
+fun ReactorDecl.toDefinition(): Reactor = when (this) {
+ is Reactor -> this
+ is ImportedReactor -> this.reactorClass
+ else -> throw AssertionError("Unknown reactor type: $this")
+}
+
+/**
+ * Given a reactor class, return a list of all its actions,
+ * which includes actions of base classes that it extends.
+ */
+val Reactor.allActions: List get() = collectInSupertypes { actions }
+
+/**
+ * Given a reactor class, return a list of all its connections,
+ * which includes connections of base classes that it extends.
+ */
+val Reactor.allConnections: List get() = collectInSupertypes { connections }
+
+/**
+ * Given a reactor class, return a list of all its inputs,
+ * which includes inputs of base classes that it extends.
+ */
+val Reactor.allInputs: List get() = collectInSupertypes { inputs }
+
+/**
+ * Given a reactor class, return a list of all its outputs,
+ * which includes outputs of base classes that it extends.
+ */
+val Reactor.allOutputs: List
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+ ${kotlin.version}
+
+
+ kotlin-compile
+ process-sources
+
+ compile
+
+
+
+ ${project.basedir}/src
+ ${project.basedir}/src-gen
+ ${project.basedir}/xtend-gen
+
+
+
+
+
+
+
+ org.eclipse.tycho
+ tycho-compiler-plugin
+ ${tycho-version}
+
+
+ default-compile
+ compile
+
+
+
+
+
+
+ consider
org.lflang
org.lflang.targetplatform
- 0.1.0-SNAPSHOT
+ ${project.version}