Skip to content

Scala parser: map def declarations to J.MethodDeclaration#7248

Merged
jkschneider merged 1 commit intomainfrom
scala-template-recipe-squash
Apr 2, 2026
Merged

Scala parser: map def declarations to J.MethodDeclaration#7248
jkschneider merged 1 commit intomainfrom
scala-template-recipe-squash

Conversation

@jkschneider
Copy link
Copy Markdown
Member

Summary

  • Maps Scala def method declarations to J.MethodDeclaration instead of J.Unknown
  • Adds ScalaPrinter.visitMethodDeclaration to print Scala syntax (def name(params): ReturnType = body)
  • Adds visitMethodParameter to parse method parameters as J.VariableDeclarations
  • Adds visitDefDefImpl with proper handling of modifiers, type parameters, return types, and bodies
  • Single-expression bodies use OmitBraces marker
  • Falls back to J.Unknown for edge cases: annotated methods, procedure syntax, complex parameter types (Map[String, Any], function types), parameterless methods, nested braces, while loops in body

Test plan

  • All 8 MethodDeclarationTest cases pass (simple, params, default params, type params, abstract, private, override, multi-param)
  • All existing tests pass with zero regressions (33 previously affected tests fixed)

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Apr 2, 2026
@jkschneider jkschneider merged commit 4baf50b into main Apr 2, 2026
1 check passed
@jkschneider jkschneider deleted the scala-template-recipe-squash branch April 2, 2026 14:10
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant