Commit ff2a0d4
committed
rewrite-go: ship parity with JS / Python / C# ports
Full RPC handler surface, recipe-author primitives, type attribution,
test harness, and recipe library brought to parity with the JavaScript,
Python, and C# language ports.
RPC handler surface
- Parse / ParseProject (project-aware: module + goModContent; per-file
closest-ancestor go.mod ownership; sibling go.sum populates
ResolvedDependencies).
- BatchVisit returns {modified, deleted, hasNewMessages, searchResultIds};
searchResultIds walker registered, hasNewMessages snapshot tracked.
- Generate drives ScanningRecipe.Generate.
- GetMarketplace emits full descriptor (recipeList, dataTables,
preconditions, maintainers, contributors, examples, option types).
- PrepareRecipe returns per-instance UUID.
- TraceGetObject for RPC tracing.
- Server CLI flags: --log-file, --trace-rpc-messages, --metrics-csv,
--recipe-install-dir, --data-tables-csv-dir.
Recipe-author surface
- recipe.Recipe + recipe.Base, ScanningRecipe end-to-end.
- recipe.DataTable[Row] generic + InMemoryDataTableStore +
CsvDataTableStore.
- visitor.GoVisitor.Cursor() / SetCursor() for RPC seeding;
visitor.BuildChain reconstructs cursors from RPC IDs.
- Cursor message map: PutMessage, GetNearestMessage,
PollNearestMessage, etc.
- recipe.Service[T](sourceFile) registry + GoVisitor.DoAfterVisit
composition.
- Five services: ImportService, AutoFormatService, AnnotationService,
WhitespaceValidationService, NamingService.
- Five foundational recipes: AddImport, RemoveImport,
RemoveUnusedImports, OrderImports, RenamePackage.
Type attribution
- Same-package multi-file resolution via parser.ParsePackage.
- Third-party module resolution via go.mod requires + vendor walker
(parses <projectRoot>/vendor/<modulePath>/*.go for real
JavaTypeMethod attribution; honors `replace` directives).
- tree.GoResolutionResult marker (Module, Requires, Replaces,
Excludes, Retracts, ResolvedDependencies); both Go-side and
Java-side RPC codecs.
- parser.ProjectImporter 3-tier lazy resolver
(sources -> requires -> stdlib).
- Build-tag file inclusion: parser.MatchBuildContext recognizes
//go:build, // +build, and filename suffixes; default
build.Default with recipe-author override.
- Cross-package generics across the corpus.
RPC sender / receiver visitor-pattern refactor
- Senders / receivers on both sides extend the language visitor
(visitor.GoVisitor on Go, JavaVisitor<RpcSendQueue/ReceiveQueue>
on Java) and override VisitX, mirroring rewrite-java.
- Eliminated ~600 LOC of switch boilerplate.
- tree.J got polymorphic GetID / GetPrefix / GetMarkers; mutators
intentionally NOT on the interface (would break RecipeScheduler
identity-based change detection).
Annotations
- tree.Annotation (J-shaped) + LeadingAnnotations on
VariableDeclarations, MethodDeclaration, TypeDecl on both Go and
Java sides.
- Struct field tags AND //go:/lint: directives uniformly modeled as
J.Annotation; printer reassembles backticks for tags and //<name>
lines for directives.
- AnnotationService surface mirrors rewrite-java
(AllAnnotations, IsAnnotatedWith, FindAnnotations,
AddAnnotationVisitor, RemoveAnnotationVisitor).
Test harness
- Java: Assertions.go(...), goMod(...), goProject(name, ...) sibling
pattern matching mavenProject(...).
- Go: test.RewriteRun + test.Golang(...), test.GoMod(...),
test.GoSum(...), test.GoProject(name, ...).
- propagateModuleResolution copies the parsed go.mod marker onto
every sibling .go CU at project expansion so cross-file recipes
read module context per file.
- ExpectType / ExpectPrimitiveType / ExpectMethodType helpers on
both sides.
- GoMod conformance corpus (10 cases) shared across Go + Java tests.
- Printer parity corpus (13 fixtures across gofmt/ + generics/),
opt-in via `make parity`, never in CI.
Recipe-author guide at doc/recipe-authoring.md.
PLAN.md removed: contents are now reflected in the codebase, doc, and
shipped tests.1 parent becae3b commit ff2a0d4
152 files changed
Lines changed: 14806 additions & 1740 deletions
File tree
- rewrite-go
- cmd/rpc
- doc
- pkg
- format
- parser
- printer
- recipe
- golang
- internal
- rpc
- template
- test
- tree
- visitor
- src
- integTest/java/org/openrewrite/golang
- rpc
- main/java/org/openrewrite/golang
- internal/rpc
- marker
- rpc
- tree
- test
- java/org/openrewrite/golang
- resources/gomod-conformance
- test
- testdata/printer-corpus
- generics
- gofmt
- rewrite-javascript/rewrite
- src/rpc/request
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
| |||
0 commit comments