Skip to content

Commit

Permalink
Revert "Update K.Constructor model"
Browse files Browse the repository at this point in the history
This reverts commit c37be7b.
  • Loading branch information
kunli2 committed Dec 11, 2023
1 parent e599c58 commit c992df9
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/openrewrite/kotlin/KotlinVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public J visitConstructor(K.Constructor constructor, P p) {
K.Constructor c = constructor;
c = c.withMarkers(visitMarkers(c.getMarkers(), p));
c = c.withMethodDeclaration(visitAndCast(c.getMethodDeclaration(), p));
c = c.withInvocation(visitLeftPadded(c.getInvocation(), p));
c = c.withColon(visitSpace(c.getColon(), KSpace.Location.CONSTRUCTOR_COLON, p));
c = c.withConstructorInvocation(visitAndCast(c.getConstructorInvocation(), p));
return c;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ public J visitConstructor(K.Constructor constructor, PrintOutputCapture<P> p) {
afterSyntax(params.getMarkers(), p);
p.append(")");

visitSpace(constructor.getInvocation().getBefore(), KSpace.Location.CONSTRUCTOR_COLON, p);
visitSpace(constructor.getColon(), KSpace.Location.CONSTRUCTOR_COLON, p);
p.append(':');
visit(constructor.getInvocation().getElement(), p);
visit(constructor.getConstructorInvocation(), p);
afterSyntax(constructor, p);

visit(method.getBody(), p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ public J visitSecondaryConstructor(KtSecondaryConstructor constructor, Execution
type
));

return delegationCall != null ? new K.Constructor(randomId(), Markers.EMPTY, methodDeclaration, Space.EMPTY, null, padLeft(prefix(constructor.getColon()), delegationCall)) :
return delegationCall != null ? new K.Constructor(randomId(), Markers.EMPTY, methodDeclaration, prefix(constructor.getColon()), delegationCall) :
methodDeclaration;
}

Expand Down
6 changes: 0 additions & 6 deletions src/main/java/org/openrewrite/kotlin/tree/K.java
Original file line number Diff line number Diff line change
Expand Up @@ -576,15 +576,9 @@ final class Constructor implements K, Statement, TypedTree {

Markers markers;
J.MethodDeclaration methodDeclaration;

@Deprecated // use `invocation` instead
Space colon;

@Deprecated // use `invocation` instead
ConstructorInvocation constructorInvocation;

JLeftPadded<ConstructorInvocation> invocation;

@Override
public Constructor withType(@Nullable JavaType type) {
return this; // type must be changed on method declaration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ class SerializationException : IllegalArgumentException {
cause -> assertThat(cause).isInstanceOf(J.VariableDeclarations.class)
);
assertThat(constructor.getMethodDeclaration().getBody()).isNull();
assertThat(constructor.getInvocation().getElement().getArguments()).satisfiesExactly(
assertThat(constructor.getConstructorInvocation().getArguments()).satisfiesExactly(
message -> assertThat(message).isInstanceOf(J.Identifier.class),
cause -> assertThat(cause).isInstanceOf(J.Identifier.class)
);
Expand Down

0 comments on commit c992df9

Please sign in to comment.