René's URL Explorer Experiment


Title: Keep a Mutiny group call on one line with the call that completes it · Issue #25 · openjavaformat/open-java-format · GitHub

Open Graph Title: Keep a Mutiny group call on one line with the call that completes it · Issue #25 · openjavaformat/open-java-format

X Title: Keep a Mutiny group call on one line with the call that completes it · Issue #25 · openjavaformat/open-java-format

Description: Motivation SmallRye Mutiny is designed so that a chain reads as a sentence. A "group" call selects what you are talking about, and the next call says what to do: onItem().transform(…), onFailure(IOException.class).recoverWithItem(…), sub...

Open Graph Description: Motivation SmallRye Mutiny is designed so that a chain reads as a sentence. A "group" call selects what you are talking about, and the next call says what to do: onItem().transform(…), onFailure(IO...

X Description: Motivation SmallRye Mutiny is designed so that a chain reads as a sentence. A "group" call selects what you are talking about, and the next call says what to do: onItem().transform(…), on...

Opengraph URL: https://github.com/openjavaformat/open-java-format/issues/25

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Keep a Mutiny group call on one line with the call that completes it","articleBody":"### Motivation\n\n[SmallRye Mutiny](https://smallrye.io/smallrye-mutiny/) is designed so that a chain reads as a sentence. A \"group\" call selects what you are talking about, and the next call says what to do: `onItem().transform(…)`, `onFailure(IOException.class).recoverWithItem(…)`, `subscribe().with(…)`. The formatter puts every call on its own line, which cuts each phrase in two.\n\nToday, 2.98.0.1:\n\n```java\nrequest.ifNoItem()\n        .after(ofMillis(100))\n        .failWith(() -> new TooSlowException(\"boom\"))\n        .onFailure(IOException.class)\n        .recoverWithItem(fail -> \"fallback\")\n        .subscribe()\n        .with(item -> log(\"ok \" + item), err -> log(err.getMessage()));\n```\n\nWanted:\n\n```java\nrequest.ifNoItem().after(ofMillis(100)).failWith(() -> new TooSlowException(\"boom\"))\n        .onFailure(IOException.class).recoverWithItem(fail -> \"fallback\")\n        .subscribe().with(item -> log(\"ok \" + item), err -> log(err.getMessage()));\n```\n\n### It fits the current design\n\nThe chain layout already knows a few method names. `LOG_METHODS` keeps Flogger's `logger.atInfo().log(…)` together, and `handleStream` keeps `stream()`, `parallelStream()` and `toBuilder()` with the expression before them.\n\nBreaks in a chain are emitted in two loops, in `visitRegularDot` and `visitDotWithPrefix`: one `breakOp` before every dot. Keeping two calls together means not emitting that break before the second one. Nothing in `doc/` has to change.\n\nThe formatter has no type information, so it cannot know that a receiver is a `Uni`. The rule therefore has to go by method names, and to keep it from firing on unrelated code it can be switched on only in a compilation unit that imports `io.smallrye.mutiny.*`. `visitCompilationUnit` sees the imports before anything else.\n\n### Prototype\n\nA spike on top of `7f06ca16` does exactly that: a set of group method names, a `gluedToPrevious(items, i)` check in both loops, and the import gate. It is one file, +41 −9 lines. A group call counts only when it has no arguments, so that `collect(Collectors.toList())` on a stream is left alone, with `onFailure(…)` and `after(…)` as the exceptions.\n\nResults:\n\n- the example above comes out as the \"wanted\" block;\n- `uni.onItem().transform(String::toUpperCase)` and `multi.collect().asList()` style phrases stay on one line, and a plain `stream()` chain in the same file is unchanged;\n- formatting the result again changes nothing;\n- the same code without the Mutiny import is byte-identical to 2.98.0.1;\n- 116 files of this repository, about 25,000 lines of output, format identically with the release and with the spike.\n\n### To design properly\n\n- **The list.** Which calls are groups, including the second-level ones. The spike leaves `.onFailure().retry()` on one line and `.atMost(3)` on the next, because `retry()` is a group too. `ifNull()`, `ifNotNull()` and `delayIt()` are in the same family.\n- **A phrase that does not fit.** The spike never breaks inside a phrase, so an over-long one breaks inside its arguments instead, which looks worse than today. The break should stay available but be taken only when the phrase does not fit on the line, that is, a level of its own with an independent break instead of no break at all.\n- **The gate.** A file that uses Mutiny without importing it, for example through `var`, keeps today's layout. That seems an acceptable fallback.\n- **Built-in knowledge or configuration.** The formatter has no options, and this should not become the first one. A small built-in table of import prefix and group method names would also cover other libraries with the same grammar, if any turn up.\n\n### Compatibility\n\nFiles that do not import Mutiny are unaffected. Files that do will format differently from palantir-java-format 2.98.0, so under the 2.x promise this is a 3.0 change unless decided otherwise.\n\n\u003cdetails>\n\u003csummary>The spike, as a diff\u003c/summary>\n\n```diff\ndiff --git a/open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java b/open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java\nindex 3917911e..6e8b1876 100644\n--- a/open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java\n+++ b/open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java\n@@ -345,6 +345,8 @@ public class JavaInputAstVisitor extends TreePathScanner\u003cVoid, Void> {\n \n     @Override\n     public Void visitCompilationUnit(CompilationUnitTree node, Void unused) {\n+        fluentGroupsEnabled = node.getImports().stream()\n+                .anyMatch(i -> i.getQualifiedIdentifier().toString().startsWith(\"io.smallrye.mutiny.\"));\n         boolean first = true;\n         if (node.getPackageName() != null) {\n             markForPartialFormat();\n@@ -1610,6 +1612,33 @@ public class JavaInputAstVisitor extends TreePathScanner\u003cVoid, Void> {\n             \"withCause\",\n             \"withStackTrace\");\n \n+    /** SPIKE: Mutiny \"group\" calls read as one phrase with the call that follows them. */\n+    private boolean fluentGroupsEnabled = false;\n+\n+    private static final ImmutableSet\u003cString> FLUENT_GROUP_METHODS = ImmutableSet.of(\n+            \"onItem\", \"onFailure\", \"onItemOrFailure\", \"onSubscription\", \"onTermination\", \"onCancellation\",\n+            \"onCompletion\", \"onOverflow\", \"onRequest\", \"ifNoItem\", \"subscribe\", \"await\", \"collect\", \"select\",\n+            \"skip\", \"group\", \"broadcast\", \"memoize\", \"convert\", \"after\");\n+\n+    /** Whether items[i] must stay on the line of items[i - 1]. */\n+    private boolean gluedToPrevious(List\u003cExpressionTree> items, int i) {\n+        if (!fluentGroupsEnabled || i == 0 || !(items.get(i) instanceof MethodInvocationTree)) {\n+            return false;\n+        }\n+        ExpressionTree previous = items.get(i - 1);\n+        if (!(previous instanceof MethodInvocationTree)) {\n+            return false;\n+        }\n+        MethodInvocationTree call = (MethodInvocationTree) previous;\n+        String name = getMethodName(call).toString();\n+        if (!FLUENT_GROUP_METHODS.contains(name)) {\n+            return false;\n+        }\n+        // `collect(toList())` on a stream is an action; Mutiny's groups take no arguments,\n+        // except onFailure(Class) and ifNoItem().after(Duration).\n+        return call.getArguments().isEmpty() || name.equals(\"onFailure\") || name.equals(\"after\");\n+    }\n+\n     private static List\u003cLong> handleStream(List\u003cExpressionTree> parts) {\n         return indexes(parts.stream(), p -> {\n                     if (!(p instanceof MethodInvocationTree)) {\n@@ -2857,9 +2886,10 @@ public class JavaInputAstVisitor extends TreePathScanner\u003cVoid, Void> {\n         // chain starts with another expression\n         int minLength = indentMultiplier * 4;\n         int length = needDot0 ? minLength : 0;\n-        for (ExpressionTree e : items) {\n+        for (int itemIndex = 0; itemIndex \u003c items.size(); itemIndex++) {\n+            ExpressionTree e = items.get(itemIndex);\n             if (needDot) {\n-                if (length > minLength) {\n+                if (length > minLength && !gluedToPrevious(items, itemIndex)) {\n                     builder.breakOp(Break.builder()\n                             .fillMode(FillMode.UNIFIED)\n                             .flat(\"\")\n@@ -2966,13 +2996,15 @@ public class JavaInputAstVisitor extends TreePathScanner\u003cVoid, Void> {\n                     fillMode = FillMode.UNIFIED;\n                 }\n \n-                builder.breakOp(Break.builder()\n-                        .fillMode(fillMode)\n-                        .flat(\"\")\n-                        .plusIndent(ZERO)\n-                        .optTag(Optional.of(nameTag))\n-                        .hasColumnLimit(shouldHaveColumnLimit(e))\n-                        .build());\n+                if (!gluedToPrevious(items, i)) {\n+                    builder.breakOp(Break.builder()\n+                            .fillMode(fillMode)\n+                            .flat(\"\")\n+                            .plusIndent(ZERO)\n+                            .optTag(Optional.of(nameTag))\n+                            .hasColumnLimit(shouldHaveColumnLimit(e))\n+                            .build());\n+                }\n                 token(\".\");\n             }\n             BreakTag tyargTag = new BreakTag();\n```\n\n\u003c/details>\n","author":{"url":"https://github.com/abashev","@type":"Person","name":"abashev"},"datePublished":"2026-09-21T14:09:35Z","url":"https://github.com/openjavaformat/open-java-format/issues/25"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:859b86fb-246d-3b04-e696-4c083306f6b9
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id826A:D1712:5E9588:7DA1C1:6AFBC735
html-safe-nonce89173416e07c53e068c4a57047f2d94376be3e380354bcefeca4d09ccc16d42b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjZBOkQxNzEyOjVFOTU4ODo3REExQzE6NkFGQkM3MzUiLCJ2aXNpdG9yX2lkIjoiNDIxODUyMjg0MTM0MDY5MjI3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaceef5d754d3626688599eb833bdab4d80fadb819eb304a8294c33e99c145661e5
hovercard-subject-tagissue:5528110041
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/openjavaformat/open-java-format/25/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7b6bb31daba8a562554e19a51e0cb71a25bea36e54774a735deca89c8f2be295/openjavaformat/open-java-format/issues/25
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7b6bb31daba8a562554e19a51e0cb71a25bea36e54774a735deca89c8f2be295/openjavaformat/open-java-format/issues/25
og:image:altMotivation SmallRye Mutiny is designed so that a chain reads as a sentence. A "group" call selects what you are talking about, and the next call says what to do: onItem().transform(…), onFailure(IO...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameabashev
hostnamegithub.com
expected-hostnamegithub.com
Noned440bda0d812801778b27bfe9f7c1ce9ff22420c73f6f95150c4fcbca311c50b
turbo-cache-controlno-preview
go-importgithub.com/openjavaformat/open-java-format git https://github.com/openjavaformat/open-java-format.git
octolytics-dimension-user_id325177626
octolytics-dimension-user_loginopenjavaformat
octolytics-dimension-repository_id1288055459
octolytics-dimension-repository_nwoopenjavaformat/open-java-format
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forktrue
octolytics-dimension-repository_parent_id214273098
octolytics-dimension-repository_parent_nwopalantir/palantir-java-format
octolytics-dimension-repository_network_root_id214273098
octolytics-dimension-repository_network_root_nwopalantir/palantir-java-format
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2c43021aed8695990c86c0eaaedc600bfeffec36
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/openjavaformat/open-java-format/issues/25#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenjavaformat%2Fopen-java-format%2Fissues%2F25
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fopenjavaformat%2Fopen-java-format%2Fissues%2F25
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=openjavaformat%2Fopen-java-format
Reloadhttps://github.com/openjavaformat/open-java-format/issues/25
Reloadhttps://github.com/openjavaformat/open-java-format/issues/25
Reloadhttps://github.com/openjavaformat/open-java-format/issues/25
openjavaformathttps://github.com/openjavaformat
open-java-formathttps://github.com/openjavaformat/open-java-format
Codehttps://github.com/openjavaformat/open-java-format
Issues30 (30)https://github.com/openjavaformat/open-java-format/issues
Pull requests5 (5)https://github.com/openjavaformat/open-java-format/pulls
Discussionshttps://github.com/openjavaformat/open-java-format/discussions
Actionshttps://github.com/openjavaformat/open-java-format/actions
Security and qualityhttps://github.com/openjavaformat/open-java-format/security
Insightshttps://github.com/openjavaformat/open-java-format/pulse
https://github.com/openjavaformat/open-java-format
New issuehttps://github.com/login?return_to=https://github.com/openjavaformat/open-java-format/issues/25
New issuehttps://github.com/login?return_to=https://github.com/openjavaformat/open-java-format/issues/25
Keep a Mutiny group call on one line with the call that completes ithttps://github.com/openjavaformat/open-java-format/issues/25#top
enhancementNew feature or requesthttps://github.com/openjavaformat/open-java-format/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com/abashev
abashevhttps://github.com/abashev
on Sep 21, 2026https://github.com/openjavaformat/open-java-format/issues/25#issue-5528110041
SmallRye Mutinyhttps://smallrye.io/smallrye-mutiny/
abashevhttps://github.com/abashev
enhancementNew feature or requesthttps://github.com/openjavaformat/open-java-format/issues?q=state%3Aopen%20label%3A%22enhancement%22
on Sep 21, 2026https://github.com/openjavaformat/open-java-format/issues/25#event-31534076625
Sign up for freehttps://github.com/signup?return_to=https://github.com/openjavaformat/open-java-format/issues/25
Sign in to commenthttps://github.com/login?return_to=https://github.com/openjavaformat/open-java-format/issues/25
enhancementNew feature or requesthttps://github.com/openjavaformat/open-java-format/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.