Skip to content

Commit

Permalink
textDocument/definition: don't jump to the type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Aug 22, 2019
1 parent 50d7fbc commit 62fbde7
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions src/messages/textDocument_definition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,6 @@
#include <stdlib.h>

namespace ccls {
namespace {
std::vector<DeclRef> GetNonDefDeclarationTargets(DB *db, SymbolRef sym) {
switch (sym.kind) {
case Kind::Var: {
std::vector<DeclRef> 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<DeclRef> 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 &param,
ReplyOnce &reply) {
int file_id;
Expand Down Expand Up @@ -84,7 +60,7 @@ void MessageHandler::textDocument_definition(TextDocumentPositionParam &param,
// |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);
Expand Down

0 comments on commit 62fbde7

Please sign in to comment.