On Wed, Dec 3, 2025, at 11:56 AM, Jonathan Gibbons wrote:
>
>
> On Wed, Dec 3, 2025, at 11:13 AM, Maurizio Cimadamore wrote:
>> Perhaps with some keywords like `break`, `continue`, ... we might be able to
>> infer the end pos (given it's just start pos + number of chars in the
>> keyword). But not sure how much we are willing to bend the code for special
>> cases like these?
>
> Doesn't the endPos records the position of the semicolon, not the end of the
> keyword?
>
> -- Jon
A useful heuristic is to check the `visit...` methods in `JCPretty`. If there
is a call to `print(String)` or `print(char)` before the `} catch (IOException`
then the node should have an endPos. In other words, an endPos is required for
all nodes that end in a specific lexical token.
For example, compare this from `visitLambda`
printExpr(tree.body);
} catch (IOException e) {
and this from `visitParens`
print(')');
} catch (IOException e) {