Skip to content
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

revert: past two commits #136

Closed
wants to merge 1 commit into from
Closed

revert: past two commits #136

wants to merge 1 commit into from

Conversation

ilevyor
Copy link
Contributor

@ilevyor ilevyor commented Apr 2, 2024

last two commits:
#132
#133

broke:

   test::access_empty_list
    test::access_empty_map
    test::match_on_falsy_accessor
    test::match_on_falsy_list_index

Summary by CodeRabbit

  • Refactor
    • Simplified the creation and usage of Binding instances across various modules.
    • Streamlined ResolvedPattern creation in After and Before implementations for improved logic flow.
    • Enhanced handling of bindings and list operations in built-in functions for efficiency.
    • Reorganized imports and removed unused code for cleaner codebase.
    • Improved pattern matching and node type handling in Matcher implementations.
    • Introduced new methods for creating bindings, enhancing code clarity and efficiency.
    • Refactored apply_effects function for better readability and potential extensibility.

Copy link
Contributor

coderabbitai bot commented Apr 2, 2024

Walkthrough

The recent update focuses on refining the codebase by enhancing enum usage, streamlining ResolvedPattern creation, and optimizing binding and pattern matching logic. It introduces methods for more intuitive binding creation, shifts to using Self:: for enum variants, and simplifies several implementations across pattern handling and utility functions. This collective effort aims to improve code clarity, maintainability, and performance.

Changes

File(s) Summary
binding.rs Introduced new methods for binding creation; updated enum variant references to Self::.
pattern/after.rs, pattern/before.rs Simplified ResolvedPattern creation by using direct methods instead of manual instantiation.
pattern/ast_node.rs, pattern/built_in_functions.rs, pattern/contains.rs, pattern/list_index.rs, pattern/or.rs, pattern/regex.rs Streamlined logic for bindings and pattern matching; optimized imports and method implementations.
pattern/resolved_pattern.rs, text_unparser.rs Enhanced ResolvedPattern methods and refactored to use new binding creation functions.

🐰✨

In the warren, deep and wide,
Changes spring from side to side.
Bindings shift, patterns dance,
Code evolves, given the chance.
Through the fields of logic, we hop,
Onward, upward, we never stop.
🌼🚀🐇

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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/coderabbit-overrides.v2.json

Documentation and Community

  • 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.

@arendjr
Copy link
Contributor

arendjr commented Apr 2, 2024

I see, I can indeed reproduce it locally too now. Was it the eager lists after all?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3581187 and 1cf8e22.
Files selected for processing (11)
  • crates/core/src/binding.rs (9 hunks)
  • crates/core/src/pattern/after.rs (2 hunks)
  • crates/core/src/pattern/ast_node.rs (3 hunks)
  • crates/core/src/pattern/before.rs (2 hunks)
  • crates/core/src/pattern/built_in_functions.rs (4 hunks)
  • crates/core/src/pattern/contains.rs (2 hunks)
  • crates/core/src/pattern/list_index.rs (3 hunks)
  • crates/core/src/pattern/or.rs (1 hunks)
  • crates/core/src/pattern/regex.rs (2 hunks)
  • crates/core/src/pattern/resolved_pattern.rs (8 hunks)
  • crates/core/src/text_unparser.rs (2 hunks)
Files skipped from review due to trivial changes (1)
  • crates/core/src/pattern/contains.rs
Additional comments not posted (36)
crates/core/src/text_unparser.rs (2)

1-1: The removal of Binding from the import statement is appropriate given the refactoring within the apply_effects function to use effect.binding.as_filename() instead of directly matching against Binding::FileName. This change simplifies the code and reduces unnecessary imports.


49-50: Refactoring to use effect.binding.as_filename() instead of directly matching against Binding::FileName improves code readability and extensibility. This encapsulation allows for easier modifications in how filenames are represented within bindings in the future.

crates/core/src/pattern/after.rs (1)

63-63: Simplifying the creation of ResolvedPattern instances by directly using ResolvedPattern::from_node(next) enhances code readability and maintainability. This change effectively streamlines the logic for creating ResolvedPattern instances based on node analysis.

crates/core/src/pattern/before.rs (1)

63-63: Simplifying the creation of ResolvedPattern instances by directly using ResolvedPattern::from_node(prev) enhances code readability and maintainability. This change effectively streamlines the logic for creating ResolvedPattern instances based on node analysis.

crates/core/src/pattern/or.rs (1)

77-80: The changes made to handle node type matching within the execute method of the Or module's Matcher implementation introduce a more explicit way of accessing and comparing the node types of binding nodes with pattern nodes. This adjustment likely improves the clarity and correctness of the node type matching logic.

crates/core/src/pattern/ast_node.rs (2)

166-166: The changes made to the handling of list bindings within the ASTNode matcher implementation streamline the execution flow by simplifying the handling of list bindings. This likely improves the efficiency and readability of the code.


181-181: The changes made to the handling of comment content resolution within the ASTNode matcher implementation streamline the execution flow by simplifying the handling of comment content resolution. This likely improves the efficiency and readability of the code.

