konveyor / editor-extensions

Developer experience stuff, like VSCode Extension, for Konveyor.
0 stars 8 forks source link

:sparkles: Create in-editor diff view #79

Closed rszwajko closed 1 week ago

rszwajko commented 1 month ago

Use built-in vscode.diff editor to compare the current code(pointed via file URI) with proposed changes(pointed via custom konveyorMemFs Uri).

Key points:

  1. proposed changes (diffs) are applied to current code base and are written to in-memory file system. Late they can be accessed via custom URI scheme konveyorMemFs.
  2. both left and right side of the diff is editable
  3. available commands grouped using konveyor (global) or konveyor.diffView prefix(diff view specific): a) applyAll - apply all fixes b) revertAll - discard local changes to the proposed fixes c) applyFile/revertFile - as above but on a single file d) copyDiff/copyPath - convenience commands (single file scope) e) next/prev - keyboard navigation (for now) using the same key bindings as reference-view extension (f4 and shift+f4) f) viewFix - wrapper around vscode.diff that uses konveyorMemFs

Sources:

  1. tree view is based on built-in reference-view extension. Only file-item nodes are used. Support for history items and dynamic model changes have been dropped. However the original architecture is there and should allow adding more advance features in the future.
  2. in-memory file system is taken as-it-is from fsprovider-sample
  3. the approach (using hidden file tree for fixes) originates from Continue's DiffManager
  4. check/discard icons taken from source-control-sample

Reference-Url: https://github.com/continuedev/continue/blob/e7fe5994ffc6a3f45ad358ced7d6890deb145d96/extensions/vscode/src/diff/horizontal.ts#L34 Reference-Url: https://github.com/microsoft/vscode/tree/main/extensions/references-view Reference-Url: https://github.com/microsoft/vscode-extension-samples/tree/main/fsprovider-sample Reference-Url: https://github.com/microsoft/vscode-extension-samples/tree/main/source-control-sample

rszwajko commented 1 month ago
  • Do we need the tree view to navigate these things?

No. Actually we use the tree as a list. However it's easier (and future-proof) to use tree view. The extensions I've followed (reference-view and SCM) use this approach. In SCM (i.e. git) you can switch between tree and list but technically it's the same tree.

  • How the result of our analyzerClient's getSolution for a specific incident is going to integrate with what is demonstrated here.

The solutions need to be written to in-memory file system. Right now I'm using static mock data from vscode/src/diffView/suggestions.

This approach (EDIT: hidden file tree) originates from Continue's DiffManager but instead of real file system we are using in-memory one borrowed from fsprovider-sample

  • Would prefer all of the commands to be registered in commands.ts. I really don't want them spread about the repository.

All commands are already listed in package.json. We could duplicate that in commands.ts but this will require imports from all modules.

  • The number of new commands being added. I would have thought we could have something like konveyor.acceptFix and konveyor.rejectFix and that is it.

Most of the commands are related to navigation. Copy* were inherited from reference-view - the seem to be commonly used in VS Code in file views.

  • We are generating all of these file changes at startup...shouldn't this be tied to some user action? This is where I had thought the mocks would come into play...You call "Generate Fix" and you get changes that you can optional accept or reject.

Yep. Right now we are using static mock data. As soon as we will have better mocks we can switch.

rszwajko commented 1 month ago

image

rszwajko commented 1 month ago

@djzager the current solution is not fully functional as it uses mock data however this will be improved in follow-up issues. First one is https://github.com/konveyor/editor-extensions/issues/68 which should provide us better mocks. If you prefer to put some fixes already in this PR then please comment.

rszwajko commented 2 weeks ago

https://github.com/user-attachments/assets/d3d09e0e-25f6-4781-8682-1eeca3683246