mirror of
https://github.com/logos-co/logos-cpp-sdk.git
synced 2026-08-31 01:31:10 +00:00
* fix: parse declarations on same line as logos_events/access specifier (#76) The impl header parser updated its section state and immediately broke out of line processing when it matched `logos_events:` (or `public:`/`private:`), discarding any declaration on the same physical line. This meant clang-format / prettier output like logos_events : void versionReady(const std::string &version); silently dropped the event, while the newline-separated form parsed fine — the same valid C++ was handled differently based on formatting. Strip any leading section specifiers in a loop, updating the section state, then let the remainder of the line fall through to the declaration parser. Brace counting still happens once per physical line and blank-line doc-comment reset is preserved. Adds a regression test (SameLineSectionSpecifiers) with a fixture covering the exact prettier form from the issue, a follow-on same-line event, the newline form alongside it, and the symmetric inline `public:` method case. Fixes #76 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: attach doc comments to same-line logos_events/access-specifier decls Address review feedback: the first pass cleared pendingDoc on every specifier match, so a `///` comment above a collapsed `logos_events : void foo();` did not attach to the event. In the collapsed form there is nowhere else to put the doc comment, so this left documentation formatting-dependent — the same bug class as #76, one level up. Only clear pendingDoc for a *bare* specifier (a section boundary, matching Qt `signals:` semantics); when a declaration shares the line, keep the pending doc so the declaration parser attaches it. Extend the fixture with a `///`-documented same-line event and assert the description is captured. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
40e7631402
commit
bb6d87b6ec
@@ -322,27 +322,51 @@ ImplParseResult parseImplHeader(const QString& headerPath,
|
||||
}
|
||||
}
|
||||
|
||||
// A section specifier may be followed by a declaration on the
|
||||
// *same* physical line — e.g. clang-format / prettier collapse
|
||||
// logos_events:
|
||||
// void versionReady(const std::string& version);
|
||||
// into `logos_events : void versionReady(const std::string& version);`.
|
||||
// Strip any leading specifiers, updating the section state, and
|
||||
// let whatever remains fall through to the declaration parser
|
||||
// below — otherwise everything after the colon is discarded and
|
||||
// the same valid C++ is parsed differently based on formatting.
|
||||
//
|
||||
// `logos_events:` takes precedence over the standard access
|
||||
// specifiers: it's a separate section that the codegen pulls
|
||||
// event prototypes from. (At preprocess time, `logos_events`
|
||||
// expands to `public`, but the raw source still carries the
|
||||
// token we recognise here.)
|
||||
if (eventsRe.match(line).hasMatch()) {
|
||||
state = InLogosEvents;
|
||||
pendingDoc.clear();
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
bool specifierStripped = false;
|
||||
while (true) {
|
||||
QRegularExpressionMatch em = eventsRe.match(line);
|
||||
if (em.hasMatch()) {
|
||||
state = InLogosEvents;
|
||||
line = line.mid(em.capturedEnd()).trimmed();
|
||||
specifierStripped = true;
|
||||
continue;
|
||||
}
|
||||
QRegularExpressionMatch am = accessRe.match(line);
|
||||
if (am.hasMatch()) {
|
||||
QString spec = am.captured(1);
|
||||
if (spec == "public") state = InPublic;
|
||||
else state = InPrivate;
|
||||
pendingDoc.clear();
|
||||
break;
|
||||
line = line.mid(am.capturedEnd()).trimmed();
|
||||
specifierStripped = true;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// A *bare* specifier (nothing after the colon) is a section
|
||||
// boundary and resets any pending doc-comment, mirroring Qt's
|
||||
// `signals:`. But when a declaration shares the line, the doc
|
||||
// comment preceding the whole line must still attach to that
|
||||
// declaration — otherwise documentation, like the declaration
|
||||
// itself (#76), would become formatting-dependent. So only clear
|
||||
// here for the bare form; the same-line form keeps pendingDoc and
|
||||
// attaches it in the declaration parser below.
|
||||
if (specifierStripped && line.isEmpty())
|
||||
pendingDoc.clear();
|
||||
|
||||
// Only doc comments (/// or /** ... */ / /*! ... */) accumulate as
|
||||
// the pending description for the next method. Plain // and /*
|
||||
|
||||
Reference in New Issue
Block a user