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

Remove some analyzer ast and src imports #384

Merged
merged 2 commits into from
Oct 22, 2018
Merged

Conversation

natebosch
Copy link
Member

  • Use LibraryElement.exportNamespace to find types across a libraries
    entire visible surface area rather than referencing a
    NamespaceBuilder.
  • Use the different getters for element typs from
    CompilationUnitElement to get all members of a library rather than
    getting the declarations from a CompilationUnit.
  • Increase minimum anlayzer version to ensure that the mixins getter
    is available.

- Use `LibraryElement.exportNamespace` to find types across a libraries
entire visible surface area rather than referencing a
`NamespaceBuilder`.
- Use the different getters for element typs from
`CompilationUnitElement` to get all members of a library rather than
getting the declarations from a `CompilationUnit`.
- Increase minimum anlayzer version to ensure that the `mixins` getter
is available.
for (var compUnitMember in cu.unit.declarations) {
yield* _getElements(compUnitMember);
}
yield* cu.accessors;
Copy link
Member

Choose a reason for hiding this comment

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

It'd be GREAT if analyzer had an API for this ( CC @scheglov @bwilkerson ) – could we get a TODO in here w/ a feature request?

These are places where things fall apart for weird reasons if things are reclassified, etc...

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -1,12 +1,12 @@
name: source_gen
version: 0.9.1+3
version: 0.9.2-dev
author: Dart Team <[email protected]>
description: Automated source code generation for Dart.
homepage: https://github.com/dart-lang/source_gen
environment:
sdk: '>=2.0.0-dev.64.0 <3.0.0'
Copy link
Member

Choose a reason for hiding this comment

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

Might as well drop 2.0.0-dev version support while you're at it...

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

import 'package:analyzer/dart/element/element.dart';
// ignore: implementation_imports
import 'package:analyzer/src/dart/resolver/scope.dart';
Copy link
Member

Choose a reason for hiding this comment

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

Nice to get rid of src imports!

ClassElement findType(String name) {
var type = element.exportNamespace.get(name);
return type is ClassElement ? type : null;
}

/// All of the declarations in this library.
Iterable<Element> get allElements sync* {
for (var cu in element.units) {
Copy link
Contributor

Choose a reason for hiding this comment

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

So units is fine but unit isn't?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, one gives CompilationUnitElement and the other CompilationUnit.

@bwilkerson
Copy link
Member

bwilkerson commented Oct 22, 2018 via email

@natebosch natebosch merged commit c080f35 into master Oct 22, 2018
@natebosch natebosch deleted the ast-imports-library branch October 22, 2018 19:47
mosuem pushed a commit to dart-lang/build that referenced this pull request Dec 10, 2024
- Use `LibraryElement.exportNamespace` to find types across a libraries
entire visible surface area rather than referencing a
`NamespaceBuilder`.
- Use the different getters for element types from
`CompilationUnitElement` to get all members of a library rather than
getting the declarations from a `CompilationUnit`.
- Increase minimum analyzer version to ensure that the `mixins` getter
is available.
mosuem pushed a commit to dart-lang/build that referenced this pull request Dec 10, 2024
- Use `LibraryElement.exportNamespace` to find types across a libraries
entire visible surface area rather than referencing a
`NamespaceBuilder`.
- Use the different getters for element types from
`CompilationUnitElement` to get all members of a library rather than
getting the declarations from a `CompilationUnit`.
- Increase minimum analyzer version to ensure that the `mixins` getter
is available.
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.

6 participants