- Added support for inline code generation without requiring explicit
// sourcery:inline
comments in the source files. To use, usesourcery:inline:auto
in a template:// sourcery:inline:auto:MyType.TemplateName
- Added
isMutable
property forVariable
- Added support for scanning multiple targets
- Added access level filters and disabled filtering private declarations
- Added support for inline comments for annotations with
/*
and*/
- Added annotations for enum case associated values and method parameters
- Added
isConvenienceInitializer
property forMethod
- Added
defaultValue
for variables and method parameters - Added docs generated with jazzy
- Sourcery now will not create empty files and will remove existing generated files with empty content if CLI flag
prune
is set totrue
(false
by default) - Sourcery now will remove inline annotation comments from generated code.
- Added
rethrows
property toMethod
- Allow duplicated annotations to be agregated into array
- Added ejs-style tags to control whitespaces and new lines in swift templates
- Added CLI option to provide path to config file
- Inserting multiple inline code block in one file
- Suppress warnings when compiling swift templates
- Accessing protocols in Swift templates
- Crash that would happen sometimes when parsing typealiases
- Replaced
TypeReflectionBox
andGenerationContext
types with commonTemplateContext
.
- Added flag to check if
TypeName
is dictionary - Added support for multiple sources and templates paths, sources, templates and output paths now should be provided with
--sources
,--templates
and--output
options - Added support for YAML file configuration
- Added generation of non-swift files using
sourcery:file
annotation
- Fixed observing swift and js templates
- Fixed parsing generic array types
- Fixed using dictionary in annotations
- Added parsing array types
- Added support for JavaScript templates (using EJS)
- Fixed escaping variables with reserved names
- Fixed duplicated methods and variables in
allMethods
andallVariables
- Fixed trimming attributes in type names
- Cache initial file contents, including the inline generated ranges so that they are always up to date
- Added per file code generation
- Fixed parsing annotations with complex content
- Fixed inline parser using wrong caching logic
- Sourcery will no longer write files if content didn't change, this improves behaviour of things depending on modification date like Xcode, Swiftlint.
- Improved support for contained types
- Fixes cache handling that got broken in 0.5.4
- Added inline code generation
- Added
isClosure
property toTypeName
to detect closure types
- Fixed parsing of associated values separater by newlines
- Fixed preserving order of inherited types
- Improved support for throwing methods in protocols
- Fixed extracting parameters of methods with closures in their bodies
- Fixed extracting method return types of tuple types
- Improved support for typealises as tuple elements types
- Method parameters with
_
argument label will now havenil
inargumentLabel
property - Improved support for generic methods
- Improved support for contained types
- adjusted internal templates and updated generated code
- moved methods parsing related tests in a separate spec
- Added support for method return types with
throws
andrethrows
- Added a new filter
replace
. Usage:{{ name|replace:"substring","replacement" }}
- replaces occurrences ofsubstring
withreplacement
inname
(case sensitive) - Improved support for inferring types of variables with initial values
- Sourcery is now bundling a set of example templates, you can access them in Templates folder.
- We now use parallel parsing and cache source artifacts. This leads to massive performance improvements:
- e.g. on big codebase of over 300 swift files:
Sourcery 0.5.2
Processing time 8.69941002130508 seconds
Sourcery 0.5.3
First time 4.69904798269272 seconds
Subsequent time: 0.882099032402039 seconds
- Method
accessLevel
was not exposed as string so not accessible properly via templates, fixed that. - Fixes on Swift Templates
-
Added support for
ImplicitlyUnwrappedOptional
-
actualTypeName
property ofMethod.Parameter
,Variable
,Enum.Case.AssociatedValue
,TupleType.Element
now returnstypeName
if type is not a type alias -
Enum
now contains type information for its raw value type.rawType
now returnType
object,rawTypeName
returns itsTypeName
-
Added
annotated
filter to filter by annotations -
Added negative filters counterparts
-
Added support for attributes, i.e.
@escaping
-
Experimental support for Swift Templates
-
Swift Templates are now supported
<% for type in types.classes { %>
extension <%= type.name %>: Equatable {}
<% if type.annotations["showComment"] != nil { %> // <%= type.name %> has Annotations <% } %>
func == (lhs: <%= type.name %>, rhs: <%= type.name %>) -> Bool {
<% for variable in type.variables { %> if lhs.<%= variable.name %> != rhs.<%= variable.name %> { return false }
<% } %>
return true
}
<% } %>
- Variables with default initializer are now supported, e.g.
var variable = Type(...)
- Added support for special escaped names in enum cases e.g.
default
orfor
- Added support for tuple types and
tuple
filter for variables - Enum associated values now have
localName
andexternalName
properties. - Added
actualTypeName
forTypeName
that is typealias - Added
implements
,inherits
andbased
filters
- Using protocols doesn't expose variables using KVC, which meant some of the typeName properties weren't accessible via Templates, we fixed that using Sourcery itself to generate specific functions.
- Fixed parsing typealiases for tuples and closure types
- Fixed parsing associated values of generic types
- Performed significant refactoring and simplified mutations in parsers
- You can now pass arbitrary values to templates with
--args
argument. - Added
open
access level - Type
inherits
andimplements
now allow you to access full type information, not just name - Type
allVariables
will now include all variables, including those inherited from supertype and known protocols. - Type
allMethods
will now include all methods, including those inherited from supertype and known protocols. - AssociatedValue exposes
unwrappedTypeName
,isOptional
- New Available stencil filters:
static
,instance
,computed
,stored
for Variablesenum
,class
,struct
,protocol
for Typesclass
,initializer
,static
,instance
for Methodscount
for Arrays, this is used when chaining arrays with filters where Stencil wouldn't allow us to do.count
, e.g.{{ variables|instance|count }}
- Now you can avoid inferring unknown protocols as enum raw types by adding conformance in extension (instead of
enum Foo: Equatable {}
doenum Foo {}; extension Foo: Equatable {}
)
- Refactor code around typenames
- Watch mode now works with folders, reacting to source-code changes and adding templates/source files.
- When using watch mode, status info will be displayed in the generated code so that you don't need to look at console at all.
- You can now access types of enum's associated values
- You can now access type's
methods
andinitializers
- You can now access
supertype
of a class - Associated values will now automatically use idx as name if no name is provided
- Fix dealing with multibyte characters
types.implementing
andtypes.based
should include protocols that are based on other protocols
- TDD Development is now easier thanks to Diffable results, no longer we need to scan wall of text on failures, instead we see exactly what's different.
- Added
contains
,hasPrefix
,hasPrefix
filters
- AccessLevel is now stored as string
- Typealiases parsing could cause crash, implemented a workaround for that until we can find a little more reliable solution
- Swift Package Manager support.
- Enum cases also have annotation support
- Improved handling of global and local typealiases.
- Add upperFirst stencil filter
- Fixes a bug with flattening
inherits
,implements
for protocols implementing other protocols - Improve
rawType
logic for Enums
- Annotations can now be declared also with sections e.g.
sourcery:begin: attribute1, attribute2 = 234
- Adds scanning class variables as static
- Refactored models
- Improved performance of annotation scanning
- Implements inherits, implements, based reflection on each Type
- Flattens inheritance, e.g. Foo implements Decodable, then FooSubclass also implements it
- Stop parsing private variables as they wouldn't be accessible to code-generated code
- improve detecting raw type
- add
isGeneric
property
- Enables support for scanning extensions of unknown type, providing partial metadata via types.based or types.all reflection
- Adds real type reflection into Variable, not only it's name
- Resolves known typealiases
- Fixes a bug that caused Sourcery to drop previous type information when encountering generated code, closes #33
- Fixes bug in escaping path
- Fixes missing protocol variant in kind
- added support for type/variable source annotations
- added property kind to Type, it contains info whether this is struct, class or enum entry
- Automatically skips .swift files that were generated with Sourcery
- improved detecting enums with rawType