Skip to content

Instantly share code, notes, and snippets.

@motlin
Last active February 24, 2022 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motlin/296ea90d642a1336cb05901968218183 to your computer and use it in GitHub Desktop.
Save motlin/296ea90d642a1336cb05901968218183 to your computer and use it in GitHub Desktop.
IntelliJ's @flow

IntelliJ's @Flow

IntelliJ's implementation of external annotations is excellent. They put @NotNull annotations on JDK methods and warn on violations.

image

When browsing the JDK code, these annotations appear grayed out, but embedded in the code.

image

IntelliJ has @Flow annotations that seem to be for tracking elements going in/out of collections.

image

Separate from annotations, IntelliJ's flow analysis is so good that it's often able to identify constant conditions in my code.

image

Putting this all together, I would expect that IntelliJ would be able to figure out that for collections where I never put null in, I'll never get null out. Yet that doesn't seem to happen.

image

Since IntelliJ doesn't already support some features I'd expect, I'm wondering if the kinds of warnings I'd want to see from tools are feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment