Skip to content

Commit 737dec0

Browse files
cushonError Prone Team
authored andcommitted
Remove DiffNotApplicableException
Let any IndexOutOfBoundsExceptions propagate, and handle RuntimeException in DiffApplier. See discussion in #4086. PiperOrigin-RevId: 567323714
1 parent f3a2bf8 commit 737dec0

4 files changed

Lines changed: 3 additions & 39 deletions

File tree

check_api/src/main/java/com/google/errorprone/apply/DescriptionBasedDiff.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void handleFix(Fix fix) {
109109
}
110110

111111
@Override
112-
public void applyDifferences(SourceFile sourceFile) throws DiffNotApplicableException {
112+
public void applyDifferences(SourceFile sourceFile) {
113113
if (!importsToAdd.isEmpty() || !importsToRemove.isEmpty()) {
114114
ImportStatements importStatements = ImportStatements.create(compilationUnit, importOrganizer);
115115
importStatements.addAll(importsToAdd);

check_api/src/main/java/com/google/errorprone/apply/Diff.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ public interface Diff {
2525
/** Gets the name of the file this difference applies to */
2626
String getRelevantFileName();
2727

28-
/**
29-
* Applies this difference to the supplied {@code sourceFile}.
30-
*
31-
* @throws DiffNotApplicableException if the diff could not be applied to the source file
32-
*/
28+
/** Applies this difference to the supplied {@code sourceFile}. */
3329
void applyDifferences(SourceFile sourceFile);
3430
}

check_api/src/main/java/com/google/errorprone/apply/DiffApplier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void run() {
123123
if (completed % 100 == 0) {
124124
logger.log(Level.INFO, String.format("Completed %d files in %s", completed, stopwatch));
125125
}
126-
} catch (IOException | DiffNotApplicableException e) {
126+
} catch (IOException | RuntimeException e) {
127127
logger.log(Level.WARNING, "Failed to apply diff to file " + diff.getRelevantFileName(), e);
128128
diffsFailedPaths.add(diff.getRelevantFileName());
129129
} finally {

check_api/src/main/java/com/google/errorprone/apply/DiffNotApplicableException.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)