| 35 | } // namespace |
| 36 | |
| 37 | void MessageHandler::textDocument_documentHighlight(TextDocumentPositionParam ¶m, ReplyOnce &reply) { |
| 38 | int file_id; |
| 39 | auto [file, wf] = findOrFail(param.textDocument.uri.getPath(), reply, &file_id); |
| 40 | if (!wf) |
| 41 | return; |
| 42 | |
| 43 | std::vector<DocumentHighlight> result; |
| 44 | std::vector<SymbolRef> syms = findSymbolsAtLocation(wf, file, param.position, true); |
| 45 | for (auto [sym, refcnt] : file->symbol2refcnt) { |
| 46 | if (refcnt <= 0) |
| 47 | continue; |
| 48 | Usr usr = sym.usr; |
| 49 | Kind kind = sym.kind; |
| 50 | if (std::none_of(syms.begin(), syms.end(), [&](auto &sym1) { return usr == sym1.usr && kind == sym1.kind; })) |
| 51 | continue; |
| 52 | if (auto loc = getLsLocation(db, wfiles, sym, file_id)) { |
| 53 | DocumentHighlight highlight; |
| 54 | highlight.range = loc->range; |
| 55 | if (sym.role & Role::Write) |
| 56 | highlight.kind = DocumentHighlight::Write; |
| 57 | else if (sym.role & Role::Read) |
| 58 | highlight.kind = DocumentHighlight::Read; |
| 59 | else |
| 60 | highlight.kind = DocumentHighlight::Text; |
| 61 | highlight.role = sym.role; |
| 62 | result.push_back(highlight); |
| 63 | } |
| 64 | } |
| 65 | std::sort(result.begin(), result.end()); |
| 66 | reply(result); |
| 67 | } |
| 68 | |
| 69 | namespace { |
| 70 | struct DocumentLink { |
nothing calls this directly
no test coverage detected