Skip to content

Commit

Permalink
Allow EncodedName to be constructed with a default namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
kjonescertinia committed Dec 3, 2024
1 parent b1f9340 commit 3ec58cd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,5 +461,5 @@ final class ExpressionVerifyContext(parentContext: BlockVerifyContext) extends V
parentContext.getVar(name, markUsed: Boolean)

def defaultNamespace(name: Name): Name =
EncodedName(name).defaultNamespace(module.namespace).fullName
EncodedName(name, module.namespace).fullName
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ trait ModuleFind {
targetType.params.isEmpty &&
(targetType.outer.isEmpty || targetType.outer.contains(TypeNames.Schema))
) {
val encName = EncodedName(targetType.name).defaultNamespace(namespace)
val encName = EncodedName(targetType.name, namespace)
if (encName.ext.nonEmpty) {
return types.getWithSchema(TypeName(encName.fullName, Nil, None))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SObjectDeployer(module: OPM.Module) {

while (objectsEvents.hasNext) {
val sObjectEvent = objectsEvents.next().asInstanceOf[SObjectEvent]
val encodedName = EncodedName(sObjectEvent.name).defaultNamespace(module.namespace)
val encodedName = EncodedName(sObjectEvent.name, module.namespace)
val typeName = TypeName(encodedName.fullName, Nil, Some(TypeNames.Schema))
val nature = SObjectNature(sObjectEvent.name, sObjectEvent)

Expand Down Expand Up @@ -632,7 +632,7 @@ class SObjectDeployer(module: OPM.Module) {
}

private def defaultNamespace(name: Name): Name = {
EncodedName(name).defaultNamespace(module.namespace).fullName
EncodedName(name, module.namespace).fullName
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ trait SObjectFieldFinder {
}

private def getRelationshipField(name: Name): Option[FieldDeclaration] = {
val encodedName = EncodedName(name).defaultNamespace(module.namespace)
val encodedName = EncodedName(name, module.namespace)
if (encodedName.ext.contains(relationshipExtension)) {
getRelationshipField(this, encodedName)
.orElse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ object EncodedName {
apply(name.value)
}

def apply(name: String): EncodedName = {
def apply(name: Name, defaultNamespace: Option[Name]): EncodedName = {
apply(name.value, defaultNamespace)
}

def apply(name: String, defaultNamespace: Option[Name] = None): EncodedName = {
val parts = nameSplit(name)
parts.size match {
case 3 =>
Expand All @@ -69,7 +73,7 @@ object EncodedName {
case 2 =>
val normalExt = parts(1).toLowerCase
if (extensions.contains(normalExt) || normalExt.endsWith("__s"))
EncodedName(Name(parts.head), Some(Name(parts(1))), None)
EncodedName(Name(parts.head), Some(Name(parts(1))), defaultNamespace)
else
EncodedName(Name(parts(1)), None, Some(Name(parts.head)))
case 0 => EncodedName(Name(name), None, None)
Expand Down

0 comments on commit 3ec58cd

Please sign in to comment.