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

Stop losing member attributes for renamed members #5278

Open MDoerner opened 4 years ago

MDoerner commented 4 years ago

For some time now, we recover member attributes on rewrites, which would otherwise be dropped by the VBE. However, this recovery has one blind spot: members getting renamed in the rewrite.

The problem is that the members the attributes belong to are identified by the component they are contained in and their name. If that name changes, we cannot recover them with the current approach. Even resorting to an attributes pass rewrite will not help here since the actual attribute has to be adapted to the new member name.

We should try to fix this blind spot.

One option is to incorporate the attribute adjustment logic into all places (via some joined utility) renaming members and then to rewrite the attributes code instead of the code pane code. However, this will lead to some complications for members changed as part of refactorings that suspend the parser while they do their thing. Inside those, we cannot execute the attributes rewrite as is, because it suspends the parser again. This leads either to an exception or a deadlock. Thus, the rewriter setup will have to be enhanced to avoid a double suspension.

MDoerner commented 4 years ago

Thinking about this a bit, this is even a bit more complicated. We cannot perform the refactorings on the attribute code, because we have no idea where the references are in the attributes code.