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

👍 add eval module and mark deprecated helper/expr_string #260

Merged
merged 21 commits into from
Aug 26, 2024
Merged

Conversation

Milly
Copy link
Contributor

@Milly Milly commented Aug 14, 2024

This is implements of #243.

New feature

  • Add eval module.
    • expr tagged template string function returns Expression.
    • rawString tagged template string function returns RawString.
      • It is similar to exprQuote and ExprString in helper/expr_string module.
    • stringify() function is similar to JSON.stringify() but it serializes values into a string that can be evaluated in Vim.
      • Allows Expression, RawString or any JavaScript values.
      • Allows ExprString for backward compatibility.
    • useEval function is similar to useExprString.
      • Allows Expression, RawString.
      • Allows ExprString for backward compatibility.
  • Improve lambda module.
    • Lambda.notify() or Lambda.request() allows arguments to be Expression or RawString.
    • Lambda.request() allows return value to be Expression or RawString.
    • Fixed issue: Some JavaScript values ​​could not be passed to Lambda.notify() or Lambda.request() arguments. (e.g. boolean)
  • Improve helper/keymap module.
    • send() allows arguments to be RawString.

Mark deprecated

  • helper/expr_string module as deprecated.

Summary by CodeRabbit

  • New Features

    • Introduced new modules for evaluating Vim expressions and handling Vim string constants.
    • Added a stringify utility to convert values into a Vim-compatible string format.
    • New utility functions for improved interaction with the Denops API.
    • Added useEval function for enhanced expression evaluation in asynchronous blocks.
  • Enhancements

    • Updated existing types and functions to support new functionalities, including the integration of RawString.
    • Extended handling of string types and improved type safety in lambdas.
  • Deprecations

    • Added deprecation notices for older string handling types and functions, encouraging users to transition to new implementations.
  • Tests

    • Introduced comprehensive test suites for stringify functionality and expression handling, ensuring robust validation of output across various input scenarios.

Copy link

coderabbitai bot commented Aug 14, 2024

Walkthrough

This update introduces new modules and enhancements for managing Vim expressions and strings in TypeScript, including new utility functions and types. It also features updated dependency versions and deprecation notices for outdated functionalities, promoting cleaner integration with Vim and clearer development practices.

Changes

Files Change Summary
deno.jsonc New export path for ./eval, updated version for @core/unknownutil, and added import for @nick/dispose.
eval/expression.ts, eval/string.ts Introduced Expression and RawString types, along with utility functions for managing Vim expressions and strings.
eval/stringify.ts, eval/use_eval.ts Added stringify function for converting values to Vim-compatible strings and useEval for evaluating expressions within Denops.
helper/expr_string.ts Added deprecation notices for ExprString, exprQuote, and isExprString functions.
lambda/mod.ts Enhanced Lambda interface to extend Disposable and refined method signatures.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant Deno
    participant Vim
    
    Developer->>Deno: Invoke expression evaluation
    Deno->>Vim: Execute Vim command
    Vim-->>Deno: Return result
    Deno-->>Developer: Send evaluated result
Loading

🐰 In the meadow where ideas bloom,
New helpers hop, dispelling gloom.
With strings and types that dance and play,
The code grows bright, come what may!
Let's cheer for changes, big and small,
A joyful leap, we celebrate all! 🌼✨


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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

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

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.

Copy link

@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: 5

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b2e9943 and 079f68a.

Files selected for processing (17)
  • deno.jsonc (3 hunks)
  • eval/expression.ts (1 hunks)
  • eval/expression_test.ts (1 hunks)
  • eval/mod.ts (1 hunks)
  • eval/string.ts (1 hunks)
  • eval/string_test.ts (1 hunks)
  • eval/stringify.ts (1 hunks)
  • eval/stringify_test.ts (1 hunks)
  • eval/use_eval.ts (1 hunks)
  • eval/use_eval_test.ts (1 hunks)
  • eval/vim_evaluatable.ts (1 hunks)
  • eval/vim_evaluatable_test.ts (1 hunks)
  • helper/expr_string.ts (4 hunks)
  • helper/keymap.ts (5 hunks)
  • helper/keymap_test.ts (1 hunks)
  • lambda/mod.ts (6 hunks)
  • lambda/mod_test.ts (1 hunks)
