Skip to content

Commit

Permalink
AbstractCommandSpecProcessor#isSubcommand(ExecutableElement, RoundEnv…
Browse files Browse the repository at this point in the history
…ironment):

Simplified
Improved performance
  • Loading branch information
rgoldberg authored and remkop committed Nov 30, 2021
1 parent ce6b3a0 commit c12e041
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,8 @@ private void updateCommandFromMethodElement(ExecutableElement method, Context co

private boolean isSubcommand(ExecutableElement method, RoundEnvironment roundEnv) {
Element typeElement = method.getEnclosingElement();
if (typeElement.getAnnotation(Command.class) != null && typeElement.getAnnotation(Command.class).addMethodSubcommands()) {
return true;
}
if (typeElement.getAnnotation(Command.class) == null) {
Command cmd = typeElement.getAnnotation(Command.class);
if (cmd == null) {
Set<Element> elements = new HashSet<Element>(typeElement.getEnclosedElements());

// The class is a Command if it has any fields or methods annotated with the below:
Expand All @@ -314,7 +312,7 @@ private boolean isSubcommand(ExecutableElement method, RoundEnvironment roundEnv
|| roundEnv.getElementsAnnotatedWith(Unmatched.class).removeAll(elements)
|| roundEnv.getElementsAnnotatedWith(Spec.class).removeAll(elements);
}
return false;
return cmd.addMethodSubcommands();
}

private Stack<TypeElement> buildTypeHierarchy(TypeElement typeElement) {
Expand Down

0 comments on commit c12e041

Please sign in to comment.