Skip to content

Commit

Permalink
Regenerate Java and Python code
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Jan 9, 2025
1 parent a7fdfbd commit fe1a22a
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* -------------------THIS FILE IS AUTO GENERATED--------------------------
* Changes to this file may cause incorrect behavior and will be lost if
Expand All @@ -22,10 +23,14 @@
package org.openrewrite.python.remote;

import com.fasterxml.jackson.core.type.TypeReference;
import org.openrewrite.python.tree.Py;
import org.openrewrite.remote.model.LstModel;
import org.openrewrite.remote.model.LstProperty;
import org.openrewrite.remote.model.LstType;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.remote.model.*;
import org.openrewrite.tree.*;
import org.openrewrite.java.tree.*;
import org.openrewrite.python.tree.*;

import java.util.List;

public class Python implements LstModel {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* -------------------THIS FILE IS AUTO GENERATED--------------------------
* Changes to this file may cause incorrect behavior and will be lost if
Expand Down Expand Up @@ -1156,6 +1157,15 @@ public J.Unknown.Source visitUnknownSource(J.Unknown.Source source, ReceiverCont
return source;
}

@Override
public J.Erroneous visitErroneous(J.Erroneous erroneous, ReceiverContext ctx) {
erroneous = erroneous.withId(ctx.receiveNonNullValue(erroneous.getId(), UUID.class));
erroneous = erroneous.withPrefix(ctx.receiveNonNullNode(erroneous.getPrefix(), PythonReceiver::receiveSpace));
erroneous = erroneous.withMarkers(ctx.receiveNonNullNode(erroneous.getMarkers(), ctx::receiveMarkers));
erroneous = erroneous.withText(ctx.receiveNonNullValue(erroneous.getText(), String.class));
return erroneous;
}

}

private static class Factory implements ReceiverFactory {
Expand Down Expand Up @@ -1267,6 +1277,7 @@ protected Function<ReceiverContext, Object> computeValue(Class type) {
if (type == J.Yield.class) return Factory::createJYield;
if (type == J.Unknown.class) return Factory::createJUnknown;
if (type == J.Unknown.Source.class) return Factory::createJUnknownSource;
if (type == J.Erroneous.class) return Factory::createJErroneous;
throw new IllegalArgumentException("Unknown type: " + type);
}
};
Expand Down Expand Up @@ -2390,6 +2401,15 @@ private static J.Unknown.Source createJUnknownSource(ReceiverContext ctx) {
);
}

private static J.Erroneous createJErroneous(ReceiverContext ctx) {
return new J.Erroneous(
ctx.receiveNonNullValue(null, UUID.class),
ctx.receiveNonNullNode(null, PythonReceiver::receiveSpace),
ctx.receiveNonNullNode(null, ctx::receiveMarkers),
ctx.receiveNonNullValue(null, String.class)
);
}

}

private static J.ClassDeclaration.Kind receiveClassDeclarationKind(J.ClassDeclaration.@Nullable Kind kind, @Nullable Class<?> type, ReceiverContext ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* -------------------THIS FILE IS AUTO GENERATED--------------------------
* Changes to this file may cause incorrect behavior and will be lost if
Expand Down Expand Up @@ -1167,6 +1168,15 @@ public J.Unknown.Source visitUnknownSource(J.Unknown.Source source, SenderContex
return source;
}

@Override
public J.Erroneous visitErroneous(J.Erroneous erroneous, SenderContext ctx) {
ctx.sendValue(erroneous, J.Erroneous::getId);
ctx.sendNode(erroneous, J.Erroneous::getPrefix, PythonSender::sendSpace);
ctx.sendNode(erroneous, J.Erroneous::getMarkers, ctx::sendMarkers);
ctx.sendValue(erroneous, J.Erroneous::getText);
return erroneous;
}

}

