Class SymbolWriter<T extends SymbolWriter<T,U>,U extends ImportContainer>
- Type Parameters:
T
- The concrete type, used to provide a fluent interface.U
- The import container used by the writer to manage imports.
- All Implemented Interfaces:
SymbolDependencyContainer
Use SymbolWriter
instead.
-
Constructor Summary
ConstructorDescriptionSymbolWriter
(DocWriter<T> documentationWriter, U importContainer) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionfinal T
addDependency
(SymbolDependencyContainer dependencies) Deprecated.Adds one or more dependencies to the generated code (represented as aSymbolDependency
).final T
addImport
(Symbol symbol, String alias, SymbolReference.ContextOption... options) Deprecated.Imports a symbol (if necessary) using a specific alias and list of context options.addUseImports
(SymbolContainer container) Deprecated.Imports one or more USE symbols using the name of the symbol (e.g.,SymbolReference.ContextOption.USE
references).addUseImports
(SymbolReference symbolReference) Deprecated.Imports a USE symbols possibly using an alias of the symbol (e.g.,SymbolReference.ContextOption.USE
references).final List<SymbolDependency>
Deprecated.Gets the list of dependencies that this object introduces.Deprecated.Gets the documentation writer.final U
Deprecated.Gets the import container associated with the writer.setRelativizeSymbols
(String relativizeSymbols) Deprecated.Sets a string used to relativize Symbols formatted using the defaultT
implementation used byCodegenWriter
in the current state.final T
Deprecated.Writes documentation comments.final T
Deprecated.Writes documentation comments from a string.Methods inherited from class software.amazon.smithy.utils.AbstractCodeWriter
call, closeBlock, consumer, copySettingsFrom, dedent, dedent, disableNewlines, enableNewlines, enableStackTraceComments, ensureNewline, format, formatLiteral, formatWithStackTraceElement, getContext, getContext, getDebugInfo, getDebugInfo, getExpressionStart, getIndentLevel, getIndentText, getInsertTrailingNewline, getNewline, getNewlinePrefix, getTrimBlankLines, getTrimTrailingSpaces, indent, indent, injectSection, insertTrailingNewline, insertTrailingNewline, isStackTraceRelevant, onSection, onSection, openBlock, openBlock, openBlock, openBlock, openBlock, openBlock, openBlock, openBlock, popState, pushFilteredState, pushState, pushState, pushState, putContext, putContext, putFormatter, removeContext, setExpressionStart, setIndentText, setNewline, setNewline, setNewlinePrefix, toString, trimBlankLines, trimBlankLines, trimTrailingSpaces, trimTrailingSpaces, unwrite, write, writeInline, writeInlineWithNoFormatting, writeOptional, writeWithNoFormatting
-
Constructor Details
-
SymbolWriter
Deprecated.- Parameters:
documentationWriter
- Writes out documentation emitted by aRunnable
.importContainer
- Container used to persist and filter imports based on package names.
-
-
Method Details
-
setRelativizeSymbols
Deprecated.Sets a string used to relativize Symbols formatted using the defaultT
implementation used byCodegenWriter
in the current state.In many programming languages, when referring to types in the same namespace as the current scope of a CodegenWriter, the symbols written in that scope don't need to be fully-qualified. They can just reference the unqualified type name. By setting a value for
relativizeSymbols
, if the result ofSymbol.getNamespace()
is equal torelativizeSymbols
, then the unqualified name of the symbol is written to theCodegenWriter
when the default implementation ofT
is written. Symbols that refer to types in other namespaces will write the fully qualified type.Note: This method may have no effect if a programming language does not use namespaces or concepts like namespaces or if
T
has been overridden with another implementation.- Parameters:
relativizeSymbols
- The package name, namespace, etc to relativize symbols with.- Returns:
- Returns the CodegenWriter.
-
getDocumentationWriter
Deprecated.Gets the documentation writer.- Returns:
- Returns the documentation writer.
-
getImportContainer
Deprecated.Gets the import container associated with the writer.The
AbstractCodeWriter.toString()
method of theCodegenWriter
should be overridden so that it includes the import container's contents in the output as appropriate.- Returns:
- Returns the import container.
-
getDependencies
Deprecated.Description copied from interface:SymbolDependencyContainer
Gets the list of dependencies that this object introduces.A dependency is a dependency on another package that a Symbol or type requires. It is quite different from a reference since a reference only refers to a symbol; a reference provides no context as to whether or not a dependency is required or the dependency's coordinates.
- Specified by:
getDependencies
in interfaceSymbolDependencyContainer
- Returns:
- Returns the dependencies.
-
addDependency
Deprecated.Adds one or more dependencies to the generated code (represented as aSymbolDependency
).Tracking dependencies on a
CodegenWriter
allows dependencies to be automatically aggregated and collected in order to generate configuration files for dependency management tools (e.g., npm, maven, etc).- Parameters:
dependencies
- Dependency to add.- Returns:
- Returns the writer.
-
addUseImports
Deprecated.Imports one or more USE symbols using the name of the symbol (e.g.,SymbolReference.ContextOption.USE
references).USE references are only necessary when referring to a symbol, not declaring the symbol. For example, when referring to a
List<Foo>
, the USE references would be both theList
type andFoo
type.This method may be overridden as needed.
- Parameters:
container
- Symbols to add.- Returns:
- Returns the writer.
-
addUseImports
Deprecated.Imports a USE symbols possibly using an alias of the symbol (e.g.,SymbolReference.ContextOption.USE
references).This method may be overridden as needed.
- Parameters:
symbolReference
- Symbol reference to import.- Returns:
- Returns the writer.
- See Also:
-
addImport
Deprecated.Imports a symbol (if necessary) using a specific alias and list of context options.This method automatically adds any dependencies of the
symbol
to the writer, callsImportContainer.importSymbol(software.amazon.smithy.codegen.core.Symbol, java.lang.String)
, and automatically callsaddImportReferences(software.amazon.smithy.codegen.core.Symbol, software.amazon.smithy.codegen.core.SymbolReference.ContextOption...)
for the providedsymbol
.When called with no
options
, bothUSE
andDECLARE
symbols are imported from any references theSymbol
might contain.- Parameters:
symbol
- Symbol to optionally import.alias
- The alias to refer to the symbol by.options
- The list of context options (e.g., is it a USE or DECLARE symbol).- Returns:
- Returns the writer.
-
writeDocs
Deprecated.Writes documentation comments.This method is responsible for setting up the writer to begin writing documentation comments. This includes writing any necessary opening tokens (e.g., "/*"), adding tokens to the beginning of lines (e.g., "*"), sanitizing documentation strings, and writing any tokens necessary to close documentation comments (e.g., "*\/").
This method does not automatically escape the expression start character ("$" by default). Write calls made by the Runnable should either use
AbstractCodeWriter.writeWithNoFormatting(java.lang.Object)
or escape the expression start character manually.This method may be overridden as needed.
- Parameters:
runnable
- Runnable that handles actually writing docs with the writer.- Returns:
- Returns the writer.
-
writeDocs
Deprecated.Writes documentation comments from a string.- Parameters:
docs
- Documentation to write.- Returns:
- Returns the writer.
-