diff --git a/packages/jsii-calc/lib/index.ts b/packages/jsii-calc/lib/index.ts index a167c46687..65d66f22cb 100644 --- a/packages/jsii-calc/lib/index.ts +++ b/packages/jsii-calc/lib/index.ts @@ -9,3 +9,5 @@ export * from './stability'; export * from './submodules'; export * as submodule from './submodule'; +export * as onlystatic from './only-static'; +export * as nodirect from './no-direct-types'; diff --git a/packages/jsii-calc/lib/no-direct-types/index.ts b/packages/jsii-calc/lib/no-direct-types/index.ts new file mode 100644 index 0000000000..215b9571d0 --- /dev/null +++ b/packages/jsii-calc/lib/no-direct-types/index.ts @@ -0,0 +1,4 @@ +// THIS MODULE ONLY EXPORTS SUBMODULES: it tests the case in which a module does not export direct +// types but rather only exports submodules (see https://github.com/aws/jsii/issues/2619) +export * as sub1 from './sub1'; +export * as sub2 from './sub2'; diff --git a/packages/jsii-calc/lib/no-direct-types/sub1/index.ts b/packages/jsii-calc/lib/no-direct-types/sub1/index.ts new file mode 100644 index 0000000000..285c5447fd --- /dev/null +++ b/packages/jsii-calc/lib/no-direct-types/sub1/index.ts @@ -0,0 +1,5 @@ +export class TypeFromSub1 { + public sub1() { + return 'foo'; + } +} diff --git a/packages/jsii-calc/lib/no-direct-types/sub2/index.ts b/packages/jsii-calc/lib/no-direct-types/sub2/index.ts new file mode 100644 index 0000000000..cfcd1ae810 --- /dev/null +++ b/packages/jsii-calc/lib/no-direct-types/sub2/index.ts @@ -0,0 +1,5 @@ +export class TypeFromSub2 { + public sub2() { + return 'foo'; + } +} diff --git a/packages/jsii-calc/lib/only-static/index.ts b/packages/jsii-calc/lib/only-static/index.ts new file mode 100644 index 0000000000..8301711a8a --- /dev/null +++ b/packages/jsii-calc/lib/only-static/index.ts @@ -0,0 +1,10 @@ +/** + * Test for https://github.com/aws/jsii/issues/2617 + */ +export class OnlyStaticMethods { + public static staticMethod() { + return 'hello'; + } + + private constructor() {} +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 1a10a78b12..d62d14f275 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -206,6 +206,30 @@ "line": 142 } }, + "jsii-calc.nodirect": { + "locationInModule": { + "filename": "lib/index.ts", + "line": 13 + } + }, + "jsii-calc.nodirect.sub1": { + "locationInModule": { + "filename": "lib/no-direct-types/index.ts", + "line": 3 + } + }, + "jsii-calc.nodirect.sub2": { + "locationInModule": { + "filename": "lib/no-direct-types/index.ts", + "line": 4 + } + }, + "jsii-calc.onlystatic": { + "locationInModule": { + "filename": "lib/index.ts", + "line": 12 + } + }, "jsii-calc.submodule": { "locationInModule": { "filename": "lib/index.ts", @@ -13860,6 +13884,111 @@ "name": "CompositionStringStyle", "namespace": "composition.CompositeOperation" }, + "jsii-calc.nodirect.sub1.TypeFromSub1": { + "assembly": "jsii-calc", + "docs": { + "stability": "stable" + }, + "fqn": "jsii-calc.nodirect.sub1.TypeFromSub1", + "initializer": { + "docs": { + "stability": "stable" + } + }, + "kind": "class", + "locationInModule": { + "filename": "lib/no-direct-types/sub1/index.ts", + "line": 1 + }, + "methods": [ + { + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/no-direct-types/sub1/index.ts", + "line": 2 + }, + "name": "sub1", + "returns": { + "type": { + "primitive": "string" + } + } + } + ], + "name": "TypeFromSub1", + "namespace": "nodirect.sub1" + }, + "jsii-calc.nodirect.sub2.TypeFromSub2": { + "assembly": "jsii-calc", + "docs": { + "stability": "stable" + }, + "fqn": "jsii-calc.nodirect.sub2.TypeFromSub2", + "initializer": { + "docs": { + "stability": "stable" + } + }, + "kind": "class", + "locationInModule": { + "filename": "lib/no-direct-types/sub2/index.ts", + "line": 1 + }, + "methods": [ + { + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/no-direct-types/sub2/index.ts", + "line": 2 + }, + "name": "sub2", + "returns": { + "type": { + "primitive": "string" + } + } + } + ], + "name": "TypeFromSub2", + "namespace": "nodirect.sub2" + }, + "jsii-calc.onlystatic.OnlyStaticMethods": { + "assembly": "jsii-calc", + "docs": { + "stability": "stable", + "summary": "Test for https://github.com/aws/jsii/issues/2617." + }, + "fqn": "jsii-calc.onlystatic.OnlyStaticMethods", + "kind": "class", + "locationInModule": { + "filename": "lib/only-static/index.ts", + "line": 4 + }, + "methods": [ + { + "docs": { + "stability": "stable" + }, + "locationInModule": { + "filename": "lib/only-static/index.ts", + "line": 5 + }, + "name": "staticMethod", + "returns": { + "type": { + "primitive": "string" + } + }, + "static": true + } + ], + "name": "OnlyStaticMethods", + "namespace": "onlystatic" + }, "jsii-calc.submodule.MyClass": { "assembly": "jsii-calc", "docs": { @@ -14477,5 +14606,5 @@ } }, "version": "3.20.120", - "fingerprint": "DPUvV1cBxUeRNl5GK1DVzpU7/802/Hb8znpxKRttRUk=" + "fingerprint": "JMTvoEnsqFjh72kI95PtIx01MmNxAbZV41K/nIgoZ4Q=" } diff --git a/packages/jsii-pacmak/lib/targets/go.ts b/packages/jsii-pacmak/lib/targets/go.ts index 7ea9980332..f0f856dbc1 100644 --- a/packages/jsii-pacmak/lib/targets/go.ts +++ b/packages/jsii-pacmak/lib/targets/go.ts @@ -43,7 +43,7 @@ export class Golang extends Target { // run `go build` with local.go.mod, go 1.16 requires that we download // modules explicit so go.sum is updated. await go('mod', ['download', '-modfile', localGoMod], { cwd: pkgDir }); - await go('build', ['-modfile', localGoMod], { cwd: pkgDir }); + await go('build', ['-modfile', localGoMod, './...'], { cwd: pkgDir }); // delete local.go.mod and local.go.sum from the output directory so it doesn't get published const localGoSum = `${path.basename(localGoMod, '.mod')}.sum`; diff --git a/packages/jsii-pacmak/lib/targets/go/package.ts b/packages/jsii-pacmak/lib/targets/go/package.ts index f8926fb5e2..4f999309a1 100644 --- a/packages/jsii-pacmak/lib/targets/go/package.ts +++ b/packages/jsii-pacmak/lib/targets/go/package.ts @@ -125,17 +125,11 @@ export abstract class Package { } protected get usesRuntimePackage(): boolean { - return ( - this.types.some((type) => type.usesRuntimePackage) || - this.submodules.some((sub) => sub.usesRuntimePackage) - ); + return this.types.some((type) => type.usesRuntimePackage); } protected get usesInitPackage(): boolean { - return ( - this.types.some((type) => type.usesInitPackage) || - this.submodules.some((sub) => sub.usesInitPackage) - ); + return this.types.some((type) => type.usesInitPackage); } /** diff --git a/packages/jsii-pacmak/lib/targets/go/types/class.ts b/packages/jsii-pacmak/lib/targets/go/types/class.ts index 4bb6674437..515f22ff35 100644 --- a/packages/jsii-pacmak/lib/targets/go/types/class.ts +++ b/packages/jsii-pacmak/lib/targets/go/types/class.ts @@ -15,7 +15,7 @@ import { getMemberDependencies, getParamDependencies } from '../util'; import { GoType } from './go-type'; import { GoTypeRef } from './go-type-reference'; import { GoInterface } from './interface'; -import { GoParameter, GoMethod, GoProperty } from './type-member'; +import { GoParameter, GoMethod, GoProperty, GoTypeMember } from './type-member'; /* * GoClass wraps a Typescript class as a Go custom struct type @@ -156,20 +156,23 @@ export class GoClass extends GoType { code.close(')'); } + public get members(): GoTypeMember[] { + return [ + ...this.methods, + ...this.properties, + ...this.staticMethods, + ...this.staticProperties, + ]; + } + public get usesInitPackage() { return ( - this.initializer != null || - this.methods.some((m) => m.usesInitPackage) || - this.properties.some((p) => p.usesInitPackage) + this.initializer != null || this.members.some((m) => m.usesInitPackage) ); } public get usesRuntimePackage() { - return ( - this.initializer != null || - this.methods.length > 0 || - this.properties.length > 0 - ); + return this.initializer != null || this.members.length > 0; } protected emitInterface(context: EmitContext): void { @@ -289,9 +292,8 @@ export class GoClass extends GoType { // need to add dependencies of method arguments and constructor arguments return [ ...this.baseTypes.map((ref) => ref.pkg), - ...getMemberDependencies(this.properties), - ...getMemberDependencies(this.methods), - ...getParamDependencies(this.methods), + ...getMemberDependencies(this.members), + ...getParamDependencies(this.members.filter(isGoMethod)), ]; } @@ -412,3 +414,7 @@ export class StaticMethod extends ClassMethod { code.line(); } } + +function isGoMethod(m: GoTypeMember): m is GoMethod { + return m instanceof GoMethod; +} diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index dfdc4e4b88..9938d31c24 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -1503,12 +1503,15 @@ class PythonModule implements PythonType { code.line(); } code.line(); - code.indent('__all__ = ['); - for (const member of exportedMembers.sort()) { - // Writing one by line might be _a lot_ of lines, but it'll make reviewing changes to the list easier. Trust me. - code.line(`${member},`); + + if (exportedMembers.length > 0) { + code.indent('__all__ = ['); + for (const member of exportedMembers.sort()) { + // Writing one by line might be _a lot_ of lines, but it'll make reviewing changes to the list easier. Trust me. + code.line(`${member},`); + } + code.unindent(']'); } - code.unindent(']'); // Finally, we'll use publication to ensure that all of the non-public names // get hidden from dir(), tab-complete, etc. 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 5ef888d857..07d3ed7867 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 @@ -2835,12 +2835,19 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┣━ 📄 NestedClassInstance.cs ┃ ┣━ 📄 NestedStruct.cs ┃ ┣━ 📄 NodeStandardLibrary.cs + ┃ ┣━ 📁 Nodirect + ┃ ┃ ┣━ 📁 Sub1 + ┃ ┃ ┃ ┗━ 📄 TypeFromSub1.cs + ┃ ┃ ┗━ 📁 Sub2 + ┃ ┃ ┗━ 📄 TypeFromSub2.cs ┃ ┣━ 📄 NullShouldBeTreatedAsUndefined.cs ┃ ┣━ 📄 NullShouldBeTreatedAsUndefinedData.cs ┃ ┣━ 📄 NumberGenerator.cs ┃ ┣━ 📄 ObjectRefsInCollections.cs ┃ ┣━ 📄 ObjectWithPropertyProvider.cs ┃ ┣━ 📄 Old.cs + ┃ ┣━ 📁 Onlystatic + ┃ ┃ ┗━ 📄 OnlyStaticMethods.cs ┃ ┣━ 📄 OptionalArgumentInvoker.cs ┃ ┣━ 📄 OptionalConstructorArgument.cs ┃ ┣━ 📄 OptionalStruct.cs @@ -12172,6 +12179,82 @@ namespace Amazon.JSII.Tests.CalculatorNamespace `; +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Nodirect/Sub1/TypeFromSub1.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Nodirect.Sub1 +{ + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Nodirect.Sub1.TypeFromSub1), fullyQualifiedName: "jsii-calc.nodirect.sub1.TypeFromSub1")] + public class TypeFromSub1 : DeputyBase + { + public TypeFromSub1(): 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 TypeFromSub1(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 TypeFromSub1(DeputyProps props): base(props) + { + } + + [JsiiMethod(name: "sub1", returnsJson: "{\\"type\\":{\\"primitive\\":\\"string\\"}}")] + public virtual string Sub1() + { + return InvokeInstanceMethod(new System.Type[]{}, new object[]{})!; + } + } +} + +`; + +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Nodirect/Sub2/TypeFromSub2.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Nodirect.Sub2 +{ + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Nodirect.Sub2.TypeFromSub2), fullyQualifiedName: "jsii-calc.nodirect.sub2.TypeFromSub2")] + public class TypeFromSub2 : DeputyBase + { + public TypeFromSub2(): 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 TypeFromSub2(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 TypeFromSub2(DeputyProps props): base(props) + { + } + + [JsiiMethod(name: "sub2", returnsJson: "{\\"type\\":{\\"primitive\\":\\"string\\"}}")] + public virtual string Sub2() + { + return InvokeInstanceMethod(new System.Type[]{}, new object[]{})!; + } + } +} + +`; + exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/NullShouldBeTreatedAsUndefined.cs 1`] = ` using Amazon.JSII.Runtime.Deputy; @@ -12443,6 +12526,41 @@ namespace Amazon.JSII.Tests.CalculatorNamespace `; +exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Onlystatic/OnlyStaticMethods.cs 1`] = ` +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Onlystatic +{ + /// Test for https://github.com/aws/jsii/issues/2617. + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Onlystatic.OnlyStaticMethods), fullyQualifiedName: "jsii-calc.onlystatic.OnlyStaticMethods")] + public class OnlyStaticMethods : DeputyBase + { + /// 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 OnlyStaticMethods(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 OnlyStaticMethods(DeputyProps props): base(props) + { + } + + [JsiiMethod(name: "staticMethod", returnsJson: "{\\"type\\":{\\"primitive\\":\\"string\\"}}")] + public static string StaticMethod() + { + return InvokeStaticMethod(typeof(Amazon.JSII.Tests.CalculatorNamespace.Onlystatic.OnlyStaticMethods), new System.Type[]{}, new object[]{})!; + } + } +} + +`; + exports[`Generated code for "jsii-calc": /dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/OptionalArgumentInvoker.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 81d0909d2d..0fa6db0132 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 @@ -1726,7 +1726,18 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┣━ 📄 jsiicalc.go ┣━ 📄 jsiicalc.init.go ┣━ 📄 LICENSE + ┣━ 📁 nodirect + ┃ ┣━ 📄 nodirect.go + ┃ ┣━ 📁 sub1 + ┃ ┃ ┣━ 📄 sub1.go + ┃ ┃ ┗━ 📄 sub1.init.go + ┃ ┗━ 📁 sub2 + ┃ ┣━ 📄 sub2.go + ┃ ┗━ 📄 sub2.init.go ┣━ 📄 NOTICE + ┣━ 📁 onlystatic + ┃ ┣━ 📄 onlystatic.go + ┃ ┗━ 📄 onlystatic.init.go ┣━ 📁 pythonself ┃ ┣━ 📄 pythonself.go ┃ ┗━ 📄 pythonself.init.go @@ -13666,6 +13677,201 @@ func init() { `; +exports[`Generated code for "jsii-calc": /go/jsiicalc/nodirect/nodirect.go 1`] = ` +package nodirect + + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/nodirect/sub1/sub1.go 1`] = ` +package sub1 + +import ( + _jsii_ "github.com/aws/jsii-runtime-go" + _init_ "github.com/aws/jsii/jsii-calc/go/jsiicalc/v3/jsii" +) + +type TypeFromSub1 interface { + Sub1() string +} + +// The jsii proxy struct for TypeFromSub1 +type typeFromSub1 struct { + _ byte // padding +} + +func NewTypeFromSub1() TypeFromSub1 { + _init_.Initialize() + t := typeFromSub1{} + + _jsii_.Create( + "jsii-calc.nodirect.sub1.TypeFromSub1", + []interface{}{}, + []_jsii_.FQN{}, + []_jsii_.Override{}, + &t, + ) + return &t +} + +func (t *typeFromSub1) Sub1() string { + var returns string + _jsii_.Invoke( + t, + "sub1", + []interface{}{}, + true, + &returns, + ) + return returns +} + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/nodirect/sub1/sub1.init.go 1`] = ` +package sub1 + +import ( + "reflect" + + _jsii_ "github.com/aws/jsii-runtime-go" +) + +func init() { + _jsii_.RegisterClass( + "jsii-calc.nodirect.sub1.TypeFromSub1", + reflect.TypeOf((*TypeFromSub1)(nil)).Elem(), + func() interface{} { + return &typeFromSub1{} + }, + ) +} + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/nodirect/sub2/sub2.go 1`] = ` +package sub2 + +import ( + _jsii_ "github.com/aws/jsii-runtime-go" + _init_ "github.com/aws/jsii/jsii-calc/go/jsiicalc/v3/jsii" +) + +type TypeFromSub2 interface { + Sub2() string +} + +// The jsii proxy struct for TypeFromSub2 +type typeFromSub2 struct { + _ byte // padding +} + +func NewTypeFromSub2() TypeFromSub2 { + _init_.Initialize() + t := typeFromSub2{} + + _jsii_.Create( + "jsii-calc.nodirect.sub2.TypeFromSub2", + []interface{}{}, + []_jsii_.FQN{}, + []_jsii_.Override{}, + &t, + ) + return &t +} + +func (t *typeFromSub2) Sub2() string { + var returns string + _jsii_.Invoke( + t, + "sub2", + []interface{}{}, + true, + &returns, + ) + return returns +} + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/nodirect/sub2/sub2.init.go 1`] = ` +package sub2 + +import ( + "reflect" + + _jsii_ "github.com/aws/jsii-runtime-go" +) + +func init() { + _jsii_.RegisterClass( + "jsii-calc.nodirect.sub2.TypeFromSub2", + reflect.TypeOf((*TypeFromSub2)(nil)).Elem(), + func() interface{} { + return &typeFromSub2{} + }, + ) +} + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/onlystatic/onlystatic.go 1`] = ` +package onlystatic + +import ( + _jsii_ "github.com/aws/jsii-runtime-go" + _init_ "github.com/aws/jsii/jsii-calc/go/jsiicalc/v3/jsii" +) + +// Test for https://github.com/aws/jsii/issues/2617. +type OnlyStaticMethods interface { +} + +// The jsii proxy struct for OnlyStaticMethods +type onlyStaticMethods struct { + _ byte // padding +} + +func OnlyStaticMethods_StaticMethod() string { + _init_.Initialize() + var returns string + _jsii_.StaticInvoke( + "jsii-calc.onlystatic.OnlyStaticMethods", + "staticMethod", + []interface{}{}, + true, + &returns, + ) + return returns +} + + +`; + +exports[`Generated code for "jsii-calc": /go/jsiicalc/onlystatic/onlystatic.init.go 1`] = ` +package onlystatic + +import ( + "reflect" + + _jsii_ "github.com/aws/jsii-runtime-go" +) + +func init() { + _jsii_.RegisterClass( + "jsii-calc.onlystatic.OnlyStaticMethods", + reflect.TypeOf((*OnlyStaticMethods)(nil)).Elem(), + func() interface{} { + return &onlyStaticMethods{} + }, + ) +} + +`; + exports[`Generated code for "jsii-calc": /go/jsiicalc/pythonself/pythonself.go 1`] = ` package pythonself @@ -14041,6 +14247,12 @@ func init() { exports[`Generated code for "jsii-calc": /go/jsiicalc/submodule/isolated/isolated.go 1`] = ` package isolated +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/jsiicalc/v3/submodule/child" +) // Ensures imports are correctly registered for kwargs lifted properties from super-structs. type Kwargs interface { 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 54c5eda303..66da64d930 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 @@ -3662,12 +3662,19 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┣━ 📄 NestedClassInstance.java ┃ ┣━ 📄 NestedStruct.java ┃ ┣━ 📄 NodeStandardLibrary.java + ┃ ┣━ 📁 nodirect + ┃ ┃ ┣━ 📁 sub1 + ┃ ┃ ┃ ┗━ 📄 TypeFromSub1.java + ┃ ┃ ┗━ 📁 sub2 + ┃ ┃ ┗━ 📄 TypeFromSub2.java ┃ ┣━ 📄 NullShouldBeTreatedAsUndefined.java ┃ ┣━ 📄 NullShouldBeTreatedAsUndefinedData.java ┃ ┣━ 📄 NumberGenerator.java ┃ ┣━ 📄 ObjectRefsInCollections.java ┃ ┣━ 📄 ObjectWithPropertyProvider.java ┃ ┣━ 📄 Old.java + ┃ ┣━ 📁 onlystatic + ┃ ┃ ┗━ 📄 OnlyStaticMethods.java ┃ ┣━ 📄 OptionalArgumentInvoker.java ┃ ┣━ 📄 OptionalConstructorArgument.java ┃ ┣━ 📄 OptionalStruct.java @@ -21324,6 +21331,107 @@ public interface Hello extends software.amazon.jsii.JsiiSerializable { `; +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; + +/** + */ +@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.nodirect.sub1.TypeFromSub1") +public class TypeFromSub1 extends software.amazon.jsii.JsiiObject { + + protected TypeFromSub1(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected TypeFromSub1(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public TypeFromSub1() { + 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.lang.String sub1() { + return software.amazon.jsii.Kernel.call(this, "sub1", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); + } +} + +`; + +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/nodirect/sub2/TypeFromSub2.java 1`] = ` +package software.amazon.jsii.tests.calculator.nodirect.sub2; + +/** + */ +@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.nodirect.sub2.TypeFromSub2") +public class TypeFromSub2 extends software.amazon.jsii.JsiiObject { + + protected TypeFromSub2(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected TypeFromSub2(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public TypeFromSub2() { + 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.lang.String sub2() { + return software.amazon.jsii.Kernel.call(this, "sub2", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); + } +} + +`; + +exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/onlystatic/OnlyStaticMethods.java 1`] = ` +package software.amazon.jsii.tests.calculator.onlystatic; + +/** + * Test for https://github.com/aws/jsii/issues/2617. + */ +@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.onlystatic.OnlyStaticMethods") +public class OnlyStaticMethods extends software.amazon.jsii.JsiiObject { + + protected OnlyStaticMethods(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected OnlyStaticMethods(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + /** + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable) + public static @org.jetbrains.annotations.NotNull java.lang.String staticMethod() { + return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.jsii.tests.calculator.onlystatic.OnlyStaticMethods.class, "staticMethod", software.amazon.jsii.NativeType.forClass(java.lang.String.class)); + } +} + +`; + exports[`Generated code for "jsii-calc": /java/src/main/java/software/amazon/jsii/tests/calculator/package-info.java 1`] = ` /** *

