-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update fix structor to contain multiple annotation changes #242
Conversation
Set<Location> otherTree = found.tree.stream().map(Fix::toLocation).collect(Collectors.toSet()); | ||
Set<Location> thisTree = | ||
this.tree.stream().flatMap(fix -> fix.toLocations().stream()).collect(Collectors.toSet()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove white line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annotator-core/src/main/java/edu/ucr/cs/riple/core/cache/Impact.java
Outdated
Show resolved
Hide resolved
@@ -187,7 +187,7 @@ private Set<String> extractUninitializedFieldNames(String errorMessage) { | |||
* @param region Region where the error is reported. | |||
* @return Set of fixes for uninitialized fields to resolve the given error. | |||
*/ | |||
protected ImmutableSet<Fix> generateFixesForUninitializedFields( | |||
protected ImmutableSet<AddAnnotation> computeAddAnnotationInstancesForUninitializedFields( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update javadoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -174,6 +175,10 @@ public boolean declaredInModule(Location location) { | |||
return methodRegistry.declaredInModule(location); | |||
} | |||
|
|||
public boolean declaredInModule(Set<Location> locations) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add javadoc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** The fixes which can resolve this error (possibly empty). */ | ||
protected final ImmutableSet<Fix> resolvingFixes; | ||
/** The fixes which can resolve this error (possibly null). */ | ||
protected final Set<Fix> resolvingFixes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make immutable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
public ImmutableSet<Fix> getResolvingFixes() { | ||
public Set<Fix> getFixes() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update return type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Fix.java
Show resolved
Hide resolved
annotator-core/src/main/java/edu/ucr/cs/riple/core/registries/index/Fix.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change LGTM. I have some high-level questions and minor comments but they don't need to block landing the PR.
@@ -157,7 +157,7 @@ private void executeNextIteration( | |||
injector.injectFixes(selectedFixes); | |||
// Update log. | |||
context.log.updateInjectedAnnotations( | |||
selectedFixes.stream().map(fix -> fix.change).collect(Collectors.toSet())); | |||
selectedFixes.stream().flatMap(fix -> fix.changes.stream()).collect(Collectors.toSet())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For after this PR: it'd be good to add Google Java Format formatting to this repo, enforced via Spotless. It will get rid of long lines like this one that are hard to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do #248
@@ -51,19 +52,19 @@ public BaseCache(S store) { | |||
|
|||
@Override | |||
public boolean isUnknown(Fix fix) { | |||
return !this.store.containsKey(fix.toLocation()); | |||
return !this.store.containsKey(fix.toLocations()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High-level question: why not use Fix
as the key type for the maps, instead of Set<Location>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*/ | ||
protected ImmutableSet<Fix> generateFixesForUninitializedFields( | ||
String errorMessage, Region region, ModuleInfo module) { | ||
private ImmutableSet<AddAnnotation> computeAddAnnotationInstancesForUninitializedFields( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't make this ImmutableSet<Fix>
because we want to evaluate each annotation individually, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly, we evaluate each annotation (uninitialized field in this case) individually.
.changes | ||
.iterator() | ||
.next() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also assert that the size of changes
is equal to 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR introduces a necessary change in preparation for the upcoming major PR that will add support for taint checker inference.
The key change in this PR is the update to the
Fix
structure, which now contains a list of changes rather than a single change. With this new design, aFix
instance represents the smallest unit of annotation changes that the Annotator will evaluate for its impact. If approved, these changes will be applied to the source code. It’s important to note that resolving an error may require adding multiple annotations, and aFix
instance can include a subset or all of these changes.In NullAway inference, we evaluate each annotation individually and apply it if approved. For example, resolving an initialization error may require annotating multiple fields as
@Nullable
, but each annotation is evaluated and applied one at a time. In contrast, taint inference requires evaluating all suggested annotations together for a given error.This updated design lays the groundwork for supporting the taint checker inference by accommodating the evaluation of grouped annotations for each error.