@sourcegraph/codeintellify
TypeScript icon, indicating that this package has built-in type declarations

3.10.0 • Public • Published

CodeIntellify

build codecov code style: prettier semantic-release sourcegraph: search

Adds code intelligence to code views on the web. Used in Sourcegraph.

What it does

  • Listens to hover and click events on the code view
  • On mouse hovers, determines the line+column position, does an LSP hover request and renders it in a nice tooltip overlay at the token
  • Shows buttons for go-to-definition and find-references
  • When clicking a token, pins the tooltip to that token
  • Highlights the hovered token

Usage

  • Call createHoverifier() to create a Hoverifier object (there should only be one on the page, to have only one HoverOverlay shown).
  • The Hoverifier exposes an Observable hoverStateUpdates that a consumer can subscribe to, which emits all data needed to render the HoverOverlay React component.
  • For each code view on the page, call hoverifier.hoverify(), passing the position events coming from findPositionsFromEvents().
  • hoverify() returns a Subscription that will "unhoverify" the code view again if unsubscribed from

Development

npm install
npm test

# Helpful options:
npm test -- --single-run      # Don't rerun on changes
npm test -- --browsers Chrome # Only run in Chrome

Development is done by running tests. Karma is used to run Mocha tests in the browser. You can debug by opening http://localhost:9876/debug.html in a browser while the test running is active. The tests will rerun automatically when files are changed.

You can run specific tests by adding .only to describe or it calls.

Releases

Releases are done automatically in CI when commits are merged into master by analyzing Conventional Commit Messages. After running npm install, commit messages will be linted automatically when committing. You may have to rebase a branch before merging to ensure it has a proper commit history.

Glossary

Term Definition
Code view The DOM element that contains all the line elements
Line number element The DOM element that contains the line number label for that line
Code element The DOM element that contains the code for one line
Diff part The part of the diff, either base, head or both (if the line didn't change). Each line belongs to one diff part, and therefor to a different commit ID and potentially different file path.
Hover overlay Also called tooltip

Readme

Keywords

none

Package Sidebar

Install

npm i @sourcegraph/codeintellify@3.10.0

Version

3.10.0

License

MIT

Unpacked Size

258 kB

Total Files

37

Last publish

Collaborators

  • techopsadmin
  • andreeleuterio
  • sourcegraph-bot
  • sqs
  • beyang
  • slimsag