Skip to content

Move AST transforms to nf-lang #6247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2025
Merged

Move AST transforms to nf-lang #6247

merged 2 commits into from
Jul 8, 2025

Conversation

bentsherman
Copy link
Member

@bentsherman bentsherman commented Jul 3, 2025

This PR moves some AST transforms, those that are used both by the v1 and v2 parsers, into nf-lang.

This is needed to give me better visibility and control over the total sequence of AST transforms in the Nextflow compiler. It also allows me to remove some ugliness in ScriptCompiler and ConfigCompiler.

I left some AST transforms like NextflowDSLImpl alone because they aren't used by the v2 parser and will be deprecated anyway.

Copilot summary

This pull request refactors the AST transformation logic in the Nextflow codebase by replacing several standalone implementation classes with inline implementations defined within their respective annotations. Additionally, it removes unused imports and simplifies the structure of transformation-related files. The changes also include the migration of the LangHelpers utility class to a new package to better align with its purpose. Below are the key changes grouped by theme:

Refactoring AST Transformations:

  • Replaced the standalone NextflowXformImpl class with an inline implementation inside the NextflowXform annotation. The new implementation uses PathCompareVisitor for path comparison logic. (modules/nextflow/src/main/groovy/nextflow/ast/NextflowXform.groovy)
  • Replaced the standalone OpXformImpl class with an inline implementation inside the OpXform annotation, utilizing OpCriteriaVisitor for transforming closure arguments into criteria objects. (modules/nextflow/src/main/groovy/nextflow/ast/OpXform.groovy)
  • Replaced the standalone TaskTemplateVarsXformImpl class with an inline implementation inside the TaskTemplateVarsXform annotation, delegating variable capture to TaskTemplateVisitor. (modules/nextflow/src/main/groovy/nextflow/ast/TaskTemplateVarsXform.groovy)
  • Replaced the standalone StripSecretsXformImpl class with an inline implementation inside the StripSecretsXform annotation, using StripSecretsVisitor to handle secret property replacements. (modules/nextflow/src/main/groovy/nextflow/config/StripSecretsXform.groovy) [1] [2]

Code Cleanup:

  • Removed the now-unused standalone implementation files: NextflowXformImpl.groovy, OpXformImpl.groovy, TaskTemplateVarsXformImpl.groovy, and StripSecretsXformImpl.groovy. [1] [2] [3]
  • Eliminated unused imports from Nextflow.groovy, ConfigCompiler.java, and ScriptCompiler.java after removing the standalone transformation implementations. [1] [2] [3]

Compiler Updates:

  • Updated the ConfigCompiler and ScriptCompiler classes to use the new visitor-based transformation approach (PathCompareVisitor, OpCriteriaVisitor, and StripSecretsVisitor) instead of the removed standalone classes. (modules/nextflow/src/main/groovy/nextflow/config/parser/v2/ConfigCompiler.java) [1] [2]

Utility Class Migration:

  • Moved the LangHelpers class from the nextflow.ast package to nextflow.util to better reflect its utility nature. Adjusted its visibility by removing the @PackageScope annotation. (modules/nextflow/src/main/groovy/nextflow/util/LangHelpers.java) [1] [2] [3] [4]

@bentsherman bentsherman requested a review from pditommaso July 3, 2025 17:41
@bentsherman bentsherman requested a review from a team as a code owner July 3, 2025 17:41
Copy link

netlify bot commented Jul 3, 2025

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 4cdef4a
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/686d378ef0429e0008225228

Copy link
Member

@pditommaso pditommaso left a comment

Choose a reason for hiding this comment

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

Looks like some tests are failing

@bentsherman bentsherman requested a review from pditommaso July 7, 2025 16:00
@pditommaso pditommaso merged commit 824dabb into master Jul 8, 2025
21 of 22 checks passed
@pditommaso pditommaso deleted the lang-ast-visitors branch July 8, 2025 15:56
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