Add CommentAttachment/ExpressionStatement types and comment fields to AST (BT-973)#1008
Add CommentAttachment/ExpressionStatement types and comment fields to AST (BT-973)#1008
Conversation
…lds to AST (BT-973) Phase 1 of ADR 0044 - Comments as First-Class AST Nodes. - Add `CommentAttachment` struct with `leading: Vec<Comment>` and `trailing: Option<Comment>` fields, `is_empty()` method, and `#[derive(Default)]` - Add `ExpressionStatement` struct with `comments: CommentAttachment` and `expression: Expression` fields, plus `bare(expr)` constructor - Add `comments: CommentAttachment` field to `ClassDefinition` and `MethodDefinition`; update all construction sites - Add `comments: CommentAttachment` and `doc_comment: Option<String>` to `StateDeclaration`; update all construction sites - Update parser/declarations.rs StateDeclaration struct literals - Update snapshot tests to include new default-empty comment fields - Add unit tests for CommentAttachment and ExpressionStatement Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…comment, and additional tests (BT-973) From code review: - Add Comment::line() and Comment::block() constructors to reduce struct literal fragility - Document StateDeclaration.doc_comment as always None until BT-975 - Add test for CommentAttachment with both leading AND trailing - Add test for Comment constructors Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds comment-support to the AST: new Changes
Sequence Diagram(s)sequenceDiagram
participant Parser
participant AST
participant SemanticAnalyzer
participant Codegen
Parser->>AST: parse source (produce nodes + comments)
Note right of AST: nodes include CommentAttachment\nand doc_comment fields
AST->>SemanticAnalyzer: provide annotated AST
SemanticAnalyzer->>Codegen: emit analysis-ready structures
Codegen->>Codegen: use comments/doc_comment where needed (tests/codegen)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/beamtalk-core/src/ast.rs`:
- Around line 214-218: The doc comment for ExpressionStatement overstates
adoption—update the comment text around the ExpressionStatement doc (the block
starting with "An expression in a statement position...") to avoid claiming that
method bodies, block bodies, and module-level expression sequences use
Vec<ExpressionStatement>; instead phrase it neutrally (e.g., note that
ExpressionStatement represents an expression with optional surrounding comments
and that some APIs or consumers may use Vec<ExpressionStatement> even though the
current fields remain Vec<Expression>) so consumers aren't misled; keep
references to ExpressionStatement and Expression to make intent clear.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (20)
test-package-compiler/tests/snapshots/compiler_tests__abstract_class_spawn_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__class_definition_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__class_methods_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__empty_method_body_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__error_message_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__intrinsic_keyword_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__method_lookup_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__sealed_class_violation_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__sealed_method_override_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__stdlib_class_dictionary_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__stdlib_class_list_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__stdlib_class_set_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__stdlib_class_tuple_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__typed_class_warnings_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__typed_methods_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__typed_value_type_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__value_type_multi_expr_method_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__value_type_param_collision_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__workspace_binding_cascade_parser.snapis excluded by!**/*.snaptest-package-compiler/tests/snapshots/compiler_tests__workspace_binding_send_parser.snapis excluded by!**/*.snap
📒 Files selected for processing (6)
crates/beamtalk-core/src/ast.rscrates/beamtalk-core/src/codegen/core_erlang/tests.rscrates/beamtalk-core/src/semantic_analysis/class_hierarchy/mod.rscrates/beamtalk-core/src/semantic_analysis/mod.rscrates/beamtalk-core/src/semantic_analysis/type_checker.rscrates/beamtalk-core/src/source_analysis/parser/declarations.rs
…-973 Address CodeRabbit review: doc comment overstated adoption since statement-position fields haven't migrated to Vec<ExpressionStatement> yet. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Phase 1 of ADR 0044 (Comments as First-Class AST Nodes), issue 1 of 6.
Adds the comment-carrying types and fields to
ast.rs. Purely additive — no existing behavior changes, all downstream consumers continue to work unchanged.Linear: https://linear.app/beamtalk/issue/BT-973
Key Changes
CommentAttachment(leading/trailing comments) andExpressionStatement(expression + comments wrapper)ClassDefinition,MethodDefinition, andStateDeclarationgaincomments: CommentAttachmentfielddoc_comment: Option<String>(alwaysNoneuntil parser support in BT-975)Comment::line(),Comment::block(),ExpressionStatement::bare()Test plan
CommentAttachment(default, leading, trailing, combined)ExpressionStatement(bare constructor, with comments)Commentconstructorsjust cipasses (build, clippy, fmt, test, test-stdlib, test-e2e)🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
New Features
Tests