Conversation
Reviewer's GuideThis PR adds full support for 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 7 minutes and 12 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 (4)
Summary by CodeRabbit
WalkthroughThis update introduces structured parsing and AST support for import statements in the parser module. The parser now identifies import statements, including those with optional aliases, and represents them as dedicated nodes in the CST and AST. Corresponding methods for extracting import paths and aliases are added, and new tests verify correct parsing and error handling for import statements. Documentation files are also reformatted for clarity. Changes
Sequence Diagram(s)sequenceDiagram
participant SourceFile
participant Parser
participant CST as ConcreteSyntaxTree
participant AST as AbstractSyntaxTree
participant ImportNode
SourceFile->>Parser: Provide source code
Parser->>Parser: Parse tokens, recognise 'import' statements
Parser->>CST: Create N_IMPORT_STMT nodes for imports
Parser->>AST: Create Import struct for each import node
AST->>ImportNode: Provide methods for path and alias extraction
Possibly related PRs
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: 7
🔭 Outside diff range comments (1)
src/parser/mod.rs (1)
104-141: Complex span matching logic needs careful consideration.The logic for matching token spans with import spans is intricate. Consider adding comments to explain the algorithm, particularly:
- Why we need to skip past import spans that have already ended (lines 104-110)
- The relationship between token spans and import spans
- Why we check both start and end boundaries
for (kind, span) in tokens { + // Skip any import spans that have already ended before this token while let Some(next) = import_iter.peek() { if span.start >= next.end { import_iter.next(); } else { break; } } + // Start an import node if this token begins at an import span start if import_iter .peek() .is_some_and(|current| span.start == current.start) { builder.start_node(DdlogLanguage::kind_to_raw(SyntaxKind::N_IMPORT_STMT)); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
docs/building-an-error-recovering-parser-with-chumsky.md(1 hunks)docs/rust-parser-testing-comprehensive-guide.md(1 hunks)src/language.rs(1 hunks)src/parser/mod.rs(4 hunks)tests/parser.rs(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/parser/mod.rs (1)
src/language.rs (1)
kind_to_raw(182-187)
🪛 LanguageTool
docs/building-an-error-recovering-parser-with-chumsky.md
[grammar] ~19-~19: Please add a punctuation mark at the end of paragraph.
Context: ...tc.”) - Examples of legal and illegal programmes ### 2 Feed It Tokens, Not Breadcrumbs ...
(PUNCTUATION_PARAGRAPH_END)
[uncategorized] ~38-~38: Loose punctuation mark.
Context: ...rser. Forward references? Wrap them in recursive(|expr| { … }) so Chumsky can see round corners. Am...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~52-~52: Possible missing comma found.
Context: ...Option`; missing bits propagate but the parse soldier on. In practice y...
(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~53-~53: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ...missing bits propagate but the parse soldier on. In practice you’ll compose the bui...
(AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)
[uncategorized] ~55-~55: A comma is probably missing here.
Context: ...pagate but the parse soldier on. In practice you’ll compose the built-ins (`NestedDe...
(MISSING_COMMA_AFTER_INTRODUCTORY_PHRASE)
[uncategorized] ~60-~60: Possible missing comma found.
Context: ...Tall Neural Net) Codex is a marvellous companion so long as you: - **Constrain its univ...
(AI_HYDRA_LEO_MISSING_COMMA)
[misspelling] ~66-~66: This word is normally spelled as one.
Context: ...** Generate random AST → pretty-print → re-parse → assert equality. Failures mean Code...
(EN_COMPOUNDS_RE_PARSE)
🔇 Additional comments (3)
src/language.rs (1)
165-165: Good naming improvement!The rename from
N_IMPORTtoN_IMPORT_STMTbetter reflects that this represents a complete import statement node in the AST, making the code more self-documenting.tests/parser.rs (1)
91-103: Well-structured test for aliased imports.The test properly validates both the import path and alias extraction.
src/parser/mod.rs (1)
64-97: Well-structured parser combinator implementation.The import parser correctly handles module paths with
::separators and optional aliases. The use ofpadded_byfor whitespace handling is appropriate.
Summary
importstatements with optional aliasesImportnodes from the ASTTesting
make fmtmake lintmake testhttps://chatgpt.com/codex/tasks/task_e_685c87ad564483229c5578b4c71e1094
Summary by Sourcery
Implement import statement parsing with AST support, tests, and updated documentation
New Features:
Enhancements:
Documentation:
Tests: