Skip to content

C#: Fix incomplete visitor traversal in JavaVisitor.cs and CSharpVisitor.cs#6970

Merged
knutwannheden merged 2 commits intomainfrom
fix-incomplete-visitor-traversal-in-javavisitor.cs-and-csharpvisitor.cs
Mar 12, 2026
Merged

C#: Fix incomplete visitor traversal in JavaVisitor.cs and CSharpVisitor.cs#6970
knutwannheden merged 2 commits intomainfrom
fix-incomplete-visitor-traversal-in-javavisitor.cs-and-csharpvisitor.cs

Conversation

@knutwannheden
Copy link
Contributor

Summary

  • Fix incomplete visitor traversal in JavaVisitor.cs — every Visit* method now visits ALL tree-typed properties in model order
  • Add VisitExpression, VisitStatement, and VisitType interception hooks matching the Java reference
  • Add Accept dispatch for NamedVariable, If.Else, ForLoop.Control, ForEachLoop.Control, and Lambda.Parameters
  • Call VisitType for all JavaType-typed properties at the end of each visitor method

Test plan

  • dotnet build passes
  • dotnet test passes
  • CSharpVisitor.cs fixes (in progress)

Visit ALL tree-typed properties in model order for every Visit* method.
Add VisitExpression/VisitStatement interception hooks matching the Java
reference, and VisitType calls for JavaType-typed properties. Add Accept
dispatch for NamedVariable, If.Else, ForLoop.Control, ForEachLoop.Control,
and Lambda.Parameters.
Every Visit* method now:
- Calls VisitStatement/VisitExpression interception hooks matching the
  type's interface hierarchy (Statement first, then Expression)
- Visits ALL tree-typed properties in constructor parameter order
- Checks nullability before visiting nullable properties
- Calls VisitType for all JavaType? properties at the end

Previously many methods were missing interception hooks, skipping
properties, or were stubs that returned the input unchanged.
@knutwannheden knutwannheden marked this pull request as ready for review March 12, 2026 19:36
@knutwannheden knutwannheden merged commit abd205e into main Mar 12, 2026
1 check passed
@knutwannheden knutwannheden deleted the fix-incomplete-visitor-traversal-in-javavisitor.cs-and-csharpvisitor.cs branch March 12, 2026 19:37
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant