-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add JSpecify annotations to 10 classes in graphql.execution package #4225
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
Closed
Copilot
wants to merge
6
commits into
master
from
copilot/add-jspecify-annotations-9b68a1b9-5125-48d5-add7-382dfedc3cc7
+164
−73
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c60fdf6
Initial plan
Copilot c02fa4e
Add JSpecify annotations to 10 classes in graphql.language package
Copilot 3db2dde
Update JSpecify annotation prompt with effectiveness improvements
Copilot 00da46a
Initial plan
Copilot e395eab
Add JSpecify annotations to 10 classes in graphql.execution package
Copilot a18d5ee
Merge branch 'master' into copilot/add-jspecify-annotations-9b68a1b9-…
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
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 |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
| import graphql.AssertException; | ||
| import graphql.PublicApi; | ||
| import graphql.collect.ImmutableKit; | ||
| import org.jspecify.annotations.NullMarked; | ||
| import org.jspecify.annotations.Nullable; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.LinkedList; | ||
|
|
@@ -21,6 +23,7 @@ | |
| * class represents that path as a series of segments. | ||
| */ | ||
| @PublicApi | ||
| @NullMarked | ||
| public class ResultPath { | ||
| private static final ResultPath ROOT_PATH = new ResultPath(); | ||
|
|
||
|
|
@@ -33,8 +36,8 @@ public static ResultPath rootPath() { | |
| return ROOT_PATH; | ||
| } | ||
|
|
||
| private final ResultPath parent; | ||
| private final Object segment; | ||
| private final @Nullable ResultPath parent; | ||
| private final @Nullable Object segment; | ||
|
|
||
| // hash is effective immutable but lazily initialized similar to the hash code of java.lang.String | ||
| private int hash; | ||
|
|
@@ -85,7 +88,7 @@ public ResultPath getPathWithoutListEnd() { | |
| if (segment instanceof String) { | ||
| return this; | ||
| } | ||
| return parent; | ||
| return assertNotNull(parent, "parent should not be null for non-root path"); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -104,18 +107,18 @@ public boolean isNamedSegment() { | |
|
|
||
|
|
||
| public String getSegmentName() { | ||
| return (String) segment; | ||
| return (String) assertNotNull(segment, "segment should not be null"); | ||
|
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. TODO: check if we want these asserts here |
||
| } | ||
|
|
||
| public int getSegmentIndex() { | ||
| return (int) segment; | ||
| return (int) assertNotNull(segment, "segment should not be null"); | ||
| } | ||
|
|
||
| public Object getSegmentValue() { | ||
| return segment; | ||
| return assertNotNull(segment, "segment should not be null"); | ||
| } | ||
|
|
||
| public ResultPath getParent() { | ||
| public @Nullable ResultPath getParent() { | ||
| return parent; | ||
| } | ||
|
|
||
|
|
@@ -201,7 +204,7 @@ public ResultPath segment(int segment) { | |
| * | ||
| * @return a new path with the last segment dropped off | ||
| */ | ||
| public ResultPath dropSegment() { | ||
| public @Nullable ResultPath dropSegment() { | ||
| if (this == rootPath()) { | ||
| return null; | ||
| } | ||
|
|
@@ -218,7 +221,7 @@ public ResultPath dropSegment() { | |
| */ | ||
| public ResultPath replaceSegment(int segment) { | ||
| assertTrue(!ROOT_PATH.equals(this), "You MUST not call this with the root path"); | ||
| return new ResultPath(parent, segment); | ||
| return new ResultPath(assertNotNull(parent, "parent should not be null"), segment); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -231,7 +234,7 @@ public ResultPath replaceSegment(int segment) { | |
| */ | ||
| public ResultPath replaceSegment(String segment) { | ||
| assertTrue(!ROOT_PATH.equals(this), "You MUST not call this with the root path"); | ||
| return new ResultPath(parent, segment); | ||
| return new ResultPath(assertNotNull(parent, "parent should not be null"), segment); | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -258,12 +261,12 @@ public ResultPath append(ResultPath path) { | |
|
|
||
| public ResultPath sibling(String siblingField) { | ||
| assertTrue(!ROOT_PATH.equals(this), "You MUST not call this with the root path"); | ||
| return new ResultPath(this.parent, siblingField); | ||
| return new ResultPath(assertNotNull(this.parent, "parent should not be null"), siblingField); | ||
| } | ||
|
|
||
| public ResultPath sibling(int siblingField) { | ||
| assertTrue(!ROOT_PATH.equals(this), "You MUST not call this with the root path"); | ||
| return new ResultPath(this.parent, siblingField); | ||
| return new ResultPath(assertNotNull(this.parent, "parent should not be null"), siblingField); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -275,7 +278,7 @@ public List<Object> toList() { | |
| } | ||
| LinkedList<Object> list = new LinkedList<>(); | ||
| ResultPath p = this; | ||
| while (p.segment != null) { | ||
| while (p != null && p.segment != null) { | ||
| list.addFirst(p.segment); | ||
| p = p.parent; | ||
| } | ||
|
|
@@ -291,7 +294,7 @@ public List<String> getKeysOnly() { | |
| } | ||
| LinkedList<String> list = new LinkedList<>(); | ||
| ResultPath p = this; | ||
| while (p.segment != null) { | ||
| while (p != null && p.segment != null) { | ||
| if (p.segment instanceof String) { | ||
| list.addFirst((String) p.segment); | ||
| } | ||
|
|
@@ -328,15 +331,15 @@ public boolean equals(Object o) { | |
|
|
||
| ResultPath self = this; | ||
| ResultPath that = (ResultPath) o; | ||
| while (self.segment != null && that.segment != null) { | ||
| while (self != null && self.segment != null && that != null && that.segment != null) { | ||
| if (!Objects.equals(self.segment, that.segment)) { | ||
| return false; | ||
| } | ||
| self = self.parent; | ||
| that = that.parent; | ||
| } | ||
|
|
||
| return self.isRootPath() && that.isRootPath(); | ||
| return (self == null || self.isRootPath()) && (that == null || that.isRootPath()); | ||
|
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. TODO: double check this change in return statement |
||
| } | ||
|
|
||
| @Override | ||
|
|
||
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.
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.
TODO: check this