RFR - JDK-8223775 String::stripIndent (Preview)

Brent Christian brent.christian at oracle.com
Thu May 23 22:52:13 UTC 2019

Hi, Jim

I have a few comments on the webrev.


2982     private static int outdent(List<String> lines) {

Can you please add a doc comment for what this method does?

2973  .map(line -> {
2974      int firstNonWhitespace = line.indexOfNonWhitespace();
2975      int lastNonWhitespace = line.lastIndexOfNonWhitespace();
2976      return firstNonWhitespace > lastNonWhitespace
2977          ? "" : line.substring(Math.min(outdent, 
firstNonWhitespace), lastNonWhitespace);
2978  })
2979  .collect(Collectors.joining("\n", "", optOut ? "\n" : ""));

Like Vicente mentioned, it would be nice if less of this work were done 
when 'optOut' is true.


I'd like for the test to be made easier to read, so it's clear which 
edge cases are covered (the last line determines a non-0 outdent, the 
last line opts out of all outdenting, etc).

Splitting the test data onto multiple lines would be a good start 
(though ironic, for this feature :).  And maybe even add a description 
of the case being tested, where not obvious.


More information about the compiler-dev mailing list