14. Structure View Factory
The structure view can be customized for a specific file type. Creating a structure view factory allows showing the structure of any file in the Structure Tool Window for easy navigation between items in the current editor.
Define a Structure View Factory
The SimpleStructureViewFactory implements PsiStructureViewFactory. The getStructureViewBuilder() implementation reuses the IntelliJ Platform class TreeBasedStructureViewBuilder. At this point the project will not compile until SimpleStructureViewModel is implemented below.
Define a Structure View Model
The SimpleStructureViewModel is created by implementing StructureViewModel, which defines the model for data displayed in the standard structure view. It also extends StructureViewModelBase, an implementation that links the model to a text editor.
Define a Structure View Element
The SimpleStructureViewElement implements StructureViewTreeElement and SortableTreeElement. The StructureViewTreeElement represents an element in the Structure View tree model. The SortableTreeElement represents an item in a smart tree that allows using text other than the presentable text as a key for alphabetic sorting.
Register the Structure View Factory
The SimpleStructureViewFactory implementation is registered with the IntelliJ Platform in the plugin configuration file using the com.intellij.lang.psiStructureViewFactory extension point.
Run the Project
Run the project by using the Gradle runIde task.
Open the test.simple file and choose . The IDE now supports a structure view of the Simple Language:
