[PATCH] D72874: [clangd] Add a textual fallback for go-to-definition

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 12:29:24 PST 2020


nridge added a comment.

Thanks for all the comments Sam! I'll have a detailed look tomorrow, but I wanted to follow up on this:

In D72874#1901383 <https://reviews.llvm.org/D72874#1901383>, @sammccall wrote:

> I think having this trigger where the identifier is an actual token in the program is a surprisingly invasive change and runs a strong risk of confusing users (who can't distinguish these textual heuristics from normal go-to-def behaviour, and rely on its accuracy), and we shouldn't do it without a lot more testing.


The "dependent code" use case is a pretty important one in my eyes.

In one of the codebases I work on, we have a fair amount of code like this:

  template <typename T>
  void foo(T t) {
     // ...
     t.someUniqueMethodName();
     // ...
     t.someOtherUniqueMethodName();
     // ...
  }

The code is in practice only instantiated with a handful of types for T (often just two). (But we don't have a way to express this in the code at this time.) Being able to invoke go-to-definition at e.g. `someUniqueMethodName` and get the definition sites of the corresponding handful of methods, as opposed to nothing at all, is something I'd really like to get working. I'm open to suggestions to how we can test this better, or scope the behaviour more narrowly to avoid other unintended results for real tokens.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72874/new/

https://reviews.llvm.org/D72874





More information about the cfe-commits mailing list