// Copyright (c) 2009-2013 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using ICSharpCode.NRefactory.Editor;
namespace ICSharpCode.NRefactory.Xml
{
///
/// Represents any markup starting with "<" and (hopefully) ending with ">"
///
public class AXmlTag : AXmlObject
{
/// These identify the start of DTD elements
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification="ReadOnlyCollection is immutable")]
public static readonly ReadOnlyCollection DtdNames = new ReadOnlyCollection(
new string[] {" Opening bracket - usually "<"
public string OpeningBracket {
get { return internalObject.OpeningBracket; }
}
/// Name following the opening bracket
public string Name {
get { return internalObject.Name; }
}
/// Gets the segment containing the tag name
public ISegment NameSegment {
get {
int start = startOffset + internalObject.RelativeNameStart;
return new XmlSegment(start, start + internalObject.Name.Length);
}
}
/// Closing bracket - usually ">"
public string ClosingBracket {
get { return internalObject.ClosingBracket; }
}
/// True if tag starts with "<"
public bool IsStartOrEmptyTag { get { return internalObject.IsStartOrEmptyTag; } }
/// True if tag starts with "<" and ends with ">"
public bool IsStartTag { get { return internalObject.IsStartTag; } }
/// True if tag starts with "<" and does not end with ">"
public bool IsEmptyTag { get { return internalObject.IsEmptyTag; } }
/// True if tag starts with "</"
public bool IsEndTag { get { return internalObject.IsEndTag; } }
/// True if tag starts with "<?"
public bool IsProcessingInstruction { get { return internalObject.IsProcessingInstruction; } }
/// True if tag starts with "<!--"
public bool IsComment { get { return internalObject.IsComment; } }
/// True if tag starts with "<![CDATA["
public bool IsCData { get { return internalObject.IsCData; } }
/// True if tag starts with one of the DTD starts
public bool IsDocumentType { get { return internalObject.IsDocumentType; } }
/// True if tag starts with "<!"
public bool IsUnknownBang { get { return internalObject.IsUnknownBang; } }
///
public override void AcceptVisitor(AXmlVisitor visitor)
{
visitor.VisitTag(this);
}
///
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "[{0} '{1}{2}{3}' Attr:{4}]", base.ToString(), this.OpeningBracket, this.Name, this.ClosingBracket, this.Children.Count);
}
}
}