-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
360 additions
and
67 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
33 changes: 33 additions & 0 deletions
33
MirrorSharp.Common/Internal/Commands/ApplyDiagnosticActionHandler.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.Collections.Immutable; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace MirrorSharp.Internal.Commands { | ||
public class ApplyDiagnosticActionHandler : ICommandHandler { | ||
public IImmutableList<char> CommandIds { get; } = ImmutableList.Create('F'); | ||
|
||
public async Task ExecuteAsync(ArraySegment<byte> data, WorkSession session, ICommandResultSender sender, CancellationToken cancellationToken) { | ||
var actionId = FastConvert.Utf8ByteArrayToInt32(data); | ||
var action = session.CurrentCodeActions[actionId]; | ||
var operations = await action.GetOperationsAsync(cancellationToken).ConfigureAwait(false); | ||
foreach (var operation in operations) { | ||
operation.Apply(session.Workspace, cancellationToken); | ||
} | ||
var changes = await session.UpdateFromWorkspaceAsync().ConfigureAwait(false); | ||
|
||
var writer = sender.StartJsonMessage("changes"); | ||
writer.WriteProperty("echo", false); | ||
writer.WritePropertyStartArray("changes"); | ||
foreach (var change in changes) { | ||
writer.WriteChange(change); | ||
} | ||
writer.WriteEndArray(); | ||
await sender.SendJsonMessageAsync(cancellationToken).ConfigureAwait(false); | ||
} | ||
|
||
public bool CanChangeSession => false; | ||
} | ||
} |
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,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using Microsoft.CodeAnalysis.CodeActions; | ||
using AshMind.Extensions; | ||
|
||
namespace MirrorSharp.Internal { | ||
public static class RoslynInternals { | ||
private static readonly Func<CodeAction, bool> _getIsInvokable = | ||
typeof(CodeAction).GetTypeInfo() | ||
.GetProperty("IsInvokable", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance) | ||
.GetMethod.CreateDelegate<Func<CodeAction, bool>>(); | ||
|
||
public static bool GetIsInvokable(CodeAction action) => _getIsInvokable(action); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.