-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to Folder Refactoring #5438
Move to Folder Refactoring #5438
Conversation
Also correctly converts folder annotation arguments to the string content and back. This also removes the parentheses around folders.
It did not consider that there could be a getter in another module with the same name.
It moves the containing folder into another folder. Also fixes ToVbaStringLiteral. (It was missing the surrounding quotes.)
Also adds members to get the initial model to InteractiveRefactoringTestsBase.
There are already tests for the involved refactoring actions.
This moves interactive refactorings from using inheritance to deal with the interaction to composition. Consequently, the interaction can be reused elsewhere.
This combines MoveToFolder and MoveFolder, selecting based on the selected node of the CE. In principle, the backing refactoring actions are capable of dealing with multiple nodes at once. However, the CE only allows selecting single items at the moment and the command reflects that when deriving the models to pass to the refactoring actions.
Codecov Report
@@ Coverage Diff @@
## next #5438 +/- ##
==========================================
- Coverage 61.49% 61.14% -0.35%
==========================================
Files 1194 1222 +28
Lines 40595 41003 +408
Branches 8666 8749 +83
==========================================
+ Hits 24961 25070 +109
- Misses 13790 14080 +290
- Partials 1844 1853 +9
|
The exception is moving into the project folder. This simply adds the explicit folder annotation.
# Conflicts: # Rubberduck.Resources/RubberduckUI.resx
return target != null | ||
&& target is ModuleDeclaration | ||
&& !_state.IsNewOrModified(target.QualifiedModuleName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the null-check be redundant with target is ModuleDeclaration module
?
e.g.
return target is ModuleDeclaration module && !_state.IsNewOrModified(module.QualifiedModuleName);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the null-check is redundant even without a module
variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove the null
check.
Rubberduck.Core/UI/Command/Refactorings/CodePaneRefactorMoveToFolderCommand.cs
Show resolved
Hide resolved
Loaded += (o, e) => | ||
{ | ||
MoveToFolderTextBox.Focus(); | ||
MoveToFolderTextBox.SelectAll(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does the inline EventHandler delegate get de-registered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to admit that I simply copied this from the Rename
dialog. Maybe, whoever wrote that can answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it simply gets unregistered when the view gets GCed. Remember, it is the event that keeps the handler alive, not the other way around.
I will add explicit de-registration, nonetheless.
Loaded += (o, e) => | ||
{ | ||
MoveToFolderTextBox.Focus(); | ||
MoveToFolderTextBox.SelectAll(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worrying about handler holding up GC here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we simply unregister the handler in the handler itself?
public interface IMoveMultipleFoldersPresenter : IRefactoringPresenter<MoveMultipleFoldersModel> | ||
{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this marker interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we use it as the type parameter in the presenter and dialog setup.
public interface IMoveMultipleToFolderPresenter : IRefactoringPresenter<MoveMultipleToFolderModel> | ||
{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marker interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
@@ -74,6 +74,25 @@ End Property | |||
Assert.AreEqual(0, InspectionResultsForModules(("MyClass", inputCode, ComponentType.ClassModule)).Count()); | |||
} | |||
|
|||
[Test] | |||
[Category("Inspections")] | |||
public void WriteOnlyProperty_ReturnsResult_GetInOtherModule() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - just curious about the marker interfaces for the generic presenters, and I think the inline EventHandler
delegates in .xaml code-behinds would be better off not-inlined and explicitly de-registered, but if it's not causing any problems it's probably a non-issue.
This is awesome BTW, well done! |
A test was there, but the assert was wrong.
This is done in Rename-, MoveMultipleToFolder- and Move MultipleFoldersView. Also addresses one more review comment to PR rubberduck-vba#5438.
Closes #3332
Closes #5159
This PR introduces
MoveToFolderRefactoring
,MoveContainingFolderRefactoring
andCodeExplorerMoveToFolderCommand
allowing to move components and folders around in the folder hierarchy. The target is derived from the selected component for the refactorings and from the selected folder or component view model for the CE command. The target folder is selected in a dialog I borrowed fromRename
.This PR also extracts the user interaction part from the
InteractiveRefactoringBase
into a different class then injected back. This allows to reuse the interaction elsewhere, e.g. in CE commands. (Sorry for any conflicts.)The backing refactoring actions and interactions for the refactorings allow to process multiple modules or folders at once. However, I had to realize that the CE does not allow multi-selection. Thus, the CE command does not deal with multiple selected nodes so far. Should we change our stand on multi-select in the CE, adapting the command to this, should be comparatively easy.
We have drag and drop now as well.
Component move via dialog:
![MoveToFolder_Component_Dialog](https://user-images.githubusercontent.com/22868956/77261752-195ffc00-6c91-11ea-8810-fb23050df24e.gif)
Folder move via dialog:
![MoveToFolder_Folder_Dialog](https://user-images.githubusercontent.com/22868956/77261760-2d0b6280-6c91-11ea-87f5-404d50034fe6.gif)
Component move via drag and drop:
![MoveToFolder_Component_DragAndDrop](https://user-images.githubusercontent.com/22868956/77261769-44e2e680-6c91-11ea-8e00-16e0bdc52541.gif)
Folder move via drag and drop:
![MoveToFolder_Folder_DragAndDrop](https://user-images.githubusercontent.com/22868956/77261775-4d3b2180-6c91-11ea-9b60-c7f49e705343.gif)