AdvancedExpressionFolding icon indicating copy to clipboard operation
AdvancedExpressionFolding copied to clipboard

Fold the @Nullable and @NotNull annotations

Open ddimtirov opened this issue 8 years ago • 7 comments

For example:

  • fold @Nullable Foo to Foo?
  • fold @NotNull Foo to Foo!
  • fold @NotNull Map<@NotNull String, @Nullable Object> to Map!<String!, Object?>

In addition to the Jetbrains annotations, support all nullability annotations that are supported by IDEA (i.e. Findbugs, Checker Framework, etc).

ddimtirov avatar Mar 08 '17 00:03 ddimtirov

"Foo!" may be confusing as such syntax is not used in any language...

cheptsov avatar Mar 09 '17 19:03 cheptsov

In Kotlin, Foo! means platform type, i.e. the compiler doesn't known whether it's nullable or not. Kotlin has the !! operator that asserts that a value is not null. Maybe it would be better to use its syntax.

cypressious avatar Mar 28 '17 13:03 cypressious

Perhaps use the double exclamation mark glyph (U+203C)? It takes slightly less space than !!

https://en.wikipedia.org/wiki/!!

ddimtirov avatar Mar 28 '17 13:03 ddimtirov

I think it would be better to use what is "valid" code (at least in one language), and use a font like FiraCode if you want to collapse !! to . I also think it would be better to not use any suffix at all on @NotNull, as normal rules assume any unannotated field is @NotNull by default. The only place where you might need to differentiate is a @NotNull method/parameter overriding a @Nullable method/parameter. I also think folding @Nullable would be confusing given Foo? already has a well-defined meaning.

petteyg avatar May 04 '17 16:05 petteyg

Do you think it's worth to also highlight nullable with special foreground/background different from non-nullable?

cheptsov avatar May 10 '17 12:05 cheptsov

Highlighting might actually be nice. My first thought would be fold away @NonNull and apply the "bold underscored" effect, and "dotted line" effect for @Nullable. Not immediately sure what colors on those underline effects would be most appropriate though, given they might need to be different for Darcula and light color schemes.

If implemented, pulling the same annotations from "@NotNull/@Nullable problems" inspection would be nice.

petteyg avatar Jun 22 '17 20:06 petteyg

As someone who made a color scheme, please allow modification if you use special highlighting

On Fri, Jun 23, 2017, 5:33 AM Gordon [email protected] wrote:

Highlighting might actually be nice. My first thought would be fold away @nonnull https://github.com/nonnull and apply the "bold underscored" effect, and "dotted line" effect for @nullable https://github.com/nullable. Not immediately sure what colors on those underline effects would be most appropriate though, given they might need to be different for Darcula and light color schemes.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cheptsov/AdvancedExpressionFolding/issues/26#issuecomment-310494753, or mute the thread https://github.com/notifications/unsubscribe-auth/AITcNXGQWJVeFMtcdEMNTNN2_DZwOJ60ks5sGs-sgaJpZM4MWOk7 .

ciscorucinski avatar Jun 23 '17 01:06 ciscorucinski