public IEnumerable<ParsedReference> Parse(string code, IAsset asset) { var comments = commentParser.Parse(code); return from comment in comments from path in ParsePaths(comment.Value, asset, comment.LineNumber) select new ParsedReference { Path = path, LineNumber = comment.LineNumber }; }
private static bool Validate(string header, ICommentParser commentParser) { try { return(commentParser.Parse(header) == header); } catch (ParseException) { return(false); } }
public IComment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options) { var typeAttribute = node.Attributes["type"]; var listTypeName = typeAttribute == null ? string.Empty : typeAttribute.Value; var list = createListForType(listTypeName); foreach (XmlNode itemNode in node.SelectNodes("item")) { Paragraph term = null; Paragraph definition = null; var termNode = itemNode.SelectSingleNode("term"); if (termNode != null) { term = new Paragraph(parser.Parse(termNode.ChildNodes)); } var definitionNode = itemNode.SelectSingleNode("description"); if (definitionNode != null) { definition = new Paragraph(parser.Parse(definitionNode.ChildNodes)); } list.Items.Add(new InlineListItem(term, definition)); } return list; }
public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options) { var typeAttribute = node.Attributes["type"]; var listTypeName = typeAttribute == null ? string.Empty : typeAttribute.Value; var list = createListForType(listTypeName); foreach (XmlNode itemNode in node.SelectNodes("item")) { Paragraph term = null; Paragraph definition = null; var termNode = itemNode.SelectSingleNode("term"); if (termNode != null) { term = new Paragraph(parser.Parse(termNode.ChildNodes)); } var definitionNode = itemNode.SelectSingleNode("description"); if (definitionNode != null) { definition = new Paragraph(parser.Parse(definitionNode.ChildNodes)); } list.Items.Add(new InlineListItem(term, definition)); } return(list); }
private IEnumerable <XmlDocumentationMember> Parse(XmlDocument document) { if (document == null) { throw new ArgumentNullException("document"); } // Get the assembly Identity. var members = new List <XmlDocumentationMember>(); // Get all members and parse them. var nodes = document.SelectNodes("/doc/members/member"); if (nodes != null) { foreach (XmlNode node in nodes) { Debug.Assert(node != null, "Node cannot be null."); Debug.Assert(node.Attributes != null, "Node has no attributes."); var name = node.Attributes["name"]; if (name == null) { throw new SparrowException("Encountered XML member without name."); } var comments = new List <Comment>(); foreach (XmlNode commentNode in node.ChildNodes) { var comment = _parser.Parse(commentNode); if (comment != null) { comments.Add(comment); } } members.Add(new XmlDocumentationMember(name.InnerText, comments)); } } // Return the result. return(members); }
public static string Prepare (string headerText, string currentHeaderText, ICommentParser commentParser) { var lineEndingInDocument = NewLineManager.DetectMostFrequentLineEnd (headerText); var headerWithNewLine = headerText; var newLine = NewLineManager.DetectMostFrequentLineEnd (headerWithNewLine); headerWithNewLine = NewLineManager.ReplaceAllLineEnds (headerWithNewLine, lineEndingInDocument); //if there's a comment right at the beginning of the file, //we need to add an empty line so that the comment doesn't //become a part of the header if (!string.IsNullOrEmpty (commentParser.Parse (currentHeaderText)) && !headerWithNewLine.EndsWith(lineEndingInDocument + lineEndingInDocument)) headerWithNewLine += newLine; return headerWithNewLine; }
public static string Prepare(string headerText, string currentHeaderText, ICommentParser commentParser) { var lineEndingInDocument = NewLineManager.DetectMostFrequentLineEnd(headerText); var headerWithNewLine = headerText; var newLine = NewLineManager.DetectMostFrequentLineEnd(headerWithNewLine); headerWithNewLine = NewLineManager.ReplaceAllLineEnds(headerWithNewLine, lineEndingInDocument); //if there's a comment right at the beginning of the file, //we need to add an empty line so that the comment doesn't //become a part of the header if (!string.IsNullOrEmpty(commentParser.Parse(currentHeaderText)) && !headerWithNewLine.EndsWith(lineEndingInDocument + lineEndingInDocument)) { headerWithNewLine += newLine; } return(headerWithNewLine); }
public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options) { return new Paragraph(parser.Parse(node.ChildNodes)); }
private static bool CurrentFileContainsCommentOnTop(string currentHeaderText, ICommentParser commentParser) { return(!string.IsNullOrEmpty(commentParser.Parse(currentHeaderText))); }
public Comment Parse(ICommentParser parser, XmlNode node, bool first, bool last, ParseOptions options) { return(new Paragraph(parser.Parse(node.ChildNodes))); }