public async Task <EditorContext> GetEditorContextAsync()
        {
            if (!TestHasLanguageServer())
            {
                return(null);
            }

            ClientEditorContext clientContext =
                await _languageServer.SendRequest(
                    "editor/getEditorContext",
                    new GetEditorContextRequest())
                .Returning <ClientEditorContext>(CancellationToken.None)
                .ConfigureAwait(false);

            return(ConvertClientEditorContext(clientContext));
        }
Exemplo n.º 2
0
        public EditorContext ConvertClientEditorContext(
            ClientEditorContext clientContext)
        {
            ScriptFile scriptFile = _workspaceService.GetFileBuffer(
                clientContext.CurrentFilePath,
                clientContext.CurrentFileContent);

            return
                (new EditorContext(
                     this,
                     scriptFile,
                     new BufferPosition(
                         clientContext.CursorPosition.Line + 1,
                         clientContext.CursorPosition.Character + 1),
                     new BufferRange(
                         clientContext.SelectionRange.Start.Line + 1,
                         clientContext.SelectionRange.Start.Character + 1,
                         clientContext.SelectionRange.End.Line + 1,
                         clientContext.SelectionRange.End.Character + 1),
                     clientContext.CurrentFileLanguage));
        }