Skip to content

Commit

Permalink
Remove DiffNotApplicableException
Browse files Browse the repository at this point in the history
Let any IndexOutOfBoundsExceptions propagate, and handle RuntimeException in
DiffApplier.

See discussion in #4086.

PiperOrigin-RevId: 566971731
  • Loading branch information
cushon authored and Error Prone Team committed Sep 21, 2023
1 parent 1d2bc93 commit 73d6b1c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void handleFix(Fix fix) {
}

@Override
public void applyDifferences(SourceFile sourceFile) throws DiffNotApplicableException {
public void applyDifferences(SourceFile sourceFile) {
if (!importsToAdd.isEmpty() || !importsToRemove.isEmpty()) {
ImportStatements importStatements = ImportStatements.create(compilationUnit, importOrganizer);
importStatements.addAll(importsToAdd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ public interface Diff {
/** Gets the name of the file this difference applies to */
String getRelevantFileName();

/**
* Applies this difference to the supplied {@code sourceFile}.
*
* @throws DiffNotApplicableException if the diff could not be applied to the source file
*/
/** Applies this difference to the supplied {@code sourceFile}. */
void applyDifferences(SourceFile sourceFile);
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void run() {
if (completed % 100 == 0) {
logger.log(Level.INFO, String.format("Completed %d files in %s", completed, stopwatch));
}
} catch (IOException | DiffNotApplicableException e) {
} catch (IOException | RuntimeException e) {
logger.log(Level.WARNING, "Failed to apply diff to file " + diff.getRelevantFileName(), e);
diffsFailedPaths.add(diff.getRelevantFileName());
} finally {
Expand Down

This file was deleted.

0 comments on commit 73d6b1c

Please sign in to comment.