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