private static <T extends J> void sendContainer(JContainer<T> container, SenderContext ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* -------------------THIS FILE IS AUTO GENERATED--------------------------
* Changes to this file may cause incorrect behavior and will be lost if
Expand Down Expand Up @@ -751,4 +752,9 @@ public J.Unknown.Source visitUnknownSource(J.Unknown.Source source, P p) {
return source;
}

@Override
public J.Erroneous visitErroneous(J.Erroneous erroneous, P p) {
return erroneous;
}

}
1 change: 1 addition & 0 deletions rewrite/rewrite/java/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
'Empty',
'EnumValue',
'EnumValueSet',
'Erroneous',
'FieldAccess',
'ForEachLoop',
'ForLoop',
Expand Down
15 changes: 15 additions & 0 deletions rewrite/rewrite/java/remote/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,13 @@ def visit_unknown_source(self, source: Unknown.Source, ctx: ReceiverContext) ->
source = source.with_text(ctx.receive_value(source.text, str))
return source

def visit_erroneous(self, erroneous: Erroneous, ctx: ReceiverContext) -> J:
erroneous = erroneous.with_id(ctx.receive_value(erroneous.id, UUID))
erroneous = erroneous.with_prefix(ctx.receive_node(erroneous.prefix, JavaReceiver.receive_space))
erroneous = erroneous.with_markers(ctx.receive_node(erroneous.markers, ctx.receive_markers))
erroneous = erroneous.with_text(ctx.receive_value(erroneous.text, str))
return erroneous

# noinspection PyTypeChecker
class Factory(ReceiverFactory):
def create(self, type: str, ctx: ReceiverContext) -> Tree:
Expand Down Expand Up @@ -1329,6 +1336,14 @@ def create(self, type: str, ctx: ReceiverContext) -> Tree:
ctx.receive_value(None, str)
)

if type in ["rewrite.java.tree.Erroneous", "org.openrewrite.java.tree.J$Erroneous"]:
return Erroneous(
ctx.receive_value(None, UUID),
ctx.receive_node(None, JavaReceiver.receive_space),
ctx.receive_node(None, ctx.receive_markers),
ctx.receive_value(None, str)
)

raise NotImplementedError("No factory method for type: " + type)

@classmethod
Expand Down
7 changes: 7 additions & 0 deletions rewrite/rewrite/java/remote/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,13 @@ def visit_unknown_source(self, source: Unknown.Source, ctx: SenderContext) -> J:
ctx.send_value(source, attrgetter('_text'))
return source

def visit_erroneous(self, erroneous: Erroneous, ctx: SenderContext) -> J:
ctx.send_value(erroneous, attrgetter('_id'))
ctx.send_node(erroneous, attrgetter('_prefix'), JavaSender.send_space)
ctx.send_node(erroneous, attrgetter('_markers'), ctx.send_markers)
ctx.send_value(erroneous, attrgetter('_text'))
return erroneous

@classmethod
def send_container(cls, container: JContainer[T], ctx: SenderContext):
extensions.send_container(container, ctx)
Expand Down
21 changes: 11 additions & 10 deletions rewrite/rewrite/java/support_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,21 @@ def format_first_prefix(cls, trees: List[J2], prefix: Space) -> List[J2]:
SINGLE_SPACE: ClassVar[Space]