Additional context used
Biome
eval/expression.ts

[error] 101-101: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 104-106: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

eval/use_eval.ts

[error] 31-31: Constraining a type parameter to any or unknown is useless.

All types are subtypes of any and unknown.
Safe fix: Remove the constraint.

(lint/complexity/noUselessTypeConstraint)

eval/string.ts

[error] 134-134: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


[error] 139-141: This constructor is unnecessary.

Unsafe fix: Remove the unnecessary constructor.

(lint/complexity/noUselessConstructor)

eval/stringify_test.ts

[error] 202-202: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

Additional comments not posted (61)
eval/vim_evaluatable.ts (1)

1-20: LGTM!

The code is well-structured and makes effective use of TypeScript's type system. The use of Symbol.for is appropriate for ensuring consistency across library versions. The predicate function is correctly implemented.

eval/vim_evaluatable_test.ts (1)

1-32: LGTM!

The tests are comprehensive and well-organized, covering both positive and negative cases for the isVimEvaluatable function. The use of t.step for subtests is a good practice.

eval/mod.ts (1)

1-38: LGTM!

The module-level comment is clear and provides a good overview of how to use the exported functions. The exports are consistent with the PR objectives.

eval/string_test.ts (3)

8-13: LGTM! The test case for rawString() is well-implemented.

The test correctly checks the Symbol.toStringTag to verify the type.


15-44: Comprehensive test case for RawString.

The test covers important aspects like @@vimExpressionOf(), toJSON(), toString(), and inspection.


46-71: Thorough test coverage for isRawString().

The test cases effectively verify the function's behavior with different data types.

eval/expression_test.ts (3)

8-13: LGTM! The test case for expr() is well-implemented.

The test correctly checks the Symbol.toStringTag to verify the type.


15-44: Comprehensive test case for Expression.

The test covers important aspects like @@vimExpressionOf(), toJSON(), toString(), and inspection.


47-72: Thorough test coverage for isExpression().

The test cases effectively verify the function's behavior with different data types.

helper/keymap.ts (3)

5-9: LGTM! Import statements are correctly updated.

The imports reflect the new module structure and dependencies.


Line range hint 12-23:
LGTM! Changes to Keys type and toKeys function enhance flexibility.

The inclusion of RawString and the check for isRawString are well-implemented.


71-83: LGTM! The send function is well-refactored.

The use of useEval and the new promise handling approach improve the function's logic.

helper/keymap_test.ts (9)

13-18: Test case for normal keys with string looks good.

The test case correctly verifies the behavior of sending normal keys using a string.


19-24: Test case for normal keys with string[] looks good.

The test case correctly verifies the behavior of sending normal keys using an array of strings.


25-29: Test case for special keys with RawString looks good.

The test case correctly verifies the behavior of sending special keys using RawString.


30-38: Test case for special keys with RawString[] looks good.

The test case correctly verifies the behavior of sending special keys using an array of RawString.


39-43: Test case for special keys with ExprString looks good.

The test case correctly verifies the behavior of sending special keys using ExprString.


44-52: Test case for special keys with ExprString[] looks good.

The test case correctly verifies the behavior of sending special keys using an array of ExprString.


53-61: Test case for non-remapped keys with Keys looks good.

The test case correctly verifies the behavior of sending non-remapped keys using Keys. The use of AsyncDisposableStack ensures proper cleanup.


62-70: Test case for remapped keys with Keys looks good.

The test case correctly verifies the behavior of sending remapped keys using Keys. The use of AsyncDisposableStack ensures proper cleanup.


71-83: Test case for mixed keys with Keys[] looks good.

The test case correctly verifies the behavior of sending mixed keys using an array of Keys. The use of AsyncDisposableStack ensures proper cleanup.

eval/expression.ts (3)

26-35: Expression type and ExpressionProps interface look good.

The Expression type and ExpressionProps interface are well-defined and correctly implement the toJSON method and Symbol.toStringTag.


66-73: expr function implementation looks good.

The expr function correctly creates an Expression from a template string and substitutions, ensuring safe conversion.


87-93: isExpression predicate looks good.

The isExpression predicate is correctly defined to check if a value is an Expression.

deno.jsonc (3)

11-11: New export path for ./eval looks good.

The addition of the export path for ./eval is correct and aligns with the new module introduction.


45-51: Import updates look good.

The version update for @core/unknownutil and the addition of @nick/dispose are appropriate and align with the project's needs.


66-66: New import path for jsr:@denops/std/eval looks good.

The addition of the import path for jsr:@denops/std/eval is correct and aligns with the new module introduction.

eval/use_eval.ts (3)

41-56: LGTM!

The ensurePrerequisites function correctly sets up the necessary script in the Denops context.


58-61: LGTM!

The trimEndOfArgs function efficiently removes trailing undefined values from an array.


63-129: LGTM!

The UseEvalHelper class is well-structured and correctly extends Denops functionality with additional methods for evaluation support.

eval/string.ts (2)

32-32: LGTM!

The RawString type is appropriately defined to represent a Vim string constant with additional properties.


99-105: LGTM!

The rawString function correctly creates a RawString from a template string using String.raw.

eval/stringify.ts (4)

69-137: LGTM!

The stringify function effectively converts JavaScript values to a Vim-evaluable string format, handling various types and circular references.


148-150: LGTM!

The isJsonable function correctly identifies objects that can be serialized with a toJSON method.


152-154: LGTM!

The isIgnoreRecordValue function correctly identifies values that should be ignored in records.


171-182: LGTM!

The toBlobLiteral function efficiently converts an ArrayBuffer to a Vim blob literal.

lambda/mod.ts (5)

35-45: Review Import Statements.

The import statements have been updated to include new types and functions from the eval module. Ensure these are used appropriately within the file.


157-157: Extend Lambda with Disposable.

The Lambda interface now extends Disposable, which is a good practice for resource management. Ensure that all instances of Lambda are properly disposed of to prevent resource leaks.


Line range hint 175-192:
Update Return Type to Expression.

The notify and request methods now return an Expression instead of a string. This change enhances type safety and aligns with the new eval module's functionality.


258-283: Refactor add Function with fnWrapper.

The add function now uses a fnWrapper to handle different argument types more gracefully. This improves flexibility and usability. The use of expr for constructing notifications and requests is a good enhancement.


283-283: Avoid Using delete Operator.

The use of the delete operator can impact performance. Consider setting the property to undefined instead.

- delete denops.dispatcher[id];
+ denops.dispatcher[id] = undefined;

Likely invalid or redundant comment.

helper/expr_string.ts (4)

26-26: Deprecate ExprString Type.

The ExprString type is deprecated. Developers should transition to using rawString and RawString for better compatibility with the new eval module.


52-53: Deprecate ExprString Usage.

The deprecation notice for ExprString encourages the use of rawString and RawString. This aligns with the new module's approach.


105-105: Deprecate exprQuote Function.

The exprQuote function is deprecated in favor of rawString. This change aims to streamline the handling of Vim's string constants.


130-131: Deprecate isExprString Function.

The isExprString function is deprecated. Use isRawString instead to check for RawString types.

eval/stringify_test.ts (3)

1-8: Comprehensive Test Setup.

The test setup includes necessary imports for assertions and mocks, ensuring a robust testing environment.


9-261: Thorough Test Coverage for stringify().

The test cases for stringify() are comprehensive, covering various data types and edge cases. This ensures the function's reliability and correctness.

Tools
Biome

[error] 202-202: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


263-300: Vim Evaluation Tests for stringify().

These tests ensure that the stringify() function produces output that can be correctly evaluated in Vim, which is crucial for its intended use.

lambda/mod_test.ts (5)

20-126: Comprehensive test coverage for register function.

The test cases for the register function are well-structured and cover synchronous, asynchronous, and error scenarios effectively.


128-165: Thorough test coverage for unregister function.

The test cases for the unregister function ensure correct behavior for both registered and non-registered IDs.


168-195: Effective test coverage for add function.

The test cases for the add function ensure correct registration and disposal of lambda functions.


196-326: Comprehensive test coverage for Lambda.notify and Lambda.request.

The test cases for Lambda.notify and Lambda.request cover various argument types and return values effectively.


