-
Notifications
You must be signed in to change notification settings - Fork 11
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 --built-in-only flag to module migrator #259
Conversation
Also fixes some built-in functions that weren't being migrated.
lib/src/migrators/module.dart
Outdated
_upstreamStylesheets.add(currentUrl); | ||
if (migrateDependencies) visitDependency(ruleUrl, import.span); | ||
_upstreamStylesheets.remove(currentUrl); | ||
return; |
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.
Why return eagerly here? What if there are multiple imports in a single @import
that all need to be traversed?
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.
Good catch. Fixed
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.
There are a lot of special cases for builtInOnly
in the module migrator. It could probably use a few more tests to exercise more of 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.
Done
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.
Consider naming the flag --built-in-only
, since "built-in" is usually spelled with a hyphen.
lib/src/migrators/module.dart
Outdated
@@ -613,7 +630,7 @@ class _ModuleMigrationVisitor extends MigrationVisitor { | |||
}); | |||
} | |||
|
|||
if (node.name == "get-function") { | |||
if (node.name == "get-function" && !builtInOnly) { |
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 about get-function()
calls for functions from built-in modules?
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.
Fixed
lib/src/migrators/module.dart
Outdated
_upstreamStylesheets.add(currentUrl); | ||
if (migrateDependencies) visitDependency(ruleUrl, import.span); | ||
_upstreamStylesheets.remove(currentUrl); |
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.
Since modifying _upstreamStylesheets
doesn't do anything when migrateDependencies
is false anyway, this makes it clearer when those lines are relevant:
_upstreamStylesheets.add(currentUrl); | |
if (migrateDependencies) visitDependency(ruleUrl, import.span); | |
_upstreamStylesheets.remove(currentUrl); | |
if (migrateDependencies) { | |
_upstreamStylesheets.add(currentUrl); | |
visitDependency(ruleUrl, import.span); | |
_upstreamStylesheets.remove(currentUrl); | |
} |
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.
Done
Also fixes some built-in functions that weren't being migrated.