Repository navigation
fix(hover): keep a declaration's trailing comment out of the method header - #868
Merged
msarson merged 1 commit intoNov 25, 2026
Conversation
…eader
The method hover header ("Class Method · Owner returns `TYPE`") reads the
return type and attributes from the declaration as written, comment and
all. parseMethodModifiers split it on commas, so "),LONG !a, b" showed
returns `LONG !a`, a method with no return type showed its comment as
the return type, and ",DERIVED !note" lost "Derived". The trailing
comment is now stripped first (DeclaredValueParser.stripTrailingComment,
which skips a ! inside a string literal). The snippet below the header
still quotes the full line.
HoverFormatter.MethodHeaderComment.test: 5 tests, 4 fail without the fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happened
The hover card for a class method shows the wrong header line (the card's first line: name, kind, class and return type) when the method's declaration has a trailing
!comment. The comment leaks into that line. The declaration quoted below the header is fine.Given this class:
hovering
Count(at its declaration, its implementation headerSomeClass.Count PROCEDUREor a callobj.Count(1)) shows this card:The first line should end at
returns LONG. The comment is cut at its first comma, because the header is built by splitting the declaration on commas.The header line of each member's card:
Count**Count** — Class Method · SomeClass returns ``LONG !Rows found` ``Upper**Upper** — Class Method · SomeClass returns ``!Upper-cases pText (in place)` ``Reset**Reset** — Class Method · SomeClass returns ``LONG` `` (not "Derived")The comment shows up as part of the return type, cut at its first comma; a method with no return type shows the comment as one; and an attribute right before the comment is lost.
Why
HoverFormatter.parseMethodModifierstakes everything after the parameter list, splits it on commas and treats the first token it does not know as the return type:With a comment on the line,
),LONG !Rows found, or -1 when closedsplits intoLONG !Rows foundandor -1 when closed, and,DERIVED !Parent first, then RefreshgivesDERIVED !Parent first, which is notDERIVED.The change
The comment is stripped before anything is read, with the existing
DeclaredValueParser.stripTrailingComment(it skips a!inside a string literal, soPROCEDURE(STRING pSep='!')keeps its parameter list):It runs before the parameter-list scan, so a
(in a comment is never taken for the parameter list of a declaration that has none. All three callers ofbuildMethodHeader(formatClassMember,formatMethodCallandformatMethodImplementation) go through it.Count**Count** — Class Method · SomeClass returns ``LONG` ``Upper**Upper** — Class Method · SomeClassReset**Reset** — Derived Class Method · SomeClass returns ``LONG` ``The declaration snippet under the header is unchanged: it quotes the line, comment and all, which is where the comment belongs. The
Countcard is now:Testing
server/src/test/HoverFormatter.MethodHeaderComment.test.ts, 5 tests: a comment with a comma after the return type, a comment and no return type,DERIVEDbefore a comment, a!inside a string-literal default, and a declaration with no comment (the header must be unchanged).🤖 Generated with Claude Code