uber / needle

Compile-time safe Swift dependency injection framework
Apache License 2.0
1.84k stars 144 forks source link

Internal properties of Components should be ignored #458

Closed rudro closed 1 year ago

rudro commented 1 year ago

Most properties of needle components classes are public when they are consumed by descendants. Some properties are fileprivate when only some other class in the same file is the only use of the property. (At Uber we put the builder class and the component class in the same file, so sometimes when a dependency is only used by the corresponding builder we use this).

The needle generated code in the vast majority of cases lives in a separate module (or maybe the main app target). In a rare case, where the whole app is in a single library maybe the needle generated code lives in the same module.

So in all the cases where needle gen code live sin a different package, we can't see the internal properties, so needle should just ignore them in it's parsing.

The reason this was not done until now is that the same AST parser is used to scan component classes as well as the dependency protocols. For the protocols, we typically mark them public so then the vars in them "look internal" as far as the AST is concerned, but they need to be considered by needle.