Split single-line and multi-line matching #53
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds two test cases that were failing before the accompanying change.
Basically: regular expressions are hard.
A single multi-line regular expression was used, but some of its subsets would have weird behaviors, especially if the preceding line was a comment. The sink would receive a multi-line match that started with a comment, and thus incorrectly classified the whole match as a comment, while the second line was, in fact, not a comment, so that would result in a false positive.
Splitting the regular expression in one that operates on single-line and another one that operates on multiple-lines has a few benefits:
grep
crates have a few optimizations when the searcher and matcher are line-based