-
Notifications
You must be signed in to change notification settings - Fork 419
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 #574 from OmniSharp/streaming-diagnostics-2
Streaming diagnostics
- Loading branch information
Showing
18 changed files
with
642 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
public class DiagnosticMessage | ||
{ | ||
public IEnumerable<DiagnosticResult> Results { get; set; } | ||
} | ||
} |
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,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
public class DiagnosticResult | ||
{ | ||
public string FileName { get; set; } | ||
public IEnumerable<DiagnosticLocation> QuickFixes { get; set; } | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/OmniSharp.Abstractions/Models/v1/DiagnosticsRequest.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 OmniSharp.Mef; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
[OmniSharpEndpoint(OmnisharpEndpoints.Diagnostics, typeof(DiagnosticsRequest), typeof(DiagnosticsResponse))] | ||
public class DiagnosticsRequest : Request | ||
{ | ||
} | ||
|
||
public class DiagnosticsResponse : IAggregateResponse | ||
{ | ||
public IAggregateResponse Merge(IAggregateResponse response) { return response; } | ||
} | ||
} |
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,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using OmniSharp.Mef; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
[OmniSharpEndpoint(OmnisharpEndpoints.Close, typeof(FileCloseRequest), typeof(FileCloseResponse))] | ||
public class FileCloseRequest : 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,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
public class FileCloseResponse : IAggregateResponse | ||
{ | ||
public IAggregateResponse Merge(IAggregateResponse response) { return response; } | ||
} | ||
} |
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 System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using OmniSharp.Mef; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
[OmniSharpEndpoint(OmnisharpEndpoints.Open, typeof(FileOpenRequest), typeof(FileOpenResponse))] | ||
public class FileOpenRequest : 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,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace OmniSharp.Models | ||
{ | ||
public class FileOpenResponse : IAggregateResponse | ||
{ | ||
public IAggregateResponse Merge(IAggregateResponse response) { return response; } | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/OmniSharp.Abstractions/Services/DiagnosticEventForwarder.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,31 @@ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Composition; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using OmniSharp.Models; | ||
using OmniSharp.Models.V2; | ||
using OmniSharp.Services; | ||
|
||
namespace OmniSharp.Services | ||
{ | ||
[Export, Shared] | ||
public class DiagnosticEventForwarder | ||
{ | ||
private readonly IEventEmitter _emitter; | ||
|
||
[ImportingConstructor] | ||
public DiagnosticEventForwarder(IEventEmitter emitter) | ||
{ | ||
_emitter = emitter; | ||
} | ||
|
||
public bool IsEnabled { get; set; } | ||
|
||
public void Forward(DiagnosticMessage message) | ||
{ | ||
_emitter.Emit(EventTypes.Diagnostic, message); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/OmniSharp.Roslyn.CSharp/Services/Diagnostics/DiagnosticsService.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,43 @@ | ||
using System.Composition; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis; | ||
using OmniSharp.Mef; | ||
using OmniSharp.Models; | ||
using OmniSharp.Services; | ||
using OmniSharp.Workers.Diagnostics; | ||
|
||
namespace OmniSharp.Roslyn.CSharp.Services.Diagnostics | ||
{ | ||
[OmniSharpHandler(OmnisharpEndpoints.Diagnostics, LanguageNames.CSharp)] | ||
public class DiagnosticsService : RequestHandler<DiagnosticsRequest, DiagnosticsResponse> | ||
{ | ||
private readonly CSharpDiagnosticService _diagnostics; | ||
private readonly DiagnosticEventForwarder _forwarder; | ||
private readonly OmnisharpWorkspace _workspace; | ||
|
||
[ImportingConstructor] | ||
public DiagnosticsService(OmnisharpWorkspace workspace, DiagnosticEventForwarder forwarder, CSharpDiagnosticService diagnostics) | ||
{ | ||
_forwarder = forwarder; | ||
_workspace = workspace; | ||
_diagnostics = diagnostics; | ||
} | ||
|
||
public Task<DiagnosticsResponse> Handle(DiagnosticsRequest request) | ||
{ | ||
if (!_forwarder.IsEnabled) | ||
{ | ||
_forwarder.IsEnabled = true; | ||
} | ||
|
||
var documents = request.FileName != null | ||
? new [] { request.FileName } | ||
: _workspace.CurrentSolution.Projects.SelectMany(project => project.Documents.Select(x => x.FilePath)); | ||
|
||
_diagnostics.QueueDiagnostics(documents.ToArray()); | ||
|
||
return Task.FromResult(new DiagnosticsResponse()); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/OmniSharp.Roslyn.CSharp/Services/Files/FileCloseService.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,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Composition; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis; | ||
using OmniSharp.Mef; | ||
using OmniSharp.Models; | ||
|
||
namespace OmniSharp.Roslyn.CSharp.Services.Files | ||
{ | ||
[OmniSharpHandler(OmnisharpEndpoints.Close, LanguageNames.CSharp)] | ||
public class FileCloseService : RequestHandler<FileCloseRequest, FileCloseResponse> | ||
{ | ||
private readonly OmnisharpWorkspace _workspace; | ||
|
||
[ImportingConstructor] | ||
public FileCloseService(OmnisharpWorkspace workspace) | ||
{ | ||
_workspace = workspace; | ||
} | ||
|
||
public Task<FileCloseResponse> Handle(FileCloseRequest request) | ||
{ | ||
var documents = _workspace.GetDocuments(request.FileName); | ||
foreach (var document in documents) | ||
{ | ||
_workspace.CloseDocument(document.Id); | ||
} | ||
return Task.FromResult(new FileCloseResponse()); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/OmniSharp.Roslyn.CSharp/Services/Files/FileOpenService.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,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Composition; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis; | ||
using OmniSharp.Mef; | ||
using OmniSharp.Models; | ||
|
||
namespace OmniSharp.Roslyn.CSharp.Services.Files | ||
{ | ||
[OmniSharpHandler(OmnisharpEndpoints.Open, LanguageNames.CSharp)] | ||
public class FileOpenService : RequestHandler<FileOpenRequest, FileOpenResponse> | ||
{ | ||
private readonly OmnisharpWorkspace _workspace; | ||
|
||
[ImportingConstructor] | ||
public FileOpenService(OmnisharpWorkspace workspace) | ||
{ | ||
_workspace = workspace; | ||
} | ||
|
||
public Task<FileOpenResponse> Handle(FileOpenRequest request) | ||
{ | ||
var documents = _workspace.GetDocuments(request.FileName); | ||
foreach (var document in documents) | ||
{ | ||
_workspace.OpenDocument(document.Id, false); | ||
} | ||
return Task.FromResult(new FileOpenResponse()); | ||
} | ||
} | ||
} |
Oops, something went wrong.