RFR: 8341907: javac -Xlint should ignore /// on first line of source file [v2]

Pavel Rappo prappo at openjdk.org
Thu Nov 7 18:27:45 UTC 2024


On Thu, 7 Nov 2024 00:09:08 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> I admit, I thought about it initially, but couldn't quickly come up with a simple and robust way to figure out if a comment tree spans a single line. I'm not yet comfortable working with compiler coordinate system (incl. source positions). If you propose such a way, I'd happily incorporate it.
>
>>  If you propose such a way, I'd happily incorporate it.
> 
> Does the content of the comment (`c.getText()`) contain a newline character that is not at the end of the content?  Maybe something like 
>   `c.getText().matches("(?s)\\R.")` 
> although there may be more effective ways to do that.

Regex sounds simple and robust. However, I thought we could concoct a more idiomatic compiler solution, using trees, start and end diagnostic positions, and also line numbers.

So, if a comment tree start and end position are on the same line that is also the first line of the file, we don't output the warning. Can we do that?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21923#discussion_r1833166696


More information about the compiler-dev mailing list