Skip to content

Commit

Permalink
PUBLIC: Include API name in DoNotCallChecker error message.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 561354031
  • Loading branch information
kluever authored and Error Prone Team committed Aug 31, 2023
1 parent e0d4682 commit 445fac9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ private void checkTree(ExpressionTree tree, MethodSymbol sym, VisitorState state

private void handleDoNotCall(ExpressionTree tree, Symbol symbol, VisitorState state) {
String doNotCall = getDoNotCallValue(symbol);
StringBuilder message = new StringBuilder("This method should not be called");
StringBuilder message =
new StringBuilder(symbol.owner.toString())
.append('.')
.append(symbol.toString())
.append(" should not be called");
if (doNotCall.isEmpty()) {
message.append(", see its documentation for details.");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ public void positive() {
" @DoNotCall final void g() {}",
" void m() {",
" // BUG: Diagnostic contains:",
" // This method should not be called: satisfying explanation",
" // Test.f() should not be called: satisfying explanation",
" f();",
" // BUG: Diagnostic contains:",
" // This method should not be called, see its documentation for details",
" // Test.g() should not be called, see its documentation for details.",
" g();",
" // BUG: Diagnostic contains:",
" // Test.g() should not be called, see its documentation for details.",
" Runnable r = this::g;",
" }",
"}")
Expand Down Expand Up @@ -264,7 +265,9 @@ public void noDNConClasspath() {
"Test.java",
"class Test {",
" void m() {",
" // BUG: Diagnostic contains: This method should not be called",
" // BUG: Diagnostic contains:"
+ " com.google.errorprone.bugpatterns.DoNotCallCheckerTest.DNCTest.f() should not"
+ " be called, see its documentation for details.",
" com.google.errorprone.bugpatterns.DoNotCallCheckerTest.DNCTest.f();",
" }",
"}")
Expand Down

0 comments on commit 445fac9

Please sign in to comment.