Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graph): add decorators that ref types to graph #137

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions lib/common/diagramvisitor.js
Original file line number Diff line number Diff line change
@@ -197,6 +197,7 @@ class DiagramVisitor {
*/
visitScalarField(field, parameters) {
this.visitField(field.getScalarField(), parameters);
field.getDecorators().forEach(decorator => decorator.accept(this, parameters));
}

/**
@@ -221,7 +222,10 @@ class DiagramVisitor {
if(field.isArray()) {
array = '[]';
}
parameters.fileWriter.writeLine(1, '+ ' + field.getType() + array + ' ' + field.getName());
field.getDecorators().forEach(decorator => decorator.accept(this, parameters));
if(parameters.fileWriter) {
parameters.fileWriter.writeLine(1, '+ ' + field.getType() + array + ' ' + field.getName());
}
}

/**
@@ -231,7 +235,10 @@ class DiagramVisitor {
* @protected
*/
visitEnumValueDeclaration(enumValueDeclaration, parameters) {
parameters.fileWriter.writeLine(1, '+ ' + enumValueDeclaration.getName());
enumValueDeclaration.getDecorators().forEach(decorator => decorator.accept(this, parameters));
if(parameters.fileWriter) {
parameters.fileWriter.writeLine(1, '+ ' + enumValueDeclaration.getName());
}
}

/**
@@ -257,9 +264,11 @@ class DiagramVisitor {
if (parameters.hideBaseModel && isBaseModel){
return;
}
const source = this.escapeString(classDeclaration.getFullyQualifiedName());
const target = this.escapeString(classDeclaration.getSuperType());
parameters.fileWriter.writeLine(0, `${source} ${DiagramVisitor.INHERITANCE} ${target}`);
if(parameters.fileWriter) {
const source = this.escapeString(classDeclaration.getFullyQualifiedName());
const target = this.escapeString(classDeclaration.getSuperType());
parameters.fileWriter.writeLine(0, `${source} ${DiagramVisitor.INHERITANCE} ${target}`);
}
}
}
}
19 changes: 11 additions & 8 deletions lib/common/graph.js
Original file line number Diff line number Diff line change
@@ -212,13 +212,16 @@ class ConcertoGraphVisitor extends DiagramVisitor {
* @protected
*/
visitDecorator(decorator, parameters) {
super.visitDecorator(decorator, parameters);
const parent = decorator.getParent();
const modelFile = parent.getModelFile();
decorator.getArguments()?.forEach(argument => {
const fqn = modelFile.getFullyQualifiedTypeName(argument.name);
if (fqn) {
parameters.graph.addVertex(fqn);
(parent === modelFile) ? parameters.graph.addEdge(parent.getNamespace(), fqn) : parameters.graph.addEdge(parent.getFullyQualifiedName(), fqn);
if(argument.name) {
const fqn = modelFile.getFullyQualifiedTypeName(argument.name);
if (fqn) {
parameters.graph.addVertex(fqn);
(parent === modelFile) ? parameters.graph.addEdge(parent.getNamespace(), fqn) : parameters.graph.addEdge(parent.getFullyQualifiedName(), fqn);
}
}
});
}
@@ -260,7 +263,7 @@ class ConcertoGraphVisitor extends DiagramVisitor {
* @protected
*/
visitScalarField(scalar, parameters) {
scalar.getDecorators().forEach(decorator => decorator.accept(this, parameters));
super.visitScalarField(scalar, parameters);
parameters.graph.addEdge(parameters.stack.slice(-1), scalar.getFullyQualifiedTypeName());
}

@@ -271,7 +274,7 @@ class ConcertoGraphVisitor extends DiagramVisitor {
* @protected
*/
visitField(field, parameters) {
field.getDecorators().forEach(decorator => decorator.accept(this, parameters));
super.visitField(field, parameters);
if (!ModelUtil.isPrimitiveType(field.getFullyQualifiedTypeName())) {
parameters.graph.addEdge(parameters.stack.slice(-1), field.getFullyQualifiedTypeName());
}
@@ -284,7 +287,7 @@ class ConcertoGraphVisitor extends DiagramVisitor {
* @protected
*/
visitRelationship(relationship, parameters) {
relationship.getDecorators().forEach(decorator => decorator.accept(this, parameters));
super.visitRelationship(relationship, parameters);
parameters.graph.addEdge(parameters.stack.slice(-1), relationship.getFullyQualifiedTypeName());
}

@@ -295,7 +298,7 @@ class ConcertoGraphVisitor extends DiagramVisitor {
* @protected
*/
visitEnumValueDeclaration(enumValueDeclaration, parameters) {
enumValueDeclaration.getDecorators().forEach(decorator => decorator.accept(this, parameters));
super.visitEnumValueDeclaration(enumValueDeclaration, parameters);
return;
}
}
Loading
Loading