Skip to content

Add JSpecify annotations to 14 classes in graphql.language package (final batch)#4221

Draft
Copilot wants to merge 79 commits intomasterfrom
copilot/add-jspecify-annotations-one-more-time
Draft

Add JSpecify annotations to 14 classes in graphql.language package (final batch)#4221
Copilot wants to merge 79 commits intomasterfrom
copilot/add-jspecify-annotations-one-more-time

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

Completes JSpecify annotation coverage for the graphql.language package by annotating the remaining 14 classes.

Changes

Annotated classes:

  • Interfaces: SDLNamedDefinition, Selection, SelectionSetContainer, TypeDefinition
  • Enum: TypeKind
  • Concrete classes: ScalarTypeDefinition, ScalarTypeExtensionDefinition, SchemaDefinition, SchemaExtensionDefinition, SelectionSet, TypeName, UnionTypeDefinition, UnionTypeExtensionDefinition, VariableDefinition

Pattern applied:

  • @NullMarked at class level
  • @NullUnmarked on static Builder classes
  • @Nullable on fields/parameters that accept null: SourceLocation, Description, Value defaultValue, SelectionSet
  • assertNotNull() wrapping deepCopy() results passed to constructors expecting non-null lists

Ripple effect fix:

  • Updated Anonymizer.java to use assertNotNull() when passing condition strings to TypeName constructor (now requires non-null after annotation)

Exemption list:

  • Removed all 14 classes from JSpecifyAnnotationsCheck.groovy
Original prompt

Task

Add JSpecify annotations to the following 14 classes in the graphql.language package (final batch for this package), following the established JSpecify annotation pattern documented in .claude/commands/jspecify-annotate.md.

Classes to annotate

  1. graphql.language.SDLNamedDefinition
  2. graphql.language.ScalarTypeDefinition
  3. graphql.language.ScalarTypeExtensionDefinition
  4. graphql.language.SchemaDefinition
  5. graphql.language.SchemaExtensionDefinition
  6. graphql.language.Selection
  7. graphql.language.SelectionSet
  8. graphql.language.SelectionSetContainer
  9. graphql.language.TypeDefinition
  10. graphql.language.TypeKind
  11. graphql.language.TypeName
  12. graphql.language.UnionTypeDefinition
  13. graphql.language.UnionTypeExtensionDefinition
  14. graphql.language.VariableDefinition

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 like IntValue.java, StringValue.java, AbstractNode.java in the same package for reference patterns.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: dondonz <13839920+dondonz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add JSpecify annotations to 14 classes in graphql.language package Add JSpecify annotations to 14 classes in graphql.language package (final batch) Jan 25, 2026
Copilot AI requested a review from dondonz January 25, 2026 07:27
@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