Skip to content
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

Merged
merged 13 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected override bool IsResultDeclaration(Declaration declaration, Declaration
|| declaration.Accessibility == Accessibility.Public
|| declaration.Accessibility == Accessibility.Global)
&& finder.MatchName(declaration.IdentifierName)
.Where(otherDeclaration => otherDeclaration.QualifiedModuleName.Equals(declaration.QualifiedModuleName))
.All(accessor => accessor.DeclarationType != DeclarationType.PropertyGet);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Rubberduck.Common;
using Rubberduck.JunkDrawer.Extensions;
using Rubberduck.Navigation.Folders;
using Rubberduck.Parsing.Symbols;
using Rubberduck.VBEditor;
Expand Down Expand Up @@ -30,7 +32,7 @@ public sealed class CodeExplorerCustomFolderViewModel : CodeExplorerItemViewMode
{
_vbe = vbe;
FolderDepth = parent is CodeExplorerCustomFolderViewModel folder ? folder.FolderDepth + 1 : 1;
FullPath = fullPath?.Trim('"') ?? string.Empty;
FullPath = fullPath?.FromVbaStringLiteral() ?? string.Empty;
Name = name.Replace("\"", string.Empty);

AddNewChildren(ref declarations);
Expand All @@ -44,7 +46,7 @@ public sealed class CodeExplorerCustomFolderViewModel : CodeExplorerItemViewMode

public string FullPath { get; }

public string FolderAttribute => $"'@Folder(\"{FullPath.Replace("\"", string.Empty)}\")";
public string FolderAttribute => $"'@Folder({FullPath.ToVbaStringLiteral()})";

/// <summary>
/// One-based depth in the folder hierarchy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Windows.Input;
using Rubberduck.Parsing.UIContext;
using Rubberduck.Templates;
using Rubberduck.UI.CodeExplorer.Commands.DragAndDrop;
using Rubberduck.UI.Command.ComCommands;
using Rubberduck.UI.UnitTesting.ComCommands;
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
Expand Down Expand Up @@ -379,6 +380,7 @@ private void ExecuteRemoveCommand(object param)
public OpenProjectPropertiesCommand OpenProjectPropertiesCommand { get; set; }
public SetAsStartupProjectCommand SetAsStartupProjectCommand { get; set; }
public RenameCommand RenameCommand { get; set; }
public CodeExplorerMoveToFolderCommand MoveToFolderCommand { get; set; }
public IndentCommand IndenterCommand { get; set; }
public CodeExplorerFindAllReferencesCommand FindAllReferencesCommand { get; set; }
public CodeExplorerFindAllImplementationsCommand FindAllImplementationsCommand { get; set; }
Expand All @@ -398,7 +400,9 @@ private void ExecuteRemoveCommand(object param)
public CommandBase SyncCodePaneCommand { get; }
public CodeExplorerExtractInterfaceCommand CodeExplorerExtractInterfaceCommand { get; set; }

public ICodeExplorerNode FindVisibleNodeForDeclaration(Declaration declaration)
public CodeExplorerMoveToFolderDragAndDropCommand MoveToFolderDragAndDropCommand { get; set; }

public ICodeExplorerNode FindVisibleNodeForDeclaration(Declaration declaration)
{
if (declaration == null)
{
Expand Down
49 changes: 49 additions & 0 deletions Rubberduck.Core/Navigation/Folders/DeclarationFolderExtensions.cs
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);
}
}
}
78 changes: 0 additions & 78 deletions Rubberduck.Core/Navigation/Folders/FolderExtensions.cs

This file was deleted.

6 changes: 6 additions & 0 deletions Rubberduck.Core/Rubberduck.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
<Compile Update="UI\Refactorings\MoveFolder\MoveMultipleFoldersView.xaml.cs">
<DependentUpon>MoveMultipleFoldersView.xaml</DependentUpon>
</Compile>
<Compile Update="UI\Refactorings\MoveToFolder\MoveMultipleToFolderView.xaml.cs">
<DependentUpon>MoveMultipleToFolderView.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,7 @@ private string Folder(CodeExplorerItemViewModel node)
return ActiveProjectFolder();
}

var customFolder = declaration.CustomFolder;
if (customFolder != null)
{
return customFolder.Replace("\"", string.Empty);
}

return ProjectFolder(declaration.ProjectName);
return declaration.CustomFolder ?? ProjectFolder(declaration.ProjectName);
}

private string ActiveProjectFolder()
Expand Down
14 changes: 12 additions & 2 deletions Rubberduck.Core/UI/CodeExplorer/CodeExplorerControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@
<Setter Property="HorizontalAlignment" Value="Left" />
<EventSetter Event="MouseDoubleClick" Handler="TreeView_OnMouseDoubleClick" />
<EventSetter Event="MouseRightButtonDown" Handler="TreeView_OnMouseRightButtonDown" />
<EventSetter Event="DragOver" Handler="TreeView_OnDragOver" />
<EventSetter Event="Drop" Handler="TreeView_OnDrop" />
<EventSetter Event="PreviewQueryContinueDrag" Handler="TreeView_PreviewContinueDrag" />
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="TreeView_PreviewMouseLeftButtonDown" />
<EventSetter Event="PreviewMouseMove" Handler="TreeView_PreviewMouseMove" />

<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderBrush" Value="{StaticResource HighlightBorderActiveBrush}"/>
Expand Down Expand Up @@ -395,7 +401,8 @@
FontSize="{Binding FontSize, Mode=OneWay}"
BorderThickness="0,1"
VirtualizingPanel.IsVirtualizing="False"
KeyDown="ProjectTree_KeyDown">
KeyDown="ProjectTree_KeyDown"
AllowDrop="True">
<TreeView.ContextMenu>
<ContextMenu>
<MenuItem Header="{Resx ResxName=Rubberduck.Resources.CodeExplorer.CodeExplorerUI, Key=CodeExplorer_Open}"
Expand All @@ -417,9 +424,12 @@
<Image Source="{StaticResource RefreshImage}" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{Resx ResxName=Rubberduck.Resources.RubberduckUI, Key=Rename}"
<MenuItem Header="{Resx ResxName=Rubberduck.Resources.CodeExplorer.CodeExplorerUI, Key=CodeExplorer_Rename}"
Command="{Binding RenameCommand}"
CommandParameter="{Binding SelectedItem, Mode=OneWay}" />
<MenuItem Header="{Resx ResxName=Rubberduck.Resources.CodeExplorer.CodeExplorerUI, Key=CodeExplorer_MoveToFolder}"
Command="{Binding MoveToFolderCommand}"
CommandParameter="{Binding SelectedItem, Mode=OneWay}" />
<MenuItem Header="{Resx ResxName=Rubberduck.Resources.CodeExplorer.CodeExplorerUI, Key=CodeExplorer_ExtractInterfaceText}"
Command="{Binding CodeExplorerExtractInterfaceCommand}"
CommandParameter="{Binding SelectedItem, Mode=OneWay}">
Expand Down
Loading