-
Notifications
You must be signed in to change notification settings - Fork 322
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 support for new self-describing/parameterised refactors #4159
Conversation
d92fea6
to
a7a4d9f
Compare
This is fantastic! I'm very excited to see this happening. When you get to where you need server changes, I'm happy for either you or I to make them, whichever of us has more time. |
@bwilkerson just going through some of the things above:
It seems VS Code doesn't have any "generic" file dialog, it has to explicitly be an Open or Save one (which are delegated to the OS by default, although users can also opt-in to a simpler text-based entry in a command-palette based picker). If it's possible we might ever want the user to select a file for reading from (an "open file dialog") perhaps we should use
This text is shown on the button in the bottom right here: Should we add some field (
Does this seem like the right choice? (I can mark it as
Similar to (3), we could add an additional field to the parameter (we could also make a simplified version, or even read the extension from |
a7a4d9f
to
cec279d
Compare
I have more thoughts than answers, but hopefully some of this will be helpful.
It seems unlikely that we'll ever need to open a file for reading, but given the low cost of guarding against it, I agree we should use 'saveFilePath' (and potentially 'openFilePath' in the future).
I can definitely see the possibility of wanting a different label on the button for other refactorings, so it seems reasonable to want to pass the label to the client. We have a 'label' field that appears to not be used in this case, but I don't know that other clients might not want it to label something. For example, I suspect that IntelliJ would implement this kind of a parameter as a text field with a button beside it that would open the system dialog and put the selected file's path in the text field. I had imagined the 'label' to be a label for the text field. It's hard to know, though what other clients might want or whether there will even be other clients. If we add 'actionText' or 'actionLabel', we should consider changing 'label' to be more specific, such as 'parameterLabel'. Not sure it's necessary, but worth considering.
I think I was assuming that we'd pass back an empty string, but allowing
We wouldn't be able to extract it from the I'm not sure whether we'll ever want to filter for other extensions (though I suppose I could imagine refactorings around analysis options files). Again, the guiding principle I'd apply is that if it isn't too high a cost to do so it would be better to keep it possible. We do want to also consider the future cost of adding support in new clients. I don't know whether passing the data over is a hinderance or a help from that perspective, so I don't know how to weight that factor. |
SGTM!
I was actually using it here for "title", though the comment on that says (which is why it doesn't show up here):
I guess using it as title probably wasn't right here then. I think your suggestion makes sense, though maybe we should also have a title? For ex.:
Ah, empty string would work. Although I did mean to ask about using strings for all the values - would it be better if we typed them based on the
For something like this (and On that note - how would you feel about making |
Probably so, yes. In which case
I find that to be convincing. Let's add it.
I'm good with being more compatible with the existing spec, both in terms of possibly getting this adopted at some future date as well as from the perspective of making it easier for more clients to support it. |
cec279d
to
79959e7
Compare
245382d
to
d1c36b7
Compare
@bwilkerson currently we have a bool experimental: {
commandParameterSupport: {
supportedKinds: ["saveUri"]
}
} This will allow the server to react to different versions of the client. For example if we shipped Dart-Code supporting only Inside refactors, checks would then be based on the bool isAvailable() => supportsFileCreation && _memberToMove != null &&
// This refactor has a string parameter with no default, so it can only be produced if the
// client is able to prompt for a string.
clientSupportsPromptingForKind("string"); |
Yes. I like that idea. I think it improves the compatibility story and is very much in keeping with the spirit of LSP. |
dc92329
to
6b61f94
Compare
Server still uses this flag, but we shouldn't need to gate this on it (otherwise we need to change the default for the flag in two places).
First one is handled because the rewrite is essentially a no-op if there aren't parameters that need completing. Second one was incomplete but likely related to handling unknown types, but this is now handled with "supportedKinds".
6b61f94
to
7b5c204
Compare
@bwilkerson there are only two unticked items above:
So my feeling is we should merge this (and ensure any future server changes are compatible with this). WDYT? The server still has a flag ( |
A couple of questions to double check my understanding. Is the flag I think the worst case scenario would be where we decided we needed to make an incompatible change to the protocol. In that case we'd need to put something in place so that the server never produced the new command structure when the client only supported the old command structure. Is that the extent of what we'd need to do? If so, I'm guessing that the standard way that happens in LSP is through the client and server capabilities. Is there anything we might want to do to the protocol (before merging these changes) to make it easier to make changes in the future? |
(turns out the flag is called
It comes from the client, but it's not coded specifically in Dart-Code. That is, you can open your VS Code settings and add
We can certainly use this flag (or another flag, or a flag per refactor) for testing like this. We can invent any settings we want in the server (by just adding them to the client config class like this) that we can then add to our own VS Code user settings without needing to involve the VS Code extension.
Yep, I would suggest we extend the We can use server capabilities if we need to inform the client what we support too, although in most cases I suspect we wouldn't need to. For example we could assume clients sending I can't think of anything we'd need to do that we couldn't do in a backwards-compatible way - I think between some of the changes above and using objects for the capabilities likely gives us all the flexibility we'll need. |
Then merging this PR sounds good to me. |
I've published a new pre-release version of the Dart extension, although it seems to be taking a while to be approved. Once it's up (the version will be 3.51.20221010 - the latter part being YYYYMMDD) if you install it (see image below for how to switch to pre-release if you haven't already) if you add Let me know if you spot any issues (and if/when you have an opinion whether we should remove move-top-level-to-file from under that flag). |
Some initial support for new server refactors:
Sep-15-2022.17-48-40.mp4
Some things outstanding:
filePath
s (may we want open? is there a more general API in VS Code we can use?)Parameter.defaultValue
is currentlyString
but since the experimental capability is intended to control refactors that have parameters without default values, it seems like this should likely beString?
?filePath
is currently implemented{ "Dart Files": ["dart"] }
, does this need to come from the server?kind
s (ultimately we won't be adding integration tests here for every refactor, but we need coverage of every parameterkind
)@bwilkerson FYI.. once I've resolved the items above I'll likely merge this (it's behind the same
dart.experimentalNewRefactors
flag server is using) to make it easier to work on the server side (at least while no additional client changes are required). Some of the things above may require related server changes though.I'm treating this experimental flag as for development only, so don't plan to worry about compatibility until we're ready to remove that.