Skip to content

Commit

Permalink
feat(i114): Java visitor updated for aliased import
Browse files Browse the repository at this point in the history
Signed-off-by: Jaskeerat Singh Saluja <[email protected]>
  • Loading branch information
Jaskeerat Singh Saluja authored and Jaskeerat Singh Saluja committed Aug 4, 2024
1 parent 818ce77 commit c3e6377
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 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 @@ -15,7 +15,7 @@

'use strict';

const { ModelUtil } = require('@accordproject/concerto-core');
const { ModelUtil, ModelFile } = require('@accordproject/concerto-core');
const camelCase = require('camelcase');
const { throwUnrecognizedType } = require('../../../common/util');

Expand Down Expand Up @@ -384,7 +384,7 @@ class CSharpVisitor {
} else if (!field.isPrimitive()) {
let fqn = this.getDotNetNamespaceOfType(field.getFullyQualifiedTypeName(), field.getParent(), parameters);
const modelFile = field.getModelFile();
if (modelFile && modelFile.isImportedType(fieldType)) {
if (modelFile instanceof ModelFile && modelFile.isImportedType(fieldType)) {
fieldType = modelFile.getActualImportType(fieldType);
}
fieldType = `${fqn}${fieldType}`;
Expand Down
12 changes: 9 additions & 3 deletions lib/codegen/fromcto/java/javavisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

'use strict';

const { ModelFile } = require('@accordproject/concerto-core');
const EmptyPlugin = require('./emptyplugin');
const ModelUtil = require('@accordproject/concerto-core').ModelUtil;
const util = require('util');
Expand Down Expand Up @@ -267,9 +268,14 @@ class JavaVisitor {
if(field.isArray()) {
array = '[]';
}

const fieldType = this.toJavaType(field.getType()) + array;

let fieldType = field.getType();
if (!ModelUtil.isPrimitiveType(fieldType)) {
const modelFile = field.getModelFile();
if (modelFile instanceof ModelFile && modelFile.isImportedType(fieldType)) {
fieldType = modelFile.getActualImportType(fieldType);
}
}
fieldType = this.toJavaType(fieldType) + array;
const fieldName = field.getName();
const getterName = 'get' + this.capitalizeFirstLetter(fieldName);
const setterName = 'set' + this.capitalizeFirstLetter(fieldName);
Expand Down

0 comments on commit c3e6377

Please sign in to comment.