Coder Social home page Coder Social logo

Comments (5)

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

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.

ilyapuchka avatar ilyapuchka commented on May 22, 2024

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.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

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.

ilyapuchka avatar ilyapuchka commented on May 22, 2024

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.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

ah right, it doesn't compile otherwise 👍

from sourcery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.