<!DOCTYPE html><html><head><title></title></head><body><div><br></div><div><br></div><div>On Wed, Dec 3, 2025, at 11:56 AM, Jonathan Gibbons wrote:</div><blockquote type="cite" id="qt" style=""><div><br></div><div><br></div><div>On Wed, Dec 3, 2025, at 11:13 AM, Maurizio Cimadamore wrote:</div><blockquote type="cite" id="qt-qt" style="">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?</blockquote><div><br></div><div>Doesn't the endPos records the position of the semicolon, not the end of the keyword?</div><div><br></div><div>-- Jon</div></blockquote><div><br></div><div>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.</div><div><br></div><div>For example, compare this from `visitLambda`<br><br></div><pre style="border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(204, 204, 204);border-right-color:rgb(204, 204, 204);border-bottom-color:rgb(204, 204, 204);border-left-color:rgb(204, 204, 204);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-image:initial;background-position-x:initial;background-position-y:initial;background-size:initial;background-repeat:initial;background-attachment:initial;background-origin:initial;background-clip:initial;background-color:rgb(246, 246, 246);font-family:menlo, consolas, monospace;font-size:90%;margin-top:7px;margin-right:0px;margin-bottom:7px;margin-left:0px;padding-top:7px;padding-right:10px;padding-bottom:7px;padding-left:10px;white-space-collapse:preserve;text-wrap-mode:wrap;overflow-wrap:break-word;"><br>    printExpr(<span class="color" style="color:rgb(0, 0, 0);">tree</span>.<span class="color" style="color:rgb(135, 16, 148);">body</span>);<br>} <span class="color" style="color:rgb(0, 51, 179);">catch </span>(<span class="color" style="color:rgb(0, 0, 0);">IOException e</span>) {</pre><div><br></div><div>and this from `visitParens`<br><br></div><pre style="border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(204, 204, 204);border-right-color:rgb(204, 204, 204);border-bottom-color:rgb(204, 204, 204);border-left-color:rgb(204, 204, 204);border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-image:initial;background-position-x:initial;background-position-y:initial;background-size:initial;background-repeat:initial;background-attachment:initial;background-origin:initial;background-clip:initial;background-color:rgb(246, 246, 246);font-family:menlo, consolas, monospace;font-size:90%;margin-top:7px;margin-right:0px;margin-bottom:7px;margin-left:0px;padding-top:7px;padding-right:10px;padding-bottom:7px;padding-left:10px;white-space-collapse:preserve;text-wrap-mode:wrap;overflow-wrap:break-word;"><br>    print(<span class="color" style="color:rgb(6, 125, 23);">')'</span>);<br>} <span class="color" style="color:rgb(0, 51, 179);">catch </span>(<span class="color" style="color:rgb(0, 0, 0);">IOException e</span>) {</pre><div><br></div></body></html>