-
Notifications
You must be signed in to change notification settings - Fork 16
Update readme #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Update readme #73
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,73 @@ | ||
# Kotlin SCIP support | ||
<img src="https://img.shields.io/maven-central/v/com.sourcegraph/semanticdb-kotlinc?style=flat-square" /> | ||
|
||
This codebase implements a Kotlin compiler plugin that can be used together | ||
with [scip-java](https://sourcegraph.github.io/scip-java) to emit | ||
This codebase implements a Kotlin compiler plugin that can be used together with | ||
[scip-java](https://sourcegraph.github.io/scip-java) to emit | ||
[SCIP](https://github.com/sourcegraph/scip) indexes for Kotlin projects. | ||
|
||
## Getting started | ||
|
||
This project must be used together with scip-java. Visit | ||
[scip-java](https://sourcegraph.github.io/scip-java/) for instructions on how | ||
to index Kotlin projects with scip-java. Note that scip-java indexes Kotlin | ||
sources even if you have no Java code. | ||
[scip-java](https://sourcegraph.github.io/scip-java/) for instructions on how to | ||
index Kotlin projects with scip-java. Note that scip-java indexes Kotlin sources | ||
even if you have no Java code. | ||
|
||
## SemanticDB support | ||
|
||
This project is implemented as a | ||
[SemanticDB](https://scalameta.org/docs/semanticdb/specification.html) compiler | ||
plugin. To generate SCIP, you first compile the Kotlin sources with the | ||
SemanticDB compiler plugin and then convert SemanticDB files into SCIP using | ||
`scip-java index-semanticdb`. See [Low-level usage](#low-level-usage) for more | ||
details on how to generate SemanticDB files and convert SemanticDB into SCIP. | ||
|
||
## Low-level usage | ||
|
||
|
||
First, fetch the jar file of the SemanticDB compiler plugin: | ||
[`com.sourcegraph:semanticdb-kotlinc:VERSION`](https://mvnrepository.com/artifact/com.sourcegraph/semanticdb-kotlinc). | ||
For example, you can use | ||
[Coursier](https://get-coursier.io) to download the jar file. | ||
|
||
```sh | ||
curl -fLo coursier https://github.com/coursier/launchers/raw/master/coursier && chmod +x ./coursier | ||
export SEMANTICDB_KOTLIN_JAR=$(./coursier fetch com.sourcegraph:semanticdb-kotlinc:VERSION) | ||
``` | ||
|
||
Once you have the jar file, you need to determine two compiler options: | ||
|
||
- `sourceroot`: the absolute path to the root directory of your codebase. All | ||
source files that you want to index should be under this directory. For Gradle | ||
codebases, this is typically the toplevel `build.gradle` file. For Maven | ||
codebases, this is typically the toplevel `pom.xml` file. | ||
- `targetroot`: the absolute path to the directory where you want the compiler | ||
plugin to write SemanticDB files. This can be any directory on your computer. | ||
|
||
Now you have all the necessary parameters to invoke the Kotlin compiler with | ||
the SemanticDB compiler plugin. | ||
|
||
```sh | ||
kotlinc -Xplugin=${SEMANTICDB_KOTLIN_JAR} \ | ||
-P plugin:semanticdb-kotlinc:sourceroot=SOURCEROOT_DIRECTORY \ | ||
-P plugin:semanticdb-kotlinc:targetroot=TARGETROOT_DIRECTORY | ||
``` | ||
|
||
Once the compilation is complete, the targetroot should contain `*.semanticdb` | ||
files in the `META-INF/semanticdb` sub-directory. | ||
|
||
To convert the SemanticDB files into SCIP, run `scip-java index TARGETROOT_DIRECTORY`. | ||
If you have Coursier installed, you can run scip-java directly like this | ||
|
||
```sh | ||
cd $SOURCEROOT_DIRECTORY | ||
./coursier launch --contrib scip-java -- index-semanticdb TARGETROOT_DIRECTORY | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.