public static Map<Language, InlineHandler.Inliner> initializeInliners(PsiElement element, InlineHandler.Settings settings, Collection<? extends PsiReference> allReferences) { final Map<Language, InlineHandler.Inliner> inliners = new HashMap<Language, InlineHandler.Inliner>(); for (PsiReference ref : allReferences) { if (ref == null) { LOG.error("element: " + element.getClass()+ ", allReferences contains null!"); continue; } PsiElement refElement = ref.getElement(); LOG.assertTrue(refElement != null, ref.getClass().getName()); final Language language = refElement.getLanguage(); if (inliners.containsKey(language)) continue; final List<InlineHandler> handlers = InlineHandlers.getInlineHandlers(language); for (InlineHandler handler : handlers) { InlineHandler.Inliner inliner = handler.createInliner(element, settings); if (inliner != null) { inliners.put(language, inliner); break; } } } return inliners; }
private static boolean hasInlineActionHandler(PsiElement element, @Nullable Language editorLanguage, Editor editor) { for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.isEnabledOnElement(element, editor)) { return true; } } return InlineHandlers.getInlineHandlers( editorLanguage != null ? editorLanguage :element.getLanguage() ).size() > 0; }
@Override protected RefactoringActionHandler getHandler(@NotNull Language language, PsiElement element) { RefactoringActionHandler handler = super.getHandler(language, element); if (handler != null) return handler; List<InlineHandler> handlers = InlineHandlers.getInlineHandlers(language); return handlers.isEmpty() ? null : new InlineRefactoringActionHandler(); }
@Override protected boolean isAvailableForLanguage(Language language) { for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.isEnabledForLanguage(language)) { return true; } } return InlineHandlers.getInlineHandlers(language).size() > 0; }
public static boolean invokeInliner(@Nullable Editor editor, PsiElement element) { final List<InlineHandler> handlers = InlineHandlers.getInlineHandlers(element.getLanguage()); for (InlineHandler handler : handlers) { if (GenericInlineHandler.invoke(element, editor, handler)) { return true; } } return false; }
@Override protected RefactoringActionHandler getHandler(@Nonnull Language language, PsiElement element) { RefactoringActionHandler handler = super.getHandler(language, element); if (handler != null) return handler; List<InlineHandler> handlers = InlineHandlers.getInlineHandlers(language); return handlers.isEmpty() ? null : new InlineRefactoringActionHandler(); }