package org.ntlab.deltaViewer; import java.util.ArrayList; import java.util.List; import org.ntlab.deltaExtractor.Alias; import org.ntlab.deltaExtractor.IAliasTracker; import org.ntlab.trace.MethodExecution; import org.ntlab.trace.MethodInvocation; /** * Collect delta alias for MagnetRON.(Derived from DeltaAliasTracker.) * * @author Nitta Lab. */ public class DeltaAliasCollector implements IAliasTracker { // Reverse execution order. private List<Alias> aliasList = new ArrayList<>(); public DeltaAliasCollector() { } @Override public void addAlias(Alias alias) { switch(alias.getAliasType()) { case FORMAL_PARAMETER: aliasList.add(0, alias); break; case THIS: aliasList.add(0, alias); break; case METHOD_INVOCATION: aliasList.add(0, alias); break; case CONSTRACTOR_INVOCATION: aliasList.add(0, alias); break; case FIELD: aliasList.add(0, alias); break; case ARRAY_ELEMENT: aliasList.add(0, alias); break; case ARRAY: aliasList.add(0, alias); break; case ACTUAL_ARGUMENT: aliasList.add(0, alias); break; case RECEIVER: aliasList.add(0, alias); if (alias.getOccurrencePoint().getStatement() instanceof MethodInvocation) { MethodExecution me = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); } break; case RETURN_VALUE: aliasList.add(0, alias); break; default: break; } System.out.println(alias.getObjectId() + ", " + alias.getMethodSignature() + " l." + alias.getLineNo() + " : " + alias.getAliasType().toString()); } @Override public List<Alias> getAliasList() { return this.aliasList; } /* * Don't write anything here. */ @Override public void changeTrackingObject(String from, String to, boolean isSrcSide) { } }