From 331b88c05ff690f8854933143f3e1d65556bb051 Mon Sep 17 00:00:00 2001 From: chrisly42 Date: Tue, 20 Jul 2021 11:18:42 +0200 Subject: [PATCH] Added ChooseByNameContributor. --- .../m68k/refs/M68kChooseByNameContributor.kt | 24 +++++++++++++++++++ src/main/resources/META-INF/plugin.xml | 1 + 2 files changed, 25 insertions(+) create mode 100644 src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kChooseByNameContributor.kt diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kChooseByNameContributor.kt b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kChooseByNameContributor.kt new file mode 100644 index 0000000..876acd7 --- /dev/null +++ b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kChooseByNameContributor.kt @@ -0,0 +1,24 @@ +package de.platon42.intellij.plugins.m68k.refs + +import com.intellij.navigation.ChooseByNameContributor +import com.intellij.navigation.NavigationItem +import com.intellij.openapi.project.Project +import de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil.findAllGlobalLabels +import de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil.findAllSymbolDefinitions + +class M68kChooseByNameContributor : ChooseByNameContributor { + override fun getNames(project: Project, includeNonProjectItems: Boolean): Array { + return listOf(findAllGlobalLabels(project), findAllSymbolDefinitions(project)) + .asSequence() + .flatten() + .mapNotNull { it.name } + .toList() + .toTypedArray() + } + + override fun getItemsByName(name: String, pattern: String, project: Project, includeNonProjectItems: Boolean): Array { + return listOf(findAllGlobalLabels(project), findAllSymbolDefinitions(project)) + .flatten() + .toTypedArray() + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index ef4ccbc..0ce46f6 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -29,6 +29,7 @@ implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kSymbolReferenceElementManipulator"/> +