@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
@@ -1,56 +1,69 @@
1
- import { code } from "@alloy-js/core";
2
1
  import { d } from "@alloy-js/core/testing";
3
2
  import { expect, it } from "vitest";
4
3
  import * as jv from "../src/components/index.js";
5
4
  import { toSourceText } from "./utils.js";
6
5
 
7
6
  it("Annotates object", () => {
8
- const res = toSourceText(code`
9
- ${<jv.Annotation type="Getter" />}
10
- class TestClass {
11
- }
12
- `);
7
+ const res = toSourceText(<jv.Annotation type="Getter" />);
13
8
 
14
9
  expect(res).toBe(d`
15
10
  package me.test.code;
16
11
 
17
12
  @Getter
18
- class TestClass {
19
- }
20
13
  `);
21
14
  });
22
15
 
23
16
  it("Takes single parameter", () => {
24
- const res = toSourceText(code`
25
- ${<jv.Annotation type="Getter" value={{ value: <jv.Value value='Test' /> }} />}
26
- class TestClass {
27
- }
28
- `);
17
+ const res = toSourceText(
18
+ <jv.Annotation
19
+ type="Getter"
20
+ value={{ value: <jv.Value value="Test" /> }}
21
+ />,
22
+ );
29
23
 
30
24
  expect(res).toBe(d`
31
25
  package me.test.code;
32
26
 
33
27
  @Getter("Test")
34
- class TestClass {
35
- }
36
28
  `);
37
29
  });
38
30
 
39
31
  it("Takes named parameters", () => {
40
- const res = toSourceText(code`
41
- ${<jv.Annotation type="Getter" value={{
42
- value1: <jv.Value value='Tester' />,
43
- value2: <jv.Value value='Tested' />
44
- }} />}
45
- class TestClass {
46
- }
47
- `);
32
+ const res = toSourceText(
33
+ <jv.Annotation
34
+ type="Getter"
35
+ value={{
36
+ value1: <jv.Value value="Tester" />,
37
+ value2: <jv.Value value="Tested" />,
38
+ }}
39
+ />,
40
+ );
48
41
 
49
42
  expect(res).toBe(d`
50
43
  package me.test.code;
51
44
 
52
45
  @Getter(value1 = "Tester", value2 = "Tested")
53
- class TestClass {
54
- }
46
+ `);
47
+ });
48
+
49
+ it("breaks named parameters across multiple lines", () => {
50
+ const res = toSourceText(
51
+ <jv.Annotation
52
+ type="Getter"
53
+ value={{
54
+ value1: <jv.Value value="Tester" />,
55
+ value2: <jv.Value value="Tested" />,
56
+ }}
57
+ />,
58
+ { printWidth: 20 },
59
+ );
60
+
61
+ expect(res).toBe(d`
62
+ package me.test.code;
63
+
64
+ @Getter(
65
+ value1 = "Tester",
66
+ value2 = "Tested"
67
+ )
55
68
  `);
56
69
  });
@@ -6,16 +6,13 @@ import { assertFileContents, testRender, toSourceText } from "./utils.js";
6
6
 
7
7
  it("works", () => {
8
8
  const res = toSourceText(
9
- <jv.Class public abstract final name='TestClass'>
10
- </jv.Class>,
9
+ <jv.Class public abstract final name="TestClass"></jv.Class>,
11
10
  );
12
11
 
13
12
  expect(res).toBe(d`
14
13
  package me.test.code;
15
14
 
16
- public abstract final class TestClass {
17
-
18
- }
15
+ public abstract final class TestClass {}
19
16
  `);
20
17
  });
21
18
 
@@ -23,13 +20,15 @@ it("extends class", () => {
23
20
  const res = testRender(
24
21
  <>
25
22
  <jv.SourceFile path="TestSuperclass.java">
26
- <jv.Class public name='TestSuperclass'>
27
- </jv.Class>
23
+ <jv.Class public name="TestSuperclass"></jv.Class>
28
24
  </jv.SourceFile>
29
- <jv.PackageDirectory package='import'>
25
+ <jv.PackageDirectory package="import">
30
26
  <jv.SourceFile path="TestSubclass.java">
31
- <jv.Class public name='TestSubclass' extends={refkey("TestSuperclass")}>
32
- </jv.Class>
27
+ <jv.Class
28
+ public
29
+ name="TestSubclass"
30
+ extends={refkey("TestSuperclass")}
31
+ ></jv.Class>
33
32
  </jv.SourceFile>
34
33
  </jv.PackageDirectory>
35
34
  </>,
@@ -41,9 +40,7 @@ it("extends class", () => {
41
40
 
42
41
  import me.test.code.TestSuperclass;
43
42
 
44
- public class TestSubclass extends TestSuperclass {
45
-
46
- }
43
+ public class TestSubclass extends TestSuperclass {}
47
44
  `,
48
45
  });
49
46
  });
@@ -52,7 +49,7 @@ it("implements interfaces", () => {
52
49
  const res = testRender(
53
50
  <>
54
51
  <jv.SourceFile path="InterfaceOne.java">
55
- <jv.Declaration name='InterfaceOne'>
52
+ <jv.Declaration name="InterfaceOne">
56
53
  {code`
57
54
  public interface InterfaceOne {
58
55
  }
@@ -60,7 +57,7 @@ it("implements interfaces", () => {
60
57
  </jv.Declaration>
61
58
  </jv.SourceFile>
62
59
  <jv.SourceFile path="InterfaceTwo.java">
63
- <jv.Declaration name='InterfaceTwo'>
60
+ <jv.Declaration name="InterfaceTwo">
64
61
  {code`
65
62
  public interface InterfaceTwo {
66
63
  }
@@ -69,8 +66,11 @@ it("implements interfaces", () => {
69
66
  </jv.SourceFile>
70
67
  <jv.PackageDirectory package="import">
71
68
  <jv.SourceFile path="TestSubclass.java">
72
- <jv.Class public name="TestSubclass" implements={[refkey("InterfaceOne"), refkey("InterfaceTwo")]}>
73
- </jv.Class>
69
+ <jv.Class
70
+ public
71
+ name="TestSubclass"
72
+ implements={[refkey("InterfaceOne"), refkey("InterfaceTwo")]}
73
+ ></jv.Class>
74
74
  </jv.SourceFile>
75
75
  </jv.PackageDirectory>
76
76
  </>,
@@ -83,9 +83,7 @@ it("implements interfaces", () => {
83
83
  import me.test.code.InterfaceOne;
84
84
  import me.test.code.InterfaceTwo;
85
85
 
86
- public class TestSubclass implements InterfaceOne, InterfaceTwo {
87
-
88
- }
86
+ public class TestSubclass implements InterfaceOne, InterfaceTwo {}
89
87
  `,
90
88
  });
91
89
  });
@@ -94,7 +92,7 @@ it("defines generics", () => {
94
92
  const res = testRender(
95
93
  <>
96
94
  <jv.SourceFile path="TypeOne.java">
97
- <jv.Declaration name='TypeOne'>
95
+ <jv.Declaration name="TypeOne">
98
96
  {code`
99
97
  public interface TypeOne {
100
98
  }
@@ -102,7 +100,7 @@ it("defines generics", () => {
102
100
  </jv.Declaration>
103
101
  </jv.SourceFile>
104
102
  <jv.SourceFile path="TypeTwo.java">
105
- <jv.Declaration name='TypeTwo'>
103
+ <jv.Declaration name="TypeTwo">
106
104
  {code`
107
105
  public interface TypeTwo {
108
106
  }
@@ -111,11 +109,20 @@ it("defines generics", () => {
111
109
  </jv.SourceFile>
112
110
  <jv.PackageDirectory package="import">
113
111
  <jv.SourceFile path="TestGenerics.java">
114
- <jv.Class public name="TestGenerics" generics={{ T: refkey("TypeOne"), N: refkey("TypeTwo"), J: 'String', K: ''}}>
115
- </jv.Class>
112
+ <jv.Class
113
+ public
114
+ name="TestGenerics"
115
+ generics={{
116
+ T: refkey("TypeOne"),
117
+ N: refkey("TypeTwo"),
118
+ J: "String",
119
+ K: "",
120
+ }}
121
+ ></jv.Class>
116
122
  </jv.SourceFile>
117
123
  </jv.PackageDirectory>
118
124
  </>,
125
+ { printWidth: 100 },
119
126
  );
120
127
 
121
128
  assertFileContents(res, {
@@ -125,9 +132,7 @@ it("defines generics", () => {
125
132
  import me.test.code.TypeOne;
126
133
  import me.test.code.TypeTwo;
127
134
 
128
- public class TestGenerics<T extends TypeOne, N extends TypeTwo, J extends String, K> {
129
-
130
- }
135
+ public class TestGenerics<T extends TypeOne, N extends TypeTwo, J extends String, K> {}
131
136
  `,
132
137
  });
133
138
  });
@@ -7,23 +7,21 @@ import { assertFileContents, testRender, toSourceText } from "./utils.js";
7
7
  it("works", () => {
8
8
  const res = toSourceText(
9
9
  <>
10
- <Declaration name="TestClass">
11
- {code`
10
+ <Declaration name="TestClass">
11
+ {code`
12
12
  public class TestClass {
13
- ${<jv.Constructor public name="TestClass" />}
13
+ ${(<jv.Constructor public name="TestClass" />)}
14
14
  }
15
15
  `}
16
- </Declaration>
17
- </>,
16
+ </Declaration>
17
+ </>,
18
18
  );
19
19
 
20
20
  expect(res).toBe(d`
21
21
  package me.test.code;
22
22
 
23
23
  public class TestClass {
24
- public TestClass() {
25
-
26
- }
24
+ public TestClass() {}
27
25
  }
28
26
  `);
29
27
  });
@@ -31,23 +29,21 @@ it("works", () => {
31
29
  it("takes name from class", () => {
32
30
  const res = toSourceText(
33
31
  <>
34
- <Declaration name="TestClass">
35
- {code`
32
+ <Declaration name="TestClass">
33
+ {code`
36
34
  public class TestClass {
37
- ${<jv.Constructor public />}
35
+ ${(<jv.Constructor public />)}
38
36
  }
39
37
  `}
40
- </Declaration>
41
- </>,
38
+ </Declaration>
39
+ </>,
42
40
  );
43
41
 
44
42
  expect(res).toBe(d`
45
43
  package me.test.code;
46
44
 
47
45
  public class TestClass {
48
- public TestClass() {
49
-
50
- }
46
+ public TestClass() {}
51
47
  }
52
48
  `);
53
49
  });
@@ -56,22 +52,27 @@ it("declares parameters", () => {
56
52
  const res = testRender(
57
53
  <>
58
54
  <jv.SourceFile path="Model.java">
59
- <jv.Declaration name='Model'>
55
+ <jv.Declaration name="Model">
60
56
  {code`
61
57
  public class Model {
62
58
  }
63
59
  `}
64
60
  </jv.Declaration>
65
61
  </jv.SourceFile>
66
- <jv.PackageDirectory package='imports'>
62
+ <jv.PackageDirectory package="imports">
67
63
  <jv.SourceFile path="TestClass.java">
68
64
  <Declaration name="TestClass">
69
65
  {code`
70
66
  public class TestClass {
71
- ${<jv.Constructor public parameters={{
72
- type: refkey("Model"),
73
- age: "int"
74
- }} />}
67
+ ${(
68
+ <jv.Constructor
69
+ public
70
+ parameters={{
71
+ type: refkey("Model"),
72
+ age: "int",
73
+ }}
74
+ />
75
+ )}
75
76
  }
76
77
  `}
77
78
  </Declaration>
@@ -87,9 +88,7 @@ it("declares parameters", () => {
87
88
  import me.test.code.Model;
88
89
 
89
90
  public class TestClass {
90
- public TestClass(Model type, int age) {
91
-
92
- }
91
+ public TestClass(Model type, int age) {}
93
92
  }
94
93
  `,
95
94
  });
@@ -5,15 +5,12 @@ import * as jv from "../src/components/index.js";
5
5
  import { assertFileContents, testRender, toSourceText } from "./utils.js";
6
6
 
7
7
  it("works", () => {
8
- const res = toSourceText(<jv.Enum public name="TestEnum">
9
- </jv.Enum>);
8
+ const res = toSourceText(<jv.Enum public name="TestEnum"></jv.Enum>);
10
9
 
11
10
  expect(res).toBe(d`
12
11
  package me.test.code;
13
12
 
14
- public enum TestEnum {
15
-
16
- }
13
+ public enum TestEnum {}
17
14
  `);
18
15
  });
19
16
 
@@ -21,7 +18,7 @@ it("implements interfaces", () => {
21
18
  const res = testRender(
22
19
  <>
23
20
  <jv.SourceFile path="InterfaceOne.java">
24
- <jv.Declaration name='InterfaceOne'>
21
+ <jv.Declaration name="InterfaceOne">
25
22
  {code`
26
23
  public interface InterfaceOne {
27
24
  }
@@ -29,7 +26,7 @@ it("implements interfaces", () => {
29
26
  </jv.Declaration>
30
27
  </jv.SourceFile>
31
28
  <jv.SourceFile path="InterfaceTwo.java">
32
- <jv.Declaration name='InterfaceTwo'>
29
+ <jv.Declaration name="InterfaceTwo">
33
30
  {code`
34
31
  public interface InterfaceTwo {
35
32
  }
@@ -38,11 +35,15 @@ it("implements interfaces", () => {
38
35
  </jv.SourceFile>
39
36
  <jv.PackageDirectory package="import">
40
37
  <jv.SourceFile path="TestEnum.java">
41
- <jv.Enum public name="TestEnum" implements={[refkey("InterfaceOne"), refkey("InterfaceTwo")]}>
42
- </jv.Enum>
38
+ <jv.Enum
39
+ public
40
+ name="TestEnum"
41
+ implements={[refkey("InterfaceOne"), refkey("InterfaceTwo")]}
42
+ ></jv.Enum>
43
43
  </jv.SourceFile>
44
44
  </jv.PackageDirectory>
45
45
  </>,
46
+ { printWidth: 100 },
46
47
  );
47
48
 
48
49
  assertFileContents(res, {
@@ -52,9 +53,7 @@ it("implements interfaces", () => {
52
53
  import me.test.code.InterfaceOne;
53
54
  import me.test.code.InterfaceTwo;
54
55
 
55
- public enum TestEnum implements InterfaceOne, InterfaceTwo {
56
-
57
- }
56
+ public enum TestEnum implements InterfaceOne, InterfaceTwo {}
58
57
  `,
59
58
  });
60
59
  });
@@ -62,8 +61,10 @@ it("implements interfaces", () => {
62
61
  it("declares members", () => {
63
62
  const res = toSourceText(
64
63
  <jv.Enum public name="TestEnum">
65
- <jv.EnumMember name="ONE" />,
66
- <jv.EnumMember name="TWO" />;
64
+ <jv.EnumMemberList>
65
+ <jv.EnumMember name="ONE" />
66
+ <jv.EnumMember name="TWO" />
67
+ </jv.EnumMemberList>
67
68
  </jv.Enum>,
68
69
  );
69
70
 
@@ -80,13 +81,17 @@ it("declares members", () => {
80
81
  it("declares members with arguments", () => {
81
82
  const res = toSourceText(
82
83
  <jv.Enum public name="TestEnum">
83
- <jv.EnumMember name="ONE" arguments={[<jv.Value value="One" />]} />,
84
- <jv.EnumMember name="TWO" arguments={[<jv.Value value="Two" />]} />;
85
-
86
- <jv.Constructor parameters={{
87
- value: "String"
88
- }}>
89
- </jv.Constructor>
84
+ <jv.EnumMemberList>
85
+ <jv.EnumMember name="ONE" args={[<jv.Value value="One" />]} />
86
+ <jv.EnumMember name="TWO" args={[<jv.Value value="Two" />]} />
87
+ </jv.EnumMemberList>
88
+ <hbr />
89
+ <hbr />
90
+ <jv.Constructor
91
+ parameters={{
92
+ value: "String",
93
+ }}
94
+ ></jv.Constructor>
90
95
  </jv.Enum>,
91
96
  );
92
97
 
@@ -96,10 +101,8 @@ it("declares members with arguments", () => {
96
101
  public enum TestEnum {
97
102
  ONE("One"),
98
103
  TWO("Two");
99
-
100
- TestEnum(String value) {
101
-
102
- }
104
+
105
+ TestEnum(String value) {}
103
106
  }
104
107
  `);
105
108
  });
@@ -1,4 +1,4 @@
1
- import { Output, render } from "@alloy-js/core";
1
+ import { Output, render, StatementList } from "@alloy-js/core";
2
2
  import { d } from "@alloy-js/core/testing";
3
3
  import { expect, it } from "vitest";
4
4
  import * as jv from "../src/components/index.js";
@@ -19,11 +19,19 @@ it("uses import from external library", () => {
19
19
  const res = render(
20
20
  <Output externals={[testLib]}>
21
21
  <jv.PackageDirectory package="me.test.code">
22
- <jv.SourceFile path='TestImport.java'>
22
+ <jv.SourceFile path="TestImport.java">
23
23
  <jv.Class public name="TestImport">
24
- <jv.ObjectDeclaration type={testLib["TestModel"]} name="myTestModel" />
25
- <jv.ObjectDeclaration type={testLib["TestClass"]} name="myTestClass" />
26
- <jv.ObjectDeclaration type={testLib["Tester"]} name="myTester" />
24
+ <StatementList>
25
+ <jv.ObjectDeclaration
26
+ type={testLib["TestModel"]}
27
+ name="myTestModel"
28
+ />
29
+ <jv.ObjectDeclaration
30
+ type={testLib["TestClass"]}
31
+ name="myTestClass"
32
+ />
33
+ <jv.ObjectDeclaration type={testLib["Tester"]} name="myTester" />
34
+ </StatementList>
27
35
  </jv.Class>
28
36
  </jv.SourceFile>
29
37
  </jv.PackageDirectory>
@@ -6,16 +6,13 @@ import { assertFileContents, testRender, toSourceText } from "./utils.js";
6
6
 
7
7
  it("works", () => {
8
8
  const res = toSourceText(
9
- <jv.Interface public name="TestInterface">
10
- </jv.Interface>,
9
+ <jv.Interface public name="TestInterface"></jv.Interface>,
11
10
  );
12
11
 
13
12
  expect(res).toBe(d`
14
13
  package me.test.code;
15
14
 
16
- public interface TestInterface {
17
-
18
- }
15
+ public interface TestInterface {}
19
16
  `);
20
17
  });
21
18
 
@@ -30,8 +27,11 @@ it("extends other interfaces", () => {
30
27
  </jv.SourceFile>
31
28
  <jv.PackageDirectory package="import">
32
29
  <jv.SourceFile path="TestInterface.java">
33
- <jv.Interface public name="TestInterface" extends={[refkey("InterfaceOne"), refkey("InterfaceTwo")]}>
34
- </jv.Interface>
30
+ <jv.Interface
31
+ public
32
+ name="TestInterface"
33
+ extends={[refkey("InterfaceOne"), refkey("InterfaceTwo")]}
34
+ ></jv.Interface>
35
35
  </jv.SourceFile>
36
36
  </jv.PackageDirectory>
37
37
  </>,
@@ -44,9 +44,7 @@ it("extends other interfaces", () => {
44
44
  import me.test.code.InterfaceOne;
45
45
  import me.test.code.InterfaceTwo;
46
46
 
47
- public interface TestInterface extends InterfaceOne, InterfaceTwo {
48
-
49
- }
47
+ public interface TestInterface extends InterfaceOne, InterfaceTwo {}
50
48
  `,
51
49
  });
52
50
  });
@@ -62,11 +60,20 @@ it("defines generics", () => {
62
60
  </jv.SourceFile>
63
61
  <jv.PackageDirectory package="import">
64
62
  <jv.SourceFile path="TestGenerics.java">
65
- <jv.Interface public name="TestGenerics" generics={{ T: refkey("TypeOne"), N: refkey("TypeTwo"), J: 'String', K: ''}}>
66
- </jv.Interface>
63
+ <jv.Interface
64
+ public
65
+ name="TestGenerics"
66
+ generics={{
67
+ T: refkey("TypeOne"),
68
+ N: refkey("TypeTwo"),
69
+ J: "String",
70
+ K: "",
71
+ }}
72
+ ></jv.Interface>
67
73
  </jv.SourceFile>
68
74
  </jv.PackageDirectory>
69
75
  </>,
76
+ { printWidth: 100 },
70
77
  );
71
78
 
72
79
  assertFileContents(res, {
@@ -76,9 +83,7 @@ it("defines generics", () => {
76
83
  import me.test.code.TypeOne;
77
84
  import me.test.code.TypeTwo;
78
85
 
79
- public interface TestGenerics<T extends TypeOne, N extends TypeTwo, J extends String, K> {
80
-
81
- }
86
+ public interface TestGenerics<T extends TypeOne, N extends TypeTwo, J extends String, K> {}
82
87
  `,
83
88
  });
84
89
  });
@@ -2,7 +2,7 @@ import { Output, render } from "@alloy-js/core";
2
2
  import { it } from "vitest";
3
3
  import { ProjectDirectory } from "../src/components/index.js";
4
4
  import { MavenProjectConfig } from "../src/index.js";
5
- import { assertFileContents } from "./utils.js";
5
+ import { assertFileContents } from "./utils.jsx";
6
6
 
7
7
  it("generates barebones pom.xml file", () => {
8
8
  const projectConfig: MavenProjectConfig = {
@@ -14,8 +14,10 @@ it("generates barebones pom.xml file", () => {
14
14
 
15
15
  const res = render(
16
16
  <Output>
17
- <ProjectDirectory name='TestMavenProject' mavenProjectConfig={projectConfig}>
18
- </ProjectDirectory>
17
+ <ProjectDirectory
18
+ name="TestMavenProject"
19
+ mavenProjectConfig={projectConfig}
20
+ ></ProjectDirectory>
19
21
  </Output>,
20
22
  );
21
23
 
@@ -25,18 +27,17 @@ it("generates barebones pom.xml file", () => {
25
27
  <project xmlns="http://maven.apache.org/POM/4.0.0"
26
28
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
27
29
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
28
-
30
+
29
31
  <modelVersion>4.0.0</modelVersion>
30
32
  <groupId>me.example</groupId>
31
33
  <artifactId>test</artifactId>
32
34
  <version>1.0.0</version>
33
-
35
+
34
36
  <properties>
35
37
  <maven.compiler.source>8</maven.compiler.source>
36
38
  <maven.compiler.target>8</maven.compiler.target>
37
39
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
38
40
  </properties>
39
-
40
41
  </project>
41
42
  `,
42
43
  });
@@ -123,8 +124,10 @@ it("generates complex configuration", () => {
123
124
 
124
125
  const res = render(
125
126
  <Output>
126
- <ProjectDirectory name='TestMavenProject' mavenProjectConfig={projectConfig}>
127
- </ProjectDirectory>
127
+ <ProjectDirectory
128
+ name="TestMavenProject"
129
+ mavenProjectConfig={projectConfig}
130
+ ></ProjectDirectory>
128
131
  </Output>,
129
132
  );
130
133
 
@@ -134,18 +137,18 @@ it("generates complex configuration", () => {
134
137
  <project xmlns="http://maven.apache.org/POM/4.0.0"
135
138
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
136
139
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
137
-
140
+
138
141
  <modelVersion>4.0.0</modelVersion>
139
142
  <groupId>me.example</groupId>
140
143
  <artifactId>test</artifactId>
141
144
  <version>1.0.0</version>
142
-
145
+
143
146
  <properties>
144
147
  <maven.compiler.source>8</maven.compiler.source>
145
148
  <maven.compiler.target>8</maven.compiler.target>
146
149
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
147
150
  </properties>
148
-
151
+
149
152
  <repositories>
150
153
  <repository>
151
154
  <id>central</id>
@@ -156,7 +159,7 @@ it("generates complex configuration", () => {
156
159
  <url>https://repo.maven.apache.org/maven2</url>
157
160
  </repository>
158
161
  </repositories>
159
-
162
+
160
163
  <pluginRepositories>
161
164
  <pluginRepository>
162
165
  <id>central</id>
@@ -254,7 +257,6 @@ it("generates complex configuration", () => {
254
257
  </resource>
255
258
  </resources>
256
259
  </build>
257
-
258
260
  </project>
259
261
  `,
260
262
  });