forked from OmniSharp/omnisharp-roslyn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileSystemHelper.cs
More file actions
42 lines (35 loc) · 1.57 KB
/
FileSystemHelper.cs
File metadata and controls
42 lines (35 loc) · 1.57 KB
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
using System.Collections.Generic;
using System.Composition;
using System.Linq;
using Microsoft.Extensions.FileSystemGlobbing;
using OmniSharp.Options;
namespace OmniSharp.FileSystem
{
[Export, Shared]
public class FileSystemHelper
{
private readonly OmniSharpOptions _omniSharpOptions;
private readonly IOmniSharpEnvironment _omniSharpEnvironment;
[ImportingConstructor]
public FileSystemHelper(OmniSharpOptions omniSharpOptions, IOmniSharpEnvironment omniSharpEnvironment)
{
_omniSharpOptions = omniSharpOptions;
_omniSharpEnvironment = omniSharpEnvironment;
}
public IEnumerable<string> GetFiles(string includePattern) => GetFiles(includePattern, _omniSharpEnvironment.TargetDirectory);
public IEnumerable<string> GetFiles(string includePattern, string targetDirectory)
{
var matcher = new Matcher();
matcher.AddInclude(includePattern);
if (_omniSharpOptions.FileOptions.SystemExcludeSearchPatterns != null && _omniSharpOptions.FileOptions.SystemExcludeSearchPatterns.Any())
{
matcher.AddExcludePatterns(_omniSharpOptions.FileOptions.SystemExcludeSearchPatterns);
}
if (_omniSharpOptions.FileOptions.ExcludeSearchPatterns != null && _omniSharpOptions.FileOptions.ExcludeSearchPatterns.Any())
{
matcher.AddExcludePatterns(_omniSharpOptions.FileOptions.ExcludeSearchPatterns);
}
return matcher.GetResultsInFullPath(targetDirectory);
}
}
}