Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove calls to deprecated model.getKnowledge #257

Merged
merged 1 commit into from
Jan 7, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static String getOperationSerializerContextType(
// Get default SerdeContext.
List<String> contextInterfaceList = getDefaultOperationSerdeContextTypes(writer);
// If event stream trait exists, add corresponding serde context type to the intersection type.
EventStreamIndex eventStreamIndex = model.getKnowledge(EventStreamIndex.class);
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
if (eventStreamIndex.getInputInfo(operation).isPresent()) {
writer.addImport("EventStreamSerdeContext", "__EventStreamSerdeContext", "@aws-sdk/types");
contextInterfaceList.add("__EventStreamSerdeContext");
Expand All @@ -77,7 +77,7 @@ public static String getOperationDeserializerContextType(
// Get default SerdeContext.
List<String> contextInterfaceList = getDefaultOperationSerdeContextTypes(writer);
// If event stream trait exists, add corresponding serde context type to the intersection type.
EventStreamIndex eventStreamIndex = model.getKnowledge(EventStreamIndex.class);
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
if (eventStreamIndex.getOutputInfo(operation).isPresent()) {
writer.addImport("EventStreamSerdeContext", "__EventStreamSerdeContext", "@aws-sdk/types");
contextInterfaceList.add("__EventStreamSerdeContext");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public Void serviceShape(ServiceShape shape) {
settings, model, symbolProvider, nonModularName, writer, applicationProtocol).run());

// Generate each operation for the service.
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
TopDownIndex topDownIndex = TopDownIndex.of(model);
Set<OperationShape> containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service));
boolean hasPaginatedOperation = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ final class CommandGenerator implements Runnable {
this.applicationProtocol = applicationProtocol;

symbol = symbolProvider.toSymbol(operation);
operationIndex = model.getKnowledge(OperationIndex.class);
operationIndex = OperationIndex.of(model);
inputType = symbol.expectProperty("inputType", Symbol.class);
outputType = symbol.expectProperty("outputType", Symbol.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ final class HttpProtocolTestGenerator implements Runnable {

@Override
public void run() {
OperationIndex operationIndex = model.getKnowledge(OperationIndex.class);
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
OperationIndex operationIndex = OperationIndex.of(model);
TopDownIndex topDownIndex = TopDownIndex.of(model);

// Use a TreeSet to have a fixed ordering of tests.
for (OperationShape operation : new TreeSet<>(topDownIndex.getContainedOperations(service))) {
Expand Down Expand Up @@ -296,7 +296,7 @@ private void writeRequestBodyAssertions(OperationShape operation, HttpRequestTes
// Fast check if we have an undescribed or plain text body.
if (mediaType == null || mediaType.equals("text/plain")) {
// Handle converting to the right comparison format for blob payloads.
HttpBindingIndex httpBindingIndex = model.getKnowledge(HttpBindingIndex.class);
HttpBindingIndex httpBindingIndex = HttpBindingIndex.of(model);
List<HttpBinding> payloadBindings = httpBindingIndex.getRequestBindings(operation, Location.PAYLOAD);
if (!payloadBindings.isEmpty() && hasBlobBinding(payloadBindings)) {
writer.write("expect(r.body).toMatchObject(Uint8Array.from($S, c => c.charCodeAt(0)));", body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void writeIndex(
writer.write("export * from \"./" + nonModularName + "\";");

// write export statements for each command in /commands directory
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
TopDownIndex topDownIndex = TopDownIndex.of(model);
Set<OperationShape> containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service));
boolean hasPaginatedOperation = false;
for (OperationShape operation : containedOperations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ final class NonModularServiceGenerator implements Runnable {

@Override
public void run() {
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
TopDownIndex topDownIndex = TopDownIndex.of(model);

// Generate the client and extend from the modular client.
writer.writeShapeDocs(service);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void writeInputOutputTypeUnion(
Function<Symbol, Optional<Symbol>> mapper,
Consumer<TypeScriptWriter> defaultTypeGenerator
) {
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
TopDownIndex topDownIndex = TopDownIndex.of(model);
Set<OperationShape> containedOperations = topDownIndex.getContainedOperations(service);

List<Symbol> symbols = containedOperations.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ final class SymbolVisitor implements SymbolProvider, ShapeVisitor<Symbol> {
.buildEscaper();

// Get each structure that's used an error.
OperationIndex operationIndex = model.getKnowledge(OperationIndex.class);
OperationIndex operationIndex = OperationIndex.of(model);
model.shapes(OperationShape.class).forEach(operationShape -> {
errorShapes.addAll(operationIndex.getErrors(operationShape));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public ShapeId resolveServiceProtocol(Model model, ServiceShape service, Set<Sha
return protocol;
}

ServiceIndex serviceIndex = model.getKnowledge(ServiceIndex.class);
ServiceIndex serviceIndex = ServiceIndex.of(model);
Set<ShapeId> resolvedProtocols = serviceIndex.getProtocols(service).keySet();
if (resolvedProtocols.isEmpty()) {
throw new UnresolvableProtocolException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ private static boolean hasEventStream(
Model model,
ServiceShape service
) {
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
TopDownIndex topDownIndex = TopDownIndex.of(model);
Set<OperationShape> operations = topDownIndex.getContainedOperations(service);
EventStreamIndex eventStreamIndex = model.getKnowledge(EventStreamIndex.class);
EventStreamIndex eventStreamIndex = EventStreamIndex.of(model);
for (OperationShape operation : operations) {
if (eventStreamIndex.getInputInfo(operation).isPresent()
|| eventStreamIndex.getOutputInfo(operation).isPresent()
Expand Down