-
-
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.
Retrieve package name and class name prefix for the code generator in…
… Kotlin from the target enum.
- Loading branch information
Showing
1 changed file
with
5 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,23 +139,12 @@ private GeneratorBase createKotlinGenerator(Target target, FileConfig fileConfig | |
// play a few tricks here so that Kotlin FileConfig and | ||
// Kotlin Generator do not appear as an import. Instead we look the | ||
// class up at runtime and instantiate it if found. | ||
String packageName; | ||
String classNamePrefix; | ||
switch (target) { | ||
case CPP: { | ||
packageName = "cpp"; | ||
classNamePrefix = "Cpp"; | ||
break; | ||
} | ||
case TS: { | ||
packageName = "ts"; | ||
classNamePrefix = "Ts"; | ||
break; | ||
} | ||
default: { | ||
throw new RuntimeException("Unexpected target!"); | ||
} | ||
if (target.name().length() < 2) { | ||
throw new RuntimeException("Unexpected target!"); | ||
} | ||
String packageName = target.name().toLowerCase(); | ||
String classNamePrefix = target.name().charAt(0) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hokeun
Author
Member
|
||
+ target.name().substring(1).toLowerCase(); | ||
try { | ||
return (GeneratorBase) Class | ||
.forName("org.lflang.generator." + packageName + "." + classNamePrefix + "Generator") | ||
|
I don't think this works for Cpp, right? Perhaps add a function called
getPackagePrefix
toTarget
?