示例#1
0
 private static bool?GetIsExternal(ReferenceItem reference)
 {
     if (reference.IsDefinition != true)
     {
         return(null);
     }
     foreach (var list in reference.Parts.Values)
     {
         foreach (var item in list)
         {
             if (item.IsExternalPath)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#2
0
        public void Merge(ReferenceItem other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }
            IsDefinition = Merge(other.IsDefinition, IsDefinition);
            Definition   = Merge(other.Definition, Definition);
            Parent       = Merge(other.Parent, Parent);

            if (other.Parts != null && Parts != null)
            {
                foreach (var pair in other.Parts)
                {
                    var             sourceParts = pair.Value;
                    List <LinkItem> targetParts;
                    if (Parts.TryGetValue(pair.Key, out targetParts))
                    {
                        if (sourceParts.Count == 0)
                        {
                            continue;
                        }
                        Debug.Assert(sourceParts.Count == targetParts.Count);
                        for (int i = 0; i < sourceParts.Count; i++)
                        {
                            Debug.Assert(sourceParts[i].Name == targetParts[i].Name);
                            // Disable for now as it will fail for .NET Core project
                            // Debug.Assert(sourceParts[i].DisplayName == targetParts[i].DisplayName);
                            // Debug.Assert(sourceParts[i].DisplayQualifiedNames == targetParts[i].DisplayQualifiedNames);
                            targetParts[i].IsExternalPath &= sourceParts[i].IsExternalPath;
                            targetParts[i].Href            = targetParts[i].Href ?? sourceParts[i].Href;
                        }
                    }
                    else
                    {
                        Parts.Add(pair.Key, pair.Value);
                    }
                }
            }
            else
            {
                Parts = Parts ?? other.Parts;
            }
        }
示例#3
0
        private static string GetName(ReferenceItem reference, SyntaxLanguage language, Converter <LinkItem, string> getName)
        {
            var list = reference.Parts.GetLanguageProperty(language);

            if (list == null)
            {
                return(null);
            }
            if (list.Count == 0)
            {
                Debug.Fail("Unexpected reference.");
                return(null);
            }
            if (list.Count == 1)
            {
                return(getName(list[0]));
            }
            return(string.Concat(list.ConvertAll(item => getName(item)).ToArray()));
        }
示例#4
0
        internal string AddSpecReference(
            ISymbol symbol,
            IReadOnlyList <string> typeGenericParameters,
            IReadOnlyList <string> methodGenericParameters,
            Dictionary <string, ReferenceItem> references,
            SymbolVisitorAdapter adapter)
        {
            var           rawId     = VisitorHelper.GetId(symbol);
            var           id        = SpecIdHelper.GetSpecId(symbol, typeGenericParameters, methodGenericParameters);
            ReferenceItem reference = new ReferenceItem();

            reference.Parts = new SortedList <SyntaxLanguage, List <LinkItem> >();
            GenerateReferenceInternal(symbol, reference, adapter);
            var originalSymbol = symbol;
            var reducedFrom    = (symbol as IMethodSymbol)?.ReducedFrom;

            if (reducedFrom != null)
            {
                originalSymbol = reducedFrom;
            }
            reference.IsDefinition = (originalSymbol == symbol) && (id == rawId) && symbol.IsDefinition;

            if (!reference.IsDefinition.Value && rawId != null)
            {
                reference.Definition = AddReference(originalSymbol.OriginalDefinition, references, adapter);
            }

            reference.Parent    = GetReferenceParent(originalSymbol, typeGenericParameters, methodGenericParameters, references, adapter);
            reference.CommentId = VisitorHelper.GetCommentId(originalSymbol);

            if (!references.ContainsKey(id))
            {
                references[id] = reference;
            }
            else
            {
                references[id].Merge(reference);
            }

            return(id);
        }
示例#5
0
        internal string AddReference(ISymbol symbol, Dictionary <string, ReferenceItem> references, SymbolVisitorAdapter adapter)
        {
            var id = VisitorHelper.GetId(symbol);

            ReferenceItem reference = new ReferenceItem();

            reference.Parts        = new SortedList <SyntaxLanguage, List <LinkItem> >();
            reference.IsDefinition = symbol.IsDefinition;
            GenerateReferenceInternal(symbol, reference, adapter);

            if (!references.ContainsKey(id))
            {
                references[id] = reference;
            }
            else
            {
                references[id].Merge(reference);
            }

            return(id);
        }
示例#6
0
        internal string AddOverloadReference(ISymbol symbol, Dictionary <string, ReferenceItem> references, SymbolVisitorAdapter adapter)
        {
            string uidBody = VisitorHelper.GetOverloadIdBody(symbol);

            ReferenceItem reference = new ReferenceItem();

            reference.Parts        = new SortedList <SyntaxLanguage, List <LinkItem> >();
            reference.IsDefinition = true;
            reference.CommentId    = "Overload:" + uidBody;
            GenerateReferenceInternal(symbol, reference, adapter, true);

            var uid = uidBody + "*";

            if (!references.ContainsKey(uid))
            {
                references[uid] = reference;
            }
            else
            {
                references[uid].Merge(reference);
            }

            return(uid);
        }
示例#7
0
 internal abstract void GenerateReferenceInternal(ISymbol symbol, ReferenceItem reference, SymbolVisitorAdapter adapter);
示例#8
0
 protected ReferenceItemVisitor(ReferenceItem referenceItem)
 {
     ReferenceItem = referenceItem;
 }
示例#9
0
 internal abstract void GenerateReferenceInternal(ISymbol symbol, ReferenceItem reference, SymbolVisitorAdapter adapter, bool asOverload = false);
示例#10
0
 internal override sealed void GenerateReferenceInternal(ISymbol symbol, ReferenceItem reference, SymbolVisitorAdapter adapter)
 {
     GenerateReference(symbol, reference, adapter);
 }
示例#11
0
 protected abstract void GenerateReference(ISymbol symbol, ReferenceItem reference, SymbolVisitorAdapter adapter);