Skip to content

Commit

Permalink
Split into subprojects for compiler and language server (#73)
Browse files Browse the repository at this point in the history
* Split into subprojects for compiler and language server
* Rename v2 package to ast
* Move compiler classes into compiler module
* Move parser classes to separate package
* Move nextflow.antlr classes into script/config parser packages
* Move groovy-json dependency to language server
* Fix groovy tests
* Replace allprojects with conventions plugin
* Fix failing tests
* Add CI build

---------

Signed-off-by: Ben Sherman <bentshermann@gmail.com>
  • Loading branch information
bentsherman authored Nov 20, 2024
1 parent 9ab8217 commit eb81457
Show file tree
Hide file tree
Showing 185 changed files with 553 additions and 376 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 6 additions & 35 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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
}
7 changes: 7 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
id 'groovy-gradle-plugin'
}

repositories {
gradlePluginPortal()
}
23 changes: 23 additions & 0 deletions buildSrc/src/main/groovy/nextflow.java-conventions.gradle
Original file line number Diff line number Diff line change
@@ -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()
}
18 changes: 18 additions & 0 deletions modules/compiler/build.gradle
Original file line number Diff line number Diff line change
@@ -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']
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) */
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) */
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package nextflow.script.v2;
package nextflow.script.ast;

import java.util.Collections;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit eb81457

Please sign in to comment.