Integrated: 8350212: Track source end positions of declarations that support @SuppressWarnings

Archie Cobbs acobbs at openjdk.org
Thu Jun 5 21:59:59 UTC 2025


On Tue, 18 Feb 2025 02:39:37 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

> This PR is a sub-task split off from [JDK-8224228](https://bugs.openjdk.org/browse/JDK-8224228), which seeks to add `@SuppressWarnings` support for lexical features.
> 
> Lexical features don't know about classes, members or symbols, so their source file positions must be matched to the source file character offset range of the innermost containing `JCModuleDecl`, `JCPackageDecl`, `JCClassDecl`, `JCMethodDecl`, or `JCVariableDecl`. That means we need the end positions of all such declarations to be available.
> 
> The parser doesn't normally store lexical end positions unless explicitly requested, and we don't want to mandate it for performance reasons.
> 
> Instead, we can just add an `int endPos` field to these five AST nodes. This field can be populated as part of the normal parsing of these node types, which already supports the (optional) tracking of end positions.

This pull request has now been integrated.

Changeset: c793de98
Author:    Archie Cobbs <acobbs at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/c793de989facdb532021e1d5ddd01eb0e089b8e6
Stats:     336 lines in 11 files changed: 176 ins; 84 del; 76 mod

8350212: Track source end positions of declarations that support @SuppressWarnings

Co-authored-by: Jan Lahoda <jlahoda at openjdk.org>
Reviewed-by: mcimadamore

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

PR: https://git.openjdk.org/jdk/pull/23669


More information about the compiler-dev mailing list