未验证 提交 6c34f631 编写于 作者: D David 提交者: GitHub

Merge pull request #34083 from dibarbet/remove_unused_comment_interface

Remove unused ICommentUncommentService.
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CommentSelection;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Editor.Implementation.CommentSelection
{
/// <summary>
/// Bridge between the new <see cref="ICommentSelectionService"/> and an existing
/// language which only supplies the old <see cref="ICommentUncommentService"/> service.
/// </summary>
internal class CommentSelectionServiceProxy : ICommentSelectionService
{
#pragma warning disable CS0618 // Type or member is obsolete
private readonly ICommentUncommentService _commentUncommentService;
public CommentSelectionServiceProxy(ICommentUncommentService commentUncommentService)
{
_commentUncommentService = commentUncommentService;
}
#pragma warning restore CS0618 // Type or member is obsolete
public Task<CommentSelectionInfo> GetInfoAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken)
=> Task.FromResult(new CommentSelectionInfo(
true, _commentUncommentService.SupportsBlockComment, _commentUncommentService.SingleLineCommentString,
_commentUncommentService.BlockCommentStartString, _commentUncommentService.BlockCommentEndString));
public Task<Document> FormatAsync(Document document, ImmutableArray<TextSpan> changes, CancellationToken cancellationToken)
=> Task.FromResult(_commentUncommentService.Format(document, changes, cancellationToken));
}
}
......@@ -146,15 +146,6 @@ private ICommentSelectionService GetService(Document document)
return service;
}
// If we couldn't find one, fallback to the legacy service.
#pragma warning disable CS0618 // Type or member is obsolete
var legacyService = document.GetLanguageService<ICommentUncommentService>();
#pragma warning restore CS0618 // Type or member is obsolete
if (legacyService != null)
{
return new CommentSelectionServiceProxy(legacyService);
}
return null;
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.Editor.Implementation.CommentSelection
{
[Obsolete("Use Microsoft.CodeAnalysis.CommentSelection.ICommentSelectionService instead")]
internal interface ICommentUncommentService : ILanguageService
{
string SingleLineCommentString { get; }
bool SupportsBlockComment { get; }
string BlockCommentStartString { get; }
string BlockCommentEndString { get; }
Document Format(Document document, IEnumerable<TextSpan> changes, CancellationToken cancellationToken);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册