Skip to content
This repository was archived by the owner on Jun 7, 2022. It is now read-only.
This repository was archived by the owner on Jun 7, 2022. It is now read-only.

Support cross-repository go-to-definition #8

@felixfbecker

Description

@felixfbecker
  • Extension makes go-to-definition request
  • Server detects definition URI is in node_modules (location will point to a .d.ts file)
  • Server reads and parses package.json
  • Server maps package to clone URL and rev from the package.json repository and gitHead fields (gitHead requires an npm registry request because of support gitHead property in package.json yarnpkg/yarn#2978)
  • Server resolves cloneURL and rev to a Sourcegraph raw target root URI (needs new API, e.g. https://sourcegraph.com/.api/resolve?clone_url=git@github.com/sourcegraph/sourcegraph&rev=abc123)
  • Server determines repo-root-relative package.json location from directory field proposed in npm RFC Add Monorepo Subdirectory Declaration RFC npm/rfcs#19)
    • If not present
      • MVP: assume root of repo (works for most libraries)
      • search all package.jsons in repo for the one with the correct name field (TODO: how? maybe raw API like /raw/**/package.json)
  • Server reads and parses .d.ts.map file for the definition URI
  • Server maps definition location in .d.ts to position in .ts file (using source-map library)
  • Server resolves package-root-relative .ts. location from package root in node_modules
  • Server resolves target URI from target root URI, repo-root-relative package.json location and package-root-relative .ts location
  • Server returns target URI to extension
  • Extension returns target URI to Sourcegraph

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions