public DocumentationComment GetDocumentation (IEntity entity) { if (entity == null) throw new System.ArgumentNullException ("entity"); // If we had an exception while getting the help xml the monodoc help provider // shouldn't try it again. A corrupt .zip file could cause long tooltip delays otherwise. if (hadError) return null; var idString = entity.GetIdString (); DocumentationComment result; if (commentCache.TryGetValue (idString, out result)) return result; XmlDocument doc = null; try { var helpTree = MonoDevelop.Projects.HelpService.HelpTree; if (helpTree == null) return null; if (entity.EntityType == EntityType.TypeDefinition) { doc = helpTree.GetHelpXml (idString); } else { var parentId = entity.DeclaringTypeDefinition.GetIdString (); doc = helpTree.GetHelpXml (parentId); if (doc == null) return null; XmlNode node = SelectNode (doc, entity); if (node != null) return commentCache [idString] = new DocumentationComment (node.OuterXml, new SimpleTypeResolveContext (entity)); return null; // var node = doc.SelectSingleNode ("/Type/Members/Member") // return new DocumentationComment (doc.OuterXml, new SimpleTypeResolveContext (entity)); } } catch (Exception e) { hadError = true; LoggingService.LogError ("Error while reading monodoc file.", e); } if (doc == null) { commentCache [idString] = null; return null; } return commentCache [idString] = new DocumentationComment (doc.OuterXml, new SimpleTypeResolveContext (entity)); }
static XmlDocumentationElement Create(DocumentationComment documentationComment, IEntity declaringEntity) { var doc = new AXmlParser().Parse(documentationComment.Xml); return new XmlDocumentationElement(doc, declaringEntity, documentationComment.ResolveCref); }
public DocumentationComment GetDocumentation(IEntity entity) { if (entity == null) throw new System.ArgumentNullException("entity"); var idString = entity.GetIdString(); DocumentationComment result; if (commentCache.TryGetValue(idString, out result)) return result; XmlDocument doc = null; try { var helpTree = MonoDevelop.Projects.HelpService.HelpTree; if (helpTree == null) return null; if (entity.EntityType == EntityType.TypeDefinition) { #pragma warning disable 612,618 doc = helpTree.GetHelpXml(idString); #pragma warning restore 612,618 } else { var parentId = entity.DeclaringTypeDefinition.GetIdString(); #pragma warning disable 612,618 doc = helpTree.GetHelpXml(parentId); #pragma warning restore 612,618 if (doc == null) { commentCache[idString] = null; return null; } XmlNode node = SelectNode(doc, entity); if (node != null) return commentCache[idString] = new DocumentationComment(node.OuterXml, new SimpleTypeResolveContext(entity)); commentCache[idString] = null; return null; // var node = doc.SelectSingleNode ("/Type/Members/Member") // return new DocumentationComment (doc.OuterXml, new SimpleTypeResolveContext (entity)); } } catch (Exception e) { Console.WriteLine("Error while reading monodoc file." + e); } if (doc == null) { commentCache[idString] = null; return null; } return commentCache[idString] = new DocumentationComment(doc.OuterXml, new SimpleTypeResolveContext(entity)); }
static string GetCref(ITypeResolveContext ctx, string cref) { if (cref == null) return ""; if (cref.Length < 2) return cref; try { var entity = new DocumentationComment ("", ctx).ResolveCref (cref.Replace("<", "{").Replace(">", "}")); if (entity != null) { var ambience = new ICSharpCode.NRefactory.CSharp.CSharpAmbience (); ambience.ConversionFlags = ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames | ConversionFlags.ShowTypeParameterList; return ambience.ConvertSymbol (entity); } } catch (Exception e) { LoggingService.LogWarning ("Invalid cref:" + cref, e); } if (cref.Substring (1, 1) == ":") return cref.Substring (2, cref.Length - 2); return cref; }