Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spoon and Nullable #5320

Open
MartinWitt opened this issue Jul 1, 2023 · 8 comments
Open

Spoon and Nullable #5320

MartinWitt opened this issue Jul 1, 2023 · 8 comments

Comments

@MartinWitt
Copy link
Collaborator

Currently, spoon has non @Nullable annotation and we only document nullablility in the Javadoc. Why don't we adopt https://jspecify.dev/docs/start-here and migrate over the time to an annotated library? An alternative is @Contract from JB, but these are only supported in IJ and are way harder to write.

@tenax66
Copy link
Contributor

tenax66 commented Jul 6, 2023

I am interested in this proposal.
If we adopt jspecify, should we start working with version 0.3 instead of waiting for version 1.0?

@MartinWitt
Copy link
Collaborator Author

MartinWitt commented Jul 7, 2023

We start with 0.3 and can update it later. The goal is to start annotating spoon and waiting for the 1.0 release can take years. A good starting point are methods with null documented in their javadoc for return values.

@MartinWitt
Copy link
Collaborator Author

MartinWitt commented Jul 7, 2023

A noteworthy alternative is using https://www.jetbrains.com/help/idea/annotating-source-code.html. These annotations are at least stable and do the same. But there could be some future where everyone uses jspecify. And the qodana rule for this is: NullableProblems.

@tenax66
Copy link
Contributor

tenax66 commented Jul 9, 2023

A good starting point are methods with null documented in their javadoc for return values.

I will see what I can do about this.

@tenax66
Copy link
Contributor

tenax66 commented Jul 26, 2023

I looked for the word "null" in @return tags in Javadoc of the spoon-core code.
Here are the counts for each package.
We may be able to start from these.

package count
spoon 1
spoon.compiler 1
spoon.metamodel 3
spoon.pattern.internal 2
spoon.pattern.internal.matcher 3
spoon.pattern.internal.node 1
spoon.pattern.internal.parameter 2
spoon.reflect.code 3
spoon.reflect.declaration 12
spoon.reflect.factory 7
spoon.reflect.path 1
spoon.reflect.reference 8
spoon.reflect.visitor 5
spoon.support.compiler 1
spoon.support.compiler.jdt 4
spoon.support.modelobs 1
spoon.support.reflect.eval 1
spoon.support.reflect.reference 1
spoon.support.sniper.internal 3
spoon.support.util 2
spoon.support.util.internal 1
spoon.support.visitor 3
spoon.support.visitor.java 2

@MartinWitt
Copy link
Collaborator Author

Yes, this is a good starting point. 👍

@tenax66
Copy link
Contributor

tenax66 commented Aug 13, 2023

Create a task list to add @Nullable annotations to the classes under each package.

  • spoon
  • spoon.compiler
  • spoon.metamodel
  • spoon.pattern.internal
  • spoon.pattern.internal.matcher
  • spoon.pattern.internal.node
  • spoon.pattern.internal.parameter
  • spoon.reflect.code
  • spoon.reflect.declaration
  • spoon.reflect.factory
  • spoon.reflect.path
  • spoon.reflect.reference
  • spoon.reflect.visitor
  • spoon.support.compiler
  • spoon.support.compiler.jdt
  • spoon.support.modelobs
  • spoon.support.reflect.eval
  • spoon.support.reflect.reference
  • spoon.support.sniper.internal
  • spoon.support.util
  • spoon.support.util.internal
  • spoon.support.visitor
  • spoon.support.visitor.java

@tenax66
Copy link
Contributor

tenax66 commented Sep 20, 2023

As I mentioned in #5424 , JavaReflectionTreeBuilderTest fails when @Nullable is applied to classes under some specific packages. (like spoon.reflect.code, spoon.reflect.declaration).

Can we remove @Nullable and @NonNull from the target of the test? Since these are TYPE_USE annotations, so JavaReflectionTreeBuilder does not build them.

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

No branches or pull requests

2 participants