From d1b1faa8d4692bbbe7e44a0caed6372c4c1a4ae9 Mon Sep 17 00:00:00 2001 From: Michael Pollmeier Date: Tue, 9 Apr 2024 17:17:09 +0200 Subject: [PATCH] scala 3.4.1 including automatic rewrites --- build.sbt | 2 +- .../scala/flatgraph/DiffGraphApplier.scala | 4 +- core/src/main/scala/flatgraph/Schema.scala | 42 +++++++++---------- .../main/scala/flatgraph/help/DocFinder.scala | 2 +- .../scala/flatgraph/help/TraversalHelp.scala | 14 +++---- .../flatgraph/storage/Deserialization.scala | 2 +- .../scala/flatgraph/storage/Manifest.scala | 8 ++-- .../scala/flatgraph/traversal/Language.scala | 26 ++++++------ .../traversal/PathAwareTraversal.scala | 2 +- .../flatgraph/traversal/RepeatBehaviour.scala | 22 +++++----- .../scala/flatgraph/codegen/Helpers.scala | 8 ++-- .../scala/flatgraph/codegen/ProtoGen.scala | 4 +- .../main/scala/flatgraph/schema/Schema.scala | 38 ++++++++--------- .../flatgraph/schema/SchemaBuilder.scala | 10 ++--- .../flatgraph/formats/graphml/package.scala | 2 +- .../formats/graphson/GraphSONProtocol.scala | 6 +-- .../flatgraph/formats/graphson/package.scala | 4 +- .../formats/neo4jcsv/ColumnDefinitions.scala | 16 +++---- .../formats/neo4jcsv/Neo4jCsvImporter.scala | 4 +- .../scala/flatgraph/formats/package.scala | 8 ++-- .../scala/flatgraph/convert/Convert.scala | 2 +- 21 files changed, 113 insertions(+), 113 deletions(-) diff --git a/build.sbt b/build.sbt index fe842fcd..e8e14c69 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ ThisBuild / organization := "io.joern" ThisBuild / scalaVersion := scala3 val slf4jVersion = "2.0.7" -val scala3 = "3.3.1" +val scala3 = "3.4.1" val scala2_12 = "2.12.18" /** Only the below listed projects are included in things like `sbt compile`. diff --git a/core/src/main/scala/flatgraph/DiffGraphApplier.scala b/core/src/main/scala/flatgraph/DiffGraphApplier.scala index 034d6d2e..a19119fd 100644 --- a/core/src/main/scala/flatgraph/DiffGraphApplier.scala +++ b/core/src/main/scala/flatgraph/DiffGraphApplier.scala @@ -411,7 +411,7 @@ private[flatgraph] class DiffGraphApplier(graph: Graph, diff: DiffGraphBuilder) // ^ change this once we switch away from full copy-on-write, see e.g. // https://github.com/joernio/flatgraph/pull/163#discussion_r1537246314 } - val propview = mutable.ArraySeq.make(edgeProp.asInstanceOf[Array[_]]).asInstanceOf[mutable.ArraySeq[Any]] + val propview = mutable.ArraySeq.make(edgeProp.asInstanceOf[Array[?]]).asInstanceOf[mutable.ArraySeq[Any]] // this will fail if the edge doesn't support properties. todo: better error message val default = graph.schema.allocateEdgeProperty(nodeKind, direction, edgeKind = edgeKind, size = 1)(0) for (edgeRepr <- setEdgeProperties(pos)) { @@ -584,7 +584,7 @@ private[flatgraph] class DiffGraphApplier(graph: Graph, diff: DiffGraphBuilder) val oldQty = Option(graph.properties(pos).asInstanceOf[Array[Int]]).getOrElse(new Array[Int](1)) val oldProperty = Option(graph.properties(pos + 1)) .getOrElse(graph.schema.getNodePropertyFormalType(nodeKind, propertyKind).allocate(0)) - .asInstanceOf[Array[_]] + .asInstanceOf[Array[?]] if oldProperty == null then throw new SchemaViolationException("Unsupported property on node") val newQty = new Array[Int](nodeCount + 1) diff --git a/core/src/main/scala/flatgraph/Schema.scala b/core/src/main/scala/flatgraph/Schema.scala index b2be3268..0bb03414 100644 --- a/core/src/main/scala/flatgraph/Schema.scala +++ b/core/src/main/scala/flatgraph/Schema.scala @@ -22,75 +22,75 @@ object FormalQtyType { object QtyMulti extends FormalQuantity sealed trait FormalType { - def allocate(n: Int): Array[_] + def allocate(n: Int): Array[?] } object NothingType extends FormalType { - def allocate(n: Int): Array[_] = null + def allocate(n: Int): Array[?] = null } object BoolType extends FormalType { - override def allocate(n: Int): Array[_] = new Array[Boolean](n) + override def allocate(n: Int): Array[?] = new Array[Boolean](n) } case class BoolTypeWithDefault(b: Boolean) extends FormalType { - override def allocate(n: Int): Array[_] = Array.fill(n)(b) + override def allocate(n: Int): Array[?] = Array.fill(n)(b) } object ByteType extends FormalType { - override def allocate(n: Int): Array[_] = new Array[Byte](n) + override def allocate(n: Int): Array[?] = new Array[Byte](n) } case class ByteTypeWithDefault(b: Byte) extends FormalType { - override def allocate(n: Int): Array[_] = Array.fill(n)(b) + override def allocate(n: Int): Array[?] = Array.fill(n)(b) } object ShortType extends FormalType { - override def allocate(n: Int): Array[_] = new Array[Short](n) + override def allocate(n: Int): Array[?] = new Array[Short](n) } case class ShortTypeWithDefault(b: Short) extends FormalType { - override def allocate(n: Int): Array[_] = Array.fill(n)(b) + override def allocate(n: Int): Array[?] = Array.fill(n)(b) } object IntType extends FormalType { - override def allocate(n: Int): Array[_] = new Array[Int](n) + override def allocate(n: Int): Array[?] = new Array[Int](n) } case class IntTypeWithDefault(b: Int) extends FormalType { - override def allocate(n: Int): Array[_] = Array.fill(n)(b) + override def allocate(n: Int): Array[?] = Array.fill(n)(b) } object LongType extends FormalType { - override def allocate(n: Int): Array[_] = new Array[Long](n) + override def allocate(n: Int): Array[?] = new Array[Long](n) } case class LongTypeWithDefault(b: Long) extends FormalType { - override def allocate(n: Int): Array[_] = Array.fill(n)(b) + override def allocate(n: Int): Array[?] = Array.fill(n)(b) } object FloatType extends FormalType { - override def allocate(n: Int): Array[_] = new Array[Float](n) + override def allocate(n: Int): Array[?] = new Array[Float](n) } case class FloatTypeWithDefault(b: Float) extends FormalType { - override def allocate(n: Int): Array[_] = Array.fill(n)(b) + override def allocate(n: Int): Array[?] = Array.fill(n)(b) } object DoubleType extends FormalType { - override def allocate(n: Int): Array[_] = new Array[Double](n) + override def allocate(n: Int): Array[?] = new Array[Double](n) } case class DoubleTypeWithDefault(b: Double) extends FormalType { - override def allocate(n: Int): Array[_] = Array.fill(n)(b) + override def allocate(n: Int): Array[?] = Array.fill(n)(b) } object StringType extends FormalType { - override def allocate(n: Int): Array[_] = new Array[String](n) + override def allocate(n: Int): Array[?] = new Array[String](n) } case class StringTypeWithDefault(b: String) extends FormalType { - override def allocate(n: Int): Array[_] = Array.fill(n)(b) + override def allocate(n: Int): Array[?] = Array.fill(n)(b) } object RefType extends FormalType { - override def allocate(n: Int): Array[_] = new Array[GNode](n) + override def allocate(n: Int): Array[?] = new Array[GNode](n) } } @@ -130,7 +130,7 @@ abstract class Schema { // fixme: API will need to change when we add generated edge classes (relevant for edge properties) def makeEdge(src: GNode, dst: GNode, edgeKind: Short, subSeq: Int, property: Any): Edge - def allocateEdgeProperty(nodeKind: Int, direction: Direction, edgeKind: Int, size: Int): Array[_] + def allocateEdgeProperty(nodeKind: Int, direction: Direction, edgeKind: Int, size: Int): Array[?] def getNodePropertyFormalType(nodeKind: Int, propertyKind: Int): FormalQtyType.FormalType def getNodePropertyFormalQuantity(nodeKind: Int, propertyKind: Int): FormalQtyType.FormalQuantity @@ -184,7 +184,7 @@ class FreeSchema( new Edge(src, dst, edgeKind, subSeq, property) override def getNodePropertyFormalType(nodeKind: Int, propertyKind: Int): FormalQtyType.FormalType = nodePropertyTypes(propertyKind) - override def allocateEdgeProperty(nodeKind: Int, direction: Direction, edgeKind: Int, size: Int): Array[_] = + override def allocateEdgeProperty(nodeKind: Int, direction: Direction, edgeKind: Int, size: Int): Array[?] = edgePropertyTypes(edgeKind).allocate(size) override def getNodePropertyFormalQuantity(nodeKind: Int, propertyKind: Int): FormalQtyType.FormalQuantity = diff --git a/core/src/main/scala/flatgraph/help/DocFinder.scala b/core/src/main/scala/flatgraph/help/DocFinder.scala index 7cf328cd..780fd394 100644 --- a/core/src/main/scala/flatgraph/help/DocFinder.scala +++ b/core/src/main/scala/flatgraph/help/DocFinder.scala @@ -1,7 +1,7 @@ package flatgraph.help object DocFinder { - def findDocumentedMethodsOf(clazz: Class[_]): Iterable[StepDoc] = { + def findDocumentedMethodsOf(clazz: Class[?]): Iterable[StepDoc] = { clazz.getMethods.flatMap { method => method.getAnnotations.find(_.isInstanceOf[Doc]).map { case docAnnotation: Doc => StepDoc( diff --git a/core/src/main/scala/flatgraph/help/TraversalHelp.scala b/core/src/main/scala/flatgraph/help/TraversalHelp.scala index 70316660..2aca4668 100644 --- a/core/src/main/scala/flatgraph/help/TraversalHelp.scala +++ b/core/src/main/scala/flatgraph/help/TraversalHelp.scala @@ -22,11 +22,11 @@ import scala.jdk.CollectionConverters.* class TraversalHelp(packageNamesToSearch: DocSearchPackages) { import TraversalHelp._ - def forElementSpecificSteps(elementClass: Class[_], verbose: Boolean)(implicit availableWidthProvider: AvailableWidthProvider): String = { + def forElementSpecificSteps(elementClass: Class[?], verbose: Boolean)(implicit availableWidthProvider: AvailableWidthProvider): String = { val isNode = classOf[GNode].isAssignableFrom(elementClass) val stepDocs = { - def parentTraitsRecursively(clazz: Class[_]): List[Class[_]] = { + def parentTraitsRecursively(clazz: Class[?]): List[Class[?]] = { val parents = clazz.getInterfaces.to(List) parents ++ parents.flatMap(parentTraitsRecursively) } @@ -76,7 +76,7 @@ class TraversalHelp(packageNamesToSearch: DocSearchPackages) { /** Scans the entire classpath for classes annotated with @TraversalExt (using java reflection), to then extract the \@Doc annotations for * all steps, and group them by the elementType (e.g. node.Method). */ - lazy val stepDocsByElementType: Map[Class[_], List[StepDoc]] = { + lazy val stepDocsByElementType: Map[Class[?], List[StepDoc]] = { for { packageName <- packageNamesToSearch() traversal <- findClassesAnnotatedWith(packageName, classOf[help.Traversal]) @@ -88,16 +88,16 @@ class TraversalHelp(packageNamesToSearch: DocSearchPackages) { private def findClassesAnnotatedWith[Annotation <: JAnnotation]( packageName: String, annotationClass: Class[Annotation] - ): Iterator[Class[_]] = + ): Iterator[Class[?]] = new Reflections(packageName).getTypesAnnotatedWith(annotationClass).asScala.iterator lazy val genericStepDocs: Iterable[StepDoc] = - findStepDocs(classOf[flatgraph.traversal.GenericSteps[_]]) + findStepDocs(classOf[flatgraph.traversal.GenericSteps[?]]) lazy val nodeStepDocs: Iterable[StepDoc] = - findStepDocs(classOf[flatgraph.traversal.NodeSteps[_]]) + findStepDocs(classOf[flatgraph.traversal.NodeSteps[?]]) - protected def findStepDocs(traversal: Class[_]): Iterable[StepDoc] = { + protected def findStepDocs(traversal: Class[?]): Iterable[StepDoc] = { DocFinder .findDocumentedMethodsOf(traversal) // scala generates additional `fooBar$extension` methods, but those don't matter in the context of .help/@Doc diff --git a/core/src/main/scala/flatgraph/storage/Deserialization.scala b/core/src/main/scala/flatgraph/storage/Deserialization.scala index 51d2d4ec..a297cd28 100644 --- a/core/src/main/scala/flatgraph/storage/Deserialization.scala +++ b/core/src/main/scala/flatgraph/storage/Deserialization.scala @@ -202,7 +202,7 @@ object Deserialization { a } - private def readArray(channel: FileChannel, ptr: OutlineStorage, nodes: Array[Array[GNode]], stringPool: Array[String]): Array[_] = { + private def readArray(channel: FileChannel, ptr: OutlineStorage, nodes: Array[Array[GNode]], stringPool: Array[String]): Array[?] = { if (ptr == null) return null val dec = Zstd .decompress(channel.map(FileChannel.MapMode.READ_ONLY, ptr.startOffset, ptr.compressedLength), ptr.decompressedLength) diff --git a/core/src/main/scala/flatgraph/storage/Manifest.scala b/core/src/main/scala/flatgraph/storage/Manifest.scala index bf32d4f5..f6fb853d 100644 --- a/core/src/main/scala/flatgraph/storage/Manifest.scala +++ b/core/src/main/scala/flatgraph/storage/Manifest.scala @@ -20,9 +20,9 @@ object Manifest { def write(item: GraphItem): ujson.Value = { val res = ujson.Obj() res(Keys.Version) = 0 - res(Keys.Nodes) = ujson.Arr(item.nodes.map(NodeItem.write): _*) - res(Keys.Edges) = ujson.Arr(item.edges.map(EdgeItem.write): _*) - res(Keys.Properties) = ujson.Arr(item.properties.map(PropertyItem.write): _*) + res(Keys.Nodes) = ujson.Arr(item.nodes.map(NodeItem.write)*) + res(Keys.Edges) = ujson.Arr(item.edges.map(EdgeItem.write)*) + res(Keys.Properties) = ujson.Arr(item.properties.map(PropertyItem.write)*) res(Keys.StringPoolLength) = OutlineStorage.write(item.stringPoolLength) res(Keys.StringPoolBytes) = OutlineStorage.write(item.stringPoolBytes) res @@ -48,7 +48,7 @@ object Manifest { res(Keys.NodeLabel) = item.nodeLabel res(Keys.NNodes) = item.nnodes res(Keys.Deletions) = - if (item.deletions == null || item.deletions.isEmpty) ujson.Null else ujson.Arr(item.deletions.map { seq => ujson.Num(seq) }: _*) + if (item.deletions == null || item.deletions.isEmpty) ujson.Null else ujson.Arr(item.deletions.map { seq => ujson.Num(seq) }*) res } diff --git a/core/src/main/scala/flatgraph/traversal/Language.scala b/core/src/main/scala/flatgraph/traversal/Language.scala index 3b156e7c..2ad5f205 100644 --- a/core/src/main/scala/flatgraph/traversal/Language.scala +++ b/core/src/main/scala/flatgraph/traversal/Language.scala @@ -165,7 +165,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal { /** perform side effect without changing the contents of the traversal */ @Doc(info = "perform side effect without changing the contents of the traversal") - def sideEffect(fun: A => _): Iterator[A] = + def sideEffect(fun: A => ?): Iterator[A] = iterator match { case pathAwareTraversal: PathAwareTraversal[A] => pathAwareTraversal._sideEffect(fun) @@ -179,26 +179,26 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal { * input - analogous to `collect` */ @Doc(info = "perform side effect without changing the contents of the traversal") - def sideEffectPF(pf: PartialFunction[A, _]): Iterator[A] = + def sideEffectPF(pf: PartialFunction[A, ?]): Iterator[A] = sideEffect(pf.lift) /** only preserves elements if the provided traversal has at least one result */ @Doc(info = "only preserves elements if the provided traversal has at least one result") - def where(trav: Iterator[A] => Iterator[_]): Iterator[A] = + def where(trav: Iterator[A] => Iterator[?]): Iterator[A] = iterator.filter { (a: A) => trav(Iterator.single(a)).hasNext } /** only preserves elements if the provided traversal does _not_ have any results */ @Doc(info = "only preserves elements if the provided traversal does _not_ have any results") - def whereNot(trav: Iterator[A] => Iterator[_]): Iterator[A] = + def whereNot(trav: Iterator[A] => Iterator[?]): Iterator[A] = iterator.filter { (a: A) => !trav(Iterator.single(a)).hasNext } /** only preserves elements if the provided traversal does _not_ have any results - alias for whereNot */ @Doc(info = "only preserves elements if the provided traversal does _not_ have any results - alias for whereNot") - def not(trav: Iterator[A] => Iterator[_]): Iterator[A] = + def not(trav: Iterator[A] => Iterator[?]): Iterator[A] = whereNot(trav) /** only preserves elements for which _at least one of_ the given traversals has at least one result Works for arbitrary amount of 'OR' @@ -208,7 +208,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal { * {{{.or(_.label("someLabel"), _.has("someProperty"))}}} */ @Doc(info = "only preserves elements for which _at least one of_ the given traversals has at least one result") - def or(traversals: (Iterator[A] => Iterator[_])*): Iterator[A] = { + def or(traversals: (Iterator[A] => Iterator[?])*): Iterator[A] = { iterator.filter { (a: A) => traversals.exists { trav => trav(Iterator.single(a)).hasNext @@ -223,7 +223,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal { * {{{.and(_.label("someLabel"), _.has("someProperty"))}}} */ @Doc(info = "only preserves elements for which _all of_ the given traversals have at least one result") - def and(traversals: (Iterator[A] => Iterator[_])*): Iterator[A] = { + def and(traversals: (Iterator[A] => Iterator[?])*): Iterator[A] = { iterator.filter { (a: A) => traversals.forall { trav => trav(Iterator.single(a)).hasNext @@ -241,7 +241,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal { @Doc(info = "union/sum/aggregate/join given traversals from the current point") def union[B](traversals: (Iterator[A] => Iterator[B])*): Iterator[B] = iterator match { case pathAwareTraversal: PathAwareTraversal[A] => - pathAwareTraversal._union(traversals: _*) + pathAwareTraversal._union(traversals*) case _ => iterator.flatMap { (a: A) => traversals.flatMap(_.apply(Iterator.single(a))) @@ -289,7 +289,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal { @Doc(info = "evaluates the provided traversals in order and returns the first traversal that emits at least one element") def coalesce[NewEnd](options: (Iterator[A] => Iterator[NewEnd])*): Iterator[NewEnd] = iterator match { case pathAwareTraversal: PathAwareTraversal[A] => - pathAwareTraversal._coalesce(options: _*) + pathAwareTraversal._coalesce(options*) case _ => iterator.flatMap { (a: A) => options.iterator @@ -316,7 +316,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal { } def isPathTracking: Boolean = - iterator.isInstanceOf[PathAwareTraversal[_]] + iterator.isInstanceOf[PathAwareTraversal[?]] /** retrieve entire path that has been traversed thus far prerequisite: enablePathTracking has been called previously * @@ -379,7 +379,7 @@ class GenericSteps[A](iterator: Iterator[A]) extends AnyVal { @Doc(info = "repeat the given traversal") def repeat[B >: A]( repeatTraversal: Iterator[A] => Iterator[B] - )(implicit behaviourBuilder: RepeatBehaviour.Builder[B] => RepeatBehaviour.Builder[B] = RepeatBehaviour.noop[B] _): Iterator[B] = { + )(implicit behaviourBuilder: RepeatBehaviour.Builder[B] => RepeatBehaviour.Builder[B] = RepeatBehaviour.noop[B]): Iterator[B] = { val behaviour = behaviourBuilder(new RepeatBehaviour.Builder[B]).build val _repeatTraversal = repeatTraversal @@ -510,7 +510,7 @@ class NodeSteps[A <: GNode](traversal: Iterator[A]) extends AnyVal { /** alias for {{{label}}} */ def hasLabel(values: String*): Iterator[A] = - label(values: _*) + label(values*) /** filter by the node label (inverse) */ def labelNot(value: String): Iterator[A] = @@ -560,7 +560,7 @@ class NodeSteps[A <: GNode](traversal: Iterator[A]) extends AnyVal { def property[@specialized T](name: String): Iterator[T] = traversal.flatMap(_.propertyOption[T](name)) - def property[@specialized ValueType](propertyKey: PropertyKey[ValueType, _]): Iterator[ValueType] = + def property[@specialized ValueType](propertyKey: PropertyKey[ValueType, ?]): Iterator[ValueType] = propertyKey match { case propertyKey: SinglePropertyKey[_] => property(propertyKey) case propertyKey: OptionalPropertyKey[_] => property(propertyKey) diff --git a/core/src/main/scala/flatgraph/traversal/PathAwareTraversal.scala b/core/src/main/scala/flatgraph/traversal/PathAwareTraversal.scala index 0fc7d9e6..6f02e797 100644 --- a/core/src/main/scala/flatgraph/traversal/PathAwareTraversal.scala +++ b/core/src/main/scala/flatgraph/traversal/PathAwareTraversal.scala @@ -73,7 +73,7 @@ class PathAwareTraversal[A](val wrapped: Iterator[(A, Vector[Any])]) extends Ite .getOrElse(Iterator.empty) }) - private[traversal] def _sideEffect(f: A => _): PathAwareTraversal[A] = new PathAwareTraversal(wrapped.map { case (a, p) => + private[traversal] def _sideEffect(f: A => ?): PathAwareTraversal[A] = new PathAwareTraversal(wrapped.map { case (a, p) => f(a); (a, p) }) diff --git a/core/src/main/scala/flatgraph/traversal/RepeatBehaviour.scala b/core/src/main/scala/flatgraph/traversal/RepeatBehaviour.scala index 40539ef4..26cea413 100644 --- a/core/src/main/scala/flatgraph/traversal/RepeatBehaviour.scala +++ b/core/src/main/scala/flatgraph/traversal/RepeatBehaviour.scala @@ -4,8 +4,8 @@ import RepeatBehaviour._ trait RepeatBehaviour[A] { val searchAlgorithm: SearchAlgorithm.Value - val untilCondition: Option[A => Iterator[_]] - val whileCondition: Option[A => Iterator[_]] + val untilCondition: Option[A => Iterator[?]] + val whileCondition: Option[A => Iterator[?]] val maxDepth: Option[Int] val dedupEnabled: Boolean @@ -39,12 +39,12 @@ object RepeatBehaviour { def noop[A](builder: RepeatBehaviour.Builder[A]): Builder[A] = builder class Builder[A] { - private[this] var _shouldEmit: (A, Int) => Boolean = (_, _) => false - private[this] var _untilCondition: Option[Traversal[A] => Traversal[_]] = None - private[this] var _whileCondition: Option[Traversal[A] => Traversal[_]] = None - private[this] var _maxDepth: Option[Int] = None - private[this] var _dedupEnabled: Boolean = false - private[this] var _searchAlgorithm: SearchAlgorithm.Value = SearchAlgorithm.DepthFirst + private var _shouldEmit: (A, Int) => Boolean = (_, _) => false + private var _untilCondition: Option[Traversal[A] => Traversal[?]] = None + private var _whileCondition: Option[Traversal[A] => Traversal[?]] = None + private var _maxDepth: Option[Int] = None + private var _dedupEnabled: Boolean = false + private var _searchAlgorithm: SearchAlgorithm.Value = SearchAlgorithm.DepthFirst /** configure search algorithm to go "breadth first", rather than the default "depth first" */ def breadthFirstSearch: Builder[A] = { @@ -70,14 +70,14 @@ object RepeatBehaviour { /** Emit intermediate elements (along the way), if they meet the given condition. Note that this does not apply a filter on the final * elements of the traversal. */ - def emit(condition: Traversal[A] => Traversal[_]): Builder[A] = { + def emit(condition: Traversal[A] => Traversal[?]): Builder[A] = { _shouldEmit = (element, _) => condition(Iterator.single(element)).hasNext this } /* Configure `repeat` step to stop traversing when given condition-traversal has at least one result. * The condition-traversal is only evaluated _after_ the first iteration, for classic repeat/until behaviour */ - def until(condition: Traversal[A] => Traversal[_]): Builder[A] = { + def until(condition: Traversal[A] => Traversal[?]): Builder[A] = { _untilCondition = Some(condition) this } @@ -87,7 +87,7 @@ object RepeatBehaviour { * * n.b. the only reason not to call this `while` is to avoid using scala keywords, which would need to be quoted. */ - def whilst(condition: Traversal[A] => Traversal[_]): Builder[A] = { + def whilst(condition: Traversal[A] => Traversal[?]): Builder[A] = { _whileCondition = Some(condition) this } diff --git a/domain-classes-generator/src/main/scala/flatgraph/codegen/Helpers.scala b/domain-classes-generator/src/main/scala/flatgraph/codegen/Helpers.scala index 8a761029..1ec34f8f 100644 --- a/domain-classes-generator/src/main/scala/flatgraph/codegen/Helpers.scala +++ b/domain-classes-generator/src/main/scala/flatgraph/codegen/Helpers.scala @@ -68,7 +68,7 @@ object Helpers { def snakeCase(camelCase: String): String = flatgraph.schema.Helpers.snakeCase(camelCase) - def getCompleteType[A](property: Property[_]): String = + def getCompleteType[A](property: Property[?]): String = getCompleteType(property.cardinality, typeFor(property)) def typeFor(containedNode: ContainedNode): String = { @@ -126,7 +126,7 @@ object Helpers { } } - def propertyDefaultValueImpl(propertyDefaultsPath: String, properties: Seq[Property[_]]): String = { + def propertyDefaultValueImpl(propertyDefaultsPath: String, properties: Seq[Property[?]]): String = { val propertyDefaultValueCases = properties .collect { case property if property.hasDefault => @@ -142,7 +142,7 @@ object Helpers { |""".stripMargin } - def propertyDefaultCases(properties: Seq[Property[_]]): String = { + def propertyDefaultCases(properties: Seq[Property[?]]): String = { properties .collect { case p if p.hasDefault => @@ -151,7 +151,7 @@ object Helpers { .mkString(s"$lineSeparator| ") } - def propertyAccessors(properties: Seq[Property[_]]): String = { + def propertyAccessors(properties: Seq[Property[?]]): String = { properties .map { property => val camelCaseName = camelCase(property.name) diff --git a/domain-classes-generator/src/main/scala/flatgraph/codegen/ProtoGen.scala b/domain-classes-generator/src/main/scala/flatgraph/codegen/ProtoGen.scala index a38f8ed8..bb747607 100644 --- a/domain-classes-generator/src/main/scala/flatgraph/codegen/ProtoGen.scala +++ b/domain-classes-generator/src/main/scala/flatgraph/codegen/ProtoGen.scala @@ -231,10 +231,10 @@ class ProtoGen(schema: Schema) { .mkString("\n") } - private def enumEntryMaybe(constant: Constant[_]): EnumEntryMaybe = + private def enumEntryMaybe(constant: Constant[?]): EnumEntryMaybe = EnumEntryMaybe(constant.protoId, constant.name, constant.comment) - private def enumEntryMaybe(property: Property[_]): EnumEntryMaybe = + private def enumEntryMaybe(property: Property[?]): EnumEntryMaybe = EnumEntryMaybe(property.protoId, property.name, property.comment) private def enumEntryMaybe(nodeType: NodeType): EnumEntryMaybe = diff --git a/domain-classes-generator/src/main/scala/flatgraph/schema/Schema.scala b/domain-classes-generator/src/main/scala/flatgraph/schema/Schema.scala index 9266bb1d..56b085af 100644 --- a/domain-classes-generator/src/main/scala/flatgraph/schema/Schema.scala +++ b/domain-classes-generator/src/main/scala/flatgraph/schema/Schema.scala @@ -14,14 +14,14 @@ class Schema( val domainShortName: String, val basePackage: String, val additionalTraversalsPackages: Seq[String], - val properties: Seq[Property[_]], + val properties: Seq[Property[?]], val anyNode: AnyNodeType, val nodeBaseTypes: Seq[NodeBaseType], val nodeTypes: Seq[NodeType], val edgeTypes: Seq[EdgeType], - val constantsByCategory: Map[String, Seq[Constant[_]]], + val constantsByCategory: Map[String, Seq[Constant[?]]], val protoOptions: Option[ProtoOptions], - val noWarnList: Set[(AbstractNodeType, Property[_])] + val noWarnList: Set[(AbstractNodeType, Property[?])] ) { /** nodeTypes and nodeBaseTypes combined */ @@ -29,11 +29,11 @@ class Schema( nodeTypes ++ nodeBaseTypes /** properties that are used in node types */ - def nodeProperties: Seq[Property[_]] = + def nodeProperties: Seq[Property[?]] = properties.filter(property => (nodeTypes ++ nodeBaseTypes).exists(_.properties.contains(property))) /** properties that are used in edge types */ - def edgeProperties: Seq[Property[_]] = + def edgeProperties: Seq[Property[?]] = properties.filter(property => edgeTypes.exists(_.properties.contains(property))) } @@ -59,12 +59,12 @@ abstract class AbstractNodeType(val name: String, val comment: Option[String], v def withoutStarter(): this.type = starterName(null) /** properties (including potentially inherited properties) */ - override def properties: Seq[Property[_]] = { + override def properties: Seq[Property[?]] = { val entireClassHierarchy = this +: extendzRecursively entireClassHierarchy.flatMap(_.propertiesWithoutInheritance).distinct.sortBy(_.name.toLowerCase) } - def propertiesWithoutInheritance: Seq[Property[_]] = + def propertiesWithoutInheritance: Seq[Property[?]] = _properties.toSeq.sortBy(_.name.toLowerCase) def extendz(additional: NodeBaseType*): this.type = { @@ -144,14 +144,14 @@ class NodeType(name: String, comment: Option[String], schemaInfo: SchemaInfo) with HasOptionalProtoId { protected val _containedNodes: mutable.Set[ContainedNode] = mutable.Set.empty - private var _primaryKey: Option[Property[_]] = None + private var _primaryKey: Option[Property[?]] = None - def primaryKey(p: Property[_]): this.type = { + def primaryKey(p: Property[?]): this.type = { this._primaryKey = Option(p) this } - def primaryKey: Option[Property[_]] = this._primaryKey + def primaryKey: Option[Property[?]] = this._primaryKey lazy val classNameDb = s"${className}Db" @@ -219,7 +219,7 @@ class EdgeType(val name: String, val comment: Option[String], val schemaInfo: Sc override def toString = s"EdgeType($name)" /** properties (including potentially inherited properties) */ - def properties: Seq[Property[_]] = + def properties: Seq[Property[?]] = _properties.toSeq.sortBy(_.name.toLowerCase) } @@ -247,7 +247,7 @@ class Property[A](val name: String, val valueType: Property.ValueType[A], val co } def isMandatory: Boolean = - cardinality.isInstanceOf[Cardinality.One[_]] + cardinality.isInstanceOf[Cardinality.One[?]] def hasDefault: Boolean = default.isDefined @@ -280,7 +280,7 @@ object Property { object Long extends ValueType[Long] object Float extends ValueType[Float] object Double extends ValueType[Double] - object List extends ValueType[Seq[_]] + object List extends ValueType[Seq[?]] object Char extends ValueType[Char] object NodeRef extends ValueType[Any] object Unknown extends ValueType[Any] @@ -365,20 +365,20 @@ trait HasClassName { } trait HasProperties { - protected val _properties: mutable.Set[Property[_]] = mutable.Set.empty + protected val _properties: mutable.Set[Property[?]] = mutable.Set.empty - def addProperty(additional: Property[_]): this.type = { + def addProperty(additional: Property[?]): this.type = { _properties.add(additional) this } - def addProperties(additional: Property[_]*): this.type = { + def addProperties(additional: Property[?]*): this.type = { additional.foreach(addProperty) this } /** properties (including potentially inherited properties) */ - def properties: Seq[Property[_]] + def properties: Seq[Property[?]] } trait HasOptionalProtoId { @@ -399,10 +399,10 @@ trait HasSchemaInfo { /** carry extra information on where a schema element is being defined, e.g. when we want to be able to refer back that `node XYZ` was * defined in `BaseSchema`, e.g. for documentation */ -case class SchemaInfo(definedIn: Option[Class[_]]) +case class SchemaInfo(definedIn: Option[Class[?]]) object SchemaInfo { val Unknown = SchemaInfo(None) - def forClass(schemaClass: Class[_]): SchemaInfo = + def forClass(schemaClass: Class[?]): SchemaInfo = SchemaInfo(Option(schemaClass)) } diff --git a/domain-classes-generator/src/main/scala/flatgraph/schema/SchemaBuilder.scala b/domain-classes-generator/src/main/scala/flatgraph/schema/SchemaBuilder.scala index f89fc69f..89ee854f 100644 --- a/domain-classes-generator/src/main/scala/flatgraph/schema/SchemaBuilder.scala +++ b/domain-classes-generator/src/main/scala/flatgraph/schema/SchemaBuilder.scala @@ -6,13 +6,13 @@ import flatgraph.schema.Property.ValueType import scala.collection.mutable class SchemaBuilder(domainShortName: String, basePackage: String, additionalTraversalsPackages: Seq[String] = Seq.empty) { - val properties = mutable.ListBuffer.empty[Property[_]] + val properties = mutable.ListBuffer.empty[Property[?]] val nodeBaseTypes = mutable.ListBuffer.empty[NodeBaseType] val nodeTypes = mutable.ListBuffer.empty[NodeType] val edgeTypes = mutable.ListBuffer.empty[EdgeType] - val constantsByCategory = mutable.Map.empty[String, Seq[Constant[_]]] + val constantsByCategory = mutable.Map.empty[String, Seq[Constant[?]]] var protoOptions: Option[ProtoOptions] = None - val noWarnList: mutable.Set[(AbstractNodeType, Property[_])] = mutable.Set.empty + val noWarnList: mutable.Set[(AbstractNodeType, Property[?])] = mutable.Set.empty /** root node trait for all nodes - use if you want to be explicitly unspecific */ lazy val anyNode: AnyNodeType = new AnyNodeType @@ -34,7 +34,7 @@ class SchemaBuilder(domainShortName: String, basePackage: String, additionalTrav def addNodeType(name: String, comment: String = "")(implicit schemaInfo: SchemaInfo = SchemaInfo.Unknown): NodeType = addAndReturn(nodeTypes, new NodeType(name, stringToOption(comment), schemaInfo)) - def addConstants(category: String, constants: Constant[_]*): Seq[Constant[_]] = { + def addConstants(category: String, constants: Constant[?]*): Seq[Constant[?]] = { val previousEntries = constantsByCategory.getOrElse(category, Seq.empty) constantsByCategory.put(category, previousEntries ++ constants) constants @@ -45,7 +45,7 @@ class SchemaBuilder(domainShortName: String, basePackage: String, additionalTrav this } - def dontWarnForDuplicateProperty(nodeType: AbstractNodeType, property: Property[_]): SchemaBuilder = { + def dontWarnForDuplicateProperty(nodeType: AbstractNodeType, property: Property[?]): SchemaBuilder = { noWarnList.add((nodeType, property)) this } diff --git a/formats/src/main/scala/flatgraph/formats/graphml/package.scala b/formats/src/main/scala/flatgraph/formats/graphml/package.scala index b54b004e..2d206e48 100644 --- a/formats/src/main/scala/flatgraph/formats/graphml/package.scala +++ b/formats/src/main/scala/flatgraph/formats/graphml/package.scala @@ -13,7 +13,7 @@ package object graphml { val Double = Value("double") val String = Value("string") - def fromRuntimeClass(clazz: Class[_]): Type.Value = { + def fromRuntimeClass(clazz: Class[?]): Type.Value = { if (clazz == classOf[Boolean] || clazz == classOf[java.lang.Boolean]) Type.Boolean else if (clazz == classOf[Int] || clazz == classOf[Integer]) diff --git a/formats/src/main/scala/flatgraph/formats/graphson/GraphSONProtocol.scala b/formats/src/main/scala/flatgraph/formats/graphson/GraphSONProtocol.scala index ff6aa6a2..99f79d69 100644 --- a/formats/src/main/scala/flatgraph/formats/graphson/GraphSONProtocol.scala +++ b/formats/src/main/scala/flatgraph/formats/graphson/GraphSONProtocol.scala @@ -24,7 +24,7 @@ object GraphSONProtocol extends DefaultJsonProtocol { } } - def read(value: JsValue): PropertyValue with Product = { + def read(value: JsValue): PropertyValue & Product = { value match { case JsString(v) => return StringValue(v) case JsBoolean(v) => return BooleanValue(v) @@ -37,7 +37,7 @@ object GraphSONProtocol extends DefaultJsonProtocol { } } - def readNonList(value: Seq[_]): PropertyValue with Product = value match { + def readNonList(value: Seq[?]): PropertyValue & Product = value match { case Seq(JsNumber(v), JsString(typ)) => if (typ.equals(Type.Long.typ)) LongValue(v.toLongExact) else if (typ.equals(Type.Int.typ)) IntValue(v.toIntExact) @@ -52,7 +52,7 @@ object GraphSONProtocol extends DefaultJsonProtocol { implicit object LongValueFormat extends RootJsonFormat[LongValue] { def write(c: LongValue): JsValue = PropertyValueJsonFormat.write(c) - def read(value: JsValue): LongValue with Product = + def read(value: JsValue): LongValue & Product = value.asJsObject.getFields("@value", "@type") match { case Seq(JsNumber(v), JsString(typ)) if typ.equals(Type.Long.typ) => LongValue(v.toLongExact) diff --git a/formats/src/main/scala/flatgraph/formats/graphson/package.scala b/formats/src/main/scala/flatgraph/formats/graphson/package.scala index b5a69dd6..560d37bb 100644 --- a/formats/src/main/scala/flatgraph/formats/graphson/package.scala +++ b/formats/src/main/scala/flatgraph/formats/graphson/package.scala @@ -17,7 +17,7 @@ package object graphson { val List = GraphSONVal(7, "g:List") val NodeId = GraphSONVal(8, "g:VertexId") - def fromRuntimeClass(clazz: Class[_]): Type.Value = { + def fromRuntimeClass(clazz: Class[?]): Type.Value = { if (clazz == classOf[Boolean] || clazz == classOf[java.lang.Boolean]) Type.Boolean else if (clazz == classOf[Int] || clazz == classOf[Integer]) @@ -30,7 +30,7 @@ package object graphson { Type.Double else if (clazz == classOf[String]) Type.String - else if (clazz == classOf[List[_]]) + else if (clazz == classOf[List[?]]) Type.List else throw new AssertionError(s"unsupported runtime class `$clazz` - only ${Type.values.mkString("|")} are supported...}") diff --git a/formats/src/main/scala/flatgraph/formats/neo4jcsv/ColumnDefinitions.scala b/formats/src/main/scala/flatgraph/formats/neo4jcsv/ColumnDefinitions.scala index d67621b4..de5364c2 100644 --- a/formats/src/main/scala/flatgraph/formats/neo4jcsv/ColumnDefinitions.scala +++ b/formats/src/main/scala/flatgraph/formats/neo4jcsv/ColumnDefinitions.scala @@ -8,7 +8,7 @@ import scala.jdk.CollectionConverters.IterableHasAsScala sealed trait ColumnDef case class ScalarColumnDef(valueType: ColumnType.Value) extends ColumnDef -case class ArrayColumnDef(valueType: Option[ColumnType.Value], iteratorAccessor: Any => Iterable[_]) extends ColumnDef +case class ArrayColumnDef(valueType: Option[ColumnType.Value], iteratorAccessor: Any => Iterable[?]) extends ColumnDef class ColumnDefinitions(propertyNames: Iterable[String]) { private val propertyNamesOrdered = propertyNames.toSeq.sorted @@ -48,7 +48,7 @@ class ColumnDefinitions(propertyNames: Iterable[String]) { /** for data file updates our internal `_columnDefByPropertyName` model with type information based on runtime values, so that we later * have all metadata required for the header file */ - def propertyValues(byNameAccessor: String => Option[_]): Seq[String] = { + def propertyValues(byNameAccessor: String => Option[?]): Seq[String] = { propertyNamesOrdered.map { propertyName => byNameAccessor(propertyName) match { case None => @@ -134,7 +134,7 @@ class ColumnDefinitions(propertyNames: Iterable[String]) { * same property */ private def deriveNeo4jType(value: Any): ColumnDef = { - def deriveNeo4jTypeForArray(iteratorAccessor: Any => Iterable[_]): ArrayColumnDef = { + def deriveNeo4jTypeForArray(iteratorAccessor: Any => Iterable[?]): ArrayColumnDef = { // Iterable is immutable, so we can safely (try to) get it's first element val valueTypeMaybe = iteratorAccessor(value).iterator .nextOption() @@ -145,19 +145,19 @@ class ColumnDefinitions(propertyNames: Iterable[String]) { value match { case _: Iterable[_] => - deriveNeo4jTypeForArray(_.asInstanceOf[Iterable[_]]) + deriveNeo4jTypeForArray(_.asInstanceOf[Iterable[?]]) case _: IterableOnce[_] => - deriveNeo4jTypeForArray(_.asInstanceOf[IterableOnce[_]].iterator.toSeq) + deriveNeo4jTypeForArray(_.asInstanceOf[IterableOnce[?]].iterator.toSeq) case _: java.lang.Iterable[_] => - deriveNeo4jTypeForArray(_.asInstanceOf[java.lang.Iterable[_]].asScala) + deriveNeo4jTypeForArray(_.asInstanceOf[java.lang.Iterable[?]].asScala) case _: Array[_] => - deriveNeo4jTypeForArray(x => ArraySeq.unsafeWrapArray(x.asInstanceOf[Array[_]])) + deriveNeo4jTypeForArray(x => ArraySeq.unsafeWrapArray(x.asInstanceOf[Array[?]])) case scalarValue => ScalarColumnDef(deriveNeo4jTypeForScalarValue(scalarValue.getClass)) } } - private def deriveNeo4jTypeForScalarValue(clazz: Class[_]): ColumnType.Value = { + private def deriveNeo4jTypeForScalarValue(clazz: Class[?]): ColumnType.Value = { if (clazz == classOf[String]) ColumnType.String else if (clazz == classOf[Int] || clazz == classOf[Integer]) diff --git a/formats/src/main/scala/flatgraph/formats/neo4jcsv/Neo4jCsvImporter.scala b/formats/src/main/scala/flatgraph/formats/neo4jcsv/Neo4jCsvImporter.scala index 1292ff06..4c3b1dc9 100644 --- a/formats/src/main/scala/flatgraph/formats/neo4jcsv/Neo4jCsvImporter.scala +++ b/formats/src/main/scala/flatgraph/formats/neo4jcsv/Neo4jCsvImporter.scala @@ -114,7 +114,7 @@ object Neo4jCsvImporter extends Importer { case s if s.endsWith(ColumnType.EndId.toString) => ColumnDef(None, ColumnType.EndId) case propertyDef if propertyDef.contains(":") => - val name :: valueTpe0 :: Nil = propertyDef.split(':').toList + val name :: valueTpe0 :: Nil = propertyDef.split(':').toList: @unchecked val isArray = propertyDef.endsWith(ColumnType.ArrayMarker) // from the docs: "To define an array type, append [] to the type" val valueTpe = if (isArray) valueTpe0.dropRight(2) @@ -222,7 +222,7 @@ object Neo4jCsvImporter extends Importer { } private def parseEntry(rawValue: String, columnDef: ColumnDef, inputFile: Path, lineNo: Int)( - handleColumn: PartialFunction[ColumnDef, _] + handleColumn: PartialFunction[ColumnDef, ?] ): Unit = { try { handleColumn.applyOrElse( diff --git a/formats/src/main/scala/flatgraph/formats/package.scala b/formats/src/main/scala/flatgraph/formats/package.scala index 406f05ca..33d2b531 100644 --- a/formats/src/main/scala/flatgraph/formats/package.scala +++ b/formats/src/main/scala/flatgraph/formats/package.scala @@ -19,13 +19,13 @@ package object formats { /** @return * true if the given class is either array or a (subclass of) Java Iterable or Scala IterableOnce */ - def isList(clazz: Class[_]): Boolean = { + def isList(clazz: Class[?]): Boolean = { clazz.isArray || - classOf[java.lang.Iterable[_]].isAssignableFrom(clazz) || - classOf[IterableOnce[_]].isAssignableFrom(clazz) + classOf[java.lang.Iterable[?]].isAssignableFrom(clazz) || + classOf[IterableOnce[?]].isAssignableFrom(clazz) } - val iterableForList: PartialFunction[Any, Iterable[_]] = { + val iterableForList: PartialFunction[Any, Iterable[?]] = { case it: Iterable[_] => it case it: IterableOnce[_] => it.iterator.toSeq case it: java.lang.Iterable[_] => it.asScala diff --git a/odb-convert/src/main/scala/flatgraph/convert/Convert.scala b/odb-convert/src/main/scala/flatgraph/convert/Convert.scala index bd51173a..dee17981 100644 --- a/odb-convert/src/main/scala/flatgraph/convert/Convert.scala +++ b/odb-convert/src/main/scala/flatgraph/convert/Convert.scala @@ -152,7 +152,7 @@ object Convert { } finally { fileChannel.close() } } - private def homogenize(items: mutable.ArrayBuffer[Any]): (String, Array[_]) = { + private def homogenize(items: mutable.ArrayBuffer[Any]): (String, Array[?]) = { items.find { _ != null } match { case None => (null, null) case Some(_: Boolean) => (storage.StorageType.Bool, items.asInstanceOf[mutable.ArrayBuffer[Boolean]].toArray)