You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+11-11
Original file line number
Diff line number
Diff line change
@@ -1,35 +1,35 @@
1
1
# kotlin-language-server
2
2
This project implements a [language server](https://microsoft.github.io/language-server-protocol/) using the internal APIs of the [Kotlin compiler](https://github.com/JetBrains/kotlin/tree/master/compiler).
3
3
4
-
## Contributing
4
+
## Getting Started
5
5
See [BUILDING.md](BUILDING.md) for build instructions.
6
6
7
7
## This repository needs your help!
8
-
[The original author](https://github.com/georgewfraser) created this project while he was considering using Kotlin in my work. He ended up deciding not to and is not really using Kotlin these days though this is a pretty fully-functional language server that just needs someone to use it every day for a while and iron out the last few pesky bugs.
8
+
[The original author](https://github.com/georgewfraser) created this project while he was considering using Kotlin in his work. He ended up deciding not to and is not really using Kotlin these days though this is a pretty fully-functional language server that just needs someone to use it every day for a while and iron out the last few pesky bugs.
9
9
10
10
There are two hard parts of implementing a language server:
11
11
- Figuring out the dependencies
12
12
- Incrementally re-compiling as the user types
13
13
14
-
Dependencies are determined by the [findClassPath](https://github.com/georgewfraser/kotlin-language-server/blob/master/src/main/kotlin/org/javacs/kt/classpath/findClassPath.kt) function, which invokes Maven or the Gradle and tells it to output a list of dependencies in a temporary folder. Currently, Maven and Gradle projects are supported.
14
+
Dependencies are determined by the [findClassPath](src/main/kotlin/org/javacs/kt/classpath/findClassPath.kt) function, which invokes Maven or the Gradle and tells it to output a list of dependencies in a temporary folder. Currently, Maven and Gradle projects are supported.
15
15
16
-
I get incremental compilation at the file-level by keeping the same `KotlinCoreEnvironment` alive between compilations in [Compiler.kt](https://github.com/georgewfraser/kotlin-language-server/blob/master/src/main/kotlin/org/javacs/kt/Compiler.kt). There is a performance benchmark in [OneFilePerformance.java](https://github.com/georgewfraser/kotlin-language-server/blob/master/src/test/java/org/javacs/kt/OneFilePerformance.java) that verifies this works.
16
+
I get incremental compilation at the file-level by keeping the same `KotlinCoreEnvironment` alive between compilations in [Compiler.kt](src/main/kotlin/org/javacs/kt/Compiler.kt). There is a performance benchmark in [OneFilePerformance.java](src/test/java/org/javacs/kt/OneFilePerformance.java) that verifies this works.
17
17
18
18
Getting incremental compilation at the expression level is a bit more complicated:
19
-
- Fully compile a file and store in [CompiledFile](https://github.com/georgewfraser/kotlin-language-server/blob/master/src/main/kotlin/org/javacs/kt/CompiledFile.kt):
19
+
- Fully compile a file and store in [CompiledFile](src/main/kotlin/org/javacs/kt/CompiledFile.kt):
20
20
-`val content: String` A snapshot of the source code
21
21
-`val parse: KtFil` The parsed AST
22
22
-`val compile: BindingContext` Additional information about the AST from typechecking
23
23
- After the user edits the file:
24
24
- Find the smallest section the encompasses all the user changes
25
25
- Get the `LexicalScope` encompassing this region from the `BindingContext` that was generated by the full-compile
26
26
- Create a fake, in-memory .kt file with just the expression we want to re-compile
27
-
-[Add space](https://github.com/georgewfraser/kotlin-language-server/blob/master/src/main/kotlin/org/javacs/kt/CompiledFile.kt#L81) at the top of the file so the line numbers match up
27
+
-[Add space](src/main/kotlin/org/javacs/kt/CompiledFile.kt#L81) at the top of the file so the line numbers match up
28
28
- Re-compile this tiny fake file
29
29
30
-
The incremental expression compilation logic is all in [CompiledFile.kt](https://github.com/georgewfraser/kotlin-language-server/blob/master/src/main/kotlin/org/javacs/kt/CompiledFile.kt). The Kotlin AST has a built-in repair API, which seems to be how IntelliJ works, but as far as I can tell this API does not work if the surrounding IntelliJ machinery is not present. Hence I created the "fake tiny file" incremental-compilation mechanism, which seems to be quite fast and predictable.
30
+
The incremental expression compilation logic is all in [CompiledFile.kt](src/main/kotlin/org/javacs/kt/CompiledFile.kt). The Kotlin AST has a built-in repair API, which seems to be how IntelliJ works, but as far as I can tell this API does not work if the surrounding IntelliJ machinery is not present. Hence I created the "fake tiny file" incremental-compilation mechanism, which seems to be quite fast and predictable.
31
31
32
-
There is an extensive suite of behavioral [tests](https://github.com/georgewfraser/kotlin-language-server/tree/master/src/test/kotlin/org/javacs/kt), which are all implemented in terms of the language server protocol, so you should be able to refactor the code any way you like and the tests should still work.
32
+
There is an extensive suite of behavioral [tests](src/test/kotlin/org/javacs/kt), which are all implemented in terms of the language server protocol, so you should be able to refactor the code any way you like and the tests should still work.
33
33
34
34
## Features
35
35
@@ -51,6 +51,6 @@ There is an extensive suite of behavioral [tests](https://github.com/georgewfras
0 commit comments