fwcd / kotlin-analysis-server

Language server prototype using the new Kotlin analysis API
MIT License
43 stars 2 forks source link

Add proper text synchronization #1

Open fwcd opened 2 years ago

fwcd commented 2 years ago

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:

Of course, we could recreate PsiFiles every time the user changes a document, ideally, however, we would like to use whatever IntelliJ offers to perform incremental compilation/parsing.

Some resources:

rami3l commented 2 years ago

Are you looking for something like this? public static void reparseFiles(Project project, Collection<? extends VirtualFile> files, boolean includeOpenFiles);


An example to use the underlying method in FileContentUtilCore: https://github.com/vsch/idea-multimarkdown/blob/f18cec21960d7f508b5e27ad47e8e3fdd8d3475a/src/main/java/com/vladsch/md/nav/MdProjectComponent.kt#L321

fwcd commented 2 months ago

The analysis API now contains a platform interface, KaSourceModificationService might be what we are looking for.