@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
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Child, Children, code } from "@alloy-js/core";
|
|
2
|
-
import { passGenerics } from "../generics.js";
|
|
3
|
-
|
|
4
|
-
export interface GenericsProps {
|
|
5
|
-
types?: (Child | Record<"?", Children>)[];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function Generics(props: GenericsProps) {
|
|
9
|
-
if (!props.types) return "<>";
|
|
10
|
-
const generics = passGenerics(props.types);
|
|
11
|
-
return code`<${generics}>`;
|
|
12
|
-
}
|
package/src/generics.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Child, Children, code, mapJoin } from "@alloy-js/core";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Allow component to specify generic typing
|
|
5
|
-
*/
|
|
6
|
-
export interface GenericTypes {
|
|
7
|
-
generics?: Record<string, Children>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Collect generics types to pass definitions to components
|
|
12
|
-
*
|
|
13
|
-
* @remarks
|
|
14
|
-
*
|
|
15
|
-
* Input of `{ T: 'String' }` will produce `<T extends String>`.
|
|
16
|
-
*
|
|
17
|
-
* Can then be passed to class definition, method definition, using a generic class etc.
|
|
18
|
-
*
|
|
19
|
-
* @param generics - Record of type variable, (T, Z, etc), mapped to its bounds (if any).
|
|
20
|
-
*/
|
|
21
|
-
export function collectGenerics(generics: Record<string, Children>) {
|
|
22
|
-
const genericTypes = mapJoin(
|
|
23
|
-
new Map(Object.entries(generics)),
|
|
24
|
-
(key, value) => {
|
|
25
|
-
const extendsExpression = value ? code` extends ${value}` : "";
|
|
26
|
-
return [key, extendsExpression];
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
joiner: ", ",
|
|
30
|
-
},
|
|
31
|
-
);
|
|
32
|
-
return code`<${genericTypes}>`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Pass generics types to an actual object. For instance if we are using the `List` class, we define it like `List<String>`
|
|
37
|
-
* or whatever type we like. These are where we define the types. Can also pass wildcard types like `List<? extends String>`, which
|
|
38
|
-
* allows you to pass unknown types.
|
|
39
|
-
*
|
|
40
|
-
* @param generics - Takes an array of either direct child (refkey or defining type), or a record which passes a wildcard type with optional bounds
|
|
41
|
-
*/
|
|
42
|
-
export function passGenerics(generics: (Child | Record<"?", Children>)[]) {
|
|
43
|
-
return mapJoin(
|
|
44
|
-
generics,
|
|
45
|
-
(val) => {
|
|
46
|
-
if (typeof val === "object" && val) {
|
|
47
|
-
const key = Object.keys(val)[0];
|
|
48
|
-
if (key === "?") {
|
|
49
|
-
// @ts-expect-error Key is ? in this case
|
|
50
|
-
const value = val[key];
|
|
51
|
-
const extendsExpression = value ? code` extends ${value}` : "";
|
|
52
|
-
return [key, extendsExpression];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return val as Child;
|
|
56
|
-
},
|
|
57
|
-
{ joiner: ", " },
|
|
58
|
-
);
|
|
59
|
-
}
|
package/src/object-modifiers.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Objects extend this interface to allow to take modifiers as boolean props.
|
|
3
|
-
* Then can declare components like so
|
|
4
|
-
*
|
|
5
|
-
* `<Class public final abstract />`
|
|
6
|
-
*
|
|
7
|
-
* Error will be thrown if try to specify multiple access modifiers
|
|
8
|
-
*/
|
|
9
|
-
export interface ObjectModifiers {
|
|
10
|
-
public?: boolean;
|
|
11
|
-
protected?: boolean;
|
|
12
|
-
private?: boolean;
|
|
13
|
-
|
|
14
|
-
default?: boolean;
|
|
15
|
-
static?: boolean;
|
|
16
|
-
final?: boolean;
|
|
17
|
-
synchronized?: boolean;
|
|
18
|
-
abstract?: boolean;
|
|
19
|
-
native?: boolean;
|
|
20
|
-
strictfp?: boolean;
|
|
21
|
-
transient?: boolean;
|
|
22
|
-
volatile?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function collectModifiers<T extends ObjectModifiers>(props: T) {
|
|
26
|
-
const modifiers = [];
|
|
27
|
-
|
|
28
|
-
// If more than one access modifier is specified, throw an error
|
|
29
|
-
if (
|
|
30
|
-
[props.public, props.protected, props.private].filter(Boolean).length > 1
|
|
31
|
-
) {
|
|
32
|
-
throw new Error("Cannot specify multiple access modifiers");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (props.public) modifiers.push("public");
|
|
36
|
-
if (props.protected) modifiers.push("protected");
|
|
37
|
-
if (props.private) modifiers.push("private");
|
|
38
|
-
if (props.abstract) modifiers.push("abstract");
|
|
39
|
-
if (props.static) modifiers.push("static");
|
|
40
|
-
if (props.synchronized) modifiers.push("synchronized");
|
|
41
|
-
if (props.transient) modifiers.push("transient");
|
|
42
|
-
if (props.volatile) modifiers.push("volatile");
|
|
43
|
-
if (props.final) modifiers.push("final");
|
|
44
|
-
if (props.default) modifiers.push("default");
|
|
45
|
-
if (props.native) modifiers.push("native");
|
|
46
|
-
if (props.strictfp) modifiers.push("strictfp");
|
|
47
|
-
return modifiers.join(" ") + (modifiers.length > 0 ? " " : "");
|
|
48
|
-
}
|