From 52bd510a994597cc166effde0b8c658a2a8cb0df Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Mon, 15 Mar 2021 17:08:22 +0200 Subject: [PATCH] fix(go): duplicate conversion functions when parent structs have the same base name (#2697) If a struct has two parent structs with the same base name (but different packages), the emitted conversion function will have the same name (`ToParentStruct` and `ToParentStruct`). Since we are not even sure that these base conversion functions are required, omit them for now and we can decide to restore them at a later stage if the use case is clearer. Fixes #2692 --- packages/jsii-calc/lib/index.ts | 2 + packages/jsii-calc/lib/module2530/index.ts | 17 + packages/jsii-calc/lib/module2692/index.ts | 2 + .../lib/module2692/submodule1/index.ts | 3 + .../lib/module2692/submodule2/index.ts | 9 + packages/jsii-calc/test/assembly.jsii | 198 +++++++- .../lib/targets/go/types/struct.ts | 33 -- packages/jsii-pacmak/lib/targets/go/util.ts | 1 + .../__snapshots__/target-dotnet.test.ts.snap | 256 ++++++++++ .../__snapshots__/target-go.test.ts.snap | 265 ++++++---- .../__snapshots__/target-java.test.ts.snap | 470 ++++++++++++++++++ .../__snapshots__/target-python.test.ts.snap | 245 +++++++++ .../test/__snapshots__/jsii-tree.test.ts.snap | 109 ++++ .../test/__snapshots__/tree.test.ts.snap | 80 +++ .../__snapshots__/type-system.test.ts.snap | 1 + 15 files changed, 1559 insertions(+), 132 deletions(-) create mode 100644 packages/jsii-calc/lib/module2530/index.ts create mode 100644 packages/jsii-calc/lib/module2692/index.ts create mode 100644 packages/jsii-calc/lib/module2692/submodule1/index.ts create mode 100644 packages/jsii-calc/lib/module2692/submodule2/index.ts diff --git a/packages/jsii-calc/lib/index.ts b/packages/jsii-calc/lib/index.ts index 724888b22e..59cc6566c7 100644 --- a/packages/jsii-calc/lib/index.ts +++ b/packages/jsii-calc/lib/index.ts @@ -13,3 +13,5 @@ export * as onlystatic from './only-static'; export * as nodirect from './no-direct-types'; export * as module2647 from './module2647'; export * as module2689 from './module2689'; +export * as module2692 from './module2692'; +export * as module2530 from './module2530'; diff --git a/packages/jsii-calc/lib/module2530/index.ts b/packages/jsii-calc/lib/module2530/index.ts new file mode 100644 index 0000000000..5bf1737738 --- /dev/null +++ b/packages/jsii-calc/lib/module2530/index.ts @@ -0,0 +1,17 @@ +/** + * Verifies a method with parameters "_" can be generated. + * @see https://github.com/aws/jsii/issues/2530 + */ +export class MyClass { + public static bar(_: boolean) { + return; + } + + public constructor(_: number) { + return; + } + + public foo(_: string) { + return; + } +} diff --git a/packages/jsii-calc/lib/module2692/index.ts b/packages/jsii-calc/lib/module2692/index.ts new file mode 100644 index 0000000000..b99b106127 --- /dev/null +++ b/packages/jsii-calc/lib/module2692/index.ts @@ -0,0 +1,2 @@ +export * as submodule1 from './submodule1'; +export * as submodule2 from './submodule2'; diff --git a/packages/jsii-calc/lib/module2692/submodule1/index.ts b/packages/jsii-calc/lib/module2692/submodule1/index.ts new file mode 100644 index 0000000000..0f415657c4 --- /dev/null +++ b/packages/jsii-calc/lib/module2692/submodule1/index.ts @@ -0,0 +1,3 @@ +export interface Bar { + readonly bar1: string; +} diff --git a/packages/jsii-calc/lib/module2692/submodule2/index.ts b/packages/jsii-calc/lib/module2692/submodule2/index.ts new file mode 100644 index 0000000000..78499f65a1 --- /dev/null +++ b/packages/jsii-calc/lib/module2692/submodule2/index.ts @@ -0,0 +1,9 @@ +import { Bar as Bar1 } from '../submodule1'; + +export interface Bar { + readonly bar2: string; +} + +export interface Foo extends Bar, Bar1 { + readonly foo2: string; +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 73ceb343b1..59f8a3a8bc 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -211,6 +211,12 @@ "line": 142 } }, + "jsii-calc.module2530": { + "locationInModule": { + "filename": "lib/index.ts", + "line": 17 + } + }, "jsii-calc.module2647": { "locationInModule": { "filename": "lib/index.ts", @@ -247,6 +253,24 @@ "line": 7 } }, + "jsii-calc.module2692": { + "locationInModule": { + "filename": "lib/index.ts", + "line": 16 + } + }, + "jsii-calc.module2692.submodule1": { + "locationInModule": { + "filename": "lib/module2692/index.ts", + "line": 1 + } + }, + "jsii-calc.module2692.submodule2": { + "locationInModule": { + "filename": "lib/module2692/index.ts", + "line": 2 + } + }, "jsii-calc.nodirect": { "locationInModule": { "filename": "lib/index.ts", @@ -14155,6 +14179,78 @@ "name": "CompositionStringStyle", "namespace": "composition.CompositeOperation" }, + "jsii-calc.module2530.MyClass": { + "assembly": "jsii-calc", + "docs": { + "see": "https://github.com/aws/jsii/issues/2530", + "stability": "stable", + "summary": "Verifies a method with parameters \"_\" can be generated." + }, + "fqn": "jsii-calc.module2530.MyClass", + "initializer": { + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/module2530/index.ts", + "line": 10 + }, + "parameters": [ + { + "name": "_", + "type": { + "primitive": "number" + } + } + ] + }, + "kind": "class", + "locationInModule": { + "filename": "lib/module2530/index.ts", + "line": 5 + }, + "methods": [ + { + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/module2530/index.ts", + "line": 6 + }, + "name": "bar", + "parameters": [ + { + "name": "_", + "type": { + "primitive": "boolean" + } + } + ], + "static": true + }, + { + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/module2530/index.ts", + "line": 14 + }, + "name": "foo", + "parameters": [ + { + "name": "_", + "type": { + "primitive": "string" + } + } + ] + } + ], + "name": "MyClass", + "namespace": "module2530" + }, "jsii-calc.module2647.ExtendAndImplement": { "assembly": "jsii-calc", "base": "@scope/jsii-calc-lib.BaseFor2647", @@ -14470,6 +14566,106 @@ } ] }, + "jsii-calc.module2692.submodule1.Bar": { + "assembly": "jsii-calc", + "datatype": true, + "docs": { + "stability": "stable" + }, + "fqn": "jsii-calc.module2692.submodule1.Bar", + "kind": "interface", + "locationInModule": { + "filename": "lib/module2692/submodule1/index.ts", + "line": 1 + }, + "name": "Bar", + "namespace": "module2692.submodule1", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "stable" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/module2692/submodule1/index.ts", + "line": 2 + }, + "name": "bar1", + "type": { + "primitive": "string" + } + } + ] + }, + "jsii-calc.module2692.submodule2.Bar": { + "assembly": "jsii-calc", + "datatype": true, + "docs": { + "stability": "stable" + }, + "fqn": "jsii-calc.module2692.submodule2.Bar", + "kind": "interface", + "locationInModule": { + "filename": "lib/module2692/submodule2/index.ts", + "line": 3 + }, + "name": "Bar", + "namespace": "module2692.submodule2", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "stable" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/module2692/submodule2/index.ts", + "line": 4 + }, + "name": "bar2", + "type": { + "primitive": "string" + } + } + ] + }, + "jsii-calc.module2692.submodule2.Foo": { + "assembly": "jsii-calc", + "datatype": true, + "docs": { + "stability": "stable" + }, + "fqn": "jsii-calc.module2692.submodule2.Foo", + "interfaces": [ + "jsii-calc.module2692.submodule2.Bar", + "jsii-calc.module2692.submodule1.Bar" + ], + "kind": "interface", + "locationInModule": { + "filename": "lib/module2692/submodule2/index.ts", + "line": 7 + }, + "name": "Foo", + "namespace": "module2692.submodule2", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "stable" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/module2692/submodule2/index.ts", + "line": 8 + }, + "name": "foo2", + "type": { + "primitive": "string" + } + } + ] + }, "jsii-calc.nodirect.sub1.TypeFromSub1": { "assembly": "jsii-calc", "docs": { @@ -15226,5 +15422,5 @@ } }, "version": "3.20.120", - "fingerprint": "bEIqxJjC2BFJEo5AIzysYAdDCVZcHPAm+paBHx0vvKE=" + "fingerprint": "hBZRskNm0XPeSO9U+PMqKKVZ2faqmKnE9eVN2tY1Wik=" } diff --git a/packages/jsii-pacmak/lib/targets/go/types/struct.ts b/packages/jsii-pacmak/lib/targets/go/types/struct.ts index 0666e948fd..07b80d1b23 100644 --- a/packages/jsii-pacmak/lib/targets/go/types/struct.ts +++ b/packages/jsii-pacmak/lib/targets/go/types/struct.ts @@ -7,7 +7,6 @@ import { Package } from '../package'; import { JSII_RT_ALIAS } from '../runtime'; import { getMemberDependencies } from '../util'; import { GoType } from './go-type'; -import { GoTypeRef } from './go-type-reference'; import { GoProperty } from './type-member'; /* @@ -50,8 +49,6 @@ export class Struct extends GoType { } code.closeBlock(); code.line(); - - this.emitBaseConversions(context); } public emitRegistration(code: CodeMaker): void { @@ -60,34 +57,4 @@ export class Struct extends GoType { code.line(`reflect.TypeOf((*${this.name})(nil)).Elem(),`); code.close(')'); } - - private emitBaseConversions({ code }: EmitContext) { - for (const base of this.type.getInterfaces(true)) { - const baseType = this.pkg.root.findType(base.fqn) as Struct; - const funcName = `To${baseType.name}`; - const instanceVar = this.name[0].toLowerCase(); - const valType = new GoTypeRef(this.pkg.root, base.reference).scopedName( - this.pkg, - ); - - code.line( - `// ${funcName} is a convenience function to obtain a new ${valType} from this ${this.name}.`, - ); - // Note - using a pointer receiver here as a convenience, as otherwise - // user code that somehow has only a pointer would need to first - // dereference it, which tends to be a code smell. - code.openBlock( - `func (${instanceVar} *${this.name}) ${funcName}() ${valType}`, - ); - - code.openBlock(`return ${valType}`); - for (const prop of baseType.properties) { - code.line(`${prop.name}: ${instanceVar}.${prop.name},`); - } - code.closeBlock(); - - code.closeBlock(); - code.line(); - } - } } diff --git a/packages/jsii-pacmak/lib/targets/go/util.ts b/packages/jsii-pacmak/lib/targets/go/util.ts index dfaf47cab9..82e2a634dd 100644 --- a/packages/jsii-pacmak/lib/targets/go/util.ts +++ b/packages/jsii-pacmak/lib/targets/go/util.ts @@ -94,6 +94,7 @@ const RESERVED_WORDS: { [word: string]: string } = { import: 'import_', return: 'return_', var: 'var_', + _: '_arg', }; /* 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 2bf9a80efe..3fb31c5bb0 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 @@ -2893,6 +2893,8 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┣━ 📄 LevelOneProps.cs ┃ ┣━ 📄 LoadBalancedFargateServiceProps.cs ┃ ┣━ 📄 MethodNamedProperty.cs + ┃ ┣━ 📁 Module2530 + ┃ ┃ ┗━ 📄 MyClass.cs ┃ ┣━ 📁 Module2647 ┃ ┃ ┗━ 📄 ExtendAndImplement.cs ┃ ┣━ 📁 Module2689 @@ -2905,6 +2907,15 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┃ ┗━ 📁 Structs ┃ ┃ ┣━ 📄 IMyStruct.cs ┃ ┃ ┗━ 📄 MyStruct.cs + ┃ ┣━ 📁 Module2692 + ┃ ┃ ┣━ 📁 Submodule1 + ┃ ┃ ┃ ┣━ 📄 Bar.cs + ┃ ┃ ┃ ┗━ 📄 IBar.cs + ┃ ┃ ┗━ 📁 Submodule2 + ┃ ┃ ┣━ 📄 Bar.cs + ┃ ┃ ┣━ 📄 Foo.cs + ┃ ┃ ┣━ 📄 IBar.cs + ┃ ┃ ┗━ 📄 IFoo.cs ┃ ┣━ 📄 Multiply.cs ┃ ┣━ 📄 NamespaceDoc.cs ┃ ┣━ 📄 Negate.cs @@ -12131,6 +12142,54 @@ namespace Amazon.JSII.Tests.CalculatorNamespace `; +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2530/MyClass.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2530 +{ + /// Verifies a method with parameters "_" can be generated. + /// + /// See: https://github.com/aws/jsii/issues/2530 + /// + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Module2530.MyClass), fullyQualifiedName: "jsii-calc.module2530.MyClass", parametersJson: "[{\\"name\\":\\"_\\",\\"type\\":{\\"primitive\\":\\"number\\"}}]")] + public class MyClass : DeputyBase + { + public MyClass(double _): base(new DeputyProps(new object?[]{_})) + { + } + + /// 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\\":\\"_\\",\\"type\\":{\\"primitive\\":\\"boolean\\"}}]")] + public static void Bar(bool _) + { + InvokeStaticVoidMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.Module2530.MyClass), new System.Type[]{typeof(bool)}, new object[]{_}); + } + + [JsiiMethod(name: "foo", parametersJson: "[{\\"name\\":\\"_\\",\\"type\\":{\\"primitive\\":\\"string\\"}}]")] + public virtual void Foo(string _) + { + InvokeInstanceVoidMethod(new System.Type[]{typeof(string)}, new object[]{_}); + } + } +} + +`; + exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2647/ExtendAndImplement.cs 1`] = ` using Amazon.JSII.Runtime.Deputy; @@ -12394,6 +12453,203 @@ namespace Amazon.JSII.Tests.CalculatorNamespace.Module2689.Structs `; +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2692/Submodule1/Bar.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule1 +{ + #pragma warning disable CS8618 + + [JsiiByValue(fqn: "jsii-calc.module2692.submodule1.Bar")] + public class Bar : Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule1.IBar + { + [JsiiProperty(name: "bar1", typeJson: "{\\"primitive\\":\\"string\\"}", isOverride: true)] + public string Bar1 + { + get; + set; + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2692/Submodule1/IBar.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule1 +{ + [JsiiInterface(nativeType: typeof(IBar), fullyQualifiedName: "jsii-calc.module2692.submodule1.Bar")] + public interface IBar + { + [JsiiProperty(name: "bar1", typeJson: "{\\"primitive\\":\\"string\\"}")] + string Bar1 + { + get; + } + + [JsiiTypeProxy(nativeType: typeof(IBar), fullyQualifiedName: "jsii-calc.module2692.submodule1.Bar")] + internal sealed class _Proxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule1.IBar + { + private _Proxy(ByRefValue reference): base(reference) + { + } + + [JsiiProperty(name: "bar1", typeJson: "{\\"primitive\\":\\"string\\"}")] + public string Bar1 + { + get => GetInstanceProperty()!; + } + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2692/Submodule2/Bar.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule2 +{ + #pragma warning disable CS8618 + + [JsiiByValue(fqn: "jsii-calc.module2692.submodule2.Bar")] + public class Bar : Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule2.IBar + { + [JsiiProperty(name: "bar2", typeJson: "{\\"primitive\\":\\"string\\"}", isOverride: true)] + public string Bar2 + { + get; + set; + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2692/Submodule2/Foo.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule2 +{ + #pragma warning disable CS8618 + + [JsiiByValue(fqn: "jsii-calc.module2692.submodule2.Foo")] + public class Foo : Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule2.IFoo + { + [JsiiProperty(name: "foo2", typeJson: "{\\"primitive\\":\\"string\\"}", isOverride: true)] + public string Foo2 + { + get; + set; + } + + [JsiiProperty(name: "bar2", typeJson: "{\\"primitive\\":\\"string\\"}", isOverride: true)] + public string Bar2 + { + get; + set; + } + + [JsiiProperty(name: "bar1", typeJson: "{\\"primitive\\":\\"string\\"}", isOverride: true)] + public string Bar1 + { + get; + set; + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2692/Submodule2/IBar.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule2 +{ + [JsiiInterface(nativeType: typeof(IBar), fullyQualifiedName: "jsii-calc.module2692.submodule2.Bar")] + public interface IBar + { + [JsiiProperty(name: "bar2", typeJson: "{\\"primitive\\":\\"string\\"}")] + string Bar2 + { + get; + } + + [JsiiTypeProxy(nativeType: typeof(IBar), fullyQualifiedName: "jsii-calc.module2692.submodule2.Bar")] + internal sealed class _Proxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule2.IBar + { + private _Proxy(ByRefValue reference): base(reference) + { + } + + [JsiiProperty(name: "bar2", typeJson: "{\\"primitive\\":\\"string\\"}")] + public string Bar2 + { + get => GetInstanceProperty()!; + } + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Module2692/Submodule2/IFoo.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule2 +{ + [JsiiInterface(nativeType: typeof(IFoo), fullyQualifiedName: "jsii-calc.module2692.submodule2.Foo")] + public interface IFoo : Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule2.IBar, Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule1.IBar + { + [JsiiProperty(name: "foo2", typeJson: "{\\"primitive\\":\\"string\\"}")] + string Foo2 + { + get; + } + + [JsiiTypeProxy(nativeType: typeof(IFoo), fullyQualifiedName: "jsii-calc.module2692.submodule2.Foo")] + new internal sealed class _Proxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.Module2692.Submodule2.IFoo + { + private _Proxy(ByRefValue reference): base(reference) + { + } + + [JsiiProperty(name: "foo2", typeJson: "{\\"primitive\\":\\"string\\"}")] + public string Foo2 + { + get => GetInstanceProperty()!; + } + + [JsiiProperty(name: "bar2", typeJson: "{\\"primitive\\":\\"string\\"}")] + public string Bar2 + { + get => GetInstanceProperty()!; + } + + [JsiiProperty(name: "bar1", typeJson: "{\\"primitive\\":\\"string\\"}")] + public string Bar1 + { + get => GetInstanceProperty()!; + } + } + } +} + +`; + 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 eb15d0b961..d1763ed700 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 @@ -294,13 +294,6 @@ type BaseProps struct { Bar string \`json:"bar"\` } -// ToVeryBaseProps is a convenience function to obtain a new scopejsiicalcbaseofbase.VeryBaseProps from this BaseProps. -func (b *BaseProps) ToVeryBaseProps() scopejsiicalcbaseofbase.VeryBaseProps { - return scopejsiicalcbaseofbase.VeryBaseProps { - Foo: b.Foo, - } -} - type IBaseInterface interface { scopejsiicalcbaseofbase.IVeryBaseInterface Bar() @@ -1849,6 +1842,9 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┣━ 📄 jsiicalc.go ┣━ 📄 jsiicalc.init.go ┣━ 📄 LICENSE + ┣━ 📁 module2530 + ┃ ┣━ 📄 module2530.go + ┃ ┗━ 📄 module2530.init.go ┣━ 📁 module2647 ┃ ┣━ 📄 module2647.go ┃ ┗━ 📄 module2647.init.go @@ -1866,6 +1862,14 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┗━ 📁 structs ┃ ┣━ 📄 structs.go ┃ ┗━ 📄 structs.init.go + ┣━ 📁 module2692 + ┃ ┣━ 📄 module2692.go + ┃ ┣━ 📁 submodule1 + ┃ ┃ ┣━ 📄 submodule1.go + ┃ ┃ ┗━ 📄 submodule1.init.go + ┃ ┗━ 📁 submodule2 + ┃ ┣━ 📄 submodule2.go + ┃ ┗━ 📄 submodule2.init.go ┣━ 📁 nodirect ┃ ┣━ 📄 nodirect.go ┃ ┣━ 📁 sub1 @@ -4141,13 +4145,6 @@ type ChildStruct982 struct { Bar float64 \`json:"bar"\` } -// ToParentStruct982 is a convenience function to obtain a new ParentStruct982 from this ChildStruct982. -func (c *ChildStruct982) ToParentStruct982() ParentStruct982 { - return ParentStruct982 { - Foo: c.Foo, - } -} - type ClassThatImplementsTheInternalInterface interface { INonInternalInterface A() string @@ -5479,15 +5476,6 @@ type DerivedStruct struct { OptionalArray []string \`json:"optionalArray"\` } -// ToMyFirstStruct is a convenience function to obtain a new scopejsiicalclib.MyFirstStruct from this DerivedStruct. -func (d *DerivedStruct) ToMyFirstStruct() scopejsiicalclib.MyFirstStruct { - return scopejsiicalclib.MyFirstStruct { - Anumber: d.Anumber, - Astring: d.Astring, - FirstOptional: d.FirstOptional, - } -} - type DiamondBottom struct { // Deprecated. HoistedTop string \`json:"hoistedTop"\` @@ -5498,22 +5486,6 @@ type DiamondBottom struct { Bottom string \`json:"bottom"\` } -// ToDiamondLeft is a convenience function to obtain a new scopejsiicalclib.DiamondLeft from this DiamondBottom. -func (d *DiamondBottom) ToDiamondLeft() scopejsiicalclib.DiamondLeft { - return scopejsiicalclib.DiamondLeft { - HoistedTop: d.HoistedTop, - Left: d.Left, - } -} - -// ToDiamondRight is a convenience function to obtain a new scopejsiicalclib.DiamondRight from this DiamondBottom. -func (d *DiamondBottom) ToDiamondRight() scopejsiicalclib.DiamondRight { - return scopejsiicalclib.DiamondRight { - HoistedTop: d.HoistedTop, - Right: d.Right, - } -} - type DiamondInheritanceBaseLevelStruct struct { BaseLevelProperty string \`json:"baseLevelProperty"\` } @@ -5523,25 +5495,11 @@ type DiamondInheritanceFirstMidLevelStruct struct { FirstMidLevelProperty string \`json:"firstMidLevelProperty"\` } -// ToDiamondInheritanceBaseLevelStruct is a convenience function to obtain a new DiamondInheritanceBaseLevelStruct from this DiamondInheritanceFirstMidLevelStruct. -func (d *DiamondInheritanceFirstMidLevelStruct) ToDiamondInheritanceBaseLevelStruct() DiamondInheritanceBaseLevelStruct { - return DiamondInheritanceBaseLevelStruct { - BaseLevelProperty: d.BaseLevelProperty, - } -} - type DiamondInheritanceSecondMidLevelStruct struct { BaseLevelProperty string \`json:"baseLevelProperty"\` SecondMidLevelProperty string \`json:"secondMidLevelProperty"\` } -// ToDiamondInheritanceBaseLevelStruct is a convenience function to obtain a new DiamondInheritanceBaseLevelStruct from this DiamondInheritanceSecondMidLevelStruct. -func (d *DiamondInheritanceSecondMidLevelStruct) ToDiamondInheritanceBaseLevelStruct() DiamondInheritanceBaseLevelStruct { - return DiamondInheritanceBaseLevelStruct { - BaseLevelProperty: d.BaseLevelProperty, - } -} - type DiamondInheritanceTopLevelStruct struct { BaseLevelProperty string \`json:"baseLevelProperty"\` FirstMidLevelProperty string \`json:"firstMidLevelProperty"\` @@ -5549,29 +5507,6 @@ type DiamondInheritanceTopLevelStruct struct { TopLevelProperty string \`json:"topLevelProperty"\` } -// ToDiamondInheritanceBaseLevelStruct is a convenience function to obtain a new DiamondInheritanceBaseLevelStruct from this DiamondInheritanceTopLevelStruct. -func (d *DiamondInheritanceTopLevelStruct) ToDiamondInheritanceBaseLevelStruct() DiamondInheritanceBaseLevelStruct { - return DiamondInheritanceBaseLevelStruct { - BaseLevelProperty: d.BaseLevelProperty, - } -} - -// ToDiamondInheritanceFirstMidLevelStruct is a convenience function to obtain a new DiamondInheritanceFirstMidLevelStruct from this DiamondInheritanceTopLevelStruct. -func (d *DiamondInheritanceTopLevelStruct) ToDiamondInheritanceFirstMidLevelStruct() DiamondInheritanceFirstMidLevelStruct { - return DiamondInheritanceFirstMidLevelStruct { - BaseLevelProperty: d.BaseLevelProperty, - FirstMidLevelProperty: d.FirstMidLevelProperty, - } -} - -// ToDiamondInheritanceSecondMidLevelStruct is a convenience function to obtain a new DiamondInheritanceSecondMidLevelStruct from this DiamondInheritanceTopLevelStruct. -func (d *DiamondInheritanceTopLevelStruct) ToDiamondInheritanceSecondMidLevelStruct() DiamondInheritanceSecondMidLevelStruct { - return DiamondInheritanceSecondMidLevelStruct { - BaseLevelProperty: d.BaseLevelProperty, - SecondMidLevelProperty: d.SecondMidLevelProperty, - } -} - // Verifies that null/undefined can be returned for optional collections. // // This source of collections is disappointing - it'll always give you nothing :( @@ -7675,21 +7610,6 @@ type ImplictBaseOfBase struct { Goo string \`json:"goo"\` } -// ToVeryBaseProps is a convenience function to obtain a new scopejsiicalcbaseofbase.VeryBaseProps from this ImplictBaseOfBase. -func (i *ImplictBaseOfBase) ToVeryBaseProps() scopejsiicalcbaseofbase.VeryBaseProps { - return scopejsiicalcbaseofbase.VeryBaseProps { - Foo: i.Foo, - } -} - -// ToBaseProps is a convenience function to obtain a new jcb.BaseProps from this ImplictBaseOfBase. -func (i *ImplictBaseOfBase) ToBaseProps() jcb.BaseProps { - return jcb.BaseProps { - Foo: i.Foo, - Bar: i.Bar, - } -} - type InbetweenClass interface { PublicClass IPublicInterface2 @@ -14814,6 +14734,87 @@ func init() { `; +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2530/module2530.go 1`] = ` +package module2530 + +import ( + _jsii_ "github.com/aws/jsii-runtime-go" + _init_ "github.com/aws/jsii/jsii-calc/go/jsiicalc/v3/jsii" +) + +// Verifies a method with parameters "_" can be generated. +// See: https://github.com/aws/jsii/issues/2530 +// +type MyClass interface { + Foo(_arg string) +} + +// The jsii proxy struct for MyClass +type jsiiProxy_MyClass struct { + _ byte // padding +} + +func NewMyClass(_arg float64) MyClass { + _init_.Initialize() + + j := jsiiProxy_MyClass{} + + _jsii_.Create( + "jsii-calc.module2530.MyClass", + []interface{}{_arg}, + []_jsii_.FQN{}, + nil, // no overrides + &j, + ) + + return &j +} + +func MyClass_Bar(_arg bool) { + _init_.Initialize() + + _jsii_.StaticInvokeVoid( + "jsii-calc.module2530.MyClass", + "bar", + []interface{}{_arg}, + ) +} + +func (m *jsiiProxy_MyClass) Foo(_arg string) { + _jsii_.InvokeVoid( + m, + "foo", + []interface{}{_arg}, + ) +} + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2530/module2530.init.go 1`] = ` +package module2530 + +import ( + "reflect" + + _jsii_ "github.com/aws/jsii-runtime-go" +) + +func init() { + _jsii_.RegisterClass( + "jsii-calc.module2530.MyClass", + reflect.TypeOf((*MyClass)(nil)).Elem(), + []_jsii_.Member{ + _jsii_.MemberMethod{JsiiMethod: "foo", GoMethod: "Foo"}, + }, + func() interface{} { + return &jsiiProxy_MyClass{} + }, + ) +} + +`; + exports[`Generated code for "jsii-calc": /go/jsiicalc/module2647/module2647.go 1`] = ` package module2647 @@ -15226,6 +15227,81 @@ func init() { `; +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2692/module2692.go 1`] = ` +package module2692 + + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2692/submodule1/submodule1.go 1`] = ` +package submodule1 + + +type Bar struct { + Bar1 string \`json:"bar1"\` +} + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2692/submodule1/submodule1.init.go 1`] = ` +package submodule1 + +import ( + "reflect" + + _jsii_ "github.com/aws/jsii-runtime-go" +) + +func init() { + _jsii_.RegisterStruct( + "jsii-calc.module2692.submodule1.Bar", + reflect.TypeOf((*Bar)(nil)).Elem(), + ) +} + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2692/submodule2/submodule2.go 1`] = ` +package submodule2 + + +type Bar struct { + Bar2 string \`json:"bar2"\` +} + +type Foo struct { + Bar2 string \`json:"bar2"\` + Bar1 string \`json:"bar1"\` + Foo2 string \`json:"foo2"\` +} + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/module2692/submodule2/submodule2.init.go 1`] = ` +package submodule2 + +import ( + "reflect" + + _jsii_ "github.com/aws/jsii-runtime-go" +) + +func init() { + _jsii_.RegisterStruct( + "jsii-calc.module2692.submodule2.Bar", + reflect.TypeOf((*Bar)(nil)).Elem(), + ) + _jsii_.RegisterStruct( + "jsii-calc.module2692.submodule2.Foo", + reflect.TypeOf((*Foo)(nil)).Elem(), + ) +} + +`; + exports[`Generated code for "jsii-calc": /go/jsiicalc/nodirect/nodirect.go 1`] = ` package nodirect @@ -15702,13 +15778,6 @@ type KwargsProps struct { Extra string \`json:"extra"\` } -// ToSomeStruct is a convenience function to obtain a new SomeStruct from this KwargsProps. -func (k *KwargsProps) ToSomeStruct() SomeStruct { - return SomeStruct { - Prop: k.Prop, - } -} - // Checks that classes can self-reference during initialization. // See: : https://github.com/aws/jsii/pull/1706 // 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 7ba7f3159c..9f5938badb 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 @@ -3710,6 +3710,8 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┣━ 📄 LevelOneProps.java ┃ ┣━ 📄 LoadBalancedFargateServiceProps.java ┃ ┣━ 📄 MethodNamedProperty.java + ┃ ┣━ 📁 module2530 + ┃ ┃ ┗━ 📄 MyClass.java ┃ ┣━ 📁 module2647 ┃ ┃ ┗━ 📄 ExtendAndImplement.java ┃ ┣━ 📁 module2689 @@ -3721,6 +3723,12 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┃ ┃ ┗━ 📄 MyClass.java ┃ ┃ ┗━ 📁 structs ┃ ┃ ┗━ 📄 MyStruct.java + ┃ ┣━ 📁 module2692 + ┃ ┃ ┣━ 📁 submodule1 + ┃ ┃ ┃ ┗━ 📄 Bar.java + ┃ ┃ ┗━ 📁 submodule2 + ┃ ┃ ┣━ 📄 Bar.java + ┃ ┃ ┗━ 📄 Foo.java ┃ ┣━ 📄 Multiply.java ┃ ┣━ 📄 Negate.java ┃ ┣━ 📄 NestedClassInstance.java @@ -21723,6 +21731,55 @@ public interface Hello extends software.amazon.jsii.JsiiSerializable { `; +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/module2530/MyClass.java 1`] = ` +package software.amazon.jsii.tests.calculator.module2530; + +/** + * Verifies a method with parameters "_" can be generated. + *

+ * @see https://github.com/aws/jsii/issues/2530 + */ +@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.module2530.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); + } + + /** + * @param _ This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public MyClass(final @org.jetbrains.annotations.NotNull java.lang.Number _) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(_, "_ is required") }); + } + + /** + * @param _ This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public static void bar(final @org.jetbrains.annotations.NotNull java.lang.Boolean _) { + software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.module2530.MyClass.class, "bar", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(_, "_ is required") }); + } + + /** + * @param _ This parameter is required. + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public void foo(final @org.jetbrains.annotations.NotNull java.lang.String _) { + software.amazon.jsii.Kernel.call(this, "foo", software.amazon.jsii.NativeType.VOID, new Object[] { java.util.Objects.requireNonNull(_, "_ is required") }); + } +} + +`; + exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/module2647/ExtendAndImplement.java 1`] = ` package software.amazon.jsii.tests.calculator.module2647; @@ -22056,6 +22113,415 @@ public interface MyStruct extends software.amazon.jsii.JsiiSerializable { `; +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/module2692/submodule1/Bar.java 1`] = ` +package software.amazon.jsii.tests.calculator.module2692.submodule1; + +/** + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.module2692.submodule1.Bar") +@software.amazon.jsii.Jsii.Proxy(Bar.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) +public interface Bar extends software.amazon.jsii.JsiiSerializable { + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @org.jetbrains.annotations.NotNull java.lang.String getBar1(); + + /** + * @return a {@link Builder} of {@link Bar} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + static Builder builder() { + return new Builder(); + } + /** + * A builder for {@link Bar} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public static final class Builder implements software.amazon.jsii.Builder { + private java.lang.String bar1; + + /** + * Sets the value of {@link Bar#getBar1} + * @param bar1 the value to be set. This parameter is required. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public Builder bar1(java.lang.String bar1) { + this.bar1 = bar1; + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link Bar} + * @throws NullPointerException if any required attribute was not provided + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @Override + public Bar build() { + return new Jsii$Proxy(bar1); + } + } + + /** + * An implementation for {@link Bar} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @software.amazon.jsii.Internal + final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements Bar { + private final java.lang.String bar1; + + /** + * 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.bar1 = software.amazon.jsii.Kernel.get(this, "bar1", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); + } + + /** + * Constructor that initializes the object based on literal property values passed by the {@link Builder}. + */ + protected Jsii$Proxy(final java.lang.String bar1) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + this.bar1 = java.util.Objects.requireNonNull(bar1, "bar1 is required"); + } + + @Override + public final java.lang.String getBar1() { + return this.bar1; + } + + @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("bar1", om.valueToTree(this.getBar1())); + + final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + struct.set("fqn", om.valueToTree("jsii-calc.module2692.submodule1.Bar")); + 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; + + Bar.Jsii$Proxy that = (Bar.Jsii$Proxy) o; + + return this.bar1.equals(that.bar1); + } + + @Override + public final int hashCode() { + int result = this.bar1.hashCode(); + return result; + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/module2692/submodule2/Bar.java 1`] = ` +package software.amazon.jsii.tests.calculator.module2692.submodule2; + +/** + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.module2692.submodule2.Bar") +@software.amazon.jsii.Jsii.Proxy(Bar.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) +public interface Bar extends software.amazon.jsii.JsiiSerializable { + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @org.jetbrains.annotations.NotNull java.lang.String getBar2(); + + /** + * @return a {@link Builder} of {@link Bar} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + static Builder builder() { + return new Builder(); + } + /** + * A builder for {@link Bar} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public static final class Builder implements software.amazon.jsii.Builder { + private java.lang.String bar2; + + /** + * Sets the value of {@link Bar#getBar2} + * @param bar2 the value to be set. This parameter is required. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public Builder bar2(java.lang.String bar2) { + this.bar2 = bar2; + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link Bar} + * @throws NullPointerException if any required attribute was not provided + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @Override + public Bar build() { + return new Jsii$Proxy(bar2); + } + } + + /** + * An implementation for {@link Bar} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @software.amazon.jsii.Internal + final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements Bar { + private final java.lang.String bar2; + + /** + * 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.bar2 = software.amazon.jsii.Kernel.get(this, "bar2", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); + } + + /** + * Constructor that initializes the object based on literal property values passed by the {@link Builder}. + */ + protected Jsii$Proxy(final java.lang.String bar2) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + this.bar2 = java.util.Objects.requireNonNull(bar2, "bar2 is required"); + } + + @Override + public final java.lang.String getBar2() { + return this.bar2; + } + + @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("bar2", om.valueToTree(this.getBar2())); + + final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + struct.set("fqn", om.valueToTree("jsii-calc.module2692.submodule2.Bar")); + 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; + + Bar.Jsii$Proxy that = (Bar.Jsii$Proxy) o; + + return this.bar2.equals(that.bar2); + } + + @Override + public final int hashCode() { + int result = this.bar2.hashCode(); + return result; + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/module2692/submodule2/Foo.java 1`] = ` +package software.amazon.jsii.tests.calculator.module2692.submodule2; + +/** + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.module2692.submodule2.Foo") +@software.amazon.jsii.Jsii.Proxy(Foo.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) +public interface Foo extends software.amazon.jsii.JsiiSerializable, software.amazon.jsii.tests.calculator.module2692.submodule2.Bar, software.amazon.jsii.tests.calculator.module2692.submodule1.Bar { + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @org.jetbrains.annotations.NotNull java.lang.String getFoo2(); + + /** + * @return a {@link Builder} of {@link Foo} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + static Builder builder() { + return new Builder(); + } + /** + * A builder for {@link Foo} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public static final class Builder implements software.amazon.jsii.Builder { + private java.lang.String foo2; + private java.lang.String bar2; + private java.lang.String bar1; + + /** + * Sets the value of {@link Foo#getFoo2} + * @param foo2 the value to be set. This parameter is required. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public Builder foo2(java.lang.String foo2) { + this.foo2 = foo2; + return this; + } + + /** + * Sets the value of {@link Foo#getBar2} + * @param bar2 the value to be set. This parameter is required. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public Builder bar2(java.lang.String bar2) { + this.bar2 = bar2; + return this; + } + + /** + * Sets the value of {@link Foo#getBar1} + * @param bar1 the value to be set. This parameter is required. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public Builder bar1(java.lang.String bar1) { + this.bar1 = bar1; + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link Foo} + * @throws NullPointerException if any required attribute was not provided + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @Override + public Foo build() { + return new Jsii$Proxy(foo2, bar2, bar1); + } + } + + /** + * An implementation for {@link Foo} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + @software.amazon.jsii.Internal + final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements Foo { + private final java.lang.String foo2; + private final java.lang.String bar2; + private final java.lang.String bar1; + + /** + * 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.foo2 = software.amazon.jsii.Kernel.get(this, "foo2", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); + this.bar2 = software.amazon.jsii.Kernel.get(this, "bar2", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); + this.bar1 = software.amazon.jsii.Kernel.get(this, "bar1", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); + } + + /** + * Constructor that initializes the object based on literal property values passed by the {@link Builder}. + */ + protected Jsii$Proxy(final java.lang.String foo2, final java.lang.String bar2, final java.lang.String bar1) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + this.foo2 = java.util.Objects.requireNonNull(foo2, "foo2 is required"); + this.bar2 = java.util.Objects.requireNonNull(bar2, "bar2 is required"); + this.bar1 = java.util.Objects.requireNonNull(bar1, "bar1 is required"); + } + + @Override + public final java.lang.String getFoo2() { + return this.foo2; + } + + @Override + public final java.lang.String getBar2() { + return this.bar2; + } + + @Override + public final java.lang.String getBar1() { + return this.bar1; + } + + @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("foo2", om.valueToTree(this.getFoo2())); + data.set("bar2", om.valueToTree(this.getBar2())); + data.set("bar1", om.valueToTree(this.getBar1())); + + final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + struct.set("fqn", om.valueToTree("jsii-calc.module2692.submodule2.Foo")); + 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; + + Foo.Jsii$Proxy that = (Foo.Jsii$Proxy) o; + + if (!foo2.equals(that.foo2)) return false; + if (!bar2.equals(that.bar2)) return false; + return this.bar1.equals(that.bar1); + } + + @Override + public final int hashCode() { + int result = this.foo2.hashCode(); + result = 31 * result + (this.bar2.hashCode()); + result = 31 * result + (this.bar1.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; @@ -23905,11 +24371,15 @@ jsii-calc.VoidCallback=software.amazon.jsii.tests.calculator.VoidCallback jsii-calc.WithPrivatePropertyInConstructor=software.amazon.jsii.tests.calculator.WithPrivatePropertyInConstructor 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.module2530.MyClass=software.amazon.jsii.tests.calculator.module2530.MyClass 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.module2692.submodule1.Bar=software.amazon.jsii.tests.calculator.module2692.submodule1.Bar +jsii-calc.module2692.submodule2.Bar=software.amazon.jsii.tests.calculator.module2692.submodule2.Bar +jsii-calc.module2692.submodule2.Foo=software.amazon.jsii.tests.calculator.module2692.submodule2.Foo 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 fae2560f1a..6164747308 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 @@ -2101,6 +2101,8 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┗━ 📄 __init__.py ┣━ 📁 interface_in_namespace_only_interface ┃ ┗━ 📄 __init__.py + ┣━ 📁 module2530 + ┃ ┗━ 📄 __init__.py ┣━ 📁 module2647 ┃ ┗━ 📄 __init__.py ┣━ 📁 module2689 @@ -2113,6 +2115,12 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┃ ┗━ 📄 __init__.py ┃ ┗━ 📁 structs ┃ ┗━ 📄 __init__.py + ┣━ 📁 module2692 + ┃ ┣━ 📄 __init__.py + ┃ ┣━ 📁 submodule1 + ┃ ┃ ┗━ 📄 __init__.py + ┃ ┗━ 📁 submodule2 + ┃ ┗━ 📄 __init__.py ┣━ 📁 nodirect ┃ ┣━ 📄 __init__.py ┃ ┣━ 📁 sub1 @@ -2426,12 +2434,16 @@ kwargs = json.loads( "jsii_calc.derived_class_has_no_properties", "jsii_calc.interface_in_namespace_includes_classes", "jsii_calc.interface_in_namespace_only_interface", + "jsii_calc.module2530", "jsii_calc.module2647", "jsii_calc.module2689", "jsii_calc.module2689.methods", "jsii_calc.module2689.props", "jsii_calc.module2689.retval", "jsii_calc.module2689.structs", + "jsii_calc.module2692", + "jsii_calc.module2692.submodule1", + "jsii_calc.module2692.submodule2", "jsii_calc.nodirect", "jsii_calc.nodirect.sub1", "jsii_calc.nodirect.sub2", @@ -10379,6 +10391,56 @@ publication.publish() `; +exports[`Generated code for "jsii-calc": /python/src/jsii_calc/module2530/__init__.py 1`] = ` +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import publication +import typing_extensions + +from .._jsii import * + + +class MyClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.module2530.MyClass"): + '''Verifies a method with parameters "_" can be generated. + + :see: https://github.com/aws/jsii/issues/2530 + ''' + + def __init__(self, _: jsii.Number) -> None: + ''' + :param _: - + ''' + jsii.create(MyClass, self, [_]) + + @jsii.member(jsii_name="bar") # type: ignore[misc] + @builtins.classmethod + def bar(cls, _: builtins.bool) -> None: + ''' + :param _: - + ''' + return typing.cast(None, jsii.sinvoke(cls, "bar", [_])) + + @jsii.member(jsii_name="foo") + def foo(self, _: builtins.str) -> None: + ''' + :param _: - + ''' + return typing.cast(None, jsii.invoke(self, "foo", [_])) + + +__all__ = [ + "MyClass", +] + +publication.publish() + +`; + exports[`Generated code for "jsii-calc": /python/src/jsii_calc/module2647/__init__.py 1`] = ` import abc import builtins @@ -10649,6 +10711,189 @@ publication.publish() `; +exports[`Generated code for "jsii-calc": /python/src/jsii_calc/module2692/__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/module2692/submodule1/__init__.py 1`] = ` +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import publication +import typing_extensions + +from ..._jsii import * + + +@jsii.data_type( + jsii_type="jsii-calc.module2692.submodule1.Bar", + jsii_struct_bases=[], + name_mapping={"bar1": "bar1"}, +) +class Bar: + def __init__(self, *, bar1: builtins.str) -> None: + ''' + :param bar1: + ''' + self._values: typing.Dict[str, typing.Any] = { + "bar1": bar1, + } + + @builtins.property + def bar1(self) -> builtins.str: + result = self._values.get("bar1") + assert result is not None, "Required property 'bar1' is missing" + return typing.cast(builtins.str, 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 "Bar(%s)" % ", ".join( + k + "=" + repr(v) for k, v in self._values.items() + ) + + +__all__ = [ + "Bar", +] + +publication.publish() + +`; + +exports[`Generated code for "jsii-calc": /python/src/jsii_calc/module2692/submodule2/__init__.py 1`] = ` +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import publication +import typing_extensions + +from ..._jsii import * + +from ..submodule1 import Bar as _Bar_ec7eccad + + +@jsii.data_type( + jsii_type="jsii-calc.module2692.submodule2.Bar", + jsii_struct_bases=[], + name_mapping={"bar2": "bar2"}, +) +class Bar: + def __init__(self, *, bar2: builtins.str) -> None: + ''' + :param bar2: + ''' + self._values: typing.Dict[str, typing.Any] = { + "bar2": bar2, + } + + @builtins.property + def bar2(self) -> builtins.str: + result = self._values.get("bar2") + assert result is not None, "Required property 'bar2' is missing" + return typing.cast(builtins.str, 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 "Bar(%s)" % ", ".join( + k + "=" + repr(v) for k, v in self._values.items() + ) + + +@jsii.data_type( + jsii_type="jsii-calc.module2692.submodule2.Foo", + jsii_struct_bases=[Bar, _Bar_ec7eccad], + name_mapping={"bar2": "bar2", "bar1": "bar1", "foo2": "foo2"}, +) +class Foo(Bar, _Bar_ec7eccad): + def __init__( + self, + *, + bar2: builtins.str, + bar1: builtins.str, + foo2: builtins.str, + ) -> None: + ''' + :param bar2: + :param bar1: + :param foo2: + ''' + self._values: typing.Dict[str, typing.Any] = { + "bar2": bar2, + "bar1": bar1, + "foo2": foo2, + } + + @builtins.property + def bar2(self) -> builtins.str: + result = self._values.get("bar2") + assert result is not None, "Required property 'bar2' is missing" + return typing.cast(builtins.str, result) + + @builtins.property + def bar1(self) -> builtins.str: + result = self._values.get("bar1") + assert result is not None, "Required property 'bar1' is missing" + return typing.cast(builtins.str, result) + + @builtins.property + def foo2(self) -> builtins.str: + result = self._values.get("foo2") + assert result is not None, "Required property 'foo2' is missing" + return typing.cast(builtins.str, 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 "Foo(%s)" % ", ".join( + k + "=" + repr(v) for k, v in self._values.items() + ) + + +__all__ = [ + "Bar", + "Foo", +] + +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 919bf194c9..64f0e22032 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.ts.snap @@ -102,6 +102,25 @@ exports[`jsii-tree --all 1`] = ` │ │ │ └─┬ enum CompositionStringStyle (stable) │ │ │ ├── NORMAL (stable) │ │ │ └── DECORATED (stable) + │ │ ├─┬ module2530 + │ │ │ └─┬ types + │ │ │ └─┬ class MyClass (stable) + │ │ │ └─┬ members + │ │ │ ├─┬ (_) initializer (stable) + │ │ │ │ └─┬ parameters + │ │ │ │ └─┬ _ + │ │ │ │ └── type: number + │ │ │ ├─┬ static bar(_) method (stable) + │ │ │ │ ├── static + │ │ │ │ ├─┬ parameters + │ │ │ │ │ └─┬ _ + │ │ │ │ │ └── type: boolean + │ │ │ │ └── returns: void + │ │ │ └─┬ foo(_) method (stable) + │ │ │ ├─┬ parameters + │ │ │ │ └─┬ _ + │ │ │ │ └── type: string + │ │ │ └── returns: void │ │ ├─┬ module2647 │ │ │ └─┬ types │ │ │ └─┬ class ExtendAndImplement (stable) @@ -166,6 +185,34 @@ exports[`jsii-tree --all 1`] = ` │ │ │ │ ├── immutable │ │ │ │ └── type: Array<@scope/jsii-calc-lib.Number> │ │ │ └── types + │ │ ├─┬ module2692 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ submodule1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ interface Bar (stable) + │ │ │ │ │ └─┬ members + │ │ │ │ │ └─┬ bar1 property (stable) + │ │ │ │ │ ├── abstract + │ │ │ │ │ ├── immutable + │ │ │ │ │ └── type: string + │ │ │ │ └─┬ submodule2 + │ │ │ │ └─┬ types + │ │ │ │ ├─┬ interface Bar (stable) + │ │ │ │ │ └─┬ members + │ │ │ │ │ └─┬ bar2 property (stable) + │ │ │ │ │ ├── abstract + │ │ │ │ │ ├── immutable + │ │ │ │ │ └── type: string + │ │ │ │ └─┬ interface Foo (stable) + │ │ │ │ ├─┬ interfaces + │ │ │ │ │ ├── Bar + │ │ │ │ │ └── Bar + │ │ │ │ └─┬ members + │ │ │ │ └─┬ foo2 property (stable) + │ │ │ │ ├── abstract + │ │ │ │ ├── immutable + │ │ │ │ └── type: string + │ │ │ └── types │ │ ├─┬ nodirect │ │ │ ├─┬ submodules │ │ │ │ ├─┬ sub1 @@ -3008,6 +3055,9 @@ exports[`jsii-tree --inheritance 1`] = ` │ │ │ ├─┬ class CompositeOperation │ │ │ │ └── base: Operation │ │ │ └── enum CompositionStringStyle + │ │ ├─┬ module2530 + │ │ │ └─┬ types + │ │ │ └── class MyClass │ │ ├─┬ module2647 │ │ │ └─┬ types │ │ │ └─┬ class ExtendAndImplement @@ -3028,6 +3078,19 @@ exports[`jsii-tree --inheritance 1`] = ` │ │ │ │ └─┬ types │ │ │ │ └── interface MyStruct │ │ │ └── types + │ │ ├─┬ module2692 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ submodule1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── interface Bar + │ │ │ │ └─┬ submodule2 + │ │ │ │ └─┬ types + │ │ │ │ ├── interface Bar + │ │ │ │ └─┬ interface Foo + │ │ │ │ └─┬ interfaces + │ │ │ │ ├── Bar + │ │ │ │ └── Bar + │ │ │ └── types │ │ ├─┬ nodirect │ │ │ ├─┬ submodules │ │ │ │ ├─┬ sub1 @@ -3451,6 +3514,13 @@ exports[`jsii-tree --members 1`] = ` │ │ │ └─┬ enum CompositionStringStyle │ │ │ ├── NORMAL │ │ │ └── DECORATED + │ │ ├─┬ module2530 + │ │ │ └─┬ types + │ │ │ └─┬ class MyClass + │ │ │ └─┬ members + │ │ │ ├── (_) initializer + │ │ │ ├── static bar(_) method + │ │ │ └── foo(_) method │ │ ├─┬ module2647 │ │ │ └─┬ types │ │ │ └─┬ class ExtendAndImplement @@ -3488,6 +3558,22 @@ exports[`jsii-tree --members 1`] = ` │ │ │ │ ├── baseMap property │ │ │ │ └── numbers property │ │ │ └── types + │ │ ├─┬ module2692 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ submodule1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ interface Bar + │ │ │ │ │ └─┬ members + │ │ │ │ │ └── bar1 property + │ │ │ │ └─┬ submodule2 + │ │ │ │ └─┬ types + │ │ │ │ ├─┬ interface Bar + │ │ │ │ │ └─┬ members + │ │ │ │ │ └── bar2 property + │ │ │ │ └─┬ interface Foo + │ │ │ │ └─┬ members + │ │ │ │ └── foo2 property + │ │ │ └── types │ │ ├─┬ nodirect │ │ │ ├─┬ submodules │ │ │ │ ├─┬ sub1 @@ -4759,6 +4845,7 @@ exports[`jsii-tree --signatures 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├── module2530 │ ├── module2647 │ ├─┬ module2689 │ │ └─┬ submodules @@ -4766,6 +4853,10 @@ exports[`jsii-tree --signatures 1`] = ` │ │ ├── props │ │ ├── retval │ │ └── structs + │ ├─┬ module2692 + │ │ └─┬ submodules + │ │ ├── submodule1 + │ │ └── submodule2 │ ├─┬ nodirect │ │ └─┬ submodules │ │ ├── sub1 @@ -4814,6 +4905,9 @@ exports[`jsii-tree --types 1`] = ` │ │ │ └─┬ types │ │ │ ├── class CompositeOperation │ │ │ └── enum CompositionStringStyle + │ │ ├─┬ module2530 + │ │ │ └─┬ types + │ │ │ └── class MyClass │ │ ├─┬ module2647 │ │ │ └─┬ types │ │ │ └── class ExtendAndImplement @@ -4832,6 +4926,16 @@ exports[`jsii-tree --types 1`] = ` │ │ │ │ └─┬ types │ │ │ │ └── interface MyStruct │ │ │ └── types + │ │ ├─┬ module2692 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ submodule1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── interface Bar + │ │ │ │ └─┬ submodule2 + │ │ │ │ └─┬ types + │ │ │ │ ├── interface Bar + │ │ │ │ └── interface Foo + │ │ │ └── types │ │ ├─┬ nodirect │ │ │ ├─┬ submodules │ │ │ │ ├─┬ sub1 @@ -5133,6 +5237,7 @@ exports[`jsii-tree 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├── module2530 │ ├── module2647 │ ├─┬ module2689 │ │ └─┬ submodules @@ -5140,6 +5245,10 @@ exports[`jsii-tree 1`] = ` │ │ ├── props │ │ ├── retval │ │ └── structs + │ ├─┬ module2692 + │ │ └─┬ submodules + │ │ ├── submodule1 + │ │ └── submodule2 │ ├─┬ 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 93f71ec70a..46d74b4f92 100644 --- a/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap @@ -9,6 +9,7 @@ exports[`defaults 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├── module2530 │ ├── module2647 │ ├─┬ module2689 │ │ └─┬ submodules @@ -16,6 +17,10 @@ exports[`defaults 1`] = ` │ │ ├── props │ │ ├── retval │ │ └── structs + │ ├─┬ module2692 + │ │ └─┬ submodules + │ │ ├── submodule1 + │ │ └── submodule2 │ ├─┬ nodirect │ │ └─┬ submodules │ │ ├── sub1 @@ -48,6 +53,7 @@ exports[`inheritance 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├── module2530 │ ├── module2647 │ ├─┬ module2689 │ │ └─┬ submodules @@ -55,6 +61,10 @@ exports[`inheritance 1`] = ` │ │ ├── props │ │ ├── retval │ │ └── structs + │ ├─┬ module2692 + │ │ └─┬ submodules + │ │ ├── submodule1 + │ │ └── submodule2 │ ├─┬ nodirect │ │ └─┬ submodules │ │ ├── sub1 @@ -87,6 +97,7 @@ exports[`members 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├── module2530 │ ├── module2647 │ ├─┬ module2689 │ │ └─┬ submodules @@ -94,6 +105,10 @@ exports[`members 1`] = ` │ │ ├── props │ │ ├── retval │ │ └── structs + │ ├─┬ module2692 + │ │ └─┬ submodules + │ │ ├── submodule1 + │ │ └── submodule2 │ ├─┬ nodirect │ │ └─┬ submodules │ │ ├── sub1 @@ -219,6 +234,25 @@ exports[`showAll 1`] = ` │ │ │ └─┬ enum CompositionStringStyle │ │ │ ├── NORMAL │ │ │ └── DECORATED + │ │ ├─┬ module2530 + │ │ │ └─┬ types + │ │ │ └─┬ class MyClass + │ │ │ └─┬ members + │ │ │ ├─┬ (_) initializer + │ │ │ │ └─┬ parameters + │ │ │ │ └─┬ _ + │ │ │ │ └── type: number + │ │ │ ├─┬ static bar(_) method + │ │ │ │ ├── static + │ │ │ │ ├─┬ parameters + │ │ │ │ │ └─┬ _ + │ │ │ │ │ └── type: boolean + │ │ │ │ └── returns: void + │ │ │ └─┬ foo(_) method + │ │ │ ├─┬ parameters + │ │ │ │ └─┬ _ + │ │ │ │ └── type: string + │ │ │ └── returns: void │ │ ├─┬ module2647 │ │ │ └─┬ types │ │ │ └─┬ class ExtendAndImplement @@ -283,6 +317,34 @@ exports[`showAll 1`] = ` │ │ │ │ ├── immutable │ │ │ │ └── type: Array<@scope/jsii-calc-lib.Number> │ │ │ └── types + │ │ ├─┬ module2692 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ submodule1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ interface Bar + │ │ │ │ │ └─┬ members + │ │ │ │ │ └─┬ bar1 property + │ │ │ │ │ ├── abstract + │ │ │ │ │ ├── immutable + │ │ │ │ │ └── type: string + │ │ │ │ └─┬ submodule2 + │ │ │ │ └─┬ types + │ │ │ │ ├─┬ interface Bar + │ │ │ │ │ └─┬ members + │ │ │ │ │ └─┬ bar2 property + │ │ │ │ │ ├── abstract + │ │ │ │ │ ├── immutable + │ │ │ │ │ └── type: string + │ │ │ │ └─┬ interface Foo + │ │ │ │ ├─┬ interfaces + │ │ │ │ │ ├── Bar + │ │ │ │ │ └── Bar + │ │ │ │ └─┬ members + │ │ │ │ └─┬ foo2 property + │ │ │ │ ├── abstract + │ │ │ │ ├── immutable + │ │ │ │ └── type: string + │ │ │ └── types │ │ ├─┬ nodirect │ │ │ ├─┬ submodules │ │ │ │ ├─┬ sub1 @@ -3107,6 +3169,7 @@ exports[`signatures 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├── module2530 │ ├── module2647 │ ├─┬ module2689 │ │ └─┬ submodules @@ -3114,6 +3177,10 @@ exports[`signatures 1`] = ` │ │ ├── props │ │ ├── retval │ │ └── structs + │ ├─┬ module2692 + │ │ └─┬ submodules + │ │ ├── submodule1 + │ │ └── submodule2 │ ├─┬ nodirect │ │ └─┬ submodules │ │ ├── sub1 @@ -3162,6 +3229,9 @@ exports[`types 1`] = ` │ │ │ └─┬ types │ │ │ ├── class CompositeOperation │ │ │ └── enum CompositionStringStyle + │ │ ├─┬ module2530 + │ │ │ └─┬ types + │ │ │ └── class MyClass │ │ ├─┬ module2647 │ │ │ └─┬ types │ │ │ └── class ExtendAndImplement @@ -3180,6 +3250,16 @@ exports[`types 1`] = ` │ │ │ │ └─┬ types │ │ │ │ └── interface MyStruct │ │ │ └── types + │ │ ├─┬ module2692 + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ submodule1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── interface Bar + │ │ │ │ └─┬ submodule2 + │ │ │ │ └─┬ types + │ │ │ │ ├── interface Bar + │ │ │ │ └── interface Foo + │ │ │ └── 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 a752a4b7b4..6d92c85d98 100644 --- a/packages/jsii-reflect/test/__snapshots__/type-system.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/type-system.test.ts.snap @@ -154,6 +154,7 @@ Array [ "jsii-calc.VoidCallback", "jsii-calc.WithPrivatePropertyInConstructor", "jsii-calc.composition.CompositeOperation", + "jsii-calc.module2530.MyClass", "jsii-calc.module2647.ExtendAndImplement", "jsii-calc.module2689.methods.MyClass", "jsii-calc.module2689.props.MyClass",