diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..775da50 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,24 @@ +name: Nextflow language server CI +# read more here: https://help.github.com/en/articles/workflow-syntax-for-github-actions#on + +on: + push: + branches: + - 'main' + pull_request: + types: [opened, reopened, synchronize] + workflow_dispatch: + +jobs: + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Compile + run: ./gradlew build diff --git a/build.gradle b/build.gradle index 79677da..63fddeb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,39 +1,10 @@ -plugins { - id 'com.gradleup.shadow' version '8.3.5' - id 'application' - id 'antlr' -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -repositories { - mavenCentral() -} - -dependencies { - antlr 'org.antlr:antlr4:4.9.2' - implementation 'com.google.guava:guava:33.3.1-jre' - implementation 'org.apache.groovy:groovy:4.0.24' - implementation 'org.apache.groovy:groovy-json:4.0.24' - implementation 'org.codehaus.gpars:gpars:1.2.1' - implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.23.0' - implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.23.0' - - testImplementation ("net.bytebuddy:byte-buddy:1.14.17") - testImplementation ("org.spockframework:spock-core:2.3-groovy-4.0") { exclude group: 'org.apache.groovy' } -} - -generateGrammarSource { - arguments += ['-no-listener', '-no-visitor'] -} -application { - mainClass = 'nextflow.lsp.NextflowLanguageServer' +task copyJar(type: Copy) { + dependsOn ':modules:language-server:build' + from "$projectDir/modules/language-server/build/libs/language-server-all.jar" + into "$buildDir/libs" } -test { - useJUnitPlatform() +task build { + dependsOn copyJar } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 0000000..7c9eeeb --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,7 @@ +plugins { + id 'groovy-gradle-plugin' +} + +repositories { + gradlePluginPortal() +} diff --git a/buildSrc/src/main/groovy/nextflow.java-conventions.gradle b/buildSrc/src/main/groovy/nextflow.java-conventions.gradle new file mode 100644 index 0000000..e7d2d53 --- /dev/null +++ b/buildSrc/src/main/groovy/nextflow.java-conventions.gradle @@ -0,0 +1,23 @@ +plugins { + id 'java' +} + +repositories { + mavenCentral() +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +compileJava { + options.release.set(17) +} + +test { + useJUnitPlatform() +} diff --git a/modules/compiler/build.gradle b/modules/compiler/build.gradle new file mode 100644 index 0000000..6df762b --- /dev/null +++ b/modules/compiler/build.gradle @@ -0,0 +1,18 @@ +plugins { + id 'nextflow.java-conventions' + id 'antlr' +} + +dependencies { + antlr 'org.antlr:antlr4:4.9.2' + implementation 'com.google.guava:guava:33.3.1-jre' + implementation 'org.apache.groovy:groovy:4.0.24' + implementation 'org.codehaus.gpars:gpars:1.2.1' + + testImplementation ('net.bytebuddy:byte-buddy:1.14.17') + testImplementation ('org.spockframework:spock-core:2.3-groovy-4.0') { exclude group: 'org.apache.groovy' } +} + +generateGrammarSource { + arguments += ['-no-listener', '-no-visitor'] +} diff --git a/src/main/antlr/ConfigLexer.g4 b/modules/compiler/src/main/antlr/ConfigLexer.g4 similarity index 99% rename from src/main/antlr/ConfigLexer.g4 rename to modules/compiler/src/main/antlr/ConfigLexer.g4 index 28eb235..6fd9201 100644 --- a/src/main/antlr/ConfigLexer.g4 +++ b/modules/compiler/src/main/antlr/ConfigLexer.g4 @@ -40,14 +40,15 @@ options { } @header { -package nextflow.antlr; +package nextflow.config.parser; import java.util.*; import java.util.regex.Pattern; +import nextflow.script.parser.AbstractLexer; import org.antlr.v4.runtime.CharStream; import org.apache.groovy.parser.antlr4.GroovySyntaxError; -import static nextflow.antlr.SemanticPredicates.*; +import static nextflow.script.parser.SemanticPredicates.*; } @members { diff --git a/src/main/antlr/ConfigParser.g4 b/modules/compiler/src/main/antlr/ConfigParser.g4 similarity index 98% rename from src/main/antlr/ConfigParser.g4 rename to modules/compiler/src/main/antlr/ConfigParser.g4 index 8334cfd..670bf2f 100644 --- a/src/main/antlr/ConfigParser.g4 +++ b/modules/compiler/src/main/antlr/ConfigParser.g4 @@ -41,9 +41,12 @@ options { } @header { -package nextflow.antlr; +package nextflow.config.parser; +import nextflow.script.parser.AbstractParser; import org.apache.groovy.parser.antlr4.GroovySyntaxError; + +import static nextflow.script.parser.SemanticPredicates.*; } @members { @@ -233,7 +236,7 @@ assignmentStatement expressionStatement : expression ( - { SemanticPredicates.isValidDirective($expression.ctx) }? argumentList + { isValidDirective($expression.ctx) }? argumentList | /* only certain expressions can be called as a directive (no parens) */ ) diff --git a/src/main/antlr/ScriptLexer.g4 b/modules/compiler/src/main/antlr/ScriptLexer.g4 similarity index 99% rename from src/main/antlr/ScriptLexer.g4 rename to modules/compiler/src/main/antlr/ScriptLexer.g4 index 0c693ed..a9d2e18 100644 --- a/src/main/antlr/ScriptLexer.g4 +++ b/modules/compiler/src/main/antlr/ScriptLexer.g4 @@ -40,14 +40,14 @@ options { } @header { -package nextflow.antlr; +package nextflow.script.parser; import java.util.*; import java.util.regex.Pattern; import org.antlr.v4.runtime.CharStream; import org.apache.groovy.parser.antlr4.GroovySyntaxError; -import static nextflow.antlr.SemanticPredicates.*; +import static nextflow.script.parser.SemanticPredicates.*; } @members { diff --git a/src/main/antlr/ScriptParser.g4 b/modules/compiler/src/main/antlr/ScriptParser.g4 similarity index 99% rename from src/main/antlr/ScriptParser.g4 rename to modules/compiler/src/main/antlr/ScriptParser.g4 index 0063b64..c610bb2 100644 --- a/src/main/antlr/ScriptParser.g4 +++ b/modules/compiler/src/main/antlr/ScriptParser.g4 @@ -41,9 +41,11 @@ options { } @header { -package nextflow.antlr; +package nextflow.script.parser; import org.apache.groovy.parser.antlr4.GroovySyntaxError; + +import static nextflow.script.parser.SemanticPredicates.*; } @members { @@ -356,7 +358,7 @@ assignmentStatement expressionStatement : expression ( - { SemanticPredicates.isValidDirective($expression.ctx) }? argumentList + { isValidDirective($expression.ctx) }? argumentList | /* only certain expressions can be called as a directive (no parens) */ ) diff --git a/src/main/java/nextflow/config/v2/ConfigAppendNode.java b/modules/compiler/src/main/java/config/ast/ConfigAppendNode.java similarity index 96% rename from src/main/java/nextflow/config/v2/ConfigAppendNode.java rename to modules/compiler/src/main/java/config/ast/ConfigAppendNode.java index d738b79..2416ea2 100644 --- a/src/main/java/nextflow/config/v2/ConfigAppendNode.java +++ b/modules/compiler/src/main/java/config/ast/ConfigAppendNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.ast; import java.util.List; diff --git a/src/main/java/nextflow/config/v2/ConfigAssignNode.java b/modules/compiler/src/main/java/config/ast/ConfigAssignNode.java similarity index 97% rename from src/main/java/nextflow/config/v2/ConfigAssignNode.java rename to modules/compiler/src/main/java/config/ast/ConfigAssignNode.java index 72e4550..39d2a6b 100644 --- a/src/main/java/nextflow/config/v2/ConfigAssignNode.java +++ b/modules/compiler/src/main/java/config/ast/ConfigAssignNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.ast; import java.util.List; diff --git a/src/main/java/nextflow/config/v2/ConfigBlockNode.java b/modules/compiler/src/main/java/config/ast/ConfigBlockNode.java similarity index 97% rename from src/main/java/nextflow/config/v2/ConfigBlockNode.java rename to modules/compiler/src/main/java/config/ast/ConfigBlockNode.java index 83d67f7..5df47cb 100644 --- a/src/main/java/nextflow/config/v2/ConfigBlockNode.java +++ b/modules/compiler/src/main/java/config/ast/ConfigBlockNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.ast; import java.util.List; diff --git a/src/main/java/nextflow/config/v2/ConfigIncludeNode.java b/modules/compiler/src/main/java/config/ast/ConfigIncludeNode.java similarity index 97% rename from src/main/java/nextflow/config/v2/ConfigIncludeNode.java rename to modules/compiler/src/main/java/config/ast/ConfigIncludeNode.java index 0c4dde9..08f632c 100644 --- a/src/main/java/nextflow/config/v2/ConfigIncludeNode.java +++ b/modules/compiler/src/main/java/config/ast/ConfigIncludeNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.ast; import org.codehaus.groovy.ast.expr.Expression; diff --git a/src/main/java/nextflow/config/v2/ConfigIncompleteNode.java b/modules/compiler/src/main/java/config/ast/ConfigIncompleteNode.java similarity index 97% rename from src/main/java/nextflow/config/v2/ConfigIncompleteNode.java rename to modules/compiler/src/main/java/config/ast/ConfigIncompleteNode.java index 8155e1a..767db3b 100644 --- a/src/main/java/nextflow/config/v2/ConfigIncompleteNode.java +++ b/modules/compiler/src/main/java/config/ast/ConfigIncompleteNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.ast; /** * diff --git a/src/main/java/nextflow/config/v2/ConfigNode.java b/modules/compiler/src/main/java/config/ast/ConfigNode.java similarity index 97% rename from src/main/java/nextflow/config/v2/ConfigNode.java rename to modules/compiler/src/main/java/config/ast/ConfigNode.java index 273c77d..3861002 100644 --- a/src/main/java/nextflow/config/v2/ConfigNode.java +++ b/modules/compiler/src/main/java/config/ast/ConfigNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.ast; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/nextflow/config/v2/ConfigStatement.java b/modules/compiler/src/main/java/config/ast/ConfigStatement.java similarity index 96% rename from src/main/java/nextflow/config/v2/ConfigStatement.java rename to modules/compiler/src/main/java/config/ast/ConfigStatement.java index dd47362..75ef799 100644 --- a/src/main/java/nextflow/config/v2/ConfigStatement.java +++ b/modules/compiler/src/main/java/config/ast/ConfigStatement.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.ast; import org.codehaus.groovy.ast.stmt.Statement; diff --git a/src/main/java/nextflow/config/v2/ConfigVisitor.java b/modules/compiler/src/main/java/config/ast/ConfigVisitor.java similarity index 97% rename from src/main/java/nextflow/config/v2/ConfigVisitor.java rename to modules/compiler/src/main/java/config/ast/ConfigVisitor.java index 70e691b..a23e18a 100644 --- a/src/main/java/nextflow/config/v2/ConfigVisitor.java +++ b/modules/compiler/src/main/java/config/ast/ConfigVisitor.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.ast; import org.codehaus.groovy.ast.GroovyCodeVisitor; diff --git a/src/main/java/nextflow/config/v2/ConfigVisitorSupport.java b/modules/compiler/src/main/java/config/ast/ConfigVisitorSupport.java similarity index 98% rename from src/main/java/nextflow/config/v2/ConfigVisitorSupport.java rename to modules/compiler/src/main/java/config/ast/ConfigVisitorSupport.java index 90eb036..7b1c373 100644 --- a/src/main/java/nextflow/config/v2/ConfigVisitorSupport.java +++ b/modules/compiler/src/main/java/config/ast/ConfigVisitorSupport.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.ast; import org.codehaus.groovy.ast.ClassCodeVisitorSupport; import org.codehaus.groovy.ast.expr.MethodCallExpression; diff --git a/src/main/java/nextflow/config/dsl/ConfigOption.java b/modules/compiler/src/main/java/config/dsl/ConfigOption.java similarity index 100% rename from src/main/java/nextflow/config/dsl/ConfigOption.java rename to modules/compiler/src/main/java/config/dsl/ConfigOption.java diff --git a/src/main/java/nextflow/config/dsl/ConfigSchema.java b/modules/compiler/src/main/java/config/dsl/ConfigSchema.java similarity index 100% rename from src/main/java/nextflow/config/dsl/ConfigSchema.java rename to modules/compiler/src/main/java/config/dsl/ConfigSchema.java diff --git a/src/main/java/nextflow/config/dsl/ConfigScope.java b/modules/compiler/src/main/java/config/dsl/ConfigScope.java similarity index 100% rename from src/main/java/nextflow/config/dsl/ConfigScope.java rename to modules/compiler/src/main/java/config/dsl/ConfigScope.java diff --git a/src/main/java/nextflow/config/v2/ConfigAstBuilder.java b/modules/compiler/src/main/java/config/parser/ConfigAstBuilder.java similarity index 99% rename from src/main/java/nextflow/config/v2/ConfigAstBuilder.java rename to modules/compiler/src/main/java/config/parser/ConfigAstBuilder.java index e80e352..cb6edbc 100644 --- a/src/main/java/nextflow/config/v2/ConfigAstBuilder.java +++ b/modules/compiler/src/main/java/config/parser/ConfigAstBuilder.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.parser; import java.io.BufferedReader; import java.io.IOException; @@ -26,9 +26,14 @@ import com.google.common.hash.Hashing; import groovy.lang.Tuple2; -import nextflow.antlr.ConfigLexer; -import nextflow.antlr.ConfigParser; -import nextflow.antlr.DescriptiveErrorStrategy; +import nextflow.config.ast.ConfigAppendNode; +import nextflow.config.ast.ConfigAssignNode; +import nextflow.config.ast.ConfigBlockNode; +import nextflow.config.ast.ConfigIncludeNode; +import nextflow.config.ast.ConfigIncompleteNode; +import nextflow.config.ast.ConfigNode; +import nextflow.config.ast.ConfigStatement; +import nextflow.script.parser.DescriptiveErrorStrategy; import org.antlr.v4.runtime.ANTLRErrorListener; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; @@ -87,8 +92,8 @@ import org.codehaus.groovy.syntax.SyntaxException; import org.codehaus.groovy.syntax.Types; -import static nextflow.antlr.ConfigParser.*; -import static nextflow.antlr.PositionConfigureUtils.ast; +import static nextflow.config.parser.ConfigParser.*; +import static nextflow.script.parser.PositionConfigureUtils.ast; import static org.codehaus.groovy.ast.expr.VariableExpression.THIS_EXPRESSION; import static org.codehaus.groovy.ast.tools.GeneralUtils.*; diff --git a/src/main/java/nextflow/config/v2/ConfigParserPlugin.java b/modules/compiler/src/main/java/config/parser/ConfigParserPlugin.java similarity index 98% rename from src/main/java/nextflow/config/v2/ConfigParserPlugin.java rename to modules/compiler/src/main/java/config/parser/ConfigParserPlugin.java index c7e8d35..5f9dd94 100644 --- a/src/main/java/nextflow/config/v2/ConfigParserPlugin.java +++ b/modules/compiler/src/main/java/config/parser/ConfigParserPlugin.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.parser; import org.codehaus.groovy.GroovyBugError; import org.codehaus.groovy.ast.ModuleNode; diff --git a/src/main/java/nextflow/config/v2/ConfigParserPluginFactory.java b/modules/compiler/src/main/java/config/parser/ConfigParserPluginFactory.java similarity index 96% rename from src/main/java/nextflow/config/v2/ConfigParserPluginFactory.java rename to modules/compiler/src/main/java/config/parser/ConfigParserPluginFactory.java index 754587a..836a683 100644 --- a/src/main/java/nextflow/config/v2/ConfigParserPluginFactory.java +++ b/modules/compiler/src/main/java/config/parser/ConfigParserPluginFactory.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.config.v2; +package nextflow.config.parser; import org.codehaus.groovy.control.ParserPlugin; import org.codehaus.groovy.control.ParserPluginFactory; diff --git a/src/main/java/nextflow/config/scopes/ApptainerConfig.java b/modules/compiler/src/main/java/config/scopes/ApptainerConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/ApptainerConfig.java rename to modules/compiler/src/main/java/config/scopes/ApptainerConfig.java diff --git a/src/main/java/nextflow/config/scopes/AwsBatchConfig.java b/modules/compiler/src/main/java/config/scopes/AwsBatchConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/AwsBatchConfig.java rename to modules/compiler/src/main/java/config/scopes/AwsBatchConfig.java diff --git a/src/main/java/nextflow/config/scopes/AwsClientConfig.java b/modules/compiler/src/main/java/config/scopes/AwsClientConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/AwsClientConfig.java rename to modules/compiler/src/main/java/config/scopes/AwsClientConfig.java diff --git a/src/main/java/nextflow/config/scopes/AwsConfig.java b/modules/compiler/src/main/java/config/scopes/AwsConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/AwsConfig.java rename to modules/compiler/src/main/java/config/scopes/AwsConfig.java diff --git a/src/main/java/nextflow/config/scopes/AzureActiveDirectoryConfig.java b/modules/compiler/src/main/java/config/scopes/AzureActiveDirectoryConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/AzureActiveDirectoryConfig.java rename to modules/compiler/src/main/java/config/scopes/AzureActiveDirectoryConfig.java diff --git a/src/main/java/nextflow/config/scopes/AzureBatchConfig.java b/modules/compiler/src/main/java/config/scopes/AzureBatchConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/AzureBatchConfig.java rename to modules/compiler/src/main/java/config/scopes/AzureBatchConfig.java diff --git a/src/main/java/nextflow/config/scopes/AzureConfig.java b/modules/compiler/src/main/java/config/scopes/AzureConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/AzureConfig.java rename to modules/compiler/src/main/java/config/scopes/AzureConfig.java diff --git a/src/main/java/nextflow/config/scopes/AzureManagedIdentityConfig.java b/modules/compiler/src/main/java/config/scopes/AzureManagedIdentityConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/AzureManagedIdentityConfig.java rename to modules/compiler/src/main/java/config/scopes/AzureManagedIdentityConfig.java diff --git a/src/main/java/nextflow/config/scopes/AzureRegistryConfig.java b/modules/compiler/src/main/java/config/scopes/AzureRegistryConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/AzureRegistryConfig.java rename to modules/compiler/src/main/java/config/scopes/AzureRegistryConfig.java diff --git a/src/main/java/nextflow/config/scopes/AzureRetryConfig.java b/modules/compiler/src/main/java/config/scopes/AzureRetryConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/AzureRetryConfig.java rename to modules/compiler/src/main/java/config/scopes/AzureRetryConfig.java diff --git a/src/main/java/nextflow/config/scopes/AzureStorageConfig.java b/modules/compiler/src/main/java/config/scopes/AzureStorageConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/AzureStorageConfig.java rename to modules/compiler/src/main/java/config/scopes/AzureStorageConfig.java diff --git a/src/main/java/nextflow/config/scopes/CharliecloudConfig.java b/modules/compiler/src/main/java/config/scopes/CharliecloudConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/CharliecloudConfig.java rename to modules/compiler/src/main/java/config/scopes/CharliecloudConfig.java diff --git a/src/main/java/nextflow/config/scopes/CondaConfig.java b/modules/compiler/src/main/java/config/scopes/CondaConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/CondaConfig.java rename to modules/compiler/src/main/java/config/scopes/CondaConfig.java diff --git a/src/main/java/nextflow/config/scopes/DagConfig.java b/modules/compiler/src/main/java/config/scopes/DagConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/DagConfig.java rename to modules/compiler/src/main/java/config/scopes/DagConfig.java diff --git a/src/main/java/nextflow/config/scopes/DockerConfig.java b/modules/compiler/src/main/java/config/scopes/DockerConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/DockerConfig.java rename to modules/compiler/src/main/java/config/scopes/DockerConfig.java diff --git a/src/main/java/nextflow/config/scopes/EnvConfig.java b/modules/compiler/src/main/java/config/scopes/EnvConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/EnvConfig.java rename to modules/compiler/src/main/java/config/scopes/EnvConfig.java diff --git a/src/main/java/nextflow/config/scopes/ExecutorConfig.java b/modules/compiler/src/main/java/config/scopes/ExecutorConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/ExecutorConfig.java rename to modules/compiler/src/main/java/config/scopes/ExecutorConfig.java diff --git a/src/main/java/nextflow/config/scopes/ExecutorRetryConfig.java b/modules/compiler/src/main/java/config/scopes/ExecutorRetryConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/ExecutorRetryConfig.java rename to modules/compiler/src/main/java/config/scopes/ExecutorRetryConfig.java diff --git a/src/main/java/nextflow/config/scopes/FusionConfig.java b/modules/compiler/src/main/java/config/scopes/FusionConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/FusionConfig.java rename to modules/compiler/src/main/java/config/scopes/FusionConfig.java diff --git a/src/main/java/nextflow/config/scopes/GoogleBatchConfig.java b/modules/compiler/src/main/java/config/scopes/GoogleBatchConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/GoogleBatchConfig.java rename to modules/compiler/src/main/java/config/scopes/GoogleBatchConfig.java diff --git a/src/main/java/nextflow/config/scopes/GoogleConfig.java b/modules/compiler/src/main/java/config/scopes/GoogleConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/GoogleConfig.java rename to modules/compiler/src/main/java/config/scopes/GoogleConfig.java diff --git a/src/main/java/nextflow/config/scopes/K8sConfig.java b/modules/compiler/src/main/java/config/scopes/K8sConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/K8sConfig.java rename to modules/compiler/src/main/java/config/scopes/K8sConfig.java diff --git a/src/main/java/nextflow/config/scopes/MailConfig.java b/modules/compiler/src/main/java/config/scopes/MailConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/MailConfig.java rename to modules/compiler/src/main/java/config/scopes/MailConfig.java diff --git a/src/main/java/nextflow/config/scopes/MailSmtpConfig.java b/modules/compiler/src/main/java/config/scopes/MailSmtpConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/MailSmtpConfig.java rename to modules/compiler/src/main/java/config/scopes/MailSmtpConfig.java diff --git a/src/main/java/nextflow/config/scopes/Manifest.java b/modules/compiler/src/main/java/config/scopes/Manifest.java similarity index 100% rename from src/main/java/nextflow/config/scopes/Manifest.java rename to modules/compiler/src/main/java/config/scopes/Manifest.java diff --git a/src/main/java/nextflow/config/scopes/ParamsConfig.java b/modules/compiler/src/main/java/config/scopes/ParamsConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/ParamsConfig.java rename to modules/compiler/src/main/java/config/scopes/ParamsConfig.java diff --git a/src/main/java/nextflow/config/scopes/PluginsConfig.java b/modules/compiler/src/main/java/config/scopes/PluginsConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/PluginsConfig.java rename to modules/compiler/src/main/java/config/scopes/PluginsConfig.java diff --git a/src/main/java/nextflow/config/scopes/PodmanConfig.java b/modules/compiler/src/main/java/config/scopes/PodmanConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/PodmanConfig.java rename to modules/compiler/src/main/java/config/scopes/PodmanConfig.java diff --git a/src/main/java/nextflow/config/scopes/ProcessConfig.java b/modules/compiler/src/main/java/config/scopes/ProcessConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/ProcessConfig.java rename to modules/compiler/src/main/java/config/scopes/ProcessConfig.java diff --git a/src/main/java/nextflow/config/scopes/ProfilesConfig.java b/modules/compiler/src/main/java/config/scopes/ProfilesConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/ProfilesConfig.java rename to modules/compiler/src/main/java/config/scopes/ProfilesConfig.java diff --git a/src/main/java/nextflow/config/scopes/ReportConfig.java b/modules/compiler/src/main/java/config/scopes/ReportConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/ReportConfig.java rename to modules/compiler/src/main/java/config/scopes/ReportConfig.java diff --git a/src/main/java/nextflow/config/scopes/ShifterConfig.java b/modules/compiler/src/main/java/config/scopes/ShifterConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/ShifterConfig.java rename to modules/compiler/src/main/java/config/scopes/ShifterConfig.java diff --git a/src/main/java/nextflow/config/scopes/SingularityConfig.java b/modules/compiler/src/main/java/config/scopes/SingularityConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/SingularityConfig.java rename to modules/compiler/src/main/java/config/scopes/SingularityConfig.java diff --git a/src/main/java/nextflow/config/scopes/SpackConfig.java b/modules/compiler/src/main/java/config/scopes/SpackConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/SpackConfig.java rename to modules/compiler/src/main/java/config/scopes/SpackConfig.java diff --git a/src/main/java/nextflow/config/scopes/TimelineConfig.java b/modules/compiler/src/main/java/config/scopes/TimelineConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/TimelineConfig.java rename to modules/compiler/src/main/java/config/scopes/TimelineConfig.java diff --git a/src/main/java/nextflow/config/scopes/TowerConfig.java b/modules/compiler/src/main/java/config/scopes/TowerConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/TowerConfig.java rename to modules/compiler/src/main/java/config/scopes/TowerConfig.java diff --git a/src/main/java/nextflow/config/scopes/TraceConfig.java b/modules/compiler/src/main/java/config/scopes/TraceConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/TraceConfig.java rename to modules/compiler/src/main/java/config/scopes/TraceConfig.java diff --git a/src/main/java/nextflow/config/scopes/UnscopedConfig.java b/modules/compiler/src/main/java/config/scopes/UnscopedConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/UnscopedConfig.java rename to modules/compiler/src/main/java/config/scopes/UnscopedConfig.java diff --git a/src/main/java/nextflow/config/scopes/WaveBuildConfig.java b/modules/compiler/src/main/java/config/scopes/WaveBuildConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/WaveBuildConfig.java rename to modules/compiler/src/main/java/config/scopes/WaveBuildConfig.java diff --git a/src/main/java/nextflow/config/scopes/WaveCondaConfig.java b/modules/compiler/src/main/java/config/scopes/WaveCondaConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/WaveCondaConfig.java rename to modules/compiler/src/main/java/config/scopes/WaveCondaConfig.java diff --git a/src/main/java/nextflow/config/scopes/WaveConfig.java b/modules/compiler/src/main/java/config/scopes/WaveConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/WaveConfig.java rename to modules/compiler/src/main/java/config/scopes/WaveConfig.java diff --git a/src/main/java/nextflow/config/scopes/WaveHttpConfig.java b/modules/compiler/src/main/java/config/scopes/WaveHttpConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/WaveHttpConfig.java rename to modules/compiler/src/main/java/config/scopes/WaveHttpConfig.java diff --git a/src/main/java/nextflow/config/scopes/WaveRetryConfig.java b/modules/compiler/src/main/java/config/scopes/WaveRetryConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/WaveRetryConfig.java rename to modules/compiler/src/main/java/config/scopes/WaveRetryConfig.java diff --git a/src/main/java/nextflow/config/scopes/WaveScanConfig.java b/modules/compiler/src/main/java/config/scopes/WaveScanConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/WaveScanConfig.java rename to modules/compiler/src/main/java/config/scopes/WaveScanConfig.java diff --git a/src/main/java/nextflow/config/scopes/WaveSpackConfig.java b/modules/compiler/src/main/java/config/scopes/WaveSpackConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/WaveSpackConfig.java rename to modules/compiler/src/main/java/config/scopes/WaveSpackConfig.java diff --git a/src/main/java/nextflow/config/scopes/WorkflowConfig.java b/modules/compiler/src/main/java/config/scopes/WorkflowConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/WorkflowConfig.java rename to modules/compiler/src/main/java/config/scopes/WorkflowConfig.java diff --git a/src/main/java/nextflow/config/scopes/WorkflowOutputConfig.java b/modules/compiler/src/main/java/config/scopes/WorkflowOutputConfig.java similarity index 100% rename from src/main/java/nextflow/config/scopes/WorkflowOutputConfig.java rename to modules/compiler/src/main/java/config/scopes/WorkflowOutputConfig.java diff --git a/src/main/java/nextflow/script/v2/ASTHelpers.java b/modules/compiler/src/main/java/script/ast/ASTHelpers.java similarity index 99% rename from src/main/java/nextflow/script/v2/ASTHelpers.java rename to modules/compiler/src/main/java/script/ast/ASTHelpers.java index f4684d5..d8191fc 100644 --- a/src/main/java/nextflow/script/v2/ASTHelpers.java +++ b/modules/compiler/src/main/java/script/ast/ASTHelpers.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import java.util.Collections; import java.util.List; diff --git a/src/main/java/nextflow/script/v2/AssignmentExpression.java b/modules/compiler/src/main/java/script/ast/AssignmentExpression.java similarity index 97% rename from src/main/java/nextflow/script/v2/AssignmentExpression.java rename to modules/compiler/src/main/java/script/ast/AssignmentExpression.java index cce26e9..4776b43 100644 --- a/src/main/java/nextflow/script/v2/AssignmentExpression.java +++ b/modules/compiler/src/main/java/script/ast/AssignmentExpression.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.expr.BinaryExpression; import org.codehaus.groovy.ast.expr.Expression; diff --git a/src/main/java/nextflow/script/v2/FeatureFlagNode.java b/modules/compiler/src/main/java/script/ast/FeatureFlagNode.java similarity index 97% rename from src/main/java/nextflow/script/v2/FeatureFlagNode.java rename to modules/compiler/src/main/java/script/ast/FeatureFlagNode.java index 3aae164..12beeaf 100644 --- a/src/main/java/nextflow/script/v2/FeatureFlagNode.java +++ b/modules/compiler/src/main/java/script/ast/FeatureFlagNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.Variable; diff --git a/src/main/java/nextflow/script/v2/FunctionNode.java b/modules/compiler/src/main/java/script/ast/FunctionNode.java similarity index 97% rename from src/main/java/nextflow/script/v2/FunctionNode.java rename to modules/compiler/src/main/java/script/ast/FunctionNode.java index 0fda97e..9d66231 100644 --- a/src/main/java/nextflow/script/v2/FunctionNode.java +++ b/modules/compiler/src/main/java/script/ast/FunctionNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.MethodNode; diff --git a/src/main/java/nextflow/script/v2/IncludeNode.java b/modules/compiler/src/main/java/script/ast/IncludeNode.java similarity index 97% rename from src/main/java/nextflow/script/v2/IncludeNode.java rename to modules/compiler/src/main/java/script/ast/IncludeNode.java index 24e4186..6ab6aa5 100644 --- a/src/main/java/nextflow/script/v2/IncludeNode.java +++ b/modules/compiler/src/main/java/script/ast/IncludeNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import java.util.List; diff --git a/src/main/java/nextflow/script/v2/IncludeVariable.java b/modules/compiler/src/main/java/script/ast/IncludeVariable.java similarity index 98% rename from src/main/java/nextflow/script/v2/IncludeVariable.java rename to modules/compiler/src/main/java/script/ast/IncludeVariable.java index 6a744db..2377b8c 100644 --- a/src/main/java/nextflow/script/v2/IncludeVariable.java +++ b/modules/compiler/src/main/java/script/ast/IncludeVariable.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassHelper; diff --git a/src/main/java/nextflow/script/v2/IncompleteNode.java b/modules/compiler/src/main/java/script/ast/IncompleteNode.java similarity index 97% rename from src/main/java/nextflow/script/v2/IncompleteNode.java rename to modules/compiler/src/main/java/script/ast/IncompleteNode.java index 0dfc57b..27843a1 100644 --- a/src/main/java/nextflow/script/v2/IncompleteNode.java +++ b/modules/compiler/src/main/java/script/ast/IncompleteNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.expr.EmptyExpression; import org.codehaus.groovy.ast.expr.Expression; diff --git a/src/main/java/nextflow/script/v2/InvalidDeclaration.java b/modules/compiler/src/main/java/script/ast/InvalidDeclaration.java similarity index 96% rename from src/main/java/nextflow/script/v2/InvalidDeclaration.java rename to modules/compiler/src/main/java/script/ast/InvalidDeclaration.java index 1c204ca..e1f1c4a 100644 --- a/src/main/java/nextflow/script/v2/InvalidDeclaration.java +++ b/modules/compiler/src/main/java/script/ast/InvalidDeclaration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.stmt.EmptyStatement; diff --git a/src/main/java/nextflow/script/v2/OutputNode.java b/modules/compiler/src/main/java/script/ast/OutputNode.java similarity index 96% rename from src/main/java/nextflow/script/v2/OutputNode.java rename to modules/compiler/src/main/java/script/ast/OutputNode.java index 085e5cb..9d3b5b2 100644 --- a/src/main/java/nextflow/script/v2/OutputNode.java +++ b/modules/compiler/src/main/java/script/ast/OutputNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.stmt.Statement; diff --git a/src/main/java/nextflow/script/v2/ParamNode.java b/modules/compiler/src/main/java/script/ast/ParamNode.java similarity index 97% rename from src/main/java/nextflow/script/v2/ParamNode.java rename to modules/compiler/src/main/java/script/ast/ParamNode.java index f5b913f..852de0c 100644 --- a/src/main/java/nextflow/script/v2/ParamNode.java +++ b/modules/compiler/src/main/java/script/ast/ParamNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.expr.Expression; diff --git a/src/main/java/nextflow/script/v2/ProcessNode.java b/modules/compiler/src/main/java/script/ast/ProcessNode.java similarity index 98% rename from src/main/java/nextflow/script/v2/ProcessNode.java rename to modules/compiler/src/main/java/script/ast/ProcessNode.java index f023434..d73cf1f 100644 --- a/src/main/java/nextflow/script/v2/ProcessNode.java +++ b/modules/compiler/src/main/java/script/ast/ProcessNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.MethodNode; diff --git a/src/main/java/nextflow/script/v2/ScriptExpressionTransformer.java b/modules/compiler/src/main/java/script/ast/ScriptExpressionTransformer.java similarity index 99% rename from src/main/java/nextflow/script/v2/ScriptExpressionTransformer.java rename to modules/compiler/src/main/java/script/ast/ScriptExpressionTransformer.java index d235306..7bf1746 100644 --- a/src/main/java/nextflow/script/v2/ScriptExpressionTransformer.java +++ b/modules/compiler/src/main/java/script/ast/ScriptExpressionTransformer.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.expr.BooleanExpression; import org.codehaus.groovy.ast.expr.Expression; diff --git a/src/main/java/nextflow/script/v2/ScriptNode.java b/modules/compiler/src/main/java/script/ast/ScriptNode.java similarity index 99% rename from src/main/java/nextflow/script/v2/ScriptNode.java rename to modules/compiler/src/main/java/script/ast/ScriptNode.java index 120320b..d2fc4b2 100644 --- a/src/main/java/nextflow/script/v2/ScriptNode.java +++ b/modules/compiler/src/main/java/script/ast/ScriptNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/nextflow/script/v2/ScriptVisitor.java b/modules/compiler/src/main/java/script/ast/ScriptVisitor.java similarity index 97% rename from src/main/java/nextflow/script/v2/ScriptVisitor.java rename to modules/compiler/src/main/java/script/ast/ScriptVisitor.java index 14c9cd6..adf82f9 100644 --- a/src/main/java/nextflow/script/v2/ScriptVisitor.java +++ b/modules/compiler/src/main/java/script/ast/ScriptVisitor.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.GroovyCodeVisitor; diff --git a/src/main/java/nextflow/script/v2/ScriptVisitorSupport.java b/modules/compiler/src/main/java/script/ast/ScriptVisitorSupport.java similarity index 99% rename from src/main/java/nextflow/script/v2/ScriptVisitorSupport.java rename to modules/compiler/src/main/java/script/ast/ScriptVisitorSupport.java index 1284ae4..42e043f 100644 --- a/src/main/java/nextflow/script/v2/ScriptVisitorSupport.java +++ b/modules/compiler/src/main/java/script/ast/ScriptVisitorSupport.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.ClassCodeVisitorSupport; import org.codehaus.groovy.ast.ClassNode; diff --git a/src/main/java/nextflow/script/v2/WorkflowNode.java b/modules/compiler/src/main/java/script/ast/WorkflowNode.java similarity index 98% rename from src/main/java/nextflow/script/v2/WorkflowNode.java rename to modules/compiler/src/main/java/script/ast/WorkflowNode.java index 27341af..90a12b4 100644 --- a/src/main/java/nextflow/script/v2/WorkflowNode.java +++ b/modules/compiler/src/main/java/script/ast/WorkflowNode.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.ast; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.MethodNode; diff --git a/src/main/java/nextflow/lsp/compiler/FutureWarning.java b/modules/compiler/src/main/java/script/control/FutureWarning.java similarity index 97% rename from src/main/java/nextflow/lsp/compiler/FutureWarning.java rename to modules/compiler/src/main/java/script/control/FutureWarning.java index 0b10420..57122c3 100644 --- a/src/main/java/nextflow/lsp/compiler/FutureWarning.java +++ b/modules/compiler/src/main/java/script/control/FutureWarning.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.lsp.compiler; +package nextflow.script.control; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.control.SourceUnit; diff --git a/src/main/java/nextflow/lsp/compiler/PhaseAware.java b/modules/compiler/src/main/java/script/control/PhaseAware.java similarity index 95% rename from src/main/java/nextflow/lsp/compiler/PhaseAware.java rename to modules/compiler/src/main/java/script/control/PhaseAware.java index 06b470f..3bc07ba 100644 --- a/src/main/java/nextflow/lsp/compiler/PhaseAware.java +++ b/modules/compiler/src/main/java/script/control/PhaseAware.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.lsp.compiler; +package nextflow.script.control; /** * diff --git a/src/main/java/nextflow/lsp/compiler/Phases.java b/modules/compiler/src/main/java/script/control/Phases.java similarity index 96% rename from src/main/java/nextflow/lsp/compiler/Phases.java rename to modules/compiler/src/main/java/script/control/Phases.java index 32cccf2..5d8c2cb 100644 --- a/src/main/java/nextflow/lsp/compiler/Phases.java +++ b/modules/compiler/src/main/java/script/control/Phases.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.lsp.compiler; +package nextflow.script.control; /** * diff --git a/src/main/java/nextflow/lsp/compiler/RelatedInformationAware.java b/modules/compiler/src/main/java/script/control/RelatedInformationAware.java similarity index 96% rename from src/main/java/nextflow/lsp/compiler/RelatedInformationAware.java rename to modules/compiler/src/main/java/script/control/RelatedInformationAware.java index 32618d7..cc4727b 100644 --- a/src/main/java/nextflow/lsp/compiler/RelatedInformationAware.java +++ b/modules/compiler/src/main/java/script/control/RelatedInformationAware.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.lsp.compiler; +package nextflow.script.control; import org.codehaus.groovy.ast.ASTNode; diff --git a/src/main/java/nextflow/lsp/services/script/ResolveVisitor.java b/modules/compiler/src/main/java/script/control/ResolveVisitor.java similarity index 98% rename from src/main/java/nextflow/lsp/services/script/ResolveVisitor.java rename to modules/compiler/src/main/java/script/control/ResolveVisitor.java index 174db51..1ac6747 100644 --- a/src/main/java/nextflow/lsp/services/script/ResolveVisitor.java +++ b/modules/compiler/src/main/java/script/control/ResolveVisitor.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.lsp.services.script; +package nextflow.script.control; import java.util.HashSet; import java.util.List; @@ -21,14 +21,12 @@ import java.util.Set; import groovy.lang.Tuple2; -import nextflow.lsp.compiler.PhaseAware; -import nextflow.lsp.compiler.Phases; +import nextflow.script.ast.AssignmentExpression; +import nextflow.script.ast.FunctionNode; +import nextflow.script.ast.ScriptExpressionTransformer; +import nextflow.script.ast.ScriptNode; +import nextflow.script.ast.ScriptVisitorSupport; import nextflow.script.types.Types; -import nextflow.script.v2.AssignmentExpression; -import nextflow.script.v2.FunctionNode; -import nextflow.script.v2.ScriptExpressionTransformer; -import nextflow.script.v2.ScriptNode; -import nextflow.script.v2.ScriptVisitorSupport; import org.codehaus.groovy.GroovyBugError; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassHelper; diff --git a/src/main/java/nextflow/lsp/services/script/VariableScopeVisitor.java b/modules/compiler/src/main/java/script/control/VariableScopeVisitor.java similarity index 84% rename from src/main/java/nextflow/lsp/services/script/VariableScopeVisitor.java rename to modules/compiler/src/main/java/script/control/VariableScopeVisitor.java index 4e817fd..3cd579a 100644 --- a/src/main/java/nextflow/lsp/services/script/VariableScopeVisitor.java +++ b/modules/compiler/src/main/java/script/control/VariableScopeVisitor.java @@ -13,27 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.lsp.services.script; +package nextflow.script.control; -import java.io.IOException; -import java.lang.reflect.Modifier; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.Collections; import java.util.HashMap; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import groovy.json.JsonSlurper; -import nextflow.lsp.compiler.FutureWarning; -import nextflow.lsp.compiler.PhaseAware; -import nextflow.lsp.compiler.Phases; -import nextflow.lsp.compiler.RelatedInformationAware; + +import nextflow.script.ast.AssignmentExpression; +import nextflow.script.ast.FeatureFlagNode; +import nextflow.script.ast.FunctionNode; +import nextflow.script.ast.IncludeNode; +import nextflow.script.ast.OutputNode; +import nextflow.script.ast.ProcessNode; +import nextflow.script.ast.ScriptNode; +import nextflow.script.ast.ScriptVisitorSupport; +import nextflow.script.ast.WorkflowNode; import nextflow.script.dsl.Constant; import nextflow.script.dsl.Description; import nextflow.script.dsl.EntryWorkflowDsl; @@ -43,18 +40,7 @@ import nextflow.script.dsl.ProcessDsl; import nextflow.script.dsl.ScriptDsl; import nextflow.script.dsl.WorkflowDsl; -import nextflow.script.types.ParamsMap; -import nextflow.script.v2.AssignmentExpression; -import nextflow.script.v2.FeatureFlagNode; -import nextflow.script.v2.FunctionNode; -import nextflow.script.v2.IncludeNode; -import nextflow.script.v2.OutputNode; -import nextflow.script.v2.ProcessNode; -import nextflow.script.v2.ScriptNode; -import nextflow.script.v2.ScriptVisitorSupport; -import nextflow.script.v2.WorkflowNode; import org.codehaus.groovy.ast.ASTNode; -import org.codehaus.groovy.ast.AnnotationNode; import org.codehaus.groovy.ast.ClassHelper; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.DynamicVariable; @@ -83,12 +69,11 @@ import org.codehaus.groovy.control.messages.SyntaxErrorMessage; import org.codehaus.groovy.control.messages.WarningMessage; import org.codehaus.groovy.runtime.DefaultGroovyMethods; -import org.codehaus.groovy.runtime.IOGroovyMethods; import org.codehaus.groovy.syntax.SyntaxException; import org.codehaus.groovy.syntax.Token; import org.codehaus.groovy.syntax.Types; -import static nextflow.script.v2.ASTHelpers.*; +import static nextflow.script.ast.ASTHelpers.*; /** * Initialize the variable scopes for an AST. @@ -107,8 +92,6 @@ public class VariableScopeVisitor extends ScriptVisitorSupport { private VariableScope currentScope; - private ClassNode paramsType; - private Set declaredVariables = Collections.newSetFromMap(new IdentityHashMap<>()); public VariableScopeVisitor(SourceUnit sourceUnit) { @@ -211,16 +194,6 @@ public void visitFeatureFlag(FeatureFlagNode node) { @Override public void visitWorkflow(WorkflowNode node) { - if( node.isEntry() ) { - try { - declareParameters(); - } - catch( Exception e ) { - System.err.println("Failed to parse parameter schema (nextflow_schema.json): " + e.toString()); - addError("Failed to parse parameter schema -- check nextflow_schema.json for possible errors", node); - } - } - pushState(node.isEntry() ? EntryWorkflowDsl.class : WorkflowDsl.class); currentDefinition = node; node.setVariableScope(currentScope); @@ -236,92 +209,6 @@ public void visitWorkflow(WorkflowNode node) { currentDefinition = null; popState(); - - if( node.isEntry() ) - this.paramsType = null; - } - - private void declareParameters() { - // load parameter schema - var uri = sourceUnit.getSource().getURI(); - var schemaPath = Path.of(uri).getParent().resolve("nextflow_schema.json"); - if( !Files.exists(schemaPath) ) - return; - var schemaJson = getParameterSchema(schemaPath); - - var defs = Optional.ofNullable(schemaJson) - .flatMap(json -> asMap(json)) - .flatMap(json -> - json.containsKey("$defs") - ? asMap(json.get("$defs")) : - json.containsKey("defs") - ? asMap(json.get("defs")) : - json.containsKey("definitions") - ? asMap(json.get("definitions")) - : Optional.empty() - ) - .orElse(Collections.emptyMap()); - - var entries = (List) defs.values().stream() - .filter(defn -> defn instanceof Map) - .map(defn -> ((Map) defn).get("properties")) - .filter(props -> props instanceof Map) - .flatMap(props -> ((Map) props).entrySet().stream()) - .collect(Collectors.toList()); - - if( entries.isEmpty() ) - return; - - // create synthetic params type - var cn = new ClassNode(ParamsMap.class); - - for( var entry : entries ) { - var name = (String) entry.getKey(); - var attrs = asMap(entry.getValue()).orElse(null); - if( attrs == null ) - continue; - var type = getTypeClassFromString((String) attrs.get("type")); - var description = (String) attrs.get("description"); - var fn = new FieldNode(name, Modifier.PUBLIC, type, cn, null); - fn.setHasNoRealSourcePosition(true); - fn.setDeclaringClass(cn); - fn.setSynthetic(true); - var an = new AnnotationNode(ClassHelper.makeCached(Description.class)); - an.addMember("value", new ConstantExpression(description)); - fn.addAnnotation(an); - cn.addField(fn); - } - - this.paramsType = cn; - } - - private Object getParameterSchema(Path schemaPath) { - try { - var schemaText = IOGroovyMethods.getText(Files.newInputStream(schemaPath)); - return new JsonSlurper().parseText(schemaText); - } - catch( IOException e ) { - System.err.println("Failed to read parameter schema: " + e.toString()); - return null; - } - } - - private static Optional asMap(Object value) { - return value instanceof Map - ? Optional.of((Map) value) - : Optional.empty(); - } - - private ClassNode getTypeClassFromString(String type) { - if( "boolean".equals(type) ) - return ClassHelper.boolean_TYPE; - if( "integer".equals(type) ) - return ClassHelper.long_TYPE; - if( "number".equals(type) ) - return ClassHelper.double_TYPE; - if( "string".equals(type) ) - return ClassHelper.STRING_TYPE; - return ClassHelper.dynamicType(); } private void declareWorkflowInputs(Statement takes) { @@ -551,7 +438,7 @@ public void visitCatchStatement(CatchStatement node) { popState(); } - // statements + // expressions private static final List KEYWORDS = List.of( "case", @@ -726,31 +613,6 @@ public void visitClosureExpression(ClosureExpression node) { currentClosure = cl; } - @Override - public void visitPropertyExpression(PropertyExpression node) { - super.visitPropertyExpression(node); - - // validate parameter against schema if applicable - // NOTE: should be incorporated into type-checking visitor - if( paramsType == null ) - return; - if( !(node.getObjectExpression() instanceof VariableExpression) ) - return; - var varX = (VariableExpression) node.getObjectExpression(); - if( !"params".equals(varX.getName()) ) - return; - var property = node.getPropertyAsString(); - if( paramsType.getDeclaredField(property) == null ) { - addError("Unrecognized parameter `" + property + "`", node); - return; - } - var variable = varX.getAccessedVariable(); - if( variable instanceof PropertyNode pn ) { - var mn = (MethodNode) pn.getNodeMetaData("access.method"); - mn.setReturnType(paramsType); - } - } - @Override public void visitVariableExpression(VariableExpression node) { var name = node.getName(); diff --git a/src/main/java/nextflow/script/dsl/Constant.java b/modules/compiler/src/main/java/script/dsl/Constant.java similarity index 100% rename from src/main/java/nextflow/script/dsl/Constant.java rename to modules/compiler/src/main/java/script/dsl/Constant.java diff --git a/src/main/java/nextflow/script/dsl/Description.java b/modules/compiler/src/main/java/script/dsl/Description.java similarity index 100% rename from src/main/java/nextflow/script/dsl/Description.java rename to modules/compiler/src/main/java/script/dsl/Description.java diff --git a/src/main/java/nextflow/script/dsl/DslScope.java b/modules/compiler/src/main/java/script/dsl/DslScope.java similarity index 100% rename from src/main/java/nextflow/script/dsl/DslScope.java rename to modules/compiler/src/main/java/script/dsl/DslScope.java diff --git a/src/main/java/nextflow/script/dsl/EntryWorkflowDsl.java b/modules/compiler/src/main/java/script/dsl/EntryWorkflowDsl.java similarity index 100% rename from src/main/java/nextflow/script/dsl/EntryWorkflowDsl.java rename to modules/compiler/src/main/java/script/dsl/EntryWorkflowDsl.java diff --git a/src/main/java/nextflow/script/dsl/FeatureFlag.java b/modules/compiler/src/main/java/script/dsl/FeatureFlag.java similarity index 100% rename from src/main/java/nextflow/script/dsl/FeatureFlag.java rename to modules/compiler/src/main/java/script/dsl/FeatureFlag.java diff --git a/src/main/java/nextflow/script/dsl/FeatureFlagDsl.java b/modules/compiler/src/main/java/script/dsl/FeatureFlagDsl.java similarity index 100% rename from src/main/java/nextflow/script/dsl/FeatureFlagDsl.java rename to modules/compiler/src/main/java/script/dsl/FeatureFlagDsl.java diff --git a/src/main/java/nextflow/script/dsl/Operator.java b/modules/compiler/src/main/java/script/dsl/Operator.java similarity index 100% rename from src/main/java/nextflow/script/dsl/Operator.java rename to modules/compiler/src/main/java/script/dsl/Operator.java diff --git a/src/main/java/nextflow/script/dsl/OutputDsl.java b/modules/compiler/src/main/java/script/dsl/OutputDsl.java similarity index 100% rename from src/main/java/nextflow/script/dsl/OutputDsl.java rename to modules/compiler/src/main/java/script/dsl/OutputDsl.java diff --git a/src/main/java/nextflow/script/dsl/ProcessDsl.java b/modules/compiler/src/main/java/script/dsl/ProcessDsl.java similarity index 100% rename from src/main/java/nextflow/script/dsl/ProcessDsl.java rename to modules/compiler/src/main/java/script/dsl/ProcessDsl.java diff --git a/src/main/java/nextflow/script/dsl/ScriptDsl.java b/modules/compiler/src/main/java/script/dsl/ScriptDsl.java similarity index 100% rename from src/main/java/nextflow/script/dsl/ScriptDsl.java rename to modules/compiler/src/main/java/script/dsl/ScriptDsl.java diff --git a/src/main/java/nextflow/script/dsl/WorkflowDsl.java b/modules/compiler/src/main/java/script/dsl/WorkflowDsl.java similarity index 100% rename from src/main/java/nextflow/script/dsl/WorkflowDsl.java rename to modules/compiler/src/main/java/script/dsl/WorkflowDsl.java diff --git a/src/main/java/nextflow/antlr/AbstractLexer.java b/modules/compiler/src/main/java/script/parser/AbstractLexer.java similarity index 97% rename from src/main/java/nextflow/antlr/AbstractLexer.java rename to modules/compiler/src/main/java/script/parser/AbstractLexer.java index 0dabb7d..00e8cae 100644 --- a/src/main/java/nextflow/antlr/AbstractLexer.java +++ b/modules/compiler/src/main/java/script/parser/AbstractLexer.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package nextflow.antlr; +package nextflow.script.parser; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.Lexer; diff --git a/src/main/java/nextflow/antlr/AbstractParser.java b/modules/compiler/src/main/java/script/parser/AbstractParser.java similarity index 97% rename from src/main/java/nextflow/antlr/AbstractParser.java rename to modules/compiler/src/main/java/script/parser/AbstractParser.java index 5a36e6f..9b8392e 100644 --- a/src/main/java/nextflow/antlr/AbstractParser.java +++ b/modules/compiler/src/main/java/script/parser/AbstractParser.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package nextflow.antlr; +package nextflow.script.parser; import org.antlr.v4.runtime.Parser; import org.antlr.v4.runtime.TokenStream; diff --git a/src/main/java/nextflow/antlr/DescriptiveErrorStrategy.java b/modules/compiler/src/main/java/script/parser/DescriptiveErrorStrategy.java similarity index 99% rename from src/main/java/nextflow/antlr/DescriptiveErrorStrategy.java rename to modules/compiler/src/main/java/script/parser/DescriptiveErrorStrategy.java index e49b0c5..b190f33 100644 --- a/src/main/java/nextflow/antlr/DescriptiveErrorStrategy.java +++ b/modules/compiler/src/main/java/script/parser/DescriptiveErrorStrategy.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package nextflow.antlr; +package nextflow.script.parser; import org.antlr.v4.runtime.BailErrorStrategy; import org.antlr.v4.runtime.CharStream; diff --git a/src/main/java/nextflow/script/v2/GroovydocManager.java b/modules/compiler/src/main/java/script/parser/GroovydocManager.java similarity index 98% rename from src/main/java/nextflow/script/v2/GroovydocManager.java rename to modules/compiler/src/main/java/script/parser/GroovydocManager.java index e37a2f5..a360de9 100644 --- a/src/main/java/nextflow/script/v2/GroovydocManager.java +++ b/modules/compiler/src/main/java/script/parser/GroovydocManager.java @@ -16,11 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package nextflow.script.v2; +package nextflow.script.parser; import groovy.lang.groovydoc.Groovydoc; import groovy.lang.groovydoc.GroovydocHolder; -import nextflow.antlr.ScriptParser; import org.antlr.v4.runtime.ParserRuleContext; import org.codehaus.groovy.GroovyBugError; import org.codehaus.groovy.ast.ASTNode; diff --git a/src/main/java/nextflow/antlr/PositionConfigureUtils.java b/modules/compiler/src/main/java/script/parser/PositionConfigureUtils.java similarity index 99% rename from src/main/java/nextflow/antlr/PositionConfigureUtils.java rename to modules/compiler/src/main/java/script/parser/PositionConfigureUtils.java index e10005e..2a456ce 100644 --- a/src/main/java/nextflow/antlr/PositionConfigureUtils.java +++ b/modules/compiler/src/main/java/script/parser/PositionConfigureUtils.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package nextflow.antlr; +package nextflow.script.parser; import groovy.lang.Tuple2; import org.antlr.v4.runtime.ParserRuleContext; diff --git a/src/main/java/nextflow/script/v2/ScriptAstBuilder.java b/modules/compiler/src/main/java/script/parser/ScriptAstBuilder.java similarity index 99% rename from src/main/java/nextflow/script/v2/ScriptAstBuilder.java rename to modules/compiler/src/main/java/script/parser/ScriptAstBuilder.java index d02c4cc..23b1f6d 100644 --- a/src/main/java/nextflow/script/v2/ScriptAstBuilder.java +++ b/modules/compiler/src/main/java/script/parser/ScriptAstBuilder.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.parser; import java.io.BufferedReader; import java.io.IOException; @@ -28,9 +28,18 @@ import com.google.common.hash.Hashing; import groovy.lang.Tuple2; -import nextflow.antlr.ScriptLexer; -import nextflow.antlr.ScriptParser; -import nextflow.antlr.DescriptiveErrorStrategy; +import nextflow.script.ast.AssignmentExpression; +import nextflow.script.ast.FeatureFlagNode; +import nextflow.script.ast.FunctionNode; +import nextflow.script.ast.IncludeNode; +import nextflow.script.ast.IncludeVariable; +import nextflow.script.ast.IncompleteNode; +import nextflow.script.ast.InvalidDeclaration; +import nextflow.script.ast.OutputNode; +import nextflow.script.ast.ParamNode; +import nextflow.script.ast.ProcessNode; +import nextflow.script.ast.ScriptNode; +import nextflow.script.ast.WorkflowNode; import org.antlr.v4.runtime.ANTLRErrorListener; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; @@ -91,9 +100,9 @@ import org.codehaus.groovy.syntax.SyntaxException; import org.codehaus.groovy.syntax.Types; -import static nextflow.antlr.ScriptParser.*; -import static nextflow.antlr.PositionConfigureUtils.ast; -import static nextflow.script.v2.ASTHelpers.*; +import static nextflow.script.parser.PositionConfigureUtils.ast; +import static nextflow.script.parser.ScriptParser.*; +import static nextflow.script.ast.ASTHelpers.*; import static org.codehaus.groovy.ast.expr.VariableExpression.THIS_EXPRESSION; import static org.codehaus.groovy.ast.tools.GeneralUtils.*; diff --git a/src/main/java/nextflow/script/v2/ScriptParserPlugin.java b/modules/compiler/src/main/java/script/parser/ScriptParserPlugin.java similarity index 98% rename from src/main/java/nextflow/script/v2/ScriptParserPlugin.java rename to modules/compiler/src/main/java/script/parser/ScriptParserPlugin.java index 3ec3ed8..3ab4b9c 100644 --- a/src/main/java/nextflow/script/v2/ScriptParserPlugin.java +++ b/modules/compiler/src/main/java/script/parser/ScriptParserPlugin.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.parser; import org.codehaus.groovy.GroovyBugError; import org.codehaus.groovy.ast.ModuleNode; diff --git a/src/main/java/nextflow/script/v2/ScriptParserPluginFactory.java b/modules/compiler/src/main/java/script/parser/ScriptParserPluginFactory.java similarity index 96% rename from src/main/java/nextflow/script/v2/ScriptParserPluginFactory.java rename to modules/compiler/src/main/java/script/parser/ScriptParserPluginFactory.java index 437e31c..1a7c9c1 100644 --- a/src/main/java/nextflow/script/v2/ScriptParserPluginFactory.java +++ b/modules/compiler/src/main/java/script/parser/ScriptParserPluginFactory.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nextflow.script.v2; +package nextflow.script.parser; import org.codehaus.groovy.control.ParserPlugin; import org.codehaus.groovy.control.ParserPluginFactory; diff --git a/src/main/java/nextflow/antlr/SemanticPredicates.java b/modules/compiler/src/main/java/script/parser/SemanticPredicates.java similarity index 81% rename from src/main/java/nextflow/antlr/SemanticPredicates.java rename to modules/compiler/src/main/java/script/parser/SemanticPredicates.java index a8e8170..a317a10 100644 --- a/src/main/java/nextflow/antlr/SemanticPredicates.java +++ b/modules/compiler/src/main/java/script/parser/SemanticPredicates.java @@ -16,13 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package nextflow.antlr; +package nextflow.script.parser; import java.util.regex.Pattern; import org.antlr.v4.runtime.CharStream; import org.codehaus.groovy.GroovyBugError; +import static nextflow.script.parser.ScriptParser.*; import static org.apache.groovy.parser.antlr4.util.StringUtils.matches; /** @@ -94,14 +95,14 @@ && matches(str2, SURROGATE_PAIR2_PATTERN) * * @param context */ - public static boolean isValidDirective(nextflow.antlr.ConfigParser.ExpressionContext context) { - if (!(context instanceof nextflow.antlr.ConfigParser.PathExprAltContext)) + public static boolean isValidDirective(nextflow.config.parser.ConfigParser.ExpressionContext context) { + if (!(context instanceof nextflow.config.parser.ConfigParser.PathExprAltContext)) return false; try { - var peac = (nextflow.antlr.ConfigParser.PathExprAltContext) context; + var peac = (nextflow.config.parser.ConfigParser.PathExprAltContext) context; var last = peac.getChild(peac.getChildCount() - 1); - return last instanceof nextflow.antlr.ConfigParser.IdentifierPrmrAltContext || last instanceof nextflow.antlr.ConfigParser.PropertyPathExprAltContext; + return last instanceof nextflow.config.parser.ConfigParser.IdentifierPrmrAltContext || last instanceof nextflow.config.parser.ConfigParser.PropertyPathExprAltContext; } catch (IndexOutOfBoundsException | ClassCastException e) { throw new GroovyBugError("Unexpected structure of expression context: " + context, e); } @@ -113,14 +114,14 @@ public static boolean isValidDirective(nextflow.antlr.ConfigParser.ExpressionCon * * @param context */ - public static boolean isValidDirective(nextflow.antlr.ScriptParser.ExpressionContext context) { - if (!(context instanceof nextflow.antlr.ScriptParser.PathExprAltContext)) + public static boolean isValidDirective(ExpressionContext context) { + if (!(context instanceof PathExprAltContext)) return false; try { - var peac = (nextflow.antlr.ScriptParser.PathExprAltContext) context; + var peac = (PathExprAltContext) context; var last = peac.getChild(peac.getChildCount() - 1); - return last instanceof nextflow.antlr.ScriptParser.IdentifierPrmrAltContext || last instanceof nextflow.antlr.ScriptParser.PropertyPathExprAltContext; + return last instanceof IdentifierPrmrAltContext || last instanceof PropertyPathExprAltContext; } catch (IndexOutOfBoundsException | ClassCastException e) { throw new GroovyBugError("Unexpected structure of expression context: " + context, e); } diff --git a/src/main/java/nextflow/script/types/Channel.java b/modules/compiler/src/main/java/script/types/Channel.java similarity index 100% rename from src/main/java/nextflow/script/types/Channel.java rename to modules/compiler/src/main/java/script/types/Channel.java diff --git a/src/main/java/nextflow/script/types/ChannelFactory.java b/modules/compiler/src/main/java/script/types/ChannelFactory.java similarity index 100% rename from src/main/java/nextflow/script/types/ChannelFactory.java rename to modules/compiler/src/main/java/script/types/ChannelFactory.java diff --git a/src/main/java/nextflow/script/types/Duration.java b/modules/compiler/src/main/java/script/types/Duration.java similarity index 100% rename from src/main/java/nextflow/script/types/Duration.java rename to modules/compiler/src/main/java/script/types/Duration.java diff --git a/src/main/java/nextflow/script/types/Manifest.java b/modules/compiler/src/main/java/script/types/Manifest.java similarity index 100% rename from src/main/java/nextflow/script/types/Manifest.java rename to modules/compiler/src/main/java/script/types/Manifest.java diff --git a/src/main/java/nextflow/script/types/MemoryUnit.java b/modules/compiler/src/main/java/script/types/MemoryUnit.java similarity index 100% rename from src/main/java/nextflow/script/types/MemoryUnit.java rename to modules/compiler/src/main/java/script/types/MemoryUnit.java diff --git a/src/main/java/nextflow/script/types/NextflowMetadata.java b/modules/compiler/src/main/java/script/types/NextflowMetadata.java similarity index 100% rename from src/main/java/nextflow/script/types/NextflowMetadata.java rename to modules/compiler/src/main/java/script/types/NextflowMetadata.java diff --git a/src/main/java/nextflow/script/types/ParamsMap.java b/modules/compiler/src/main/java/script/types/ParamsMap.java similarity index 100% rename from src/main/java/nextflow/script/types/ParamsMap.java rename to modules/compiler/src/main/java/script/types/ParamsMap.java diff --git a/src/main/java/nextflow/script/types/TaskConfig.java b/modules/compiler/src/main/java/script/types/TaskConfig.java similarity index 100% rename from src/main/java/nextflow/script/types/TaskConfig.java rename to modules/compiler/src/main/java/script/types/TaskConfig.java diff --git a/src/main/java/nextflow/script/types/Types.java b/modules/compiler/src/main/java/script/types/Types.java similarity index 100% rename from src/main/java/nextflow/script/types/Types.java rename to modules/compiler/src/main/java/script/types/Types.java diff --git a/src/main/java/nextflow/script/types/VersionNumber.java b/modules/compiler/src/main/java/script/types/VersionNumber.java similarity index 100% rename from src/main/java/nextflow/script/types/VersionNumber.java rename to modules/compiler/src/main/java/script/types/VersionNumber.java diff --git a/src/main/java/nextflow/script/types/WorkflowMetadata.java b/modules/compiler/src/main/java/script/types/WorkflowMetadata.java similarity index 100% rename from src/main/java/nextflow/script/types/WorkflowMetadata.java rename to modules/compiler/src/main/java/script/types/WorkflowMetadata.java diff --git a/modules/language-server/build.gradle b/modules/language-server/build.gradle new file mode 100644 index 0000000..b393799 --- /dev/null +++ b/modules/language-server/build.gradle @@ -0,0 +1,22 @@ +plugins { + id 'nextflow.java-conventions' + id 'com.gradleup.shadow' version '8.3.5' + id 'application' + id 'groovy' +} + +dependencies { + implementation project(':modules:compiler') + implementation 'org.apache.groovy:groovy:4.0.24' + implementation 'org.apache.groovy:groovy-json:4.0.24' + implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.23.0' + implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.23.0' + + testImplementation ('org.objenesis:objenesis:3.4') + testImplementation ('net.bytebuddy:byte-buddy:1.14.17') + testImplementation ('org.spockframework:spock-core:2.3-groovy-4.0') { exclude group: 'org.apache.groovy' } +} + +application { + mainClass = 'nextflow.lsp.NextflowLanguageServer' +} diff --git a/src/main/java/nextflow/lsp/NextflowLanguageServer.java b/modules/language-server/src/main/java/nextflow/lsp/NextflowLanguageServer.java similarity index 100% rename from src/main/java/nextflow/lsp/NextflowLanguageServer.java rename to modules/language-server/src/main/java/nextflow/lsp/NextflowLanguageServer.java diff --git a/src/main/java/nextflow/lsp/ast/ASTNodeCache.java b/modules/language-server/src/main/java/nextflow/lsp/ast/ASTNodeCache.java similarity index 100% rename from src/main/java/nextflow/lsp/ast/ASTNodeCache.java rename to modules/language-server/src/main/java/nextflow/lsp/ast/ASTNodeCache.java diff --git a/src/main/java/nextflow/lsp/ast/ASTNodeStringUtils.java b/modules/language-server/src/main/java/nextflow/lsp/ast/ASTNodeStringUtils.java similarity index 97% rename from src/main/java/nextflow/lsp/ast/ASTNodeStringUtils.java rename to modules/language-server/src/main/java/nextflow/lsp/ast/ASTNodeStringUtils.java index e2438a5..0fb92b5 100644 --- a/src/main/java/nextflow/lsp/ast/ASTNodeStringUtils.java +++ b/modules/language-server/src/main/java/nextflow/lsp/ast/ASTNodeStringUtils.java @@ -21,17 +21,17 @@ import groovy.lang.groovydoc.Groovydoc; import nextflow.lsp.services.util.FormattingOptions; import nextflow.lsp.services.util.Formatter; +import nextflow.script.ast.AssignmentExpression; +import nextflow.script.ast.FeatureFlagNode; +import nextflow.script.ast.FunctionNode; +import nextflow.script.ast.ProcessNode; +import nextflow.script.ast.WorkflowNode; import nextflow.script.dsl.Constant; import nextflow.script.dsl.Description; import nextflow.script.dsl.FeatureFlag; import nextflow.script.dsl.Operator; import nextflow.script.dsl.OutputDsl; import nextflow.script.dsl.ProcessDsl; -import nextflow.script.v2.AssignmentExpression; -import nextflow.script.v2.FeatureFlagNode; -import nextflow.script.v2.FunctionNode; -import nextflow.script.v2.ProcessNode; -import nextflow.script.v2.WorkflowNode; import org.codehaus.groovy.ast.AnnotatedNode; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassHelper; @@ -43,7 +43,7 @@ import org.codehaus.groovy.ast.stmt.ExpressionStatement; import org.codehaus.groovy.runtime.StringGroovyMethods; -import static nextflow.script.v2.ASTHelpers.*; +import static nextflow.script.ast.ASTHelpers.*; /** * Utility methods for retreiving text information for ast nodes. diff --git a/src/main/java/nextflow/lsp/ast/ASTParentVisitor.java b/modules/language-server/src/main/java/nextflow/lsp/ast/ASTParentVisitor.java similarity index 100% rename from src/main/java/nextflow/lsp/ast/ASTParentVisitor.java rename to modules/language-server/src/main/java/nextflow/lsp/ast/ASTParentVisitor.java diff --git a/src/main/java/nextflow/lsp/ast/ASTUtils.java b/modules/language-server/src/main/java/nextflow/lsp/ast/ASTUtils.java similarity index 99% rename from src/main/java/nextflow/lsp/ast/ASTUtils.java rename to modules/language-server/src/main/java/nextflow/lsp/ast/ASTUtils.java index 485a279..7e6b5c9 100644 --- a/src/main/java/nextflow/lsp/ast/ASTUtils.java +++ b/modules/language-server/src/main/java/nextflow/lsp/ast/ASTUtils.java @@ -20,8 +20,8 @@ import java.util.List; import java.util.stream.Collectors; -import nextflow.script.v2.FeatureFlagNode; -import nextflow.script.v2.IncludeVariable; +import nextflow.script.ast.FeatureFlagNode; +import nextflow.script.ast.IncludeVariable; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.FieldNode; diff --git a/src/main/java/nextflow/lsp/compiler/Compiler.java b/modules/language-server/src/main/java/nextflow/lsp/compiler/Compiler.java similarity index 100% rename from src/main/java/nextflow/lsp/compiler/Compiler.java rename to modules/language-server/src/main/java/nextflow/lsp/compiler/Compiler.java diff --git a/src/main/java/nextflow/lsp/compiler/LanguageServerErrorCollector.java b/modules/language-server/src/main/java/nextflow/lsp/compiler/LanguageServerErrorCollector.java similarity index 97% rename from src/main/java/nextflow/lsp/compiler/LanguageServerErrorCollector.java rename to modules/language-server/src/main/java/nextflow/lsp/compiler/LanguageServerErrorCollector.java index 7918248..6fac4e2 100644 --- a/src/main/java/nextflow/lsp/compiler/LanguageServerErrorCollector.java +++ b/modules/language-server/src/main/java/nextflow/lsp/compiler/LanguageServerErrorCollector.java @@ -17,6 +17,7 @@ import java.util.List; +import nextflow.script.control.PhaseAware; import org.codehaus.groovy.control.CompilerConfiguration; import org.codehaus.groovy.control.ErrorCollector; import org.codehaus.groovy.control.messages.Message; diff --git a/src/main/java/nextflow/lsp/compiler/StringReaderSourceWithURI.java b/modules/language-server/src/main/java/nextflow/lsp/compiler/StringReaderSourceWithURI.java similarity index 100% rename from src/main/java/nextflow/lsp/compiler/StringReaderSourceWithURI.java rename to modules/language-server/src/main/java/nextflow/lsp/compiler/StringReaderSourceWithURI.java diff --git a/src/main/java/nextflow/lsp/file/FileCache.java b/modules/language-server/src/main/java/nextflow/lsp/file/FileCache.java similarity index 100% rename from src/main/java/nextflow/lsp/file/FileCache.java rename to modules/language-server/src/main/java/nextflow/lsp/file/FileCache.java diff --git a/src/main/java/nextflow/lsp/file/PathUtils.java b/modules/language-server/src/main/java/nextflow/lsp/file/PathUtils.java similarity index 100% rename from src/main/java/nextflow/lsp/file/PathUtils.java rename to modules/language-server/src/main/java/nextflow/lsp/file/PathUtils.java diff --git a/src/main/java/nextflow/lsp/services/CallHierarchyProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/CallHierarchyProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/CallHierarchyProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/CallHierarchyProvider.java diff --git a/src/main/java/nextflow/lsp/services/CodeLensProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/CodeLensProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/CodeLensProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/CodeLensProvider.java diff --git a/src/main/java/nextflow/lsp/services/CompletionProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/CompletionProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/CompletionProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/CompletionProvider.java diff --git a/src/main/java/nextflow/lsp/services/DefinitionProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/DefinitionProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/DefinitionProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/DefinitionProvider.java diff --git a/src/main/java/nextflow/lsp/services/FormattingProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/FormattingProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/FormattingProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/FormattingProvider.java diff --git a/src/main/java/nextflow/lsp/services/HoverProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/HoverProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/HoverProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/HoverProvider.java diff --git a/src/main/java/nextflow/lsp/services/LanguageService.java b/modules/language-server/src/main/java/nextflow/lsp/services/LanguageService.java similarity index 99% rename from src/main/java/nextflow/lsp/services/LanguageService.java rename to modules/language-server/src/main/java/nextflow/lsp/services/LanguageService.java index de4402d..0222452 100644 --- a/src/main/java/nextflow/lsp/services/LanguageService.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/LanguageService.java @@ -35,8 +35,6 @@ import nextflow.lsp.ast.ASTNodeCache; import nextflow.lsp.compiler.Compiler; -import nextflow.lsp.compiler.FutureWarning; -import nextflow.lsp.compiler.RelatedInformationAware; import nextflow.lsp.file.FileCache; import nextflow.lsp.file.PathUtils; import nextflow.lsp.services.util.FormattingOptions; @@ -44,6 +42,8 @@ import nextflow.lsp.util.LanguageServerUtils; import nextflow.lsp.util.Logger; import nextflow.lsp.util.Positions; +import nextflow.script.control.FutureWarning; +import nextflow.script.control.RelatedInformationAware; import org.codehaus.groovy.runtime.DefaultGroovyMethods; import org.eclipse.lsp4j.CallHierarchyIncomingCall; import org.eclipse.lsp4j.CallHierarchyItem; diff --git a/src/main/java/nextflow/lsp/services/LinkProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/LinkProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/LinkProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/LinkProvider.java diff --git a/src/main/java/nextflow/lsp/services/ReferenceProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/ReferenceProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/ReferenceProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/ReferenceProvider.java diff --git a/src/main/java/nextflow/lsp/services/RenameProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/RenameProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/RenameProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/RenameProvider.java diff --git a/src/main/java/nextflow/lsp/services/SymbolProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/SymbolProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/SymbolProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/SymbolProvider.java diff --git a/src/main/java/nextflow/lsp/services/config/ConfigAstCache.java b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigAstCache.java similarity index 94% rename from src/main/java/nextflow/lsp/services/config/ConfigAstCache.java rename to modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigAstCache.java index 7b2814c..b9599f2 100644 --- a/src/main/java/nextflow/lsp/services/config/ConfigAstCache.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigAstCache.java @@ -21,21 +21,21 @@ import java.util.Set; import groovy.lang.GroovyClassLoader; +import nextflow.config.ast.ConfigAssignNode; +import nextflow.config.ast.ConfigBlockNode; +import nextflow.config.ast.ConfigIncludeNode; +import nextflow.config.ast.ConfigIncompleteNode; +import nextflow.config.ast.ConfigNode; +import nextflow.config.ast.ConfigVisitorSupport; +import nextflow.config.parser.ConfigParserPluginFactory; import nextflow.lsp.ast.ASTNodeCache; import nextflow.lsp.ast.ASTParentVisitor; import nextflow.lsp.compiler.Compiler; import nextflow.lsp.compiler.LanguageServerErrorCollector; -import nextflow.lsp.compiler.PhaseAware; -import nextflow.lsp.compiler.Phases; import nextflow.lsp.file.FileCache; -import nextflow.config.v2.ConfigAssignNode; -import nextflow.config.v2.ConfigBlockNode; -import nextflow.config.v2.ConfigIncludeNode; -import nextflow.config.v2.ConfigIncompleteNode; -import nextflow.config.v2.ConfigNode; -import nextflow.config.v2.ConfigParserPluginFactory; -import nextflow.config.v2.ConfigVisitorSupport; -import org.codehaus.groovy.ast.ASTNode;; +import nextflow.script.control.PhaseAware; +import nextflow.script.control.Phases; +import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.Parameter; import org.codehaus.groovy.ast.expr.BinaryExpression; import org.codehaus.groovy.ast.expr.BitwiseNegationExpression; diff --git a/src/main/java/nextflow/lsp/services/config/ConfigCompletionProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigCompletionProvider.java similarity index 97% rename from src/main/java/nextflow/lsp/services/config/ConfigCompletionProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigCompletionProvider.java index f36444f..fa07a25 100644 --- a/src/main/java/nextflow/lsp/services/config/ConfigCompletionProvider.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigCompletionProvider.java @@ -20,9 +20,9 @@ import java.util.Collections; import java.util.List; -import nextflow.config.v2.ConfigAssignNode; -import nextflow.config.v2.ConfigBlockNode; -import nextflow.config.v2.ConfigIncompleteNode; +import nextflow.config.ast.ConfigAssignNode; +import nextflow.config.ast.ConfigBlockNode; +import nextflow.config.ast.ConfigIncompleteNode; import nextflow.config.dsl.ConfigSchema; import nextflow.config.dsl.ConfigScope; import nextflow.lsp.ast.ASTNodeCache; diff --git a/src/main/java/nextflow/lsp/services/config/ConfigFormattingProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigFormattingProvider.java similarity index 95% rename from src/main/java/nextflow/lsp/services/config/ConfigFormattingProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigFormattingProvider.java index 1ea582b..20b29b8 100644 --- a/src/main/java/nextflow/lsp/services/config/ConfigFormattingProvider.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigFormattingProvider.java @@ -21,12 +21,12 @@ import java.util.List; import java.util.regex.Pattern; -import nextflow.config.v2.ConfigAppendNode; -import nextflow.config.v2.ConfigAssignNode; -import nextflow.config.v2.ConfigBlockNode; -import nextflow.config.v2.ConfigIncludeNode; -import nextflow.config.v2.ConfigNode; -import nextflow.config.v2.ConfigVisitorSupport; +import nextflow.config.ast.ConfigAppendNode; +import nextflow.config.ast.ConfigAssignNode; +import nextflow.config.ast.ConfigBlockNode; +import nextflow.config.ast.ConfigIncludeNode; +import nextflow.config.ast.ConfigNode; +import nextflow.config.ast.ConfigVisitorSupport; import nextflow.lsp.services.util.FormattingOptions; import nextflow.lsp.services.util.Formatter; import nextflow.lsp.services.FormattingProvider; diff --git a/src/main/java/nextflow/lsp/services/config/ConfigHoverProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigHoverProvider.java similarity index 98% rename from src/main/java/nextflow/lsp/services/config/ConfigHoverProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigHoverProvider.java index 54f85cd..3963f77 100644 --- a/src/main/java/nextflow/lsp/services/config/ConfigHoverProvider.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigHoverProvider.java @@ -19,9 +19,9 @@ import java.util.ArrayList; import java.util.List; +import nextflow.config.ast.ConfigAssignNode; +import nextflow.config.ast.ConfigBlockNode; import nextflow.config.dsl.ConfigSchema; -import nextflow.config.v2.ConfigAssignNode; -import nextflow.config.v2.ConfigBlockNode; import nextflow.lsp.ast.ASTNodeCache; import nextflow.lsp.services.HoverProvider; import nextflow.lsp.util.Logger; diff --git a/src/main/java/nextflow/lsp/services/config/ConfigLinkProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigLinkProvider.java similarity index 95% rename from src/main/java/nextflow/lsp/services/config/ConfigLinkProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigLinkProvider.java index 80057d1..2a7e6ea 100644 --- a/src/main/java/nextflow/lsp/services/config/ConfigLinkProvider.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigLinkProvider.java @@ -21,9 +21,9 @@ import java.util.Collections; import java.util.List; -import nextflow.config.v2.ConfigIncludeNode; -import nextflow.config.v2.ConfigNode; -import nextflow.config.v2.ConfigVisitorSupport; +import nextflow.config.ast.ConfigIncludeNode; +import nextflow.config.ast.ConfigNode; +import nextflow.config.ast.ConfigVisitorSupport; import nextflow.lsp.services.LinkProvider; import nextflow.lsp.util.Logger; import nextflow.lsp.util.LanguageServerUtils; diff --git a/src/main/java/nextflow/lsp/services/config/ConfigSchemaVisitor.java b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigSchemaVisitor.java similarity index 93% rename from src/main/java/nextflow/lsp/services/config/ConfigSchemaVisitor.java rename to modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigSchemaVisitor.java index bb3122e..e24ded8 100644 --- a/src/main/java/nextflow/lsp/services/config/ConfigSchemaVisitor.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigSchemaVisitor.java @@ -18,14 +18,14 @@ import java.util.ArrayList; import java.util.List; +import nextflow.config.ast.ConfigAssignNode; +import nextflow.config.ast.ConfigBlockNode; +import nextflow.config.ast.ConfigIncludeNode; +import nextflow.config.ast.ConfigNode; +import nextflow.config.ast.ConfigVisitorSupport; import nextflow.config.dsl.ConfigSchema; -import nextflow.config.v2.ConfigAssignNode; -import nextflow.config.v2.ConfigBlockNode; -import nextflow.config.v2.ConfigIncludeNode; -import nextflow.config.v2.ConfigNode; -import nextflow.config.v2.ConfigVisitorSupport; -import nextflow.lsp.compiler.PhaseAware; -import nextflow.lsp.compiler.Phases; +import nextflow.script.control.PhaseAware; +import nextflow.script.control.Phases; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.control.SourceUnit; import org.codehaus.groovy.control.messages.SyntaxErrorMessage; diff --git a/src/main/java/nextflow/lsp/services/config/ConfigService.java b/modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigService.java similarity index 100% rename from src/main/java/nextflow/lsp/services/config/ConfigService.java rename to modules/language-server/src/main/java/nextflow/lsp/services/config/ConfigService.java diff --git a/src/main/java/nextflow/lsp/services/config/ResolveIncludeVisitor.java b/modules/language-server/src/main/java/nextflow/lsp/services/config/ResolveIncludeVisitor.java similarity index 94% rename from src/main/java/nextflow/lsp/services/config/ResolveIncludeVisitor.java rename to modules/language-server/src/main/java/nextflow/lsp/services/config/ResolveIncludeVisitor.java index f671699..80e6a8a 100644 --- a/src/main/java/nextflow/lsp/services/config/ResolveIncludeVisitor.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/config/ResolveIncludeVisitor.java @@ -21,11 +21,11 @@ import java.util.List; import java.util.Set; -import nextflow.config.v2.ConfigIncludeNode; -import nextflow.config.v2.ConfigNode; -import nextflow.config.v2.ConfigVisitorSupport; -import nextflow.lsp.compiler.PhaseAware; -import nextflow.lsp.compiler.Phases; +import nextflow.config.ast.ConfigIncludeNode; +import nextflow.config.ast.ConfigNode; +import nextflow.config.ast.ConfigVisitorSupport; +import nextflow.script.control.PhaseAware; +import nextflow.script.control.Phases; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.expr.ConstantExpression; import org.codehaus.groovy.control.SourceUnit; diff --git a/src/main/java/nextflow/lsp/services/script/MethodCallVisitor.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/MethodCallVisitor.java similarity index 96% rename from src/main/java/nextflow/lsp/services/script/MethodCallVisitor.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/MethodCallVisitor.java index d777f93..67f8100 100644 --- a/src/main/java/nextflow/lsp/services/script/MethodCallVisitor.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/MethodCallVisitor.java @@ -18,12 +18,12 @@ import java.util.Optional; import nextflow.lsp.ast.ASTUtils; -import nextflow.lsp.compiler.PhaseAware; -import nextflow.lsp.compiler.Phases; -import nextflow.script.v2.ProcessNode; -import nextflow.script.v2.ScriptNode; -import nextflow.script.v2.ScriptVisitorSupport; -import nextflow.script.v2.WorkflowNode; +import nextflow.script.ast.ProcessNode; +import nextflow.script.ast.ScriptNode; +import nextflow.script.ast.ScriptVisitorSupport; +import nextflow.script.ast.WorkflowNode; +import nextflow.script.control.PhaseAware; +import nextflow.script.control.Phases; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.MethodNode; import org.codehaus.groovy.ast.expr.BinaryExpression; @@ -37,7 +37,7 @@ import org.codehaus.groovy.control.messages.SyntaxErrorMessage; import org.codehaus.groovy.syntax.SyntaxException; -import static nextflow.script.v2.ASTHelpers.*; +import static nextflow.script.ast.ASTHelpers.*; /** * Validate process and workflow invocations. diff --git a/modules/language-server/src/main/java/nextflow/lsp/services/script/ParameterSchemaVisitor.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ParameterSchemaVisitor.java new file mode 100644 index 0000000..7d2d67e --- /dev/null +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/ParameterSchemaVisitor.java @@ -0,0 +1,221 @@ +/* + * Copyright 2024, Seqera Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nextflow.lsp.services.script; + +import java.io.IOException; +import java.lang.reflect.Modifier; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +import groovy.json.JsonSlurper; +import nextflow.script.ast.ScriptNode; +import nextflow.script.ast.ScriptVisitorSupport; +import nextflow.script.ast.WorkflowNode; +import nextflow.script.control.PhaseAware; +import nextflow.script.control.Phases; +import nextflow.script.dsl.Description; +import nextflow.script.types.ParamsMap; +import org.codehaus.groovy.ast.ASTNode; +import org.codehaus.groovy.ast.AnnotationNode; +import org.codehaus.groovy.ast.ClassHelper; +import org.codehaus.groovy.ast.ClassNode; +import org.codehaus.groovy.ast.FieldNode; +import org.codehaus.groovy.ast.MethodNode; +import org.codehaus.groovy.ast.PropertyNode; +import org.codehaus.groovy.ast.expr.ConstantExpression; +import org.codehaus.groovy.ast.expr.PropertyExpression; +import org.codehaus.groovy.ast.expr.VariableExpression; +import org.codehaus.groovy.control.SourceUnit; +import org.codehaus.groovy.control.messages.SyntaxErrorMessage; +import org.codehaus.groovy.runtime.IOGroovyMethods; +import org.codehaus.groovy.syntax.SyntaxException; + +/** + * Validate params based on the JSON schema. + * + * @author Ben Sherman + */ +public class ParameterSchemaVisitor extends ScriptVisitorSupport { + + private SourceUnit sourceUnit; + + private ClassNode paramsType; + + public ParameterSchemaVisitor(SourceUnit sourceUnit) { + this.sourceUnit = sourceUnit; + } + + @Override + protected SourceUnit getSourceUnit() { + return sourceUnit; + } + + public void visit() { + var moduleNode = sourceUnit.getAST(); + if( moduleNode instanceof ScriptNode sn ) { + if( sn.getEntry() != null ) + visitWorkflow(sn.getEntry()); + } + } + + @Override + public void visitWorkflow(WorkflowNode node) { + try { + declareParameters(); + } + catch( Exception e ) { + System.err.println("Failed to parse parameter schema (nextflow_schema.json): " + e.toString()); + addError("Failed to parse parameter schema -- check nextflow_schema.json for possible errors", node); + return; + } + super.visitWorkflow(node); + } + + private void declareParameters() { + // load parameter schema + var uri = sourceUnit.getSource().getURI(); + var schemaPath = Path.of(uri).getParent().resolve("nextflow_schema.json"); + if( !Files.exists(schemaPath) ) + return; + var schemaJson = getParameterSchema(schemaPath); + + var defs = Optional.ofNullable(schemaJson) + .flatMap(json -> asMap(json)) + .flatMap(json -> + json.containsKey("$defs") + ? asMap(json.get("$defs")) : + json.containsKey("defs") + ? asMap(json.get("defs")) : + json.containsKey("definitions") + ? asMap(json.get("definitions")) + : Optional.empty() + ) + .orElse(Collections.emptyMap()); + + var entries = (List) defs.values().stream() + .filter(defn -> defn instanceof Map) + .map(defn -> ((Map) defn).get("properties")) + .filter(props -> props instanceof Map) + .flatMap(props -> ((Map) props).entrySet().stream()) + .collect(Collectors.toList()); + + if( entries.isEmpty() ) + return; + + // create synthetic params type + var cn = new ClassNode(ParamsMap.class); + + for( var entry : entries ) { + var name = (String) entry.getKey(); + var attrs = asMap(entry.getValue()).orElse(null); + if( attrs == null ) + continue; + var type = getTypeClassFromString((String) attrs.get("type")); + var description = (String) attrs.get("description"); + var fn = new FieldNode(name, Modifier.PUBLIC, type, cn, null); + fn.setHasNoRealSourcePosition(true); + fn.setDeclaringClass(cn); + fn.setSynthetic(true); + var an = new AnnotationNode(ClassHelper.makeCached(Description.class)); + an.addMember("value", new ConstantExpression(description)); + fn.addAnnotation(an); + cn.addField(fn); + } + + this.paramsType = cn; + } + + private Object getParameterSchema(Path schemaPath) { + try { + var schemaText = IOGroovyMethods.getText(Files.newInputStream(schemaPath)); + return new JsonSlurper().parseText(schemaText); + } + catch( IOException e ) { + System.err.println("Failed to read parameter schema: " + e.toString()); + return null; + } + } + + private static Optional asMap(Object value) { + return value instanceof Map + ? Optional.of((Map) value) + : Optional.empty(); + } + + private ClassNode getTypeClassFromString(String type) { + if( "boolean".equals(type) ) + return ClassHelper.boolean_TYPE; + if( "integer".equals(type) ) + return ClassHelper.long_TYPE; + if( "number".equals(type) ) + return ClassHelper.double_TYPE; + if( "string".equals(type) ) + return ClassHelper.STRING_TYPE; + return ClassHelper.dynamicType(); + } + + @Override + public void visitPropertyExpression(PropertyExpression node) { + super.visitPropertyExpression(node); + + // validate parameter against schema if applicable + // NOTE: should be incorporated into type-checking visitor + if( paramsType == null ) + return; + if( !(node.getObjectExpression() instanceof VariableExpression) ) + return; + var varX = (VariableExpression) node.getObjectExpression(); + if( !"params".equals(varX.getName()) ) + return; + var property = node.getPropertyAsString(); + if( paramsType.getDeclaredField(property) == null ) { + addError("Unrecognized parameter `" + property + "`", node); + return; + } + var variable = varX.getAccessedVariable(); + if( variable instanceof PropertyNode pn ) { + var mn = (MethodNode) pn.getNodeMetaData("access.method"); + mn.setReturnType(paramsType); + } + } + + // helpers + + @Override + public void addError(String message, ASTNode node) { + var cause = new ParameterSchemaError(message, node); + var errorMessage = new SyntaxErrorMessage(cause, sourceUnit); + sourceUnit.getErrorCollector().addErrorAndContinue(errorMessage); + } + + private class ParameterSchemaError extends SyntaxException implements PhaseAware { + + public ParameterSchemaError(String message, ASTNode node) { + super(message, node); + } + + @Override + public int getPhase() { + return Phases.NAME_RESOLUTION; + } + } + +} diff --git a/src/main/java/nextflow/lsp/services/script/ResolveIncludeVisitor.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ResolveIncludeVisitor.java similarity index 95% rename from src/main/java/nextflow/lsp/services/script/ResolveIncludeVisitor.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ResolveIncludeVisitor.java index 025f9ac..d01ef68 100644 --- a/src/main/java/nextflow/lsp/services/script/ResolveIncludeVisitor.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/ResolveIncludeVisitor.java @@ -22,11 +22,11 @@ import java.util.List; import java.util.Set; -import nextflow.lsp.compiler.PhaseAware; -import nextflow.lsp.compiler.Phases; -import nextflow.script.v2.IncludeNode; -import nextflow.script.v2.ScriptNode; -import nextflow.script.v2.ScriptVisitorSupport; +import nextflow.script.ast.IncludeNode; +import nextflow.script.ast.ScriptNode; +import nextflow.script.ast.ScriptVisitorSupport; +import nextflow.script.control.PhaseAware; +import nextflow.script.control.Phases; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.control.SourceUnit; import org.codehaus.groovy.control.messages.SyntaxErrorMessage; diff --git a/src/main/java/nextflow/lsp/services/script/ScriptAstCache.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptAstCache.java similarity index 95% rename from src/main/java/nextflow/lsp/services/script/ScriptAstCache.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptAstCache.java index 6ac1cd3..d7c75cb 100644 --- a/src/main/java/nextflow/lsp/services/script/ScriptAstCache.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptAstCache.java @@ -35,20 +35,22 @@ import nextflow.lsp.ast.ASTParentVisitor; import nextflow.lsp.compiler.Compiler; import nextflow.lsp.compiler.LanguageServerErrorCollector; -import nextflow.lsp.compiler.PhaseAware; -import nextflow.lsp.compiler.Phases; import nextflow.lsp.file.FileCache; -import nextflow.script.v2.FeatureFlagNode; -import nextflow.script.v2.FunctionNode; -import nextflow.script.v2.IncludeNode; -import nextflow.script.v2.IncludeVariable; -import nextflow.script.v2.OutputNode; -import nextflow.script.v2.ParamNode; -import nextflow.script.v2.ProcessNode; -import nextflow.script.v2.ScriptNode; -import nextflow.script.v2.ScriptParserPluginFactory; -import nextflow.script.v2.ScriptVisitorSupport; -import nextflow.script.v2.WorkflowNode; +import nextflow.script.ast.FeatureFlagNode; +import nextflow.script.ast.FunctionNode; +import nextflow.script.ast.IncludeNode; +import nextflow.script.ast.IncludeVariable; +import nextflow.script.ast.OutputNode; +import nextflow.script.ast.ParamNode; +import nextflow.script.ast.ProcessNode; +import nextflow.script.ast.ScriptNode; +import nextflow.script.ast.ScriptVisitorSupport; +import nextflow.script.ast.WorkflowNode; +import nextflow.script.control.PhaseAware; +import nextflow.script.control.Phases; +import nextflow.script.control.ResolveVisitor; +import nextflow.script.control.VariableScopeVisitor; +import nextflow.script.parser.ScriptParserPluginFactory; import org.codehaus.groovy.GroovyBugError; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassNode; @@ -105,8 +107,10 @@ protected SourceUnit buildAST(URI uri, FileCache fileCache) { // phase 2: name resolution // NOTE: must be done before visiting parents because it transforms nodes - if( sourceUnit != null ) + if( sourceUnit != null ) { new ResolveVisitor(sourceUnit, compilationUnit, libClasses).visit(); + new ParameterSchemaVisitor(sourceUnit).visit(); + } return sourceUnit; } diff --git a/src/main/java/nextflow/lsp/services/script/ScriptCallHierarchyProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCallHierarchyProvider.java similarity index 99% rename from src/main/java/nextflow/lsp/services/script/ScriptCallHierarchyProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCallHierarchyProvider.java index 137f3cd..eadf18f 100644 --- a/src/main/java/nextflow/lsp/services/script/ScriptCallHierarchyProvider.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCallHierarchyProvider.java @@ -25,8 +25,8 @@ import nextflow.lsp.services.CallHierarchyProvider; import nextflow.lsp.util.LanguageServerUtils; import nextflow.lsp.util.Logger; -import nextflow.script.v2.ProcessNode; -import nextflow.script.v2.WorkflowNode; +import nextflow.script.ast.ProcessNode; +import nextflow.script.ast.WorkflowNode; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassCodeVisitorSupport; import org.codehaus.groovy.ast.MethodNode; diff --git a/src/main/java/nextflow/lsp/services/script/ScriptCodeLensProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCodeLensProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/script/ScriptCodeLensProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCodeLensProvider.java diff --git a/src/main/java/nextflow/lsp/services/script/ScriptCompletionProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCompletionProvider.java similarity index 98% rename from src/main/java/nextflow/lsp/services/script/ScriptCompletionProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCompletionProvider.java index 3fd4856..f0343d8 100644 --- a/src/main/java/nextflow/lsp/services/script/ScriptCompletionProvider.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCompletionProvider.java @@ -30,16 +30,16 @@ import nextflow.lsp.services.CompletionProvider; import nextflow.lsp.util.LanguageServerUtils; import nextflow.lsp.util.Logger; +import nextflow.script.ast.FunctionNode; +import nextflow.script.ast.InvalidDeclaration; +import nextflow.script.ast.OutputNode; +import nextflow.script.ast.ProcessNode; +import nextflow.script.ast.WorkflowNode; import nextflow.script.dsl.Constant; import nextflow.script.dsl.Description; import nextflow.script.dsl.FeatureFlag; import nextflow.script.dsl.FeatureFlagDsl; import nextflow.script.types.Types; -import nextflow.script.v2.FunctionNode; -import nextflow.script.v2.InvalidDeclaration; -import nextflow.script.v2.OutputNode; -import nextflow.script.v2.ProcessNode; -import nextflow.script.v2.WorkflowNode; import org.codehaus.groovy.ast.AnnotatedNode; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassHelper; @@ -70,7 +70,7 @@ import org.eclipse.lsp4j.TextDocumentIdentifier; import org.eclipse.lsp4j.jsonrpc.messages.Either; -import static nextflow.script.v2.ASTHelpers.*; +import static nextflow.script.ast.ASTHelpers.*; /** * Provide suggestions for an incomplete expression or statement diff --git a/src/main/java/nextflow/lsp/services/script/ScriptDefinitionProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptDefinitionProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/script/ScriptDefinitionProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptDefinitionProvider.java diff --git a/src/main/java/nextflow/lsp/services/script/ScriptFormattingProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptFormattingProvider.java similarity index 97% rename from src/main/java/nextflow/lsp/services/script/ScriptFormattingProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptFormattingProvider.java index cddd01a..6606eb3 100644 --- a/src/main/java/nextflow/lsp/services/script/ScriptFormattingProvider.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptFormattingProvider.java @@ -25,17 +25,17 @@ import nextflow.lsp.services.FormattingProvider; import nextflow.lsp.util.Logger; import nextflow.lsp.util.Positions; -import nextflow.script.v2.AssignmentExpression; -import nextflow.script.v2.FeatureFlagNode; -import nextflow.script.v2.FunctionNode; -import nextflow.script.v2.IncludeNode; -import nextflow.script.v2.IncludeVariable; -import nextflow.script.v2.OutputNode; -import nextflow.script.v2.ParamNode; -import nextflow.script.v2.ProcessNode; -import nextflow.script.v2.ScriptNode; -import nextflow.script.v2.ScriptVisitorSupport; -import nextflow.script.v2.WorkflowNode; +import nextflow.script.ast.AssignmentExpression; +import nextflow.script.ast.FeatureFlagNode; +import nextflow.script.ast.FunctionNode; +import nextflow.script.ast.IncludeNode; +import nextflow.script.ast.IncludeVariable; +import nextflow.script.ast.OutputNode; +import nextflow.script.ast.ParamNode; +import nextflow.script.ast.ProcessNode; +import nextflow.script.ast.ScriptNode; +import nextflow.script.ast.ScriptVisitorSupport; +import nextflow.script.ast.WorkflowNode; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.expr.EmptyExpression; import org.codehaus.groovy.ast.expr.MethodCallExpression; @@ -51,7 +51,7 @@ import org.eclipse.lsp4j.Range; import org.eclipse.lsp4j.TextEdit; -import static nextflow.script.v2.ASTHelpers.*; +import static nextflow.script.ast.ASTHelpers.*; /** * Provide formatting for a script. diff --git a/src/main/java/nextflow/lsp/services/script/ScriptHoverProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptHoverProvider.java similarity index 96% rename from src/main/java/nextflow/lsp/services/script/ScriptHoverProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptHoverProvider.java index c4b01a4..33063a3 100644 --- a/src/main/java/nextflow/lsp/services/script/ScriptHoverProvider.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptHoverProvider.java @@ -21,9 +21,9 @@ import nextflow.lsp.ast.ASTUtils; import nextflow.lsp.services.HoverProvider; import nextflow.lsp.util.Logger; -import nextflow.script.v2.FunctionNode; -import nextflow.script.v2.ProcessNode; -import nextflow.script.v2.WorkflowNode; +import nextflow.script.ast.FunctionNode; +import nextflow.script.ast.ProcessNode; +import nextflow.script.ast.WorkflowNode; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.MethodNode; import org.codehaus.groovy.ast.Variable; diff --git a/src/main/java/nextflow/lsp/services/script/ScriptLinkProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptLinkProvider.java similarity index 100% rename from src/main/java/nextflow/lsp/services/script/ScriptLinkProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptLinkProvider.java diff --git a/src/main/java/nextflow/lsp/services/script/ScriptReferenceProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptReferenceProvider.java similarity index 99% rename from src/main/java/nextflow/lsp/services/script/ScriptReferenceProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptReferenceProvider.java index c44964f..5d9912b 100644 --- a/src/main/java/nextflow/lsp/services/script/ScriptReferenceProvider.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptReferenceProvider.java @@ -26,7 +26,7 @@ import nextflow.lsp.services.RenameProvider; import nextflow.lsp.util.LanguageServerUtils; import nextflow.lsp.util.Logger; -import nextflow.script.v2.IncludeVariable; +import nextflow.script.ast.IncludeVariable; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.MethodNode; diff --git a/src/main/java/nextflow/lsp/services/script/ScriptService.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptService.java similarity index 100% rename from src/main/java/nextflow/lsp/services/script/ScriptService.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptService.java diff --git a/src/main/java/nextflow/lsp/services/script/ScriptSymbolProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptSymbolProvider.java similarity index 97% rename from src/main/java/nextflow/lsp/services/script/ScriptSymbolProvider.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptSymbolProvider.java index 0f9dc94..af87c86 100644 --- a/src/main/java/nextflow/lsp/services/script/ScriptSymbolProvider.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptSymbolProvider.java @@ -23,9 +23,9 @@ import nextflow.lsp.services.SymbolProvider; import nextflow.lsp.util.LanguageServerUtils; import nextflow.lsp.util.Logger; -import nextflow.script.v2.FunctionNode; -import nextflow.script.v2.ProcessNode; -import nextflow.script.v2.WorkflowNode; +import nextflow.script.ast.FunctionNode; +import nextflow.script.ast.ProcessNode; +import nextflow.script.ast.WorkflowNode; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.ClassNode; import org.codehaus.groovy.ast.MethodNode; diff --git a/src/main/java/nextflow/lsp/services/script/dag/DataflowVisitor.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/dag/DataflowVisitor.java similarity index 98% rename from src/main/java/nextflow/lsp/services/script/dag/DataflowVisitor.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/dag/DataflowVisitor.java index 6be9ef9..122d618 100644 --- a/src/main/java/nextflow/lsp/services/script/dag/DataflowVisitor.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/dag/DataflowVisitor.java @@ -31,11 +31,11 @@ import groovy.lang.Tuple3; import nextflow.lsp.ast.ASTUtils; import nextflow.lsp.services.script.ScriptAstCache; -import nextflow.script.v2.AssignmentExpression; -import nextflow.script.v2.ProcessNode; -import nextflow.script.v2.ScriptNode; -import nextflow.script.v2.ScriptVisitorSupport; -import nextflow.script.v2.WorkflowNode; +import nextflow.script.ast.AssignmentExpression; +import nextflow.script.ast.ProcessNode; +import nextflow.script.ast.ScriptNode; +import nextflow.script.ast.ScriptVisitorSupport; +import nextflow.script.ast.WorkflowNode; import org.codehaus.groovy.ast.ASTNode; import org.codehaus.groovy.ast.MethodNode; import org.codehaus.groovy.ast.expr.*; @@ -43,7 +43,7 @@ import org.codehaus.groovy.control.SourceUnit; import org.codehaus.groovy.syntax.Types; -import static nextflow.script.v2.ASTHelpers.*; +import static nextflow.script.ast.ASTHelpers.*; import static org.codehaus.groovy.ast.tools.GeneralUtils.*; diff --git a/src/main/java/nextflow/lsp/services/script/dag/MermaidRenderer.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/dag/MermaidRenderer.java similarity index 100% rename from src/main/java/nextflow/lsp/services/script/dag/MermaidRenderer.java rename to modules/language-server/src/main/java/nextflow/lsp/services/script/dag/MermaidRenderer.java diff --git a/src/main/java/nextflow/lsp/services/util/Formatter.java b/modules/language-server/src/main/java/nextflow/lsp/services/util/Formatter.java similarity index 99% rename from src/main/java/nextflow/lsp/services/util/Formatter.java rename to modules/language-server/src/main/java/nextflow/lsp/services/util/Formatter.java index 6d60a70..2cc6824 100644 --- a/src/main/java/nextflow/lsp/services/util/Formatter.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/util/Formatter.java @@ -60,7 +60,7 @@ import org.codehaus.groovy.runtime.DefaultGroovyMethods; import org.codehaus.groovy.syntax.Types; -import static nextflow.script.v2.ASTHelpers.*; +import static nextflow.script.ast.ASTHelpers.*; /** * diff --git a/src/main/java/nextflow/lsp/services/util/FormattingOptions.java b/modules/language-server/src/main/java/nextflow/lsp/services/util/FormattingOptions.java similarity index 100% rename from src/main/java/nextflow/lsp/services/util/FormattingOptions.java rename to modules/language-server/src/main/java/nextflow/lsp/services/util/FormattingOptions.java diff --git a/src/main/java/nextflow/lsp/util/DebouncingExecutor.java b/modules/language-server/src/main/java/nextflow/lsp/util/DebouncingExecutor.java similarity index 100% rename from src/main/java/nextflow/lsp/util/DebouncingExecutor.java rename to modules/language-server/src/main/java/nextflow/lsp/util/DebouncingExecutor.java diff --git a/src/main/java/nextflow/lsp/util/LanguageServerUtils.java b/modules/language-server/src/main/java/nextflow/lsp/util/LanguageServerUtils.java similarity index 100% rename from src/main/java/nextflow/lsp/util/LanguageServerUtils.java rename to modules/language-server/src/main/java/nextflow/lsp/util/LanguageServerUtils.java diff --git a/src/main/java/nextflow/lsp/util/Logger.java b/modules/language-server/src/main/java/nextflow/lsp/util/Logger.java similarity index 100% rename from src/main/java/nextflow/lsp/util/Logger.java rename to modules/language-server/src/main/java/nextflow/lsp/util/Logger.java diff --git a/src/main/java/nextflow/lsp/util/Positions.java b/modules/language-server/src/main/java/nextflow/lsp/util/Positions.java similarity index 100% rename from src/main/java/nextflow/lsp/util/Positions.java rename to modules/language-server/src/main/java/nextflow/lsp/util/Positions.java diff --git a/src/test/groovy/nextflow/lsp/TestLanguageClient.groovy b/modules/language-server/src/test/groovy/nextflow/lsp/TestLanguageClient.groovy similarity index 100% rename from src/test/groovy/nextflow/lsp/TestLanguageClient.groovy rename to modules/language-server/src/test/groovy/nextflow/lsp/TestLanguageClient.groovy diff --git a/src/test/groovy/nextflow/lsp/ast/ASTNodeStringUtilsTest.groovy b/modules/language-server/src/test/groovy/nextflow/lsp/ast/ASTNodeStringUtilsTest.groovy similarity index 94% rename from src/test/groovy/nextflow/lsp/ast/ASTNodeStringUtilsTest.groovy rename to modules/language-server/src/test/groovy/nextflow/lsp/ast/ASTNodeStringUtilsTest.groovy index 37e56c9..3b5ac90 100644 --- a/src/test/groovy/nextflow/lsp/ast/ASTNodeStringUtilsTest.groovy +++ b/modules/language-server/src/test/groovy/nextflow/lsp/ast/ASTNodeStringUtilsTest.groovy @@ -17,13 +17,13 @@ package nextflow.lsp.ast import groovy.lang.groovydoc.Groovydoc +import nextflow.script.ast.FeatureFlagNode +import nextflow.script.ast.FunctionNode +import nextflow.script.ast.ProcessNode +import nextflow.script.ast.WorkflowNode import nextflow.script.dsl.FeatureFlagDsl import nextflow.script.dsl.ProcessDsl import nextflow.script.types.Channel -import nextflow.script.v2.FeatureFlagNode -import nextflow.script.v2.FunctionNode -import nextflow.script.v2.ProcessNode -import nextflow.script.v2.WorkflowNode import org.codehaus.groovy.ast.ClassHelper import org.codehaus.groovy.ast.ClassNode import org.codehaus.groovy.ast.Parameter @@ -36,14 +36,14 @@ import spock.lang.Specification */ class ASTNodeStringUtilsTest extends Specification { - def 'should get the label and docs for a type' () { + def 'should get the label and docs for a class' () { when: def classNode = Mock(ClassNode) { isEnum() >> false getNameWithoutPackage() >> 'Channel' } then: - ASTNodeStringUtils.getLabel(classNode) == 'type Channel' + ASTNodeStringUtils.getLabel(classNode) == 'class Channel' when: def enumNode = Mock(ClassNode) { @@ -154,7 +154,7 @@ class ASTNodeStringUtilsTest extends Specification { '''.stripIndent(true) } then: - ASTNodeStringUtils.getLabel(node) == 'sayHello(message, target)' + ASTNodeStringUtils.getLabel(node) == 'def sayHello(message, target)' ASTNodeStringUtils.getDocumentation(node) == 'Say hello to someone.' } diff --git a/src/test/groovy/nextflow/lsp/compiler/LanguageServerErrorCollectorTest.groovy b/modules/language-server/src/test/groovy/nextflow/lsp/compiler/LanguageServerErrorCollectorTest.groovy similarity index 96% rename from src/test/groovy/nextflow/lsp/compiler/LanguageServerErrorCollectorTest.groovy rename to modules/language-server/src/test/groovy/nextflow/lsp/compiler/LanguageServerErrorCollectorTest.groovy index 0b0e8d0..e0c6992 100644 --- a/src/test/groovy/nextflow/lsp/compiler/LanguageServerErrorCollectorTest.groovy +++ b/modules/language-server/src/test/groovy/nextflow/lsp/compiler/LanguageServerErrorCollectorTest.groovy @@ -16,6 +16,8 @@ package nextflow.lsp.compiler +import nextflow.script.control.PhaseAware +import nextflow.script.control.Phases import org.codehaus.groovy.ast.expr.EmptyExpression import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.SourceUnit diff --git a/src/test/groovy/nextflow/lsp/file/FileCacheTest.groovy b/modules/language-server/src/test/groovy/nextflow/lsp/file/FileCacheTest.groovy similarity index 100% rename from src/test/groovy/nextflow/lsp/file/FileCacheTest.groovy rename to modules/language-server/src/test/groovy/nextflow/lsp/file/FileCacheTest.groovy diff --git a/src/test/groovy/nextflow/lsp/file/PathUtilsTest.groovy b/modules/language-server/src/test/groovy/nextflow/lsp/file/PathUtilsTest.groovy similarity index 100% rename from src/test/groovy/nextflow/lsp/file/PathUtilsTest.groovy rename to modules/language-server/src/test/groovy/nextflow/lsp/file/PathUtilsTest.groovy diff --git a/src/test/groovy/nextflow/lsp/services/config/ConfigFormattingTest.groovy b/modules/language-server/src/test/groovy/nextflow/lsp/services/config/ConfigFormattingTest.groovy similarity index 100% rename from src/test/groovy/nextflow/lsp/services/config/ConfigFormattingTest.groovy rename to modules/language-server/src/test/groovy/nextflow/lsp/services/config/ConfigFormattingTest.groovy diff --git a/src/test/groovy/nextflow/lsp/services/script/ScriptFormattingTest.groovy b/modules/language-server/src/test/groovy/nextflow/lsp/services/script/ScriptFormattingTest.groovy similarity index 100% rename from src/test/groovy/nextflow/lsp/services/script/ScriptFormattingTest.groovy rename to modules/language-server/src/test/groovy/nextflow/lsp/services/script/ScriptFormattingTest.groovy diff --git a/src/test/groovy/nextflow/lsp/util/PositionsTest.groovy b/modules/language-server/src/test/groovy/nextflow/lsp/util/PositionsTest.groovy similarity index 100% rename from src/test/groovy/nextflow/lsp/util/PositionsTest.groovy rename to modules/language-server/src/test/groovy/nextflow/lsp/util/PositionsTest.groovy diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..86921e8 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,4 @@ +rootProject.name = 'language-server' + +include 'modules:compiler' +include 'modules:language-server'