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

Dart: do not generate redundant import for external constants #1640

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

Conversation

pwrobeldev
Copy link
Contributor

@pwrobeldev pwrobeldev commented Dec 18, 2024

----- Motivation -----
The generator added redundant import when external type
was used to specify constants. This resulted in linter error
unused_import.

----- Content of the change -----
This change adjusts 'DartImportResolver' to import
only necessary file, when a type, which uses external
one is specified for constants.

First two commits shows the invalid behavior in smoke
and functional tests. The latter is used to ensure, that
the code builds when the redundant import is removed.

The third commit contains the actual fix (one-line).

This change introduces usage of constants that use
a type, which is external.

As we can see an unneeded import is present in
'external_dart_constants.dart' file:

`package:library/src/smoke/rectangle_int_.dart` is not
used, but it is imported.

Signed-off-by: Patryk Wrobel <[email protected]>
The same file is generated in functional tests.
It build. This will be used as a checkpoint to
confirm that the code builds, when the redundant
import is removed.

Signed-off-by: Patryk Wrobel <[email protected]>
This change adjusts 'DartImportResolver' to import
only neccessary file, when a type, which uses external
one is specified for constants.

Signed-off-by: Patryk Wrobel <[email protected]>
Signed-off-by: Patryk Wrobel <[email protected]>
@pwrobeldev pwrobeldev marked this pull request as ready for review December 18, 2024 13:38
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.

1 participant