Incendo / Incendo/cloud

Add annotation processor (java + ksp) that can execute at compile-time

Open
#685 6 comments 0 reactions 1 assignee View on GitHub

@solonovamax is already working on this.

Since Feb 5, 2024.

enhancement
Dominant language
Java
Stars
548
Forks
60
PR merge metrics
No merged PRs in 30d

Description

Add an implementation of the annotation processors that can be run at compile time to parse the commands into a file format that can then be loaded at runtime. the format could, perhaps, be json.

Annotation processors implementing javax.annotation.processing.Processor and com.google.devtools.ksp.processing.SymbolProcessor would be quite beneficial, as it would anyone using the cloud annotations api to avoid having to scan the classpath to register their commands using something like reflections, and is much more convenient than having to manually list all the classes with commands.

I'm going to look into doing this myself, but for some reason gh mobile doesn't let me assign myself while creating the issue.

ways it could be done:

  • simply serialize a json array of class names to run reflection on at runtime
  • run the reflection & annotation processing (eg. interpreting the value of the @Command(String) annotation, parsing the default value (if possible), etc.) at compile time instead of runtime then serialize this as a json datastructure. the format could be smth like this (not comprehensive):
    commands:
      - class: [class name]
        root: [root command name]
        permission: [permission]
        meta: [meta stuff]
        - commands: [list of nested commands]
          method: [method name]
          name: [command name]
          permission: permission
          meta: [meta stuff]
          arguments:
            - name: [argument name]
              aliases: [aliases]
              parameterName: [name of parameter]
              parameterIndex: [index of parameter] # the index can be used when the class is compiled without parameter names
              default:
                value: [default value] # if specified
                method: [name of method] # if specified
              type: [fully qualified type]
          commands: [nested subcommands]
    

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.