Skip to content

feat(tdl): Add a super header to import all AST nodes and hide the implementation namespace. - #202

Merged
LinZhihao-723 merged 1 commit into
y-scope:mainfrom
LinZhihao-723:super-node-header
Aug 20, 2025
Merged

feat(tdl): Add a super header to import all AST nodes and hide the implementation namespace.#202
LinZhihao-723 merged 1 commit into
y-scope:mainfrom
LinZhihao-723:super-node-header

Conversation

@LinZhihao-723

@LinZhihao-723 LinZhihao-723 commented Aug 20, 2025

Copy link
Copy Markdown
Member

Description

As planned to use Antlr's actions to embed AST generation in the generated Antlr parser, this PR adds a super header that includes all AST nodes and hides implementation namespaces. Doing this has two benefits:

  • For Antlr, it only needs to include this super header to use all AST nodes.
  • We can use the derived node types without knowing the namespace prefix for implementation.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • Ensure all workflows pass.

Summary by CodeRabbit

  • New Features
    • Introduced a consolidated public header that aggregates all AST node types, providing a single, stable entry point for consuming the parser’s type definitions.
    • Exposes commonly used node and type aliases under a consistent namespace for simpler imports and improved discoverability.
    • No runtime behaviour changes; this is an API surface enhancement for easier integration.

@coderabbitai

coderabbitai Bot commented Aug 20, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a new public aggregate header tdl/parser/ast/nodes.hpp that re-exports AST node types via type aliases, and updates src/spider/CMakeLists.txt to include this header in SPIDER_TDL_SHARED_HEADERS. No source or runtime control-flow changes.

Changes

Cohort / File(s) Summary
Build configuration update
src/spider/CMakeLists.txt
Added tdl/parser/ast/nodes.hpp to SPIDER_TDL_SHARED_HEADERS, exposing it in the spider_tdl public interface.
Public AST aggregate header
src/spider/tdl/parser/ast/nodes.hpp
New header aggregating AST node types; re-exports internal implementations via type aliases: Function, Identifier, NamedVar, Namespace, StructSpec, Type, Container, Primitive, Struct, List, Map, Tuple, Int, Float, Bool. Includes IWYU pragmas and header guard.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • sitaowang1998

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@LinZhihao-723
LinZhihao-723 marked this pull request as ready for review August 20, 2025 19:14
@LinZhihao-723
LinZhihao-723 requested review from a team and sitaowang1998 as code owners August 20, 2025 19:14

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/spider/tdl/parser/ast/nodes.hpp (2)

7-22: Re-export all includes for IWYU so consumers aren’t nudged to include node_impl headers directly.

Currently only FloatSpec/IntSpec/Node are inside IWYU begin_exports. If clients include this super header and use, e.g., Function or List, IWYU may suggest including internal node_impl headers, which undermines the “single include” goal. Wrap all of these includes in the export block (or add per-include // IWYU pragma: export).

Apply this diff:

-#include <spider/tdl/parser/ast/node_impl/Function.hpp>
+// IWYU pragma: begin_exports
+#include <spider/tdl/parser/ast/node_impl/Function.hpp>
 #include <spider/tdl/parser/ast/node_impl/Identifier.hpp>
 #include <spider/tdl/parser/ast/node_impl/NamedVar.hpp>
 #include <spider/tdl/parser/ast/node_impl/Namespace.hpp>
 #include <spider/tdl/parser/ast/node_impl/StructSpec.hpp>
 #include <spider/tdl/parser/ast/node_impl/Type.hpp>
 #include <spider/tdl/parser/ast/node_impl/type_impl/Container.hpp>
 #include <spider/tdl/parser/ast/node_impl/type_impl/container_impl/List.hpp>
 #include <spider/tdl/parser/ast/node_impl/type_impl/container_impl/Map.hpp>
 #include <spider/tdl/parser/ast/node_impl/type_impl/container_impl/Tuple.hpp>
 #include <spider/tdl/parser/ast/node_impl/type_impl/Primitive.hpp>
 #include <spider/tdl/parser/ast/node_impl/type_impl/primitive_impl/Bool.hpp>
 #include <spider/tdl/parser/ast/node_impl/type_impl/primitive_impl/Float.hpp>
 #include <spider/tdl/parser/ast/node_impl/type_impl/primitive_impl/Int.hpp>
 #include <spider/tdl/parser/ast/node_impl/type_impl/Struct.hpp>
-
-// IWYU pragma: begin_exports
 #include <spider/tdl/parser/ast/FloatSpec.hpp>
 #include <spider/tdl/parser/ast/IntSpec.hpp>
 #include <spider/tdl/parser/ast/Node.hpp>
-
-// IWYU pragma: end_exports
+// IWYU pragma: end_exports

Alternative: keep the current layout but add “// IWYU pragma: export” after each include that you intend to re-export.

Also applies to: 23-29


30-46: Type alias façade reads clean and achieves the namespace-hiding goal.

The alias set is coherent and keeps consumer code in spider::tdl::parser::ast. Consider a brief comment grouping (primitives/containers/nodes) for scanability, but this is optional.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 605fb29 and 69054a0.

📒 Files selected for processing (2)
  • src/spider/CMakeLists.txt (1 hunks)
  • src/spider/tdl/parser/ast/nodes.hpp (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: non-storage-unit-tests (ubuntu-24.04)
  • GitHub Check: non-storage-unit-tests (ubuntu-22.04)
  • GitHub Check: lint
🔇 Additional comments (1)
src/spider/tdl/parser/ast/nodes.hpp (1)

1-6: Header guard and intent doc look good.

Guard is conventional and the file’s purpose is clear.

Comment thread src/spider/CMakeLists.txt
@LinZhihao-723
LinZhihao-723 merged commit 024ed13 into y-scope:main Aug 20, 2025
7 checks passed
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.

2 participants