-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to query workspace/symbols by a SymbolDescriptor #12
Conversation
This LGTM, @beyang any comments? |
### Extended Workspace Symbol Request | ||
|
||
The `workspace/symbol` request takes an optional parameter `symbol` that allows you to query by known properties about the symbol. | ||
The string `query` parameter becomes optional. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felixfbecker think it might be good to give examples of the different use cases of query
and symbol
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add an examples section.
/** | ||
* Known properties about the symbol. | ||
*/ | ||
symbol?: Partial<SymbolDescriptor>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we must modify the type of query
to be optional with this extensive anyway, what is the reason to have the fields be separate?
i.e. why not just have query
be either a string
or a Partial<SymbolDescriptor>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about that too, but there are languages that are strictly typed and cannot have it either be a string or an object. LSP will avoid these union types in the future, see microsoft#39. There isn't really a disadvantage to it, but it increases the likelihood of the proposal getting accepted later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query |
symbol |
---|---|
user input in UI | used programmatically |
matches as fuzzily as possible | matches as exact as possible |
returns as many results as possible | returns as few results as possible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, and sounds good. In that case:
- How about naming it
querySymbol
instead? - Can we clarify that only one of
query
orquerySymbol
should be present? If not, what is the behavior of a LS when both are specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I like to keep it short and precise - if any, I would prefer
symbolQuery
, and that is kind of confusing since the whole thing you are doing is a symbol query. I thought about naming itsymbolDescriptor
, but it is not a fullSymbolDescriptor
, and I would like to change it toSymbolInformation
soon. - Yes, this should be specified. The semantics should be an AND, because it could be useful to query with a fuzzy
query
but restrict it to a specificSymbolKind
orpackage
.
The motivation behind this PR is to enable querying based on Sourcegraph URLs like I assume it is. So the question arises: how does Sourcegraph know to get a If we would need a language-specific Sourcegraph piece to do this, why not just pass the string directly into the LS and let it parse it? e.g. we could change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(requesting changes so this doesn't get merged prematurely)
@slimsag The idea was to add a new field to |
TODO: need to add |
Can you elaborate on this? Not sure if I understand which endpoint you are talking about |
|
Ok, I see why you'd want to pack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This was @beyang's point, I think it is needed because in TypeScript global j2d would normally not resolve to the actual declaration in the TS source, but to the TS definition file (which is just a stub). So I think the steps needed there are to do |
Got it, that makes sense. So it was talking about the TS/JS cross-repo j2d. Thanks for the clarification @felixfbecker ! |
Who's gonna implement this for the Go LS? |
@felixfbecker I think @slimsag should implement this on the Go side, see my note in slack. |
Yes, I will implement for the Go LS |
@beyang please provide final LGTM |
Use cases are constructing symbol URLs and global j2d.
Discussed with @rothfels and @beyang