Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

Adds JSpecify null-safety annotations to 10 core AST classes in graphql.language, removing them from the exemption list.

Changes

Annotated classes:

  • AbstractDescribedNode, DescribedNode - @Nullable on description field/return (descriptions are optional in GraphQL SDL)
  • Description - @Nullable on content and sourceLocation fields
  • AstPrinter, AstSignature, AstSorter, AstTransformer - @Nullable on method parameters that accept nulls
  • AstNodeAdapter - Non-null throughout
  • Directive, DirectiveDefinition - @NullUnmarked on Builder inner classes per convention

NullAway fixes:

  • Added assertNotNull() calls in deepCopy() methods where generic @Nullable List<V> returns are passed to non-null constructors (lists are always non-null at call site)

Example

@PublicApi
@NullMarked
public class Description implements Serializable {
    public final @Nullable String content;
    public final @Nullable SourceLocation sourceLocation;
    
    public Description(@Nullable String content, @Nullable SourceLocation sourceLocation, boolean multiLine) {
        // ...
    }
}

Removed all 10 classes from JSpecifyAnnotationsCheck.groovy exemption list.

Original prompt

Task

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

Classes to annotate

  1. graphql.language.AbstractDescribedNode
  2. graphql.language.AstNodeAdapter
  3. graphql.language.AstPrinter
  4. graphql.language.AstSignature
  5. graphql.language.AstSorter
  6. graphql.language.AstTransformer
  7. graphql.language.DescribedNode
  8. graphql.language.Description
  9. graphql.language.Directive
  10. graphql.language.DirectiveDefinition

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.


✨ 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 10 classes in graphql.language package Add JSpecify annotations to 10 graphql.language classes Jan 25, 2026
Copilot AI requested a review from dondonz January 25, 2026 06:56
@dondonz dondonz changed the base branch from copilot/add-jspecify-annotations-to-classes to master February 8, 2026 07:17
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