class Location(Enum):
ANY = auto()
ANNOTATED_TYPE_PREFIX = auto()
ANNOTATIONS = auto()
ANNOTATION_ARGUMENTS = auto()
ANNOTATION_ARGUMENT_SUFFIX = auto()
ANNOTATIONS = auto()
ANNOTATION_PREFIX = auto()
ANY = auto()
ARRAY_ACCESS_PREFIX = auto()
ARRAY_INDEX_SUFFIX = auto()
ARRAY_TYPE_PREFIX = auto()
ASSERT_PREFIX = auto()
ASSERT_DETAIL = auto()
ASSERT_DETAIL_PREFIX = auto()
ASSERT_PREFIX = auto()
ASSIGNMENT = auto()
ASSIGNMENT_OPERATION_PREFIX = auto()
ASSIGNMENT_OPERATION_OPERATOR = auto()
ASSIGNMENT_OPERATION_PREFIX = auto()
ASSIGNMENT_PREFIX = auto()
BINARY_OPERATOR = auto()
BINARY_PREFIX = auto()
Expand All @@ -154,9 +154,9 @@ class Location(Enum):
BLOCK_STATEMENT_SUFFIX = auto()
BREAK_PREFIX = auto()
CASE = auto()
CASE_PREFIX = auto()
CASE_BODY = auto()
CASE_EXPRESSION = auto()
CASE_PREFIX = auto()
CASE_SUFFIX = auto()
CATCH_ALTERNATIVE_SUFFIX = auto()
CATCH_PREFIX = auto()
Expand All @@ -166,15 +166,16 @@ class Location(Enum):
COMPILATION_UNIT_PREFIX = auto()
CONTINUE_PREFIX = auto()
CONTROL_PARENTHESES_PREFIX = auto()
DIMENSION_PREFIX = auto()
DIMENSION = auto()
DIMENSION_PREFIX = auto()
DIMENSION_SUFFIX = auto()
DO_WHILE_PREFIX = auto()
ELSE_PREFIX = auto()
EMPTY_PREFIX = auto()
ENUM_VALUE_PREFIX = auto()
ENUM_VALUE_SET_PREFIX = auto()
ENUM_VALUE_SUFFIX = auto()
ERRONEOUS_PREFIX = auto()
EXPRESSION_PREFIX = auto()
EXTENDS = auto()
FIELD_ACCESS_NAME = auto()
Expand All @@ -194,9 +195,8 @@ class Location(Enum):
IF_PREFIX = auto()
IF_THEN_SUFFIX = auto()
IMPLEMENTS = auto()
IMPORT_ALIAS_PREFIX = auto()
PERMITS = auto()
IMPLEMENTS_SUFFIX = auto()
IMPORT_ALIAS_PREFIX = auto()
IMPORT_PREFIX = auto()
IMPORT_SUFFIX = auto()
INSTANCEOF_PREFIX = auto()
Expand All @@ -213,9 +213,9 @@ class Location(Enum):
MEMBER_REFERENCE_CONTAINING = auto()
MEMBER_REFERENCE_NAME = auto()
MEMBER_REFERENCE_PREFIX = auto()
METHOD_DECLARATION_DEFAULT_VALUE = auto()
METHOD_DECLARATION_PARAMETERS = auto()
METHOD_DECLARATION_PARAMETER_SUFFIX = auto()
METHOD_DECLARATION_DEFAULT_VALUE = auto()
METHOD_DECLARATION_PREFIX = auto()
METHOD_INVOCATION_ARGUMENTS = auto()
METHOD_INVOCATION_ARGUMENT_SUFFIX = auto()
Expand All @@ -240,6 +240,7 @@ class Location(Enum):
PARAMETERIZED_TYPE_PREFIX = auto()
PARENTHESES_PREFIX = auto()
PARENTHESES_SUFFIX = auto()
PERMITS = auto()
PERMITS_SUFFIX = auto()
PRIMITIVE_PREFIX = auto()
RECORD_STATE_VECTOR = auto()
Expand All @@ -248,8 +249,8 @@ class Location(Enum):
STATEMENT_PREFIX = auto()
STATIC_IMPORT = auto()
STATIC_INIT_SUFFIX = auto()
SWITCH_PREFIX = auto()
SWITCH_EXPRESSION_PREFIX = auto()
SWITCH_PREFIX = auto()
SYNCHRONIZED_PREFIX = auto()
TERNARY_FALSE = auto()
TERNARY_PREFIX = auto()
Expand Down
62 changes: 52 additions & 10 deletions rewrite/rewrite/java/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ def with_statements(self, statements: List[Statement]) -> Case:

@property
def body(self) -> Optional[J]:
return self._body.element
return self._body.element if self._body else None

