mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-27 18:11:57 +00:00
Add all: boolean to textDocument/documentSymbol
This commit is contained in:
parent
aebf2dfaed
commit
e92378df9c
@ -22,17 +22,19 @@ using namespace clang;
|
|||||||
namespace {
|
namespace {
|
||||||
MethodType kMethodType = "textDocument/documentSymbol";
|
MethodType kMethodType = "textDocument/documentSymbol";
|
||||||
|
|
||||||
struct lsDocumentSymbolParams {
|
|
||||||
lsTextDocumentIdentifier textDocument;
|
|
||||||
int startLine = -1;
|
|
||||||
int endLine = -1;
|
|
||||||
};
|
|
||||||
MAKE_REFLECT_STRUCT(lsDocumentSymbolParams, textDocument, startLine, endLine);
|
|
||||||
|
|
||||||
struct In_TextDocumentDocumentSymbol : public RequestInMessage {
|
struct In_TextDocumentDocumentSymbol : public RequestInMessage {
|
||||||
MethodType GetMethodType() const override { return kMethodType; }
|
MethodType GetMethodType() const override { return kMethodType; }
|
||||||
lsDocumentSymbolParams params;
|
struct Params {
|
||||||
|
lsTextDocumentIdentifier textDocument;
|
||||||
|
// false: outline; true: all symbols
|
||||||
|
bool all = false;
|
||||||
|
// If >= 0, return Range[] instead of SymbolInformation[] to reduce output.
|
||||||
|
int startLine = -1;
|
||||||
|
int endLine = -1;
|
||||||
|
} params;
|
||||||
};
|
};
|
||||||
|
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentSymbol::Params, textDocument, all,
|
||||||
|
startLine, endLine);
|
||||||
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentSymbol, id, params);
|
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentSymbol, id, params);
|
||||||
REGISTER_IN_MESSAGE(In_TextDocumentDocumentSymbol);
|
REGISTER_IN_MESSAGE(In_TextDocumentDocumentSymbol);
|
||||||
|
|
||||||
@ -62,10 +64,12 @@ struct Handler_TextDocumentDocumentSymbol
|
|||||||
params.textDocument.uri.GetPath(), &file, &file_id))
|
params.textDocument.uri.GetPath(), &file, &file_id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const auto &symbol2refcnt =
|
||||||
|
params.all ? file->symbol2refcnt : file->outline2refcnt;
|
||||||
if (params.startLine >= 0) {
|
if (params.startLine >= 0) {
|
||||||
Out_SimpleDocumentSymbol out;
|
Out_SimpleDocumentSymbol out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
for (auto [sym, refcnt] : file->symbol2refcnt)
|
for (auto [sym, refcnt] : symbol2refcnt)
|
||||||
if (refcnt > 0 && params.startLine <= sym.range.start.line &&
|
if (refcnt > 0 && params.startLine <= sym.range.start.line &&
|
||||||
sym.range.start.line <= params.endLine)
|
sym.range.start.line <= params.endLine)
|
||||||
if (auto ls_loc = GetLsLocation(
|
if (auto ls_loc = GetLsLocation(
|
||||||
@ -77,7 +81,7 @@ struct Handler_TextDocumentDocumentSymbol
|
|||||||
} else {
|
} else {
|
||||||
Out_TextDocumentDocumentSymbol out;
|
Out_TextDocumentDocumentSymbol out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
for (auto [sym, refcnt] : file->outline2refcnt) {
|
for (auto [sym, refcnt] : symbol2refcnt) {
|
||||||
if (refcnt <= 0) continue;
|
if (refcnt <= 0) continue;
|
||||||
if (std::optional<lsSymbolInformation> info =
|
if (std::optional<lsSymbolInformation> info =
|
||||||
GetSymbolInfo(db, working_files, sym, false)) {
|
GetSymbolInfo(db, working_files, sym, false)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user