Java Code Examples for com.intellij.refactoring.rename.RenamePsiElementProcessor#substituteElementToRename()
The following examples show how to use
com.intellij.refactoring.rename.RenamePsiElementProcessor#substituteElementToRename() .
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: LSPRenameHandler.java From lsp4intellij with Apache License 2.0 | 5 votes |
private InplaceRefactoring doRename(PsiElement elementToRename, Editor editor) { if (elementToRename instanceof PsiNameIdentifierOwner) { RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(elementToRename); if (processor.isInplaceRenameSupported()) { StartMarkAction startMarkAction = StartMarkAction.canStart(elementToRename.getProject()); if (startMarkAction == null || (processor.substituteElementToRename(elementToRename, editor) == elementToRename)) { processor.substituteElementToRename(elementToRename, editor, new Pass<PsiElement>() { @Override public void pass(PsiElement element) { MemberInplaceRenamer renamer = createMemberRenamer(element, (PsiNameIdentifierOwner) elementToRename, editor); boolean startedRename = renamer.performInplaceRename(); if (!startedRename) { performDialogRename(editor); } } }); return null; } } else { InplaceRefactoring inplaceRefactoring = editor.getUserData(InplaceRefactoring.INPLACE_RENAMER); if ((inplaceRefactoring instanceof MemberInplaceRenamer)) { TemplateState templateState = TemplateManagerImpl .getTemplateState(InjectedLanguageUtil.getTopLevelEditor(editor)); if (templateState != null) { templateState.gotoEnd(true); } } } } performDialogRename(editor); return null; }
Example 3
Source File: MemberInplaceRenameHandler.java From consulo with Apache License 2.0 | 5 votes |
@Override public InplaceRefactoring doRename(@Nonnull final PsiElement elementToRename, final Editor editor, final DataContext dataContext) { if (elementToRename instanceof PsiNameIdentifierOwner) { final RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(elementToRename); if (processor.isInplaceRenameSupported()) { final StartMarkAction startMarkAction = StartMarkAction.canStart(elementToRename.getProject()); if (startMarkAction == null || processor.substituteElementToRename(elementToRename, editor) == elementToRename) { processor.substituteElementToRename(elementToRename, editor, new Pass<PsiElement>() { @Override public void pass(PsiElement element) { final MemberInplaceRenamer renamer = createMemberRenamer(element, (PsiNameIdentifierOwner)elementToRename, editor); boolean startedRename = renamer.performInplaceRename(); if (!startedRename) { performDialogRename(elementToRename, editor, dataContext); } } }); return null; } else { final InplaceRefactoring inplaceRefactoring = editor.getUserData(InplaceRefactoring.INPLACE_RENAMER); if (inplaceRefactoring != null && inplaceRefactoring.getClass() == MemberInplaceRenamer.class) { final TemplateState templateState = TemplateManagerImpl.getTemplateState(InjectedLanguageUtil.getTopLevelEditor(editor)); if (templateState != null) { templateState.gotoEnd(true); } } } } } performDialogRename(elementToRename, editor, dataContext); return null; }
Example 4
Source File: LombokElementRenameHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public InplaceRefactoring doRename(@NotNull PsiElement elementToRename, @NotNull Editor editor, @Nullable DataContext dataContext) { RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(elementToRename); PsiElement actualElem = processor.substituteElementToRename(elementToRename, editor); return super.doRename(actualElem, editor, dataContext); }