private void AppendTypeElement([NotNull] ITypeElement typeElement, [NotNull] ISubstitution substitution, NamespaceDisplays expectedNamespaceDisplay) { if (!(typeElement is ITypeParameter)) { if ((_options.ShowNamespaces & expectedNamespaceDisplay) != NamespaceDisplays.None) { AppendNamespace(typeElement.GetContainingNamespace()); AppendText(".", VsHighlightingAttributeIds.Operator); } ITypeElement containingType = typeElement.GetContainingType(); if (containingType != null && !(typeElement is IDelegate && _options.FormatDelegatesAsLambdas)) { AppendDeclaredType(TypeFactory.CreateType(containingType, substitution), NamespaceDisplays.None); AppendText(".", VsHighlightingAttributeIds.Operator); } } var deleg = typeElement as IDelegate; if (deleg != null && _options.FormatDelegatesAsLambdas && expectedNamespaceDisplay == NamespaceDisplays.Parameters) { AppendParameters(deleg.InvokeMethod, substitution, false); AppendText(" => ", VsHighlightingAttributeIds.Operator); AppendType(substitution.Apply(deleg.InvokeMethod.ReturnType), expectedNamespaceDisplay); return; } string attributeId = _options.UseReSharperColors ? HighlightingAttributeIds.GetHighlightAttributeForTypeElement(typeElement) : VsHighlightingAttributeIds.GetForTypeElement(typeElement); AppendText(FormatShortName(typeElement.ShortName), attributeId); AppendTypeParameters(typeElement, substitution); }
public static string GetHighlightingAttributeId([CanBeNull] this ITypeElement typeElement, bool useReSharperColors) { if (typeElement == null) { return(null); } if (useReSharperColors) { return(HighlightingAttributeIds.GetHighlightAttributeForTypeElement(typeElement)); } return(VsHighlightingAttributeIds.GetForTypeElement(typeElement)); }
public string GetForTypeElement([CanBeNull] ITypeElement typeElement) { if (typeElement == null) { return(null); } if (_useReSharperColors) { return(HighlightingAttributeIds.GetHighlightAttributeForTypeElement(typeElement)); } if (typeElement is IDelegate) { return(Delegate); } if (typeElement is IEnum) { return(Enum); } if (typeElement is IInterface) { return(Interface); } if (typeElement is IStruct) { return(Struct); } if (typeElement is ITypeParameter) { return(TypeParameter); } var @class = typeElement as IClass; if (@class != null) { return(@class.IsAbstract && @class.IsSealed ? StaticClass : Class); } return(VsIdentifier); }
public string GetForTypeElement([CanBeNull] ITypeElement typeElement) { if (typeElement == null) { return(null); } if (_useReSharperColors) { return(HighlightingAttributeIds.GetHighlightAttributeForTypeElement(typeElement)); } switch (typeElement) { case IDelegate _: return(Delegate); case IEnum _: return(Enum); case IInterface _: return(Interface); case IStruct _: return(Struct); case ITypeParameter _: return(TypeParameter); case IClass @class: return(@class.IsAbstract && @class.IsSealed ? StaticClass : Class); default: return(VsIdentifier); } }