Пример #1
0
		private IEnumerable<Tuple<DocElementType, DocElement>> ParseDocumentation(LangElement element)
		{
			CommentSet cs;

			// if there is no commentary annotation present, exit
			if (!element.Annotations.TryGet<CommentSet>(out cs))
				return null;

			// if there are no preceeding comments, exit
			if (cs.Preceeding.Count == 0)
				return null;

			// if the last preceeding comment is not doc comment, exit
            Comment lastcs = cs.Preceeding[cs.Preceeding.Count - 1];
            if (lastcs.Type != CommentType.Documentation)
				return null;

            //
            // parse the comment to resolve a collection of DocElement
            //
			Scanner scanner = new Scanner(new StringReader(lastcs.Content ?? string.Empty));

            Parser parser = new Parser() { Scanner = scanner };
			parser.Parse();

			//of there was an error during parsing, null is returned here
			return parser.Elements;
		}
Пример #2
0
 /// <summary>
 /// Visit language element and all children recursively.
 /// Depth-first search.
 /// </summary>
 /// <param name="element">Any LanguageElement. Can be null.</param>
 public virtual void VisitElement(LangElement element)
 {
     if ( element != null )
         element.VisitMe(this);
 }
Пример #3
0
 /// <summary>
 /// Finds DOC comment at given position and annotates statement with it.
 /// </summary>
 private void Annotate(LangElement/*!*/stmt, int start)
 {
     PHPDocBlock phpdoc;
     if (TryReleaseBlock(start, out phpdoc))
     {
         stmt.SetPHPDoc(phpdoc);
     }
 }
Пример #4
0
 /// <summary>
 /// Parses the comments around the element. Set new DocBlock annotation.
 /// </summary>
 /// <param name="element">Element to be parsed.</param>
 /// <returns>DocBlock of the element.</returns>
 public static DocBlock ParseSubtree(LangElement element)
 {
     (new DocResolver()).VisitElement(element);
     return element.Annotations.Get<DocBlock>();
 }