Search in sources :

Example 1 with InlineActionHandler

use of com.intellij.lang.refactoring.InlineActionHandler in project intellij-community by JetBrains.

the class InlineRefactoringActionHandler method invoke.

@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);
    }
}
Also used : PsiElement(com.intellij.psi.PsiElement) InlineActionHandler(com.intellij.lang.refactoring.InlineActionHandler)

Example 2 with InlineActionHandler

use of com.intellij.lang.refactoring.InlineActionHandler in project intellij-community by JetBrains.

the class InlineRefactoringActionHandler method invoke.

@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]);
}
Also used : Editor(com.intellij.openapi.editor.Editor) InlineActionHandler(com.intellij.lang.refactoring.InlineActionHandler)

Aggregations

InlineActionHandler (com.intellij.lang.refactoring.InlineActionHandler)2 Editor (com.intellij.openapi.editor.Editor)1 PsiElement (com.intellij.psi.PsiElement)1