From 62fbde7873b3974f84bfc7dc6471f7d4b1af753f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 22 Aug 2019 02:24:20 -0700 Subject: [PATCH] textDocument/definition: don't jump to the type definition --- src/messages/textDocument_definition.cc | 26 +------------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/messages/textDocument_definition.cc b/src/messages/textDocument_definition.cc index b63cac40..6395826d 100644 --- a/src/messages/textDocument_definition.cc +++ b/src/messages/textDocument_definition.cc @@ -9,30 +9,6 @@ #include namespace ccls { -namespace { -std::vector GetNonDefDeclarationTargets(DB *db, SymbolRef sym) { - switch (sym.kind) { - case Kind::Var: { - std::vector ret = GetNonDefDeclarations(db, sym); - // If there is no declaration, jump to its type. - if (ret.empty()) { - for (auto &def : db->GetVar(sym).def) - if (def.type) { - if (Maybe use = - GetDefinitionSpell(db, SymbolIdx{def.type, Kind::Type})) { - ret.push_back(*use); - break; - } - } - } - return ret; - } - default: - return GetNonDefDeclarations(db, sym); - } -} -} // namespace - void MessageHandler::textDocument_declaration(TextDocumentPositionParam ¶m, ReplyOnce &reply) { int file_id; @@ -84,7 +60,7 @@ void MessageHandler::textDocument_definition(TextDocumentPositionParam ¶m, // |uses| is empty if on a declaration/definition, otherwise it includes // all declarations/definitions. if (drs.empty()) { - for (DeclRef dr : GetNonDefDeclarationTargets(db, sym)) + for (DeclRef dr : GetNonDefDeclarations(db, sym)) if (!(dr.file_id == file_id && dr.range.Contains(ls_pos.line, ls_pos.character))) drs.push_back(dr);