File tree Expand file tree Collapse file tree
rewrite-java-25/src/main/java/org/openrewrite/java/isolated
rewrite-java-tck/src/main/java/org/openrewrite/java/tree Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4444import java .util .HashMap ;
4545import java .util .List ;
4646import java .util .Map ;
47+ import java .util .function .Predicate ;
4748
4849import static java .util .Collections .*;
4950import static java .util .stream .Collectors .toList ;
@@ -981,7 +982,7 @@ public List<Javadoc> visitText(String node) {
981982 // The AST contained unnecessary whitespace for Javadoc, and they got rid of this with Java 25.
982983 // So now have to manually account for this.
983984 if (i +1 <= node .length () -1 && node .charAt (i +1 ) != source .charAt (cursor ) && Character .isWhitespace (source .charAt (cursor ))) {
984- text .append (whitespaceBeforeAsString ());
985+ text .append (whitespaceBeforeAsString (Character :: isSpaceChar ));
985986 }
986987 }
987988
@@ -1085,13 +1086,17 @@ private List<Javadoc> sourceBefore(String delim) {
10851086 }
10861087
10871088 private String whitespaceBeforeAsString () {
1089+ return whitespaceBeforeAsString (Character ::isWhitespace );
1090+ }
1091+
1092+ private String whitespaceBeforeAsString (Predicate <Character > whitespace ) {
10881093 if (cursor >= source .length ()) {
10891094 return "" ;
10901095 }
10911096
10921097 int i = cursor ;
10931098 for (; i < source .length (); i ++) {
1094- if (!Character . isWhitespace (source .charAt (i ))) {
1099+ if (!whitespace . test (source .charAt (i ))) {
10951100 break ;
10961101 }
10971102 }
Original file line number Diff line number Diff line change @@ -2200,6 +2200,22 @@ public void methodC(String aString) {
22002200 );
22012201 }
22022202
2203+ @ Test
2204+ void redundantSpacing () {
2205+ rewriteRun (
2206+ java (
2207+ """
2208+ /**
2209+ * <p>Some text.
2210+ *\s
2211+ * <p>More text.
2212+ */
2213+ class SomeClass {}
2214+ """
2215+ )
2216+ );
2217+ }
2218+
22032219 @ Issue ("https://github.com/openrewrite/rewrite/issues/5855" )
22042220 @ Nested
22052221 class GenericWildcard {
You can’t perform that action at this time.
0 commit comments