Skip to content

Commit 1749f38

Browse files
committed
Minor stylistic changes and updates to README
1 parent f9c2cc8 commit 1749f38

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

BUILDING.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Contains the commands require to build this project. Note that you might need to use `gradlew` instead of `./gradlew` when running on `cmd.exe`.
33

44
## Setting up the development environment
5+
* Java should be installed and located under JAVA_HOME or PATH
56

67
### For language server development
78
* `./gradlew install`

README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
# kotlin-language-server
22
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).
33

4-
## Contributing
4+
## Getting Started
55
See [BUILDING.md](BUILDING.md) for build instructions.
66

77
## 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.
99

1010
There are two hard parts of implementing a language server:
1111
- Figuring out the dependencies
1212
- Incrementally re-compiling as the user types
1313

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.
1515

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.
1717

1818
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):
2020
- `val content: String` A snapshot of the source code
2121
- `val parse: KtFil` The parsed AST
2222
- `val compile: BindingContext` Additional information about the AST from typechecking
2323
- After the user edits the file:
2424
- Find the smallest section the encompasses all the user changes
2525
- Get the `LexicalScope` encompassing this region from the `BindingContext` that was generated by the full-compile
2626
- 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
2828
- Re-compile this tiny fake file
2929

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.
3131

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.
3333

3434
## Features
3535

@@ -51,6 +51,6 @@ There is an extensive suite of behavioral [tests](https://github.com/georgewfras
5151
### Global symbols
5252
![Global symbols](images/GlobalSymbols.png)
5353

54-
## Requirements
55-
56-
## Known Issues
54+
## Authors
55+
* [georgewfraser](https://github.com/georgewfraser)
56+
* [fwcd](https://github.com/fwcd)

TODO.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
# TODO
2+
13
## Bugs
24

35
## Features
46
- Fix-imports-on-save, default to 'on'
57
- See https://godoc.org/golang.org/x/tools/cmd/goimports
68
- Rename
7-
- .kts support with eval
9+
- .kts support with eval
10+
11+
## Requirements
12+
13+
## Known Issues

src/main/kotlin/org/javacs/kt/CompiledFile.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ class CompiledFile(
125125
}
126126

127127
fun describePosition(offset: Int, oldContent: Boolean = false): String {
128-
val c = if (oldContent) parse.text else content
128+
val c = if (oldContent) parse.text else content
129129
val pos = position(c, offset)
130130
val file = parse.toPath().fileName
131131

132132
return "$file ${pos.line + 1}:${pos.character + 1}"
133133
}
134134

135135
private fun describeRange(range: TextRange, oldContent: Boolean = false): String {
136-
val c = if (oldContent) parse.text else content
136+
val c = if (oldContent) parse.text else content
137137
val start = position(c, range.startOffset)
138138
val end = position(c, range.endOffset)
139139
val file = parse.toPath().fileName

0 commit comments

Comments
 (0)