Sourcegraph offers, in the words of the San-Francisco-based startup of the same name, “code search + intelligence.” What this means is that Sourcegraph offers the code intelligence features (jump to definition, find references, and documentation hovers) that you’ve come to expect from your IDE whenever you browse code outside your IDE, be it on Github or in your code review tool.
What Does It Do?
Sourcegraph allows you to view any code from a public Github repository almost like you would in your IDE. Sourcegraph’s slick Web UI offers not only syntax highlighting, but also advanced navigation features like jump to definition or find references.
The following screenshot depicts the result of such a find references search for a type from the SpotBugs project (click on the image to browse in Sourcegraph):
But you can do more than browse the source code of a single project. Sourcegraph envisions a global code graph which allows you to easily jump from project to project or to search for references in many projects at once.
Sourcegraph already supports languages like Java and Go, with many more on the roadmap.
How does it work?
Sourcegraph employs information retrieval at a large scale, searching through the code (and all revisions) of thousands of projects hosted at Github. It does not perform any machine learning yet.
Under the hood, Sourcegraph uses the Language Server Protocol (LSP). This allows it to easily support many languages with a single implementation. As the LSP notion of code intelligence (finding definitions, references, …) is somewhat limited, however, Sourcegraph cannot gain a deeper, structural understanding of the code. Thus, advanced searches like finding similar code snippets (like Codota does) are currently out of reach.
Where Can I Try it?
You can download multiple integrations with popular editors (VS Code, Sublime Text, Atom, IntelliJ) and browsers (Chrome, Firefox), which allow you to quickly open the current file in Sourcegraph’s Web-based viewer. You can also sign up and connect Sourcegraph with your Github account. Finally, their commercial offering Sourcegraph Enterprise will search through code that doesn’t reside on a public server.
About the author: Dr. Marcel Bruch is the founder of Codetrails and holds a PhD from Darmstadt University of Technology. He leads the Eclipse Code Recommenders project, which brought AI-powered developer assistance tools to over 4 million users.