|
@ -20,6 +20,21 @@ struct In_TextDocumentDocumentSymbol : public RequestInMessage { |
|
|
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentSymbol, id, params); |
|
|
MAKE_REFLECT_STRUCT(In_TextDocumentDocumentSymbol, id, params); |
|
|
REGISTER_IN_MESSAGE(In_TextDocumentDocumentSymbol); |
|
|
REGISTER_IN_MESSAGE(In_TextDocumentDocumentSymbol); |
|
|
|
|
|
|
|
|
|
|
|
struct lsSimpleLocation { |
|
|
|
|
|
lsRange range; |
|
|
|
|
|
}; |
|
|
|
|
|
MAKE_REFLECT_STRUCT(lsSimpleLocation, range); |
|
|
|
|
|
struct lsSimpleSymbolInformation { |
|
|
|
|
|
lsSimpleLocation location; |
|
|
|
|
|
}; |
|
|
|
|
|
MAKE_REFLECT_STRUCT(lsSimpleSymbolInformation, location); |
|
|
|
|
|
struct Out_SimpleDocumentSymbol |
|
|
|
|
|
: public lsOutMessage<Out_SimpleDocumentSymbol> { |
|
|
|
|
|
lsRequestId id; |
|
|
|
|
|
std::vector<lsSimpleSymbolInformation> result; |
|
|
|
|
|
}; |
|
|
|
|
|
MAKE_REFLECT_STRUCT(Out_SimpleDocumentSymbol, jsonrpc, id, result); |
|
|
|
|
|
|
|
|
struct Out_TextDocumentDocumentSymbol |
|
|
struct Out_TextDocumentDocumentSymbol |
|
|
: public lsOutMessage<Out_TextDocumentDocumentSymbol> { |
|
|
: public lsOutMessage<Out_TextDocumentDocumentSymbol> { |
|
|
lsRequestId id; |
|
|
lsRequestId id; |
|
@ -32,8 +47,6 @@ struct Handler_TextDocumentDocumentSymbol |
|
|
MethodType GetMethodType() const override { return kMethodType; } |
|
|
MethodType GetMethodType() const override { return kMethodType; } |
|
|
void Run(In_TextDocumentDocumentSymbol* request) override { |
|
|
void Run(In_TextDocumentDocumentSymbol* request) override { |
|
|
auto& params = request->params; |
|
|
auto& params = request->params; |
|
|
Out_TextDocumentDocumentSymbol out; |
|
|
|
|
|
out.id = request->id; |
|
|
|
|
|
|
|
|
|
|
|
QueryFile* file; |
|
|
QueryFile* file; |
|
|
int file_id; |
|
|
int file_id; |
|
@ -42,17 +55,17 @@ struct Handler_TextDocumentDocumentSymbol |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
if (params.all) { |
|
|
if (params.all) { |
|
|
|
|
|
Out_SimpleDocumentSymbol out; |
|
|
|
|
|
out.id = request->id; |
|
|
for (SymbolRef sym : file->def->all_symbols) |
|
|
for (SymbolRef sym : file->def->all_symbols) |
|
|
if (std::optional<lsSymbolInformation> info = |
|
|
|
|
|
GetSymbolInfo(db, working_files, sym, false)) { |
|
|
|
|
|
if (std::optional<lsLocation> location = GetLsLocation( |
|
|
if (std::optional<lsLocation> location = GetLsLocation( |
|
|
db, working_files, |
|
|
db, working_files, |
|
|
Use{{sym.range, sym.usr, sym.kind, sym.role}, file_id})) { |
|
|
Use{{sym.range, sym.usr, sym.kind, sym.role}, file_id})) |
|
|
info->location = *location; |
|
|
out.result.push_back({{location->range}}); |
|
|
out.result.push_back(*info); |
|
|
pipeline::WriteStdout(kMethodType, out); |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
|
|
|
Out_TextDocumentDocumentSymbol out; |
|
|
|
|
|
out.id = request->id; |
|
|
for (SymbolRef sym : file->def->outline) |
|
|
for (SymbolRef sym : file->def->outline) |
|
|
if (std::optional<lsSymbolInformation> info = |
|
|
if (std::optional<lsSymbolInformation> info = |
|
|
GetSymbolInfo(db, working_files, sym, false)) { |
|
|
GetSymbolInfo(db, working_files, sym, false)) { |
|
@ -69,10 +82,9 @@ struct Handler_TextDocumentDocumentSymbol |
|
|
out.result.push_back(*info); |
|
|
out.result.push_back(*info); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pipeline::WriteStdout(kMethodType, out); |
|
|
pipeline::WriteStdout(kMethodType, out); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDocumentSymbol); |
|
|
REGISTER_MESSAGE_HANDLER(Handler_TextDocumentDocumentSymbol); |
|
|
} // namespace
|
|
|
} // namespace
|