mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-21 16:09:40 +00:00
Support #include for textDocument/references
This commit is contained in:
parent
b305beb419
commit
6c45663002
@ -7,23 +7,22 @@
|
|||||||
namespace {
|
namespace {
|
||||||
struct Ipc_TextDocumentReferences
|
struct Ipc_TextDocumentReferences
|
||||||
: public RequestMessage<Ipc_TextDocumentReferences> {
|
: public RequestMessage<Ipc_TextDocumentReferences> {
|
||||||
|
const static IpcId kIpcId = IpcId::TextDocumentReferences;
|
||||||
struct lsReferenceContext {
|
struct lsReferenceContext {
|
||||||
// Include the declaration of the current symbol.
|
// Include the declaration of the current symbol.
|
||||||
bool includeDeclaration;
|
bool includeDeclaration;
|
||||||
};
|
};
|
||||||
struct lsReferenceParams : public lsTextDocumentPositionParams {
|
struct Params {
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
lsPosition position;
|
lsPosition position;
|
||||||
lsReferenceContext context;
|
lsReferenceContext context;
|
||||||
};
|
};
|
||||||
|
|
||||||
const static IpcId kIpcId = IpcId::TextDocumentReferences;
|
Params params;
|
||||||
|
|
||||||
lsReferenceParams params;
|
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences::lsReferenceContext,
|
MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences::lsReferenceContext,
|
||||||
includeDeclaration);
|
includeDeclaration);
|
||||||
MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences::lsReferenceParams,
|
MAKE_REFLECT_STRUCT(Ipc_TextDocumentReferences::Params,
|
||||||
textDocument,
|
textDocument,
|
||||||
position,
|
position,
|
||||||
context);
|
context);
|
||||||
@ -75,6 +74,25 @@ struct TextDocumentReferencesHandler
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (out.result.empty())
|
||||||
|
for (const IndexInclude& include : file->def->includes)
|
||||||
|
if (include.line == request->params.position.line) {
|
||||||
|
// |include| is the line the cursor is on.
|
||||||
|
for (QueryFile& file1 : db->files)
|
||||||
|
if (file1.def)
|
||||||
|
for (const IndexInclude& include1 : file1.def->includes)
|
||||||
|
if (include1.resolved_path == include.resolved_path) {
|
||||||
|
// Another file |file1| has the same include line.
|
||||||
|
lsLocation result;
|
||||||
|
result.uri = lsDocumentUri::FromPath(file1.def->path);
|
||||||
|
result.range.start.line = result.range.end.line =
|
||||||
|
include1.line;
|
||||||
|
out.result.push_back(std::move(result));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentReferences, out);
|
QueueManager::WriteStdout(IpcId::TextDocumentReferences, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user