@alloy-js/java 0.15.0 → 0.17.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 +8 -0
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +4 -2
- package/dist/src/components/ImportStatement.d.ts +1 -1
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/Modifiers.d.ts +1 -1
- package/dist/src/components/Modifiers.d.ts.map +1 -1
- package/dist/src/components/Name.d.ts +1 -1
- package/dist/src/components/Name.d.ts.map +1 -1
- package/dist/src/components/PackageDirectory.d.ts.map +1 -1
- package/dist/src/components/PackageDirectory.js +3 -3
- package/dist/src/components/Parameters.d.ts +1 -1
- package/dist/src/components/Parameters.d.ts.map +1 -1
- package/dist/src/components/ProjectDirectory.d.ts.map +1 -1
- package/dist/src/components/ProjectDirectory.js +6 -3
- package/dist/src/components/Reference.d.ts +1 -1
- package/dist/src/components/Reference.d.ts.map +1 -1
- package/dist/src/components/stc/index.d.ts +27 -26
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +27 -27
- package/dist/src/create-library.d.ts.map +1 -1
- package/dist/src/create-library.js +11 -7
- package/dist/src/symbols/java-output-symbol.d.ts +8 -5
- package/dist/src/symbols/java-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/java-output-symbol.js +22 -15
- package/dist/src/symbols/java-package-scope.d.ts +3 -4
- package/dist/src/symbols/java-package-scope.d.ts.map +1 -1
- package/dist/src/symbols/java-package-scope.js +5 -6
- package/dist/src/symbols/java-project-scope.d.ts +18 -8
- package/dist/src/symbols/java-project-scope.d.ts.map +1 -1
- package/dist/src/symbols/java-project-scope.js +60 -16
- package/dist/test/class.test.js +4 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/components/Declaration.tsx +4 -2
- package/src/components/PackageDirectory.tsx +2 -11
- package/src/components/ProjectDirectory.tsx +4 -10
- package/src/components/stc/index.ts +27 -27
- package/src/create-library.ts +13 -7
- package/src/symbols/java-output-symbol.ts +25 -19
- package/src/symbols/java-package-scope.ts +5 -15
- package/src/symbols/java-project-scope.ts +83 -32
- package/temp/api.json +391 -304
- package/test/class.test.tsx +5 -1
- package/tsdoc-metadata.json +1 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as core from "@alloy-js/core";
|
|
2
2
|
import * as base from "../index.js";
|
|
3
3
|
|
|
4
|
-
export const Annotation = stc(base.Annotation);
|
|
5
|
-
export const ArgumentList = stc(base.ArgumentList);
|
|
6
|
-
export const Class = stc(base.Class);
|
|
7
|
-
export const Constructor = stc(base.Constructor);
|
|
8
|
-
export const Declaration = stc(base.Declaration);
|
|
9
|
-
export const Enum = stc(base.Enum);
|
|
10
|
-
export const ExtendsClause = stc(base.ExtendsClause);
|
|
11
|
-
export const ImplementsClause = stc(base.ImplementsClause);
|
|
12
|
-
export const TypeArguments = stc(base.TypeArguments);
|
|
13
|
-
export const EnumMember = stc(base.EnumMember);
|
|
14
|
-
export const ImportStatement = stc(base.ImportStatement);
|
|
15
|
-
export const Interface = stc(base.Interface);
|
|
16
|
-
export const MavenProject = stc(base.MavenProject);
|
|
17
|
-
export const Method = stc(base.Method);
|
|
18
|
-
export const Modifiers = stc(base.Modifiers);
|
|
19
|
-
export const Name = stc(base.Name);
|
|
20
|
-
export const ObjectDeclaration = stc(base.ObjectDeclaration);
|
|
21
|
-
export const PackageDirectory = stc(base.PackageDirectory);
|
|
22
|
-
export const Parameters = stc(base.Parameters);
|
|
23
|
-
export const ProjectDirectory = stc(base.ProjectDirectory);
|
|
24
|
-
export const Reference = stc(base.Reference);
|
|
25
|
-
export const SourceFile = stc(base.SourceFile);
|
|
26
|
-
export const Value = stc(base.Value);
|
|
27
|
-
export const Variable = stc(base.Variable);
|
|
28
|
-
export const TypeParameters = stc(base.TypeParameters);
|
|
29
|
-
export const NamedArgumentList = stc(base.NamedArgumentList);
|
|
4
|
+
export const Annotation = core.stc(base.Annotation);
|
|
5
|
+
export const ArgumentList = core.stc(base.ArgumentList);
|
|
6
|
+
export const Class = core.stc(base.Class);
|
|
7
|
+
export const Constructor = core.stc(base.Constructor);
|
|
8
|
+
export const Declaration = core.stc(base.Declaration);
|
|
9
|
+
export const Enum = core.stc(base.Enum);
|
|
10
|
+
export const ExtendsClause = core.stc(base.ExtendsClause);
|
|
11
|
+
export const ImplementsClause = core.stc(base.ImplementsClause);
|
|
12
|
+
export const TypeArguments = core.stc(base.TypeArguments);
|
|
13
|
+
export const EnumMember = core.stc(base.EnumMember);
|
|
14
|
+
export const ImportStatement = core.stc(base.ImportStatement);
|
|
15
|
+
export const Interface = core.stc(base.Interface);
|
|
16
|
+
export const MavenProject = core.stc(base.MavenProject);
|
|
17
|
+
export const Method = core.stc(base.Method);
|
|
18
|
+
export const Modifiers = core.stc(base.Modifiers);
|
|
19
|
+
export const Name = core.stc(base.Name);
|
|
20
|
+
export const ObjectDeclaration = core.stc(base.ObjectDeclaration);
|
|
21
|
+
export const PackageDirectory = core.stc(base.PackageDirectory);
|
|
22
|
+
export const Parameters = core.stc(base.Parameters);
|
|
23
|
+
export const ProjectDirectory = core.stc(base.ProjectDirectory);
|
|
24
|
+
export const Reference = core.stc(base.Reference);
|
|
25
|
+
export const SourceFile = core.stc(base.SourceFile);
|
|
26
|
+
export const Value = core.stc(base.Value);
|
|
27
|
+
export const Variable = core.stc(base.Variable);
|
|
28
|
+
export const TypeParameters = core.stc(base.TypeParameters);
|
|
29
|
+
export const NamedArgumentList = core.stc(base.NamedArgumentList);
|
package/src/create-library.ts
CHANGED
|
@@ -8,8 +8,11 @@ import {
|
|
|
8
8
|
refkey,
|
|
9
9
|
SymbolCreator,
|
|
10
10
|
} from "@alloy-js/core";
|
|
11
|
-
import {
|
|
12
|
-
|
|
11
|
+
import {
|
|
12
|
+
JavaOutputSymbol,
|
|
13
|
+
JavaPackageScope,
|
|
14
|
+
JavaProjectScope,
|
|
15
|
+
} from "./symbols/index.js";
|
|
13
16
|
|
|
14
17
|
export interface LibraryDescriptor {
|
|
15
18
|
[pkg: string]: string[];
|
|
@@ -20,16 +23,19 @@ function createSymbols(
|
|
|
20
23
|
props: CreateLibraryProps<LibraryDescriptor>,
|
|
21
24
|
refkeys: Record<string, any>,
|
|
22
25
|
) {
|
|
23
|
-
const projectScope =
|
|
26
|
+
const projectScope = new JavaProjectScope(props.groupId, { binder });
|
|
24
27
|
|
|
25
28
|
for (const [pkg, symbols] of Object.entries(props.descriptor)) {
|
|
26
|
-
const packageScope =
|
|
29
|
+
const packageScope = new JavaPackageScope(pkg, {
|
|
30
|
+
binder,
|
|
31
|
+
parent: projectScope,
|
|
32
|
+
});
|
|
27
33
|
|
|
28
34
|
for (const symB of symbols) {
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
new JavaOutputSymbol(symB, {
|
|
36
|
+
binder,
|
|
31
37
|
scope: packageScope,
|
|
32
|
-
|
|
38
|
+
refkeys: refkeys[symB],
|
|
33
39
|
package: packageScope.name,
|
|
34
40
|
});
|
|
35
41
|
}
|
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
import { OutputSymbol,
|
|
2
|
-
import {
|
|
3
|
-
import { JavaOutputScope } from "./scopes.js";
|
|
1
|
+
import { OutputSymbol, OutputSymbolOptions, refkey } from "@alloy-js/core";
|
|
2
|
+
import { usePackage } from "../components/PackageDirectory.jsx";
|
|
4
3
|
|
|
4
|
+
export interface JavaOutputSymbolOptions extends OutputSymbolOptions {
|
|
5
|
+
package?: string;
|
|
6
|
+
}
|
|
5
7
|
/**
|
|
6
8
|
* Represents an 'exported' symbol from a .java file. Class, enum, interface etc.
|
|
7
9
|
* Not considered exported if private
|
|
8
10
|
*/
|
|
9
|
-
export
|
|
11
|
+
export class JavaOutputSymbol extends OutputSymbol {
|
|
10
12
|
/**
|
|
11
13
|
* Fully qualified package name
|
|
12
14
|
*/
|
|
13
|
-
package
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const binder = useBinder();
|
|
18
|
-
const scope = useScope() as JavaOutputScope;
|
|
19
|
-
|
|
20
|
-
const parentPackage = usePackage();
|
|
15
|
+
get package() {
|
|
16
|
+
return this.#package;
|
|
17
|
+
}
|
|
18
|
+
#package?: string;
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
20
|
+
constructor(name: string, options: JavaOutputSymbolOptions = {}) {
|
|
21
|
+
if (options.refkeys === undefined) {
|
|
22
|
+
options.refkeys = [refkey(name)];
|
|
23
|
+
}
|
|
24
|
+
super(name, options);
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
if (options.package) {
|
|
27
|
+
this.#package = options.package;
|
|
28
|
+
} else {
|
|
29
|
+
const parentPackage = usePackage();
|
|
30
|
+
this.#package =
|
|
31
|
+
(options.package ?? parentPackage !== null) ?
|
|
32
|
+
parentPackage?.qualifiedName
|
|
33
|
+
: "";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
30
36
|
}
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OutputScope } from "@alloy-js/core";
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
kind
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function createJavaPackageScope(
|
|
8
|
-
binder: Binder,
|
|
9
|
-
parent: OutputScope | undefined,
|
|
10
|
-
name: string,
|
|
11
|
-
): JavaPackageScope {
|
|
12
|
-
return binder.createScope<JavaPackageScope>({
|
|
13
|
-
kind: "package",
|
|
14
|
-
name,
|
|
15
|
-
parent,
|
|
16
|
-
});
|
|
3
|
+
export class JavaPackageScope extends OutputScope {
|
|
4
|
+
get kind() {
|
|
5
|
+
return "package";
|
|
6
|
+
}
|
|
17
7
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
OutputScope,
|
|
3
|
+
OutputScopeOptions,
|
|
4
|
+
track,
|
|
5
|
+
TrackOpTypes,
|
|
6
|
+
trigger,
|
|
7
|
+
TriggerOpTypes,
|
|
8
|
+
} from "@alloy-js/core";
|
|
2
9
|
|
|
3
10
|
/**
|
|
4
11
|
* Represents an external dependency imported through a maven or gradle project
|
|
@@ -56,49 +63,93 @@ export interface MavenProjectConfig {
|
|
|
56
63
|
// TODO: Support gradle projects
|
|
57
64
|
export interface GradleProjectConfig {}
|
|
58
65
|
|
|
66
|
+
export interface JavaProjectScopeOptions extends OutputScopeOptions {
|
|
67
|
+
mavenProjectConfig?: MavenProjectConfig;
|
|
68
|
+
gradleProjectConfig?: GradleProjectConfig;
|
|
69
|
+
}
|
|
59
70
|
/**
|
|
60
71
|
* Represents the java project itself (maven, gradle, etc)
|
|
61
72
|
*/
|
|
62
|
-
export
|
|
63
|
-
kind
|
|
73
|
+
export class JavaProjectScope extends OutputScope {
|
|
74
|
+
get kind() {
|
|
75
|
+
return "project";
|
|
76
|
+
}
|
|
64
77
|
|
|
65
78
|
/**
|
|
66
79
|
* The dependencies of this project
|
|
67
80
|
* Map qualified package name to dependency
|
|
68
81
|
*/
|
|
69
|
-
dependencies
|
|
70
|
-
|
|
82
|
+
get dependencies() {
|
|
83
|
+
return this.#dependencies;
|
|
84
|
+
}
|
|
85
|
+
#dependencies = new Map<string, JavaDependency>();
|
|
71
86
|
|
|
72
87
|
/**
|
|
73
88
|
* Define project configuration. Either maven or gradle
|
|
74
89
|
*/
|
|
75
|
-
mavenProjectConfig
|
|
76
|
-
|
|
77
|
-
|
|
90
|
+
get mavenProjectConfig() {
|
|
91
|
+
track(this, TrackOpTypes.GET, "mavenProjectConfig");
|
|
92
|
+
return this.#mavenProjectConfig;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
set(mavenProjectConfig: MavenProjectConfig | undefined) {
|
|
96
|
+
const old = this.#mavenProjectConfig;
|
|
97
|
+
if (old === mavenProjectConfig) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
78
100
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
this.#mavenProjectConfig = mavenProjectConfig;
|
|
102
|
+
trigger(
|
|
103
|
+
this,
|
|
104
|
+
TriggerOpTypes.SET,
|
|
105
|
+
"mavenProjectConfig",
|
|
106
|
+
mavenProjectConfig,
|
|
107
|
+
old,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
#mavenProjectConfig?: MavenProjectConfig;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Define project configuration. Either maven or gradle
|
|
114
|
+
*/
|
|
115
|
+
get gradleProjectConfig() {
|
|
116
|
+
track(this, TrackOpTypes.GET, "gradleProjectConfig");
|
|
117
|
+
return this.#gradleProjectConfig;
|
|
118
|
+
}
|
|
119
|
+
set gradleProjectConfig(
|
|
120
|
+
gradleProjectConfig: GradleProjectConfig | undefined,
|
|
121
|
+
) {
|
|
122
|
+
const old = this.#gradleProjectConfig;
|
|
123
|
+
if (old === gradleProjectConfig) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this.#gradleProjectConfig = gradleProjectConfig;
|
|
128
|
+
trigger(
|
|
129
|
+
this,
|
|
130
|
+
TriggerOpTypes.SET,
|
|
131
|
+
"gradleProjectConfig",
|
|
132
|
+
gradleProjectConfig,
|
|
133
|
+
old,
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
#gradleProjectConfig?: GradleProjectConfig;
|
|
137
|
+
|
|
138
|
+
constructor(name: string, options: JavaProjectScopeOptions = {}) {
|
|
139
|
+
super(name, options);
|
|
140
|
+
|
|
141
|
+
this.#mavenProjectConfig = options.mavenProjectConfig;
|
|
142
|
+
this.#gradleProjectConfig = options.gradleProjectConfig;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
addDependency(dependency: JavaDependency): string {
|
|
146
|
+
const depKey = `${dependency.groupId}.${dependency.artifactId}.${dependency.version}`;
|
|
147
|
+
|
|
148
|
+
if (this.dependencies.has(depKey)) {
|
|
99
149
|
return depKey;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
this.dependencies.set(depKey, dependency);
|
|
153
|
+
return depKey;
|
|
154
|
+
}
|
|
104
155
|
}
|