Skip to content

Commit

Permalink
undo rename
Browse files Browse the repository at this point in the history
  • Loading branch information
nimakarimipour committed Oct 3, 2024
1 parent fbbd9bf commit 150cc19
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public boolean equals(Object o) {
// message and should not be treated as a separate error.
return true;
}
return message.equals(error.message) && fixes.equals(error.fixes) && offset == error.offset;
return message.equals(error.message)
&& resolvingFixes.equals(error.resolvingFixes)
&& offset == error.offset;
}

@Override
Expand All @@ -86,7 +88,7 @@ public int hashCode() {
// to make sure equal objects will produce the same hashcode.
messageType.equals(METHOD_INITIALIZER_ERROR) ? METHOD_INITIALIZER_ERROR : message,
region,
fixes,
resolvingFixes,
offset);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class Error {
/** Error message. */
public final String message;
/** The fixes which can resolve this error (possibly null). */
protected final Set<Fix> fixes;
protected final Set<Fix> resolvingFixes;
/** Offset of program point in original version where error is reported. */
protected final int offset;
/** Containing region. */
Expand All @@ -60,13 +60,13 @@ public Error(
this.messageType = messageType;
this.message = message;
this.offset = offset;
this.fixes = computeFixesFromAnnotations(annotations);
this.resolvingFixes = computeFixesFromAnnotations(annotations);
}

protected abstract Set<Fix> computeFixesFromAnnotations(Set<AddAnnotation> annotations);

public Set<Fix> getFixes() {
return this.fixes;
return this.resolvingFixes;
}

/**
Expand All @@ -75,7 +75,7 @@ public Set<Fix> getFixes() {
* @return true if error is resolvable with only one annotation and false otherwise.
*/
public boolean isSingleAnnotationFix() {
return !fixes.isEmpty() && fixes.iterator().next().changes.size() == 1;
return !resolvingFixes.isEmpty() && resolvingFixes.iterator().next().changes.size() == 1;
}

/**
Expand All @@ -84,9 +84,10 @@ public boolean isSingleAnnotationFix() {
* @return Location of the fix resolving this error.
*/
public Location toResolvingLocation() {
Preconditions.checkArgument(!fixes.isEmpty() && fixes.iterator().next().changes.size() == 1);
Preconditions.checkArgument(
!resolvingFixes.isEmpty() && resolvingFixes.iterator().next().changes.size() == 1);
// no get() method, have to use iterator.
return fixes.iterator().next().changes.iterator().next().getLocation();
return resolvingFixes.iterator().next().changes.iterator().next().getLocation();
}

/**
Expand Down Expand Up @@ -139,7 +140,7 @@ public boolean equals(Object o) {
return messageType.equals(other.messageType)
&& region.equals(other.region)
&& message.equals(other.message)
&& fixes.equals(other.fixes)
&& resolvingFixes.equals(other.resolvingFixes)
&& offset == other.offset;
}

Expand All @@ -151,14 +152,14 @@ public boolean equals(Object o) {
* @return true, if error is resolvable via fixes on target module.
*/
public boolean isFixableOnTarget(Context context) {
return this.fixes.stream()
return this.resolvingFixes.stream()
.flatMap(fix -> fix.changes.stream())
.allMatch(change -> context.targetModuleInfo.declaredInModule(change.getLocation()));
}

@Override
public int hashCode() {
return Objects.hash(messageType, message, region, fixes, offset);
return Objects.hash(messageType, message, region, resolvingFixes, offset);
}

@Override
Expand All @@ -182,7 +183,9 @@ public String toString() {
*/
public static <T extends Error> ImmutableSet<Fix> getResolvingFixesOfErrors(
Collection<T> errors) {
return errors.stream().flatMap(t -> t.fixes.stream()).collect(ImmutableSet.toImmutableSet());
return errors.stream()
.flatMap(t -> t.resolvingFixes.stream())
.collect(ImmutableSet.toImmutableSet());
}

/**
Expand All @@ -192,9 +195,9 @@ public static <T extends Error> ImmutableSet<Fix> getResolvingFixesOfErrors(
* @return true, if this error is resolvable.
*/
public boolean isResolvableWith(Collection<Fix> fixes) {
if (this.fixes.isEmpty()) {
if (this.resolvingFixes.isEmpty()) {
return false;
}
return fixes.containsAll(this.fixes);
return fixes.containsAll(this.resolvingFixes);
}
}

0 comments on commit 150cc19

Please sign in to comment.