Skip to content

Commit

Permalink
Move Glyph helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwengier committed Sep 24, 2020
1 parent c703f1a commit 0b60e89
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/EditorFeatures/Core/Shared/Extensions/GlyphExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.Tags;
using Microsoft.VisualStudio.Core.Imaging;
using Microsoft.VisualStudio.Imaging;
using Microsoft.VisualStudio.Text.Adornments;

namespace Microsoft.CodeAnalysis.Editor.Shared.Extensions
{
Expand Down Expand Up @@ -219,5 +220,8 @@ public static ImageId GetImageId(this Glyph glyph)
throw new ArgumentException(nameof(glyph));
}
}

public static ImageElement GetImageElement(this Glyph glyph)
=> new ImageElement(glyph.GetImageId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Classification;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.FindSymbols.Finders;
Expand Down Expand Up @@ -179,7 +180,7 @@ public override async ValueTask OnReferenceFoundAsync(SourceReferenceItem refere
{
DefinitionId = definitionId,
DefinitionText = definitionText, // Only definitions should have a non-null DefinitionText
DefinitionIcon = ProtocolConversions.GlyphToImageElement(definitionGlyph),
DefinitionIcon = definitionGlyph.GetImageElement(),
DisplayPath = location.Uri.LocalPath,
Id = id,
Kind = symbolUsageInfo.HasValue ? ProtocolConversions.SymbolUsageInfoToReferenceKinds(symbolUsageInfo.Value) : Array.Empty<ReferenceKind>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,6 @@ public static Glyph CompletionItemKindToGlyph(LSP.CompletionItemKind kind)
}
}

public static ImageElement GlyphToImageElement(Glyph glyph)
=> new ImageElement(glyph.GetImageId());

// The mappings here are roughly based off of SymbolUsageInfoExtensions.ToSymbolReferenceKinds.
public static LSP.ReferenceKind[] SymbolUsageInfoToReferenceKinds(SymbolUsageInfo symbolUsageInfo)
{
Expand Down

0 comments on commit 0b60e89

Please sign in to comment.