Skip to content
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

Resolve initial rename value #37691

Merged
merged 6 commits into from
Jan 26, 2018
Merged

Resolve initial rename value #37691

merged 6 commits into from
Jan 26, 2018

Conversation

Krzysztof-Cieslak
Copy link
Contributor

PR implements the functionality discussed in #7340. It's just a proposal, I've done it mostly to learn a bit about architecture around extensions API, so feel free to close it if it's not going in good direction.

CC: @aeschli & @jrieken

@jrieken
Copy link
Member

jrieken commented Nov 9, 2017

Looks pretty good after a quick read... I have to check with my schedule but we make this happen in November...

@jrieken jrieken added api editor-contrib Editor collection of extras feature-request Request for new features or functionality labels Nov 9, 2017
@jrieken jrieken added this to the November 2017 milestone Nov 9, 2017
@alexdima alexdima modified the milestones: February 2018, December 2017 Dec 12, 2017
Copy link
Member

@jrieken jrieken left a comment

Choose a reason for hiding this comment

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

This is quite good already... API needs always a few extra rounds and iterations of thinking and discussion (because never ever want to break it) but I am positive about this.

@@ -79,6 +79,33 @@ export function rename(model: IReadOnlyModel, position: Position, newName: strin
});
}

function resolveInitialRenameValue(model: IReadOnlyModel, position: Position): TPromise<RenameInitialValue> {
const supports = RenameProviderRegistry.ordered(model);
Copy link
Member

Choose a reason for hiding this comment

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

We should just go for the first rename provider so that we always use the same for resolving the location and for the actual rename.


let initialValue = await resolveInitialRenameValue(this.editor.getModel(), this.editor.getPosition());

if(initialValue) {
Copy link
Member

Choose a reason for hiding this comment

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

We can maybe move this to a 'default' implementation of resolveRenameValue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not really sure, the code below is just setting values local to the run function. It's only small extension of the logic that was already there before.

@@ -2482,6 +2482,11 @@ declare module 'vscode' {
appendVariable(name: string, defaultValue: string | ((snippet: SnippetString) => any)): SnippetString;
}

export interface RenameInitialValue {
Copy link
Member

Choose a reason for hiding this comment

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

Needs maybe some better naming here but idea is good

Copy link
Member

Choose a reason for hiding this comment

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

I am actually wondering when we would return both, so range and text (which then would be different from the text in range?). Do you have a use-case in mind?

@@ -594,6 +594,7 @@ export interface ExtHostLanguageFeaturesShape {
$resolveWorkspaceSymbol(handle: number, symbol: modes.SymbolInformation): TPromise<IWorkspaceSymbol>;
$releaseWorkspaceSymbols(handle: number, id: number): void;
$provideRenameEdits(handle: number, resource: URI, position: IPosition, newName: string): TPromise<modes.WorkspaceEdit>;
$resolveInitialRenameValue(handle: number, resource: URI, position: IPosition): TPromise<modes.RenameInitialValue>;
Copy link
Member

Choose a reason for hiding this comment

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

We removed some automagic marshalling and UriComponent must be used now

@jrieken
Copy link
Member

jrieken commented Jan 9, 2018

@Krzysztof-Cieslak Are you still with us on this one? We have scheduled this for January.

@Krzysztof-Cieslak
Copy link
Contributor Author

@jrieken, yes, I’ve been on vacations after Xmas. Give me day or two and I’ll get back to it.

@Krzysztof-Cieslak
Copy link
Contributor Author

@jrieken I've rebased PR to latest master and moved to using the first provider for resolving. I'm not sure if I agree/understand second suggestion.

Also, happy to hear any suggestions for the naming :)

@Krzysztof-Cieslak Krzysztof-Cieslak changed the title [Proposal] Resolve initial rename value Resolve initial rename value Jan 16, 2018
return this._createDisposable(handle);
}

$provideRenameEdits(handle: number, resource: UriComponents, position: IPosition, newName: string): TPromise<modes.WorkspaceEdit> {
return this._withAdapter(handle, RenameAdapter, adapter => adapter.provideRenameEdits(URI.revive(resource), position, newName));
}

$resolveInitialRenameValue(handle: number, resource: URI, position: IPosition): TPromise<modes.RenameInitialValue> {
Copy link
Member

Choose a reason for hiding this comment

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

The URI argument won't be of that type at runtime. That's because the function will be called by our JSON-rpc internals and the runtime type will be UriComponents (from which you then create an URI using revive).

@@ -2482,6 +2482,11 @@ declare module 'vscode' {
appendVariable(name: string, defaultValue: string | ((snippet: SnippetString) => any)): SnippetString;
}

export interface RenameInitialValue {
Copy link
Member

Choose a reason for hiding this comment

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

I am actually wondering when we would return both, so range and text (which then would be different from the text in range?). Do you have a use-case in mind?

@@ -2567,6 +2572,8 @@ declare module 'vscode' {
* signaled by returning `undefined` or `null`.
*/
provideRenameEdits(document: TextDocument, position: Position, newName: string, token: CancellationToken): ProviderResult<WorkspaceEdit>;

resolveInitialRenameValue?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<RenameInitialValue>;
Copy link
Member

@jrieken jrieken Jan 18, 2018

Choose a reason for hiding this comment

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

Maybe RenameInformation? That would make it:

resolveRenameInformation?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<RenameInformation>;

provideRenameInformation?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<RenameInformation>;

Copy link
Member

Choose a reason for hiding this comment

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

Or something more clever sounding, like RenameForesight, RenamePreflight, etc...

@jrieken
Copy link
Member

jrieken commented Jan 26, 2018

Pulling this in but marking the new API as proposed which buys as some time to polish names etc. @Krzysztof-Cieslak Thanks for good work.

@jrieken jrieken merged commit 86b8fb2 into microsoft:master Jan 26, 2018
@Krzysztof-Cieslak
Copy link
Contributor Author

@jrieken, thanks for merging!

@Krzysztof-Cieslak Krzysztof-Cieslak deleted the resolveInitialRenameValue branch January 27, 2018 19:41
@jrieken jrieken removed the feature-request Request for new features or functionality label Jan 29, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api editor-contrib Editor collection of extras
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants