Comparing version 2.5.19 to 2.5.20
@@ -16,6 +16,13 @@ "use strict"; | ||
return umlClass; | ||
// Could not find a link so now need to recursively look at imports of imports | ||
// Could not find association so now need to recursively look at imports of imports | ||
// add to already recursively processed files to avoid getting stuck in circular imports | ||
searchedAbsolutePaths.push(sourceUmlClass.absolutePath); | ||
return findChainedImport(association, sourceUmlClass, umlClasses, searchedAbsolutePaths); | ||
const importedType = findChainedImport(association, sourceUmlClass, umlClasses, searchedAbsolutePaths); | ||
if (importedType) | ||
return importedType; | ||
// Still could not find association so now need to recursively look for inherited types | ||
const inheritedType = findInheritedType(association, sourceUmlClass, umlClasses); | ||
if (inheritedType) | ||
return inheritedType; | ||
return undefined; | ||
}; | ||
@@ -40,15 +47,14 @@ exports.findAssociatedClass = findAssociatedClass; | ||
// If a parent contract with no import alias | ||
(association.parentUmlClassName !== undefined && | ||
(association.targetUmlClassName === | ||
targetUmlClass.name && | ||
association.parentUmlClassName === | ||
importedClass.className && | ||
importedClass.className === | ||
targetUmlClass.name && | ||
importedClass.alias == undefined) || | ||
// If a parent contract with import alias | ||
(association.parentUmlClassName !== undefined && | ||
(association.targetUmlClassName === | ||
targetUmlClass.name && | ||
association.parentUmlClassName === | ||
importedClass.alias && | ||
importedClass.className === | ||
targetUmlClass.name)))); | ||
importedClass.alias)))); | ||
} | ||
// No parent class in the association | ||
return ( | ||
@@ -75,2 +81,35 @@ // class is in the same source file | ||
}; | ||
const findInheritedType = (association, sourceUmlClass, umlClasses) => { | ||
// Get all realized associations. | ||
const parentAssociations = sourceUmlClass.getParentContracts(); | ||
// For each parent association | ||
for (const parentAssociation of parentAssociations) { | ||
const parent = (0, exports.findAssociatedClass)(parentAssociation, sourceUmlClass, umlClasses); | ||
if (!parent) | ||
continue; | ||
// For each struct on the parent | ||
for (const structId of parent.structs) { | ||
const structUmlClass = umlClasses.find((c) => c.id === structId); | ||
if (!structUmlClass) | ||
continue; | ||
if (structUmlClass.name === association.targetUmlClassName) { | ||
return structUmlClass; | ||
} | ||
} | ||
// For each enum on the parent | ||
for (const enumId of parent.enums) { | ||
const enumUmlClass = umlClasses.find((c) => c.id === enumId); | ||
if (!enumUmlClass) | ||
continue; | ||
if (enumUmlClass.name === association.targetUmlClassName) { | ||
return enumUmlClass; | ||
} | ||
} | ||
// Recursively look for inherited types | ||
const targetClass = findInheritedType(association, parent, umlClasses); | ||
if (targetClass) | ||
return targetClass; | ||
} | ||
return undefined; | ||
}; | ||
const findChainedImport = (association, sourceUmlClass, umlClasses, searchedRelativePaths) => { | ||
@@ -77,0 +116,0 @@ // Get all valid imports. That is, imports that do not explicitly import contracts or interfaces |
{ | ||
"name": "sol2uml", | ||
"version": "2.5.19", | ||
"version": "2.5.20", | ||
"description": "Solidity contract visualisation tool.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
268199
5281