Skip to content

Commit

Permalink
Solved the murder we committed
Browse files Browse the repository at this point in the history
  • Loading branch information
SofiaBrittoSchwartz committed Oct 10, 2020
1 parent 92592e8 commit 05775b9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions rewrite-core/src/main/java/org/openrewrite/Refactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ public Collection<Change> fix(Iterable<? extends SourceFile> sources, int maxCyc
for (int i = 0; i < maxCycles; i++) {
int visitorsThatMadeChangesThisCycle = 0;
for (int j = 0; j < accumulatedSources.size(); j++) {
SourceFile prev = accumulatedSources.get(j);
if (prev == null) {
SourceFile originalSource = accumulatedSources.get(j);
if (originalSource == null) {

// source was deleted in a previous iteration
continue;
}

SourceFile acc = prev;
SourceFile acc = originalSource;

for (RefactorVisitor<? extends Tree> visitor : visitors) {
try {
Expand All @@ -119,11 +120,12 @@ public Collection<Change> fix(Iterable<? extends SourceFile> sources, int maxCyc
acc = (SourceFile) transformPipeline(acc, visitor);

if (before != acc) {

// we should only report on the top-level visitors, not any andThen() visitors that
// are applied as part of the top-level visitor's pipeline
changesByTree.compute(acc, (acc2, prevChange) -> prevChange == null ?
new Change(prev, acc2, Collections.singleton(visitor.getName())) :
new Change(prev, acc2, Stream
new Change(originalSource, acc2, Collections.singleton(visitor.getName())) :
new Change(originalSource, acc2, Stream
.concat(prevChange.getVisitorsThatMadeChanges().stream(), Stream.of(visitor.getName()))
.collect(toSet()))
);
Expand All @@ -135,7 +137,7 @@ public Collection<Change> fix(Iterable<? extends SourceFile> sources, int maxCyc
.baseUnit("errors")
.description("Visitors that threw exceptions")
.tag("visitor", visitor.getName())
.tag("tree.type", prev.getClass().getName())
.tag("tree.type", originalSource.getClass().getName())
.tag("exception", t.getClass().getSimpleName())
.register(meterRegistry)
.increment();
Expand Down

0 comments on commit 05775b9

Please sign in to comment.