Open fwcd opened 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
The analysis API now contains a platform interface, KaSourceModificationService
might be what we are looking for.
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
andVirtualFile
(withLightVirtualFile
being an in-memory implementation, see e101c13ece40ac3d31f7f36ad33685be6ba16709 for some experimentation with this)Document
(apparently for mediating between virtual files and PSI?)FileDocumentManager
andPsiDocumentManager
are interesting herePsiFile
(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
(interesting since it uses the same APIs for roughly the same purpose, however in a plugin context)kotlin-language-server
(using an expression-level tiny fake file mechanism)