mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
parent
0f0c328a91
commit
19d38bc1d2
@ -78,13 +78,22 @@ MAKE_REFLECT_STRUCT(DocumentLink, range, target);
|
|||||||
void MessageHandler::textDocument_documentLink(TextDocumentParam ¶m,
|
void MessageHandler::textDocument_documentLink(TextDocumentParam ¶m,
|
||||||
ReplyOnce &reply) {
|
ReplyOnce &reply) {
|
||||||
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath());
|
QueryFile *file = FindFile(reply, param.textDocument.uri.GetPath());
|
||||||
if (!file)
|
WorkingFile *wf = file ? wfiles->GetFileByFilename(file->def->path) : nullptr;
|
||||||
|
if (!wf) {
|
||||||
|
reply.Error(ErrorCode::InternalError, "not opened");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<DocumentLink> result;
|
std::vector<DocumentLink> result;
|
||||||
for (const IndexInclude &include : file->def->includes)
|
for (const IndexInclude &include : file->def->includes)
|
||||||
result.push_back({lsRange{{include.line, 0}, {include.line + 1, 0}},
|
if (std::optional<int> bline =
|
||||||
DocumentUri::FromPath(include.resolved_path)});
|
wf->GetBufferPosFromIndexPos(include.line, nullptr, false)) {
|
||||||
|
const std::string &line = wf->buffer_lines[*bline];
|
||||||
|
auto start = line.find_first_of("\"<"), end = line.find_last_of("\">");
|
||||||
|
if (start < end)
|
||||||
|
result.push_back({lsRange{{*bline, (int)start + 1}, {*bline, (int)end}},
|
||||||
|
DocumentUri::FromPath(include.resolved_path)});
|
||||||
|
}
|
||||||
reply(result);
|
reply(result);
|
||||||
} // namespace ccls
|
} // namespace ccls
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user