/// <summary>
        /// Creates an XmlFoldStart for the start tag of an element.
        /// </summary>
        AmlFoldStart CreateElementFoldStart(TextDocument document, XmlReader reader)
        {
            // Take off 1 from the offset returned
            // from the xml since it points to the start
            // of the element name and not the beginning
            // tag.
            //XmlFoldStart newFoldStart = new XmlFoldStart(reader.Prefix, reader.LocalName, reader.LineNumber - 1, reader.LinePosition - 2);
            AmlFoldStart newFoldStart = new AmlFoldStart();

            IXmlLineInfo lineInfo = (IXmlLineInfo)reader;

            newFoldStart.StartLine   = lineInfo.LineNumber;
            newFoldStart.StartOffset = document.GetOffset(newFoldStart.StartLine, lineInfo.LinePosition - 1);

            if (this.ShowAttributesWhenFolded && reader.HasAttributes)
            {
                newFoldStart.Name = reader.Name;
                newFoldStart.AddAttr(reader);
            }
            else
            {
                newFoldStart.Name = reader.Name;
            }

            return(newFoldStart);
        }
        public void SetStartPropOffset(TextDocument document, XmlReader reader)
        {
            IXmlLineInfo lineInfo = (IXmlLineInfo)reader;

            if (!_properties.Any() || lineInfo.LineNumber > _properties.Last().EndLine + 1)
            {
                var prop = new AmlFoldStart();
                prop.StartLine   = lineInfo.LineNumber;
                prop.StartOffset = document.GetOffset(lineInfo.LineNumber, lineInfo.LinePosition - 1);
                _properties.Add(prop);
            }
        }
        /// <summary>
        /// Create an element fold if the start and end tag are on
        /// different lines.
        /// </summary>
        static void CreateElementFold(TextDocument document, List <NewFolding> foldMarkers, XmlReader reader, AmlFoldStart foldStart)
        {
            IXmlLineInfo lineInfo = (IXmlLineInfo)reader;
            int          endLine  = lineInfo.LineNumber;

            if (endLine > foldStart.StartLine)
            {
                int endCol = lineInfo.LinePosition + reader.Name.Length + 1;
                foldStart.EndOffset = document.GetOffset(endLine, endCol);

                if (foldStart.Properties.Any())
                {
                    foreach (var prop in foldStart.Properties)
                    {
                        foldMarkers.Add(prop);
                    }
                }

                foldMarkers.Add(foldStart);
            }
        }
    /// <summary>
    /// Creates an XmlFoldStart for the start tag of an element.
    /// </summary>
    AmlFoldStart CreateElementFoldStart(TextDocument document, XmlReader reader)
    {
      // Take off 1 from the offset returned
      // from the xml since it points to the start
      // of the element name and not the beginning
      // tag.
      //XmlFoldStart newFoldStart = new XmlFoldStart(reader.Prefix, reader.LocalName, reader.LineNumber - 1, reader.LinePosition - 2);
      AmlFoldStart newFoldStart = new AmlFoldStart();

      IXmlLineInfo lineInfo = (IXmlLineInfo)reader;
      newFoldStart.StartLine = lineInfo.LineNumber;
      newFoldStart.StartOffset = document.GetOffset(newFoldStart.StartLine, lineInfo.LinePosition - 1);

      if (this.ShowAttributesWhenFolded && reader.HasAttributes)
      {
        newFoldStart.Name = reader.Name;
        newFoldStart.AddAttr(reader);
      }
      else
      {
        newFoldStart.Name = reader.Name;
      }

      return newFoldStart;
    }
    /// <summary>
    /// Create an element fold if the start and end tag are on
    /// different lines.
    /// </summary>
    static void CreateElementFold(TextDocument document, List<NewFolding> foldMarkers, XmlReader reader, AmlFoldStart foldStart)
    {
      IXmlLineInfo lineInfo = (IXmlLineInfo)reader;
      int endLine = lineInfo.LineNumber;
      if (endLine > foldStart.StartLine)
      {
        int endCol = lineInfo.LinePosition + reader.Name.Length + 1;
        foldStart.EndOffset = document.GetOffset(endLine, endCol);

        if (foldStart.Properties.Any())
        {
          foreach (var prop in foldStart.Properties)
          {
            foldMarkers.Add(prop);
          }
        }

        foldMarkers.Add(foldStart);
      }
    }
 public void SetStartPropOffset(TextDocument document, XmlReader reader)
 {
   IXmlLineInfo lineInfo = (IXmlLineInfo)reader;
   if (!_properties.Any() || lineInfo.LineNumber > _properties.Last().EndLine + 1)
   {
     var prop = new AmlFoldStart();
     prop.StartLine = lineInfo.LineNumber;
     prop.StartOffset = document.GetOffset(lineInfo.LineNumber, lineInfo.LinePosition - 1);
     _properties.Add(prop);
   }
 }