/// <summary> /// Parses an attribute. /// </summary> /// <param name="comments">The comments.</param> /// <param name="nested">Whether or not the attribute is nested/chained.</param> /// <returns>An attribute code element.</returns> private AttributeElement ParseAttribute(ReadOnlyCollection<ICommentElement> comments, bool nested) { AttributeElement attributeElement = new AttributeElement(); string typeName = CaptureTypeName(false); EatLineContinuation(); // // Check for an attribute target // if (TryReadChar(VBSymbol.LineDelimiter)) { attributeElement.Target = typeName; typeName = CaptureTypeName(false); EatLineContinuation(); } attributeElement.Name = typeName; if (NextChar == VBSymbol.BeginParameterList) { string attributeText = ParseNestedText( VBSymbol.BeginParameterList, VBSymbol.EndParameterList, true, true); attributeElement.BodyText = attributeText; } EatLineContinuation(); while (!nested && TryReadChar(VBSymbol.AliasSeparator)) { if (NextChar != VBSymbol.AliasSeparator) { AttributeElement childAttributeElement = ParseAttribute(null, true); if (string.IsNullOrEmpty(childAttributeElement.Target)) { childAttributeElement.Target = attributeElement.Target; } attributeElement.AddChild(childAttributeElement); } } EatLineContinuation(); if (!nested) { EatChar(VBSymbol.EndAttribute); } if (comments != null && comments.Count > 0) { foreach (ICommentElement comment in comments) { attributeElement.AddHeaderComment(comment); } } return attributeElement; }
/// <summary> /// Parses a VB Option directive from comments. /// </summary> /// <param name="comments">Comments to analyze.</param> /// <returns>The code element.</returns> private ICodeElement ParseOption(ReadOnlyCollection<ICommentElement> comments) { // HACK: Create an explicit element type for Option (or compiler directive) string option = VBKeyword.Option + ReadCodeLine(); AttributeElement optionElement = new AttributeElement(); optionElement.BodyText = option; optionElement[VBExtendedProperties.Option] = true; foreach (ICommentElement comment in comments) { optionElement.AddHeaderComment(comment); } return optionElement; }