← 输入框|github.com|刷新
Skip to content

Structs: Infer parameter members from functional method signature instead from solely annotations #2

Closed

Description

@Treiblesschorle

Currently, ParameterStructs utility class only check for @Parameter annotations in order to structify an object. Instead, members should be inferred from the signature of the functional method of the class of the passed object. This should have the following behavior:

  • If no @Parameter annotations are given, the type and the ItemIO should be inferred from the functional method signature. In doing so, the return type will always be ItemIO.Output and method parameters should be ItemIO.Input. If a method parameter is ItemIO.Both, it should be annotated with a @Mutable annotation. Methods to get the functional method types from a type and the @Mutable already exists.
  • Additionally, the @Parameter annotations may be given in order to specify the names and further metadata of the member (e.g. required status). Also, this enabled to do fail fast checks if the ItemIO or the number of parameters does not match the types inferred from the functional method.
  • A ItemIO.Auto was already added in order to indicate that the ItemIO should be automatically inferred from the functional method. ItemIO.Auto should be made the default.

Activity

  1. ctrueden commented on May 15, 2019

    @ctrueden
    Member

    @MarcelWiedenmann Can you please check whether this work was ever completed? And if not, try your hand at it? Thank you!

  2. Treiblesschorle commented on May 16, 2019

    @Treiblesschorle
    CollaboratorAuthor

    There is an open PR which is done. However, a lot seems to have changed in the meantime, hence I'm not sure if this can be easily merged.

  3. ctrueden commented on May 16, 2019

    @ctrueden
    Member

    Thanks @Treiblesschorle. For reference the PR is #11. And ouch, I had forgotten all about that, and now the histories are probably very incompatible. Sorting out the patches will take some time.

  4. Treiblesschorle commented on May 16, 2019

    @Treiblesschorle
    CollaboratorAuthor

    @MarcelWiedenmann we can have a look at it together if you want.

  5. wiedenm commented on May 21, 2019

    @wiedenm
    Member

    @ctrueden As previously discussed in person, rebasing #11 onto the most recent new-ops branch was straightforward. I still had a look at the PR, mainly because @Treiblesschorle was a bit concerned about the new dependency to io.leangen.geantyref that is added by the PR. We use GeAnTyRef to synthesize Parameter annotations. For what it's worth, I tried to copy over GeAnTyRef's relevant internal functionality and it's about 250 LoC we use. The entire project has ~4300 LoC. Don't know if that matters or if using that dependency is just fine.

    Other than that, the PR looks good to me. I rebased it onto migrate-imagej-ops on my machine to see if those tests still run through, and they do.

  6. ctrueden commented on May 21, 2019

    @ctrueden
    Member

    Would GeAnTyRef be able to replace all the generics-related features of org.scijava.util.Types? I.e.: could we get rid of the Apache Commons TypeUtils fork and the GenTyRef fork, and get rid of the Guava dependency, and make Nil use GeAnTyRef's TypeToken instead?

    Anyway, I'm fine merging as-is for the moment. But the proliferation of generics-related code, much of it overlapping, bugs me. I'd much rather have one clean upstream generics reasoning dependency, if it can meet all our needs.

  7. wiedenm commented on May 21, 2019

    @wiedenm
    Member

    That would be nice. I'll create a dedicated issue for that & do some exploration.

    + Merging for now sounds good 👍.

  8. ctrueden commented on Sep 22, 2019

    @ctrueden
    Member

    Resolved by 623d0cd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions