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 Fallback to Prim_Text_Helper.compile_regex; accept Regex in Text.parse_to_table #7297

Merged
merged 7 commits into from
Jul 18, 2023

Conversation

GregoryTravis
Copy link
Contributor

@GregoryTravis GregoryTravis commented Jul 14, 2023

Pull Request Description

This PR does three related things:

  • Fails more gracefully when a non-string is passed to compile_regex
  • Don't pass a non-string to compile_regex
  • Allow a Regex param to parse_to_table

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

Copy link
Member

@jdunkerley jdunkerley left a comment

Choose a reason for hiding this comment

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

A couple of minor changes but looks good.

case_insensitive = case_sensitivity.is_case_insensitive_in_memory
pattern = Regex.compile pattern_string case_insensitive=case_insensitive
pattern = case regex_or_pattern_string of
_ : Regex -> regex_or_pattern_string
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_ : Regex -> regex_or_pattern_string
_ : Regex -> regex_or_pattern_string.recompile case_sensitivity

Will need to be rebased on my one for this to work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@GregoryTravis
Copy link
Contributor Author

Screen Shot 2023-07-14 at 12 43 28 PM

Bad argument to Regex.compile no longer breaks the IDE; Regexes are also now allowed.

GregoryTravis and others added 2 commits July 14, 2023 12:44
…rsions.enso

Co-authored-by: James Dunkerley <jdunkerley@users.noreply.github.com>
…o_Table.enso

Co-authored-by: James Dunkerley <jdunkerley@users.noreply.github.com>
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

Fallback in RegexCompileNode seems OK.

Comment on lines +38 to +39
p = Regex.compile "[a-z]"
Test.expect_panic_with (Regex.compile p) Type_Error
Copy link
Member

Choose a reason for hiding this comment

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

Given this behaviour (that I think is good), do we still need the parseRegexPattern?

I assume it should not be allowed to pass an already-compiled regex to compile_regex, we should use James's recompile instead - e.g. to update case sensitivity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding is that parseRegexPattern is for caching compiled regexes, so if you compile the same one multiple times, it uses the cache. This test is for passing a non-string to Regex.compile.

Copy link
Member

Choose a reason for hiding this comment

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

Ah sorry! I read that wrong apparently.

@GregoryTravis GregoryTravis added the CI: Ready to merge This PR is eligible for automatic merge label Jul 18, 2023
@mergify mergify bot merged commit 2fb5c37 into develop Jul 18, 2023
27 of 28 checks passed
@mergify mergify bot deleted the wip/gmt/7266-regex-builtin branch July 18, 2023 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
4 participants