Esempio n. 1
0
        private static DefinitionSymbol GetDefinitionSymbol(ISymbol symbol, string id = null)
        {
            // Use unspecialized generic
            symbol = symbol.OriginalDefinition;
            id     = id ?? GetDocumentationCommentId(symbol);

            bool isMember = symbol.Kind == SymbolKind.Field ||
                            symbol.Kind == SymbolKind.Method ||
                            symbol.Kind == SymbolKind.Event ||
                            symbol.Kind == SymbolKind.Property;

            string containerQualifierName = string.Empty;

            if (symbol.ContainingSymbol != null)
            {
                containerQualifierName = symbol.ContainingSymbol.ToDisplayString(DisplayFormats.QualifiedNameDisplayFormat);
            }

            var boundSymbol = new DefinitionSymbol()
            {
                ProjectId              = symbol.ContainingAssembly.Name,
                Id                     = CreateSymbolId(id),
                DisplayName            = symbol.GetDisplayString(),
                ShortName              = symbol.ToDisplayString(DisplayFormats.ShortNameDisplayFormat),
                ContainerQualifiedName = containerQualifierName,
                Kind                   = GetSymbolKind(symbol),
                Glyph                  = symbol.GetGlyph(),
                SymbolDepth            = symbol.GetSymbolDepth()
            };

            return(boundSymbol);
        }
        public static void AddAttributeValueDefinition(
            this BoundSourceFileBuilder binder,
            XmlAttributeSyntax attribute,
            DefinitionSymbol definition)
        {
            var node = attribute?.ValueNode.As <XmlStringSyntax>()?.TextTokens.Node;

            if (node != null)
            {
                binder.AnnotateDefinition(node.Start, node.FullWidth, definition);
            }
        }
        public void AppendDefinition(string text, DefinitionSymbol definition)
        {
            SymbolSpan symbolSpan = new SymbolSpan()
            {
                Start  = StringBuilder.Length,
                Length = text.Length,
            };

            StringBuilder.Append(text);
            BoundSourceFile.Definitions.Add(symbolSpan.CreateDefinition(definition));
            references.Add(symbolSpan.CreateReference(definition));
        }
        public void AnnotateDefinition(int start, int length, DefinitionSymbol definition)
        {
            BoundSourceFile.Definitions.Add(new DefinitionSpan()
            {
                Definition = definition,
                Start      = start,
                Length     = length
            });

            references.Add(new ReferenceSpan()
            {
                Start     = start,
                Length    = length,
                Reference = definition
            });
        }
Esempio n. 5
0
        private static DefinitionSymbolModel FromObjectModel(DefinitionSymbol symbol)
        {
            if (symbol == null)
            {
                return(null);
            }

            var tokenizedDisplayName = symbol.DisplayName;

            if (tokenizedDisplayName != null)
            {
                if (!string.IsNullOrEmpty(symbol.ContainerQualifiedName))
                {
                    tokenizedDisplayName = tokenizedDisplayName.Replace(symbol.ContainerQualifiedName, ContainerQualifiedNameToken);
                }

                tokenizedDisplayName = tokenizedDisplayName.Replace(symbol.ShortName, ShortNameToken);
            }

            var result = new DefinitionSymbolModel
            {
                ProjectId                = symbol.ProjectId,
                Id                       = symbol.Id.Value,
                Uid                      = symbol.Uid,
                DisplayName              = symbol.DisplayName,
                ContainerQualifiedName   = symbol.ContainerQualifiedName,
                ShortName                = symbol.ShortName,
                Kind                     = symbol.Kind,
                ExcludeFromSearch        = symbol.ExcludeFromSearch,
                ExcludeFromDefaultSearch = symbol.ExcludeFromDefaultSearch,
                Glyph                    = symbol.Glyph == Glyph.Unknown ? null : symbol.Glyph.ToString(),
                SymbolDepth              = symbol.SymbolDepth,
                IsImplicitlyDeclared     = symbol.IsImplicitlyDeclared,
                ShortDisplayName         = symbol.DeclarationName,
                Comment                  = symbol.Comment,
                TypeName                 = symbol.TypeName
            };

            return(result);
        }