-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Import auto-complete should not suggest non-dependencies #43678
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
Comments
(An added 👍 if this feature hinted if packages were imported that were not dependencies) |
That sounds reasonable to me. At the very least completion ought to be ranking suggestions for direct dependencies higher than suggestions for implicit dependencies. But I definitely agree that we don't want to encourage the practice of importing from packages that are only implicitly depended on. |
It would be much more pragmatic to have dependencies themselves tell the analyzer which dependencies they want to expose with for example a transitive entry in their pubspec: name: package_a
# private_dependency is excluded from search results by default in all packages that depend on package_a
private_dependency: some_version
# public_dependency is included in search results in packages that depend on package_a
public_dependency: some_version
transitive: true It is difficult to track down which dependencies must be explicitly depended on if a user wants to be able to use any given package without having to unnecessarily make transitive dependencies explicit. The deeper the deepest path in the package dependency graph, the worse this issue becomes. Example:Think of the following package dependency graph (A > B means package B depends on package A) vector_math > geometry > business_logic > ui_base > macos_application
instead, if all packages that the user might need would be marked as transitive and therefore included in autocompletion search results (directives as well as type autocompletion), he'd only need to type XIm... and press enter to get what he needs. TLDR: Excluding transitive dependencies from search results without the ability to opt-out/in per package is the wrong approach. |
@modulovalue Sorry to miss this comment for almost a year. This suggestion has a lot of features and benefits to it, but I think improved auto-completions would be near the smallest of them. If you're interested in doing so, I recommend filing a new issue, likely in this repo, to add this to the pubspec format, which would lead to changes in pub. |
Unfortunately, the package_config.json file today does not indicate which packages are direct dependencies, and which are indirect. We could look at pubspec.yaml to tell, but that seems hacky; could lead to more bugs when pubspec.yaml and package_config.json get out of sync. Perhaps not a big ask to change the package_config.json format to indicate if a package is a direct dependency of "this" package. |
As @DanTup mentioned on another issue, I would like to add another interesting point to this question: In dart 2.17 we had the implementation of code completion and quickfix working for extension functions. But, it does not work for transient packages as I mentioned here #38894 (comment) Maybe, as @modulovalue speced, this implementation could also serve as for the code completion machine to also look for exported-transient packages |
Sorry to bump this (October 2020) issue, but so I understand correctly - Would it be possible to use (If it's the latter, either by decree or effect - i.e. too complicated otherwise, should I file an issue on the language repo to ask for augmenting the |
I think code completion is using @bwilkerson how much do you expect contributors to change with the refactors you're planning? Would changes in this area be better left until afterwards? |
Correct. The Not only does the
As Danny noted, I believe that we are using the Sam's concern, which I think is valid, is that if the user has edited the
No, there's not hard requirement. We just need to consider all of the above when deciding what would make for the best UX. My suggestion is that we should start with the packages known through the
Most of the code in the existing contributors will be rewritten to some extent, but the If this is something that someone wanted to address relatively soon I wouldn't be concerned about wasted effort or merge conflicts. |
In this particular case I only depend on
package:test
, which in turn I guess transitively depends on these?It seems wrong to suggest them at all.
If it would be too breaking to change this behavior might I suggest something in
analysis_options.yaml
?:The text was updated successfully, but these errors were encountered: