Repository navigation
Classes, Collection Literals, and More
What's new
Class declarations
Build and render classes with ClassDescriptor. Use the MemberAccessDescriptor.superMember(_:) convenience for describing super member access.
Collections
Array and dictionary literals can now contain expressions:
.array([
.integer(1),
.integer(1),
]).array([
.functionCall("resolveSetting"),
]).dictionary([
.init(key: .string("key"), value: .boolean(true)),
])Note
Each element for arrays and dictionaries will always be output onto a new-line with a trailing comma.
New integer literals
Integer literals can be rendered in decimal, hexadecimal, octal, or binary using IntegerLiteral.
.integer(.decimal(1234)) // explicit form of .integer(1234)
.integer(.hexadecimal(0x4096Ee))
.integer(.octal(0o12345))
.integer(.binary(0b100))Note
The integer value you provide does not need to match the decimal, hexadecimal, octal, or binary you wish to be rendered to the code; the compiler does not distinguish between how a literal is declared and is just provided as Int to SwiftStructureKit.
Commenting
DocC, inline comments, and mark comments now support Swift string interpolation.
Imports
- Import descriptors support
varandletimports ImportDescriptor.foundationis a convenience for importing Foundation; the most common import.
Force unwrapping
Forced-value expressions render postfix !
.forcedValue(.identifier("value"))Renders as value!.
Breaking changes and migration
StatementDescriptor.controlFlowis replaced by.controlTransfer. Update construction and switch patterns to use.controlTransfer.LiteralDescriptorno longer conforms toEquatable. Its integer case now usesIntegerLiteral; integer construction such as.integer(42)remains available, but code that switches on literals cases will need to handle.decimal,.hexadecimal,.octal, and.binary.- If you switch exhaustively over
ImportDescriptor.Kind, add handling for.varand.let.