diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/XmlParser/Collections.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/XmlParser/Collections.cs index 47f81df460..fffb859223 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/XmlParser/Collections.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/XmlParser/Collections.cs @@ -12,9 +12,6 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; -// Missing XML comment -#pragma warning disable 1591 - namespace ICSharpCode.AvalonEdit.XmlParser { /// @@ -23,8 +20,10 @@ namespace ICSharpCode.AvalonEdit.XmlParser /// public class ChildrenCollection: Collection, INotifyCollectionChanged { + /// Occurs when the collection is changed public event NotifyCollectionChangedEventHandler CollectionChanged; + /// Raises event protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { if (CollectionChanged != null) { @@ -32,21 +31,25 @@ namespace ICSharpCode.AvalonEdit.XmlParser } } + /// protected override void ClearItems() { throw new NotSupportedException(); } + /// protected override void InsertItem(int index, T item) { throw new NotSupportedException(); } + /// protected override void RemoveItem(int index) { throw new NotSupportedException(); } + /// protected override void SetItem(int index, T item) { throw new NotSupportedException(); @@ -173,8 +176,10 @@ namespace ICSharpCode.AvalonEdit.XmlParser Predicate condition; List srcPtrs = new List(); // Index to the original collection + /// Wrap the given collection. Items of type other then T are filtered public FilteredCollection(C source) : this (source, x => true) { } + /// Wrap the given collection. Items of type other then T are filtered. Items not matching the condition are filtered. public FilteredCollection(C source, Predicate condition) { this.source = source; @@ -254,6 +259,7 @@ namespace ICSharpCode.AvalonEdit.XmlParser C a; C b; + /// Create a wrapper containing elements of 'a' and then 'b' public MergedCollection(C a, C b) { this.a = a; diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/XmlParser/RawObjects.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/XmlParser/RawObjects.cs index 9e1a3744c2..9618cdadca 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/XmlParser/RawObjects.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/XmlParser/RawObjects.cs @@ -12,13 +12,12 @@ using System.Linq; using ICSharpCode.AvalonEdit.Document; -// TODO: Missing XML comment -#pragma warning disable 1591 - namespace ICSharpCode.AvalonEdit.XmlParser { + /// Holds event args for event caused by public class RawObjectEventArgs: EventArgs { + /// The object that cause the event public RawObject Object { get; set; } } @@ -52,7 +51,9 @@ namespace ICSharpCode.AvalonEdit.XmlParser /// public RawObject Parent { get; set; } - // TODO: Performance + /// + /// Gets the document owning this object or null if orphaned + /// public RawDocument Document { get { if (this.Parent != null) { @@ -119,11 +120,13 @@ namespace ICSharpCode.AvalonEdit.XmlParser syntaxErrors.Add(error); } - public RawObject() + /// Create new object + protected RawObject() { this.ReadCallID = new object(); } + /// Throws exception if condition is false protected static void Assert(bool condition) { if (!condition) { @@ -131,14 +134,17 @@ namespace ICSharpCode.AvalonEdit.XmlParser } } + /// Recursively gets self and all nested nodes. public virtual IEnumerable GetSelfAndAllChildren() { return new RawObject[] { this }; } + /// Call appropriate visit method on the given visitor public abstract void AcceptVisitor(IXmlVisitor visitor); - public virtual void UpdateDataFrom(RawObject source) + /// Copy all data from the 'source' to this object + internal virtual void UpdateDataFrom(RawObject source) { this.ReadCallID = source.ReadCallID; // In some cases we are just updating objects of that same @@ -160,12 +166,13 @@ namespace ICSharpCode.AvalonEdit.XmlParser } } + /// public override string ToString() { return string.Format("{0}({1}-{2})", this.GetType().Name.Remove(0, 3), this.StartOffset, this.EndOffset); } - public static void LogDom(string format, params object[] args) + internal static void LogDom(string format, params object[] args) { System.Diagnostics.Debug.WriteLine(string.Format("XML DOM: " + format, args)); } @@ -234,6 +241,7 @@ namespace ICSharpCode.AvalonEdit.XmlParser /// public ChildrenCollection Children { get; private set; } + /// Create new container public RawContainer() { this.Children = new ChildrenCollection(); @@ -255,7 +263,8 @@ namespace ICSharpCode.AvalonEdit.XmlParser #endregion - public override void UpdateDataFrom(RawObject source) + /// + internal override void UpdateDataFrom(RawObject source) { if (this.ReadCallID == source.ReadCallID) return; base.UpdateDataFrom(source); @@ -263,6 +272,7 @@ namespace ICSharpCode.AvalonEdit.XmlParser UpdateChildrenFrom(src.Children); } + /// public override IEnumerable GetSelfAndAllChildren() { return Enumerable.Union( @@ -272,13 +282,15 @@ namespace ICSharpCode.AvalonEdit.XmlParser } /// - /// Gets a child at the given document offset. + /// Gets a child fully containg the given offset. /// Goes recursively down the tree. + /// Specail case if at the end of attribute /// public RawObject GetChildAtOffset(int offset) { foreach(RawObject child in this.Children) { - if (child.StartOffset <= offset && offset <= child.EndOffset) { + if (child is RawAttribute && offset == child.EndOffset) return child; + if (child.StartOffset < offset && offset < child.EndOffset) { if (child is RawContainer) { return ((RawContainer)child).GetChildAtOffset(offset); } else { @@ -591,16 +603,19 @@ namespace ICSharpCode.AvalonEdit.XmlParser if (ObjectChanged != null) ObjectChanged(this, new RawObjectEventArgs() { Object = obj } ); } + /// Create new document public RawDocument() { this.SyntaxErrors = new TextSegmentCollection(); } + /// public override void AcceptVisitor(IXmlVisitor visitor) { visitor.VisitDocument(this); } + /// public override string ToString() { return string.Format("[{0} Chld:{1}]", base.ToString(), this.Children.Count); @@ -612,27 +627,41 @@ namespace ICSharpCode.AvalonEdit.XmlParser /// public class RawTag: RawContainer { + /// These identify the start of DTD elements public static readonly string[] DTDNames = new string[] {" Opening bracket - usually "<" public string OpeningBracket { get; set; } + /// Name following the opening bracket public string Name { get; set; } + /// Opening bracket - usually ">" public string ClosingBracket { get; set; } // Exactly one of the folling will be true + + /// True if tag starts with "<" public bool IsStartTag { get { return OpeningBracket == "<"; } } + /// True if tag starts with "</" public bool IsEndTag { get { return OpeningBracket == " True if tag starts with "<?" public bool IsProcessingInstruction { get { return OpeningBracket == " True if tag starts with "<!--" public bool IsComment { get { return OpeningBracket == "