This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Sanitize function name when building methods #690
Comments
Can you use NameAllocator for this? It will take care of avoiding language
keywords.
…On Wed, Nov 7, 2018, 8:44 AM Ivaylo Kirilov ***@***.*** wrote:
When writing code generators to wrap constructs from another language to
java we sometimes hit issues that some constructs are given names which are
reserved in the java language.
I propose that MethodSpec.methodBuilder() can be overloaded like this:
MethodSpec.Builder methodBuilder =
MethodSpec.methodBuilder(functionName, sanitizingChar, append)
.addModifiers(Modifier.PUBLIC);
which will append (or prepend if set to false) the sanitizingChar to the
method name if SourceVersion.isName(functionName) returns false.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#690>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEEEYiZ7Qx_-Mix5DApMI5urrijdC_Iks5usvG6gaJpZM4YSkC0>
.
|
Thank you for the suggestion. I would like to make it more configurable like being able to define your own "sanitizing character" and whether it should be prepended or appended. Makes sense? |
I don't think we'll want to support that due to the number of locations we
accept a name.
…On Sat, Nov 10, 2018, 7:48 AM Ivaylo Kirilov ***@***.*** wrote:
Thank you for the suggestion. I would like to make it more configurable
like being able to define your own "sanitizing character" and whether it
should be prepended or appended. Makes sense?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#690 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEEESDG2xaLHPKIvDUqwy6L71IZjOQDks5utssGgaJpZM4YSkC0>
.
|
OK - I decided to just use
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When writing code generators to wrap constructs from another language to java we sometimes hit issues that some constructs are given names which are reserved in the java language.
I propose that
MethodSpec.methodBuilder()
can be overloaded like this:which will append (or prepend if set to
false
) thesanitizingChar
to the method name ifSourceVersion.isName(functionName)
returns false.See: hyperledger-web3j/web3j#658
The text was updated successfully, but these errors were encountered: