com.intellij.refactoring.rename.PsiElementRenameHandler Java Examples
The following examples show how to use
com.intellij.refactoring.rename.PsiElementRenameHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LombokElementRenameHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) { PsiElement element = PsiElementRenameHandler.getElement(dataContext); if (null == element) { element = BaseRefactoringAction.getElementAtCaret(editor, file); } if (null != element) { RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(element); element = processor.substituteElementToRename(element, editor); } if (null != element) { editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); PsiElement nameSuggestionContext = file.getViewProvider().findElementAt(editor.getCaretModel().getOffset()); PsiElementRenameHandler.invoke(element, project, nameSuggestionContext, editor); } }
Example #2
Source File: VariableInplaceRenameHandler.java From consulo with Apache License 2.0 | 6 votes |
@Override public void invoke(@Nonnull final Project project, final Editor editor, final PsiFile file, final DataContext dataContext) { PsiElement element = PsiElementRenameHandler.getElement(dataContext); if (element == null) { if (LookupManager.getActiveLookup(editor) != null) { final PsiElement elementUnderCaret = file.findElementAt(editor.getCaretModel().getOffset()); if (elementUnderCaret != null) { final PsiElement parent = elementUnderCaret.getParent(); if (parent instanceof PsiReference) { element = ((PsiReference)parent).resolve(); } else { element = PsiTreeUtil.getParentOfType(elementUnderCaret, PsiNamedElement.class); } } if (element == null) return; } else { return; } } editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); if (checkAvailable(element, editor, dataContext)) { doRename(element, editor, dataContext); } }
Example #3
Source File: LSPRenameHandler.java From lsp4intellij with Apache License 2.0 | 5 votes |
@Override public boolean isAvailableOnDataContext(DataContext dataContext) { PsiElement element = PsiElementRenameHandler.getElement(dataContext); Editor editor = CommonDataKeys.EDITOR.getData(dataContext); PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext); return editor != null && file != null && isAvailable(element, editor, file); }
Example #4
Source File: VariableInplaceRenameHandler.java From consulo with Apache License 2.0 | 5 votes |
@Override public final boolean isAvailableOnDataContext(final DataContext dataContext) { final PsiElement element = PsiElementRenameHandler.getElement(dataContext); final Editor editor = dataContext.getData(CommonDataKeys.EDITOR); final PsiFile file = dataContext.getData(CommonDataKeys.PSI_FILE); if (editor == null || file == null) return false; if (ourPreventInlineRenameFlag.get() != null) { return false; } return isAvailable(element, editor, file); }
Example #5
Source File: VariableInplaceRenameHandler.java From consulo with Apache License 2.0 | 5 votes |
@Override public void invoke(@Nonnull final Project project, @Nonnull final PsiElement[] elements, final DataContext dataContext) { PsiElement element = elements.length == 1 ? elements[0] : null; if (element == null) element = PsiElementRenameHandler.getElement(dataContext); LOG.assertTrue(element != null); Editor editor = dataContext.getData(CommonDataKeys.EDITOR); if (checkAvailable(element, editor, dataContext)) { doRename(element, editor, dataContext); } }
Example #6
Source File: LombokElementRenameVetoHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
public boolean isAvailableOnDataContext(DataContext dataContext) { final PsiElement element = PsiElementRenameHandler.getElement(dataContext); return element instanceof LombokLightClassBuilder || ((element instanceof LombokLightMethodBuilder || element instanceof LombokLightFieldBuilder) && element.getNavigationElement() instanceof PsiAnnotation); }
Example #7
Source File: RefactoringActionHandlerFactoryImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public RefactoringActionHandler createRenameHandler() { return new PsiElementRenameHandler(); }