Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ allprojects {
// The root project doesn't produce a JAR.
tasks["jar"].enabled = false

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

repositories {
mavenLocal()
Expand Down Expand Up @@ -105,8 +102,14 @@ subprojects {
}
}

// Always run javadoc after build.
tasks["build"].finalizedBy(tasks["javadoc"])
tasks {
javadoc {
// not enabled due to excessive output.
// if taking up the task of resolving javadoc issues, at
// that time this can be enabled again.
enabled = false
}
}

/*
* Maven
Expand Down Expand Up @@ -145,7 +148,7 @@ subprojects {
licenses {
license {
name.set("Apache License 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
Expand Down Expand Up @@ -293,4 +296,4 @@ jreleaser {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.knowledge.KnowledgeIndex;
import software.amazon.smithy.model.selector.Selector;
import software.amazon.smithy.model.shapes.MemberShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.shapes.ShapeId;
import software.amazon.smithy.model.shapes.ToShapeId;
Expand All @@ -28,13 +29,13 @@
*/
public class SerdeElisionIndex implements KnowledgeIndex {
private final Map<ShapeId, Boolean> elisionBinding = new HashMap<>();
private final Map<String, Class> mutatingTraits = MapUtils.of(
"jsonName", JsonNameTrait.class,
"streaming", StreamingTrait.class,
"mediaType", MediaTypeTrait.class,
"sparse", SparseTrait.class,
"idempotencyToken", IdempotencyTokenTrait.class
);
private final Map<String, ShapeId> mutatingTraits = MapUtils.of(
"jsonName", JsonNameTrait.ID,
"streaming", StreamingTrait.ID,
"mediaType", MediaTypeTrait.ID,
"sparse", SparseTrait.ID,
"idempotencyToken", IdempotencyTokenTrait.ID
);

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

private boolean hasMutatingTraits(Shape shape, Model model) {
for (Map.Entry<String, Class> entry : mutatingTraits.entrySet()) {
for (var entry : mutatingTraits.entrySet()) {
if (shape.hasTrait(entry.getValue())) {
return true;
}
if (shape.getMemberTrait(model, entry.getValue()).isPresent()) {
return true;
if (shape instanceof MemberShape memberShape) {
if (model.expectShape(memberShape.getTarget()).hasTrait(entry.getValue())) {
return true;
}
}
Selector selector = Selector.parse(
"[id = '" + shape.getId() + "']" + " ~> [trait|" + entry.getKey() + "]");
"[id = '" + shape.getId() + "']" + " ~> [trait|" + entry.getKey() + "]");
if (!selector.select(model).isEmpty()) {
return true;
}
Expand All @@ -91,15 +94,15 @@ private boolean hasIncompatibleTypes(Shape shape, Model model, int depth) {
return hasIncompatibleTypes(target.asSetShape().get().getMember(), model, depth + 1);
case STRUCTURE:
return target.asStructureShape().get().getAllMembers().values().stream().anyMatch(
s -> hasIncompatibleTypes(s, model, depth + 1)
s -> hasIncompatibleTypes(s, model, depth + 1)
);
case UNION:
return target.asUnionShape().get().getAllMembers().values().stream().anyMatch(
s -> hasIncompatibleTypes(s, model, depth + 1)
s -> hasIncompatibleTypes(s, model, depth + 1)
);
case MAP:
return hasIncompatibleTypes(model.getShape(target.asMapShape().get().getValue().getTarget()).get(),
model, depth + 1);
model, depth + 1);
case BIG_DECIMAL:
case BIG_INTEGER:
case BLOB:
Expand Down