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

extract private method #10473

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -347,25 +347,9 @@ private DispatchedExecutableMethod(AbstractExecutableMethodsDefinition dispatche
this.index = index;
this.methodReference = methodReference;
this.annotationMetadata = annotationMetadata;
this.arguments = new Argument[methodReference.arguments.length];
boolean foundExpressions = false;
Argument<?>[] methodArguments = methodReference.arguments;
for (int i = 0; i < methodArguments.length; i++) {
Argument<?> argument = methodArguments[i];
AnnotationMetadata argumentAnnotationMetadata = argument.getAnnotationMetadata();
AnnotationMetadata wrappedArgumentAnnotationMetadata = EvaluatedAnnotationMetadata.wrapIfNecessary(argumentAnnotationMetadata);
if (argumentAnnotationMetadata == wrappedArgumentAnnotationMetadata) {
arguments[i] = argument;
} else {
foundExpressions = true;
if (argument instanceof GenericPlaceholder<?> genericPlaceholder) {
arguments[i] = Argument.ofTypeVariable(argument.getType(), argument.getName(), genericPlaceholder.getVariableName(), wrappedArgumentAnnotationMetadata, argument.getTypeParameters());
} else {
arguments[i] = Argument.of(argument.getType(), argument.getName(), wrappedArgumentAnnotationMetadata, argument.getTypeParameters());
}
}
}
this.argumentsAnnotationsWithExpressions = foundExpressions;
MethodArguments methodArguments = methodArguments(methodReference);
this.arguments = methodArguments.arguments;
this.argumentsAnnotationsWithExpressions = methodArguments.argumentsAnnotationsWithExpressions;
}

@Override
Expand Down Expand Up @@ -505,6 +489,30 @@ public String toString() {
return getReturnType().getType().getSimpleName() + " " + getMethodName() + "(" + text + ")";
}

private record MethodArguments(Argument<?>[] arguments, boolean argumentsAnnotationsWithExpressions) {
}

private MethodArguments methodArguments(MethodReference methodReference) {
final Argument<?>[] arguments= new Argument[methodReference.arguments.length];
boolean foundExpressions = false;
Argument<?>[] methodArguments = methodReference.arguments;
for (int i = 0; i < methodArguments.length; i++) {
Argument<?> argument = methodArguments[i];
AnnotationMetadata argumentAnnotationMetadata = argument.getAnnotationMetadata();
AnnotationMetadata wrappedArgumentAnnotationMetadata = EvaluatedAnnotationMetadata.wrapIfNecessary(argumentAnnotationMetadata);
if (argumentAnnotationMetadata == wrappedArgumentAnnotationMetadata) {
arguments[i] = argument;
} else {
foundExpressions = true;
if (argument instanceof GenericPlaceholder<?> genericPlaceholder) {
arguments[i] = Argument.ofTypeVariable(argument.getType(), argument.getName(), genericPlaceholder.getVariableName(), wrappedArgumentAnnotationMetadata, argument.getTypeParameters());
} else {
arguments[i] = Argument.of(argument.getType(), argument.getName(), wrappedArgumentAnnotationMetadata, argument.getTypeParameters());
}
}
}
return new MethodArguments(arguments, foundExpressions);
}
}

/**
Expand Down