jsii Calculator

@@ -22943,6 +23051,9 @@ 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.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 jsii-calc.submodule.MyClass=software.amazon.jsii.tests.calculator.submodule.MyClass jsii-calc.submodule.back_references.MyClassReference=software.amazon.jsii.tests.calculator.submodule.back_references.MyClassReference jsii-calc.submodule.child.Awesomeness=software.amazon.jsii.tests.calculator.submodule.child.Awesomeness 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 31c77d8a3e..5771ea5b69 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 @@ -2067,6 +2067,14 @@ exports[`Generated code for "jsii-calc": / 1`] = ` ┃ ┗━ 📄 __init__.py ┣━ 📁 interface_in_namespace_only_interface ┃ ┗━ 📄 __init__.py + ┣━ 📁 nodirect + ┃ ┣━ 📄 __init__.py + ┃ ┣━ 📁 sub1 + ┃ ┃ ┗━ 📄 __init__.py + ┃ ┗━ 📁 sub2 + ┃ ┗━ 📄 __init__.py + ┣━ 📁 onlystatic + ┃ ┗━ 📄 __init__.py ┣━ 📄 py.typed ┣━ 📁 python_self ┃ ┗━ 📄 __init__.py @@ -2372,6 +2380,10 @@ 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.nodirect", + "jsii_calc.nodirect.sub1", + "jsii_calc.nodirect.sub2", + "jsii_calc.onlystatic", "jsii_calc.python_self", "jsii_calc.submodule", "jsii_calc.submodule.back_references", @@ -10175,6 +10187,126 @@ publication.publish() `; +exports[`Generated code for "jsii-calc": /python/src/jsii_calc/nodirect/__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/nodirect/sub1/__init__.py 1`] = ` +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import publication +import typing_extensions + +from ..._jsii import * + + +class TypeFromSub1( + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.nodirect.sub1.TypeFromSub1", +): + def __init__(self) -> None: + jsii.create(TypeFromSub1, self, []) + + @jsii.member(jsii_name="sub1") + def sub1(self) -> builtins.str: + return typing.cast(builtins.str, jsii.invoke(self, "sub1", [])) + + +__all__ = [ + "TypeFromSub1", +] + +publication.publish() + +`; + +exports[`Generated code for "jsii-calc": /python/src/jsii_calc/nodirect/sub2/__init__.py 1`] = ` +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import publication +import typing_extensions + +from ..._jsii import * + + +class TypeFromSub2( + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.nodirect.sub2.TypeFromSub2", +): + def __init__(self) -> None: + jsii.create(TypeFromSub2, self, []) + + @jsii.member(jsii_name="sub2") + def sub2(self) -> builtins.str: + return typing.cast(builtins.str, jsii.invoke(self, "sub2", [])) + + +__all__ = [ + "TypeFromSub2", +] + +publication.publish() + +`; + +exports[`Generated code for "jsii-calc": /python/src/jsii_calc/onlystatic/__init__.py 1`] = ` +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import publication +import typing_extensions + +from .._jsii import * + + +class OnlyStaticMethods( + metaclass=jsii.JSIIMeta, + jsii_type="jsii-calc.onlystatic.OnlyStaticMethods", +): + '''Test for https://github.com/aws/jsii/issues/2617.''' + + @jsii.member(jsii_name="staticMethod") # type: ignore[misc] + @builtins.classmethod + def static_method(cls) -> builtins.str: + return typing.cast(builtins.str, jsii.sinvoke(cls, "staticMethod", [])) + + +__all__ = [ + "OnlyStaticMethods", +] + +publication.publish() + +`; + exports[`Generated code for "jsii-calc": /python/src/jsii_calc/py.typed 1`] = ` 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 4001a1e815..ef44e72781 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,30 @@ exports[`jsii-tree --all 1`] = ` │ │ │ └─┬ enum CompositionStringStyle (stable) │ │ │ ├── NORMAL (stable) │ │ │ └── DECORATED (stable) + │ │ ├─┬ nodirect + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ sub1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class TypeFromSub1 (stable) + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer (stable) + │ │ │ │ │ └─┬ sub1() method (stable) + │ │ │ │ │ └── returns: string + │ │ │ │ └─┬ sub2 + │ │ │ │ └─┬ types + │ │ │ │ └─┬ class TypeFromSub2 (stable) + │ │ │ │ └─┬ members + │ │ │ │ ├── () initializer (stable) + │ │ │ │ └─┬ sub2() method (stable) + │ │ │ │ └── returns: string + │ │ │ └── types + │ │ ├─┬ onlystatic + │ │ │ └─┬ types + │ │ │ └─┬ class OnlyStaticMethods (stable) + │ │ │ └─┬ members + │ │ │ └─┬ static staticMethod() method (stable) + │ │ │ ├── static + │ │ │ └── returns: string │ │ └─┬ submodule │ │ ├─┬ submodules │ │ │ ├─┬ back_references @@ -2863,6 +2887,18 @@ exports[`jsii-tree --inheritance 1`] = ` │ │ │ ├─┬ class CompositeOperation │ │ │ │ └── base: Operation │ │ │ └── enum CompositionStringStyle + │ │ ├─┬ nodirect + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ sub1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class TypeFromSub1 + │ │ │ │ └─┬ sub2 + │ │ │ │ └─┬ types + │ │ │ │ └── class TypeFromSub2 + │ │ │ └── types + │ │ ├─┬ onlystatic + │ │ │ └─┬ types + │ │ │ └── class OnlyStaticMethods │ │ └─┬ submodule │ │ ├─┬ submodules │ │ │ ├─┬ back_references @@ -3267,6 +3303,26 @@ exports[`jsii-tree --members 1`] = ` │ │ │ └─┬ enum CompositionStringStyle │ │ │ ├── NORMAL │ │ │ └── DECORATED + │ │ ├─┬ nodirect + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ sub1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class TypeFromSub1 + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer + │ │ │ │ │ └── sub1() method + │ │ │ │ └─┬ sub2 + │ │ │ │ └─┬ types + │ │ │ │ └─┬ class TypeFromSub2 + │ │ │ │ └─┬ members + │ │ │ │ ├── () initializer + │ │ │ │ └── sub2() method + │ │ │ └── types + │ │ ├─┬ onlystatic + │ │ │ └─┬ types + │ │ │ └─┬ class OnlyStaticMethods + │ │ │ └─┬ members + │ │ │ └── static staticMethod() method │ │ └─┬ submodule │ │ ├─┬ submodules │ │ │ ├─┬ back_references @@ -4490,6 +4546,11 @@ exports[`jsii-tree --signatures 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├─┬ nodirect + │ │ └─┬ submodules + │ │ ├── sub1 + │ │ └── sub2 + │ ├── onlystatic │ └─┬ submodule │ └─┬ submodules │ ├── back_references @@ -4533,6 +4594,18 @@ exports[`jsii-tree --types 1`] = ` │ │ │ └─┬ types │ │ │ ├── class CompositeOperation │ │ │ └── enum CompositionStringStyle + │ │ ├─┬ nodirect + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ sub1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class TypeFromSub1 + │ │ │ │ └─┬ sub2 + │ │ │ │ └─┬ types + │ │ │ │ └── class TypeFromSub2 + │ │ │ └── types + │ │ ├─┬ onlystatic + │ │ │ └─┬ types + │ │ │ └── class OnlyStaticMethods │ │ └─┬ submodule │ │ ├─┬ submodules │ │ │ ├─┬ back_references @@ -4815,6 +4888,11 @@ exports[`jsii-tree 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├─┬ nodirect + │ │ └─┬ submodules + │ │ ├── sub1 + │ │ └── sub2 + │ ├── onlystatic │ └─┬ submodule │ └─┬ submodules │ ├── back_references diff --git a/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap b/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap index 912f35b07f..e847895178 100644 --- a/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/tree.test.ts.snap @@ -9,6 +9,11 @@ exports[`defaults 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├─┬ nodirect + │ │ └─┬ submodules + │ │ ├── sub1 + │ │ └── sub2 + │ ├── onlystatic │ └─┬ submodule │ └─┬ submodules │ ├── back_references @@ -36,6 +41,11 @@ exports[`inheritance 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├─┬ nodirect + │ │ └─┬ submodules + │ │ ├── sub1 + │ │ └── sub2 + │ ├── onlystatic │ └─┬ submodule │ └─┬ submodules │ ├── back_references @@ -63,6 +73,11 @@ exports[`members 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├─┬ nodirect + │ │ └─┬ submodules + │ │ ├── sub1 + │ │ └── sub2 + │ ├── onlystatic │ └─┬ submodule │ └─┬ submodules │ ├── back_references @@ -183,6 +198,30 @@ exports[`showAll 1`] = ` │ │ │ └─┬ enum CompositionStringStyle │ │ │ ├── NORMAL │ │ │ └── DECORATED + │ │ ├─┬ nodirect + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ sub1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └─┬ class TypeFromSub1 + │ │ │ │ │ └─┬ members + │ │ │ │ │ ├── () initializer + │ │ │ │ │ └─┬ sub1() method + │ │ │ │ │ └── returns: string + │ │ │ │ └─┬ sub2 + │ │ │ │ └─┬ types + │ │ │ │ └─┬ class TypeFromSub2 + │ │ │ │ └─┬ members + │ │ │ │ ├── () initializer + │ │ │ │ └─┬ sub2() method + │ │ │ │ └── returns: string + │ │ │ └── types + │ │ ├─┬ onlystatic + │ │ │ └─┬ types + │ │ │ └─┬ class OnlyStaticMethods + │ │ │ └─┬ members + │ │ │ └─┬ static staticMethod() method + │ │ │ ├── static + │ │ │ └── returns: string │ │ └─┬ submodule │ │ ├─┬ submodules │ │ │ ├─┬ back_references @@ -2926,6 +2965,11 @@ exports[`signatures 1`] = ` │ ├── InterfaceInNamespaceOnlyInterface │ ├── PythonSelf │ ├── composition + │ ├─┬ nodirect + │ │ └─┬ submodules + │ │ ├── sub1 + │ │ └── sub2 + │ ├── onlystatic │ └─┬ submodule │ └─┬ submodules │ ├── back_references @@ -2969,6 +3013,18 @@ exports[`types 1`] = ` │ │ │ └─┬ types │ │ │ ├── class CompositeOperation │ │ │ └── enum CompositionStringStyle + │ │ ├─┬ nodirect + │ │ │ ├─┬ submodules + │ │ │ │ ├─┬ sub1 + │ │ │ │ │ └─┬ types + │ │ │ │ │ └── class TypeFromSub1 + │ │ │ │ └─┬ sub2 + │ │ │ │ └─┬ types + │ │ │ │ └── class TypeFromSub2 + │ │ │ └── types + │ │ ├─┬ onlystatic + │ │ │ └─┬ types + │ │ │ └── class OnlyStaticMethods │ │ └─┬ submodule │ │ ├─┬ submodules │ │ │ ├─┬ back_references 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 592faa8acb..0c57a972f7 100644 --- a/packages/jsii-reflect/test/__snapshots__/type-system.test.ts.snap +++ b/packages/jsii-reflect/test/__snapshots__/type-system.test.ts.snap @@ -149,6 +149,9 @@ Array [ "jsii-calc.VoidCallback", "jsii-calc.WithPrivatePropertyInConstructor", "jsii-calc.composition.CompositeOperation", + "jsii-calc.nodirect.sub1.TypeFromSub1", + "jsii-calc.nodirect.sub2.TypeFromSub2", + "jsii-calc.onlystatic.OnlyStaticMethods", "jsii-calc.submodule.MyClass", "jsii-calc.submodule.child.InnerClass", "jsii-calc.submodule.child.OuterClass",