MikePopoloski / slang

SystemVerilog compiler and language services
MIT License
592 stars 132 forks source link

Add helper function to determine if a location is in a range #891

Closed suzizecat closed 7 months ago

suzizecat commented 7 months ago

Adds SourceRange::contains(SourceLocation) allowing to know if a source location is within the boundaries of the source range.


The objective is to know if a location is included in a range. I assumed that the boundaries of the range are both included (hence the usage of <= and >= operators)

Please let me know if any update are required (or do not hesitate to make the changes yourself).

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (3ddb9b3) 93.76% compared to head (41d5cf1) 93.76%. Report is 1 commits behind head on master.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/MikePopoloski/slang/pull/891/graphs/tree.svg?width=650&height=150&src=pr&token=sS5JjK9091&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Popoloski)](https://app.codecov.io/gh/MikePopoloski/slang/pull/891?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Popoloski) ```diff @@ Coverage Diff @@ ## master #891 +/- ## ======================================= Coverage 93.76% 93.76% ======================================= Files 189 189 Lines 47018 47018 ======================================= Hits 44087 44087 Misses 2931 2931 ``` | [Files](https://app.codecov.io/gh/MikePopoloski/slang/pull/891?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Popoloski) | Coverage Δ | | |---|---|---| | [include/slang/text/SourceLocation.h](https://app.codecov.io/gh/MikePopoloski/slang/pull/891?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Popoloski#diff-aW5jbHVkZS9zbGFuZy90ZXh0L1NvdXJjZUxvY2F0aW9uLmg=) | `100.00% <ø> (ø)` | | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/MikePopoloski/slang/pull/891?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Popoloski). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Popoloski) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/MikePopoloski/slang/pull/891?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Popoloski). Last update [3ddb9b3...41d5cf1](https://app.codecov.io/gh/MikePopoloski/slang/pull/891?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Popoloski). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Michael+Popoloski).