Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup for Kotlin-based TypeScript generator (Comments from code review 21-07-29) #444

Merged
merged 9 commits into from
Aug 2, 2021
4 changes: 4 additions & 0 deletions org.lflang/src/org/lflang/generator/LFGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ private GeneratorBase createGenerator(Target target, FileConfig fileConfig,
case Python: {
return new PythonGenerator(fileConfig, errorReporter);
}
// FIXME: make case exhaustive
Copy link
Member

Choose a reason for hiding this comment

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

Making the switch exhaustive without default actually didn't work due to Missing return statement error.

Please see here for more information: https://stackoverflow.com/questions/39225553/complete-switch-on-enum-in-java-produces-missing-return-statement-error

default: {
// FIXME: rename createKotlinBaseGenerator
return createKotlinGenerator(target, fileConfig, errorReporter);
}
}
Expand All @@ -158,6 +160,7 @@ private GeneratorBase createKotlinGenerator(Target target, FileConfig fileConfig
// class up at runtime and instantiate it if found.
String packageName = getPackageName(target);
String classNamePrefix = getClassNamePrefix(target);
// FIXME: make the above attributes of the target
try {
return (GeneratorBase) Class
.forName("org.lflang.generator." + packageName + "." + classNamePrefix + "Generator")
Expand All @@ -179,6 +182,7 @@ private GeneratorBase createKotlinGenerator(Target target, FileConfig fileConfig
+ "broken, preventing us from loading the generator"
+ "properly. Please consider building the RCA via Maven.");
// FIXME: Add a link to the wiki with more information.
// FIXME: really do above
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion org.lflang/src/org/lflang/generator/cpp/CppExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ val TriggerRef.name: String
/** Return a comment to be inserted at the top of generated files. */
fun fileComment(r: Resource) = """
/*
* This file was autogenerated by the Lingua Franca Compiler
* This file was autogenerated by the Lingua Franca Compiler.
*
* Source: ${r.uri}
* Date: ${LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))}
Expand Down