Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

Conversation

@chrismwendt
Copy link
Contributor

This tries LSIF before falling back to basic-code-intel (symbol and text search).

Most of the code is copied from https://github.com/sourcegraph/sourcegraph/blob/598201b6678c4819bd0f63e9095809fc34de82a2/lsif/extension/src/lsif.ts Once this is merged into all of the individual language extensions, the sourcegraph/lsif extension in sourcegraph/sourcegraph can be deleted.

@chrismwendt chrismwendt requested a review from lguychard July 19, 2019 08:17
Copy link
Contributor

@lguychard lguychard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving as code changes generally LGTM. I'd like to raise a couple of items for discussion:

  • How do we feel about the fact that, with this PR in, the name of this package now belies the extent of its functionality? It would now provides basic, heuristic-based code intel, but also precise code intel when LSIF is available.

  • In the language extensions that can be backed by a language server, the activation flow is currently as follows:

if (hasLanguageServerURL) {
    activateLanguageServer()
} else {
    activateBasicCodeIntel()
}

(see sourcegraph-go, sourcegraph-typescript)

This means that by default, language servers would essentially be prioritized over LSIF when available. This is the case on sourcegraph.com. Shouldn't it be the other way around? If LSIF dumps are available, they should be preferred to all other types of code intelligence, as they're guaranteed to be precise and fast. Yet if no LSIF dump is available for a given commit, we'd still want to fall back to using the language server.

I understand that, outside of sourcegraph.com, a situation where an instance has both language servers and LSIF set up will be excessively rare, but I still feel like the prioritization of the different types of code intelligence should be as obvious/intuitive as possible.

@chrismwendt
Copy link
Contributor Author

  • How do we feel about the fact that, with this PR in, the name of this package now belies the extent of its functionality? It would now provides basic, heuristic-based code intel, but also precise code intel when LSIF is available.

I'll rethink this after GopherCon. Ideas:

  • Rename it
  • Move LSIF into lsp-client and depend on lsp-client
  • Make a new package lsif, and have sourcegraph-{typescript,go} depend on all 3: lsif, basic-code-intel, and lsp-client

This means that by default, language servers would essentially be prioritized over LSIF when available. This is the case on sourcegraph.com. Shouldn't it be the other way around?

Oh yeah, I completely overlooked this, thanks for pointing it out! I'll figure out how to set the priority to: LSIF, language server, then basic-code-intel.

@chrismwendt chrismwendt merged commit 2a03df3 into master Jul 20, 2019
@chrismwendt chrismwendt deleted the lsif branch July 20, 2019 04:29
// Prevent leaking the name of a private repository to
// Sourcegraph.com by relying on the Sourcegraph extension host's
// private repository detection, which will throw an error when
// making a GraphQL request.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the code is not clear to me.

  • How would we leak private repo names? Wouldn't we always contact the private instance?
  • Why would the extension host throw an error on any GraphQL request to the private instance? How would it even intercept GraphQL requests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Private repo names would have been leaked by a browser extension running on private GitHub.com repos.

There's already code in the extension host to detect if the page is a private repo. This logic triggers that code to get run at the expense of an extra GraphQL request. Do you have any ideas to improve this? Maybe the extension API could expose isPrivateRepository?

return defaultR
}

export function initLSIF() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be that there is no TSLint setup in this repo? Because this function doesn't have a return type annotation, which would be rejected by our TSLint config (and also would have made it a lot easier to understand this code, as a reviewer)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP on tslint in #125

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants