Class ResolverLookup

java.lang.Object
io.github.projectunified.craftcommand.processor.ResolverLookup

public final class ResolverLookup extends Object
Compile-time lookups for local resolvers, suggest methods, fields, and command-model class resolution.

Holds a ProcessingEnvironment for type comparison. Constructed once per processor Processor.init(javax.annotation.processing.ProcessingEnvironment) call.

  • Constructor Details

  • Method Details

    • findMethod

      public static ExecutableElement findMethod(TypeElement typeElement, String name)
      Find a no-arg/instance method by name on the given type element. Searches the current class and all parent classes.
    • findLocalResolver

      public ExecutableElement findLocalResolver(CommandModel classModel, ParameterModel p)
      Find a local @Resolve method for the given parameter.

      If the parameter carries an explicit @Resolve("name"), the method is matched by name. Implicit resolution by return type is no longer supported — use explicit @Resolve("name") instead.

      Parameters:
      classModel - the command class where resolution starts
      p - the parameter to resolve
      Returns:
      the matching resolver method, or null if none
    • findModelForClass

      public CommandModel findModelForClass(CommandModel current, TypeElement targetClass)
      Walk the command tree to find the CommandModel whose element equals targetClass.
    • findSuggestMethod

      public ExecutableElement findSuggestMethod(TypeElement typeElement, String name)
      Find a suggest method by name and validate its signature.

      Valid signatures (where S is a sender type):

      • Collection<String> m()
      • Collection<String> m(String[] current)
      • Collection<String> m(String[] current, String[] context)
      • Collection<String> m(S sender, String[] current)
      • Collection<String> m(S sender, String[] current, String[] context)
      Parameters:
      typeElement - the type element to search
      name - the method name
      Returns:
      the matching method, or null if not found or invalid signature
    • isField

      public boolean isField(TypeElement typeElement, String name)
      Returns:
      true if the type element declares a field with the given name.