Exemplo n.º 1
0
 /// <summary>
 /// Begins an asynchronous reparse.
 /// This method is thread-safe.
 /// </summary>
 /// <returns>
 /// Returns a task that will make the parse result available.
 /// </returns>
 /// <remarks>
 /// EnqueueForParsing has been renamed to BeginParse and now provides a future (Task&lt;ParseInformation&gt;)
 /// to allow waiting for the result. However, to avoid deadlocks, this should not be done by any
 /// thread the parser might be waiting for  (especially the main thread).
 ///
 /// Unlike BeginParse().Wait(), ParseFile() is safe to call from the main thread.
 /// </remarks>
 public static Task <ParseInformation> BeginParse(string fileName, ITextBuffer fileContent)
 {
     if (fileContent == null)
     {
         throw new ArgumentNullException("fileContent");
     }
     // create snapshot (in case someone passes a mutable document to BeginParse)
     return(GetFileEntry(fileName, true).BeginParse(fileContent.CreateSnapshot()));
 }
Exemplo n.º 2
0
		public ReadOnlyDocument(ITextBuffer textBuffer)
		{
			// ensure that underlying buffer is immutable
			this.textBuffer = textBuffer.CreateSnapshot();
			List<int> lines = new List<int>();
			lines.Add(0);
			int offset = 0;
			string newlineType;
			var textSource = DocumentUtilitites.GetTextSource(this.textBuffer);
			while ((offset = ICSharpCode.AvalonEdit.Document.TextUtilities.FindNextNewLine(textSource, offset, out newlineType)) >= 0) {
				offset += newlineType.Length;
				lines.Add(offset);
			}
			this.lines = lines.ToArray();
		}
Exemplo n.º 3
0
        public ReadOnlyDocument(ITextBuffer textBuffer)
        {
            if (textBuffer == null)
            {
                throw new ArgumentNullException("textBuffer");
            }
            // ensure that underlying buffer is immutable
            this.textBuffer = textBuffer.CreateSnapshot();
            List <int> lines = new List <int>();

            lines.Add(0);
            int    offset = 0;
            string newlineType;
            var    textSource = DocumentUtilitites.GetTextSource(this.textBuffer);

            while ((offset = ICSharpCode.AvalonEdit.Document.TextUtilities.FindNextNewLine(textSource, offset, out newlineType)) >= 0)
            {
                offset += newlineType.Length;
                lines.Add(offset);
            }
            this.lines = lines.ToArray();
        }
Exemplo n.º 4
0
 public ITextSource CreateSnapshot()
 {
     return(GetTextSource(textBuffer.CreateSnapshot()));
 }
Exemplo n.º 5
0
 public ITextBuffer CreateSnapshot(int offset, int length)
 {
     return(textBuffer.CreateSnapshot(offset, length));
 }
Exemplo n.º 6
0
		/// <summary>
		/// Begins an asynchronous reparse.
		/// This method is thread-safe.
		/// </summary>
		/// <returns>
		/// Returns a task that will make the parse result available.
		/// </returns>
		/// <remarks>
		/// EnqueueForParsing has been renamed to BeginParse and now provides a future (Task&lt;ParseInformation&gt;)
		/// to allow waiting for the result. However, to avoid deadlocks, this should not be done by any
		/// thread the parser might be waiting for  (especially the main thread).
		/// 
		/// Unlike BeginParse().Wait(), ParseFile() is safe to call from the main thread.
		/// </remarks>
		public static Task<ParseInformation> BeginParse(string fileName, ITextBuffer fileContent)
		{
			if (fileContent == null)
				throw new ArgumentNullException("fileContent");
			// create snapshot (in case someone passes a mutable document to BeginParse)
			return GetFileEntry(fileName, true).BeginParse(fileContent.CreateSnapshot());
		}