diff --git a/packages/jsii-calc/lib/index.ts b/packages/jsii-calc/lib/index.ts index 7f40a0c0a9..724888b22e 100644 --- a/packages/jsii-calc/lib/index.ts +++ b/packages/jsii-calc/lib/index.ts @@ -12,3 +12,4 @@ export * as submodule from './submodule'; export * as onlystatic from './only-static'; export * as nodirect from './no-direct-types'; export * as module2647 from './module2647'; +export * as module2689 from './module2689'; diff --git a/packages/jsii-calc/lib/module2689/index.ts b/packages/jsii-calc/lib/module2689/index.ts new file mode 100644 index 0000000000..6d0a18f778 --- /dev/null +++ b/packages/jsii-calc/lib/module2689/index.ts @@ -0,0 +1,10 @@ +// +// Verifies that the correct imports are generated for Go code when forien types +// are referenced in complex fields (array and map). +// +// @see https://github.com/aws/jsii/issues/2689 + +export * as structs from './structs'; +export * as methods from './methods'; +export * as props from './props'; +export * as retval from './retval'; diff --git a/packages/jsii-calc/lib/module2689/methods/index.ts b/packages/jsii-calc/lib/module2689/methods/index.ts new file mode 100644 index 0000000000..bf7221cd83 --- /dev/null +++ b/packages/jsii-calc/lib/module2689/methods/index.ts @@ -0,0 +1,12 @@ +import { BaseProps } from '@scope/jsii-calc-base'; +import { Number as NumberClass } from '@scope/jsii-calc-lib'; + +export class MyClass { + public foo(_values: NumberClass[]) { + return; + } + + public bar(_bar: { [k: string]: BaseProps }) { + return; + } +} diff --git a/packages/jsii-calc/lib/module2689/props/index.ts b/packages/jsii-calc/lib/module2689/props/index.ts new file mode 100644 index 0000000000..8d622f549a --- /dev/null +++ b/packages/jsii-calc/lib/module2689/props/index.ts @@ -0,0 +1,7 @@ +import { BaseProps } from '@scope/jsii-calc-base'; +import { Number as NumberClass } from '@scope/jsii-calc-lib'; + +export class MyClass { + public readonly foo: NumberClass[] = []; + public readonly bar: { [key: string]: BaseProps } = {}; +} diff --git a/packages/jsii-calc/lib/module2689/retval/index.ts b/packages/jsii-calc/lib/module2689/retval/index.ts new file mode 100644 index 0000000000..551ada82b8 --- /dev/null +++ b/packages/jsii-calc/lib/module2689/retval/index.ts @@ -0,0 +1,12 @@ +import { BaseProps } from '@scope/jsii-calc-base'; +import { Number as NumberClass } from '@scope/jsii-calc-lib'; + +export class MyClass { + public foo(): NumberClass[] { + return []; + } + + public bar(): { [k: string]: BaseProps } { + return {}; + } +} diff --git a/packages/jsii-calc/lib/module2689/structs/index.ts b/packages/jsii-calc/lib/module2689/structs/index.ts new file mode 100644 index 0000000000..5aa1393f40 --- /dev/null +++ b/packages/jsii-calc/lib/module2689/structs/index.ts @@ -0,0 +1,7 @@ +import { BaseProps } from '@scope/jsii-calc-base'; +import { Number as NumberClass } from '@scope/jsii-calc-lib'; + +export interface MyStruct { + readonly numbers: NumberClass[]; + readonly baseMap: { [key: string]: BaseProps }; +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index ff8a023301..73ceb343b1 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -217,6 +217,36 @@ "line": 14 } }, + "jsii-calc.module2689": { + "locationInModule": { + "filename": "lib/index.ts", + "line": 15 + } + }, + "jsii-calc.module2689.methods": { + "locationInModule": { + "filename": "lib/module2689/index.ts", + "line": 8 + } + }, + "jsii-calc.module2689.props": { + "locationInModule": { + "filename": "lib/module2689/index.ts", + "line": 9 + } + }, + "jsii-calc.module2689.retval": { + "locationInModule": { + "filename": "lib/module2689/index.ts", + "line": 10 + } + }, + "jsii-calc.module2689.structs": { + "locationInModule": { + "filename": "lib/module2689/index.ts", + "line": 7 + } + }, "jsii-calc.nodirect": { "locationInModule": { "filename": "lib/index.ts", @@ -14196,6 +14226,250 @@ "name": "ExtendAndImplement", "namespace": "module2647" }, + "jsii-calc.module2689.methods.MyClass": { + "assembly": "jsii-calc", + "docs": { + "stability": "stable" + }, + "fqn": "jsii-calc.module2689.methods.MyClass", + "initializer": { + "docs": { + "stability": "stable" + } + }, + "kind": "class", + "locationInModule": { + "filename": "lib/module2689/methods/index.ts", + "line": 4 + }, + "methods": [ + { + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/module2689/methods/index.ts", + "line": 9 + }, + "name": "bar", + "parameters": [ + { + "name": "_bar", + "type": { + "collection": { + "elementtype": { + "fqn": "@scope/jsii-calc-base.BaseProps" + }, + "kind": "map" + } + } + } + ] + }, + { + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/module2689/methods/index.ts", + "line": 5 + }, + "name": "foo", + "parameters": [ + { + "name": "_values", + "type": { + "collection": { + "elementtype": { + "fqn": "@scope/jsii-calc-lib.Number" + }, + "kind": "array" + } + } + } + ] + } + ], + "name": "MyClass", + "namespace": "module2689.methods" + }, + "jsii-calc.module2689.props.MyClass": { + "assembly": "jsii-calc", + "docs": { + "stability": "stable" + }, + "fqn": "jsii-calc.module2689.props.MyClass", + "initializer": { + "docs": { + "stability": "stable" + } + }, + "kind": "class", + "locationInModule": { + "filename": "lib/module2689/props/index.ts", + "line": 4 + }, + "name": "MyClass", + "namespace": "module2689.props", + "properties": [ + { + "docs": { + "stability": "stable" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/module2689/props/index.ts", + "line": 6 + }, + "name": "bar", + "type": { + "collection": { + "elementtype": { + "fqn": "@scope/jsii-calc-base.BaseProps" + }, + "kind": "map" + } + } + }, + { + "docs": { + "stability": "stable" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/module2689/props/index.ts", + "line": 5 + }, + "name": "foo", + "type": { + "collection": { + "elementtype": { + "fqn": "@scope/jsii-calc-lib.Number" + }, + "kind": "array" + } + } + } + ] + }, + "jsii-calc.module2689.retval.MyClass": { + "assembly": "jsii-calc", + "docs": { + "stability": "stable" + }, + "fqn": "jsii-calc.module2689.retval.MyClass", + "initializer": { + "docs": { + "stability": "stable" + } + }, + "kind": "class", + "locationInModule": { + "filename": "lib/module2689/retval/index.ts", + "line": 4 + }, + "methods": [ + { + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/module2689/retval/index.ts", + "line": 9 + }, + "name": "bar", + "returns": { + "type": { + "collection": { + "elementtype": { + "fqn": "@scope/jsii-calc-base.BaseProps" + }, + "kind": "map" + } + } + } + }, + { + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/module2689/retval/index.ts", + "line": 5 + }, + "name": "foo", + "returns": { + "type": { + "collection": { + "elementtype": { + "fqn": "@scope/jsii-calc-lib.Number" + }, + "kind": "array" + } + } + } + } + ], + "name": "MyClass", + "namespace": "module2689.retval" + }, + "jsii-calc.module2689.structs.MyStruct": { + "assembly": "jsii-calc", + "datatype": true, + "docs": { + "stability": "stable" + }, + "fqn": "jsii-calc.module2689.structs.MyStruct", + "kind": "interface", + "locationInModule": { + "filename": "lib/module2689/structs/index.ts", + "line": 4 + }, + "name": "MyStruct", + "namespace": "module2689.structs", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "stable" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/module2689/structs/index.ts", + "line": 6 + }, + "name": "baseMap", + "type": { + "collection": { + "elementtype": { + "fqn": "@scope/jsii-calc-base.BaseProps" + }, + "kind": "map" + } + } + }, + { + "abstract": true, + "docs": { + "stability": "stable" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/module2689/structs/index.ts", + "line": 5 + }, + "name": "numbers", + "type": { + "collection": { + "elementtype": { + "fqn": "@scope/jsii-calc-lib.Number" + }, + "kind": "array" + } + } + } + ] + }, "jsii-calc.nodirect.sub1.TypeFromSub1": { "assembly": "jsii-calc", "docs": { @@ -14952,5 +15226,5 @@ } }, "version": "3.20.120", - "fingerprint": "jhFZc5fa0gXEmH6s8wlAhaQm8CX/ZCHNvpY1jXxwMgE=" + "fingerprint": "bEIqxJjC2BFJEo5AIzysYAdDCVZcHPAm+paBHx0vvKE=" } diff --git a/packages/jsii-pacmak/lib/targets/go/types/go-type-reference.ts b/packages/jsii-pacmak/lib/targets/go/types/go-type-reference.ts index 8b1afc42e5..adeba2cfe4 100644 --- a/packages/jsii-pacmak/lib/targets/go/types/go-type-reference.ts +++ b/packages/jsii-pacmak/lib/targets/go/types/go-type-reference.ts @@ -87,6 +87,38 @@ export class GoTypeRef { return this._typeMap; } + /** + * The go `import`s required in order to be able to use this type in code. + */ + public get dependencies(): readonly Package[] { + const ret = new Array(); + + switch (this.typeMap.type) { + case 'interface': + if (this.type?.pkg) { + ret.push(this.type?.pkg); + } + break; + + case 'array': + case 'map': + ret.push(...(this.typeMap.value.dependencies ?? [])); + break; + + case 'union': + for (const t of this.typeMap.value) { + ret.push(...(t.dependencies ?? [])); + } + break; + + case 'void': + case 'primitive': + break; + } + + return ret; + } + /* * Return the name of a type for reference from the `Package` passed in */ diff --git a/packages/jsii-pacmak/lib/targets/go/util.ts b/packages/jsii-pacmak/lib/targets/go/util.ts index 4ac14c50e9..dfaf47cab9 100644 --- a/packages/jsii-pacmak/lib/targets/go/util.ts +++ b/packages/jsii-pacmak/lib/targets/go/util.ts @@ -50,21 +50,19 @@ export function flatMap( export function getMemberDependencies( members: readonly GoTypeMember[], ): Package[] { - return members.reduce((accum: Package[], member) => { - return member.reference?.type?.pkg - ? [...accum, member.reference?.type.pkg] - : accum; - }, []); + const deps = new Array(); + for (const member of members) { + deps.push(...(member.reference?.dependencies ?? [])); + } + + return deps; } export function getParamDependencies(methods: GoMethod[]): Package[] { const dependencies: Package[] = []; for (const method of methods) { for (const param of method.parameters) { - const pkg = param.reference?.type?.pkg; - if (pkg) { - dependencies.push(pkg); - } + dependencies.push(...(param.reference?.dependencies ?? [])); } } return dependencies; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap index cbcd354145..2bf9a80efe 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.ts.snap @@ -2895,6 +2895,16 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┣━ 📄 MethodNamedProperty.cs ┃ ┣━ 📁 Module2647 ┃ ┃ ┗━ 📄 ExtendAndImplement.cs + ┃ ┣━ 📁 Module2689 + ┃ ┃ ┣━ 📁 Methods + ┃ ┃ ┃ ┗━ 📄 MyClass.cs + ┃ ┃ ┣━ 📁 Props + ┃ ┃ ┃ ┗━ 📄 MyClass.cs + ┃ ┃ ┣━ 📁 Retval + ┃ ┃ ┃ ┗━ 📄 MyClass.cs + ┃ ┃ ┗━ 📁 Structs + ┃ ┃ ┣━ 📄 IMyStruct.cs + ┃ ┃ ┗━ 📄 MyStruct.cs ┃ ┣━ 📄 Multiply.cs ┃ ┣━ 📄 NamespaceDoc.cs ┃ ┣━ 📄 Negate.cs @@ -12176,6 +12186,214 @@ namespace Amazon.JSII.Tests.CalculatorNamespace.Module2647 `; +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2689/Methods/MyClass.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2689.Methods +{ + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Module2689.Methods.MyClass), fullyQualifiedName: "jsii-calc.module2689.methods.MyClass")] + public class MyClass : DeputyBase + { + public MyClass(): base(new DeputyProps(System.Array.Empty())) + { + } + + /// Used by jsii to construct an instance of this class from a Javascript-owned object reference + /// The Javascript-owned object reference + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + protected MyClass(ByRefValue reference): base(reference) + { + } + + /// Used by jsii to construct an instance of this class from DeputyProps + /// The deputy props + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + protected MyClass(DeputyProps props): base(props) + { + } + + [JsiiMethod(name: "bar", parametersJson: "[{\\"name\\":\\"_bar\\",\\"type\\":{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-base.BaseProps\\"},\\"kind\\":\\"map\\"}}}]")] + public virtual void Bar(System.Collections.Generic.IDictionary bar) + { + InvokeInstanceVoidMethod(new System.Type[]{typeof(System.Collections.Generic.IDictionary)}, new object[]{bar}); + } + + [JsiiMethod(name: "foo", parametersJson: "[{\\"name\\":\\"_values\\",\\"type\\":{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-lib.Number\\"},\\"kind\\":\\"array\\"}}}]")] + public virtual void Foo(Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.Number[] values) + { + InvokeInstanceVoidMethod(new System.Type[]{typeof(Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.Number[])}, new object[]{values}); + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2689/Props/MyClass.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2689.Props +{ + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Module2689.Props.MyClass), fullyQualifiedName: "jsii-calc.module2689.props.MyClass")] + public class MyClass : DeputyBase + { + public MyClass(): base(new DeputyProps(System.Array.Empty())) + { + } + + /// Used by jsii to construct an instance of this class from a Javascript-owned object reference + /// The Javascript-owned object reference + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + protected MyClass(ByRefValue reference): base(reference) + { + } + + /// Used by jsii to construct an instance of this class from DeputyProps + /// The deputy props + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + protected MyClass(DeputyProps props): base(props) + { + } + + [JsiiProperty(name: "bar", typeJson: "{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-base.BaseProps\\"},\\"kind\\":\\"map\\"}}")] + public virtual System.Collections.Generic.IDictionary Bar + { + get => GetInstanceProperty>()!; + } + + [JsiiProperty(name: "foo", typeJson: "{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-lib.Number\\"},\\"kind\\":\\"array\\"}}")] + public virtual Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.Number[] Foo + { + get => GetInstanceProperty()!; + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2689/Retval/MyClass.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2689.Retval +{ + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Module2689.Retval.MyClass), fullyQualifiedName: "jsii-calc.module2689.retval.MyClass")] + public class MyClass : DeputyBase + { + public MyClass(): base(new DeputyProps(System.Array.Empty())) + { + } + + /// Used by jsii to construct an instance of this class from a Javascript-owned object reference + /// The Javascript-owned object reference + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + protected MyClass(ByRefValue reference): base(reference) + { + } + + /// Used by jsii to construct an instance of this class from DeputyProps + /// The deputy props + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + protected MyClass(DeputyProps props): base(props) + { + } + + [JsiiMethod(name: "bar", returnsJson: "{\\"type\\":{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-base.BaseProps\\"},\\"kind\\":\\"map\\"}}}")] + public virtual System.Collections.Generic.IDictionary Bar() + { + return InvokeInstanceMethod>(new System.Type[]{}, new object[]{})!; + } + + [JsiiMethod(name: "foo", returnsJson: "{\\"type\\":{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-lib.Number\\"},\\"kind\\":\\"array\\"}}}")] + public virtual Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.Number[] Foo() + { + return InvokeInstanceMethod(new System.Type[]{}, new object[]{})!; + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2689/Structs/IMyStruct.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2689.Structs +{ + [JsiiInterface(nativeType: typeof(IMyStruct), fullyQualifiedName: "jsii-calc.module2689.structs.MyStruct")] + public interface IMyStruct + { + [JsiiProperty(name: "baseMap", typeJson: "{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-base.BaseProps\\"},\\"kind\\":\\"map\\"}}")] + System.Collections.Generic.IDictionary BaseMap + { + get; + } + + [JsiiProperty(name: "numbers", typeJson: "{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-lib.Number\\"},\\"kind\\":\\"array\\"}}")] + Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.Number[] Numbers + { + get; + } + + [JsiiTypeProxy(nativeType: typeof(IMyStruct), fullyQualifiedName: "jsii-calc.module2689.structs.MyStruct")] + internal sealed class _Proxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.Module2689.Structs.IMyStruct + { + private _Proxy(ByRefValue reference): base(reference) + { + } + + [JsiiProperty(name: "baseMap", typeJson: "{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-base.BaseProps\\"},\\"kind\\":\\"map\\"}}")] + public System.Collections.Generic.IDictionary BaseMap + { + get => GetInstanceProperty>()!; + } + + [JsiiProperty(name: "numbers", typeJson: "{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-lib.Number\\"},\\"kind\\":\\"array\\"}}")] + public Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.Number[] Numbers + { + get => GetInstanceProperty()!; + } + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2689/Structs/MyStruct.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2689.Structs +{ + #pragma warning disable CS8618 + + [JsiiByValue(fqn: "jsii-calc.module2689.structs.MyStruct")] + public class MyStruct : Amazon.JSII.Tests.CalculatorNamespace.Module2689.Structs.IMyStruct + { + [JsiiProperty(name: "baseMap", typeJson: "{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-base.BaseProps\\"},\\"kind\\":\\"map\\"}}", isOverride: true)] + public System.Collections.Generic.IDictionary BaseMap + { + get; + set; + } + + [JsiiProperty(name: "numbers", typeJson: "{\\"collection\\":{\\"elementtype\\":{\\"fqn\\":\\"@scope/jsii-calc-lib.Number\\"},\\"kind\\":\\"array\\"}}", isOverride: true)] + public Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.Number[] Numbers + { + get; + set; + } + } +} + +`; + exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Multiply.cs 1`] = ` using Amazon.JSII.Runtime.Deputy; diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap index 1aa712043b..eb15d0b961 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-go.test.ts.snap @@ -1852,6 +1852,20 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┣━ 📁 module2647 ┃ ┣━ 📄 module2647.go ┃ ┗━ 📄 module2647.init.go + ┣━ 📁 module2689 + ┃ ┣━ 📁 methods + ┃ ┃ ┣━ 📄 methods.go + ┃ ┃ ┗━ 📄 methods.init.go + ┃ ┣━ 📄 module2689.go + ┃ ┣━ 📁 props + ┃ ┃ ┣━ 📄 props.go + ┃ ┃ ┗━ 📄 props.init.go + ┃ ┣━ 📁 retval + ┃ ┃ ┣━ 📄 retval.go + ┃ ┃ ┗━ 📄 retval.init.go + ┃ ┗━ 📁 structs + ┃ ┣━ 📄 structs.go + ┃ ┗━ 📄 structs.init.go ┣━ 📁 nodirect ┃ ┣━ 📄 nodirect.go ┃ ┣━ 📁 sub1 @@ -14913,6 +14927,305 @@ func init() { `; +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2689/methods/methods.go 1`] = ` +package methods + +import ( + _jsii_ "github.com/aws/jsii-runtime-go" + _init_ "github.com/aws/jsii/jsii-calc/go/jsiicalc/v3/jsii" + + "github.com/aws/jsii/jsii-calc/go/jcb" + "github.com/aws/jsii/jsii-calc/go/scopejsiicalclib" +) + +type MyClass interface { + Bar(_bar map[string]jcb.BaseProps) + Foo(_values []scopejsiicalclib.Number) +} + +// The jsii proxy struct for MyClass +type jsiiProxy_MyClass struct { + _ byte // padding +} + +func NewMyClass() MyClass { + _init_.Initialize() + + j := jsiiProxy_MyClass{} + + _jsii_.Create( + "jsii-calc.module2689.methods.MyClass", + nil /* no parameters */, + []_jsii_.FQN{}, + nil, // no overrides + &j, + ) + + return &j +} + +func (m *jsiiProxy_MyClass) Bar(_bar map[string]jcb.BaseProps) { + _jsii_.InvokeVoid( + m, + "bar", + []interface{}{_bar}, + ) +} + +func (m *jsiiProxy_MyClass) Foo(_values []scopejsiicalclib.Number) { + _jsii_.InvokeVoid( + m, + "foo", + []interface{}{_values}, + ) +} + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2689/methods/methods.init.go 1`] = ` +package methods + +import ( + "reflect" + + _jsii_ "github.com/aws/jsii-runtime-go" +) + +func init() { + _jsii_.RegisterClass( + "jsii-calc.module2689.methods.MyClass", + reflect.TypeOf((*MyClass)(nil)).Elem(), + []_jsii_.Member{ + _jsii_.MemberMethod{JsiiMethod: "bar", GoMethod: "Bar"}, + _jsii_.MemberMethod{JsiiMethod: "foo", GoMethod: "Foo"}, + }, + func() interface{} { + return &jsiiProxy_MyClass{} + }, + ) +} + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2689/module2689.go 1`] = ` +package module2689 + + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2689/props/props.go 1`] = ` +package props + +import ( + _jsii_ "github.com/aws/jsii-runtime-go" + _init_ "github.com/aws/jsii/jsii-calc/go/jsiicalc/v3/jsii" + + "github.com/aws/jsii/jsii-calc/go/jcb" + "github.com/aws/jsii/jsii-calc/go/scopejsiicalclib" +) + +type MyClass interface { + Bar() map[string]jcb.BaseProps + Foo() []scopejsiicalclib.Number +} + +// The jsii proxy struct for MyClass +type jsiiProxy_MyClass struct { + _ byte // padding +} + +func (j *jsiiProxy_MyClass) Bar() map[string]jcb.BaseProps { + var returns map[string]jcb.BaseProps + _jsii_.Get( + j, + "bar", + &returns, + ) + return returns +} + +func (j *jsiiProxy_MyClass) Foo() []scopejsiicalclib.Number { + var returns []scopejsiicalclib.Number + _jsii_.Get( + j, + "foo", + &returns, + ) + return returns +} + + +func NewMyClass() MyClass { + _init_.Initialize() + + j := jsiiProxy_MyClass{} + + _jsii_.Create( + "jsii-calc.module2689.props.MyClass", + nil /* no parameters */, + []_jsii_.FQN{}, + nil, // no overrides + &j, + ) + + return &j +} + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2689/props/props.init.go 1`] = ` +package props + +import ( + "reflect" + + _jsii_ "github.com/aws/jsii-runtime-go" +) + +func init() { + _jsii_.RegisterClass( + "jsii-calc.module2689.props.MyClass", + reflect.TypeOf((*MyClass)(nil)).Elem(), + []_jsii_.Member{ + _jsii_.MemberProperty{JsiiProperty: "bar", GoGetter: "Bar"}, + _jsii_.MemberProperty{JsiiProperty: "foo", GoGetter: "Foo"}, + }, + func() interface{} { + return &jsiiProxy_MyClass{} + }, + ) +} + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2689/retval/retval.go 1`] = ` +package retval + +import ( + _jsii_ "github.com/aws/jsii-runtime-go" + _init_ "github.com/aws/jsii/jsii-calc/go/jsiicalc/v3/jsii" + + "github.com/aws/jsii/jsii-calc/go/jcb" + "github.com/aws/jsii/jsii-calc/go/scopejsiicalclib" +) + +type MyClass interface { + Bar() map[string]jcb.BaseProps + Foo() []scopejsiicalclib.Number +} + +// The jsii proxy struct for MyClass +type jsiiProxy_MyClass struct { + _ byte // padding +} + +func NewMyClass() MyClass { + _init_.Initialize() + + j := jsiiProxy_MyClass{} + + _jsii_.Create( + "jsii-calc.module2689.retval.MyClass", + nil /* no parameters */, + []_jsii_.FQN{}, + nil, // no overrides + &j, + ) + + return &j +} + +func (m *jsiiProxy_MyClass) Bar() map[string]jcb.BaseProps { + var returns map[string]jcb.BaseProps + + _jsii_.Invoke( + m, + "bar", + nil /* no parameters */, + &returns, + ) + + return returns +} + +func (m *jsiiProxy_MyClass) Foo() []scopejsiicalclib.Number { + var returns []scopejsiicalclib.Number + + _jsii_.Invoke( + m, + "foo", + nil /* no parameters */, + &returns, + ) + + return returns +} + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2689/retval/retval.init.go 1`] = ` +package retval + +import ( + "reflect" + + _jsii_ "github.com/aws/jsii-runtime-go" +) + +func init() { + _jsii_.RegisterClass( + "jsii-calc.module2689.retval.MyClass", + reflect.TypeOf((*MyClass)(nil)).Elem(), + []_jsii_.Member{ + _jsii_.MemberMethod{JsiiMethod: "bar", GoMethod: "Bar"}, + _jsii_.MemberMethod{JsiiMethod: "foo", GoMethod: "Foo"}, + }, + func() interface{} { + return &jsiiProxy_MyClass{} + }, + ) +} + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2689/structs/structs.go 1`] = ` +package structs + +import ( + "github.com/aws/jsii/jsii-calc/go/jcb" + "github.com/aws/jsii/jsii-calc/go/scopejsiicalclib" +) + +type MyStruct struct { + BaseMap map[string]jcb.BaseProps \`json:"baseMap"\` + Numbers []scopejsiicalclib.Number \`json:"numbers"\` +} + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2689/structs/structs.init.go 1`] = ` +package structs + +import ( + "reflect" + + _jsii_ "github.com/aws/jsii-runtime-go" +) + +func init() { + _jsii_.RegisterStruct( + "jsii-calc.module2689.structs.MyStruct", + reflect.TypeOf((*MyStruct)(nil)).Elem(), + ) +} + +`; + exports[`Generated code for "jsii-calc": /go/jsiicalc/nodirect/nodirect.go 1`] = ` package nodirect diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap index ad1b732858..7ba7f3159c 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-java.test.ts.snap @@ -3712,6 +3712,15 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┣━ 📄 MethodNamedProperty.java ┃ ┣━ 📁 module2647 ┃ ┃ ┗━ 📄 ExtendAndImplement.java + ┃ ┣━ 📁 module2689 + ┃ ┃ ┣━ 📁 methods + ┃ ┃ ┃ ┗━ 📄 MyClass.java + ┃ ┃ ┣━ 📁 props + ┃ ┃ ┃ ┗━ 📄 MyClass.java + ┃ ┃ ┣━ 📁 retval + ┃ ┃ ┃ ┗━ 📄 MyClass.java + ┃ ┃ ┗━ 📁 structs + ┃ ┃ ┗━ 📄 MyStruct.java ┃ ┣━ 📄 Multiply.java ┃ ┣━ 📄 Negate.java ┃ ┣━ 📄 NestedClassInstance.java @@ -21764,6 +21773,289 @@ public class ExtendAndImplement extends software.amazon.jsii.tests.calculator.li `; +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/module2689/methods/MyClass.java 1`] = ` +package software.amazon.jsii.tests.calculator.module2689.methods; + +/** + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.module2689.methods.MyClass") +public class MyClass extends software.amazon.jsii.JsiiObject { + + protected MyClass(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected MyClass(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public MyClass() { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + /** + * @param _bar This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public void bar(final @org.jetbrains.annotations.NotNull java.util.Map _bar) { + software.amazon.jsii.Kernel.call(this, "bar", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(_bar, "_bar is required") }); + } + + /** + * @param _values This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public void foo(final @org.jetbrains.annotations.NotNull java.util.List _values) { + software.amazon.jsii.Kernel.call(this, "foo", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(_values, "_values is required") }); + } +} + +`; + +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/module2689/props/MyClass.java 1`] = ` +package software.amazon.jsii.tests.calculator.module2689.props; + +/** + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.module2689.props.MyClass") +public class MyClass extends software.amazon.jsii.JsiiObject { + + protected MyClass(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected MyClass(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public MyClass() { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public @org.jetbrains.annotations.NotNull java.util.Map getBar() { + return java.util.Collections.unmodifiableMap(software.amazon.jsii.Kernel.get(this, "bar", software.amazon.jsii.NativeType.mapOf(software.amazon.jsii.NativeType.forClass(software.amazon.jsii.tests.calculator.base.BaseProps.class)))); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public @org.jetbrains.annotations.NotNull java.util.List getFoo() { + return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.get(this, "foo", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(software.amazon.jsii.tests.calculator.lib.Number.class)))); + } +} + +`; + +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/module2689/retval/MyClass.java 1`] = ` +package software.amazon.jsii.tests.calculator.module2689.retval; + +/** + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.module2689.retval.MyClass") +public class MyClass extends software.amazon.jsii.JsiiObject { + + protected MyClass(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected MyClass(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public MyClass() { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public @org.jetbrains.annotations.NotNull java.util.Map bar() { + return java.util.Collections.unmodifiableMap(software.amazon.jsii.Kernel.call(this, "bar", software.amazon.jsii.NativeType.mapOf(software.amazon.jsii.NativeType.forClass(software.amazon.jsii.tests.calculator.base.BaseProps.class)))); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public @org.jetbrains.annotations.NotNull java.util.List foo() { + return java.util.Collections.unmodifiableList(software.amazon.jsii.Kernel.call(this, "foo", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(software.amazon.jsii.tests.calculator.lib.Number.class)))); + } +} + +`; + +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/module2689/structs/MyStruct.java 1`] = ` +package software.amazon.jsii.tests.calculator.module2689.structs; + +/** + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.module2689.structs.MyStruct") +@software.amazon.jsii.Jsii.Proxy(MyStruct.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) +public interface MyStruct extends software.amazon.jsii.JsiiSerializable { + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @org.jetbrains.annotations.NotNull java.util.Map getBaseMap(); + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @org.jetbrains.annotations.NotNull java.util.List getNumbers(); + + /** + * @return a {@link Builder} of {@link MyStruct} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + static Builder builder() { + return new Builder(); + } + /** + * A builder for {@link MyStruct} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public static final class Builder implements software.amazon.jsii.Builder { + private java.util.Map baseMap; + private java.util.List numbers; + + /** + * Sets the value of {@link MyStruct#getBaseMap} + * @param baseMap the value to be set. This parameter is required. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @SuppressWarnings("unchecked") + public Builder baseMap(java.util.Map baseMap) { + this.baseMap = (java.util.Map)baseMap; + return this; + } + + /** + * Sets the value of {@link MyStruct#getNumbers} + * @param numbers the value to be set. This parameter is required. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @SuppressWarnings("unchecked") + public Builder numbers(java.util.List numbers) { + this.numbers = (java.util.List)numbers; + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link MyStruct} + * @throws NullPointerException if any required attribute was not provided + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @Override + public MyStruct build() { + return new Jsii$Proxy(baseMap, numbers); + } + } + + /** + * An implementation for {@link MyStruct} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @software.amazon.jsii.Internal + final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements MyStruct { + private final java.util.Map baseMap; + private final java.util.List numbers; + + /** + * Constructor that initializes the object based on values retrieved from the JsiiObject. + * @param objRef Reference to the JSII managed object. + */ + protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + this.baseMap = software.amazon.jsii.Kernel.get(this, "baseMap", software.amazon.jsii.NativeType.mapOf(software.amazon.jsii.NativeType.forClass(software.amazon.jsii.tests.calculator.base.BaseProps.class))); + this.numbers = software.amazon.jsii.Kernel.get(this, "numbers", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(software.amazon.jsii.tests.calculator.lib.Number.class))); + } + + /** + * Constructor that initializes the object based on literal property values passed by the {@link Builder}. + */ + @SuppressWarnings("unchecked") + protected Jsii$Proxy(final java.util.Map baseMap, final java.util.List numbers) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + this.baseMap = (java.util.Map)java.util.Objects.requireNonNull(baseMap, "baseMap is required"); + this.numbers = (java.util.List)java.util.Objects.requireNonNull(numbers, "numbers is required"); + } + + @Override + public final java.util.Map getBaseMap() { + return this.baseMap; + } + + @Override + public final java.util.List getNumbers() { + return this.numbers; + } + + @Override + @software.amazon.jsii.Internal + public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() { + final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE; + final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + + data.set("baseMap", om.valueToTree(this.getBaseMap())); + data.set("numbers", om.valueToTree(this.getNumbers())); + + final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + struct.set("fqn", om.valueToTree("jsii-calc.module2689.structs.MyStruct")); + struct.set("data", data); + + final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + obj.set("$jsii.struct", struct); + + return obj; + } + + @Override + public final boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + MyStruct.Jsii$Proxy that = (MyStruct.Jsii$Proxy) o; + + if (!baseMap.equals(that.baseMap)) return false; + return this.numbers.equals(that.numbers); + } + + @Override + public final int hashCode() { + int result = this.baseMap.hashCode(); + result = 31 * result + (this.numbers.hashCode()); + return result; + } + } +} + +`; + exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/nodirect/sub1/TypeFromSub1.java 1`] = ` package software.amazon.jsii.tests.calculator.nodirect.sub1; @@ -23614,6 +23906,10 @@ jsii-calc.WithPrivatePropertyInConstructor=software.amazon.jsii.tests.calculator jsii-calc.composition.CompositeOperation=software.amazon.jsii.tests.calculator.composition.CompositeOperation jsii-calc.composition.CompositeOperation.CompositionStringStyle=software.amazon.jsii.tests.calculator.composition.CompositeOperation$CompositionStringStyle jsii-calc.module2647.ExtendAndImplement=software.amazon.jsii.tests.calculator.module2647.ExtendAndImplement +jsii-calc.module2689.methods.MyClass=software.amazon.jsii.tests.calculator.module2689.methods.MyClass +jsii-calc.module2689.props.MyClass=software.amazon.jsii.tests.calculator.module2689.props.MyClass +jsii-calc.module2689.retval.MyClass=software.amazon.jsii.tests.calculator.module2689.retval.MyClass +jsii-calc.module2689.structs.MyStruct=software.amazon.jsii.tests.calculator.module2689.structs.MyStruct jsii-calc.nodirect.sub1.TypeFromSub1=software.amazon.jsii.tests.calculator.nodirect.sub1.TypeFromSub1 jsii-calc.nodirect.sub2.TypeFromSub2=software.amazon.jsii.tests.calculator.nodirect.sub2.TypeFromSub2 jsii-calc.onlystatic.OnlyStaticMethods=software.amazon.jsii.tests.calculator.onlystatic.OnlyStaticMethods diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap index c853d1f10e..fae2560f1a 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap @@ -2103,6 +2103,16 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┗━ 📄 __init__.py ┣━ 📁 module2647 ┃ ┗━ 📄 __init__.py + ┣━ 📁 module2689 + ┃ ┣━ 📄 __init__.py + ┃ ┣━ 📁 methods + ┃ ┃ ┗━ 📄 __init__.py + ┃ ┣━ 📁 props + ┃ ┃ ┗━ 📄 __init__.py + ┃ ┣━ 📁 retval + ┃ ┃ ┗━ 📄 __init__.py + ┃ ┗━ 📁 structs + ┃ ┗━ 📄 __init__.py ┣━ 📁 nodirect ┃ ┣━ 📄 __init__.py ┃ ┣━ 📁 sub1 @@ -2417,6 +2427,11 @@ kwargs = json.loads( "jsii_calc.interface_in_namespace_includes_classes", "jsii_calc.interface_in_namespace_only_interface", "jsii_calc.module2647", + "jsii_calc.module2689", + "jsii_calc.module2689.methods", + "jsii_calc.module2689.props", + "jsii_calc.module2689.retval", + "jsii_calc.module2689.structs", "jsii_calc.nodirect", "jsii_calc.nodirect.sub1", "jsii_calc.nodirect.sub2", @@ -10418,6 +10433,222 @@ publication.publish() `; +exports[`Generated code for "jsii-calc": /python/src/jsii_calc/module2689/__init__.py 1`] = ` +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import publication +import typing_extensions + +from .._jsii import * + + +publication.publish() + +`; + +exports[`Generated code for "jsii-calc": /python/src/jsii_calc/module2689/methods/__init__.py 1`] = ` +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import publication +import typing_extensions + +from ..._jsii import * + +import scope.jsii_calc_base +import scope.jsii_calc_lib + + +class MyClass( + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.module2689.methods.MyClass", +): + def __init__(self) -> None: + jsii.create(MyClass, self, []) + + @jsii.member(jsii_name="bar") + def bar( + self, + _bar: typing.Mapping[builtins.str, scope.jsii_calc_base.BaseProps], + ) -> None: + ''' + :param _bar: - + ''' + return typing.cast(None, jsii.invoke(self, "bar", [_bar])) + + @jsii.member(jsii_name="foo") + def foo(self, _values: typing.List[scope.jsii_calc_lib.Number]) -> None: + ''' + :param _values: - + ''' + return typing.cast(None, jsii.invoke(self, "foo", [_values])) + + +__all__ = [ + "MyClass", +] + +publication.publish() + +`; + +exports[`Generated code for "jsii-calc": /python/src/jsii_calc/module2689/props/__init__.py 1`] = ` +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import publication +import typing_extensions + +from ..._jsii import * + +import scope.jsii_calc_base +import scope.jsii_calc_lib + + +class MyClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2689.props.MyClass"): + def __init__(self) -> None: + jsii.create(MyClass, self, []) + + @builtins.property # type: ignore[misc] + @jsii.member(jsii_name="bar") + def bar(self) -> typing.Mapping[builtins.str, scope.jsii_calc_base.BaseProps]: + return typing.cast(typing.Mapping[builtins.str, scope.jsii_calc_base.BaseProps], jsii.get(self, "bar")) + + @builtins.property # type: ignore[misc] + @jsii.member(jsii_name="foo") + def foo(self) -> typing.List[scope.jsii_calc_lib.Number]: + return typing.cast(typing.List[scope.jsii_calc_lib.Number], jsii.get(self, "foo")) + + +__all__ = [ + "MyClass", +] + +publication.publish() + +`; + +exports[`Generated code for "jsii-calc": /python/src/jsii_calc/module2689/retval/__init__.py 1`] = ` +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import publication +import typing_extensions + +from ..._jsii import * + +import scope.jsii_calc_base +import scope.jsii_calc_lib + + +class MyClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2689.retval.MyClass"): + def __init__(self) -> None: + jsii.create(MyClass, self, []) + + @jsii.member(jsii_name="bar") + def bar(self) -> typing.Mapping[builtins.str, scope.jsii_calc_base.BaseProps]: + return typing.cast(typing.Mapping[builtins.str, scope.jsii_calc_base.BaseProps], jsii.invoke(self, "bar", [])) + + @jsii.member(jsii_name="foo") + def foo(self) -> typing.List[scope.jsii_calc_lib.Number]: + return typing.cast(typing.List[scope.jsii_calc_lib.Number], jsii.invoke(self, "foo", [])) + + +__all__ = [ + "MyClass", +] + +publication.publish() + +`; + +exports[`Generated code for "jsii-calc": /python/src/jsii_calc/module2689/structs/__init__.py 1`] = ` +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import publication +import typing_extensions + +from ..._jsii import * + +import scope.jsii_calc_base +import scope.jsii_calc_lib + + +@jsii.data_type( + jsii_type="jsii-calc.module2689.structs.MyStruct", + jsii_struct_bases=[], + name_mapping={"base_map": "baseMap", "numbers": "numbers"}, +) +class MyStruct: + def __init__( + self, + *, + base_map: typing.Mapping[builtins.str, scope.jsii_calc_base.BaseProps], + numbers: typing.List[scope.jsii_calc_lib.Number], + ) -> None: + ''' + :param base_map: + :param numbers: + ''' + self._values: typing.Dict[str, typing.Any] = { + "base_map": base_map, + "numbers": numbers, + } + + @builtins.property + def base_map(self) -> typing.Mapping[builtins.str, scope.jsii_calc_base.BaseProps]: + result = self._values.get("base_map") + assert result is not None, "Required property 'base_map' is missing" + return typing.cast(typing.Mapping[builtins.str, scope.jsii_calc_base.BaseProps], result) + + @builtins.property + def numbers(self) -> typing.List[scope.jsii_calc_lib.Number]: + result = self._values.get("numbers") + assert result is not None, "Required property 'numbers' is missing" + return typing.cast(typing.List[scope.jsii_calc_lib.Number], result) + + def __eq__(self, rhs: typing.Any) -> builtins.bool: + return isinstance(rhs, self.__class__) and rhs._values == self._values + + def __ne__(self, rhs: typing.Any) -> builtins.bool: + return not (rhs == self) + + def __repr__(self) -> str: + return "MyStruct(%s)" % ", ".join( + k + "=" + repr(v) for k, v in self._values.items() + ) + + +__all__ = [ + "MyStruct", +] + +publication.publish() + +`; + exports[`Generated code for "jsii-calc": /python/src/jsii_calc/nodirect/__init__.py 1`] = ` import abc import builtins diff --git a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap index 2463cf3987..919bf194c9 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap @@ -116,6 +116,56 @@ exports[`jsii-tree --all 1`] = ` │ │ │ │ └── returns: string │ │ │ └─┬ localMethod() method (stable) │ │ │ └── returns: string + │ │ ├─┬ module2689 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ methods + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class MyClass (stable) + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer (stable) + │ │ │ │ │ ├─┬ bar(_bar) method (stable) + │ │ │ │ │ │ ├─┬ parameters + │ │ │ │ │ │ │ └─┬ _bar + │ │ │ │ │ │ │ └── type: Map @scope/jsii-calc-base.BaseProps> + │ │ │ │ │ │ └── returns: void + │ │ │ │ │ └─┬ foo(_values) method (stable) + │ │ │ │ │ ├─┬ parameters + │ │ │ │ │ │ └─┬ _values + │ │ │ │ │ │ └── type: Array<@scope/jsii-calc-lib.Number> + │ │ │ │ │ └── returns: void + │ │ │ │ ├─┬ props + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class MyClass (stable) + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer (stable) + │ │ │ │ │ ├─┬ bar property (stable) + │ │ │ │ │ │ ├── immutable + │ │ │ │ │ │ └── type: Map @scope/jsii-calc-base.BaseProps> + │ │ │ │ │ └─┬ foo property (stable) + │ │ │ │ │ ├── immutable + │ │ │ │ │ └── type: Array<@scope/jsii-calc-lib.Number> + │ │ │ │ ├─┬ retval + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class MyClass (stable) + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer (stable) + │ │ │ │ │ ├─┬ bar() method (stable) + │ │ │ │ │ │ └── returns: Map @scope/jsii-calc-base.BaseProps> + │ │ │ │ │ └─┬ foo() method (stable) + │ │ │ │ │ └── returns: Array<@scope/jsii-calc-lib.Number> + │ │ │ │ └─┬ structs + │ │ │ │ └─┬ types + │ │ │ │ └─┬ interface MyStruct (stable) + │ │ │ │ └─┬ members + │ │ │ │ ├─┬ baseMap property (stable) + │ │ │ │ │ ├── abstract + │ │ │ │ │ ├── immutable + │ │ │ │ │ └── type: Map @scope/jsii-calc-base.BaseProps> + │ │ │ │ └─┬ numbers property (stable) + │ │ │ │ ├── abstract + │ │ │ │ ├── immutable + │ │ │ │ └── type: Array<@scope/jsii-calc-lib.Number> + │ │ │ └── types │ │ ├─┬ nodirect │ │ │ ├─┬ submodules │ │ │ │ ├─┬ sub1 @@ -2963,6 +3013,21 @@ exports[`jsii-tree --inheritance 1`] = ` │ │ │ └─┬ class ExtendAndImplement │ │ │ ├── base: BaseFor2647 │ │ │ └── interfaces: IFriendly + │ │ ├─┬ module2689 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ methods + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class MyClass + │ │ │ │ ├─┬ props + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class MyClass + │ │ │ │ ├─┬ retval + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class MyClass + │ │ │ │ └─┬ structs + │ │ │ │ └─┬ types + │ │ │ │ └── interface MyStruct + │ │ │ └── types │ │ ├─┬ nodirect │ │ │ ├─┬ submodules │ │ │ │ ├─┬ sub1 @@ -3393,6 +3458,36 @@ exports[`jsii-tree --members 1`] = ` │ │ │ ├── (very) initializer │ │ │ ├── hello() method │ │ │ └── localMethod() method + │ │ ├─┬ module2689 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ methods + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class MyClass + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer + │ │ │ │ │ ├── bar(_bar) method + │ │ │ │ │ └── foo(_values) method + │ │ │ │ ├─┬ props + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class MyClass + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer + │ │ │ │ │ ├── bar property + │ │ │ │ │ └── foo property + │ │ │ │ ├─┬ retval + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class MyClass + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer + │ │ │ │ │ ├── bar() method + │ │ │ │ │ └── foo() method + │ │ │ │ └─┬ structs + │ │ │ │ └─┬ types + │ │ │ │ └─┬ interface MyStruct + │ │ │ │ └─┬ members + │ │ │ │ ├── baseMap property + │ │ │ │ └── numbers property + │ │ │ └── types │ │ ├─┬ nodirect │ │ │ ├─┬ submodules │ │ │ │ ├─┬ sub1 @@ -4665,6 +4760,12 @@ exports[`jsii-tree --signatures 1`] = ` │ ├── PythonSelf │ ├── composition │ ├── module2647 + │ ├─┬ module2689 + │ │ └─┬ submodules + │ │ ├── methods + │ │ ├── props + │ │ ├── retval + │ │ └── structs │ ├─┬ nodirect │ │ └─┬ submodules │ │ ├── sub1 @@ -4716,6 +4817,21 @@ exports[`jsii-tree --types 1`] = ` │ │ ├─┬ module2647 │ │ │ └─┬ types │ │ │ └── class ExtendAndImplement + │ │ ├─┬ module2689 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ methods + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class MyClass + │ │ │ │ ├─┬ props + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class MyClass + │ │ │ │ ├─┬ retval + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class MyClass + │ │ │ │ └─┬ structs + │ │ │ │ └─┬ types + │ │ │ │ └── interface MyStruct + │ │ │ └── types │ │ ├─┬ nodirect │ │ │ ├─┬ submodules │ │ │ │ ├─┬ sub1 @@ -5018,6 +5134,12 @@ exports[`jsii-tree 1`] = ` │ ├── PythonSelf │ ├── composition │ ├── module2647 + │ ├─┬ module2689 + │ │ └─┬ submodules + │ │ ├── methods + │ │ ├── props + │ │ ├── retval + │ │ └── structs │ ├─┬ nodirect │ │ └─┬ submodules │ │ ├── sub1 diff --git a/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap b/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap index 6eaa378b93..93f71ec70a 100644 --- a/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap @@ -10,6 +10,12 @@ exports[`defaults 1`] = ` │ ├── PythonSelf │ ├── composition │ ├── module2647 + │ ├─┬ module2689 + │ │ └─┬ submodules + │ │ ├── methods + │ │ ├── props + │ │ ├── retval + │ │ └── structs │ ├─┬ nodirect │ │ └─┬ submodules │ │ ├── sub1 @@ -43,6 +49,12 @@ exports[`inheritance 1`] = ` │ ├── PythonSelf │ ├── composition │ ├── module2647 + │ ├─┬ module2689 + │ │ └─┬ submodules + │ │ ├── methods + │ │ ├── props + │ │ ├── retval + │ │ └── structs │ ├─┬ nodirect │ │ └─┬ submodules │ │ ├── sub1 @@ -76,6 +88,12 @@ exports[`members 1`] = ` │ ├── PythonSelf │ ├── composition │ ├── module2647 + │ ├─┬ module2689 + │ │ └─┬ submodules + │ │ ├── methods + │ │ ├── props + │ │ ├── retval + │ │ └── structs │ ├─┬ nodirect │ │ └─┬ submodules │ │ ├── sub1 @@ -215,6 +233,56 @@ exports[`showAll 1`] = ` │ │ │ │ └── returns: string │ │ │ └─┬ localMethod() method │ │ │ └── returns: string + │ │ ├─┬ module2689 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ methods + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class MyClass + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer + │ │ │ │ │ ├─┬ bar(_bar) method + │ │ │ │ │ │ ├─┬ parameters + │ │ │ │ │ │ │ └─┬ _bar + │ │ │ │ │ │ │ └── type: Map @scope/jsii-calc-base.BaseProps> + │ │ │ │ │ │ └── returns: void + │ │ │ │ │ └─┬ foo(_values) method + │ │ │ │ │ ├─┬ parameters + │ │ │ │ │ │ └─┬ _values + │ │ │ │ │ │ └── type: Array<@scope/jsii-calc-lib.Number> + │ │ │ │ │ └── returns: void + │ │ │ │ ├─┬ props + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class MyClass + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer + │ │ │ │ │ ├─┬ bar property + │ │ │ │ │ │ ├── immutable + │ │ │ │ │ │ └── type: Map @scope/jsii-calc-base.BaseProps> + │ │ │ │ │ └─┬ foo property + │ │ │ │ │ ├── immutable + │ │ │ │ │ └── type: Array<@scope/jsii-calc-lib.Number> + │ │ │ │ ├─┬ retval + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class MyClass + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer + │ │ │ │ │ ├─┬ bar() method + │ │ │ │ │ │ └── returns: Map @scope/jsii-calc-base.BaseProps> + │ │ │ │ │ └─┬ foo() method + │ │ │ │ │ └── returns: Array<@scope/jsii-calc-lib.Number> + │ │ │ │ └─┬ structs + │ │ │ │ └─┬ types + │ │ │ │ └─┬ interface MyStruct + │ │ │ │ └─┬ members + │ │ │ │ ├─┬ baseMap property + │ │ │ │ │ ├── abstract + │ │ │ │ │ ├── immutable + │ │ │ │ │ └── type: Map @scope/jsii-calc-base.BaseProps> + │ │ │ │ └─┬ numbers property + │ │ │ │ ├── abstract + │ │ │ │ ├── immutable + │ │ │ │ └── type: Array<@scope/jsii-calc-lib.Number> + │ │ │ └── types │ │ ├─┬ nodirect │ │ │ ├─┬ submodules │ │ │ │ ├─┬ sub1 @@ -3040,6 +3108,12 @@ exports[`signatures 1`] = ` │ ├── PythonSelf │ ├── composition │ ├── module2647 + │ ├─┬ module2689 + │ │ └─┬ submodules + │ │ ├── methods + │ │ ├── props + │ │ ├── retval + │ │ └── structs │ ├─┬ nodirect │ │ └─┬ submodules │ │ ├── sub1 @@ -3091,6 +3165,21 @@ exports[`types 1`] = ` │ │ ├─┬ module2647 │ │ │ └─┬ types │ │ │ └── class ExtendAndImplement + │ │ ├─┬ module2689 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ methods + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class MyClass + │ │ │ │ ├─┬ props + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class MyClass + │ │ │ │ ├─┬ retval + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class MyClass + │ │ │ │ └─┬ structs + │ │ │ │ └─┬ types + │ │ │ │ └── interface MyStruct + │ │ │ └── types │ │ ├─┬ nodirect │ │ │ ├─┬ submodules │ │ │ │ ├─┬ sub1 diff --git a/packages/jsii-reflect/test/__snapshots__/type-system.test.ts.snap b/packages/jsii-reflect/test/__snapshots__/type-system.test.ts.snap index 0cb209e9d1..a752a4b7b4 100644 --- a/packages/jsii-reflect/test/__snapshots__/type-system.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/type-system.test.ts.snap @@ -155,6 +155,9 @@ Array [ "jsii-calc.WithPrivatePropertyInConstructor", "jsii-calc.composition.CompositeOperation", "jsii-calc.module2647.ExtendAndImplement", + "jsii-calc.module2689.methods.MyClass", + "jsii-calc.module2689.props.MyClass", + "jsii-calc.module2689.retval.MyClass", "jsii-calc.nodirect.sub1.TypeFromSub1", "jsii-calc.nodirect.sub2.TypeFromSub2", "jsii-calc.onlystatic.OnlyStaticMethods",