Skip to content

Commit

Permalink
feat: increase logging for refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWitt committed Oct 27, 2022
1 parent 7538085 commit 86d5684
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package xyz.keksdose.spoon.code_solver;

import com.google.common.flogger.FluentLogger;
import java.util.Collection;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.factory.Factory;
Expand All @@ -13,7 +14,9 @@
*/
public class RepeatingProcessingManager extends QueueProcessingManager {

private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final ChangeListener listener;
private int iteration = 0;

public RepeatingProcessingManager(Factory factory, ChangeListener listener) {
super(factory);
Expand All @@ -24,7 +27,9 @@ public RepeatingProcessingManager(Factory factory, ChangeListener listener) {
public void process(Collection<? extends CtElement> elements) {
do {
listener.reset();
logger.atInfo().log("Starting iteration %d", iteration++);
super.process(elements);
logger.atInfo().log("Finished iteration %d", iteration);
} while (listener.isChanged());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ public TransformationEngine setPrinting(IPrinting printing) {
}

public Changelog applyToGivenPath(String path) {
LOGGER.atInfo().log("Applying transformations to %s", path);
LOGGER.atInfo().log("Applying transformations to %s with %s processors", path, processors.size());
Launcher launcher = new Launcher();
Environment environment = EnvironmentOptions.setEnvironmentOptions(launcher);
addInput(path, launcher);
CtModel model = launcher.buildModel();
LOGGER.atInfo().log("Model built");
PrinterCreation.setPrettyPrinter(environment, model);
if (printing == null) {
printing = new ChangedTypePrinting(environment.createPrettyPrinter());
Expand Down Expand Up @@ -101,7 +102,7 @@ private void addProcessors(ProcessingManager pm, ChangeListener listener) {
}

public Changelog applyToGivenPath(String path, String typeName) {
LOGGER.atInfo().log("Applying transformations to %s", path);
LOGGER.atInfo().log("Applying transformations to %s with %s processors", path, processors.size());
Launcher launcher = new Launcher();
Environment environment = EnvironmentOptions.setEnvironmentOptions(launcher);
addInput(path, launcher);
Expand Down

0 comments on commit 86d5684

Please sign in to comment.