-
Notifications
You must be signed in to change notification settings - Fork 111
Add APIs to expose analyzer elements2 models. #735
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 APIs to expose analyzer elements2 models. #735
Conversation
5fd2bd0
to
41778ae
Compare
); | ||
}); | ||
|
||
test('applies to annotated directives', () async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the story here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Directives in the element model are no longer elements, so we cannot support annotations on them. Or at least the way it used to work. This so far did not cause any breakage in google3, but I have not yet migrated external packages, only a lot of internal generators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The codegen for checks
(not released) will rely on reading metadata from LibraryImportElement
. Internal link: http://google3/third_party/dart/checks_codegen/lib/src/builder.dart;l=32-34;rcl=634834855
Is there an alternative way to read them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked in our chat.
dart_flutter_team_lints: ^3.1.0 | ||
term_glyph: ^1.2.0 | ||
test: ^1.16.0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just published these! we can drop 'em
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are actually needed, they expose a different API to get at the new element models, but its only to help with the internal migration.
export 'src/generator_for_annotation.dart' show GeneratorForAnnotation; | ||
export 'src/library.dart' show AnnotatedElement, LibraryReader; | ||
export 'src/span_for_element.dart' show spanForElement; | ||
export 'src/span_for_element.dart' show spanForElement, spanForElement2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a changelog update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will never be published, we will restore the name with different types.
/// | ||
/// Implementations should return `null` when no content is generated. Empty | ||
/// or whitespace-only [String] instances are also ignored. | ||
dynamic generateForAnnotatedElement2( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, so which version is going to be called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both, but any specific generator will override only one.
So, both migrated and not-yet-migrated generators will work.
Continue #735 Note that it restores applies to annotated directives test, as discussed in the previous PR. This functionality is indeed used, by package:checks generator. The first version uses analyzer dependency override, because I want want you to look at the code before I publish analyzer .
See https://docs.google.com/presentation/d/1Vxr-y5ljuo0Os78R4tKZg8cc0In984EQcLs06HOqS28/edit#slide=id.p for the new element model details. It is possible that you will not able access it, unless you work for Google.