329-388: Thorough test coverage for Lambda.dispose.

The test cases for Lambda.dispose ensure correct behavior for disposing lambda functions.

eval/use_eval_test.ts (8)

16-74: Comprehensive test coverage for useEval.

The test cases for useEval cover executor calls, value resolution, and error handling effectively.


81-88: Effective test coverage for UseEvalHelper.redraw.

The test case ensures correct behavior for calling denops.redraw.


90-245: Comprehensive test coverage for UseEvalHelper.call.

The test cases for UseEvalHelper.call cover various argument types effectively.


247-391: Comprehensive test coverage for UseEvalHelper.cmd.

The test cases for UseEvalHelper.cmd cover various contexts effectively.


393-551: Comprehensive test coverage for UseEvalHelper.eval.

The test cases for UseEvalHelper.eval cover various contexts effectively.


553-760: Comprehensive test coverage for UseEvalHelper.batch.

The test cases for UseEvalHelper.batch cover various argument types effectively.


762-800: Effective test coverage for UseEvalHelper.dispatch.

The test case ensures correct behavior for calling denops.dispatch.


802-869: Effective test coverage for UseEvalHelper properties.

The test cases ensure correct behavior for accessing various UseEvalHelper properties.

eval/use_eval.ts Outdated Show resolved Hide resolved
eval/string.ts Outdated Show resolved Hide resolved
eval/string.ts Outdated Show resolved Hide resolved
eval/expression.ts Outdated Show resolved Hide resolved
eval/expression.ts Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.42%. Comparing base (b2e9943) to head (6fea3d2).
Report is 32 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
+ Coverage   82.61%   84.42%   +1.80%     
==========================================
  Files          57       63       +6     
  Lines        2979     3293     +314     
  Branches      251      291      +40     
==========================================
+ Hits         2461     2780     +319     
+ Misses        516      511       -5     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@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 details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 079f68a and 007d372.

Files selected for processing (3)
  • eval/expression.ts (1 hunks)
  • eval/string.ts (1 hunks)
  • eval/use_eval.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • eval/use_eval.ts
Additional context used
Biome
eval/expression.ts

[error] 101-101: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

eval/string.ts

[error] 134-134: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

Additional comments not posted (6)
eval/expression.ts (3)

87-93: LGTM! Test isExpression for edge cases.

The isExpression function is correctly implemented. Consider testing it with various edge cases to ensure robustness.


98-102: Refactor: Avoid using this in a static context.

Using this in a static context can be confusing. Use the class name ExpressionImpl instead.

-    this.prototype[Symbol.toStringTag] = "Expression";
+    ExpressionImpl.prototype[Symbol.toStringTag] = "Expression";
Tools
Biome

[error] 101-101: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)


66-73: LGTM! Verify stringify handles all edge cases.

The expr function is well-structured. Ensure that stringify correctly handles all possible substitution values.

Verification successful

stringify function handles edge cases effectively.

The stringify function is thoroughly tested across various scenarios, ensuring robust handling of different data types and edge cases.

  • Located in eval/stringify.ts.
  • Extensive tests are in eval/stringify_test.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `stringify` to ensure it handles all edge cases.

# Test: Search for the `stringify` function definition.
ast-grep --lang typescript --pattern $'function stringify($_) {
  $$$
}'

Length of output: 73


Script:

#!/bin/bash
# Description: Broaden the search for the `stringify` function definition.

# Try searching for `stringify` defined as a constant or exported function.
rg 'stringify' -A 5 --type=typescript

Length of output: 72


Script:

#!/bin/bash
# Description: Correct the search for the `stringify` function definition.

# Correct the file type to `ts` for TypeScript files.
rg 'stringify' -A 5 --type=ts

Length of output: 24870

eval/string.ts (3)

99-105: LGTM!

The rawString function is well-structured and correctly constructs a RawString.


120-126: LGTM! Test isRawString for edge cases.

The isRawString function is correctly implemented. Consider testing it with various edge cases to ensure robustness.


131-135: Refactor: Avoid using this in a static context.

Using this in a static context can be confusing. Use the class name RawStringImpl instead.

-    this.prototype[Symbol.toStringTag] = "RawString";
+    RawStringImpl.prototype[Symbol.toStringTag] = "RawString";
Tools
Biome

