/// <summary>
 /// Creates a new instance of the EditorContext class.
 /// </summary>
 /// <param name="editorOperations">An IEditorOperations implementation which performs operations in the editor.</param>
 /// <param name="currentFile">The ScriptFile that is in the active editor buffer.</param>
 /// <param name="cursorPosition">The position of the user's cursor in the active editor buffer.</param>
 /// <param name="selectedRange">The range of the user's selection in the active editor buffer.</param>
 /// <param name="language">Determines the language of the file.false If it is not specified, then it defaults to "Unknown"</param>
 internal EditorContext(
     IEditorOperations editorOperations,
     ScriptFile currentFile,
     BufferPosition cursorPosition,
     BufferRange selectedRange,
     string language = "Unknown")
 {
     this.editorOperations = editorOperations;
     this.CurrentFile      = new FileContext(currentFile, this, editorOperations, language);
     this.SelectedRange    = new BufferFileRange(selectedRange);
     this.CursorPosition   = new BufferFilePosition(cursorPosition);
 }
Beispiel #2
0
 internal static BufferPosition ToBufferPosition(this IFilePosition position)
 {
     return(new BufferPosition(position.Line, position.Column));
 }
Beispiel #3
0
 /// <summary>
 /// Convert a 1-based file position to a 0-based file position.
 /// </summary>
 /// <param name="position">The 1-based file position to convert.</param>
 /// <returns>An equivalent 0-based file position.</returns>
 public static ILspFilePosition ToLspPosition(this IFilePosition position)
 {
     return(new LspFilePosition(position.Line - 1, position.Column - 1));
 }
Beispiel #4
0
 public FileRange(IFilePosition start, IFilePosition end, string file)
 {
     Start = start;
     End   = end;
     File  = file;
 }
Beispiel #5
0
 public FileRange(IFilePosition start, IFilePosition end)
     : this(start, end, file : null)
 {
 }
 /// <summary>
 /// Inserts a text string at the specified buffer position.
 /// </summary>
 /// <param name="textToInsert">The text string to insert.</param>
 /// <param name="insertPosition">The position at which the text will be inserted.</param>
 public void InsertText(string textToInsert, IFilePosition insertPosition)
 {
     this.InsertText(
         textToInsert,
         new FileRange(insertPosition, insertPosition));
 }
 /// <summary>
 /// Convert a 1-based file position to a 0-based file position.
 /// </summary>
 /// <param name="position">The 1-based file position to convert.</param>
 /// <returns>An equivalent 0-based file position.</returns>
 public static ILspFilePosition ToLspPosition(this IFilePosition position) => new LspFilePosition(position.Line - 1, position.Column - 1);