mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-14 12:12:20 +00:00
add flat option to ccls/inheritanceHierarchy
useful for xref-like examination.
This commit is contained in:
parent
924fedbb02
commit
2a3695613b
@ -1,6 +1,8 @@
|
|||||||
#include "message_handler.h"
|
#include "message_handler.h"
|
||||||
#include "query_utils.h"
|
#include "query_utils.h"
|
||||||
#include "pipeline.hh"
|
#include "pipeline.hh"
|
||||||
|
#include "log.hh"
|
||||||
|
|
||||||
using namespace ccls;
|
using namespace ccls;
|
||||||
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
@ -24,6 +26,7 @@ struct In_CclsInheritanceHierarchy : public RequestInMessage {
|
|||||||
bool derived = false;
|
bool derived = false;
|
||||||
bool qualified = true;
|
bool qualified = true;
|
||||||
int levels = 1;
|
int levels = 1;
|
||||||
|
bool flat = false;
|
||||||
};
|
};
|
||||||
Params params;
|
Params params;
|
||||||
};
|
};
|
||||||
@ -35,7 +38,8 @@ MAKE_REFLECT_STRUCT(In_CclsInheritanceHierarchy::Params,
|
|||||||
kind,
|
kind,
|
||||||
derived,
|
derived,
|
||||||
qualified,
|
qualified,
|
||||||
levels);
|
levels,
|
||||||
|
flat);
|
||||||
MAKE_REFLECT_STRUCT(In_CclsInheritanceHierarchy, id, params);
|
MAKE_REFLECT_STRUCT(In_CclsInheritanceHierarchy, id, params);
|
||||||
REGISTER_IN_MESSAGE(In_CclsInheritanceHierarchy);
|
REGISTER_IN_MESSAGE(In_CclsInheritanceHierarchy);
|
||||||
|
|
||||||
@ -158,8 +162,10 @@ struct Handler_CclsInheritanceHierarchy
|
|||||||
auto& params = request->params;
|
auto& params = request->params;
|
||||||
Out_CclsInheritanceHierarchy out;
|
Out_CclsInheritanceHierarchy out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
|
bool flat = params.flat;
|
||||||
|
|
||||||
if (params.id.size()) {
|
if (params.id.size()) {
|
||||||
|
if (flat) return;
|
||||||
try {
|
try {
|
||||||
params.usr = std::stoull(params.id);
|
params.usr = std::stoull(params.id);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
@ -188,7 +194,25 @@ struct Handler_CclsInheritanceHierarchy
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (flat) {
|
||||||
|
Out_LocationList out2;
|
||||||
|
out2.id = request->id;
|
||||||
|
if (out.result) {
|
||||||
|
auto push = [&out2](Out_CclsInheritanceHierarchy::Entry & entry) {
|
||||||
|
auto y = [&out2](Out_CclsInheritanceHierarchy::Entry & entry, auto& z)
|
||||||
|
-> void {
|
||||||
|
if (entry.location.uri.GetPath().size())
|
||||||
|
out2.result.push_back({entry.location});
|
||||||
|
for (auto & child : entry.children) {
|
||||||
|
z(child, z);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
y(entry, y);
|
||||||
|
};
|
||||||
|
push(*out.result);
|
||||||
|
}
|
||||||
|
pipeline::WriteStdout(kMethodType, out2);
|
||||||
|
} else
|
||||||
pipeline::WriteStdout(kMethodType, out);
|
pipeline::WriteStdout(kMethodType, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user