Skip to content

fix(compiler): wrap long generated lines#3799

Draft
jamalasidd wants to merge 6 commits into
apache:mainfrom
jamalasidd:fix-issue-3233
Draft

fix(compiler): wrap long generated lines#3799
jamalasidd wants to merge 6 commits into
apache:mainfrom
jamalasidd:fix-issue-3233

Conversation

@jamalasidd

Copy link
Copy Markdown

Why?

Issue #3233 asks for generated code to include clear generated-file headers and better line breaking. In my local reproduction, the generated-file notice was already present, but generated output still contained long lines over 80 characters across multiple languages.

This PR focuses on the reproducible long-line formatting part of the issue. The changes update specific generator patterns such as Java builder chains, Go fory.New(...) calls, Python pyfory.field(...) output, Rust helper/type lines, and C++ generated method/macro lines.

What does this PR do?

This PR improves generated code formatting for Apache Fory compiler output by wrapping long generated lines in several language generators. It adds targeted, language-safe line breaks in the Java, Go, Python, Rust, and C++ generators instead of using a generic line wrapper that could break syntax.

The implementation keeps the changes focused on generated output formatting and avoids changing generated behavior.

Related issues

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: yes
  • I included the required AI Usage Disclosure.
  • Final ai_review evidence has been completed.

AI Usage Disclosure

Substantial AI assistance was used for this PR. I used AI assistance to help understand the issue, trace generated long lines back to language-specific generator code, suggest safe language-specific line-break changes, debug local testing commands, and organize the PR/README documentation.

I reviewed the suggested code changes manually, applied them locally, regenerated compiler output, and tested the reproduction case before committing the changes. The implementation decisions and final submitted code were reviewed and accepted by me before submission.

ai_review Summary

Pending before requesting maintainer review.

  • Fory-guided reviewer result: pending. I checked upstream/main and .claude/skills/fory-code-review/SKILL.md does not currently exist there.
  • Independent general reviewer result: pending.

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

This PR changes generated source formatting only. It is not intended to change public APIs, binary protocol behavior, or generated runtime behavior.

Benchmark

No benchmark was run. This PR changes compiler-generated source formatting and is not expected to affect runtime performance.

Testing

I tested this manually using a small reproduction schema:

namespace repro;

struct Person {
  1: string first_name;
  2: string last_name;
  3: string email_address;
  4: list<string> tags;
  5: map<string, string> metadata;
}

struct Company {
  1: string company_name;
  2: Person owner;
  3: list<Person> employees;
}

Generated code with:

foryc repro_3233.fdl --lang java,python,go,cpp,rust --output ./generated_3233

Then checked for generated lines longer than 80 characters with:

Get-ChildItem .\generated_3233 -Recurse -File | ForEach-Object {
    $file = $_.FullName
    $lineNumber = 0
    Get-Content $file | ForEach-Object {
        $lineNumber++
        if ($_.Length -gt 80) {
            Write-Host "$file line $lineNumber has $($_.Length) characters"
            Write-Host $_
            Write-Host ""
        }
    }
}

After these changes, the checker produced no long-line output for the reproduced generated files.

@jamalasidd

jamalasidd commented Jun 29, 2026

Copy link
Copy Markdown
Author

Hi, this is my first contribution to Apache Fory. I opened this PR as a draft while I finish the AI review checklist.

I noticed the PR template references .claude/skills/fory-code-review/SKILL.md, but I could not find that file on upstream/main. I checked with:

git show upstream/main:.claude/skills/fory-code-review/SKILL.md

and got:

fatal: path '.claude/skills/fory-code-review/SKILL.md' does not exist in 'upstream/main'

Could someone point me to the current Fory-guided review instructions I should use for the required ai_review section?

@jamalasidd jamalasidd changed the title [Compiler] Wrap long generated lines across language generatorsFix issue 3233 Jun 29, 2026
@ayush00git

Copy link
Copy Markdown
Contributor

Hii @jamalasidd
Welcome and thanks for your first PR. Here's the checklist you're looking for -https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants