Closed cdaguerre closed 3 years ago
Can you give some explanation of why this is needed? Examples of what this enables that doesn't currently work?
@UziTech Sure!
This enables resource operations (basically file and directory operations) as part of workspaceEdit
s, which is currently not implemented at all.
I came across this while working on the rename
functionality for the ide-intelephense package. If this PR makes it, i'll open another one to improve the rename functionality aswell (which to my understanding doesn't work at all right now).
From https://microsoft.github.io/language-server-protocol/specification#workspaceEdit:
Since version 3.13.0 a workspace edit can contain resource operations (create, delete or rename files and folders) as well. If resource operations are present clients need to execute the operations in the order in which they are provided. So a workspace edit for example can consist of the following two changes: (1) create file a.txt and (2) a text document edit which insert text into file a.txt. And:
export interface WorkspaceEdit { /** * Holds changes to existing resources. */ changes?: { [uri: DocumentUri]: TextEdit[]; };
/**
* Depending on the client capability
* `workspace.workspaceEdit.resourceOperations` document changes are either
* an array of `TextDocumentEdit`s to express changes to n different text
* documents where each text document edit addresses a specific version of
* a text document. Or it can contain above `TextDocumentEdit`s mixed with
* create, rename and delete file / folder operations.
*
* Whether a client supports versioned document edits is expressed via
* `workspace.workspaceEdit.documentChanges` client capability.
*
* If a client neither supports `documentChanges` nor
* `workspace.workspaceEdit.resourceOperations` then only plain `TextEdit`s
* using the `changes` property are supported.
*/
documentChanges?: (
TextDocumentEdit[] |
(TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[]
);
/**
* A map of change annotations that can be referenced in
* `AnnotatedTextEdit`s or create, rename and delete file / folder
* operations.
*
* Whether clients honor this property depends on the client capability
* `workspace.changeAnnotationSupport`.
*
* @since 3.16.0
*/
changeAnnotations?: {
[id: string /* ChangeAnnotationIdentifier */]: ChangeAnnotation;
};
}
@aminya looks like linting is failing because of an issue with pnpm. Could you look into that?
@aminya looks like linting is failing because of an issue with pnpm. Could you look into that?
Yes, I will fix that. https://github.com/atom-community/atom-ide-hyperclick/issues/132#issuecomment-818310509
@UziTech I implemented handling of resource operation options and added tests. Rollbacks of applied resource operations in case of error are not handled for now but I think it should ok for a first iteration.
@aminya looks like linting is failing because of an issue with pnpm. Could you look into that?
I changed the code to use fs.stats
and fixed linting/format errors.
Build is green! 🎉
:tada: This PR is included in version 1.7.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
This is my first experience with typescript, feedback much appreciated ;)