-
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 #969 from OmniSharp/lsp
[Beta] Language Server Protocol
- Loading branch information
Showing
32 changed files
with
1,618 additions
and
66 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
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,6 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("TestUtility")] | ||
[assembly: InternalsVisibleTo("OmniSharp")] | ||
[assembly: InternalsVisibleTo("OmniSharp.Stdio.Tests")] | ||
[assembly: InternalsVisibleTo("OmniSharp.LanguageServer.Tests")] |
59 changes: 59 additions & 0 deletions
59
src/OmniSharp.LanguageServerProtocol/Eventing/LanguageServerEventEmitter.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,59 @@ | ||
using System; | ||
using System.Linq; | ||
using Microsoft.Extensions.Logging; | ||
using Newtonsoft.Json; | ||
using OmniSharp.Eventing; | ||
using OmniSharp.Extensions.LanguageServer; | ||
using OmniSharp.Extensions.LanguageServer.Models; | ||
using OmniSharp.Extensions.LanguageServer.Protocol; | ||
using OmniSharp.Models.Diagnostics; | ||
using OmniSharp.Models.Events; | ||
using OmniSharp.Stdio.Protocol; | ||
using OmniSharp.Stdio.Services; | ||
|
||
namespace OmniSharp.LanguageServerProtocol.Eventing | ||
{ | ||
public class LanguageServerEventEmitter : IEventEmitter | ||
{ | ||
private readonly LanguageServer _server; | ||
|
||
public LanguageServerEventEmitter(LanguageServer server) | ||
{ | ||
_server = server; | ||
} | ||
|
||
public void Emit(string kind, object args) | ||
{ | ||
switch (kind) | ||
{ | ||
case EventTypes.Diagnostic: | ||
if (args is DiagnosticMessage message) | ||
{ | ||
var groups = message.Results | ||
.GroupBy(z => Helpers.ToUri(z.FileName), z => z.QuickFixes); | ||
|
||
foreach (var group in groups) | ||
{ | ||
_server.PublishDiagnostics(new PublishDiagnosticsParams() | ||
{ | ||
Uri = group.Key, | ||
Diagnostics = group | ||
.SelectMany(z => z.Select(v => v.ToDiagnostic())) | ||
.ToArray() | ||
}); | ||
} | ||
} | ||
break; | ||
case EventTypes.ProjectAdded: | ||
case EventTypes.ProjectChanged: | ||
case EventTypes.ProjectRemoved: | ||
case EventTypes.Error: | ||
case EventTypes.PackageRestoreStarted: | ||
case EventTypes.PackageRestoreFinished: | ||
case EventTypes.UnresolvedDependencies: | ||
// TODO: As custom notifications | ||
break; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.