这是indexloc提供的服务,不要输入任何密码
Skip to content

Fix bug when resolving entrypoint against package config #81248

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

Merged
merged 4 commits into from
Apr 27, 2021

Conversation

blasten
Copy link

@blasten blasten commented Apr 26, 2021

It should use the target's absolute path URI as opposed to the relative one.
The relative path produces null in all cases.

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Apr 26, 2021
@google-cla google-cla bot added the cla: yes label Apr 26, 2021
@blasten blasten requested a review from jonahwilliams April 26, 2021 23:36
@@ -45,9 +45,9 @@ class DartPluginRegistrantTarget extends Target {
final String targetFile = environment.defines[kTargetFile] ??
environment.fileSystem.path.join('lib', 'main.dart');
final File mainFile = environment.fileSystem.file(targetFile);
final Uri mainFileUri = mainFile.uri;
assert(packagesFile.path != null);
final Uri mainFileUri = mainFile.absolute.uri;
final String mainUri = packageConfig.toPackageUri(mainFileUri)?.toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the main file URI is not in any package?

Copy link
Contributor

Choose a reason for hiding this comment

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

i.e. flutter run --target some/absolute/path/test/test_foo.dart

Copy link
Author

Choose a reason for hiding this comment

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

What would be an example?

Copy link
Author

Choose a reason for hiding this comment

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

Do we validate the target earlier?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thats not an invalid target though - you'd need to fallback to embedding an absolute URI

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not quite sure what you mean - if the package config fails to resolve the absolute file URI to a package URI, it only means that the file was not under any of the defined package roots. Its still an otherwise valid target file

Copy link
Author

Choose a reason for hiding this comment

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

ah I see what you mean, import 'package:<package-name>/some/absolute/path/test/test_foo.dart in this case, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

For example:

import 'file:///C:/Users/Jonah/flutter/packages/flutter_tools/bin/flutter_tools.dart';

Copy link
Contributor

Choose a reason for hiding this comment

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

This is totally valid (well, on my computer at least)

Copy link
Author

Choose a reason for hiding this comment

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

👍 I cleaned up the test file a bit, and added the new test. PTAL

Emmanuel Garcia and others added 2 commits April 26, 2021 16:40
…/dart_plugin_registrant_test.dart

Co-authored-by: Jonah Williams <jonahwilliams@google.com>
@blasten blasten requested a review from jonahwilliams April 27, 2021 02:07
Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@fluttergithubbot fluttergithubbot merged commit 91d6c97 into flutter:master Apr 27, 2021
@blasten blasten deleted the recompile_fix branch April 28, 2021 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants