From 3260c145af4b63071ee0460707bc4e942cb2dae8 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 12:45:23 -0700 Subject: [PATCH 01/15] Move all events to OmniSharp.Models.Events namespace --- .../Extensions/IEventEmitterExtensions.cs | 2 +- src/OmniSharp.Abstractions/Models/Events/EventTypes.cs | 2 +- src/OmniSharp.Abstractions/Models/Events/PackageDependency.cs | 2 +- .../Models/Events/PackageRestoreMessage.cs | 2 +- .../Models/Events/UnresolvedDependenciesMessage.cs | 2 +- src/OmniSharp.Abstractions/Services/DiagnosticEventForwarder.cs | 2 +- src/OmniSharp.DotNet/Cache/ProjectStatesCache.cs | 2 +- src/OmniSharp.DotNet/DotNetProjectSystem.cs | 2 +- src/OmniSharp.Roslyn/ProjectEventForwarder.cs | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/OmniSharp.Abstractions/Extensions/IEventEmitterExtensions.cs b/src/OmniSharp.Abstractions/Extensions/IEventEmitterExtensions.cs index ea992c36fe..b1c094aa24 100644 --- a/src/OmniSharp.Abstractions/Extensions/IEventEmitterExtensions.cs +++ b/src/OmniSharp.Abstractions/Extensions/IEventEmitterExtensions.cs @@ -1,4 +1,4 @@ -using OmniSharp.Models; +using OmniSharp.Models.Events; namespace OmniSharp.Services { diff --git a/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs b/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs index 48dcecf78f..ea6a5a214b 100644 --- a/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs +++ b/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs @@ -1,4 +1,4 @@ -namespace OmniSharp.Models +namespace OmniSharp.Models.Events { public static class EventTypes { diff --git a/src/OmniSharp.Abstractions/Models/Events/PackageDependency.cs b/src/OmniSharp.Abstractions/Models/Events/PackageDependency.cs index e5e646567a..a4885e31b3 100644 --- a/src/OmniSharp.Abstractions/Models/Events/PackageDependency.cs +++ b/src/OmniSharp.Abstractions/Models/Events/PackageDependency.cs @@ -1,4 +1,4 @@ -namespace OmniSharp.Models +namespace OmniSharp.Models.Events { public class PackageDependency { diff --git a/src/OmniSharp.Abstractions/Models/Events/PackageRestoreMessage.cs b/src/OmniSharp.Abstractions/Models/Events/PackageRestoreMessage.cs index c9234325fc..32a52b9bca 100644 --- a/src/OmniSharp.Abstractions/Models/Events/PackageRestoreMessage.cs +++ b/src/OmniSharp.Abstractions/Models/Events/PackageRestoreMessage.cs @@ -1,4 +1,4 @@ -namespace OmniSharp.Models +namespace OmniSharp.Models.Events { public class PackageRestoreMessage { diff --git a/src/OmniSharp.Abstractions/Models/Events/UnresolvedDependenciesMessage.cs b/src/OmniSharp.Abstractions/Models/Events/UnresolvedDependenciesMessage.cs index 8bbe43edd0..ca88210c38 100644 --- a/src/OmniSharp.Abstractions/Models/Events/UnresolvedDependenciesMessage.cs +++ b/src/OmniSharp.Abstractions/Models/Events/UnresolvedDependenciesMessage.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace OmniSharp.Models +namespace OmniSharp.Models.Events { public class UnresolvedDependenciesMessage { diff --git a/src/OmniSharp.Abstractions/Services/DiagnosticEventForwarder.cs b/src/OmniSharp.Abstractions/Services/DiagnosticEventForwarder.cs index 94330b0f53..d96378cb0b 100644 --- a/src/OmniSharp.Abstractions/Services/DiagnosticEventForwarder.cs +++ b/src/OmniSharp.Abstractions/Services/DiagnosticEventForwarder.cs @@ -1,6 +1,6 @@ using System.Composition; -using OmniSharp.Models; using OmniSharp.Models.Diagnostics; +using OmniSharp.Models.Events; namespace OmniSharp.Services { diff --git a/src/OmniSharp.DotNet/Cache/ProjectStatesCache.cs b/src/OmniSharp.DotNet/Cache/ProjectStatesCache.cs index cc446d8f4e..b327a529ad 100644 --- a/src/OmniSharp.DotNet/Cache/ProjectStatesCache.cs +++ b/src/OmniSharp.DotNet/Cache/ProjectStatesCache.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Logging; using NuGet.Frameworks; using OmniSharp.DotNet.Models; -using OmniSharp.Models; +using OmniSharp.Models.Events; using OmniSharp.Models.ProjectInformation; using OmniSharp.Services; diff --git a/src/OmniSharp.DotNet/DotNetProjectSystem.cs b/src/OmniSharp.DotNet/DotNetProjectSystem.cs index 2eb51d356e..e7d347b533 100644 --- a/src/OmniSharp.DotNet/DotNetProjectSystem.cs +++ b/src/OmniSharp.DotNet/DotNetProjectSystem.cs @@ -14,7 +14,7 @@ using OmniSharp.DotNet.Extensions; using OmniSharp.DotNet.Models; using OmniSharp.DotNet.Tools; -using OmniSharp.Models; +using OmniSharp.Models.Events; using OmniSharp.Models.WorkspaceInformation; using OmniSharp.Services; using OmniSharp.Services.FileWatching; diff --git a/src/OmniSharp.Roslyn/ProjectEventForwarder.cs b/src/OmniSharp.Roslyn/ProjectEventForwarder.cs index f2d93a59c3..563104e6b7 100644 --- a/src/OmniSharp.Roslyn/ProjectEventForwarder.cs +++ b/src/OmniSharp.Roslyn/ProjectEventForwarder.cs @@ -2,7 +2,7 @@ using System.Composition; using System.Threading.Tasks; using Microsoft.CodeAnalysis; -using OmniSharp.Models; +using OmniSharp.Models.Events; using OmniSharp.Models.ProjectInformation; using OmniSharp.Services; From 842cbe094228801ee46f5a48f1a91f2e0f182873 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 12:59:01 -0700 Subject: [PATCH 02/15] Move IEventEmitter to OmniSharp.Eventing namespace and move IEventEmitter implementations into OmniSharp.Host --- .../{Services => Eventing}/IEventEmitter.cs | 2 +- .../{Extensions => Eventing}/IEventEmitterExtensions.cs | 2 +- src/OmniSharp.Abstractions/Services/DotNetCliService.cs | 1 + src/OmniSharp.DotNet/Cache/ProjectStatesCache.cs | 2 +- src/OmniSharp.DotNet/DotNetProjectSystem.cs | 1 + src/OmniSharp.DotNetTest/Legacy/LegacyTestManager.cs | 1 + src/OmniSharp.DotNetTest/Services/BaseTestService.cs | 1 + src/OmniSharp.DotNetTest/Services/BaseTestService`2.cs | 1 + src/OmniSharp.DotNetTest/Services/DebugTestService.cs | 1 + src/OmniSharp.DotNetTest/Services/GetTestStartInfoService.cs | 1 + src/OmniSharp.DotNetTest/Services/RunTestService.cs | 1 + src/OmniSharp.DotNetTest/TestManager.cs | 1 + src/OmniSharp.DotNetTest/VSTestManager.cs | 1 + .../Services => OmniSharp.Host/Eventing}/NullEventEmitter.cs | 4 ++-- .../Services => OmniSharp.Host/Eventing}/StdioEventEmitter.cs | 4 ++-- src/OmniSharp.Host/Startup.cs | 1 + src/OmniSharp.MSBuild/MSBuildProjectSystem.cs | 1 + .../Services/Diagnostics/DiagnosticsService.cs | 1 - .../Workers/Diagnostics/CSharpDiagnosticService.cs | 2 +- .../Services => OmniSharp.Roslyn}/DiagnosticEventForwarder.cs | 3 ++- src/OmniSharp.Roslyn/ProjectEventForwarder.cs | 1 + .../DiagnosticsV2Facts.DiagnosticTestEmitter.cs | 2 +- 22 files changed, 24 insertions(+), 11 deletions(-) rename src/OmniSharp.Abstractions/{Services => Eventing}/IEventEmitter.cs (76%) rename src/OmniSharp.Abstractions/{Extensions => Eventing}/IEventEmitterExtensions.cs (96%) rename src/{OmniSharp.Abstractions/Services => OmniSharp.Host/Eventing}/NullEventEmitter.cs (73%) rename src/{OmniSharp.Abstractions/Services => OmniSharp.Host/Eventing}/StdioEventEmitter.cs (85%) rename src/{OmniSharp.Abstractions/Services => OmniSharp.Roslyn}/DiagnosticEventForwarder.cs (91%) diff --git a/src/OmniSharp.Abstractions/Services/IEventEmitter.cs b/src/OmniSharp.Abstractions/Eventing/IEventEmitter.cs similarity index 76% rename from src/OmniSharp.Abstractions/Services/IEventEmitter.cs rename to src/OmniSharp.Abstractions/Eventing/IEventEmitter.cs index b540307103..048b6f8a35 100644 --- a/src/OmniSharp.Abstractions/Services/IEventEmitter.cs +++ b/src/OmniSharp.Abstractions/Eventing/IEventEmitter.cs @@ -1,4 +1,4 @@ -namespace OmniSharp.Services +namespace OmniSharp.Eventing { public interface IEventEmitter { diff --git a/src/OmniSharp.Abstractions/Extensions/IEventEmitterExtensions.cs b/src/OmniSharp.Abstractions/Eventing/IEventEmitterExtensions.cs similarity index 96% rename from src/OmniSharp.Abstractions/Extensions/IEventEmitterExtensions.cs rename to src/OmniSharp.Abstractions/Eventing/IEventEmitterExtensions.cs index b1c094aa24..6caa72190f 100644 --- a/src/OmniSharp.Abstractions/Extensions/IEventEmitterExtensions.cs +++ b/src/OmniSharp.Abstractions/Eventing/IEventEmitterExtensions.cs @@ -1,6 +1,6 @@ using OmniSharp.Models.Events; -namespace OmniSharp.Services +namespace OmniSharp.Eventing { public static class IEventEmitterExtensions { diff --git a/src/OmniSharp.Abstractions/Services/DotNetCliService.cs b/src/OmniSharp.Abstractions/Services/DotNetCliService.cs index 20bbd1fb7f..0a7a923f11 100644 --- a/src/OmniSharp.Abstractions/Services/DotNetCliService.cs +++ b/src/OmniSharp.Abstractions/Services/DotNetCliService.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using NuGet.Versioning; +using OmniSharp.Eventing; using OmniSharp.Utilities; namespace OmniSharp.Services diff --git a/src/OmniSharp.DotNet/Cache/ProjectStatesCache.cs b/src/OmniSharp.DotNet/Cache/ProjectStatesCache.cs index b327a529ad..aa7442911c 100644 --- a/src/OmniSharp.DotNet/Cache/ProjectStatesCache.cs +++ b/src/OmniSharp.DotNet/Cache/ProjectStatesCache.cs @@ -6,9 +6,9 @@ using Microsoft.Extensions.Logging; using NuGet.Frameworks; using OmniSharp.DotNet.Models; +using OmniSharp.Eventing; using OmniSharp.Models.Events; using OmniSharp.Models.ProjectInformation; -using OmniSharp.Services; namespace OmniSharp.DotNet.Cache { diff --git a/src/OmniSharp.DotNet/DotNetProjectSystem.cs b/src/OmniSharp.DotNet/DotNetProjectSystem.cs index e7d347b533..5aad34738e 100644 --- a/src/OmniSharp.DotNet/DotNetProjectSystem.cs +++ b/src/OmniSharp.DotNet/DotNetProjectSystem.cs @@ -14,6 +14,7 @@ using OmniSharp.DotNet.Extensions; using OmniSharp.DotNet.Models; using OmniSharp.DotNet.Tools; +using OmniSharp.Eventing; using OmniSharp.Models.Events; using OmniSharp.Models.WorkspaceInformation; using OmniSharp.Services; diff --git a/src/OmniSharp.DotNetTest/Legacy/LegacyTestManager.cs b/src/OmniSharp.DotNetTest/Legacy/LegacyTestManager.cs index f2cc8f4f1b..f54fd1c5d0 100644 --- a/src/OmniSharp.DotNetTest/Legacy/LegacyTestManager.cs +++ b/src/OmniSharp.DotNetTest/Legacy/LegacyTestManager.cs @@ -10,6 +10,7 @@ using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; using OmniSharp.DotNetTest.Models; using OmniSharp.DotNetTest.TestFrameworks; +using OmniSharp.Eventing; using OmniSharp.Models; using OmniSharp.Models.Events; using OmniSharp.Services; diff --git a/src/OmniSharp.DotNetTest/Services/BaseTestService.cs b/src/OmniSharp.DotNetTest/Services/BaseTestService.cs index 4da7b32e87..3faa20207c 100644 --- a/src/OmniSharp.DotNetTest/Services/BaseTestService.cs +++ b/src/OmniSharp.DotNetTest/Services/BaseTestService.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using OmniSharp.Eventing; using OmniSharp.Services; namespace OmniSharp.DotNetTest.Services diff --git a/src/OmniSharp.DotNetTest/Services/BaseTestService`2.cs b/src/OmniSharp.DotNetTest/Services/BaseTestService`2.cs index 0f01526abb..e4f48fe304 100644 --- a/src/OmniSharp.DotNetTest/Services/BaseTestService`2.cs +++ b/src/OmniSharp.DotNetTest/Services/BaseTestService`2.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.Extensions.Logging; +using OmniSharp.Eventing; using OmniSharp.Mef; using OmniSharp.Models; using OmniSharp.Services; diff --git a/src/OmniSharp.DotNetTest/Services/DebugTestService.cs b/src/OmniSharp.DotNetTest/Services/DebugTestService.cs index bdfb2be976..69c186c770 100644 --- a/src/OmniSharp.DotNetTest/Services/DebugTestService.cs +++ b/src/OmniSharp.DotNetTest/Services/DebugTestService.cs @@ -4,6 +4,7 @@ using Microsoft.CodeAnalysis; using Microsoft.Extensions.Logging; using OmniSharp.DotNetTest.Models; +using OmniSharp.Eventing; using OmniSharp.Mef; using OmniSharp.Services; diff --git a/src/OmniSharp.DotNetTest/Services/GetTestStartInfoService.cs b/src/OmniSharp.DotNetTest/Services/GetTestStartInfoService.cs index 37a2032df2..c9065f6a20 100644 --- a/src/OmniSharp.DotNetTest/Services/GetTestStartInfoService.cs +++ b/src/OmniSharp.DotNetTest/Services/GetTestStartInfoService.cs @@ -2,6 +2,7 @@ using Microsoft.CodeAnalysis; using Microsoft.Extensions.Logging; using OmniSharp.DotNetTest.Models; +using OmniSharp.Eventing; using OmniSharp.Mef; using OmniSharp.Services; diff --git a/src/OmniSharp.DotNetTest/Services/RunTestService.cs b/src/OmniSharp.DotNetTest/Services/RunTestService.cs index 58f5fdb8c2..6cafbd2a43 100644 --- a/src/OmniSharp.DotNetTest/Services/RunTestService.cs +++ b/src/OmniSharp.DotNetTest/Services/RunTestService.cs @@ -2,6 +2,7 @@ using Microsoft.CodeAnalysis; using Microsoft.Extensions.Logging; using OmniSharp.DotNetTest.Models; +using OmniSharp.Eventing; using OmniSharp.Mef; using OmniSharp.Services; diff --git a/src/OmniSharp.DotNetTest/TestManager.cs b/src/OmniSharp.DotNetTest/TestManager.cs index 6287471df4..63960cfb28 100644 --- a/src/OmniSharp.DotNetTest/TestManager.cs +++ b/src/OmniSharp.DotNetTest/TestManager.cs @@ -12,6 +12,7 @@ using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; using OmniSharp.DotNetTest.Legacy; using OmniSharp.DotNetTest.Models; +using OmniSharp.Eventing; using OmniSharp.Services; using OmniSharp.Utilities; diff --git a/src/OmniSharp.DotNetTest/VSTestManager.cs b/src/OmniSharp.DotNetTest/VSTestManager.cs index a9a4f89771..d3212d6aeb 100644 --- a/src/OmniSharp.DotNetTest/VSTestManager.cs +++ b/src/OmniSharp.DotNetTest/VSTestManager.cs @@ -12,6 +12,7 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using OmniSharp.DotNetTest.Models; using OmniSharp.DotNetTest.TestFrameworks; +using OmniSharp.Eventing; using OmniSharp.Models; using OmniSharp.Models.Events; using OmniSharp.Services; diff --git a/src/OmniSharp.Abstractions/Services/NullEventEmitter.cs b/src/OmniSharp.Host/Eventing/NullEventEmitter.cs similarity index 73% rename from src/OmniSharp.Abstractions/Services/NullEventEmitter.cs rename to src/OmniSharp.Host/Eventing/NullEventEmitter.cs index 476a333b56..18b8ed6340 100644 --- a/src/OmniSharp.Abstractions/Services/NullEventEmitter.cs +++ b/src/OmniSharp.Host/Eventing/NullEventEmitter.cs @@ -1,6 +1,6 @@ -namespace OmniSharp.Services +namespace OmniSharp.Eventing { - public class NullEventEmitter : IEventEmitter + internal class NullEventEmitter : IEventEmitter { public static IEventEmitter Instance { get; } = new NullEventEmitter(); diff --git a/src/OmniSharp.Abstractions/Services/StdioEventEmitter.cs b/src/OmniSharp.Host/Eventing/StdioEventEmitter.cs similarity index 85% rename from src/OmniSharp.Abstractions/Services/StdioEventEmitter.cs rename to src/OmniSharp.Host/Eventing/StdioEventEmitter.cs index 1b0bbd3d53..adcc84a31e 100644 --- a/src/OmniSharp.Abstractions/Services/StdioEventEmitter.cs +++ b/src/OmniSharp.Host/Eventing/StdioEventEmitter.cs @@ -1,9 +1,9 @@ using OmniSharp.Stdio.Protocol; using OmniSharp.Stdio.Services; -namespace OmniSharp.Services +namespace OmniSharp.Eventing { - public class StdioEventEmitter : IEventEmitter + internal class StdioEventEmitter : IEventEmitter { private readonly ISharedTextWriter _writer; diff --git a/src/OmniSharp.Host/Startup.cs b/src/OmniSharp.Host/Startup.cs index ce4937e45b..86c9053365 100644 --- a/src/OmniSharp.Host/Startup.cs +++ b/src/OmniSharp.Host/Startup.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using OmniSharp.Eventing; using OmniSharp.Host.Internal; using OmniSharp.Mef; using OmniSharp.Middleware; diff --git a/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs b/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs index db44af0c8e..f9e710c0d5 100644 --- a/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs +++ b/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs @@ -11,6 +11,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using NuGet.ProjectModel; +using OmniSharp.Eventing; using OmniSharp.Models; using OmniSharp.Models.Events; using OmniSharp.Models.WorkspaceInformation; diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Diagnostics/DiagnosticsService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Diagnostics/DiagnosticsService.cs index 14799c42bb..9ed6cda2f6 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Diagnostics/DiagnosticsService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Diagnostics/DiagnosticsService.cs @@ -4,7 +4,6 @@ using Microsoft.CodeAnalysis; using OmniSharp.Mef; using OmniSharp.Models.Diagnostics; -using OmniSharp.Services; using OmniSharp.Workers.Diagnostics; namespace OmniSharp.Roslyn.CSharp.Services.Diagnostics diff --git a/src/OmniSharp.Roslyn.CSharp/Workers/Diagnostics/CSharpDiagnosticService.cs b/src/OmniSharp.Roslyn.CSharp/Workers/Diagnostics/CSharpDiagnosticService.cs index b7ff48046d..3ff8e77a74 100644 --- a/src/OmniSharp.Roslyn.CSharp/Workers/Diagnostics/CSharpDiagnosticService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Workers/Diagnostics/CSharpDiagnosticService.cs @@ -6,7 +6,7 @@ using Microsoft.CodeAnalysis; using Microsoft.Extensions.Logging; using OmniSharp.Models.Diagnostics; -using OmniSharp.Services; +using OmniSharp.Roslyn; namespace OmniSharp.Workers.Diagnostics { diff --git a/src/OmniSharp.Abstractions/Services/DiagnosticEventForwarder.cs b/src/OmniSharp.Roslyn/DiagnosticEventForwarder.cs similarity index 91% rename from src/OmniSharp.Abstractions/Services/DiagnosticEventForwarder.cs rename to src/OmniSharp.Roslyn/DiagnosticEventForwarder.cs index d96378cb0b..9c5b45ec61 100644 --- a/src/OmniSharp.Abstractions/Services/DiagnosticEventForwarder.cs +++ b/src/OmniSharp.Roslyn/DiagnosticEventForwarder.cs @@ -1,8 +1,9 @@ using System.Composition; +using OmniSharp.Eventing; using OmniSharp.Models.Diagnostics; using OmniSharp.Models.Events; -namespace OmniSharp.Services +namespace OmniSharp.Roslyn { [Export, Shared] public class DiagnosticEventForwarder diff --git a/src/OmniSharp.Roslyn/ProjectEventForwarder.cs b/src/OmniSharp.Roslyn/ProjectEventForwarder.cs index 563104e6b7..b847446b57 100644 --- a/src/OmniSharp.Roslyn/ProjectEventForwarder.cs +++ b/src/OmniSharp.Roslyn/ProjectEventForwarder.cs @@ -2,6 +2,7 @@ using System.Composition; using System.Threading.Tasks; using Microsoft.CodeAnalysis; +using OmniSharp.Eventing; using OmniSharp.Models.Events; using OmniSharp.Models.ProjectInformation; using OmniSharp.Services; diff --git a/tests/OmniSharp.Roslyn.CSharp.Tests/DiagnosticsV2Facts.DiagnosticTestEmitter.cs b/tests/OmniSharp.Roslyn.CSharp.Tests/DiagnosticsV2Facts.DiagnosticTestEmitter.cs index 55f9bca63a..456a4b3a00 100644 --- a/tests/OmniSharp.Roslyn.CSharp.Tests/DiagnosticsV2Facts.DiagnosticTestEmitter.cs +++ b/tests/OmniSharp.Roslyn.CSharp.Tests/DiagnosticsV2Facts.DiagnosticTestEmitter.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; +using OmniSharp.Eventing; using OmniSharp.Models.Diagnostics; -using OmniSharp.Services; namespace OmniSharp.Roslyn.CSharp.Tests { From fdcea5f80c96205c75a3ab4852353b22699bf81f Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 13:02:43 -0700 Subject: [PATCH 03/15] Move TestMessageEvent to OmniSharp.DotNetTest --- src/OmniSharp.Abstractions/Models/Events/EventTypes.cs | 1 - src/OmniSharp.DotNetTest/Legacy/LegacyTestManager.cs | 5 ++--- .../Models/Events/TestMessageEvent.cs | 4 +++- src/OmniSharp.DotNetTest/VSTestManager.cs | 7 +++---- 4 files changed, 8 insertions(+), 9 deletions(-) rename src/{OmniSharp.Abstractions => OmniSharp.DotNetTest}/Models/Events/TestMessageEvent.cs (59%) diff --git a/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs b/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs index ea6a5a214b..d189e888b2 100644 --- a/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs +++ b/src/OmniSharp.Abstractions/Models/Events/EventTypes.cs @@ -10,7 +10,6 @@ public static class EventTypes public static readonly string MsBuildProjectDiagnostics = nameof(MsBuildProjectDiagnostics); public static readonly string PackageRestoreStarted = nameof(PackageRestoreStarted); public static readonly string PackageRestoreFinished = nameof(PackageRestoreFinished); - public static readonly string TestMessage = nameof(TestMessage); public static readonly string UnresolvedDependencies = nameof(UnresolvedDependencies); } } \ No newline at end of file diff --git a/src/OmniSharp.DotNetTest/Legacy/LegacyTestManager.cs b/src/OmniSharp.DotNetTest/Legacy/LegacyTestManager.cs index f54fd1c5d0..3b24aa25e9 100644 --- a/src/OmniSharp.DotNetTest/Legacy/LegacyTestManager.cs +++ b/src/OmniSharp.DotNetTest/Legacy/LegacyTestManager.cs @@ -9,10 +9,9 @@ using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel; using OmniSharp.DotNetTest.Models; +using OmniSharp.DotNetTest.Models.Events; using OmniSharp.DotNetTest.TestFrameworks; using OmniSharp.Eventing; -using OmniSharp.Models; -using OmniSharp.Models.Events; using OmniSharp.Services; using OmniSharp.Utilities; @@ -85,7 +84,7 @@ public override RunTestResponse RunTest(string methodName, string testFrameworkN testProcess.OutputDataReceived += (_, e) => { - EventEmitter.Emit(EventTypes.TestMessage, + EventEmitter.Emit(TestMessageEvent.Id, new TestMessageEvent { MessageLevel = "info", diff --git a/src/OmniSharp.Abstractions/Models/Events/TestMessageEvent.cs b/src/OmniSharp.DotNetTest/Models/Events/TestMessageEvent.cs similarity index 59% rename from src/OmniSharp.Abstractions/Models/Events/TestMessageEvent.cs rename to src/OmniSharp.DotNetTest/Models/Events/TestMessageEvent.cs index bd0a4952eb..39bf136e8a 100644 --- a/src/OmniSharp.Abstractions/Models/Events/TestMessageEvent.cs +++ b/src/OmniSharp.DotNetTest/Models/Events/TestMessageEvent.cs @@ -1,7 +1,9 @@ -namespace OmniSharp.Models.Events +namespace OmniSharp.DotNetTest.Models.Events { public class TestMessageEvent { + public const string Id = "TestMessage"; + public string MessageLevel { get; set; } public string Message { get; set; } } diff --git a/src/OmniSharp.DotNetTest/VSTestManager.cs b/src/OmniSharp.DotNetTest/VSTestManager.cs index d3212d6aeb..d7ca460e54 100644 --- a/src/OmniSharp.DotNetTest/VSTestManager.cs +++ b/src/OmniSharp.DotNetTest/VSTestManager.cs @@ -11,10 +11,9 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using OmniSharp.DotNetTest.Models; +using OmniSharp.DotNetTest.Models.Events; using OmniSharp.DotNetTest.TestFrameworks; using OmniSharp.Eventing; -using OmniSharp.Models; -using OmniSharp.Models.Events; using OmniSharp.Services; namespace OmniSharp.DotNetTest @@ -133,7 +132,7 @@ public override async Task DebugLaunchAsync(CancellationToken cancellationToken) { case MessageType.TestMessage: var testMessage = message.DeserializePayload(); - EventEmitter.Emit(EventTypes.TestMessage, + EventEmitter.Emit(TestMessageEvent.Id, new TestMessageEvent { MessageLevel = testMessage.MessageLevel.ToString().ToLowerInvariant(), @@ -176,7 +175,7 @@ public override RunTestResponse RunTest(string methodName, string testFrameworkN { case MessageType.TestMessage: var testMessage = message.DeserializePayload(); - EventEmitter.Emit(EventTypes.TestMessage, + EventEmitter.Emit(TestMessageEvent.Id, new TestMessageEvent { MessageLevel = testMessage.MessageLevel.ToString().ToLowerInvariant(), From 247a528e2f3e7af0a2fb7cf621d5a2f8c1a5ac6e Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 13:11:45 -0700 Subject: [PATCH 04/15] Move ISymbolExtensions to OmniSharp.Roslyn --- src/OmniSharp.DotNetTest/TestFeaturesDiscover.cs | 2 +- .../Utilities}/ISymbolExtensions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{OmniSharp.Abstractions/Extensions => OmniSharp.Roslyn/Utilities}/ISymbolExtensions.cs (98%) diff --git a/src/OmniSharp.DotNetTest/TestFeaturesDiscover.cs b/src/OmniSharp.DotNetTest/TestFeaturesDiscover.cs index 83900b48e6..0c5d2393e7 100644 --- a/src/OmniSharp.DotNetTest/TestFeaturesDiscover.cs +++ b/src/OmniSharp.DotNetTest/TestFeaturesDiscover.cs @@ -4,8 +4,8 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using OmniSharp.Abstractions.Services; using OmniSharp.DotNetTest.TestFrameworks; -using OmniSharp.Extensions; using OmniSharp.Models; +using OmniSharp.Roslyn.Utilities; namespace OmniSharp.DotNetTest { diff --git a/src/OmniSharp.Abstractions/Extensions/ISymbolExtensions.cs b/src/OmniSharp.Roslyn/Utilities/ISymbolExtensions.cs similarity index 98% rename from src/OmniSharp.Abstractions/Extensions/ISymbolExtensions.cs rename to src/OmniSharp.Roslyn/Utilities/ISymbolExtensions.cs index 17d1091567..38577b5efb 100644 --- a/src/OmniSharp.Abstractions/Extensions/ISymbolExtensions.cs +++ b/src/OmniSharp.Roslyn/Utilities/ISymbolExtensions.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; using OmniSharp.Utilities; -namespace OmniSharp.Extensions +namespace OmniSharp.Roslyn.Utilities { public static class ISymbolExtensions { From 583c840806803baacdb3ff218631cad8c87b0668 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 13:14:44 -0700 Subject: [PATCH 05/15] Move LoggerExtensions --- .../LoggerExceptions.cs => Logging/LoggerExtensions.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/OmniSharp.Abstractions/{Extensions/LoggerExceptions.cs => Logging/LoggerExtensions.cs} (100%) diff --git a/src/OmniSharp.Abstractions/Extensions/LoggerExceptions.cs b/src/OmniSharp.Abstractions/Logging/LoggerExtensions.cs similarity index 100% rename from src/OmniSharp.Abstractions/Extensions/LoggerExceptions.cs rename to src/OmniSharp.Abstractions/Logging/LoggerExtensions.cs From 59b5a53586ed5dbe4f56c53413c5ad5e39509abd Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 13:27:08 -0700 Subject: [PATCH 06/15] Move file watching types to OmniSharp.FileWatching namespace and move implementations to OmniSharp.Host --- .../FileWatching/IFileSystemWatcher.cs | 2 +- src/OmniSharp.DotNet/DotNetProjectSystem.cs | 2 +- .../FileWatching/FileSystemWatcherWrapper.cs | 13 +++++++++---- .../FileWatching/ManualFileSystemWatcher.cs | 2 +- src/OmniSharp.Host/Startup.cs | 2 +- src/OmniSharp.MSBuild/MSBuildProjectSystem.cs | 2 +- .../Services/Files/OnFilesChangedService.cs | 2 +- 7 files changed, 15 insertions(+), 10 deletions(-) rename src/OmniSharp.Abstractions/{Services => }/FileWatching/IFileSystemWatcher.cs (83%) rename src/{OmniSharp.Abstractions/Services => OmniSharp.Host}/FileWatching/FileSystemWatcherWrapper.cs (87%) rename src/{OmniSharp.Abstractions/Services => OmniSharp.Host}/FileWatching/ManualFileSystemWatcher.cs (93%) diff --git a/src/OmniSharp.Abstractions/Services/FileWatching/IFileSystemWatcher.cs b/src/OmniSharp.Abstractions/FileWatching/IFileSystemWatcher.cs similarity index 83% rename from src/OmniSharp.Abstractions/Services/FileWatching/IFileSystemWatcher.cs rename to src/OmniSharp.Abstractions/FileWatching/IFileSystemWatcher.cs index ee19ce3188..38ee979c99 100644 --- a/src/OmniSharp.Abstractions/Services/FileWatching/IFileSystemWatcher.cs +++ b/src/OmniSharp.Abstractions/FileWatching/IFileSystemWatcher.cs @@ -1,6 +1,6 @@ using System; -namespace OmniSharp.Services.FileWatching +namespace OmniSharp.FileWatching { // TODO: Flesh out this API more public interface IFileSystemWatcher diff --git a/src/OmniSharp.DotNet/DotNetProjectSystem.cs b/src/OmniSharp.DotNet/DotNetProjectSystem.cs index 5aad34738e..34333ae9bd 100644 --- a/src/OmniSharp.DotNet/DotNetProjectSystem.cs +++ b/src/OmniSharp.DotNet/DotNetProjectSystem.cs @@ -15,10 +15,10 @@ using OmniSharp.DotNet.Models; using OmniSharp.DotNet.Tools; using OmniSharp.Eventing; +using OmniSharp.FileWatching; using OmniSharp.Models.Events; using OmniSharp.Models.WorkspaceInformation; using OmniSharp.Services; -using OmniSharp.Services.FileWatching; namespace OmniSharp.DotNet { diff --git a/src/OmniSharp.Abstractions/Services/FileWatching/FileSystemWatcherWrapper.cs b/src/OmniSharp.Host/FileWatching/FileSystemWatcherWrapper.cs similarity index 87% rename from src/OmniSharp.Abstractions/Services/FileWatching/FileSystemWatcherWrapper.cs rename to src/OmniSharp.Host/FileWatching/FileSystemWatcherWrapper.cs index 314e1dea3e..1b2789c1fb 100644 --- a/src/OmniSharp.Abstractions/Services/FileWatching/FileSystemWatcherWrapper.cs +++ b/src/OmniSharp.Host/FileWatching/FileSystemWatcherWrapper.cs @@ -1,8 +1,9 @@ using System; using System.Collections.Generic; using System.IO; +using OmniSharp.Services; -namespace OmniSharp.Services.FileWatching +namespace OmniSharp.FileWatching { public class FileSystemWatcherWrapper : IFileSystemWatcher { @@ -12,12 +13,16 @@ public class FileSystemWatcherWrapper : IFileSystemWatcher public FileSystemWatcherWrapper(IOmniSharpEnvironment env) { // Environment.SetEnvironmentVariable ("MONO_MANAGED_WATCHER", "1"); - _watcher = new FileSystemWatcher(env.TargetDirectory); - _watcher.IncludeSubdirectories = true; - _watcher.EnableRaisingEvents = true; + _watcher = new FileSystemWatcher(env.TargetDirectory) + { + IncludeSubdirectories = true, + EnableRaisingEvents = true, + }; + _watcher.Changed += OnChanged; _watcher.Created += OnChanged; _watcher.Deleted += OnChanged; + _watcher.Renamed += (sender, e) => { TriggerChange(e.OldFullPath); diff --git a/src/OmniSharp.Abstractions/Services/FileWatching/ManualFileSystemWatcher.cs b/src/OmniSharp.Host/FileWatching/ManualFileSystemWatcher.cs similarity index 93% rename from src/OmniSharp.Abstractions/Services/FileWatching/ManualFileSystemWatcher.cs rename to src/OmniSharp.Host/FileWatching/ManualFileSystemWatcher.cs index 5bcf970607..d487319ade 100644 --- a/src/OmniSharp.Abstractions/Services/FileWatching/ManualFileSystemWatcher.cs +++ b/src/OmniSharp.Host/FileWatching/ManualFileSystemWatcher.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace OmniSharp.Services.FileWatching +namespace OmniSharp.FileWatching { public class ManualFileSystemWatcher : IFileSystemWatcher { diff --git a/src/OmniSharp.Host/Startup.cs b/src/OmniSharp.Host/Startup.cs index 86c9053365..009513ad8e 100644 --- a/src/OmniSharp.Host/Startup.cs +++ b/src/OmniSharp.Host/Startup.cs @@ -13,13 +13,13 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using OmniSharp.Eventing; +using OmniSharp.FileWatching; using OmniSharp.Host.Internal; using OmniSharp.Mef; using OmniSharp.Middleware; using OmniSharp.Options; using OmniSharp.Roslyn; using OmniSharp.Services; -using OmniSharp.Services.FileWatching; using OmniSharp.Stdio.Logging; using OmniSharp.Stdio.Services; using OmniSharp.Utilities; diff --git a/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs b/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs index f9e710c0d5..65e3eb4bfd 100644 --- a/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs +++ b/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs @@ -12,13 +12,13 @@ using Microsoft.Extensions.Logging; using NuGet.ProjectModel; using OmniSharp.Eventing; +using OmniSharp.FileWatching; using OmniSharp.Models; using OmniSharp.Models.Events; using OmniSharp.Models.WorkspaceInformation; using OmniSharp.MSBuild.ProjectFile; using OmniSharp.Options; using OmniSharp.Services; -using OmniSharp.Services.FileWatching; namespace OmniSharp.MSBuild { diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Files/OnFilesChangedService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Files/OnFilesChangedService.cs index 8dacebdd2b..9a40de7748 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Files/OnFilesChangedService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Files/OnFilesChangedService.cs @@ -2,10 +2,10 @@ using System.Composition; using System.Threading.Tasks; using Microsoft.CodeAnalysis; +using OmniSharp.FileWatching; using OmniSharp.Mef; using OmniSharp.Models; using OmniSharp.Models.FilesChanged; -using OmniSharp.Services.FileWatching; namespace OmniSharp.Roslyn.CSharp.Services.Files { From 3b4d84c3a29d4bab5f2c6780a219bdadc97e6231 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 13:29:09 -0700 Subject: [PATCH 07/15] Move ZeroBasedIndexConverter to OmniSharp.Models --- src/OmniSharp.Abstractions/Models/Events/ErrorMessage.cs | 2 -- src/OmniSharp.Abstractions/Models/Request.cs | 1 - .../{Json => Models}/ZeroBasedIndexConverter.cs | 2 +- .../Models/v1/ChangeBuffer/ChangeBufferRequest.cs | 1 - .../Models/v1/CodeAction/CodeActionRequest.cs | 2 -- .../Models/v1/Format/FormatRangeRequest.cs | 1 - .../Models/v1/GotoDefinition/GotoDefinitionResponse.cs | 1 - .../Models/v1/Highlight/HighlightRequest.cs | 1 - src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightSpan.cs | 1 - .../Models/v1/LinePositionSpanTextChange.cs | 1 - .../Models/v1/Navigate/NavigateResponse.cs | 2 -- src/OmniSharp.Abstractions/Models/v1/QuickFix.cs | 1 - src/OmniSharp.Abstractions/Models/v2/ICodeActionRequest.cs | 1 - src/OmniSharp.Abstractions/Models/v2/Point.cs | 1 - 14 files changed, 1 insertion(+), 17 deletions(-) rename src/OmniSharp.Abstractions/{Json => Models}/ZeroBasedIndexConverter.cs (99%) diff --git a/src/OmniSharp.Abstractions/Models/Events/ErrorMessage.cs b/src/OmniSharp.Abstractions/Models/Events/ErrorMessage.cs index 6ed8f5ebfd..b1183cde47 100644 --- a/src/OmniSharp.Abstractions/Models/Events/ErrorMessage.cs +++ b/src/OmniSharp.Abstractions/Models/Events/ErrorMessage.cs @@ -1,6 +1,4 @@ using Newtonsoft.Json; -using OmniSharp.Json; - namespace OmniSharp.Models.Events { public class ErrorMessage diff --git a/src/OmniSharp.Abstractions/Models/Request.cs b/src/OmniSharp.Abstractions/Models/Request.cs index 0957c79fc2..b51a9dd982 100644 --- a/src/OmniSharp.Abstractions/Models/Request.cs +++ b/src/OmniSharp.Abstractions/Models/Request.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.IO; using Newtonsoft.Json; -using OmniSharp.Json; namespace OmniSharp.Models { diff --git a/src/OmniSharp.Abstractions/Json/ZeroBasedIndexConverter.cs b/src/OmniSharp.Abstractions/Models/ZeroBasedIndexConverter.cs similarity index 99% rename from src/OmniSharp.Abstractions/Json/ZeroBasedIndexConverter.cs rename to src/OmniSharp.Abstractions/Models/ZeroBasedIndexConverter.cs index 5a179a51aa..da1d16a0b5 100644 --- a/src/OmniSharp.Abstractions/Json/ZeroBasedIndexConverter.cs +++ b/src/OmniSharp.Abstractions/Models/ZeroBasedIndexConverter.cs @@ -3,7 +3,7 @@ using System.Linq; using Newtonsoft.Json; -namespace OmniSharp.Json +namespace OmniSharp.Models { public class ZeroBasedIndexConverter : JsonConverter { diff --git a/src/OmniSharp.Abstractions/Models/v1/ChangeBuffer/ChangeBufferRequest.cs b/src/OmniSharp.Abstractions/Models/v1/ChangeBuffer/ChangeBufferRequest.cs index f2b1f4d26f..16873a4f14 100644 --- a/src/OmniSharp.Abstractions/Models/v1/ChangeBuffer/ChangeBufferRequest.cs +++ b/src/OmniSharp.Abstractions/Models/v1/ChangeBuffer/ChangeBufferRequest.cs @@ -1,5 +1,4 @@ using Newtonsoft.Json; -using OmniSharp.Json; using OmniSharp.Mef; namespace OmniSharp.Models.ChangeBuffer diff --git a/src/OmniSharp.Abstractions/Models/v1/CodeAction/CodeActionRequest.cs b/src/OmniSharp.Abstractions/Models/v1/CodeAction/CodeActionRequest.cs index 89160134f9..107de6101c 100644 --- a/src/OmniSharp.Abstractions/Models/v1/CodeAction/CodeActionRequest.cs +++ b/src/OmniSharp.Abstractions/Models/v1/CodeAction/CodeActionRequest.cs @@ -1,6 +1,4 @@ using Newtonsoft.Json; -using OmniSharp.Json; - namespace OmniSharp.Models.CodeAction { public abstract class CodeActionRequest : Request diff --git a/src/OmniSharp.Abstractions/Models/v1/Format/FormatRangeRequest.cs b/src/OmniSharp.Abstractions/Models/v1/Format/FormatRangeRequest.cs index 2077dc62a1..eb7117cae4 100644 --- a/src/OmniSharp.Abstractions/Models/v1/Format/FormatRangeRequest.cs +++ b/src/OmniSharp.Abstractions/Models/v1/Format/FormatRangeRequest.cs @@ -1,5 +1,4 @@ using Newtonsoft.Json; -using OmniSharp.Json; using OmniSharp.Mef; namespace OmniSharp.Models.Format diff --git a/src/OmniSharp.Abstractions/Models/v1/GotoDefinition/GotoDefinitionResponse.cs b/src/OmniSharp.Abstractions/Models/v1/GotoDefinition/GotoDefinitionResponse.cs index 6a533d7f73..b9bfca5a0d 100644 --- a/src/OmniSharp.Abstractions/Models/v1/GotoDefinition/GotoDefinitionResponse.cs +++ b/src/OmniSharp.Abstractions/Models/v1/GotoDefinition/GotoDefinitionResponse.cs @@ -1,5 +1,4 @@ using Newtonsoft.Json; -using OmniSharp.Json; using OmniSharp.Models.Metadata; namespace OmniSharp.Models.GotoDefinition diff --git a/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightRequest.cs b/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightRequest.cs index 64b077552e..5d64273da1 100644 --- a/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightRequest.cs +++ b/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightRequest.cs @@ -1,5 +1,4 @@ using Newtonsoft.Json; -using OmniSharp.Json; using OmniSharp.Mef; namespace OmniSharp.Models.Highlight diff --git a/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightSpan.cs b/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightSpan.cs index 8ccf69c80d..6403100f2d 100644 --- a/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightSpan.cs +++ b/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightSpan.cs @@ -3,7 +3,6 @@ using Microsoft.CodeAnalysis.Classification; using Microsoft.CodeAnalysis.Text; using Newtonsoft.Json; -using OmniSharp.Json; namespace OmniSharp.Models.Highlight { diff --git a/src/OmniSharp.Abstractions/Models/v1/LinePositionSpanTextChange.cs b/src/OmniSharp.Abstractions/Models/v1/LinePositionSpanTextChange.cs index f66fb0f5df..a44fcb5b82 100644 --- a/src/OmniSharp.Abstractions/Models/v1/LinePositionSpanTextChange.cs +++ b/src/OmniSharp.Abstractions/Models/v1/LinePositionSpanTextChange.cs @@ -4,7 +4,6 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Text; using Newtonsoft.Json; -using OmniSharp.Json; namespace OmniSharp.Models { diff --git a/src/OmniSharp.Abstractions/Models/v1/Navigate/NavigateResponse.cs b/src/OmniSharp.Abstractions/Models/v1/Navigate/NavigateResponse.cs index 47bb5de19c..70205cf534 100644 --- a/src/OmniSharp.Abstractions/Models/v1/Navigate/NavigateResponse.cs +++ b/src/OmniSharp.Abstractions/Models/v1/Navigate/NavigateResponse.cs @@ -1,6 +1,4 @@ using Newtonsoft.Json; -using OmniSharp.Json; - namespace OmniSharp.Models.Navigate { public class NavigateResponse diff --git a/src/OmniSharp.Abstractions/Models/v1/QuickFix.cs b/src/OmniSharp.Abstractions/Models/v1/QuickFix.cs index 08d539d4ed..5c50436b25 100644 --- a/src/OmniSharp.Abstractions/Models/v1/QuickFix.cs +++ b/src/OmniSharp.Abstractions/Models/v1/QuickFix.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using Newtonsoft.Json; -using OmniSharp.Json; namespace OmniSharp.Models { diff --git a/src/OmniSharp.Abstractions/Models/v2/ICodeActionRequest.cs b/src/OmniSharp.Abstractions/Models/v2/ICodeActionRequest.cs index ae397e3822..b12f3654ea 100644 --- a/src/OmniSharp.Abstractions/Models/v2/ICodeActionRequest.cs +++ b/src/OmniSharp.Abstractions/Models/v2/ICodeActionRequest.cs @@ -1,5 +1,4 @@ using Newtonsoft.Json; -using OmniSharp.Json; namespace OmniSharp.Models.V2 { diff --git a/src/OmniSharp.Abstractions/Models/v2/Point.cs b/src/OmniSharp.Abstractions/Models/v2/Point.cs index e6df3aa099..f329524d6a 100644 --- a/src/OmniSharp.Abstractions/Models/v2/Point.cs +++ b/src/OmniSharp.Abstractions/Models/v2/Point.cs @@ -1,5 +1,4 @@ using Newtonsoft.Json; -using OmniSharp.Json; namespace OmniSharp.Models.V2 { From 9380da61880250a1e2a3d87fbada7d6d56638b8b Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 13:37:54 -0700 Subject: [PATCH 08/15] Move Options and IWorkspaceOptionsProvider to OmniSharp.Options namespace --- .../{Mef => }/Options/FormattingOptions.cs | 1 + .../Options/IWorkspaceOptionsProvider.cs | 10 ++++++++++ .../{Mef => }/Options/OmniSharpOptions.cs | 0 .../Services/IWorkspaceOptionsProvider.cs | 9 --------- .../Services/CSharpWorkspaceOptionsProvider.cs | 15 ++++++++------- 5 files changed, 19 insertions(+), 16 deletions(-) rename src/OmniSharp.Abstractions/{Mef => }/Options/FormattingOptions.cs (98%) create mode 100644 src/OmniSharp.Abstractions/Options/IWorkspaceOptionsProvider.cs rename src/OmniSharp.Abstractions/{Mef => }/Options/OmniSharpOptions.cs (100%) delete mode 100644 src/OmniSharp.Abstractions/Services/IWorkspaceOptionsProvider.cs diff --git a/src/OmniSharp.Abstractions/Mef/Options/FormattingOptions.cs b/src/OmniSharp.Abstractions/Options/FormattingOptions.cs similarity index 98% rename from src/OmniSharp.Abstractions/Mef/Options/FormattingOptions.cs rename to src/OmniSharp.Abstractions/Options/FormattingOptions.cs index d97ba8f713..b5b34cc335 100644 --- a/src/OmniSharp.Abstractions/Mef/Options/FormattingOptions.cs +++ b/src/OmniSharp.Abstractions/Options/FormattingOptions.cs @@ -1,5 +1,6 @@ namespace OmniSharp.Options { + // TODO: These are mostly C#-specific. Should they be moved into in OmniSharp.Roslyn.CSharp somehow? public class FormattingOptions { public FormattingOptions() diff --git a/src/OmniSharp.Abstractions/Options/IWorkspaceOptionsProvider.cs b/src/OmniSharp.Abstractions/Options/IWorkspaceOptionsProvider.cs new file mode 100644 index 0000000000..e4801cf764 --- /dev/null +++ b/src/OmniSharp.Abstractions/Options/IWorkspaceOptionsProvider.cs @@ -0,0 +1,10 @@ +using Microsoft.CodeAnalysis.Options; +using OmniSharp.Options; + +namespace OmniSharp.Options +{ + public interface IWorkspaceOptionsProvider + { + OptionSet Process(OptionSet optionSet, FormattingOptions options); + } +} \ No newline at end of file diff --git a/src/OmniSharp.Abstractions/Mef/Options/OmniSharpOptions.cs b/src/OmniSharp.Abstractions/Options/OmniSharpOptions.cs similarity index 100% rename from src/OmniSharp.Abstractions/Mef/Options/OmniSharpOptions.cs rename to src/OmniSharp.Abstractions/Options/OmniSharpOptions.cs diff --git a/src/OmniSharp.Abstractions/Services/IWorkspaceOptionsProvider.cs b/src/OmniSharp.Abstractions/Services/IWorkspaceOptionsProvider.cs deleted file mode 100644 index c56b8b72dc..0000000000 --- a/src/OmniSharp.Abstractions/Services/IWorkspaceOptionsProvider.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Microsoft.CodeAnalysis.Options; - -namespace OmniSharp.Services -{ - public interface IWorkspaceOptionsProvider - { - OptionSet Process(OptionSet optionSet, Options.FormattingOptions options); - } -} \ No newline at end of file diff --git a/src/OmniSharp.Roslyn.CSharp/Services/CSharpWorkspaceOptionsProvider.cs b/src/OmniSharp.Roslyn.CSharp/Services/CSharpWorkspaceOptionsProvider.cs index e4cb66d2e3..646f364f79 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/CSharpWorkspaceOptionsProvider.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/CSharpWorkspaceOptionsProvider.cs @@ -1,22 +1,23 @@ using System.Composition; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Formatting; -using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Options; -using OmniSharp.Services; +using OmniSharp.Options; + +using RoslynFormattingOptions = Microsoft.CodeAnalysis.Formatting.FormattingOptions; namespace OmniSharp.Roslyn.CSharp.Services { [Export(typeof(IWorkspaceOptionsProvider)), Shared] public class CSharpWorkspaceOptionsProvider : IWorkspaceOptionsProvider { - private static OptionSet GetOptions(OptionSet optionSet, Options.FormattingOptions formattingOptions) + private static OptionSet GetOptions(OptionSet optionSet, FormattingOptions formattingOptions) { return optionSet - .WithChangedOption(FormattingOptions.NewLine, LanguageNames.CSharp, formattingOptions.NewLine) - .WithChangedOption(FormattingOptions.UseTabs, LanguageNames.CSharp, formattingOptions.UseTabs) - .WithChangedOption(FormattingOptions.TabSize, LanguageNames.CSharp, formattingOptions.TabSize) - .WithChangedOption(FormattingOptions.IndentationSize, LanguageNames.CSharp, formattingOptions.IndentationSize) + .WithChangedOption(RoslynFormattingOptions.NewLine, LanguageNames.CSharp, formattingOptions.NewLine) + .WithChangedOption(RoslynFormattingOptions.UseTabs, LanguageNames.CSharp, formattingOptions.UseTabs) + .WithChangedOption(RoslynFormattingOptions.TabSize, LanguageNames.CSharp, formattingOptions.TabSize) + .WithChangedOption(RoslynFormattingOptions.IndentationSize, LanguageNames.CSharp, formattingOptions.IndentationSize) .WithChangedOption(CSharpFormattingOptions.SpacingAfterMethodDeclarationName, formattingOptions.SpacingAfterMethodDeclarationName) .WithChangedOption(CSharpFormattingOptions.SpaceWithinMethodDeclarationParenthesis, formattingOptions.SpaceWithinMethodDeclarationParenthesis) .WithChangedOption(CSharpFormattingOptions.SpaceBetweenEmptyMethodDeclarationParentheses, formattingOptions.SpaceBetweenEmptyMethodDeclarationParentheses) From 0a72c21fcd587e84bd9f6a41e462ef041a8e597d Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 13:40:11 -0700 Subject: [PATCH 09/15] Move IWorkspaceOptionsProvider to OmniSharp.Roslyn --- src/OmniSharp.Host/Startup.cs | 1 + .../Options/IWorkspaceOptionsProvider.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) rename src/{OmniSharp.Abstractions => OmniSharp.Roslyn}/Options/IWorkspaceOptionsProvider.cs (85%) diff --git a/src/OmniSharp.Host/Startup.cs b/src/OmniSharp.Host/Startup.cs index 009513ad8e..d41ebd0904 100644 --- a/src/OmniSharp.Host/Startup.cs +++ b/src/OmniSharp.Host/Startup.cs @@ -19,6 +19,7 @@ using OmniSharp.Middleware; using OmniSharp.Options; using OmniSharp.Roslyn; +using OmniSharp.Roslyn.Options; using OmniSharp.Services; using OmniSharp.Stdio.Logging; using OmniSharp.Stdio.Services; diff --git a/src/OmniSharp.Abstractions/Options/IWorkspaceOptionsProvider.cs b/src/OmniSharp.Roslyn/Options/IWorkspaceOptionsProvider.cs similarity index 85% rename from src/OmniSharp.Abstractions/Options/IWorkspaceOptionsProvider.cs rename to src/OmniSharp.Roslyn/Options/IWorkspaceOptionsProvider.cs index e4801cf764..cadac086b0 100644 --- a/src/OmniSharp.Abstractions/Options/IWorkspaceOptionsProvider.cs +++ b/src/OmniSharp.Roslyn/Options/IWorkspaceOptionsProvider.cs @@ -1,7 +1,7 @@ using Microsoft.CodeAnalysis.Options; using OmniSharp.Options; -namespace OmniSharp.Options +namespace OmniSharp.Roslyn.Options { public interface IWorkspaceOptionsProvider { From e658947899b4a7a3117c213daee0637a8ecf1b66 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 13:42:55 -0700 Subject: [PATCH 10/15] Move several extension methods into OmniSharp.Utilities namespace --- .../{Extensions => Utilities}/ReflectionExtensions.cs | 2 +- .../{Extensions => Utilities}/TaskExtensions.cs | 2 +- .../Services/Refactoring/V2/BaseCodeActionService.cs | 1 + src/OmniSharp.Roslyn/MetadataHelper.cs | 1 + src/OmniSharp.Roslyn/OmniSharpWorkspace.cs | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) rename src/OmniSharp.Abstractions/{Extensions => Utilities}/ReflectionExtensions.cs (99%) rename src/OmniSharp.Abstractions/{Extensions => Utilities}/TaskExtensions.cs (90%) diff --git a/src/OmniSharp.Abstractions/Extensions/ReflectionExtensions.cs b/src/OmniSharp.Abstractions/Utilities/ReflectionExtensions.cs similarity index 99% rename from src/OmniSharp.Abstractions/Extensions/ReflectionExtensions.cs rename to src/OmniSharp.Abstractions/Utilities/ReflectionExtensions.cs index 19bcad3c12..e664d991f2 100644 --- a/src/OmniSharp.Abstractions/Extensions/ReflectionExtensions.cs +++ b/src/OmniSharp.Abstractions/Utilities/ReflectionExtensions.cs @@ -1,7 +1,7 @@ using System; using System.Reflection; -namespace OmniSharp.Services +namespace OmniSharp.Utilities { public static class ReflectionExtensions { diff --git a/src/OmniSharp.Abstractions/Extensions/TaskExtensions.cs b/src/OmniSharp.Abstractions/Utilities/TaskExtensions.cs similarity index 90% rename from src/OmniSharp.Abstractions/Extensions/TaskExtensions.cs rename to src/OmniSharp.Abstractions/Utilities/TaskExtensions.cs index 4025baa4c5..d3f802ff2c 100644 --- a/src/OmniSharp.Abstractions/Extensions/TaskExtensions.cs +++ b/src/OmniSharp.Abstractions/Utilities/TaskExtensions.cs @@ -1,7 +1,7 @@ using System.Threading; using System.Threading.Tasks; -namespace OmniSharp.Extensions +namespace OmniSharp.Utilities { public static class TaskExtensions { diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs index e4f51e2f30..5b4b4c48a0 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs @@ -15,6 +15,7 @@ using OmniSharp.Models.V2; using OmniSharp.Roslyn.CSharp.Services.CodeActions; using OmniSharp.Services; +using OmniSharp.Utilities; namespace OmniSharp.Roslyn.CSharp.Services.Refactoring.V2 { diff --git a/src/OmniSharp.Roslyn/MetadataHelper.cs b/src/OmniSharp.Roslyn/MetadataHelper.cs index 15f8124e57..833a5cb127 100644 --- a/src/OmniSharp.Roslyn/MetadataHelper.cs +++ b/src/OmniSharp.Roslyn/MetadataHelper.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis; using OmniSharp.Services; +using OmniSharp.Utilities; namespace OmniSharp.Roslyn { diff --git a/src/OmniSharp.Roslyn/OmniSharpWorkspace.cs b/src/OmniSharp.Roslyn/OmniSharpWorkspace.cs index 538b24fda4..e8140892d0 100644 --- a/src/OmniSharp.Roslyn/OmniSharpWorkspace.cs +++ b/src/OmniSharp.Roslyn/OmniSharpWorkspace.cs @@ -4,8 +4,8 @@ using System.Threading; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Text; -using OmniSharp.Extensions; using OmniSharp.Roslyn; +using OmniSharp.Utilities; namespace OmniSharp { From 44dc8cf619f2f2b5a3b85745b665dd5d8933fc88 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 13:50:05 -0700 Subject: [PATCH 11/15] Update CSharpWorkspaceOptionsProvider due to moved type --- .../Services/CSharpWorkspaceOptionsProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OmniSharp.Roslyn.CSharp/Services/CSharpWorkspaceOptionsProvider.cs b/src/OmniSharp.Roslyn.CSharp/Services/CSharpWorkspaceOptionsProvider.cs index 646f364f79..b99c3e88d7 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/CSharpWorkspaceOptionsProvider.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/CSharpWorkspaceOptionsProvider.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis.CSharp.Formatting; using Microsoft.CodeAnalysis.Options; using OmniSharp.Options; - +using OmniSharp.Roslyn.Options; using RoslynFormattingOptions = Microsoft.CodeAnalysis.Formatting.FormattingOptions; namespace OmniSharp.Roslyn.CSharp.Services @@ -92,7 +92,7 @@ private static BinaryOperatorSpacingOptions BinaryOperatorSpacingOptionForString } } - public OptionSet Process(OptionSet workOptionSet, Options.FormattingOptions options) + public OptionSet Process(OptionSet workOptionSet, FormattingOptions options) { return GetOptions(workOptionSet, options); } From fe83d0d525334392f47479fb62acd4c53c9f9ac9 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 14:06:09 -0700 Subject: [PATCH 12/15] Move IOmniSharpEnvironment and TransportType to OmniSharp namespace --- .../{Services => }/IOmniSharpEnvironment.cs | 2 +- src/OmniSharp.Abstractions/{Services => }/TransportType.cs | 2 +- tests/TestUtility/TestServiceProvider.cs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) rename src/OmniSharp.Abstractions/{Services => }/IOmniSharpEnvironment.cs (93%) rename src/OmniSharp.Abstractions/{Services => }/TransportType.cs (71%) diff --git a/src/OmniSharp.Abstractions/Services/IOmniSharpEnvironment.cs b/src/OmniSharp.Abstractions/IOmniSharpEnvironment.cs similarity index 93% rename from src/OmniSharp.Abstractions/Services/IOmniSharpEnvironment.cs rename to src/OmniSharp.Abstractions/IOmniSharpEnvironment.cs index 64f8ea3a99..91708463be 100644 --- a/src/OmniSharp.Abstractions/Services/IOmniSharpEnvironment.cs +++ b/src/OmniSharp.Abstractions/IOmniSharpEnvironment.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.Logging; -namespace OmniSharp.Services +namespace OmniSharp { public interface IOmniSharpEnvironment { diff --git a/src/OmniSharp.Abstractions/Services/TransportType.cs b/src/OmniSharp.Abstractions/TransportType.cs similarity index 71% rename from src/OmniSharp.Abstractions/Services/TransportType.cs rename to src/OmniSharp.Abstractions/TransportType.cs index 3302605e00..65c6b386d4 100644 --- a/src/OmniSharp.Abstractions/Services/TransportType.cs +++ b/src/OmniSharp.Abstractions/TransportType.cs @@ -1,4 +1,4 @@ -namespace OmniSharp.Services +namespace OmniSharp { public enum TransportType { diff --git a/tests/TestUtility/TestServiceProvider.cs b/tests/TestUtility/TestServiceProvider.cs index 2e55d52c4c..012b208cb6 100644 --- a/tests/TestUtility/TestServiceProvider.cs +++ b/tests/TestUtility/TestServiceProvider.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Logging; +using OmniSharp; using OmniSharp.Host.Loader; using OmniSharp.Services; using OmniSharp.Stdio.Services; From ddb22754a43bf565c6d0c70ae4154c76df958ddb Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 14:18:32 -0700 Subject: [PATCH 13/15] Move a few services to OmniSharp.Roslyn and delete IMetadataFileReferenceCache --- .../Services/IMetadataFileReferenceCache.cs | 9 --------- src/OmniSharp.DotNet/DotNetProjectSystem.cs | 4 ++-- src/OmniSharp.MSBuild/MSBuildProjectSystem.cs | 4 ++-- .../Services/ICodeActionProvider.cs | 0 .../Services/IHostServicesProvider.cs | 0 .../Services/ISyntaxFeaturesDiscover.cs | 0 .../Services/MetadataFileReferenceCache.cs | 4 ++-- src/OmniSharp.Script/ScriptProjectSystem.cs | 4 ++-- 8 files changed, 8 insertions(+), 17 deletions(-) delete mode 100644 src/OmniSharp.Abstractions/Services/IMetadataFileReferenceCache.cs rename src/{OmniSharp.Abstractions => OmniSharp.Roslyn}/Services/ICodeActionProvider.cs (100%) rename src/{OmniSharp.Abstractions => OmniSharp.Roslyn}/Services/IHostServicesProvider.cs (100%) rename src/{OmniSharp.Abstractions => OmniSharp.Roslyn}/Services/ISyntaxFeaturesDiscover.cs (100%) diff --git a/src/OmniSharp.Abstractions/Services/IMetadataFileReferenceCache.cs b/src/OmniSharp.Abstractions/Services/IMetadataFileReferenceCache.cs deleted file mode 100644 index c2ba41ab84..0000000000 --- a/src/OmniSharp.Abstractions/Services/IMetadataFileReferenceCache.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Microsoft.CodeAnalysis; - -namespace OmniSharp.Services -{ - public interface IMetadataFileReferenceCache - { - MetadataReference GetMetadataReference(string filePath); - } -} \ No newline at end of file diff --git a/src/OmniSharp.DotNet/DotNetProjectSystem.cs b/src/OmniSharp.DotNet/DotNetProjectSystem.cs index 34333ae9bd..cf4c04f7a5 100644 --- a/src/OmniSharp.DotNet/DotNetProjectSystem.cs +++ b/src/OmniSharp.DotNet/DotNetProjectSystem.cs @@ -30,7 +30,7 @@ public class DotNetProjectSystem : IProjectSystem private readonly IOmniSharpEnvironment _environment; private readonly OmniSharpWorkspace _workspace; private readonly DotNetCliService _dotNetCliService; - private readonly IMetadataFileReferenceCache _metadataFileReferenceCache; + private readonly MetadataFileReferenceCache _metadataFileReferenceCache; private readonly IEventEmitter _eventEmitter; private readonly IFileSystemWatcher _fileSystemWatcher; private readonly ILogger _logger; @@ -44,7 +44,7 @@ public DotNetProjectSystem( IOmniSharpEnvironment environment, OmniSharpWorkspace workspace, DotNetCliService dotNetCliService, - IMetadataFileReferenceCache metadataFileReferenceCache, + MetadataFileReferenceCache metadataFileReferenceCache, IEventEmitter eventEmitter, IFileSystemWatcher fileSystemWatcher, ILoggerFactory loggerFactory) diff --git a/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs b/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs index 65e3eb4bfd..c62928b27f 100644 --- a/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs +++ b/src/OmniSharp.MSBuild/MSBuildProjectSystem.cs @@ -28,7 +28,7 @@ public class MSBuildProjectSystem : IProjectSystem private readonly IOmniSharpEnvironment _environment; private readonly OmniSharpWorkspace _workspace; private readonly DotNetCliService _dotNetCliService; - private readonly IMetadataFileReferenceCache _metadataFileReferenceCache; + private readonly MetadataFileReferenceCache _metadataFileReferenceCache; private readonly IEventEmitter _eventEmitter; private readonly IFileSystemWatcher _fileSystemWatcher; private readonly ILoggerFactory _loggerFactory; @@ -56,7 +56,7 @@ public MSBuildProjectSystem( IOmniSharpEnvironment environment, OmniSharpWorkspace workspace, DotNetCliService dotNetCliService, - IMetadataFileReferenceCache metadataFileReferenceCache, + MetadataFileReferenceCache metadataFileReferenceCache, IEventEmitter eventEmitter, IFileSystemWatcher fileSystemWatcher, ILoggerFactory loggerFactory) diff --git a/src/OmniSharp.Abstractions/Services/ICodeActionProvider.cs b/src/OmniSharp.Roslyn/Services/ICodeActionProvider.cs similarity index 100% rename from src/OmniSharp.Abstractions/Services/ICodeActionProvider.cs rename to src/OmniSharp.Roslyn/Services/ICodeActionProvider.cs diff --git a/src/OmniSharp.Abstractions/Services/IHostServicesProvider.cs b/src/OmniSharp.Roslyn/Services/IHostServicesProvider.cs similarity index 100% rename from src/OmniSharp.Abstractions/Services/IHostServicesProvider.cs rename to src/OmniSharp.Roslyn/Services/IHostServicesProvider.cs diff --git a/src/OmniSharp.Abstractions/Services/ISyntaxFeaturesDiscover.cs b/src/OmniSharp.Roslyn/Services/ISyntaxFeaturesDiscover.cs similarity index 100% rename from src/OmniSharp.Abstractions/Services/ISyntaxFeaturesDiscover.cs rename to src/OmniSharp.Roslyn/Services/ISyntaxFeaturesDiscover.cs diff --git a/src/OmniSharp.Roslyn/Services/MetadataFileReferenceCache.cs b/src/OmniSharp.Roslyn/Services/MetadataFileReferenceCache.cs index 9321f3d4ec..c387668f4b 100644 --- a/src/OmniSharp.Roslyn/Services/MetadataFileReferenceCache.cs +++ b/src/OmniSharp.Roslyn/Services/MetadataFileReferenceCache.cs @@ -10,8 +10,8 @@ namespace OmniSharp.Services { - [Export(typeof(IMetadataFileReferenceCache)), Shared] - public class MetadataFileReferenceCache : IMetadataFileReferenceCache + [Export, Shared] + public class MetadataFileReferenceCache { private static readonly string _cacheKeyPrefix = nameof(MetadataFileReferenceCache); diff --git a/src/OmniSharp.Script/ScriptProjectSystem.cs b/src/OmniSharp.Script/ScriptProjectSystem.cs index 173e1ff5f4..05223cadab 100644 --- a/src/OmniSharp.Script/ScriptProjectSystem.cs +++ b/src/OmniSharp.Script/ScriptProjectSystem.cs @@ -71,7 +71,7 @@ public class ScriptProjectSystem : IProjectSystem return compilationOptions; }); - private readonly IMetadataFileReferenceCache _metadataFileReferenceCache; + private readonly MetadataFileReferenceCache _metadataFileReferenceCache; // used for tracking purposes only private readonly HashSet _assemblyReferences = new HashSet(); @@ -82,7 +82,7 @@ public class ScriptProjectSystem : IProjectSystem private readonly ILogger _logger; [ImportingConstructor] - public ScriptProjectSystem(OmniSharpWorkspace workspace, IOmniSharpEnvironment env, ILoggerFactory loggerFactory, IMetadataFileReferenceCache metadataFileReferenceCache) + public ScriptProjectSystem(OmniSharpWorkspace workspace, IOmniSharpEnvironment env, ILoggerFactory loggerFactory, MetadataFileReferenceCache metadataFileReferenceCache) { _metadataFileReferenceCache = metadataFileReferenceCache; _workspace = workspace; From 7adba3b2e3d16e9faf654eedb78e9091d5b6b7cf Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 16:00:42 -0700 Subject: [PATCH 14/15] Move enough services into OmniSharp.Roslyn that the references to Roslyn in OmniSharp.Abstractions can be removed --- .../Models/v1/Highlight/HighlightSpan.cs | 17 ----- .../Models/v1/LinePositionSpanTextChange.cs | 53 -------------- .../v1/TestCommand}/TestCommandType.cs | 2 +- .../OmniSharp.Abstractions.csproj | 3 +- src/OmniSharp.Host/AssemblyInfo.cs | 3 + .../Mef/MefValueProvider.cs | 4 +- src/OmniSharp.Host/OmniSharp.Host.csproj | 5 +- .../{Loader => Services}/AssemblyLoader.cs | 2 +- .../Services/Formatting/CodeFormatService.cs | 7 +- .../Formatting/FormatAfterKeystrokeService.cs | 2 +- .../Services/Formatting/FormatRangeService.cs | 2 +- .../Highlighting/HighlightingService.cs | 17 ++++- .../Services/Refactoring/FixUsingService.cs | 19 ++--- .../Services/Refactoring/RenameService.cs | 4 +- .../Refactoring/RunCodeActionService.cs | 16 +++-- .../Refactoring/V2/RunCodeActionService.cs | 12 ++-- .../TestCommands/TestCommandService.cs | 1 + .../Workers/Formatting/FormattingWorker.cs | 29 ++++---- src/OmniSharp.Roslyn/AssemblyInfo.cs | 4 ++ .../Services/ITestCommandProvider.cs | 2 +- .../Services/TestContext.cs | 3 +- .../Utilities/TextChangeHelper.cs | 72 +++++++++++++++++++ .../LinePositionSpanTextChangeFacts.cs | 10 ++- 23 files changed, 160 insertions(+), 129 deletions(-) rename src/OmniSharp.Abstractions/{Services => Models/v1/TestCommand}/TestCommandType.cs (66%) create mode 100644 src/OmniSharp.Host/AssemblyInfo.cs rename src/{OmniSharp.Abstractions => OmniSharp.Host}/Mef/MefValueProvider.cs (89%) rename src/OmniSharp.Host/{Loader => Services}/AssemblyLoader.cs (93%) create mode 100644 src/OmniSharp.Roslyn/AssemblyInfo.cs rename src/{OmniSharp.Abstractions => OmniSharp.Roslyn}/Services/ITestCommandProvider.cs (79%) rename src/{OmniSharp.Abstractions => OmniSharp.Roslyn}/Services/TestContext.cs (88%) create mode 100644 src/OmniSharp.Roslyn/Utilities/TextChangeHelper.cs diff --git a/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightSpan.cs b/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightSpan.cs index 6403100f2d..fe713ff752 100644 --- a/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightSpan.cs +++ b/src/OmniSharp.Abstractions/Models/v1/Highlight/HighlightSpan.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using Microsoft.CodeAnalysis.Classification; -using Microsoft.CodeAnalysis.Text; using Newtonsoft.Json; namespace OmniSharp.Models.Highlight @@ -19,21 +17,6 @@ public class HighlightSpan : IComparable public string Kind { get; set; } public IEnumerable Projects { get; set; } - public static HighlightSpan FromClassifiedSpan(ClassifiedSpan span, TextLineCollection lines, IEnumerable projects) - { - var linePos = lines.GetLinePositionSpan(span.TextSpan); - - return new HighlightSpan - { - StartLine = linePos.Start.Line, - EndLine = linePos.End.Line, - StartColumn = linePos.Start.Character, - EndColumn = linePos.End.Character, - Kind = span.ClassificationType, - Projects = projects - }; - } - public int CompareTo(HighlightSpan other) { if (other.StartLine < StartLine) diff --git a/src/OmniSharp.Abstractions/Models/v1/LinePositionSpanTextChange.cs b/src/OmniSharp.Abstractions/Models/v1/LinePositionSpanTextChange.cs index a44fcb5b82..3a7363fb6a 100644 --- a/src/OmniSharp.Abstractions/Models/v1/LinePositionSpanTextChange.cs +++ b/src/OmniSharp.Abstractions/Models/v1/LinePositionSpanTextChange.cs @@ -1,62 +1,9 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Text; using Newtonsoft.Json; namespace OmniSharp.Models { public class LinePositionSpanTextChange { - public static async Task> Convert(Document document, IEnumerable changes) - { - var text = await document.GetTextAsync(); - - return changes - .OrderByDescending(change => change.Span) - .Select(change => - { - var span = change.Span; - var newText = change.NewText; - var prefix = string.Empty; - var postfix = string.Empty; - - if (newText.Length > 0) - { - // Roslyn computes text changes on character arrays. So it might happen that a - // change starts inbetween \r\n which is OK when you are offset-based but a problem - // when you are line,column-based. This code extends text edits which just overlap - // a with a line break to its full line break - - if (span.Start > 0 && newText[0] == '\n' && text[span.Start - 1] == '\r') - { - // text: foo\r\nbar\r\nfoo - // edit: [----) - span = TextSpan.FromBounds(span.Start - 1, span.End); - prefix = "\r"; - } - if (span.End < text.Length - 1 && newText[newText.Length - 1] == '\r' && text[span.End] == '\n') - { - // text: foo\r\nbar\r\nfoo - // edit: [----) - span = TextSpan.FromBounds(span.Start, span.End + 1); - postfix = "\n"; - } - } - - var linePositionSpan = text.Lines.GetLinePositionSpan(span); - return new LinePositionSpanTextChange() - { - NewText = prefix + newText + postfix, - StartLine = linePositionSpan.Start.Line, - StartColumn = linePositionSpan.Start.Character, - EndLine = linePositionSpan.End.Line, - EndColumn = linePositionSpan.End.Character - }; - }); - } - public string NewText { get; set; } [JsonConverter(typeof(ZeroBasedIndexConverter))] diff --git a/src/OmniSharp.Abstractions/Services/TestCommandType.cs b/src/OmniSharp.Abstractions/Models/v1/TestCommand/TestCommandType.cs similarity index 66% rename from src/OmniSharp.Abstractions/Services/TestCommandType.cs rename to src/OmniSharp.Abstractions/Models/v1/TestCommand/TestCommandType.cs index 611619d39f..5b2a9ea1ca 100644 --- a/src/OmniSharp.Abstractions/Services/TestCommandType.cs +++ b/src/OmniSharp.Abstractions/Models/v1/TestCommand/TestCommandType.cs @@ -1,4 +1,4 @@ -namespace OmniSharp +namespace OmniSharp.Models.TestCommand { public enum TestCommandType { diff --git a/src/OmniSharp.Abstractions/OmniSharp.Abstractions.csproj b/src/OmniSharp.Abstractions/OmniSharp.Abstractions.csproj index 84066b440a..8a7928cdbf 100644 --- a/src/OmniSharp.Abstractions/OmniSharp.Abstractions.csproj +++ b/src/OmniSharp.Abstractions/OmniSharp.Abstractions.csproj @@ -12,8 +12,7 @@ - - + diff --git a/src/OmniSharp.Host/AssemblyInfo.cs b/src/OmniSharp.Host/AssemblyInfo.cs new file mode 100644 index 0000000000..71fdf9edab --- /dev/null +++ b/src/OmniSharp.Host/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("TestUtility")] \ No newline at end of file diff --git a/src/OmniSharp.Abstractions/Mef/MefValueProvider.cs b/src/OmniSharp.Host/Mef/MefValueProvider.cs similarity index 89% rename from src/OmniSharp.Abstractions/Mef/MefValueProvider.cs rename to src/OmniSharp.Host/Mef/MefValueProvider.cs index d7abdd1fde..38ba78957c 100644 --- a/src/OmniSharp.Abstractions/Mef/MefValueProvider.cs +++ b/src/OmniSharp.Host/Mef/MefValueProvider.cs @@ -4,7 +4,7 @@ namespace OmniSharp.Mef { - public class MefValueProvider : ExportDescriptorProvider + internal class MefValueProvider : ExportDescriptorProvider { private readonly T _item; @@ -24,7 +24,7 @@ public override IEnumerable GetExportDescriptors(Compos } } - public static class MefValueProvider + internal static class MefValueProvider { public static MefValueProvider From(T value) { diff --git a/src/OmniSharp.Host/OmniSharp.Host.csproj b/src/OmniSharp.Host/OmniSharp.Host.csproj index b0cbe2ed1e..c736d5edff 100644 --- a/src/OmniSharp.Host/OmniSharp.Host.csproj +++ b/src/OmniSharp.Host/OmniSharp.Host.csproj @@ -9,6 +9,10 @@ $(PackageTargetFallback);dotnet5.4;portable-net45+win8 + + + + @@ -19,7 +23,6 @@ - diff --git a/src/OmniSharp.Host/Loader/AssemblyLoader.cs b/src/OmniSharp.Host/Services/AssemblyLoader.cs similarity index 93% rename from src/OmniSharp.Host/Loader/AssemblyLoader.cs rename to src/OmniSharp.Host/Services/AssemblyLoader.cs index 1dad0d359a..36e3595bd0 100644 --- a/src/OmniSharp.Host/Loader/AssemblyLoader.cs +++ b/src/OmniSharp.Host/Services/AssemblyLoader.cs @@ -5,7 +5,7 @@ namespace OmniSharp.Host.Loader { - public class AssemblyLoader : IAssemblyLoader + internal class AssemblyLoader : IAssemblyLoader { private readonly ILogger _logger; diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Formatting/CodeFormatService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Formatting/CodeFormatService.cs index 50206265a0..2c21900d5d 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Formatting/CodeFormatService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Formatting/CodeFormatService.cs @@ -28,15 +28,16 @@ public async Task Handle(CodeFormatRequest request) if (request.WantsTextChanges) { - var textChanges = await FormattingWorker.GetFormattedDocumentTextChanges(_workspace, document); + var textChanges = await FormattingWorker.GetFormattedTextChanges(document); return new CodeFormatResponse() { Changes = textChanges }; } - var newText = await FormattingWorker.GetFormattedDocument(_workspace, document); - return new CodeFormatResponse() + var newText = await FormattingWorker.GetFormattedText(document); + + return new CodeFormatResponse { Buffer = newText }; diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Formatting/FormatAfterKeystrokeService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Formatting/FormatAfterKeystrokeService.cs index fb5eb4322f..19497e6b17 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Formatting/FormatAfterKeystrokeService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Formatting/FormatAfterKeystrokeService.cs @@ -29,7 +29,7 @@ public async Task Handle(FormatAfterKeystrokeRequest reques var text = await document.GetTextAsync(); int position = text.Lines.GetPosition(new LinePosition(request.Line, request.Column)); - var changes = await FormattingWorker.GetFormattingChangesAfterKeystroke(_workspace, document, position, request.Char); + var changes = await FormattingWorker.GetFormattingChangesAfterKeystroke(document, position, request.Char); return new FormatRangeResponse() { diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Formatting/FormatRangeService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Formatting/FormatRangeService.cs index 249486bab2..33a8ac4405 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Formatting/FormatRangeService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Formatting/FormatRangeService.cs @@ -30,7 +30,7 @@ public async Task Handle(FormatRangeRequest request) var text = await document.GetTextAsync(); var start = text.Lines.GetPosition(new LinePosition(request.Line, request.Column)); var end = text.Lines.GetPosition(new LinePosition(request.EndLine, request.EndColumn)); - var changes = await FormattingWorker.GetFormattingChangesForRange(_workspace, document, start, end); + var changes = await FormattingWorker.GetFormattingChanges(document, start, end); return new FormatRangeResponse() { diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Highlighting/HighlightingService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Highlighting/HighlightingService.cs index 5810fe2d67..118417f60c 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Highlighting/HighlightingService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Highlighting/HighlightingService.cs @@ -82,11 +82,26 @@ public async Task Handle(HighlightRequest request) { Highlights = results .GroupBy(result => result.Span.TextSpan.ToString()) - .Select(grouping => HighlightSpan.FromClassifiedSpan(grouping.First().Span, grouping.First().Lines, grouping.Select(z => z.Project))) + .Select(grouping => CreateHighlightSpan(grouping.First().Span, grouping.First().Lines, grouping.Select(z => z.Project))) .ToArray() }; } + public static HighlightSpan CreateHighlightSpan(ClassifiedSpan span, TextLineCollection lines, IEnumerable projects) + { + var linePos = lines.GetLinePositionSpan(span.TextSpan); + + return new HighlightSpan + { + StartLine = linePos.Start.Line, + EndLine = linePos.End.Line, + StartColumn = linePos.Start.Character, + EndColumn = linePos.End.Character, + Kind = span.ClassificationType, + Projects = projects + }; + } + class ClassifiedResult { public ClassifiedSpan Span { get; set; } diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/FixUsingService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/FixUsingService.cs index f7b61d7cc7..38e33c8944 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/FixUsingService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/FixUsingService.cs @@ -4,8 +4,8 @@ using Microsoft.CodeAnalysis; using Microsoft.Extensions.Logging; using OmniSharp.Mef; -using OmniSharp.Models; using OmniSharp.Models.FixUsings; +using OmniSharp.Roslyn.Utilities; using OmniSharp.Services; namespace OmniSharp.Roslyn.CSharp.Services.Refactoring @@ -35,11 +35,11 @@ public async Task Handle(FixUsingsRequest request) { var response = new FixUsingsResponse(); - var document = _workspace.GetDocument(request.FileName); - if (document != null) + var oldDocument = _workspace.GetDocument(request.FileName); + if (oldDocument != null) { var fixUsingsResponse = await new FixUsingsWorker(_providers) - .FixUsingsAsync(document); + .FixUsingsAsync(oldDocument); response.AmbiguousResults = fixUsingsResponse.AmbiguousResults; @@ -48,17 +48,18 @@ public async Task Handle(FixUsingsRequest request) _workspace.TryApplyChanges(fixUsingsResponse.Document.Project.Solution); } + var newDocument = fixUsingsResponse.Document; + if (!request.WantsTextChanges) { - // return the new document - var docText = await fixUsingsResponse.Document.GetTextAsync(); - response.Buffer = docText.ToString(); + // return the text of the new document + var newText = await newDocument.GetTextAsync(); + response.Buffer = newText.ToString(); } else { // return the text changes - var changes = await fixUsingsResponse.Document.GetTextChangesAsync(document); - response.Changes = await LinePositionSpanTextChange.Convert(document, changes); + response.Changes = await TextChanges.GetAsync(newDocument, oldDocument); } } diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RenameService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RenameService.cs index c19c323e55..8b136b0761 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RenameService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RenameService.cs @@ -10,6 +10,7 @@ using OmniSharp.Mef; using OmniSharp.Models; using OmniSharp.Models.Rename; +using OmniSharp.Roslyn.Utilities; namespace OmniSharp.Roslyn.CSharp.Services.Refactoring { @@ -72,8 +73,7 @@ public async Task Handle(RenameRequest request) else { var originalDocument = _workspace.CurrentSolution.GetDocument(changedDocumentId); - var textChanges = await changedDocument.GetTextChangesAsync(originalDocument); - var linePositionSpanTextChanges = await LinePositionSpanTextChange.Convert(originalDocument, textChanges); + var linePositionSpanTextChanges = await TextChanges.GetAsync(changedDocument, originalDocument); modifiedFileResponse.Changes = modifiedFileResponse.Changes != null ? modifiedFileResponse.Changes.Union(linePositionSpanTextChanges) diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RunCodeActionService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RunCodeActionService.cs index 532206b1b9..e0b3f59bd3 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RunCodeActionService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/RunCodeActionService.cs @@ -8,8 +8,8 @@ using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Text; using OmniSharp.Mef; -using OmniSharp.Models; using OmniSharp.Models.CodeAction; +using OmniSharp.Roslyn.Utilities; using OmniSharp.Services; namespace OmniSharp.Roslyn.CSharp.Services.Refactoring @@ -47,19 +47,21 @@ public async Task Handle(RunCodeActionRequest request) o.Apply(_workspace, CancellationToken.None); } - var originalDocument = context.Value.Document; + var oldDocument = context.Value.Document; + var newDocument = _workspace.CurrentSolution.GetDocument(oldDocument.Id); + var response = new RunCodeActionResponse(); + if (!request.WantsTextChanges) { - // return the new document - var sourceText = await _workspace.CurrentSolution.GetDocument(originalDocument.Id).GetTextAsync(); - response.Text = sourceText.ToString(); + // return the text of the new document + var newText = await newDocument.GetTextAsync(); + response.Text = newText.ToString(); } else { // return the text changes - var changes = await _workspace.CurrentSolution.GetDocument(originalDocument.Id).GetTextChangesAsync(originalDocument); - response.Changes = await LinePositionSpanTextChange.Convert(originalDocument, changes); + response.Changes = await TextChanges.GetAsync(newDocument, oldDocument); } return response; diff --git a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/RunCodeActionService.cs b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/RunCodeActionService.cs index 379227f548..ee7ff601e6 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/RunCodeActionService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/RunCodeActionService.cs @@ -10,6 +10,7 @@ using OmniSharp.Mef; using OmniSharp.Models; using OmniSharp.Roslyn.CSharp.Services.CodeActions; +using OmniSharp.Roslyn.Utilities; using OmniSharp.Services; using RunCodeActionRequest = OmniSharp.Models.V2.RunCodeActionRequest; @@ -49,8 +50,7 @@ public override async Task Handle(RunCodeActionRequest re foreach (var o in operations) { - var applyChangesOperation = o as ApplyChangesOperation; - if (applyChangesOperation != null) + if (o is ApplyChangesOperation applyChangesOperation) { var fileChanges = await GetFileChangesAsync(applyChangesOperation.ChangedSolution, solution, directory, request.WantsTextChanges); @@ -136,8 +136,7 @@ private async Task> GetFileChangesAsync(Soluti var newDocument = newSolution.GetDocument(documentId); var filePath = newDocument.FilePath; - ModifiedFileResponse modifiedFileResponse; - if (!filePathToResponseMap.TryGetValue(filePath, out modifiedFileResponse)) + if (!filePathToResponseMap.TryGetValue(filePath, out var modifiedFileResponse)) { modifiedFileResponse = new ModifiedFileResponse(filePath); filePathToResponseMap[filePath] = modifiedFileResponse; @@ -145,9 +144,8 @@ private async Task> GetFileChangesAsync(Soluti if (wantTextChanges) { - var originalDocument = oldSolution.GetDocument(documentId); - var textChanges = await newDocument.GetTextChangesAsync(originalDocument); - var linePositionSpanTextChanges = await LinePositionSpanTextChange.Convert(originalDocument, textChanges); + var oldDocument = oldSolution.GetDocument(documentId); + var linePositionSpanTextChanges = await TextChanges.GetAsync(newDocument, oldDocument); modifiedFileResponse.Changes = modifiedFileResponse.Changes != null ? modifiedFileResponse.Changes.Union(linePositionSpanTextChanges) diff --git a/src/OmniSharp.Roslyn.CSharp/Services/TestCommands/TestCommandService.cs b/src/OmniSharp.Roslyn.CSharp/Services/TestCommands/TestCommandService.cs index 359905a3a0..1fc153cc02 100644 --- a/src/OmniSharp.Roslyn.CSharp/Services/TestCommands/TestCommandService.cs +++ b/src/OmniSharp.Roslyn.CSharp/Services/TestCommands/TestCommandService.cs @@ -10,6 +10,7 @@ using OmniSharp.Mef; using OmniSharp.Models; using OmniSharp.Models.TestCommand; +using OmniSharp.Services; namespace OmniSharp.Roslyn.CSharp.Services.TestCommands { diff --git a/src/OmniSharp.Roslyn.CSharp/Workers/Formatting/FormattingWorker.cs b/src/OmniSharp.Roslyn.CSharp/Workers/Formatting/FormattingWorker.cs index 8854b9bfe0..f64b3c76c1 100644 --- a/src/OmniSharp.Roslyn.CSharp/Workers/Formatting/FormattingWorker.cs +++ b/src/OmniSharp.Roslyn.CSharp/Workers/Formatting/FormattingWorker.cs @@ -3,17 +3,16 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Formatting; using Microsoft.CodeAnalysis.Formatting; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Text; using OmniSharp.Models; +using OmniSharp.Roslyn.Utilities; namespace OmniSharp.Roslyn.CSharp.Workers.Formatting { public static class FormattingWorker { - public static async Task> GetFormattingChangesAfterKeystroke(Workspace workspace, Document document, int position, char character) + public static async Task> GetFormattingChangesAfterKeystroke(Document document, int position, char character) { if (character == '\n') { @@ -23,7 +22,7 @@ public static async Task> GetFormattingC var targetLine = lines[lines.GetLineFromPosition(position).LineNumber - 1]; if (!string.IsNullOrWhiteSpace(targetLine.Text.ToString(targetLine.Span))) { - return await GetFormattingChangesForRange(workspace, document, targetLine.Start, targetLine.End); + return await GetFormattingChanges(document, targetLine.Start, targetLine.End); } } else if (character == '}' || character == ';') @@ -33,7 +32,7 @@ public static async Task> GetFormattingC var node = FindFormatTarget(root, position); if (node != null) { - return await GetFormattingChangesForRange(workspace, document, node.FullSpan.Start, node.FullSpan.End); + return await GetFormattingChanges(document, node.FullSpan.Start, node.FullSpan.End); } } @@ -77,28 +76,26 @@ public static SyntaxNode FindFormatTarget(SyntaxNode root, int position) return null; } - public static async Task> GetFormattingChangesForRange(Workspace workspace, Document document, int start, int end) + public static async Task> GetFormattingChanges(Document document, int start, int end) { - var changedDocument = await Formatter.FormatAsync(document, TextSpan.FromBounds(start, end), workspace.Options); - var textChanges = await changedDocument.GetTextChangesAsync(document); + var newDocument = await Formatter.FormatAsync(document, TextSpan.FromBounds(start, end), document.Project.Solution.Workspace.Options); - return await LinePositionSpanTextChange.Convert(document, textChanges); + return await TextChanges.GetAsync(newDocument, document); } - public static async Task GetFormattedDocument(Workspace workspace, Document document) + public static async Task GetFormattedText(Document document) { - var formattedDocument = await Formatter.FormatAsync(document, workspace.Options); - var text = await formattedDocument.GetTextAsync(); + var newDocument = await Formatter.FormatAsync(document, document.Project.Solution.Workspace.Options); + var text = await newDocument.GetTextAsync(); return text.ToString(); } - public static async Task> GetFormattedDocumentTextChanges(Workspace workspace, Document document) + public static async Task> GetFormattedTextChanges(Document document) { - var formattedDocument = await Formatter.FormatAsync(document, workspace.Options); - var textChanges = await formattedDocument.GetTextChangesAsync(document); + var newDocument = await Formatter.FormatAsync(document, document.Project.Solution.Workspace.Options); - return await LinePositionSpanTextChange.Convert(document, textChanges); + return await TextChanges.GetAsync(newDocument, document); } } } diff --git a/src/OmniSharp.Roslyn/AssemblyInfo.cs b/src/OmniSharp.Roslyn/AssemblyInfo.cs new file mode 100644 index 0000000000..03cf2732b9 --- /dev/null +++ b/src/OmniSharp.Roslyn/AssemblyInfo.cs @@ -0,0 +1,4 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("OmniSharp.Tests")] +[assembly: InternalsVisibleTo("OmniSharp.Roslyn.CSharp")] \ No newline at end of file diff --git a/src/OmniSharp.Abstractions/Services/ITestCommandProvider.cs b/src/OmniSharp.Roslyn/Services/ITestCommandProvider.cs similarity index 79% rename from src/OmniSharp.Abstractions/Services/ITestCommandProvider.cs rename to src/OmniSharp.Roslyn/Services/ITestCommandProvider.cs index 43391c2676..acbd816d32 100644 --- a/src/OmniSharp.Abstractions/Services/ITestCommandProvider.cs +++ b/src/OmniSharp.Roslyn/Services/ITestCommandProvider.cs @@ -1,4 +1,4 @@ -namespace OmniSharp +namespace OmniSharp.Services { public interface ITestCommandProvider { diff --git a/src/OmniSharp.Abstractions/Services/TestContext.cs b/src/OmniSharp.Roslyn/Services/TestContext.cs similarity index 88% rename from src/OmniSharp.Abstractions/Services/TestContext.cs rename to src/OmniSharp.Roslyn/Services/TestContext.cs index 35a66247a0..2442933cff 100644 --- a/src/OmniSharp.Abstractions/Services/TestContext.cs +++ b/src/OmniSharp.Roslyn/Services/TestContext.cs @@ -1,6 +1,7 @@ using Microsoft.CodeAnalysis; +using OmniSharp.Models.TestCommand; -namespace OmniSharp +namespace OmniSharp.Services { public class TestContext { diff --git a/src/OmniSharp.Roslyn/Utilities/TextChangeHelper.cs b/src/OmniSharp.Roslyn/Utilities/TextChangeHelper.cs new file mode 100644 index 0000000000..1faa3d13b1 --- /dev/null +++ b/src/OmniSharp.Roslyn/Utilities/TextChangeHelper.cs @@ -0,0 +1,72 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Text; +using OmniSharp.Models; + +namespace OmniSharp.Roslyn.Utilities +{ + internal static class TextChanges + { + public static async Task> GetAsync(Document document, Document oldDocument) + { + var changes = await document.GetTextChangesAsync(oldDocument); + var oldText = await oldDocument.GetTextAsync(); + + return Convert(oldText, changes); + } + + public static IEnumerable Convert(SourceText oldText, params TextChange[] changes) + { + return Convert(oldText, (IEnumerable)changes); + } + + public static IEnumerable Convert(SourceText oldText, IEnumerable changes) + { + return changes + .OrderByDescending(change => change.Span) + .Select(change => + { + var span = change.Span; + var newText = change.NewText; + var prefix = string.Empty; + var postfix = string.Empty; + + if (newText.Length > 0) + { + // Roslyn computes text changes on character arrays. So it might happen that a + // change starts inbetween \r\n which is OK when you are offset-based but a problem + // when you are line,column-based. This code extends text edits which just overlap + // a with a line break to its full line break + + if (span.Start > 0 && newText[0] == '\n' && oldText[span.Start - 1] == '\r') + { + // text: foo\r\nbar\r\nfoo + // edit: [----) + span = TextSpan.FromBounds(span.Start - 1, span.End); + prefix = "\r"; + } + if (span.End < oldText.Length - 1 && newText[newText.Length - 1] == '\r' && oldText[span.End] == '\n') + { + // text: foo\r\nbar\r\nfoo + // edit: [----) + span = TextSpan.FromBounds(span.Start, span.End + 1); + postfix = "\n"; + } + } + + var linePositionSpan = oldText.Lines.GetLinePositionSpan(span); + + return new LinePositionSpanTextChange() + { + NewText = prefix + newText + postfix, + StartLine = linePositionSpan.Start.Line, + StartColumn = linePositionSpan.Start.Character, + EndLine = linePositionSpan.End.Line, + EndColumn = linePositionSpan.End.Character + }; + }); + } + } +} diff --git a/tests/OmniSharp.Tests/LinePositionSpanTextChangeFacts.cs b/tests/OmniSharp.Tests/LinePositionSpanTextChangeFacts.cs index 762748292e..b2d70b2bc5 100644 --- a/tests/OmniSharp.Tests/LinePositionSpanTextChangeFacts.cs +++ b/tests/OmniSharp.Tests/LinePositionSpanTextChangeFacts.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Text; -using OmniSharp.Models; +using OmniSharp.Roslyn.Utilities; using TestUtility; using Xunit; using Xunit.Abstractions; @@ -22,9 +22,11 @@ public async Task ExtendsTextChangeAtStart() using (var host = CreateOmniSharpHost(testFile)) { var document = host.Workspace.GetDocument(testFile.FileName); + var text = await document.GetTextAsync(); var textChange = new TextChange(TextSpan.FromBounds(8, 11), "\n}"); - var adjustedTextChanges = await LinePositionSpanTextChange.Convert(document, new[] { textChange }); + + var adjustedTextChanges = TextChanges.Convert(text, textChange); var adjustedTextChange = adjustedTextChanges.First(); Assert.Equal("\r\n}", adjustedTextChange.NewText); @@ -42,9 +44,11 @@ public async Task ExtendsTextChangeAtEnd() using (var host = CreateOmniSharpHost(testFile)) { var document = host.Workspace.GetDocument(testFile.FileName); + var text = await document.GetTextAsync(); var textChange = new TextChange(TextSpan.FromBounds(5, 7), "\r\n {\r"); - var adjustedTextChanges = await LinePositionSpanTextChange.Convert(document, new[] { textChange }); + + var adjustedTextChanges = TextChanges.Convert(text, textChange); var adjustedTextChange = adjustedTextChanges.First(); Assert.Equal("\r\n {\r\n", adjustedTextChange.NewText); From 1a0932f6954ada9ff576101b13cfa131a305a452 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 20 Apr 2017 16:47:05 -0700 Subject: [PATCH 15/15] Clean up some package references --- src/OmniSharp.Abstractions/OmniSharp.Abstractions.csproj | 3 --- src/OmniSharp.Roslyn/OmniSharp.Roslyn.csproj | 7 +------ 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/OmniSharp.Abstractions/OmniSharp.Abstractions.csproj b/src/OmniSharp.Abstractions/OmniSharp.Abstractions.csproj index 8a7928cdbf..a9db2a1ee8 100644 --- a/src/OmniSharp.Abstractions/OmniSharp.Abstractions.csproj +++ b/src/OmniSharp.Abstractions/OmniSharp.Abstractions.csproj @@ -13,7 +13,6 @@ - @@ -26,8 +25,6 @@ - - diff --git a/src/OmniSharp.Roslyn/OmniSharp.Roslyn.csproj b/src/OmniSharp.Roslyn/OmniSharp.Roslyn.csproj index 3d759b6bca..73445d552a 100644 --- a/src/OmniSharp.Roslyn/OmniSharp.Roslyn.csproj +++ b/src/OmniSharp.Roslyn/OmniSharp.Roslyn.csproj @@ -16,12 +16,7 @@ - - - - - - +