Skip to content

Commit

Permalink
Support mapping of generic thrown exception types
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Dec 25, 2024
1 parent 3b9bdd9 commit 28cc6a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex
})).afterRecipe(run -> {
J.CompilationUnit cu = (J.CompilationUnit) run.getChangeset().getAllResults().get(0).getAfter();
J.MethodDeclaration testMethodDecl = (J.MethodDeclaration) cu.getClasses().get(0).getBody().getStatements().get(0);
assertThat(testMethodDecl.getMethodType().getThrownExceptions().stream().map(JavaType.FullyQualified::getFullyQualifiedName))
assertThat(testMethodDecl.getMethodType().getThrownExceptions().stream()
.map(JavaType.FullyQualified.class::cast)
.map(JavaType.FullyQualified::getFullyQualifiedName))
.containsExactly("java.lang.Exception");
}),
java(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public JavaType visitMethod(JavaType.Method method, P p) {
(JavaType.FullyQualified) visit(method.getDeclaringType(), p),
visit(method.getReturnType(), p),
mapInPlace(method.getParameterTypes().toArray(EMPTY_JAVA_TYPE_ARRAY), pt -> visit(pt, p)),
mapInPlace(method.getThrownExceptions().toArray(EMPTY_FULLY_QUALIFIED_ARRAY), t -> (JavaType.FullyQualified) visit(t, p)),
mapInPlace(method.getThrownExceptions().toArray(EMPTY_JAVA_TYPE_ARRAY), t -> visit(t, p)),
mapInPlace(method.getAnnotations().toArray(EMPTY_FULLY_QUALIFIED_ARRAY), a -> (JavaType.FullyQualified) visit(a, p))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ public Method unsafeSet(@Nullable FullyQualified declaringType,
public Method unsafeSet(@Nullable FullyQualified declaringType,
@Nullable JavaType returnType,
JavaType @Nullable [] parameterTypes,
FullyQualified @Nullable [] thrownExceptions,
JavaType @Nullable [] thrownExceptions,
FullyQualified @Nullable [] annotations) {
this.declaringType = unknownIfNull(declaringType);
this.returnType = unknownIfNull(returnType);
Expand Down

0 comments on commit 28cc6a5

Please sign in to comment.