public override void WriteStartType(INamedTypeSymbol typeSymbol)
        {
            if (typeSymbol != null)
            {
                WriteLocalRef(typeSymbol);

                bool writeHierarchyLinks = Layout == SymbolDefinitionListLayout.TypeHierarchy &&
                                           _typeHierarchy?.Count > 1;

                if (writeHierarchyLinks)
                {
                    for (int i = 0; i < _typeHierarchy.Count - 1; i++)
                    {
                        TypeHierarchyItem item = _typeHierarchy[i];

                        WriteStartElement("a");
                        WriteStartAttribute("href");
                        Write("#");
                        WriteLocalLink(item.Symbol);
                        WriteEndAttribute();
                        WriteStartAttribute("title");

                        if (i == _typeHierarchy.Count - 2)
                        {
                            for (int j = 0; j < _typeHierarchy.Count - 1; j++)
                            {
                                for (int k = 1; k <= j; k++)
                                {
                                    Write(" ");
                                }

                                base.WriteSymbol(_typeHierarchy[j].Symbol, TypeSymbolDisplayFormats.Name_ContainingTypes_TypeParameters);

                                if (j < _typeHierarchy.Count - 2)
                                {
                                    _writer.WriteWhitespace(_writer.Settings.NewLineChars);
                                }
                            }
                        }
                        else
                        {
                            base.WriteSymbol(item.Symbol, TypeSymbolDisplayFormats.Name_ContainingTypes_TypeParameters);
                        }

                        WriteEndAttribute();
                        WriteAttributeString("class", "type-hierarchy-link");
                        _writer.WriteRaw("&middot;");
                        WriteEndElement();
                        Write(" ");
                    }
                }

                bool isExternal = Layout == SymbolDefinitionListLayout.TypeHierarchy &&
                                  IsExternal(typeSymbol);

                WriteStartCodeElement(indent: !writeHierarchyLinks, isExternal: isExternal);
            }
        }
예제 #2
0
        internal override void WriteTypeHierarchyItem(TypeHierarchyItem item, CancellationToken cancellationToken = default)
        {
            INamedTypeSymbol typeSymbol = item.Symbol;

            if (HasContent(item))
            {
                WriteStartObject();

                WritePropertyName("type");
                WriteDefinition(typeSymbol, DefinitionFormat);

                if (Format.Includes(SymbolDefinitionPartFilter.Attributes))
                {
                    WriteAttributes(typeSymbol);
                    WriteParameters(GetParameters(typeSymbol));
                }

                if (!item.IsExternal)
                {
                    WriteMembers(typeSymbol);
                }

                if (item.HasChildren)
                {
                    SymbolHierarchy.Add(item.Symbol);
                    WriteStartHierarchyTypes();

                    foreach (TypeHierarchyItem child in item.Children())
                    {
                        WriteTypeSeparator();
                        WriteTypeHierarchyItem(child, cancellationToken);
                    }

                    WriteEndHierarchyTypes();
                    SymbolHierarchy.RemoveAt(SymbolHierarchy.Count - 1);
                }

                WriteEndObject();
            }
            else if (typeSymbol != null)
            {
                WriteDefinition(typeSymbol, DefinitionFormat);
            }
            else
            {
                WriteValue("");
            }
        }
 internal override void WriteTypeHierarchyItem(TypeHierarchyItem item, CancellationToken cancellationToken = default)
 {
     (_typeHierarchy ??= new List <TypeHierarchyItem>()).Add(item);
     base.WriteTypeHierarchyItem(item, cancellationToken);
     _typeHierarchy.RemoveAt(_typeHierarchy.Count - 1);
 }
예제 #4
0
 private bool HasContent(TypeHierarchyItem item)
 {
     return(item.HasChildren ||
            HasContent(item.Symbol));
 }