Comments (5)
my changes in #39 will help since we will be able to access parent types from children, I've few ideas how we can implement this but not sure if you started on this or is this for the picking?
from sourcery.
I didn't start on that, just though about how to implement that so you can pick it if you want. What were your ideas?
I was thinking that to parse type aliases inside the type is not a big deal, we just need to get a syntax map for not the whole content, but just for the type body portion. Then we can store discovered type aliases in the collection in the Type
just the same way as inherited types. This way it will be possible to find types for type names "MyType.MyAlias" later.
The problem then is how to parse global type aliases. Probably we need to check if typealias token is outside of any types body ranges (I guess we can get that from __parserData).
Another problem is what to do with private type aliases. The thing is that it's possible to have different private typealiases with the same name in different extensions.
struct MyStruct {}
extension MyStruct {
private typealias MyAlias = Int
private var myInt: MyAlias { return 0 }
}
extension MyStruct {
private typealias MyAlias = String
private var myString: MyAlias { return "" }
}
So to find proper type in this case we need to do that before we extend type with these extensions... But to be honest I'm not sure we should handle that case as these variables will not be accessible from generated code. But then maybe we should ignore everything what is private? Like private methods, variables, contained types.
Also we should probably only process type aliases defined on a type level.
And another thing to think about - generic type aliases which are now possible in Swift 3...
from sourcery.
Pretty much the same idea, it seems you have thought this through more than I did though, want to try this out? I think it makes sense to skip scanning private variables since you are right they wouldn't be accessible, if it's not private variable but has private typealias we can replace it with right type then
from sourcery.
Ok, I'll go for it then.
If it's private type alias we can not use it for anything but private variables, or only in private methods, so we can simply ignore all the private stuff.
from sourcery.
ah right, it doesn't compile otherwise 👍
from sourcery.
Related Issues (20)
- Malformed generated mocks HOT 1
- Missing bin folder with 2.1.3 HOT 5
- Missing bin folder with 2.1.4 HOT 5
- Homebrew does not include latest version (2.1.4) HOT 3
- The platform of the target `MyApp` (iOS 16.0) is not compatible with `Sourcery (2.1.4)`, which does not support `iOS` HOT 18
- AutoMockable stencil does not support inout parameters HOT 3
- Generated Automockable compilation issue due to malformed generated variable name HOT 2
- Generated AutoMockable compilation issue due to variadic parameters HOT 11
- [BUG] Generated AutoMockable compilation issues HOT 1
- Windows Support
- Sourcery doesn't properly work when using protocols with primary associated types HOT 2
- Add whitespace trimming configuration for Stencil templates
- [QUESTION] Thread-Safe Mocks HOT 1
- [Bug] Failed to resolve dependencies (SPM issue) HOT 5
- Watch mode only watches sources from last configuration file when passing multiple paths to configuration files using `--config` command line options
- Getting generic requirements from methods HOT 1
- Possible to generate asset catalog constants? HOT 1
- Detecting if a variable is an Enum works if enum is declared in the file but doesn't otherwise. HOT 4
- AutoMockable does not generate valid Swift code during method generic requirement parsing HOT 2
- Swift macros and method bodies HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sourcery.