srctx: source context
A lib for source context analysis based on LSIF.
| Name |
Status |
| Latest Version |
 |
| Unit Tests |
 |
| Code Coverage |
 |
| Code Style |
 |
About
This lib processes LSIF file into graphs then you can apply some analysis on them.
This lib originally was designed for monitoring the influence of each commits.
With the raw diff, we can only get something like:
@@ -19,6 +20,7 @@ func AddDiffCmd(app *cli.App) {
var lsifZip string
var outputJson string
var outputCsv string
+ var outputDot string
diffCmd := &cli.Command{
Name: "diff",
:
If we need to know the impact of these line changes on the entire repository, we can only rely on manual reading of the code to evaluate.
With this lib developers can know exactly what happened in every lines of your code. Such as definition, reference. For example, get all the references happened in a specific line:
vertices, _ := sourceContext.RefsByLine(path, eachLine)
log.Debugf("path %s line %d affected %d vertexes", path, eachLine, len(vertices))
Some "dangerous" line changes can be found automatically.
We hope to utilize the powerful indexing capabilities of LSIF to quantify and evaluate the impact of text changes on the repository, reducing the mental burden on developers.
Usage
Usage as Lib
Please see cmd/srctx/cmd_diff.go.
Usage as Cli
1. Generate LSIF file
https://lsif.dev/
LSIF is a standard format for persisted code analyzer output.
Today, several companies are working to support its growth, including Sourcegraph and GitHub/Microsoft.
You can easily find an existed tool for generating LSIF file for your repo.
You will get a dump.lsif file after that.
2. Run srctx
Download our prebuilt binaries from release page.
./srctx diff --lsif dump.lsif --outputCsv output.csv
You can see every edited lines and their impacts. Currently we provided:
- total referenced
- referenced out of current files
- referenced out of current dir
Contribution
Issues and PRs are always welcome.
License
Apache 2.0