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); }
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; } }
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())); }
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); }
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); }
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); }
internal abstract void GenerateReferenceInternal(ISymbol symbol, ReferenceItem reference, SymbolVisitorAdapter adapter);
protected ReferenceItemVisitor(ReferenceItem referenceItem) { ReferenceItem = referenceItem; }
internal abstract void GenerateReferenceInternal(ISymbol symbol, ReferenceItem reference, SymbolVisitorAdapter adapter, bool asOverload = false);
internal override sealed void GenerateReferenceInternal(ISymbol symbol, ReferenceItem reference, SymbolVisitorAdapter adapter) { GenerateReference(symbol, reference, adapter); }
protected abstract void GenerateReference(ISymbol symbol, ReferenceItem reference, SymbolVisitorAdapter adapter);