def with_body(self, body: Optional[J]) -> Case:
return self.padding.with_body(JRightPadded.with_element(self._body, body))
Expand Down Expand Up @@ -969,7 +969,7 @@ def with_primary_constructor(self, primary_constructor: Optional[List[Statement]

@property
def extends(self) -> Optional[TypeTree]:
return self._extends.element
return self._extends.element if self._extends else None

def with_extends(self, extends: Optional[TypeTree]) -> ClassDeclaration:
return self.padding.with_extends(JLeftPadded.with_element(self._extends, extends))
Expand Down Expand Up @@ -1213,7 +1213,7 @@ def with_checksum(self, checksum: Optional[Checksum]) -> CompilationUnit:

@property
def package_declaration(self) -> Optional[Package]:
return self._package_declaration.element
return self._package_declaration.element if self._package_declaration else None

def with_package_declaration(self, package_declaration: Optional[Package]) -> CompilationUnit:
return self.padding.with_package_declaration(JRightPadded.with_element(self._package_declaration, package_declaration))
Expand Down Expand Up @@ -2340,7 +2340,7 @@ def with_qualid(self, qualid: FieldAccess) -> Import:

@property
def alias(self) -> Optional[Identifier]:
return self._alias.element
return self._alias.element if self._alias else None

def with_alias(self, alias: Optional[Identifier]) -> Import:
return self.padding.with_alias(JLeftPadded.with_element(self._alias, alias))
Expand Down Expand Up @@ -3081,7 +3081,7 @@ def with_body(self, body: Optional[Block]) -> MethodDeclaration:

@property
def default_value(self) -> Optional[Expression]:
return self._default_value.element
return self._default_value.element if self._default_value else None

def with_default_value(self, default_value: Optional[Expression]) -> MethodDeclaration:
return self.padding.with_default_value(JLeftPadded.with_element(self._default_value, default_value))
Expand Down Expand Up @@ -3262,7 +3262,7 @@ def with_markers(self, markers: Markers) -> MethodInvocation:

@property
def select(self) -> Optional[Expression]:
return self._select.element
return self._select.element if self._select else None

def with_select(self, select: Optional[Expression]) -> MethodInvocation:
return self.padding.with_select(JRightPadded.with_element(self._select, select))
Expand Down Expand Up @@ -3695,7 +3695,7 @@ def with_markers(self, markers: Markers) -> NewClass:

@property
def enclosing(self) -> Optional[Expression]:
return self._enclosing.element
return self._enclosing.element if self._enclosing else None

def with_enclosing(self, enclosing: Optional[Expression]) -> NewClass:
return self.padding.with_enclosing(JRightPadded.with_element(self._enclosing, enclosing))
Expand Down Expand Up @@ -4575,7 +4575,7 @@ def with_catches(self, catches: List[Catch]) -> Try:

@property
def finally_(self) -> Optional[Block]:
return self._finally.element
return self._finally.element if self._finally else None

def with_finally(self, finally_: Optional[Block]) -> Try:
return self.padding.with_finally(JLeftPadded.with_element(self._finally, finally_))
Expand Down Expand Up @@ -5177,7 +5177,7 @@ def with_dimensions_after_name(self, dimensions_after_name: List[JLeftPadded[Spa

@property
def initializer(self) -> Optional[Expression]:
return self._initializer.element
return self._initializer.element if self._initializer else None

def with_initializer(self, initializer: Optional[Expression]) -> VariableDeclarations.NamedVariable:
return self.padding.with_initializer(JLeftPadded.with_element(self._initializer, initializer))
Expand Down Expand Up @@ -5363,7 +5363,7 @@ def with_markers(self, markers: Markers) -> Wildcard:

@property
def bound(self) -> Optional[Bound]:
return self._bound.element
return self._bound.element if self._bound else None

def with_bound(self, bound: Optional[Bound]) -> Wildcard:
return self.padding.with_bound(JLeftPadded.with_element(self._bound, bound))
Expand Down Expand Up @@ -5545,3 +5545,45 @@ def accept_java(self, v: JavaVisitor[P], p: P) -> J:

def accept_java(self, v: JavaVisitor[P], p: P) -> J:
return v.visit_unknown(self, p)

# noinspection PyShadowingBuiltins,PyShadowingNames,DuplicatedCode
@dataclass(frozen=True, eq=False)
class Erroneous(Statement, Expression):
_id: UUID

@property
def id(self) -> UUID:
return self._id

def with_id(self, id: UUID) -> Erroneous:
return self if id is self._id else replace(self, _id=id)

_prefix: Space

@property
def prefix(self) -> Space:
return self._prefix

def with_prefix(self, prefix: Space) -> Erroneous:
return self if prefix is self._prefix else replace(self, _prefix=prefix)

_markers: Markers

@property
def markers(self) -> Markers:
return self._markers

def with_markers(self, markers: Markers) -> Erroneous:
return self if markers is self._markers else replace(self, _markers=markers)

_text: str

@property
def text(self) -> str:
return self._text

def with_text(self, text: str) -> Erroneous:
return self if text is self._text else replace(self, _text=text)

def accept_java(self, v: JavaVisitor[P], p: P) -> J:
return v.visit_erroneous(self, p)
Loading

0 comments on commit fe1a22a

Please sign in to comment.