|
18 | 18 | import com.fasterxml.jackson.annotation.JsonCreator;
|
19 | 19 | import lombok.Data;
|
20 | 20 | import lombok.EqualsAndHashCode;
|
| 21 | +import lombok.Getter; |
21 | 22 | import lombok.Value;
|
22 | 23 | import org.jspecify.annotations.Nullable;
|
23 | 24 | import org.openrewrite.SourceFile;
|
@@ -69,7 +70,7 @@ public static class Detector {
|
69 | 70 | private final FindTrailingCommaVisitor findTrailingComma = new FindTrailingCommaVisitor();
|
70 | 71 |
|
71 | 72 | public void sample(SourceFile cu) {
|
72 |
| - if (cu instanceof JavaSourceFile) { |
| 73 | + if (cu instanceof K.CompilationUnit) { |
73 | 74 | findImportLayout.visitNonNull(cu, 0);
|
74 | 75 | findIndent.visitNonNull(cu, indentStatistics);
|
75 | 76 | findSpaces.visitNonNull(cu, spacesStatistics);
|
@@ -174,16 +175,11 @@ private static class IndentStatistics {
|
174 | 175 | private int multilineAlignedToFirstArgument = 0;
|
175 | 176 | private int multilineNotAlignedToFirstArgument = 0;
|
176 | 177 |
|
| 178 | + @Getter |
177 | 179 | private int depth = 0;
|
178 |
| - private int continuationDepth = 1; |
179 |
| - |
180 |
| - public int getDepth() { |
181 |
| - return depth; |
182 |
| - } |
183 | 180 |
|
184 |
| - public int getContinuationDepth() { |
185 |
| - return continuationDepth; |
186 |
| - } |
| 181 | + @Getter |
| 182 | + private int continuationDepth = 1; |
187 | 183 |
|
188 | 184 | public void incrementDepth() {
|
189 | 185 | depth++;
|
@@ -621,13 +617,9 @@ public ImportLayoutStyle getImportLayoutStyle() {
|
621 | 617 |
|
622 | 618 | // Add static imports at the top if it's the standard.
|
623 | 619 | boolean addNewLine = false;
|
624 |
| - addNewLine = false; |
625 | 620 |
|
626 | 621 | // There are no non-static imports, add a block of all other import.
|
627 | 622 | if (!insertAllOthers) {
|
628 |
| - if (addNewLine) { |
629 |
| - builder = builder.blankLine(); |
630 |
| - } |
631 | 623 |
|
632 | 624 | builder = builder.importAllOthers();
|
633 | 625 | // Add java/javax if they're missing from the block that is being used as a template.
|
@@ -1145,7 +1137,7 @@ public J.If visitIf(J.If iff, SpacesStatistics stats) {
|
1145 | 1137 | public J.Lambda visitLambda(J.Lambda lambda, SpacesStatistics stats) {
|
1146 | 1138 | List<J> parameters = lambda.getParameters().getParameters();
|
1147 | 1139 | if (parameters.size() > 1) {
|
1148 |
| - List<JRightPadded<J>> paddedParameters = lambda.getParameters().getPadding().getParams(); |
| 1140 | + List<JRightPadded<J>> paddedParameters = lambda.getParameters().getPadding().getParameters(); |
1149 | 1141 | for (int i = 0; i < paddedParameters.size() - 1; i++) {
|
1150 | 1142 | stats.beforeComma += hasSpace(paddedParameters.get(i).getAfter());
|
1151 | 1143 | }
|
|
0 commit comments