@alloy-js/python 0.1.0-dev.4 → 0.1.0-dev.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/dist/src/builtins/python.js +2 -1
  2. package/dist/src/builtins/python.js.map +1 -0
  3. package/dist/src/components/Atom.js +2 -1
  4. package/dist/src/components/Atom.js.map +1 -0
  5. package/dist/src/components/CallSignature.d.ts.map +1 -1
  6. package/dist/src/components/CallSignature.js +10 -12
  7. package/dist/src/components/CallSignature.js.map +1 -0
  8. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  9. package/dist/src/components/ClassDeclaration.js +8 -21
  10. package/dist/src/components/ClassDeclaration.js.map +1 -0
  11. package/dist/src/components/ClassInstantiation.d.ts.map +1 -1
  12. package/dist/src/components/ClassInstantiation.js +6 -5
  13. package/dist/src/components/ClassInstantiation.js.map +1 -0
  14. package/dist/src/components/Declaration.d.ts +1 -5
  15. package/dist/src/components/Declaration.d.ts.map +1 -1
  16. package/dist/src/components/Declaration.js +8 -16
  17. package/dist/src/components/Declaration.js.map +1 -0
  18. package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
  19. package/dist/src/components/EnumDeclaration.js +35 -60
  20. package/dist/src/components/EnumDeclaration.js.map +1 -0
  21. package/dist/src/components/EnumMember.d.ts.map +1 -1
  22. package/dist/src/components/EnumMember.js +5 -5
  23. package/dist/src/components/EnumMember.js.map +1 -0
  24. package/dist/src/components/FunctionCallExpression.js +2 -1
  25. package/dist/src/components/FunctionCallExpression.js.map +1 -0
  26. package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
  27. package/dist/src/components/FunctionDeclaration.js +8 -16
  28. package/dist/src/components/FunctionDeclaration.js.map +1 -0
  29. package/dist/src/components/ImportStatement.js +2 -1
  30. package/dist/src/components/ImportStatement.js.map +1 -0
  31. package/dist/src/components/LexicalScope.d.ts +8 -0
  32. package/dist/src/components/LexicalScope.d.ts.map +1 -0
  33. package/dist/src/components/LexicalScope.js +22 -0
  34. package/dist/src/components/LexicalScope.js.map +1 -0
  35. package/dist/src/components/MemberExpression.js +2 -1
  36. package/dist/src/components/MemberExpression.js.map +1 -0
  37. package/dist/src/components/MemberScope.d.ts +8 -0
  38. package/dist/src/components/MemberScope.d.ts.map +1 -0
  39. package/dist/src/components/MemberScope.js +16 -0
  40. package/dist/src/components/MemberScope.js.map +1 -0
  41. package/dist/src/components/NoNamePolicy.js +2 -1
  42. package/dist/src/components/NoNamePolicy.js.map +1 -0
  43. package/dist/src/components/PyDoc.js +2 -1
  44. package/dist/src/components/PyDoc.js.map +1 -0
  45. package/dist/src/components/PythonBlock.js +2 -1
  46. package/dist/src/components/PythonBlock.js.map +1 -0
  47. package/dist/src/components/Reference.js +2 -1
  48. package/dist/src/components/Reference.js.map +1 -0
  49. package/dist/src/components/SourceFile.js +3 -3
  50. package/dist/src/components/SourceFile.js.map +1 -0
  51. package/dist/src/components/StatementList.js +2 -1
  52. package/dist/src/components/StatementList.js.map +1 -0
  53. package/dist/src/components/UnionTypeExpression.js +2 -1
  54. package/dist/src/components/UnionTypeExpression.js.map +1 -0
  55. package/dist/src/components/VariableDeclaration.d.ts.map +1 -1
  56. package/dist/src/components/VariableDeclaration.js +10 -32
  57. package/dist/src/components/VariableDeclaration.js.map +1 -0
  58. package/dist/src/components/index.d.ts +2 -0
  59. package/dist/src/components/index.d.ts.map +1 -1
  60. package/dist/src/components/index.js +4 -1
  61. package/dist/src/components/index.js.map +1 -0
  62. package/dist/src/create-module.d.ts.map +1 -1
  63. package/dist/src/create-module.js +5 -5
  64. package/dist/src/create-module.js.map +1 -0
  65. package/dist/src/index.js +2 -1
  66. package/dist/src/index.js.map +1 -0
  67. package/dist/src/name-conflict-resolver.d.ts +3 -0
  68. package/dist/src/name-conflict-resolver.d.ts.map +1 -0
  69. package/dist/src/name-conflict-resolver.js +8 -0
  70. package/dist/src/name-conflict-resolver.js.map +1 -0
  71. package/dist/src/name-policy.js +2 -1
  72. package/dist/src/name-policy.js.map +1 -0
  73. package/dist/src/parameter-descriptor.js +2 -1
  74. package/dist/src/parameter-descriptor.js.map +1 -0
  75. package/dist/src/symbol-creation.d.ts +13 -2
  76. package/dist/src/symbol-creation.d.ts.map +1 -1
  77. package/dist/src/symbol-creation.js +35 -10
  78. package/dist/src/symbol-creation.js.map +1 -0
  79. package/dist/src/symbols/index.d.ts +1 -1
  80. package/dist/src/symbols/index.d.ts.map +1 -1
  81. package/dist/src/symbols/index.js +3 -2
  82. package/dist/src/symbols/index.js.map +1 -0
  83. package/dist/src/symbols/python-lexical-scope.d.ts +7 -0
  84. package/dist/src/symbols/python-lexical-scope.d.ts.map +1 -0
  85. package/dist/src/symbols/python-lexical-scope.js +15 -0
  86. package/dist/src/symbols/python-lexical-scope.js.map +1 -0
  87. package/dist/src/symbols/python-member-scope.d.ts +3 -4
  88. package/dist/src/symbols/python-member-scope.d.ts.map +1 -1
  89. package/dist/src/symbols/python-member-scope.js +6 -8
  90. package/dist/src/symbols/python-member-scope.js.map +1 -0
  91. package/dist/src/symbols/python-module-scope.d.ts +4 -9
  92. package/dist/src/symbols/python-module-scope.d.ts.map +1 -1
  93. package/dist/src/symbols/python-module-scope.js +8 -15
  94. package/dist/src/symbols/python-module-scope.js.map +1 -0
  95. package/dist/src/symbols/python-output-symbol.d.ts +10 -7
  96. package/dist/src/symbols/python-output-symbol.d.ts.map +1 -1
  97. package/dist/src/symbols/python-output-symbol.js +25 -7
  98. package/dist/src/symbols/python-output-symbol.js.map +1 -0
  99. package/dist/src/symbols/reference.d.ts +2 -2
  100. package/dist/src/symbols/reference.d.ts.map +1 -1
  101. package/dist/src/symbols/reference.js +37 -36
  102. package/dist/src/symbols/reference.js.map +1 -0
  103. package/dist/src/symbols/scopes.d.ts +3 -1
  104. package/dist/src/symbols/scopes.d.ts.map +1 -1
  105. package/dist/src/symbols/scopes.js +10 -1
  106. package/dist/src/symbols/scopes.js.map +1 -0
  107. package/dist/src/utils.js +2 -1
  108. package/dist/src/utils.js.map +1 -0
  109. package/dist/test/callsignatures.test.js +2 -1
  110. package/dist/test/callsignatures.test.js.map +1 -0
  111. package/dist/test/classdeclarations.test.js +89 -53
  112. package/dist/test/classdeclarations.test.js.map +1 -0
  113. package/dist/test/classinstantiations.test.js +2 -1
  114. package/dist/test/classinstantiations.test.js.map +1 -0
  115. package/dist/test/enums.test.js +10 -3
  116. package/dist/test/enums.test.js.map +1 -0
  117. package/dist/test/externals.test.js +8 -6
  118. package/dist/test/externals.test.js.map +1 -0
  119. package/dist/test/functioncallexpressions.test.js +2 -1
  120. package/dist/test/functioncallexpressions.test.js.map +1 -0
  121. package/dist/test/functiondeclaration.test.js +75 -37
  122. package/dist/test/functiondeclaration.test.js.map +1 -0
  123. package/dist/test/imports.test.js +11 -37
  124. package/dist/test/imports.test.js.map +1 -0
  125. package/dist/test/memberexpressions.test.js +2 -1
  126. package/dist/test/memberexpressions.test.js.map +1 -0
  127. package/dist/test/namepolicies.test.js +2 -1
  128. package/dist/test/namepolicies.test.js.map +1 -0
  129. package/dist/test/pydocs.test.js +2 -1
  130. package/dist/test/pydocs.test.js.map +1 -0
  131. package/dist/test/references.test.js +2 -1
  132. package/dist/test/references.test.js.map +1 -0
  133. package/dist/test/sourcefiles.test.js +2 -1
  134. package/dist/test/sourcefiles.test.js.map +1 -0
  135. package/dist/test/uniontypeexpression.test.js +2 -1
  136. package/dist/test/uniontypeexpression.test.js.map +1 -0
  137. package/dist/test/utils.d.ts +2 -3
  138. package/dist/test/utils.d.ts.map +1 -1
  139. package/dist/test/utils.js +8 -4
  140. package/dist/test/utils.js.map +1 -0
  141. package/dist/test/values.test.js +2 -1
  142. package/dist/test/values.test.js.map +1 -0
  143. package/dist/test/variables.test.js +13 -12
  144. package/dist/test/variables.test.js.map +1 -0
  145. package/dist/tsconfig.tsbuildinfo +1 -1
  146. package/package.json +3 -3
  147. package/src/components/CallSignature.tsx +9 -17
  148. package/src/components/ClassDeclaration.tsx +5 -32
  149. package/src/components/ClassInstantiation.tsx +6 -12
  150. package/src/components/Declaration.tsx +1 -20
  151. package/src/components/EnumDeclaration.tsx +18 -41
  152. package/src/components/EnumMember.tsx +1 -3
  153. package/src/components/FunctionDeclaration.tsx +5 -24
  154. package/src/components/LexicalScope.tsx +24 -0
  155. package/src/components/MemberScope.tsx +18 -0
  156. package/src/components/SourceFile.tsx +2 -2
  157. package/src/components/VariableDeclaration.tsx +7 -35
  158. package/src/components/index.ts +2 -0
  159. package/src/create-module.ts +7 -13
  160. package/src/name-conflict-resolver.ts +21 -0
  161. package/src/symbol-creation.ts +50 -11
  162. package/src/symbols/index.ts +1 -1
  163. package/src/symbols/python-lexical-scope.ts +16 -0
  164. package/src/symbols/python-member-scope.ts +4 -8
  165. package/src/symbols/python-module-scope.ts +6 -32
  166. package/src/symbols/python-output-symbol.ts +36 -10
  167. package/src/symbols/reference.tsx +70 -0
  168. package/src/symbols/scopes.ts +15 -1
  169. package/temp/api.json +897 -539
  170. package/test/classdeclarations.test.tsx +66 -31
  171. package/test/enums.test.tsx +2 -2
  172. package/test/externals.test.tsx +6 -7
  173. package/test/functiondeclaration.test.tsx +48 -39
  174. package/test/imports.test.tsx +11 -36
  175. package/test/utils.tsx +11 -5
  176. package/test/variables.test.tsx +11 -7
  177. package/dist/src/symbols/custom-output-scope.d.ts +0 -10
  178. package/dist/src/symbols/custom-output-scope.d.ts.map +0 -1
  179. package/dist/src/symbols/custom-output-scope.js +0 -25
  180. package/src/symbols/custom-output-scope.ts +0 -35
  181. package/src/symbols/reference.ts +0 -99