crates/core/src/pattern/regex.rs (2)

9-9: The removal of imports for binding::Binding and context::Context, and the elimination of the use of im::vector are appropriate given the refactoring within the file. These changes contribute to reducing unnecessary imports and dependencies.


203-203: Replacing ResolvedPattern::Binding construction with ResolvedPattern::from_range improves clarity and efficiency. This simplification enhances code readability and likely improves performance by avoiding unnecessary wrapping of data structures.

crates/core/src/pattern/list_index.rs (2)

131-140: The modifications to how list items are accessed and processed in the ListIndex implementation improve the efficiency and clarity of the code. These changes simplify the access and processing of list items, making the code more readable and maintainable.


164-173: The modifications to how list items are accessed and processed in the ListIndex implementation, specifically for mutable access, maintain the improvements in efficiency and clarity. These changes ensure that the code remains readable and maintainable while handling mutable access to list items.

crates/core/src/pattern/built_in_functions.rs (3)

1-1: The simplification of use statements by removing unnecessary imports contributes to making the code more efficient and maintainable. This change aligns with the overall goal of cleaner and more readable code.


369-372: The revision of logic within the join_fn function to handle bindings and list operations more efficiently improves the performance and readability of the code. This change simplifies the handling of bindings and list operations, making the code more maintainable.


482-486: The revision of logic within the length_fn function to handle bindings and list operations more efficiently improves the performance and readability of the code. This change simplifies the handling of bindings and list operations, making the code more maintainable.

crates/core/src/binding.rs (8)

310-312: The addition of the from_constant method is a good practice for creating instances of Binding from a Constant. It enhances readability and encapsulation.


318-320: The from_path method simplifies the creation of FileName bindings. This is a positive change for maintainability and readability.


322-324: Introducing the from_range method for creating String bindings from a range and source is a good encapsulation practice, improving code readability.


354-355: The get_sexp method's handling of Node and List bindings to generate S-expressions is correctly implemented. It's a good practice for debugging or serialization purposes.


375-378: The position method's implementation for Node bindings correctly returns the range of the node. This is crucial for operations that depend on the position of bindings within the source code.


435-436: The from_path method correctly creates a FileName binding from a Path. This encapsulation simplifies the creation of file name bindings.


432-439: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [439-440]

The from_range method for creating String bindings from a range and source is correctly implemented, enhancing code readability and maintainability.


80-95: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [881-884]

The matches_undefined method correctly identifies if a Binding or Constant is Undefined. This is important for handling cases where the absence of a value needs to be explicitly checked.

crates/core/src/pattern/resolved_pattern.rs (14)

60-60: The name method in the File enum correctly uses the new from_path method for creating a ResolvedPattern from a file path. This is a good example of utilizing new utility methods to simplify code.


71-73: The absolute_path method's use of from_path for creating a ResolvedPattern from an absolute path is correctly implemented, enhancing code readability.


83-83: The body method's implementation for creating a ResolvedPattern from a range and source using the from_range method is a good practice, improving code readability.


94-94: The binding method's use of from_node for creating a ResolvedPattern from a NodeWithSource is correctly implemented, enhancing encapsulation and readability.


108-108: The JoinFn struct's from_resolved method correctly initializes the struct with a list of ResolvedPattern and a separator. This simplifies the creation of JoinFn instances.


111-115: The from_list_binding method in the JoinFn struct correctly creates a JoinFn instance from a list binding, enhancing the flexibility of handling list bindings.


127-142: The linearized_text method in the JoinFn struct correctly linearizes each pattern in the list and joins them with the specified separator. This is a key functionality for handling join operations on patterns.


420-420: The from_constant method in ResolvedPattern correctly utilizes the Binding::from_constant method for creating a ResolvedPattern from a Constant. This is a good example of reusing existing functionality to simplify code.


424-424: The from_node method in ResolvedPattern correctly utilizes the Binding::from_node method for creating a ResolvedPattern from a NodeWithSource. This enhances code readability and maintainability.


428-428: The from_list method in ResolvedPattern correctly utilizes the Binding::List constructor for creating a ResolvedPattern from a list binding. This is a good practice for handling list bindings.


432-433: The empty_field method in ResolvedPattern correctly utilizes the Binding::Empty constructor for creating a ResolvedPattern from an empty field binding. This is important for handling cases where a field is expected but not present.


435-437: The from_path method in ResolvedPattern correctly utilizes the Binding::from_path method for creating a ResolvedPattern from a Path. This simplifies the creation of file path bindings.


439-440: The from_range method in ResolvedPattern correctly utilizes the Binding::from_range method for creating a ResolvedPattern from a range and source. This is a good practice for handling string bindings.


881-884: The matches_undefined method correctly identifies if a ResolvedPattern matches an undefined constant. This is crucial for handling cases where the absence of a value needs to be explicitly checked.

@ilevyor
Copy link
Contributor Author

ilevyor commented Apr 2, 2024

I see, I can indeed reproduce it locally too now. Was it the eager lists after all?
No I would review the code in ListIndex and MapAccessor

@ilevyor ilevyor closed this Apr 2, 2024
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