[error] 134-134: Using this in a static context can be confusing.

this refers to the class.
Unsafe fix: Use the class name instead.

(lint/complexity/noThisInStatic)

Copy link

@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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 007d372 and 9fb0d64.

Files selected for processing (1)
  • eval/stringify_test.ts (1 hunks)
Additional context used
Biome
eval/stringify_test.ts

[error] 229-229: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

Additional comments not posted (2)
eval/stringify_test.ts (2)

11-300: Comprehensive test coverage for stringify().

The test cases for the stringify() function are well-structured and cover a wide range of data types and scenarios, ensuring robust validation of the function's behavior.

Tools
Biome

[error] 229-229: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


303-340: Effective use of parameterized testing in test().

The test case uses parameterized testing effectively to validate stringify() values, ensuring compatibility with Vim evaluations.

eval/stringify_test.ts Show resolved Hide resolved
eval/expression.ts Outdated Show resolved Hide resolved
eval/expression_test.ts Outdated Show resolved Hide resolved
eval/stringify.ts Outdated Show resolved Hide resolved
eval/stringify.ts Outdated Show resolved Hide resolved
eval/stringify.ts Show resolved Hide resolved
eval/use_eval.ts Outdated Show resolved Hide resolved
Copy link

@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 details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9fb0d64 and 45d330b.

Files selected for processing (1)
  • eval/expression_test.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • eval/expression_test.ts

Copy link

@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 details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 45d330b and d087b73.

Files selected for processing (7)
  • deno.jsonc (3 hunks)
  • eval/expression.ts (1 hunks)
  • eval/string.ts (1 hunks)
  • eval/stringify.ts (1 hunks)
  • eval/use_eval.ts (1 hunks)
  • helper/expr_string.ts (4 hunks)
  • lambda/mod.ts (6 hunks)
Additional comments not posted (29)
eval/expression.ts (5)

26-26: Type Definition is Correct.

The Expression type is correctly defined as a string with additional properties from ExpressionProps.


28-35: Interface Definition is Correct.

The ExpressionProps interface is well-defined, extending VimEvaluatable and providing necessary methods.


66-73: Function Implementation is Correct.

The expr function correctly creates an Expression from a template string and substitutions.


87-93: Function Implementation is Correct.

The isExpression function correctly checks if a value is an Expression using isIntersectionOf.


98-113: Class Implementation is Correct.

The ExpressionImpl class correctly extends String and implements ExpressionProps, providing necessary methods.

eval/use_eval.ts (4)

25-31: Function Implementation is Correct.

The useEval function is correctly implemented, allowing the use of expressions within a Denops context.


35-50: Function Implementation is Correct.

The ensurePrerequisites function is correctly implemented, setting up necessary Vim script functions.


52-55: Function Implementation is Correct.

The trimEndOfArgs function correctly removes undefined values from the end of an array.


57-123: Class Implementation is Correct.

The UseEvalHelper class correctly extends Denops, providing additional methods for expression evaluation.

deno.jsonc (3)

11-11: Export Path Addition is Correct.

The export path for the ./eval module is correctly added.


45-45: Version Update is Correct.

The version update for @core/unknownutil to ^4.3.0 is appropriate and consistent with maintaining up-to-date dependencies.


51-51: New Dependency Addition is Correct.

The new dependency @nick/dispose with version ^1.1.0 is appropriately added, likely for resource management or cleanup.

eval/string.ts (4)

32-32: Type definition is correct.

The RawString type correctly combines string with RawStringProps.


99-105: Function implementation is correct.

The rawString function correctly processes the template and substitutions to return a RawString.


120-126: Function implementation is correct.

The isRawString function correctly uses intersection checks to determine if a value is a RawString.


131-151: Class implementation is correct.

The RawStringImpl class correctly extends String and implements RawStringProps, providing necessary methods and properties.

eval/stringify.ts (5)

64-132: Function implementation is correct.

The stringify function effectively converts JavaScript values to Vim-evaluable strings, handling various data types and circular references.


134-136: Function implementation is correct.

The isIgnoreRecordValue function correctly identifies ignorable values in a record.


