@Nullable public static HierarchyProvider findBestHierarchyProvider(final LanguageExtension<HierarchyProvider> extension, @Nullable PsiElement element, DataContext dataContext) { if (element == null) return null; List<HierarchyProvider> providers = extension.allForLanguage(element.getLanguage()); for (HierarchyProvider provider : providers) { PsiElement target = provider.getTarget(dataContext); if (target != null) { return provider; } } return ContainerUtil.getFirstItem(providers); }
@Nullable @RequiredReadAction public static HierarchyProvider findProvider(@Nonnull LanguageExtension<HierarchyProvider> extension, @Nullable PsiElement psiElement, @Nullable PsiFile psiFile, @Nonnull DataContext dataContext) { final HierarchyProvider provider = findBestHierarchyProvider(extension, psiElement, dataContext); if (provider == null) { return findBestHierarchyProvider(extension, psiFile, dataContext); } return provider; }
@Nullable @RequiredReadAction public static HierarchyProvider findBestHierarchyProvider(final LanguageExtension<HierarchyProvider> extension, @Nullable PsiElement element, DataContext dataContext) { if (element == null) return null; List<HierarchyProvider> providers = extension.allForLanguage(element.getLanguage()); for (HierarchyProvider provider : providers) { PsiElement target = provider.getTarget(dataContext); if (target != null) { return provider; } } return ContainerUtil.getFirstItem(providers); }
BaseOnThisElementAction(@Nonnull String text, @Nonnull String actionId, @Nonnull Key<?> browserDataKey, @Nonnull LanguageExtension<HierarchyProvider> providerLanguageExtension) { super(text); myActionId = actionId; myBrowserDataKey = browserDataKey; myProviderLanguageExtension = providerLanguageExtension; }
@NotNull @Override protected LanguageExtension<CodeInsightActionHandler> getLanguageExtension() { return CodeInsightActions.GOTO_SUPER; }
@NotNull @Override protected LanguageExtension<LanguageCodeInsightActionHandler> getLanguageExtension() { return CodeInsightActions.IMPLEMENT_METHOD; }
@NotNull @Override protected LanguageExtension<LanguageCodeInsightActionHandler> getLanguageExtension() { return CodeInsightActions.OVERRIDE_METHOD; }
@NotNull protected abstract LanguageExtension<? extends CodeInsightActionHandler> getLanguageExtension();
protected BrowseHierarchyActionBase(final LanguageExtension<HierarchyProvider> extension) { myExtension = extension; }
public <T> void addExplicitExtension(@Nonnull LanguageExtension<T> instance, @Nonnull Language language, @Nonnull T object) { doAddExplicitExtension(instance, language, object); }
protected BrowseHierarchyActionBase(@Nonnull LanguageExtension<HierarchyProvider> extension) { myExtension = extension; }