/
DeclarationFolderExtensions.cs
49 lines (42 loc) · 1.47 KB
/
DeclarationFolderExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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);
}
}
}