refactor AddType
This commit is contained in:
@@ -351,6 +351,14 @@ public static partial class SymbolInfoComponents
|
||||
label.Pop(); // table
|
||||
}
|
||||
|
||||
private static void AddType(this RichTextLabel label, ITypeSymbol symbol)
|
||||
{
|
||||
var colour = symbol.GetSymbolColourByType();
|
||||
label.PushColor(colour);
|
||||
label.AddText(symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
label.Pop();
|
||||
}
|
||||
|
||||
// TODO: handle arrays etc, where there are multiple colours in one type
|
||||
private static Color GetSymbolColourByType(this ITypeSymbol symbol)
|
||||
{
|
||||
|
||||
@@ -57,9 +57,7 @@ public static partial class SymbolInfoComponents
|
||||
|
||||
private static void AddFieldTypeName(this RichTextLabel label, IFieldSymbol fieldSymbol)
|
||||
{
|
||||
label.PushColor(GetSymbolColourByType(fieldSymbol.Type));
|
||||
label.AddText(fieldSymbol.Type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
label.Pop();
|
||||
label.AddType(fieldSymbol.Type);
|
||||
label.AddText(" ");
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,7 @@ public static partial class SymbolInfoComponents
|
||||
|
||||
private static void AddLocalVariableTypeName(this RichTextLabel label, ILocalSymbol symbol)
|
||||
{
|
||||
label.PushColor(GetSymbolColourByType(symbol.Type));
|
||||
label.AddText(symbol.Type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
label.Pop();
|
||||
label.AddType(symbol.Type);
|
||||
label.AddText(" ");
|
||||
}
|
||||
|
||||
|
||||
@@ -124,9 +124,7 @@ public static partial class SymbolInfoComponents
|
||||
label.Pop();
|
||||
label.AddText(" ");
|
||||
}
|
||||
label.PushColor(parameterSymbol.Type.GetSymbolColourByType());
|
||||
label.AddText(parameterSymbol.Type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
label.Pop();
|
||||
label.AddType(parameterSymbol.Type);
|
||||
label.AddText(" ");
|
||||
label.PushColor(CachedColors.VariableBlue);
|
||||
label.AddText(parameterSymbol.Name);
|
||||
@@ -209,9 +207,7 @@ public static partial class SymbolInfoComponents
|
||||
label.AddText(typeParameter.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
label.Pop();
|
||||
label.AddText(" is ");
|
||||
label.PushColor(typeArgument.GetSymbolColourByType());
|
||||
label.AddText(typeArgument.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
label.Pop();
|
||||
label.AddType(typeArgument);
|
||||
if (index < methodSymbol.TypeArguments.Length - 1)
|
||||
{
|
||||
label.Newline();
|
||||
|
||||
@@ -33,9 +33,7 @@ public static partial class SymbolInfoComponents
|
||||
|
||||
private static void AddNamedTypeSymbolName(this RichTextLabel label, INamedTypeSymbol symbol)
|
||||
{
|
||||
label.PushColor(GetSymbolColourByType(symbol));
|
||||
label.AddText(symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
label.Pop();
|
||||
label.AddType(symbol);
|
||||
}
|
||||
|
||||
private static void AddInheritedTypes(this RichTextLabel label, INamedTypeSymbol symbol)
|
||||
@@ -43,9 +41,7 @@ public static partial class SymbolInfoComponents
|
||||
if (symbol.BaseType is not null && symbol.BaseType.SpecialType != SpecialType.System_Object)
|
||||
{
|
||||
label.AddText(" : ");
|
||||
label.PushColor(GetSymbolColourByType(symbol.BaseType));
|
||||
label.AddText(symbol.BaseType.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
label.Pop();
|
||||
label.AddType(symbol.BaseType);
|
||||
}
|
||||
if (symbol.Interfaces.Length > 0)
|
||||
{
|
||||
@@ -59,10 +55,8 @@ public static partial class SymbolInfoComponents
|
||||
}
|
||||
for (int i = 0; i < symbol.Interfaces.Length; i++)
|
||||
{
|
||||
var iface = symbol.Interfaces[i];
|
||||
label.PushColor(GetSymbolColourByType(iface));
|
||||
label.AddText(iface.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
label.Pop();
|
||||
var @interface = symbol.Interfaces[i];
|
||||
label.AddType(@interface);
|
||||
if (i < symbol.Interfaces.Length - 1)
|
||||
{
|
||||
label.AddText(", ");
|
||||
|
||||
@@ -34,9 +34,7 @@ public static partial class SymbolInfoComponents
|
||||
|
||||
private static void AddParameterTypeName(this RichTextLabel label, IParameterSymbol symbol)
|
||||
{
|
||||
label.PushColor(GetSymbolColourByType(symbol.Type));
|
||||
label.AddText(symbol.Type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
label.Pop();
|
||||
label.AddType(symbol.Type);
|
||||
label.AddText(" ");
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,7 @@ public partial class SymbolInfoComponents
|
||||
|
||||
private static void AddPropertyTypeName(this RichTextLabel label, IPropertySymbol symbol)
|
||||
{
|
||||
label.PushColor(GetSymbolColourByType(symbol.Type));
|
||||
label.AddText(symbol.Type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
|
||||
label.Pop();
|
||||
label.AddType(symbol.Type);
|
||||
label.AddText(" ");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user