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

[Close #22] Lines are lexically aware of keywords #24

Merged
merged 2 commits into from
Dec 4, 2020
Merged

Conversation

schneems
Copy link
Collaborator

@schneems schneems commented Dec 4, 2020

CodeLines are now lexically aware of keywords. This is used by the AroundBlockScan to allow stopping after a keyword has been hit.

In addition to stripping heredocs before searching, the CodeSearch now also strips lines that contain only comments. The combination of stripping heredocs and comments prevents false positives from lexing individual lines (since a comment might contain valid code i.e. # def foo; end.

New APIs:

  • CodeLine#is_comment?
  • CodeLine#is_kw?
  • CodeLine#is_end?
  • AroundBlockScan.stop_after_kw
  • AroundBlockScan.scan_neighbors

CodeLines are now lexically aware of keywords. This is used by the AroundBlockScan to allow stopping after a keyword has been hit.

In addition to stripping heredocs before searching, the CodeSearch now also strips lines that contain only comments. The combination of stripping heredocs and comments prevents false positives from lexing individual lines (since a comment might contain valid code i.e. `# def foo; end`. 

New APIs:

- CodeLine#is_comment?
- CodeLine#is_kw?
- CodeLine#is_end?
- AroundBlockScan.stop_after_kw
- AroundBlockScan.scan_neighbors
@schneems schneems merged commit a20706e into main Dec 4, 2020
@schneems schneems deleted the schneems/on_kw branch December 4, 2020 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant