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

feat: enforce FTL name rules in JVM #2835

Merged
merged 1 commit into from
Sep 26, 2024
Merged

Conversation

stuartwdouglas
Copy link
Collaborator

fixes: #2366

@stuartwdouglas stuartwdouglas requested review from a team and deniseli and removed request for a team September 26, 2024 03:45
This was referenced Sep 26, 2024
@@ -74,6 +76,7 @@ public class ModuleBuilder {
public static final DotName OFFSET_DATE_TIME = DotName.createSimple(OffsetDateTime.class.getName());
public static final DotName GENERATED_REF = DotName.createSimple(GeneratedRef.class);
public static final DotName EXPORT = DotName.createSimple(Export.class);
private static final Pattern NAME_PATTERN = Pattern.compile("^[A-Za-z_][A-Za-z0-9_]*$");
Copy link
Collaborator

Choose a reason for hiding this comment

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

The naming convention isn't quite this simple, but this is a good improvement. ie. this will allow DNSServer, but the FTL name for that would be DnsServer. I think this is very uncommon in the JVM though?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I copied this from validator.go:

var validNameRe = regexp.MustCompile(`^[A-Za-z_][A-Za-z0-9_]*$`)

Is there stricter validation somewhere? I had a look but I did not seem to be able to find it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Aaah!

I think that's okay. We use strcase.ToUpperCamel() for types and strcase.ToLowerCamel() for values, but they would be difficult to reproduce. What will end up happening is that when they round-trip through code-genn from the schema they'll be canonicalised to the above.

@stuartwdouglas stuartwdouglas merged commit 13fa198 into main Sep 26, 2024
91 checks passed
@stuartwdouglas stuartwdouglas deleted the stuartwdouglas/2366 branch September 26, 2024 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enforce FTL naming conventions in Java
2 participants