提交 607515b4 编写于 作者: C Cyrus Najmabadi

Fix goto-def and glyph for builtin operators.

上级 5a8dabf9
......@@ -97,6 +97,18 @@ internal static class DefinitionItemExtensions
// root definition node for it. That node won't be navigable.
if (definition.Kind != SymbolKind.Namespace)
{
if (definition is IMethodSymbol methodSymbol &&
methodSymbol.MethodKind == MethodKind.BuiltinOperator)
{
// Built-in operators (like string's operator `==`) don't have any actual
// locations. But we still want to be able to go-to def on them. Treat them as
// a metadata-definition as that's how they're viewed by the rest of the
// language service.
return DefinitionItem.CreateMetadataDefinition(
tags, displayParts, nameDisplayParts, project,
definition, properties, displayIfNoReferences);
}
foreach (var location in definition.Locations)
{
if (location.IsInMetadata)
......
......@@ -93,11 +93,14 @@ public static Glyph GetGlyph(this ISymbol symbol)
{
var methodSymbol = (IMethodSymbol)symbol;
if (methodSymbol.MethodKind == MethodKind.UserDefinedOperator || methodSymbol.MethodKind == MethodKind.Conversion)
if (methodSymbol.MethodKind == MethodKind.UserDefinedOperator ||
methodSymbol.MethodKind == MethodKind.Conversion ||
methodSymbol.MethodKind == MethodKind.BuiltinOperator)
{
return Glyph.Operator;
}
else if (methodSymbol.IsExtensionMethod || methodSymbol.MethodKind == MethodKind.ReducedExtension)
else if (methodSymbol.IsExtensionMethod ||
methodSymbol.MethodKind == MethodKind.ReducedExtension)
{
publicIcon = Glyph.ExtensionMethodPublic;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册