Skip to content

Commit

Permalink
Expose NavigationService to OmniSharp
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Dec 20, 2024
1 parent 9cb6907 commit a48b428
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Composition;
using Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Notification;

namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Internal.Notification;

[ExportWorkspaceService(typeof(INotificationService)), Shared]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class OmniSharpNotificationService(
IOmniSharpNotificationService omniSharpNotificationService) : INotificationService
{
public bool ConfirmMessageBox(string message, string? title = null, NotificationSeverity severity = NotificationSeverity.Warning)
{
return omniSharpNotificationService.ConfirmMessageBox(message, title, (OmniSharpNotificationSeverity)severity);
}

public void SendNotification(string message, string? title = null, NotificationSeverity severity = NotificationSeverity.Warning)
{
omniSharpNotificationService.SendNotification(message, title, (OmniSharpNotificationSeverity)severity);
}
}
13 changes: 13 additions & 0 deletions src/Features/ExternalAccess/OmniSharp/InternalAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Navigation.OmniSharpNavigableIte
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Navigation.OmniSharpNavigableItem.OmniSharpNavigableItem() -> void
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Navigation.OmniSharpNavigableItem.OmniSharpNavigableItem(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.TaggedText> displayTaggedParts, Microsoft.CodeAnalysis.Document! document, Microsoft.CodeAnalysis.Text.TextSpan sourceSpan) -> void
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Navigation.OmniSharpNavigableItem.SourceSpan.get -> Microsoft.CodeAnalysis.Text.TextSpan
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.IOmniSharpNotificationService
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.IOmniSharpNotificationService.ConfirmMessageBox(string! message, string? title = null, Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.OmniSharpNotificationSeverity severity = Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.OmniSharpNotificationSeverity.Warning) -> bool
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.IOmniSharpNotificationService.SendNotification(string! message, string? title = null, Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.OmniSharpNotificationSeverity severity = Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.OmniSharpNotificationSeverity.Warning) -> void
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.OmniSharpNotificationSeverity
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.OmniSharpNotificationSeverity.Error = 2 -> Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.OmniSharpNotificationSeverity
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.OmniSharpNotificationSeverity.Information = 0 -> Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.OmniSharpNotificationSeverity
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.OmniSharpNotificationSeverity.Warning = 1 -> Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification.OmniSharpNotificationSeverity
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.OmniSharpRenameOptions
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.OmniSharpRenameOptions.Deconstruct(out bool RenameInComments, out bool RenameInStrings, out bool RenameOverloads) -> void
Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.OmniSharpRenameOptions.Equals(Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.OmniSharpRenameOptions other) -> bool
Expand Down Expand Up @@ -381,3 +388,9 @@ virtual Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.NavigateTo.OmniSharpNavi
~override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.OmniSharpRenamer.RenameResult.ToString() -> string
~override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockStructureOptions.Equals(object obj) -> bool
~override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockStructureOptions.ToString() -> string
~override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.OmniSharpRenameOptions.Equals(object obj) -> bool
~override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.OmniSharpRenameOptions.ToString() -> string
~override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.OmniSharpRenamer.RenameResult.Equals(object obj) -> bool
~override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.OmniSharpRenamer.RenameResult.ToString() -> string
~override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockStructureOptions.Equals(object obj) -> bool
~override Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Structure.OmniSharpBlockStructureOptions.ToString() -> string
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification;

internal interface IOmniSharpNotificationService
{
/// <summary>
/// Displays a message box with an OK button to the user.
/// </summary>
/// <param name="message">The message shown within the message box.</param>
/// <param name="title">The title bar to be shown in the message box. May be ignored by some implementations.</param>
/// <param name="severity">The severity of the message.</param>
void SendNotification(
string message,
string? title = null,
OmniSharpNotificationSeverity severity = OmniSharpNotificationSeverity.Warning);

/// <summary>
/// Displays a message box with a yes/no question to the user.
/// </summary>
/// <param name="message">The message shown within the message box.</param>
/// <param name="title">The title bar to be shown in the message box. May be ignored by some implementations.</param>
/// <param name="severity">The severity of the message.</param>
/// <returns>true if yes was clicked, false otherwise.</returns>
bool ConfirmMessageBox(
string message,
string? title = null,
OmniSharpNotificationSeverity severity = OmniSharpNotificationSeverity.Warning);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CodeAnalysis.Notification;

namespace Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.Notification;

internal enum OmniSharpNotificationSeverity
{
Information = NotificationSeverity.Information,
Warning = NotificationSeverity.Warning,
Error = NotificationSeverity.Error
}

0 comments on commit a48b428

Please sign in to comment.