-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #848 from filipw/features/code-actions-folder
Added an option to configure a code actions folder
- Loading branch information
Showing
8 changed files
with
147 additions
and
9 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
32 changes: 32 additions & 0 deletions
32
src/OmniSharp.Abstractions/Options/RoslynExtensionsOptions.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,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace OmniSharp.Options | ||
{ | ||
public class RoslynExtensionsOptions | ||
{ | ||
public string[] LocationPaths { get; set; } | ||
|
||
public IEnumerable<string> GetNormalizedLocationPaths(IOmniSharpEnvironment env) | ||
{ | ||
if (LocationPaths == null || LocationPaths.Length == 0) return Enumerable.Empty<string>(); | ||
|
||
var normalizePaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase); | ||
foreach (var locationPath in LocationPaths) | ||
{ | ||
if (Path.IsPathRooted(locationPath)) | ||
{ | ||
normalizePaths.Add(locationPath); | ||
} | ||
else | ||
{ | ||
normalizePaths.Add(Path.Combine(env.TargetDirectory, locationPath)); | ||
} | ||
} | ||
|
||
return normalizePaths; | ||
} | ||
} | ||
} |
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
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
src/OmniSharp.Roslyn.CSharp/CodeActions/ExternalCodeActionProvider.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 System.Composition; | ||
using OmniSharp.Services; | ||
|
||
namespace OmniSharp.Roslyn.CSharp.Services.CodeActions | ||
{ | ||
[Export(typeof(ICodeActionProvider))] | ||
public class ExternalCodeActionProvider : AbstractCodeActionProvider | ||
{ | ||
[ImportingConstructor] | ||
public ExternalCodeActionProvider(ExternalFeaturesHostServicesProvider featuresHostServicesProvider) | ||
: base("ExternalCodeActions", featuresHostServicesProvider.Assemblies) | ||
{ | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/OmniSharp.Roslyn.CSharp/Services/ExternalFeaturesHostServicesProvider.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,34 @@ | ||
using System.Collections.Immutable; | ||
using System.Composition; | ||
using System.Linq; | ||
using System.Reflection; | ||
using OmniSharp.Options; | ||
using OmniSharp.Services; | ||
|
||
namespace OmniSharp.Roslyn.CSharp.Services | ||
{ | ||
[Export(typeof(IHostServicesProvider))] | ||
[Export(typeof(ExternalFeaturesHostServicesProvider))] | ||
[Shared] | ||
public class ExternalFeaturesHostServicesProvider : IHostServicesProvider | ||
{ | ||
public ImmutableArray<Assembly> Assemblies { get; } | ||
|
||
[ImportingConstructor] | ||
public ExternalFeaturesHostServicesProvider(IAssemblyLoader loader, OmniSharpOptions options, IOmniSharpEnvironment env) | ||
{ | ||
var builder = ImmutableArray.CreateBuilder<Assembly>(); | ||
|
||
var roslynExtensionsLocations = options.RoslynExtensionsOptions.GetNormalizedLocationPaths(env); | ||
if (roslynExtensionsLocations?.Any() == true) | ||
{ | ||
foreach (var roslynExtensionsLocation in roslynExtensionsLocations) | ||
{ | ||
builder.AddRange(loader.LoadAllFrom(roslynExtensionsLocation)); | ||
} | ||
} | ||
|
||
Assemblies = builder.ToImmutable(); | ||
} | ||
} | ||
} |
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
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