Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Register custom @propertyWrapper as Attribute #920

Open
m1entus opened this issue Mar 13, 2021 · 2 comments
Open

[Question] Register custom @propertyWrapper as Attribute #920

m1entus opened this issue Mar 13, 2021 · 2 comments

Comments

@m1entus
Copy link

m1entus commented Mar 13, 2021

First of all big up for Sourcery @krzysztofzablocki!

  1. I am wondering if it is possible to register custom @propertyWrapper as Attribute.Identifier type and find them in stencil files ?
  2. Trying to get {% for var in type.variables %} {{ var.type.inherits.UIView }} and check if veriable inherits from UIView, seems type is always nil no matter what, but typeName give me UILabel/UIView is there a reason for that type is nil for variables ?
@krzysztofzablocki
Copy link
Owner

krzysztofzablocki commented Mar 13, 2021

@m1entus
regarding 2. UIView is unknown type so you'd have to use type.based.UIView, you should be getting type property if the types are known to Sourcery (defined in the source it scans), let me know if that's not the case

as for 1 I think you'll get attribute named propertyWrapper and could look into it's arguments to find whatever you are looking for

@m1entus
Copy link
Author

m1entus commented Mar 13, 2021

Thanks for quick reply!

For the 1 i have defined, where @AccessibilityIdentify is propertyWrapper type and seems there are no results, IBOutlers etc. are working fine but for my custom one i am not getting anything:
@AccessibilityIdentify(identifier: "custom_id") var testView = UIView(frame: .zero)

Regardin 2. i have done some workaround and extended UIView with my custom protocol UIViewAccessibilityIdentificable for custom types and checking if hasPrefix UI and seems this is satisfying me for now.
{% if var.type.based.UIViewAccessibilityIdentificable or var.typeName|hasPrefix:"UI" %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants