Skip to content

ctf: fix struct member duplicating issue#408

Open
arfio wants to merge 1 commit into
eclipse-tracecompass:masterfrom
arfio:ctf2-error-struct
Open

ctf: fix struct member duplicating issue#408
arfio wants to merge 1 commit into
eclipse-tracecompass:masterfrom
arfio:ctf2-error-struct

Conversation

@arfio
Copy link
Copy Markdown
Contributor

@arfio arfio commented Jun 4, 2026

What it does

Constructing the member field only as the constructor already adds the member to its parent. Previously the struct member was added twice causing an error. Fixes #375

How to test

Opening the trace that it provided in the issue.

Follow-ups

N/A

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Summary by CodeRabbit

  • Refactor
    • Simplified internal metadata parsing logic by streamlining the creation and attachment of structural elements during JSON processing.

Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The PR refactors StructParser.parse to construct JsonStructureFieldMemberMetadataNode instances directly during JSON memberClasses parsing. The constructor now automatically attaches the node to its parent, eliminating the previous pattern of creating a local variable and calling memberNode.addChild(...) explicitly.

Changes

Node instantiation refactoring

Layer / File(s) Summary
Member node constructor attachment
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/tsdl/struct/StructParser.java
During JSON memberClasses iteration, JsonStructureFieldMemberMetadataNode is instantiated inline with the constructor automatically attaching to parent, replacing the intermediate local variable and explicit addChild() call pattern.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Suggested reviewers

  • MatthewKhouzam

Poem

🐰 A node now builds and holds its place,
No extra hands to set its space—
The constructor binds with grace,
Two lines removed, cleaner trace!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a struct member duplication issue by removing redundant child addition logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@arfio arfio changed the title ctf: fix issue #375 ctf: fix struct member duplicating issue Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CTF2 metadata seems to read the same json node twice

1 participant