Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support Scala3 #556

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/pr_and_push_verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
run: mvn -P scala-212 clean verify --file pom.xml
- name: Build for Scala 2.13 with Maven
run: mvn -P scala-213 clean verify --file pom.xml
- name: Build for Scala 3 with Maven
run: mvn -P scala-3 clean verify --file pom.xml
- name: Grammar scripts
run: |
./tools/grammar/src/main/shell/launch.sh RailRoadDiagramPages -outputDir=grammar/generated/railroad cypher.xml
Expand Down
55 changes: 43 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@
<properties>
<dep.antlr4.version>4.7.2</dep.antlr4.version>
<dep.batik.version>1.13</dep.batik.version>
<dep.scalatags.version>0.10.0</dep.scalatags.version>
<dep.scalatags.version>0.11.0</dep.scalatags.version>
<dep.cucumber.version>5.7.0</dep.cucumber.version>
<dep.fastparse.version>2.3.3</dep.fastparse.version>
<dep.fastparse.version>3.0.0</dep.fastparse.version>
<dep.hamcrest.version>2.2</dep.hamcrest.version>
<dep.junit.platform.version>1.7.0</dep.junit.platform.version>
<dep.junit.version>5.7.0</dep.junit.version>
<dep.maven.compiler.plugin.version>3.8.1</dep.maven.compiler.plugin.version>
<dep.maven.javadoc.plugin.version>3.2.0</dep.maven.javadoc.plugin.version>
<dep.maven.source.plugin.version>3.2.1</dep.maven.source.plugin.version>
<dep.maven.surefire.plugin.version>2.22.2</dep.maven.surefire.plugin.version>
<dep.scala.maven.plugin.version>3.4.4</dep.scala.maven.plugin.version>
<dep.scalatest.version>3.2.2</dep.scalatest.version>
<dep.scala.maven.plugin.version>4.9.1</dep.scala.maven.plugin.version>
<dep.scalatest.version>3.2.11</dep.scalatest.version>
<dep.scalatest.runner.version>0.1.8</dep.scalatest.runner.version>
<dep.scala.compat.version>2.2.0</dep.scala.compat.version>
<dep.scala.compat.version>2.6.0</dep.scala.compat.version>
<dep.xmlgraphics-commons.version>2.6</dep.xmlgraphics-commons.version>
<dep.commons-csv.version>1.8</dep.commons-csv.version>
<dep.commons-cli.version>1.4</dep.commons-cli.version>
Expand Down Expand Up @@ -83,13 +83,7 @@
<dependencyManagement>
<dependencies>

<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>

