[PR #1252] [MERGED] Adjust formatting of qualified access chains #970

Closed
opened 2025-12-30 01:28:01 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/apple/pkl/pull/1252
Author: @bioball
Created: 10/23/2025
Status: Merged
Merged: 10/25/2025
Merged by: @bioball

Base: mainHead: qualified-access-chain-formatting-2


📝 Commits (3)

  • 6292719 Adjust formatting of qualified access chains
  • 8c074d1 Update pkl-parser/src/main/java/org/pkl/parser/GenericParser.java
  • 022a1b3 Address PR comments

📊 Changes

7 files changed (+275 additions, -53 deletions)

View changed files

📝 pkl-formatter/src/main/kotlin/org/pkl/formatter/Builder.kt (+143 -33)
pkl-formatter/src/test/files/FormatterSnippetTests/input/expr-chain-grouping.pkl (+31 -0)
pkl-formatter/src/test/files/FormatterSnippetTests/output/expr-chain-grouping.pkl (+65 -0)
📝 pkl-parser/src/main/java/org/pkl/parser/GenericParser.java (+15 -10)
📝 pkl-parser/src/main/java/org/pkl/parser/syntax/generic/NodeType.java (+1 -0)
📝 pkl-parser/src/test/kotlin/org/pkl/parser/GenericSexpRenderer.kt (+4 -4)
📝 pkl-parser/src/test/kotlin/org/pkl/parser/SexpRenderer.kt (+16 -6)

📄 Description

This adjusts formatting of qualified access chains so that leading dot calls are kept in the same line if possible.

Formatting rules:

If there is a call chain that ends with the only method call, prefer to only wrap the argument list. Render this:

prop =
  foo.baz(new {
    foo = 1
  })

Instead of:

prop =
  foo
    .baz(new {
      foo = 1
    })

If the method call is interspersed within the chain, prefer to wrap before the first method call: Render this:

prop =
  foo.bar
    .baz(new {
      foo = 1
    })
    .qux()

Instead of:

prop =
  foo
    .bar
    .baz(new {
      foo = 1
    })
    .qux()

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/apple/pkl/pull/1252 **Author:** [@bioball](https://github.com/bioball) **Created:** 10/23/2025 **Status:** ✅ Merged **Merged:** 10/25/2025 **Merged by:** [@bioball](https://github.com/bioball) **Base:** `main` ← **Head:** `qualified-access-chain-formatting-2` --- ### 📝 Commits (3) - [`6292719`](https://github.com/apple/pkl/commit/62927198e9678588ca40e85173e69a50f827545e) Adjust formatting of qualified access chains - [`8c074d1`](https://github.com/apple/pkl/commit/8c074d16d56a67d65b52c35ae3f6b8e222044b68) Update pkl-parser/src/main/java/org/pkl/parser/GenericParser.java - [`022a1b3`](https://github.com/apple/pkl/commit/022a1b321d461af846228094448f133af5fb6b33) Address PR comments ### 📊 Changes **7 files changed** (+275 additions, -53 deletions) <details> <summary>View changed files</summary> 📝 `pkl-formatter/src/main/kotlin/org/pkl/formatter/Builder.kt` (+143 -33) ➕ `pkl-formatter/src/test/files/FormatterSnippetTests/input/expr-chain-grouping.pkl` (+31 -0) ➕ `pkl-formatter/src/test/files/FormatterSnippetTests/output/expr-chain-grouping.pkl` (+65 -0) 📝 `pkl-parser/src/main/java/org/pkl/parser/GenericParser.java` (+15 -10) 📝 `pkl-parser/src/main/java/org/pkl/parser/syntax/generic/NodeType.java` (+1 -0) 📝 `pkl-parser/src/test/kotlin/org/pkl/parser/GenericSexpRenderer.kt` (+4 -4) 📝 `pkl-parser/src/test/kotlin/org/pkl/parser/SexpRenderer.kt` (+16 -6) </details> ### 📄 Description This adjusts formatting of qualified access chains so that leading dot calls are kept in the same line if possible. Formatting rules: If there is a call chain that ends with the only method call, prefer to only wrap the argument list. Render this: ```pkl prop = foo.baz(new { foo = 1 }) ``` Instead of: ```pkl prop = foo .baz(new { foo = 1 }) ``` If the method call is interspersed within the chain, prefer to wrap before the first method call: Render this: ```pkl prop = foo.bar .baz(new { foo = 1 }) .qux() ``` Instead of: ```pkl prop = foo .bar .baz(new { foo = 1 }) .qux() ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 01:28:01 +01:00
adam closed this issue 2025-12-30 01:28:01 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#970