Skip to content

Commit

Permalink
Revert recent TSFileConfig changes and instead do not override
Browse files Browse the repository at this point in the history
  • Loading branch information
petervdonovan committed Jun 21, 2024
1 parent 6828b22 commit cf6c1f3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 38 deletions.
4 changes: 1 addition & 3 deletions core/src/main/java/org/lflang/generator/LFGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ public static FileConfig createFileConfig(
case Python -> new PyFileConfig(resource, srcGenBasePath, useHierarchicalBin);
case CPP -> new CppFileConfig(resource, srcGenBasePath, useHierarchicalBin);
case Rust -> new RustFileConfig(resource, srcGenBasePath, useHierarchicalBin);
// null is passed to the docker argument because it is up to the TS Generator to tell the
// FileConfig whether Docker is enabled
case TS -> new TSFileConfig(resource, srcGenBasePath, useHierarchicalBin, null);
case TS -> new TSFileConfig(resource, srcGenBasePath, useHierarchicalBin);
};
} catch (IOException e) {
throw new RuntimeException(
Expand Down
35 changes: 1 addition & 34 deletions core/src/main/kotlin/org/lflang/generator/ts/TSFileConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import java.nio.file.Path
* @author Hokeun Kim
*/
class TSFileConfig(
resource: Resource, srcGenBasePath: Path, useHierarchicalBin: Boolean, var docker: Boolean? = null
resource: Resource, srcGenBasePath: Path, useHierarchicalBin: Boolean
) : FileConfig(resource, srcGenBasePath, useHierarchicalBin) {

/**
Expand All @@ -53,37 +53,4 @@ class TSFileConfig(
super.doClean()
FileUtil.deleteDirectory(srcGenPath)
}

fun setDocker(dockerEnabled: Boolean) {
docker = dockerEnabled
}

override fun getCommand(): LFCommand {
if (docker == true) {
return super.getCommand()
} else if (docker == false) {
return LFCommand.get(
"node",
listOf(srcPkgPath.relativize(executable).toString()),
true,
srcPkgPath
)
} else {
throw java.lang.IllegalStateException("The execute command cannot be determined because it is not known whether code generation is in Docker mode.")
}
}

override fun getExecutableExtension(): String {
if (docker == true) {
return super.getExecutableExtension()
}
return ".js"
}

override fun getExecutable(): Path {
if (docker == true) {
return super.getExecutable()
}
return srcGenPath.resolve("dist").resolve(name + executableExtension)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class TSGenerator(
override fun doGenerate(resource: Resource, context: LFGeneratorContext) {
// Register the after delay transformation to be applied by GeneratorBase.
registerTransformation(DelayedConnectionTransformation(TSDelayBodyGenerator, targetTypes, resource, true, true))
fileConfig.setDocker(targetConfig.get(DockerProperty.INSTANCE).enabled)

super.doGenerate(resource, context)

instantiationGraph
Expand Down

1 comment on commit cf6c1f3

@lhstrh
Copy link
Member

@lhstrh lhstrh commented on cf6c1f3 Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this looks much better to me.

Please sign in to comment.