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

Pavel Rappo prappo at openjdk.org
Fri Nov 8 12:23:22 UTC 2024


On Thu, 7 Nov 2024 20:15:05 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> Generally, the method you want is `DiagnosticSource.getLineNumber(int pos)`, which means you need a `DiagnosticSource` object.   `JavacParser` (that is, this class) has a `Log log` member, and `[Abstract]Log` provides `currentSource()`, so to get the line number for a position it should be possible to use something like `log.currentSource().getLineNumber(pos)`, assuming that the current source is set up correctly at the time you need it.
>
>> So, if a comment tree start and end position are on the same line that is also the first line of the file
> 
> The end position will always be after the start position, so you only need check if the line number of the end position of the comment is line 1. (Line numbers are 1-based.)

Jon, please have a look at the updated version and approve if it is to your liking; thanks.

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

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


More information about the compiler-dev mailing list