Giter VIP home page Giter VIP logo

Comments (25)

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024 1

@ilyapuchka @vknabel so what I've right now is:

  • variables - all available variables = typeVariable + variables from inherits and implements
  • typeVariables (could use a better name?) - only variables defined in this type (or it's extension)

All our filters e.g. staticVariables apply against variables now, should we modify this behaviour?

maybe leave variables as is on master and name the new property allVariables / flatVariables + corresponding allStaticVariables but maybe you have better name suggestions?

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024 1

@AliSoftware how about the suggestion I added above? keeping variables as is and adding [all or flattened]Variables and corresponding filters

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024 1

I'm adding allVariables and introducing few filters as I liked that suggestion from @vknabel 🥇

I've also removed documentation for staticVariables, computedVariables, instanceVariables but they will still work until 1.0, we should be moving to filters

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

cc @FilipZawada @vknabel @bejar37 @AliSoftware @kzaher

from sourcery.

ilyapuchka avatar ilyapuchka commented on May 22, 2024

Absolutely. But not sure what do you mean by "choose between inherited or direct variables"?

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

@ilyapuchka on both questions? what I meant is that it might be useful to be able to differentiate between variables defined in the class vs supertype

from sourcery.

ilyapuchka avatar ilyapuchka commented on May 22, 2024

Regarding annotation, I don't think we should propagate them, anyway it's easy to add annotations.
Regarding distinguishing inherited properties from own properties, how that can be used?
Another question to add to the list - should we combine annotations when overriding property or method or just override them? (I would say we should override)

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

override makes sense to me, I'll skip differentiation between inherited vs own for now since we don't have use-case

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

@ilyapuchka shouldn't we do the same with methods then? I think the way you implemented it now it won't inherit from supertype?

from sourcery.

ilyapuchka avatar ilyapuchka commented on May 22, 2024

Sure. Currently it only adds methods from extensions, the same as variables.

from sourcery.

vknabel avatar vknabel commented on May 22, 2024

I think flattening all variables by default could lead to duplicate code generation, but a flattened context could still be very useful

from sourcery.

AliSoftware avatar AliSoftware commented on May 22, 2024

I think we shouldn't flatten the variables by default but offer a special variable (like super or similar) which exposes the flatten representation.

So Foo.variables wouldn't contain typeName but Foo.super.variables would (or maybe inherited instead of super, or ^ ? I'm open to alternatives)

from sourcery.

ilyapuchka avatar ilyapuchka commented on May 22, 2024

Accessing super class variables through supertype is fine, but what about i.e. computed variables (plus static) or methods defined in protocol extensions?
Having variables and allVariables (the same pattern applied to methods) looks like the best option.

from sourcery.

AliSoftware avatar AliSoftware commented on May 22, 2024

@krzysztofzablocki I prefer all.variables / flatten.variables rather than allVariables / flattenVariables, feels more flexible and generic to me, and a little similar to your implementing.Foo / inherit.Foo / … other patterns imho

from sourcery.

AliSoftware avatar AliSoftware commented on May 22, 2024

@krzysztofzablocki so basically we have the same idea (keeping variables unchanged and adding a separate entry for flatten Variables) except that I would give that new entry a name with dot, while you propose a camelcase one

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

Doesn't type.all.variables sound a little weird?

from sourcery.

AliSoftware avatar AliSoftware commented on May 22, 2024

Hence me being open to alternate names. Like type.inherited.variables maybe?

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

I think it only make sense to have distinction between local and all variables, thus type.inherited.variables would be confusing.

if we don't want to use allVariables then how about doing something like this:

type.variables.local <- local variables to this type
type.variables.local.instance <- local instance variables
type.variables.all <- local + inherited / implementing
type.variables.all.instance <- all instance variables
etc.

Happy to replace [all, local] with better naming suggestion

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

@vknabel @AliSoftware @FilipZawada @ilyapuchka ^ thoughts? I've implemented this already so I just need us to decide on naming

from sourcery.

AliSoftware avatar AliSoftware commented on May 22, 2024

That means that type.variables won't be valid anymore (I mean, as a value that would be rendered by Stencil directly). It won't be an array on which we could {% for v in type.variables %} directly then? Wondering if that wouldn't be confusing? (But not sure I like any solution anyway)

from sourcery.

vknabel avatar vknabel commented on May 22, 2024

@AliSoftware's point about compatibility is quite strong and I think all.variables reads quite well.

Alternatively: does it make sense (if possible) to use Stencil filters for this? Like {% for v in type.variables | local %}. On the downside it requires all (or flattened) to be the default and it requires variables to contain their origin (inherited vs local).

from sourcery.

ilyapuchka avatar ilyapuchka commented on May 22, 2024

With filters, how do we get the number of static/computed/other variables if we remove dedicated collections for variables?

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

Good question, I think Stencil doesn't support () so .count won't work but once we have set node from @AliSoftware we can set variable to filtered array.

{% if type.allVariables|instance %} should work as well as it will run if statement around empty array?

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

@ilyapuchka I added count filter that will turn array into its count and since we can chain filters that will work

from sourcery.

ilyapuchka avatar ilyapuchka commented on May 22, 2024

Cool, looks pretty elegant solution! Will look closer at your pr later today

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.