From c235455f5eaaa879a5dc86637fa91b2011f7ba2e Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Tue, 8 Aug 2023 14:14:32 +0200 Subject: [PATCH] fix(go): properties on interfaces should be uppercased --- src/languages/go.ts | 11 +++++------ test/translations/interfaces/interface_with_method.go | 2 +- test/translations/interfaces/interface_with_method.ts | 2 +- test/translations/interfaces/interface_with_props.go | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/languages/go.ts b/src/languages/go.ts index d9a3c515..f005c855 100644 --- a/src/languages/go.ts +++ b/src/languages/go.ts @@ -294,6 +294,7 @@ export class GoVisitor extends DefaultVisitor { ? JSON.stringify(node.name.text) : this.goName(node.name.text, renderer, renderer.typeChecker.getSymbolAtLocation(node.name)) : renderer.convert(node.name); + return new OTree( [ key, @@ -543,11 +544,9 @@ export class GoVisitor extends DefaultVisitor { public override methodSignature(node: ts.MethodSignature, renderer: AstRenderer): OTree { const type = this.renderTypeNode(node.type, true, renderer); + return new OTree( - [ - renderer.updateContext({ isExported: renderer.currentContext.isExported && isPublic(node) }).convert(node.name), - '(', - ], + [renderer.updateContext({ isExported: isPublic(node) }).convert(node.name), '('], renderer.convertAll(node.parameters), { suffix: `) ${type}`, canBreakLine: true }, ); @@ -571,7 +570,7 @@ export class GoVisitor extends DefaultVisitor { if (renderer.currentContext.isInterface) { const type = this.renderTypeNode(node.type, true, renderer); const getter = new OTree([ - renderer.updateContext({ isExported: renderer.currentContext.isExported && isPublic(node) }).convert(node.name), + renderer.updateContext({ isExported: isPublic(node) }).convert(node.name), '() ', type, ]); @@ -580,7 +579,7 @@ export class GoVisitor extends DefaultVisitor { } const setter = new OTree([ '\n', - renderer.currentContext.isExported && isPublic(node) ? 'Set' : 'set', + isPublic(node) ? 'Set' : 'set', renderer.updateContext({ isExported: true }).convert(node.name), '(value ', type, diff --git a/test/translations/interfaces/interface_with_method.go b/test/translations/interfaces/interface_with_method.go index ee948fc6..5b74ad22 100644 --- a/test/translations/interfaces/interface_with_method.go +++ b/test/translations/interfaces/interface_with_method.go @@ -1,3 +1,3 @@ type iThing interface { - doAThing() + DoAThing() } diff --git a/test/translations/interfaces/interface_with_method.ts b/test/translations/interfaces/interface_with_method.ts index 93eb5714..492cfeb2 100644 --- a/test/translations/interfaces/interface_with_method.ts +++ b/test/translations/interfaces/interface_with_method.ts @@ -1,3 +1,3 @@ interface IThing { doAThing(): void; -} \ No newline at end of file +} diff --git a/test/translations/interfaces/interface_with_props.go b/test/translations/interfaces/interface_with_props.go index 7c3dce8d..ddfd7214 100644 --- a/test/translations/interfaces/interface_with_props.go +++ b/test/translations/interfaces/interface_with_props.go @@ -1,3 +1,3 @@ type iThing interface { - thingArn() *string + ThingArn() *string }