-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
New error message for depend_on_referenced_packages
quick-fix
#55985
Comments
Those are good point. It does seem like server ought to minimally be able to tell whether the Whether it's worth looking in the |
It's possible this fix is coming from Dart-Code and not the server. Although we do call The implementation is pretty basic so it's no surprise if there are edge cases. Perhaps moving it to server and fixing this issue together would make sense (because server has much better understanding of the projects than Dart-Code does). |
Yes, in general we should have as much support as possible in the server. |
Should I open a new issue for us to reference this work? I was thinking of taking a look at these but with this on the way I figured it should be done first.
Also, to note. I've found in |
The current fix provided by Dart-Code doesn't actually modify the pubspec, it runs So to provide the same functionality in the server, we'd need a fix/assist that triggers a command (I'm not sure if we currently support commands except for on refactors, which go through a generic command.. this would need to be a fix that can provide its own command), and then a custom command that can invoke If we implement this here, we could update Dart-Code to only add its own actions if the new command is not registered by the server (so we don't show duplicates). The legacy protocol doesn't support fixes/assists that call back to the server, so I think there are two options:
Alternatively, we could add support to fixes/assists for commands, but then we'd need to ensure they didn't show up in the list for the legacy protocol because they wouldn't contain any source changes and instead have a command that can't be represented. |
I think we could probably use this one to cover fixing this message by moving it to the server and updating it there? |
@DanTup already suggested this on Discord, but as I was about to say the same thing I'll add it here for the record. It isn't clear to me that we want to execute Do we have other features (in either the server or in the plugin) that automatically run As for the technical aspects ...
We currently can't trigger commands in IntelliJ (and maybe some LSP clients), so we need to decide whether we're ok having different behaviors on different clients (assuming we want to pursue executing a command).
Both of these have the disadvantage that they'd only make the functionality available in a subset of clients. I don't want to support functionality on a single client if we can find a way to make it available more generally, but the first of these options is better than the second because there's at least a path forward for other clients, even if it's non-trivial.
We currently send a command (as well as an edit) with every quick fix whose only purpose is to allow us to gather analytics data (when we're authorized to do so). We could presumably add additional behavior for some fixes if we want to, but I don't think we can guarantee that the pubspec file has been saved before executing |
In Dart-Code, we run
Correct (or at least, not with custom code in the client that could do this). Another possibility (though I haven't completely thought it through) is we just make a normal fix that edits the pubspec, but in Dart-Code we detect when this is executed, and if the pubspec was not dirty before, then we auto-save it after the fixes edits are applied. That would retain the current behaviour in Dart-Code (and be possible to implement in other clients with a little code), but gives us the safety of not modifying files on disk that the user has open changes for. |
Here is a new issue that came up regarding this being currently handled by Dart-Code Dart-Code/Dart-Code#5378. The current method will stop working (for directories inside package) and it'll need to be handled in the future.
|
@FMorschel thanks - that issue was a bad regex that extracted the package name from the import string. I've pushed a fix for that (although based on the above, if/when this moves to server, we will probably stop calling |
I have a use case for a change in
depend_on_referenced_packages
quick-fix error message.In my company we create some local packages. They sometimes depend on each other.
Just now I was editing a package, let's call it
a
, that has a dependency in a second packageb
which ultimately depends onc
.When I wrote down some code that needed package
c
and then added the import line, I got a this lint:The imported package 'c' isn't a dependency of the importing package.
But when trying to use the assist I got an error.
But (I believe) the analysis server knows that my
b
package depends on ac
package from path.I dont't think the analyzer should be able to figure out the path from both packages to solve where
c
is at in my machine, but shouldn't it at least show me that the dependency is not from pub.dev?I have not tested but it got me guessing about dependencies that rely on GitHub repository links or similar. What then? If I need something that is not in release yet I'll need to manually change there anyway so the quick-fix would not be actually helping but IMO it would be generating doubts.
The text was updated successfully, but these errors were encountered: