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

Various fixes for generating @SuppressWarnings #271

Merged
merged 4 commits into from Dec 13, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -209,6 +209,46 @@ public void suggestSuppressionFieldLambdaAssignment() {
bcr.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
public void suggestLambdaAssignInMethod() {
BugCheckerRefactoringTestHelper bcr =
BugCheckerRefactoringTestHelper.newInstance(
new NullAway(flagsNoAutoFixSuppressionComment), getClass());

bcr.setArgs("-d", temporaryFolder.getRoot().getAbsolutePath());
bcr.addInputLines(
"Test.java",
"package com.uber;",
"import javax.annotation.Nullable;",
"class Test {",
" @Nullable private Integer foo;",
" @Nullable private java.util.function.Function<Object, Integer> f;",
" void m1() {",
" f = (x) -> { return foo + 1; };",
" }",
" void m2() {",
" java.util.function.Function<Object,Integer> g = (x) -> { return foo + 1; };",
" }",
"}")
.addOutputLines(
"out/Test.java",
"package com.uber;",
"import javax.annotation.Nullable;",
"class Test {",
" @Nullable private Integer foo;",
" @Nullable private java.util.function.Function<Object, Integer> f;",
" @SuppressWarnings(\"NullAway\")",
" void m1() {",
" f = (x) -> { return foo + 1; };",
" }",
" void m2() {",
" @SuppressWarnings(\"NullAway\")",
" java.util.function.Function<Object,Integer> g = (x) -> { return foo + 1; };",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

" }",
"}");
bcr.doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH);
}

@Test
public void suppressMethodRefOverrideParam() {
BugCheckerRefactoringTestHelper bcr =
Expand Down