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

Add a note about not importable annotations #576

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

natebosch
Copy link
Member

The build systems run on the Dart VM only, so there are limitations on
what imports can be used by builders. Add documentation describing how
to work around this limitation by overriding the TypeChecker with
something other than fromRuntime.

The build systems run on the Dart VM only, so there are limitations on
what imports can be used by builders. Add documentation describing how
to work around this limitation by overriding the `TypeChecker` with
something other than `fromRuntime`.
Copy link
Contributor

@jakemac53 jakemac53 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just provide a GeneratorForMatchingAnnotation which takes a TypeChecker?

@kevmoo
Copy link
Member

kevmoo commented Dec 3, 2021

Should we just provide a GeneratorForMatchingAnnotation which takes a TypeChecker?

Just as a factory even, would be great. A follow-up is good here.

@natebosch
Copy link
Member Author

Should we just provide a GeneratorForMatchingAnnotation which takes a TypeChecker?

Just as a factory even, would be great. A follow-up is good here.

The existing design imposes an extends already - you are intended to override generateForAnnotatedElement.

It would be nice to change that and allow composition but 🤷‍♂️

Given the current design, I think @override fits. WDYT?

@jakemac53
Copy link
Contributor

Given the current design, I think @override fits. WDYT?

Ya the design I would envision is making a base class that just takes a type checker, and then the existing class would just extend that to make the type checker for you.

I wouldn't change anything about how it works generally, just which class you extend would change (and what you pass to the super constructor)

@natebosch
Copy link
Member Author

which class you extend would change (and what you pass to the super constructor)

Adding another class to the public API would increase the surface area of the package and IMO make things harder to find.

@jakemac53
Copy link
Contributor

Adding another class to the public API would increase the surface area of the package and IMO make things harder to find.

🤷‍♂️ I don't really agree, I think its significantly better than doing the whole GeneratorForAnnotation<void> thing and then overriding the type checker. Overriding the type checker in that way is definitely a bit funky, and you are relying essentially on how that thing is being used internally in the super class...

@natebosch
Copy link
Member Author

I'm not able to find a design I like here with another class (especially because I can't think of a nice name).

With a breaking change I could imagine something different, maybe where we drop the generic and you need a constructor when forwards to super.forType(someType) or super.forTypeChecker(someTypeChecker). If we're going with a breaking change we may as well drop the need for extends entirely though...

@kevmoo
Copy link
Member

kevmoo commented Sep 13, 2022

@natebosch – thoughts on this?

@kevmoo
Copy link
Member

kevmoo commented Apr 5, 2023

Uh...this is old @natebosch

@natebosch
Copy link
Member Author

@jakemac53 - do you think this is worth landing as is?

@@ -39,6 +42,7 @@
represents their type. Previously we checked this pattern only for enums,
however there are enum-like usages in classes which are not enums.
- Allow the latest version of `package:analyzer`.
>>>>>>> master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>>>>>> master

@jakemac53
Copy link
Contributor

I still really don't like the GeneratorForAnnotation<void> suggestion personally. Should we instead just tell people to split up their annotation libraries so they don't have those imports?

@natebosch
Copy link
Member Author

Should we instead just tell people to split up their annotation libraries so they don't have those imports?

I don't know if that is always feasible - some annotations could use dart:ui classes as arguments.

Copy the implementation and test for `GeneratorForAnnotation.`
@natebosch
Copy link
Member Author

@jakemac53 - is this implementation of GeneratorForMatchingAnnotation match what you were thinking?

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

Successfully merging this pull request may close these issues.

3 participants