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

JavaIntegration: Allow expanding generic types #148

Open
16 tasks
kindlich opened this issue Jun 2, 2024 · 0 comments
Open
16 tasks

JavaIntegration: Allow expanding generic types #148

kindlich opened this issue Jun 2, 2024 · 0 comments
Assignees
Labels
CraftTweaker All Issues that are needed by CraftTweaker JavaIntegration All issues that relate to integrating ZenCode with existing Java Code
Milestone

Comments

@kindlich
Copy link
Member

kindlich commented Jun 2, 2024

We want to create Expansions that have Generic Type Parameters from JavaIntegration code.
Basically, we want to be able use Java Annotations to register the equivalent of this:

public expand <T> KnownTag<T> {

    public get T? first => this.empty ? null : this.elements[0];
}

For that we need multiple things working:

  • Define Type parameters for @ZenCodeType.Expansion classes.
    • Define Type bounds for these type parameters
    • Define Name of these parameters
  • Be able to use these parameters inside the @ZenCodeType.Expansion#value method

Jared already started with some work:
https://github.com/ZenCodeLang/ZenCode/tree/feature/expansion-generics

Acceptance Criteria:

  • Test cases (valid code):
    • Simple case with unbounded/default bounded <T>
    • Case with type bound <T: CommandStringDisplayable>
    • Case with super bound <T super SomeType>
    • Case with multiple generic Parameters <T, U>
    • Case where the number of Generic bounds and type bounds don't match <T> expand Function<T, T>
    • Case where the type bounds reference each other <T, U expands T> expand Function<T, U>
    • Case where the expansion is generic and the added method itself also
      public <T> expand SomeType<T> { public <U> doSomethingWith(U: value): void; }
  • Test Cases (invalid code):
    • Specify Type Parameters that are not used in the expansion <T> expand string
    • Specify Type parameters whose bounds are not proper <T: string> expand Recipe<T>
    • Specify two type parameters with the same name <T, T> expand Function<T, T>
@kindlich kindlich added the CraftTweaker All Issues that are needed by CraftTweaker label Jun 2, 2024
@kindlich kindlich changed the title Fix generic type expansions JavaIntegration: Allow expanding generic types Jun 2, 2024
@kindlich kindlich added the JavaIntegration All issues that relate to integrating ZenCode with existing Java Code label Jun 2, 2024
@kindlich kindlich added this to the v1.0.0 milestone Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CraftTweaker All Issues that are needed by CraftTweaker JavaIntegration All issues that relate to integrating ZenCode with existing Java Code
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants