rope icon indicating copy to clipboard operation
rope copied to clipboard

History support for multi-project refactorings?

Open abingham opened this issue 6 years ago • 12 comments

Is there any support for doing undo/redo for multi-project refactorings? If not, are there plans for this?

abingham avatar Oct 18 '17 13:10 abingham

I don't think this support exists and is not planned. What is your use case?

soupytwist avatar Oct 18 '17 16:10 soupytwist

I'm writing a HTTP server that exposes rope functionality, and I'd like to let users add cross-projects to do multi-project refactorings. It offers undo/redo support for refactorings, and it seems like it would be odd if undo only worked for the root project.

I might be able to manage the multi-project un/redo support myself, but I'd like to avoid the work if it comes natively from rope.

abingham avatar Oct 18 '17 19:10 abingham

Oh, I like this idea, I'd like to join this project :)

sergeyglazyrindev avatar Oct 18 '17 19:10 sergeyglazyrindev

@sergeyglazyrindev Any help is appreciated! I'm in the middle of making some substantial changes, so it's in a weird state. But hopefully I'll have it back to "normal" soon.

abingham avatar Oct 18 '17 21:10 abingham

@abingham , https://github.com/python-rope/rope/blob/master/rope/base/history.py

emacsway avatar Oct 19 '17 00:10 emacsway

@abingham , what do you mean "for multi-project"?

emacsway avatar Oct 19 '17 00:10 emacsway

@emacsway https://github.com/python-rope/rope/blob/master/rope/refactor/multiproject.py

abingham avatar Oct 19 '17 05:10 abingham

I'm writing a HTTP server that exposes rope functionality,

I like the idea, but wouldn't it be better to support Language Server Protocol? Would it make sense? I believe that creativity around protocols is almost always The Wrong Idea™. This in end, maybe even a good replacement for ropemode, ropevim, and ropemacs. Otherwise apparently the best Python LSP is based on Jedi.

mcepl avatar Oct 19 '17 11:10 mcepl

@abingham , as I see, there is a Composite pattern, which simple delegates calls to the Leaves, see:

  • https://github.com/python-rope/rope/blob/master/rope/refactor/multiproject.py#L44
  • https://github.com/python-rope/rope/blob/master/rope/refactor/multiproject.py#L52

There is only one little problem, the non-polymorphic call for the .do() method, see:

  • https://github.com/python-rope/rope/blob/master/rope/refactor/multiproject.py#L78
  • https://github.com/python-rope/rope/blob/master/ropetest/refactor/multiprojecttest.py#L30

I think, we can easy fix this issue, thus, the History class will be able to work with the Composite (_MultiRefactoring) as well as with a Leaf.

emacsway avatar Oct 19 '17 12:10 emacsway

I like the idea, but wouldn't it be better to support Language Server Protocol?

Maybe so. I started traad because nothing (including ropemacs, since I'm primarily an emacs user) worked for what I needed, and I only really do enough work to make it work for me. If someone wants to put in the effort to create a better refactoring server of some sort, that would be fine with me. FWIW, I definitely feel that an HTTP language server is a better model than pymacs/ropemacs.

abingham avatar Oct 19 '17 12:10 abingham

If someone wants to put in the effort to create a better refactoring server of some sort, that would be fine with me.

So, it won't be you, do I understand correctly?

Just that you could save yourself work on the Emacs-side of the things (and there are even rumours Emacs will have support for LSP natively, and there are already LSP clients for Emacs in existence).

Also, I would love to see rope-based LSP server. If LSP is the future (and it seems to have a great momentum behind it), it could be very neat way how to make rope relevant again (and we could get rid of all three rope{mode,vim,macs} projects which feel to me like the worst part of whole endeavour.

mcepl avatar Oct 19 '17 14:10 mcepl

So, it won't be you, do I understand correctly?

Currently that's correct. I barely have the bandwidth to keep traad hobbling along.

abingham avatar Oct 19 '17 15:10 abingham