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

WorkspaceEdit should support creating, deleting, and renaming of files #10659

Closed
dbaeumer opened this issue Aug 18, 2016 · 21 comments · Fixed by #41552
Closed

WorkspaceEdit should support creating, deleting, and renaming of files #10659

dbaeumer opened this issue Aug 18, 2016 · 21 comments · Fixed by #41552
Assignees
Labels
api api-finalization editor-contrib Editor collection of extras feature-request Request for new features or functionality on-testplan workspace-edit
Milestone

Comments

@dbaeumer
Copy link
Member

  • VSCode Version: 1.4

Languages like Java require that renaming the top level class needs to rename the file as well. Currently the rename provider doesn't allow me to do that.

@jrieken
Copy link
Member

jrieken commented Aug 18, 2016

Yeah, maybe it's enough to enrich the WorkspaceEdit to allow renaming of files

@jrieken jrieken added the feature-request Request for new features or functionality label Aug 18, 2016
@dbaeumer
Copy link
Member Author

Agree. May be we should support create, rename and delete of files.

@gorkem
Copy link

gorkem commented Oct 20, 2017

@jrieken @dbaeumer I am looking at providing a patch to LSP and language-server-node for rename with file operations and move but without this API it is really hard to continue that work. Do you have an ETA for this one? Any way to prioritize this? /cc @egamma

@egamma
Copy link
Member

egamma commented Oct 21, 2017

@gorkem I cannot give an ETA, but it is on the backlog and it is on the radar for our next iteration plan.

@gorkem
Copy link

gorkem commented Nov 8, 2017

@egamma @dbaeumer Do you mind, if we propose a change to LSP and implement it for instance on Che as the reference implementation. I guess vscode can eventually catch up but it would provide the language servers implementors to something to work with.

@dbaeumer
Copy link
Member Author

dbaeumer commented Nov 9, 2017

@gorkem no I don't as long as it doesn't beak existing clients. However it would be nice if you could implement this for VS Code :-). It shouldn't be too hard.

@jrieken
Copy link
Member

jrieken commented Jan 11, 2018

Work has started on this, maybe Jan, surely Feb

mjbvz added a commit that referenced this issue Jan 12, 2018
Fixes #10659

Allows workspace edits to also change files in the workspace
jrieken added a commit that referenced this issue Jan 24, 2018
@jrieken
Copy link
Member

jrieken commented Jan 24, 2018

That's the new methods we have added on WorkspaceEdit

		/**
		 * Renames a given resource in the workspace.
		 *
		 * @param from Uri of current resource.
		 * @param to Uri of renamed resource.
		 */
		renameResource(from: Uri, to: Uri): void;

		/**
		 * Create a new resource in the workspace.
		 *
		 * @param uri Uri of resource to create.
		 */
		createResource(uri: Uri): void;

		/**
		 * Delete a given resource in the workspace.
		 *
		 * @param uri Uri of resource to delete.
		 */
		deleteResource(uri: Uri): void;

		/**
		 * Get the resource edits for this workspace edit.
		 *
		 * @returns A shallow copy of uri-tuples in which a rename-edit
		 * is represented as `[from, to]`, a delete-operation as `[from, null]`,
		 * and a create-operation as `[null, to]`;
		 */
		resourceEdits(): [Uri, Uri][];

		/**
		 * Get all edits, textual changes and file changes. The order is the order
		 * in which edits have been added to this workspace edits. Textuals edits
		 * are grouped and the first textual edit for a resource matters.
		 *
		 * @returns A shallow copy of all changes.
		 */
		allEntries(): ([Uri, TextEdit[]] | [Uri, Uri])[];

@jrieken jrieken removed this from the January 2018 milestone Feb 1, 2018
jrieken added a commit that referenced this issue Jun 18, 2018
jrieken added a commit that referenced this issue Jun 18, 2018
jrieken added a commit that referenced this issue Jun 19, 2018
jrieken added a commit that referenced this issue Jun 19, 2018
jrieken added a commit that referenced this issue Jun 19, 2018
@mjbvz
Copy link
Contributor

mjbvz commented Jun 20, 2018

@jrieken I've hooked up TS to use the new API with 7c96862

One small complication: TS doesn't tell us which files need to be created so I believe the code still has to use openTextDocument to check if the file exists first. Not sure if this problem is common enough for us to worry about with our API

@jrieken
Copy link
Member

jrieken commented Jun 20, 2018

TS doesn't tell us which files need to be created so I believe the code still has to use openTextDocument to check if the file exists first

Yeah, I stumbled over that when looking into how TypeScript uses this and I have an item on my todo-list. One option would be to ignore files that already exist. However that might violate your assumption about the file being empty... Alternatively, we could expose more options on the create-call, like { overwrite: boolean } with similar semantic as FileSystemProvider.writeFile...

@jrieken
Copy link
Member

jrieken commented Jun 20, 2018

@mjbvz I have added an ignoreIfExists option which will skip create requests for files that already exists. I have have also added an overwrite option but that will throw when the file already exists.

jrieken added a commit that referenced this issue Jun 20, 2018
jrieken added a commit that referenced this issue Jun 20, 2018
@jrieken jrieken changed the title Rename provider api should support renaming of the file WorkspaceEdit should support creating, deleting, and renaming of files Jun 25, 2018
@jrieken jrieken modified the milestones: June 2018, July 2018 Jun 25, 2018
@jrieken
Copy link
Member

jrieken commented Jun 25, 2018

Moving to Juli for api finalisation

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api api-finalization editor-contrib Editor collection of extras feature-request Request for new features or functionality on-testplan workspace-edit
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants