JavaDoc for abstract properties (i.e. no backing field that has the same name as the property)

Answered

The org.hl7.fhir.core project contains many javadoc comments for abstract properties, like for example in CanonicalResource.java. In other words, there are only (abstract) getter and setter functions but no backing field with the property name; the property is only implied by the names of the getters and setters. I.e. there's a `getFoo()` and a `setFoo()` and the javadoc contains '{@link #foo}'.

This usage is not listed in the only decent JavaDoc documentation that I could find, which is for Java 5 (see `package.class#member`).

I have no idea what tool they're using, but IntelliJ does not like these doc comments at all and the only way to work with the code base in question is to disable the inspection. This is somewhat unfortunate because I was considering to contribute code and fixes to the project.

In this forum I found an old topic that regards the same problem (Spring support: properties marked red in abstract beans), but that is from the year 2007. Have things improved in the meantime? Is there some secret setting in IntelliJ that simply needs to be activated?

 

0
3 comments

Hello Darthgizka. Could you please share a screenshot of the problem you met and specify which IDE version you use? On my side, there are no problems with the comments in the file you mentioned in IntelliJIDEA 2023.1.2. 

0

Here's a typical section in the in the source file that I linked:

And here's a minimal reproducible example, without any external dependencies (least of all a monster ball of 16000+ java files):

0

 Darthgizka, thank you for the screenshot. After cloning the full repository, I was able to reproduce the problem on my side. Looks like these Javadoc comments don't meet the standard, and the inspection works correctly in this case. 

Could you please explain why disabling the inspection doesn't suit you? To get rid of these errors, you need to disable only the  Java | Javadoc | Declaration has problems in Javadoc reference  inspection in  Settings | Editor | Inspections:

 

Alternatively, you could fix these comments, for example, by deleting the  @link  tag. Regrettably, the automatically applied fix deletes tags with element names, so it could be better to use the  Edit  | Find | Replace in Files...  feature to replace the  {@link #url}  and other similar tags with just  url, etc.

0

Please sign in to leave a comment.