138-140: Constants are correctly defined.

The constants for checking specific object types are correctly defined using isInstanceOf.


142-148: Function implementation is correct.

The toVimExpression function correctly converts a VimEvaluatable to a Vim expression string, ensuring type safety.


153-165: Function implementation is correct.

The toBlobLiteral function efficiently converts an ArrayBuffer to a Vim blob literal using a cached array of hex strings.

lambda/mod.ts (5)

Line range hint 153-198: Interface changes are correct.

The Lambda interface changes enhance type safety and align with the new evaluation context.


254-279: Function changes are correct.

The add function changes improve flexibility and type safety in handling function calls.


283-283: Constant definition is correct.

The VIM_REQUEST_FLAG provides a clear and standardized approach to handling request flags.


285-289: Type definition is correct.

The FnWrapperArgs type aligns with the intended use and enhances type safety.


291-295: Function implementation is correct.

The isFnWrapperArgs function correctly uses tuple checks to ensure argument structure.

helper/expr_string.ts (3)

48-49: Deprecation notice for ExprString is clear.

The deprecation notice provides clear guidance on using rawString and RawString as alternatives.


101-101: Deprecation notice for exprQuote is clear.

The deprecation notice correctly advises using rawString as an alternative.


126-127: Deprecation notice for isExprString is clear.

The deprecation notice provides clear guidance on using rawString and isRawString as alternatives.

@Milly Milly requested a review from lambdalisue August 24, 2024 03:05
@Milly
Copy link
Contributor Author

Milly commented Aug 24, 2024

@lambdalisue Would it be better to export it separately like eval/expression?

@lambdalisue
Copy link
Member

@lambdalisue Would it be better to export it separately like eval/expression?

which "it"?

@Milly
Copy link
Contributor Author

Milly commented Aug 24, 2024

@lambdalisue Would it be better to export it separately like eval/expression?

which "it"?

Should I export eval/expression, etc?

@lambdalisue
Copy link
Member

lambdalisue commented Aug 24, 2024

If there is demand, then it should be done. If you can't imagine any demand, then at the very least, it should be treated as private for now. This decision can be based on the implementer's 'intuition.'

For example, something like stringify seems useful even outside the context of expr. However, if it is truly useful, it might not even belong under the expr package in the first place. The implementer is likely the one who understands this best.

Copy link

@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 details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d087b73 and b1ec78b.

Files selected for processing (5)
  • deno.jsonc (3 hunks)
  • eval/expression.ts (1 hunks)
  • eval/string.ts (1 hunks)
  • eval/stringify.ts (1 hunks)
  • eval/use_eval.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • eval/use_eval.ts
Files skipped from review as they are similar to previous changes (4)
  • deno.jsonc
  • eval/expression.ts
  • eval/string.ts
  • eval/stringify.ts

Copy link
Member

@lambdalisue lambdalisue left a comment

Choose a reason for hiding this comment

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

LGTM. Let me know if you are going to fix docstring.

helper/expr_string.ts Outdated Show resolved Hide resolved
helper/expr_string.ts Outdated Show resolved Hide resolved
lambda/mod.ts Outdated Show resolved Hide resolved
Copy link

@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 details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b1ec78b and 3662f40.

Files selected for processing (1)
  • helper/expr_string.ts (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • helper/expr_string.ts

@Milly Milly requested a review from lambdalisue August 25, 2024 10:02
jsr.io does not support `{@linkcode class#member}` style.
#260 (comment)
Copy link

@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 details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3662f40 and 6fea3d2.

Files selected for processing (2)
  • helper/expr_string.ts (4 hunks)
  • lambda/mod.ts (6 hunks)
Files skipped from review as they are similar to previous changes (2)
  • helper/expr_string.ts
  • lambda/mod.ts

Copy link
Member

@lambdalisue lambdalisue left a comment

Choose a reason for hiding this comment

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

LGTM. I'll merge and release it tonight (ping me if I forget)

@lambdalisue lambdalisue merged commit 8cd0dc0 into main Aug 26, 2024
10 checks passed
@lambdalisue lambdalisue deleted the eval branch August 26, 2024 13:47
@lambdalisue lambdalisue mentioned this pull request Aug 26, 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