Skip to content

Incorrect renaming when the method/field already has a numeric suffix #571

Closed

Description

@HosseinYousefi

For example, if we have three methods: overloaded, overloaded and overloaded1. The second overloaded gets converted to overloaded1 but overloaded1 stays the same.

Activity

  1. moved this from Backlog to Todo in JNIgen trackeron May 22, 2024
  2. moved this from Todo to In Progress in JNIgen trackeron Jul 9, 2024
  3. HosseinYousefi commented on Sep 5, 2024

    @HosseinYousefi
    ContributorAuthor

    Multiple ways to solve this:

    • First come first serve: foo, foo, foo1 -> foo, foo1, foo2
      • Pro: Simplest.
      • Con: User would expect foo1 to be foo1 but it's not.
    • First all the unique names, then all the non-unique ones: foo, foo, foo1 -> foo, foo2, foo1
      • Pro: Less confusing foo1 remains foo1.
      • Con: Users would expect all these to be overloadings of foo, but the only overloading is foo2.
    • Use a separator: foo, foo ,foo1 -> foo, foo$1, foo1.
      • Pro: Most clear. Anything with $ is overloaded.
      • Con: Adds a symbol to all overloaded methods. Overloaded methods are used a lot, but methods that end with a number are rare.

    @liamappelbe @dcharkes wdyt? What happens in ffigen? Maybe we should use the same technique.

  4. dcharkes commented on Sep 5, 2024

    @dcharkes
    Collaborator

    The second option would require multiple traversals with visitors and saving such information somewhere. Could be done, but complicates things for users.

    A separator is not a bad idea, it also signals the rename to the user.

  5. HosseinYousefi commented on Sep 5, 2024

    @HosseinYousefi
    ContributorAuthor

    A separator is not a bad idea, it also signals the rename to the user.

    Another way: methods with numeric suffices get an extra $ suffix.

    foo, foo, foo1, foo1 -> foo, foo1, foo1$, foo1$1

    As methods ending with a number are rare in Java (as Java has operator overloading), it's both correct and not ugly in the happy path.

  6. liamappelbe commented on Sep 5, 2024

    @liamappelbe
    Contributor

    In this case, ffigen's UniqueNamer would do foo, foo, foo1, foo1 -> foo, foo1, foo11, foo12 😆. It doesn't try to parse the numbers at the end of the name, it just adds an incrementing number to the end of whatever you give it, until it finds something not in its set.

  7. HosseinYousefi commented on Sep 6, 2024

    @HosseinYousefi
    ContributorAuthor

    I think I like the last way the best. @liamappelbe Feel free to do the same for ffigen to be consistent.

    Although eventually I want to give the users the ability to change this through transformations.

  8. moved this from In Progress to Done in JNIgen trackeron Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

package:jnipackage:jnigentype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions