rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

Method for pausing Rubberduck #5025

Open neilt1700 opened 5 years ago

neilt1700 commented 5 years ago

Justification When working on a large project and when creating, removing or renaming modules, this process is greatly slowed down as Rubberduck automatically does a refresh after each of these actions - I may need to wait for up to a minute after each one before being able to do anything else in the VBE.

Description Having an option to pause Rubberduck - so that when it needs to do a refresh, rather than doing the refresh it goes back to "pending" - for the user to manually intitiate a refresh when they are ready to do so.

Vogel612 commented 5 years ago

Do note that we're not doing these refreshes willy nilly. If you use Rubberduck tools on a project where the state that Rubberduck knows and the VBE internal state have diverged, the results may be destructive.

What I mean by that is:
If Rubberduck is out of sync, especially refactorings and quickfixes can inadvertently delete code and/or make it uncompilable or nonsensical.

Rubberduck only parses modules that have changed, but we need to recompute and reresolve references between modules to make sure the duck works correctly. As such I think this is not something we want to enable...

daFreeMan commented 5 years ago

@Vogel612 If I use the CE to add a new, blank module, and RD only parses modules that have change, then the parse should be nearly instant - it should only parse a new, blank module with no code and possibly a @Folder("xyz") annotation, and that shouldn't take long, nor should it take long to update the CE. Additionally, resolving references shouldn't be necessary because there should be no references to this new, empty module, and since it's empty there should be no references from it either.

My experience, though, leads me to believe that it's parsing the whole project because it still takes quite a while to parse after adding a new module.

Maybe there could be some sort of short circuit in the parsing logic that recognizes that the parse was caused by a module add and skip most of the steps?

OTOH, maybe the parse time is really inspection running time (since I've got them set to run on parse), and I'm not paying enough attention to notice the difference...

chrisdaniels commented 5 years ago

I agree. I think a RD turn on/off button would be handy with large projects.

retailcoder commented 5 years ago

RD suspends parsing when the IDE isn't in design mode - an interim work-around can be to add/remove modules programmatically, at run-time.

IvenBach commented 5 years ago

Another workaround would be to unload RD from the menu via Add-Ins>Add-In Manager...>Load Behavior group>Loaded/Unloaded. Unload the duck, perform your various edits and reload ducky after completing. I've had to do that myself when doing a lot of renaming. However whenever ducky is missing the IDE doesn't feel complete.

neilt1700 commented 5 years ago

Another workaround would be to unload RD from the menu via Add-Ins>Add-In Manager...>Load Behavior group>Loaded/Unloaded. Unload the duck, perform your various edits and reload ducky after completing. I've had to do that myself when doing a lot of renaming. However whenever ducky is missing the IDE doesn't feel complete.

Is it OK to do this now? - I'd been avoiding doing this because of dire warnings about unloading/loading Rubberduck in the past.

IvenBach commented 5 years ago

I tried it with a project and didn't have any issue. We, those of us at the pond, are pretty sure it's been fixed for a while.

retailcoder commented 5 years ago

@neilt1700 AFAICT it's been fixed a little while ago, but since we know for a fact that some of the objects are still leaking (mostly parser state stuff IIRC), we haven't gone all-out on green-lighting unload+reload; it should work just fine, but I'd still recommend saving.

Back when the "dire warnings" were made, unloading+reloading RD would downright corrupt the entire VBE and its host process, wasn't pretty. We've come a long way!

neilt1700 commented 5 years ago

Well I'd always save... I'd be really happy with unloading/reloading for the odd occasion when I am getting a lot of refreshes.

jim-oflaherty-jr-qalocate-com commented 3 years ago

Has anything on this changed?

Desired Enhancement: I'd love to know if there was a way to Pause/Suspend/Unload RubberDuck temporarily so I can stop the "Automatic Refresh" that occurs on every single edit in my current refactoring.

Use Case: I am doing a refactoring pass on someone else's Excel spreadsheet I have just received for which I am now moving to a more maintainable state. However, I also hit this when I am doing a new greenfield project and lots of root things are in a state of flux for a couple of weeks.

It's fine while the RubberDuck parsing only takes a second or two. It doesn't interrupt my development flow state. However, when the cycles start taking +15 seconds and the UI becomes unusably slow, it really starts to impact staying in a state-of-flow for a refactoring pass. I'm already fighting internal agitation, resistance, and opposition on this maintenance pass to the spreadsheet and on the code itself (because code maintenance is just so fun-filled, right?). These undesirable feelings become increasingly exacerbated as Rubberduck begins to get more and more in the way for no actual value in the immediate refactoring activities.

IOW, I am not really using any aspect of Rubberduck during this particular type of origination/refactoring activity and am fine "disabling Rubberduck" (which includes using none of its tools or windows) until I am done with all the noise generating changes.

Workarounds: A. An immediately obvious one is to follow these steps:

  1. Save the Excel file
  2. Exit Excel
  3. Uninstall Rubberduck
  4. Open the Excel file
  5. Enter the VBA IDE and do my noisy edits/refactorings
  6. Save the Excel file
  7. Exit Excel
  8. Reinstall Rubberduck
  9. Open the Excel file
  10. Continue using all the Rubberduck goodness I now couldn't possibly live without

Doing this loop once a month is probably okay. Doing it more than once every week or so can become quite tedious.

B. Have Rubberduck installed on my desktop, but not on my laptop. So, when I need to suspend Rubberduck, I just...

  1. Save the Excel file to the cloud from my desktop
  2. Open the Excel file from the cloud on my laptop
  3. Perform my noisy edit/refactor pass without Rubberduck
  4. Save the Excel file to the cloud from my laptop
  5. Open the Excel file from the cloud on my desktop
  6. Resume editing/refactoring with Rubberduck

This process is slightly less distracting than A above (assuming my laptop is up and available...which it is NOT about 50% of the time). But it's not by very much. The desktop/laptop Kabuki dance DEFINITELY risks a loss of my very valuable (to me) state-of-flow.

SIDENOTE: I love Love LOVE Rubberduck. It's a fantastic piece of software engineering. I wouldn't choose to do any VBA Project without it. I am deeply grateful to and appreciative of those who have created and maintain this.

MDoerner commented 3 years ago

We currently have not implemented any functionality to pause Rubberduck. I also do not see this coming up in the near future, to be honest.

However, there might be a currently available workaround C: you can unload Rubberduck (and choose whether it starts immediately with the VBE) in the VBE's AddIns->Add-In Manager... menu. Just select Rubberduck and remove the checkmark next to Loaded/Unleaded and Rubberduck will unload. You can reload it by checking the box again. Note that Rubberduck will essentially be in the same state as at startup after reloading via the menu. So it will not be able to use cached state from before the unload.

jim-oflaherty-jr-qalocate-com commented 3 years ago

However, there might be a currently available workaround C: you can unload Rubberduck (and choose whether it starts immediately with the VBE) in the VBE's AddIns->Add-In Manager... menu. Just select Rubberduck and remove the checkmark next to Loaded/Unleaded and Rubberduck will unload. You can reload it by checking the box again.

Aha! That's a way shorter loop than B. And honestly, it is only a smidge worse than having an explicit option within Rubberduck itself.

IOW, this is close enough to meet my immediate needs. So, please don't spend another cycle on this on my behalf.

Tysvm for replying and offering that specific workaround. I really appreciate it.

daFreeMan commented 3 years ago

If the issue is adding modules, you could always add them via the default Project Explorer instead of RD's Code Explorer. Add your 3, 4, 5, whatever number of standard & class modules, add the appropriate '@folder "" and other annotations by hand then do a single parse to have RD recognize them all in one shot.

It's not as pretty or glorious as adding them via RD, but it may be smoother process-wise and less intrusive on the workflow.