Repository navigation
Add JSpecify annotations to language package nodes - redo (12 more) #4257
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
Changes from 1 commit
b261a43
4df4205
8fb836e
298fea2
82712c7
7a9e810
dd49296
9e31132
1063251
f4e0f1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,9 @@ | |
| import graphql.language.NodeUtil.DirectivesHolder; | ||
| 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.ArrayList; | ||
| import java.util.LinkedHashMap; | ||
|
|
@@ -22,15 +25,16 @@ | |
| import static graphql.language.NodeChildrenContainer.newNodeChildrenContainer; | ||
|
|
||
| @PublicApi | ||
| @NullMarked | ||
| public class OperationDefinition extends AbstractNode<OperationDefinition> implements Definition<OperationDefinition>, SelectionSetContainer<OperationDefinition>, DirectivesContainer<OperationDefinition>, NamedNode<OperationDefinition> { | ||
|
|
||
| public enum Operation { | ||
| QUERY, MUTATION, SUBSCRIPTION | ||
| } | ||
|
|
||
| private final String name; | ||
| private final @Nullable String name; | ||
|
|
||
| private final Operation operation; | ||
| private final @Nullable Operation operation; | ||
| private final ImmutableList<VariableDefinition> variableDefinitions; | ||
| private final DirectivesHolder directives; | ||
| private final SelectionSet selectionSet; | ||
|
|
@@ -40,12 +44,12 @@ public enum Operation { | |
| public static final String CHILD_SELECTION_SET = "selectionSet"; | ||
|
|
||
| @Internal | ||
| protected OperationDefinition(String name, | ||
| Operation operation, | ||
| protected OperationDefinition(@Nullable String name, | ||
| @Nullable Operation operation, | ||
| List<VariableDefinition> variableDefinitions, | ||
| List<Directive> directives, | ||
| SelectionSet selectionSet, | ||
| SourceLocation sourceLocation, | ||
| @Nullable SourceLocation sourceLocation, | ||
| List<Comment> comments, | ||
| IgnoredChars ignoredChars, | ||
| Map<String, String> additionalData) { | ||
|
|
@@ -57,15 +61,6 @@ protected OperationDefinition(String name, | |
| this.selectionSet = selectionSet; | ||
| } | ||
|
|
||
| public OperationDefinition(String name, | ||
| Operation operation) { | ||
| this(name, operation, emptyList(), emptyList(), null, null, emptyList(), IgnoredChars.EMPTY, emptyMap()); | ||
| } | ||
|
|
||
| public OperationDefinition(String name) { | ||
| this(name, null, emptyList(), emptyList(), null, null, emptyList(), IgnoredChars.EMPTY, emptyMap()); | ||
| } | ||
|
|
||
|
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. Fair enough - cruft must be removed at some point |
||
| @Override | ||
| public List<Node> getChildren() { | ||
| List<Node> result = new ArrayList<>(); | ||
|
|
@@ -93,11 +88,12 @@ public OperationDefinition withNewChildren(NodeChildrenContainer newChildren) { | |
| ); | ||
| } | ||
|
|
||
| public String getName() { | ||
| @Override | ||
| public @Nullable String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public Operation getOperation() { | ||
| public @Nullable Operation getOperation() { | ||
|
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. Ummmmmm can this be null??? if its not specified surely is defaults to QUERY??
Member
Author
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. Yep I agree, should have defaulted to query instead
Member
Author
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. It does in the parser as well |
||
| return operation; | ||
| } | ||
|
|
||
|
|
@@ -130,7 +126,7 @@ public SelectionSet getSelectionSet() { | |
| } | ||
|
|
||
| @Override | ||
| public boolean isEqualTo(Node o) { | ||
| public boolean isEqualTo(@Nullable Node o) { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
|
|
@@ -148,9 +144,9 @@ public boolean isEqualTo(Node o) { | |
| public OperationDefinition deepCopy() { | ||
| return new OperationDefinition(name, | ||
| operation, | ||
| deepCopy(variableDefinitions), | ||
| deepCopy(directives.getDirectives()), | ||
| deepCopy(selectionSet), | ||
| assertNotNull(deepCopy(variableDefinitions), "variableDefinitions deepCopy should not return null"), | ||
| assertNotNull(deepCopy(directives.getDirectives()), "directives deepCopy should not return null"), | ||
| assertNotNull(deepCopy(selectionSet), "selectionSet deepCopy should not return null"), | ||
| getSourceLocation(), | ||
| getComments(), | ||
| getIgnoredChars(), | ||
|
|
@@ -183,6 +179,7 @@ public OperationDefinition transform(Consumer<Builder> builderConsumer) { | |
| return builder.build(); | ||
| } | ||
|
|
||
| @NullUnmarked | ||
| public static final class Builder implements NodeDirectivesBuilder { | ||
| private SourceLocation sourceLocation; | ||
| private ImmutableList<Comment> comments = emptyList(); | ||
|
|
||
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.
These constructors date back to 2018, no longer needed with the builders we have today.
I am removing these lines because these parameters should be not-nullable.
I would usually first deprecate the methods, then remove, but if I keep them here with a deprecated annotation, the nullability annotations will not be correct.
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 is technically a breaking change