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);
}
}
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]);
}
Aggregations