Conversation
| }); | ||
| applyWorkspaceEditAction.applyWorkspaceEdit(edit); | ||
| view.close(); | ||
| refactoringActionDelegate.closeWizard(); |
There was a problem hiding this comment.
It invokes onCancelButtonClicked();
I think view.close() is enough.
There was a problem hiding this comment.
view.close() closes just Preview window, but also we need to close the other one (Rename or Move) window which was opened previously
| public void onEditorOpened(EditorOpenedEvent event) { | ||
| String uri = buildHelper.getUri(event.getFile()); | ||
| if (uri.endsWith(POM_FILE)) { | ||
| if (!uri.endsWith(POM_FILE)) { |
| if (!arg.isPresent()) { | ||
| return; | ||
| } | ||
| File existedFile = arg.get(); |
| } | ||
| PreviewNode node = nodes.get(selectedNode.getUri()); | ||
| List<TextEdit> edits = new ArrayList<>(); | ||
| if (node.getId().equals(selectedNode.getId())) { |
There was a problem hiding this comment.
Not quite sure what we are doing here. Refactor so it's obvious or add comments.
There was a problem hiding this comment.
refactored and added some comments
|
|
||
| private RefactorInfo refactorInfo; | ||
| private RefactoringSession session; | ||
| private Map<String, PreviewNode> nodes; |
There was a problem hiding this comment.
Are all nodes in this map? If not, this needs a different name. fileNodes?
| this.refactoringActionDelegate = refactoringActionDelegate; | ||
| nodes = new LinkedHashMap<>(); | ||
|
|
||
| prepareNodes(workspaceEdit); |
There was a problem hiding this comment.
As I see it, prepareNodes just fills in the nodes map. why not do
nodes= prepareNodes(workspaceEdit);
If you make prepareNodes static, you can show that there are no side-effects in the method. Making stuff side-effect free simplifies understanding the code.
| for (ResourceChange resourceChange : edits.getResourceChanges()) { | ||
| edit.getResourceChanges().add(Either.forLeft(resourceChange)); | ||
| } | ||
| undoChanges(); |
There was a problem hiding this comment.
Could you clarify please?
If you're thinking about why I undo changes here. It is because before applying all TextEdit changes we need to have initial state of the content where linked mode was activated.
There was a problem hiding this comment.
yes, that's what I was thinking of.
| edit.setChanges(workspaceEdit.getChanges()); | ||
| edit.setResourceChanges(new LinkedList<>()); | ||
| for (ResourceChange resourceChange : workspaceEdit.getResourceChanges()) { | ||
| edit.getResourceChanges().add(Either.forLeft(resourceChange)); |
There was a problem hiding this comment.
Out of curiosity...I thought sending WorkspaceChange over the wire did not work? What has changed?
There was a problem hiding this comment.
Sending List<Either<ResourceChange, TextEdit>> which is described in org.eclipse.lsp4j.WorkspaceEdit doesn't work.
So here workspaceEdit is an instance of custom object (org.eclipse.che.jdt.ls.extension.api.dto.CheWorkspaceEdit) where I already have all actual changes and I take all changes from it and put them to the edit (org.eclipse.lsp4j.WorkspaceEdit) to sent it to class which applies org.eclipse.lsp4j.WorkspaceEdit (org.eclipse.che.plugin.languageserver.ide.editor.quickassist.ApplyWorkspaceEditAction#ApplyWorkspaceEditAction)
| String newUri = change.getNewUri(); | ||
| String current = change.getCurrent(); | ||
|
|
||
| Path path = toPath(newUri).removeFirstSegments(1).makeAbsolute(); |
There was a problem hiding this comment.
Transformation of file uri's to paths is usually done in WSMaster, so results from lsp servers contain either workspace paths of non-file URI's. See LanguageServiceUtils.removePrefixURI.
There was a problem hiding this comment.
GWT doesn't support java.net.* so we can't use LanguageServiceUtils.java on the client. I've created utility class org.eclipse.che.api.languageserver.util.URIUtil which transforms uri to path.
There was a problem hiding this comment.
Not what I mean, I've tried to explain in chat.
| .getResource(path) | ||
| .then( | ||
| resource -> { | ||
| if (isNullOrEmpty(path.getFileExtension())) { |
There was a problem hiding this comment.
I dont' think this is a valid condition. It's perfectly valid to create files without extensions and folders with.
There was a problem hiding this comment.
yes, but I don't see another way to recognize which type of resource is here. Is it a folder or is a file.
There was a problem hiding this comment.
I think we need to fix this in CheWorkspaceEdit (make CheResourceChange.java) and have a "resourceType" enum to be used on create.
| resource | ||
| .move(path) | ||
| .then( | ||
| arg -> { |
6901019 to
518f5f6
Compare
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
What does this PR do?
Make it possible to do Rename operation by using jdt.ls.
The result of this PR is here: https://youtu.be/HkCKpGSP05o
Depends on
What issues does this PR fix or reference?
#8939