-
-
Notifications
You must be signed in to change notification settings - Fork 4
Cambiar la estructura de import #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Runner
participant Importer
participant FileSystem
participant Lexer
participant Parser
Runner->>Importer: local_import(path, already_imported, base_dir)
Importer->>FileSystem: Check if file exists and is valid
alt File not found or invalid
Importer-->>Runner: Err(WaveError)
else File found
Importer->>FileSystem: Read file content
Importer->>Lexer: Tokenize content
Importer->>Parser: Parse tokens
alt Parse error
Importer-->>Runner: Err(WaveError with diagnostics)
else Success
Importer-->>Runner: Ok(Vec<ASTNode>)
end
end
Runner->>Runner: Handle Ok or display error from Err
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Clippy (1.86.0)warning: failed to write cache, path: /usr/local/registry/index/index.crates.io-1949cf8c6b5b557f/.cache/re/ge/regex, error: Permission denied (os error 13) Caused by: ✨ Finishing Touches
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. 🪧 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 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
front/parser/src/parser/import.rs (1)
91-107: Remove or document unused functionfind_wave_file_recursive.This helper is only ever called by itself (for recursion) and isn’t invoked anywhere else in the codebase. To keep the code clean:
- Location: front/parser/src/parser/import.rs (lines 91–107)
- Actions:
- Remove the entire function if it’s no longer needed.
- Otherwise, add a comment or
#[allow(dead_code)]annotation explaining its intended future use.
🧹 Nitpick comments (1)
front/parser/src/parser/import.rs (1)
77-86: Consider using actual parse error location.The error uses hardcoded line/column numbers (1, 1) which may not reflect the actual error location in the imported file.
If the parser provides error location information, consider extracting and using it for more accurate error reporting. This would improve the debugging experience when imports fail to parse.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
Cargo.toml(1 hunks)front/parser/src/parser/import.rs(1 hunks)src/runner.rs(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/runner.rs (1)
front/parser/src/parser/import.rs (1)
local_import(8-89)
⏰ 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). (1)
- GitHub Check: build
🔇 Additional comments (3)
Cargo.toml (1)
3-3: LGTM! Version simplification is appropriate.The version change from a dated nightly build to a cleaner pre-beta tag aligns well with the import system improvements.
front/parser/src/parser/import.rs (1)
8-21: Good error handling for empty paths.The Result-based approach with explicit error messages improves the developer experience as intended by the PR.
src/runner.rs (1)
31-39: Proper error handling implementation.The updated code correctly handles the Result type from
local_import, displaying detailed error information before exiting. This aligns perfectly with the PR's goal of improving error messages.
| let abs_path_str = abs_path.to_str().ok_or_else(|| { | ||
| WaveError::new( | ||
| WaveErrorKind::UnexpectedChar('?'), | ||
| "Invalid path encoding", | ||
| target_file_name.clone(), | ||
| 0, | ||
| 0, | ||
| ) | ||
| })?.to_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use appropriate error kind for path encoding issues.
WaveErrorKind::UnexpectedChar('?') is semantically incorrect for path encoding errors. This error kind is typically used for lexical analysis, not filesystem operations.
Consider using a more appropriate error kind:
- WaveError::new(
- WaveErrorKind::UnexpectedChar('?'),
- "Invalid path encoding",
+ WaveError::new(
+ WaveErrorKind::SyntaxError("Invalid path encoding".to_string()),
+ "Path contains invalid UTF-8 characters",📝 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.
| let abs_path_str = abs_path.to_str().ok_or_else(|| { | |
| WaveError::new( | |
| WaveErrorKind::UnexpectedChar('?'), | |
| "Invalid path encoding", | |
| target_file_name.clone(), | |
| 0, | |
| 0, | |
| ) | |
| })?.to_string(); | |
| let abs_path_str = abs_path.to_str().ok_or_else(|| { | |
| WaveError::new( | |
| WaveErrorKind::SyntaxError("Invalid path encoding".to_string()), | |
| "Path contains invalid UTF-8 characters", | |
| target_file_name.clone(), | |
| 0, | |
| 0, | |
| ) | |
| })?.to_string(); |
🤖 Prompt for AI Agents
In front/parser/src/parser/import.rs around lines 49 to 57, the error kind used
for invalid path encoding is WaveErrorKind::UnexpectedChar('?'), which is
inappropriate for filesystem-related errors. Replace this with a more suitable
error kind that reflects path or encoding errors, ensuring the error accurately
represents the nature of the failure.
Added directory support from local import, including error message improvement.
import("math");->project_root/math.waveimport("math/math")->project_root/math/math.waveError Message Example:
Summary by CodeRabbit
Refactor
Style