IntelliJ Platform Plugin SDK Help

15. Structure Aware Navigation Bar

Structure-aware navbar allows displaying specific file elements in the navigation bar, depending on the location of the caret in it. For example, in Java this is used to display the class and method in which the caret is currently located.

Define a Structure-Aware Navbar

The SimpleStructureAwareNavbar implements StructureAwareNavBarModelExtension.

final class SimpleStructureAwareNavbar extends StructureAwareNavBarModelExtension { @NotNull @Override protected Language getLanguage() { return SimpleLanguage.INSTANCE; } @Override public @Nullable String getPresentableText(Object object) { if (object instanceof SimpleFile) { return ((SimpleFile) object).getName(); } if (object instanceof SimpleProperty) { return ((SimpleProperty) object).getName(); } return null; } @Override @Nullable public Icon getIcon(Object object) { if (object instanceof SimpleProperty) { return AllIcons.Nodes.Property; } return null; } }

Register the Structure-Aware Navbar

The SimpleStructureAwareNavbar implementation is registered with the IntelliJ Platform in the plugin configuration file using the com.intellij.navbar extension point.

<extensions defaultExtensionNs="com.intellij"> <navbar implementation="org.intellij.sdk.language.SimpleStructureAwareNavbar"/> </extensions>

Run the Project

Run the project by using the Gradle runIde task.

Open the test.simple file and position the caret on any property. The navigation bar displays the name and icon of this property.

Structure Aware Navbar
Last modified: 09 April 2024