@alloy-js/java 0.5.0 → 0.7.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 +27 -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
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Children, For, Indent, Match, Switch } from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
export interface TypeArgumentsProps {
|
|
4
|
+
args?: Children[] | TypeArgumentDescriptor[];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface WildcardTypeArgumentDescriptor {
|
|
8
|
+
wildcard: true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ExtendsTypeArgumentDescriptor {
|
|
12
|
+
extends: Children;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SuperTypeArgumentDescriptor {
|
|
16
|
+
super: Children;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface NamedTypeArgumentDescriptor {
|
|
20
|
+
name: Children;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type TypeArgumentDescriptor =
|
|
24
|
+
| ExtendsTypeArgumentDescriptor
|
|
25
|
+
| SuperTypeArgumentDescriptor
|
|
26
|
+
| NamedTypeArgumentDescriptor
|
|
27
|
+
| WildcardTypeArgumentDescriptor;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Type arguments for a generic type. Can be called with either an array of
|
|
31
|
+
* Children which are rendered as type arguments, or an array of
|
|
32
|
+
* {@link TypeArgumentDescriptor}s which allow for specifying use-site variance.
|
|
33
|
+
*/
|
|
34
|
+
export function TypeArguments(props: TypeArgumentsProps) {
|
|
35
|
+
return (
|
|
36
|
+
<Switch>
|
|
37
|
+
<Match when={!props.args || props.args.length === 0}>
|
|
38
|
+
<>{"<>"}</>
|
|
39
|
+
</Match>
|
|
40
|
+
<Match else>
|
|
41
|
+
<group>
|
|
42
|
+
{"<"}
|
|
43
|
+
<Indent break="soft">
|
|
44
|
+
<Switch>
|
|
45
|
+
<Match when={isTypeArgumentDescriptor(props.args![0])}>
|
|
46
|
+
<For each={props.args as TypeArgumentDescriptor[]} comma line>
|
|
47
|
+
{(value) => {
|
|
48
|
+
if ("name" in value) {
|
|
49
|
+
return value.name;
|
|
50
|
+
}
|
|
51
|
+
if ("extends" in value) {
|
|
52
|
+
return <>? extends {value.extends}</>;
|
|
53
|
+
}
|
|
54
|
+
if ("super" in value) {
|
|
55
|
+
return <>? super {value.super}</>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return "?";
|
|
59
|
+
}}
|
|
60
|
+
</For>
|
|
61
|
+
</Match>
|
|
62
|
+
<Match else>
|
|
63
|
+
<For each={props.args as Children[]} comma line>
|
|
64
|
+
{(value) => value}
|
|
65
|
+
</For>
|
|
66
|
+
</Match>
|
|
67
|
+
</Switch>
|
|
68
|
+
</Indent>
|
|
69
|
+
<sbr />
|
|
70
|
+
{">"}
|
|
71
|
+
</group>
|
|
72
|
+
</Match>
|
|
73
|
+
</Switch>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function isTypeArgumentDescriptor(
|
|
78
|
+
value: unknown,
|
|
79
|
+
): value is TypeArgumentDescriptor {
|
|
80
|
+
return (
|
|
81
|
+
typeof value === "object" &&
|
|
82
|
+
value !== null &&
|
|
83
|
+
("extends" in value ||
|
|
84
|
+
"super" in value ||
|
|
85
|
+
"argument" in value ||
|
|
86
|
+
"wildcard" in value)
|
|
87
|
+
);
|
|
88
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Children, For, Indent, Show } from "@alloy-js/core";
|
|
2
|
+
|
|
3
|
+
export interface TypeParametersProps {
|
|
4
|
+
generics?: Record<string, Children>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Render a set of generic types for a method or class.
|
|
9
|
+
*/
|
|
10
|
+
export function TypeParameters(props: TypeParametersProps) {
|
|
11
|
+
return (
|
|
12
|
+
<>
|
|
13
|
+
<Show when={!props.generics || Object.keys(props.generics).length === 0}>
|
|
14
|
+
{undefined}
|
|
15
|
+
</Show>
|
|
16
|
+
<Show when={props.generics && Object.keys(props.generics).length > 0}>
|
|
17
|
+
<group>
|
|
18
|
+
{"<"}
|
|
19
|
+
<Indent break="soft" trailingBreak>
|
|
20
|
+
<For each={Object.entries(props.generics!)} comma line>
|
|
21
|
+
{([name, constraint]) => (
|
|
22
|
+
<>
|
|
23
|
+
{name}
|
|
24
|
+
{constraint && <> extends {constraint}</>}
|
|
25
|
+
</>
|
|
26
|
+
)}
|
|
27
|
+
</For>
|
|
28
|
+
</Indent>
|
|
29
|
+
{">"}
|
|
30
|
+
</group>
|
|
31
|
+
</Show>
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Children, code } from "@alloy-js/core";
|
|
2
2
|
import { useJavaNamePolicy } from "../name-policy.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ModifierProps, Modifiers } from "./Modifiers.jsx";
|
|
4
4
|
|
|
5
|
-
export interface VariableProps extends
|
|
6
|
-
type:
|
|
5
|
+
export interface VariableProps extends ModifierProps {
|
|
6
|
+
type: Children;
|
|
7
7
|
name: string;
|
|
8
8
|
value?: Children;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function Variable(props: VariableProps) {
|
|
12
12
|
const name = useJavaNamePolicy().getName(props.name, "variable");
|
|
13
|
-
const modifiers =
|
|
13
|
+
const modifiers = <Modifiers {...props} />;
|
|
14
14
|
|
|
15
|
-
return code`${modifiers}${props.type} ${name}${props.value ? code` = ${props.value}` : ""}
|
|
15
|
+
return code`${modifiers}${props.type} ${name}${props.value ? code` = ${props.value}` : ""}`;
|
|
16
16
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
export * from "./Annotation.js";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./ArgumentList.js";
|
|
3
|
+
export * from "./ArgumentList.jsx";
|
|
3
4
|
export * from "./Class.js";
|
|
4
5
|
export * from "./Constructor.js";
|
|
5
6
|
export * from "./Declaration.js";
|
|
6
7
|
export * from "./Enum.js";
|
|
7
|
-
export * from "./
|
|
8
|
+
export * from "./ExtendsClause.jsx";
|
|
9
|
+
export * from "./ImplementsClause.jsx";
|
|
8
10
|
export * from "./ImportStatement.js";
|
|
9
11
|
export * from "./Interface.js";
|
|
10
12
|
export * from "./MavenProject.js";
|
|
11
13
|
export * from "./Method.js";
|
|
14
|
+
export * from "./Modifiers.jsx";
|
|
12
15
|
export * from "./Name.js";
|
|
16
|
+
export * from "./NamedArgumentList.jsx";
|
|
13
17
|
export * from "./ObjectDeclaration.js";
|
|
14
18
|
export * from "./PackageDirectory.js";
|
|
15
19
|
export * from "./Parameters.js";
|
|
16
20
|
export * from "./ProjectDirectory.js";
|
|
17
21
|
export * from "./Reference.js";
|
|
18
22
|
export * from "./SourceFile.js";
|
|
23
|
+
export * from "./TypeArguments.jsx";
|
|
24
|
+
export * from "./TypeParameters.jsx";
|
|
19
25
|
export * from "./Value.js";
|
|
20
26
|
export * from "./Variable.js";
|
|
@@ -2,17 +2,20 @@ import { stc } from "@alloy-js/core";
|
|
|
2
2
|
import * as base from "../index.js";
|
|
3
3
|
|
|
4
4
|
export const Annotation = stc(base.Annotation);
|
|
5
|
-
export const
|
|
5
|
+
export const ArgumentList = stc(base.ArgumentList);
|
|
6
6
|
export const Class = stc(base.Class);
|
|
7
7
|
export const Constructor = stc(base.Constructor);
|
|
8
8
|
export const Declaration = stc(base.Declaration);
|
|
9
9
|
export const Enum = stc(base.Enum);
|
|
10
|
-
export const
|
|
10
|
+
export const ExtendsClause = stc(base.ExtendsClause);
|
|
11
|
+
export const ImplementsClause = stc(base.ImplementsClause);
|
|
12
|
+
export const TypeArguments = stc(base.TypeArguments);
|
|
11
13
|
export const EnumMember = stc(base.EnumMember);
|
|
12
14
|
export const ImportStatement = stc(base.ImportStatement);
|
|
13
15
|
export const Interface = stc(base.Interface);
|
|
14
16
|
export const MavenProject = stc(base.MavenProject);
|
|
15
17
|
export const Method = stc(base.Method);
|
|
18
|
+
export const Modifiers = stc(base.Modifiers);
|
|
16
19
|
export const Name = stc(base.Name);
|
|
17
20
|
export const ObjectDeclaration = stc(base.ObjectDeclaration);
|
|
18
21
|
export const PackageDirectory = stc(base.PackageDirectory);
|
|
@@ -22,3 +25,5 @@ export const Reference = stc(base.Reference);
|
|
|
22
25
|
export const SourceFile = stc(base.SourceFile);
|
|
23
26
|
export const Value = stc(base.Value);
|
|
24
27
|
export const Variable = stc(base.Variable);
|
|
28
|
+
export const TypeParameters = stc(base.TypeParameters);
|
|
29
|
+
export const NamedArgumentList = stc(base.NamedArgumentList);
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
export * from "./arguments.js";
|
|
2
1
|
export * from "./builtins/index.js";
|
|
3
2
|
export * from "./components/index.js";
|
|
4
3
|
export * from "./create-library.js";
|
|
5
|
-
export * from "./generics.js";
|
|
6
4
|
export * from "./name-policy.js";
|
|
7
|
-
export * from "./object-modifiers.js";
|
|
8
5
|
export * from "./symbols/index.js";
|