-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Moving everything to top level * Changing to neotype * Changing to neotype * Changing to neotype
- Loading branch information
1 parent
c43f442
commit f44048e
Showing
17 changed files
with
527 additions
and
591 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
11 changes: 4 additions & 7 deletions
11
morphir/src/org/finos/morphir/ir/gen1/NamingOptionsModule.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
package org.finos.morphir.ir.gen1 | ||
|
||
trait NamingOptionsModule { self: PackageNameModule with ModuleNameModule => | ||
sealed case class FQNamingOptions(defaultPackage: PackageName, defaultModule: ModuleName, defaultSeparator: String) | ||
|
||
sealed case class FQNamingOptions(defaultPackage: PackageName, defaultModule: ModuleName, defaultSeparator: String) | ||
|
||
object FQNamingOptions { | ||
implicit val default: FQNamingOptions = | ||
FQNamingOptions(PackageName.empty, ModuleName.empty, ":") | ||
} | ||
object FQNamingOptions { | ||
implicit val default: FQNamingOptions = | ||
FQNamingOptions(PackageName.empty, ModuleName.empty, ":") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
morphir/src/org/finos/morphir/ir/gen1/TypeMapReferenceName.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,99 @@ | ||
package org.finos.morphir.ir.gen1 | ||
|
||
trait FQNameModule { | ||
self: NameModule with ModuleNameModule with NamespaceModule with PackageNameModule with PathModule | ||
with QualifiedModuleNameModule | ||
with QNameModule | ||
with NamingOptionsModule => | ||
|
||
sealed case class FQName(packagePath: PackageName, modulePath: ModuleName, localName: Name) { self => | ||
def getPackagePath: Path = packagePath.toPath | ||
|
||
def getModulePath: Path = modulePath.toPath | ||
def getModuleName: ModuleName = modulePath | ||
|
||
/// An alias for `packagePath` | ||
def pack: PackageName = packagePath | ||
|
||
def toReferenceName: String = Seq( | ||
Path.toString(Name.toTitleCase, ".", packagePath.toPath), | ||
Path.toString(Name.toTitleCase, ".", modulePath.toPath), | ||
localName.toTitleCase | ||
).mkString(".") | ||
|
||
override def toString: String = Array( | ||
Path.toString(Name.toTitleCase, ".", packagePath.toPath), | ||
Path.toString(Name.toTitleCase, ".", modulePath.toPath), | ||
Name.toCamelCase(localName) | ||
).mkString(":") | ||
|
||
def toStringTitleCase: String = Array( | ||
Path.toString(Name.toTitleCase, ".", packagePath.toPath), | ||
Path.toString(Name.toTitleCase, ".", modulePath.toPath), | ||
Name.toTitleCase(this.localName) | ||
).mkString(":") | ||
} | ||
sealed case class FQName(packagePath: PackageName, modulePath: ModuleName, localName: Name) { self => | ||
def getPackagePath: Path = packagePath.toPath | ||
|
||
def getModulePath: Path = modulePath.toPath | ||
def getModuleName: ModuleName = modulePath | ||
|
||
/// An alias for `packagePath` | ||
def pack: PackageName = packagePath | ||
|
||
def toReferenceName: String = Seq( | ||
Path.toString(Name.toTitleCase, ".", packagePath.toPath), | ||
Path.toString(Name.toTitleCase, ".", modulePath.toPath), | ||
localName.toTitleCase | ||
).mkString(".") | ||
|
||
override def toString: String = Array( | ||
Path.toString(Name.toTitleCase, ".", packagePath.toPath), | ||
Path.toString(Name.toTitleCase, ".", modulePath.toPath), | ||
Name.toCamelCase(localName) | ||
).mkString(":") | ||
|
||
def toStringTitleCase: String = Array( | ||
Path.toString(Name.toTitleCase, ".", packagePath.toPath), | ||
Path.toString(Name.toTitleCase, ".", modulePath.toPath), | ||
Name.toTitleCase(this.localName) | ||
).mkString(":") | ||
} | ||
|
||
object FQName { | ||
val empty: FQName = FQName(PackageName.empty, ModuleName.empty, Name.empty) | ||
// def apply(packagePath: Path, modulePath: Path, localName: Name): FQName = | ||
// FQName(PackageName(packagePath), ModulePath(modulePath), localName) | ||
object FQName { | ||
val empty: FQName = FQName(PackageName.empty, ModuleName.empty, Name.empty) | ||
// def apply(packagePath: Path, modulePath: Path, localName: Name): FQName = | ||
// FQName(PackageName(packagePath), ModulePath(modulePath), localName) | ||
|
||
val fqName: Path => Path => Name => FQName = packagePath => | ||
modulePath => localName => FQName(PackageName.fromPath(packagePath), ModuleName(modulePath), localName) | ||
val fqName: Path => Path => Name => FQName = packagePath => | ||
modulePath => localName => FQName(PackageName.fromPath(packagePath), ModuleName(modulePath), localName) | ||
|
||
def fromQName(packagePath: Path, qName: QName): FQName = | ||
FQName(PackageName.fromPath(packagePath), ModuleName(qName.modulePath), qName.localName) | ||
def fromQName(packagePath: Path, qName: QName): FQName = | ||
FQName(PackageName.fromPath(packagePath), ModuleName(qName.modulePath), qName.localName) | ||
|
||
def fromQName(qName: QName)(implicit packageName: PackageName): FQName = | ||
FQName(packageName, ModuleName(qName.modulePath), qName.localName) | ||
def fromQName(qName: QName)(implicit packageName: PackageName): FQName = | ||
FQName(packageName, ModuleName(qName.modulePath), qName.localName) | ||
|
||
def fromQName(qName: QName)(implicit options: FQNamingOptions): FQName = | ||
FQName(options.defaultPackage, ModuleName(QName.getModulePath(qName)), QName.getLocalName(qName)) | ||
def fromQName(qName: QName)(implicit options: FQNamingOptions): FQName = | ||
FQName(options.defaultPackage, ModuleName(QName.getModulePath(qName)), QName.getLocalName(qName)) | ||
|
||
/** Get the package path part of a fully-qualified name. */ | ||
def getPackagePath(fqName: FQName): Path = fqName.getPackagePath | ||
/** Get the package path part of a fully-qualified name. */ | ||
def getPackagePath(fqName: FQName): Path = fqName.getPackagePath | ||
|
||
/** Get the module path part of a fully-qualified name */ | ||
def getModulePath(fqName: FQName): Path = fqName.getModulePath | ||
/** Get the module path part of a fully-qualified name */ | ||
def getModulePath(fqName: FQName): Path = fqName.getModulePath | ||
|
||
/** Get the local name part of a fully-qualified name */ | ||
def getLocalName(fqName: FQName): Name = fqName.localName | ||
/** Get the local name part of a fully-qualified name */ | ||
def getLocalName(fqName: FQName): Name = fqName.localName | ||
|
||
/** Convenience function to create a fully-qualified name from 3 strings */ | ||
def fqn(packageName: String, moduleName: String, localName: String): FQName = | ||
FQName(PackageName.fromString(packageName), ModuleName.fromString(moduleName), Name.fromString(localName)) | ||
/** Convenience function to create a fully-qualified name from 3 strings */ | ||
def fqn(packageName: String, moduleName: String, localName: String): FQName = | ||
FQName(PackageName.fromString(packageName), ModuleName.fromString(moduleName), Name.fromString(localName)) | ||
|
||
/** Convenience function to create a fully-qualified name from 2 strings with default package name */ | ||
def fqn(moduleName: String, localName: String)(implicit options: FQNamingOptions): FQName = | ||
FQName(options.defaultPackage, ModuleName(Path.fromString(moduleName)), Name.fromString(localName)) | ||
/** Convenience function to create a fully-qualified name from 2 strings with default package name */ | ||
def fqn(moduleName: String, localName: String)(implicit options: FQNamingOptions): FQName = | ||
FQName(options.defaultPackage, ModuleName(Path.fromString(moduleName)), Name.fromString(localName)) | ||
|
||
/** Convenience function to create a fully-qualified name from 1 string with defaults for package and module */ | ||
def fqn(localName: String)(implicit options: FQNamingOptions): FQName = | ||
FQName(options.defaultPackage, options.defaultModule, Name.fromString(localName)) | ||
/** Convenience function to create a fully-qualified name from 1 string with defaults for package and module */ | ||
def fqn(localName: String)(implicit options: FQNamingOptions): FQName = | ||
FQName(options.defaultPackage, options.defaultModule, Name.fromString(localName)) | ||
|
||
/// Convenience function to create a fully-qualified name from a local name and an implicitly provided `QualifiedModuleName`. | ||
def fromLocalName(localName: String)(implicit qualifiedModuleName: QualifiedModuleName): FQName = | ||
FQName(qualifiedModuleName.packageName, qualifiedModuleName.modulePath, Name.fromString(localName)) | ||
/// Convenience function to create a fully-qualified name from a local name and an implicitly provided `QualifiedModuleName`. | ||
def fromLocalName(localName: String)(implicit qualifiedModuleName: QualifiedModuleName): FQName = | ||
FQName(qualifiedModuleName.packageName, qualifiedModuleName.modulePath, Name.fromString(localName)) | ||
|
||
def fromLocalName(localName: Name)(implicit qualifiedModuleName: QualifiedModuleName): FQName = | ||
FQName(qualifiedModuleName.packageName, qualifiedModuleName.modulePath, localName) | ||
def fromLocalName(localName: Name)(implicit qualifiedModuleName: QualifiedModuleName): FQName = | ||
FQName(qualifiedModuleName.packageName, qualifiedModuleName.modulePath, localName) | ||
|
||
def toString(fqName: FQName): String = fqName.toString | ||
def toString(fqName: FQName): String = fqName.toString | ||
|
||
/** Parse a string into a FQName using splitter as the separator between package, module, and local names */ | ||
def fromString(fqNameString: String, splitter: String)(implicit options: FQNamingOptions): FQName = | ||
fqNameString.split(splitter) match { | ||
case Array(packageNameString, moduleNameString, localNameString) => | ||
fqn(packageNameString, moduleNameString, localNameString) | ||
case Array(moduleNameString, localNameString) => | ||
fqn(moduleNameString, localNameString) | ||
case Array(localNameString) => | ||
fqn(localNameString) | ||
case _ => throw FQNameParsingError(fqNameString) | ||
} | ||
/** Parse a string into a FQName using splitter as the separator between package, module, and local names */ | ||
def fromString(fqNameString: String, splitter: String)(implicit options: FQNamingOptions): FQName = | ||
fqNameString.split(splitter) match { | ||
case Array(packageNameString, moduleNameString, localNameString) => | ||
fqn(packageNameString, moduleNameString, localNameString) | ||
case Array(moduleNameString, localNameString) => | ||
fqn(moduleNameString, localNameString) | ||
case Array(localNameString) => | ||
fqn(localNameString) | ||
case _ => throw FQNameParsingError(fqNameString) | ||
} | ||
|
||
def fromString(fqNameString: String)(implicit options: FQNamingOptions): FQName = | ||
fromString(fqNameString, options.defaultSeparator) | ||
def fromString(fqNameString: String)(implicit options: FQNamingOptions): FQName = | ||
fromString(fqNameString, options.defaultSeparator) | ||
|
||
object ReferenceName { | ||
def unapply(fqName: FQName): Some[String] = Some(fqName.toReferenceName) | ||
} | ||
object ReferenceName { | ||
def unapply(fqName: FQName): Some[String] = Some(fqName.toReferenceName) | ||
} | ||
|
||
sealed case class FQNameParsingError(invalidName: String) | ||
extends Exception(s"Unable to parse: [$invalidName] into a valid FQName") | ||
} | ||
|
||
sealed case class FQNameParsingError(invalidName: String) | ||
extends Exception(s"Unable to parse: [$invalidName] into a valid FQName") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.