void SerializePHPDoc(IDocBlock doc) { if (doc != null) { _serializer.Serialize("PHPDoc", SerializeSpan(doc.Span), new NodeObj("Comment", doc.Summary ?? string.Empty)); } }
/// <summary> /// Returns first <see cref="IDocEntry"/> of type <typeparamref name="T"/>, or <c>null</c> if there is no such entry. /// </summary> /// <typeparam name="T">Type of entry.</typeparam> /// <param name="docblock">Block of entries.</param> public static T GetElementOfType <T>(this IDocBlock docblock) where T : IDocEntry { foreach (var entry in docblock) { if (entry is T t) { return(t); } } return(default(T)); }
/// <summary> /// Inserts DOC block into the list. /// </summary> public IPhpDocExtent /*!*/ Append(IDocBlock /*!*/ phpdoc) { Debug.Assert(phpdoc != null); Debug.Assert(_doclist == null || _doclist.Count == 0 || _doclist.Last().Extent.Start < phpdoc.Span.Start, "Blocks have to be appended in order."); var docinfo = new PhpDocExtent(phpdoc); _doclist.Add(docinfo); // return(docinfo); }
/// <summary> /// Finds DOC comment above given position, removes it from the internal list and returns its reference. /// </summary> public bool TryReleaseIndexedBlock(int index, out IDocBlock phpdoc) { if (index >= 0 && index < _doclist.Count) { var list = _doclist; phpdoc = list[index].DocComment; list.RemoveAt(index); // return(true); } // phpdoc = null; return(false); }
/// <summary> /// Sets <see cref="PHPDocBlock"/> to <paramref name="properties"/>. /// </summary> public static void SetPHPDoc(this IPropertyCollection /*!*/ properties, IDocBlock phpdoc) { if (phpdoc != null) { properties.SetProperty <IDocBlock>(phpdoc); // remember LangElement associated with phpdoc if (properties is LangElement element) { phpdoc.Properties.SetProperty <LangElement>(element); } } else { properties.RemoveProperty <IDocBlock>(); } }
public PHPDocStmt(IDocBlock /*!*/ docblock) : base(docblock.Span) { Debug.Assert(docblock != null); this.PHPDoc = docblock ?? throw new ArgumentNullException(nameof(docblock)); }
public virtual LangElement PHPDoc(Span span, IDocBlock block) { return(new PHPDocStmt(block)); }
public override LangElement PHPDoc(Span span, IDocBlock content) => CountLE(base.PHPDoc(span, content));
/// <summary> /// Finds DOC comment above given position, removes it from the internal list and returns its reference. /// </summary> public bool TryReleaseBlock(int position, out IDocBlock phpdoc) { var index = this.FindIndex(position - 1); return(TryReleaseIndexedBlock(index, out phpdoc)); }
public PhpDocExtent(IDocBlock phpdoc) { this.DocComment = phpdoc ?? throw new ArgumentNullException(nameof(phpdoc)); this.Extent = phpdoc.Span; }
/// <summary> /// Finds DOC comment inside given position, removes it from the internal list and returns its reference. /// </summary> public bool TryReleaseBlock(Span position, out IDocBlock phpdoc) { var index = FindFirstIn(_doclist, position); return(TryReleaseIndexedBlock(index, out phpdoc)); }
virtual public void VisitPHPDocBlock(IDocBlock x) { // nothing }
void SetDocBlock() => DocComment = _docblockFactory.CreateDocBlock(new Span(_charOffset, this.TokenLength), GetTokenString(intern: false)); // TokenPosition is not updated yet at this point void ResetDocBlock() => DocComment = null;
void SetDocBlock() => DocComment = _docblockFactory.CreateDocBlock(new Span(_charOffset, this.TokenLength), GetTokenString(intern: false)); // TokenPosition is not updated yet at this point