@alloy-js/java 0.19.0 → 0.20.0-dev.1

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 (63) hide show
  1. package/dist/src/components/Class.d.ts.map +1 -1
  2. package/dist/src/components/Class.js +3 -3
  3. package/dist/src/components/Declaration.d.ts.map +1 -1
  4. package/dist/src/components/Declaration.js +6 -1
  5. package/dist/src/components/Enum.d.ts.map +1 -1
  6. package/dist/src/components/Enum.js +3 -3
  7. package/dist/src/components/Interface.d.ts.map +1 -1
  8. package/dist/src/components/Interface.js +3 -3
  9. package/dist/src/components/LexicalScope.d.ts +8 -0
  10. package/dist/src/components/LexicalScope.d.ts.map +1 -0
  11. package/dist/src/components/LexicalScope.js +23 -0
  12. package/dist/src/components/PackageDirectory.d.ts.map +1 -1
  13. package/dist/src/components/PackageDirectory.js +3 -2
  14. package/dist/src/components/SourceFile.d.ts.map +1 -1
  15. package/dist/src/components/SourceFile.js +3 -3
  16. package/dist/src/create-library.d.ts.map +1 -1
  17. package/dist/src/create-library.js +3 -5
  18. package/dist/src/index.d.ts +1 -0
  19. package/dist/src/index.d.ts.map +1 -1
  20. package/dist/src/index.js +2 -1
  21. package/dist/src/symbols/index.d.ts +1 -0
  22. package/dist/src/symbols/index.d.ts.map +1 -1
  23. package/dist/src/symbols/index.js +1 -0
  24. package/dist/src/symbols/java-lexical-scope.d.ts +6 -0
  25. package/dist/src/symbols/java-lexical-scope.d.ts.map +1 -0
  26. package/dist/src/symbols/java-lexical-scope.js +7 -0
  27. package/dist/src/symbols/java-output-symbol.d.ts +4 -2
  28. package/dist/src/symbols/java-output-symbol.d.ts.map +1 -1
  29. package/dist/src/symbols/java-output-symbol.js +13 -2
  30. package/dist/src/symbols/java-package-scope.d.ts +2 -0
  31. package/dist/src/symbols/java-package-scope.d.ts.map +1 -1
  32. package/dist/src/symbols/java-package-scope.js +4 -0
  33. package/dist/src/symbols/java-project-scope.js +1 -1
  34. package/dist/src/symbols/reference.js +2 -2
  35. package/dist/src/utils.d.ts +3 -0
  36. package/dist/src/utils.d.ts.map +1 -0
  37. package/dist/src/utils.js +12 -0
  38. package/dist/test/constructor.test.js +4 -4
  39. package/dist/test/method.test.js +3 -3
  40. package/dist/test/variables.test.js +3 -3
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +7 -7
  43. package/src/components/Class.tsx +4 -3
  44. package/src/components/Declaration.tsx +7 -1
  45. package/src/components/Enum.tsx +4 -3
  46. package/src/components/Interface.tsx +4 -3
  47. package/src/components/LexicalScope.tsx +31 -0
  48. package/src/components/PackageDirectory.tsx +3 -1
  49. package/src/components/SourceFile.tsx +2 -4
  50. package/src/create-library.ts +2 -4
  51. package/src/index.ts +1 -0
  52. package/src/symbols/index.ts +1 -0
  53. package/src/symbols/java-lexical-scope.ts +9 -0
  54. package/src/symbols/java-output-symbol.ts +24 -3
  55. package/src/symbols/java-package-scope.ts +6 -0
  56. package/src/symbols/java-project-scope.ts +1 -1
  57. package/src/symbols/reference.ts +2 -2
  58. package/src/utils.ts +17 -0
  59. package/temp/api.json +290 -3
  60. package/test/constructor.test.tsx +7 -7
  61. package/test/method.test.tsx +5 -5
  62. package/test/variables.test.tsx +5 -5
  63. package/tsdoc-metadata.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Class.d.ts","sourceRoot":"","sources":["../../../src/components/Class.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAe,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAAe,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EAAE,aAAa,EAAa,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAkB,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3E,MAAM,WAAW,UACf,SAAQ,gBAAgB,EACtB,aAAa,EACb,mBAAmB;IACrB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,YAmBtC"}
1
+ {"version":3,"file":"Class.d.ts","sourceRoot":"","sources":["../../../src/components/Class.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAQ,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAe,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIjE,OAAO,EAAE,aAAa,EAAa,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAkB,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3E,MAAM,WAAW,UACf,SAAQ,gBAAgB,EACtB,aAAa,EACb,mBAAmB;IACrB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,YAmBtC"}
@@ -1,9 +1,10 @@
1
1
  import { createComponent as _$createComponent, memo as _$memo, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
- import { Block, Scope, Show } from "@alloy-js/core";
2
+ import { Block, Show } from "@alloy-js/core";
3
3
  import { useJavaNamePolicy } from "../name-policy.js";
4
4
  import { Declaration } from "./Declaration.js";
5
5
  import { ExtendsClause } from "./ExtendsClause.js";
6
6
  import { ImplementsClause } from "./ImplementsClause.js";
7
+ import { LexicalScope } from "./LexicalScope.js";
7
8
  import { Modifiers } from "./Modifiers.js";
8
9
  import { Name } from "./Name.js";
9
10
  import { TypeParameters } from "./TypeParameters.js";
@@ -33,9 +34,8 @@ export function Class(props) {
33
34
  get interfaces() {
34
35
  return props.implements;
35
36
  }
36
- }), " ", _$createComponent(Scope, {
37
+ }), " ", _$createComponent(LexicalScope, {
37
38
  name: name,
38
- kind: "class",
39
39
  get children() {
40
40
  return _$createComponent(Block, {
41
41
  get children() {
@@ -1 +1 @@
1
- {"version":3,"file":"Declaration.d.ts","sourceRoot":"","sources":["../../../src/components/Declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAER,MAAM,EACP,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,gBAAgB;IAE/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAKlD"}
1
+ {"version":3,"file":"Declaration.d.ts","sourceRoot":"","sources":["../../../src/components/Declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAER,MAAM,EACP,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,gBAAgB;IAE/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAUlD"}
@@ -1,12 +1,17 @@
1
1
  import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
2
  import { Declaration as CoreDeclaration } from "@alloy-js/core";
3
3
  import { JavaOutputSymbol } from "../symbols/java-output-symbol.js";
4
+ import { useLexicalScope } from "../utils.js";
4
5
  /**
5
6
  * Declare a symbol in the program. Declaring classes, interfaces, enums, etc. Should also pass in
6
7
  * access modifier so we can manage access
7
8
  */
8
9
  export function Declaration(props) {
9
- const sym = new JavaOutputSymbol(props.name, {
10
+ const scope = useLexicalScope();
11
+ if (!scope) {
12
+ throw new Error("A lexical scope is required for declaration");
13
+ }
14
+ const sym = new JavaOutputSymbol(props.name, scope.symbols, {
10
15
  refkeys: props.refkey
11
16
  });
12
17
  return _$createComponent(CoreDeclaration, {
@@ -1 +1 @@
1
- {"version":3,"file":"Enum.d.ts","sourceRoot":"","sources":["../../../src/components/Enum.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAe,MAAM,gBAAgB,CAAC;AAG9D,OAAO,EAAe,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAa,MAAM,iBAAiB,CAAC;AAG3D,MAAM,WAAW,SAAU,SAAQ,gBAAgB,EAAE,aAAa;IAChE,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,YAepC;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAShD;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,YAExD"}
1
+ {"version":3,"file":"Enum.d.ts","sourceRoot":"","sources":["../../../src/components/Enum.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAQ,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAAe,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EAAE,aAAa,EAAa,MAAM,iBAAiB,CAAC;AAG3D,MAAM,WAAW,SAAU,SAAQ,gBAAgB,EAAE,aAAa;IAChE,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,YAepC;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAShD;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,YAExD"}
@@ -1,9 +1,10 @@
1
1
  import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
- import { Block, List, Scope } from "@alloy-js/core";
2
+ import { Block, List } from "@alloy-js/core";
3
3
  import { useJavaNamePolicy } from "../name-policy.js";
4
4
  import { ArgumentList } from "./ArgumentList.js";
5
5
  import { Declaration } from "./Declaration.js";
6
6
  import { ImplementsClause } from "./ImplementsClause.js";
7
+ import { LexicalScope } from "./LexicalScope.js";
7
8
  import { Modifiers } from "./Modifiers.js";
8
9
  import { Name } from "./Name.js";
9
10
  export function Enum(props) {
@@ -19,8 +20,7 @@ export function Enum(props) {
19
20
  }
20
21
  })];
21
22
  }
22
- }), " ", _$createComponent(Scope, {
23
- kind: "enum",
23
+ }), " ", _$createComponent(LexicalScope, {
24
24
  get children() {
25
25
  return _$createComponent(Block, {
26
26
  get children() {
@@ -1 +1 @@
1
- {"version":3,"file":"Interface.d.ts","sourceRoot":"","sources":["../../../src/components/Interface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAS,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAe,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAa,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAkB,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3E,MAAM,WAAW,cACf,SAAQ,gBAAgB,EACtB,aAAa,EACb,mBAAmB;IACrB,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,YAe9C"}
1
+ {"version":3,"file":"Interface.d.ts","sourceRoot":"","sources":["../../../src/components/Interface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAe,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGjE,OAAO,EAAE,aAAa,EAAa,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAkB,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3E,MAAM,WAAW,cACf,SAAQ,gBAAgB,EACtB,aAAa,EACb,mBAAmB;IACrB,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,YAe9C"}
@@ -1,8 +1,9 @@
1
1
  import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
- import { Block, Scope } from "@alloy-js/core";
2
+ import { Block } from "@alloy-js/core";
3
3
  import { useJavaNamePolicy } from "../name-policy.js";
4
4
  import { Declaration } from "./Declaration.js";
5
5
  import { ExtendsClause } from "./ExtendsClause.js";
6
+ import { LexicalScope } from "./LexicalScope.js";
6
7
  import { Modifiers } from "./Modifiers.js";
7
8
  import { Name } from "./Name.js";
8
9
  import { TypeParameters } from "./TypeParameters.js";
@@ -23,9 +24,8 @@ export function Interface(props) {
23
24
  }
24
25
  }), " "];
25
26
  }
26
- }), _$createComponent(Scope, {
27
+ }), _$createComponent(LexicalScope, {
27
28
  name: name,
28
- kind: "interface",
29
29
  get children() {
30
30
  return _$createComponent(Block, {
31
31
  get children() {
@@ -0,0 +1,8 @@
1
+ import { ScopePropsWithInfo, ScopePropsWithValue } from "@alloy-js/core";
2
+ export interface LexicalScopePropsWithScopeValue extends ScopePropsWithValue {
3
+ }
4
+ export interface LeixcalScopePropsWithScopeInfo extends ScopePropsWithInfo {
5
+ }
6
+ export type LexicalScopeProps = LexicalScopePropsWithScopeValue | LeixcalScopePropsWithScopeInfo;
7
+ export declare function LexicalScope(props: LexicalScopeProps): import("@alloy-js/core").Children;
8
+ //# sourceMappingURL=LexicalScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LexicalScope.d.ts","sourceRoot":"","sources":["../../../src/components/LexicalScope.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,+BAAgC,SAAQ,mBAAmB;CAAG;AAC/E,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;CAAG;AAE7E,MAAM,MAAM,iBAAiB,GACzB,+BAA+B,GAC/B,8BAA8B,CAAC;AAEnC,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,qCAepD"}
@@ -0,0 +1,23 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { Scope, useScope } from "@alloy-js/core";
3
+ import { JavaLexicalScope } from "../symbols/index.js";
4
+ export function LexicalScope(props) {
5
+ let scope;
6
+ if ("value" in props) {
7
+ if (!(props.value instanceof JavaLexicalScope)) {
8
+ throw new Error("LexicalScope value must be a TSLexicalScope instance");
9
+ }
10
+ scope = props.value;
11
+ } else {
12
+ const parentScope = useScope();
13
+ scope = new JavaLexicalScope(props.name ?? "lexical scope", parentScope, {
14
+ ...props
15
+ });
16
+ }
17
+ return _$createComponent(Scope, {
18
+ value: scope,
19
+ get children() {
20
+ return props.children;
21
+ }
22
+ });
23
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"PackageDirectory.d.ts","sourceRoot":"","sources":["../../../src/components/PackageDirectory.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAMjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,gBAAgB,CAAC;IAExB,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;IAEb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,uBAAuB,EAAE,gBAAgB,CAAC,uBAAuB,CAC7D,CAAC;AAElB,wBAAgB,UAAU,wCAEzB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,YAgD5D"}
1
+ {"version":3,"file":"PackageDirectory.d.ts","sourceRoot":"","sources":["../../../src/components/PackageDirectory.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAOjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,gBAAgB,CAAC;IAExB,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;IAEb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,uBAAuB,EAAE,gBAAgB,CAAC,uBAAuB,CAC7D,CAAC;AAElB,wBAAgB,UAAU,wCAEzB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,YAiD5D"}
@@ -1,5 +1,5 @@
1
1
  import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { createContext, Scope, SourceDirectory, SourceDirectoryContext, useContext } from "@alloy-js/core";
2
+ import { createContext, Scope, SourceDirectory, SourceDirectoryContext, useContext, useScope } from "@alloy-js/core";
3
3
  import { JavaPackageScope } from "../symbols/java-package-scope.js";
4
4
  export const PackageDirectoryContext = createContext();
5
5
  export function usePackage() {
@@ -11,7 +11,8 @@ export function PackageDirectory(props) {
11
11
  const packageNames = props.package.split(".");
12
12
  const packageName = packageNames[0];
13
13
  const fullyQualifiedPackageName = parentPackage ? parentPackage.qualifiedName + "." + packageName : packageName;
14
- const scope = new JavaPackageScope(fullyQualifiedPackageName);
14
+ const parentScope = useScope();
15
+ const scope = new JavaPackageScope(fullyQualifiedPackageName, parentScope);
15
16
  const packagePath = sourceDirectory?.path + "/" + packageName;
16
17
  const packageContext = {
17
18
  scope,
@@ -1 +1 @@
1
- {"version":3,"file":"SourceFile.d.ts","sourceRoot":"","sources":["../../../src/components/SourceFile.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGhB,YAAY,EAGb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAMtD,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC;CACzC;AAED,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,CAAC,iBAAiB,CACjD,CAAC;AAElB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAwDhD"}
1
+ {"version":3,"file":"SourceFile.d.ts","sourceRoot":"","sources":["../../../src/components/SourceFile.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAGhB,YAAY,EAEb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAOtD,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAAC;CACzC;AAED,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,CAAC,iBAAiB,CACjD,CAAC;AAElB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAsDhD"}
@@ -1,6 +1,7 @@
1
1
  import { memo as _$memo, createIntrinsic as _$createIntrinsic, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { SourceFile as CoreSourceFile, createContext, reactive, Scope } from "@alloy-js/core";
2
+ import { SourceFile as CoreSourceFile, createContext, reactive } from "@alloy-js/core";
3
3
  import { ImportStatements } from "./ImportStatement.js";
4
+ import { LexicalScope } from "./LexicalScope.js";
4
5
  import { usePackage } from "./PackageDirectory.js";
5
6
  import { Reference } from "./Reference.js";
6
7
  export const SourceFileContext = createContext();
@@ -52,11 +53,10 @@ export function SourceFile(props) {
52
53
  }), _$createIntrinsic("hbr", {}), _$createIntrinsic("hbr", {})] : undefined), _$createComponent(SourceFileContext.Provider, {
53
54
  value: sfContext,
54
55
  get children() {
55
- return _$createComponent(Scope, {
56
+ return _$createComponent(LexicalScope, {
56
57
  get name() {
57
58
  return props.path;
58
59
  },
59
- kind: "source-file",
60
60
  get children() {
61
61
  return props.children;
62
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"create-library.d.ts","sourceRoot":"","sources":["../../src/create-library.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,MAAM,EAEN,aAAa,EACd,MAAM,gBAAgB,CAAC;AAOxB,MAAM,WAAW,iBAAiB;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;AA0BD,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,iBAAiB,IAAI;KACvD,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAC7D,KAAK,GAAG,MAAM;CACjB,CAAC;AAEF,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,iBAAiB;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,iBAAiB,EAC7D,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC3B,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CAcnC"}
1
+ {"version":3,"file":"create-library.d.ts","sourceRoot":"","sources":["../../src/create-library.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,MAAM,EAEN,aAAa,EACd,MAAM,gBAAgB,CAAC;AAOxB,MAAM,WAAW,iBAAiB;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB;AAwBD,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,iBAAiB,IAAI;KACvD,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAC7D,KAAK,GAAG,MAAM;CACjB,CAAC;AAEF,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,iBAAiB;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,iBAAiB,EAC7D,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC3B,cAAc,CAAC,CAAC,CAAC,GAAG,aAAa,CAcnC"}
@@ -8,14 +8,12 @@ function createSymbols(binder, props, refkeys) {
8
8
  binder
9
9
  });
10
10
  for (const [pkg, symbols] of Object.entries(props.descriptor)) {
11
- const packageScope = new JavaPackageScope(pkg, {
12
- binder,
13
- parent: projectScope
11
+ const packageScope = new JavaPackageScope(pkg, projectScope, {
12
+ binder
14
13
  });
15
14
  for (const symB of symbols) {
16
- new JavaOutputSymbol(symB, {
15
+ new JavaOutputSymbol(symB, packageScope.symbols, {
17
16
  binder,
18
- scope: packageScope,
19
17
  refkeys: refkeys[symB],
20
18
  package: packageScope.name
21
19
  });
@@ -3,4 +3,5 @@ export * from "./components/index.js";
3
3
  export * from "./create-library.js";
4
4
  export * from "./name-policy.js";
5
5
  export * from "./symbols/index.js";
6
+ export * from "./utils.js";
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
package/dist/src/index.js CHANGED
@@ -2,4 +2,5 @@ export * from "./builtins/index.js";
2
2
  export * from "./components/index.js";
3
3
  export * from "./create-library.js";
4
4
  export * from "./name-policy.js";
5
- export * from "./symbols/index.js";
5
+ export * from "./symbols/index.js";
6
+ export * from "./utils.js";
@@ -1,3 +1,4 @@
1
+ export * from "./java-lexical-scope.js";
1
2
  export * from "./java-output-symbol.js";
2
3
  export * from "./java-package-scope.js";
3
4
  export * from "./java-project-scope.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/symbols/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/symbols/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
@@ -1,3 +1,4 @@
1
+ export * from "./java-lexical-scope.js";
1
2
  export * from "./java-output-symbol.js";
2
3
  export * from "./java-package-scope.js";
3
4
  export * from "./java-project-scope.js";
@@ -0,0 +1,6 @@
1
+ import { OutputScope } from "@alloy-js/core";
2
+ export declare class JavaLexicalScope extends OutputScope {
3
+ static readonly declarationSpaces: string[];
4
+ get symbols(): import("@alloy-js/core").OutputSpace;
5
+ }
6
+ //# sourceMappingURL=java-lexical-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"java-lexical-scope.d.ts","sourceRoot":"","sources":["../../../src/symbols/java-lexical-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,gBAAuB,iBAAiB,WAAe;IAEvD,IAAI,OAAO,yCAEV;CACF"}
@@ -0,0 +1,7 @@
1
+ import { OutputScope } from "@alloy-js/core";
2
+ export class JavaLexicalScope extends OutputScope {
3
+ static declarationSpaces = ["symbols"];
4
+ get symbols() {
5
+ return this.spaceFor("symbols");
6
+ }
7
+ }
@@ -1,4 +1,4 @@
1
- import { OutputSymbol, OutputSymbolOptions } from "@alloy-js/core";
1
+ import { OutputSpace, OutputSymbol, OutputSymbolOptions } from "@alloy-js/core";
2
2
  export interface JavaOutputSymbolOptions extends OutputSymbolOptions {
3
3
  package?: string;
4
4
  }
@@ -8,10 +8,12 @@ export interface JavaOutputSymbolOptions extends OutputSymbolOptions {
8
8
  */
9
9
  export declare class JavaOutputSymbol extends OutputSymbol {
10
10
  #private;
11
+ static memberSpaces: readonly ["static", "instance"];
11
12
  /**
12
13
  * Fully qualified package name
13
14
  */
14
15
  get package(): string | undefined;
15
- constructor(name: string, options?: JavaOutputSymbolOptions);
16
+ constructor(name: string, spaces: OutputSpace[] | OutputSpace | undefined, options?: JavaOutputSymbolOptions);
17
+ copy(): JavaOutputSymbol;
16
18
  }
17
19
  //# sourceMappingURL=java-output-symbol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"java-output-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/java-output-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAU,MAAM,gBAAgB,CAAC;AAG3E,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AACD;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;;IAChD;;OAEG;IACH,IAAI,OAAO,uBAEV;gBAGW,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;CAgBhE"}
1
+ {"version":3,"file":"java-output-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/java-output-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,mBAAmB,EAEpB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AACD;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;;IAChD,MAAM,CAAC,YAAY,kCAAmC;IAEtD;;OAEG;IACH,IAAI,OAAO,uBAEV;gBAIC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,GAAG,SAAS,EAC/C,OAAO,GAAE,uBAA4B;IAkBvC,IAAI;CASL"}
@@ -5,6 +5,8 @@ import { usePackage } from "../components/PackageDirectory.js";
5
5
  * Not considered exported if private
6
6
  */
7
7
  export class JavaOutputSymbol extends OutputSymbol {
8
+ static memberSpaces = ["static", "instance"];
9
+
8
10
  /**
9
11
  * Fully qualified package name
10
12
  */
@@ -12,11 +14,11 @@ export class JavaOutputSymbol extends OutputSymbol {
12
14
  return this.#package;
13
15
  }
14
16
  #package;
15
- constructor(name, options = {}) {
17
+ constructor(name, spaces, options = {}) {
16
18
  if (options.refkeys === undefined) {
17
19
  options.refkeys = [refkey(name)];
18
20
  }
19
- super(name, options);
21
+ super(name, spaces, options);
20
22
  if (options.package) {
21
23
  this.#package = options.package;
22
24
  } else {
@@ -24,4 +26,13 @@ export class JavaOutputSymbol extends OutputSymbol {
24
26
  this.#package = options.package ?? parentPackage !== null ? parentPackage?.qualifiedName : "";
25
27
  }
26
28
  }
29
+ copy() {
30
+ const options = this.getCopyOptions();
31
+ const copy = new JavaOutputSymbol(this.name, undefined, {
32
+ ...options,
33
+ package: this.#package
34
+ });
35
+ this.initializeCopy(copy);
36
+ return copy;
37
+ }
27
38
  }
@@ -1,5 +1,7 @@
1
1
  import { OutputScope } from "@alloy-js/core";
2
2
  export declare class JavaPackageScope extends OutputScope {
3
+ static readonly declarationSpaces: readonly ["symbols"];
3
4
  get kind(): string;
5
+ get symbols(): import("@alloy-js/core").OutputSpace;
4
6
  }
5
7
  //# sourceMappingURL=java-package-scope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"java-package-scope.d.ts","sourceRoot":"","sources":["../../../src/symbols/java-package-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,IAAI,IAAI,WAEP;CACF"}
1
+ {"version":3,"file":"java-package-scope.d.ts","sourceRoot":"","sources":["../../../src/symbols/java-package-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,gBAAuB,iBAAiB,uBAAwB;IAEhE,IAAI,IAAI,WAEP;IAED,IAAI,OAAO,yCAEV;CACF"}
@@ -1,6 +1,10 @@
1
1
  import { OutputScope } from "@alloy-js/core";
2
2
  export class JavaPackageScope extends OutputScope {
3
+ static declarationSpaces = ["symbols"];
3
4
  get kind() {
4
5
  return "package";
5
6
  }
7
+ get symbols() {
8
+ return this.spaceFor("symbols");
9
+ }
6
10
  }
@@ -57,7 +57,7 @@ export class JavaProjectScope extends OutputScope {
57
57
  }
58
58
  #gradleProjectConfig;
59
59
  constructor(name, options = {}) {
60
- super(name, options);
60
+ super(name, undefined, options);
61
61
  this.#mavenProjectConfig = options.mavenProjectConfig;
62
62
  this.#gradleProjectConfig = options.gradleProjectConfig;
63
63
  }
@@ -13,8 +13,8 @@ export function ref(refkey) {
13
13
  return "<Unresolved Symbol>";
14
14
  }
15
15
  const {
16
- targetDeclaration
16
+ symbol
17
17
  } = result.value;
18
- return untrack(() => sourceFile.addImport(targetDeclaration));
18
+ return untrack(() => sourceFile.addImport(symbol));
19
19
  });
20
20
  }
@@ -0,0 +1,3 @@
1
+ import { JavaLexicalScope } from "./symbols/java-lexical-scope.js";
2
+ export declare function useLexicalScope(): JavaLexicalScope | undefined;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,wBAAgB,eAAe,IAAI,gBAAgB,GAAG,SAAS,CAa9D"}
@@ -0,0 +1,12 @@
1
+ import { useScope } from "@alloy-js/core";
2
+ import { JavaLexicalScope } from "./symbols/java-lexical-scope.js";
3
+ export function useLexicalScope() {
4
+ const scopeContext = useScope();
5
+ if (!scopeContext) {
6
+ return undefined;
7
+ }
8
+ if (!(scopeContext instanceof JavaLexicalScope)) {
9
+ throw new Error("A lexical scope is required but the current scope is not a lexical scope");
10
+ }
11
+ return scopeContext;
12
+ }
@@ -1,11 +1,11 @@
1
1
  import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { code, Declaration, refkey } from "@alloy-js/core";
2
+ import { code, refkey } from "@alloy-js/core";
3
3
  import { d } from "@alloy-js/core/testing";
4
4
  import { expect, it } from "vitest";
5
5
  import * as jv from "../src/components/index.js";
6
6
  import { assertFileContents, testRender, toSourceText } from "./utils.js";
7
7
  it("works", () => {
8
- const res = toSourceText([_$createComponent(Declaration, {
8
+ const res = toSourceText([_$createComponent(jv.Declaration, {
9
9
  name: "TestClass",
10
10
  get children() {
11
11
  return code`
@@ -27,7 +27,7 @@ it("works", () => {
27
27
  `);
28
28
  });
29
29
  it("takes name from class", () => {
30
- const res = toSourceText([_$createComponent(Declaration, {
30
+ const res = toSourceText([_$createComponent(jv.Declaration, {
31
31
  name: "TestClass",
32
32
  get children() {
33
33
  return code`
@@ -65,7 +65,7 @@ it("declares parameters", () => {
65
65
  return _$createComponent(jv.SourceFile, {
66
66
  path: "TestClass.java",
67
67
  get children() {
68
- return _$createComponent(Declaration, {
68
+ return _$createComponent(jv.Declaration, {
69
69
  name: "TestClass",
70
70
  get children() {
71
71
  return code`
@@ -1,5 +1,5 @@
1
1
  import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
- import { code, Declaration, refkey } from "@alloy-js/core";
2
+ import { code, refkey } from "@alloy-js/core";
3
3
  import { d } from "@alloy-js/core/testing";
4
4
  import { describe, expect, it } from "vitest";
5
5
  import * as jv from "../src/components/index.js";
@@ -173,7 +173,7 @@ it("declares parameters", () => {
173
173
  return _$createComponent(jv.SourceFile, {
174
174
  path: "Test.java",
175
175
  get children() {
176
- return _$createComponent(Declaration, {
176
+ return _$createComponent(jv.Declaration, {
177
177
  name: "Test",
178
178
  get children() {
179
179
  return code`
@@ -229,7 +229,7 @@ it("defines generics", () => {
229
229
  return _$createComponent(jv.SourceFile, {
230
230
  path: "Test.java",
231
231
  get children() {
232
- return _$createComponent(Declaration, {
232
+ return _$createComponent(jv.Declaration, {
233
233
  name: "Test",
234
234
  get children() {
235
235
  return code`
@@ -1,5 +1,5 @@
1
1
  import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { code, Declaration, refkey } from "@alloy-js/core";
2
+ import { code, refkey } from "@alloy-js/core";
3
3
  import { d } from "@alloy-js/core/testing";
4
4
  import { expect, it } from "vitest";
5
5
  import * as jv from "../src/components/index.js";
@@ -52,7 +52,7 @@ it("works with external type", () => {
52
52
  return _$createComponent(jv.SourceFile, {
53
53
  path: "Test.java",
54
54
  get children() {
55
- return _$createComponent(Declaration, {
55
+ return _$createComponent(jv.Declaration, {
56
56
  name: "Test",
57
57
  get children() {
58
58
  return code`
@@ -103,7 +103,7 @@ it("declares new object", () => {
103
103
  return _$createComponent(jv.SourceFile, {
104
104
  path: "Test.java",
105
105
  get children() {
106
- return _$createComponent(Declaration, {
106
+ return _$createComponent(jv.Declaration, {
107
107
  name: "Test",
108
108
  get children() {
109
109
  return code`