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 }); }
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())); }