public abstract class JChangeTrackingVisitor extends JModVisitor
Subclasses of JChangeTrackingVisitor should override enter/exit instead of visit/endVisit for JMethod, JConstructor, JVariable and JField
Passes that modify the Java AST while an OptimizerContext is in effect should subclass this
class (JChangeTrackingVisitor) instead of JModVisitor
or interact with
OptimizerContext
directly.
Passes that would like to act only on parts of the tree related to the modification that happened
since the pass was last run should do something like:
String passName = "SomeUniqueNameForThisPass";
int lastSeenOptmizationStep = optimizerContext.getLastStepFor(passName);
Set<JMethod> modifiedMethods =
optimizerContext.getModifiedMethodsSince(lastSeenOptmizationStep)
Set<JField> modifiedFields =
optimizerContext.getModifiedFieldsSince(lastSeenOptmizationStep)
// compute potentially affected fields and methods and run the optimizer just on those
....
//
optimizerContext.setLastStepFor(passName, optimizerContext.getCurrentOptimizationStep());
optimizerContext.incOptimizationStep;
LVALUE_CONTEXT, UNMODIFIABLE_CONTEXT
Constructor and Description |
---|
JChangeTrackingVisitor(OptimizerContext optimizerCtx) |
accept, accept, accept, acceptImmutable, acceptLvalue, acceptWithInsertRemove, acceptWithInsertRemoveImmutable, checkReplacement, didChange, getNumMods, traverse
accept, accept, accept, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, translateException, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
public JChangeTrackingVisitor(OptimizerContext optimizerCtx)
public final void endVisit(JConstructor x, Context ctx)
public boolean enter(JConstructor x, Context ctx)
public void exit(JConstructor x, Context ctx)
public JField getCurrentField()
public JMethod getCurrentMethod()
public final boolean visit(JConstructor x, Context ctx)
public final void wasRemoved(JField field)
public final void wasRemoved(JMethod method)
public final void methodsWereRemoved(Collection<JMethod> methods)
public final void fieldsWereRemoved(Collection<JField> fields)
protected final void madeChanges()
JModVisitor
madeChanges
in class JModVisitor
Copyright © 2018. All rights reserved.