fwcd / fwcd/kotlin-analysis-server
Add proper text synchronization
- Dominant language
- Kotlin
- Stars
- 48
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
The language server should synchronize its virtual file system via LSP's text synchronization methods (mainly `KotlinTextDocumentService.didChange`). To do so, we should investigate how much the IntelliJ APIs take care of for us. Essentially, there are a few abstraction levels in the IntelliJ API, that are partly accessible to us:
- `VirtualFileSystem` and `VirtualFile` (with `LightVirtualFile` being an in-memory implementation, see e101c13ece40ac3d31f7f36ad33685be6ba16709 for some experimentation with this)
- `Document` (apparently for mediating between virtual files and PSI?)
- `FileDocumentManager` and `PsiDocumentManager` are interesting here
- We cannot really change them though, since we apparently miss some extension points from IntelliJ (write access guards)
- `PsiFile` (the parsed AST)
Of course, we could recreate `PsiFile`s every time the user changes a document, ideally, however, we would like to use whatever IntelliJ offers to perform incremental compilation/parsing.
Some resources:
- [`intellij-lsp-server`](https://github.com/Ruin0x11/intellij-lsp-server) (interesting since it uses the same APIs for roughly [the same purpose](https://github.com/Ruin0x11/intellij-lsp-server/blob/50e6726d8535b5f00ef507db19272c551a694db4/src/main/kotlin/com/ruin/lsp/model/WorkspaceManager.kt#L230), however in a plugin context)
- [`kotlin-language-server`](https://github.com/fwcd/kotlin-language-server) (using an [expression-level tiny fake file mechanism](https://github.com/fwcd/kotlin-language-server#incrementally-re-compiling-as-the-user-types))
- The IntelliJ Platform docs on [virtual files](https://plugins.jetbrains.com/docs/intellij/virtual-file.html), [VFSes](https://plugins.jetbrains.com/docs/intellij/virtual-file-system.html), [documents](https://plugins.jetbrains.com/docs/intellij/documents.html) and [PSI](https://plugins.jetbrains.com/docs/intellij/psi-files.html)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.