Skip to content

Commit a26aa66

Browse files
authored
chore(codegen): turn off javadoc task & fix unsafe Class usage warning (#1797)
* chore(codegen): turn off javadoc task * fix(codegen): fix unsafe code from checkstyle warning
1 parent e1f05cc commit a26aa66

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

build.gradle.kts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ allprojects {
3434
// The root project doesn't produce a JAR.
3535
tasks["jar"].enabled = false
3636

37-
// Load the Sonatype user/password for use in publishing tasks.
38-
val sonatypeUser: String? by project
39-
val sonatypePassword: String? by project
4037

4138
repositories {
4239
mavenLocal()
@@ -105,8 +102,14 @@ subprojects {
105102
}
106103
}
107104

108-
// Always run javadoc after build.
109-
tasks["build"].finalizedBy(tasks["javadoc"])
105+
tasks {
106+
javadoc {
107+
// not enabled due to excessive output.
108+
// if taking up the task of resolving javadoc issues, at
109+
// that time this can be enabled again.
110+
enabled = false
111+
}
112+
}
110113

111114
/*
112115
* Maven
@@ -145,7 +148,7 @@ subprojects {
145148
licenses {
146149
license {
147150
name.set("Apache License 2.0")
148-
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
151+
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
149152
distribution.set("repo")
150153
}
151154
}
@@ -293,4 +296,4 @@ jreleaser {
293296
}
294297
}
295298
}
296-
}
299+
}

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/knowledge/SerdeElisionIndex.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import software.amazon.smithy.model.Model;
1111
import software.amazon.smithy.model.knowledge.KnowledgeIndex;
1212
import software.amazon.smithy.model.selector.Selector;
13+
import software.amazon.smithy.model.shapes.MemberShape;
1314
import software.amazon.smithy.model.shapes.Shape;
1415
import software.amazon.smithy.model.shapes.ShapeId;
1516
import software.amazon.smithy.model.shapes.ToShapeId;
@@ -28,13 +29,13 @@
2829
*/
2930
public class SerdeElisionIndex implements KnowledgeIndex {
3031
private final Map<ShapeId, Boolean> elisionBinding = new HashMap<>();
31-
private final Map<String, Class> mutatingTraits = MapUtils.of(
32-
"jsonName", JsonNameTrait.class,
33-
"streaming", StreamingTrait.class,
34-
"mediaType", MediaTypeTrait.class,
35-
"sparse", SparseTrait.class,
36-
"idempotencyToken", IdempotencyTokenTrait.class
37-
);
32+
private final Map<String, ShapeId> mutatingTraits = MapUtils.of(
33+
"jsonName", JsonNameTrait.ID,
34+
"streaming", StreamingTrait.ID,
35+
"mediaType", MediaTypeTrait.ID,
36+
"sparse", SparseTrait.ID,
37+
"idempotencyToken", IdempotencyTokenTrait.ID
38+
);
3839

3940
public SerdeElisionIndex(Model model) {
4041
for (Shape shape : model.toSet()) {
@@ -58,15 +59,17 @@ private boolean canBeElided(Shape shape, Model model) {
5859
}
5960

6061
private boolean hasMutatingTraits(Shape shape, Model model) {
61-
for (Map.Entry<String, Class> entry : mutatingTraits.entrySet()) {
62+
for (var entry : mutatingTraits.entrySet()) {
6263
if (shape.hasTrait(entry.getValue())) {
6364
return true;
6465
}
65-
if (shape.getMemberTrait(model, entry.getValue()).isPresent()) {
66-
return true;
66+
if (shape instanceof MemberShape memberShape) {
67+
if (model.expectShape(memberShape.getTarget()).hasTrait(entry.getValue())) {
68+
return true;
69+
}
6770
}
6871
Selector selector = Selector.parse(
69-
"[id = '" + shape.getId() + "']" + " ~> [trait|" + entry.getKey() + "]");
72+
"[id = '" + shape.getId() + "']" + " ~> [trait|" + entry.getKey() + "]");
7073
if (!selector.select(model).isEmpty()) {
7174
return true;
7275
}
@@ -91,15 +94,15 @@ private boolean hasIncompatibleTypes(Shape shape, Model model, int depth) {
9194
return hasIncompatibleTypes(target.asSetShape().get().getMember(), model, depth + 1);
9295
case STRUCTURE:
9396
return target.asStructureShape().get().getAllMembers().values().stream().anyMatch(
94-
s -> hasIncompatibleTypes(s, model, depth + 1)
97+
s -> hasIncompatibleTypes(s, model, depth + 1)
9598
);
9699
case UNION:
97100
return target.asUnionShape().get().getAllMembers().values().stream().anyMatch(
98-
s -> hasIncompatibleTypes(s, model, depth + 1)
101+
s -> hasIncompatibleTypes(s, model, depth + 1)
99102
);
100103
case MAP:
101104
return hasIncompatibleTypes(model.getShape(target.asMapShape().get().getValue().getTarget()).get(),
102-
model, depth + 1);
105+
model, depth + 1);
103106
case BIG_DECIMAL:
104107
case BIG_INTEGER:
105108
case BLOB:

0 commit comments

Comments
 (0)