-
Notifications
You must be signed in to change notification settings - Fork 6
Support cross-repository go-to-definition #8
Comments
I assume this is primarily necessary to support private repos dependencies? Public repositories could just be cloned directly from the code host, right? If this is the constraint, then instead of having a dependency back to Sourcegraph could the requirement be that the user configured the server container to have the appropriate git credentials for cloning private things (e.g. .netrc, SSH keys, etc.)? |
Please look at the bold terms - the target root URI that is the result of that step is used to form the final definition URI in the last step, so Sourcegraph can navigate to it. It is not used anywhere to fetch contents from that repo, so additional credentials for cloning would not help. We just need to tell the client "the definition is at this location". The only alternative I see to this is return a made-up URI (not a URL) that only has meaning to Sourcegraph, like our legacy repo URI |
Can you give an example of what a target root URI looks like? |
It's a URL pointing to the Sourcegraph raw API for the repo root. E.g. |
Given the flow above (if I understand correctly), I think I would favor the URI approach to an extra round trip. In other words, delete this step:
Modify these steps:
|
So you would return |
I must be missing some understanding, but just reading the issue description it seems like the proposed flow is:
If we treat these like variables in algebra, then it seems like we could eliminate the first network call.
The only reason I call it target URI 2 is to clarify that this is a potentially different URI from the original proposal. |
You can eliminate the first network call by returning all context needed for the computation of the final URI and shifting the responsibility to do that computation to the client. You would have to put clone URL, rev and repo-root relative .ts location all into the target URI (2). That means either return the HTTP resolve API URL, e.g. |
(b) makes the most sense to be between the two because it seems strictly simpler. I wouldn't hesitate to use regular query params so you don't have to do special parsing with the |
That is basically what we are currently doing with The goal is to remove Sourcegraph-specific things from public API of language servers. That's the reason we are moving from |
Sorry, I am still catching up in understanding here. I now understand the desire to return a URL so I would change my answer to (a), and I actually like your idea to have it redirect instead of resolving it a priori (I am curious to hear why you think the redirect isn't clean). For example: I guess my question about your proposal is "how does the language server know to contact This sounds like it would be a "Sourcegraph proposed extension to LSP" as a general way to resolve cross repo definitions. The fact that the language server ends up calling a Sourcegraph endpoint isn't really the problem. The design problem is can we spec this out in a way that feels like a natural extension to LSP that anyone could use and isn't Sourcegraph specific (I think we can). |
Thanks for staying with me!
It would know that Sourcegraph exposes a public API to resolve clone URLs and uses it internally as an implementation detail.
No, Sourcegraph extensions to LSP are forbidden in the new world. We tried speccing these out to feel like "natural extensions to LSP" in the past and they never got adoption. We need to work with what LSP already offers, one of which is arbitrary URIs. |
Ok, I see the value in returning a canonical url, so not using a redirect seems like a good solution.
Do you think a non-Sourcegraph language server author would merge a PR that embeds a Sourcegraph URL? This seems strictly more Sourcegraph specific than my proposal to define a (hopefully) simple capability for doing this generally (i.e. this would support anyone providing a cross reference definition service). |
node_modules
(location will point to a.d.ts
file)repository
andgitHead
fields (gitHead
requires an npm registry request because of support gitHead property in package.json yarnpkg/yarn#2978)https://sourcegraph.com/.api/[email protected]/sourcegraph/sourcegraph&rev=abc123
)directory
field proposed in npm RFC Add Monorepo Subdirectory Declaration RFC npm/rfcs#19)name
field (TODO: how? maybe raw API like/raw/**/package.json
).d.ts.map
file for the definition URI.d.ts
to position in.ts
file (usingsource-map
library).ts.
location from package root innode_modules
.ts
locationThe text was updated successfully, but these errors were encountered: