Skip to content

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

@solonovamax

Description

@solonovamax

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]

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions