// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using ICSharpCode.NRefactory; using System; namespace ICSharpCode.SharpDevelop.Dom.Refactoring { /// /// A document representing a source code file for refactoring. /// Line and column counting starts at 1. /// Offset counting starts at 0. /// public interface IRefactoringDocument : IServiceProvider { /// /// Gets the total text length. /// /// The length of the text, in characters. /// This is the same as Text.Length, but is more efficient because /// it doesn't require creating a String object. int TextLength { get; } /// /// Gets the total number of lines in the document. /// int TotalNumberOfLines { get; } /// /// Gets/Sets the whole text as string. /// string Text { get; set; } /// /// Gets the document line with the specified number. /// /// The number of the line to retrieve. The first line has number 1. IRefactoringDocumentLine GetLine(int lineNumber); /// /// Gets the document line that contains the specified offset. /// IRefactoringDocumentLine GetLineForOffset(int offset); int PositionToOffset(int line, int column); Location OffsetToPosition(int offset); void Insert(int offset, string text); void Remove(int offset, int length); void Replace(int offset, int length, string newText); /// /// Gets a character at the specified position in the document. /// /// The index of the character to get. /// Offset is outside the valid range (0 to TextLength-1). /// The character at the specified position. /// This is the same as Text[offset], but is more efficient because /// it doesn't require creating a String object. char GetCharAt(int offset); /// /// Retrieves the text for a portion of the document. /// /// offset or length is outside the valid range. /// This is the same as Text.Substring, but is more efficient because /// it doesn't require creating a String object for the whole document. string GetText(int offset, int length); /// /// Make the document combine the following actions into a single /// action for undo purposes. /// void StartUndoableAction(); /// /// Ends the undoable action started with . /// void EndUndoableAction(); /// /// Creates an undo group. Dispose the returned value to close the undo group. /// /// An object that closes the undo group when Dispose() is called. IDisposable OpenUndoGroup(); } /// /// A line inside a . /// public interface IRefactoringDocumentLine { /// /// Gets the starting offset of the line in the document's text. /// int Offset { get; } /// /// Gets the length of this line (=the number of characters on the line). /// int Length { get; } /// /// Gets the length of this line, including the line delimiter. /// int TotalLength { get; } /// /// Gets the length of the line terminator. /// Returns 1 or 2; or 0 at the end of the document. /// int DelimiterLength { get; } /// /// Gets the number of this line. /// The first line has the number 1. /// int LineNumber { get; } /// /// Gets the text on this line. /// string Text { get; } } }