Skip to content

Commit

Permalink
chore(*): add definition of how we use includeDerivedTypes in JSDoc
Browse files Browse the repository at this point in the history
Signed-off-by: muhammed-abdulkadir <[email protected]>
  • Loading branch information
muhammed-abdulkadir committed Nov 1, 2024
1 parent 13442eb commit 2c40067
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/common/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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() !== '[email protected]') {
if(parameters.includeDerivedTypes && classDeclaration.getSuperType() !== '[email protected]') {
parameters.graph.addVertex(classDeclaration.getSuperType());
parameters.graph.addEdge(classDeclaration.getSuperType(), classDeclaration.getFullyQualifiedName());
}
Expand Down
6 changes: 3 additions & 3 deletions test/common/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('graph', function() {
const writer = new InMemoryWriter();

const graph = new DirectedGraph();
modelManager.accept(visitor, { graph });
modelManager.accept(visitor, { graph, includeDerivedTypes: true });

writer.openFile('graph.mmd');
graph.print(writer);
Expand All @@ -71,7 +71,7 @@ describe('graph', function() {
const writer = new InMemoryWriter();

const graph = new DirectedGraph();
modelManager.accept(visitor, { graph });
modelManager.accept(visitor, { graph, includeDerivedTypes: true });

const connectedGraph = graph.findConnectedGraph(
'[email protected]'
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('graph', function() {
const graph = new DirectedGraph();
modelManager.accept(visitor, {
graph,
createDependencyGraph: true
includeDerivedTypes: false
});

expect(
Expand Down
2 changes: 2 additions & 0 deletions types/lib/common/graph.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2c40067

Please sign in to comment.