Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It moves the containing folder into another folder. Also fixes ToVbaStringLiteral. (It was missing the surrounding quotes.)
- Loading branch information
Showing
37 changed files
with
1,095 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Rubberduck.Core/Navigation/Folders/DeclarationFolderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using Rubberduck.Parsing.Symbols; | ||
using Rubberduck.JunkDrawer.Extensions; | ||
|
||
namespace Rubberduck.Navigation.Folders | ||
{ | ||
public static class DeclarationFolderExtensions | ||
{ | ||
public static string RootFolder(this Declaration declaration) | ||
{ | ||
return declaration?.CustomFolder?.RootFolder() | ||
?? declaration?.ProjectName | ||
?? string.Empty; | ||
} | ||
|
||
public static bool IsInFolder(this Declaration declaration, string folder) | ||
{ | ||
if (declaration?.CustomFolder is null || folder is null) | ||
{ | ||
return false; | ||
} | ||
|
||
return declaration.CustomFolder.Equals(folder, StringComparison.Ordinal); | ||
} | ||
|
||
public static bool IsInSubFolder(this Declaration declaration, string folder) | ||
{ | ||
var declarationFolder = declaration?.CustomFolder; | ||
if (declarationFolder is null || folder is null) | ||
{ | ||
return false; | ||
} | ||
|
||
return declarationFolder.IsSubFolderOf(folder); | ||
} | ||
|
||
public static bool IsInFolderOrSubFolder(this Declaration declaration, string folder) | ||
{ | ||
var declarationFolder = declaration?.CustomFolder; | ||
if (declarationFolder is null || folder is null) | ||
{ | ||
return false; | ||
} | ||
|
||
return declaration.IsInFolder(folder) | ||
|| declarationFolder.IsSubFolderOf(folder); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Rubberduck.Core/UI/Command/MenuItems/CodePaneRefactorMoveContainingFolderCommandMenuItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Rubberduck.Parsing.VBA; | ||
using Rubberduck.UI.Command.MenuItems.ParentMenus; | ||
using Rubberduck.UI.Command.Refactorings; | ||
|
||
namespace Rubberduck.UI.Command.MenuItems | ||
{ | ||
public class CodePaneRefactorMoveContainingFolderCommandMenuItem : CommandMenuItemBase | ||
{ | ||
public CodePaneRefactorMoveContainingFolderCommandMenuItem(CodePaneRefactorMoveContainingFolderCommand command) | ||
: base(command) | ||
{} | ||
|
||
public override string Key => "RefactorMenu_MoveContainingFolder"; | ||
public override int DisplayOrder => (int)RefactoringsMenuItemDisplayOrder.MoveContainingFolder; | ||
public override bool BeginGroup => false; | ||
|
||
public override bool EvaluateCanExecute(RubberduckParserState state) | ||
{ | ||
return state != null && Command.CanExecute(null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Rubberduck.Core/UI/Command/Refactorings/CodePaneRefactorMoveContainingFolderCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Rubberduck.Parsing.Symbols; | ||
using Rubberduck.Parsing.VBA; | ||
using Rubberduck.Refactorings.MoveFolder; | ||
using Rubberduck.UI.Command.Refactorings.Notifiers; | ||
using Rubberduck.VBEditor.Utility; | ||
|
||
namespace Rubberduck.UI.Command.Refactorings | ||
{ | ||
public class CodePaneRefactorMoveContainingFolderCommand : RefactorCodePaneCommandBase | ||
{ | ||
private readonly RubberduckParserState _state; | ||
private readonly ISelectedDeclarationProvider _selectedDeclarationProvider; | ||
|
||
public CodePaneRefactorMoveContainingFolderCommand( | ||
MoveContainingFolderRefactoring refactoring, | ||
MoveContainingFolderRefactoringFailedNotifier failureNotifier, | ||
ISelectionProvider selectionProvider, | ||
RubberduckParserState state, | ||
ISelectedDeclarationProvider selectedDeclarationProvider) | ||
: base(refactoring, failureNotifier, selectionProvider, state) | ||
{ | ||
_selectedDeclarationProvider = selectedDeclarationProvider; | ||
_state = state; | ||
|
||
AddToCanExecuteEvaluation(SpecializedEvaluateCanExecute); | ||
} | ||
|
||
private bool SpecializedEvaluateCanExecute(object parameter) | ||
{ | ||
var target = GetTarget(); | ||
|
||
return target != null | ||
&& target is ModuleDeclaration | ||
&& !_state.IsNewOrModified(target.QualifiedModuleName); | ||
} | ||
|
||
private Declaration GetTarget() | ||
{ | ||
return _selectedDeclarationProvider.SelectedModule(); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...k.Core/UI/Command/Refactorings/Notifiers/MoveContainingFolderRefactoringFailedNotifier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Rubberduck.Interaction; | ||
using Rubberduck.Parsing.Symbols; | ||
using Rubberduck.Refactorings.Exceptions; | ||
using Rubberduck.Refactorings.Exceptions.MoveToFolder; | ||
|
||
namespace Rubberduck.UI.Command.Refactorings.Notifiers | ||
{ | ||
public class MoveContainingFolderRefactoringFailedNotifier : RefactoringFailureNotifierBase | ||
{ | ||
public MoveContainingFolderRefactoringFailedNotifier(IMessageBox messageBox) | ||
: base(messageBox) | ||
{} | ||
|
||
protected override string Caption => Resources.RubberduckUI.MoveToFolderDialog_Caption; | ||
|
||
protected override string Message(RefactoringException exception) | ||
{ | ||
switch (exception) | ||
{ | ||
case InvalidDeclarationTypeException invalidDeclarationType: | ||
Logger.Warn(invalidDeclarationType); | ||
return string.Format( | ||
Resources.RubberduckUI.RefactoringFailure_InvalidDeclarationType, | ||
invalidDeclarationType.TargetDeclaration.QualifiedName, | ||
invalidDeclarationType.TargetDeclaration.DeclarationType, | ||
DeclarationType.Module); | ||
case NoTargetFolderException noTargetFolder: | ||
return Resources.RubberduckUI.RefactoringFailure_NoTargetFolder; | ||
case AffectedModuleIsStaleException affectedModuleIsStale: | ||
return string.Format( | ||
Resources.RubberduckUI.RefactoringFailure_AffectedModuleIsStale, | ||
affectedModuleIsStale.StaleModule.ToString()); | ||
default: | ||
return base.Message(exception); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Rubberduck.Core/UI/Refactorings/MoveFolder/MoveMultipleFoldersPresenter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Rubberduck.Refactorings.MoveFolder; | ||
using Rubberduck.Resources; | ||
|
||
namespace Rubberduck.UI.Refactorings.MoveFolder | ||
{ | ||
internal class MoveMultipleFoldersPresenter : RefactoringPresenterBase<MoveMultipleFoldersModel>, IMoveMultipleFoldersPresenter | ||
{ | ||
private static readonly DialogData DialogData = DialogData.Create(RubberduckUI.MoveToFolderDialog_Caption, 164, 684); | ||
|
||
public MoveMultipleFoldersPresenter(MoveMultipleFoldersModel model, IRefactoringDialogFactory dialogFactory) : | ||
base(DialogData, model, dialogFactory) | ||
{} | ||
} | ||
} | ||
|
Oops, something went wrong.