Coder Social home page Coder Social logo

Comments (4)

eernstg avatar eernstg commented on July 20, 2024

depth for reflection

What would that mean?

from reflectable.dart.

viniciusandd avatar viniciusandd commented on July 20, 2024

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.

eernstg avatar eernstg commented on July 20, 2024

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.

eernstg avatar eernstg commented on July 20, 2024

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)

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.