Repository navigation
Mark code in every message with backticks, and name the lines they refer to - #533
CatarinaGamboa wants to merge 3 commits into
Conversation
Headlines, hints, origin notes, the declared-here gloss, alias where lines and counterexamples write code as `code`. Plain-text clients get the backticks, as rustc gives them; the terminal shows code in blue without them, unless NO_COLOR is set or the output is not a terminal. A note or hint that names a line also carries it as a SourceReference (the line, the words naming the place, file, line and column), which LJDiagnostic.getReferences() gives clients to link to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clean-code reviewI audited the diff with the clean-code-principles checklist. Fixed:
Declined:
|
…t found - Code.render strips only the padding Code.of adds around code that starts or ends with a backtick, and reads code across line breaks. - SourceReference gives where its words start in the message, since the code of a call may hold the same words. - Not-found errors and their suggestion mark the name as code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex review, round 1
Soundness prompt. It found three issues:
Fixed in "Keep the spaces of code, name where a reference starts, mark names not found":
Declined:
The study tasks are byte-identical to the previous commit. Tests: 740 run, 0 failures. |
…it exact Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex review, round 2
Soundness prompt. It found no verifier program with code left unmarked, prose marked, or a wrong reference. It reported three direct
Fixed (1) in "Pad code that holds a backtick or ends with a space, so render keeps it exact". Declined (2) and (3). No message builds an empty span or puts two spans side by side without words between them: every template separates its spans with prose or The study tasks are byte-identical. Tests: 740 run, 0 failures. |
Codex review, round 3
Soundness prompt: it found no
Declined for this PR, as a follow-up. #532 lists headlines, hints, origin notes, the gloss and counterexamples, the messages a participant reads when a call or value is wrong. These three report mistakes in the specification itself. They go through This ends the Codex loop for this PR: nothing relevant to #532's scope is left. |
Closes #532. Stacked on #530 (→ #528 →
main). Retarget it tomainbefore #530 is merged with--delete-branch.Every message that shows code now marks it with backticks, inside the message string:
found … but expected …,expected … but could not prove it);where … means …);wherelines;How each client sees it
getMessage(),getMessageNotes(),Hint.message(),getCounterexampleStr(),getDeclarationNotes(), and so the Problems tab and the hover): the string with backticks, as rustc writes its messages.Colors.BLUE), without backticks. The backticks stay when colour is off:NO_COLORset (https://no-color.org) or no console (output piped or redirected). The colour switch applies to code spans only; the CLI's other colours are unchanged.LJDiagnostic.getReferences(), aList<SourceReference>with one entry per line reference. See below.Escaping:
Code.offences code that holds backticks with a longer run, and pads it with one space on each side when it holds a backtick or starts or ends with a space:`` c == '`' ``.Code.renderstrips exactly that padding, so it shows any non-empty code exactly as marked.Source references (for vscode-liquidjava#192)
record SourceReference(String message, String text, int start, String file, int line, int column):message: the whole message line it belongs to, exactly asgetMessageNotes()orHint.message()gives it;text: the words ofmessagethat name the place, e.g.line 134orArrayListRefinements.java:162;start: wheretextstarts inmessage, as a UTF-16 index (a Java/JS string index), somessage.substring(start, start + text.length())istext. Use it instead of searching, because the code of a call can hold the same words (d.lock("line 18")on line 18);file: the absolute path;line,column: 1-based, from Spoon.Who carries one:
… on line 20 decides …), through the newHint.reference(), which is null for other hints.getReferences()returns the notes' references first, then the hints'.Before → after (CLI piped, so backticks shown)
For all eight tasks (six study tasks and both practice tasks), the output with backticks removed is byte-identical to #530's. Each task still gives exactly one error, on its
reportedLine. On a terminal the spans are blue and the backticks are gone. WithNO_COLOR=1the backticks stay.Changes
Code(of,render),SourceReference, andColors.enabled().LJDiagnostic:addMessageNote(SourceReference)andgetReferences();toStringrenders the message, notes, counterexample, hints and declaration notes.ErrorMessage(both headline frames);RefinementError(counterexample, alias lines);AuxStateHandler.addMeanings(gloss);StateHints: each state name, call, receiver and constructor, with the prose wordsor,and,then,withleft unmarked;OriginNotes/StateOrigin, whose notes are nowSourceReferences.NotFoundErrormarks the missing name and the suggestion (Alias `Positiv` could not be found,Did you mean `Positive`?).Tests
TestStateHints.assertHintscompares kind and message.CodeTest(fence, colour on and off);TestOriginNotes.noteNamesTheLineOfTheCallForClientsToLinkTo;mvn test: 740 run, 0 failures.Conflicts
StateHints.java, on main: the hint templates at 116–119, 131–132, 182–184, 234, 239–240, 249, 252, 258, 260, 269, 295–297, 301, 303–305, 349, andstateNameat 387–389;RefinementError.java, on main: 71 (counterexample) and 123 (aliaswherelines);ErrorMessage.java39–41 (headline);AuxStateHandler.java865–866 (gloss).VCChecker.throwStateRefinementError. This PR changes only the notes' parameter type there.🤖 Generated with Claude Code