diff --git a/docs/specifications/2-type-system.md b/docs/specifications/2-type-system.md index 961e71d42f..f8de1ff23f 100644 --- a/docs/specifications/2-type-system.md +++ b/docs/specifications/2-type-system.md @@ -311,6 +311,86 @@ document. } ``` +## Submodules + +> :construction: The *submodules* feature is still under active development and +> the specific behavior around it (in particular with respects to code +> generation) are still subject to change. + +### Overview + +Typescript allows grouping declarations together in *namespaces*, which are +interpreted by *jsii* as *submodules*. *Submodules* names are the fully +qualified name of the namespace from the package's root (if a package `foo` +defines a namespace `ns1`, which itself contains `ns2`, the submodule for `ns2` +will be named `foo.ns1.ns2`). + +*Submodules* may use different [code-generation configuration](#code-generation) +than their parent submodule or package. + +> :construction: *Submodule*-level code-generation configuration is not yet +> implemented. + +### Restrictions + +*Submodules* cannot be involved in dependency cycles. While it is possible to +build such cycles in **JavaScript**, that configuration cannot be reliably +reprensented in certain other programming languages (e.g: **Python**). + +> :construction: [`jsii`] does not currently check for circular submodule +> dependencies. Invalid dependency patterns may result in errors at code +> generation by [`jsii-pacmak`], or at runtime. + +Since this would result in ambiguity that cannot be consistently resolved, a +given type can only be exported as part of one *submodule*. + +[`jsii`]: ../../packages/jsii +[`jsii-pacmak`]: ../../packages/jsii-pacmak + +### Declaration + +There are two supported ways to introduce *submodules*: +* Using the namespaced export syntax: + ```ts + export * as ns from './module'; + ``` +* Using an explicit namespace declaration: + ```ts + export namespace ns { /* ... */ } + ``` + +*Submodules* declared using the `export * as ns from './module';` syntax can be +documented using a markdown document located at `./module/README.md`. + +> :construction: The `./module/README.md` file support is not yet implemented. + +### Code Generation + +In languages where this is relevant (e.g: **Python**), *submodules* are rendered +as native *submodules*. In languages where a namespace system exists (**Java** +uses *packages*, **C#** uses *namespaces*, ...), *submodules* are rendered using +that. + +## Code Generation + +In order to generate code in various programming languages, [`jsii-pacmak`] +needs configuration that provides naming directives (e.g: **Java** package +names, **C#** namespaces, **Python** module names, ...). This configuration is +language-specific and each language implementation specifies and documents its +own configuration schema. + +Configuration is sourced in the `package.json` file at the root of the npm +package, under the special `jsii` key. The general schema is described in the +[configuration] document. + +> :construction: There is a proposition to allow this configuration to be placed +> in a `.jsiirc.json` file, which would take precedence over what is specified +> in `package.json`. *Submodules* introduced using the +> `export * as ns from './module';` syntax would then be able to define +> *submodule*-local configuration using the `./module/.jsiirc.json` file. + +[configuration]: ../configuration.md + ## References The [**TypeScript** Handbook] describes the language's type system and syntax diff --git a/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs b/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs index 49d8f1fbc2..0efed214b6 100644 --- a/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs +++ b/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs @@ -3,7 +3,7 @@ using System.Linq; using Amazon.JSII.Runtime.Deputy; using Amazon.JSII.Tests.CalculatorNamespace; -using CompositeOperation = Amazon.JSII.Tests.CalculatorNamespace.composition.CompositeOperation; +using CompositeOperation = Amazon.JSII.Tests.CalculatorNamespace.Composition.CompositeOperation; using Amazon.JSII.Tests.CalculatorNamespace.LibNamespace; using Newtonsoft.Json.Linq; using Xunit; @@ -1413,11 +1413,11 @@ public void AbstractMembersAreCorrectlyHandled() var abstractSuite = new AbstractSuiteImpl(); Assert.Equal("Wrapped>", abstractSuite.WorkItAll("Oomf!")); } - + private sealed class AbstractSuiteImpl : AbstractSuite { private string _property = ""; - + public AbstractSuiteImpl() {} protected override string SomeMethod(string str) @@ -1440,7 +1440,7 @@ public void CollectionOfInterfaces_ListOfStructs() Assert.IsAssignableFrom(elt); } } - + [Fact(DisplayName = Prefix + nameof(CollectionOfInterfaces_ListOfInterfaces))] public void CollectionOfInterfaces_ListOfInterfaces() { @@ -1449,7 +1449,7 @@ public void CollectionOfInterfaces_ListOfInterfaces() Assert.IsAssignableFrom(elt); } } - + [Fact(DisplayName = Prefix + nameof(CollectionOfInterfaces_MapOfStructs))] public void CollectionOfInterfaces_MapOfStructs() { @@ -1458,7 +1458,7 @@ public void CollectionOfInterfaces_MapOfStructs() Assert.IsAssignableFrom(elt); } } - + [Fact(DisplayName = Prefix + nameof(CollectionOfInterfaces_MapOfInterfaces))] public void CollectionOfInterfaces_MapOfInterfaces() { diff --git a/packages/jsii-calc/lib/index.ts b/packages/jsii-calc/lib/index.ts index 0b507f6734..04754deacd 100644 --- a/packages/jsii-calc/lib/index.ts +++ b/packages/jsii-calc/lib/index.ts @@ -3,3 +3,5 @@ export * from './compliance'; export * from './documented'; export * from './erasures'; export * from './stability'; + +export * as submodule from './submodule'; diff --git a/packages/jsii-calc/lib/submodule/child/index.ts b/packages/jsii-calc/lib/submodule/child/index.ts new file mode 100644 index 0000000000..57dd858234 --- /dev/null +++ b/packages/jsii-calc/lib/submodule/child/index.ts @@ -0,0 +1,12 @@ +export interface Structure { + readonly bool: boolean; +} + +export enum Goodness { + /** It's pretty good */ + PRETTY_GOOD, + /** It's really good */ + REALLY_GOOD, + /** It's amazingly good */ + AMAZINGLY_GOOD +} diff --git a/packages/jsii-calc/lib/submodule/index.ts b/packages/jsii-calc/lib/submodule/index.ts new file mode 100644 index 0000000000..e316cdc703 --- /dev/null +++ b/packages/jsii-calc/lib/submodule/index.ts @@ -0,0 +1,4 @@ +export * as child from './child'; +export * from './my-class'; +export * from './nested_submodule'; +export * as back_references from './refers-to-parent'; diff --git a/packages/jsii-calc/lib/submodule/my-class.ts b/packages/jsii-calc/lib/submodule/my-class.ts new file mode 100644 index 0000000000..991f55679d --- /dev/null +++ b/packages/jsii-calc/lib/submodule/my-class.ts @@ -0,0 +1,11 @@ +import { nested_submodule } from './nested_submodule'; +import { Goodness } from './child'; +import { AllTypes } from '..'; + +export class MyClass implements nested_submodule.deeplyNested.INamespaced { + public readonly definedAt = __filename; + public readonly goodness = Goodness.AMAZINGLY_GOOD; + public allTypes?: AllTypes; + + public constructor() { } +} diff --git a/packages/jsii-calc/lib/submodule/nested_submodule.ts b/packages/jsii-calc/lib/submodule/nested_submodule.ts new file mode 100644 index 0000000000..144e62e904 --- /dev/null +++ b/packages/jsii-calc/lib/submodule/nested_submodule.ts @@ -0,0 +1,16 @@ +import { Goodness } from './child'; + +export namespace nested_submodule { + export namespace deeplyNested { + export interface INamespaced { + readonly definedAt: string; + } + } + + export abstract class Namespaced implements deeplyNested.INamespaced { + public readonly definedAt = __filename; + public abstract readonly goodness: Goodness; + + private constructor() { } + } +} diff --git a/packages/jsii-calc/lib/submodule/refers-to-parent/index.ts b/packages/jsii-calc/lib/submodule/refers-to-parent/index.ts new file mode 100644 index 0000000000..4c4f5b11db --- /dev/null +++ b/packages/jsii-calc/lib/submodule/refers-to-parent/index.ts @@ -0,0 +1,5 @@ +import { MyClass } from '..'; + +export interface MyClassReference { + readonly reference: MyClass; +} diff --git a/packages/jsii-calc/test/assembly.jsii b/packages/jsii-calc/test/assembly.jsii index 56967ae828..0db4ab2889 100644 --- a/packages/jsii-calc/test/assembly.jsii +++ b/packages/jsii-calc/test/assembly.jsii @@ -12153,8 +12153,257 @@ ], "name": "CompositionStringStyle", "namespace": "composition.CompositeOperation" + }, + "jsii-calc.submodule.MyClass": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.MyClass", + "initializer": { + "docs": { + "stability": "experimental" + } + }, + "interfaces": [ + "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced" + ], + "kind": "class", + "locationInModule": { + "filename": "lib/submodule/my-class.ts", + "line": 5 + }, + "name": "MyClass", + "namespace": "submodule", + "properties": [ + { + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/my-class.ts", + "line": 6 + }, + "name": "definedAt", + "overrides": "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced", + "type": { + "primitive": "string" + } + }, + { + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/my-class.ts", + "line": 7 + }, + "name": "goodness", + "type": { + "fqn": "jsii-calc.submodule.child.Goodness" + } + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/submodule/my-class.ts", + "line": 8 + }, + "name": "allTypes", + "optional": true, + "type": { + "fqn": "jsii-calc.AllTypes" + } + } + ] + }, + "jsii-calc.submodule.back_references.MyClassReference": { + "assembly": "jsii-calc", + "datatype": true, + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.back_references.MyClassReference", + "kind": "interface", + "locationInModule": { + "filename": "lib/submodule/refers-to-parent/index.ts", + "line": 3 + }, + "name": "MyClassReference", + "namespace": "submodule.back_references", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/refers-to-parent/index.ts", + "line": 4 + }, + "name": "reference", + "type": { + "fqn": "jsii-calc.submodule.MyClass" + } + } + ] + }, + "jsii-calc.submodule.child.Goodness": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.child.Goodness", + "kind": "enum", + "locationInModule": { + "filename": "lib/submodule/child/index.ts", + "line": 5 + }, + "members": [ + { + "docs": { + "stability": "experimental", + "summary": "It's pretty good." + }, + "name": "PRETTY_GOOD" + }, + { + "docs": { + "stability": "experimental", + "summary": "It's really good." + }, + "name": "REALLY_GOOD" + }, + { + "docs": { + "stability": "experimental", + "summary": "It's amazingly good." + }, + "name": "AMAZINGLY_GOOD" + } + ], + "name": "Goodness", + "namespace": "submodule.child" + }, + "jsii-calc.submodule.child.Structure": { + "assembly": "jsii-calc", + "datatype": true, + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.child.Structure", + "kind": "interface", + "locationInModule": { + "filename": "lib/submodule/child/index.ts", + "line": 1 + }, + "name": "Structure", + "namespace": "submodule.child", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/child/index.ts", + "line": 2 + }, + "name": "bool", + "type": { + "primitive": "boolean" + } + } + ] + }, + "jsii-calc.submodule.nested_submodule.Namespaced": { + "abstract": true, + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.nested_submodule.Namespaced", + "interfaces": [ + "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced" + ], + "kind": "class", + "locationInModule": { + "filename": "lib/submodule/nested_submodule.ts", + "line": 10 + }, + "name": "Namespaced", + "namespace": "submodule.nested_submodule", + "properties": [ + { + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/nested_submodule.ts", + "line": 11 + }, + "name": "definedAt", + "overrides": "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced", + "type": { + "primitive": "string" + } + }, + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/nested_submodule.ts", + "line": 12 + }, + "name": "goodness", + "type": { + "fqn": "jsii-calc.submodule.child.Goodness" + } + } + ] + }, + "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced", + "kind": "interface", + "locationInModule": { + "filename": "lib/submodule/nested_submodule.ts", + "line": 5 + }, + "name": "INamespaced", + "namespace": "submodule.nested_submodule.deeplyNested", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/nested_submodule.ts", + "line": 6 + }, + "name": "definedAt", + "type": { + "primitive": "string" + } + } + ] } }, "version": "1.1.0", - "fingerprint": "EIFtfZN4eukuZnpbTeqrxdc/JrKnU8eDm1SVncWk/vU=" + "fingerprint": "vtobmk8xL6Ke30Blb4NyDZ1X7T7J8lcKbbrmZtMtcpU=" } diff --git a/packages/jsii-diff/lib/index.ts b/packages/jsii-diff/lib/index.ts index 50928d65fc..18e6c1b335 100644 --- a/packages/jsii-diff/lib/index.ts +++ b/packages/jsii-diff/lib/index.ts @@ -59,7 +59,11 @@ export function compareEnums(original: reflect.Assembly, updated: reflect.Assemb } } -function* typePairs(xs: T[], updatedAssembly: reflect.Assembly, context: ComparisonContext): IterableIterator<[T, T]> { +function* typePairs( + xs: readonly T[], + updatedAssembly: reflect.Assembly, + context: ComparisonContext +): IterableIterator<[T, T]> { for (const origType of xs) { LOG.trace(origType.fqn); diff --git a/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts index ebc2d9cea6..9691630fb6 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/dotnetgenerator.ts @@ -1,7 +1,9 @@ import * as clone from 'clone'; +import { toPascalCase } from 'codemaker'; import * as fs from 'fs-extra'; import * as reflect from 'jsii-reflect'; import * as spec from '@jsii/spec'; +import { Rosetta } from 'jsii-rosetta'; import * as path from 'path'; import { Generator } from '../../generator'; import { DotNetDocGenerator } from './dotnetdocgenerator'; @@ -9,7 +11,6 @@ import { DotNetRuntimeGenerator } from './dotnetruntimegenerator'; import { DotNetTypeResolver } from './dotnettyperesolver'; import { FileGenerator } from './filegenerator'; import { DotNetNameUtils } from './nameutils'; -import { Rosetta } from 'jsii-rosetta'; /** * CODE GENERATOR V2 @@ -120,7 +121,7 @@ export class DotNetGenerator extends Generator { protected onBeginInterface(ifc: spec.InterfaceType) { const implementations = this.typeresolver.resolveImplementedInterfaces(ifc); const interfaceName = this.nameutils.convertInterfaceName(ifc); - const namespace = ifc.namespace ? `${this.assembly.targets!.dotnet!.namespace}.${ifc.namespace}` : this.assembly.targets!.dotnet!.namespace; + const namespace = this.namespaceFor(this.assembly, ifc); this.openFileIfNeeded(interfaceName, namespace, this.isNested(ifc)); this.dotnetDocGenerator.emitDocs(ifc); @@ -137,7 +138,7 @@ export class DotNetGenerator extends Generator { protected onEndInterface(ifc: spec.InterfaceType) { const interfaceName = this.nameutils.convertInterfaceName(ifc); this.code.closeBlock(); - const namespace = ifc.namespace ? `${this.assembly.targets!.dotnet!.namespace}.${ifc.namespace}` : this.assembly.targets!.dotnet!.namespace; + const namespace = this.namespaceFor(this.assembly, ifc); this.closeFileIfNeeded(interfaceName, namespace, this.isNested(ifc)); // emit interface proxy class @@ -212,7 +213,7 @@ export class DotNetGenerator extends Generator { protected onBeginClass(cls: spec.ClassType, abstract: boolean) { let baseTypeNames: string[] = []; - const namespace = cls.namespace ? `${this.assembly.targets!.dotnet!.namespace}.${cls.namespace}` : this.assembly.targets!.dotnet!.namespace; + const namespace = this.namespaceFor(this.assembly, cls); // A class can derive from only one base class // But can implement multiple interfaces @@ -294,7 +295,7 @@ export class DotNetGenerator extends Generator { protected onEndClass(cls: spec.ClassType) { this.code.closeBlock(); const className = this.nameutils.convertClassName(cls); - const namespace = cls.namespace ? `${this.assembly.targets!.dotnet!.namespace}.${cls.namespace}` : this.assembly.targets!.dotnet!.namespace; + const namespace = this.namespaceFor(this.assembly, cls); this.closeFileIfNeeded(className, namespace, this.isNested(cls)); if (cls.abstract) { @@ -338,7 +339,7 @@ export class DotNetGenerator extends Generator { protected onBeginEnum(enm: spec.EnumType) { const enumName = this.nameutils.convertTypeName(enm.name); - const namespace = enm.namespace ? `${this.assembly.targets!.dotnet!.namespace}.${enm.namespace}` : this.assembly.targets!.dotnet!.namespace; + const namespace = this.namespaceFor(this.assembly, enm); this.openFileIfNeeded(enumName, namespace, this.isNested(enm)); this.emitNewLineIfNecessary(); this.dotnetDocGenerator.emitDocs(enm); @@ -349,7 +350,7 @@ export class DotNetGenerator extends Generator { protected onEndEnum(enm: spec.EnumType) { this.code.closeBlock(); const enumName = this.nameutils.convertTypeName(enm.name); - const namespace = enm.namespace ? `${this.assembly.targets!.dotnet!.namespace}.${enm.namespace}` : this.assembly.targets!.dotnet!.namespace; + const namespace = this.namespaceFor(this.assembly, enm); this.closeFileIfNeeded(enumName, namespace, this.isNested(enm)); } @@ -365,6 +366,19 @@ export class DotNetGenerator extends Generator { } } + private namespaceFor(assm: spec.Assembly, type: spec.Type): string { + const parts = [assm.targets!.dotnet!.namespace]; + let ns = type.namespace; + while (ns != null && assm.types?.[`${assm.name}.${ns}`] != null) { + const nesting = assm.types[`${assm.name}.${ns}`]; + ns = nesting.namespace; + } + if (ns != null) { + parts.push(...ns.split('.').map(n => toPascalCase(n))); + } + return parts.join('.'); + } + private emitMethod(cls: spec.ClassType | spec.InterfaceType, method: spec.Method, emitForProxyOrDatatype = false): void { this.emitNewLineIfNecessary(); const returnType = method.returns ? this.typeresolver.toDotNetType(method.returns.type) : 'void'; @@ -502,7 +516,7 @@ export class DotNetGenerator extends Generator { private emitInterfaceProxy(ifc: spec.InterfaceType | spec.ClassType): void { // No need to slugify for a proxy const name = `${this.nameutils.convertTypeName(ifc.name)}Proxy`; - const namespace = ifc.namespace ? `${this.assembly.targets!.dotnet!.namespace}.${ifc.namespace}` : this.assembly.targets!.dotnet!.namespace; + const namespace = this.namespaceFor(this.assembly, ifc); const isNested = this.isNested(ifc); this.openFileIfNeeded(name, namespace, isNested); @@ -537,7 +551,7 @@ export class DotNetGenerator extends Generator { private emitInterfaceDataType(ifc: spec.InterfaceType): void { // Interface datatypes do not need to be prefixed by I, we can call convertClassName const name = this.nameutils.convertClassName(ifc); - const namespace = ifc.namespace ? `${this.assembly.targets!.dotnet!.namespace}.${ifc.namespace}` : this.assembly.targets!.dotnet!.namespace; + const namespace = this.namespaceFor(this.assembly, ifc); const isNested = this.isNested(ifc); this.openFileIfNeeded(name, namespace, isNested); diff --git a/packages/jsii-pacmak/lib/targets/dotnet/dotnettyperesolver.ts b/packages/jsii-pacmak/lib/targets/dotnet/dotnettyperesolver.ts index f809520466..a72d673d3b 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/dotnettyperesolver.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/dotnettyperesolver.ts @@ -1,4 +1,5 @@ import * as spec from '@jsii/spec'; +import { toPascalCase } from 'codemaker'; import { DotNetDependency } from './filegenerator'; import { DotNetNameUtils } from './nameutils'; @@ -46,6 +47,7 @@ export class DotNetTypeResolver { } const [mod] = fqn.split('.'); const depMod = this.findModule(mod); + const dotnetNamespace = depMod.targets?.dotnet?.namespace; if (!dotnetNamespace) { throw new Error('The module does not have a dotnet.namespace setting'); @@ -59,7 +61,7 @@ export class DotNetTypeResolver { const actualNamespace = this.toDotNetType(this.findType(namespaceFqn)); return `${actualNamespace}.${typeName}`; } - return `${dotnetNamespace}.${type.namespace}.${typeName}`; + return `${dotnetNamespace}.${type.namespace.split('.').map(s => toPascalCase(s)).join('.')}.${typeName}`; } // When undefined, the type is located at the root of the assembly return `${dotnetNamespace}.${typeName}`; diff --git a/packages/jsii-pacmak/lib/targets/java.ts b/packages/jsii-pacmak/lib/targets/java.ts index 25ef90fed7..8a61e9c8c9 100644 --- a/packages/jsii-pacmak/lib/targets/java.ts +++ b/packages/jsii-pacmak/lib/targets/java.ts @@ -1,5 +1,5 @@ import * as clone from 'clone'; -import { toPascalCase } from 'codemaker/lib/case-utils'; +import { toPascalCase, toSnakeCase } from 'codemaker/lib/case-utils'; import * as fs from 'fs-extra'; import * as reflect from 'jsii-reflect'; import { Rosetta, typeScriptSnippetFromSource, Translation, markDownToJavaDoc } from 'jsii-rosetta'; @@ -395,9 +395,9 @@ class JavaGenerator extends Generator { ]; /** - * Turns a raw javascript property name (eg: 'default') into a safe Java property name (eg: 'defaultValue'). - * @param propertyName the raw JSII property Name - */ + * Turns a raw javascript property name (eg: 'default') into a safe Java property name (eg: 'defaultValue'). + * @param propertyName the raw JSII property Name + */ private static safeJavaPropertyName(propertyName: string) { if (!propertyName) { return propertyName; @@ -411,9 +411,9 @@ class JavaGenerator extends Generator { } /** - * Turns a raw javascript method name (eg: 'import') into a safe Java method name (eg: 'doImport'). - * @param methodName - */ + * Turns a raw javascript method name (eg: 'import') into a safe Java method name (eg: 'doImport'). + * @param methodName + */ private static safeJavaMethodName(methodName: string) { if (!methodName) { return methodName; @@ -431,11 +431,11 @@ class JavaGenerator extends Generator { private moduleClass!: string; /** - * A map of all the modules ever referenced during code generation. These include - * direct dependencies but can potentially also include transitive dependencies, when, - * for example, we need to refer to their types when flatting the class hierarchy for - * interface proxies. - */ + * A map of all the modules ever referenced during code generation. These include + * direct dependencies but can potentially also include transitive dependencies, when, + * for example, we need to refer to their types when flatting the class hierarchy for + * interface proxies. + */ private readonly referencedModules: { [name: string]: spec.AssemblyConfiguration } = { }; public constructor(private readonly rosetta: Rosetta) { @@ -530,8 +530,8 @@ class JavaGenerator extends Generator { } /** - * Since we expand the union setters, we will use this event to only emit the getter which returns an Object. - */ + * Since we expand the union setters, we will use this event to only emit the getter which returns an Object. + */ protected onUnionProperty(cls: spec.ClassType, prop: spec.Property, _union: spec.UnionTypeReference) { this.emitProperty(cls, prop); } @@ -651,8 +651,13 @@ class JavaGenerator extends Generator { private emitPackageInfo(mod: spec.Assembly) { if (!mod.docs) { return; } - const packageName = this.getNativeName(mod, undefined); - const packageInfoFile = this.toJavaFilePath(`${mod.name}.package-info`); + const { packageName } = this.toNativeName(mod); + const packageInfoFile = this.toJavaFilePath(mod, { + assembly: mod.name, + fqn: `${mod.name}.package-info`, + kind: spec.TypeKind.Class, + name: 'package-info' + }); this.code.openFile(packageInfoFile); this.code.line('/**'); if (mod.readme) { @@ -1011,14 +1016,14 @@ class JavaGenerator extends Generator { } /** - * We are now going to build a class that can be used as a proxy for untyped - * javascript objects that implement this interface. we want java code to be - * able to interact with them, so we will create a proxy class which - * implements this interface and has the same methods. - * - * These proxies are also used to extend abstract classes to allow the JSII - * engine to instantiate an abstract class in Java. - */ + * We are now going to build a class that can be used as a proxy for untyped + * javascript objects that implement this interface. we want java code to be + * able to interact with them, so we will create a proxy class which + * implements this interface and has the same methods. + * + * These proxies are also used to extend abstract classes to allow the JSII + * engine to instantiate an abstract class in Java. + */ private emitProxy(ifc: spec.InterfaceType | spec.ClassType) { const name = INTERFACE_PROXY_CLASS_NAME; @@ -1516,8 +1521,8 @@ class JavaGenerator extends Generator { return; } - this.code.openFile(this.toJavaFilePath(type.fqn)); - this.code.line(`package ${this.getNativeName(this.assembly, type.namespace)};`); + this.code.openFile(this.toJavaFilePath(this.assembly, type)); + this.code.line(`package ${this.toNativeName(this.assembly, type).packageName};`); this.code.line(); } @@ -1525,7 +1530,7 @@ class JavaGenerator extends Generator { if (this.isNested(type)) { return; } - this.code.closeFile(this.toJavaFilePath(type.fqn)); + this.code.closeFile(this.toJavaFilePath(this.assembly, type)); } private isNested(type: spec.Type) { @@ -1534,11 +1539,12 @@ class JavaGenerator extends Generator { return parent in this.assembly.types; } - private toJavaFilePath(fqn: string) { - const nativeFqn = this.toNativeFqn(fqn); - return `${path.join('src', 'main', 'java', ...nativeFqn.split('.'))}.java`; + private toJavaFilePath(assm: spec.Assembly, type: spec.Type) { + const { packageName, typeName } = this.toNativeName(assm, type); + return `${path.join('src', 'main', 'java', ...packageName.split('.'), typeName.split('.')[0])}.java`; } + // eslint-disable-next-line complexity private addJavaDocs(doc: spec.Documentable, defaultText?: string) { if (!defaultText && Object.keys(doc.docs ?? {}).length === 0 && !((doc as spec.Method).parameters ?? []).some(p => Object.keys(p.docs ?? {}).length !== 0)) { @@ -1758,12 +1764,12 @@ class JavaGenerator extends Generator { } /** - * Wraps a collection into an unmodifiable collection else returns the existing statement. - * @param statement The statement to wrap if necessary. - * @param type The type of the object to wrap. - * @param optional Whether the value is optional (can be null/undefined) or not. - * @returns The modified or original statement. - */ + * Wraps a collection into an unmodifiable collection else returns the existing statement. + * @param statement The statement to wrap if necessary. + * @param type The type of the object to wrap. + * @param optional Whether the value is optional (can be null/undefined) or not. + * @returns The modified or original statement. + */ private wrapCollection(statement: string, type: spec.TypeReference, optional?: boolean): string { if (spec.isCollectionTypeReference(type)) { let wrapper: string; @@ -1804,16 +1810,17 @@ class JavaGenerator extends Generator { return `${this.toNativeFqn(moduleName)}.${MODULE_CLASS_NAME}`; } - private makeModuleFqn(moduleName: string) { - return `${moduleName}.${MODULE_CLASS_NAME}`; - } - private emitModuleFile(mod: spec.Assembly) { const moduleName = mod.name; const moduleClass = this.makeModuleClass(moduleName); - const moduleFile = this.toJavaFilePath(this.makeModuleFqn(moduleName)); + const moduleFile = this.toJavaFilePath(mod, { + assembly: mod.name, + fqn: `${mod.name}.${MODULE_CLASS_NAME}`, + kind: spec.TypeKind.Class, + name: MODULE_CLASS_NAME, + }); this.code.openFile(moduleFile); - this.code.line(`package ${this.toNativeFqn(moduleName)};`); + this.code.line(`package ${this.toNativeName(mod).packageName};`); this.code.line(); if (Object.keys(mod.dependencies ?? {}).length > 0) { this.code.line('import static java.util.Arrays.asList;'); @@ -1875,17 +1882,17 @@ class JavaGenerator extends Generator { } /** - * Computes the java FQN for a JSII FQN: - * 1. Determine which assembly the FQN belongs to (first component of the FQN) - * 2. Locate the `targets.java.package` value for that assembly (this assembly, or one of the dependencies) - * 3. Return the java FQN: ``.`` - * - * @param fqn the JSII FQN to be used. - * - * @returns the corresponding Java FQN. - * - * @throws if the assembly the FQN belongs to does not have a `targets.java.package` set. - */ + * Computes the java FQN for a JSII FQN: + * 1. Determine which assembly the FQN belongs to (first component of the FQN) + * 2. Locate the `targets.java.package` value for that assembly (this assembly, or one of the dependencies) + * 3. Return the java FQN: ``.`` + * + * @param fqn the JSII FQN to be used. + * + * @returns the corresponding Java FQN. + * + * @throws if the assembly the FQN belongs to does not have a `targets.java.package` set. + */ private toNativeFqn(fqn: string): string { const [mod, ...name] = fqn.split('.'); const depMod = this.findModule(mod); @@ -1894,8 +1901,11 @@ class JavaGenerator extends Generator { // dependencies' dependency structure). if (mod !== this.assembly.name) { this.referencedModules[mod] = depMod; + return this.getNativeName(depMod, name.join('.'), mod); } - return this.getNativeName(depMod, name.join('.'), mod); + + const { packageName, typeName } = this.toNativeName(this.assembly, this.assembly.types![fqn]); + return `${packageName}${typeName ? `.${typeName}` : ''}`; } private getNativeName(assm: spec.Assembly, name: string | undefined): string; @@ -1910,9 +1920,33 @@ class JavaGenerator extends Generator { return `${javaPackage}${name ? `.${name}` : ''}`; } + private toNativeName(assm: spec.Assembly): { packageName: string }; + private toNativeName(assm: spec.Assembly, type: spec.Type): { packageName: string, typeName: string }; + private toNativeName(assm: spec.Assembly, type?: spec.Type): { packageName: string, typeName?: string } { + const javaPackage = assm.targets?.java?.package; + if (!javaPackage) { throw new Error(`The module ${assm.name} does not have a java.package setting`); } + + if (type == null) { + return { packageName: javaPackage }; + } + + let ns = type.namespace; + let typeName = type.name; + while (ns != null && assm.types?.[`${assm.name}.${ns}`] != null) { + const nestingType = assm.types[`${assm.name}.${ns}`]; + ns = nestingType.namespace; + typeName = `${nestingType.name}.${typeName}`; + } + + const packageName = ns != null + ? `${javaPackage}.${ns.split('.').map(s => toSnakeCase(s)).join('.')}` + : javaPackage; + return { packageName, typeName }; + } + /** - * Emits an ``@Generated`` annotation honoring the ``this.emitFullGeneratorInfo`` setting. - */ + * Emits an ``@Generated`` annotation honoring the ``this.emitFullGeneratorInfo`` setting. + */ private emitGeneratedAnnotation() { const date = this.emitFullGeneratorInfo ? `, date = "${new Date().toISOString()}"` diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 198c4cdacf..2e616be024 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -76,7 +76,7 @@ const PYTHON_KEYWORDS = [ ]; const pythonModuleNameToFilename = (name: string): string => { - return name.replace(/\./g, '/'); + return path.join(...name.split('.')); }; const toPythonIdentifier = (name: string): string => { @@ -130,49 +130,47 @@ function toPythonParameterName(name: string, liftedParamNames = new Set( return result; } -const setDifference = (setA: Set, setB: Set): Set => { - const difference = new Set(setA); - for (const elem of setB) { - difference.delete(elem); +const setDifference = (setA: Set, setB: Set): Set => { + const result = new Set(); + for (const item of setA) { + if (!setB.has(item)) { + result.add(item); + } } - return difference; + return result; }; -const sortMembers = (sortable: PythonBase[], resolver: TypeResolver): PythonBase[] => { - const sorted: PythonBase[] = []; - const seen: Set = new Set(); - - // We're going to take a copy of our sortable item, because it'll make it easier if - // this method doesn't have side effects. - sortable = sortable.slice(); +const sortMembers = (members: PythonBase[], resolver: TypeResolver): PythonBase[] => { + let sortable = new Array <{ member: PythonBase & ISortableType, dependsOn: Set }>(); + const sorted = new Array(); + const seen = new Set(); // The first thing we want to do, is push any item which is not sortable to the very // front of the list. This will be things like methods, properties, etc. - for (const item of sortable) { - if (!isSortableType(item)) { - sorted.push(item); - seen.add(item); + for (const member of members) { + if (!isSortableType(member)) { + sorted.push(member); + seen.add(member); + } else { + sortable.push({ member, dependsOn: new Set(member.dependsOn(resolver)) }); } } - sortable = sortable.filter(i => !seen.has(i)); // Now that we've pulled out everything that couldn't possibly have dependencies, // we will go through the remaining items, and pull off any items which have no // dependencies that we haven't already sorted. while (sortable.length > 0) { - for (const item of (sortable as Array)) { - const itemDeps: Set = new Set(item.dependsOn(resolver)); - if (setDifference(itemDeps, seen).size === 0) { - sorted.push(item); - seen.add(item); - - break; + for (const { member, dependsOn } of sortable) { + const diff = setDifference(dependsOn, seen); + if ([...diff].find(dep => !(dep instanceof PythonModule)) == null) { + sorted.push(member); + seen.add(member); } } - const leftover = sortable.filter(i => !seen.has(i)); + const leftover = sortable.filter(({ member }) => !seen.has(member)); if (leftover.length === sortable.length) { - throw new Error('Could not sort members (circular dependency?).'); + throw new Error(`Could not sort members (circular dependency?). Leftover: ${leftover.map(lo => lo.member.pythonName).join(', ')}`); } else { sortable = leftover; } @@ -185,6 +183,15 @@ interface PythonBase { readonly pythonName: string; emit(code: CodeMaker, resolver: TypeResolver, opts?: any): void; + + /** + * Determines what modules a particular sortable entity depends on. + * + * @param resolver a TypeResolver. + * + * @returns the pythonNames of modules this entity depends on. + */ + dependsOnModules(resolver: TypeResolver): Set; } interface PythonType extends PythonBase { @@ -199,8 +206,8 @@ interface ISortableType { dependsOn(resolver: TypeResolver): PythonType[]; } -function isSortableType(arg: any): arg is ISortableType { - return arg.dependsOn !== undefined; +function isSortableType(arg: unknown): arg is ISortableType { + return (arg as Partial).dependsOn !== undefined; } interface PythonTypeOpts { @@ -226,12 +233,12 @@ abstract class BasePythonClassType implements PythonType, ISortableType { } public dependsOn(resolver: TypeResolver): PythonType[] { - const dependencies: PythonType[] = []; + const dependencies = new Array(); const parent = resolver.getParent(this.fqn!); // We need to return any bases that are in the same module at the same level of // nesting. - const seen: Set = new Set(); + const seen = new Set(); for (const base of this.bases) { if (spec.isNamedTypeReference(base)) { if (resolver.isInModule(base)) { @@ -258,6 +265,19 @@ abstract class BasePythonClassType implements PythonType, ISortableType { return dependencies; } + public dependsOnModules(resolver: TypeResolver): Set { + const result = new Set(); + const thisModule = resolver.getDefiningPythonModule(this.fqn!); + for (const base of this.bases) { + if (!spec.isNamedTypeReference(base)) { continue; } + const definingModule = resolver.getDefiningPythonModule(base); + if (thisModule !== definingModule) { + result.add(definingModule); + } + } + return result; + } + public addMember(member: PythonBase) { this.members.push(member); } @@ -272,7 +292,7 @@ abstract class BasePythonClassType implements PythonType, ISortableType { this.emitPreamble(code, resolver); if (this.members.length > 0) { - resolver = this.fqn ? resolver.bind(this.fqn) : resolver; + resolver = this.boundResolver(resolver); for (const member of sortMembers(this.members, resolver)) { member.emit(code, resolver); } @@ -283,6 +303,13 @@ abstract class BasePythonClassType implements PythonType, ISortableType { code.closeBlock(); } + protected boundResolver(resolver: TypeResolver): TypeResolver { + if (this.fqn == null) { + return resolver; + } + return resolver.bind(this.fqn); + } + protected abstract getClassParams(resolver: TypeResolver): string[]; protected emitPreamble(_code: CodeMaker, _resolver: TypeResolver) { return; } @@ -291,7 +318,7 @@ abstract class BasePythonClassType implements PythonType, ISortableType { interface BaseMethodOpts { abstract?: boolean; liftedProp?: spec.InterfaceType; - parent?: spec.NamedTypeReference; + parent: spec.NamedTypeReference; } interface BaseMethodEmitOpts { @@ -310,20 +337,40 @@ abstract class BaseMethod implements PythonBase { protected readonly shouldEmitBody: boolean = true; private readonly liftedProp?: spec.InterfaceType; - private readonly parent?: spec.NamedTypeReference; + private readonly parent: spec.NamedTypeReference; public constructor(protected readonly generator: PythonGenerator, public readonly pythonName: string, private readonly jsName: string | undefined, private readonly parameters: spec.Parameter[], - private readonly returns?: spec.OptionalValue, - private readonly docs?: spec.Docs, - opts: BaseMethodOpts = {}) { + private readonly returns: spec.OptionalValue | undefined, + private readonly docs: spec.Docs | undefined, + opts: BaseMethodOpts) { this.abstract = !!opts.abstract; this.liftedProp = opts.liftedProp; this.parent = opts.parent; } + public dependsOnModules(resolver: TypeResolver) { + const result = new Set(); + const thisModule = resolver.getDefiningPythonModule(this.parent); + if (this.returns && spec.isNamedTypeReference(this.returns.type)) { + const definingModule = resolver.getDefiningPythonModule(this.returns.type); + if (thisModule !== definingModule) { + result.add(definingModule); + } + } + for (const param of this.parameters) { + if (spec.isNamedTypeReference(param.type)) { + const definingModule = resolver.getDefiningPythonModule(param.type); + if (thisModule !== definingModule) { + result.add(definingModule); + } + } + } + return result; + } + public emit(code: CodeMaker, resolver: TypeResolver, opts?: BaseMethodEmitOpts) { const { renderAbstract = true, forceEmitBody = false } = opts ?? {}; @@ -339,7 +386,7 @@ abstract class BaseMethod implements PythonBase { // This can hopefully be removed once we get https://github.com/aws/jsii/issues/288 // resolved, so build up a list of all of the prop names so we can check against // them later. - const liftedPropNames: Set = new Set(); + const liftedPropNames = new Set(); if (this.liftedProp?.properties?.length ?? 0 >= 1) { for (const prop of this.liftedProp!.properties!) { liftedPropNames.add(toPythonParameterName(prop.name)); @@ -452,7 +499,7 @@ abstract class BaseMethod implements PythonBase { // We need to build up a list of properties, which are mandatory, these are the // ones we will specifiy to start with in our dictionary literal. - const liftedProps = this.getLiftedProperties(resolver).map(p => new StructField(this.generator, p)); + const liftedProps = this.getLiftedProperties(resolver).map(p => new StructField(this.generator, p, this.parent)); const assignments = liftedProps .map(p => p.pythonName) .map(v => `${v}=${v}`); @@ -514,6 +561,7 @@ abstract class BaseMethod implements PythonBase { interface BasePropertyOpts { abstract?: boolean; immutable?: boolean; + parent: spec.NamedTypeReference; } interface BasePropertyEmitOpts { @@ -531,6 +579,7 @@ abstract class BaseProperty implements PythonBase { protected readonly shouldEmitBody: boolean = true; private readonly immutable: boolean; + private readonly parent: spec.NamedTypeReference; public constructor( private readonly generator: PythonGenerator, @@ -538,7 +587,7 @@ abstract class BaseProperty implements PythonBase { private readonly jsName: string, private readonly type: spec.OptionalValue, private readonly docs: spec.Docs | undefined, - opts: BasePropertyOpts = {}) { + opts: BasePropertyOpts) { const { abstract = false, immutable = false, @@ -546,6 +595,19 @@ abstract class BaseProperty implements PythonBase { this.abstract = abstract; this.immutable = immutable; + this.parent = opts.parent; + } + + public dependsOnModules(resolver: TypeResolver) { + const result = new Set(); + const thisModule = resolver.getDefiningPythonModule(this.parent); + if (spec.isNamedTypeReference(this.type.type)) { + const definingModule = resolver.getDefiningPythonModule(this.type.type); + if (definingModule !== thisModule) { + result.add(definingModule); + } + } + return result; } public emit(code: CodeMaker, resolver: TypeResolver, opts?: BasePropertyEmitOpts) { @@ -679,7 +741,7 @@ class Struct extends BasePythonClassType { * Find all fields (inherited as well) */ private get allMembers(): StructField[] { - return this.thisInterface.allProperties.map(x => new StructField(this.generator, x.spec)); + return this.thisInterface.allProperties.map(x => new StructField(this.generator, x.spec, this.thisInterface)); } private get thisInterface() { @@ -764,7 +826,11 @@ class StructField implements PythonBase { public readonly docs?: spec.Docs; public readonly type: spec.OptionalValue; - public constructor(private readonly generator: PythonGenerator, public readonly prop: spec.Property) { + public constructor( + private readonly generator: PythonGenerator, + public readonly prop: spec.Property, + private readonly parent: spec.NamedTypeReference, + ) { this.pythonName = toPythonPropertyName(prop.name); this.jsiiName = prop.name; this.type = prop; @@ -775,6 +841,18 @@ class StructField implements PythonBase { return !!this.type.optional; } + public dependsOnModules(resolver: TypeResolver) { + const result = new Set(); + const thisModule = resolver.getDefiningPythonModule(this.parent); + if (spec.isNamedTypeReference(this.type.type)) { + const definingModule = resolver.getDefiningPythonModule(this.type.type); + if (thisModule !== definingModule) { + result.add(definingModule); + } + } + return result; + } + public isStruct(generator: PythonGenerator): boolean { return isStruct(generator.reflectAssembly.system, this.type.type); } @@ -811,7 +889,7 @@ interface ClassOpts extends PythonTypeOpts { abstractBases?: spec.ClassType[]; } -class Class extends BasePythonClassType { +class Class extends BasePythonClassType implements ISortableType { private readonly abstract: boolean; private readonly abstractBases: spec.ClassType[]; @@ -833,7 +911,7 @@ class Class extends BasePythonClassType { // We need to return any ifaces that are in the same module at the same level of // nesting. - const seen: Set = new Set(); + const seen = new Set(); for (const iface of this.interfaces) { if (resolver.isInModule(iface)) { // Given a iface, we need to locate the ifaces's parent that is the same @@ -858,6 +936,18 @@ class Class extends BasePythonClassType { return dependencies; } + public dependsOnModules(resolver: TypeResolver): Set { + const result = super.dependsOnModules(resolver); + + for (const member of this.members) { + for (const dep of member.dependsOnModules(resolver)) { + result.add(dep); + } + } + + return result; + } + public emit(code: CodeMaker, resolver: TypeResolver) { // First we emit our implments decorator if (this.interfaces.length > 0) { @@ -874,7 +964,7 @@ class Class extends BasePythonClassType { if (this.abstract) { resolver = this.fqn ? resolver.bind(this.fqn) : resolver; - const proxyBases: string[] = [this.pythonName]; + const proxyBases = [this.pythonName]; for (const base of this.abstractBases) { proxyBases.push(`jsii.proxy_for(${resolver.resolve({ type: base })})`); } @@ -982,18 +1072,16 @@ class EnumMember implements PythonBase { this.value = value; } + public dependsOnModules() { + return new Set(); + } + public emit(code: CodeMaker, _resolver: TypeResolver) { code.line(`${this.pythonName} = "${this.value}"`); this.generator.emitDocString(code, this.docs, { documentableItem: `enum-${this.pythonName}` }); } } -class Namespace extends BasePythonClassType { - protected getClassParams(_resolver: TypeResolver): string[] { - return []; - } -} - interface ModuleOpts { assembly: spec.Assembly; assemblyFilename: string; @@ -1001,32 +1089,39 @@ interface ModuleOpts { package?: Package; } -class Module implements PythonType { - - public readonly pythonName: string; - public readonly fqn: string | null; - +class PythonModule implements PythonType { private readonly assembly: spec.Assembly; private readonly assemblyFilename: string; private readonly loadAssembly: boolean; - private readonly members: PythonBase[]; + private readonly members = new Array(); private readonly package?: Package; - public constructor(name: string, fqn: string | null, opts: ModuleOpts) { - this.pythonName = name; - this.fqn = fqn; - + public constructor( + public readonly pythonName: string, + public readonly fqn: string | null, + opts: ModuleOpts + ) { this.assembly = opts.assembly; this.assemblyFilename = opts.assemblyFilename; this.loadAssembly = opts.loadAssembly; this.package = opts.package; - this.members = []; } public addMember(member: PythonBase) { this.members.push(member); } + public dependsOnModules(resolver: TypeResolver) { + resolver = this.fqn ? resolver.bind(this.fqn, this.pythonName) : resolver; + const result = new Set(); + for (const mem of this.members) { + for (const dep of mem.dependsOnModules(resolver)) { + result.add(dep); + } + } + return result; + } + public emit(code: CodeMaker, resolver: TypeResolver) { this.emitModuleDocumentation(code); @@ -1050,14 +1145,17 @@ class Module implements PythonType { // Determine if we need to write out the kernel load line. if (this.loadAssembly) { code.line(); - code.line( - '__jsii_assembly__ = jsii.JSIIAssembly.load(' + - `"${this.assembly.name}", ` + - `"${this.assembly.version}", ` + - '__name__, ' + - `"${this.assemblyFilename}")` - ); - code.line(); + const params = [ + `"${this.assembly.name}"`, + `"${this.assembly.version}"`, + `"${this.assembly.targets!.python!.module}"`, + `"${this.assemblyFilename}"`, + ]; + code.line(`__jsii_assembly__ = jsii.JSIIAssembly.load(${params.join(', ')})`); + } + + code.line(); + if (this.members.length > 0) { code.line(); } @@ -1083,30 +1181,28 @@ class Module implements PythonType { * Emit the README as module docstring if this is the entry point module (it loads the assembly) */ private emitModuleDocumentation(code: CodeMaker) { - if (this.package && this.loadAssembly && this.package.convertedReadme.trim().length > 0) { + if (this.package && this.fqn === this.assembly.name && this.package.convertedReadme.trim().length > 0) { code.line('"""'); code.line(this.package.convertedReadme); code.line('"""'); } } - private emitDependencyImports(code: CodeMaker, _resolver: TypeResolver) { - const deps = Array.from( - new Set([ - ...Object.keys(this.assembly.dependencies ?? {}).map(d => { - return this.assembly.dependencyClosure![d]!.targets!.python!.module; - }), - ]) - ); + private emitDependencyImports(code: CodeMaker, resolver: TypeResolver) { + const deps = this.dependsOnModules(resolver); - for (const [idx, moduleName] of deps.sort().entries()) { - // If this our first dependency, add a blank line to format our imports - // slightly nicer. - if (idx === 0) { - code.line(); - } + // We need to make sure direct dependencies are always loaded... + for (const dep of Object.keys(this.assembly.dependencies ?? {})) { + const depConfig = this.assembly.dependencyClosure![dep]; + deps.add(depConfig.targets!.python!.module); + } - code.line(`import ${moduleName}`); + // Now actually write the import statements... + if (deps.size > 0) { + code.line(); + for (const moduleName of Array.from(deps).sort()) { + code.line(`import ${moduleName}`); + } } } } @@ -1123,23 +1219,20 @@ class Package { public readonly version: string; public readonly metadata: spec.Assembly; - private readonly modules: Map; - private readonly data: Map; + private readonly modules = new Map(); + private readonly data = new Map(); public constructor(private readonly generator: PythonGenerator, name: string, version: string, metadata: spec.Assembly) { this.name = name; this.version = version; this.metadata = metadata; - - this.modules = new Map(); - this.data = new Map(); } - public addModule(module: Module) { + public addModule(module: PythonModule) { this.modules.set(module.pythonName, module); } - public addData(module: Module, filename: string, data: string | null) { + public addData(module: PythonModule, filename: string, data: string | null) { if (!this.data.has(module.pythonName)) { this.data.set(module.pythonName, []); } @@ -1289,10 +1382,10 @@ interface TypeResolverOpts { } class TypeResolver { + private static readonly STD_TYPES_REGEX = /^(datetime\.datetime|typing\.[A-Z][a-z]+|jsii\.Number)$/; private readonly types: Map; private readonly boundTo?: string; - private readonly stdTypesRe = new RegExp('^(datetime\\.datetime|typing\\.[A-Z][a-z]+|jsii\\.Number)$'); private readonly boundRe!: RegExp; private readonly moduleName?: string; private readonly moduleRe!: RegExp; @@ -1325,7 +1418,9 @@ class TypeResolver { this.findModule, this.findType, fqn, - moduleName !== undefined ? moduleName : this.moduleName, + moduleName !== undefined + ? moduleName.startsWith('.') ? `${this.moduleName}${moduleName}` : moduleName + : this.moduleName, ); } @@ -1341,7 +1436,11 @@ class TypeResolver { public getParent(typeRef: spec.NamedTypeReference | string): PythonType { const fqn = typeof typeRef !== 'string' ? typeRef.fqn : typeRef; - const [, parentFQN] = /^(.+)\.[^.]+$/.exec(fqn) as string[]; + const matches = /^(.+)\.[^.]+$/.exec(fqn); + if (matches == null || !Array.isArray(matches)) { + throw new Error(`Invalid FQN: ${fqn}`); + } + const [, parentFQN] = matches; const parent = this.types.get(parentFQN); if (parent === undefined) { @@ -1351,6 +1450,26 @@ class TypeResolver { return parent; } + public getDefiningPythonModule(typeRef: spec.NamedTypeReference | string): string { + const fqn = typeof typeRef !== 'string' ? typeRef.fqn : typeRef; + const parent = this.types.get(fqn); + + if (parent) { + let mod = parent; + while (!(mod instanceof PythonModule)) { + mod = this.getParent(mod.fqn!); + } + return mod.pythonName; + } + + const matches = /^([^.]+)\./.exec(fqn); + if (matches == null || !Array.isArray(matches)) { + throw new Error(`Invalid FQN: ${fqn}`); + } + const [, assm] = matches; + return this.findModule(assm).targets!.python!.module; + } + public getType(typeRef: spec.NamedTypeReference): PythonType { const type = this.types.get(typeRef.fqn); @@ -1393,7 +1512,7 @@ class TypeResolver { // These are not exactly built in types, but they're also not types that // this resolver has to worry about. - if (this.stdTypesRe.test(innerType)) { + if (TypeResolver.STD_TYPES_REGEX.test(innerType)) { continue; } @@ -1514,6 +1633,7 @@ class PythonGenerator extends Generator { this.types = new Map(); } + // eslint-disable-next-line complexity public emitDocString( code: CodeMaker, docs: spec.Docs | undefined, @@ -1659,13 +1779,14 @@ class PythonGenerator extends Generator { ); // This is the '._jsii' module - const assemblyModule = new Module( + const assemblyModule = new PythonModule( this.getAssemblyModuleName(assm), null, - { assembly: assm, + { + assembly: assm, assemblyFilename: this.getAssemblyFileName(), loadAssembly: false, - package: this.package + package: this.package, }, ); @@ -1683,41 +1804,27 @@ class PythonGenerator extends Generator { } protected onBeginNamespace(ns: string) { - // If we're generating the Namespace that matches our assembly, then we'll - // actually be generating a module, otherwise we'll generate a class within - // that module. - if (ns === this.assembly.name) { - // This is the main Python entry point (facade to the JSII module) - - const module = new Module( + const module = new PythonModule( + [ this.assembly.targets!.python!.module, - ns, - { assembly: this.assembly, - assemblyFilename: this.getAssemblyFileName(), - loadAssembly: ns === this.assembly.name, - package: this.package - }, - ); + ...ns.split('.').slice(1) + .map(toPythonIdentifier) + .map(s => toSnakeCase(s)) + ].join('.'), + ns, + { + assembly: this.assembly, + assemblyFilename: this.getAssemblyFileName(), + loadAssembly: true, + package: this.package, + } + ); - this.package.addModule(module); - // Add our py.typed marker to ensure that gradual typing works for this - // package. + this.package.addModule(module); + this.types.set(ns, module); + if (ns === this.assembly.name) { + // This applies recursively to submodules, so no need to duplicate! this.package.addData(module, 'py.typed', ''); - - this.types.set(ns, module); - } else { - // This should be temporary code, which can be removed and turned into an - // error case once https://github.com/aws/jsii/issues/270 and - // https://github.com/aws/jsii/issues/283 are solved. - this.addPythonType( - new Namespace( - this, - toPythonIdentifier(ns.replace(/^.+\.([^.]+)$/, '$1')), - ns, - {}, - undefined, - ), - ); } } @@ -1765,7 +1872,7 @@ class PythonGenerator extends Generator { parameters, method.returns, method.docs, - { abstract: method.abstract, liftedProp: this.getliftedProp(method) }, + { abstract: method.abstract, liftedProp: this.getliftedProp(method), parent: cls }, ) ); } @@ -1778,7 +1885,7 @@ class PythonGenerator extends Generator { prop.name, prop, prop.docs, - { abstract: prop.abstract, immutable: prop.immutable }, + { abstract: prop.abstract, immutable: prop.immutable, parent: cls }, ) ); } @@ -1795,7 +1902,7 @@ class PythonGenerator extends Generator { parameters, method.returns, method.docs, - { abstract: method.abstract, liftedProp: this.getliftedProp(method) }, + { abstract: method.abstract, liftedProp: this.getliftedProp(method), parent: cls }, ) ); } else { @@ -1807,7 +1914,7 @@ class PythonGenerator extends Generator { parameters, method.returns, method.docs, - { abstract: method.abstract, liftedProp: this.getliftedProp(method) }, + { abstract: method.abstract, liftedProp: this.getliftedProp(method), parent: cls }, ) ); } @@ -1821,7 +1928,7 @@ class PythonGenerator extends Generator { prop.name, prop, prop.docs, - { abstract: prop.abstract, immutable: prop.immutable }, + { abstract: prop.abstract, immutable: prop.immutable, parent: cls }, ) ); } @@ -1867,7 +1974,7 @@ class PythonGenerator extends Generator { parameters, method.returns, method.docs, - { liftedProp: this.getliftedProp(method) }, + { liftedProp: this.getliftedProp(method), parent: ifc }, ) ); } @@ -1876,7 +1983,7 @@ class PythonGenerator extends Generator { let ifaceProperty: InterfaceProperty | StructField; if (ifc.datatype) { - ifaceProperty = new StructField(this, prop); + ifaceProperty = new StructField(this, prop, ifc); } else { ifaceProperty = new InterfaceProperty( this, @@ -1884,7 +1991,7 @@ class PythonGenerator extends Generator { prop.name, prop, prop.docs, - { immutable: prop.immutable }, + { immutable: prop.immutable, parent: ifc }, ); } diff --git a/packages/jsii-pacmak/test/diff-test.sh b/packages/jsii-pacmak/test/diff-test.sh index 288682cf5a..031c3a548b 100755 --- a/packages/jsii-pacmak/test/diff-test.sh +++ b/packages/jsii-pacmak/test/diff-test.sh @@ -2,7 +2,7 @@ set -e cd $(dirname $0) -workdir="$(mktemp -d)" +workdir="$(mktemp -d -t jsii-diff-test.XXXXXXXXXX)" success=true function mktmpdir() { diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base-of-base/python/src/scope/jsii_calc_base_of_base/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc-base-of-base/python/src/scope/jsii_calc_base_of_base/__init__.py index 590690c4bb..fd9d308181 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base-of-base/python/src/scope/jsii_calc_base_of_base/__init__.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base-of-base/python/src/scope/jsii_calc_base_of_base/__init__.py @@ -8,7 +8,7 @@ import jsii.compat import publication -__jsii_assembly__ = jsii.JSIIAssembly.load("@scope/jsii-calc-base-of-base", "1.1.0", __name__, "jsii-calc-base-of-base@1.1.0.jsii.tgz") +__jsii_assembly__ = jsii.JSIIAssembly.load("@scope/jsii-calc-base-of-base", "1.1.0", "scope.jsii_calc_base_of_base", "jsii-calc-base-of-base@1.1.0.jsii.tgz") @jsii.interface(jsii_type="@scope/jsii-calc-base-of-base.IVeryBaseInterface") diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base-of-base/python/src/scope/jsii_calc_base_of_base/_jsii/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc-base-of-base/python/src/scope/jsii_calc_base_of_base/_jsii/__init__.py index 9e39789e5a..8286c95df3 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base-of-base/python/src/scope/jsii_calc_base_of_base/_jsii/__init__.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base-of-base/python/src/scope/jsii_calc_base_of_base/_jsii/__init__.py @@ -7,6 +7,7 @@ import jsii import jsii.compat import publication + __all__ = [] publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/python/src/scope/jsii_calc_base/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc-base/python/src/scope/jsii_calc_base/__init__.py index ec61a7b2a8..6338fc2be9 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/python/src/scope/jsii_calc_base/__init__.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/python/src/scope/jsii_calc_base/__init__.py @@ -10,7 +10,7 @@ import scope.jsii_calc_base_of_base -__jsii_assembly__ = jsii.JSIIAssembly.load("@scope/jsii-calc-base", "1.1.0", __name__, "jsii-calc-base@1.1.0.jsii.tgz") +__jsii_assembly__ = jsii.JSIIAssembly.load("@scope/jsii-calc-base", "1.1.0", "scope.jsii_calc_base", "jsii-calc-base@1.1.0.jsii.tgz") class Base(metaclass=jsii.JSIIAbstractClass, jsii_type="@scope/jsii-calc-base.Base"): diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/python/src/scope/jsii_calc_base/_jsii/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc-base/python/src/scope/jsii_calc_base/_jsii/__init__.py index 03ffbd0be5..2b6e82f761 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/python/src/scope/jsii_calc_base/_jsii/__init__.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/python/src/scope/jsii_calc_base/_jsii/__init__.py @@ -9,6 +9,7 @@ import publication import scope.jsii_calc_base_of_base + __all__ = [] publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/src/scope/jsii_calc_lib/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/src/scope/jsii_calc_lib/__init__.py index f5df0ebf89..d8214aac9a 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/src/scope/jsii_calc_lib/__init__.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/src/scope/jsii_calc_lib/__init__.py @@ -11,7 +11,7 @@ import scope.jsii_calc_base import scope.jsii_calc_base_of_base -__jsii_assembly__ = jsii.JSIIAssembly.load("@scope/jsii-calc-lib", "1.1.0", __name__, "jsii-calc-lib@1.1.0.jsii.tgz") +__jsii_assembly__ = jsii.JSIIAssembly.load("@scope/jsii-calc-lib", "1.1.0", "scope.jsii_calc_lib", "jsii-calc-lib@1.1.0.jsii.tgz") @jsii.enum(jsii_type="@scope/jsii-calc-lib.EnumFromScopedModule") diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/src/scope/jsii_calc_lib/_jsii/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/src/scope/jsii_calc_lib/_jsii/__init__.py index e3fcd0f7bb..181a0c1151 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/src/scope/jsii_calc_lib/_jsii/__init__.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/src/scope/jsii_calc_lib/_jsii/__init__.py @@ -10,6 +10,7 @@ import scope.jsii_calc_base import scope.jsii_calc_base_of_base + __all__ = [] publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii index 56967ae828..0db4ab2889 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/.jsii @@ -12153,8 +12153,257 @@ ], "name": "CompositionStringStyle", "namespace": "composition.CompositeOperation" + }, + "jsii-calc.submodule.MyClass": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.MyClass", + "initializer": { + "docs": { + "stability": "experimental" + } + }, + "interfaces": [ + "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced" + ], + "kind": "class", + "locationInModule": { + "filename": "lib/submodule/my-class.ts", + "line": 5 + }, + "name": "MyClass", + "namespace": "submodule", + "properties": [ + { + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/my-class.ts", + "line": 6 + }, + "name": "definedAt", + "overrides": "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced", + "type": { + "primitive": "string" + } + }, + { + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/my-class.ts", + "line": 7 + }, + "name": "goodness", + "type": { + "fqn": "jsii-calc.submodule.child.Goodness" + } + }, + { + "docs": { + "stability": "experimental" + }, + "locationInModule": { + "filename": "lib/submodule/my-class.ts", + "line": 8 + }, + "name": "allTypes", + "optional": true, + "type": { + "fqn": "jsii-calc.AllTypes" + } + } + ] + }, + "jsii-calc.submodule.back_references.MyClassReference": { + "assembly": "jsii-calc", + "datatype": true, + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.back_references.MyClassReference", + "kind": "interface", + "locationInModule": { + "filename": "lib/submodule/refers-to-parent/index.ts", + "line": 3 + }, + "name": "MyClassReference", + "namespace": "submodule.back_references", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/refers-to-parent/index.ts", + "line": 4 + }, + "name": "reference", + "type": { + "fqn": "jsii-calc.submodule.MyClass" + } + } + ] + }, + "jsii-calc.submodule.child.Goodness": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.child.Goodness", + "kind": "enum", + "locationInModule": { + "filename": "lib/submodule/child/index.ts", + "line": 5 + }, + "members": [ + { + "docs": { + "stability": "experimental", + "summary": "It's pretty good." + }, + "name": "PRETTY_GOOD" + }, + { + "docs": { + "stability": "experimental", + "summary": "It's really good." + }, + "name": "REALLY_GOOD" + }, + { + "docs": { + "stability": "experimental", + "summary": "It's amazingly good." + }, + "name": "AMAZINGLY_GOOD" + } + ], + "name": "Goodness", + "namespace": "submodule.child" + }, + "jsii-calc.submodule.child.Structure": { + "assembly": "jsii-calc", + "datatype": true, + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.child.Structure", + "kind": "interface", + "locationInModule": { + "filename": "lib/submodule/child/index.ts", + "line": 1 + }, + "name": "Structure", + "namespace": "submodule.child", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/child/index.ts", + "line": 2 + }, + "name": "bool", + "type": { + "primitive": "boolean" + } + } + ] + }, + "jsii-calc.submodule.nested_submodule.Namespaced": { + "abstract": true, + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.nested_submodule.Namespaced", + "interfaces": [ + "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced" + ], + "kind": "class", + "locationInModule": { + "filename": "lib/submodule/nested_submodule.ts", + "line": 10 + }, + "name": "Namespaced", + "namespace": "submodule.nested_submodule", + "properties": [ + { + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/nested_submodule.ts", + "line": 11 + }, + "name": "definedAt", + "overrides": "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced", + "type": { + "primitive": "string" + } + }, + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/nested_submodule.ts", + "line": 12 + }, + "name": "goodness", + "type": { + "fqn": "jsii-calc.submodule.child.Goodness" + } + } + ] + }, + "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced": { + "assembly": "jsii-calc", + "docs": { + "stability": "experimental" + }, + "fqn": "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced", + "kind": "interface", + "locationInModule": { + "filename": "lib/submodule/nested_submodule.ts", + "line": 5 + }, + "name": "INamespaced", + "namespace": "submodule.nested_submodule.deeplyNested", + "properties": [ + { + "abstract": true, + "docs": { + "stability": "experimental" + }, + "immutable": true, + "locationInModule": { + "filename": "lib/submodule/nested_submodule.ts", + "line": 6 + }, + "name": "definedAt", + "type": { + "primitive": "string" + } + } + ] } }, "version": "1.1.0", - "fingerprint": "EIFtfZN4eukuZnpbTeqrxdc/JrKnU8eDm1SVncWk/vU=" + "fingerprint": "vtobmk8xL6Ke30Blb4NyDZ1X7T7J8lcKbbrmZtMtcpU=" } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Calculator.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Calculator.cs index 448c28e32f..806c1e9cd3 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Calculator.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Calculator.cs @@ -28,7 +28,7 @@ namespace Amazon.JSII.Tests.CalculatorNamespace /// Console.WriteLine(calculator.Expression.Value); /// [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Calculator), fullyQualifiedName: "jsii-calc.Calculator", parametersJson: "[{\"docs\":{\"summary\":\"Initialization properties.\"},\"name\":\"props\",\"optional\":true,\"type\":{\"fqn\":\"jsii-calc.CalculatorProps\"}}]")] - public class Calculator : Amazon.JSII.Tests.CalculatorNamespace.composition.CompositeOperation + public class Calculator : Amazon.JSII.Tests.CalculatorNamespace.Composition.CompositeOperation { /// Creates a Calculator object. /// Initialization properties. diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/composition/CompositeOperation.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Composition/CompositeOperation.cs similarity index 95% rename from packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/composition/CompositeOperation.cs rename to packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Composition/CompositeOperation.cs index 3a63d09ea9..d1cb0ef425 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/composition/CompositeOperation.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Composition/CompositeOperation.cs @@ -2,13 +2,13 @@ #pragma warning disable CS0672,CS0809,CS1591 -namespace Amazon.JSII.Tests.CalculatorNamespace.composition +namespace Amazon.JSII.Tests.CalculatorNamespace.Composition { /// Abstract operation composed from an expression of other operations. /// /// Stability: Experimental /// - [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.composition.CompositeOperation), fullyQualifiedName: "jsii-calc.composition.CompositeOperation")] + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Composition.CompositeOperation), fullyQualifiedName: "jsii-calc.composition.CompositeOperation")] public abstract class CompositeOperation : Amazon.JSII.Tests.CalculatorNamespace.LibNamespace.Operation { protected CompositeOperation(): base(new DeputyProps(new object[]{})) @@ -88,9 +88,9 @@ public virtual string[] DecorationPrefixes /// Stability: Experimental /// [JsiiProperty(name: "stringStyle", typeJson: "{\"fqn\":\"jsii-calc.composition.CompositeOperation.CompositionStringStyle\"}")] - public virtual Amazon.JSII.Tests.CalculatorNamespace.composition.CompositeOperation.CompositionStringStyle StringStyle + public virtual Amazon.JSII.Tests.CalculatorNamespace.Composition.CompositeOperation.CompositionStringStyle StringStyle { - get => GetInstanceProperty(); + get => GetInstanceProperty(); set => SetInstanceProperty(value); } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/composition/CompositeOperationProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Composition/CompositeOperationProxy.cs similarity index 85% rename from packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/composition/CompositeOperationProxy.cs rename to packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Composition/CompositeOperationProxy.cs index 4f70dac317..ab8f07c320 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/composition/CompositeOperationProxy.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Composition/CompositeOperationProxy.cs @@ -2,14 +2,14 @@ #pragma warning disable CS0672,CS0809,CS1591 -namespace Amazon.JSII.Tests.CalculatorNamespace.composition +namespace Amazon.JSII.Tests.CalculatorNamespace.Composition { /// Abstract operation composed from an expression of other operations. /// /// Stability: Experimental /// - [JsiiTypeProxy(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.composition.CompositeOperation), fullyQualifiedName: "jsii-calc.composition.CompositeOperation")] - internal sealed class CompositeOperationProxy : Amazon.JSII.Tests.CalculatorNamespace.composition.CompositeOperation + [JsiiTypeProxy(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Composition.CompositeOperation), fullyQualifiedName: "jsii-calc.composition.CompositeOperation")] + internal sealed class CompositeOperationProxy : Amazon.JSII.Tests.CalculatorNamespace.Composition.CompositeOperation { private CompositeOperationProxy(ByRefValue reference): base(reference) { diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Power.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Power.cs index fe37ebe7b0..f366aa6847 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Power.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Power.cs @@ -9,7 +9,7 @@ namespace Amazon.JSII.Tests.CalculatorNamespace /// Stability: Experimental /// [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Power), fullyQualifiedName: "jsii-calc.Power", parametersJson: "[{\"docs\":{\"summary\":\"The base of the power.\"},\"name\":\"base\",\"type\":{\"fqn\":\"@scope/jsii-calc-lib.Value\"}},{\"docs\":{\"summary\":\"The number of times to multiply.\"},\"name\":\"pow\",\"type\":{\"fqn\":\"@scope/jsii-calc-lib.Value\"}}]")] - public class Power : Amazon.JSII.Tests.CalculatorNamespace.composition.CompositeOperation + public class Power : Amazon.JSII.Tests.CalculatorNamespace.Composition.CompositeOperation { /// Creates a Power operation. /// The base of the power. diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/BackReferences/IMyClassReference.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/BackReferences/IMyClassReference.cs new file mode 100644 index 0000000000..d0bba143dc --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/BackReferences/IMyClassReference.cs @@ -0,0 +1,22 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule.BackReferences +{ + /// + /// Stability: Experimental + /// + [JsiiInterface(nativeType: typeof(IMyClassReference), fullyQualifiedName: "jsii-calc.submodule.back_references.MyClassReference")] + public interface IMyClassReference + { + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "reference", typeJson: "{\"fqn\":\"jsii-calc.submodule.MyClass\"}")] + Amazon.JSII.Tests.CalculatorNamespace.Submodule.MyClass Reference + { + get; + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/BackReferences/MyClassReference.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/BackReferences/MyClassReference.cs new file mode 100644 index 0000000000..3abbb5b89f --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/BackReferences/MyClassReference.cs @@ -0,0 +1,25 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule.BackReferences +{ + #pragma warning disable CS8618 + + /// + /// Stability: Experimental + /// + [JsiiByValue(fqn: "jsii-calc.submodule.back_references.MyClassReference")] + public class MyClassReference : Amazon.JSII.Tests.CalculatorNamespace.Submodule.BackReferences.IMyClassReference + { + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "reference", typeJson: "{\"fqn\":\"jsii-calc.submodule.MyClass\"}", isOverride: true)] + public Amazon.JSII.Tests.CalculatorNamespace.Submodule.MyClass Reference + { + get; + set; + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/BackReferences/MyClassReferenceProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/BackReferences/MyClassReferenceProxy.cs new file mode 100644 index 0000000000..e2c5c7874a --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/BackReferences/MyClassReferenceProxy.cs @@ -0,0 +1,26 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule.BackReferences +{ + /// + /// Stability: Experimental + /// + [JsiiTypeProxy(nativeType: typeof(IMyClassReference), fullyQualifiedName: "jsii-calc.submodule.back_references.MyClassReference")] + internal sealed class MyClassReferenceProxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.Submodule.BackReferences.IMyClassReference + { + private MyClassReferenceProxy(ByRefValue reference): base(reference) + { + } + + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "reference", typeJson: "{\"fqn\":\"jsii-calc.submodule.MyClass\"}")] + public Amazon.JSII.Tests.CalculatorNamespace.Submodule.MyClass Reference + { + get => GetInstanceProperty(); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/Goodness.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/Goodness.cs new file mode 100644 index 0000000000..d479b90294 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/Goodness.cs @@ -0,0 +1,33 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule.Child +{ + + /// + /// Stability: Experimental + /// + [JsiiEnum(nativeType: typeof(Goodness), fullyQualifiedName: "jsii-calc.submodule.child.Goodness")] + public enum Goodness + { + /// It's pretty good. + /// + /// Stability: Experimental + /// + [JsiiEnumMember(name: "PRETTY_GOOD")] + PRETTY_GOOD, + /// It's really good. + /// + /// Stability: Experimental + /// + [JsiiEnumMember(name: "REALLY_GOOD")] + REALLY_GOOD, + /// It's amazingly good. + /// + /// Stability: Experimental + /// + [JsiiEnumMember(name: "AMAZINGLY_GOOD")] + AMAZINGLY_GOOD + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/IStructure.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/IStructure.cs new file mode 100644 index 0000000000..0592d56531 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/IStructure.cs @@ -0,0 +1,22 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule.Child +{ + /// + /// Stability: Experimental + /// + [JsiiInterface(nativeType: typeof(IStructure), fullyQualifiedName: "jsii-calc.submodule.child.Structure")] + public interface IStructure + { + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "bool", typeJson: "{\"primitive\":\"boolean\"}")] + bool Bool + { + get; + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/Structure.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/Structure.cs new file mode 100644 index 0000000000..249762ae88 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/Structure.cs @@ -0,0 +1,25 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule.Child +{ + #pragma warning disable CS8618 + + /// + /// Stability: Experimental + /// + [JsiiByValue(fqn: "jsii-calc.submodule.child.Structure")] + public class Structure : Amazon.JSII.Tests.CalculatorNamespace.Submodule.Child.IStructure + { + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "bool", typeJson: "{\"primitive\":\"boolean\"}", isOverride: true)] + public bool Bool + { + get; + set; + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/StructureProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/StructureProxy.cs new file mode 100644 index 0000000000..945641b246 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/Child/StructureProxy.cs @@ -0,0 +1,26 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule.Child +{ + /// + /// Stability: Experimental + /// + [JsiiTypeProxy(nativeType: typeof(IStructure), fullyQualifiedName: "jsii-calc.submodule.child.Structure")] + internal sealed class StructureProxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.Submodule.Child.IStructure + { + private StructureProxy(ByRefValue reference): base(reference) + { + } + + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "bool", typeJson: "{\"primitive\":\"boolean\"}")] + public bool Bool + { + get => GetInstanceProperty(); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/MyClass.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/MyClass.cs new file mode 100644 index 0000000000..4d3fc83144 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/MyClass.cs @@ -0,0 +1,63 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule +{ + /// + /// Stability: Experimental + /// + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Submodule.MyClass), fullyQualifiedName: "jsii-calc.submodule.MyClass")] + public class MyClass : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.Submodule.NestedSubmodule.DeeplyNested.INamespaced + { + /// + /// Stability: Experimental + /// + public MyClass(): 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) + { + } + + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "definedAt", typeJson: "{\"primitive\":\"string\"}")] + public virtual string DefinedAt + { + get => GetInstanceProperty(); + } + + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "goodness", typeJson: "{\"fqn\":\"jsii-calc.submodule.child.Goodness\"}")] + public virtual Amazon.JSII.Tests.CalculatorNamespace.Submodule.Child.Goodness Goodness + { + get => GetInstanceProperty(); + } + + /// + /// Stability: Experimental + /// + [JsiiOptional] + [JsiiProperty(name: "allTypes", typeJson: "{\"fqn\":\"jsii-calc.AllTypes\"}", isOptional: true)] + public virtual Amazon.JSII.Tests.CalculatorNamespace.AllTypes? AllTypes + { + get => GetInstanceProperty(); + set => SetInstanceProperty(value); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/DeeplyNested/INamespaced.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/DeeplyNested/INamespaced.cs new file mode 100644 index 0000000000..b68772f183 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/DeeplyNested/INamespaced.cs @@ -0,0 +1,22 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule.NestedSubmodule.DeeplyNested +{ + /// + /// Stability: Experimental + /// + [JsiiInterface(nativeType: typeof(INamespaced), fullyQualifiedName: "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced")] + public interface INamespaced + { + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "definedAt", typeJson: "{\"primitive\":\"string\"}")] + string DefinedAt + { + get; + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/DeeplyNested/INamespacedProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/DeeplyNested/INamespacedProxy.cs new file mode 100644 index 0000000000..13f38d0463 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/DeeplyNested/INamespacedProxy.cs @@ -0,0 +1,26 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule.NestedSubmodule.DeeplyNested +{ + /// + /// Stability: Experimental + /// + [JsiiTypeProxy(nativeType: typeof(INamespaced), fullyQualifiedName: "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced")] + internal sealed class INamespacedProxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.Submodule.NestedSubmodule.DeeplyNested.INamespaced + { + private INamespacedProxy(ByRefValue reference): base(reference) + { + } + + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "definedAt", typeJson: "{\"primitive\":\"string\"}")] + public string DefinedAt + { + get => GetInstanceProperty(); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/Namespaced.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/Namespaced.cs new file mode 100644 index 0000000000..665a692841 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/Namespaced.cs @@ -0,0 +1,45 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule.NestedSubmodule +{ + /// + /// Stability: Experimental + /// + [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Submodule.NestedSubmodule.Namespaced), fullyQualifiedName: "jsii-calc.submodule.nested_submodule.Namespaced")] + public abstract class Namespaced : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.Submodule.NestedSubmodule.DeeplyNested.INamespaced + { + /// 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 Namespaced(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 Namespaced(DeputyProps props): base(props) + { + } + + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "definedAt", typeJson: "{\"primitive\":\"string\"}")] + public virtual string DefinedAt + { + get => GetInstanceProperty(); + } + + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "goodness", typeJson: "{\"fqn\":\"jsii-calc.submodule.child.Goodness\"}")] + public abstract Amazon.JSII.Tests.CalculatorNamespace.Submodule.Child.Goodness Goodness + { + get; + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/NamespacedProxy.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/NamespacedProxy.cs new file mode 100644 index 0000000000..8ba980f079 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Submodule/NestedSubmodule/NamespacedProxy.cs @@ -0,0 +1,26 @@ +using Amazon.JSII.Runtime.Deputy; + +#pragma warning disable CS0672,CS0809,CS1591 + +namespace Amazon.JSII.Tests.CalculatorNamespace.Submodule.NestedSubmodule +{ + /// + /// Stability: Experimental + /// + [JsiiTypeProxy(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Submodule.NestedSubmodule.Namespaced), fullyQualifiedName: "jsii-calc.submodule.nested_submodule.Namespaced")] + internal sealed class NamespacedProxy : Amazon.JSII.Tests.CalculatorNamespace.Submodule.NestedSubmodule.Namespaced + { + private NamespacedProxy(ByRefValue reference): base(reference) + { + } + + /// + /// Stability: Experimental + /// + [JsiiProperty(name: "goodness", typeJson: "{\"fqn\":\"jsii-calc.submodule.child.Goodness\"}")] + public override Amazon.JSII.Tests.CalculatorNamespace.Submodule.Child.Goodness Goodness + { + get => GetInstanceProperty(); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Sum.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Sum.cs index c58a18874c..a6c703dc0e 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Sum.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/Sum.cs @@ -9,7 +9,7 @@ namespace Amazon.JSII.Tests.CalculatorNamespace /// Stability: Experimental /// [JsiiClass(nativeType: typeof(Amazon.JSII.Tests.CalculatorNamespace.Sum), fullyQualifiedName: "jsii-calc.Sum")] - public class Sum : Amazon.JSII.Tests.CalculatorNamespace.composition.CompositeOperation + public class Sum : Amazon.JSII.Tests.CalculatorNamespace.Composition.CompositeOperation { /// /// Stability: Experimental diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java index 3725d26e83..3c583fc74c 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/$Module.java @@ -56,8 +56,8 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.DeprecatedClass": return software.amazon.jsii.tests.calculator.DeprecatedClass.class; case "jsii-calc.DeprecatedEnum": return software.amazon.jsii.tests.calculator.DeprecatedEnum.class; case "jsii-calc.DeprecatedStruct": return software.amazon.jsii.tests.calculator.DeprecatedStruct.class; - case "jsii-calc.DerivedClassHasNoProperties.Base": return software.amazon.jsii.tests.calculator.DerivedClassHasNoProperties.Base.class; - case "jsii-calc.DerivedClassHasNoProperties.Derived": return software.amazon.jsii.tests.calculator.DerivedClassHasNoProperties.Derived.class; + case "jsii-calc.DerivedClassHasNoProperties.Base": return software.amazon.jsii.tests.calculator.derived_class_has_no_properties.Base.class; + case "jsii-calc.DerivedClassHasNoProperties.Derived": return software.amazon.jsii.tests.calculator.derived_class_has_no_properties.Derived.class; case "jsii-calc.DerivedStruct": return software.amazon.jsii.tests.calculator.DerivedStruct.class; case "jsii-calc.DiamondInheritanceBaseLevelStruct": return software.amazon.jsii.tests.calculator.DiamondInheritanceBaseLevelStruct.class; case "jsii-calc.DiamondInheritanceFirstMidLevelStruct": return software.amazon.jsii.tests.calculator.DiamondInheritanceFirstMidLevelStruct.class; @@ -123,9 +123,9 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.ImplictBaseOfBase": return software.amazon.jsii.tests.calculator.ImplictBaseOfBase.class; case "jsii-calc.InbetweenClass": return software.amazon.jsii.tests.calculator.InbetweenClass.class; case "jsii-calc.InterfaceCollections": return software.amazon.jsii.tests.calculator.InterfaceCollections.class; - case "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo": return software.amazon.jsii.tests.calculator.InterfaceInNamespaceIncludesClasses.Foo.class; - case "jsii-calc.InterfaceInNamespaceIncludesClasses.Hello": return software.amazon.jsii.tests.calculator.InterfaceInNamespaceIncludesClasses.Hello.class; - case "jsii-calc.InterfaceInNamespaceOnlyInterface.Hello": return software.amazon.jsii.tests.calculator.InterfaceInNamespaceOnlyInterface.Hello.class; + case "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo": return software.amazon.jsii.tests.calculator.interface_in_namespace_includes_classes.Foo.class; + case "jsii-calc.InterfaceInNamespaceIncludesClasses.Hello": return software.amazon.jsii.tests.calculator.interface_in_namespace_includes_classes.Hello.class; + case "jsii-calc.InterfaceInNamespaceOnlyInterface.Hello": return software.amazon.jsii.tests.calculator.interface_in_namespace_only_interface.Hello.class; case "jsii-calc.InterfacesMaker": return software.amazon.jsii.tests.calculator.InterfacesMaker.class; case "jsii-calc.JSII417Derived": return software.amazon.jsii.tests.calculator.JSII417Derived.class; case "jsii-calc.JSII417PublicBaseOfBase": return software.amazon.jsii.tests.calculator.JSII417PublicBaseOfBase.class; @@ -207,6 +207,12 @@ protected Class resolveClass(final String fqn) throws ClassNotFoundException case "jsii-calc.WithPrivatePropertyInConstructor": return software.amazon.jsii.tests.calculator.WithPrivatePropertyInConstructor.class; case "jsii-calc.composition.CompositeOperation": return software.amazon.jsii.tests.calculator.composition.CompositeOperation.class; case "jsii-calc.composition.CompositeOperation.CompositionStringStyle": return software.amazon.jsii.tests.calculator.composition.CompositeOperation.CompositionStringStyle.class; + case "jsii-calc.submodule.MyClass": return software.amazon.jsii.tests.calculator.submodule.MyClass.class; + case "jsii-calc.submodule.back_references.MyClassReference": return software.amazon.jsii.tests.calculator.submodule.back_references.MyClassReference.class; + case "jsii-calc.submodule.child.Goodness": return software.amazon.jsii.tests.calculator.submodule.child.Goodness.class; + case "jsii-calc.submodule.child.Structure": return software.amazon.jsii.tests.calculator.submodule.child.Structure.class; + case "jsii-calc.submodule.nested_submodule.Namespaced": return software.amazon.jsii.tests.calculator.submodule.nested_submodule.Namespaced.class; + case "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced": return software.amazon.jsii.tests.calculator.submodule.nested_submodule.deeply_nested.INamespaced.class; default: throw new ClassNotFoundException("Unknown JSII type: " + fqn); } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DerivedClassHasNoProperties/Base.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/derived_class_has_no_properties/Base.java similarity index 94% rename from packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DerivedClassHasNoProperties/Base.java rename to packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/derived_class_has_no_properties/Base.java index 089588633c..351ad6515a 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DerivedClassHasNoProperties/Base.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/derived_class_has_no_properties/Base.java @@ -1,4 +1,4 @@ -package software.amazon.jsii.tests.calculator.DerivedClassHasNoProperties; +package software.amazon.jsii.tests.calculator.derived_class_has_no_properties; /** * EXPERIMENTAL diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DerivedClassHasNoProperties/Derived.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/derived_class_has_no_properties/Derived.java similarity index 86% rename from packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DerivedClassHasNoProperties/Derived.java rename to packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/derived_class_has_no_properties/Derived.java index a21a1dba31..2544874c3a 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/DerivedClassHasNoProperties/Derived.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/derived_class_has_no_properties/Derived.java @@ -1,4 +1,4 @@ -package software.amazon.jsii.tests.calculator.DerivedClassHasNoProperties; +package software.amazon.jsii.tests.calculator.derived_class_has_no_properties; /** * EXPERIMENTAL @@ -6,7 +6,7 @@ @javax.annotation.Generated(value = "jsii-pacmak") @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.DerivedClassHasNoProperties.Derived") -public class Derived extends software.amazon.jsii.tests.calculator.DerivedClassHasNoProperties.Base { +public class Derived extends software.amazon.jsii.tests.calculator.derived_class_has_no_properties.Base { protected Derived(final software.amazon.jsii.JsiiObjectRef objRef) { super(objRef); diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceInNamespaceIncludesClasses/Foo.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/interface_in_namespace_includes_classes/Foo.java similarity index 93% rename from packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceInNamespaceIncludesClasses/Foo.java rename to packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/interface_in_namespace_includes_classes/Foo.java index c5d4bd64c0..1c4a652e4f 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceInNamespaceIncludesClasses/Foo.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/interface_in_namespace_includes_classes/Foo.java @@ -1,4 +1,4 @@ -package software.amazon.jsii.tests.calculator.InterfaceInNamespaceIncludesClasses; +package software.amazon.jsii.tests.calculator.interface_in_namespace_includes_classes; /** * EXPERIMENTAL diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceInNamespaceIncludesClasses/Hello.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/interface_in_namespace_includes_classes/Hello.java similarity index 98% rename from packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceInNamespaceIncludesClasses/Hello.java rename to packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/interface_in_namespace_includes_classes/Hello.java index c043e21246..2ac3a8a133 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceInNamespaceIncludesClasses/Hello.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/interface_in_namespace_includes_classes/Hello.java @@ -1,4 +1,4 @@ -package software.amazon.jsii.tests.calculator.InterfaceInNamespaceIncludesClasses; +package software.amazon.jsii.tests.calculator.interface_in_namespace_includes_classes; /** * EXPERIMENTAL diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceInNamespaceOnlyInterface/Hello.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/interface_in_namespace_only_interface/Hello.java similarity index 98% rename from packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceInNamespaceOnlyInterface/Hello.java rename to packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/interface_in_namespace_only_interface/Hello.java index 2651725351..f2558d4221 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/InterfaceInNamespaceOnlyInterface/Hello.java +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/interface_in_namespace_only_interface/Hello.java @@ -1,4 +1,4 @@ -package software.amazon.jsii.tests.calculator.InterfaceInNamespaceOnlyInterface; +package software.amazon.jsii.tests.calculator.interface_in_namespace_only_interface; /** * EXPERIMENTAL diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/MyClass.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/MyClass.java new file mode 100644 index 0000000000..3c7642e65c --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/MyClass.java @@ -0,0 +1,60 @@ +package software.amazon.jsii.tests.calculator.submodule; + +/** + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.submodule.MyClass") +public class MyClass extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.submodule.nested_submodule.deeply_nested.INamespaced { + + protected MyClass(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected MyClass(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public MyClass() { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this); + } + + /** + * EXPERIMENTAL + */ + @Override + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public @org.jetbrains.annotations.NotNull java.lang.String getDefinedAt() { + return this.jsiiGet("definedAt", java.lang.String.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public @org.jetbrains.annotations.NotNull software.amazon.jsii.tests.calculator.submodule.child.Goodness getGoodness() { + return this.jsiiGet("goodness", software.amazon.jsii.tests.calculator.submodule.child.Goodness.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public @org.jetbrains.annotations.Nullable software.amazon.jsii.tests.calculator.AllTypes getAllTypes() { + return this.jsiiGet("allTypes", software.amazon.jsii.tests.calculator.AllTypes.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public void setAllTypes(final @org.jetbrains.annotations.Nullable software.amazon.jsii.tests.calculator.AllTypes value) { + this.jsiiSet("allTypes", value); + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/back_references/MyClassReference.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/back_references/MyClassReference.java new file mode 100644 index 0000000000..da53a9f033 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/back_references/MyClassReference.java @@ -0,0 +1,116 @@ +package software.amazon.jsii.tests.calculator.submodule.back_references; + +/** + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.submodule.back_references.MyClassReference") +@software.amazon.jsii.Jsii.Proxy(MyClassReference.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +public interface MyClassReference extends software.amazon.jsii.JsiiSerializable { + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + @org.jetbrains.annotations.NotNull software.amazon.jsii.tests.calculator.submodule.MyClass getReference(); + + /** + * @return a {@link Builder} of {@link MyClassReference} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + static Builder builder() { + return new Builder(); + } + /** + * A builder for {@link MyClassReference} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static final class Builder { + private software.amazon.jsii.tests.calculator.submodule.MyClass reference; + + /** + * Sets the value of {@link MyClassReference#getReference} + * @param reference the value to be set. This parameter is required. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public Builder reference(software.amazon.jsii.tests.calculator.submodule.MyClass reference) { + this.reference = reference; + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link MyClassReference} + * @throws NullPointerException if any required attribute was not provided + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public MyClassReference build() { + return new Jsii$Proxy(reference); + } + } + + /** + * An implementation for {@link MyClassReference} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements MyClassReference { + private final software.amazon.jsii.tests.calculator.submodule.MyClass reference; + + /** + * 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.reference = this.jsiiGet("reference", software.amazon.jsii.tests.calculator.submodule.MyClass.class); + } + + /** + * Constructor that initializes the object based on literal property values passed by the {@link Builder}. + */ + private Jsii$Proxy(final software.amazon.jsii.tests.calculator.submodule.MyClass reference) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + this.reference = java.util.Objects.requireNonNull(reference, "reference is required"); + } + + @Override + public software.amazon.jsii.tests.calculator.submodule.MyClass getReference() { + return this.reference; + } + + @Override + 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("reference", om.valueToTree(this.getReference())); + + final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + struct.set("fqn", om.valueToTree("jsii-calc.submodule.back_references.MyClassReference")); + 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 boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + MyClassReference.Jsii$Proxy that = (MyClassReference.Jsii$Proxy) o; + + return this.reference.equals(that.reference); + } + + @Override + public int hashCode() { + int result = this.reference.hashCode(); + return result; + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/child/Goodness.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/child/Goodness.java new file mode 100644 index 0000000000..7adb4c2f2c --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/child/Goodness.java @@ -0,0 +1,31 @@ +package software.amazon.jsii.tests.calculator.submodule.child; + +/** + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.submodule.child.Goodness") +public enum Goodness { + /** + * It's pretty good. + *

+ * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + PRETTY_GOOD, + /** + * It's really good. + *

+ * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + REALLY_GOOD, + /** + * It's amazingly good. + *

+ * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + AMAZINGLY_GOOD, +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/child/Structure.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/child/Structure.java new file mode 100644 index 0000000000..9ddcc8d1dd --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/child/Structure.java @@ -0,0 +1,116 @@ +package software.amazon.jsii.tests.calculator.submodule.child; + +/** + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.submodule.child.Structure") +@software.amazon.jsii.Jsii.Proxy(Structure.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +public interface Structure extends software.amazon.jsii.JsiiSerializable { + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + @org.jetbrains.annotations.NotNull java.lang.Boolean getBool(); + + /** + * @return a {@link Builder} of {@link Structure} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + static Builder builder() { + return new Builder(); + } + /** + * A builder for {@link Structure} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public static final class Builder { + private java.lang.Boolean bool; + + /** + * Sets the value of {@link Structure#getBool} + * @param bool the value to be set. This parameter is required. + * @return {@code this} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public Builder bool(java.lang.Boolean bool) { + this.bool = bool; + return this; + } + + /** + * Builds the configured instance. + * @return a new instance of {@link Structure} + * @throws NullPointerException if any required attribute was not provided + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public Structure build() { + return new Jsii$Proxy(bool); + } + } + + /** + * An implementation for {@link Structure} + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements Structure { + private final java.lang.Boolean bool; + + /** + * 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.bool = this.jsiiGet("bool", java.lang.Boolean.class); + } + + /** + * Constructor that initializes the object based on literal property values passed by the {@link Builder}. + */ + private Jsii$Proxy(final java.lang.Boolean bool) { + super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); + this.bool = java.util.Objects.requireNonNull(bool, "bool is required"); + } + + @Override + public java.lang.Boolean getBool() { + return this.bool; + } + + @Override + 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("bool", om.valueToTree(this.getBool())); + + final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); + struct.set("fqn", om.valueToTree("jsii-calc.submodule.child.Structure")); + 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 boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Structure.Jsii$Proxy that = (Structure.Jsii$Proxy) o; + + return this.bool.equals(that.bool); + } + + @Override + public int hashCode() { + int result = this.bool.hashCode(); + return result; + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/nested_submodule/Namespaced.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/nested_submodule/Namespaced.java new file mode 100644 index 0000000000..55c46c15f1 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/nested_submodule/Namespaced.java @@ -0,0 +1,60 @@ +package software.amazon.jsii.tests.calculator.submodule.nested_submodule; + +/** + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.submodule.nested_submodule.Namespaced") +public abstract class Namespaced extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.submodule.nested_submodule.deeply_nested.INamespaced { + + protected Namespaced(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + protected Namespaced(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) { + super(initializationMode); + } + + /** + * EXPERIMENTAL + */ + @Override + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public @org.jetbrains.annotations.NotNull java.lang.String getDefinedAt() { + return this.jsiiGet("definedAt", java.lang.String.class); + } + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public abstract @org.jetbrains.annotations.NotNull software.amazon.jsii.tests.calculator.submodule.child.Goodness getGoodness(); + + /** + * A proxy class which represents a concrete javascript instance of this type. + */ + final static class Jsii$Proxy extends software.amazon.jsii.tests.calculator.submodule.nested_submodule.Namespaced { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + /** + * EXPERIMENTAL + */ + @Override + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public @org.jetbrains.annotations.NotNull software.amazon.jsii.tests.calculator.submodule.child.Goodness getGoodness() { + return this.jsiiGet("goodness", software.amazon.jsii.tests.calculator.submodule.child.Goodness.class); + } + + /** + * EXPERIMENTAL + */ + @Override + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public @org.jetbrains.annotations.NotNull java.lang.String getDefinedAt() { + return this.jsiiGet("definedAt", java.lang.String.class); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/nested_submodule/deeply_nested/INamespaced.java b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/nested_submodule/deeply_nested/INamespaced.java new file mode 100644 index 0000000000..bbd6b414c9 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/java/src/main/java/software/amazon/jsii/tests/calculator/submodule/nested_submodule/deeply_nested/INamespaced.java @@ -0,0 +1,35 @@ +package software.amazon.jsii.tests.calculator.submodule.nested_submodule.deeply_nested; + +/** + * EXPERIMENTAL + */ +@javax.annotation.Generated(value = "jsii-pacmak") +@software.amazon.jsii.Jsii(module = software.amazon.jsii.tests.calculator.$Module.class, fqn = "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced") +@software.amazon.jsii.Jsii.Proxy(INamespaced.Jsii$Proxy.class) +@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) +public interface INamespaced extends software.amazon.jsii.JsiiSerializable { + + /** + * EXPERIMENTAL + */ + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + @org.jetbrains.annotations.NotNull java.lang.String getDefinedAt(); + + /** + * A proxy class which represents a concrete javascript instance of this type. + */ + final static class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements software.amazon.jsii.tests.calculator.submodule.nested_submodule.deeply_nested.INamespaced { + protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { + super(objRef); + } + + /** + * EXPERIMENTAL + */ + @Override + @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) + public @org.jetbrains.annotations.NotNull java.lang.String getDefinedAt() { + return this.jsiiGet("definedAt", java.lang.String.class); + } + } +} diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/setup.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/setup.py index 552e60c6a5..8ec5e190db 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/python/setup.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/setup.py @@ -18,7 +18,16 @@ }, "packages": [ "jsii_calc", - "jsii_calc._jsii" + "jsii_calc._jsii", + "jsii_calc.composition", + "jsii_calc.derived_class_has_no_properties", + "jsii_calc.interface_in_namespace_includes_classes", + "jsii_calc.interface_in_namespace_only_interface", + "jsii_calc.submodule", + "jsii_calc.submodule.back_references", + "jsii_calc.submodule.child", + "jsii_calc.submodule.nested_submodule", + "jsii_calc.submodule.nested_submodule.deeply_nested" ], "package_data": { "jsii_calc._jsii": [ diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py index 3a29c72b32..fff94152a9 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py @@ -37,11 +37,12 @@ import jsii.compat import publication +import jsii_calc.composition import scope.jsii_calc_base import scope.jsii_calc_base_of_base import scope.jsii_calc_lib -__jsii_assembly__ = jsii.JSIIAssembly.load("jsii-calc", "1.1.0", __name__, "jsii-calc@1.1.0.jsii.tgz") +__jsii_assembly__ = jsii.JSIIAssembly.load("jsii-calc", "1.1.0", "jsii_calc", "jsii-calc@1.1.0.jsii.tgz") class AbstractClassBase(metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.AbstractClassBase"): @@ -740,41 +741,165 @@ def rhs(self) -> scope.jsii_calc_lib.Value: class _BinaryOperationProxy(BinaryOperation, jsii.proxy_for(scope.jsii_calc_lib.Operation)): pass -class Add(BinaryOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Add"): - """The "+" binary operation. +class Calculator(composition.CompositeOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Calculator"): + """A calculator which maintains a current value and allows adding operations. + + Here's how you use it:: + + # Example automatically generated. See https://github.com/aws/jsii/issues/826 + calculator = calc.Calculator() + calculator.add(5) + calculator.mul(3) + print(calculator.expression.value) + + I will repeat this example again, but in an @example tag. stability :stability: experimental + + Example:: + + # Example automatically generated. See https://github.com/aws/jsii/issues/826 + calculator = calc.Calculator() + calculator.add(5) + calculator.mul(3) + print(calculator.expression.value) """ - def __init__(self, lhs: scope.jsii_calc_lib.Value, rhs: scope.jsii_calc_lib.Value) -> None: - """Creates a BinaryOperation. + def __init__(self, *, initial_value: typing.Optional[jsii.Number]=None, maximum_value: typing.Optional[jsii.Number]=None) -> None: + """Creates a Calculator object. - :param lhs: Left-hand side operand. - :param rhs: Right-hand side operand. + :param initial_value: The initial value of the calculator. NOTE: Any number works here, it's fine. Default: 0 + :param maximum_value: The maximum value the calculator can store. Default: none stability :stability: experimental """ - jsii.create(Add, self, [lhs, rhs]) + props = CalculatorProps(initial_value=initial_value, maximum_value=maximum_value) - @jsii.member(jsii_name="toString") - def to_string(self) -> str: - """String representation of the value. + jsii.create(Calculator, self, [props]) + + @jsii.member(jsii_name="add") + def add(self, value: jsii.Number) -> None: + """Adds a number to the current value. + + :param value: - stability :stability: experimental """ - return jsii.invoke(self, "toString", []) + return jsii.invoke(self, "add", [value]) + + @jsii.member(jsii_name="mul") + def mul(self, value: jsii.Number) -> None: + """Multiplies the current value by a number. + + :param value: - + + stability + :stability: experimental + """ + return jsii.invoke(self, "mul", [value]) + + @jsii.member(jsii_name="neg") + def neg(self) -> None: + """Negates the current value. + + stability + :stability: experimental + """ + return jsii.invoke(self, "neg", []) + + @jsii.member(jsii_name="pow") + def pow(self, value: jsii.Number) -> None: + """Raises the current value by a power. + + :param value: - + + stability + :stability: experimental + """ + return jsii.invoke(self, "pow", [value]) + + @jsii.member(jsii_name="readUnionValue") + def read_union_value(self) -> jsii.Number: + """Returns teh value of the union property (if defined). + + stability + :stability: experimental + """ + return jsii.invoke(self, "readUnionValue", []) @builtins.property - @jsii.member(jsii_name="value") - def value(self) -> jsii.Number: - """The value. + @jsii.member(jsii_name="expression") + def expression(self) -> scope.jsii_calc_lib.Value: + """Returns the expression. stability :stability: experimental """ - return jsii.get(self, "value") + return jsii.get(self, "expression") + + @builtins.property + @jsii.member(jsii_name="operationsLog") + def operations_log(self) -> typing.List[scope.jsii_calc_lib.Value]: + """A log of all operations. + + stability + :stability: experimental + """ + return jsii.get(self, "operationsLog") + + @builtins.property + @jsii.member(jsii_name="operationsMap") + def operations_map(self) -> typing.Mapping[str,typing.List[scope.jsii_calc_lib.Value]]: + """A map of per operation name of all operations performed. + + stability + :stability: experimental + """ + return jsii.get(self, "operationsMap") + + @builtins.property + @jsii.member(jsii_name="curr") + def curr(self) -> scope.jsii_calc_lib.Value: + """The current value. + + stability + :stability: experimental + """ + return jsii.get(self, "curr") + + @curr.setter + def curr(self, value: scope.jsii_calc_lib.Value): + jsii.set(self, "curr", value) + + @builtins.property + @jsii.member(jsii_name="maxValue") + def max_value(self) -> typing.Optional[jsii.Number]: + """The maximum value allows in this calculator. + + stability + :stability: experimental + """ + return jsii.get(self, "maxValue") + + @max_value.setter + def max_value(self, value: typing.Optional[jsii.Number]): + jsii.set(self, "maxValue", value) + + @builtins.property + @jsii.member(jsii_name="unionProperty") + def union_property(self) -> typing.Optional[typing.Union[typing.Optional["Add"], typing.Optional["Multiply"], typing.Optional["Power"]]]: + """Example of a property that accepts a union of types. + + stability + :stability: experimental + """ + return jsii.get(self, "unionProperty") + + @union_property.setter + def union_property(self, value: typing.Optional[typing.Union[typing.Optional["Add"], typing.Optional["Multiply"], typing.Optional["Power"]]]): + jsii.set(self, "unionProperty", value) @jsii.data_type(jsii_type="jsii-calc.CalculatorProps", jsii_struct_bases=[], name_mapping={'initial_value': 'initialValue', 'maximum_value': 'maximumValue'}) @@ -1575,39 +1700,6 @@ def __repr__(self) -> str: return 'DeprecatedStruct(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) -class DerivedClassHasNoProperties: - class Base(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DerivedClassHasNoProperties.Base"): - """ - stability - :stability: experimental - """ - def __init__(self) -> None: - jsii.create(DerivedClassHasNoProperties.Base, self, []) - - @builtins.property - @jsii.member(jsii_name="prop") - def prop(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "prop") - - @prop.setter - def prop(self, value: str): - jsii.set(self, "prop", value) - - - class Derived(Base, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DerivedClassHasNoProperties.Derived"): - """ - stability - :stability: experimental - """ - def __init__(self) -> None: - jsii.create(DerivedClassHasNoProperties.Derived, self, []) - - - @jsii.data_type(jsii_type="jsii-calc.DerivedStruct", jsii_struct_bases=[scope.jsii_calc_lib.MyFirstStruct], name_mapping={'anumber': 'anumber', 'astring': 'astring', 'first_optional': 'firstOptional', 'another_required': 'anotherRequired', 'bool': 'bool', 'non_primitive': 'nonPrimitive', 'another_optional': 'anotherOptional', 'optional_any': 'optionalAny', 'optional_array': 'optionalArray'}) class DerivedStruct(scope.jsii_calc_lib.MyFirstStruct): def __init__(self, *, anumber: jsii.Number, astring: str, first_optional: typing.Optional[typing.List[str]]=None, another_required: datetime.datetime, bool: bool, non_primitive: "DoubleTrouble", another_optional: typing.Optional[typing.Mapping[str,scope.jsii_calc_lib.Value]]=None, optional_any: typing.Any=None, optional_array: typing.Optional[typing.List[str]]=None): @@ -2496,32 +2588,6 @@ def provide_as_interface(self) -> "IAnonymouslyImplementMe": return jsii.invoke(self, "provideAsInterface", []) -@jsii.implements(IAnonymousImplementationProvider) -class AnonymousImplementationProvider(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AnonymousImplementationProvider"): - """ - stability - :stability: experimental - """ - def __init__(self) -> None: - jsii.create(AnonymousImplementationProvider, self, []) - - @jsii.member(jsii_name="provideAsClass") - def provide_as_class(self) -> "Implementation": - """ - stability - :stability: experimental - """ - return jsii.invoke(self, "provideAsClass", []) - - @jsii.member(jsii_name="provideAsInterface") - def provide_as_interface(self) -> "IAnonymouslyImplementMe": - """ - stability - :stability: experimental - """ - return jsii.invoke(self, "provideAsInterface", []) - - @jsii.interface(jsii_type="jsii-calc.IAnonymouslyImplementMe") class IAnonymouslyImplementMe(jsii.compat.Protocol): """ @@ -2652,37 +2718,6 @@ def ring(self) -> None: return jsii.invoke(self, "ring", []) -@jsii.implements(IBell) -class Bell(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Bell"): - """ - stability - :stability: experimental - """ - def __init__(self) -> None: - jsii.create(Bell, self, []) - - @jsii.member(jsii_name="ring") - def ring(self) -> None: - """ - stability - :stability: experimental - """ - return jsii.invoke(self, "ring", []) - - @builtins.property - @jsii.member(jsii_name="rung") - def rung(self) -> bool: - """ - stability - :stability: experimental - """ - return jsii.get(self, "rung") - - @rung.setter - def rung(self, value: bool): - jsii.set(self, "rung", value) - - @jsii.interface(jsii_type="jsii-calc.IBellRinger") class IBellRinger(jsii.compat.Protocol): """Takes the object parameter as an interface. @@ -3063,92 +3098,38 @@ def prop_from_interface(self) -> str: return jsii.get(self, "propFromInterface") -@jsii.implements(IInterfaceImplementedByAbstractClass) -class AbstractClass(AbstractClassBase, metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.AbstractClass"): +@jsii.interface(jsii_type="jsii-calc.IInterfaceWithInternal") +class IInterfaceWithInternal(jsii.compat.Protocol): """ stability :stability: experimental """ @builtins.staticmethod def __jsii_proxy_class__(): - return _AbstractClassProxy - - def __init__(self) -> None: - jsii.create(AbstractClass, self, []) + return _IInterfaceWithInternalProxy - @jsii.member(jsii_name="abstractMethod") - @abc.abstractmethod - def abstract_method(self, name: str) -> str: + @jsii.member(jsii_name="visible") + def visible(self) -> None: """ - :param name: - - stability :stability: experimental """ ... - @jsii.member(jsii_name="nonAbstractMethod") - def non_abstract_method(self) -> jsii.Number: + +class _IInterfaceWithInternalProxy(): + """ + stability + :stability: experimental + """ + __jsii_type__ = "jsii-calc.IInterfaceWithInternal" + @jsii.member(jsii_name="visible") + def visible(self) -> None: """ stability :stability: experimental """ - return jsii.invoke(self, "nonAbstractMethod", []) - - @builtins.property - @jsii.member(jsii_name="propFromInterface") - def prop_from_interface(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "propFromInterface") - - -class _AbstractClassProxy(AbstractClass, jsii.proxy_for(AbstractClassBase)): - @jsii.member(jsii_name="abstractMethod") - def abstract_method(self, name: str) -> str: - """ - :param name: - - - stability - :stability: experimental - """ - return jsii.invoke(self, "abstractMethod", [name]) - - -@jsii.interface(jsii_type="jsii-calc.IInterfaceWithInternal") -class IInterfaceWithInternal(jsii.compat.Protocol): - """ - stability - :stability: experimental - """ - @builtins.staticmethod - def __jsii_proxy_class__(): - return _IInterfaceWithInternalProxy - - @jsii.member(jsii_name="visible") - def visible(self) -> None: - """ - stability - :stability: experimental - """ - ... - - -class _IInterfaceWithInternalProxy(): - """ - stability - :stability: experimental - """ - __jsii_type__ = "jsii-calc.IInterfaceWithInternal" - @jsii.member(jsii_name="visible") - def visible(self) -> None: - """ - stability - :stability: experimental - """ - return jsii.invoke(self, "visible", []) + return jsii.invoke(self, "visible", []) @jsii.interface(jsii_type="jsii-calc.IInterfaceWithMethods") @@ -3203,44 +3184,6 @@ def do_things(self) -> None: return jsii.invoke(self, "doThings", []) -@jsii.interface(jsii_type="jsii-calc.IInterfaceThatShouldNotBeADataType") -class IInterfaceThatShouldNotBeADataType(IInterfaceWithMethods, jsii.compat.Protocol): - """Even though this interface has only properties, it is disqualified from being a datatype because it inherits from an interface that is not a datatype. - - stability - :stability: experimental - """ - @builtins.staticmethod - def __jsii_proxy_class__(): - return _IInterfaceThatShouldNotBeADataTypeProxy - - @builtins.property - @jsii.member(jsii_name="otherValue") - def other_value(self) -> str: - """ - stability - :stability: experimental - """ - ... - - -class _IInterfaceThatShouldNotBeADataTypeProxy(jsii.proxy_for(IInterfaceWithMethods)): - """Even though this interface has only properties, it is disqualified from being a datatype because it inherits from an interface that is not a datatype. - - stability - :stability: experimental - """ - __jsii_type__ = "jsii-calc.IInterfaceThatShouldNotBeADataType" - @builtins.property - @jsii.member(jsii_name="otherValue") - def other_value(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "otherValue") - - @jsii.interface(jsii_type="jsii-calc.IInterfaceWithOptionalMethodArguments") class IInterfaceWithOptionalMethodArguments(jsii.compat.Protocol): """awslabs/jsii#175 Interface proxies (and builders) do not respect optional arguments in methods. @@ -3345,48 +3288,6 @@ def read_write_string(self, value: str): jsii.set(self, "readWriteString", value) -@jsii.implements(IInterfaceWithProperties) -class ClassWithPrivateConstructorAndAutomaticProperties(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ClassWithPrivateConstructorAndAutomaticProperties"): - """Class that implements interface properties automatically, but using a private constructor. - - stability - :stability: experimental - """ - @jsii.member(jsii_name="create") - @builtins.classmethod - def create(cls, read_only_string: str, read_write_string: str) -> "ClassWithPrivateConstructorAndAutomaticProperties": - """ - :param read_only_string: - - :param read_write_string: - - - stability - :stability: experimental - """ - return jsii.sinvoke(cls, "create", [read_only_string, read_write_string]) - - @builtins.property - @jsii.member(jsii_name="readOnlyString") - def read_only_string(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "readOnlyString") - - @builtins.property - @jsii.member(jsii_name="readWriteString") - def read_write_string(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "readWriteString") - - @read_write_string.setter - def read_write_string(self, value: str): - jsii.set(self, "readWriteString", value) - - @jsii.interface(jsii_type="jsii-calc.IInterfaceWithPropertiesExtension") class IInterfaceWithPropertiesExtension(IInterfaceWithProperties, jsii.compat.Protocol): """ @@ -3483,74 +3384,6 @@ def foo(self) -> None: return jsii.invoke(self, "foo", []) -@jsii.interface(jsii_type="jsii-calc.IJSII417Derived") -class IJSII417Derived(IJSII417PublicBaseOfBase, jsii.compat.Protocol): - """ - stability - :stability: experimental - """ - @builtins.staticmethod - def __jsii_proxy_class__(): - return _IJSII417DerivedProxy - - @builtins.property - @jsii.member(jsii_name="property") - def property(self) -> str: - """ - stability - :stability: experimental - """ - ... - - @jsii.member(jsii_name="bar") - def bar(self) -> None: - """ - stability - :stability: experimental - """ - ... - - @jsii.member(jsii_name="baz") - def baz(self) -> None: - """ - stability - :stability: experimental - """ - ... - - -class _IJSII417DerivedProxy(jsii.proxy_for(IJSII417PublicBaseOfBase)): - """ - stability - :stability: experimental - """ - __jsii_type__ = "jsii-calc.IJSII417Derived" - @builtins.property - @jsii.member(jsii_name="property") - def property(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "property") - - @jsii.member(jsii_name="bar") - def bar(self) -> None: - """ - stability - :stability: experimental - """ - return jsii.invoke(self, "bar", []) - - @jsii.member(jsii_name="baz") - def baz(self) -> None: - """ - stability - :stability: experimental - """ - return jsii.invoke(self, "baz", []) - - @jsii.interface(jsii_type="jsii-calc.IJsii487External") class IJsii487External(jsii.compat.Protocol): """ @@ -3725,182 +3558,58 @@ def c(self, value: str): jsii.set(self, "c", value) -@jsii.implements(INonInternalInterface) -class ClassThatImplementsTheInternalInterface(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ClassThatImplementsTheInternalInterface"): - """ +@jsii.interface(jsii_type="jsii-calc.IObjectWithProperty") +class IObjectWithProperty(jsii.compat.Protocol): + """Make sure that setters are properly called on objects with interfaces. + stability :stability: experimental """ - def __init__(self) -> None: - jsii.create(ClassThatImplementsTheInternalInterface, self, []) + @builtins.staticmethod + def __jsii_proxy_class__(): + return _IObjectWithPropertyProxy @builtins.property - @jsii.member(jsii_name="a") - def a(self) -> str: + @jsii.member(jsii_name="property") + def property(self) -> str: """ stability :stability: experimental """ - return jsii.get(self, "a") + ... - @a.setter - def a(self, value: str): - jsii.set(self, "a", value) + @property.setter + def property(self, value: str): + ... - @builtins.property - @jsii.member(jsii_name="b") - def b(self) -> str: + @jsii.member(jsii_name="wasSet") + def was_set(self) -> bool: """ stability :stability: experimental """ - return jsii.get(self, "b") + ... - @b.setter - def b(self, value: str): - jsii.set(self, "b", value) +class _IObjectWithPropertyProxy(): + """Make sure that setters are properly called on objects with interfaces. + + stability + :stability: experimental + """ + __jsii_type__ = "jsii-calc.IObjectWithProperty" @builtins.property - @jsii.member(jsii_name="c") - def c(self) -> str: + @jsii.member(jsii_name="property") + def property(self) -> str: """ stability :stability: experimental """ - return jsii.get(self, "c") + return jsii.get(self, "property") - @c.setter - def c(self, value: str): - jsii.set(self, "c", value) - - @builtins.property - @jsii.member(jsii_name="d") - def d(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "d") - - @d.setter - def d(self, value: str): - jsii.set(self, "d", value) - - -@jsii.implements(INonInternalInterface) -class ClassThatImplementsThePrivateInterface(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ClassThatImplementsThePrivateInterface"): - """ - stability - :stability: experimental - """ - def __init__(self) -> None: - jsii.create(ClassThatImplementsThePrivateInterface, self, []) - - @builtins.property - @jsii.member(jsii_name="a") - def a(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "a") - - @a.setter - def a(self, value: str): - jsii.set(self, "a", value) - - @builtins.property - @jsii.member(jsii_name="b") - def b(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "b") - - @b.setter - def b(self, value: str): - jsii.set(self, "b", value) - - @builtins.property - @jsii.member(jsii_name="c") - def c(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "c") - - @c.setter - def c(self, value: str): - jsii.set(self, "c", value) - - @builtins.property - @jsii.member(jsii_name="e") - def e(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "e") - - @e.setter - def e(self, value: str): - jsii.set(self, "e", value) - - -@jsii.interface(jsii_type="jsii-calc.IObjectWithProperty") -class IObjectWithProperty(jsii.compat.Protocol): - """Make sure that setters are properly called on objects with interfaces. - - stability - :stability: experimental - """ - @builtins.staticmethod - def __jsii_proxy_class__(): - return _IObjectWithPropertyProxy - - @builtins.property - @jsii.member(jsii_name="property") - def property(self) -> str: - """ - stability - :stability: experimental - """ - ... - - @property.setter - def property(self, value: str): - ... - - @jsii.member(jsii_name="wasSet") - def was_set(self) -> bool: - """ - stability - :stability: experimental - """ - ... - - -class _IObjectWithPropertyProxy(): - """Make sure that setters are properly called on objects with interfaces. - - stability - :stability: experimental - """ - __jsii_type__ = "jsii-calc.IObjectWithProperty" - @builtins.property - @jsii.member(jsii_name="property") - def property(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "property") - - @property.setter - def property(self, value: str): - jsii.set(self, "property", value) + @property.setter + def property(self, value: str): + jsii.set(self, "property", value) @jsii.member(jsii_name="wasSet") def was_set(self) -> bool: @@ -4095,54 +3804,6 @@ def next(self) -> jsii.Number: return jsii.invoke(self, "next", []) -@jsii.interface(jsii_type="jsii-calc.IFriendlyRandomGenerator") -class IFriendlyRandomGenerator(IRandomNumberGenerator, scope.jsii_calc_lib.IFriendly, jsii.compat.Protocol): - """ - stability - :stability: experimental - """ - @builtins.staticmethod - def __jsii_proxy_class__(): - return _IFriendlyRandomGeneratorProxy - - pass - -class _IFriendlyRandomGeneratorProxy(jsii.proxy_for(IRandomNumberGenerator), jsii.proxy_for(scope.jsii_calc_lib.IFriendly)): - """ - stability - :stability: experimental - """ - __jsii_type__ = "jsii-calc.IFriendlyRandomGenerator" - pass - -@jsii.implements(IFriendlyRandomGenerator) -class DoubleTrouble(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DoubleTrouble"): - """ - stability - :stability: experimental - """ - def __init__(self) -> None: - jsii.create(DoubleTrouble, self, []) - - @jsii.member(jsii_name="hello") - def hello(self) -> str: - """Say hello! - - stability - :stability: experimental - """ - return jsii.invoke(self, "hello", []) - - @jsii.member(jsii_name="next") - def next(self) -> jsii.Number: - """Returns another random number. - - stability - :stability: experimental - """ - return jsii.invoke(self, "next", []) - - @jsii.interface(jsii_type="jsii-calc.IReturnJsii976") class IReturnJsii976(jsii.compat.Protocol): """Returns a subclass of a known class which implements an interface. @@ -4482,94 +4143,6 @@ def map_of_structs(cls) -> typing.Mapping[str,"StructA"]: return jsii.sinvoke(cls, "mapOfStructs", []) -class InterfaceInNamespaceIncludesClasses: - class Foo(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.InterfaceInNamespaceIncludesClasses.Foo"): - """ - stability - :stability: experimental - """ - def __init__(self) -> None: - jsii.create(InterfaceInNamespaceIncludesClasses.Foo, self, []) - - @builtins.property - @jsii.member(jsii_name="bar") - def bar(self) -> typing.Optional[str]: - """ - stability - :stability: experimental - """ - return jsii.get(self, "bar") - - @bar.setter - def bar(self, value: typing.Optional[str]): - jsii.set(self, "bar", value) - - - @jsii.data_type(jsii_type="jsii-calc.InterfaceInNamespaceIncludesClasses.Hello", jsii_struct_bases=[], name_mapping={'foo': 'foo'}) - class Hello(): - def __init__(self, *, foo: jsii.Number): - """ - :param foo: - - stability - :stability: experimental - """ - self._values = { - 'foo': foo, - } - - @builtins.property - def foo(self) -> jsii.Number: - """ - stability - :stability: experimental - """ - return self._values.get('foo') - - def __eq__(self, rhs) -> bool: - return isinstance(rhs, self.__class__) and rhs._values == self._values - - def __ne__(self, rhs) -> bool: - return not (rhs == self) - - def __repr__(self) -> str: - return 'Hello(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) - - - -class InterfaceInNamespaceOnlyInterface: - @jsii.data_type(jsii_type="jsii-calc.InterfaceInNamespaceOnlyInterface.Hello", jsii_struct_bases=[], name_mapping={'foo': 'foo'}) - class Hello(): - def __init__(self, *, foo: jsii.Number): - """ - :param foo: - - stability - :stability: experimental - """ - self._values = { - 'foo': foo, - } - - @builtins.property - def foo(self) -> jsii.Number: - """ - stability - :stability: experimental - """ - return self._values.get('foo') - - def __eq__(self, rhs) -> bool: - return isinstance(rhs, self.__class__) and rhs._values == self._values - - def __ne__(self, rhs) -> bool: - return not (rhs == self) - - def __repr__(self) -> str: - return 'Hello(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) - - - class InterfacesMaker(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.InterfacesMaker"): """We can return arrays of interfaces See aws/aws-cdk#2362. @@ -4623,46 +4196,6 @@ def has_root(self) -> bool: return jsii.get(self, "hasRoot") -class JSII417Derived(JSII417PublicBaseOfBase, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.JSII417Derived"): - """ - stability - :stability: experimental - """ - def __init__(self, property: str) -> None: - """ - :param property: - - - stability - :stability: experimental - """ - jsii.create(JSII417Derived, self, [property]) - - @jsii.member(jsii_name="bar") - def bar(self) -> None: - """ - stability - :stability: experimental - """ - return jsii.invoke(self, "bar", []) - - @jsii.member(jsii_name="baz") - def baz(self) -> None: - """ - stability - :stability: experimental - """ - return jsii.invoke(self, "baz", []) - - @builtins.property - @jsii.member(jsii_name="property") - def _property(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.get(self, "property") - - class JSObjectLiteralForInterface(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.JSObjectLiteralForInterface"): """ stability @@ -6119,55 +5652,14 @@ def __repr__(self) -> str: return 'ParentStruct982(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) -@jsii.data_type(jsii_type="jsii-calc.ChildStruct982", jsii_struct_bases=[ParentStruct982], name_mapping={'foo': 'foo', 'bar': 'bar'}) -class ChildStruct982(ParentStruct982): - def __init__(self, *, foo: str, bar: jsii.Number): - """ - :param foo: - :param bar: - - stability - :stability: experimental - """ - self._values = { - 'foo': foo, - 'bar': bar, - } - - @builtins.property - def foo(self) -> str: - """ - stability - :stability: experimental - """ - return self._values.get('foo') - - @builtins.property - def bar(self) -> jsii.Number: - """ - stability - :stability: experimental - """ - return self._values.get('bar') - - def __eq__(self, rhs) -> bool: - return isinstance(rhs, self.__class__) and rhs._values == self._values - - def __ne__(self, rhs) -> bool: - return not (rhs == self) - - def __repr__(self) -> str: - return 'ChildStruct982(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) - - -class PartiallyInitializedThisConsumer(metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.PartiallyInitializedThisConsumer"): - """ - stability - :stability: experimental - """ - @builtins.staticmethod - def __jsii_proxy_class__(): - return _PartiallyInitializedThisConsumerProxy +class PartiallyInitializedThisConsumer(metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.PartiallyInitializedThisConsumer"): + """ + stability + :stability: experimental + """ + @builtins.staticmethod + def __jsii_proxy_class__(): + return _PartiallyInitializedThisConsumerProxy def __init__(self) -> None: jsii.create(PartiallyInitializedThisConsumer, self, []) @@ -6219,6 +5711,56 @@ def say_hello(self, friendly: scope.jsii_calc_lib.IFriendly) -> str: return jsii.invoke(self, "sayHello", [friendly]) +class Power(composition.CompositeOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Power"): + """The power operation. + + stability + :stability: experimental + """ + def __init__(self, base: scope.jsii_calc_lib.Value, pow: scope.jsii_calc_lib.Value) -> None: + """Creates a Power operation. + + :param base: The base of the power. + :param pow: The number of times to multiply. + + stability + :stability: experimental + """ + jsii.create(Power, self, [base, pow]) + + @builtins.property + @jsii.member(jsii_name="base") + def base(self) -> scope.jsii_calc_lib.Value: + """The base of the power. + + stability + :stability: experimental + """ + return jsii.get(self, "base") + + @builtins.property + @jsii.member(jsii_name="expression") + def expression(self) -> scope.jsii_calc_lib.Value: + """The expression that this operation consists of. + + Must be implemented by derived classes. + + stability + :stability: experimental + """ + return jsii.get(self, "expression") + + @builtins.property + @jsii.member(jsii_name="pow") + def pow(self) -> scope.jsii_calc_lib.Value: + """The number of times to multiply. + + stability + :stability: experimental + """ + return jsii.get(self, "pow") + + class PropertyNamedProperty(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.PropertyNamedProperty"): """Reproduction for https://github.com/aws/jsii/issues/1113 Where a method or property named "property" would result in impossible to load Python code. @@ -6264,24 +5806,6 @@ def hello(self) -> None: return jsii.invoke(self, "hello", []) -@jsii.implements(IPublicInterface2) -class InbetweenClass(PublicClass, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.InbetweenClass"): - """ - stability - :stability: experimental - """ - def __init__(self) -> None: - jsii.create(InbetweenClass, self, []) - - @jsii.member(jsii_name="ciao") - def ciao(self) -> str: - """ - stability - :stability: experimental - """ - return jsii.invoke(self, "ciao", []) - - class PythonReservedWords(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.PythonReservedWords"): """ stability @@ -7439,6 +6963,46 @@ def __repr__(self) -> str: return 'StructWithJavaReservedWords(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) +class Sum(composition.CompositeOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Sum"): + """An operation that sums multiple values. + + stability + :stability: experimental + """ + def __init__(self) -> None: + """ + stability + :stability: experimental + """ + jsii.create(Sum, self, []) + + @builtins.property + @jsii.member(jsii_name="expression") + def expression(self) -> scope.jsii_calc_lib.Value: + """The expression that this operation consists of. + + Must be implemented by derived classes. + + stability + :stability: experimental + """ + return jsii.get(self, "expression") + + @builtins.property + @jsii.member(jsii_name="parts") + def parts(self) -> typing.List[scope.jsii_calc_lib.Value]: + """The parts to sum. + + stability + :stability: experimental + """ + return jsii.get(self, "parts") + + @parts.setter + def parts(self, value: typing.List[scope.jsii_calc_lib.Value]): + jsii.set(self, "parts", value) + + @jsii.data_type(jsii_type="jsii-calc.SupportsNiceJavaBuilderProps", jsii_struct_bases=[], name_mapping={'bar': 'bar', 'id': 'id'}) class SupportsNiceJavaBuilderProps(): def __init__(self, *, bar: jsii.Number, id: typing.Optional[str]=None): @@ -7532,43 +7096,6 @@ def prop_id(self) -> typing.Optional[str]: return jsii.get(self, "propId") -class SupportsNiceJavaBuilder(SupportsNiceJavaBuilderWithRequiredProps, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.SupportsNiceJavaBuilder"): - """ - stability - :stability: experimental - """ - def __init__(self, id: jsii.Number, default_bar: typing.Optional[jsii.Number]=None, props: typing.Optional["SupportsNiceJavaBuilderProps"]=None, *rest: str) -> None: - """ - :param id: some identifier. - :param default_bar: the default value of ``bar``. - :param props: some props once can provide. - :param rest: a variadic continuation. - - stability - :stability: experimental - """ - jsii.create(SupportsNiceJavaBuilder, self, [id, default_bar, props, *rest]) - - @builtins.property - @jsii.member(jsii_name="id") - def id(self) -> jsii.Number: - """some identifier. - - stability - :stability: experimental - """ - return jsii.get(self, "id") - - @builtins.property - @jsii.member(jsii_name="rest") - def rest(self) -> typing.List[str]: - """ - stability - :stability: experimental - """ - return jsii.get(self, "rest") - - class SyncVirtualMethods(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.SyncVirtualMethods"): """ stability @@ -7843,69 +7370,6 @@ def operand(self) -> scope.jsii_calc_lib.Value: class _UnaryOperationProxy(UnaryOperation, jsii.proxy_for(scope.jsii_calc_lib.Operation)): pass -@jsii.implements(IFriendlier) -class Negate(UnaryOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Negate"): - """The negation operation ("-value"). - - stability - :stability: experimental - """ - def __init__(self, operand: scope.jsii_calc_lib.Value) -> None: - """ - :param operand: - - - stability - :stability: experimental - """ - jsii.create(Negate, self, [operand]) - - @jsii.member(jsii_name="farewell") - def farewell(self) -> str: - """Say farewell. - - stability - :stability: experimental - """ - return jsii.invoke(self, "farewell", []) - - @jsii.member(jsii_name="goodbye") - def goodbye(self) -> str: - """Say goodbye. - - stability - :stability: experimental - """ - return jsii.invoke(self, "goodbye", []) - - @jsii.member(jsii_name="hello") - def hello(self) -> str: - """Say hello! - - stability - :stability: experimental - """ - return jsii.invoke(self, "hello", []) - - @jsii.member(jsii_name="toString") - def to_string(self) -> str: - """String representation of the value. - - stability - :stability: experimental - """ - return jsii.invoke(self, "toString", []) - - @builtins.property - @jsii.member(jsii_name="value") - def value(self) -> jsii.Number: - """The value. - - stability - :stability: experimental - """ - return jsii.get(self, "value") - - @jsii.data_type(jsii_type="jsii-calc.UnionProperties", jsii_struct_bases=[], name_mapping={'bar': 'bar', 'foo': 'foo'}) class UnionProperties(): def __init__(self, *, bar: typing.Union[str, jsii.Number, "AllTypes"], foo: typing.Optional[typing.Union[typing.Optional[str], typing.Optional[jsii.Number]]]=None): @@ -8223,381 +7687,673 @@ def success(self) -> bool: return jsii.get(self, "success") -class composition: - class CompositeOperation(scope.jsii_calc_lib.Operation, metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.composition.CompositeOperation"): - """Abstract operation composed from an expression of other operations. - - stability - :stability: experimental - """ - @builtins.staticmethod - def __jsii_proxy_class__(): - return _CompositeOperationProxy - - def __init__(self) -> None: - jsii.create(composition.CompositeOperation, self, []) - - @jsii.member(jsii_name="toString") - def to_string(self) -> str: - """String representation of the value. - - stability - :stability: experimental - """ - return jsii.invoke(self, "toString", []) +@jsii.implements(IInterfaceImplementedByAbstractClass) +class AbstractClass(AbstractClassBase, metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.AbstractClass"): + """ + stability + :stability: experimental + """ + @builtins.staticmethod + def __jsii_proxy_class__(): + return _AbstractClassProxy - @builtins.property - @jsii.member(jsii_name="expression") - @abc.abstractmethod - def expression(self) -> scope.jsii_calc_lib.Value: - """The expression that this operation consists of. + def __init__(self) -> None: + jsii.create(AbstractClass, self, []) - Must be implemented by derived classes. + @jsii.member(jsii_name="abstractMethod") + @abc.abstractmethod + def abstract_method(self, name: str) -> str: + """ + :param name: - - stability - :stability: experimental - """ - ... + stability + :stability: experimental + """ + ... - @builtins.property - @jsii.member(jsii_name="value") - def value(self) -> jsii.Number: - """The value. + @jsii.member(jsii_name="nonAbstractMethod") + def non_abstract_method(self) -> jsii.Number: + """ + stability + :stability: experimental + """ + return jsii.invoke(self, "nonAbstractMethod", []) - stability - :stability: experimental - """ - return jsii.get(self, "value") + @builtins.property + @jsii.member(jsii_name="propFromInterface") + def prop_from_interface(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "propFromInterface") - @builtins.property - @jsii.member(jsii_name="decorationPostfixes") - def decoration_postfixes(self) -> typing.List[str]: - """A set of postfixes to include in a decorated .toString(). - stability - :stability: experimental - """ - return jsii.get(self, "decorationPostfixes") +class _AbstractClassProxy(AbstractClass, jsii.proxy_for(AbstractClassBase)): + @jsii.member(jsii_name="abstractMethod") + def abstract_method(self, name: str) -> str: + """ + :param name: - - @decoration_postfixes.setter - def decoration_postfixes(self, value: typing.List[str]): - jsii.set(self, "decorationPostfixes", value) + stability + :stability: experimental + """ + return jsii.invoke(self, "abstractMethod", [name]) - @builtins.property - @jsii.member(jsii_name="decorationPrefixes") - def decoration_prefixes(self) -> typing.List[str]: - """A set of prefixes to include in a decorated .toString(). - stability - :stability: experimental - """ - return jsii.get(self, "decorationPrefixes") +class Add(BinaryOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Add"): + """The "+" binary operation. - @decoration_prefixes.setter - def decoration_prefixes(self, value: typing.List[str]): - jsii.set(self, "decorationPrefixes", value) + stability + :stability: experimental + """ + def __init__(self, lhs: scope.jsii_calc_lib.Value, rhs: scope.jsii_calc_lib.Value) -> None: + """Creates a BinaryOperation. - @builtins.property - @jsii.member(jsii_name="stringStyle") - def string_style(self) -> "CompositionStringStyle": - """The .toString() style. + :param lhs: Left-hand side operand. + :param rhs: Right-hand side operand. - stability - :stability: experimental - """ - return jsii.get(self, "stringStyle") + stability + :stability: experimental + """ + jsii.create(Add, self, [lhs, rhs]) - @string_style.setter - def string_style(self, value: "CompositionStringStyle"): - jsii.set(self, "stringStyle", value) + @jsii.member(jsii_name="toString") + def to_string(self) -> str: + """String representation of the value. - @jsii.enum(jsii_type="jsii-calc.composition.CompositeOperation.CompositionStringStyle") - class CompositionStringStyle(enum.Enum): - """Style of .toString() output for CompositeOperation. + stability + :stability: experimental + """ + return jsii.invoke(self, "toString", []) - stability - :stability: experimental - """ - NORMAL = "NORMAL" - """Normal string expression. + @builtins.property + @jsii.member(jsii_name="value") + def value(self) -> jsii.Number: + """The value. - stability - :stability: experimental - """ - DECORATED = "DECORATED" - """Decorated string expression. + stability + :stability: experimental + """ + return jsii.get(self, "value") - stability - :stability: experimental - """ - - - class _CompositeOperationProxy(CompositeOperation, jsii.proxy_for(scope.jsii_calc_lib.Operation)): - @builtins.property - @jsii.member(jsii_name="expression") - def expression(self) -> scope.jsii_calc_lib.Value: - """The expression that this operation consists of. - - Must be implemented by derived classes. - - stability - :stability: experimental - """ - return jsii.get(self, "expression") +@jsii.implements(IAnonymousImplementationProvider) +class AnonymousImplementationProvider(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.AnonymousImplementationProvider"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(AnonymousImplementationProvider, self, []) + @jsii.member(jsii_name="provideAsClass") + def provide_as_class(self) -> "Implementation": + """ + stability + :stability: experimental + """ + return jsii.invoke(self, "provideAsClass", []) -class Calculator(composition.CompositeOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Calculator"): - """A calculator which maintains a current value and allows adding operations. + @jsii.member(jsii_name="provideAsInterface") + def provide_as_interface(self) -> "IAnonymouslyImplementMe": + """ + stability + :stability: experimental + """ + return jsii.invoke(self, "provideAsInterface", []) - Here's how you use it:: - # Example automatically generated. See https://github.com/aws/jsii/issues/826 - calculator = calc.Calculator() - calculator.add(5) - calculator.mul(3) - print(calculator.expression.value) +@jsii.implements(IBell) +class Bell(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Bell"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(Bell, self, []) + + @jsii.member(jsii_name="ring") + def ring(self) -> None: + """ + stability + :stability: experimental + """ + return jsii.invoke(self, "ring", []) + + @builtins.property + @jsii.member(jsii_name="rung") + def rung(self) -> bool: + """ + stability + :stability: experimental + """ + return jsii.get(self, "rung") + + @rung.setter + def rung(self, value: bool): + jsii.set(self, "rung", value) + + +@jsii.data_type(jsii_type="jsii-calc.ChildStruct982", jsii_struct_bases=[ParentStruct982], name_mapping={'foo': 'foo', 'bar': 'bar'}) +class ChildStruct982(ParentStruct982): + def __init__(self, *, foo: str, bar: jsii.Number): + """ + :param foo: + :param bar: + + stability + :stability: experimental + """ + self._values = { + 'foo': foo, + 'bar': bar, + } + + @builtins.property + def foo(self) -> str: + """ + stability + :stability: experimental + """ + return self._values.get('foo') + + @builtins.property + def bar(self) -> jsii.Number: + """ + stability + :stability: experimental + """ + return self._values.get('bar') + + def __eq__(self, rhs) -> bool: + return isinstance(rhs, self.__class__) and rhs._values == self._values + + def __ne__(self, rhs) -> bool: + return not (rhs == self) + + def __repr__(self) -> str: + return 'ChildStruct982(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) + + +@jsii.implements(INonInternalInterface) +class ClassThatImplementsTheInternalInterface(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ClassThatImplementsTheInternalInterface"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(ClassThatImplementsTheInternalInterface, self, []) + + @builtins.property + @jsii.member(jsii_name="a") + def a(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "a") + + @a.setter + def a(self, value: str): + jsii.set(self, "a", value) + + @builtins.property + @jsii.member(jsii_name="b") + def b(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "b") + + @b.setter + def b(self, value: str): + jsii.set(self, "b", value) + + @builtins.property + @jsii.member(jsii_name="c") + def c(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "c") + + @c.setter + def c(self, value: str): + jsii.set(self, "c", value) + + @builtins.property + @jsii.member(jsii_name="d") + def d(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "d") + + @d.setter + def d(self, value: str): + jsii.set(self, "d", value) + + +@jsii.implements(INonInternalInterface) +class ClassThatImplementsThePrivateInterface(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ClassThatImplementsThePrivateInterface"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(ClassThatImplementsThePrivateInterface, self, []) + + @builtins.property + @jsii.member(jsii_name="a") + def a(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "a") + + @a.setter + def a(self, value: str): + jsii.set(self, "a", value) + + @builtins.property + @jsii.member(jsii_name="b") + def b(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "b") + + @b.setter + def b(self, value: str): + jsii.set(self, "b", value) + + @builtins.property + @jsii.member(jsii_name="c") + def c(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "c") + + @c.setter + def c(self, value: str): + jsii.set(self, "c", value) + + @builtins.property + @jsii.member(jsii_name="e") + def e(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "e") + + @e.setter + def e(self, value: str): + jsii.set(self, "e", value) + + +@jsii.implements(IInterfaceWithProperties) +class ClassWithPrivateConstructorAndAutomaticProperties(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.ClassWithPrivateConstructorAndAutomaticProperties"): + """Class that implements interface properties automatically, but using a private constructor. + + stability + :stability: experimental + """ + @jsii.member(jsii_name="create") + @builtins.classmethod + def create(cls, read_only_string: str, read_write_string: str) -> "ClassWithPrivateConstructorAndAutomaticProperties": + """ + :param read_only_string: - + :param read_write_string: - + + stability + :stability: experimental + """ + return jsii.sinvoke(cls, "create", [read_only_string, read_write_string]) + + @builtins.property + @jsii.member(jsii_name="readOnlyString") + def read_only_string(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "readOnlyString") + + @builtins.property + @jsii.member(jsii_name="readWriteString") + def read_write_string(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "readWriteString") + + @read_write_string.setter + def read_write_string(self, value: str): + jsii.set(self, "readWriteString", value) + + +@jsii.interface(jsii_type="jsii-calc.IFriendlyRandomGenerator") +class IFriendlyRandomGenerator(IRandomNumberGenerator, scope.jsii_calc_lib.IFriendly, jsii.compat.Protocol): + """ + stability + :stability: experimental + """ + @builtins.staticmethod + def __jsii_proxy_class__(): + return _IFriendlyRandomGeneratorProxy + + pass + +class _IFriendlyRandomGeneratorProxy(jsii.proxy_for(IRandomNumberGenerator), jsii.proxy_for(scope.jsii_calc_lib.IFriendly)): + """ + stability + :stability: experimental + """ + __jsii_type__ = "jsii-calc.IFriendlyRandomGenerator" + pass + +@jsii.interface(jsii_type="jsii-calc.IInterfaceThatShouldNotBeADataType") +class IInterfaceThatShouldNotBeADataType(IInterfaceWithMethods, jsii.compat.Protocol): + """Even though this interface has only properties, it is disqualified from being a datatype because it inherits from an interface that is not a datatype. + + stability + :stability: experimental + """ + @builtins.staticmethod + def __jsii_proxy_class__(): + return _IInterfaceThatShouldNotBeADataTypeProxy + + @builtins.property + @jsii.member(jsii_name="otherValue") + def other_value(self) -> str: + """ + stability + :stability: experimental + """ + ... + + +class _IInterfaceThatShouldNotBeADataTypeProxy(jsii.proxy_for(IInterfaceWithMethods)): + """Even though this interface has only properties, it is disqualified from being a datatype because it inherits from an interface that is not a datatype. + + stability + :stability: experimental + """ + __jsii_type__ = "jsii-calc.IInterfaceThatShouldNotBeADataType" + @builtins.property + @jsii.member(jsii_name="otherValue") + def other_value(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "otherValue") + + +@jsii.interface(jsii_type="jsii-calc.IJSII417Derived") +class IJSII417Derived(IJSII417PublicBaseOfBase, jsii.compat.Protocol): + """ + stability + :stability: experimental + """ + @builtins.staticmethod + def __jsii_proxy_class__(): + return _IJSII417DerivedProxy + + @builtins.property + @jsii.member(jsii_name="property") + def property(self) -> str: + """ + stability + :stability: experimental + """ + ... + + @jsii.member(jsii_name="bar") + def bar(self) -> None: + """ + stability + :stability: experimental + """ + ... + + @jsii.member(jsii_name="baz") + def baz(self) -> None: + """ + stability + :stability: experimental + """ + ... - I will repeat this example again, but in an @example tag. +class _IJSII417DerivedProxy(jsii.proxy_for(IJSII417PublicBaseOfBase)): + """ stability :stability: experimental - - Example:: - - # Example automatically generated. See https://github.com/aws/jsii/issues/826 - calculator = calc.Calculator() - calculator.add(5) - calculator.mul(3) - print(calculator.expression.value) """ - def __init__(self, *, initial_value: typing.Optional[jsii.Number]=None, maximum_value: typing.Optional[jsii.Number]=None) -> None: - """Creates a Calculator object. - - :param initial_value: The initial value of the calculator. NOTE: Any number works here, it's fine. Default: 0 - :param maximum_value: The maximum value the calculator can store. Default: none + __jsii_type__ = "jsii-calc.IJSII417Derived" + @builtins.property + @jsii.member(jsii_name="property") + def property(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "property") + @jsii.member(jsii_name="bar") + def bar(self) -> None: + """ stability :stability: experimental """ - props = CalculatorProps(initial_value=initial_value, maximum_value=maximum_value) + return jsii.invoke(self, "bar", []) - jsii.create(Calculator, self, [props]) + @jsii.member(jsii_name="baz") + def baz(self) -> None: + """ + stability + :stability: experimental + """ + return jsii.invoke(self, "baz", []) - @jsii.member(jsii_name="add") - def add(self, value: jsii.Number) -> None: - """Adds a number to the current value. - :param value: - +@jsii.implements(IPublicInterface2) +class InbetweenClass(PublicClass, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.InbetweenClass"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(InbetweenClass, self, []) + @jsii.member(jsii_name="ciao") + def ciao(self) -> str: + """ stability :stability: experimental """ - return jsii.invoke(self, "add", [value]) + return jsii.invoke(self, "ciao", []) - @jsii.member(jsii_name="mul") - def mul(self, value: jsii.Number) -> None: - """Multiplies the current value by a number. - :param value: - +class JSII417Derived(JSII417PublicBaseOfBase, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.JSII417Derived"): + """ + stability + :stability: experimental + """ + def __init__(self, property: str) -> None: + """ + :param property: - stability :stability: experimental """ - return jsii.invoke(self, "mul", [value]) - - @jsii.member(jsii_name="neg") - def neg(self) -> None: - """Negates the current value. + jsii.create(JSII417Derived, self, [property]) + @jsii.member(jsii_name="bar") + def bar(self) -> None: + """ stability :stability: experimental """ - return jsii.invoke(self, "neg", []) - - @jsii.member(jsii_name="pow") - def pow(self, value: jsii.Number) -> None: - """Raises the current value by a power. - - :param value: - + return jsii.invoke(self, "bar", []) + @jsii.member(jsii_name="baz") + def baz(self) -> None: + """ stability :stability: experimental """ - return jsii.invoke(self, "pow", [value]) - - @jsii.member(jsii_name="readUnionValue") - def read_union_value(self) -> jsii.Number: - """Returns teh value of the union property (if defined). + return jsii.invoke(self, "baz", []) + @builtins.property + @jsii.member(jsii_name="property") + def _property(self) -> str: + """ stability :stability: experimental """ - return jsii.invoke(self, "readUnionValue", []) + return jsii.get(self, "property") - @builtins.property - @jsii.member(jsii_name="expression") - def expression(self) -> scope.jsii_calc_lib.Value: - """Returns the expression. + +@jsii.implements(IFriendlier) +class Negate(UnaryOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Negate"): + """The negation operation ("-value"). + + stability + :stability: experimental + """ + def __init__(self, operand: scope.jsii_calc_lib.Value) -> None: + """ + :param operand: - stability :stability: experimental """ - return jsii.get(self, "expression") + jsii.create(Negate, self, [operand]) - @builtins.property - @jsii.member(jsii_name="operationsLog") - def operations_log(self) -> typing.List[scope.jsii_calc_lib.Value]: - """A log of all operations. + @jsii.member(jsii_name="farewell") + def farewell(self) -> str: + """Say farewell. stability :stability: experimental """ - return jsii.get(self, "operationsLog") + return jsii.invoke(self, "farewell", []) - @builtins.property - @jsii.member(jsii_name="operationsMap") - def operations_map(self) -> typing.Mapping[str,typing.List[scope.jsii_calc_lib.Value]]: - """A map of per operation name of all operations performed. + @jsii.member(jsii_name="goodbye") + def goodbye(self) -> str: + """Say goodbye. stability :stability: experimental """ - return jsii.get(self, "operationsMap") + return jsii.invoke(self, "goodbye", []) - @builtins.property - @jsii.member(jsii_name="curr") - def curr(self) -> scope.jsii_calc_lib.Value: - """The current value. + @jsii.member(jsii_name="hello") + def hello(self) -> str: + """Say hello! stability :stability: experimental """ - return jsii.get(self, "curr") - - @curr.setter - def curr(self, value: scope.jsii_calc_lib.Value): - jsii.set(self, "curr", value) + return jsii.invoke(self, "hello", []) - @builtins.property - @jsii.member(jsii_name="maxValue") - def max_value(self) -> typing.Optional[jsii.Number]: - """The maximum value allows in this calculator. + @jsii.member(jsii_name="toString") + def to_string(self) -> str: + """String representation of the value. stability :stability: experimental """ - return jsii.get(self, "maxValue") - - @max_value.setter - def max_value(self, value: typing.Optional[jsii.Number]): - jsii.set(self, "maxValue", value) + return jsii.invoke(self, "toString", []) @builtins.property - @jsii.member(jsii_name="unionProperty") - def union_property(self) -> typing.Optional[typing.Union[typing.Optional["Add"], typing.Optional["Multiply"], typing.Optional["Power"]]]: - """Example of a property that accepts a union of types. + @jsii.member(jsii_name="value") + def value(self) -> jsii.Number: + """The value. stability :stability: experimental """ - return jsii.get(self, "unionProperty") - - @union_property.setter - def union_property(self, value: typing.Optional[typing.Union[typing.Optional["Add"], typing.Optional["Multiply"], typing.Optional["Power"]]]): - jsii.set(self, "unionProperty", value) - + return jsii.get(self, "value") -class Power(composition.CompositeOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Power"): - """The power operation. +class SupportsNiceJavaBuilder(SupportsNiceJavaBuilderWithRequiredProps, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.SupportsNiceJavaBuilder"): + """ stability :stability: experimental """ - def __init__(self, base: scope.jsii_calc_lib.Value, pow: scope.jsii_calc_lib.Value) -> None: - """Creates a Power operation. - - :param base: The base of the power. - :param pow: The number of times to multiply. - - stability - :stability: experimental + def __init__(self, id: jsii.Number, default_bar: typing.Optional[jsii.Number]=None, props: typing.Optional["SupportsNiceJavaBuilderProps"]=None, *rest: str) -> None: """ - jsii.create(Power, self, [base, pow]) - - @builtins.property - @jsii.member(jsii_name="base") - def base(self) -> scope.jsii_calc_lib.Value: - """The base of the power. + :param id: some identifier. + :param default_bar: the default value of ``bar``. + :param props: some props once can provide. + :param rest: a variadic continuation. stability :stability: experimental """ - return jsii.get(self, "base") + jsii.create(SupportsNiceJavaBuilder, self, [id, default_bar, props, *rest]) @builtins.property - @jsii.member(jsii_name="expression") - def expression(self) -> scope.jsii_calc_lib.Value: - """The expression that this operation consists of. - - Must be implemented by derived classes. + @jsii.member(jsii_name="id") + def id(self) -> jsii.Number: + """some identifier. stability :stability: experimental """ - return jsii.get(self, "expression") + return jsii.get(self, "id") @builtins.property - @jsii.member(jsii_name="pow") - def pow(self) -> scope.jsii_calc_lib.Value: - """The number of times to multiply. - + @jsii.member(jsii_name="rest") + def rest(self) -> typing.List[str]: + """ stability :stability: experimental """ - return jsii.get(self, "pow") - + return jsii.get(self, "rest") -class Sum(composition.CompositeOperation, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Sum"): - """An operation that sums multiple values. +@jsii.implements(IFriendlyRandomGenerator) +class DoubleTrouble(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DoubleTrouble"): + """ stability :stability: experimental """ def __init__(self) -> None: - """ - stability - :stability: experimental - """ - jsii.create(Sum, self, []) - - @builtins.property - @jsii.member(jsii_name="expression") - def expression(self) -> scope.jsii_calc_lib.Value: - """The expression that this operation consists of. + jsii.create(DoubleTrouble, self, []) - Must be implemented by derived classes. + @jsii.member(jsii_name="hello") + def hello(self) -> str: + """Say hello! stability :stability: experimental """ - return jsii.get(self, "expression") + return jsii.invoke(self, "hello", []) - @builtins.property - @jsii.member(jsii_name="parts") - def parts(self) -> typing.List[scope.jsii_calc_lib.Value]: - """The parts to sum. + @jsii.member(jsii_name="next") + def next(self) -> jsii.Number: + """Returns another random number. stability :stability: experimental """ - return jsii.get(self, "parts") - - @parts.setter - def parts(self, value: typing.List[scope.jsii_calc_lib.Value]): - jsii.set(self, "parts", value) + return jsii.invoke(self, "next", []) -__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "AbstractSuite", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AmbiguousParameters", "AnonymousImplementationProvider", "AsyncVirtualMethods", "AugmentableClass", "BaseJsii976", "Bell", "BinaryOperation", "Calculator", "CalculatorProps", "ChildStruct982", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithCollections", "ClassWithDocs", "ClassWithJavaReservedWords", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConfusingToJackson", "ConfusingToJacksonStruct", "ConstructorPassesThisOut", "Constructors", "ConsumePureInterface", "ConsumerCanRingBell", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", "Demonstrate982", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedClassHasNoProperties", "DerivedStruct", "DiamondInheritanceBaseLevelStruct", "DiamondInheritanceFirstMidLevelStruct", "DiamondInheritanceSecondMidLevelStruct", "DiamondInheritanceTopLevelStruct", "DisappointingCollectionSource", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EnumDispenser", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnonymousImplementationProvider", "IAnonymouslyImplementMe", "IAnotherPublicInterface", "IBell", "IBellRinger", "IConcreteBellRinger", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IObjectWithProperty", "IOptionalMethod", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnJsii976", "IReturnsNumber", "IStableInterface", "IStructReturningDelegate", "ImplementInternalInterface", "Implementation", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceCollections", "InterfaceInNamespaceIncludesClasses", "InterfaceInNamespaceOnlyInterface", "InterfacesMaker", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "JsonFormatter", "LoadBalancedFargateServiceProps", "MethodNamedProperty", "Multiply", "Negate", "NestedStruct", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "ObjectWithPropertyProvider", "Old", "OptionalArgumentInvoker", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverridableProtectedMember", "OverrideReturnsObject", "ParentStruct982", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PropertyNamedProperty", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RootStruct", "RootStructValidator", "RuntimeTypeChecking", "SecondLevelStruct", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "SmellyStruct", "SomeTypeJsii976", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "StructA", "StructB", "StructParameterType", "StructPassing", "StructUnionConsumer", "StructWithJavaReservedWords", "Sum", "SupportsNiceJavaBuilder", "SupportsNiceJavaBuilderProps", "SupportsNiceJavaBuilderWithRequiredProps", "SyncVirtualMethods", "Thrower", "TopLevelStruct", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicInvoker", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__", "composition"] +__all__ = ["AbstractClass", "AbstractClassBase", "AbstractClassReturner", "AbstractSuite", "Add", "AllTypes", "AllTypesEnum", "AllowedMethodNames", "AmbiguousParameters", "AnonymousImplementationProvider", "AsyncVirtualMethods", "AugmentableClass", "BaseJsii976", "Bell", "BinaryOperation", "Calculator", "CalculatorProps", "ChildStruct982", "ClassThatImplementsTheInternalInterface", "ClassThatImplementsThePrivateInterface", "ClassWithCollections", "ClassWithDocs", "ClassWithJavaReservedWords", "ClassWithMutableObjectLiteralProperty", "ClassWithPrivateConstructorAndAutomaticProperties", "ConfusingToJackson", "ConfusingToJacksonStruct", "ConstructorPassesThisOut", "Constructors", "ConsumePureInterface", "ConsumerCanRingBell", "ConsumersOfThisCrazyTypeSystem", "DataRenderer", "DefaultedConstructorArgument", "Demonstrate982", "DeprecatedClass", "DeprecatedEnum", "DeprecatedStruct", "DerivedStruct", "DiamondInheritanceBaseLevelStruct", "DiamondInheritanceFirstMidLevelStruct", "DiamondInheritanceSecondMidLevelStruct", "DiamondInheritanceTopLevelStruct", "DisappointingCollectionSource", "DoNotOverridePrivates", "DoNotRecognizeAnyAsOptional", "DocumentedClass", "DontComplainAboutVariadicAfterOptional", "DoubleTrouble", "EnumDispenser", "EraseUndefinedHashValues", "EraseUndefinedHashValuesOptions", "ExperimentalClass", "ExperimentalEnum", "ExperimentalStruct", "ExportedBaseClass", "ExtendsInternalInterface", "GiveMeStructs", "Greetee", "GreetingAugmenter", "IAnonymousImplementationProvider", "IAnonymouslyImplementMe", "IAnotherPublicInterface", "IBell", "IBellRinger", "IConcreteBellRinger", "IDeprecatedInterface", "IExperimentalInterface", "IExtendsPrivateInterface", "IFriendlier", "IFriendlyRandomGenerator", "IInterfaceImplementedByAbstractClass", "IInterfaceThatShouldNotBeADataType", "IInterfaceWithInternal", "IInterfaceWithMethods", "IInterfaceWithOptionalMethodArguments", "IInterfaceWithProperties", "IInterfaceWithPropertiesExtension", "IJSII417Derived", "IJSII417PublicBaseOfBase", "IJsii487External", "IJsii487External2", "IJsii496", "IMutableObjectLiteral", "INonInternalInterface", "IObjectWithProperty", "IOptionalMethod", "IPrivatelyImplemented", "IPublicInterface", "IPublicInterface2", "IRandomNumberGenerator", "IReturnJsii976", "IReturnsNumber", "IStableInterface", "IStructReturningDelegate", "ImplementInternalInterface", "Implementation", "ImplementsInterfaceWithInternal", "ImplementsInterfaceWithInternalSubclass", "ImplementsPrivateInterface", "ImplictBaseOfBase", "InbetweenClass", "InterfaceCollections", "InterfacesMaker", "JSII417Derived", "JSII417PublicBaseOfBase", "JSObjectLiteralForInterface", "JSObjectLiteralToNative", "JSObjectLiteralToNativeClass", "JavaReservedWords", "Jsii487Derived", "Jsii496Derived", "JsiiAgent", "JsonFormatter", "LoadBalancedFargateServiceProps", "MethodNamedProperty", "Multiply", "Negate", "NestedStruct", "NodeStandardLibrary", "NullShouldBeTreatedAsUndefined", "NullShouldBeTreatedAsUndefinedData", "NumberGenerator", "ObjectRefsInCollections", "ObjectWithPropertyProvider", "Old", "OptionalArgumentInvoker", "OptionalConstructorArgument", "OptionalStruct", "OptionalStructConsumer", "OverridableProtectedMember", "OverrideReturnsObject", "ParentStruct982", "PartiallyInitializedThisConsumer", "Polymorphism", "Power", "PropertyNamedProperty", "PublicClass", "PythonReservedWords", "ReferenceEnumFromScopedPackage", "ReturnsPrivateImplementationOfInterface", "RootStruct", "RootStructValidator", "RuntimeTypeChecking", "SecondLevelStruct", "SingleInstanceTwoTypes", "SingletonInt", "SingletonIntEnum", "SingletonString", "SingletonStringEnum", "SmellyStruct", "SomeTypeJsii976", "StableClass", "StableEnum", "StableStruct", "StaticContext", "Statics", "StringEnum", "StripInternal", "StructA", "StructB", "StructParameterType", "StructPassing", "StructUnionConsumer", "StructWithJavaReservedWords", "Sum", "SupportsNiceJavaBuilder", "SupportsNiceJavaBuilderProps", "SupportsNiceJavaBuilderWithRequiredProps", "SyncVirtualMethods", "Thrower", "TopLevelStruct", "UnaryOperation", "UnionProperties", "UseBundledDependency", "UseCalcBase", "UsesInterfaceWithProperties", "VariadicInvoker", "VariadicMethod", "VirtualMethodPlayground", "VoidCallback", "WithPrivatePropertyInConstructor", "__jsii_assembly__"] publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/_jsii/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/_jsii/__init__.py index a4986f03cf..6e6b14b45b 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/_jsii/__init__.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/_jsii/__init__.py @@ -11,6 +11,7 @@ import scope.jsii_calc_base import scope.jsii_calc_base_of_base import scope.jsii_calc_lib + __all__ = [] publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/composition/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/composition/__init__.py new file mode 100644 index 0000000000..c55d2a0f43 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/composition/__init__.py @@ -0,0 +1,142 @@ +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import jsii.compat +import publication + +import scope.jsii_calc_base +import scope.jsii_calc_base_of_base +import scope.jsii_calc_lib + +__jsii_assembly__ = jsii.JSIIAssembly.load("jsii-calc", "1.1.0", "jsii_calc", "jsii-calc@1.1.0.jsii.tgz") + + +class CompositeOperation(scope.jsii_calc_lib.Operation, metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.composition.CompositeOperation"): + """Abstract operation composed from an expression of other operations. + + stability + :stability: experimental + """ + @builtins.staticmethod + def __jsii_proxy_class__(): + return _CompositeOperationProxy + + def __init__(self) -> None: + jsii.create(CompositeOperation, self, []) + + @jsii.member(jsii_name="toString") + def to_string(self) -> str: + """String representation of the value. + + stability + :stability: experimental + """ + return jsii.invoke(self, "toString", []) + + @builtins.property + @jsii.member(jsii_name="expression") + @abc.abstractmethod + def expression(self) -> scope.jsii_calc_lib.Value: + """The expression that this operation consists of. + + Must be implemented by derived classes. + + stability + :stability: experimental + """ + ... + + @builtins.property + @jsii.member(jsii_name="value") + def value(self) -> jsii.Number: + """The value. + + stability + :stability: experimental + """ + return jsii.get(self, "value") + + @builtins.property + @jsii.member(jsii_name="decorationPostfixes") + def decoration_postfixes(self) -> typing.List[str]: + """A set of postfixes to include in a decorated .toString(). + + stability + :stability: experimental + """ + return jsii.get(self, "decorationPostfixes") + + @decoration_postfixes.setter + def decoration_postfixes(self, value: typing.List[str]): + jsii.set(self, "decorationPostfixes", value) + + @builtins.property + @jsii.member(jsii_name="decorationPrefixes") + def decoration_prefixes(self) -> typing.List[str]: + """A set of prefixes to include in a decorated .toString(). + + stability + :stability: experimental + """ + return jsii.get(self, "decorationPrefixes") + + @decoration_prefixes.setter + def decoration_prefixes(self, value: typing.List[str]): + jsii.set(self, "decorationPrefixes", value) + + @builtins.property + @jsii.member(jsii_name="stringStyle") + def string_style(self) -> "CompositionStringStyle": + """The .toString() style. + + stability + :stability: experimental + """ + return jsii.get(self, "stringStyle") + + @string_style.setter + def string_style(self, value: "CompositionStringStyle"): + jsii.set(self, "stringStyle", value) + + @jsii.enum(jsii_type="jsii-calc.composition.CompositeOperation.CompositionStringStyle") + class CompositionStringStyle(enum.Enum): + """Style of .toString() output for CompositeOperation. + + stability + :stability: experimental + """ + NORMAL = "NORMAL" + """Normal string expression. + + stability + :stability: experimental + """ + DECORATED = "DECORATED" + """Decorated string expression. + + stability + :stability: experimental + """ + + +class _CompositeOperationProxy(CompositeOperation, jsii.proxy_for(scope.jsii_calc_lib.Operation)): + @builtins.property + @jsii.member(jsii_name="expression") + def expression(self) -> scope.jsii_calc_lib.Value: + """The expression that this operation consists of. + + Must be implemented by derived classes. + + stability + :stability: experimental + """ + return jsii.get(self, "expression") + + +__all__ = ["CompositeOperation", "__jsii_assembly__"] + +publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/derived_class_has_no_properties/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/derived_class_has_no_properties/__init__.py new file mode 100644 index 0000000000..add1f8fbb4 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/derived_class_has_no_properties/__init__.py @@ -0,0 +1,51 @@ +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import jsii.compat +import publication + +import scope.jsii_calc_base +import scope.jsii_calc_base_of_base +import scope.jsii_calc_lib + +__jsii_assembly__ = jsii.JSIIAssembly.load("jsii-calc", "1.1.0", "jsii_calc", "jsii-calc@1.1.0.jsii.tgz") + + +class Base(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DerivedClassHasNoProperties.Base"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(jsii_calc.DerivedClassHasNoProperties.Base, self, []) + + @builtins.property + @jsii.member(jsii_name="prop") + def prop(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "prop") + + @prop.setter + def prop(self, value: str): + jsii.set(self, "prop", value) + + +class Derived(jsii_calc.DerivedClassHasNoProperties.Base, metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DerivedClassHasNoProperties.Derived"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(jsii_calc.DerivedClassHasNoProperties.Derived, self, []) + + +__all__ = ["Base", "Derived", "__jsii_assembly__"] + +publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/interface_in_namespace_includes_classes/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/interface_in_namespace_includes_classes/__init__.py new file mode 100644 index 0000000000..7569b9fd1f --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/interface_in_namespace_includes_classes/__init__.py @@ -0,0 +1,73 @@ +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import jsii.compat +import publication + +import scope.jsii_calc_base +import scope.jsii_calc_base_of_base +import scope.jsii_calc_lib + +__jsii_assembly__ = jsii.JSIIAssembly.load("jsii-calc", "1.1.0", "jsii_calc", "jsii-calc@1.1.0.jsii.tgz") + + +class Foo(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.InterfaceInNamespaceIncludesClasses.Foo"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + jsii.create(jsii_calc.InterfaceInNamespaceIncludesClasses.Foo, self, []) + + @builtins.property + @jsii.member(jsii_name="bar") + def bar(self) -> typing.Optional[str]: + """ + stability + :stability: experimental + """ + return jsii.get(self, "bar") + + @bar.setter + def bar(self, value: typing.Optional[str]): + jsii.set(self, "bar", value) + + +@jsii.data_type(jsii_type="jsii-calc.InterfaceInNamespaceIncludesClasses.Hello", jsii_struct_bases=[], name_mapping={'foo': 'foo'}) +class Hello(): + def __init__(self, *, foo: jsii.Number): + """ + :param foo: + + stability + :stability: experimental + """ + self._values = { + 'foo': foo, + } + + @builtins.property + def foo(self) -> jsii.Number: + """ + stability + :stability: experimental + """ + return self._values.get('foo') + + def __eq__(self, rhs) -> bool: + return isinstance(rhs, self.__class__) and rhs._values == self._values + + def __ne__(self, rhs) -> bool: + return not (rhs == self) + + def __repr__(self) -> str: + return 'Hello(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) + + +__all__ = ["Foo", "Hello", "__jsii_assembly__"] + +publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/interface_in_namespace_only_interface/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/interface_in_namespace_only_interface/__init__.py new file mode 100644 index 0000000000..9ad121c642 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/interface_in_namespace_only_interface/__init__.py @@ -0,0 +1,51 @@ +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import jsii.compat +import publication + +import scope.jsii_calc_base +import scope.jsii_calc_base_of_base +import scope.jsii_calc_lib + +__jsii_assembly__ = jsii.JSIIAssembly.load("jsii-calc", "1.1.0", "jsii_calc", "jsii-calc@1.1.0.jsii.tgz") + + +@jsii.data_type(jsii_type="jsii-calc.InterfaceInNamespaceOnlyInterface.Hello", jsii_struct_bases=[], name_mapping={'foo': 'foo'}) +class Hello(): + def __init__(self, *, foo: jsii.Number): + """ + :param foo: + + stability + :stability: experimental + """ + self._values = { + 'foo': foo, + } + + @builtins.property + def foo(self) -> jsii.Number: + """ + stability + :stability: experimental + """ + return self._values.get('foo') + + def __eq__(self, rhs) -> bool: + return isinstance(rhs, self.__class__) and rhs._values == self._values + + def __ne__(self, rhs) -> bool: + return not (rhs == self) + + def __repr__(self) -> str: + return 'Hello(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) + + +__all__ = ["Hello", "__jsii_assembly__"] + +publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/__init__.py new file mode 100644 index 0000000000..6f220a897d --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/__init__.py @@ -0,0 +1,67 @@ +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import jsii.compat +import publication + +import jsii_calc +import jsii_calc.submodule.child +import scope.jsii_calc_base +import scope.jsii_calc_base_of_base +import scope.jsii_calc_lib + +__jsii_assembly__ = jsii.JSIIAssembly.load("jsii-calc", "1.1.0", "jsii_calc", "jsii-calc@1.1.0.jsii.tgz") + + +@jsii.implements(nested_submodule.deeplyNested.INamespaced) +class MyClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.submodule.MyClass"): + """ + stability + :stability: experimental + """ + def __init__(self) -> None: + """ + stability + :stability: experimental + """ + jsii.create(MyClass, self, []) + + @builtins.property + @jsii.member(jsii_name="definedAt") + def defined_at(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "definedAt") + + @builtins.property + @jsii.member(jsii_name="goodness") + def goodness(self) -> "child.Goodness": + """ + stability + :stability: experimental + """ + return jsii.get(self, "goodness") + + @builtins.property + @jsii.member(jsii_name="allTypes") + def all_types(self) -> typing.Optional[jsii_calc.AllTypes]: + """ + stability + :stability: experimental + """ + return jsii.get(self, "allTypes") + + @all_types.setter + def all_types(self, value: typing.Optional[jsii_calc.AllTypes]): + jsii.set(self, "allTypes", value) + + +__all__ = ["MyClass", "__jsii_assembly__"] + +publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/back_references/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/back_references/__init__.py new file mode 100644 index 0000000000..7d061d3c1b --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/back_references/__init__.py @@ -0,0 +1,51 @@ +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import jsii.compat +import publication + +import scope.jsii_calc_base +import scope.jsii_calc_base_of_base +import scope.jsii_calc_lib + +__jsii_assembly__ = jsii.JSIIAssembly.load("jsii-calc", "1.1.0", "jsii_calc", "jsii-calc@1.1.0.jsii.tgz") + + +@jsii.data_type(jsii_type="jsii-calc.submodule.back_references.MyClassReference", jsii_struct_bases=[], name_mapping={'reference': 'reference'}) +class MyClassReference(): + def __init__(self, *, reference: jsii_calc.submodule.MyClass): + """ + :param reference: + + stability + :stability: experimental + """ + self._values = { + 'reference': reference, + } + + @builtins.property + def reference(self) -> jsii_calc.submodule.MyClass: + """ + stability + :stability: experimental + """ + return self._values.get('reference') + + def __eq__(self, rhs) -> bool: + return isinstance(rhs, self.__class__) and rhs._values == self._values + + def __ne__(self, rhs) -> bool: + return not (rhs == self) + + def __repr__(self) -> str: + return 'MyClassReference(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) + + +__all__ = ["MyClassReference", "__jsii_assembly__"] + +publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/child/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/child/__init__.py new file mode 100644 index 0000000000..e322ab6c71 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/child/__init__.py @@ -0,0 +1,76 @@ +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import jsii.compat +import publication + +import scope.jsii_calc_base +import scope.jsii_calc_base_of_base +import scope.jsii_calc_lib + +__jsii_assembly__ = jsii.JSIIAssembly.load("jsii-calc", "1.1.0", "jsii_calc", "jsii-calc@1.1.0.jsii.tgz") + + +@jsii.enum(jsii_type="jsii-calc.submodule.child.Goodness") +class Goodness(enum.Enum): + """ + stability + :stability: experimental + """ + PRETTY_GOOD = "PRETTY_GOOD" + """It's pretty good. + + stability + :stability: experimental + """ + REALLY_GOOD = "REALLY_GOOD" + """It's really good. + + stability + :stability: experimental + """ + AMAZINGLY_GOOD = "AMAZINGLY_GOOD" + """It's amazingly good. + + stability + :stability: experimental + """ + +@jsii.data_type(jsii_type="jsii-calc.submodule.child.Structure", jsii_struct_bases=[], name_mapping={'bool': 'bool'}) +class Structure(): + def __init__(self, *, bool: bool): + """ + :param bool: + + stability + :stability: experimental + """ + self._values = { + 'bool': bool, + } + + @builtins.property + def bool(self) -> bool: + """ + stability + :stability: experimental + """ + return self._values.get('bool') + + def __eq__(self, rhs) -> bool: + return isinstance(rhs, self.__class__) and rhs._values == self._values + + def __ne__(self, rhs) -> bool: + return not (rhs == self) + + def __repr__(self) -> str: + return 'Structure(%s)' % ', '.join(k + '=' + repr(v) for k, v in self._values.items()) + + +__all__ = ["Goodness", "Structure", "__jsii_assembly__"] + +publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/nested_submodule/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/nested_submodule/__init__.py new file mode 100644 index 0000000000..1381d80e61 --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/nested_submodule/__init__.py @@ -0,0 +1,62 @@ +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import jsii.compat +import publication + +import jsii_calc.submodule.child +import scope.jsii_calc_base +import scope.jsii_calc_base_of_base +import scope.jsii_calc_lib + +__jsii_assembly__ = jsii.JSIIAssembly.load("jsii-calc", "1.1.0", "jsii_calc", "jsii-calc@1.1.0.jsii.tgz") + + +@jsii.implements(deeplyNested.INamespaced) +class Namespaced(metaclass=jsii.JSIIAbstractClass, jsii_type="jsii-calc.submodule.nested_submodule.Namespaced"): + """ + stability + :stability: experimental + """ + @builtins.staticmethod + def __jsii_proxy_class__(): + return _NamespacedProxy + + @builtins.property + @jsii.member(jsii_name="definedAt") + def defined_at(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "definedAt") + + @builtins.property + @jsii.member(jsii_name="goodness") + @abc.abstractmethod + def goodness(self) -> jsii_calc.submodule.child.Goodness: + """ + stability + :stability: experimental + """ + ... + + +class _NamespacedProxy(Namespaced): + @builtins.property + @jsii.member(jsii_name="goodness") + def goodness(self) -> jsii_calc.submodule.child.Goodness: + """ + stability + :stability: experimental + """ + return jsii.get(self, "goodness") + + +__all__ = ["Namespaced", "__jsii_assembly__"] + +publication.publish() diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/nested_submodule/deeply_nested/__init__.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/nested_submodule/deeply_nested/__init__.py new file mode 100644 index 0000000000..147de6591a --- /dev/null +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/submodule/nested_submodule/deeply_nested/__init__.py @@ -0,0 +1,56 @@ +import abc +import builtins +import datetime +import enum +import typing + +import jsii +import jsii.compat +import publication + +import scope.jsii_calc_base +import scope.jsii_calc_base_of_base +import scope.jsii_calc_lib + +__jsii_assembly__ = jsii.JSIIAssembly.load("jsii-calc", "1.1.0", "jsii_calc", "jsii-calc@1.1.0.jsii.tgz") + + +@jsii.interface(jsii_type="jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced") +class INamespaced(jsii.compat.Protocol): + """ + stability + :stability: experimental + """ + @builtins.staticmethod + def __jsii_proxy_class__(): + return _INamespacedProxy + + @builtins.property + @jsii.member(jsii_name="definedAt") + def defined_at(self) -> str: + """ + stability + :stability: experimental + """ + ... + + +class _INamespacedProxy(): + """ + stability + :stability: experimental + """ + __jsii_type__ = "jsii-calc.submodule.nested_submodule.deeplyNested.INamespaced" + @builtins.property + @jsii.member(jsii_name="definedAt") + def defined_at(self) -> str: + """ + stability + :stability: experimental + """ + return jsii.get(self, "definedAt") + + +__all__ = ["INamespaced", "__jsii_assembly__"] + +publication.publish() diff --git a/packages/jsii-reflect/actual.txt b/packages/jsii-reflect/actual.txt deleted file mode 100644 index 7df10da8b9..0000000000 --- a/packages/jsii-reflect/actual.txt +++ /dev/null @@ -1,1223 +0,0 @@ -assemblies - ├─┬ jsii-calc - │ ├─┬ dependencies - │ │ ├── @scope/jsii-calc-base - │ │ └── @scope/jsii-calc-lib - │ └─┬ types - │ ├─┬ AbstractClass class - │ │ ├── base: AbstractClassBase - │ │ ├── interfaces: InterfaceImplementedByAbstractClass - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ abstractMethod(name) method - │ │ │ ├── abstract - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ name - │ │ │ │ └── type: primitive:string - │ │ │ └── returns: primitive:string - │ │ ├─┬ nonAbstractMethod() method - │ │ │ └── returns: primitive:number - │ │ └─┬ propFromInterface property - │ │ ├── immutable - │ │ └── type: primitive:string - │ ├─┬ AbstractClassBase class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ abstractProperty property - │ │ ├── abstract - │ │ ├── immutable - │ │ └── type: primitive:string - │ ├─┬ AbstractClassReturner class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ giveMeAbstract() method - │ │ │ └── returns: class:jsii-calc.AbstractClass - │ │ ├─┬ giveMeInterface() method - │ │ │ └── returns: interface:jsii-calc.InterfaceImplementedByAbstractClass - │ │ └─┬ returnAbstractFromProperty property - │ │ ├── immutable - │ │ └── type: class:jsii-calc.AbstractClassBase - │ ├─┬ Add class - │ │ ├── base: BinaryOperation - │ │ └─┬ members - │ │ ├─┬ (lhs,rhs) method - │ │ │ ├─┬ parameters - │ │ │ │ ├─┬ lhs - │ │ │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ │ │ └─┬ rhs - │ │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ │ └── returns: void - │ │ ├─┬ toString() method - │ │ │ └── returns: primitive:string - │ │ └─┬ value property - │ │ ├── immutable - │ │ └── type: primitive:number - │ ├─┬ AllTypes class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ enumMethod(value) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ value - │ │ │ │ └── type: enum:jsii-calc.StringEnum - │ │ │ └── returns: enum:jsii-calc.StringEnum - │ │ ├─┬ enumPropertyValue property - │ │ │ ├── immutable - │ │ │ └── type: primitive:number - │ │ ├─┬ anyArrayProperty property - │ │ │ └── type: Array - │ │ ├─┬ anyMapProperty property - │ │ │ └── type: Map primitive:any> - │ │ ├─┬ anyProperty property - │ │ │ └── type: primitive:any - │ │ ├─┬ arrayProperty property - │ │ │ └── type: Array - │ │ ├─┬ booleanProperty property - │ │ │ └── type: primitive:boolean - │ │ ├─┬ dateProperty property - │ │ │ └── type: primitive:date - │ │ ├─┬ enumProperty property - │ │ │ └── type: enum:jsii-calc.AllTypesEnum - │ │ ├─┬ jsonProperty property - │ │ │ └── type: primitive:json - │ │ ├─┬ mapProperty property - │ │ │ └── type: Map class:@scope/jsii-calc-lib.Number> - │ │ ├─┬ numberProperty property - │ │ │ └── type: primitive:number - │ │ ├─┬ stringProperty property - │ │ │ └── type: primitive:string - │ │ ├─┬ unionArrayProperty property - │ │ │ └── type: Array - │ │ ├─┬ unionMapProperty property - │ │ │ └── type: Map primitive:string | primitive:number | class:@scope/jsii-calc-lib.Number> - │ │ ├─┬ unionProperty property - │ │ │ └── type: primitive:string | primitive:number | class:jsii-calc.Multiply | class:@scope/jsii-calc-lib.Number - │ │ ├─┬ unknownArrayProperty property - │ │ │ └── type: Array - │ │ ├─┬ unknownMapProperty property - │ │ │ └── type: Map primitive:any> - │ │ ├─┬ unknownProperty property - │ │ │ └── type: primitive:any - │ │ └─┬ optionalEnumValue property - │ │ └── type: enum:jsii-calc.StringEnum (optional) - │ ├─┬ AllowedMethodNames class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ getBar(_p1,_p2) method - │ │ │ ├─┬ parameters - │ │ │ │ ├─┬ _p1 - │ │ │ │ │ └── type: primitive:string - │ │ │ │ └─┬ _p2 - │ │ │ │ └── type: primitive:number - │ │ │ └── returns: void - │ │ ├─┬ getFoo(withParam) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ withParam - │ │ │ │ └── type: primitive:string - │ │ │ └── returns: primitive:string - │ │ ├─┬ setBar(_x,_y,_z) method - │ │ │ ├─┬ parameters - │ │ │ │ ├─┬ _x - │ │ │ │ │ └── type: primitive:string - │ │ │ │ ├─┬ _y - │ │ │ │ │ └── type: primitive:number - │ │ │ │ └─┬ _z - │ │ │ │ └── type: primitive:boolean - │ │ │ └── returns: void - │ │ └─┬ setFoo(_x,_y) method - │ │ ├─┬ parameters - │ │ │ ├─┬ _x - │ │ │ │ └── type: primitive:string - │ │ │ └─┬ _y - │ │ │ └── type: primitive:number - │ │ └── returns: void - │ ├─┬ AsyncVirtualMethods class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ callMe() method - │ │ │ └── returns: primitive:number (promise) - │ │ ├─┬ callMe2() method - │ │ │ └── returns: primitive:number (promise) - │ │ ├─┬ callMeDoublePromise() method - │ │ │ └── returns: primitive:number (promise) - │ │ ├─┬ dontOverrideMe() method - │ │ │ └── returns: primitive:number - │ │ ├─┬ overrideMe(mult) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ mult - │ │ │ │ └── type: primitive:number - │ │ │ └── returns: primitive:number (promise) - │ │ └─┬ overrideMeToo() method - │ │ └── returns: primitive:number (promise) - │ ├─┬ BinaryOperation class - │ │ ├── base: Operation - │ │ ├── interfaces: IFriendly - │ │ └─┬ members - │ │ ├─┬ (lhs,rhs) method - │ │ │ ├─┬ parameters - │ │ │ │ ├─┬ lhs - │ │ │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ │ │ └─┬ rhs - │ │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ │ └── returns: void - │ │ ├─┬ hello() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ lhs property - │ │ │ ├── immutable - │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ └─┬ rhs property - │ │ ├── immutable - │ │ └── type: class:@scope/jsii-calc-lib.Value - │ ├─┬ Calculator class - │ │ ├── base: CompositeOperation - │ │ └─┬ members - │ │ ├─┬ (props) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ props - │ │ │ │ └── type: interface:jsii-calc.CalculatorProps (optional) - │ │ │ └── returns: void - │ │ ├─┬ add(value) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ value - │ │ │ │ └── type: primitive:number - │ │ │ └── returns: void - │ │ ├─┬ mul(value) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ value - │ │ │ │ └── type: primitive:number - │ │ │ └── returns: void - │ │ ├─┬ neg() method - │ │ │ └── returns: void - │ │ ├─┬ pow(value) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ value - │ │ │ │ └── type: primitive:number - │ │ │ └── returns: void - │ │ ├─┬ readUnionValue() method - │ │ │ └── returns: primitive:number - │ │ ├─┬ expression property - │ │ │ ├── immutable - │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ ├─┬ operationsLog property - │ │ │ ├── immutable - │ │ │ └── type: Array - │ │ ├─┬ operationsMap property - │ │ │ ├── immutable - │ │ │ └── type: Map Array> - │ │ ├─┬ curr property - │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ ├─┬ maxValue property - │ │ │ └── type: primitive:number (optional) - │ │ └─┬ unionProperty property - │ │ └── type: class:jsii-calc.Add | class:jsii-calc.Multiply | class:jsii-calc.Power - │ ├─┬ ClassWithMutableObjectLiteralProperty class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ mutableObject property - │ │ └── type: interface:jsii-calc.MutableObjectLiteral - │ ├─┬ ClassWithPrivateConstructorAndAutomaticProperties class - │ │ ├── interfaces: InterfaceWithProperties - │ │ └─┬ members - │ │ ├─┬ create(readOnlyString,readWriteString) method - │ │ │ ├── static - │ │ │ ├─┬ parameters - │ │ │ │ ├─┬ readOnlyString - │ │ │ │ │ └── type: primitive:string - │ │ │ │ └─┬ readWriteString - │ │ │ │ └── type: primitive:string - │ │ │ └── returns: class:jsii-calc.ClassWithPrivateConstructorAndAutomaticProperties - │ │ ├─┬ readOnlyString property - │ │ │ ├── immutable - │ │ │ └── type: primitive:string - │ │ └─┬ readWriteString property - │ │ └── type: primitive:string - │ ├─┬ DefaultedConstructorArgument class - │ │ └─┬ members - │ │ ├─┬ (arg1,arg2,arg3) method - │ │ │ ├─┬ parameters - │ │ │ │ ├─┬ arg1 - │ │ │ │ │ └── type: primitive:number (optional) - │ │ │ │ ├─┬ arg2 - │ │ │ │ │ └── type: primitive:string (optional) - │ │ │ │ └─┬ arg3 - │ │ │ │ └── type: primitive:date (optional) - │ │ │ └── returns: void - │ │ ├─┬ arg1 property - │ │ │ ├── immutable - │ │ │ └── type: primitive:number - │ │ ├─┬ arg3 property - │ │ │ ├── immutable - │ │ │ └── type: primitive:date - │ │ └─┬ arg2 property - │ │ ├── immutable - │ │ └── type: primitive:string (optional) - │ ├─┬ Base class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ prop property - │ │ └── type: primitive:string - │ ├─┬ Derived class - │ │ ├── base: Base - │ │ └─┬ members - │ │ └─┬ () method - │ │ └── returns: void - │ ├─┬ DoNotOverridePrivates class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ changePrivatePropertyValue(newValue) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ newValue - │ │ │ │ └── type: primitive:string - │ │ │ └── returns: void - │ │ ├─┬ privateMethodValue() method - │ │ │ └── returns: primitive:string - │ │ └─┬ privatePropertyValue() method - │ │ └── returns: primitive:string - │ ├─┬ DoNotRecognizeAnyAsOptional class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ method(_requiredAny,_optionalAny,_optionalString) method - │ │ ├─┬ parameters - │ │ │ ├─┬ _requiredAny - │ │ │ │ └── type: primitive:any - │ │ │ ├─┬ _optionalAny - │ │ │ │ └── type: primitive:any (optional) - │ │ │ └─┬ _optionalString - │ │ │ └── type: primitive:string (optional) - │ │ └── returns: void - │ ├─┬ DontComplainAboutVariadicAfterOptional class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ optionalAndVariadic(optional,things) method - │ │ ├── variadic - │ │ ├─┬ parameters - │ │ │ ├─┬ optional - │ │ │ │ └── type: primitive:string (optional) - │ │ │ └─┬ things - │ │ │ ├── type: primitive:string - │ │ │ └── variadic - │ │ └── returns: primitive:string - │ ├─┬ DoubleTrouble class - │ │ ├── interfaces: IFriendlyRandomGenerator - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ hello() method - │ │ │ └── returns: primitive:string - │ │ └─┬ next() method - │ │ └── returns: primitive:number - │ ├─┬ ExportedBaseClass class - │ │ └─┬ members - │ │ ├─┬ (success) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ success - │ │ │ │ └── type: primitive:boolean - │ │ │ └── returns: void - │ │ └─┬ success property - │ │ ├── immutable - │ │ └── type: primitive:boolean - │ ├─┬ GiveMeStructs class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ derivedToFirst(derived) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ derived - │ │ │ │ └── type: interface:jsii-calc.DerivedStruct - │ │ │ └── returns: interface:@scope/jsii-calc-lib.MyFirstStruct - │ │ ├─┬ readDerivedNonPrimitive(derived) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ derived - │ │ │ │ └── type: interface:jsii-calc.DerivedStruct - │ │ │ └── returns: class:jsii-calc.DoubleTrouble - │ │ ├─┬ readFirstNumber(first) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ first - │ │ │ │ └── type: interface:@scope/jsii-calc-lib.MyFirstStruct - │ │ │ └── returns: primitive:number - │ │ └─┬ structLiteral property - │ │ ├── immutable - │ │ └── type: interface:@scope/jsii-calc-lib.StructWithOnlyOptionals - │ ├─┬ GreetingAugmenter class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ betterGreeting(friendly) method - │ │ ├─┬ parameters - │ │ │ └─┬ friendly - │ │ │ └── type: interface:@scope/jsii-calc-lib.IFriendly - │ │ └── returns: primitive:string - │ ├─┬ Foo class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ bar property - │ │ └── type: primitive:string (optional) - │ ├─┬ JSObjectLiteralForInterface class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ giveMeFriendly() method - │ │ │ └── returns: interface:@scope/jsii-calc-lib.IFriendly - │ │ └─┬ giveMeFriendlyGenerator() method - │ │ └── returns: interface:jsii-calc.IFriendlyRandomGenerator - │ ├─┬ JSObjectLiteralToNative class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ returnLiteral() method - │ │ └── returns: class:jsii-calc.JSObjectLiteralToNativeClass - │ ├─┬ JSObjectLiteralToNativeClass class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ propA property - │ │ │ └── type: primitive:string - │ │ └─┬ propB property - │ │ └── type: primitive:number - │ ├─┬ JavaReservedWords class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ abstract() method - │ │ │ └── returns: void - │ │ ├─┬ assert() method - │ │ │ └── returns: void - │ │ ├─┬ boolean() method - │ │ │ └── returns: void - │ │ ├─┬ break() method - │ │ │ └── returns: void - │ │ ├─┬ byte() method - │ │ │ └── returns: void - │ │ ├─┬ case() method - │ │ │ └── returns: void - │ │ ├─┬ catch() method - │ │ │ └── returns: void - │ │ ├─┬ char() method - │ │ │ └── returns: void - │ │ ├─┬ class() method - │ │ │ └── returns: void - │ │ ├─┬ const() method - │ │ │ └── returns: void - │ │ ├─┬ continue() method - │ │ │ └── returns: void - │ │ ├─┬ default() method - │ │ │ └── returns: void - │ │ ├─┬ do() method - │ │ │ └── returns: void - │ │ ├─┬ double() method - │ │ │ └── returns: void - │ │ ├─┬ else() method - │ │ │ └── returns: void - │ │ ├─┬ enum() method - │ │ │ └── returns: void - │ │ ├─┬ extends() method - │ │ │ └── returns: void - │ │ ├─┬ false() method - │ │ │ └── returns: void - │ │ ├─┬ final() method - │ │ │ └── returns: void - │ │ ├─┬ finally() method - │ │ │ └── returns: void - │ │ ├─┬ float() method - │ │ │ └── returns: void - │ │ ├─┬ for() method - │ │ │ └── returns: void - │ │ ├─┬ goto() method - │ │ │ └── returns: void - │ │ ├─┬ if() method - │ │ │ └── returns: void - │ │ ├─┬ implements() method - │ │ │ └── returns: void - │ │ ├─┬ import() method - │ │ │ └── returns: void - │ │ ├─┬ instanceof() method - │ │ │ └── returns: void - │ │ ├─┬ int() method - │ │ │ └── returns: void - │ │ ├─┬ interface() method - │ │ │ └── returns: void - │ │ ├─┬ long() method - │ │ │ └── returns: void - │ │ ├─┬ native() method - │ │ │ └── returns: void - │ │ ├─┬ new() method - │ │ │ └── returns: void - │ │ ├─┬ null() method - │ │ │ └── returns: void - │ │ ├─┬ package() method - │ │ │ └── returns: void - │ │ ├─┬ private() method - │ │ │ └── returns: void - │ │ ├─┬ protected() method - │ │ │ └── returns: void - │ │ ├─┬ public() method - │ │ │ └── returns: void - │ │ ├─┬ return() method - │ │ │ └── returns: void - │ │ ├─┬ short() method - │ │ │ └── returns: void - │ │ ├─┬ static() method - │ │ │ └── returns: void - │ │ ├─┬ strictfp() method - │ │ │ └── returns: void - │ │ ├─┬ super() method - │ │ │ └── returns: void - │ │ ├─┬ switch() method - │ │ │ └── returns: void - │ │ ├─┬ synchronized() method - │ │ │ └── returns: void - │ │ ├─┬ this() method - │ │ │ └── returns: void - │ │ ├─┬ throw() method - │ │ │ └── returns: void - │ │ ├─┬ throws() method - │ │ │ └── returns: void - │ │ ├─┬ transient() method - │ │ │ └── returns: void - │ │ ├─┬ true() method - │ │ │ └── returns: void - │ │ ├─┬ try() method - │ │ │ └── returns: void - │ │ ├─┬ void() method - │ │ │ └── returns: void - │ │ ├─┬ volatile() method - │ │ │ └── returns: void - │ │ └─┬ while property - │ │ └── type: primitive:string - │ ├─┬ JsiiAgent class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ jsiiAgent property - │ │ ├── immutable - │ │ ├── static - │ │ └── type: primitive:string (optional) - │ ├─┬ Multiply class - │ │ ├── base: BinaryOperation - │ │ ├── interfaces: IFriendlier,IRandomNumberGenerator - │ │ └─┬ members - │ │ ├─┬ (lhs,rhs) method - │ │ │ ├─┬ parameters - │ │ │ │ ├─┬ lhs - │ │ │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ │ │ └─┬ rhs - │ │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ │ └── returns: void - │ │ ├─┬ farewell() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ goodbye() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ next() method - │ │ │ └── returns: primitive:number - │ │ ├─┬ toString() method - │ │ │ └── returns: primitive:string - │ │ └─┬ value property - │ │ ├── immutable - │ │ └── type: primitive:number - │ ├─┬ Negate class - │ │ ├── base: UnaryOperation - │ │ ├── interfaces: IFriendlier - │ │ └─┬ members - │ │ ├─┬ (operand) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ operand - │ │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ │ └── returns: void - │ │ ├─┬ farewell() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ goodbye() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ hello() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ toString() method - │ │ │ └── returns: primitive:string - │ │ └─┬ value property - │ │ ├── immutable - │ │ └── type: primitive:number - │ ├─┬ NodeStandardLibrary class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ cryptoSha256() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ fsReadFile() method - │ │ │ └── returns: primitive:string (promise) - │ │ ├─┬ fsReadFileSync() method - │ │ │ └── returns: primitive:string - │ │ └─┬ osPlatform property - │ │ ├── immutable - │ │ └── type: primitive:string - │ ├─┬ NullShouldBeTreatedAsUndefined class - │ │ └─┬ members - │ │ ├─┬ (_param1,optional) method - │ │ │ ├─┬ parameters - │ │ │ │ ├─┬ _param1 - │ │ │ │ │ └── type: primitive:string - │ │ │ │ └─┬ optional - │ │ │ │ └── type: primitive:any (optional) - │ │ │ └── returns: void - │ │ ├─┬ giveMeUndefined(value) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ value - │ │ │ │ └── type: primitive:any (optional) - │ │ │ └── returns: void - │ │ ├─┬ giveMeUndefinedInsideAnObject(input) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ input - │ │ │ │ └── type: interface:jsii-calc.NullShouldBeTreatedAsUndefinedData - │ │ │ └── returns: void - │ │ ├─┬ verifyPropertyIsUndefined() method - │ │ │ └── returns: void - │ │ └─┬ changeMeToUndefined property - │ │ └── type: primitive:string (optional) - │ ├─┬ NumberGenerator class - │ │ └─┬ members - │ │ ├─┬ (generator) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ generator - │ │ │ │ └── type: interface:jsii-calc.IRandomNumberGenerator - │ │ │ └── returns: void - │ │ ├─┬ isSameGenerator(gen) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ gen - │ │ │ │ └── type: interface:jsii-calc.IRandomNumberGenerator - │ │ │ └── returns: primitive:boolean - │ │ ├─┬ nextTimes100() method - │ │ │ └── returns: primitive:number - │ │ └─┬ generator property - │ │ └── type: interface:jsii-calc.IRandomNumberGenerator - │ ├─┬ ObjectRefsInCollections class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ sumFromArray(values) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ values - │ │ │ │ └── type: Array - │ │ │ └── returns: primitive:number - │ │ └─┬ sumFromMap(values) method - │ │ ├─┬ parameters - │ │ │ └─┬ values - │ │ │ └── type: Map class:@scope/jsii-calc-lib.Value> - │ │ └── returns: primitive:number - │ ├─┬ OptionalConstructorArgument class - │ │ └─┬ members - │ │ ├─┬ (arg1,arg2,arg3) method - │ │ │ ├─┬ parameters - │ │ │ │ ├─┬ arg1 - │ │ │ │ │ └── type: primitive:number - │ │ │ │ ├─┬ arg2 - │ │ │ │ │ └── type: primitive:string - │ │ │ │ └─┬ arg3 - │ │ │ │ └── type: primitive:date (optional) - │ │ │ └── returns: void - │ │ ├─┬ arg1 property - │ │ │ ├── immutable - │ │ │ └── type: primitive:number - │ │ ├─┬ arg2 property - │ │ │ ├── immutable - │ │ │ └── type: primitive:string - │ │ └─┬ arg3 property - │ │ ├── immutable - │ │ └── type: primitive:date (optional) - │ ├─┬ OverrideReturnsObject class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ test(obj) method - │ │ ├─┬ parameters - │ │ │ └─┬ obj - │ │ │ └── type: interface:jsii-calc.IReturnsNumber - │ │ └── returns: primitive:number - │ ├─┬ Polymorphism class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ sayHello(friendly) method - │ │ ├─┬ parameters - │ │ │ └─┬ friendly - │ │ │ └── type: interface:@scope/jsii-calc-lib.IFriendly - │ │ └── returns: primitive:string - │ ├─┬ Power class - │ │ ├── base: CompositeOperation - │ │ └─┬ members - │ │ ├─┬ (base,pow) method - │ │ │ ├─┬ parameters - │ │ │ │ ├─┬ base - │ │ │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ │ │ └─┬ pow - │ │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ │ └── returns: void - │ │ ├─┬ base property - │ │ │ ├── immutable - │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ ├─┬ expression property - │ │ │ ├── immutable - │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ └─┬ pow property - │ │ ├── immutable - │ │ └── type: class:@scope/jsii-calc-lib.Value - │ ├─┬ ReferenceEnumFromScopedPackage class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ loadFoo() method - │ │ │ └── returns: enum:@scope/jsii-calc-lib.EnumFromScopedModule (optional) - │ │ ├─┬ saveFoo(value) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ value - │ │ │ │ └── type: enum:@scope/jsii-calc-lib.EnumFromScopedModule - │ │ │ └── returns: void - │ │ └─┬ foo property - │ │ └── type: enum:@scope/jsii-calc-lib.EnumFromScopedModule (optional) - │ ├─┬ ReturnsPrivateImplementationOfInterface class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ privateImplementation property - │ │ ├── immutable - │ │ └── type: interface:jsii-calc.IPrivatelyImplemented - │ ├─┬ RuntimeTypeChecking class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ methodWithDefaultedArguments(arg1,arg2,arg3) method - │ │ │ ├─┬ parameters - │ │ │ │ ├─┬ arg1 - │ │ │ │ │ └── type: primitive:number (optional) - │ │ │ │ ├─┬ arg2 - │ │ │ │ │ └── type: primitive:string (optional) - │ │ │ │ └─┬ arg3 - │ │ │ │ └── type: primitive:date (optional) - │ │ │ └── returns: void - │ │ ├─┬ methodWithOptionalAnyArgument(arg) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ arg - │ │ │ │ └── type: primitive:any (optional) - │ │ │ └── returns: void - │ │ └─┬ methodWithOptionalArguments(arg1,arg2,arg3) method - │ │ ├─┬ parameters - │ │ │ ├─┬ arg1 - │ │ │ │ └── type: primitive:number - │ │ │ ├─┬ arg2 - │ │ │ │ └── type: primitive:string - │ │ │ └─┬ arg3 - │ │ │ └── type: primitive:date (optional) - │ │ └── returns: void - │ ├─┬ Statics class - │ │ └─┬ members - │ │ ├─┬ (value) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ value - │ │ │ │ └── type: primitive:string - │ │ │ └── returns: void - │ │ ├─┬ staticMethod(name) method - │ │ │ ├── static - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ name - │ │ │ │ └── type: primitive:string - │ │ │ └── returns: primitive:string - │ │ ├─┬ justMethod() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ BAR property - │ │ │ ├── const - │ │ │ ├── immutable - │ │ │ ├── static - │ │ │ └── type: primitive:number - │ │ ├─┬ ConstObj property - │ │ │ ├── const - │ │ │ ├── immutable - │ │ │ ├── static - │ │ │ └── type: class:jsii-calc.DoubleTrouble - │ │ ├─┬ Foo property - │ │ │ ├── const - │ │ │ ├── immutable - │ │ │ ├── static - │ │ │ └── type: primitive:string - │ │ ├─┬ zooBar property - │ │ │ ├── const - │ │ │ ├── immutable - │ │ │ ├── static - │ │ │ └── type: Map primitive:string> - │ │ ├─┬ instance property - │ │ │ ├── static - │ │ │ └── type: class:jsii-calc.Statics - │ │ ├─┬ nonConstStatic property - │ │ │ ├── static - │ │ │ └── type: primitive:number - │ │ └─┬ value property - │ │ ├── immutable - │ │ └── type: primitive:string - │ ├─┬ Sum class - │ │ ├── base: CompositeOperation - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ expression property - │ │ │ ├── immutable - │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ └─┬ parts property - │ │ └── type: Array - │ ├─┬ SyncVirtualMethods class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ callerIsAsync() method - │ │ │ └── returns: primitive:number (promise) - │ │ ├─┬ callerIsMethod() method - │ │ │ └── returns: primitive:number - │ │ ├─┬ modifyOtherProperty(value) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ value - │ │ │ │ └── type: primitive:string - │ │ │ └── returns: void - │ │ ├─┬ modifyValueOfTheProperty(value) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ value - │ │ │ │ └── type: primitive:string - │ │ │ └── returns: void - │ │ ├─┬ readA() method - │ │ │ └── returns: primitive:number - │ │ ├─┬ retrieveOtherProperty() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ retrieveReadOnlyProperty() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ retrieveValueOfTheProperty() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ virtualMethod(n) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ n - │ │ │ │ └── type: primitive:number - │ │ │ └── returns: primitive:number - │ │ ├─┬ writeA(value) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ value - │ │ │ │ └── type: primitive:number - │ │ │ └── returns: void - │ │ ├─┬ readonlyProperty property - │ │ │ ├── immutable - │ │ │ └── type: primitive:string - │ │ ├─┬ a property - │ │ │ └── type: primitive:number - │ │ ├─┬ callerIsProperty property - │ │ │ └── type: primitive:number - │ │ ├─┬ otherProperty property - │ │ │ └── type: primitive:string - │ │ ├─┬ theProperty property - │ │ │ └── type: primitive:string - │ │ └─┬ valueOfOtherProperty property - │ │ └── type: primitive:string - │ ├─┬ Thrower class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ throwError() method - │ │ └── returns: void - │ ├─┬ UnaryOperation class - │ │ ├── base: Operation - │ │ └─┬ members - │ │ ├─┬ (operand) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ operand - │ │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ │ └── returns: void - │ │ └─┬ operand property - │ │ ├── immutable - │ │ └── type: class:@scope/jsii-calc-lib.Value - │ ├─┬ UseBundledDependency class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ value() method - │ │ └── returns: primitive:any - │ ├─┬ UseCalcBase class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ hello() method - │ │ └── returns: class:@scope/jsii-calc-base.Base - │ ├─┬ UsesInterfaceWithProperties class - │ │ └─┬ members - │ │ ├─┬ (obj) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ obj - │ │ │ │ └── type: interface:jsii-calc.InterfaceWithProperties - │ │ │ └── returns: void - │ │ ├─┬ justRead() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ readStringAndNumber(ext) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ ext - │ │ │ │ └── type: interface:jsii-calc.InterfaceWithPropertiesExtension - │ │ │ └── returns: primitive:string - │ │ ├─┬ writeAndRead(value) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ value - │ │ │ │ └── type: primitive:string - │ │ │ └── returns: primitive:string - │ │ └─┬ obj property - │ │ ├── immutable - │ │ └── type: interface:jsii-calc.InterfaceWithProperties - │ ├─┬ VariadicMethod class - │ │ └─┬ members - │ │ ├─┬ (prefix) method - │ │ │ ├── variadic - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ prefix - │ │ │ │ ├── type: primitive:number - │ │ │ │ └── variadic - │ │ │ └── returns: void - │ │ └─┬ asArray(first,others) method - │ │ ├── variadic - │ │ ├─┬ parameters - │ │ │ ├─┬ first - │ │ │ │ └── type: primitive:number - │ │ │ └─┬ others - │ │ │ ├── type: primitive:number - │ │ │ └── variadic - │ │ └── returns: Array - │ ├─┬ VirtualMethodPlayground class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ overrideMeAsync(index) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ index - │ │ │ │ └── type: primitive:number - │ │ │ └── returns: primitive:number (promise) - │ │ ├─┬ overrideMeSync(index) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ index - │ │ │ │ └── type: primitive:number - │ │ │ └── returns: primitive:number - │ │ ├─┬ parallelSumAsync(count) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ count - │ │ │ │ └── type: primitive:number - │ │ │ └── returns: primitive:number (promise) - │ │ ├─┬ serialSumAsync(count) method - │ │ │ ├─┬ parameters - │ │ │ │ └─┬ count - │ │ │ │ └── type: primitive:number - │ │ │ └── returns: primitive:number (promise) - │ │ └─┬ sumSync(count) method - │ │ ├─┬ parameters - │ │ │ └─┬ count - │ │ │ └── type: primitive:number - │ │ └── returns: primitive:number - │ ├─┬ CompositeOperation class - │ │ ├── base: Operation - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ ├─┬ toString() method - │ │ │ └── returns: primitive:string - │ │ ├─┬ expression property - │ │ │ ├── abstract - │ │ │ ├── immutable - │ │ │ └── type: class:@scope/jsii-calc-lib.Value - │ │ ├─┬ value property - │ │ │ ├── immutable - │ │ │ └── type: primitive:number - │ │ ├─┬ decorationPostfixes property - │ │ │ └── type: Array - │ │ ├─┬ decorationPrefixes property - │ │ │ └── type: Array - │ │ └─┬ stringStyle property - │ │ └── type: enum:jsii-calc.composition.CompositeOperation.CompositionStringStyle - │ ├─┬ CalculatorProps interface - │ │ └─┬ members - │ │ ├─┬ initialValue property - │ │ │ ├── abstract - │ │ │ └── type: primitive:number (optional) - │ │ └─┬ maximumValue property - │ │ ├── abstract - │ │ └── type: primitive:number (optional) - │ ├─┬ DerivedStruct interface - │ │ ├─┬ interfaces - │ │ │ └── MyFirstStruct - │ │ └─┬ members - │ │ ├─┬ anotherRequired property - │ │ │ ├── abstract - │ │ │ └── type: primitive:date - │ │ ├─┬ bool property - │ │ │ ├── abstract - │ │ │ └── type: primitive:boolean - │ │ ├─┬ nonPrimitive property - │ │ │ ├── abstract - │ │ │ └── type: class:jsii-calc.DoubleTrouble - │ │ ├─┬ anotherOptional property - │ │ │ ├── abstract - │ │ │ └── type: Map class:@scope/jsii-calc-lib.Value> - │ │ ├─┬ optionalAny property - │ │ │ ├── abstract - │ │ │ └── type: primitive:any (optional) - │ │ └─┬ optionalArray property - │ │ ├── abstract - │ │ └── type: Array - │ ├─┬ IFriendlier interface - │ │ ├─┬ interfaces - │ │ │ └── IFriendly - │ │ └─┬ members - │ │ ├─┬ farewell() method - │ │ │ ├── abstract - │ │ │ └── returns: primitive:string - │ │ └─┬ goodbye() method - │ │ ├── abstract - │ │ └── returns: primitive:string - │ ├─┬ IFriendlyRandomGenerator interface - │ │ ├─┬ interfaces - │ │ │ ├── IRandomNumberGenerator - │ │ │ └── IFriendly - │ │ └── members - │ ├─┬ IInterfaceThatShouldNotBeADataType interface - │ │ ├─┬ interfaces - │ │ │ └── IInterfaceWithMethods - │ │ └─┬ members - │ │ └─┬ otherValue property - │ │ ├── abstract - │ │ ├── immutable - │ │ └── type: primitive:string - │ ├─┬ IInterfaceWithMethods interface - │ │ └─┬ members - │ │ ├─┬ doThings() method - │ │ │ ├── abstract - │ │ │ └── returns: void - │ │ └─┬ value property - │ │ ├── abstract - │ │ ├── immutable - │ │ └── type: primitive:string - │ ├─┬ IInterfaceWithOptionalMethodArguments interface - │ │ └─┬ members - │ │ └─┬ hello(arg1,arg2) method - │ │ ├── abstract - │ │ ├─┬ parameters - │ │ │ ├─┬ arg1 - │ │ │ │ └── type: primitive:string - │ │ │ └─┬ arg2 - │ │ │ └── type: primitive:number (optional) - │ │ └── returns: void - │ ├─┬ IPrivatelyImplemented interface - │ │ └─┬ members - │ │ └─┬ success property - │ │ ├── abstract - │ │ ├── immutable - │ │ └── type: primitive:boolean - │ ├─┬ IRandomNumberGenerator interface - │ │ └─┬ members - │ │ └─┬ next() method - │ │ ├── abstract - │ │ └── returns: primitive:number - │ ├─┬ IReturnsNumber interface - │ │ └─┬ members - │ │ ├─┬ obtainNumber() method - │ │ │ ├── abstract - │ │ │ └── returns: interface:@scope/jsii-calc-lib.IDoublable - │ │ └─┬ numberProp property - │ │ ├── abstract - │ │ ├── immutable - │ │ └── type: class:@scope/jsii-calc-lib.Number - │ ├─┬ ImplictBaseOfBase interface - │ │ ├─┬ interfaces - │ │ │ └── BaseProps - │ │ └─┬ members - │ │ └─┬ goo property - │ │ ├── abstract - │ │ └── type: primitive:date - │ ├─┬ InterfaceImplementedByAbstractClass interface - │ │ └─┬ members - │ │ └─┬ propFromInterface property - │ │ ├── abstract - │ │ ├── immutable - │ │ └── type: primitive:string - │ ├─┬ Hello interface - │ │ └─┬ members - │ │ └─┬ foo property - │ │ ├── abstract - │ │ └── type: primitive:number - │ ├─┬ Hello interface - │ │ └─┬ members - │ │ └─┬ foo property - │ │ ├── abstract - │ │ └── type: primitive:number - │ ├─┬ InterfaceWithProperties interface - │ │ └─┬ members - │ │ ├─┬ readOnlyString property - │ │ │ ├── abstract - │ │ │ ├── immutable - │ │ │ └── type: primitive:string - │ │ └─┬ readWriteString property - │ │ ├── abstract - │ │ └── type: primitive:string - │ ├─┬ InterfaceWithPropertiesExtension interface - │ │ ├─┬ interfaces - │ │ │ └── InterfaceWithProperties - │ │ └─┬ members - │ │ └─┬ foo property - │ │ ├── abstract - │ │ └── type: primitive:number - │ ├─┬ LoadBalancedFargateServiceProps interface - │ │ └─┬ members - │ │ ├─┬ containerPort property - │ │ │ ├── abstract - │ │ │ └── type: primitive:number (optional) - │ │ ├─┬ cpu property - │ │ │ ├── abstract - │ │ │ └── type: primitive:string (optional) - │ │ ├─┬ memoryMiB property - │ │ │ ├── abstract - │ │ │ └── type: primitive:string (optional) - │ │ ├─┬ publicLoadBalancer property - │ │ │ ├── abstract - │ │ │ └── type: primitive:boolean (optional) - │ │ └─┬ publicTasks property - │ │ ├── abstract - │ │ └── type: primitive:boolean (optional) - │ ├─┬ MutableObjectLiteral interface - │ │ └─┬ members - │ │ └─┬ value property - │ │ ├── abstract - │ │ └── type: primitive:string - │ ├─┬ NullShouldBeTreatedAsUndefinedData interface - │ │ └─┬ members - │ │ ├─┬ arrayWithThreeElementsAndUndefinedAsSecondArgument property - │ │ │ ├── abstract - │ │ │ └── type: Array - │ │ └─┬ thisShouldBeUndefined property - │ │ ├── abstract - │ │ └── type: primitive:any (optional) - │ ├─┬ UnionProperties interface - │ │ └─┬ members - │ │ ├─┬ bar property - │ │ │ ├── abstract - │ │ │ ├── immutable - │ │ │ └── type: primitive:string | primitive:number | class:jsii-calc.AllTypes - │ │ └─┬ foo property - │ │ ├── abstract - │ │ └── type: primitive:string | primitive:number - │ ├─┬ AllTypesEnum enum - │ │ ├── MY_ENUM_VALUE - │ │ ├── YOUR_ENUM_VALUE - │ │ └── THIS_IS_GREAT - │ ├─┬ StringEnum enum - │ │ ├── A - │ │ ├── B - │ │ └── C - │ └─┬ CompositionStringStyle enum - │ ├── NORMAL - │ └── DECORATED - ├─┬ @scope/jsii-calc-base - │ ├─┬ dependencies - │ │ └── @scope/jsii-calc-base-of-base - │ └─┬ types - │ ├─┬ Base class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ typeName() method - │ │ └── returns: primitive:any - │ └─┬ BaseProps interface - │ ├─┬ interfaces - │ │ └── VeryBaseProps - │ └─┬ members - │ └─┬ bar property - │ ├── abstract - │ └── type: primitive:string - ├─┬ @scope/jsii-calc-base-of-base - │ └─┬ types - │ ├─┬ Very class - │ │ └─┬ members - │ │ ├─┬ () method - │ │ │ └── returns: void - │ │ └─┬ hey() method - │ │ └── returns: primitive:number - │ └─┬ VeryBaseProps interface - │ └─┬ members - │ └─┬ foo property - │ ├── abstract - │ └── type: class:@scope/jsii-calc-base-of-base.Very - └─┬ @scope/jsii-calc-lib - ├─┬ dependencies - │ └── @scope/jsii-calc-base - └─┬ types - ├─┬ Number class - │ ├── base: Value - │ ├── interfaces: IDoublable - │ └─┬ members - │ ├─┬ (value) method - │ │ ├─┬ parameters - │ │ │ └─┬ value - │ │ │ └── type: primitive:number - │ │ └── returns: void - │ ├─┬ doubleValue property - │ │ ├── immutable - │ │ └── type: primitive:number - │ └─┬ value property - │ ├── immutable - │ └── type: primitive:number - ├─┬ Operation class - │ ├── base: Value - │ └─┬ members - │ ├─┬ () method - │ │ └── returns: void - │ └─┬ toString() method - │ ├── abstract - │ └── returns: primitive:string - ├─┬ Value class - │ ├── base: Base - │ └─┬ members - │ ├─┬ () method - │ │ └── returns: void - │ ├─┬ toString() method - │ │ └── returns: primitive:string - │ └─┬ value property - │ ├── abstract - │ ├── immutable - │ └── type: primitive:number - ├─┬ IDoublable interface - │ └─┬ members - │ └─┬ doubleValue property - │ ├── abstract - │ ├── immutable - │ └── type: primitive:number - ├─┬ IFriendly interface - │ └─┬ members - │ └─┬ hello() method - │ ├── abstract - │ └── returns: primitive:string - ├─┬ MyFirstStruct interface - │ └─┬ members - │ ├─┬ anumber property - │ │ ├── abstract - │ │ └── type: primitive:number - │ ├─┬ astring property - │ │ ├── abstract - │ │ └── type: primitive:string - │ └─┬ firstOptional property - │ ├── abstract - │ └── type: Array - ├─┬ StructWithOnlyOptionals interface - │ └─┬ members - │ ├─┬ optional1 property - │ │ ├── abstract - │ │ └── type: primitive:string (optional) - │ ├─┬ optional2 property - │ │ ├── abstract - │ │ └── type: primitive:number (optional) - │ └─┬ optional3 property - │ ├── abstract - │ └── type: primitive:boolean (optional) - └─┬ EnumFromScopedModule enum - ├── VALUE1 - └── VALUE2 diff --git a/packages/jsii-reflect/jsii-tree.test.stdout b/packages/jsii-reflect/jsii-tree.test.stdout deleted file mode 100644 index 195636909e..0000000000 --- a/packages/jsii-reflect/jsii-tree.test.stdout +++ /dev/null @@ -1,5 +0,0 @@ -assemblies - ├── jsii-calc - ├── @scope/jsii-calc-base - ├── @scope/jsii-calc-base-of-base - └── @scope/jsii-calc-lib diff --git a/packages/jsii-reflect/lib/assembly.ts b/packages/jsii-reflect/lib/assembly.ts index 92f0425be4..e075600a10 100644 --- a/packages/jsii-reflect/lib/assembly.ts +++ b/packages/jsii-reflect/lib/assembly.ts @@ -2,17 +2,24 @@ import * as jsii from '@jsii/spec'; import { ClassType } from './class'; import { Dependency } from './dependency'; import { EnumType } from './enum'; +import { ModuleLike } from './module-like'; import { InterfaceType } from './interface'; +import { Submodule } from './submodule'; import { Type } from './type'; import { TypeSystem } from './type-system'; -export class Assembly { +export class Assembly extends ModuleLike { private _typeCache?: { [fqn: string]: Type }; + private _submoduleCache?: { [fqn: string]: Submodule }; private _dependencyCache?: { [name: string]: Dependency }; - public constructor( - public readonly system: TypeSystem, - public readonly spec: jsii.Assembly) { } + public constructor(system: TypeSystem, public readonly spec: jsii.Assembly) { + super(system); + } + + public get fqn(): string { + return this.spec.name; + } /** * The version of the spec schema @@ -54,7 +61,7 @@ export class Assembly { * The module repository, maps to "repository" from package.json * This is required since some package managers (like Maven) require it. */ - public get repository(): { type: string, url: string, directory?: string } { + public get repository(): { readonly type: string, readonly url: string, readonly directory?: string } { return this.spec.repository; } @@ -68,7 +75,7 @@ export class Assembly { /** * Additional contributors to this package. */ - public get contributors(): jsii.Person[] { + public get contributors(): readonly jsii.Person[] { return this.spec.contributors ?? []; } @@ -104,7 +111,7 @@ export class Assembly { /** * Dependencies on other assemblies (with semver), the key is the JSII assembly name. */ - public get dependencies(): Dependency[] { + public get dependencies(): readonly Dependency[] { return Object.keys(this._dependencies).map(name => this._dependencies[name]); } @@ -119,7 +126,7 @@ export class Assembly { /** * List if bundled dependencies (these are not expected to be jsii assemblies). */ - public get bundled(): { [module: string]: string } { + public get bundled(): { readonly [module: string]: string } { return this.spec.bundled ?? { }; } @@ -130,37 +137,27 @@ export class Assembly { return this.spec.readme; } - /** - * All types in the assembly, keyed by their fully-qualified-name - */ - public get types(): Type[] { - return Object.keys(this._types).map(key => this._types[key]); + public get submodules(): readonly Submodule[] { + const { submodules } = this._types; + return Object.values(submodules); } - public get classes(): ClassType[] { - return this.types.filter(t => t instanceof ClassType).map(t => t as ClassType); - } - - public get interfaces(): InterfaceType[] { - return this.types.filter(t => t instanceof InterfaceType).map(t => t as InterfaceType); - } - - public get enums(): EnumType[] { - return this.types.filter(t => t instanceof EnumType).map(t => t as EnumType); + /** + * All types in the assembly + */ + public get types(): readonly Type[] { + const { types } = this._types; + return Object.values(types); } public findType(fqn: string) { - const type = this._types[fqn]; + const type = this.tryFindType(fqn); if (!type) { throw new Error(`Type '${fqn}' not found in assembly ${this.name}`); } return type; } - public tryFindType(fqn: string): Type | undefined { - return this._types[fqn]; - } - /** * Validate an assembly after loading * @@ -185,31 +182,70 @@ export class Assembly { } private get _types() { - if (!this._typeCache) { - this._typeCache = { }; + if (!this._typeCache || !this._submoduleCache) { + this._typeCache = {}; + + const submodules: { [fullName: string]: SubmoduleMap } = {}; const ts = this.spec.types ?? { }; for (const fqn of Object.keys(ts)) { - const type = ts[fqn]; - switch (type.kind) { + const typeSpec = ts[fqn]; + + let submodule = typeSpec.namespace; + while (submodule != null && `${this.spec.name}.${submodule}` in ts) { + submodule = ts[`${this.spec.name}.${submodule}`].namespace; + } + + let type: Type; + switch (typeSpec.kind) { case jsii.TypeKind.Class: - this._typeCache[fqn] = new ClassType(this.system, this, type); + type = new ClassType(this.system, this, typeSpec); break; case jsii.TypeKind.Interface: - this._typeCache[fqn] = new InterfaceType(this.system, this, type); + type = new InterfaceType(this.system, this, typeSpec); break; case jsii.TypeKind.Enum: - this._typeCache[fqn] = new EnumType(this.system, this, type); + type = new EnumType(this.system, this, typeSpec); break; default: throw new Error('Unknown type kind'); } + + if (submodule != null) { + const [root, ...parts] = submodule.split('.'); + let container = submodules[root] = submodules[root] ?? { submodules: {}, types: [] }; + for (const part of parts) { + container = container.submodules[part] = container.submodules[part] ?? { submodules: {}, types: [] }; + } + container.types.push(type); + } else { + this._typeCache[fqn] = type; + } + } + + this._submoduleCache = {}; + for (const [name, map] of Object.entries(submodules)) { + this._submoduleCache[name] = makeSubmodule(this.system, map, `${this.name}.${name}`); } } - return this._typeCache; + return { types: this._typeCache, submodules: this._submoduleCache }; } } + +interface SubmoduleMap { + readonly submodules: { [fullName: string]: SubmoduleMap }; + readonly types: Type[]; +} + +function makeSubmodule(system: TypeSystem, map: SubmoduleMap, fullName: string): Submodule { + return new Submodule( + system, + fullName, + Object.entries(map.submodules).map(([name, subMap]) => makeSubmodule(system, subMap, `${fullName}.${name}`)), + map.types, + ); +} diff --git a/packages/jsii-reflect/lib/index.ts b/packages/jsii-reflect/lib/index.ts index 211c90b020..5a6711367f 100644 --- a/packages/jsii-reflect/lib/index.ts +++ b/packages/jsii-reflect/lib/index.ts @@ -7,10 +7,12 @@ export * from './enum'; export * from './initializer'; export * from './interface'; export * from './method'; +export * from './module-like'; export * from './optional-value'; export * from './overridable'; export * from './parameter'; export * from './property'; +export * from './submodule'; export * from './tree'; export * from './type'; export * from './type-member'; diff --git a/packages/jsii-reflect/lib/module-like.ts b/packages/jsii-reflect/lib/module-like.ts new file mode 100644 index 0000000000..88e81970ee --- /dev/null +++ b/packages/jsii-reflect/lib/module-like.ts @@ -0,0 +1,41 @@ +import { ClassType } from './class'; +import { EnumType } from './enum'; +import { InterfaceType } from './interface'; +import { Submodule } from './submodule'; +import { Type } from './type'; +import { TypeSystem } from './type-system'; + +export abstract class ModuleLike { + public abstract readonly fqn: string; + public abstract readonly submodules: readonly Submodule[]; + public abstract readonly types: readonly Type[]; + + protected constructor(public readonly system: TypeSystem) { } + + public get classes(): readonly ClassType[] { + return this.types.filter(t => t instanceof ClassType).map(t => t as ClassType); + } + + public get interfaces(): readonly InterfaceType[] { + return this.types.filter(t => t instanceof InterfaceType).map(t => t as InterfaceType); + } + + public get enums(): readonly EnumType[] { + return this.types.filter(t => t instanceof EnumType).map(t => t as EnumType); + } + + public tryFindType(fqn: string): Type | undefined { + const ownType = this.types.find(type => type.fqn === fqn); + if (ownType != null) { + return ownType; + } + + if (!fqn.startsWith(`${this.fqn}.`)) { + return undefined; + } + + const [subName] = fqn.slice(this.fqn.length + 1).split('.'); + const sub = this.submodules.find(sub => sub.name === subName); + return sub?.tryFindType(fqn); + } +} diff --git a/packages/jsii-reflect/lib/submodule.ts b/packages/jsii-reflect/lib/submodule.ts new file mode 100644 index 0000000000..07b183edf9 --- /dev/null +++ b/packages/jsii-reflect/lib/submodule.ts @@ -0,0 +1,21 @@ +import { ModuleLike } from './module-like'; +import { Type } from './type'; +import { TypeSystem } from './type-system'; + +export class Submodule extends ModuleLike { + /** + * The simple name of the submodule (the last segment of the `fullName`). + */ + public readonly name: string; + + public constructor( + system: TypeSystem, + public readonly fqn: string, + public readonly submodules: readonly Submodule[], + public readonly types: readonly Type[], + ) { + super(system); + + this.name = fqn.split('.').pop()!; + } +} diff --git a/packages/jsii-reflect/lib/tree.ts b/packages/jsii-reflect/lib/tree.ts index 5276ed9c9b..cb55ab98d6 100644 --- a/packages/jsii-reflect/lib/tree.ts +++ b/packages/jsii-reflect/lib/tree.ts @@ -13,6 +13,7 @@ import { OptionalValue } from './optional-value'; import { Parameter } from './parameter'; import { Property } from './property'; import { TypeSystem } from './type-system'; +import { Submodule } from './submodule'; export interface TypeSystemTreeOptions { /** @@ -101,6 +102,13 @@ class AssemblyNode extends AsciiTree { deps.add(...assembly.dependencies.map(d => new DependencyNode(d, options))); } + const submodules = assembly.submodules; + if (submodules.length > 0) { + const title = new TitleNode('submodules'); + this.add(title); + title.add(...submodules.map(s => new SubmoduleNode(s, options))); + } + if (options.types) { const types = new TitleNode('types'); this.add(types); @@ -111,6 +119,27 @@ class AssemblyNode extends AsciiTree { } } +class SubmoduleNode extends AsciiTree { + public constructor(submodule: Submodule, options: TypeSystemTreeOptions) { + super(colors.green(submodule.name)); + + const submodules = submodule.submodules; + if (submodules.length > 0) { + const title = new TitleNode('submodules'); + this.add(title); + title.add(...submodules.map(s => new SubmoduleNode(s, options))); + } + + if (options.types) { + const types = new TitleNode('types'); + this.add(types); + types.add(...submodule.classes.map(c => new ClassNode(c, options))); + types.add(...submodule.interfaces.map(i => new InterfaceNode(i, options))); + types.add(...submodule.enums.map(e => new EnumNode(e, options))); + } + } +} + class MethodNode extends AsciiTree { public constructor(method: Method, options: TypeSystemTreeOptions) { const args = method.parameters.map(p => p.name).join(','); diff --git a/packages/jsii-reflect/lib/type-system.ts b/packages/jsii-reflect/lib/type-system.ts index 8ca951d264..cfafcbe852 100644 --- a/packages/jsii-reflect/lib/type-system.ts +++ b/packages/jsii-reflect/lib/type-system.ts @@ -7,6 +7,7 @@ import { ClassType } from './class'; import { EnumType } from './enum'; import { InterfaceType } from './interface'; import { Method } from './method'; +import { ModuleLike } from './module-like'; import { Property } from './property'; import { Type } from './type'; @@ -227,26 +228,26 @@ export class TypeSystem { return out; } - public get classes() { + public get classes(): readonly ClassType[] { const out = new Array(); this.assemblies.forEach(a => { - out.push(...a.classes); + out.push(...collectTypes(a, item => item.classes)); }); return out; } - public get interfaces() { + public get interfaces(): readonly InterfaceType[] { const out = new Array(); this.assemblies.forEach(a => { - out.push(...a.interfaces); + out.push(...collectTypes(a, item => item.interfaces)); }); return out; } - public get enums() { + public get enums(): readonly EnumType[] { const out = new Array(); this.assemblies.forEach(a => { - out.push(...a.enums); + out.push(...collectTypes(a, item => item.enums)); }); return out; } @@ -275,3 +276,12 @@ function dependenciesOf(packageJson: any) { Object.keys(packageJson.peerDependencies ?? {}).forEach(deps.add.bind(deps)); return Array.from(deps); } + +function collectTypes(module: ModuleLike, getter: (module: ModuleLike) => readonly T[]): readonly T[] { + const result = new Array(); + for (const submodule of module.submodules) { + result.push(...collectTypes(submodule, getter)); + } + result.push(...getter(module)); + return result; +} diff --git a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap index 922cd1bce4..bcd8bd6335 100644 --- a/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap @@ -7,6 +7,119 @@ exports[`jsii-tree --all 1`] = ` │ │ ├── @scope/jsii-calc-base │ │ ├── @scope/jsii-calc-base-of-base │ │ └── @scope/jsii-calc-lib + │ ├─┬ submodules + │ │ ├─┬ DerivedClassHasNoProperties + │ │ │ └─┬ types + │ │ │ ├─┬ class Base (experimental) + │ │ │ │ └─┬ members + │ │ │ │ ├── () initializer (experimental) + │ │ │ │ └─┬ prop property (experimental) + │ │ │ │ └── type: string + │ │ │ └─┬ class Derived (experimental) + │ │ │ ├── base: Base + │ │ │ └─┬ members + │ │ │ └── () initializer (experimental) + │ │ ├─┬ InterfaceInNamespaceIncludesClasses + │ │ │ └─┬ types + │ │ │ ├─┬ class Foo (experimental) + │ │ │ │ └─┬ members + │ │ │ │ ├── () initializer (experimental) + │ │ │ │ └─┬ bar property (experimental) + │ │ │ │ └── type: Optional + │ │ │ └─┬ interface Hello (experimental) + │ │ │ └─┬ members + │ │ │ └─┬ foo property (experimental) + │ │ │ ├── abstract + │ │ │ ├── immutable + │ │ │ └── type: number + │ │ ├─┬ InterfaceInNamespaceOnlyInterface + │ │ │ └─┬ types + │ │ │ └─┬ interface Hello (experimental) + │ │ │ └─┬ members + │ │ │ └─┬ foo property (experimental) + │ │ │ ├── abstract + │ │ │ ├── immutable + │ │ │ └── type: number + │ │ ├─┬ composition + │ │ │ └─┬ types + │ │ │ ├─┬ class CompositeOperation (experimental) + │ │ │ │ ├── base: Operation + │ │ │ │ └─┬ members + │ │ │ │ ├── () initializer (experimental) + │ │ │ │ ├─┬ toString() method (experimental) + │ │ │ │ │ └── returns: string + │ │ │ │ ├─┬ expression property (experimental) + │ │ │ │ │ ├── abstract + │ │ │ │ │ ├── immutable + │ │ │ │ │ └── type: @scope/jsii-calc-lib.Value + │ │ │ │ ├─┬ value property (experimental) + │ │ │ │ │ ├── immutable + │ │ │ │ │ └── type: number + │ │ │ │ ├─┬ decorationPostfixes property (experimental) + │ │ │ │ │ └── type: Array + │ │ │ │ ├─┬ decorationPrefixes property (experimental) + │ │ │ │ │ └── type: Array + │ │ │ │ └─┬ stringStyle property (experimental) + │ │ │ │ └── type: jsii-calc.composition.CompositeOperation.CompositionStringStyle + │ │ │ └─┬ enum CompositionStringStyle (experimental) + │ │ │ ├── NORMAL (experimental) + │ │ │ └── DECORATED (experimental) + │ │ └─┬ submodule + │ │ ├─┬ submodules + │ │ │ ├─┬ back_references + │ │ │ │ └─┬ types + │ │ │ │ └─┬ interface MyClassReference (experimental) + │ │ │ │ └─┬ members + │ │ │ │ └─┬ reference property (experimental) + │ │ │ │ ├── abstract + │ │ │ │ ├── immutable + │ │ │ │ └── type: jsii-calc.submodule.MyClass + │ │ │ ├─┬ child + │ │ │ │ └─┬ types + │ │ │ │ ├─┬ interface Structure (experimental) + │ │ │ │ │ └─┬ members + │ │ │ │ │ └─┬ bool property (experimental) + │ │ │ │ │ ├── abstract + │ │ │ │ │ ├── immutable + │ │ │ │ │ └── type: boolean + │ │ │ │ └─┬ enum Goodness (experimental) + │ │ │ │ ├── PRETTY_GOOD (experimental) + │ │ │ │ ├── REALLY_GOOD (experimental) + │ │ │ │ └── AMAZINGLY_GOOD (experimental) + │ │ │ └─┬ nested_submodule + │ │ │ ├─┬ submodules + │ │ │ │ └─┬ deeplyNested + │ │ │ │ └─┬ types + │ │ │ │ └─┬ interface INamespaced (experimental) + │ │ │ │ └─┬ members + │ │ │ │ └─┬ definedAt property (experimental) + │ │ │ │ ├── abstract + │ │ │ │ ├── immutable + │ │ │ │ └── type: string + │ │ │ └─┬ types + │ │ │ └─┬ class Namespaced (experimental) + │ │ │ ├── interfaces: INamespaced + │ │ │ └─┬ members + │ │ │ ├─┬ definedAt property (experimental) + │ │ │ │ ├── immutable + │ │ │ │ └── type: string + │ │ │ └─┬ goodness property (experimental) + │ │ │ ├── abstract + │ │ │ ├── immutable + │ │ │ └── type: jsii-calc.submodule.child.Goodness + │ │ └─┬ types + │ │ └─┬ class MyClass (experimental) + │ │ ├── interfaces: INamespaced + │ │ └─┬ members + │ │ ├── () initializer (experimental) + │ │ ├─┬ definedAt property (experimental) + │ │ │ ├── immutable + │ │ │ └── type: string + │ │ ├─┬ goodness property (experimental) + │ │ │ ├── immutable + │ │ │ └── type: jsii-calc.submodule.child.Goodness + │ │ └─┬ allTypes property (experimental) + │ │ └── type: Optional │ └─┬ types │ ├─┬ class AbstractClass (experimental) │ │ ├── base: AbstractClassBase @@ -531,15 +644,6 @@ exports[`jsii-tree --all 1`] = ` │ │ │ └── type: string │ │ └─┬ mutableProperty property (deprecated) │ │ └── type: Optional - │ ├─┬ class Base (experimental) - │ │ └─┬ members - │ │ ├── () initializer (experimental) - │ │ └─┬ prop property (experimental) - │ │ └── type: string - │ ├─┬ class Derived (experimental) - │ │ ├── base: Base - │ │ └─┬ members - │ │ └── () initializer (experimental) │ ├─┬ class DisappointingCollectionSource (experimental) │ │ └─┬ members │ │ ├─┬ static maybeList property (experimental) @@ -731,11 +835,6 @@ exports[`jsii-tree --all 1`] = ` │ │ └─┬ static mapOfStructs() method (experimental) │ │ ├── static │ │ └── returns: Map jsii-calc.StructA> - │ ├─┬ class Foo (experimental) - │ │ └─┬ members - │ │ ├── () initializer (experimental) - │ │ └─┬ bar property (experimental) - │ │ └── type: Optional │ ├─┬ class InterfacesMaker (experimental) │ │ └─┬ members │ │ └─┬ static makeInterfaces(count) method (experimental) @@ -1674,25 +1773,6 @@ exports[`jsii-tree --all 1`] = ` │ │ └─┬ success property (experimental) │ │ ├── immutable │ │ └── type: boolean - │ ├─┬ class CompositeOperation (experimental) - │ │ ├── base: Operation - │ │ └─┬ members - │ │ ├── () initializer (experimental) - │ │ ├─┬ toString() method (experimental) - │ │ │ └── returns: string - │ │ ├─┬ expression property (experimental) - │ │ │ ├── abstract - │ │ │ ├── immutable - │ │ │ └── type: @scope/jsii-calc-lib.Value - │ │ ├─┬ value property (experimental) - │ │ │ ├── immutable - │ │ │ └── type: number - │ │ ├─┬ decorationPostfixes property (experimental) - │ │ │ └── type: Array - │ │ ├─┬ decorationPrefixes property (experimental) - │ │ │ └── type: Array - │ │ └─┬ stringStyle property (experimental) - │ │ └── type: jsii-calc.composition.CompositeOperation.CompositionStringStyle │ ├─┬ interface CalculatorProps (experimental) │ │ └─┬ members │ │ ├─┬ initialValue property (experimental) @@ -2065,18 +2145,6 @@ exports[`jsii-tree --all 1`] = ` │ │ ├── abstract │ │ ├── immutable │ │ └── type: date - │ ├─┬ interface Hello (experimental) - │ │ └─┬ members - │ │ └─┬ foo property (experimental) - │ │ ├── abstract - │ │ ├── immutable - │ │ └── type: number - │ ├─┬ interface Hello (experimental) - │ │ └─┬ members - │ │ └─┬ foo property (experimental) - │ │ ├── abstract - │ │ ├── immutable - │ │ └── type: number │ ├─┬ interface LoadBalancedFargateServiceProps (experimental) │ │ └─┬ members │ │ ├─┬ containerPort property (experimental) @@ -2270,13 +2338,10 @@ exports[`jsii-tree --all 1`] = ` │ ├─┬ enum StableEnum (stable) │ │ ├── OPTION_A (stable) │ │ └── OPTION_B (stable) - │ ├─┬ enum StringEnum (experimental) - │ │ ├── A (experimental) - │ │ ├── B (experimental) - │ │ └── C (experimental) - │ └─┬ enum CompositionStringStyle (experimental) - │ ├── NORMAL (experimental) - │ └── DECORATED (experimental) + │ └─┬ enum StringEnum (experimental) + │ ├── A (experimental) + │ ├── B (experimental) + │ └── C (experimental) ├─┬ @scope/jsii-calc-base │ ├─┬ dependencies │ │ └── @scope/jsii-calc-base-of-base @@ -2410,6 +2475,44 @@ exports[`jsii-tree --all 1`] = ` exports[`jsii-tree --inheritance 1`] = ` "assemblies ├─┬ jsii-calc + │ ├─┬ submodules + │ │ ├─┬ DerivedClassHasNoProperties + │ │ │ └─┬ types + │ │ │ ├── class Base + │ │ │ └─┬ class Derived + │ │ │ └── base: Base + │ │ ├─┬ InterfaceInNamespaceIncludesClasses + │ │ │ └─┬ types + │ │ │ ├── class Foo + │ │ │ └── interface Hello + │ │ ├─┬ InterfaceInNamespaceOnlyInterface + │ │ │ └─┬ types + │ │ │ └── interface Hello + │ │ ├─┬ composition + │ │ │ └─┬ types + │ │ │ ├─┬ class CompositeOperation + │ │ │ │ └── base: Operation + │ │ │ └── enum CompositionStringStyle + │ │ └─┬ submodule + │ │ ├─┬ submodules + │ │ │ ├─┬ back_references + │ │ │ │ └─┬ types + │ │ │ │ └── interface MyClassReference + │ │ │ ├─┬ child + │ │ │ │ └─┬ types + │ │ │ │ ├── interface Structure + │ │ │ │ └── enum Goodness + │ │ │ └─┬ nested_submodule + │ │ │ ├─┬ submodules + │ │ │ │ └─┬ deeplyNested + │ │ │ │ └─┬ types + │ │ │ │ └── interface INamespaced + │ │ │ └─┬ types + │ │ │ └─┬ class Namespaced + │ │ │ └── interfaces: INamespaced + │ │ └─┬ types + │ │ └─┬ class MyClass + │ │ └── interfaces: INamespaced │ └─┬ types │ ├─┬ class AbstractClass │ │ ├── base: AbstractClassBase @@ -2454,9 +2557,6 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├── class DefaultedConstructorArgument │ ├── class Demonstrate982 │ ├── class DeprecatedClass - │ ├── class Base - │ ├─┬ class Derived - │ │ └── base: Base │ ├── class DisappointingCollectionSource │ ├── class DoNotOverridePrivates │ ├── class DoNotRecognizeAnyAsOptional @@ -2481,7 +2581,6 @@ exports[`jsii-tree --inheritance 1`] = ` │ │ ├── base: PublicClass │ │ └── interfaces: IPublicInterface2 │ ├── class InterfaceCollections - │ ├── class Foo │ ├── class InterfacesMaker │ ├─┬ class JSII417Derived │ │ └── base: JSII417PublicBaseOfBase @@ -2552,8 +2651,6 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├── class VirtualMethodPlayground │ ├── class VoidCallback │ ├── class WithPrivatePropertyInConstructor - │ ├─┬ class CompositeOperation - │ │ └── base: Operation │ ├── interface CalculatorProps │ ├─┬ interface ChildStruct982 │ │ └─┬ interfaces @@ -2629,8 +2726,6 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├─┬ interface ImplictBaseOfBase │ │ └─┬ interfaces │ │ └── BaseProps - │ ├── interface Hello - │ ├── interface Hello │ ├── interface LoadBalancedFargateServiceProps │ ├── interface NestedStruct │ ├── interface NullShouldBeTreatedAsUndefinedData @@ -2653,8 +2748,7 @@ exports[`jsii-tree --inheritance 1`] = ` │ ├── enum SingletonIntEnum │ ├── enum SingletonStringEnum │ ├── enum StableEnum - │ ├── enum StringEnum - │ └── enum CompositionStringStyle + │ └── enum StringEnum ├─┬ @scope/jsii-calc-base │ └─┬ types │ ├── class Base @@ -2692,6 +2786,79 @@ exports[`jsii-tree --inheritance 1`] = ` exports[`jsii-tree --members 1`] = ` "assemblies ├─┬ jsii-calc + │ ├─┬ submodules + │ │ ├─┬ DerivedClassHasNoProperties + │ │ │ └─┬ types + │ │ │ ├─┬ class Base + │ │ │ │ └─┬ members + │ │ │ │ ├── () initializer + │ │ │ │ └── prop property + │ │ │ └─┬ class Derived + │ │ │ └─┬ members + │ │ │ └── () initializer + │ │ ├─┬ InterfaceInNamespaceIncludesClasses + │ │ │ └─┬ types + │ │ │ ├─┬ class Foo + │ │ │ │ └─┬ members + │ │ │ │ ├── () initializer + │ │ │ │ └── bar property + │ │ │ └─┬ interface Hello + │ │ │ └─┬ members + │ │ │ └── foo property + │ │ ├─┬ InterfaceInNamespaceOnlyInterface + │ │ │ └─┬ types + │ │ │ └─┬ interface Hello + │ │ │ └─┬ members + │ │ │ └── foo property + │ │ ├─┬ composition + │ │ │ └─┬ types + │ │ │ ├─┬ class CompositeOperation + │ │ │ │ └─┬ members + │ │ │ │ ├── () initializer + │ │ │ │ ├── toString() method + │ │ │ │ ├── expression property + │ │ │ │ ├── value property + │ │ │ │ ├── decorationPostfixes property + │ │ │ │ ├── decorationPrefixes property + │ │ │ │ └── stringStyle property + │ │ │ └─┬ enum CompositionStringStyle + │ │ │ ├── NORMAL + │ │ │ └── DECORATED + │ │ └─┬ submodule + │ │ ├─┬ submodules + │ │ │ ├─┬ back_references + │ │ │ │ └─┬ types + │ │ │ │ └─┬ interface MyClassReference + │ │ │ │ └─┬ members + │ │ │ │ └── reference property + │ │ │ ├─┬ child + │ │ │ │ └─┬ types + │ │ │ │ ├─┬ interface Structure + │ │ │ │ │ └─┬ members + │ │ │ │ │ └── bool property + │ │ │ │ └─┬ enum Goodness + │ │ │ │ ├── PRETTY_GOOD + │ │ │ │ ├── REALLY_GOOD + │ │ │ │ └── AMAZINGLY_GOOD + │ │ │ └─┬ nested_submodule + │ │ │ ├─┬ submodules + │ │ │ │ └─┬ deeplyNested + │ │ │ │ └─┬ types + │ │ │ │ └─┬ interface INamespaced + │ │ │ │ └─┬ members + │ │ │ │ └── definedAt property + │ │ │ └─┬ types + │ │ │ └─┬ class Namespaced + │ │ │ └─┬ members + │ │ │ ├── definedAt property + │ │ │ └── goodness property + │ │ └─┬ types + │ │ └─┬ class MyClass + │ │ └─┬ members + │ │ ├── () initializer + │ │ ├── definedAt property + │ │ ├── goodness property + │ │ └── allTypes property │ └─┬ types │ ├─┬ class AbstractClass │ │ └─┬ members @@ -2905,13 +3072,6 @@ exports[`jsii-tree --members 1`] = ` │ │ ├── method() method │ │ ├── readonlyProperty property │ │ └── mutableProperty property - │ ├─┬ class Base - │ │ └─┬ members - │ │ ├── () initializer - │ │ └── prop property - │ ├─┬ class Derived - │ │ └─┬ members - │ │ └── () initializer │ ├─┬ class DisappointingCollectionSource │ │ └─┬ members │ │ ├── static maybeList property @@ -3000,10 +3160,6 @@ exports[`jsii-tree --members 1`] = ` │ │ ├── static listOfStructs() method │ │ ├── static mapOfInterfaces() method │ │ └── static mapOfStructs() method - │ ├─┬ class Foo - │ │ └─┬ members - │ │ ├── () initializer - │ │ └── bar property │ ├─┬ class InterfacesMaker │ │ └─┬ members │ │ └── static makeInterfaces(count) method @@ -3408,15 +3564,6 @@ exports[`jsii-tree --members 1`] = ` │ │ └─┬ members │ │ ├── (privateField) initializer │ │ └── success property - │ ├─┬ class CompositeOperation - │ │ └─┬ members - │ │ ├── () initializer - │ │ ├── toString() method - │ │ ├── expression property - │ │ ├── value property - │ │ ├── decorationPostfixes property - │ │ ├── decorationPrefixes property - │ │ └── stringStyle property │ ├─┬ interface CalculatorProps │ │ └─┬ members │ │ ├── initialValue property @@ -3583,12 +3730,6 @@ exports[`jsii-tree --members 1`] = ` │ ├─┬ interface ImplictBaseOfBase │ │ └─┬ members │ │ └── goo property - │ ├─┬ interface Hello - │ │ └─┬ members - │ │ └── foo property - │ ├─┬ interface Hello - │ │ └─┬ members - │ │ └── foo property │ ├─┬ interface LoadBalancedFargateServiceProps │ │ └─┬ members │ │ ├── containerPort property @@ -3674,13 +3815,10 @@ exports[`jsii-tree --members 1`] = ` │ ├─┬ enum StableEnum │ │ ├── OPTION_A │ │ └── OPTION_B - │ ├─┬ enum StringEnum - │ │ ├── A - │ │ ├── B - │ │ └── C - │ └─┬ enum CompositionStringStyle - │ ├── NORMAL - │ └── DECORATED + │ └─┬ enum StringEnum + │ ├── A + │ ├── B + │ └── C ├─┬ @scope/jsii-calc-base │ └─┬ types │ ├─┬ class Base @@ -3748,7 +3886,19 @@ exports[`jsii-tree --members 1`] = ` exports[`jsii-tree --signatures 1`] = ` "assemblies - ├── jsii-calc + ├─┬ jsii-calc + │ └─┬ submodules + │ ├── DerivedClassHasNoProperties + │ ├── InterfaceInNamespaceIncludesClasses + │ ├── InterfaceInNamespaceOnlyInterface + │ ├── composition + │ └─┬ submodule + │ └─┬ submodules + │ ├── back_references + │ ├── child + │ └─┬ nested_submodule + │ └─┬ submodules + │ └── deeplyNested ├── @scope/jsii-calc-base ├── @scope/jsii-calc-base-of-base └── @scope/jsii-calc-lib @@ -3758,6 +3908,40 @@ exports[`jsii-tree --signatures 1`] = ` exports[`jsii-tree --types 1`] = ` "assemblies ├─┬ jsii-calc + │ ├─┬ submodules + │ │ ├─┬ DerivedClassHasNoProperties + │ │ │ └─┬ types + │ │ │ ├── class Base + │ │ │ └── class Derived + │ │ ├─┬ InterfaceInNamespaceIncludesClasses + │ │ │ └─┬ types + │ │ │ ├── class Foo + │ │ │ └── interface Hello + │ │ ├─┬ InterfaceInNamespaceOnlyInterface + │ │ │ └─┬ types + │ │ │ └── interface Hello + │ │ ├─┬ composition + │ │ │ └─┬ types + │ │ │ ├── class CompositeOperation + │ │ │ └── enum CompositionStringStyle + │ │ └─┬ submodule + │ │ ├─┬ submodules + │ │ │ ├─┬ back_references + │ │ │ │ └─┬ types + │ │ │ │ └── interface MyClassReference + │ │ │ ├─┬ child + │ │ │ │ └─┬ types + │ │ │ │ ├── interface Structure + │ │ │ │ └── enum Goodness + │ │ │ └─┬ nested_submodule + │ │ │ ├─┬ submodules + │ │ │ │ └─┬ deeplyNested + │ │ │ │ └─┬ types + │ │ │ │ └── interface INamespaced + │ │ │ └─┬ types + │ │ │ └── class Namespaced + │ │ └─┬ types + │ │ └── class MyClass │ └─┬ types │ ├── class AbstractClass │ ├── class AbstractClassBase @@ -3791,8 +3975,6 @@ exports[`jsii-tree --types 1`] = ` │ ├── class DefaultedConstructorArgument │ ├── class Demonstrate982 │ ├── class DeprecatedClass - │ ├── class Base - │ ├── class Derived │ ├── class DisappointingCollectionSource │ ├── class DoNotOverridePrivates │ ├── class DoNotRecognizeAnyAsOptional @@ -3812,7 +3994,6 @@ exports[`jsii-tree --types 1`] = ` │ ├── class ImplementsPrivateInterface │ ├── class InbetweenClass │ ├── class InterfaceCollections - │ ├── class Foo │ ├── class InterfacesMaker │ ├── class JSII417Derived │ ├── class JSII417PublicBaseOfBase @@ -3872,7 +4053,6 @@ exports[`jsii-tree --types 1`] = ` │ ├── class VirtualMethodPlayground │ ├── class VoidCallback │ ├── class WithPrivatePropertyInConstructor - │ ├── class CompositeOperation │ ├── interface CalculatorProps │ ├── interface ChildStruct982 │ ├── interface ConfusingToJacksonStruct @@ -3922,8 +4102,6 @@ exports[`jsii-tree --types 1`] = ` │ ├── interface IStableInterface │ ├── interface IStructReturningDelegate │ ├── interface ImplictBaseOfBase - │ ├── interface Hello - │ ├── interface Hello │ ├── interface LoadBalancedFargateServiceProps │ ├── interface NestedStruct │ ├── interface NullShouldBeTreatedAsUndefinedData @@ -3946,8 +4124,7 @@ exports[`jsii-tree --types 1`] = ` │ ├── enum SingletonIntEnum │ ├── enum SingletonStringEnum │ ├── enum StableEnum - │ ├── enum StringEnum - │ └── enum CompositionStringStyle + │ └── enum StringEnum ├─┬ @scope/jsii-calc-base │ └─┬ types │ ├── class Base @@ -3974,7 +4151,19 @@ exports[`jsii-tree --types 1`] = ` exports[`jsii-tree 1`] = ` "assemblies - ├── jsii-calc + ├─┬ jsii-calc + │ └─┬ submodules + │ ├── DerivedClassHasNoProperties + │ ├── InterfaceInNamespaceIncludesClasses + │ ├── InterfaceInNamespaceOnlyInterface + │ ├── composition + │ └─┬ submodule + │ └─┬ submodules + │ ├── back_references + │ ├── child + │ └─┬ nested_submodule + │ └─┬ submodules + │ └── deeplyNested ├── @scope/jsii-calc-base ├── @scope/jsii-calc-base-of-base └── @scope/jsii-calc-lib diff --git a/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap b/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap index 09c3596970..c039455160 100644 --- a/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap +++ b/packages/jsii-reflect/test/__snapshots__/type-system.test.js.snap @@ -11,125 +11,127 @@ Array [ exports[`TypeSystem.classes lists all the classes in the typesystem 1`] = ` Array [ - "AbstractClass", - "AbstractClassBase", - "AbstractClassReturner", - "AbstractSuite", - "Add", - "AllTypes", - "AllowedMethodNames", - "AmbiguousParameters", - "AnonymousImplementationProvider", - "AsyncVirtualMethods", - "AugmentableClass", - "Base", - "Base", - "BaseJsii976", - "Bell", - "BinaryOperation", - "Calculator", - "ClassThatImplementsTheInternalInterface", - "ClassThatImplementsThePrivateInterface", - "ClassWithCollections", - "ClassWithDocs", - "ClassWithJavaReservedWords", - "ClassWithMutableObjectLiteralProperty", - "ClassWithPrivateConstructorAndAutomaticProperties", - "CompositeOperation", - "ConfusingToJackson", - "ConstructorPassesThisOut", - "Constructors", - "ConsumePureInterface", - "ConsumerCanRingBell", - "ConsumersOfThisCrazyTypeSystem", - "DataRenderer", - "DefaultedConstructorArgument", - "Demonstrate982", - "DeprecatedClass", - "Derived", - "DisappointingCollectionSource", - "DoNotOverridePrivates", - "DoNotRecognizeAnyAsOptional", - "DocumentedClass", - "DontComplainAboutVariadicAfterOptional", - "DoubleTrouble", - "EnumDispenser", - "EraseUndefinedHashValues", - "ExperimentalClass", - "ExportedBaseClass", - "Foo", - "GiveMeStructs", - "GreetingAugmenter", - "ImplementInternalInterface", - "Implementation", - "ImplementsInterfaceWithInternal", - "ImplementsInterfaceWithInternalSubclass", - "ImplementsPrivateInterface", - "InbetweenClass", - "InterfaceCollections", - "InterfacesMaker", - "JSII417Derived", - "JSII417PublicBaseOfBase", - "JSObjectLiteralForInterface", - "JSObjectLiteralToNative", - "JSObjectLiteralToNativeClass", - "JavaReservedWords", - "Jsii487Derived", - "Jsii496Derived", - "JsiiAgent", - "JsonFormatter", - "MethodNamedProperty", - "Multiply", - "Negate", - "NodeStandardLibrary", - "NullShouldBeTreatedAsUndefined", - "Number", - "NumberGenerator", - "ObjectRefsInCollections", - "ObjectWithPropertyProvider", - "Old", - "Operation", - "OptionalArgumentInvoker", - "OptionalConstructorArgument", - "OptionalStructConsumer", - "OverridableProtectedMember", - "OverrideReturnsObject", - "PartiallyInitializedThisConsumer", - "Polymorphism", - "Power", - "PropertyNamedProperty", - "PublicClass", - "PythonReservedWords", - "ReferenceEnumFromScopedPackage", - "ReturnsPrivateImplementationOfInterface", - "RootStructValidator", - "RuntimeTypeChecking", - "SingleInstanceTwoTypes", - "SingletonInt", - "SingletonString", - "SomeTypeJsii976", - "StableClass", - "StaticContext", - "Statics", - "StripInternal", - "StructPassing", - "StructUnionConsumer", - "Sum", - "SupportsNiceJavaBuilder", - "SupportsNiceJavaBuilderWithRequiredProps", - "SyncVirtualMethods", - "Thrower", - "UnaryOperation", - "UseBundledDependency", - "UseCalcBase", - "UsesInterfaceWithProperties", - "Value", - "VariadicInvoker", - "VariadicMethod", - "Very", - "VirtualMethodPlayground", - "VoidCallback", - "WithPrivatePropertyInConstructor", + "@scope/jsii-calc-base-of-base.Very", + "@scope/jsii-calc-base.Base", + "@scope/jsii-calc-lib.Number", + "@scope/jsii-calc-lib.Operation", + "@scope/jsii-calc-lib.Value", + "jsii-calc.AbstractClass", + "jsii-calc.AbstractClassBase", + "jsii-calc.AbstractClassReturner", + "jsii-calc.AbstractSuite", + "jsii-calc.Add", + "jsii-calc.AllTypes", + "jsii-calc.AllowedMethodNames", + "jsii-calc.AmbiguousParameters", + "jsii-calc.AnonymousImplementationProvider", + "jsii-calc.AsyncVirtualMethods", + "jsii-calc.AugmentableClass", + "jsii-calc.BaseJsii976", + "jsii-calc.Bell", + "jsii-calc.BinaryOperation", + "jsii-calc.Calculator", + "jsii-calc.ClassThatImplementsTheInternalInterface", + "jsii-calc.ClassThatImplementsThePrivateInterface", + "jsii-calc.ClassWithCollections", + "jsii-calc.ClassWithDocs", + "jsii-calc.ClassWithJavaReservedWords", + "jsii-calc.ClassWithMutableObjectLiteralProperty", + "jsii-calc.ClassWithPrivateConstructorAndAutomaticProperties", + "jsii-calc.ConfusingToJackson", + "jsii-calc.ConstructorPassesThisOut", + "jsii-calc.Constructors", + "jsii-calc.ConsumePureInterface", + "jsii-calc.ConsumerCanRingBell", + "jsii-calc.ConsumersOfThisCrazyTypeSystem", + "jsii-calc.DataRenderer", + "jsii-calc.DefaultedConstructorArgument", + "jsii-calc.Demonstrate982", + "jsii-calc.DeprecatedClass", + "jsii-calc.DerivedClassHasNoProperties.Base", + "jsii-calc.DerivedClassHasNoProperties.Derived", + "jsii-calc.DisappointingCollectionSource", + "jsii-calc.DoNotOverridePrivates", + "jsii-calc.DoNotRecognizeAnyAsOptional", + "jsii-calc.DocumentedClass", + "jsii-calc.DontComplainAboutVariadicAfterOptional", + "jsii-calc.DoubleTrouble", + "jsii-calc.EnumDispenser", + "jsii-calc.EraseUndefinedHashValues", + "jsii-calc.ExperimentalClass", + "jsii-calc.ExportedBaseClass", + "jsii-calc.GiveMeStructs", + "jsii-calc.GreetingAugmenter", + "jsii-calc.ImplementInternalInterface", + "jsii-calc.Implementation", + "jsii-calc.ImplementsInterfaceWithInternal", + "jsii-calc.ImplementsInterfaceWithInternalSubclass", + "jsii-calc.ImplementsPrivateInterface", + "jsii-calc.InbetweenClass", + "jsii-calc.InterfaceCollections", + "jsii-calc.InterfaceInNamespaceIncludesClasses.Foo", + "jsii-calc.InterfacesMaker", + "jsii-calc.JSII417Derived", + "jsii-calc.JSII417PublicBaseOfBase", + "jsii-calc.JSObjectLiteralForInterface", + "jsii-calc.JSObjectLiteralToNative", + "jsii-calc.JSObjectLiteralToNativeClass", + "jsii-calc.JavaReservedWords", + "jsii-calc.Jsii487Derived", + "jsii-calc.Jsii496Derived", + "jsii-calc.JsiiAgent", + "jsii-calc.JsonFormatter", + "jsii-calc.MethodNamedProperty", + "jsii-calc.Multiply", + "jsii-calc.Negate", + "jsii-calc.NodeStandardLibrary", + "jsii-calc.NullShouldBeTreatedAsUndefined", + "jsii-calc.NumberGenerator", + "jsii-calc.ObjectRefsInCollections", + "jsii-calc.ObjectWithPropertyProvider", + "jsii-calc.Old", + "jsii-calc.OptionalArgumentInvoker", + "jsii-calc.OptionalConstructorArgument", + "jsii-calc.OptionalStructConsumer", + "jsii-calc.OverridableProtectedMember", + "jsii-calc.OverrideReturnsObject", + "jsii-calc.PartiallyInitializedThisConsumer", + "jsii-calc.Polymorphism", + "jsii-calc.Power", + "jsii-calc.PropertyNamedProperty", + "jsii-calc.PublicClass", + "jsii-calc.PythonReservedWords", + "jsii-calc.ReferenceEnumFromScopedPackage", + "jsii-calc.ReturnsPrivateImplementationOfInterface", + "jsii-calc.RootStructValidator", + "jsii-calc.RuntimeTypeChecking", + "jsii-calc.SingleInstanceTwoTypes", + "jsii-calc.SingletonInt", + "jsii-calc.SingletonString", + "jsii-calc.SomeTypeJsii976", + "jsii-calc.StableClass", + "jsii-calc.StaticContext", + "jsii-calc.Statics", + "jsii-calc.StripInternal", + "jsii-calc.StructPassing", + "jsii-calc.StructUnionConsumer", + "jsii-calc.Sum", + "jsii-calc.SupportsNiceJavaBuilder", + "jsii-calc.SupportsNiceJavaBuilderWithRequiredProps", + "jsii-calc.SyncVirtualMethods", + "jsii-calc.Thrower", + "jsii-calc.UnaryOperation", + "jsii-calc.UseBundledDependency", + "jsii-calc.UseCalcBase", + "jsii-calc.UsesInterfaceWithProperties", + "jsii-calc.VariadicInvoker", + "jsii-calc.VariadicMethod", + "jsii-calc.VirtualMethodPlayground", + "jsii-calc.VoidCallback", + "jsii-calc.WithPrivatePropertyInConstructor", + "jsii-calc.composition.CompositeOperation", + "jsii-calc.submodule.MyClass", + "jsii-calc.submodule.nested_submodule.Namespaced", ] `; diff --git a/packages/jsii-reflect/test/type-system.test.ts b/packages/jsii-reflect/test/type-system.test.ts index 21ad3b03fb..354d9da511 100644 --- a/packages/jsii-reflect/test/type-system.test.ts +++ b/packages/jsii-reflect/test/type-system.test.ts @@ -22,7 +22,7 @@ test('TypeSystem.assemblies lists all the loaded assemblies', () => ); test('TypeSystem.classes lists all the classes in the typesystem', () => - expect(typesys.classes.map(c => c.name).sort()).toMatchSnapshot() + expect(typesys.classes.map(c => c.fqn).sort()).toMatchSnapshot() ); test('findClass', () => { diff --git a/packages/jsii/lib/assembler.ts b/packages/jsii/lib/assembler.ts index 4a7b2996e1..33480b93f5 100644 --- a/packages/jsii/lib/assembler.ts +++ b/packages/jsii/lib/assembler.ts @@ -1,3 +1,4 @@ +import * as Case from 'case'; import * as colors from 'colors/safe'; import * as crypto from 'crypto'; // eslint-disable-next-line @typescript-eslint/no-require-imports @@ -32,6 +33,10 @@ export class Assembler implements Emitter { private _deferred = new Array(); private _types: { [fqn: string]: spec.Type } = {}; + /** Map of Symbol to namespace export Symbol */ + private readonly _submoduleMap = new Map(); + private readonly _submodules = new Set(); + /** * @param projectInfo information about the package being assembled * @param program the TypeScript program to be assembled from @@ -104,7 +109,11 @@ export class Assembler implements Emitter { } const symbol = this._typeChecker.getSymbolAtLocation(sourceFile); if (symbol) { - for (const node of this._typeChecker.getExportsOfModule(symbol)) { + const moduleExports = this._typeChecker.getExportsOfModule(symbol); + for (const node of moduleExports) { + this._registerNamespaces(node); + } + for (const node of moduleExports) { visitPromises.push(this._visitNode(node.declarations[0], new EmitContext([], this.projectInfo.stability))); } } @@ -282,7 +291,12 @@ export class Assembler implements Emitter { return type; } - private _diagnostic(node: ts.Node | null, category: ts.DiagnosticCategory, messageText: string) { + private _diagnostic( + node: ts.Node | null, + category: ts.DiagnosticCategory, + messageText: string, + relatedInformation?: ts.DiagnosticRelatedInformation[] + ) { this._diagnostics.push({ domain: 'JSII', category, @@ -291,6 +305,7 @@ export class Assembler implements Emitter { file: node != null ? node.getSourceFile() : undefined, start: node != null ? node.getStart() : undefined, length: node != null ? node.getEnd() - node.getStart() : undefined, + relatedInformation, }); } @@ -318,7 +333,18 @@ export class Assembler implements Emitter { this._diagnostic(node, ts.DiagnosticCategory.Error, `Could not find module for ${modulePath}`); return `unknown.${typeName}`; } - const fqn = `${pkg.name}.${typeName}`; + + let submodule = this._submoduleMap.get(type.symbol); + let submoduleNs = submodule?.name; + // Submodules can be in submodules themselves, so we crawl up the tree... + while (submodule != null && this._submoduleMap.has(submodule)) { + submodule = this._submoduleMap.get(submodule)!; + submoduleNs = `${submodule.name}.${submoduleNs}`; + } + + const fqn = submoduleNs != null + ? `${pkg.name}.${submoduleNs}.${typeName}` + : `${pkg.name}.${typeName}`; if (pkg.name !== this.projectInfo.name && !this._dereference({ fqn }, type.symbol.valueDeclaration)) { this._diagnostic(node, ts.DiagnosticCategory.Error, @@ -337,26 +363,155 @@ export class Assembler implements Emitter { } } + private _registerNamespaces(symbol: ts.Symbol): void { + const declaration = symbol.valueDeclaration ?? symbol.declarations[0]; + if (declaration == null || !ts.isNamespaceExport(declaration)) { + // Nothing to do here... + return; + } + const moduleSpecifier = declaration.parent.moduleSpecifier; + if (moduleSpecifier == null || !ts.isStringLiteral(moduleSpecifier)) { + // There is a grammar error here, so we'll let tsc report this for us. + return; + } + const resolution = ts.resolveModuleName( + moduleSpecifier.text, + declaration.getSourceFile().fileName, + this.program.getCompilerOptions(), + ts.sys + ); + if (resolution.resolvedModule == null) { + // Unresolvable module... We'll let tsc report this for us. + return; + } + if (resolution.resolvedModule.isExternalLibraryImport) { + // External re-exports are "pure-javascript" sugar; they need not be + // represented in the jsii Assembly since the types in there will be + // resolved through dependencies. + return; + } + const sourceFile = this.program.getSourceFile(resolution.resolvedModule.resolvedFileName)!; + const sourceModule = this._typeChecker.getSymbolAtLocation(sourceFile); + // If there's no module, it's a syntax error, and tsc will have reported it for us. + if (sourceModule) { + if (symbol.name !== Case.camel(symbol.name) && symbol.name !== Case.snake(symbol.name)) { + this._diagnostic(declaration, ts.DiagnosticCategory.Error, + `Submodule namespaces must be camelCased or snake_cased. Consider renaming to "${Case.camel(symbol.name)}".`); + } + this._submodules.add(symbol); + this._addToSubmodule(symbol, sourceModule); + } + } + + /** + * Registers Symbols to a particular submodule. This is used to associate + * declarations exported by an `export * as ns from 'moduleLike';` statement + * so that they can subsequently be correctly namespaced. + * + * @param ns the symbol that identifies the submodule. + * @param moduleLike the module-like symbol bound to the submodule. + */ + private _addToSubmodule(ns: ts.Symbol, moduleLike: ts.Symbol) { + // For each symbol exported by the moduleLike, map it to the ns submodule. + for (const symbol of this._typeChecker.getExportsOfModule(moduleLike)) { + if (this._submoduleMap.has(symbol)) { + const currNs = this._submoduleMap.get(symbol)!; + // Checking if there's been two submodules exporting the same symbol, + // which is illegal. We can tell if the currently registered symbol has + // a different name than the one we're currently trying to register in. + if (currNs.name !== ns.name) { + const currNsDecl = currNs.valueDeclaration ?? currNs.declarations[0]; + const nsDecl = ns.valueDeclaration ?? ns.declarations[0]; + this._diagnostic( + symbol.valueDeclaration, + ts.DiagnosticCategory.Error, + `Symbol is re-exported under two distinct submodules (${currNs.name} and ${ns.name})`, + [{ + category: ts.DiagnosticCategory.Warning, + file: currNsDecl.getSourceFile(), + length: currNsDecl.getStart() - currNsDecl.getEnd(), + messageText: `Symbol is exported under the "${currNs.name}" submodule`, + start: currNsDecl.getStart(), + code: JSII_DIAGNOSTICS_CODE + }, { + category: ts.DiagnosticCategory.Warning, + file: nsDecl.getSourceFile(), + length: nsDecl.getStart() - nsDecl.getEnd(), + messageText: `Symbol is exported under the "${ns.name}" submodule`, + start: nsDecl.getStart(), + code: JSII_DIAGNOSTICS_CODE + }] + ); + } + // Found two re-exports, which is odd, but they use the same submodule, + // so it's probably okay? That's likely a tsc error, which will have + // been reported for us already anyway. + continue; + } + this._submoduleMap.set(symbol, ns); + + // If the exported symbol has any declaration, and that delcaration is of + // an entity that can have nested declarations of interest to jsii + // (classes, interfaces, enums, modules), we need to also associate those + // nested symbols to the submodule (or they won't be named correctly!) + const decl = symbol.declarations?.[0]; + if (decl != null) { + if (ts.isClassDeclaration(decl) || ts.isInterfaceDeclaration(decl) || ts.isEnumDeclaration(decl)) { + const type = this._typeChecker.getTypeAtLocation(decl); + if (type.symbol.exports) { + this._addToSubmodule(ns, symbol); + } + } else if (ts.isModuleDeclaration(decl)) { + this._addToSubmodule(ns, symbol); + } else if (ts.isNamespaceExport(decl)) { + this._submoduleMap.set(symbol, ns); + this._registerNamespaces(symbol); + } + } + } + } + /** * Register exported types in ``this.types``. * * @param node a node found in a module * @param namePrefix the prefix for the types' namespaces */ + // eslint-disable-next-line complexity private async _visitNode(node: ts.Declaration, context: EmitContext): Promise { + if (ts.isNamespaceExport(node)) { // export * as ns from 'module'; + // Note: the "ts.NamespaceExport" refers to the "export * as ns" part of + // the statement only. We must refer to `node.parent` in order to be able + // to access the module specifier ("from 'module'") part. + const symbol = this._typeChecker.getSymbolAtLocation(node.parent.moduleSpecifier!)!; + + if (LOG.isTraceEnabled()) { LOG.trace(`Entering submodule: ${colors.cyan([...context.namespace, symbol.name].join('.'))}`); } + + const nsContext = context.appendNamespace(node.name.text); + const promises = new Array>(); + for (const child of this._typeChecker.getExportsOfModule(symbol)) { + promises.push(this._visitNode(child.declarations[0], nsContext)); + } + const allTypes = flattenPromises(promises); + + if (LOG.isTraceEnabled()) { LOG.trace(`Leaving submodule: ${colors.cyan([...context.namespace, symbol.name].join('.'))}`); } + + return allTypes; + } + if ((ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) === 0) { return []; } let jsiiType: spec.Type | undefined; - if (ts.isClassDeclaration(node) && _isExported(node)) { + if (ts.isClassDeclaration(node) && _isExported(node)) { // export class Name { ... } jsiiType = await this._visitClass(this._typeChecker.getTypeAtLocation(node), context); - } else if (ts.isInterfaceDeclaration(node) && _isExported(node)) { + } else if (ts.isInterfaceDeclaration(node) && _isExported(node)) { // export interface Name { ... } jsiiType = await this._visitInterface(this._typeChecker.getTypeAtLocation(node), context); - } else if (ts.isEnumDeclaration(node) && _isExported(node)) { + } else if (ts.isEnumDeclaration(node) && _isExported(node)) { // export enum Name { ... } jsiiType = await this._visitEnum(this._typeChecker.getTypeAtLocation(node), context); - } else if (ts.isModuleDeclaration(node)) { + } else if (ts.isModuleDeclaration(node)) { // export namespace name { ... } const name = node.name.getText(); - const symbol = (node as any).symbol; + const symbol = this._typeChecker.getSymbolAtLocation(node.name)!; if (LOG.isTraceEnabled()) { LOG.trace(`Entering namespace: ${colors.cyan([...context.namespace, name].join('.'))}`); } @@ -374,6 +529,31 @@ export class Assembler implements Emitter { if (!jsiiType) { return []; } + // Let's quickly verify the declaration does not collide with a submodule. Submodules get case-adjusted for each + // target language separately, so names cannot collide with case-variations. + for (const submodule of this._submodules) { + const candidates = Array.from(new Set([ + submodule.name, + Case.camel(submodule.name), + Case.pascal(submodule.name), + Case.snake(submodule.name), + ])); + const colliding = candidates.find(name => `${this.projectInfo.name}.${name}` === jsiiType!.fqn); + if (colliding != null) { + const submoduleDecl = submodule.valueDeclaration ?? submodule.declarations[0]; + this._diagnostic(node, ts.DiagnosticCategory.Error, + `Submodule "${submodule.name}" conflicts with "${jsiiType.name}". Restricted names are: ${candidates.join(', ')}`, + [{ + category: ts.DiagnosticCategory.Warning, + code: JSII_DIAGNOSTICS_CODE, + file: submoduleDecl.getSourceFile(), + length: submoduleDecl.getEnd() - submoduleDecl.getStart(), + messageText: 'This is the conflicting submodule declaration.', + start: submoduleDecl.getStart() + }]); + } + } + if (LOG.isInfoEnabled()) { LOG.info(`Registering JSII ${colors.magenta(jsiiType.kind)}: ${colors.green(jsiiType.fqn)}`); } @@ -462,6 +642,7 @@ export class Assembler implements Emitter { return { interfaces: result.length === 0 ? undefined : result, erasedBases }; } + // eslint-disable-next-line complexity private async _visitClass(type: ts.Type, ctx: EmitContext): Promise { if (LOG.isTraceEnabled()) { LOG.trace(`Processing class: ${colors.gray(ctx.namespace.join('.'))}.${colors.cyan(type.symbol.name)}`); @@ -590,7 +771,8 @@ export class Assembler implements Emitter { if (!classDecl.members) { continue; } for (const memberDecl of classDecl.members) { - const member: ts.Symbol = (memberDecl as any).symbol; + // The "??" is to get to the __constructor symbol (getSymbolAtLocation wouldn't work there...) + const member = this._typeChecker.getSymbolAtLocation(memberDecl.name!) ?? ((memberDecl as any).symbol as ts.Symbol); if (!(declaringType.symbol.getDeclarations() ?? []).find(d => d === memberDecl.parent)) { continue; diff --git a/packages/jsii/lib/compiler.ts b/packages/jsii/lib/compiler.ts index ce2632dfe4..8daea35735 100644 --- a/packages/jsii/lib/compiler.ts +++ b/packages/jsii/lib/compiler.ts @@ -190,7 +190,7 @@ export class Compiler implements Emitter { hasErrors = hasErrors || emitHasErrors(assmEmit, this.options.failOnWarnings); diagnostics.push(...assmEmit.diagnostics); } catch (e) { - LOG.error(`Error during type model analysis: ${e}`); + LOG.error(`Error during type model analysis: ${e}\n${e.stack}`); } return { emitSkipped: hasErrors, diagnostics, emittedFiles: emit.emittedFiles }; diff --git a/packages/jsii/lib/validator.ts b/packages/jsii/lib/validator.ts index f29c25b386..be1bfba2c7 100644 --- a/packages/jsii/lib/validator.ts +++ b/packages/jsii/lib/validator.ts @@ -58,7 +58,7 @@ function _defaultValidations(): ValidationFunction[] { _staticConstantNamesMustUseUpperSnakeCase, _memberNamesMustNotLookLikeJavaGettersOrSetters, _allTypeReferencesAreValid, - _inehritanceDoesNotChangeContracts + _inehritanceDoesNotChangeContracts, ]; function _typeNamesMustUsePascalCase(_: Validator, assembly: spec.Assembly, diagnostic: DiagnosticEmitter) { diff --git a/packages/jsii/test/negatives/namespaced/index.ts b/packages/jsii/test/negatives/namespaced/index.ts new file mode 100644 index 0000000000..f666ae2bc7 --- /dev/null +++ b/packages/jsii/test/negatives/namespaced/index.ts @@ -0,0 +1,3 @@ +export class Declaration { + private constructor() { } +} diff --git a/packages/jsii/test/negatives/neg.submodules-cannot-have-colliding-names.ts b/packages/jsii/test/negatives/neg.submodules-cannot-have-colliding-names.ts new file mode 100644 index 0000000000..b92063f8e3 --- /dev/null +++ b/packages/jsii/test/negatives/neg.submodules-cannot-have-colliding-names.ts @@ -0,0 +1,7 @@ +///!MATCH_ERROR: Submodule "ns1" conflicts with "Ns1". + +export * as ns1 from './namespaced'; + +export class Ns1 { + private constructor() { } +} diff --git a/packages/jsii/test/negatives/neg.submodules-cannot-share-symbols.ts b/packages/jsii/test/negatives/neg.submodules-cannot-share-symbols.ts new file mode 100644 index 0000000000..314594178a --- /dev/null +++ b/packages/jsii/test/negatives/neg.submodules-cannot-share-symbols.ts @@ -0,0 +1,4 @@ +///!MATCH_ERROR: Symbol is re-exported under two distinct submodules (ns1 and ns2) + +export * as ns1 from './namespaced'; +export * as ns2 from './namespaced'; diff --git a/packages/jsii/test/negatives/neg.submodules-must-be-camel-cased.ts b/packages/jsii/test/negatives/neg.submodules-must-be-camel-cased.ts new file mode 100644 index 0000000000..0b2d93899c --- /dev/null +++ b/packages/jsii/test/negatives/neg.submodules-must-be-camel-cased.ts @@ -0,0 +1,3 @@ +///!MATCH_ERROR: Submodule namespaces must be camelCased or snake_cased. Consider renaming to "ns1" + +export * as Ns1 from './namespaced'; diff --git a/tsconfig.json b/tsconfig.json index 5e07b4a860..8b462437c8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,15 +2,8 @@ "files": [], "include": [], "references": [ - { "path": "packages/@jsii/dotnet-analyzers" }, - { "path": "packages/@jsii/dotnet-jsonmodel" }, - { "path": "packages/@jsii/dotnet-runtime" }, - { "path": "packages/@jsii/dotnet-runtime-test" }, - { "path": "packages/@jsii/java-runtime" }, - { "path": "packages/@jsii/kernel" }, - { "path": "packages/@jsii/runtime" }, - { "path": "packages/@jsii/spec" }, { "path": "packages/codemaker" }, + { "path": "packages/jsii-calc" }, { "path": "packages/jsii-config" }, { "path": "packages/jsii-diff" }, { "path": "packages/jsii-pacmak" }, @@ -18,5 +11,17 @@ { "path": "packages/jsii-rosetta" }, { "path": "packages/jsii" }, { "path": "packages/oo-ascii-tree" }, + { "path": "packages/@jsii/dotnet-analyzers" }, + { "path": "packages/@jsii/dotnet-jsonmodel" }, + { "path": "packages/@jsii/dotnet-runtime-test" }, + { "path": "packages/@jsii/dotnet-runtime" }, + { "path": "packages/@jsii/integ-test" }, + { "path": "packages/@jsii/java-runtime" }, + { "path": "packages/@jsii/kernel" }, + { "path": "packages/@jsii/runtime" }, + { "path": "packages/@jsii/spec" }, + { "path": "packages/@scope/jsii-calc-base-of-base" }, + { "path": "packages/@scope/jsii-calc-base" }, + { "path": "packages/@scope/jsii-calc-lib" } ] }