-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Specify nullness for nodes in the graphql.language package
#3899
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c5e0ae6
Specify nullness for nodes
mk868 8446dff
Merge branch 'master' into jspecify-node
dondonz 237ee1f
Set builders to null unmarked
dondonz d559d7b
Require array and object value to not be null, use empty list instead
dondonz 5dd0424
Fix up nullability annotation
dondonz 0393ee9
Add assertion
dondonz b124c00
Change to assert
dondonz 28a3301
Merge branch 'master' into jspecify-node
dondonz d7f087e
Update exemptions
dondonz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -7,6 +7,9 @@ | |
| import graphql.collect.ImmutableKit; | ||
| import graphql.util.TraversalControl; | ||
| import graphql.util.TraverserContext; | ||
| import org.jspecify.annotations.NullMarked; | ||
| import org.jspecify.annotations.NullUnmarked; | ||
| import org.jspecify.annotations.Nullable; | ||
|
|
||
| import java.util.LinkedHashMap; | ||
| import java.util.List; | ||
|
|
@@ -19,13 +22,14 @@ | |
| import static graphql.language.NodeChildrenContainer.newNodeChildrenContainer; | ||
|
|
||
| @PublicApi | ||
| @NullMarked | ||
| public class ArrayValue extends AbstractNode<ArrayValue> implements Value<ArrayValue> { | ||
|
|
||
| public static final String CHILD_VALUES = "values"; | ||
| private final ImmutableList<Value> values; | ||
|
|
||
| @Internal | ||
| protected ArrayValue(List<Value> values, SourceLocation sourceLocation, List<Comment> comments, IgnoredChars ignoredChars, Map<String, String> additionalData) { | ||
| protected ArrayValue(List<Value> values, @Nullable SourceLocation sourceLocation, List<Comment> comments, IgnoredChars ignoredChars, Map<String, String> additionalData) { | ||
| super(sourceLocation, comments, ignoredChars, additionalData); | ||
| this.values = ImmutableList.copyOf(values); | ||
| } | ||
|
|
@@ -67,7 +71,7 @@ public ArrayValue withNewChildren(NodeChildrenContainer newChildren) { | |
| } | ||
|
|
||
| @Override | ||
| public boolean isEqualTo(Node o) { | ||
| public boolean isEqualTo(@Nullable Node o) { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
|
|
@@ -87,7 +91,8 @@ public String toString() { | |
|
|
||
| @Override | ||
| public ArrayValue deepCopy() { | ||
| return new ArrayValue(deepCopy(values), getSourceLocation(), getComments(), getIgnoredChars(), getAdditionalData()); | ||
| List<Value> copiedValues = assertNotNull(deepCopy(values)); | ||
| return new ArrayValue(copiedValues, getSourceLocation(), getComments(), getIgnoredChars(), getAdditionalData()); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -101,6 +106,7 @@ public ArrayValue transform(Consumer<Builder> builderConsumer) { | |
| return builder.build(); | ||
| } | ||
|
|
||
| @NullUnmarked | ||
|
Member
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. After giving a few classes the JSpecify treatment: we now generally annotate Builders with |
||
| public static final class Builder implements NodeBuilder { | ||
| private SourceLocation sourceLocation; | ||
| private ImmutableList<Value> values = emptyList(); | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Add an assert here to keep NullAway happy
In practice it is not possible to have null values. Have to put this here otherwise you'll get a NullAway error