Skip to content

Commit

Permalink
Adding testing
Browse files Browse the repository at this point in the history
  • Loading branch information
michelchan committed Oct 3, 2024
1 parent 3ccc0c3 commit 3dd9912
Show file tree
Hide file tree
Showing 5 changed files with 496 additions and 607 deletions.
55 changes: 55 additions & 0 deletions morphir/src/org/finos/morphir/ir/gen1/naming.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.finos.morphir.ir.gen1

object naming extends Names {

final implicit class PackageNameSyntax(val self: PackageName) extends AnyVal {
def /(moduleName: ModuleName): QualifiedModuleName = QualifiedModuleName(self, moduleName)
}

final implicit class QualifiedModuleNameSyntax(val self: QualifiedModuleName) extends AnyVal {
def %(localName: String): FQName = FQName(self.packageName, self.modulePath, Name.fromString(localName))
def %(name: Name): FQName = FQName(self.packageName, self.modulePath, name)
}

final implicit class NamingHelper(val sc: StringContext) extends AnyVal {

def fqn(args: Any*): FQName = {
val interlaced = interlace(sc.parts, args.map(_.toString))
FQName.fromString(interlaced.mkString)
}

def mod(args: Any*): ModuleName = {
val interlaced = interlace(sc.parts, args.map(_.toString))
ModuleName.fromString(interlaced.mkString)
}

def n(args: Any*): Name = {
val interlaced = interlace(sc.parts, args.map(_.toString))
Name.fromString(interlaced.mkString)
}

def qmn(args: Any*): QualifiedModuleName = {
val interlaced = interlace(sc.parts, args.map(_.toString))
QualifiedModuleName.fromString(interlaced.mkString)
}

def name(args: Any*): Name = {
val interlaced = interlace(sc.parts, args.map(_.toString))
Name.fromString(interlaced.mkString)
}

def pkg(args: Any*): PackageName = {
val interlaced = interlace(sc.parts, args.map(_.toString))
PackageName.fromString(interlaced.mkString)
}

def path(args: Any*): Path = {
val interlaced = interlace(sc.parts, args.map(_.toString))
Path.fromString(interlaced.mkString)
}
}

private[morphir] def interlace[T](a: Iterable[T], b: Iterable[T]): List[T] =
if (a.isEmpty) b.toList
else a.head +: interlace(b, a.tail)
}
Loading

0 comments on commit 3dd9912

Please sign in to comment.