From c204762ac95cf13c8e7d62184dcc43ed7711adba Mon Sep 17 00:00:00 2001 From: Jaskeerat Singh Saluja Date: Tue, 3 Sep 2024 18:50:33 +0530 Subject: [PATCH] feat(alias-import): Pr suggestions Signed-off-by: Jaskeerat Singh Saluja --- lib/codegen/fromcto/csharp/csharpvisitor.js | 2 +- lib/codegen/fromcto/java/javavisitor.js | 2 +- test/codegen/fromcto/java/javavisitor.js | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/codegen/fromcto/csharp/csharpvisitor.js b/lib/codegen/fromcto/csharp/csharpvisitor.js index 6b8c9706..e7ac7a7b 100644 --- a/lib/codegen/fromcto/csharp/csharpvisitor.js +++ b/lib/codegen/fromcto/csharp/csharpvisitor.js @@ -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?.isImportedType?.(fieldType)) { + if (modelFile?.isImportedType(fieldType)) { fieldType = modelFile.getImportedType(fieldType); } fieldType = `${fqn}${fieldType}`; diff --git a/lib/codegen/fromcto/java/javavisitor.js b/lib/codegen/fromcto/java/javavisitor.js index bffc386e..7a6b838d 100644 --- a/lib/codegen/fromcto/java/javavisitor.js +++ b/lib/codegen/fromcto/java/javavisitor.js @@ -270,7 +270,7 @@ class JavaVisitor { let fieldType = field.getType(); if (!ModelUtil.isPrimitiveType(fieldType)) { const modelFile = field.getModelFile(); - if (modelFile?.isImportedType?.(fieldType)) { + if (modelFile?.isImportedType(fieldType)) { fieldType = modelFile.getImportedType(fieldType); } } diff --git a/test/codegen/fromcto/java/javavisitor.js b/test/codegen/fromcto/java/javavisitor.js index 557eab24..375ab986 100644 --- a/test/codegen/fromcto/java/javavisitor.js +++ b/test/codegen/fromcto/java/javavisitor.js @@ -467,9 +467,10 @@ describe('JavaVisitor', function () { const mockField = sinon.createStubInstance(Field); const getType = sinon.stub(); + const isImportedType = sinon.stub(); mockField.ast = { type: { name: 'Dummy Value'} }; - mockField.getModelFile.returns({ getType: getType }); + mockField.getModelFile.returns({ getType: getType, isImportedType: isImportedType }); const mockMapDeclaration = sinon.createStubInstance(MapDeclaration); const getKeyType = sinon.stub(); @@ -481,6 +482,7 @@ describe('JavaVisitor', function () { getType.returns(mockMapDeclaration); getKeyType.returns('String'); getValueType.returns('String'); + isImportedType.returns(false); mockField.getName.returns('Map1'); mockMapDeclaration.getName.returns('Map1'); mockMapDeclaration.isMapDeclaration.returns(true);