Print only @Nullable type use annotations in error messages#1507
Print only @Nullable type use annotations in error messages#1507
@Nullable type use annotations in error messages#1507Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1507 +/- ##
============================================
- Coverage 88.44% 88.43% -0.01%
Complexity 2813 2813
============================================
Files 99 99
Lines 9414 9410 -4
Branches 1890 1888 -2
============================================
- Hits 8326 8322 -4
Misses 529 529
Partials 559 559 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WalkthroughReworked pretty-printing of type-use nullability in GenericTypePrettyPrintingVisitor: removed per-annotation emission and added a private helper appendNullableAnnotationIfPresent(Type t, StringBuilder sb) that scans annotation mirrors and appends exactly Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@nullaway/src/main/java/com/uber/nullaway/generics/GenericTypePrettyPrintingVisitor.java`:
- Around line 68-80: The array type pretty-printer still prints annotations
directly in visitArrayType, allowing "@NonNull" to appear; update visitArrayType
to use the same filtering helper by invoking
appendAnnotation(Attribute.TypeCompound compound, StringBuilder sb) for each
annotation on the array (or element) instead of calling
compound.type.accept(this, null) directly, so "@NonNull" is elided consistently;
locate the visitArrayType method and replace direct annotation rendering with
calls to appendAnnotation for each Attribute.TypeCompound found.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 9e8187e7-5394-4d03-ae9e-c0417315817b
📒 Files selected for processing (3)
nullaway/src/main/java/com/uber/nullaway/generics/GenericTypePrettyPrintingVisitor.javanullaway/src/test/java/com/uber/nullaway/jspecify/GenericMethodTests.javanullaway/src/test/java/com/uber/nullaway/jspecify/GenericsTests.java
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@nullaway/src/main/java/com/uber/nullaway/generics/GenericTypePrettyPrintingVisitor.java`:
- Around line 68-80: The Javadoc for appendAnnotation in
GenericTypePrettyPrintingVisitor uses an invalid HTML tag <emph>; update the
Javadoc for the method appendAnnotation(Attribute.TypeCompound compound,
StringBuilder sb) to replace the <emph> tag with the proper <em> tag so the
comment reads "... <em>unless</em> the simple name...". Ensure only the tag is
changed and spacing/punctuation around the sentence remains the same.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: dee133ca-519e-430d-8cf7-955f15eba012
📒 Files selected for processing (1)
nullaway/src/main/java/com/uber/nullaway/generics/GenericTypePrettyPrintingVisitor.java
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@nullaway/src/main/java/com/uber/nullaway/generics/GenericTypePrettyPrintingVisitor.java`:
- Around line 66-79: The helper appendNullableAnnotationIfPresent currently
drops all non-Nullable type-use annotations; update it to only suppress printing
for NonNull while preserving other annotations: iterate the
Type.getAnnotationMirrors() as before, derive the annotation simple name via
compound.type.accept(this, null) (same symbol already used), if the name equals
"Nullable" append "@Nullable " to sb, if it equals "NonNull" continue/ignore,
otherwise append "@" + annotName + " " so other qualifiers are preserved; keep
the method signature appendNullableAnnotationIfPresent(Type t, StringBuilder sb)
and its loop structure but adjust the conditional logic to implement this
filtering.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b617c3b0-bf4a-437d-a960-a9c341d6812f
📒 Files selected for processing (1)
nullaway/src/main/java/com/uber/nullaway/generics/GenericTypePrettyPrintingVisitor.java
@Nullable type use annotations in types in error messages
@Nullable type use annotations in types in error messages@Nullable type use annotations in error messages
See #1499 (comment). This should make our error messages more consistent and less confusing. We now only include
@Nullabletype use annotations.Eventually, we may want to adopt JSpecify shorthand when printing types, but we'd have to think more carefully about that.
Summary by CodeRabbit
Refactor
Tests