Extending Breadcrumbs Follow Answered Mdargyte Created March 06, 2019 08:04 I'd like to extend the editor Breadcrumbs, specifically to add the file name as the first "crumb" before any symbols. Where should I look to start out?
You may start right here com.intellij.ui.breadcrumbs.BreadcrumbsProvider
Thanks for the info @Alexander.
Unfortunately despite my best efforts I can't seen to figure out how this API is supposed to work.
Can you provide an explanation or example?
It looks as though I would need to provide a subclass of FileBreadcrumbsCollector to a VirtualFile, Editor or EditorWindow, but there doesn't seem to be a way to do that.
Okayyyyy update. Using the IntelliJ Community source I tracked this down to (in the case of the Java language) simply subclassing 'JavaBreadcrumbsInfoProvider', overriding 'acceptElement()' to accept everything the superclass accepts, plus 'PsiFile', and updating 'java/java-impl/src/META-INF/JavaPlugin.xml' to reference the new class. Works perfectly.
How do I get this to work in a plugin? It looks like Extensions may be the way to go. I experimented with adding this to my plugin.xml:
...and defining a class of 'JavaFilenameBreadcrumbsInfoProvider' in my plugin.
Am I heading down the right path?
I can't see JavaBreadcrumbsInfoProvider from within my plugin. This means I need to inherit from 'BreadcrumbsProvider', provide 'private static final Language ourLanguages' myself, and I can't rely on the superclass's implementation of 'acceptElement()'. Fine. However, in re-creating JavaFilenameBreadcrumbsInfoProvider's acceptElement() I need visibility to 'PsiMember' and 'PsiLambdaExpression' which apparently I can't have in a plugin. Am I missing something here? How can I use these missing classes in my plugin?
What might be a good approach for adding more languages? I only really care about making this work for C/C++ with CLion, but I'd like to make this plugin available to others in other environments if possible.