CreateReader() public method

public CreateReader ( ) : System.IO.TextReader
return System.IO.TextReader
Exemplo n.º 1
0
        public void IndentLine(ICSharpCode.AvalonEdit.Document.TextDocument document, DocumentLine line, bool TakeCaret)
        {
            if (line.PreviousLine == null)
            {
                return;
            }

            if (!DSettings.Instance.EnableSmartIndentation)
            {
                var t = document.GetText(line);
                int c = 0;
                for (; c < t.Length && (t[c] == ' ' || t[c] == '\t'); c++)
                {
                    ;
                }

                RawlyIndentLine(t.Length == 0 ? string.Empty : t.Substring(0, c + 1), document, line);

                return;
            }

            var tr        = document.CreateReader();
            var newIndent = D_Parser.Formatting.Indent.IndentEngineWrapper.CalculateIndent(tr, line.LineNumber, dEditor.Editor.Options.ConvertTabsToSpaces, dEditor.Editor.Options.IndentationSize);

            tr.Close();

            RawlyIndentLine(newIndent, document, line);
        }
Exemplo n.º 2
0
		/// <summary>
		/// Create <see cref="NewFolding"/>s for the specified document.
		/// </summary>
		public override IEnumerable<NewFolding> CreateNewFoldings(TextDocument document, out int firstErrorOffset)
		{
			try {
				XmlTextReader reader = new XmlTextReader(document.CreateReader());
				reader.XmlResolver = null; // don't resolve DTDs
				return CreateNewFoldings(document, reader, out firstErrorOffset);
			} catch (XmlException) {
				firstErrorOffset = 0;
				return Enumerable.Empty<NewFolding>();
			}
		}
Exemplo n.º 3
0
        public void IndentLine(TextDocument document, DocumentLine line, bool TakeCaret)
        {
            if (line.PreviousLine == null)
                return;

            if (!DSettings.Instance.EnableSmartIndentation)
            {
                var prevIndent = ReadRawLineIndentation(document.GetText(line));

                RawlyIndentLine(prevIndent, document, line);

                return;
            }

            var tr=document.CreateReader();
            var block = CalculateIndentation(tr, line.LineNumber);
            tr.Close();

            RawlyIndentLine(block != null ? block.GetLineIndentation(line.LineNumber) : 0, document, line);
        }
    /// <summary>
    /// Create <see cref="NewFolding"/>s for the specified document.
    /// </summary>
    public IEnumerable<NewFolding> CreateNewFoldings(TextDocument document, out int firstErrorOffset)
    {
      firstErrorOffset = 0;
      if (document.TextLength < 1)
        return Enumerable.Empty<NewFolding>();

      try
      {
        if (document.IndexOf('<', 0, document.TextLength) < 0)
          return Enumerable.Empty<NewFolding>();
        var reader = new XmlTextReader(document.CreateReader());
        reader.XmlResolver = null; // don't resolve DTDs
        return CreateNewFoldings(document, reader, out firstErrorOffset);
      }
      catch (XmlException)
      {
        return Enumerable.Empty<NewFolding>();
      }
    }