From a94788b89f0448e968f60d8bee5c14ab1b110ce8 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 4 Jul 2018 19:16:56 -0700 Subject: [PATCH] textDocument/references: add excludeRole --- src/messages/textDocument_references.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/messages/textDocument_references.cc b/src/messages/textDocument_references.cc index d8d60f11..479a72ef 100644 --- a/src/messages/textDocument_references.cc +++ b/src/messages/textDocument_references.cc @@ -12,10 +12,12 @@ struct In_TextDocumentReferences : public RequestInMessage { MethodType GetMethodType() const override { return kMethodType; } struct lsReferenceContext { bool base = true; + // Exclude references with any |Role| bits set. + Role excludeRole = Role::None; // Include the declaration of the current symbol. bool includeDeclaration = false; - // Include references with these |Role| bits set. - Role role = Role::All; + // Include references with all |Role| bits set. + Role role = Role::None; }; struct Params { lsTextDocumentIdentifier textDocument; @@ -27,6 +29,7 @@ struct In_TextDocumentReferences : public RequestInMessage { }; MAKE_REFLECT_STRUCT(In_TextDocumentReferences::lsReferenceContext, base, + excludeRole, includeDeclaration, role); MAKE_REFLECT_STRUCT(In_TextDocumentReferences::Params, @@ -72,7 +75,8 @@ struct Handler_TextDocumentReferences sym.usr = stack.back(); stack.pop_back(); auto fn = [&](Use use, lsSymbolKind parent_kind) { - if (use.role & params.context.role) + if (Role(use.role & params.context.role) == params.context.role && + !(use.role & params.context.excludeRole)) if (std::optional ls_loc = GetLsLocationEx(db, working_files, use, container)) { if (container)