Skip to content

Remove unnecessary useShapeWriter method #541

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

Merged
merged 1 commit into from
May 10, 2022
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 @@ -347,7 +347,7 @@ public Void stringShape(StringShape shape) {
@Override
public Void operationShape(OperationShape operation) {
if (settings.generateServerSdk()) {
writers.useShapeWriter(operation, symbolProvider, w -> {
writers.useShapeWriter(operation, w -> {
ServerGenerator.generateOperationHandler(symbolProvider, service, operation, w);
});
}
Expand Down Expand Up @@ -395,11 +395,11 @@ public Void serviceShape(ServiceShape shape) {
protocolGenerator.generateRequestDeserializers(serverContext);
protocolGenerator.generateResponseSerializers(serverContext);
protocolGenerator.generateFrameworkErrorSerializer(serverContext);
writers.useShapeWriter(shape, symbolProvider, w -> {
writers.useShapeWriter(shape, w -> {
protocolGenerator.generateServiceHandlerFactory(serverContext.withWriter(w));
});
for (OperationShape operation: TopDownIndex.of(model).getContainedOperations(service)) {
writers.useShapeWriter(operation, symbolProvider, w -> {
writers.useShapeWriter(operation, w -> {
protocolGenerator.generateOperationHandlerFactory(serverContext.withWriter(w), operation);
});
}
Expand Down Expand Up @@ -462,7 +462,7 @@ private void generateClient(ServiceShape shape) {
private void generateServiceInterface(ServiceShape shape) {
TopDownIndex topDownIndex = TopDownIndex.of(model);
Set<OperationShape> operations = new TreeSet<>(topDownIndex.getContainedOperations(shape));
writers.useShapeWriter(shape, symbolProvider, writer -> {
writers.useShapeWriter(shape, writer -> {
ServerGenerator.generateOperationsType(symbolProvider, shape, operations, writer);
ServerGenerator.generateServerInterfaces(symbolProvider, shape, operations, writer);
ServerGenerator.generateServiceHandler(symbolProvider, shape, operations, writer);
Expand All @@ -484,7 +484,7 @@ private void generateCommands(ServiceShape shape) {

if (settings.generateServerSdk()) {
ServerCommandGenerator.writeIndex(model, service, symbolProvider, fileManifest);
writers.useShapeWriter(operation, symbolProvider, commandWriter -> new ServerCommandGenerator(
writers.useShapeWriter(operation, commandWriter -> new ServerCommandGenerator(
settings, model, operation, symbolProvider, commandWriter,
protocolGenerator, applicationProtocol).run());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,11 @@ List<SymbolDependency> getDependencies() {
* with the writer.
*
* @param shape Shape to create the writer for.
* @param provider The symbol provider to use (instead of the default one).
* @param writerConsumer Consumer that accepts and works with the file.
*/
void useShapeWriter(Shape shape, SymbolProvider provider, Consumer<TypeScriptWriter> writerConsumer) {
void useShapeWriter(Shape shape, Consumer<TypeScriptWriter> writerConsumer) {
// Checkout/create the appropriate writer for the shape.
Symbol symbol = provider.toSymbol(shape);
Symbol symbol = symbolProvider.toSymbol(shape);
String fileName = symbol.getDefinitionFile();
if (!fileName.startsWith(Paths.get(".", CodegenUtils.SOURCE_FOLDER).toString())) {
fileName = Paths.get(".", CodegenUtils.SOURCE_FOLDER, fileName).toString();
Expand All @@ -106,26 +105,13 @@ void useShapeWriter(Shape shape, SymbolProvider provider, Consumer<TypeScriptWri
// Allow integrations to do things like add onSection callbacks.
// These onSection callbacks are removed when popState is called.
for (TypeScriptIntegration integration : integrations) {
integration.onShapeWriterUse(settings, model, provider, writer, shape);
integration.onShapeWriterUse(settings, model, symbolProvider, writer, shape);
}

writerConsumer.accept(writer);
writer.popState();
}

/**
* Gets a previously created writer or creates a new one if needed.
*
* <p>Any imports required by the given symbol are automatically registered
* with the writer.
*
* @param shape Shape to create the writer for.
* @param writerConsumer Consumer that accepts and works with the file.
*/
void useShapeWriter(Shape shape, Consumer<TypeScriptWriter> writerConsumer) {
useShapeWriter(shape, symbolProvider, writerConsumer);
}

/**
* Gets a previously created writer or creates a new one if needed
* and adds a new line if the writer already exists.
Expand Down