@@ -0,0 +1 @@
1
+ {"version":3,"names":["OutputScope","PythonMemberScope","ownerSymbol"],"sources":["../../../src/symbols/python-member-scope.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAAQ,gBAAgB;AAG5C,OAAO,MAAMC,iBAAiB,SAASD,WAAW,CAAC;EACjD,IAAIE,WAAWA,CAAA,EAAG;IAChB,OAAO,KAAK,CAACA,WAAW;EAC1B;AACF","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { CustomOutputScope } from "./custom-output-scope.js";
1
+ import { PythonLexicalScope } from "./python-lexical-scope.js";
2
2
  import { PythonOutputSymbol } from "./python-output-symbol.js";
3
3
  export declare class ImportedSymbol {
4
4
  local: PythonOutputSymbol;
@@ -9,15 +9,10 @@ export declare class ImportedSymbol {
9
9
  export interface ImportRecordProps {
10
10
  symbols: Set<ImportedSymbol>;
11
11
  }
12
- export type ImportRecords = Map<PythonModuleScope, ImportRecordProps>;
13
- export declare const ImportRecords: {
14
- new (): ImportRecords;
15
- new (entries?: readonly (readonly [PythonModuleScope, ImportRecordProps])[] | null): ImportRecords;
16
- prototype: Map<PythonModuleScope, ImportRecordProps>;
17
- };
18
- export declare class PythonModuleScope extends CustomOutputScope {
12
+ export declare class ImportRecords extends Map<PythonModuleScope, ImportRecordProps> {
13
+ }
14
+ export declare class PythonModuleScope extends PythonLexicalScope {
19
15
  #private;
20
- get kind(): "module";
21
16
  get importedSymbols(): Map<PythonOutputSymbol, PythonOutputSymbol>;
22
17
  get importedModules(): ImportRecords;
23
18
  addImport(targetSymbol: PythonOutputSymbol, targetModule: PythonModuleScope): PythonOutputSymbol;
@@ -1 +1 @@
1
- {"version":3,"file":"python-module-scope.d.ts","sourceRoot":"","sources":["../../../src/symbols/python-module-scope.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,qBAAa,cAAc;IACzB,KAAK,EAAE,kBAAkB,CAAC;IAC1B,MAAM,EAAE,kBAAkB,CAAC;gBAEf,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,kBAAkB;IAKjE,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,kBAAkB;CAGlE;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC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AE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB;CA0B5E"}
@@ -1,6 +1,6 @@
1
1
  import { reactive, shallowReactive } from "@alloy-js/core";
2
- import { createPythonSymbol } from "../symbol-creation.js";
3
- import { CustomOutputScope } from "./custom-output-scope.js";
2
+ import { PythonLexicalScope } from "./python-lexical-scope.js";
3
+ import { PythonOutputSymbol } from "./python-output-symbol.js";
4
4
  export class ImportedSymbol {
5
5
  constructor(target, local) {
6
6
  this.target = target;
@@ -10,11 +10,8 @@ export class ImportedSymbol {
10
10
  return new ImportedSymbol(target, local);
11
11
  }
12
12
  }
13
- export const ImportRecords = Map;
14
- export class PythonModuleScope extends CustomOutputScope {
15
- get kind() {
16
- return "module";
17
- }
13
+ export class ImportRecords extends Map {}
14
+ export class PythonModuleScope extends PythonLexicalScope {
18
15
  #importedSymbols = shallowReactive(new Map());
19
16
  get importedSymbols() {
20
17
  return this.#importedSymbols;
@@ -28,20 +25,15 @@ export class PythonModuleScope extends CustomOutputScope {
28
25
  if (existing) {
29
26
  return existing;
30
27
  }
31
- if (targetModule.kind !== "module") {
32
- throw new Error("Cannot import symbol that isn't in module scope");
33
- }
34
28
  if (!this.importedModules.has(targetModule)) {
35
29
  this.importedModules.set(targetModule, {
36
30
  symbols: new Set()
37
31
  });
38
32
  }
39
- const localSymbol = createPythonSymbol(targetSymbol.name, {
33
+ const localSymbol = new PythonOutputSymbol(targetSymbol.name, this.symbols, {
40
34
  binder: this.binder,
41
- scope: this,
42
35
  aliasTarget: targetSymbol
43
- }, undefined, false);
44
- targetSymbol.copyTo(localSymbol);
36
+ });
45
37
  this.importedSymbols.set(targetSymbol, localSymbol);
46
38
  this.importedModules.get(targetModule).symbols?.add({
47
39
  local: localSymbol,
@@ -49,4 +41,5 @@ export class PythonModuleScope extends CustomOutputScope {
49
41
  });
50
42
  return localSymbol;
51
43
  }
52
- }
44
+ }
45
+ //# sourceMappingURL=python-module-scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["reactive","shallowReactive","PythonLexicalScope","PythonOutputSymbol","ImportedSymbol","constructor","target","local","from","ImportRecords","Map","PythonModuleScope","importedSymbols","importedModules","addImport","targetSymbol","targetModule","existing","get","has","set","symbols","Set","localSymbol","name","binder","aliasTarget","add"],"sources":["../../../src/symbols/python-module-scope.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAQ,EAAEC,eAAe,QAAQ,gBAAgB;AAC1D,SAASC,kBAAkB,QAAQ,2BAA2B;AAC9D,SAASC,kBAAkB,QAAQ,2BAA2B;AAE9D,OAAO,MAAMC,cAAc,CAAC;EAI1BC,WAAWA,CAACC,MAA0B,EAAEC,KAAyB,EAAE;IACjE,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,KAAK,GAAGA,KAAK;EACpB;EAEA,OAAOC,IAAIA,CAACF,MAA0B,EAAEC,KAAyB,EAAE;IACjE,OAAO,IAAIH,cAAc,CAACE,MAAM,EAAEC,KAAK,CAAC;EAC1C;AACF;AAMA,OAAO,MAAME,aAAa,SAASC,GAAG,CAAuC;AAE7E,OAAO,MAAMC,iBAAiB,SAAST,kBAAkB,CAAC;EACxD,CAACU,eAAe,GACdX,eAAe,CAAC,IAAIS,GAAG,CAAC,CAAC,CAAC;EAC5B,IAAIE,eAAeA,CAAA,EAAG;IACpB,OAAO,IAAI,CAAC,CAACA,eAAe;EAC9B;EAEA,CAACC,eAAe,GAAkBb,QAAQ,CAAC,IAAIU,GAAG,CAAC,CAAC,CAAC;EACrD,IAAIG,eAAeA,CAAA,EAAG;IACpB,OAAO,IAAI,CAAC,CAACA,eAAe;EAC9B;EAEAC,SAASA,CAACC,YAAgC,EAAEC,YAA+B,EAAE;IAC3E,MAAMC,QAAQ,GAAG,IAAI,CAACL,eAAe,CAACM,GAAG,CAACH,YAAY,CAAC;IACvD,IAAIE,QAAQ,EAAE;MACZ,OAAOA,QAAQ;IACjB;IAEA,IAAI,CAAC,IAAI,CAACJ,eAAe,CAACM,GAAG,CAACH,YAAY,CAAC,EAAE;MAC3C,IAAI,CAACH,eAAe,CAACO,GAAG,CAACJ,YAAY,EAAE;QACrCK,OAAO,EAAE,IAAIC,GAAG,CAAiB;MACnC,CAAC,CAAC;IACJ;IAEA,MAAMC,WAAW,GAAG,IAAIpB,kBAAkB,CACxCY,YAAY,CAACS,IAAI,EACjB,IAAI,CAACH,OAAO,EACZ;MAAEI,MAAM,EAAE,IAAI,CAACA,MAAM;MAAEC,WAAW,EAAEX;IAAa,CACnD,CAAC;IAED,IAAI,CAACH,eAAe,CAACQ,GAAG,CAACL,YAAY,EAAEQ,WAAW,CAAC;IACnD,IAAI,CAACV,eAAe,CAACK,GAAG,CAACF,YAAY,CAAC,CAAEK,OAAO,EAAEM,GAAG,CAAC;MACnDpB,KAAK,EAAEgB,WAAW;MAClBjB,MAAM,EAAES;IACV,CAAC,CAAC;IAEF,OAAOQ,WAAW;EACpB;AACF","ignoreList":[]}
@@ -1,9 +1,8 @@
1
- import { OutputSymbol, OutputSymbolOptions } from "@alloy-js/core";
2
- import { PythonMemberScope } from "./python-member-scope.js";
3
- export interface CreatePythonSymbolOptions extends OutputSymbolOptions {
1
+ import { OutputSpace, OutputSymbol, OutputSymbolOptions } from "@alloy-js/core";
2
+ export interface PythonOutputSymbolOptions extends OutputSymbolOptions {
4
3
  module?: string;
5
4
  }
6
- export interface CreatePythonSymbolFunctionOptions extends CreatePythonSymbolOptions {
5
+ export interface CreatePythonSymbolFunctionOptions extends PythonOutputSymbolOptions {
7
6
  name: string;
8
7
  }
9
8
  /**
@@ -11,9 +10,13 @@ export interface CreatePythonSymbolFunctionOptions extends CreatePythonSymbolOpt
11
10
  */
12
11
  export declare class PythonOutputSymbol extends OutputSymbol {
13
12
  #private;
14
- constructor(name: string, options: CreatePythonSymbolOptions);
13
+ static readonly memberSpaces: readonly ["static", "instance"];
14
+ constructor(name: string, spaces: OutputSpace[] | OutputSpace | undefined, options: PythonOutputSymbolOptions);
15
15
  get module(): string | undefined;
16
- set module(value: string | undefined);
17
- get instanceMemberScope(): PythonMemberScope | undefined;
16
+ get staticMembers(): import("@alloy-js/core").OutputMemberSpace;
17
+ get instanceMembers(): import("@alloy-js/core").OutputMemberSpace;
18
+ get isStaticMemberSymbol(): boolean;
19
+ get isInstanceMemberSymbol(): boolean;
20
+ copy(): PythonOutputSymbol;
18
21
  }
19
22
  //# sourceMappingURL=python-output-symbol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"python-output-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/python-output-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iCACf,SAAQ,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;;gBACtC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB;IAQ5D,IAAI,MAAM,IAIQ,MAAM,GAAG,SAAS,CAFnC;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAEnC;IAED,IAAI,mBAAmB,IACe,iBAAiB,GAAG,SAAS,CAClE;CACF"}
1
+ {"version":3,"file":"python-output-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/python-output-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEhF,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iCACf,SAAQ,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,YAAY;;IAClD,MAAM,CAAC,QAAQ,CAAC,YAAY,kCAAmC;gBAG7D,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,GAAG,SAAS,EAC/C,OAAO,EAAE,yBAAyB;IASpC,IAAI,MAAM,uBAET;IAED,IAAI,aAAa,+CAEhB;IAED,IAAI,eAAe,+CAElB;IAED,IAAI,oBAAoB,YAEvB;IAED,IAAI,sBAAsB,YAEzB;IAED,IAAI;CAYL"}
@@ -3,8 +3,9 @@ import { OutputSymbol } from "@alloy-js/core";
3
3
  * Represents an 'exported' symbol from a .py file. Class, enum, interface etc.
4
4
  */
5
5
  export class PythonOutputSymbol extends OutputSymbol {
6
- constructor(name, options) {
7
- super(name, options);
6
+ static memberSpaces = ["static", "instance"];
7
+ constructor(name, spaces, options) {
8
+ super(name, spaces, options);
8
9
  this.#module = options.module ?? undefined;
9
10
  }
10
11
 
@@ -13,10 +14,27 @@ export class PythonOutputSymbol extends OutputSymbol {
13
14
  get module() {
14
15
  return this.#module;
15
16
  }
16
- set module(value) {
17
- this.#module = value;
17
+ get staticMembers() {
18
+ return this.memberSpaceFor("static");
18
19
  }
19
- get instanceMemberScope() {
20
- return super.instanceMemberScope;
20
+ get instanceMembers() {
21
+ return this.memberSpaceFor("instance");
21
22
  }
22
- }
23
+ get isStaticMemberSymbol() {
24
+ return !this.isInstanceMemberSymbol;
25
+ }
26
+ get isInstanceMemberSymbol() {
27
+ return this.spaces.some(s => s.key === "instance");
28
+ }
29
+ copy() {
30
+ const copy = new PythonOutputSymbol(this.name, undefined, {
31
+ binder: this.binder,
32
+ aliasTarget: this.aliasTarget,
33
+ module: this.module,
34
+ metadata: this.metadata
35
+ });
36
+ this.initializeCopy(copy);
37
+ return copy;
38
+ }
39
+ }
40
+ //# sourceMappingURL=python-output-symbol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["OutputSymbol","PythonOutputSymbol","memberSpaces","constructor","name","spaces","options","module","undefined","staticMembers","memberSpaceFor","instanceMembers","isStaticMemberSymbol","isInstanceMemberSymbol","some","s","key","copy","binder","aliasTarget","metadata","initializeCopy"],"sources":["../../../src/symbols/python-output-symbol.ts"],"sourcesContent":[null],"mappings":"AAAA,SAAsBA,YAAY,QAA6B,gBAAgB;AAW/E;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,SAASD,YAAY,CAAC;EACnD,OAAgBE,YAAY,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC;EAErDC,WAAWA,CACTC,IAAY,EACZC,MAA+C,EAC/CC,OAAkC,EAClC;IACA,KAAK,CAACF,IAAI,EAAEC,MAAM,EAAEC,OAAO,CAAC;IAC5B,IAAI,CAAC,CAACC,MAAM,GAAGD,OAAO,CAACC,MAAM,IAAIC,SAAS;EAC5C;;EAEA;EACA,CAACD,MAAM;EAEP,IAAIA,MAAMA,CAAA,EAAG;IACX,OAAO,IAAI,CAAC,CAACA,MAAM;EACrB;EAEA,IAAIE,aAAaA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACC,cAAc,CAAC,QAAQ,CAAC;EACtC;EAEA,IAAIC,eAAeA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACD,cAAc,CAAC,UAAU,CAAC;EACxC;EAEA,IAAIE,oBAAoBA,CAAA,EAAG;IACzB,OAAO,CAAC,IAAI,CAACC,sBAAsB;EACrC;EAEA,IAAIA,sBAAsBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACR,MAAM,CAACS,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,GAAG,KAAK,UAAU,CAAC;EACtD;EAEAC,IAAIA,CAAA,EAAG;IACL,MAAMA,IAAI,GAAG,IAAIhB,kBAAkB,CAAC,IAAI,CAACG,IAAI,EAAEI,SAAS,EAAE;MACxDU,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBC,WAAW,EAAE,IAAI,CAACA,WAAW;MAC7BZ,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBa,QAAQ,EAAE,IAAI,CAACA;IACjB,CAAC,CAAC;IAEF,IAAI,CAACC,cAAc,CAACJ,IAAI,CAAC;IAEzB,OAAOA,IAAI;EACb;AACF","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { Refkey } from "@alloy-js/core";
1
+ import { Children, Refkey } from "@alloy-js/core";
2
2
  import { PythonOutputSymbol } from "./index.js";
3
- export declare function ref(refkey: Refkey): () => [string, PythonOutputSymbol | undefined];
3
+ export declare function ref(refkey: Refkey): () => [Children, PythonOutputSymbol | undefined];
4
4
  //# sourceMappingURL=reference.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/symbols/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAIL,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,GAAG,CACjB,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAAC,CA6DhD"}
1
+ {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/symbols/reference.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAER,MAAM,EAIP,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAGL,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,GAAG,CACjB,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,QAAQ,EAAE,kBAAkB,GAAG,SAAS,CAAC,CAmDlD"}
@@ -1,60 +1,61 @@
1
- import { memo, OutputSymbolFlags, resolve, untrack, useContext, useMemberScope } from "@alloy-js/core";
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { memo, resolve, untrack, useContext } from "@alloy-js/core";
3
+ import { MemberExpression } from "../components/MemberExpression.js";
2
4
  import { PythonSourceFileContext } from "../components/SourceFile.js";
5
+ import { PythonModuleScope } from "./index.js";
3
6
  export function ref(refkey) {
4
7
  const sourceFile = useContext(PythonSourceFileContext);
5
8
  const resolveResult = resolve(refkey);
6
- const currentScope = useMemberScope();
7
9
  return memo(() => {
8
10
  if (resolveResult.value === undefined) {
9
11
  return ["<Unresolved Symbol>", undefined];
10
12
  }
11
13
  const {
12
- targetDeclaration,
14
+ commonScope,
15
+ lexicalDeclaration,
16
+ symbol,
13
17
  pathDown,
14
18
  memberPath
15
19
  } = resolveResult.value;
16
20
 
17
- // if we resolved a instance member, check if we should be able to access
18
- // it.
19
- if (targetDeclaration.flags & OutputSymbolFlags.InstanceMember) {
20
- if (currentScope?.instanceMembers !== targetDeclaration.scope) {
21
- throw new Error("Cannot resolve member symbols from a different member scope");
22
- }
23
- }
24
-
25
21
  // Where the target declaration is relative to the referencing scope.
26
22
  // * module: target symbol is in a different module
27
23
  // * local: target symbol is within the current module
28
- const targetLocation = pathDown[0]?.kind ?? "local";
24
+ const targetLocation = pathDown[0] instanceof PythonModuleScope ? "module" : "local";
29
25
  let localSymbol;
30
26
  if (targetLocation === "module") {
31
- // Handling of targets in other modules, either created with createModule()
32
- // or from other files.
33
- const symbolPath = [...pathDown.slice(1).map(s => s.owner), targetDeclaration];
34
- const importSymbol = symbolPath[0];
35
- localSymbol = untrack(() => sourceFile.scope.addImport(importSymbol, pathDown[0]));
27
+ localSymbol = untrack(() => sourceFile.scope.addImport(lexicalDeclaration, pathDown[0]));
36
28
  }
37
- if (memberPath && memberPath.length > 0) {
38
- if (localSymbol) {
39
- memberPath[0] = localSymbol;
29
+ const parts = [];
30
+ if (commonScope && commonScope.isMemberScope) {
31
+ // we are referencing a member of a type we are inside
32
+ if (lexicalDeclaration.isInstanceMemberSymbol) {
33
+ parts.push(_$createComponent(MemberExpression.Part, {
34
+ id: "self"
35
+ }));
36
+ } else {
37
+ parts.push(_$createComponent(MemberExpression.Part, {
38
+ get symbol() {
39
+ return commonScope.ownerSymbol;
40
+ }
41
+ }));
40
42
  }
41
- return [buildMemberExpression(memberPath), memberPath.at(-1)];
43
+ parts.push(_$createComponent(MemberExpression.Part, {
44
+ symbol: lexicalDeclaration
45
+ }));
42
46
  } else {
43
- return [buildMemberExpression([localSymbol ?? targetDeclaration]), localSymbol ?? targetDeclaration];
47
+ parts.push(_$createComponent(MemberExpression.Part, {
48
+ symbol: localSymbol ?? lexicalDeclaration
49
+ }));
50
+ }
51
+ for (const part of memberPath) {
52
+ parts.push(_$createComponent(MemberExpression.Part, {
53
+ symbol: part
54
+ }));
44
55
  }
56
+ return [_$createComponent(MemberExpression, {
57
+ children: parts
58
+ }), localSymbol ?? symbol];
45
59
  });
46
60
  }
47
- function buildMemberExpression(path) {
48
- let memberExpr = "";
49
- const base = path[0];
50
- if (base.flags & OutputSymbolFlags.InstanceMember) {
51
- memberExpr += "self";
52
- } else {
53
- memberExpr += base.name;
54
- path = path.slice(1);
55
- }
56
- for (const sym of path) {
57
- memberExpr += `.${sym.name}`;
58
- }
59
- return memberExpr;
60
- }
61
+ //# sourceMappingURL=reference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["memo","resolve","untrack","useContext","MemberExpression","PythonSourceFileContext","PythonModuleScope","ref","refkey","sourceFile","resolveResult","value","undefined","commonScope","lexicalDeclaration","symbol","pathDown","memberPath","targetLocation","localSymbol","scope","addImport","parts","isMemberScope","isInstanceMemberSymbol","push","_$createComponent","Part","id","ownerSymbol","part","children"],"sources":["../../../src/symbols/reference.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAEEA,IAAI,EAEJC,OAAO,EACPC,OAAO,EACPC,UAAU,QACL,gBAAgB;AACvB,SAASC,gBAAgB;AACzB,SAASC,uBAAuB;AAChC,SACEC,iBAAiB,QAGZ,YAAY;AAEnB,OAAO,SAASC,GAAGA,CACjBC,MAAc,EACoC;EAClD,MAAMC,UAAU,GAAGN,UAAU,CAACE,uBAAuB,CAAC;EACtD,MAAMK,aAAa,GAAGT,OAAO,CAC3BO,MACF,CAAC;EAED,OAAOR,IAAI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,EAAE;MAC7BK,KAAK,CAACG,IAAI,CAAAC,iBAAA,CAAEtB,gBAAgB,CAACuB,IAAI;QAACZ,MAAM,EAAEe;MAAI,EAAI,CAAC;IACrD;IAEA,OAAO,CAAAJ,iBAAA,CAAEtB,gBAAgB;MAAC2B,QAAQ,EAAET;IAAK,IAAMH,WAAW,IAAIJ,MAAM,CAAC;EACvE,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1,5 +1,7 @@
1
+ import { PythonLexicalScope } from "./python-lexical-scope.js";
1
2
  import { PythonMemberScope } from "./python-member-scope.js";
2
3
  import { PythonModuleScope } from "./python-module-scope.js";
3
- export type PythonOutputScope = PythonModuleScope | PythonMemberScope;
4
+ export type PythonOutputScope = PythonLexicalScope | PythonModuleScope | PythonMemberScope;
4
5
  export declare function usePythonScope(): PythonOutputScope;
6
+ export declare function usePythonLexicalScope(): PythonLexicalScope | PythonModuleScope;
5
7
  //# sourceMappingURL=scopes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../../src/symbols/scopes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAEtE,wBAAgB,cAAc,IACP,iBAAiB,CACvC"}
1
+ {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../../src/symbols/scopes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,MAAM,iBAAiB,GACzB,kBAAkB,GAClB,iBAAiB,GACjB,iBAAiB,CAAC;AAEtB,wBAAgB,cAAc,IACP,iBAAiB,CACvC;AAED,wBAAgB,qBAAqB,2CAQpC"}
@@ -1,4 +1,13 @@
1
1
  import { useScope } from "@alloy-js/core";
2
+ import { PythonLexicalScope } from "./python-lexical-scope.js";
2
3
  export function usePythonScope() {
3
4
  return useScope();
4
- }
5
+ }
6
+ export function usePythonLexicalScope() {
7
+ const scope = usePythonScope();
8
+ if (!(scope instanceof PythonLexicalScope)) {
9
+ throw new Error("Expected a PythonLexicalScope, but got " + scope.constructor.name);
10
+ }
11
+ return scope;
12
+ }
13
+ //# sourceMappingURL=scopes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useScope","PythonLexicalScope","usePythonScope","usePythonLexicalScope","scope","Error","constructor","name"],"sources":["../../../src/symbols/scopes.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,kBAAkB,QAAQ,2BAA2B;AAS9D,OAAO,SAASC,cAAcA,CAAA,EAAG;EAC/B,OAAOF,QAAQ,CAAC,CAAC;AACnB;AAEA,OAAO,SAASG,qBAAqBA,CAAA,EAAG;EACtC,MAAMC,KAAK,GAAGF,cAAc,CAAC,CAAC;EAC9B,IAAI,EAAEE,KAAK,YAAYH,kBAAkB,CAAC,EAAE;IAC1C,MAAM,IAAII,KAAK,CACb,yCAAyC,GAAGD,KAAK,CAACE,WAAW,CAACC,IAChE,CAAC;EACH;EACA,OAAOH,KAAK;AACd","ignoreList":[]}
package/dist/src/utils.js CHANGED
@@ -9,4 +9,5 @@ export function getCallSignatureProps(props, defaults) {
9
9
  return callSignatureProps;
10
10
  }
11
11
  return defaultProps(callSignatureProps, defaults);
12
- }
12
+ }
13
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["defaultProps","splitProps","getCallSignatureProps","props","defaults","callSignatureProps"],"sources":["../../src/utils.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,YAAY,EAAEC,UAAU,QAAQ,gBAAgB;AAGzD;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnCC,KAAyB,EACzBC,QAAsC,EACtC;EACA,MAAM,CAACC,kBAAkB,CAAC,GAAGJ,UAAU,CAACE,KAAK,EAAE,CAC7C,YAAY,EACZ,gBAAgB,EAChB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,CACb,CAAC;EAEF,IAAI,CAACC,QAAQ,EAAE;IACb,OAAOC,kBAAkB;EAC3B;EAEA,OAAOL,YAAY,CAACK,kBAAkB,EAAED,QAAQ,CAAC;AACnD","ignoreList":[]}
@@ -273,4 +273,5 @@ describe("Call Signature - Parameter Descriptors", () => {
273
273
  [T, U](a: int, b: str = "default_value") -> int
274
274
  `);
275
275
  });
276
- });
276
+ });
277
+ //# sourceMappingURL=callsignatures.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["d","describe","expect","it","py","toSourceText","result","_$createComponent","CallSignatureParameters","parameters","toRenderTo","name","type","optional","default","CallSignature","args","kwargs","typeParameters","returnType","classFunction","instanceFunction","toThrowError"],"sources":["../../test/callsignatures.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,CAAC,QAAQ,wBAAwB;AAC1C,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,OAAO,KAAKC,EAAE,MAAM,iBAAiB;AACrC,SAASC,YAAY;AAErBJ,QAAQ,CAAC,2BAA2B,EAAE,MAAM;EAC1CE,EAAE,CAAC,oCAAoC,EAAE,MAAM;IAC7C,MAAMG,MAAM,GAAGD,YAAY,CAAC,CAAAE,iBAAA,CACzBH,EAAE,CAACI,uBAAuB;MAACC,UAAU,EAAE,CAAC,GAAG,EAAE,GAAG;IAAC,GACnD,CAAC;IACFP,MAAM,CAACI,MAAM,CAAC,CAACI,UAAU,CAACV,CAAC;AAC/B;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;EACFG,EAAE,CAAC,wCAAwC,EAAE,MAAM;IACjD,M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32,15 @@ describe("Python Class", () => {
32
32
  const result = toSourceText([_$createComponent(py.StatementList, {
33
33
  get children() {
34
34
  return [_$createComponent(py.ClassDeclaration, {
35
- name: "Base1"
35
+ name: "Base1",
36
+ get refkey() {
37
+ return refkey("Base1");
38
+ }
36
39
  }), _$createComponent(py.ClassDeclaration, {
37
- name: "Base2"
40
+ name: "Base2",
41
+ get refkey() {
42
+ return refkey("Base2");
43
+ }
38
44
  }), _$createComponent(py.ClassDeclaration, {
39
45
  name: "Baz",
40
46
  get bases() {
@@ -75,7 +81,10 @@ describe("Python Class", () => {
75
81
  path: "mod1.py",
76
82
  get children() {
77
83
  return _$createComponent(py.ClassDeclaration, {
78
- name: "A"
84
+ name: "A",
85
+ get refkey() {
86
+ return refkey("A");
87
+ }
79
88
  });
80
89
  }
81
90
  }), _$createComponent(py.SourceFile, {
@@ -83,6 +92,9 @@ describe("Python Class", () => {
83
92
  get children() {
84
93
  return _$createComponent(py.ClassDeclaration, {
85
94
  name: "B",
95
+ get refkey() {
96
+ return refkey("B");
97
+ },
86
98
  get bases() {
87
99
  return [refkey("A")];
88
100
  }
@@ -135,7 +147,10 @@ describe("Python Class", () => {
135
147
  const result = toSourceText([_$createComponent(py.StatementList, {
136
148
  get children() {
137
149
  return [_$createComponent(py.ClassDeclaration, {
138
- name: "A"
150
+ name: "A",
151
+ get refkey() {
152
+ return refkey("A");
153
+ }
139
154
  }), _$createComponent(py.ClassDeclaration, {
140
155
  name: "B",
141
156
  get children() {
@@ -171,6 +186,8 @@ describe("Python Class", () => {
171
186
  expect(result).toRenderTo(expected);
172
187
  });
173
188
  it("renders a class with class variables like foo: str, and another identical class", () => {
189
+ const fooKey = refkey();
190
+ const barKey = refkey();
174
191
  const result = toSourceText([_$createComponent(py.StatementList, {
175
192
  get children() {
176
193
  return [_$createComponent(py.ClassDeclaration, {
@@ -181,6 +198,7 @@ describe("Python Class", () => {
181
198
  return _$createComponent(py.VariableDeclaration, {
182
199
  name: "foo",
183
200
  type: "str",
201
+ refkey: fooKey,
184
202
  omitNone: true
185
203
  });
186
204
  }
@@ -194,12 +212,13 @@ describe("Python Class", () => {
194
212
  return _$createComponent(py.VariableDeclaration, {
195
213
  name: "foo",
196
214
  type: "str",
215
+ refkey: barKey,
197
216
  omitNone: true
198
217
  });
199
218
  }
200
219
  });
201
220
  }
202
- })];
221
+ }), fooKey, barKey];
203
222
  }
204
223
  })]);
205
224
  const expected = d`
@@ -209,7 +228,8 @@ describe("Python Class", () => {
209
228
  class B:
210
229
  foo: str
211
230
 
212
-
231
+ A.foo
232
+ B.foo
213
233
  `;
214
234
  expect(result).toRenderTo(expected);
215
235
  });
@@ -219,22 +239,32 @@ describe("Python Class - VariableDeclaration", () => {
219
239
  const result = toSourceText([_$createComponent(py.StatementList, {
220
240
  get children() {
221
241
  return [_$createComponent(py.ClassDeclaration, {
242
+ get refkey() {
243
+ return refkey("Base");
244
+ },
222
245
  name: "Base"
223
246
  }), _$createComponent(py.ClassDeclaration, {
247
+ get refkey() {
248
+ return refkey("A");
249
+ },
224
250
  name: "A",
225
251
  get children() {
226
252
  return _$createComponent(py.StatementList, {
227
253
  get children() {
228
254
  return [_$createComponent(py.VariableDeclaration, {
255
+ instanceVariable: true,
229
256
  name: "just_name"
230
257
  }), _$createComponent(py.VariableDeclaration, {
258
+ instanceVariable: true,
231
259
  name: "name_and_type",
232
260
  type: "number"
233
261
  }), _$createComponent(py.VariableDeclaration, {
262
+ instanceVariable: true,
234
263
  name: "name_type_and_value",
235
264
  type: "number",
236
265
  initializer: 12
237
266
  }), _$createComponent(py.VariableDeclaration, {
267
+ instanceVariable: true,
238
268
  name: "class_based",
239
269
  get type() {
240
270
  return refkey("Base");
@@ -275,14 +305,8 @@ describe("Python Class - VariableDeclaration", () => {
275
305
  refkey: v1Rk,
276
306
  type: classRk,
277
307
  get initializer() {
278
- return _$createComponent(py.MemberExpression, {
279
- get children() {
280
- return [_$createComponent(py.MemberExpression.Part, {
281
- refkey: classRk
282
- }), _$createComponent(py.MemberExpression.Part, {
283
- args: true
284
- })];
285
- }
308
+ return _$createComponent(py.ClassInstantiation, {
309
+ target: classRk
286
310
  });
287
311
  }
288
312
  }), [_$memo(() => memberRefkey(v1Rk, classMemberRk))], [_$memo(() => memberRefkey(v1Rk, classMethodRk)), "()"]];
@@ -336,46 +360,56 @@ describe("Python Class - VariableDeclaration", () => {
336
360
  });
337
361
  describe("Python Class - FunctionDeclaration", () => {
338
362
  it("renders a class with class fields and method", () => {
339
- const result = toSourceText([[_$createComponent(py.ClassDeclaration, {
340
- name: "MyClass",
341
- bases: ["BaseClass"],
363
+ const methodRefkey = refkey();
364
+ const classMethodRefkey = refkey();
365
+ const staticMethodRefkey = refkey();
366
+ const result = toSourceText([_$createComponent(py.StatementList, {
342
367
  get children() {
343
- return _$createComponent(py.StatementList, {
368
+ return [_$createComponent(py.ClassDeclaration, {
369
+ name: "MyClass",
370
+ bases: ["BaseClass"],
344
371
  get children() {
345
- return [_$createComponent(py.VariableDeclaration, {
346
- name: "a",
347
- type: "int"
348
- }), _$createComponent(py.VariableDeclaration, {
349
- name: "b",
350
- type: "int"
351
- }), _$createComponent(py.FunctionDeclaration, {
352
- name: "my_method",
353
- parameters: [{
354
- name: "a",
355
- type: "int"
356
- }, {
357
- name: "b",
358
- type: "int"
359
- }],
360
- returnType: "int",
361
- instanceFunction: true,
362
- children: "return a + b"
363
- }), _$createComponent(py.FunctionDeclaration, {
364
- name: "my_class_method",
365
- instanceFunction: false,
366
- classFunction: true,
367
- returnType: "int",
368
- children: "pass"
369
- }), _$createComponent(py.FunctionDeclaration, {
370
- name: "my_standalone_function",
371
- instanceFunction: false,
372
- returnType: "int",
373
- children: "pass"
374
- })];
372
+ return _$createComponent(py.StatementList, {
373
+ get children() {
374
+ return [_$createComponent(py.VariableDeclaration, {
375
+ name: "a",
376
+ type: "int",
377
+ instanceVariable: true
378
+ }), _$createComponent(py.VariableDeclaration, {
379
+ name: "b",
380
+ type: "int",
381
+ instanceVariable: true
382
+ }), _$createComponent(py.FunctionDeclaration, {
383
+ name: "my_method",
384
+ parameters: [{
385
+ name: "a",
386
+ type: "int"
387
+ }, {
388
+ name: "b",
389
+ type: "int"
390
+ }],
391
+ returnType: "int",
392
+ instanceFunction: true,
393
+ refkey: methodRefkey,
394
+ children: "return a + b"
395
+ }), _$createComponent(py.FunctionDeclaration, {
396
+ name: "my_class_method",
397
+ classFunction: true,
398
+ returnType: "int",
399
+ refkey: classMethodRefkey,
400
+ children: "pass"
401
+ }), _$createComponent(py.FunctionDeclaration, {
402
+ name: "my_standalone_function",
403
+ returnType: "int",
404
+ refkey: staticMethodRefkey,
405
+ children: "pass"
406
+ })];
407
+ }
408
+ });
375
409
  }
376
- });
410
+ }), classMethodRefkey, staticMethodRefkey];
377
411
  }
378
- })]]);
412
+ })]);
379
413
  const expected = d`
380
414
  class MyClass(BaseClass):
381
415
  a: int = None
@@ -389,9 +423,11 @@ describe("Python Class - FunctionDeclaration", () => {
389
423
  def my_standalone_function() -> int:
390
424
  pass
391
425
 
392
-
393
-
426
+
427
+ MyClass.my_class_method
428
+ MyClass.my_standalone_function
394
429
  `;
395
430
  expect(result).toRenderTo(expected);
396
431
  });
397
- });
432
+ });
433
+ //# sourceMappingURL=classdeclarations.test.js.map