/// <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<ParseInformation>) /// 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())); }
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(); }
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(); }
public ITextSource CreateSnapshot() { return(GetTextSource(textBuffer.CreateSnapshot())); }
public ITextBuffer CreateSnapshot(int offset, int length) { return(textBuffer.CreateSnapshot(offset, length)); }
/// <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<ParseInformation>) /// 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()); }