-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: muhammed-abdulkadir <[email protected]>
- Loading branch information
muhammed-abdulkadir
committed
Oct 31, 2024
1 parent
558cf41
commit 5547294
Showing
3 changed files
with
24 additions
and
82 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -178,20 +178,16 @@ class ConcertoGraphVisitor extends DiagramVisitor { | |
* @protected | ||
*/ | ||
visitClassDeclaration(classDeclaration, parameters) { | ||
parameters.stack ??= []; | ||
parameters.stack.push(classDeclaration.getFullyQualifiedName()); | ||
parameters.graph.addVertex(classDeclaration.getFullyQualifiedName()); | ||
|
||
if (classDeclaration.getSuperType()){ | ||
parameters.graph.addEdge(classDeclaration.getFullyQualifiedName(), classDeclaration.getSuperType()); | ||
// this "if" block adds the types that extend the Super type | ||
if(!parameters.createDependencyGraph && classDeclaration.getSuperType() !== '[email protected]') { | ||
parameters.graph.addVertex(classDeclaration.getSuperType()); | ||
parameters.graph.addEdge(classDeclaration.getSuperType(), classDeclaration.getFullyQualifiedName()); | ||
} | ||
} | ||
super.visitClassDeclaration(classDeclaration, parameters); | ||
parameters.stack.pop(); | ||
} | ||
|
||
/** | ||
|
@@ -276,7 +272,7 @@ class ConcertoGraphVisitor extends DiagramVisitor { | |
*/ | ||
visitScalarField(scalar, parameters) { | ||
super.visitScalarField(scalar, parameters); | ||
parameters.graph.addEdge(parameters.stack.slice(-1), scalar.getFullyQualifiedTypeName()); | ||
parameters.graph.addEdge(scalar.getParent().getFullyQualifiedName(), scalar.getFullyQualifiedTypeName()); | ||
} | ||
|
||
/** | ||
|
@@ -288,7 +284,7 @@ class ConcertoGraphVisitor extends DiagramVisitor { | |
visitField(field, parameters) { | ||
super.visitField(field, parameters); | ||
if (!ModelUtil.isPrimitiveType(field.getFullyQualifiedTypeName())) { | ||
parameters.graph.addEdge(parameters.stack.slice(-1), field.getFullyQualifiedTypeName()); | ||
parameters.graph.addEdge(field.getParent().getFullyQualifiedName(), field.getFullyQualifiedTypeName()); | ||
} | ||
} | ||
|
||
|
@@ -300,7 +296,7 @@ class ConcertoGraphVisitor extends DiagramVisitor { | |
*/ | ||
visitRelationship(relationship, parameters) { | ||
super.visitRelationship(relationship, parameters); | ||
parameters.graph.addEdge(parameters.stack.slice(-1), relationship.getFullyQualifiedTypeName()); | ||
parameters.graph.addEdge(relationship.getParent().getFullyQualifiedName(), relationship.getFullyQualifiedTypeName()); | ||
} | ||
|
||
/** | ||
|
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 |
---|---|---|
|
@@ -82,12 +82,6 @@ describe('graph', function() { | |
'[email protected]' | ||
) | ||
); | ||
expect( | ||
connectedGraph.hasEdge( | ||
'[email protected]', | ||
'[email protected]' | ||
) | ||
); | ||
|
||
const filteredModelManager = modelManager.filter((declaration) => | ||
connectedGraph.hasVertex(declaration.getFullyQualifiedName()) | ||
|
@@ -96,7 +90,7 @@ describe('graph', function() { | |
expect(filteredModelManager.getModelFiles()).toHaveLength(2); | ||
expect( | ||
filteredModelManager.getModelFiles()[0].getAllDeclarations() | ||
).toHaveLength(8); | ||
).toHaveLength(5); | ||
|
||
writer.openFile('graph.mmd'); | ||
connectedGraph.print(writer); | ||
|
@@ -115,6 +109,13 @@ describe('graph', function() { | |
createDependencyGraph: true | ||
}); | ||
|
||
expect( | ||
graph.hasEdge( | ||
'[email protected]', | ||
'[email protected]' | ||
) | ||
); | ||
|
||
writer.openFile('graph.mmd'); | ||
graph.print(writer); | ||
writer.closeFile(); | ||
|