Skip to content

Commit

Permalink
Set methods with null return type to have "void" return type
Browse files Browse the repository at this point in the history
Addresses NPE in JavaSearchTests.testEnum04

Signed-off-by: David Thompson <[email protected]>
  • Loading branch information
datho7561 authored and mickaelistria committed Feb 8, 2024
1 parent 93f71b4 commit 165c429
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,12 @@ public boolean visit(MethodDeclaration method) {
info.arguments = ((List<SingleVariableDeclaration>)method.parameters()).stream()
.map(this::toLocalVariable)
.toArray(LocalVariable[]::new);
if (method.getAST().apiLevel() > 2 && method.getReturnType2() != null) {
info.setReturnType(method.getReturnType2().toString().toCharArray());
if (method.getAST().apiLevel() > 2) {
if (method.getReturnType2() != null) {
info.setReturnType(method.getReturnType2().toString().toCharArray());
} else {
info.setReturnType("void".toCharArray()); //$NON-NLS-1$
}
}
info.setSourceRangeStart(method.getStartPosition());
info.setSourceRangeEnd(method.getStartPosition() + method.getLength() - 1);
Expand Down

0 comments on commit 165c429

Please sign in to comment.