Skip to content

Pass all options to Pico formatter - #2939

Open
toinehartman wants to merge 1 commit into
mainfrom
fix/pico-formatter-options
Open

toinehartman wants to merge 1 commit into
mainfrom
fix/pico-formatter-options

Conversation

@toinehartman

Copy link
Copy Markdown
Member
  1. Pass all formatting options through the recursive calls of the Pico formatting library/example.
  2. Document some undocumented formatter rules, so the respective page on the website is more accurate.

@toinehartman toinehartman self-assigned this Oct 19, 2026
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45%. Comparing base (9115006) to head (ac97db1).

Additional details and impacted files
@@           Coverage Diff           @@
##              main   #2939   +/-   ##
=======================================
- Coverage       45%     45%   -1%     
  Complexity    6807    6807           
=======================================
  Files          844     844           
  Lines        68823   68823           
  Branches     10038   10038           
=======================================
- Hits         31415   31411    -4     
- Misses       35005   35010    +5     
+ Partials      2403    2402    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jurgenvinju

Copy link
Copy Markdown
Member

Maybe we should move all of pico under the demo folder? The tutor compiler will show all the bodies of functions as well for modules under a demo folder. So: demo::lang::pico instead of lang::pico


@synopsis{Format while}
Box toBox((Statement) `while <Expression e> do <{Statement ";"}* block> od`)
Box toBox((Statement) `while <Expression e> do <{Statement ";"}* block> od`, FormattingOptions opts = fo())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toBox only implements the styling options for case-insensitive literals. On the otherhand these and all the other options are picked up by str format(Box, FormattingOptions opts=fo()) and layoutDiff

@jurgenvinju jurgenvinju Oct 20, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To pick up the options, pass them to fileFormatter, which passes them to fileEditFormatter which passes them to format and layoutDiff. You also see how needsConfirmation is passed into the file patch API.

void(loc) fileFormatter(type[&G <: Tree] grammar, Style style, FormattingOptions opts=fo()) {
    list[TextEdit](loc) toEdits = fileEditFormatter(grammar, style, opts=opts);

    return void (loc input) {  
        executeFileSystemChanges([changed(input, toEdits(input), needsConfirmation=opts.needsConfirmation)]);
    };
}

@jurgenvinju jurgenvinju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better demonstrate without the opts for toBox since that is almost a noop for most languages and a lot of wiring for every recursive call.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants