@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.
- package/CHANGELOG.md +23 -0
- package/dist/src/components/Annotation.d.ts +4 -4
- package/dist/src/components/Annotation.d.ts.map +1 -1
- package/dist/src/components/Annotation.js +27 -5
- package/dist/src/components/Annotation.js.map +1 -1
- package/dist/src/components/ArgumentList.d.ts +12 -0
- package/dist/src/components/ArgumentList.d.ts.map +1 -0
- package/dist/src/components/ArgumentList.js +33 -0
- package/dist/src/components/ArgumentList.js.map +1 -0
- package/dist/src/components/Class.d.ts +4 -4
- package/dist/src/components/Class.d.ts.map +1 -1
- package/dist/src/components/Class.js +33 -14
- package/dist/src/components/Class.js.map +1 -1
- package/dist/src/components/Constructor.d.ts +3 -3
- package/dist/src/components/Constructor.d.ts.map +1 -1
- package/dist/src/components/Constructor.js +9 -10
- package/dist/src/components/Constructor.js.map +1 -1
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +0 -1
- package/dist/src/components/Declaration.js.map +1 -1
- package/dist/src/components/Enum.d.ts +14 -6
- package/dist/src/components/Enum.d.ts.map +1 -1
- package/dist/src/components/Enum.js +38 -16
- package/dist/src/components/Enum.js.map +1 -1
- package/dist/src/components/ExtendsClause.d.ts +9 -0
- package/dist/src/components/ExtendsClause.d.ts.map +1 -0
- package/dist/src/components/ExtendsClause.js +28 -0
- package/dist/src/components/ExtendsClause.js.map +1 -0
- package/dist/src/components/ImplementsClause.d.ts +9 -0
- package/dist/src/components/ImplementsClause.d.ts.map +1 -0
- package/dist/src/components/ImplementsClause.js +28 -0
- package/dist/src/components/ImplementsClause.js.map +1 -0
- package/dist/src/components/ImportStatement.d.ts +1 -1
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/ImportStatement.js +1 -1
- package/dist/src/components/ImportStatement.js.map +1 -1
- package/dist/src/components/Interface.d.ts +4 -4
- package/dist/src/components/Interface.d.ts.map +1 -1
- package/dist/src/components/Interface.js +23 -16
- package/dist/src/components/Interface.js.map +1 -1
- package/dist/src/components/MavenProject.d.ts +4 -2
- package/dist/src/components/MavenProject.d.ts.map +1 -1
- package/dist/src/components/MavenProject.js +183 -122
- package/dist/src/components/MavenProject.js.map +1 -1
- package/dist/src/components/Method.d.ts +3 -3
- package/dist/src/components/Method.d.ts.map +1 -1
- package/dist/src/components/Method.js +8 -4
- package/dist/src/components/Method.js.map +1 -1
- package/dist/src/{object-modifiers.d.ts → components/Modifiers.d.ts} +6 -3
- package/dist/src/components/Modifiers.d.ts.map +1 -0
- package/dist/src/components/Modifiers.js +27 -0
- package/dist/src/components/Modifiers.js.map +1 -0
- package/dist/src/components/Name.js +1 -1
- package/dist/src/components/Name.js.map +1 -1
- package/dist/src/components/NamedArgumentList.d.ts +11 -0
- package/dist/src/components/NamedArgumentList.d.ts.map +1 -0
- package/dist/src/components/NamedArgumentList.js +30 -0
- package/dist/src/components/NamedArgumentList.js.map +1 -0
- package/dist/src/components/ObjectDeclaration.d.ts +3 -3
- package/dist/src/components/ObjectDeclaration.d.ts.map +1 -1
- package/dist/src/components/ObjectDeclaration.js +8 -4
- package/dist/src/components/ObjectDeclaration.js.map +1 -1
- package/dist/src/components/PackageDirectory.d.ts.map +1 -1
- package/dist/src/components/PackageDirectory.js.map +1 -1
- package/dist/src/components/Parameters.d.ts +3 -3
- package/dist/src/components/Parameters.d.ts.map +1 -1
- package/dist/src/components/Parameters.js +1 -1
- package/dist/src/components/Parameters.js.map +1 -1
- package/dist/src/components/ProjectDirectory.d.ts.map +1 -1
- package/dist/src/components/ProjectDirectory.js +3 -3
- package/dist/src/components/ProjectDirectory.js.map +1 -1
- package/dist/src/components/Reference.js +1 -1
- package/dist/src/components/Reference.js.map +1 -1
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +3 -2
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/components/TypeArguments.d.ts +24 -0
- package/dist/src/components/TypeArguments.d.ts.map +1 -0
- package/dist/src/components/TypeArguments.js +82 -0
- package/dist/src/components/TypeArguments.js.map +1 -0
- package/dist/src/components/TypeParameters.d.ts +9 -0
- package/dist/src/components/TypeParameters.d.ts.map +1 -0
- package/dist/src/components/TypeParameters.js +40 -0
- package/dist/src/components/TypeParameters.js.map +1 -0
- package/dist/src/components/Variable.d.ts +5 -5
- package/dist/src/components/Variable.d.ts.map +1 -1
- package/dist/src/components/Variable.js +4 -3
- package/dist/src/components/Variable.js.map +1 -1
- package/dist/src/components/index.d.ts +8 -2
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +8 -2
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/stc/index.d.ts +37 -17
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +7 -2
- package/dist/src/components/stc/index.js.map +1 -1
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +1 -1
- package/dist/test/maven.test.d.ts +2 -0
- package/dist/test/maven.test.d.ts.map +1 -0
- package/dist/test/type-arguments.test.d.ts +2 -0
- package/dist/test/type-arguments.test.d.ts.map +1 -0
- package/dist/test/utils.d.ts +3 -3
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -5
- package/src/components/Annotation.tsx +24 -13
- package/src/components/ArgumentList.tsx +29 -0
- package/src/components/Class.tsx +24 -20
- package/src/components/Constructor.tsx +11 -10
- package/src/components/Declaration.tsx +1 -3
- package/src/components/Enum.tsx +39 -23
- package/src/components/ExtendsClause.tsx +19 -0
- package/src/components/ImplementsClause.tsx +19 -0
- package/src/components/ImportStatement.tsx +5 -2
- package/src/components/Interface.tsx +20 -20
- package/src/components/MavenProject.tsx +256 -121
- package/src/components/Method.tsx +12 -10
- package/src/components/Modifiers.tsx +54 -0
- package/src/components/NamedArgumentList.tsx +31 -0
- package/src/components/ObjectDeclaration.tsx +6 -6
- package/src/components/PackageDirectory.tsx +14 -7
- package/src/components/Parameters.tsx +4 -4
- package/src/components/ProjectDirectory.tsx +7 -5
- package/src/components/SourceFile.tsx +15 -11
- package/src/components/TypeArguments.tsx +88 -0
- package/src/components/TypeParameters.tsx +34 -0
- package/src/components/Variable.tsx +6 -6
- package/src/components/index.ts +8 -2
- package/src/components/stc/index.ts +7 -2
- package/src/index.ts +0 -3
- package/temp/api.json +1455 -963
- package/test/annotation.test.tsx +38 -25
- package/test/class.test.tsx +32 -27
- package/test/constructor.test.tsx +24 -25
- package/test/enum.test.tsx +28 -25
- package/test/externals.test.tsx +13 -5
- package/test/interface.test.tsx +20 -15
- package/test/{maven.tsx → maven.test.tsx} +15 -13
- package/test/method.test.tsx +39 -23
- package/test/package.test.tsx +2 -3
- package/test/reference.test.tsx +14 -12
- package/test/{generics.tsx → type-arguments.test.tsx} +6 -6
- package/test/utils.tsx +10 -6
- package/test/values.test.tsx +1 -3
- package/test/variables.test.tsx +7 -7
- package/dist/src/arguments.d.ts +0 -15
- package/dist/src/arguments.d.ts.map +0 -1
- package/dist/src/arguments.js +0 -27
- package/dist/src/arguments.js.map +0 -1
- package/dist/src/components/Block.d.ts +0 -6
- package/dist/src/components/Block.d.ts.map +0 -1
- package/dist/src/components/Block.js +0 -4
- package/dist/src/components/Block.js.map +0 -1
- package/dist/src/components/Generics.d.ts +0 -6
- package/dist/src/components/Generics.d.ts.map +0 -1
- package/dist/src/components/Generics.js +0 -8
- package/dist/src/components/Generics.js.map +0 -1
- package/dist/src/generics.d.ts +0 -28
- package/dist/src/generics.d.ts.map +0 -1
- package/dist/src/generics.js +0 -51
- package/dist/src/generics.js.map +0 -1
- package/dist/src/object-modifiers.d.ts.map +0 -1
- package/dist/src/object-modifiers.js +0 -31
- package/dist/src/object-modifiers.js.map +0 -1
- package/dist/test/generics.d.ts +0 -2
- package/dist/test/generics.d.ts.map +0 -1
- package/dist/test/maven.d.ts +0 -2
- package/dist/test/maven.d.ts.map +0 -1
- package/src/arguments.ts +0 -30
- package/src/components/Block.tsx +0 -8
- package/src/components/Generics.tsx +0 -12
- package/src/generics.ts +0 -59
- package/src/object-modifiers.ts +0 -48
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
code,
|
|
4
|
+
List,
|
|
5
|
+
mapJoin,
|
|
6
|
+
Show,
|
|
7
|
+
SourceFile,
|
|
8
|
+
} from "@alloy-js/core";
|
|
2
9
|
import { MavenProjectConfig } from "../symbols/index.js";
|
|
3
10
|
import { useProject } from "./ProjectDirectory.js";
|
|
4
11
|
|
|
@@ -23,129 +30,257 @@ export function PomFile({ projectConfig }: PomFileProps) {
|
|
|
23
30
|
// The following spaghetti mess is so the final output is formatted correctly.
|
|
24
31
|
// Needs to be this way for when some options aren't provided, there's no random whitespace,
|
|
25
32
|
// and so that looped sections are indented correctly.
|
|
26
|
-
return
|
|
33
|
+
return (
|
|
34
|
+
<SourceFile path="pom.xml" filetype="xml">
|
|
35
|
+
<PomFileRoot>
|
|
36
|
+
<hbr />
|
|
37
|
+
<List
|
|
38
|
+
joiner={
|
|
39
|
+
<>
|
|
40
|
+
<hbr />
|
|
41
|
+
<hbr />
|
|
42
|
+
</>
|
|
43
|
+
}
|
|
44
|
+
>
|
|
45
|
+
<PomFileMetadata projectConfig={projectConfig} />
|
|
46
|
+
<PomFileProperties projectConfig={projectConfig} />
|
|
47
|
+
{projectConfig.repositories && (
|
|
48
|
+
<PomFileRepositories projectConfig={projectConfig} />
|
|
49
|
+
)}
|
|
50
|
+
{projectConfig.pluginRepositories && (
|
|
51
|
+
<PomFilePluginRepositories projectConfig={projectConfig} />
|
|
52
|
+
)}
|
|
53
|
+
{scope.dependencies.size > 0 && (
|
|
54
|
+
<PomFileDependencies projectConfig={projectConfig} />
|
|
55
|
+
)}
|
|
56
|
+
{projectConfig.build && (
|
|
57
|
+
<PomFileBuild projectConfig={projectConfig} />
|
|
58
|
+
)}
|
|
59
|
+
</List>
|
|
60
|
+
</PomFileRoot>
|
|
61
|
+
</SourceFile>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function PomFileRoot(props: { children: Children }) {
|
|
66
|
+
return code`
|
|
67
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
68
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
69
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
70
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
71
|
+
${props.children}
|
|
72
|
+
</project>
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function PomFileMetadata(props: PomFileProps) {
|
|
77
|
+
return code`
|
|
78
|
+
<modelVersion>4.0.0</modelVersion>
|
|
79
|
+
<groupId>${props.projectConfig.groupId}</groupId>
|
|
80
|
+
<artifactId>${props.projectConfig.artifactId}</artifactId>
|
|
81
|
+
<version>${props.projectConfig.version}</version>
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function PomFileProperties(props: PomFileProps) {
|
|
86
|
+
return code`
|
|
87
|
+
<properties>
|
|
88
|
+
<maven.compiler.source>${props.projectConfig?.javaVersion}</maven.compiler.source>
|
|
89
|
+
<maven.compiler.target>${props.projectConfig?.javaVersion}</maven.compiler.target>
|
|
90
|
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
91
|
+
</properties>
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function PomFileRepositories(props: PomFileProps) {
|
|
96
|
+
if (props.projectConfig.repositories === undefined) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return code`
|
|
101
|
+
<repositories>
|
|
102
|
+
${mapJoin(
|
|
103
|
+
() => props.projectConfig.repositories!,
|
|
104
|
+
(repo) => code`
|
|
105
|
+
<repository>
|
|
106
|
+
<id>${repo.id}</id>
|
|
107
|
+
<url>${repo.url}</url>
|
|
108
|
+
</repository>
|
|
109
|
+
`,
|
|
110
|
+
{ joiner: <hbr /> },
|
|
111
|
+
)}
|
|
112
|
+
</repositories>
|
|
113
|
+
`;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function PomFilePluginRepositories(props: PomFileProps) {
|
|
117
|
+
if (!props.projectConfig.pluginRepositories) {
|
|
118
|
+
return "";
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return code`
|
|
122
|
+
<pluginRepositories>
|
|
123
|
+
${mapJoin(
|
|
124
|
+
() => props.projectConfig.pluginRepositories!,
|
|
125
|
+
(repo) => code`
|
|
126
|
+
<pluginRepository>
|
|
127
|
+
<id>${repo.id}</id>
|
|
128
|
+
<url>${repo.url}</url>
|
|
129
|
+
</pluginRepository>
|
|
130
|
+
`,
|
|
131
|
+
{ joiner: <hbr /> },
|
|
132
|
+
)}
|
|
133
|
+
</pluginRepositories>
|
|
134
|
+
`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function PomFileDependencies(props: PomFileProps) {
|
|
138
|
+
const scope = useProject().scope;
|
|
139
|
+
return (
|
|
140
|
+
<Show when={scope.dependencies.size > 0}>
|
|
27
141
|
{code`
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
`}${<Indent>{projectConfig?.pluginRepositories && code`
|
|
142
|
+
<dependencies>${Array.from(scope.dependencies.values()).map(
|
|
143
|
+
(dep) => code`
|
|
144
|
+
|
|
145
|
+
<dependency>
|
|
146
|
+
<groupId>${dep.groupId}</groupId>
|
|
147
|
+
<artifactId>${dep.artifactId}</artifactId>
|
|
148
|
+
${dep.version !== undefined ? `<version>${dep.version}</version>` : undefined}
|
|
149
|
+
<scope>${dep.scope ?? "provided"}</scope>
|
|
150
|
+
</dependency>
|
|
151
|
+
`,
|
|
152
|
+
)}
|
|
153
|
+
</dependencies>
|
|
154
|
+
`}
|
|
155
|
+
</Show>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function PomFileBuild(props: PomFileProps) {
|
|
160
|
+
if (!props.projectConfig.build) {
|
|
161
|
+
return "";
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return code`
|
|
165
|
+
<build>
|
|
166
|
+
${(<PomFileBuildPlugins {...props.projectConfig.build} />)}
|
|
167
|
+
${(<PomFileBuildResources {...props.projectConfig.build} />)}
|
|
168
|
+
</build>
|
|
169
|
+
`;
|
|
170
|
+
}
|
|
58
171
|
|
|
172
|
+
function PomFileBuildPlugins(props: MavenProjectConfig["build"]) {
|
|
173
|
+
if (!props || !props.plugins) {
|
|
174
|
+
return "";
|
|
175
|
+
}
|
|
59
176
|
|
|
60
|
-
|
|
177
|
+
return code`
|
|
178
|
+
<plugins>
|
|
179
|
+
${mapJoin(
|
|
180
|
+
() => props.plugins!,
|
|
181
|
+
(plugin) => code`
|
|
182
|
+
<plugin>
|
|
183
|
+
<groupId>${plugin.groupId}</groupId>
|
|
184
|
+
<artifactId>${plugin.artifactId}</artifactId>
|
|
185
|
+
${plugin.version !== undefined ? `<version>${plugin.version}</version>` : undefined}
|
|
186
|
+
${
|
|
187
|
+
plugin.executions &&
|
|
188
|
+
code`
|
|
189
|
+
<executions>
|
|
190
|
+
${mapJoin(
|
|
191
|
+
() => plugin.executions!,
|
|
192
|
+
(execution) => code`
|
|
193
|
+
<execution>
|
|
194
|
+
${execution.id ? `<id>${execution.id}</id>` : undefined}
|
|
195
|
+
${execution.phase ? `<phase>${execution.phase}</phase>` : undefined}
|
|
196
|
+
${
|
|
197
|
+
execution.goals &&
|
|
198
|
+
code`
|
|
199
|
+
<goals>
|
|
200
|
+
${mapJoin(
|
|
201
|
+
() => execution.goals!,
|
|
202
|
+
(goal) => code`
|
|
203
|
+
<goal>${goal}</goal>
|
|
204
|
+
`,
|
|
205
|
+
)}
|
|
206
|
+
</goals>
|
|
207
|
+
`
|
|
208
|
+
}
|
|
209
|
+
</execution>
|
|
210
|
+
`,
|
|
211
|
+
)}
|
|
212
|
+
</executions>
|
|
213
|
+
`
|
|
214
|
+
}${
|
|
215
|
+
plugin.configuration &&
|
|
216
|
+
code`
|
|
217
|
+
|
|
218
|
+
<configuration>
|
|
219
|
+
${mapJoin(
|
|
220
|
+
() => Object.entries(plugin.configuration!),
|
|
221
|
+
([key, value]) => code`
|
|
222
|
+
<${key}>${value}</${key}>
|
|
223
|
+
`,
|
|
224
|
+
)}
|
|
225
|
+
</configuration>
|
|
226
|
+
`
|
|
227
|
+
}
|
|
228
|
+
</plugin>
|
|
229
|
+
`,
|
|
230
|
+
)}
|
|
231
|
+
</plugins>
|
|
232
|
+
`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function PomFileBuildResources(props: MavenProjectConfig["build"]) {
|
|
236
|
+
if (!props || !props.resources) {
|
|
237
|
+
return "";
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return code`
|
|
241
|
+
<resources>
|
|
242
|
+
${mapJoin(
|
|
243
|
+
() => props.resources!,
|
|
244
|
+
(resource) => code`
|
|
245
|
+
<resource>
|
|
246
|
+
<directory>${resource.directory}</directory>${
|
|
247
|
+
resource.includes &&
|
|
248
|
+
code`
|
|
249
|
+
|
|
250
|
+
<includes>${resource.includes.map(
|
|
251
|
+
(include) => code`
|
|
61
252
|
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<
|
|
253
|
+
<include>${include}</include>
|
|
254
|
+
`,
|
|
255
|
+
)}
|
|
256
|
+
</includes>
|
|
257
|
+
`
|
|
258
|
+
}${
|
|
259
|
+
resource.excludes &&
|
|
260
|
+
code`
|
|
261
|
+
|
|
262
|
+
<excludes>${resource.excludes.map(
|
|
263
|
+
(exclude) => code`
|
|
72
264
|
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<execution>
|
|
96
|
-
${execution.id ? `<id>${execution.id}</id>` : undefined}
|
|
97
|
-
${execution.phase ? `<phase>${execution.phase}</phase>` : undefined}
|
|
98
|
-
${execution.goals && code`
|
|
99
|
-
<goals>${execution.goals.map(goal => code`
|
|
100
|
-
|
|
101
|
-
<goal>${goal}</goal>
|
|
102
|
-
`)}
|
|
103
|
-
</goals>
|
|
104
|
-
`}
|
|
105
|
-
</execution>
|
|
106
|
-
`)}
|
|
107
|
-
</executions>
|
|
108
|
-
`}${plugin.configuration && code`
|
|
109
|
-
|
|
110
|
-
<configuration>${Object.entries(plugin.configuration).map(([key, value]) => code`
|
|
111
|
-
|
|
112
|
-
<${key}>${value}</${key}>
|
|
113
|
-
`)}
|
|
114
|
-
</configuration>
|
|
115
|
-
`}
|
|
116
|
-
</plugin>
|
|
117
|
-
`)}
|
|
118
|
-
</plugins>
|
|
119
|
-
`}${projectConfig?.build?.resources && code`
|
|
120
|
-
|
|
121
|
-
<resources>${projectConfig?.build?.resources.map(resource => code`
|
|
122
|
-
|
|
123
|
-
<resource>
|
|
124
|
-
<directory>${resource.directory}</directory>${resource.includes && code`
|
|
125
|
-
|
|
126
|
-
<includes>${resource.includes.map(include => code`
|
|
127
|
-
|
|
128
|
-
<include>${include}</include>
|
|
129
|
-
`)}
|
|
130
|
-
</includes>
|
|
131
|
-
`}${resource.excludes && code`
|
|
132
|
-
|
|
133
|
-
<excludes>${resource.excludes.map(exclude => code`
|
|
134
|
-
|
|
135
|
-
<exclude>${exclude}</exclude>
|
|
136
|
-
`)}
|
|
137
|
-
</excludes>
|
|
138
|
-
`}${resource.filtering !== undefined ? `
|
|
139
|
-
<filtering>${resource.filtering}</filtering>` : undefined}${resource.targetPath !== undefined ? `
|
|
140
|
-
<targetPath>${resource.targetPath}</targetPath>` : undefined}
|
|
141
|
-
</resource>
|
|
142
|
-
`)}
|
|
143
|
-
</resources>
|
|
144
|
-
`}
|
|
145
|
-
</build>
|
|
146
|
-
`}
|
|
147
|
-
|
|
148
|
-
</project>
|
|
149
|
-
`}
|
|
150
|
-
</SourceFile>;
|
|
265
|
+
<exclude>${exclude}</exclude>
|
|
266
|
+
`,
|
|
267
|
+
)}
|
|
268
|
+
</excludes>
|
|
269
|
+
`
|
|
270
|
+
}${
|
|
271
|
+
resource.filtering !== undefined ?
|
|
272
|
+
`
|
|
273
|
+
<filtering>${resource.filtering}</filtering>`
|
|
274
|
+
: undefined
|
|
275
|
+
}${
|
|
276
|
+
resource.targetPath !== undefined ?
|
|
277
|
+
`
|
|
278
|
+
<targetPath>${resource.targetPath}</targetPath>`
|
|
279
|
+
: undefined
|
|
280
|
+
}
|
|
281
|
+
</resource>
|
|
282
|
+
`,
|
|
283
|
+
)}
|
|
284
|
+
</resources>
|
|
285
|
+
`;
|
|
151
286
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Children, code } from "@alloy-js/core";
|
|
2
|
-
import { collectGenerics, GenericTypes } from "../generics.js";
|
|
3
2
|
import { useJavaNamePolicy } from "../name-policy.js";
|
|
4
|
-
import {
|
|
3
|
+
import { ModifierProps, Modifiers } from "./Modifiers.jsx";
|
|
5
4
|
import { Parameters } from "./Parameters.js";
|
|
5
|
+
import { TypeParameters, TypeParametersProps } from "./TypeParameters.jsx";
|
|
6
6
|
|
|
7
|
-
export interface MethodProps extends
|
|
7
|
+
export interface MethodProps extends ModifierProps, TypeParametersProps {
|
|
8
8
|
name: string;
|
|
9
9
|
return?: Children;
|
|
10
10
|
throws?: Children;
|
|
@@ -15,18 +15,20 @@ export interface MethodProps extends ObjectModifiers, GenericTypes {
|
|
|
15
15
|
export function Method(props: MethodProps) {
|
|
16
16
|
const params = <Parameters parameters={props.parameters}></Parameters>;
|
|
17
17
|
const name = useJavaNamePolicy().getName(props.name, "method");
|
|
18
|
-
const modifiers =
|
|
18
|
+
const modifiers = <Modifiers {...props} />;
|
|
19
19
|
const throwsClause = props.throws ? code` throws ${props.throws}` : "";
|
|
20
|
-
const generics =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const generics =
|
|
21
|
+
props.generics ?
|
|
22
|
+
code`${(<TypeParameters generics={props.generics} />)}${" "}`
|
|
23
|
+
: "";
|
|
24
|
+
const sBody =
|
|
25
|
+
props.children !== undefined ?
|
|
26
|
+
code`
|
|
25
27
|
${" "}{
|
|
26
28
|
${props.children}
|
|
27
29
|
}
|
|
28
30
|
`
|
|
29
|
-
|
|
31
|
+
: ";";
|
|
30
32
|
return code`
|
|
31
33
|
${modifiers}${generics}${props.return ?? "void"} ${name}(${params})${throwsClause}${sBody}
|
|
32
34
|
`;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { For } from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Objects extend this interface to allow to take modifiers as boolean props.
|
|
5
|
+
* Then can declare components like so
|
|
6
|
+
*
|
|
7
|
+
* `<Class public final abstract />`
|
|
8
|
+
*
|
|
9
|
+
* Error will be thrown if try to specify multiple access modifiers
|
|
10
|
+
*/
|
|
11
|
+
export interface ModifierProps {
|
|
12
|
+
public?: boolean;
|
|
13
|
+
protected?: boolean;
|
|
14
|
+
private?: boolean;
|
|
15
|
+
default?: boolean;
|
|
16
|
+
static?: boolean;
|
|
17
|
+
final?: boolean;
|
|
18
|
+
synchronized?: boolean;
|
|
19
|
+
abstract?: boolean;
|
|
20
|
+
native?: boolean;
|
|
21
|
+
strictfp?: boolean;
|
|
22
|
+
transient?: boolean;
|
|
23
|
+
volatile?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const modifiers = [
|
|
27
|
+
"public",
|
|
28
|
+
"protected",
|
|
29
|
+
"private",
|
|
30
|
+
"abstract",
|
|
31
|
+
"static",
|
|
32
|
+
"synchronized",
|
|
33
|
+
"transient",
|
|
34
|
+
"volatile",
|
|
35
|
+
"final",
|
|
36
|
+
"default",
|
|
37
|
+
"native",
|
|
38
|
+
"strictfp",
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Renders the modifiers based on the provided props.
|
|
43
|
+
**/
|
|
44
|
+
export function Modifiers(props: ModifierProps) {
|
|
45
|
+
const modifierList = modifiers.filter(
|
|
46
|
+
(modifier) => props[modifier as keyof ModifierProps],
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<For each={modifierList} joiner=" " ender=" ">
|
|
51
|
+
{(modifier) => modifier}
|
|
52
|
+
</For>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { For, Indent } from "@alloy-js/core";
|
|
2
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
export interface NamedArgumentListProps {
|
|
5
|
+
args: Record<string, Children>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Collect a set of named arguments. Will pass to object as named arguments.
|
|
10
|
+
*
|
|
11
|
+
* @param args - of name to argument value
|
|
12
|
+
*/
|
|
13
|
+
export function NamedArgumentList(props: NamedArgumentListProps) {
|
|
14
|
+
return (
|
|
15
|
+
<group>
|
|
16
|
+
(
|
|
17
|
+
<Indent break="soft">
|
|
18
|
+
<For each={Object.entries(props.args)} comma line>
|
|
19
|
+
{([key, value]) => {
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
{key} = {value}
|
|
23
|
+
</>
|
|
24
|
+
);
|
|
25
|
+
}}
|
|
26
|
+
</For>
|
|
27
|
+
</Indent>
|
|
28
|
+
<sbr />)
|
|
29
|
+
</group>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Children, code } from "@alloy-js/core";
|
|
2
|
-
import {
|
|
3
|
-
import { ObjectModifiers } from "../object-modifiers.js";
|
|
2
|
+
import { ArgumentList } from "./ArgumentList.jsx";
|
|
4
3
|
import { DeclarationProps } from "./Declaration.js";
|
|
4
|
+
import { ModifierProps } from "./Modifiers.jsx";
|
|
5
5
|
import { Variable } from "./Variable.js";
|
|
6
6
|
|
|
7
7
|
export interface ObjectDeclarationProps
|
|
8
8
|
extends DeclarationProps,
|
|
9
|
-
|
|
9
|
+
ModifierProps {
|
|
10
10
|
type: Children;
|
|
11
|
-
|
|
11
|
+
args?: Children[];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -16,7 +16,7 @@ export interface ObjectDeclarationProps
|
|
|
16
16
|
* Declares it with 'new' and passes arguments to the constructor of the object, if any
|
|
17
17
|
*/
|
|
18
18
|
export function ObjectDeclaration(props: ObjectDeclarationProps) {
|
|
19
|
-
const args =
|
|
20
|
-
const value = code`new ${props.type}
|
|
19
|
+
const args = <ArgumentList args={props.args} />;
|
|
20
|
+
const value = code`new ${props.type}${args}`;
|
|
21
21
|
return <Variable {...props} value={value} />;
|
|
22
22
|
}
|
|
@@ -43,9 +43,10 @@ export function PackageDirectory(props: PackageDirectoryProps) {
|
|
|
43
43
|
const packageNames = props.package.split(".");
|
|
44
44
|
const packageName = packageNames[0];
|
|
45
45
|
|
|
46
|
-
const fullyQualifiedPackageName =
|
|
47
|
-
parentPackage
|
|
48
|
-
|
|
46
|
+
const fullyQualifiedPackageName =
|
|
47
|
+
parentPackage ?
|
|
48
|
+
parentPackage.qualifiedName + "." + packageName
|
|
49
|
+
: packageName;
|
|
49
50
|
|
|
50
51
|
const scope = createJavaPackageScope(
|
|
51
52
|
useBinder(),
|
|
@@ -66,19 +67,25 @@ export function PackageDirectory(props: PackageDirectoryProps) {
|
|
|
66
67
|
*/
|
|
67
68
|
function ChildPackageDirectory() {
|
|
68
69
|
if (packageNames.length > 1) {
|
|
69
|
-
return
|
|
70
|
+
return (
|
|
71
|
+
<PackageDirectory
|
|
72
|
+
package={packageNames.slice(1, packageNames.length).join(".")}
|
|
73
|
+
>
|
|
70
74
|
{props.children}
|
|
71
|
-
</PackageDirectory
|
|
75
|
+
</PackageDirectory>
|
|
76
|
+
);
|
|
72
77
|
} else {
|
|
73
78
|
return props.children;
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
return
|
|
82
|
+
return (
|
|
83
|
+
<PackageDirectoryContext.Provider value={packageContext}>
|
|
78
84
|
<Scope value={scope}>
|
|
79
85
|
<SourceDirectory path={packageName}>
|
|
80
86
|
<ChildPackageDirectory />
|
|
81
87
|
</SourceDirectory>
|
|
82
88
|
</Scope>
|
|
83
|
-
</PackageDirectoryContext.Provider
|
|
89
|
+
</PackageDirectoryContext.Provider>
|
|
90
|
+
);
|
|
84
91
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Children, mapJoin } from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
export interface ParametersProps {
|
|
4
|
-
parameters?: Record<string,
|
|
4
|
+
parameters?: Record<string, Children>; // Map parameter name to type
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -12,8 +12,8 @@ export interface ParametersProps {
|
|
|
12
12
|
export function Parameters(props: ParametersProps) {
|
|
13
13
|
const { parameters = {} } = props;
|
|
14
14
|
return mapJoin(
|
|
15
|
-
|
|
16
|
-
(name, type) => {
|
|
15
|
+
() => Object.entries(parameters),
|
|
16
|
+
([name, type]) => {
|
|
17
17
|
return [type, " ", name];
|
|
18
18
|
},
|
|
19
19
|
{ joiner: ", " },
|
|
@@ -61,16 +61,18 @@ export function ProjectDirectory(props: ProjectDirectoryProps) {
|
|
|
61
61
|
props.gradleProjectConfig !== undefined;
|
|
62
62
|
const defaultCodePath = usingBuildSystem ? "src/main/java" : "src";
|
|
63
63
|
|
|
64
|
-
return
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
65
66
|
<Scope value={scope}>
|
|
66
67
|
<ProjectContext.Provider value={projectContext}>
|
|
67
68
|
<SourceDirectory path={defaultCodePath}>
|
|
68
|
-
|
|
69
|
+
{props.children}
|
|
69
70
|
</SourceDirectory>
|
|
70
|
-
{scope.mavenProjectConfig ?
|
|
71
|
+
{scope.mavenProjectConfig ?
|
|
71
72
|
<MavenProject projectConfig={scope.mavenProjectConfig} />
|
|
72
|
-
|
|
73
|
+
: undefined}
|
|
73
74
|
</ProjectContext.Provider>
|
|
74
75
|
</Scope>
|
|
75
|
-
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
76
78
|
}
|
|
@@ -67,18 +67,22 @@ export function SourceFile(props: SourceFileProps) {
|
|
|
67
67
|
addImport,
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
return (
|
|
71
|
+
<CoreSourceFile path={props.path} filetype="java" reference={Reference}>
|
|
72
|
+
package {packageCtx.qualifiedName};<hbr />
|
|
73
|
+
<hbr />
|
|
74
|
+
{importRecords.length > 0 ?
|
|
74
75
|
<>
|
|
75
76
|
<ImportStatements imports={importRecords} />
|
|
76
|
-
|
|
77
|
+
<hbr />
|
|
78
|
+
<hbr />
|
|
77
79
|
</>
|
|
78
|
-
|
|
79
|
-
<
|
|
80
|
-
{props.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
: undefined}
|
|
81
|
+
<SourceFileContext.Provider value={sfContext}>
|
|
82
|
+
<Scope name={props.path} kind="source-file">
|
|
83
|
+
{props.children}
|
|
84
|
+
</Scope>
|
|
85
|
+
</SourceFileContext.Provider>
|
|
86
|
+
</CoreSourceFile>
|
|
87
|
+
);
|
|
84
88
|
}
|