sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.1k stars 1.28k forks source link

Search for symbols by containerName #3448

Open sqs opened 5 years ago

sqs commented 5 years ago

As a user, I would like to be able to quickly search for symbols that are "inside" of other symbols, such as a method inside a namespace in a class. I would like to be able to use fuzzy matching to type the minimum necessary to unambiguously specify what I'm looking for, as in:

image

(from ReSharper: https://www.jetbrains.com/help/resharper/Navigation_and_Search__Go_to_Type.html)

Right now, I need to type the full name, and Sourcegraph doesn't know that dot- or space-separated parts of my query should match on containerName vs. name.

From @dobrou:

Is there any way to search in symbol's `containerName` field? This field contains full path `(namespace,class)` of parent symbol. I see it's returned in results, but I can not find any way how to search in it from the query. I could imagine, that if I write search query like this: `type:symbol MyClass.MyMeth` If dot '.' is included in searched symbol name, suggestions and search results will give me symbols where `MyClass` does match `symbol.containerName` and `MyMeth` does match `symbol.name`. My goal is to get as close as possible to my favorite Resharper feature - https://www.jetbrains.com/help/resharper/Navigation_and_Search__Go_to_Type.html Simply type eg: `type:symbol MyN Cla Met` and get quickly to definition like `namespace MyNamespace { class MyClass { void Method () {} }}`

Requested by https://app.hubspot.com/contacts/2762526/company/557889642

/cc @sourcegraph/search-platform

dadlerj commented 4 years ago

Also requested by https://app.hubspot.com/contacts/2762526/company/693777200

slimsag commented 4 years ago

Requested by https://sourcegraph.slack.com/archives/C011899KB6U/p1591909103229700 (https://app.hubspot.com/contacts/2762526/company/693777200)

keegancsmith commented 4 years ago

Would something like this need to be implemented in both zoekt and the symbol server?

Yes. If I am not mistaken in both cases we treat the containerName and name as different data. So this might not be that straight forward to implement. In particular the implementation in Zoekt might be a bit tricky due to how that is designed (I don't think we can search by containerName at all?)