Documentation
¶
Index ¶
- Constants
- Variables
- func CollectSearchResultIDs(t Tree) []uuid.UUID
- func FindMarker[T any](markers Markers) *T
- func HasMarker[T any](markers Markers) bool
- func TypeSignature(t JavaType) string
- func UnwrapRightPadded[T any](padded []RightPadded[T]) []T
- type Annotation
- func (n *Annotation) GetID() uuid.UUID
- func (n *Annotation) GetMarkers() Markers
- func (n *Annotation) GetPrefix() Space
- func (*Annotation) IsExpression()
- func (*Annotation) IsJ()
- func (*Annotation) IsTree()
- func (n *Annotation) WithAnnotationType(annotationType Expression) *Annotation
- func (n *Annotation) WithArguments(arguments *Container[Expression]) *Annotation
- func (n *Annotation) WithID(id uuid.UUID) J
- func (n *Annotation) WithMarkers(markers Markers) *Annotation
- func (n *Annotation) WithPrefix(prefix Space) *Annotation
- type ArrayAccess
- func (n *ArrayAccess) GetID() uuid.UUID
- func (n *ArrayAccess) GetMarkers() Markers
- func (n *ArrayAccess) GetPrefix() Space
- func (*ArrayAccess) IsExpression()
- func (*ArrayAccess) IsJ()
- func (*ArrayAccess) IsTree()
- func (n *ArrayAccess) WithID(id uuid.UUID) J
- func (n *ArrayAccess) WithMarkers(markers Markers) *ArrayAccess
- func (n *ArrayAccess) WithPrefix(prefix Space) *ArrayAccess
- type ArrayDimension
- func (n *ArrayDimension) GetID() uuid.UUID
- func (n *ArrayDimension) GetMarkers() Markers
- func (n *ArrayDimension) GetPrefix() Space
- func (*ArrayDimension) IsJ()
- func (*ArrayDimension) IsTree()
- func (n *ArrayDimension) WithID(id uuid.UUID) J
- func (n *ArrayDimension) WithMarkers(markers Markers) *ArrayDimension
- func (n *ArrayDimension) WithPrefix(prefix Space) *ArrayDimension
- type ArrayType
- func (n *ArrayType) GetID() uuid.UUID
- func (n *ArrayType) GetMarkers() Markers
- func (n *ArrayType) GetPrefix() Space
- func (*ArrayType) IsExpression()
- func (*ArrayType) IsJ()
- func (*ArrayType) IsTree()
- func (n *ArrayType) WithID(id uuid.UUID) J
- func (n *ArrayType) WithMarkers(markers Markers) *ArrayType
- func (n *ArrayType) WithPrefix(prefix Space) *ArrayType
- type AssignOp
- type Assignment
- func (n *Assignment) GetID() uuid.UUID
- func (n *Assignment) GetMarkers() Markers
- func (n *Assignment) GetPrefix() Space
- func (*Assignment) IsExpression()
- func (*Assignment) IsJ()
- func (*Assignment) IsStatement()
- func (*Assignment) IsTree()
- func (n *Assignment) WithID(id uuid.UUID) J
- func (n *Assignment) WithMarkers(markers Markers) *Assignment
- func (n *Assignment) WithPrefix(prefix Space) *Assignment
- func (n *Assignment) WithVariable(variable Expression) *Assignment
- type AssignmentOperation
- func (n *AssignmentOperation) GetID() uuid.UUID
- func (n *AssignmentOperation) GetMarkers() Markers
- func (n *AssignmentOperation) GetPrefix() Space
- func (*AssignmentOperation) IsExpression()
- func (*AssignmentOperation) IsJ()
- func (*AssignmentOperation) IsStatement()
- func (*AssignmentOperation) IsTree()
- func (n *AssignmentOperation) WithID(id uuid.UUID) J
- func (n *AssignmentOperation) WithMarkers(markers Markers) *AssignmentOperation
- func (n *AssignmentOperation) WithPrefix(prefix Space) *AssignmentOperation
- func (n *AssignmentOperation) WithVariable(variable Expression) *AssignmentOperation
- type AssignmentOperator
- type Binary
- func (n *Binary) GetID() uuid.UUID
- func (n *Binary) GetMarkers() Markers
- func (n *Binary) GetPrefix() Space
- func (*Binary) IsExpression()
- func (*Binary) IsJ()
- func (*Binary) IsTree()
- func (n *Binary) WithID(id uuid.UUID) J
- func (n *Binary) WithLeft(left Expression) *Binary
- func (n *Binary) WithMarkers(markers Markers) *Binary
- func (n *Binary) WithPrefix(prefix Space) *Binary
- func (n *Binary) WithRight(right Expression) *Binary
- type BinaryOperator
- type Block
- func (n *Block) GetID() uuid.UUID
- func (n *Block) GetMarkers() Markers
- func (n *Block) GetPrefix() Space
- func (*Block) IsJ()
- func (*Block) IsStatement()
- func (*Block) IsTree()
- func (n *Block) WithEnd(end Space) *Block
- func (n *Block) WithID(id uuid.UUID) J
- func (n *Block) WithMarkers(markers Markers) *Block
- func (n *Block) WithPrefix(prefix Space) *Block
- func (n *Block) WithStatements(statements []RightPadded[Statement]) *Block
- type Break
- func (n *Break) GetID() uuid.UUID
- func (n *Break) GetMarkers() Markers
- func (n *Break) GetPrefix() Space
- func (*Break) IsJ()
- func (*Break) IsStatement()
- func (*Break) IsTree()
- func (n *Break) WithID(id uuid.UUID) J
- func (n *Break) WithMarkers(markers Markers) *Break
- func (n *Break) WithPrefix(prefix Space) *Break
- type Case
- func (n *Case) GetID() uuid.UUID
- func (n *Case) GetMarkers() Markers
- func (n *Case) GetPrefix() Space
- func (*Case) IsJ()
- func (*Case) IsStatement()
- func (*Case) IsTree()
- func (n *Case) WithID(id uuid.UUID) J
- func (n *Case) WithMarkers(markers Markers) *Case
- func (n *Case) WithPrefix(prefix Space) *Case
- type Comment
- type CommentKind
- type Container
- type Continue
- func (n *Continue) GetID() uuid.UUID
- func (n *Continue) GetMarkers() Markers
- func (n *Continue) GetPrefix() Space
- func (*Continue) IsJ()
- func (*Continue) IsStatement()
- func (*Continue) IsTree()
- func (n *Continue) WithID(id uuid.UUID) J
- func (n *Continue) WithMarkers(markers Markers) *Continue
- func (n *Continue) WithPrefix(prefix Space) *Continue
- type ControlParentheses
- func (n *ControlParentheses) GetID() uuid.UUID
- func (n *ControlParentheses) GetMarkers() Markers
- func (n *ControlParentheses) GetPrefix() Space
- func (*ControlParentheses) IsExpression()
- func (*ControlParentheses) IsJ()
- func (*ControlParentheses) IsTree()
- func (n *ControlParentheses) WithID(id uuid.UUID) J
- func (n *ControlParentheses) WithMarkers(markers Markers) *ControlParentheses
- func (n *ControlParentheses) WithPrefix(prefix Space) *ControlParentheses
- type Else
- type Empty
- type Expression
- type FieldAccess
- func (n *FieldAccess) GetID() uuid.UUID
- func (n *FieldAccess) GetMarkers() Markers
- func (n *FieldAccess) GetPrefix() Space
- func (*FieldAccess) IsExpression()
- func (*FieldAccess) IsJ()
- func (*FieldAccess) IsTree()
- func (n *FieldAccess) WithID(id uuid.UUID) J
- func (n *FieldAccess) WithMarkers(markers Markers) *FieldAccess
- func (n *FieldAccess) WithPrefix(prefix Space) *FieldAccess
- func (n *FieldAccess) WithTarget(target Expression) *FieldAccess
- type ForControl
- func (n *ForControl) GetID() uuid.UUID
- func (n *ForControl) GetMarkers() Markers
- func (n *ForControl) GetPrefix() Space
- func (*ForControl) IsJ()
- func (*ForControl) IsTree()
- func (n *ForControl) WithID(id uuid.UUID) J
- func (n *ForControl) WithMarkers(markers Markers) *ForControl
- func (n *ForControl) WithPrefix(prefix Space) *ForControl
- type ForEachControl
- func (n *ForEachControl) GetID() uuid.UUID
- func (n *ForEachControl) GetMarkers() Markers
- func (n *ForEachControl) GetPrefix() Space
- func (*ForEachControl) IsJ()
- func (*ForEachControl) IsTree()
- func (n *ForEachControl) WithID(id uuid.UUID) J
- func (n *ForEachControl) WithMarkers(markers Markers) *ForEachControl
- func (n *ForEachControl) WithPrefix(prefix Space) *ForEachControl
- type ForEachLoop
- func (n *ForEachLoop) GetID() uuid.UUID
- func (n *ForEachLoop) GetMarkers() Markers
- func (n *ForEachLoop) GetPrefix() Space
- func (*ForEachLoop) IsJ()
- func (*ForEachLoop) IsStatement()
- func (*ForEachLoop) IsTree()
- func (n *ForEachLoop) WithBody(body *Block) *ForEachLoop
- func (n *ForEachLoop) WithID(id uuid.UUID) J
- func (n *ForEachLoop) WithMarkers(markers Markers) *ForEachLoop
- func (n *ForEachLoop) WithPrefix(prefix Space) *ForEachLoop
- type ForLoop
- func (n *ForLoop) GetID() uuid.UUID
- func (n *ForLoop) GetMarkers() Markers
- func (n *ForLoop) GetPrefix() Space
- func (*ForLoop) IsJ()
- func (*ForLoop) IsStatement()
- func (*ForLoop) IsTree()
- func (n *ForLoop) WithBody(body *Block) *ForLoop
- func (n *ForLoop) WithID(id uuid.UUID) J
- func (n *ForLoop) WithMarkers(markers Markers) *ForLoop
- func (n *ForLoop) WithPrefix(prefix Space) *ForLoop
- type FullyQualified
- type GenericMarker
- type GoProject
- type Identifier
- func (n *Identifier) GetID() uuid.UUID
- func (n *Identifier) GetMarkers() Markers
- func (n *Identifier) GetPrefix() Space
- func (*Identifier) IsExpression()
- func (*Identifier) IsJ()
- func (*Identifier) IsTree()
- func (n *Identifier) WithFieldType(ft *JavaTypeVariable) *Identifier
- func (n *Identifier) WithID(id uuid.UUID) J
- func (n *Identifier) WithMarkers(markers Markers) *Identifier
- func (n *Identifier) WithName(name string) *Identifier
- func (n *Identifier) WithPrefix(prefix Space) *Identifier
- func (n *Identifier) WithType(t JavaType) *Identifier
- type If
- func (n *If) GetID() uuid.UUID
- func (n *If) GetMarkers() Markers
- func (n *If) GetPrefix() Space
- func (*If) IsJ()
- func (*If) IsStatement()
- func (*If) IsTree()
- func (n *If) WithCondition(condition Expression) *If
- func (n *If) WithID(id uuid.UUID) J
- func (n *If) WithMarkers(markers Markers) *If
- func (n *If) WithPrefix(prefix Space) *If
- func (n *If) WithThen(then *Block) *If
- type Import
- type J
- type JavaType
- type JavaTypeAnnotation
- type JavaTypeAnnotationArrayElementValue
- type JavaTypeAnnotationElementValue
- type JavaTypeAnnotationSingleElementValue
- type JavaTypeArray
- type JavaTypeClass
- type JavaTypeGenericTypeVariable
- type JavaTypeIntersection
- type JavaTypeMethod
- type JavaTypeMultiCatch
- type JavaTypeParameterized
- type JavaTypePrimitive
- type JavaTypeShallowClass
- type JavaTypeUnknown
- type JavaTypeVariable
- type Label
- func (n *Label) GetID() uuid.UUID
- func (n *Label) GetMarkers() Markers
- func (n *Label) GetPrefix() Space
- func (*Label) IsJ()
- func (*Label) IsStatement()
- func (*Label) IsTree()
- func (n *Label) WithID(id uuid.UUID) J
- func (n *Label) WithMarkers(markers Markers) *Label
- func (n *Label) WithPrefix(prefix Space) *Label
- type LeftPadded
- type Literal
- func (n *Literal) GetID() uuid.UUID
- func (n *Literal) GetMarkers() Markers
- func (n *Literal) GetPrefix() Space
- func (*Literal) IsExpression()
- func (*Literal) IsJ()
- func (*Literal) IsTree()
- func (n *Literal) WithID(id uuid.UUID) J
- func (n *Literal) WithMarkers(markers Markers) *Literal
- func (n *Literal) WithPrefix(prefix Space) *Literal
- func (n *Literal) WithSource(source string) *Literal
- func (n *Literal) WithValue(value any) *Literal
- type LiteralKind
- type Marker
- type Markers
- func AddMarker(markers Markers, marker Marker) Markers
- func FoundSearchResult(markers Markers, description string) Markers
- func MarkupError(markers Markers, message string) Markers
- func MarkupInfo(markers Markers, message string) Markers
- func MarkupWarn(markers Markers, message string) Markers
- func MarkupWarnDetail(markers Markers, message, detail string) Markers
- type Markup
- type MarkupLevel
- type MethodDeclaration
- func (n *MethodDeclaration) GetID() uuid.UUID
- func (n *MethodDeclaration) GetMarkers() Markers
- func (n *MethodDeclaration) GetPrefix() Space
- func (*MethodDeclaration) IsExpression()
- func (*MethodDeclaration) IsJ()
- func (*MethodDeclaration) IsStatement()
- func (*MethodDeclaration) IsTree()
- func (n *MethodDeclaration) WithBody(body *Block) *MethodDeclaration
- func (n *MethodDeclaration) WithID(id uuid.UUID) J
- func (n *MethodDeclaration) WithLeadingAnnotations(anns []*Annotation) *MethodDeclaration
- func (n *MethodDeclaration) WithMarkers(markers Markers) *MethodDeclaration
- func (n *MethodDeclaration) WithName(name *Identifier) *MethodDeclaration
- func (n *MethodDeclaration) WithPrefix(prefix Space) *MethodDeclaration
- func (n *MethodDeclaration) WithTypeParameters(tps *TypeParameters) *MethodDeclaration
- type MethodInvocation
- func (n *MethodInvocation) GetID() uuid.UUID
- func (n *MethodInvocation) GetMarkers() Markers
- func (n *MethodInvocation) GetPrefix() Space
- func (*MethodInvocation) IsExpression()
- func (*MethodInvocation) IsJ()
- func (*MethodInvocation) IsStatement()
- func (*MethodInvocation) IsTree()
- func (n *MethodInvocation) WithID(id uuid.UUID) J
- func (n *MethodInvocation) WithMarkers(markers Markers) *MethodInvocation
- func (n *MethodInvocation) WithName(name *Identifier) *MethodInvocation
- func (n *MethodInvocation) WithPrefix(prefix Space) *MethodInvocation
- func (n *MethodInvocation) WithTypeParameters(typeParameters *Container[Expression]) *MethodInvocation
- type ParameterizedType
- func (n *ParameterizedType) GetID() uuid.UUID
- func (n *ParameterizedType) GetMarkers() Markers
- func (n *ParameterizedType) GetPrefix() Space
- func (*ParameterizedType) IsExpression()
- func (*ParameterizedType) IsJ()
- func (*ParameterizedType) IsTree()
- func (n *ParameterizedType) WithID(id uuid.UUID) J
- func (n *ParameterizedType) WithMarkers(markers Markers) *ParameterizedType
- func (n *ParameterizedType) WithPrefix(prefix Space) *ParameterizedType
- type Parentheses
- func (n *Parentheses) GetID() uuid.UUID
- func (n *Parentheses) GetMarkers() Markers
- func (n *Parentheses) GetPrefix() Space
- func (*Parentheses) IsExpression()
- func (*Parentheses) IsJ()
- func (*Parentheses) IsTree()
- func (n *Parentheses) WithID(id uuid.UUID) J
- func (n *Parentheses) WithMarkers(markers Markers) *Parentheses
- func (n *Parentheses) WithPrefix(prefix Space) *Parentheses
- type ParseError
- type ParseExceptionResult
- type Return
- func (n *Return) GetID() uuid.UUID
- func (n *Return) GetMarkers() Markers
- func (n *Return) GetPrefix() Space
- func (*Return) IsJ()
- func (*Return) IsStatement()
- func (*Return) IsTree()
- func (n *Return) WithID(id uuid.UUID) J
- func (n *Return) WithMarkers(markers Markers) *Return
- func (n *Return) WithPrefix(prefix Space) *Return
- type RightPadded
- type SearchResult
- type SearchResultMarker
- type Semicolon
- type SourceFile
- type Space
- type Statement
- type Switch
- func (n *Switch) GetID() uuid.UUID
- func (n *Switch) GetMarkers() Markers
- func (n *Switch) GetPrefix() Space
- func (*Switch) IsJ()
- func (*Switch) IsStatement()
- func (*Switch) IsTree()
- func (n *Switch) WithBody(body *Block) *Switch
- func (n *Switch) WithID(id uuid.UUID) J
- func (n *Switch) WithMarkers(markers Markers) *Switch
- func (n *Switch) WithPrefix(prefix Space) *Switch
- type Tree
- type TypeCast
- func (n *TypeCast) GetID() uuid.UUID
- func (n *TypeCast) GetMarkers() Markers
- func (n *TypeCast) GetPrefix() Space
- func (*TypeCast) IsExpression()
- func (*TypeCast) IsJ()
- func (*TypeCast) IsTree()
- func (n *TypeCast) WithID(id uuid.UUID) J
- func (n *TypeCast) WithMarkers(markers Markers) *TypeCast
- func (n *TypeCast) WithPrefix(prefix Space) *TypeCast
- type TypeParameter
- func (n *TypeParameter) GetID() uuid.UUID
- func (n *TypeParameter) GetMarkers() Markers
- func (n *TypeParameter) GetPrefix() Space
- func (*TypeParameter) IsJ()
- func (*TypeParameter) IsTree()
- func (n *TypeParameter) WithID(id uuid.UUID) J
- func (n *TypeParameter) WithMarkers(markers Markers) *TypeParameter
- func (n *TypeParameter) WithPrefix(prefix Space) *TypeParameter
- type TypeParameters
- func (n *TypeParameters) GetID() uuid.UUID
- func (n *TypeParameters) GetMarkers() Markers
- func (n *TypeParameters) GetPrefix() Space
- func (*TypeParameters) IsJ()
- func (*TypeParameters) IsTree()
- func (n *TypeParameters) WithID(id uuid.UUID) J
- func (n *TypeParameters) WithMarkers(markers Markers) *TypeParameters
- func (n *TypeParameters) WithPrefix(prefix Space) *TypeParameters
- type Unary
- func (n *Unary) GetID() uuid.UUID
- func (n *Unary) GetMarkers() Markers
- func (n *Unary) GetPrefix() Space
- func (*Unary) IsExpression()
- func (*Unary) IsJ()
- func (*Unary) IsStatement()
- func (*Unary) IsTree()
- func (n *Unary) WithID(id uuid.UUID) J
- func (n *Unary) WithMarkers(markers Markers) *Unary
- func (n *Unary) WithOperand(operand Expression) *Unary
- func (n *Unary) WithPrefix(prefix Space) *Unary
- type UnaryOperator
- type VariableDeclarations
- func (n *VariableDeclarations) GetID() uuid.UUID
- func (n *VariableDeclarations) GetMarkers() Markers
- func (n *VariableDeclarations) GetPrefix() Space
- func (*VariableDeclarations) IsJ()
- func (*VariableDeclarations) IsStatement()
- func (*VariableDeclarations) IsTree()
- func (n *VariableDeclarations) WithID(id uuid.UUID) J
- func (n *VariableDeclarations) WithLeadingAnnotations(anns []*Annotation) *VariableDeclarations
- func (n *VariableDeclarations) WithMarkers(markers Markers) *VariableDeclarations
- func (n *VariableDeclarations) WithPrefix(prefix Space) *VariableDeclarations
- type VariableDeclarator
- func (n *VariableDeclarator) GetID() uuid.UUID
- func (n *VariableDeclarator) GetMarkers() Markers
- func (n *VariableDeclarator) GetPrefix() Space
- func (*VariableDeclarator) IsJ()
- func (*VariableDeclarator) IsTree()
- func (n *VariableDeclarator) WithID(id uuid.UUID) J
- func (n *VariableDeclarator) WithMarkers(markers Markers) *VariableDeclarator
- func (n *VariableDeclarator) WithName(name *Identifier) *VariableDeclarator
- func (n *VariableDeclarator) WithPrefix(prefix Space) *VariableDeclarator
Constants ¶
const ( JavaTypeClassKind = "org.openrewrite.java.tree.JavaType$Class" JavaTypeShallowClassKind = "org.openrewrite.java.tree.JavaType$ShallowClass" JavaTypeParameterizedKind = "org.openrewrite.java.tree.JavaType$Parameterized" JavaTypeGenericTypeVariableKind = "org.openrewrite.java.tree.JavaType$GenericTypeVariable" JavaTypeArrayKind = "org.openrewrite.java.tree.JavaType$Array" JavaTypePrimitiveKind = "org.openrewrite.java.tree.JavaType$Primitive" JavaTypeMethodKind = "org.openrewrite.java.tree.JavaType$Method" JavaTypeVariableKind = "org.openrewrite.java.tree.JavaType$Variable" JavaTypeAnnotationKind = "org.openrewrite.java.tree.JavaType$Annotation" JavaTypeAnnotationSingleElementValueKind = "org.openrewrite.java.tree.JavaType$Annotation$SingleElementValue" JavaTypeAnnotationArrayElementValueKind = "org.openrewrite.java.tree.JavaType$Annotation$ArrayElementValue" JavaTypeMultiCatchKind = "org.openrewrite.java.tree.JavaType$MultiCatch" JavaTypeIntersectionKind = "org.openrewrite.java.tree.JavaType$Intersection" JavaTypeUnknownKind = "org.openrewrite.java.tree.JavaType$Unknown" )
Java class name constants for RPC deserialization.
Variables ¶
var EmptySpace = Space{}
EmptySpace is the zero-value Space with no whitespace or comments.
var SingleSpace = Space{Whitespace: " "}
SingleSpace is a Space containing exactly one space character.
var UnknownType = &JavaTypeUnknown{}
UnknownType is the singleton instance of JavaTypeUnknown.
Functions ¶
func CollectSearchResultIDs ¶
CollectSearchResultIDs walks the given tree and returns the IDs of every SearchResult and SearchResultMarker found in any node's Markers. The returned slice has stable insertion order; duplicates are dropped.
Implementation: reflection-based descent. Every LST node has a `Markers Markers` field, plus zero or more child fields that are themselves trees (or wrappers like RightPadded / LeftPadded / Container holding trees). A visitor-based walker would be cleaner but would require every concrete node type to opt in; reflection lets BatchVisit collect search markers without touching the 60+ node definitions.
func FindMarker ¶
FindMarker returns a pointer to the first marker of type T, or nil if not found.
func TypeSignature ¶
TypeSignature computes a string signature for a JavaType, used for list identity tracking in the RPC protocol. Mirrors DefaultJavaTypeSignatureBuilder in Java.
func UnwrapRightPadded ¶
func UnwrapRightPadded[T any](padded []RightPadded[T]) []T
UnwrapRightPadded extracts the elements from a slice of RightPadded wrappers.
Types ¶
type Annotation ¶
type Annotation struct {
ID uuid.UUID
Prefix Space
Markers Markers
AnnotationType Expression // NameTree — Identifier or FieldAccess
Arguments *Container[Expression] // nullable; tags always have one Literal
}
Annotation represents annotation metadata attached to a declaration. Mirrors org.openrewrite.java.tree.J.Annotation.
Java has first-class `@Annotation(args)` syntax. Go has no `@`, but has two analogous concepts that this type models uniformly:
Struct field tags. Each `key:"value"` pair in a struct field tag becomes one Annotation on the field's VariableDeclarations: AnnotationType = Identifier{Name: key}, Arguments = [Literal{Value: value}]. The printer renders the run of struct-tag annotations on a VariableDeclarations whose parent is a StructType as a single backtick-wrapped tag.
Source directives like `//go:noinline`, `//go:generate`, `//lint:ignore`. Each directive becomes one Annotation on the enclosing MethodDeclaration / TypeDecl / VariableDeclarations: AnnotationType = Identifier{Name: "go:noinline"}, Arguments = [Literal(args)] when the directive carries text after the keyword, else nil.
In both cases, AnnotationType is an Expression (typically Identifier; FieldAccess for qualified directives like `lint:ignore`).
Recipes use AnnotationService to inspect / match / mutate, mirroring Java's AnnotationService surface.
func (*Annotation) GetID ¶
func (n *Annotation) GetID() uuid.UUID
func (*Annotation) GetMarkers ¶
func (n *Annotation) GetMarkers() Markers
func (*Annotation) GetPrefix ¶
func (n *Annotation) GetPrefix() Space
func (*Annotation) IsExpression ¶
func (*Annotation) IsExpression()
func (*Annotation) IsJ ¶
func (*Annotation) IsJ()
func (*Annotation) IsTree ¶
func (*Annotation) IsTree()
func (*Annotation) WithAnnotationType ¶
func (n *Annotation) WithAnnotationType(annotationType Expression) *Annotation
func (*Annotation) WithArguments ¶
func (n *Annotation) WithArguments(arguments *Container[Expression]) *Annotation
func (*Annotation) WithMarkers ¶
func (n *Annotation) WithMarkers(markers Markers) *Annotation
func (*Annotation) WithPrefix ¶
func (n *Annotation) WithPrefix(prefix Space) *Annotation
type ArrayAccess ¶
type ArrayAccess struct {
ID uuid.UUID
Prefix Space
Markers Markers
Indexed Expression
Dimension *ArrayDimension
Type JavaType // the result type (nullable)
}
ArrayAccess represents an index expression like `a[i]` or `m[key]`.
func (*ArrayAccess) GetID ¶
func (n *ArrayAccess) GetID() uuid.UUID
func (*ArrayAccess) GetMarkers ¶
func (n *ArrayAccess) GetMarkers() Markers
func (*ArrayAccess) GetPrefix ¶
func (n *ArrayAccess) GetPrefix() Space
func (*ArrayAccess) IsExpression ¶
func (*ArrayAccess) IsExpression()
func (*ArrayAccess) IsJ ¶
func (*ArrayAccess) IsJ()
func (*ArrayAccess) IsTree ¶
func (*ArrayAccess) IsTree()
func (*ArrayAccess) WithMarkers ¶
func (n *ArrayAccess) WithMarkers(markers Markers) *ArrayAccess
func (*ArrayAccess) WithPrefix ¶
func (n *ArrayAccess) WithPrefix(prefix Space) *ArrayAccess
type ArrayDimension ¶
type ArrayDimension struct {
ID uuid.UUID
Prefix Space
Markers Markers
Index RightPadded[Expression] // Element = index expr, After = space before `]`
}
ArrayDimension represents the `[index]` part of an array access.
func (*ArrayDimension) GetID ¶
func (n *ArrayDimension) GetID() uuid.UUID
func (*ArrayDimension) GetMarkers ¶
func (n *ArrayDimension) GetMarkers() Markers
func (*ArrayDimension) GetPrefix ¶
func (n *ArrayDimension) GetPrefix() Space
func (*ArrayDimension) IsJ ¶
func (*ArrayDimension) IsJ()
func (*ArrayDimension) IsTree ¶
func (*ArrayDimension) IsTree()
func (*ArrayDimension) WithMarkers ¶
func (n *ArrayDimension) WithMarkers(markers Markers) *ArrayDimension
func (*ArrayDimension) WithPrefix ¶
func (n *ArrayDimension) WithPrefix(prefix Space) *ArrayDimension
type ArrayType ¶
type ArrayType struct {
ID uuid.UUID
Prefix Space
Markers Markers
Dimension LeftPadded[Space] // Before = space before `[`, Element = space inside brackets before `]`; for `[N]T`, the length expr is stored separately
Length Expression // nil for slices (`[]T`), non-nil for arrays (`[N]T`)
ElementType Expression // the element type
Type JavaType // the array type (nullable)
}
ArrayType represents an array or slice type like `[]T`, `[N]T`.
func (*ArrayType) GetMarkers ¶
func (*ArrayType) IsExpression ¶
func (*ArrayType) IsExpression()
func (*ArrayType) WithMarkers ¶
func (*ArrayType) WithPrefix ¶
type AssignOp ¶
type AssignOp int
AssignOp distinguishes := from = in assignment contexts.
func ParseAssignOp ¶
ParseAssignOp converts a string to an AssignOp. Accepts both the Go enum names emitted by AssignOp.String() ("Equals", "Define") and the Java-side source-symbol spellings ("=", ":=").
type Assignment ¶
type Assignment struct {
ID uuid.UUID
Prefix Space
Markers Markers
Variable Expression
Value LeftPadded[Expression]
Type JavaType // the result type (nullable)
}
Assignment represents an assignment statement like `x = expr`.
func (*Assignment) GetID ¶
func (n *Assignment) GetID() uuid.UUID
func (*Assignment) GetMarkers ¶
func (n *Assignment) GetMarkers() Markers
func (*Assignment) GetPrefix ¶
func (n *Assignment) GetPrefix() Space
func (*Assignment) IsExpression ¶
func (*Assignment) IsExpression()
func (*Assignment) IsJ ¶
func (*Assignment) IsJ()
func (*Assignment) IsStatement ¶
func (*Assignment) IsStatement()
func (*Assignment) IsTree ¶
func (*Assignment) IsTree()
func (*Assignment) WithMarkers ¶
func (n *Assignment) WithMarkers(markers Markers) *Assignment
func (*Assignment) WithPrefix ¶
func (n *Assignment) WithPrefix(prefix Space) *Assignment
func (*Assignment) WithVariable ¶
func (n *Assignment) WithVariable(variable Expression) *Assignment
type AssignmentOperation ¶
type AssignmentOperation struct {
ID uuid.UUID
Prefix Space
Markers Markers
Variable Expression
Operator LeftPadded[AssignmentOperator]
Assignment Expression
Type JavaType // the result type (nullable)
}
AssignmentOperation represents a compound assignment like `x += expr`.
func (*AssignmentOperation) GetID ¶
func (n *AssignmentOperation) GetID() uuid.UUID
func (*AssignmentOperation) GetMarkers ¶
func (n *AssignmentOperation) GetMarkers() Markers
func (*AssignmentOperation) GetPrefix ¶
func (n *AssignmentOperation) GetPrefix() Space
func (*AssignmentOperation) IsExpression ¶
func (*AssignmentOperation) IsExpression()
func (*AssignmentOperation) IsJ ¶
func (*AssignmentOperation) IsJ()
func (*AssignmentOperation) IsStatement ¶
func (*AssignmentOperation) IsStatement()
func (*AssignmentOperation) IsTree ¶
func (*AssignmentOperation) IsTree()
func (*AssignmentOperation) WithMarkers ¶
func (n *AssignmentOperation) WithMarkers(markers Markers) *AssignmentOperation
func (*AssignmentOperation) WithPrefix ¶
func (n *AssignmentOperation) WithPrefix(prefix Space) *AssignmentOperation
func (*AssignmentOperation) WithVariable ¶
func (n *AssignmentOperation) WithVariable(variable Expression) *AssignmentOperation
type AssignmentOperator ¶
type AssignmentOperator int
const ( AddAssign AssignmentOperator = iota + 1 // += SubAssign // -= MulAssign // *= DivAssign // /= ModAssign // %= AndAssign // &= OrAssign // |= XorAssign // ^= ShlAssign // <<= ShrAssign // >>= AndNotAssign // &^= (Go-specific) )
func ParseAssignmentOperator ¶
func ParseAssignmentOperator(s string) AssignmentOperator
ParseAssignmentOperator converts a Java enum name to an AssignmentOperator.
func (AssignmentOperator) String ¶
func (op AssignmentOperator) String() string
String returns the Java enum name for this AssignmentOperator.
type Binary ¶
type Binary struct {
ID uuid.UUID
Prefix Space
Markers Markers
Left Expression
Operator LeftPadded[BinaryOperator]
Right Expression
Type JavaType // the result type (nullable)
}
Binary represents a binary expression like `a + b`.
func (*Binary) GetMarkers ¶
func (*Binary) IsExpression ¶
func (*Binary) IsExpression()
func (*Binary) WithLeft ¶
func (n *Binary) WithLeft(left Expression) *Binary
func (*Binary) WithMarkers ¶
func (*Binary) WithPrefix ¶
func (*Binary) WithRight ¶
func (n *Binary) WithRight(right Expression) *Binary
type BinaryOperator ¶
type BinaryOperator int
BinaryOperator represents the operator in a binary expression.
const ( Add BinaryOperator = iota + 1 Subtract Multiply Divide Modulo And Or BitwiseAnd BitwiseOr BitwiseXor LeftShift RightShift Equal NotEqual LessThan LessThanOrEqual GreaterThan GreaterThanOrEqual LogicalAnd LogicalOr AndNot // Go-specific: &^ )
func ParseBinaryOperator ¶
func ParseBinaryOperator(s string) BinaryOperator
ParseBinaryOperator converts a Java enum name to a BinaryOperator.
func (BinaryOperator) String ¶
func (op BinaryOperator) String() string
String returns the Java enum name for this BinaryOperator.
type Block ¶
type Block struct {
ID uuid.UUID
Prefix Space
Markers Markers
Statements []RightPadded[Statement]
End Space // whitespace before the closing brace
}
Block represents a brace-delimited block of statements.
func (*Block) GetMarkers ¶
func (*Block) IsStatement ¶
func (*Block) IsStatement()
func (*Block) WithMarkers ¶
func (*Block) WithPrefix ¶
func (*Block) WithStatements ¶
func (n *Block) WithStatements(statements []RightPadded[Statement]) *Block
type Break ¶
type Break struct {
ID uuid.UUID
Prefix Space
Markers Markers
Label *Identifier // nil if no label
}
Break represents a break statement with optional label.
func (*Break) GetMarkers ¶
func (*Break) IsStatement ¶
func (*Break) IsStatement()
func (*Break) WithMarkers ¶
func (*Break) WithPrefix ¶
type Case ¶
type Case struct {
ID uuid.UUID
Prefix Space
Markers Markers
Expressions Container[Expression] // empty for default case
Body []RightPadded[Statement] // statements after the colon
}
Case represents a case or default clause in a switch statement.
func (*Case) GetMarkers ¶
func (*Case) IsStatement ¶
func (*Case) IsStatement()
func (*Case) WithMarkers ¶
func (*Case) WithPrefix ¶
type Comment ¶
type Comment struct {
Kind CommentKind
Text string
Suffix string // whitespace after the comment, before the next token
Multiline bool
Markers Markers
}
Comment represents a comment in source code.
type Container ¶
type Container[T any] struct { Before Space Elements []RightPadded[T] Markers Markers }
Container wraps a list of elements with surrounding whitespace, representing constructs like parenthesized argument lists or bracketed type parameters.
type Continue ¶
type Continue struct {
ID uuid.UUID
Prefix Space
Markers Markers
Label *Identifier // nil if no label
}
Continue represents a continue statement with optional label.
func (*Continue) GetMarkers ¶
func (*Continue) IsStatement ¶
func (*Continue) IsStatement()
func (*Continue) WithMarkers ¶
func (*Continue) WithPrefix ¶
type ControlParentheses ¶
type ControlParentheses struct {
ID uuid.UUID
Prefix Space
Markers Markers
Tree RightPadded[Expression] // Element = inner, After = space before `)`
}
ControlParentheses wraps an expression in parentheses for control flow.
func (*ControlParentheses) GetID ¶
func (n *ControlParentheses) GetID() uuid.UUID
func (*ControlParentheses) GetMarkers ¶
func (n *ControlParentheses) GetMarkers() Markers
func (*ControlParentheses) GetPrefix ¶
func (n *ControlParentheses) GetPrefix() Space
func (*ControlParentheses) IsExpression ¶
func (*ControlParentheses) IsExpression()
func (*ControlParentheses) IsJ ¶
func (*ControlParentheses) IsJ()
func (*ControlParentheses) IsTree ¶
func (*ControlParentheses) IsTree()
func (*ControlParentheses) WithMarkers ¶
func (n *ControlParentheses) WithMarkers(markers Markers) *ControlParentheses
func (*ControlParentheses) WithPrefix ¶
func (n *ControlParentheses) WithPrefix(prefix Space) *ControlParentheses
type Else ¶
Else represents an else clause of an if statement. This matches Java's J.If.Else for RPC wire format compatibility.
func (*Else) GetMarkers ¶
func (*Else) WithMarkers ¶
func (*Else) WithPrefix ¶
type Empty ¶
Empty represents an empty statement or expression placeholder.
func (*Empty) GetMarkers ¶
func (*Empty) IsExpression ¶
func (*Empty) IsExpression()
func (*Empty) IsStatement ¶
func (*Empty) IsStatement()
func (*Empty) WithPrefix ¶
type Expression ¶
type Expression interface {
J
IsExpression()
}
Expression is a J node that evaluates to a value.
type FieldAccess ¶
type FieldAccess struct {
ID uuid.UUID
Prefix Space
Markers Markers
Target Expression
Name LeftPadded[*Identifier]
Type JavaType // the result type (nullable)
}
FieldAccess represents a field or method access like `obj.Field`.
func (*FieldAccess) GetID ¶
func (n *FieldAccess) GetID() uuid.UUID
func (*FieldAccess) GetMarkers ¶
func (n *FieldAccess) GetMarkers() Markers
func (*FieldAccess) GetPrefix ¶
func (n *FieldAccess) GetPrefix() Space
func (*FieldAccess) IsExpression ¶
func (*FieldAccess) IsExpression()
func (*FieldAccess) IsJ ¶
func (*FieldAccess) IsJ()
func (*FieldAccess) IsTree ¶
func (*FieldAccess) IsTree()
func (*FieldAccess) WithMarkers ¶
func (n *FieldAccess) WithMarkers(markers Markers) *FieldAccess
func (*FieldAccess) WithPrefix ¶
func (n *FieldAccess) WithPrefix(prefix Space) *FieldAccess
func (*FieldAccess) WithTarget ¶
func (n *FieldAccess) WithTarget(target Expression) *FieldAccess
type ForControl ¶
type ForControl struct {
ID uuid.UUID
Prefix Space
Markers Markers
Init *RightPadded[Statement] // nil for condition-only or infinite loops
Condition *RightPadded[Expression] // nil for infinite loops
Update *RightPadded[Statement] // nil when no update clause
}
ForControl holds the init, condition, and update of a for loop. When Init is non-nil, this is a 3-clause loop with semicolons; Init.After and Condition.After capture whitespace around semicolons. When Init is nil and Condition is non-nil, it's a condition-only loop (no semicolons). When both are nil, it's an infinite loop.
func (*ForControl) GetID ¶
func (n *ForControl) GetID() uuid.UUID
func (*ForControl) GetMarkers ¶
func (n *ForControl) GetMarkers() Markers
func (*ForControl) GetPrefix ¶
func (n *ForControl) GetPrefix() Space
func (*ForControl) IsJ ¶
func (*ForControl) IsJ()
func (*ForControl) IsTree ¶
func (*ForControl) IsTree()
func (*ForControl) WithMarkers ¶
func (n *ForControl) WithMarkers(markers Markers) *ForControl
func (*ForControl) WithPrefix ¶
func (n *ForControl) WithPrefix(prefix Space) *ForControl
type ForEachControl ¶
type ForEachControl struct {
ID uuid.UUID
Prefix Space
Markers Markers
Key *RightPadded[Expression] // nil for `for range expr`; After = space after key (including comma)
Value *RightPadded[Expression] // nil when no value; After = space before operator
Operator LeftPadded[AssignOp] // `:=` or `=`; Before = space before operator. Unused when Key is nil
Iterable Expression // expression after "range" keyword
}
ForEachControl holds the variable and iterable of a for-range loop. The "range" keyword is implicit (always present).
Structure: `for` [key] [`,` value] [`:=`|`=`] `range` iterable
- Key and Value may be nil (e.g., `for range expr {}`)
- When Key is non-nil, Operator contains `:=` or `=`
func (*ForEachControl) GetID ¶
func (n *ForEachControl) GetID() uuid.UUID
func (*ForEachControl) GetMarkers ¶
func (n *ForEachControl) GetMarkers() Markers
func (*ForEachControl) GetPrefix ¶
func (n *ForEachControl) GetPrefix() Space
func (*ForEachControl) IsJ ¶
func (*ForEachControl) IsJ()
func (*ForEachControl) IsTree ¶
func (*ForEachControl) IsTree()
func (*ForEachControl) WithMarkers ¶
func (n *ForEachControl) WithMarkers(markers Markers) *ForEachControl
func (*ForEachControl) WithPrefix ¶
func (n *ForEachControl) WithPrefix(prefix Space) *ForEachControl
type ForEachLoop ¶
type ForEachLoop struct {
ID uuid.UUID
Prefix Space
Markers Markers
Control ForEachControl
Body *Block
}
ForEachLoop represents a for-range loop: `for k, v := range expr { body }`
func (*ForEachLoop) GetID ¶
func (n *ForEachLoop) GetID() uuid.UUID
func (*ForEachLoop) GetMarkers ¶
func (n *ForEachLoop) GetMarkers() Markers
func (*ForEachLoop) GetPrefix ¶
func (n *ForEachLoop) GetPrefix() Space
func (*ForEachLoop) IsJ ¶
func (*ForEachLoop) IsJ()
func (*ForEachLoop) IsStatement ¶
func (*ForEachLoop) IsStatement()
func (*ForEachLoop) IsTree ¶
func (*ForEachLoop) IsTree()
func (*ForEachLoop) WithBody ¶
func (n *ForEachLoop) WithBody(body *Block) *ForEachLoop
func (*ForEachLoop) WithMarkers ¶
func (n *ForEachLoop) WithMarkers(markers Markers) *ForEachLoop
func (*ForEachLoop) WithPrefix ¶
func (n *ForEachLoop) WithPrefix(prefix Space) *ForEachLoop
type ForLoop ¶
ForLoop represents a classic for loop: `for init; cond; update { body }` Also covers condition-only `for cond {}` and infinite `for {}`.
func (*ForLoop) GetMarkers ¶
func (*ForLoop) IsStatement ¶
func (*ForLoop) IsStatement()
func (*ForLoop) WithMarkers ¶
func (*ForLoop) WithPrefix ¶
type FullyQualified ¶
FullyQualified is a JavaType with a fully qualified name.
type GenericMarker ¶
type GenericMarker struct {
Ident uuid.UUID
JavaType string // Original Java class name for round-trip fidelity
Data map[string]any
}
GenericMarker is a marker type for Java-side markers that the Go side doesn't have a native type for (e.g., RecipesThatMadeChanges, SearchResult). It preserves the marker data as opaque fields during RPC round-trips.
func (GenericMarker) ID ¶
func (m GenericMarker) ID() uuid.UUID
type GoProject ¶
GoProject identifies the Go project (logical grouping of go.mod + .go files) a source belongs to. Mirrors org.openrewrite.golang.marker.GoProject on the Java side.
func NewGoProject ¶
NewGoProject creates a GoProject marker with a new UUID.
type Identifier ¶
type Identifier struct {
ID uuid.UUID
Prefix Space
Markers Markers
Annotations []Tree // Java annotations on this identifier (empty in Go, received from Java)
Name string
Type JavaType // the type of this identifier (nullable)
FieldType *JavaTypeVariable // the variable type when this identifier refers to a field (nullable)
}
Identifier represents a name reference in source code.
func (*Identifier) GetID ¶
func (n *Identifier) GetID() uuid.UUID
func (*Identifier) GetMarkers ¶
func (n *Identifier) GetMarkers() Markers
func (*Identifier) GetPrefix ¶
func (n *Identifier) GetPrefix() Space
func (*Identifier) IsExpression ¶
func (*Identifier) IsExpression()
func (*Identifier) IsJ ¶
func (*Identifier) IsJ()
func (*Identifier) IsTree ¶
func (*Identifier) IsTree()
func (*Identifier) WithFieldType ¶
func (n *Identifier) WithFieldType(ft *JavaTypeVariable) *Identifier
func (*Identifier) WithMarkers ¶
func (n *Identifier) WithMarkers(markers Markers) *Identifier
func (*Identifier) WithName ¶
func (n *Identifier) WithName(name string) *Identifier
func (*Identifier) WithPrefix ¶
func (n *Identifier) WithPrefix(prefix Space) *Identifier
func (*Identifier) WithType ¶
func (n *Identifier) WithType(t JavaType) *Identifier
type If ¶
type If struct {
ID uuid.UUID
Prefix Space
Markers Markers
Init *RightPadded[Statement] // nil if no init; After = space before `;`
Condition Expression
ConditionCP *ControlParentheses // cached ControlParentheses from RPC round-trip
Then *Block
ElsePart *RightPadded[J] // nil if no else clause
}
If represents an if statement. In Go, if can have an init statement: `if init; cond { }`.
func (*If) GetMarkers ¶
func (*If) IsStatement ¶
func (*If) IsStatement()
func (*If) WithCondition ¶
func (n *If) WithCondition(condition Expression) *If
func (*If) WithMarkers ¶
func (*If) WithPrefix ¶
type Import ¶
type Import struct {
ID uuid.UUID
Prefix Space
Markers Markers
Alias *LeftPadded[*Identifier] // nil if no alias
Qualid Expression // typically *Literal for Go imports
}
Import represents a single import declaration.
func (*Import) GetMarkers ¶
func (*Import) WithMarkers ¶
func (*Import) WithPrefix ¶
type J ¶
type J interface {
Tree
IsJ()
GetID() uuid.UUID
WithID(uuid.UUID) J
GetPrefix() Space
GetMarkers() Markers
}
J is the interface for all Java-like AST nodes that carry a prefix space. Mirrors org.openrewrite.java.tree.J — `getId`, `getPrefix`, `getMarkers` are polymorphic accessors so RPC senders, receivers, and other framework code can read the cross-cutting fields without per-type switches.
Concrete impls live in j_methods.go (keep in sync with the J types in j.go and go.go).
Mutation: the J interface exposes only the common ID wither. For prefix/markers, use the typed `WithPrefix(Space) *T` / `WithMarkers(Markers) *T` per-type methods — they return a *new* instance so the visitor framework's change-detection (pointer identity) works correctly. Framework code that needs to invoke those polymorphically (e.g. the RPC receiver's PreVisit) goes through reflection — see the `withPrefixViaReflection` helper in pkg/rpc.
In-place mutation of Prefix / Markers / ID is never safe because it would silently bypass RecipeScheduler's "did this recipe change the tree?" check.
type JavaType ¶
type JavaType interface {
// contains filtered or unexported methods
}
JavaType is the interface for all Java type representations used for type attribution.
type JavaTypeAnnotation ¶
type JavaTypeAnnotation struct {
Type FullyQualified
Values []JavaTypeAnnotationElementValue
}
JavaTypeAnnotation represents an annotation type reference.
type JavaTypeAnnotationArrayElementValue ¶
type JavaTypeAnnotationArrayElementValue struct {
Element JavaType
ConstantValues []any
ReferenceValues []JavaType
}
JavaTypeAnnotationArrayElementValue is an array of annotation element values.
func (*JavaTypeAnnotationArrayElementValue) GetElement ¶
func (a *JavaTypeAnnotationArrayElementValue) GetElement() JavaType
type JavaTypeAnnotationElementValue ¶
type JavaTypeAnnotationElementValue interface {
GetElement() JavaType
// contains filtered or unexported methods
}
JavaTypeAnnotationElementValue is the interface for annotation element values. One of *JavaTypeAnnotationSingleElementValue or *JavaTypeAnnotationArrayElementValue.
type JavaTypeAnnotationSingleElementValue ¶
type JavaTypeAnnotationSingleElementValue struct {
Element JavaType
ConstantValue any
ReferenceValue JavaType
}
JavaTypeAnnotationSingleElementValue is a single annotation element value (one constant or one reference). Java parser puts class literals and enum constants in ReferenceValue; only String/Number/Boolean/Character live in ConstantValue.
func (*JavaTypeAnnotationSingleElementValue) GetElement ¶
func (s *JavaTypeAnnotationSingleElementValue) GetElement() JavaType
type JavaTypeArray ¶
type JavaTypeArray struct {
ElemType JavaType
Annotations []FullyQualified
}
JavaTypeArray represents an array type.
type JavaTypeClass ¶
type JavaTypeClass struct {
FlagsBitMap int64
Kind string
FullyQualifiedName string
TypeParameters []JavaType
Supertype FullyQualified
OwningClass FullyQualified
Annotations []FullyQualified
Interfaces []FullyQualified
Members []*JavaTypeVariable
Methods []*JavaTypeMethod
}
JavaTypeClass represents a class, interface, enum, or annotation type.
func (*JavaTypeClass) GetFullyQualifiedName ¶
func (c *JavaTypeClass) GetFullyQualifiedName() string
type JavaTypeGenericTypeVariable ¶
JavaTypeGenericTypeVariable represents a generic type variable like T extends Comparable.
type JavaTypeIntersection ¶
type JavaTypeIntersection struct {
Bounds []JavaType
}
JavaTypeIntersection represents an intersection type (e.g., Serializable & Comparable).
type JavaTypeMethod ¶
type JavaTypeMethod struct {
DeclaringType FullyQualified
Name string
FlagsBitMap int64
ReturnType JavaType
ParameterNames []string
ParameterTypes []JavaType
ThrownExceptions []JavaType
Annotations []FullyQualified
DefaultValue []string
DeclaredFormalTypeNames []string
}
JavaTypeMethod represents a method type signature.
type JavaTypeMultiCatch ¶
type JavaTypeMultiCatch struct {
ThrowableTypes []JavaType
}
JavaTypeMultiCatch represents a multi-catch type (e.g., IOException | SQLException).
type JavaTypeParameterized ¶
type JavaTypeParameterized struct {
Type FullyQualified
TypeParameters []JavaType
}
JavaTypeParameterized represents a parameterized type like List<String>.
func (*JavaTypeParameterized) GetFullyQualifiedName ¶
func (p *JavaTypeParameterized) GetFullyQualifiedName() string
type JavaTypePrimitive ¶
type JavaTypePrimitive struct {
Keyword string
}
JavaTypePrimitive represents a primitive type like int, boolean, etc.
type JavaTypeShallowClass ¶
type JavaTypeShallowClass struct {
JavaTypeClass
}
JavaTypeShallowClass mirrors Java's JavaType.ShallowClass — a Class instance that carries minimal metadata (kind, FQN, owning class) and otherwise behaves identically to JavaTypeClass. The wire format preserves the distinction; on the Go side the embedded JavaTypeClass supplies all fields and accessors.
type JavaTypeUnknown ¶
type JavaTypeUnknown struct{}
JavaTypeUnknown represents an unknown or unresolved type.
type JavaTypeVariable ¶
type JavaTypeVariable struct {
Name string
Owner JavaType
Type JavaType
Annotations []FullyQualified
}
JavaTypeVariable represents a variable type.
type Label ¶
type Label struct {
ID uuid.UUID
Prefix Space
Markers Markers
Name RightPadded[*Identifier] // After = space before ':'
Statement Statement
}
Label represents a labeled statement: `label: stmt`.
func (*Label) GetMarkers ¶
func (*Label) IsStatement ¶
func (*Label) IsStatement()
func (*Label) WithMarkers ¶
func (*Label) WithPrefix ¶
type LeftPadded ¶
LeftPadded wraps an element with preceding whitespace/comments. Used for operators and delimiters where whitespace appears before the element (e.g., the space before an operator in a binary expression).
type Literal ¶
type Literal struct {
ID uuid.UUID
Prefix Space
Markers Markers
Kind LiteralKind
Value any
Source string // the original source text of the literal
Type JavaType // the type of this literal (nullable)
}
Literal represents a literal value (string, number, boolean, etc.).
func (*Literal) GetMarkers ¶
func (*Literal) IsExpression ¶
func (*Literal) IsExpression()
func (*Literal) WithMarkers ¶
func (*Literal) WithPrefix ¶
func (*Literal) WithSource ¶
type LiteralKind ¶
type LiteralKind int
const ( BoolLiteral LiteralKind = iota IntLiteral FloatLiteral StringLiteral CharLiteral NilLiteral )
type Markers ¶
Markers holds a collection of Marker instances attached to a tree node.
func FoundSearchResult ¶
FoundSearchResult attaches a SearchResult marker to the given Markers.
func MarkupError ¶
MarkupError attaches an error-level Markup marker to the given Markers.
func MarkupInfo ¶
MarkupInfo attaches an info-level Markup marker to the given Markers.
func MarkupWarn ¶
MarkupWarn attaches a warning-level Markup marker to the given Markers.
func MarkupWarnDetail ¶
MarkupWarnDetail attaches a warning-level Markup marker with detail to the given Markers.
type Markup ¶
type Markup struct {
Ident uuid.UUID
Level MarkupLevel
Message string
Detail string
}
Markup is a marker for attaching diagnostic messages to LST nodes. It is rendered as a comment in printed output (e.g., /*~~(message: detail)~~>*/).
func NewMarkup ¶
func NewMarkup(level MarkupLevel, message, detail string) Markup
NewMarkup creates a Markup marker with the given level and message.
type MarkupLevel ¶
type MarkupLevel int
MarkupLevel indicates the severity of a Markup marker.
const ( MarkupDebugLevel MarkupLevel = iota MarkupInfoLevel MarkupWarnLevel MarkupErrorLevel )
type MethodDeclaration ¶
type MethodDeclaration struct {
ID uuid.UUID
Prefix Space
Markers Markers
LeadingAnnotations []*Annotation // `//go:noinline` / `//go:nosplit` etc. on funcs
Name *Identifier
TypeParameters *TypeParameters // nil for non-generic functions; `[T any]` declaration-site type params
Parameters Container[Statement] // parameter list in parentheses
ReturnType Expression // nil for void functions; single type or *TypeList for multiple
Body *Block // nil for forward declarations
MethodType *JavaTypeMethod // the method type signature (nullable)
}
MethodDeclaration represents a function or method declaration.
func (*MethodDeclaration) GetID ¶
func (n *MethodDeclaration) GetID() uuid.UUID
func (*MethodDeclaration) GetMarkers ¶
func (n *MethodDeclaration) GetMarkers() Markers
func (*MethodDeclaration) GetPrefix ¶
func (n *MethodDeclaration) GetPrefix() Space
func (*MethodDeclaration) IsExpression ¶
func (*MethodDeclaration) IsExpression()
func (*MethodDeclaration) IsJ ¶
func (*MethodDeclaration) IsJ()
func (*MethodDeclaration) IsStatement ¶
func (*MethodDeclaration) IsStatement()
func (*MethodDeclaration) IsTree ¶
func (*MethodDeclaration) IsTree()
func (*MethodDeclaration) WithBody ¶
func (n *MethodDeclaration) WithBody(body *Block) *MethodDeclaration
func (*MethodDeclaration) WithLeadingAnnotations ¶
func (n *MethodDeclaration) WithLeadingAnnotations(anns []*Annotation) *MethodDeclaration
func (*MethodDeclaration) WithMarkers ¶
func (n *MethodDeclaration) WithMarkers(markers Markers) *MethodDeclaration
func (*MethodDeclaration) WithName ¶
func (n *MethodDeclaration) WithName(name *Identifier) *MethodDeclaration
func (*MethodDeclaration) WithPrefix ¶
func (n *MethodDeclaration) WithPrefix(prefix Space) *MethodDeclaration
func (*MethodDeclaration) WithTypeParameters ¶ added in v0.0.5
func (n *MethodDeclaration) WithTypeParameters(tps *TypeParameters) *MethodDeclaration
type MethodInvocation ¶
type MethodInvocation struct {
ID uuid.UUID
Prefix Space
Markers Markers
Select *RightPadded[Expression] // nil for free functions
TypeParameters *Container[Expression] // explicit call-site type arguments, e.g. `[int]` in `Map[int](42)`; nil otherwise
Name *Identifier
Arguments Container[Expression]
MethodType *JavaTypeMethod // the method type being invoked (nullable)
}
MethodInvocation represents a function or method call like `f(args)`.
func (*MethodInvocation) GetID ¶
func (n *MethodInvocation) GetID() uuid.UUID
func (*MethodInvocation) GetMarkers ¶
func (n *MethodInvocation) GetMarkers() Markers
func (*MethodInvocation) GetPrefix ¶
func (n *MethodInvocation) GetPrefix() Space
func (*MethodInvocation) IsExpression ¶
func (*MethodInvocation) IsExpression()
func (*MethodInvocation) IsJ ¶
func (*MethodInvocation) IsJ()
func (*MethodInvocation) IsStatement ¶
func (*MethodInvocation) IsStatement()
func (*MethodInvocation) IsTree ¶
func (*MethodInvocation) IsTree()
func (*MethodInvocation) WithMarkers ¶
func (n *MethodInvocation) WithMarkers(markers Markers) *MethodInvocation
func (*MethodInvocation) WithName ¶
func (n *MethodInvocation) WithName(name *Identifier) *MethodInvocation
func (*MethodInvocation) WithPrefix ¶
func (n *MethodInvocation) WithPrefix(prefix Space) *MethodInvocation
func (*MethodInvocation) WithTypeParameters ¶ added in v0.0.12
func (n *MethodInvocation) WithTypeParameters(typeParameters *Container[Expression]) *MethodInvocation
type ParameterizedType ¶
type ParameterizedType struct {
ID uuid.UUID
Prefix Space
Markers Markers
Clazz Expression // the base type being parameterized
TypeParameters *Container[Expression] // the type arguments (nullable)
Type JavaType // resolved type (nullable)
}
ParameterizedType represents a generic type instantiation like `List[string]`.
func (*ParameterizedType) GetID ¶
func (n *ParameterizedType) GetID() uuid.UUID
func (*ParameterizedType) GetMarkers ¶
func (n *ParameterizedType) GetMarkers() Markers
func (*ParameterizedType) GetPrefix ¶
func (n *ParameterizedType) GetPrefix() Space
func (*ParameterizedType) IsExpression ¶
func (*ParameterizedType) IsExpression()
func (*ParameterizedType) IsJ ¶
func (*ParameterizedType) IsJ()
func (*ParameterizedType) IsTree ¶
func (*ParameterizedType) IsTree()
func (*ParameterizedType) WithMarkers ¶
func (n *ParameterizedType) WithMarkers(markers Markers) *ParameterizedType
func (*ParameterizedType) WithPrefix ¶
func (n *ParameterizedType) WithPrefix(prefix Space) *ParameterizedType
type Parentheses ¶
type Parentheses struct {
ID uuid.UUID
Prefix Space
Markers Markers
Tree RightPadded[Expression] // Element = inner expr, After = space before `)`
Type JavaType // the result type (nullable)
}
Parentheses wraps an expression in parentheses: `(expr)`.
func (*Parentheses) GetID ¶
func (n *Parentheses) GetID() uuid.UUID
func (*Parentheses) GetMarkers ¶
func (n *Parentheses) GetMarkers() Markers
func (*Parentheses) GetPrefix ¶
func (n *Parentheses) GetPrefix() Space
func (*Parentheses) IsExpression ¶
func (*Parentheses) IsExpression()
func (*Parentheses) IsJ ¶
func (*Parentheses) IsJ()
func (*Parentheses) IsTree ¶
func (*Parentheses) IsTree()
func (*Parentheses) WithMarkers ¶
func (n *Parentheses) WithMarkers(markers Markers) *Parentheses
func (*Parentheses) WithPrefix ¶
func (n *Parentheses) WithPrefix(prefix Space) *Parentheses
type ParseError ¶
type ParseError struct {
Ident uuid.UUID
Markers Markers
SourcePath string
CharsetName string
CharsetBomMarked bool
Text string
}
ParseError represents a source file that failed to parse. Mirrors org.openrewrite.tree.ParseError on the Java side.
func NewParseError ¶
func NewParseError(sourcePath string, source string, err error) *ParseError
NewParseError creates a ParseError from a source path, source text, and error.
func (*ParseError) IsTree ¶
func (*ParseError) IsTree()
ParseError isn't a J node (no Prefix, no acceptVisitor double- dispatch in the J hierarchy) but it does flow through the same Tree-typed Visit pipeline as a SourceFile alternate, so it satisfies Tree to allow visitor.GoVisitor.Visit to receive it. The visitor framework's switch has no case for ParseError; it falls through to the default arm. RPC senders/receivers special-case it ahead of the dispatch.
type ParseExceptionResult ¶
type ParseExceptionResult struct {
Ident uuid.UUID
ParserType string
ExceptionType string
Message string
TreeType *string // nullable
}
ParseExceptionResult is a marker that captures information about a parse failure. Mirrors org.openrewrite.ParseExceptionResult on the Java side.
func (ParseExceptionResult) ID ¶
func (p ParseExceptionResult) ID() uuid.UUID
type Return ¶
type Return struct {
ID uuid.UUID
Prefix Space
Markers Markers
Expression Expression // nil for a naked `return`
}
Return represents a return statement. Mirrors Java's J.Return: a single, nullable returned expression. Go return statements with more than one value map to golang.Return instead.
func (*Return) GetMarkers ¶
func (*Return) IsStatement ¶
func (*Return) IsStatement()
func (*Return) WithMarkers ¶
func (*Return) WithPrefix ¶
type RightPadded ¶
RightPadded wraps an element with trailing whitespace/comments. Used for list elements where whitespace appears after the element (e.g., before a comma or closing delimiter).
type SearchResult ¶
SearchResult is a marker indicating that a search recipe found a match. It is rendered as a comment in printed output (e.g., /*~~(description)~~>*/).
func NewSearchResult ¶
func NewSearchResult(description string) SearchResult
NewSearchResult creates a SearchResult marker with a new UUID.
func (SearchResult) ID ¶
func (s SearchResult) ID() uuid.UUID
type SearchResultMarker ¶
SearchResultMarker represents a SearchResult marker from Java. It implements RpcCodec on the Java side, sending 2 sub-fields (id, description).
func (SearchResultMarker) ID ¶
func (m SearchResultMarker) ID() uuid.UUID
type Semicolon ¶
Semicolon marks a RightPadded element that is followed by an explicit `;` separator in the source — i.e. multiple statements on one line: `_ = 1; _ = 2`. Go inserts implicit semicolons at end-of-line so most files don't need this marker; it's only emitted when the source literally has a `;` between statements that the printer must reproduce.
Mirrors org.openrewrite.java.marker.Semicolon on the Java side.
func NewSemicolon ¶
func NewSemicolon() Semicolon
NewSemicolon creates a Semicolon marker with a fresh UUID.
type SourceFile ¶
type SourceFile interface {
J
IsSourceFile()
}
SourceFile is a J node representing an entire source file.
type Space ¶
Space represents whitespace and comments that appear before a syntax element. This is the fundamental unit of formatting preservation in OpenRewrite.
func ParseSpace ¶
ParseSpace parses raw text (between two token positions) into a Space, extracting any line comments (//) and block comments (/* */).
The model follows Java OpenRewrite's convention:
- Space.Whitespace = whitespace BEFORE the first comment
- Comment.Suffix = whitespace AFTER each comment
The printer emits: Whitespace + (Comment.Text + Comment.Suffix)* to reconstruct the original text.
type Statement ¶
type Statement interface {
J
IsStatement()
}
Statement is a J node that can appear at statement level.
type Switch ¶
type Switch struct {
ID uuid.UUID
Prefix Space
Markers Markers
Init *RightPadded[Statement] // optional init statement; After = space after semicolon
Tag *RightPadded[Expression] // optional tag expression; After = space before {
Body *Block // contains Case statements
}
Switch represents a switch statement.
func (*Switch) GetMarkers ¶
func (*Switch) IsStatement ¶
func (*Switch) IsStatement()
func (*Switch) WithMarkers ¶
func (*Switch) WithPrefix ¶
type TypeCast ¶
type TypeCast struct {
ID uuid.UUID
Prefix Space
Markers Markers
Clazz *ControlParentheses // the type in parentheses
Expr Expression // the expression being cast/asserted
Type JavaType // the result type (nullable)
}
TypeCast represents a type assertion or type cast: `x.(T)` in Go.
func (*TypeCast) GetMarkers ¶
func (*TypeCast) IsExpression ¶
func (*TypeCast) IsExpression()
func (*TypeCast) WithMarkers ¶
func (*TypeCast) WithPrefix ¶
type TypeParameter ¶ added in v0.0.5
type TypeParameter struct {
ID uuid.UUID
Prefix Space
Markers Markers
Annotations []*Annotation
Name Expression
Bounds *Container[Expression]
}
TypeParameter represents a single declaration-site type parameter, e.g. Go `T any` (Java `T extends Foo`). The constraint (Go) / bound (Java) lives in Bounds as a single-element container; it is nil when the parameter shares a later sibling's constraint, as in `[T, U any]`. Maps to org.openrewrite.java.tree.J$TypeParameter.
func (*TypeParameter) GetID ¶ added in v0.0.5
func (n *TypeParameter) GetID() uuid.UUID
func (*TypeParameter) GetMarkers ¶ added in v0.0.5
func (n *TypeParameter) GetMarkers() Markers
func (*TypeParameter) GetPrefix ¶ added in v0.0.5
func (n *TypeParameter) GetPrefix() Space
func (*TypeParameter) IsJ ¶ added in v0.0.5
func (*TypeParameter) IsJ()
func (*TypeParameter) IsTree ¶ added in v0.0.5
func (*TypeParameter) IsTree()
func (*TypeParameter) WithMarkers ¶ added in v0.0.5
func (n *TypeParameter) WithMarkers(markers Markers) *TypeParameter
func (*TypeParameter) WithPrefix ¶ added in v0.0.5
func (n *TypeParameter) WithPrefix(prefix Space) *TypeParameter
type TypeParameters ¶ added in v0.0.5
type TypeParameters struct {
ID uuid.UUID
Prefix Space
Markers Markers
Annotations []*Annotation
// Elements are *TypeParameter. Typed as RightPadded[J] so the RPC padding
// machinery (which reconstructs J-only nodes as RightPadded[J]) round-trips
// them without bespoke type-switch cases.
TypeParameters []RightPadded[J]
}
TypeParameters represents a declaration-site type parameter list, e.g. Go `[T any, U comparable]` (Java `<T, U>`). Maps to org.openrewrite.java.tree.J$TypeParameters.
func (*TypeParameters) GetID ¶ added in v0.0.5
func (n *TypeParameters) GetID() uuid.UUID
func (*TypeParameters) GetMarkers ¶ added in v0.0.5
func (n *TypeParameters) GetMarkers() Markers
func (*TypeParameters) GetPrefix ¶ added in v0.0.5
func (n *TypeParameters) GetPrefix() Space
func (*TypeParameters) IsJ ¶ added in v0.0.5
func (*TypeParameters) IsJ()
func (*TypeParameters) IsTree ¶ added in v0.0.5
func (*TypeParameters) IsTree()
func (*TypeParameters) WithMarkers ¶ added in v0.0.5
func (n *TypeParameters) WithMarkers(markers Markers) *TypeParameters
func (*TypeParameters) WithPrefix ¶ added in v0.0.5
func (n *TypeParameters) WithPrefix(prefix Space) *TypeParameters
type Unary ¶
type Unary struct {
ID uuid.UUID
Prefix Space
Markers Markers
Operator LeftPadded[UnaryOperator]
Operand Expression
Type JavaType // the result type (nullable)
}
Unary represents a unary expression like `-x` or `!y`.
func (*Unary) GetMarkers ¶
func (*Unary) IsExpression ¶
func (*Unary) IsExpression()
func (*Unary) IsStatement ¶
func (*Unary) IsStatement()
func (*Unary) WithMarkers ¶
func (*Unary) WithOperand ¶
func (n *Unary) WithOperand(operand Expression) *Unary
func (*Unary) WithPrefix ¶
type UnaryOperator ¶
type UnaryOperator int
const ( Negate UnaryOperator = iota + 1 // - Not // ! BitwiseNot // ^ Deref // * AddressOf // & Receive // <- (channel receive, Go-specific) Positive // + PostIncrement // ++ (postfix) PostDecrement // -- (postfix) Spread // ... (variadic prefix, param declaration) SpreadPostfix // ... (variadic postfix, call site) Tilde // ~ (approximate type constraint, Go-specific) )
func ParseUnaryOperator ¶
func ParseUnaryOperator(s string) UnaryOperator
ParseUnaryOperator converts a Java enum name to a UnaryOperator.
func (UnaryOperator) String ¶
func (op UnaryOperator) String() string
String returns the Java enum name for this UnaryOperator.
type VariableDeclarations ¶
type VariableDeclarations struct {
ID uuid.UUID
Prefix Space
Markers Markers
LeadingAnnotations []*Annotation // struct field tags (one per `key:"value"` pair) or `//go:` directives
TypeExpr Expression // the declared type (nil if inferred)
Varargs *Space // non-nil for variadic params (`...T`); holds prefix of `...`
Variables []RightPadded[*VariableDeclarator] // the declared variables
}
VariableDeclarations represents one or more variable declarations. Grouped declarations `var ( ... )` / `const ( ... )` are modeled by golang.DeclarationBlock, whose elements are single VariableDeclarations.
func (*VariableDeclarations) GetID ¶
func (n *VariableDeclarations) GetID() uuid.UUID
func (*VariableDeclarations) GetMarkers ¶
func (n *VariableDeclarations) GetMarkers() Markers
func (*VariableDeclarations) GetPrefix ¶
func (n *VariableDeclarations) GetPrefix() Space
func (*VariableDeclarations) IsJ ¶
func (*VariableDeclarations) IsJ()
func (*VariableDeclarations) IsStatement ¶
func (*VariableDeclarations) IsStatement()
func (*VariableDeclarations) IsTree ¶
func (*VariableDeclarations) IsTree()
func (*VariableDeclarations) WithLeadingAnnotations ¶
func (n *VariableDeclarations) WithLeadingAnnotations(anns []*Annotation) *VariableDeclarations
func (*VariableDeclarations) WithMarkers ¶
func (n *VariableDeclarations) WithMarkers(markers Markers) *VariableDeclarations
func (*VariableDeclarations) WithPrefix ¶
func (n *VariableDeclarations) WithPrefix(prefix Space) *VariableDeclarations
type VariableDeclarator ¶
type VariableDeclarator struct {
ID uuid.UUID
Prefix Space
Markers Markers
Name *Identifier
Initializer *LeftPadded[Expression] // nil if no initializer
}
VariableDeclarator represents a single variable with optional initializer.
func (*VariableDeclarator) GetID ¶
func (n *VariableDeclarator) GetID() uuid.UUID
func (*VariableDeclarator) GetMarkers ¶
func (n *VariableDeclarator) GetMarkers() Markers
func (*VariableDeclarator) GetPrefix ¶
func (n *VariableDeclarator) GetPrefix() Space
func (*VariableDeclarator) IsJ ¶
func (*VariableDeclarator) IsJ()
func (*VariableDeclarator) IsTree ¶
func (*VariableDeclarator) IsTree()
func (*VariableDeclarator) WithMarkers ¶
func (n *VariableDeclarator) WithMarkers(markers Markers) *VariableDeclarator
func (*VariableDeclarator) WithName ¶
func (n *VariableDeclarator) WithName(name *Identifier) *VariableDeclarator
func (*VariableDeclarator) WithPrefix ¶
func (n *VariableDeclarator) WithPrefix(prefix Space) *VariableDeclarator