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
Remove nullable annotation configuration in fix serialization. #621
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,64 +26,56 @@ | |
import com.sun.source.util.TreePath; | ||
import com.uber.nullaway.ErrorMessage; | ||
import com.uber.nullaway.fixserialization.location.FixLocation; | ||
import com.uber.nullaway.fixserialization.qual.AnnotationConfig; | ||
import java.util.Objects; | ||
|
||
/** Stores information suggesting a type change of an element in source code. */ | ||
public class SuggestedFixInfo { | ||
/** Stores information suggesting adding @Nullable on an element in source code. */ | ||
public class SuggestedNullableFixInfo { | ||
|
||
/** FixLocation of the target element in source code. */ | ||
private final FixLocation fixLocation; | ||
/** Error which will be resolved by this type change. */ | ||
private final ErrorMessage errorMessage; | ||
/** Suggested annotation. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this comment as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
private final AnnotationConfig.Annotation annotation; | ||
|
||
private final ClassAndMethodInfo classAndMethodInfo; | ||
|
||
public SuggestedFixInfo( | ||
TreePath path, | ||
FixLocation fixLocation, | ||
ErrorMessage errorMessage, | ||
AnnotationConfig.Annotation annotation) { | ||
public SuggestedNullableFixInfo( | ||
TreePath path, FixLocation fixLocation, ErrorMessage errorMessage) { | ||
this.classAndMethodInfo = new ClassAndMethodInfo(path); | ||
this.fixLocation = fixLocation; | ||
this.errorMessage = errorMessage; | ||
this.annotation = annotation; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof SuggestedFixInfo)) { | ||
if (!(o instanceof SuggestedNullableFixInfo)) { | ||
return false; | ||
} | ||
SuggestedFixInfo suggestedFixInfo = (SuggestedFixInfo) o; | ||
return Objects.equals(fixLocation, suggestedFixInfo.fixLocation) | ||
&& Objects.equals(annotation, suggestedFixInfo.annotation) | ||
SuggestedNullableFixInfo suggestedNullableFixInfo = (SuggestedNullableFixInfo) o; | ||
return Objects.equals(fixLocation, suggestedNullableFixInfo.fixLocation) | ||
&& Objects.equals( | ||
errorMessage.getMessageType().toString(), | ||
suggestedFixInfo.errorMessage.getMessageType().toString()); | ||
suggestedNullableFixInfo.errorMessage.getMessageType().toString()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(fixLocation, annotation, errorMessage.getMessageType().toString()); | ||
return Objects.hash(fixLocation, errorMessage.getMessageType().toString()); | ||
} | ||
|
||
/** | ||
* returns string representation of content of an object. | ||
* | ||
* @return string representation of contents of an object in a line seperated by tabs. | ||
* @return string representation of contents of an object in a line separated by tabs. | ||
*/ | ||
public String tabSeparatedToString() { | ||
return fixLocation.tabSeparatedToString() | ||
+ '\t' | ||
+ errorMessage.getMessageType().toString() | ||
+ '\t' | ||
+ annotation | ||
+ "nullable" | ||
+ '\t' | ||
+ (classAndMethodInfo.getClazz() == null | ||
? "null" | ||
|
@@ -100,8 +92,8 @@ public void initEnclosing() { | |
} | ||
|
||
/** | ||
* Creates header of an output file containing all {@link SuggestedFixInfo} written in string | ||
* which values are separated by tabs. | ||
* Creates header of an output file containing all {@link SuggestedNullableFixInfo} written in | ||
* string which values are separated by tabs. | ||
* | ||
* @return string representation of the header separated by tabs. | ||
*/ | ||
|
82 changes: 0 additions & 82 deletions
82
nullaway/src/main/java/com/uber/nullaway/fixserialization/qual/AnnotationConfig.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why the rename here? It makes sense for now, but I wonder if we will have to flip it right back once we start adding other types of fixes? Or maybe the idea will be to add a common supertype for fixes and retain this one as a subclass?
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.
I did the renaming since instantiating this class only means we are suggesting
Nullable
and the valueNullable
is hardcoded in this class. I though for better understanding the class purpose, I should refine the name.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.
Sounds good for now. We might revisit this if we are adding other kinds of fixes, but right not it isn't clear if that will happen within NullAway or within the annotator or where, so this makes sense to me.