RFR: 8341907: javac -Xlint should ignore /// on first line of source file [v2]
Jonathan Gibbons
jjg at openjdk.org
Thu Nov 7 19:47:42 UTC 2024
On Thu, 7 Nov 2024 18:24:53 GMT, Pavel Rappo <prappo at openjdk.org> wrote:
>>> 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?
Computing line numbers is a relatively expensive operation, because the internal coordinates are character-offset based. That being said, there is a bunch of caching going on under the covers, and, the check can be guarded by the additional (proposed) check that the check is only suppressed if the comment begins at offset 0.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21923#discussion_r1833257972
More information about the compiler-dev
mailing list