fwcd / kotlin-language-server

Kotlin code completion, diagnostics and more for any editor/IDE using the Language Server Protocol
MIT License
1.66k stars 212 forks source link

Diagnostics false negatives #47

Open Strum355 opened 6 years ago

Strum355 commented 6 years ago

I have the following line (from this repo) return Hover(listOf(Either.forRight(MarkedString("kotlin", hoverText) for which KLS reports:

[INFO]      debounce0   main    Linting .../hover/hovers.kt
[INFO]      async0      main    Finished in 11 ms
[INFO]      debounce0   main    No diagnostics in hovers.kt
[INFO]      async0      main    Find symbols in TextDocumentIdentifier [
                                uri = "file:///home/noah/Kotlin/KotlinLanguageServer/src/main/kotlin/org/javacs/kt/hover/hovers.kt"
                                ]    

while gradle complains: e: /home/noah/Kotlin/KotlinLanguageServer/src/main/kotlin/org/javacs/kt/hover/hovers.kt: (51, 74): Expecting ')'

fwcd commented 6 years ago

@Strum355 I do not see any issues with this line:

https://github.com/fwcd/KotlinLanguageServer/blob/cb946ecc73319b319f53e037588187f5b90d1054/src/main/kotlin/org/javacs/kt/hover/hovers.kt#L51

The Gradle build did pass too: https://travis-ci.org/fwcd/KotlinLanguageServer/builds/409471711

Maybe you have edited the file unintentionally?

Strum355 commented 6 years ago

yea thats the point, i had edited it myself but KotlinLangServer didnt give a diagnostic for it, the output as shown in the codeblock also says that theres no diagnostics. Even if i changed a character to try refresh it, it still would mark it as not an error

fwcd commented 6 years ago

@Strum355 The linter ist not 100% accurate currently, because the mechanism used to incrementally compile an expression is somewhat hacky.

Maybe some kind of race condition occurred when the compiler tries to evaluate your currently selected expression as you move your cursor too quickly for the linter to keep up.

I will leave this open for now.

Strum355 commented 6 years ago

I tried to reduce the possible outside interference, typing only one character to see if anything would refresh, not moving my mouse. Maybe there was some bad state left over, I dont know the workings of this (yet! Hopefully i can get around to learning it!) Thanks for your great work anyways, especially with providing gradle support!

Out of curiosity, do all features (hover, code completion, diagnostics etc) run on the one thread async or do they all have a dedicated thread upon which they run async?

fwcd commented 6 years ago

@Strum355 Yes, they all run on a single async thread (except for the linter), because the Kotlin compiler internals seem to have trouble with concurrency (see #42).