<dependency>
<dependency>
<groupId>org.opencypher</groupId>
<artifactId>tck</artifactId>
<version>${project.version}</version>
Expand Down Expand Up @@ -384,15 +378,52 @@
<id>scala-212</id>
<properties>
<scala.binary.version>2.12</scala.binary.version>
<scala2.binary.version>2.12</scala2.binary.version>
<scala.version>2.12.13</scala.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
<profile>
<id>scala-213</id>
<properties>
<scala.binary.version>2.13</scala.binary.version>
<scala2.binary.version>2.13</scala2.binary.version>
<scala.version>2.13.7</scala.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
<profile>
<id>scala-3</id>
<properties>
<scala.binary.version>3</scala.binary.version>
<scala2.binary.version>2.13</scala2.binary.version>
<scala.version>3.3.3</scala.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala3-library_${scala.binary.version}</artifactId>
<version>${scala.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
</profiles>

Expand Down
34 changes: 30 additions & 4 deletions tools/tck-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@
</build>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</dependency>

<dependency>
<groupId>org.opencypher</groupId>
Expand Down Expand Up @@ -119,4 +115,34 @@

</dependencies>

<profiles>
<profile>
<id>scala-212</id>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>scala-213</id>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>scala-3</id>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala3-library_${scala.binary.version}</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ object CypherTCK {
val directoryPath: Path = Paths.get(resource)
try {
val featurePaths = Files.walk(directoryPath).filter {
t: Path => Files.isRegularFile(t) && t.toString.endsWith(featureSuffix)
(t: Path) => Files.isRegularFile(t) && t.toString.endsWith(featureSuffix)
}
// Note that converting to list is necessary to cut off lazy evaluation
// otherwise evaluation of parsePathFeature will happen after the file system is already closed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ import org.opencypher.tools.tck.values.Connection.{backward, forward}
case class CypherValueParseException(msg: String, expected: String) extends Exception(msg)

class CypherValueParser(val orderedLists: Boolean) {

implicit object whitespace extends Whitespace {
override def apply(ctx: ParsingRun[_]): ParsingRun[Unit] = {
implicit val p: ParsingRun[_] = ctx
implicit val w: Whitespace = this
invisible.rep
}
}

def parse(s: String): CypherValue = {
fastparse.parse(s, cypherValueFromEntireInput(_), verboseFailures = true) match {
case Success(value, _) => value
Expand Down Expand Up @@ -174,6 +183,4 @@ class CypherValueParser(val orderedLists: Boolean) {

private def newline[X: P]: P[Unit] = "\n" | "\r\n" | "\r" | "\f"
private def invisible[X: P]: P[Unit] = " " | "\t" | newline

implicit val whitespace: P[_] => P[Unit] = { implicit ctx: ParsingRun[_] => invisible.rep }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2015-2024 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* 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.
*
* Attribution Notice under the terms of the Apache License 2.0
*
* This work was created by the collective efforts of the openCypher community.
* Without limiting the terms of Section 6, any Derivative Work that is not
* approved by the public consensus process of the openCypher Implementers Group
* should not be described as “Cypher” (and Cypher® is a registered trademark of
* Neo4j Inc.) or as "openCypher". Extensions by implementers or prototypes or
* proposals for change that have been documented or implemented should only be
* described as "implementation extensions to Cypher" or as "proposed changes to
* Cypher that are not yet approved by the openCypher community".
*/
package org.opencypher.tools.tck.api.events

import scala.collection.mutable

/**
* This is a cut-down version of these classes from the 2.12 Scala collections API that just provides
* the functionality we use.
*/
object Collections {

trait Subscriber[-Evt, -Pub] {
def notify(pub: Pub, event: Evt): Unit
}

trait Publisher[Evt] {
private val subs: mutable.Buffer[Subscriber[Evt, Publisher[Evt]]] = mutable.Buffer()

def subscribe(sub: Subscriber[Evt, Publisher[Evt]]): Unit = {
subs += sub
}

def removeSubscriptions() = subs.clear()

def publish(e: Evt) = subs.foreach(_.notify(this, e))
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2015-2024 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* 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.
*
* Attribution Notice under the terms of the Apache License 2.0
*
* This work was created by the collective efforts of the openCypher community.
* Without limiting the terms of Section 6, any Derivative Work that is not
* approved by the public consensus process of the openCypher Implementers Group
* should not be described as “Cypher” (and Cypher® is a registered trademark of
* Neo4j Inc.) or as "openCypher". Extensions by implementers or prototypes or
* proposals for change that have been documented or implemented should only be
* described as "implementation extensions to Cypher" or as "proposed changes to
* Cypher that are not yet approved by the openCypher community".
*/
package org.opencypher.tools.tck.values

import scala.util.hashing.MurmurHash3

object Hashing {

def productHash(p: Product) = MurmurHash3.productHash(p, MurmurHash3.productSeed, ignorePrefix = true)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2015-2024 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* 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.
*
* Attribution Notice under the terms of the Apache License 2.0
*
* This work was created by the collective efforts of the openCypher community.
* Without limiting the terms of Section 6, any Derivative Work that is not
* approved by the public consensus process of the openCypher Implementers Group
* should not be described as “Cypher” (and Cypher® is a registered trademark of
* Neo4j Inc.) or as "openCypher". Extensions by implementers or prototypes or
* proposals for change that have been documented or implemented should only be
* described as "implementation extensions to Cypher" or as "proposed changes to
* Cypher that are not yet approved by the openCypher community".
*/
package org.opencypher.tools.tck.values

import scala.math.Ordering.Implicits.seqOrdering

object OrderingCompatibility {
trait Implicits {
implicit def seqOrdering[CC[X] <: scala.collection.Seq[X], T](implicit ord: Ordering[T]): Ordering[CC[T]] = scala.math.Ordering.Implicits.seqOrdering
}
object Implicits extends Implicits { }
}
34 changes: 29 additions & 5 deletions tools/tck-compatibility-tests/tck-compatibility-tests-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@
</build>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</dependency>

<dependency>
<groupId>org.opencypher</groupId>
<artifactId>tck-api_${scala.binary.version}</artifactId>
Expand Down Expand Up @@ -122,5 +117,34 @@

</dependencies>

<profiles>
<profile>
<id>scala-212</id>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>scala-213</id>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>scala-3</id>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala3-library_${scala.binary.version}</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>

</project>
6 changes: 6 additions & 0 deletions tools/tck-inspection/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@
<dep.cask.version>0.7.12</dep.cask.version>
</properties>
</profile>
<profile>
<id>scala-3</id>
<properties>
<dep.cask.version>0.7.12</dep.cask.version>
</properties>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ case class LCSbasedListDiff[A](before: List[A], after: List[A]) extends ListDiff
case class Memo[I, K, O](f: I => O)(implicit ev: I => K) extends (I => O) {
import scala.collection.mutable
val cache: mutable.Map[K, O] = mutable.Map.empty[K, O]
override def apply(x: I): O = cache.getOrElseUpdate(x, f(x))
override def apply(x: I): O = cache.getOrElseUpdate(ev(x), f(x))
}

def lcs[A](a: List[(A, Int)], b: List[(A, Int)], eq: (A, A) => Boolean): List[(Int, Int)] = {
Expand Down
Loading
Loading