Integrate the comment-preserving nf-lang formatter - #163
Open
ewels wants to merge 8 commits into
Open
Conversation
…xtflow#7346) Points the build at the nf-lang formatter overhaul from PR nextflow-io/nextflow#7346, published to Maven local from the PR head branch. This commit must be amended to the released nf-lang version once the PR is merged and an nf-lang release exists — do not ship it as-is. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6xXG4ocbea6AW3f9hYsJb
Expose the new nf-lang line-wrapping option as nextflow.formatting.maxLineLength (default FormattingOptions.DEFAULT_MAX_LINE_LENGTH = 120, 0 disables wrapping) and pass it explicitly into every FormattingOptions construction, so the language server never relies on the 5-arg constructor's implicit default. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6xXG4ocbea6AW3f9hYsJb
…omment loss Use the new 3-arg visitor constructors so comment reattachment always sees exactly the buffer being formatted instead of re-reading the SourceUnit. Adopt the same safety check as 'nextflow lint -format': compare CommentReattacher.commentTexts before and after formatting and refuse to return any edit if a comment would be removed or altered. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6xXG4ocbea6AW3f9hYsJb
Pin the new canonical style at the language-server level: K&R if/else, blank-line normalization, comment preservation (trailing, dangling and commented-out declarations), line wrapping at the configured maximum line length, and fmt: skip / fmt: off / fmt: on directives. Add integration tests for the language-server trigger scenarios: - formatting the same cached AST repeatedly without a document change produces identical output (comment metadata re-derivation must be idempotent) - maxLineLength=0 disables line wrapping - a file using fmt: off/on round-trips unchanged - converting a script to static types after formatting the same cached AST neither crashes nor duplicates comments (the conversion formats freshly-built AST nodes that carry no reattached comment metadata) The cached-AST tests write the file to disk first: the deferred workspace scan re-scans from disk and would otherwise evict an in-memory-only file from the AST cache between requests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6xXG4ocbea6AW3f9hYsJb
…ents Pin the language-server-side behavior for the remaining formatter issues closed by nextflow-io/nextflow#7346: include sorting under sortDeclarations (#54), multi-line string re-indentation (#116), and leading comments in CRLF files no longer merging with the following code (#127). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6xXG4ocbea6AW3f9hYsJb
The Nextflow docs moved from nextflow.io/docs/latest to docs.seqera.io/nextflow upstream, so the doc links baked into nf-lang 26.07.0-edge annotations changed accordingly. This change is durable: it applies to any nf-lang release cut from current master, independent of the formatter overhaul. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6xXG4ocbea6AW3f9hYsJb
- Extract the comment-preservation check into a shared FormattingProvider.commentsPreserved helper so the script and config providers no longer duplicate the safety-critical guard, and return no edits when the formatted text is unchanged instead of a whole-document no-op edit. - Move the file-on-disk workaround for the deferred workspace scan into TestUtils (openOnDisk/deleteOnDisk) so the eviction rationale is documented once instead of in three test classes. - Rebuild ConfigFormattingTest on the shared TestUtils harness instead of a private service-bootstrap clone. - Collapse round-trip test cases onto checkRoundTrip helpers instead of pasting identical literals twice, and make the cached-AST tests use non-canonical input so a refused format cannot be mistaken for a no-op. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6xXG4ocbea6AW3f9hYsJb
nextflow-io/nextflow#7346 was merged in a reworked form scoped to comment preservation and multi-line string re-indentation: comments are now collected at parse time (opt-in via COMMENTS_OPTION) and attached positionally per formatting pass, and the maxLineLength option, fmt directives, K&R style, blank-line normalization, and include sorting were deferred to follow-up PRs. - Bump nf-lang to the released 26.08.0-edge (contains the merge). - Enable COMMENTS_OPTION in the script and config compiler configurations so parses collect the comment metadata the formatter needs; without it every comment is dropped and the blank-line map degenerates (each preceding line counts as blank). - Remove the maxLineLength option and wiring (deferred upstream). - Revert the formatting visitors to the 2-arg constructors and port the refuse-to-format guard to Comments.textsOf. - Drop the LEADING_COMMENTS metadata hack in the params conversion: the marker was removed and comments now attach positionally, so synthesized params no longer carry description comments (a known limitation of the conversion preview). - Prune the tests pinning deferred features; keep comment preservation, CRLF handling, string re-indentation, cached-AST idempotency, and the conversion tests; update hover-doc links for the upstream stdlib-namespaces docs move. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6xXG4ocbea6AW3f9hYsJb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Integrates the nf-lang formatter rework from nextflow-io/nextflow#7346 (merged, released as nf-lang
26.08.0-edge): comment preservation, multi-line string re-indentation, and the same refuse-to-format-on-comment-loss guard asnextflow lint. Updates the test suite accordingly.Changes
nf-lang 26.08.0-edge
build.gradlebumpsio.nextflow:nf-langto26.08.0-edge, the first release containing the merged formatter rework.Comment collection at parse time
COMMENTS_OPTION, so every parse attaches theCOMMENTSmetadata the formatter needs. Without it, formatting silently drops every comment and the formatter's blank-line map degenerates (each line preceding a node counts as blank).Safety guard
FormattingProvider.commentsPreserved()helper uses the publicComments.textsOf(source, config)API: if formatting would remove or alter any comment, the provider shows an error and returns no edits — same behavior asnextflow lint -format.Code lens conversion
convertScriptToTyped/convertPipelineToTyped) no longer attachLEADING_COMMENTSmetadata to synthesized params: the marker was removed upstream and comments now attach positionally per formatting pass. Converted params no longer carry their@Descriptioncomments — a known limitation of the conversion preview to revisit.Tests
maxLineLength, K&R, blank-line normalization,fmt:directives, include sorting).PluginSpecCacheTestin sandboxed environments without network egress (unrelated; passes in CI).Issue closing
With the reduced upstream scope, only these language-server issues are fixed by this integration: #111, #116, #127, #140 (GitHub does not auto-close cross-repo references, so they need manual closing once this ships). The rest of the original list — #26, #54, #75, #115, #150, #153 — remain open, deferred to follow-up nf-lang PRs.
Release ordering
Preserve comments in formatter nextflow#7346 merges(done, 2026-08-18)nf-lang release(done,26.08.0-edge)🤖 Generated with Claude Code
https://claude.ai/code/session_01L6xXG4ocbea6AW3f9hYsJb