diff --git a/core/src/main/java/org/lflang/target/Target.java b/core/src/main/java/org/lflang/target/Target.java index 98f39929f4..6128c95c13 100644 --- a/core/src/main/java/org/lflang/target/Target.java +++ b/core/src/main/java/org/lflang/target/Target.java @@ -425,6 +425,14 @@ public boolean supportsFederated() { }; } + /** Return true if the target supports decentralized coordination. */ + public boolean supportsDecentralizedCoordination() { + return switch (this) { + case C, CCPP, Python, Polyglot -> true; + default -> false; + }; + } + /** Return true if the target supports reactor inheritance (extends keyword). */ public boolean supportsInheritance() { return switch (this) { diff --git a/core/src/main/java/org/lflang/target/property/CoordinationProperty.java b/core/src/main/java/org/lflang/target/property/CoordinationProperty.java index 6809aeb99d..3307b5300b 100644 --- a/core/src/main/java/org/lflang/target/property/CoordinationProperty.java +++ b/core/src/main/java/org/lflang/target/property/CoordinationProperty.java @@ -3,6 +3,8 @@ import org.lflang.MessageReporter; import org.lflang.ast.ASTUtils; import org.lflang.lf.Element; +import org.lflang.lf.LfPackage.Literals; +import org.lflang.target.TargetConfig; import org.lflang.target.property.type.CoordinationModeType; import org.lflang.target.property.type.CoordinationModeType.CoordinationMode; @@ -35,6 +37,19 @@ protected CoordinationMode fromString(String string, MessageReporter reporter) { return ((CoordinationModeType) this.type).forName(string); } + @Override + public void validate(TargetConfig config, MessageReporter reporter) { + if (config.get(this) == CoordinationMode.DECENTRALIZED + && !config.target.supportsDecentralizedCoordination()) { + reporter + .at(config.lookup(this), Literals.KEY_VALUE_PAIR__VALUE) + .error( + "The " + + config.target.getDisplayName() + + " target does not support decentralized coordination."); + } + } + @Override public Element toAstElement(CoordinationMode value) { return ASTUtils.toElement(value.toString()); diff --git a/core/src/main/resources/lib/ts/pnpm-workspace.yaml b/core/src/main/resources/lib/ts/pnpm-workspace.yaml index 65ea82f557..89c4c82a02 100644 --- a/core/src/main/resources/lib/ts/pnpm-workspace.yaml +++ b/core/src/main/resources/lib/ts/pnpm-workspace.yaml @@ -1,3 +1 @@ -allowBuilds: - '@lf-lang/reactor-ts': true - 'microtime': true +dangerouslyAllowAllBuilds: true diff --git a/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java b/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java index 8f8677ba02..147dd2c9ac 100644 --- a/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java +++ b/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java @@ -40,6 +40,7 @@ import org.lflang.target.property.type.TargetPropertyType; import org.lflang.target.property.type.UnionType; import org.lflang.tests.LFInjectorProvider; +import org.lflang.tests.TestBase; import org.lflang.util.StringUtil; /** @@ -1091,6 +1092,21 @@ public void testFederationSupport() throws Exception { } } + @Test + public void testDecentralizedCoordinationNotSupportedForTypeScript() throws Exception { + validator.assertError( + parseWithoutError( + """ + target TypeScript { + coordination: decentralized + } + main reactor {} + """), + LfPackage.eINSTANCE.getKeyValuePair(), + null, + TestBase.Message.NO_DECENTRALIZED_COORDINATION_SUPPORT); + } + /** Tests for state and parameter declarations, including native lists. */ @Test public void stateAndParameterDeclarationsInC() throws Exception { diff --git a/core/src/testFixtures/java/org/lflang/tests/TestBase.java b/core/src/testFixtures/java/org/lflang/tests/TestBase.java index 9d51cfd3ff..992ae611ab 100644 --- a/core/src/testFixtures/java/org/lflang/tests/TestBase.java +++ b/core/src/testFixtures/java/org/lflang/tests/TestBase.java @@ -125,6 +125,8 @@ public static class Message { "Target does not support single-threaded execution."; public static final String NO_FEDERATION_SUPPORT = "Target does not support federated execution."; + public static final String NO_DECENTRALIZED_COORDINATION_SUPPORT = + "The TypeScript target does not support decentralized coordination."; public static final String NO_ENCLAVE_SUPPORT = "Targeet does not support the enclave feature."; public static final String NO_DOCKER_SUPPORT = "Target does not support the 'docker' property."; public static final String NO_DOCKER_TEST_SUPPORT = "Docker tests are only supported on Linux.";