Skip to content

Commit

Permalink
feat(map): gets type from model file
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Casey <[email protected]>
  • Loading branch information
jonathan-casey committed Oct 21, 2023
1 parent 8cff2ac commit 41e2d3f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/codegen/fromcto/csharp/csharpvisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ class CSharpVisitor {
writeField(field, parameters, externalFieldType, isOptional = false) {

// write Map field
if ( Object.keys(field).length > 0 && ModelUtil.isMap?.(field)) {
const decl = field.getModelFile().getAllDeclarations().find(d => d.name === field.ast.type.name);
if (Object.keys(field).length > 0 && ModelUtil.isMap?.(field)) {
const decl = field.getModelFile().getType(field.getType());
parameters.fileWriter.writeLine(1, `public Dictionary<string, ${this.toCSharpType(decl.getValue().getType())}> ${field.getName()} { get; set; }`);
return null;
}
Expand Down
4 changes: 1 addition & 3 deletions lib/codegen/fromcto/typescript/typescriptvisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,7 @@ class TypescriptVisitor {
const isPrimitive = ModelUtil.isPrimitiveType(mapDeclaration.getValue().getType());

if (isScalar) {
const scalar = mapDeclaration.getModelFile()
.getAllDeclarations()
.find(decl => decl.name === mapDeclaration.getValue().getType());
const scalar = mapDeclaration.getModelFile(mapDeclaration.getValue().getType());
const scalarType = scalar.getType();
valueType = this.toTsType(scalarType, false, false);
} else if (isPrimitive) {
Expand Down
4 changes: 2 additions & 2 deletions lib/common/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,15 @@ class ConcertoGraphVisitor extends DiagramVisitor {
let valueEdge = mapDeclaration.getValue().getType();

if(!ModelUtil.isPrimitiveType(keyEdge)) {
keyEdge = modelFile.getAllDeclarations().find(d => d.name === mapDeclaration.getKey().getType()).getFullyQualifiedName();
keyEdge = modelFile.getType(mapDeclaration.getKey().getType()).getFullyQualifiedName();
}

if(!ModelUtil.isPrimitiveType(valueEdge)) {
// handle imported types
if (!modelFile.isLocalType(mapDeclaration.getValue().getType())) {
valueEdge = modelFile.resolveImport(mapDeclaration.getValue().getType());
} else {
valueEdge = modelFile.getAllDeclarations().find(d => d.name === mapDeclaration.getValue().getType()).getFullyQualifiedName();
valueEdge = modelFile.getType(mapDeclaration.getValue().getType()).getFullyQualifiedName();
}
}

Expand Down

0 comments on commit 41e2d3f

Please sign in to comment.