Esempio n. 1
0
        public async Task <CodeFormatResponse> Handle(CodeFormatRequest request)
        {
            var document = _workspace.GetDocument(request.FileName);

            if (document == null)
            {
                return(null);
            }

            if (request.WantsTextChanges)
            {
                var textChanges = await FormattingWorker.GetFormattedTextChanges(document, _omnisharpOptions);

                return(new CodeFormatResponse()
                {
                    Changes = textChanges
                });
            }

            var newText = await FormattingWorker.GetFormattedText(document, _omnisharpOptions);

            return(new CodeFormatResponse
            {
                Buffer = newText
            });
        }
Esempio n. 2
0
        public Task <object> Handle(DesignHub hub, InvokeArgs args)
        {
            var fileName = args.GetString();
            var document = hub.TypeSystem.Workspace.GetOpenedDocumentByName(fileName);

            if (document == null)
            {
                throw new Exception(string.Format("Cannot find opened document: {0}", fileName));
            }

            var changes = FormattingWorker.GetFormattedTextChanges(document).Result;

            return(Task.FromResult <object>(changes.ToArray()));
        }