Skip to content

added "formatter" to all functions that produce text edits directly - #2872

Open
jurgenvinju wants to merge 1 commit into
mainfrom
fix/better-names-in-util-formatting
Open

added "formatter" to all functions that produce text edits directly#2872
jurgenvinju wants to merge 1 commit into
mainfrom
fix/better-names-in-util-formatting

Conversation

@jurgenvinju

Copy link
Copy Markdown
Member

No description provided.

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45%. Comparing base (a6ab889) to head (4328e52).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##              main   #2872   +/-   ##
=======================================
  Coverage       45%     45%           
- Complexity    6788    6799   +11     
=======================================
  Files          844     844           
  Lines        68785   68785           
  Branches     10023   10023           
=======================================
+ Hits         31329   31343   +14     
+ Misses       35081   35068   -13     
+ Partials      2375    2374    -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.

@DavyLandman DavyLandman 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.

less chance of clashing 👍🏼 but it looks like the refactoring it not complete? (as the build is failing)

* can be used to normalize case-insensitive literals in one go
}
@pitfalls{
* only applicable to entire files. For selection-based formatting see ((subTreeEdits)) and ((subStringEdits)).

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.

Suggested change
* only applicable to entire files. For selection-based formatting see ((subTreeEditFormatter)) and ((subStringEditFormatter)).

@toinehartman toinehartman 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 names! Like @DavyLandman pointed out, the renaming is not complete, as the old names appear at use sites and in the tutor documentation in various places. I tried to point them all out.

| ((fileFormatter)) | `void (loc)` | replaces the current file |
| ((stringFormatter)) | `str (str) ` | |
| ((subStringFormatter)) | str (type[Tree], str) | can be used on any non-terminal in the grammar |
| ((fileEdits)) | `list[TextEdit] (loc)` | use ((executeTextEdits)) or ((executeFileSystemChanges)) or ((applyFileSystemEdits)) later |

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.

fileEditFormatter

| ((stringFormatter)) | `str (str) ` | |
| ((subStringFormatter)) | str (type[Tree], str) | can be used on any non-terminal in the grammar |
| ((fileEdits)) | `list[TextEdit] (loc)` | use ((executeTextEdits)) or ((executeFileSystemChanges)) or ((applyFileSystemEdits)) later |
| ((treeEdits)) | `list[TextEdit] (Tree)` | |

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.

treeEditFormatter

| ((subStringFormatter)) | str (type[Tree], str) | can be used on any non-terminal in the grammar |
| ((fileEdits)) | `list[TextEdit] (loc)` | use ((executeTextEdits)) or ((executeFileSystemChanges)) or ((applyFileSystemEdits)) later |
| ((treeEdits)) | `list[TextEdit] (Tree)` | |
| ((subTreeEdits)) | `list[TextEdit](Tree)` | this uses a subparser based on the top-level type of the input tree` |

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.

subTreeEditFormatter

| ((fileEdits)) | `list[TextEdit] (loc)` | use ((executeTextEdits)) or ((executeFileSystemChanges)) or ((applyFileSystemEdits)) later |
| ((treeEdits)) | `list[TextEdit] (Tree)` | |
| ((subTreeEdits)) | `list[TextEdit](Tree)` | this uses a subparser based on the top-level type of the input tree` |
| ((stringEdits)) | `list[TextEdit](str)` | |

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.

stringEditFormatter

| ((treeEdits)) | `list[TextEdit] (Tree)` | |
| ((subTreeEdits)) | `list[TextEdit](Tree)` | this uses a subparser based on the top-level type of the input tree` |
| ((stringEdits)) | `list[TextEdit](str)` | |
| ((subStringEdits)) | `list[TextEdit](type[Tree], str)` | |

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.

subStringEditFormatter

* can be used to normalize case-insensitive literals in one go
}
@pitfalls{
* only applicable to entire files. For selection-based formatting see ((subTreeEdits)) and ((subStringEdits)).

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.

subTreeEditFormatter and subStringEditFormatter

* can be used to normalize case-insensitive literals in one go
}
@pitfalls{
* only applicable to entire files. For selection-based formatting see ((subTreeEdits)) and ((subStringEdits)).

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.

subTreeEditFormatter en subStringEditFormatter

* can be used to normalize case-insensitive literals in one go
}
@pitfalls{
* only applicable to entire files. For selection-based formatting see ((subTreeEdits)) and ((subStringEdits)).

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.

subTreeEditFormatter and subStringEditFormatter

* can be slow for very very large input
}
str(str) stringFormatter(type[&G <: Tree] grammar, Style style, FormattingOptions opts=fo()) {
list[TextEdit](str) toEdits = stringEdits(grammar, style, opts=opts);

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.

stringEditFormatter

* can be slow for very very large input
}
str(type[Tree], str) subStringFormatter(type[&G <: Tree] grammar, Style style, FormattingOptions opts=fo()) {
list[TextEdit](type[Tree], str) toEdits = subStringEdits(grammar, style, opts=opts);

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.

subStringEditFormatter

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.

3 participants