From c8a185d3942cfd8281c4dce4f4f5bb7d8db5962b Mon Sep 17 00:00:00 2001 From: muhammed-abdulkadir Date: Fri, 1 Nov 2024 16:39:13 +0000 Subject: [PATCH] chore(*): add definition of how we use includeDerivedTypes in JSDoc --- lib/common/graph.js | 4 +++- test/common/graph.js | 2 +- types/lib/common/graph.d.ts | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/common/graph.js b/lib/common/graph.js index b2b09c6..e3ea787 100644 --- a/lib/common/graph.js +++ b/lib/common/graph.js @@ -174,6 +174,8 @@ class ConcertoGraphVisitor extends BaseVisitor { * Visitor design pattern * @param {ClassDeclaration} classDeclaration - the object being visited * @param {Object} parameters - the parameter + * @property {boolean} parameters.includeDerivedTypes - If this option is enabled, edges will be created from super types to their derived types. + * This guarantees that if type X exists in the model manager, all types that inherit from X will be represented in the graph. * @protected */ visitClassDeclaration(classDeclaration, parameters) { @@ -183,7 +185,7 @@ class ConcertoGraphVisitor extends BaseVisitor { parameters.graph.addEdge(classDeclaration.getFullyQualifiedName(), classDeclaration.getSuperType()); // Adds a reverse edge to create a cyclic dependency between a class declaration and its supertype. - if(!parameters.createDependencyGraph && classDeclaration.getSuperType() !== 'concerto@1.0.0.Concept') { + if(parameters.includeDerivedTypes && classDeclaration.getSuperType() !== 'concerto@1.0.0.Concept') { parameters.graph.addVertex(classDeclaration.getSuperType()); parameters.graph.addEdge(classDeclaration.getSuperType(), classDeclaration.getFullyQualifiedName()); } diff --git a/test/common/graph.js b/test/common/graph.js index 5dfc83d..dabb5b9 100644 --- a/test/common/graph.js +++ b/test/common/graph.js @@ -106,7 +106,7 @@ describe('graph', function() { const graph = new DirectedGraph(); modelManager.accept(visitor, { graph, - createDependencyGraph: true + includeDerivedTypes: true }); expect( diff --git a/types/lib/common/graph.d.ts b/types/lib/common/graph.d.ts index 22f4ccb..2ad159d 100644 --- a/types/lib/common/graph.d.ts +++ b/types/lib/common/graph.d.ts @@ -11,6 +11,8 @@ export class ConcertoGraphVisitor extends BaseVisitor { * Visitor design pattern * @param {ClassDeclaration} classDeclaration - the object being visited * @param {Object} parameters - the parameter + * @property {boolean} parameters.includeDerivedTypes - If this option is enabled, edges will be created from super types to their derived types. + * This guarantees that if type X exists in the model manager, all types that inherit from X will be represented in the graph. * @protected */ protected visitClassDeclaration(classDeclaration: ClassDeclaration, parameters: any): void;