RFR: 8241187: ToolBox::grep should allow for negative filtering

Jonathan Gibbons jjg at openjdk.java.net
Mon Jan 4 18:14:03 UTC 2021


On Mon, 4 Jan 2021 17:17:58 GMT, Guoxiong Li <github.com+13688759+lgxbslgx at openjdk.org> wrote:

> Hi all,
> 
> This patch adds two methods in `ToolBox` to do the negative filtering. Although the label `noreg-self` was added, I write a test for this enhancement to verify the code. And the method name `grepNotMatch` may need to be improved. Any idea is appreciated.
>  
> Thank you for taking the time to review.
> 
> Best Regards.

test/langtools/tools/lib/toolbox/ToolBox.java line 204:

> 202:      * @return the strings not matching the regular expression
> 203:      */
> 204:     public List<String> grepNotMatch(Pattern pattern, List<String> lines) {

Instead of new methods named `grepNotMatch` I suggest adding new overloads of `grep` that take an additional `boolean invert` parameter that is conceptually equivalent to the `grep` `-v` option.  The existing `grep` methods can be updated to delegate to the new methods, passing `false` for the new parameter.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1934


More information about the compiler-dev mailing list