Skip to content

Add JSpecify annotations to graphql.analysis package#4222

Draft
Copilot wants to merge 79 commits intomasterfrom
copilot/add-jspecify-annotations-please-work
Draft

Add JSpecify annotations to graphql.analysis package#4222
Copilot wants to merge 79 commits intomasterfrom
copilot/add-jspecify-annotations-please-work

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

Adds JSpecify @NullMarked annotations to all 17 classes in the graphql.analysis package to enable null-safety checking via NullAway.

Changes

Interfaces (9 classes)

  • Added @NullMarked to all query visitor environment interfaces
  • Marked nullable return types: QueryVisitorFieldArgumentInputValue.getParent(), getValue(), and QueryVisitorFieldEnvironment.getParentEnvironment()

Classes (8 classes)

  • Added @NullMarked to QueryVisitorStub, QueryTraversalOptions, and all builder-based classes
  • Marked builder inner classes with @NullUnmarked per established pattern
  • Marked nullable fields: QueryComplexityCalculator.operationName

NullAway fixes

  • ValueTraverser: Added @Nullable to internal traversal methods and public visitPreOrder return types; modified list building to handle null values (Guava's ImmutableList rejects nulls)
  • QueryTraverser.visitImpl(): Marked Boolean preOrder parameter as @Nullable
  • MaxQueryDepthInstrumentation.getPathLength(): Marked parameter as @Nullable

Cleanup

  • Removed all 17 classes from JSpecify exemption list in JSpecifyAnnotationsCheck.groovy
Original prompt

Task

Add JSpecify annotations to all 16 classes in the graphql.analysis package, following the established JSpecify annotation pattern documented in .claude/commands/jspecify-annotate.md.

Classes to annotate

  1. graphql.analysis.QueryComplexityCalculator
  2. graphql.analysis.QueryComplexityInfo
  3. graphql.analysis.QueryDepthInfo
  4. graphql.analysis.QueryReducer
  5. graphql.analysis.QueryTransformer
  6. graphql.analysis.QueryTraversalOptions
  7. graphql.analysis.QueryTraverser
  8. graphql.analysis.QueryVisitor
  9. graphql.analysis.QueryVisitorFieldArgumentEnvironment
  10. graphql.analysis.QueryVisitorFieldArgumentInputValue
  11. graphql.analysis.QueryVisitorFieldArgumentValueEnvironment
  12. graphql.analysis.QueryVisitorFieldEnvironment
  13. graphql.analysis.QueryVisitorFragmentDefinitionEnvironment
  14. graphql.analysis.QueryVisitorFragmentSpreadEnvironment
  15. graphql.analysis.QueryVisitorInlineFragmentEnvironment
  16. graphql.analysis.QueryVisitorStub
  17. graphql.analysis.values.ValueTraverser

Instructions

Follow the JSpecify annotation process documented in .claude/commands/jspecify-annotate.md:

  1. Set each class to be @NullMarked at the class level
  2. Remove all redundant @NonNull annotations that IntelliJ may have added
  3. Check Javadoc for @param tags mentioning "null", "nullable", "may be null"
  4. Check Javadoc @return tags mentioning "null", "optional", "if available"
  5. Inspect method implementations that return null or check for null
  6. Consider GraphQL specification details when determining nullability
  7. For Builder static classes, label them @NullUnmarked and no further annotations needed

Validation

After making changes, run the NullAway compile check:

./gradlew compileJava

If you find NullAway errors, make the smallest possible change to fix them. You can use assertNotNull with a message if needed.

Cleanup

  1. Remove each completed class from the exemption list in src/test/groovy/graphql/archunit/JSpecifyAnnotationsCheck.groovy
  2. Delete all unused imports from the classes you've annotated
  3. Do not make spacing or formatting changes - only make minimal changes necessary for the annotations

Reference

Look at existing annotated classes in the repository for reference patterns.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add JSpecify annotations to classes in graphql.analysis package Add JSpecify annotations to graphql.analysis package Jan 25, 2026
Copilot AI requested a review from dondonz January 25, 2026 07:18
@dondonz dondonz changed the base branch from copilot/add-jspecify-annotations-to-classes to master February 8, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants