@alloy-js/java 0.5.0 → 0.6.0

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 (176) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/src/components/Annotation.d.ts +4 -4
  3. package/dist/src/components/Annotation.d.ts.map +1 -1
  4. package/dist/src/components/Annotation.js +27 -5
  5. package/dist/src/components/Annotation.js.map +1 -1
  6. package/dist/src/components/ArgumentList.d.ts +12 -0
  7. package/dist/src/components/ArgumentList.d.ts.map +1 -0
  8. package/dist/src/components/ArgumentList.js +33 -0
  9. package/dist/src/components/ArgumentList.js.map +1 -0
  10. package/dist/src/components/Class.d.ts +4 -4
  11. package/dist/src/components/Class.d.ts.map +1 -1
  12. package/dist/src/components/Class.js +33 -14
  13. package/dist/src/components/Class.js.map +1 -1
  14. package/dist/src/components/Constructor.d.ts +3 -3
  15. package/dist/src/components/Constructor.d.ts.map +1 -1
  16. package/dist/src/components/Constructor.js +9 -10
  17. package/dist/src/components/Constructor.js.map +1 -1
  18. package/dist/src/components/Declaration.d.ts.map +1 -1
  19. package/dist/src/components/Declaration.js +0 -1
  20. package/dist/src/components/Declaration.js.map +1 -1
  21. package/dist/src/components/Enum.d.ts +14 -6
  22. package/dist/src/components/Enum.d.ts.map +1 -1
  23. package/dist/src/components/Enum.js +38 -16
  24. package/dist/src/components/Enum.js.map +1 -1
  25. package/dist/src/components/ExtendsClause.d.ts +9 -0
  26. package/dist/src/components/ExtendsClause.d.ts.map +1 -0
  27. package/dist/src/components/ExtendsClause.js +28 -0
  28. package/dist/src/components/ExtendsClause.js.map +1 -0
  29. package/dist/src/components/ImplementsClause.d.ts +9 -0
  30. package/dist/src/components/ImplementsClause.d.ts.map +1 -0
  31. package/dist/src/components/ImplementsClause.js +28 -0
  32. package/dist/src/components/ImplementsClause.js.map +1 -0
  33. package/dist/src/components/ImportStatement.d.ts +1 -1
  34. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  35. package/dist/src/components/ImportStatement.js +1 -1
  36. package/dist/src/components/ImportStatement.js.map +1 -1
  37. package/dist/src/components/Interface.d.ts +4 -4
  38. package/dist/src/components/Interface.d.ts.map +1 -1
  39. package/dist/src/components/Interface.js +23 -16
  40. package/dist/src/components/Interface.js.map +1 -1
  41. package/dist/src/components/MavenProject.d.ts +4 -2
  42. package/dist/src/components/MavenProject.d.ts.map +1 -1
  43. package/dist/src/components/MavenProject.js +183 -122
  44. package/dist/src/components/MavenProject.js.map +1 -1
  45. package/dist/src/components/Method.d.ts +3 -3
  46. package/dist/src/components/Method.d.ts.map +1 -1
  47. package/dist/src/components/Method.js +8 -4
  48. package/dist/src/components/Method.js.map +1 -1
  49. package/dist/src/{object-modifiers.d.ts → components/Modifiers.d.ts} +6 -3
  50. package/dist/src/components/Modifiers.d.ts.map +1 -0
  51. package/dist/src/components/Modifiers.js +27 -0
  52. package/dist/src/components/Modifiers.js.map +1 -0
  53. package/dist/src/components/Name.js +1 -1
  54. package/dist/src/components/Name.js.map +1 -1
  55. package/dist/src/components/NamedArgumentList.d.ts +11 -0
  56. package/dist/src/components/NamedArgumentList.d.ts.map +1 -0
  57. package/dist/src/components/NamedArgumentList.js +30 -0
  58. package/dist/src/components/NamedArgumentList.js.map +1 -0
  59. package/dist/src/components/ObjectDeclaration.d.ts +3 -3
  60. package/dist/src/components/ObjectDeclaration.d.ts.map +1 -1
  61. package/dist/src/components/ObjectDeclaration.js +8 -4
  62. package/dist/src/components/ObjectDeclaration.js.map +1 -1
  63. package/dist/src/components/PackageDirectory.d.ts.map +1 -1
  64. package/dist/src/components/PackageDirectory.js.map +1 -1
  65. package/dist/src/components/Parameters.d.ts +3 -3
  66. package/dist/src/components/Parameters.d.ts.map +1 -1
  67. package/dist/src/components/Parameters.js +1 -1
  68. package/dist/src/components/Parameters.js.map +1 -1
  69. package/dist/src/components/ProjectDirectory.d.ts.map +1 -1
  70. package/dist/src/components/ProjectDirectory.js +3 -3
  71. package/dist/src/components/ProjectDirectory.js.map +1 -1
  72. package/dist/src/components/Reference.js +1 -1
  73. package/dist/src/components/Reference.js.map +1 -1
  74. package/dist/src/components/SourceFile.d.ts.map +1 -1
  75. package/dist/src/components/SourceFile.js +3 -2
  76. package/dist/src/components/SourceFile.js.map +1 -1
  77. package/dist/src/components/TypeArguments.d.ts +24 -0
  78. package/dist/src/components/TypeArguments.d.ts.map +1 -0
  79. package/dist/src/components/TypeArguments.js +82 -0
  80. package/dist/src/components/TypeArguments.js.map +1 -0
  81. package/dist/src/components/TypeParameters.d.ts +9 -0
  82. package/dist/src/components/TypeParameters.d.ts.map +1 -0
  83. package/dist/src/components/TypeParameters.js +40 -0
  84. package/dist/src/components/TypeParameters.js.map +1 -0
  85. package/dist/src/components/Variable.d.ts +5 -5
  86. package/dist/src/components/Variable.d.ts.map +1 -1
  87. package/dist/src/components/Variable.js +4 -3
  88. package/dist/src/components/Variable.js.map +1 -1
  89. package/dist/src/components/index.d.ts +8 -2
  90. package/dist/src/components/index.d.ts.map +1 -1
  91. package/dist/src/components/index.js +8 -2
  92. package/dist/src/components/index.js.map +1 -1
  93. package/dist/src/components/stc/index.d.ts +37 -17
  94. package/dist/src/components/stc/index.d.ts.map +1 -1
  95. package/dist/src/components/stc/index.js +7 -2
  96. package/dist/src/components/stc/index.js.map +1 -1
  97. package/dist/src/index.d.ts +0 -3
  98. package/dist/src/index.d.ts.map +1 -1
  99. package/dist/src/index.js +0 -3
  100. package/dist/src/index.js.map +1 -1
  101. package/dist/test/maven.test.d.ts +2 -0
  102. package/dist/test/maven.test.d.ts.map +1 -0
  103. package/dist/test/type-arguments.test.d.ts +2 -0
  104. package/dist/test/type-arguments.test.d.ts.map +1 -0
  105. package/dist/test/utils.d.ts +3 -3
  106. package/dist/test/utils.d.ts.map +1 -1
  107. package/dist/tsconfig.tsbuildinfo +1 -1
  108. package/package.json +3 -5
  109. package/src/components/Annotation.tsx +24 -13
  110. package/src/components/ArgumentList.tsx +29 -0
  111. package/src/components/Class.tsx +24 -20
  112. package/src/components/Constructor.tsx +11 -10
  113. package/src/components/Declaration.tsx +1 -3
  114. package/src/components/Enum.tsx +39 -23
  115. package/src/components/ExtendsClause.tsx +19 -0
  116. package/src/components/ImplementsClause.tsx +19 -0
  117. package/src/components/ImportStatement.tsx +5 -2
  118. package/src/components/Interface.tsx +20 -20
  119. package/src/components/MavenProject.tsx +256 -121
  120. package/src/components/Method.tsx +12 -10
  121. package/src/components/Modifiers.tsx +54 -0
  122. package/src/components/NamedArgumentList.tsx +31 -0
  123. package/src/components/ObjectDeclaration.tsx +6 -6
  124. package/src/components/PackageDirectory.tsx +14 -7
  125. package/src/components/Parameters.tsx +4 -4
  126. package/src/components/ProjectDirectory.tsx +7 -5
  127. package/src/components/SourceFile.tsx +15 -11
  128. package/src/components/TypeArguments.tsx +88 -0
  129. package/src/components/TypeParameters.tsx +34 -0
  130. package/src/components/Variable.tsx +6 -6
  131. package/src/components/index.ts +8 -2
  132. package/src/components/stc/index.ts +7 -2
  133. package/src/index.ts +0 -3
  134. package/temp/api.json +1455 -963
  135. package/test/annotation.test.tsx +38 -25
  136. package/test/class.test.tsx +32 -27
  137. package/test/constructor.test.tsx +24 -25
  138. package/test/enum.test.tsx +28 -25
  139. package/test/externals.test.tsx +13 -5
  140. package/test/interface.test.tsx +20 -15
  141. package/test/{maven.tsx → maven.test.tsx} +15 -13
  142. package/test/method.test.tsx +39 -23
  143. package/test/package.test.tsx +2 -3
  144. package/test/reference.test.tsx +14 -12
  145. package/test/{generics.tsx → type-arguments.test.tsx} +6 -6
  146. package/test/utils.tsx +10 -6
  147. package/test/values.test.tsx +1 -3
  148. package/test/variables.test.tsx +7 -7
  149. package/dist/src/arguments.d.ts +0 -15
  150. package/dist/src/arguments.d.ts.map +0 -1
  151. package/dist/src/arguments.js +0 -27
  152. package/dist/src/arguments.js.map +0 -1
  153. package/dist/src/components/Block.d.ts +0 -6
  154. package/dist/src/components/Block.d.ts.map +0 -1
  155. package/dist/src/components/Block.js +0 -4
  156. package/dist/src/components/Block.js.map +0 -1
  157. package/dist/src/components/Generics.d.ts +0 -6
  158. package/dist/src/components/Generics.d.ts.map +0 -1
  159. package/dist/src/components/Generics.js +0 -8
  160. package/dist/src/components/Generics.js.map +0 -1
  161. package/dist/src/generics.d.ts +0 -28
  162. package/dist/src/generics.d.ts.map +0 -1
  163. package/dist/src/generics.js +0 -51
  164. package/dist/src/generics.js.map +0 -1
  165. package/dist/src/object-modifiers.d.ts.map +0 -1
  166. package/dist/src/object-modifiers.js +0 -31
  167. package/dist/src/object-modifiers.js.map +0 -1
  168. package/dist/test/generics.d.ts +0 -2
  169. package/dist/test/generics.d.ts.map +0 -1
  170. package/dist/test/maven.d.ts +0 -2
  171. package/dist/test/maven.d.ts.map +0 -1
  172. package/src/arguments.ts +0 -30
  173. package/src/components/Block.tsx +0 -8
  174. package/src/components/Generics.tsx +0 -12
  175. package/src/generics.ts +0 -59
  176. package/src/object-modifiers.ts +0 -48
package/package.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "@alloy-js/java",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
7
- "development": "./src/index.ts",
8
7
  "import": "./dist/src/index.js"
9
8
  },
10
9
  "./stc": {
11
- "development": "./src/components/stc/index.ts",
12
10
  "import": "./dist/src/components/stc/index.js"
13
11
  }
14
12
  },
@@ -18,7 +16,7 @@
18
16
  "dependencies": {
19
17
  "change-case": "^5.4.4",
20
18
  "pathe": "^1.1.2",
21
- "@alloy-js/core": "~0.5.0"
19
+ "@alloy-js/core": "~0.6.0"
22
20
  },
23
21
  "devDependencies": {
24
22
  "@babel/cli": "^7.24.7",
@@ -29,7 +27,7 @@
29
27
  "concurrently": "^8.2.2",
30
28
  "typescript": "^5.7.3",
31
29
  "vitest": "^3.0.4",
32
- "@alloy-js/babel-preset": "~0.1.1"
30
+ "@alloy-js/babel-preset": "~0.2.0"
33
31
  },
34
32
  "type": "module",
35
33
  "scripts": {
@@ -1,10 +1,10 @@
1
- import { code } from "@alloy-js/core";
2
- import { Child } from "@alloy-js/core/jsx-runtime";
3
- import { collectNamedArguments } from "../arguments.js";
1
+ import { Match, Switch } from "@alloy-js/core";
2
+ import { Children } from "@alloy-js/core/jsx-runtime";
3
+ import { NamedArgumentList } from "./NamedArgumentList.jsx";
4
4
 
5
5
  export interface AnnotationProps {
6
- type: Child;
7
- value?: Record<string, Child>; // Either single value or named values if many
6
+ type: Children;
7
+ value?: Record<string, Children>; // Either single value or named values if many
8
8
  }
9
9
 
10
10
  /**
@@ -12,12 +12,23 @@ export interface AnnotationProps {
12
12
  * For instance, use this if you want to annotate a method with '\@Override'.
13
13
  */
14
14
  export function Annotation(props: AnnotationProps) {
15
- const args =
16
- props.value ?
17
- Object.keys(props.value).length === 1 ?
18
- Object.values(props.value)[0]
19
- : collectNamedArguments(props.value as Record<string, Child>)
20
- : "";
21
- const supplyingArgs = props.value ? code`(${args})` : "";
22
- return code`@${props.type}${supplyingArgs}`;
15
+ return (
16
+ <>
17
+ @{props.type}
18
+ <Switch>
19
+ <Match
20
+ when={
21
+ props.value &&
22
+ Object.keys(props.value).length === 1 &&
23
+ "value" in props.value
24
+ }
25
+ >
26
+ ({props.value!["value"]})
27
+ </Match>
28
+ <Match when={!!props.value}>
29
+ <NamedArgumentList args={props.value!} />
30
+ </Match>
31
+ </Switch>
32
+ </>
33
+ );
23
34
  }
@@ -0,0 +1,29 @@
1
+ import { Children, For, Indent } from "@alloy-js/core";
2
+
3
+ export interface ArgumentListProps {
4
+ args?: Children[];
5
+ omitParensWhenEmpty?: boolean;
6
+ }
7
+
8
+ /**
9
+ * A list of arguments to be passed to a function, constructor, enum, and so
10
+ * forth. Includes parenthesis when arguments are passed, otherwise returns an
11
+ * empty string.
12
+ */
13
+ export function ArgumentList(props: ArgumentListProps) {
14
+ if (props.omitParensWhenEmpty && (!props.args || props.args.length === 0)) {
15
+ return "";
16
+ }
17
+
18
+ return (
19
+ <group>
20
+ (
21
+ <Indent break="soft" trailingBreak>
22
+ <For each={props.args ?? []} comma line>
23
+ {(value) => value}
24
+ </For>
25
+ </Indent>
26
+ )
27
+ </group>
28
+ );
29
+ }
@@ -1,33 +1,37 @@
1
- import { Children, code, Scope } from "@alloy-js/core";
2
- import { collectArguments } from "../arguments.js";
3
- import { collectGenerics, GenericTypes } from "../generics.js";
1
+ import { Block, Children, Scope, Show } from "@alloy-js/core";
4
2
  import { useJavaNamePolicy } from "../name-policy.js";
5
- import { collectModifiers, ObjectModifiers } from "../object-modifiers.js";
6
3
  import { Declaration, DeclarationProps } from "./Declaration.js";
4
+ import { ExtendsClause } from "./ExtendsClause.js";
5
+ import { ImplementsClause } from "./ImplementsClause.js";
6
+ import { ModifierProps, Modifiers } from "./Modifiers.jsx";
7
7
  import { Name } from "./Name.js";
8
+ import { TypeParameters, TypeParametersProps } from "./TypeParameters.jsx";
8
9
 
9
10
  export interface ClassProps
10
11
  extends DeclarationProps,
11
- ObjectModifiers,
12
- GenericTypes {
12
+ ModifierProps,
13
+ TypeParametersProps {
13
14
  extends?: Children;
14
- implements?: Children;
15
+ implements?: Children[];
15
16
  }
16
17
 
17
18
  export function Class(props: ClassProps) {
18
19
  const name = useJavaNamePolicy().getName(props.name, "class");
19
- const extendExpression = props.extends ? code` extends ${props.extends}` : "";
20
- const collectedInterfaces = collectArguments(props.implements);
21
- const implementsExpression = props.implements ?
22
- code` implements ${collectedInterfaces}`
23
- : "";
24
- const generics = props.generics ? collectGenerics(props.generics) : "";
25
- const modifiers = collectModifiers(props);
26
- return <Declaration {...props} name={name}>
27
- {modifiers}class <Name />{generics}{extendExpression}{implementsExpression} {"{"}
28
- <Scope name={name} kind='class'>
29
- {props.children}
20
+
21
+ return (
22
+ <Declaration {...props} name={name}>
23
+ <group>
24
+ <Modifiers {...props} />
25
+ class <Name />
26
+ <Show when={!!props.generics}>
27
+ <TypeParameters generics={props.generics} />
28
+ </Show>
29
+ <ExtendsClause extends={props.extends ? [props.extends] : []} />
30
+ <ImplementsClause interfaces={props.implements} />{" "}
31
+ <Scope name={name} kind="class">
32
+ <Block>{props.children}</Block>
30
33
  </Scope>
31
- {"}"}
32
- </Declaration>;
34
+ </group>
35
+ </Declaration>
36
+ );
33
37
  }
@@ -1,10 +1,10 @@
1
- import { code } from "@alloy-js/core";
1
+ import { Block } from "@alloy-js/core";
2
2
  import { Children } from "@alloy-js/core/jsx-runtime";
3
- import { collectModifiers, ObjectModifiers } from "../object-modifiers.js";
3
+ import { ModifierProps, Modifiers } from "./Modifiers.jsx";
4
4
  import { Name } from "./Name.js";
5
5
  import { Parameters } from "./Parameters.js";
6
6
 
7
- export interface ConstructorProps extends ObjectModifiers {
7
+ export interface ConstructorProps extends ModifierProps {
8
8
  name?: string;
9
9
  parameters?: Record<string, Children>; // Map of parameter name to type
10
10
  children?: Children;
@@ -15,11 +15,12 @@ export interface ConstructorProps extends ObjectModifiers {
15
15
  * If no name is provided, will try take name from class or enum declaration
16
16
  */
17
17
  export function Constructor(props: ConstructorProps) {
18
- const params = <Parameters parameters={props.parameters}></Parameters>;
19
- const modifiers = collectModifiers(props);
20
- return code`
21
- ${modifiers}${props.name ?? <Name />}(${params}) {
22
- ${props.children}
23
- }
24
- `;
18
+ return (
19
+ <>
20
+ <Modifiers {...props} />
21
+ {props.name ?? <Name />}(
22
+ <Parameters parameters={props.parameters} />){" "}
23
+ <Block>{props.children}</Block>
24
+ </>
25
+ );
25
26
  }
@@ -18,7 +18,5 @@ export interface DeclarationProps {
18
18
  */
19
19
  export function Declaration(props: DeclarationProps) {
20
20
  const sym = createJavaSymbol(props);
21
- return <CoreDeclaration symbol={sym}>
22
- {props.children}
23
- </CoreDeclaration>;
21
+ return <CoreDeclaration symbol={sym}>{props.children}</CoreDeclaration>;
24
22
  }
@@ -1,40 +1,56 @@
1
- import { Children, code, Scope } from "@alloy-js/core";
2
- import { collectArguments } from "../arguments.js";
1
+ import { Block, Children, List, Scope } from "@alloy-js/core";
3
2
  import { useJavaNamePolicy } from "../name-policy.js";
4
- import { collectModifiers, ObjectModifiers } from "../object-modifiers.js";
3
+ import { ArgumentList } from "./ArgumentList.jsx";
5
4
  import { Declaration, DeclarationProps } from "./Declaration.js";
5
+ import { ImplementsClause } from "./ImplementsClause.jsx";
6
+ import { ModifierProps, Modifiers } from "./Modifiers.jsx";
6
7
  import { Name } from "./Name.js";
7
8
 
8
- export interface EnumProps extends DeclarationProps, ObjectModifiers {
9
- implements?: Children;
9
+ export interface EnumProps extends DeclarationProps, ModifierProps {
10
+ implements?: Children[];
10
11
  }
11
12
 
12
13
  export function Enum(props: EnumProps) {
13
14
  const name = useJavaNamePolicy().getName(props.name, "enum");
14
- const collectedInterfaces = collectArguments(props.implements);
15
- const implementsExpression = props.implements ?
16
- code` implements ${collectedInterfaces}`
17
- : "";
18
- const modifiers = collectModifiers(props);
19
-
20
- return <Declaration {...props} name={name}>
21
- {modifiers}enum <Name />{implementsExpression} {"{"}
22
- <Scope kind='enum'>
23
- {props.children}
24
- </Scope>
25
- {"}"}
26
- </Declaration>;
15
+
16
+ return (
17
+ <Declaration {...props} name={name}>
18
+ <group>
19
+ <Modifiers {...props} />
20
+ enum <Name />
21
+ <ImplementsClause interfaces={props.implements} />
22
+ </group>{" "}
23
+ <Scope kind="enum">
24
+ <Block>{props.children}</Block>
25
+ </Scope>
26
+ </Declaration>
27
+ );
27
28
  }
28
29
 
29
- export interface EnumMemberProps extends ObjectModifiers {
30
+ export interface EnumMemberProps extends ModifierProps {
30
31
  name: string;
31
- arguments?: Children;
32
+ args?: Children[];
32
33
  }
33
34
 
34
35
  export function EnumMember(props: EnumMemberProps) {
35
- const collectedArgs = collectArguments(props.arguments);
36
- const args = props.arguments ? code`(${collectedArgs})` : "";
37
36
  const name = useJavaNamePolicy().getName(props.name, "enum-member");
38
37
 
39
- return code`${name}${args}`;
38
+ return (
39
+ <>
40
+ {name}
41
+ <ArgumentList args={props.args} omitParensWhenEmpty />
42
+ </>
43
+ );
44
+ }
45
+
46
+ export interface EnumMemberListProps {
47
+ children: Children;
48
+ }
49
+
50
+ /**
51
+ * Create a list of enum members, joining with a comma and a hardline, and
52
+ * ending with a semicolon.
53
+ */
54
+ export function EnumMemberList(props: EnumMemberListProps) {
55
+ return <List children={props.children} comma hardline ender=";" />;
40
56
  }
@@ -0,0 +1,19 @@
1
+ import { Children, List, Show } from "@alloy-js/core";
2
+
3
+ export interface ExtendsClauseProps {
4
+ extends: Children[] | undefined;
5
+ }
6
+
7
+ /**
8
+ * The extends clause for a class or interface.
9
+ */
10
+ export function ExtendsClause(props: ExtendsClauseProps) {
11
+ return (
12
+ <Show when={props.extends !== undefined && props.extends.length > 0}>
13
+ <indent>
14
+ <br />
15
+ extends <List children={props.extends} comma space />
16
+ </indent>
17
+ </Show>
18
+ );
19
+ }
@@ -0,0 +1,19 @@
1
+ import { Children, List, Show } from "@alloy-js/core";
2
+
3
+ export interface ImplementsClauseProps {
4
+ interfaces: Children[] | undefined;
5
+ }
6
+
7
+ /**
8
+ * The implements clause for a class, interface, or enum.
9
+ */
10
+ export function ImplementsClause(props: ImplementsClauseProps) {
11
+ return (
12
+ <Show when={props.interfaces !== undefined && props.interfaces.length > 0}>
13
+ <indent>
14
+ <br />
15
+ implements <List children={props.interfaces} comma space />
16
+ </indent>
17
+ </Show>
18
+ );
19
+ }
@@ -12,8 +12,11 @@ export interface ImportStatementsProps {
12
12
 
13
13
  export function ImportStatements(props: ImportStatementsProps) {
14
14
  return memo(() =>
15
- mapJoin(props.imports, (importProp) =>
16
- () => <ImportStatement {...importProp} />));
15
+ mapJoin(
16
+ () => props.imports,
17
+ (importProp) => () => <ImportStatement {...importProp} />,
18
+ ),
19
+ );
17
20
  }
18
21
 
19
22
  export function ImportStatement(props: ImportSymbol) {
@@ -1,31 +1,31 @@
1
- import { Children, code, Scope } from "@alloy-js/core";
2
- import { collectArguments } from "../arguments.js";
3
- import { collectGenerics, GenericTypes } from "../generics.js";
1
+ import { Block, Children, Scope } from "@alloy-js/core";
4
2
  import { useJavaNamePolicy } from "../name-policy.js";
5
- import { collectModifiers, ObjectModifiers } from "../object-modifiers.js";
6
3
  import { Declaration, DeclarationProps } from "./Declaration.js";
4
+ import { ExtendsClause } from "./ExtendsClause.jsx";
5
+ import { ModifierProps, Modifiers } from "./Modifiers.jsx";
7
6
  import { Name } from "./Name.js";
7
+ import { TypeParameters, TypeParametersProps } from "./TypeParameters.jsx";
8
8
 
9
9
  export interface InterfaceProps
10
10
  extends DeclarationProps,
11
- ObjectModifiers,
12
- GenericTypes {
13
- extends?: Children;
11
+ ModifierProps,
12
+ TypeParametersProps {
13
+ extends?: Children[];
14
14
  }
15
15
 
16
16
  export function Interface(props: InterfaceProps) {
17
17
  const name = useJavaNamePolicy().getName(props.name, "interface");
18
- const collectedInterfaces = collectArguments(props.extends);
19
- const implementsExpression = props.extends ?
20
- code` extends ${collectedInterfaces}`
21
- : "";
22
- const modifiers = collectModifiers(props);
23
- const generics = props.generics ? collectGenerics(props.generics) : "";
24
- return <Declaration {...props} name={name}>
25
- {modifiers}interface <Name />{generics}{implementsExpression} {"{"}
26
- <Scope name={name} kind='interface'>
27
- {props.children}
28
- </Scope>
29
- {"}"}
30
- </Declaration>;
18
+ return (
19
+ <Declaration {...props} name={name}>
20
+ <group>
21
+ <Modifiers {...props} />
22
+ interface <Name />
23
+ <TypeParameters generics={props.generics} />
24
+ <ExtendsClause extends={props.extends} />{" "}
25
+ </group>
26
+ <Scope name={name} kind="interface">
27
+ <Block>{props.children}</Block>
28
+ </Scope>
29
+ </Declaration>
30
+ );
31
31
  }