-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tolerate but ignore
UseImportPolicy
to cover additional recipes (#53)
* Document what's generated for recipes with new static imports * Expect `maybeAddImport("java.nio.file.Files", "exists")` And remove `new UsesMethod<>("java.io.File exists(..)")` * Add UseImportPolicy as present on similar cases * UsesMethod should be present; Update description * Do not skip `UseImportPolicy` * Remove Javadocs from reference * Maybe add static imports as needed * Use both processors for both tests * Further reduce diff * Remove for loops with contains checks * Drop field also super class * More symmetry in methods * Only remove/add if there are any static imports * Skip if statements for now as seen in AssortedRules * Use `String[]` instead of `Array` as lambda type * Count messages and early return on invalid * Do not add static imports; merely ignore UseImportPolicy
- Loading branch information
Showing
5 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/test/java/com/google/errorprone/refaster/ImportPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.errorprone.refaster; | ||
|
||
public enum ImportPolicy { | ||
IMPORT_TOP_LEVEL, | ||
IMPORT_CLASS_DIRECTLY, | ||
STATIC_IMPORT_ALWAYS | ||
} |
28 changes: 28 additions & 0 deletions
28
src/test/java/com/google/errorprone/refaster/annotation/UseImportPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.errorprone.refaster.annotation; | ||
|
||
import com.google.errorprone.refaster.ImportPolicy; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({ElementType.METHOD}) | ||
@Retention(RetentionPolicy.SOURCE) | ||
public @interface UseImportPolicy { | ||
ImportPolicy value(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters