Comments (4)
depth for reflection
What would that mean?
from reflectable.dart.
Basically delimit the generated reflections.
An example would be generating A
(I want its attributes) and B
(as it is the type of the secondAttr
attribute). But ignore C
, as I won't be using B
attributes.
class A {
final int firstAttr;
final B secondAttr;
}
class B {
final C anyAttr;
}
class C {
...
}
In my use case I have control over the classes involved, but not over all types of attributes present in them.
This lack of predictability prevents me from controlling reflections through GlobalQuantifyCapability
.
I can't replicate what you did here
from reflectable.dart.
Presumably you can't edit the target classes, and that's the reason why you are using GlobalQuantifyCapability
?
In any case, the whole capability system has been introduced exactly in order to support a somewhat detailed kind of control over the extent to which there is support for reflection with various program entities. So there are lots of things you can do.
First, a regular expression can list alternatives, so there's nothing that prevents using a regular expression like ^my_library.(A|B)$
which will match class A
and class B
from a library that has the library directive library my_library;
. This will instruct the reflectable code generator to support reflection for instances of A
and B
, but not C
.
You may have some difficulties making that regexp precise enough if the given libraries don't have a library
directive, because then you can't specify the libraries (and then an \.A$
would match any class named A
, in any library).
Next, if you want to support reflection for a class like B
implicitly because A
contains a member whose signature mentions B
then you'd use typeAnnotationQuantifyCapability
in your reflector, or TypeAnnotationQuantifyCapability(transitive: true)
. The latter as quite aggressive, because you can easily get to a large number of classes if you use the transitive closure of classes that are reachable in this sense.
I noticed that Flutter uses a few library
directives, but in some cases (like widget.dart
) the library itself doesn't contain all the declarations that it provides, it just has a lot of export
directives from some other libraries, and this means that you can't use ^widgets.SomeWidget$
to select it. But SomeWidget$
should still select the desired class, and if you don't include too many other classes with the same name then it should be OK.
from reflectable.dart.
I'll close this issue, I don't see any descriptions that contradict the assumption that it is working as intended.
from reflectable.dart.
Related Issues (20)
- Fails when upgrading
- 【macos】Attempt to `invoke` without class mirrors. HOT 1
- [Question] is it possible build an "Angular Style DI" library using Reflectable? HOT 1
- [question] - Is it possible to have Annotations with Parameters? HOT 2
- [Question] - how to get Constructor arguments? HOT 2
- [Bug?] ERROR: This requires the 'constructor-tearoffs' language feature to be enabled. HOT 12
- [Question] - Listening to Method invocation HOT 6
- [Question] - Stats on Bundle Sizes and Performance Implications/metrics of using Reflectable ? HOT 1
- Cannot reflect ```flutter/material.dart``` URIs for ```Container``` type HOT 12
- This reflector does not match anything HOT 11
- Reflectable is not a know builder HOT 1
- Unsupported operation: location HOT 4
- Reflectable don't find "main" but im using in my library not an application HOT 5
- How to generate code according to filter rules HOT 2
- The build_runner those not generate anything HOT 1
- Annotated parameter and Functions
- Include annotated types that are not imported to `main.dart` HOT 2
- Severe error during build with @reflector and @JsonKey on the same class. HOT 1
- isSubtype exception for classes without parents HOT 2
- Where is initializeReflectable method? HOT 3
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 reflectable.dart.