未验证 提交 ed1b58c7 编写于 作者: D David Wengier 提交者: GitHub

Don't map completion items to function (#47412)

上级 7e65d92e
......@@ -24,6 +24,8 @@ namespace Microsoft.CodeAnalysis.LanguageServer
{
internal static class ProtocolConversions
{
// NOTE: While the spec allows it, don't use Function and Method, as both VS and VS Code display them the same way
// which can confuse users
public static readonly Dictionary<string, LSP.CompletionItemKind> RoslynTagToCompletionItemKind = new Dictionary<string, LSP.CompletionItemKind>()
{
{ WellKnownTags.Public, LSP.CompletionItemKind.Keyword },
......@@ -36,7 +38,7 @@ internal static class ProtocolConversions
{ WellKnownTags.Assembly, LSP.CompletionItemKind.File },
{ WellKnownTags.Class, LSP.CompletionItemKind.Class },
{ WellKnownTags.Constant, LSP.CompletionItemKind.Constant },
{ WellKnownTags.Delegate, LSP.CompletionItemKind.Function },
{ WellKnownTags.Delegate, LSP.CompletionItemKind.Method },
{ WellKnownTags.Enum, LSP.CompletionItemKind.Enum },
{ WellKnownTags.EnumMember, LSP.CompletionItemKind.EnumMember },
{ WellKnownTags.Event, LSP.CompletionItemKind.Event },
......@@ -326,7 +328,6 @@ public static LSP.SymbolKind GlyphToSymbolKind(Glyph glyph)
case Glyph.DelegateProtected:
case Glyph.DelegatePrivate:
case Glyph.DelegateInternal:
return LSP.SymbolKind.Function;
case Glyph.ExtensionMethodPublic:
case Glyph.ExtensionMethodProtected:
case Glyph.ExtensionMethodPrivate:
......@@ -355,9 +356,8 @@ public static Glyph CompletionItemKindToGlyph(LSP.CompletionItemKind kind)
return Glyph.None;
case LSP.CompletionItemKind.Method:
case LSP.CompletionItemKind.Constructor:
case LSP.CompletionItemKind.Function: // We don't use Function, but map it just in case. It has the same icon as Method in VS and VS Code
return Glyph.MethodPublic;
case LSP.CompletionItemKind.Function:
return Glyph.DelegatePublic;
case LSP.CompletionItemKind.Field:
return Glyph.FieldPublic;
case LSP.CompletionItemKind.Variable:
......
// 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.Linq;
using Microsoft.VisualStudio.LanguageServer.Protocol;
using Xunit;
namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests
{
public class ProtocolConversionsTests
{
[Fact]
public void CompletionItemKind_DontUseMethodAndFunction()
{
var map = ProtocolConversions.RoslynTagToCompletionItemKind;
var containsMethod = map.Values.Any(c => c == CompletionItemKind.Method);
var containsFunction = map.Values.Any(c => c == CompletionItemKind.Function);
Assert.False(containsFunction && containsMethod, "Don't use Method and Function completion item kinds as it causes user confusion.");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册