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

Emit imports in sorted order #778

Merged
merged 3 commits into from Nov 30, 2022
Merged

Conversation

devoncarew
Copy link
Collaborator

Part of #771 - ensure that the imports in the generated code are in lexical order.

  • introduce an ImportWriter class
  • use that when generating code
  • have ImportWriter use regular dart import conventions (dart: first, package: second, path imports third, and lexically ordered within the groups)

Done as separate commits for easier review.

@devoncarew
Copy link
Collaborator Author

devoncarew commented Nov 28, 2022

FWIW, I mostly saw this affecting the files in out/.

/// A utility class to generate a set of imports. The imports will be grouped
/// by kind (`dart:` imports, `package:` imports, ...) and sorted lexically
/// within the groups.
class ImportWriter {
Copy link
Collaborator

Choose a reason for hiding this comment

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

pkg:code_builder "just does this". Hrm...

@devoncarew devoncarew merged commit 4f3e328 into google:master Nov 30, 2022
osa1 added a commit that referenced this pull request May 30, 2023
- Bring unnecessary_import back. (was removed with #778)

- Generate unused_import in grpc files as well.

- Don't generate return_of_invalid_type: this lint seems to be removed.

(The first two issues were found in cl/535141580)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants