@Override public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) { LOG.assertTrue(elements.length == 1); if (dataContext == null) { dataContext = DataManager.getInstance().getDataContext(); } final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.canInlineElement(elements[0])) { handler.inlineElement(project, editor, elements [0]); return; } } invokeInliner(editor, elements[0]); }
@Override public void invoke(@NotNull final Project project, Editor editor, PsiFile file, DataContext dataContext) { editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext); if (element == null) { element = BaseRefactoringAction.getElementAtCaret(editor, file); } if (element != null) { for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.canInlineElementInEditor(element, editor)) { handler.inlineElement(project, editor, element); return; } } if (invokeInliner(editor, element)) return; String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name")); CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null); } }
@Override public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) { LOG.assertTrue(elements.length == 1); if (dataContext == null) { dataContext = DataManager.getInstance().getDataContext(); } final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext); for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.canInlineElement(elements[0])) { handler.inlineElement(project, editor, elements [0]); return; } } invokeInliner(editor, elements[0]); }
@Override public void invoke(@NotNull final Project project, Editor editor, PsiFile file, DataContext dataContext) { editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext); if (element == null) { element = BaseRefactoringAction.getElementAtCaret(editor, file); } if (element != null) { for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.canInlineElementInEditor(element, editor)) { handler.inlineElement(project, editor, element); return; } } if (invokeInliner(editor, element)) return; String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name")); CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null); } }
@Override public void invoke(@Nonnull Project project, @Nonnull PsiElement[] elements, DataContext dataContext) { LOG.assertTrue(elements.length == 1); if (dataContext == null) { dataContext = DataManager.getInstance().getDataContext(); } final Editor editor = dataContext.getData(PlatformDataKeys.EDITOR); for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.canInlineElement(elements[0])) { handler.inlineElement(project, editor, elements [0]); return; } } invokeInliner(editor, elements[0]); }
@Override public void invoke(@Nonnull final Project project, Editor editor, PsiFile file, DataContext dataContext) { editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); PsiElement element = dataContext.getData(LangDataKeys.PSI_ELEMENT); if (element == null) { element = BaseRefactoringAction.getElementAtCaret(editor, file); } if (element != null) { for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.canInlineElementInEditor(element, editor)) { handler.inlineElement(project, editor, element); return; } } if (invokeInliner(editor, element)) return; String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.method.or.local.name")); CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, null); } }
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 boolean isAvailableForLanguage(Language language) { for(InlineActionHandler handler: Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.isEnabledForLanguage(language)) { return true; } } return InlineHandlers.getInlineHandlers(language).size() > 0; }
private void inlineElement(final PsiElement element){ if (element == null) return; if (!(element instanceof PsiModifierListOwner)) return; boolean isPublic = ((PsiModifierListOwner) element).hasModifierProperty("public"); if (isPublic) return; for (final InlineActionHandler handler : Extensions.getExtensions(InlineActionHandler.EP_NAME)) { if (handler.canInlineElement(element)) { handler.inlineElement(element.getProject(), null, element); return; } } }