Relationship Between Editor and PsiFile...
I'm helping Scott with the Gosu language plugin. We are still filling in the details of the PSI tree, but we've got a decent translation between our parsers data structures and the PSI stuff.
What I'm wondering about is how the editor works with the PsiFile. I've created an Annotator to display messages, but I keep getting the original PsiFile that was set up, so even after I fix errors, the error messages keep showing up. I have a feeling this is due to the way that we are constructing the Psi elements, but I was hoping someone could give me a clear explanation of the relationship between the editor and the PsiFile:
* Does the PsiFile manage it's own modifications via a reparse in response to editing?
* Is the PsiFile recreated by IntelliJ and replaced?
Some rough details on where to look or set breakpoints would be very helpful.
Thanks in advanced for your patience while I stumble around the IDE internals...
Cheers,
Carson
Please sign in to leave a comment.
Hello Carson,
First of all, please refer to http://confluence.jetbrains.net/display/IDEADEV/PluginDevelopment
and in particular to http://confluence.jetbrains.net/display/IDEADEV/IntelliJIDEAArchitectural+Overview
for a more comprehensive explanation.
To answer your specific question: the PsiFile instance is not recreated when
a file is modified and reparsed; only the specific elements in the changed
area of the code are recreated on a reparse. The reparse itself is performed
when PsiDocumentManager.commitDocument() is called. The background error
highligting process performs this as the first step of the highlighting.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Awesome, thanks Dmitry.
If I can ask an unrelated question:
There are multiple ways to implement auto-complete:
* override com.intellij.psi.PsiReference#getVariants()
* register with com.intellij.codeInsight.completion.CompletionContributor#extend()
* override com.intellij.codeInsight.completion.CompletionContributor#fillCompletionVariants()
Would the following be a correct understanding of these?
We should implement getVariants() for basic member code completion. We should then use a CompletionContributor to implement key word and symbol completion (? on the second piece.) Ideally we should avoid overriding fillCompletionVariants().
Would you say that's a correct approach?
Thanks again,
Carson
Hello Carson,
That's basically correct. There is no big advantage in implementing completion
via PsiReference.getVariants() as opposed to CompletionContributor.extend(),
so you should use the former if it's convenient for you (if resolve and completion
variant collection are both implemented using the same approach of walking
up the PSI tree, for example). Otherwise, you can implement all completion
options via CompletionContributor.extend().
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Perfect. Thanks Dmitry.
Cheers,
Carson