mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 23:55:08 +00:00
[formatting] textDocument/rangeFormatting
This commit is contained in:
parent
12ad0303be
commit
86768b7d36
@ -468,15 +468,6 @@ struct lsFormattingOptions {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsFormattingOptions, tabSize, insertSpaces);
|
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
|
// A document highlight is a range inside a text document which deserves
|
||||||
// special attention. Usually a document highlight is visualized by changing
|
// special attention. Usually a document highlight is visualized by changing
|
||||||
// the background color of its range.
|
// the background color of its range.
|
||||||
|
@ -6,6 +6,13 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
struct lsTextDocumentFormattingParams {
|
||||||
|
lsTextDocumentIdentifier textDocument;
|
||||||
|
lsFormattingOptions options;
|
||||||
|
};
|
||||||
|
MAKE_REFLECT_STRUCT(lsTextDocumentFormattingParams, textDocument, options);
|
||||||
|
|
||||||
struct Ipc_TextDocumentFormatting
|
struct Ipc_TextDocumentFormatting
|
||||||
: public IpcMessage<Ipc_TextDocumentFormatting> {
|
: public IpcMessage<Ipc_TextDocumentFormatting> {
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentFormatting;
|
const static IpcId kIpcId = IpcId::TextDocumentFormatting;
|
||||||
|
@ -7,15 +7,25 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
struct lsTextDocumentRangeFormattingParams {
|
||||||
|
lsTextDocumentIdentifier textDocument;
|
||||||
|
lsRange range;
|
||||||
|
lsFormattingOptions options;
|
||||||
|
};
|
||||||
|
MAKE_REFLECT_STRUCT(lsTextDocumentRangeFormattingParams,
|
||||||
|
textDocument,
|
||||||
|
range,
|
||||||
|
options);
|
||||||
|
|
||||||
struct Ipc_TextDocumentRangeFormatting
|
struct Ipc_TextDocumentRangeFormatting
|
||||||
: public IpcMessage<Ipc_TextDocumentRangeFormatting> {
|
: public IpcMessage<Ipc_TextDocumentRangeFormatting> {
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentRangeFormatting;
|
const static IpcId kIpcId = IpcId::TextDocumentRangeFormatting;
|
||||||
|
|
||||||
lsRequestId id;
|
lsRequestId id;
|
||||||
lsRange range;
|
lsTextDocumentRangeFormattingParams params;
|
||||||
lsTextDocumentFormattingParams params;
|
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRangeFormatting, id, range, params);
|
MAKE_REFLECT_STRUCT(Ipc_TextDocumentRangeFormatting, id, params);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_TextDocumentRangeFormatting);
|
REGISTER_IPC_MESSAGE(Ipc_TextDocumentRangeFormatting);
|
||||||
|
|
||||||
struct Out_TextDocumentRangeFormatting
|
struct Out_TextDocumentRangeFormatting
|
||||||
@ -40,9 +50,9 @@ struct TextDocumentRangeFormattingHandler
|
|||||||
WorkingFile* working_file =
|
WorkingFile* working_file =
|
||||||
working_files->GetFileByFilename(file->def->path);
|
working_files->GetFileByFilename(file->def->path);
|
||||||
|
|
||||||
int start = GetOffsetForPosition(request->range.start,
|
int start = GetOffsetForPosition(request->params.range.start,
|
||||||
working_file->buffer_content),
|
working_file->buffer_content),
|
||||||
end = GetOffsetForPosition(request->range.end,
|
end = GetOffsetForPosition(request->params.range.end,
|
||||||
working_file->buffer_content);
|
working_file->buffer_content);
|
||||||
response.result = ConvertClangReplacementsIntoTextEdits(
|
response.result = ConvertClangReplacementsIntoTextEdits(
|
||||||
working_file->buffer_content,
|
working_file->buffer_content,
|
||||||
|
Loading…
Reference in New Issue
Block a user