Conversation
Reviewer's GuideIntegrate rowan-based parsing by adding necessary dependencies, defining a comprehensive SyntaxKind enum, implementing the DdlogLanguage wrapper for rowan’s Language trait, and exposing the language module in lib.rs. Class diagram for SyntaxKind enum and DdlogLanguage wrapperclassDiagram
class SyntaxKind {
<<enum>>
+T_COMMENT
+T_WHITESPACE
+T_IDENT
+T_STRING
+T_NUMBER
+T_LPAREN
+T_RPAREN
+T_LBRACE
+T_RBRACE
+T_LBRACKET
+T_RBRACKET
+T_SEMI
+T_COMMA
+T_DOT
+T_COLON
+T_COLON_COLON
+T_PIPE
+T_AMP
+T_EQEQ
+T_EQ
+T_IMPLIES
+T_PERCENT
+T_STAR
+T_SLASH
+T_PLUS
+T_MINUS
+T_ARROW
+T_FAT_ARROW
+T_LTE
+T_SPACESHIP
+T_GTE
+T_LT
+T_GT
+T_NEQ
+T_SHR
+T_SHL
+T_TILDE
+T_AT
+T_HASH
+T_APOSTROPHE
+K_ABSTRACT
+K_AGGREGATE
+K_AND
+K_APPLY
+K_AS
+K_ASYNC
+K_AWAIT
+K_BECOME
+K_BIGINT
+K_BIT
+K_BOOL
+K_BOX
+K_BREAK
+K_CONST
+K_CONTINUE
+K_CRATE
+K_DO
+K_DOUBLE
+K_DYN
+K_ELSE
+K_EXTERN
+K_FALSE
+K_FINAL
+K_FN
+K_FLATMAP
+K_FLOAT
+K_FOR
+K_FUNCTION
+K_IF
+K_IMPL
+K_IMPORT
+K_IN
+K_INPUT
+K_INSPECT
+K_LET
+K_LOOP
+K_MACRO
+K_MATCH
+K_MOD
+K_MOVE
+K_MULTISET
+K_MUT
+K_NOT
+K_OR
+K_OVERRIDE
+K_OUTPUT
+K_PRIV
+K_PUB
+K_REF
+K_RELATION
+K_RETURN
+K_SELF
+K_SELF_TYPE
+K_SIGNED
+K_SKIP
+K_STATIC
+K_STREAM
+K_STRUCT
+K_SUPER
+K_TRAIT
+K_TRANSFORMER
+K_TRY
+K_TRUE
+K_TYPE
+K_TYPEDEF
+K_TYPEOF
+K_UNDERSCORE
+K_UNSAFE
+K_UNSIZED
+K_USE
+K_VAR
+K_VIRTUAL
+K_WHERE
+K_WHILE
+K_YIELD
+N_ATTRIBUTE
+N_FIELD
+N_ARG_TYPE
+N_IDENTIFIER_WITH_POS
+N_TYPE
+N_TYPE_DEF
+N_CONSTRUCTOR
+N_KEY_EXPR
+N_RELATION_ROLE
+N_RELATION_SEMANTICS
+N_RELATION
+N_INDEX
+N_DELAY
+N_ATOM
+N_RULE_LHS
+N_RULE_RHS
+N_RULE
+N_EXPR_NODE
+N_CLOSURE_EXPR_ARG
+N_FUNC_ARG
+N_FUNCTION
+N_MODULE_NAME
+N_HO_TYPE
+N_HO_FIELD
+N_TRANSFORMER
+N_APPLY
+N_IMPORT
+N_DATALOG_PROGRAM
+N_ERROR
}
class DdlogLanguage {
+kind_from_raw(raw: RowanSyntaxKind) SyntaxKind
+kind_to_raw(kind: SyntaxKind) RowanSyntaxKind
}
DdlogLanguage ..> SyntaxKind : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Rate limit exceeded@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 1 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
WalkthroughA new library crate for ddlint has been created, introducing a Changes
Poem
✨ Finishing Touches
🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
Cargo.toml(1 hunks)src/language.rs(1 hunks)src/lib.rs(1 hunks)
🔇 Additional comments (2)
Cargo.toml (1)
4-4:edition = "2024"ties the crate to nightly; confirm this is intentional
The 2024 edition is currently only available on nightly toolchains. This will break builds for contributors or CI pipelines that default to stable Rust.
Consider sticking to2021until 2024 is stabilised, or document the nightly requirement inREADME.md/CI config.src/language.rs (1)
14-18:#[expect(..., reason = "...")]is still a nightly-only feature
Thereasonfield behindlint_reasonsrequires nightly (mirroring the 2024 edition choice). Make sure CI uses nightly and that downstream crates are aware of this requirement.
| fn kind_from_raw(raw: RowanSyntaxKind) -> Self::Kind { | ||
| SyntaxKind::from_u16(raw.0).unwrap_or(SyntaxKind::N_ERROR) | ||
| } | ||
|
|
||
| fn kind_to_raw(kind: Self::Kind) -> RowanSyntaxKind { | ||
| RowanSyntaxKind(kind.to_u16().unwrap_or(SyntaxKind::N_ERROR as u16)) | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
unwrap_or branch is unreachable; prefer explicit expect for clarity
to_u16() is infallible for an enum with #[repr(u16)]. Using unwrap_or hides logic errors. Consider:
-RowanSyntaxKind(kind.to_u16().unwrap_or(SyntaxKind::N_ERROR as u16))
+RowanSyntaxKind(kind.to_u16().expect("all SyntaxKind variants map to u16"))This makes accidental future misuse obvious in debug builds.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| fn kind_from_raw(raw: RowanSyntaxKind) -> Self::Kind { | |
| SyntaxKind::from_u16(raw.0).unwrap_or(SyntaxKind::N_ERROR) | |
| } | |
| fn kind_to_raw(kind: Self::Kind) -> RowanSyntaxKind { | |
| RowanSyntaxKind(kind.to_u16().unwrap_or(SyntaxKind::N_ERROR as u16)) | |
| } | |
| fn kind_from_raw(raw: RowanSyntaxKind) -> Self::Kind { | |
| SyntaxKind::from_u16(raw.0).unwrap_or(SyntaxKind::N_ERROR) | |
| } | |
| fn kind_to_raw(kind: Self::Kind) -> RowanSyntaxKind { | |
| RowanSyntaxKind(kind.to_u16().expect("all SyntaxKind variants map to u16")) | |
| } |
🤖 Prompt for AI Agents
In src/language.rs around lines 176 to 182, replace the use of unwrap_or in
kind_to_raw with an explicit expect call, since to_u16() is infallible for the
enum and the unwrap_or branch is unreachable. This change will make any
accidental misuse clear by panicking with a descriptive message instead of
silently defaulting.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@sourcery-ai review |
Summary
rowan,num-deriveandnum-traitsdependenciesSyntaxKindenum for tokens and nodesDdlogLanguageforrowanintegrationTesting
make fmtmake lintmake testmake markdownlinthttps://chatgpt.com/codex/tasks/task_e_6859ff4be70083229090af09148752b3
Summary by Sourcery
Add rowan-based syntax tree support by defining a comprehensive SyntaxKind enum for DDlog tokens and nodes, wrapping it in a DdlogLanguage type that implements rowan::Language, and expose these in the library crate.
New Features:
Enhancements:
Build:
Summary by CodeRabbit