diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/BaseCache.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/BaseCache.java index 1e35fda32..f5227a85a 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/BaseCache.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/BaseCache.java @@ -27,11 +27,9 @@ import com.google.common.collect.ImmutableSet; import edu.ucr.cs.riple.core.registries.index.Error; import edu.ucr.cs.riple.core.registries.index.Fix; -import edu.ucr.cs.riple.injector.location.Location; import java.util.Collection; import java.util.Map; import java.util.Objects; -import java.util.Set; import javax.annotation.Nullable; /** @@ -40,8 +38,7 @@ * @param type of impacts saved in this model. * @param type of the map used to store impacts. */ -public abstract class BaseCache, T>> - implements ImpactCache { +public abstract class BaseCache> implements ImpactCache { /** Container holding cache entries. */ protected final S store; @@ -52,19 +49,19 @@ public BaseCache(S store) { @Override public boolean isUnknown(Fix fix) { - return !this.store.containsKey(fix.toLocations()); + return !this.store.containsKey(fix); } @Nullable @Override public T fetchImpact(Fix fix) { - return store.get(fix.toLocations()); + return store.get(fix); } @Override public ImmutableSet getTriggeredErrorsForCollection(Collection fixes) { return fixes.stream() - .map(fix -> store.get(fix.toLocations())) + .map(store::get) .filter(Objects::nonNull) .flatMap(impact -> impact.triggeredErrors.stream()) // filter errors that will be resolved with the existing collection of fixes. @@ -75,7 +72,7 @@ public ImmutableSet getTriggeredErrorsForCollection(Collection fixes @Override public ImmutableSet getTriggeredFixesFromDownstreamForCollection(Collection fixTree) { return fixTree.stream() - .map(fix -> store.get(fix.toLocations())) + .map(store::get) .filter(Objects::nonNull) .flatMap(impact -> impact.getTriggeredFixesFromDownstreamErrors().stream()) // filter fixes that are already inside tree. @@ -96,6 +93,6 @@ public void updateImpactsAfterInjection(Collection fixes) { @Override public int size() { - return this.store.values().size(); + return this.store.size(); } } diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/Impact.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/Impact.java index 56df8d12b..363336030 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/Impact.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/Impact.java @@ -27,7 +27,6 @@ import com.google.common.collect.ImmutableSet; import edu.ucr.cs.riple.core.registries.index.Error; import edu.ucr.cs.riple.core.registries.index.Fix; -import edu.ucr.cs.riple.injector.location.Location; import java.util.Collection; import java.util.Objects; import java.util.Set; @@ -90,15 +89,6 @@ public ImmutableSet getTriggeredFixesFromDownstreamErrors() { return triggeredFixesFromDownstreamErrors; } - /** - * Gets the containing locations. - * - * @return Containing fix locations. - */ - public Set toLocations() { - return fix.toLocations(); - } - @Override public int hashCode() { return fix.hashCode(); diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/TargetModuleCache.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/TargetModuleCache.java index fe73631fa..74bff2d29 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/TargetModuleCache.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/TargetModuleCache.java @@ -24,7 +24,7 @@ package edu.ucr.cs.riple.core.cache; -import edu.ucr.cs.riple.injector.location.Location; +import edu.ucr.cs.riple.core.registries.index.Fix; import java.util.HashMap; import java.util.Set; @@ -32,7 +32,7 @@ * Cache for storing impacts of fixes on target module. This cache's state is not immutable and can * be updated. */ -public class TargetModuleCache extends BaseCache, Impact>> { +public class TargetModuleCache extends BaseCache> { public TargetModuleCache() { super(new HashMap<>()); @@ -44,6 +44,6 @@ public TargetModuleCache() { * @param newData New given impacts. */ public void updateCacheState(Set newData) { - newData.forEach(t -> store.put(t.toLocations(), t)); + newData.forEach(t -> store.put(t.fix, t)); } } diff --git a/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/downstream/DownstreamImpactCacheImpl.java b/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/downstream/DownstreamImpactCacheImpl.java index e9059cc64..343a22736 100644 --- a/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/downstream/DownstreamImpactCacheImpl.java +++ b/annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/downstream/DownstreamImpactCacheImpl.java @@ -51,7 +51,7 @@ * once created, cannot be updated. */ public class DownstreamImpactCacheImpl - extends BaseCache, DownstreamImpact>> + extends BaseCache> implements DownstreamImpactCache { /** Annotator context instance. */ @@ -130,7 +130,7 @@ public void analyzeDownstreamDependencies() { reports.forEach( report -> { DownstreamImpact impact = new DownstreamImpact(report); - store.put(report.root.toLocations(), impact); + store.put(report.root, impact); }); System.out.println("Analyzing downstream dependencies completed!"); }