forked from OmniSharp/omnisharp-roslyn
-
Notifications
You must be signed in to change notification settings - Fork 0
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 OmniSharp#293 from OmniSharp/plugins/mef
Plugin system with MEF
- Loading branch information
Showing
476 changed files
with
4,161 additions
and
1,630 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
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
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,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using OmniSharp.Mef; | ||
using OmniSharp.Models; | ||
using OmniSharp.Models.v1; | ||
using V2 = OmniSharp.Models.V2; | ||
|
||
namespace OmniSharp | ||
{ | ||
public interface RequestHandler<TRequest, TResponse> : IRequestHandler | ||
{ | ||
Task<TResponse> Handle(TRequest request); | ||
} | ||
|
||
public interface IAggregateResponse | ||
{ | ||
IAggregateResponse Merge(IAggregateResponse response); | ||
} | ||
|
||
public interface IRequest { } | ||
|
||
public static class OmnisharpEndpoints | ||
{ | ||
public const string GotoDefinition = "/gotodefinition"; | ||
public const string FindSymbols = "/findsymbols"; | ||
public const string UpdateBuffer = "/updatebuffer"; | ||
public const string ChangeBuffer = "/changebuffer"; | ||
public const string CodeCheck = "/codecheck"; | ||
public const string FilesChanged = "/filesChanged"; | ||
public const string FormatAfterKeystroke = "/formatAfterKeystroke"; | ||
public const string FormatRange = "/formatRange"; | ||
public const string CodeFormat = "/codeformat"; | ||
public const string Highlight = "/highlight"; | ||
public const string AutoComplete = "/autocomplete"; | ||
public const string FindImplementations = "/findimplementations"; | ||
public const string FindUsages = "/findusages"; | ||
public const string GotoFile = "/gotofile"; | ||
public const string GotoRegion = "/gotoregion"; | ||
public const string NavigateUp = "/navigateup"; | ||
public const string NavigateDown = "/navigatedown"; | ||
public const string TypeLookup = "/typelookup"; | ||
public const string GetCodeAction = "/getcodeactions"; | ||
public const string RunCodeAction = "/runcodeaction"; | ||
public const string Rename = "/rename"; | ||
public const string SignatureHelp = "/signatureHelp"; | ||
public const string MembersTree = "/currentfilemembersastree"; | ||
public const string MembersFlat = "/currentfilemembersasflat"; | ||
public const string TestCommand = "/gettestcontext"; | ||
public const string Metadata = "/metadata"; | ||
public const string PackageSource = "/packagesource"; | ||
public const string PackageSearch = "/packagesearch"; | ||
public const string PackageVersion = "/packageversion"; | ||
public const string WorkspaceInformation = "/projects"; | ||
public const string ProjectInformation = "/project"; | ||
public const string FixUsings = "/fixusings"; | ||
|
||
public const string CheckAliveStatus = "/checkalivestatus"; | ||
public const string CheckReadyStatus = "/checkreadystatus"; | ||
public const string StopServer = "/stopserver"; | ||
|
||
public static class V2 | ||
{ | ||
public const string GetCodeActions = "/v2/getcodeactions"; | ||
public const string RunCodeAction = "/v2/runcodeaction"; | ||
} | ||
} | ||
} |
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.Generic; | ||
using System.Composition.Hosting.Core; | ||
using System.Linq; | ||
|
||
namespace OmniSharp.Mef | ||
{ | ||
public class MefValueProvider<T> : ExportDescriptorProvider | ||
{ | ||
private readonly T _item; | ||
|
||
public MefValueProvider(T item) | ||
{ | ||
_item = item; | ||
} | ||
|
||
public override IEnumerable<ExportDescriptorPromise> GetExportDescriptors(CompositionContract contract, DependencyAccessor descriptorAccessor) | ||
{ | ||
if (contract.ContractType == typeof(T)) | ||
{ | ||
yield return new ExportDescriptorPromise(contract, string.Empty, true, | ||
() => Enumerable.Empty<CompositionDependency>(), | ||
deps => ExportDescriptor.Create((context, operation) => _item, new Dictionary<string, object>())); | ||
} | ||
} | ||
} | ||
|
||
public static class MefValueProvider | ||
{ | ||
public static MefValueProvider<T> From<T>(T value) | ||
{ | ||
return new MefValueProvider<T>(value); | ||
} | ||
} | ||
} |
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,28 @@ | ||
using System; | ||
using System.Composition; | ||
using System.Threading.Tasks; | ||
|
||
namespace OmniSharp.Mef | ||
{ | ||
public class EndpointDescriptor | ||
{ | ||
public string EndpointName { get; set; } | ||
public Type RequestType { get; set; } | ||
public Type ResponseType { get; set; } | ||
} | ||
|
||
[MetadataAttribute] | ||
public class OmniSharpEndpointAttribute : ExportAttribute | ||
{ | ||
public string EndpointName { get; } | ||
public Type RequestType { get; } | ||
public Type ResponseType { get; } | ||
|
||
public OmniSharpEndpointAttribute(string endpointName, Type requestType, Type responseType) : base(typeof(IRequest)) | ||
{ | ||
EndpointName = endpointName; | ||
RequestType = requestType; | ||
ResponseType = responseType; | ||
} | ||
} | ||
} |
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,27 @@ | ||
using System; | ||
using System.Composition; | ||
using System.Threading.Tasks; | ||
|
||
namespace OmniSharp.Mef | ||
{ | ||
public interface IRequestHandler { } | ||
|
||
public class OmniSharpLanguage | ||
{ | ||
public string EndpointName { get; set; } | ||
public string Language { get; set; } | ||
} | ||
|
||
[MetadataAttribute] | ||
public class OmniSharpHandlerAttribute : ExportAttribute | ||
{ | ||
public string Language { get; } | ||
public string EndpointName { get; } | ||
|
||
public OmniSharpHandlerAttribute(string endpoint, string language) : base(typeof(IRequestHandler)) | ||
{ | ||
EndpointName = endpoint; | ||
Language = language; | ||
} | ||
} | ||
} |
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
...mniSharp/Models/v1/AutoCompleteRequest.cs → ...ractions/Models/v1/AutoCompleteRequest.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
File renamed without changes.
5 changes: 4 additions & 1 deletion
5
...mniSharp/Models/v1/ChangeBufferRequest.cs → ...ractions/Models/v1/ChangeBufferRequest.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
4 changes: 2 additions & 2 deletions
4
src/OmniSharp/Models/v1/CodeActionRequest.cs → ...stractions/Models/v1/CodeActionRequest.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
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,9 @@ | ||
using OmniSharp.Mef; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
[OmniSharpEndpoint(OmnisharpEndpoints.CodeCheck, typeof(CodeCheckRequest), typeof(QuickFixResponse))] | ||
public class CodeCheckRequest : Request | ||
{ | ||
} | ||
} |
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,9 @@ | ||
using OmniSharp.Mef; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
[OmniSharpEndpoint(OmnisharpEndpoints.CodeFormat, typeof(CodeFormatRequest), typeof(CodeFormatResponse))] | ||
public class CodeFormatRequest : Request | ||
{ | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,8 @@ | ||
using System.Collections.Generic; | ||
using OmniSharp.Mef; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
[OmniSharpEndpoint(OmnisharpEndpoints.FilesChanged, typeof(IEnumerable<Request>), typeof(FilesChangedResponse))] | ||
public class FilesChangedRequest : IRequest { } | ||
} |
15 changes: 15 additions & 0 deletions
15
src/OmniSharp.Abstractions/Models/v1/FilesChangedResponse.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; | ||
using System.Collections.Generic; | ||
using OmniSharp.Mef; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
public class FilesChangedResponse : IAggregateResponse | ||
{ | ||
public IAggregateResponse Merge(IAggregateResponse response) | ||
{ | ||
// File Changes just need to inform plugins, editors are not expecting any kind of real response | ||
return response ?? new FilesChangedResponse(); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/OmniSharp.Abstractions/Models/v1/FindImplementationsRequest.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,9 @@ | ||
using OmniSharp.Mef; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
[OmniSharpEndpoint(OmnisharpEndpoints.FindImplementations, typeof(FindImplementationsRequest), typeof(QuickFixResponse))] | ||
public class FindImplementationsRequest : Request | ||
{ | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/OmniSharp.Abstractions/Models/v1/FindSymbolsRequest.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,11 @@ | ||
using OmniSharp.Mef; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
[OmniSharpEndpoint(OmnisharpEndpoints.FindSymbols, typeof(FindSymbolsRequest), typeof(QuickFixResponse))] | ||
public class FindSymbolsRequest : IRequest | ||
{ | ||
public string Language { get; set; } | ||
public string Filter { get; set; } | ||
} | ||
} |
Oops, something went wrong.