This page is part of multi-step Custom Language Support Tutorial. All previous steps must be executed in sequence for the code to work.
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 NavbarThe 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 NavbarThe 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 ProjectRun 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.
19 March 2025
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4