-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve CodeWriter backwards compatibility
Adding a parent of CodeWriter that changed the return type of its methods, even though those returned objects were always in practice the same type as they had been before, broke binary backwards compatibility for consumers of CodeWriter. This returns CodeWriter back to its previous state, mostly, and adds a new default extension of AbstractCodeWriter called SimpleCodeWriter. Current consumers of CodeWriter will continue to work, and have access to some new features.
- Loading branch information
1 parent
0f442d2
commit a89ed09
Showing
16 changed files
with
2,223 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
smithy-codegen-core/src/main/java/software/amazon/smithy/codegen/core/writer/DocWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.smithy.codegen.core.writer; | ||
|
||
import software.amazon.smithy.utils.AbstractCodeWriter; | ||
import software.amazon.smithy.utils.SmithyUnstableApi; | ||
|
||
/** | ||
* Responsible for properly writing documentation emitted when a | ||
* {@code Runnable} in invoked. | ||
* | ||
* <p>The following example shows how to implement a basic | ||
* {@code DocumentationWriter} that encloses documentation in | ||
* successive lines that start with "///". | ||
* | ||
* <pre>{@code | ||
* public final class MyDocWriter implements DocumentationWriter<MyWriter> { | ||
* \@Override | ||
* public void writeDocs(T writer, Runnable runnable) { | ||
* setNewlinePrefix("/// ") | ||
* runnable.run(); | ||
* } | ||
* } | ||
* }</pre> | ||
* | ||
* @param <T> The type of {@code AbstractCodeWriter} being written to. | ||
*/ | ||
@FunctionalInterface | ||
@SmithyUnstableApi | ||
public interface DocWriter<T extends AbstractCodeWriter<T>> { | ||
|
||
/** | ||
* Writes documentation comments. | ||
* | ||
* <p>Implementations are expected to write out the beginning of a documentation | ||
* comment, set any necessary prefix for each line written while writing docs, | ||
* then invoke the given {@code runnable}, then finally write the closing | ||
* characters for documentation. | ||
* | ||
* @param writer Writer to configure for writing documentation. | ||
* @param runnable Runnable that handles actually writing docs with the writer. | ||
*/ | ||
void writeDocs(T writer, Runnable runnable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.