-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1674 from lf-lang/fix-eclipse-build
TSDockerGenerator and TSTypes ported to Java for Eclipse developers
- Loading branch information
Showing
14 changed files
with
123 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
org.lflang/src/org/lflang/generator/ts/TSDockerGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.lflang.generator.ts; | ||
|
||
import org.lflang.generator.DockerGenerator; | ||
import org.lflang.generator.LFGeneratorContext; | ||
|
||
/** | ||
* Generates the docker file related code for the Typescript target. | ||
* | ||
* @author Hou Seng Wong | ||
*/ | ||
public class TSDockerGenerator extends DockerGenerator { | ||
|
||
/** Construct a new Docker generator. */ | ||
public TSDockerGenerator(LFGeneratorContext context) { | ||
super(context); | ||
} | ||
|
||
/** | ||
* Return the content of the docker file for [tsFileName]. | ||
*/ | ||
public String generateDockerFileContent() { | ||
return """ | ||
|FROM node:alpine | ||
|WORKDIR /linguafranca/$name | ||
|COPY . . | ||
|ENTRYPOINT ["node", "dist/%s.js"] | ||
""".formatted(context.getFileConfig().name); | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
org.lflang/src/org/lflang/generator/ts/TSDockerGenerator.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.lflang.generator.ts; | ||
|
||
import java.util.List; | ||
|
||
import org.lflang.ASTUtils; | ||
import org.lflang.TimeValue; | ||
import org.lflang.generator.TargetTypes; | ||
import org.lflang.generator.UnsupportedGeneratorFeatureException; | ||
import org.lflang.lf.StateVar; | ||
|
||
public class TSTypes implements TargetTypes { | ||
|
||
private static TSTypes INSTANCE = new TSTypes(); | ||
|
||
private TSTypes() { | ||
|
||
} | ||
|
||
@Override | ||
public String getTargetType(StateVar s) { | ||
var type = TargetTypes.super.getTargetType(s); | ||
if (!ASTUtils.isInitialized(s)) { | ||
return "%s | undefined".formatted(type); | ||
} else { | ||
return type; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean supportsGenerics() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getTargetTimeType() { | ||
return "TimeValue"; | ||
} | ||
|
||
@Override | ||
public String getTargetTagType() { | ||
return "TimeValue"; | ||
} | ||
|
||
@Override | ||
public String getTargetUndefinedType() { | ||
return "Present"; | ||
} | ||
|
||
public String getTargetTimeExpr(TimeValue value) { | ||
if (value.unit != null) { | ||
return "TimeValue.%s(%s)".formatted(value.unit.getCanonicalName(), value.time); | ||
} else { | ||
// The value must be zero. | ||
return "TimeValue.zero()"; | ||
} | ||
} | ||
|
||
@Override | ||
public String getTargetFixedSizeListType(String baseType, int size) { | ||
throw new UnsupportedGeneratorFeatureException("TypeScript does not support fixed-size array types."); | ||
} | ||
|
||
@Override | ||
public String getTargetVariableSizeListType(String baseType) { | ||
return "Array<%s>".formatted(baseType); // same as "$baseType[]" | ||
} | ||
|
||
public String getVariableSizeListInitExpression(List<String> contents, boolean withBraces) { | ||
return "[" + String.join(", ", contents) + "]"; | ||
} | ||
|
||
public static TSTypes getInstance() { | ||
return INSTANCE; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.