Skip to content

Commit

Permalink
Add flat to $ccls/inheritanceHierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Aug 8, 2018
1 parent 3931951 commit b9e1c2e
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions src/messages/ccls_inheritanceHierarchy.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "message_handler.h"
#include "query_utils.h"
#include "pipeline.hh"
#include "query_utils.h"
using namespace ccls;

#include <queue>
#include <unordered_set>

namespace {
Expand All @@ -24,18 +25,12 @@ struct In_CclsInheritanceHierarchy : public RequestInMessage {
bool derived = false;
bool qualified = true;
int levels = 1;
};
Params params;
bool flat = false;
} params;
};

MAKE_REFLECT_STRUCT(In_CclsInheritanceHierarchy::Params,
textDocument,
position,
id,
kind,
derived,
qualified,
levels);
MAKE_REFLECT_STRUCT(In_CclsInheritanceHierarchy::Params, textDocument, position,
id, kind, derived, qualified, levels, flat);
MAKE_REFLECT_STRUCT(In_CclsInheritanceHierarchy, id, params);
REGISTER_IN_MESSAGE(In_CclsInheritanceHierarchy);

Expand Down Expand Up @@ -159,7 +154,7 @@ struct Handler_CclsInheritanceHierarchy
Out_CclsInheritanceHierarchy out;
out.id = request->id;

if (params.id.size()) {
if (!params.flat && params.id.size()) {
try {
params.usr = std::stoull(params.id);
} catch (...) {
Expand Down Expand Up @@ -189,7 +184,26 @@ struct Handler_CclsInheritanceHierarchy
}
}

pipeline::WriteStdout(kMethodType, out);
if (!params.flat) {
pipeline::WriteStdout(kMethodType, out);
return;
}
Out_LocationList out1;
out1.id = request->id;
if (out.result) {
std::queue<Out_CclsInheritanceHierarchy::Entry *> q;
for (auto &entry1 : out.result->children)
q.push(&entry1);
while (q.size()) {
auto *entry = q.front();
q.pop();
if (entry->location.uri.raw_uri.size())
out1.result.push_back({entry->location});
for (auto &entry1 : entry->children)
q.push(&entry1);
}
}
pipeline::WriteStdout(kMethodType, out1);
}
};
REGISTER_MESSAGE_HANDLER(Handler_CclsInheritanceHierarchy);
Expand Down

0 comments on commit b9e1c2e

Please sign in to comment.