Structure View update

I have implemented a minimal version of a structure view. The initial structure of the file is displayed but I am unable to reflect in the structure view any changes that occur in the file. I have used both Javascript and Ruby plugins as basis but still something is not working correctly.

What am I not doing right? Any suggestions?

0
4 comments

Hello Jean-Paul Balabanian,

I have implemented a minimal version of a structure view. The initial
structure of the file is displayed but I am unable to reflect in the
structure view any changes that occur in the file. I have tried
several approaches and compared with the Javascript and Ruby plugins.

What am I not doing right?


The structure view contains an optimization causing it to update only when
changes affecting the file structure (outside of method bodies) have occurred.
To make this work correctly for custom languages, you need to call ((PsiModificationTrackerImpl)
PsiManager.getModificationTracker()).incOutOfCodeBlockModificationCount()
when a PSI change happens that affects the file structure in your language.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Hello Dmitry Jemerov,

Thanks for the reply. I added the code you suggested but the tree still does not update. I added it to an intention that I could activate to force the update.

I have checked that the updated tree is provided through getRoot() of TextEditorBasedStructureViewModel and that the method is actually queried during code changes.
I have changed the getChildren() of StructureViewTreeElement to dynamically create the tree with every call, but still no change.

0

My structure view now reflects some of the changes that occur. For some reason higher level structures use longer time to get reflected, in many cases changing the current file is necessary. Is there a reason for this?

0

I am unsure if this is the right solution, or if I just missed the documentation on this, but I was able to make it work by having the ItemPresentation always represent the contents of the associated PsiElement. My final solution was a tree that for every call to getChildren() recreated the child nodes and for every getPresentation() reset the ItemPresentation contents. Not efficient but it works.

Do you have any suggestions on how to improve this? Something that is more aligned with the architecture of the Structure View.

Message was edited by: Jean-Paul Balabanian

0

Please sign in to leave a comment.