[formatting] textDocument/rangeFormatting

This commit is contained in:
Fangrui Song 2017-12-31 20:03:43 -08:00
parent 12ad0303be
commit 86768b7d36
3 changed files with 22 additions and 14 deletions

View File

@ -468,15 +468,6 @@ struct lsFormattingOptions {
};
MAKE_REFLECT_STRUCT(lsFormattingOptions, tabSize, insertSpaces);
struct lsTextDocumentFormattingParams {
// The text document.
lsTextDocumentIdentifier textDocument;
// The format options, like tabs or spaces.
lsFormattingOptions options;
};
MAKE_REFLECT_STRUCT(lsTextDocumentFormattingParams, textDocument, options);
// A document highlight is a range inside a text document which deserves
// special attention. Usually a document highlight is visualized by changing
// the background color of its range.

View File

@ -6,6 +6,13 @@
#include <loguru.hpp>
namespace {
struct lsTextDocumentFormattingParams {
lsTextDocumentIdentifier textDocument;
lsFormattingOptions options;
};
MAKE_REFLECT_STRUCT(lsTextDocumentFormattingParams, textDocument, options);
struct Ipc_TextDocumentFormatting
: public IpcMessage<Ipc_TextDocumentFormatting> {
const static IpcId kIpcId = IpcId::TextDocumentFormatting;

View File

@ -7,15 +7,25 @@
#include <loguru.hpp>
namespace {
struct lsTextDocumentRangeFormattingParams {
lsTextDocumentIdentifier textDocument;
lsRange range;
lsFormattingOptions options;
};
MAKE_REFLECT_STRUCT(lsTextDocumentRangeFormattingParams,
textDocument,
range,
options);
struct Ipc_TextDocumentRangeFormatting
: public IpcMessage<Ipc_TextDocumentRangeFormatting> {
const static IpcId kIpcId = IpcId::TextDocumentRangeFormatting;
lsRequestId id;
lsRange range;
lsTextDocumentFormattingParams params;
lsTextDocumentRangeFormattingParams params;
};
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRangeFormatting, id, range, params);
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRangeFormatting, id, params);
REGISTER_IPC_MESSAGE(Ipc_TextDocumentRangeFormatting);
struct Out_TextDocumentRangeFormatting
@ -40,9 +50,9 @@ struct TextDocumentRangeFormattingHandler
WorkingFile* working_file =
working_files->GetFileByFilename(file->def->path);
int start = GetOffsetForPosition(request->range.start,
int start = GetOffsetForPosition(request->params.range.start,
working_file->buffer_content),
end = GetOffsetForPosition(request->range.end,
end = GetOffsetForPosition(request->params.range.end,
working_file->buffer_content);
response.result = ConvertClangReplacementsIntoTextEdits(
working_file->buffer_content,