Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Mar 12, 2023
1 parent 120e418 commit 2c73ea8
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,34 @@ void findMethodExitedOnReturn() {
" toString();",
" }",
"",
" String m() {",
" // BUG: Diagnostic contains:",
" String topLevelMethod() {",
" // BUG: Diagnostic contains: topLevelMethod",
" toString();",
" // BUG: Diagnostic contains:",
" // BUG: Diagnostic contains: topLevelMethod",
" return toString();",
" }",
"",
" Stream<String> m2() {",
" // BUG: Diagnostic contains:",
" Stream<String> anotherMethod() {",
" // BUG: Diagnostic contains: anotherMethod",
" return Stream.of(1)",
" .map(",
" n -> {",
" toString();",
" return toString();",
" });",
" }",
"",
" void recursiveMethod(Runnable r) {",
" // BUG: Diagnostic contains: recursiveMethod",
" recursiveMethod(",
" new Runnable() {",
" @Override",
" public void run() {",
" // BUG: Diagnostic contains: run",
" toString();",
" }",
" });",
" }",
"}")
.doTest();
}
Expand Down Expand Up @@ -187,7 +199,7 @@ public Description matchReturn(ReturnTree tree, VisitorState state) {

private Description flagMethodReturnLocation(Tree tree, VisitorState state) {
return MoreASTHelpers.findMethodExitedOnReturn(state)
.map(m -> buildDescription(tree).setMessage(state.getSourceForNode(m)).build())
.map(m -> buildDescription(tree).setMessage(m.getName().toString()).build())
.orElse(Description.NO_MATCH);
}
}
Expand Down

0 comments on commit 2c73ea8

Please sign in to comment.