Search in sources :

Example 1 with PerlRefactoringSupportProvider

use of com.perl5.lang.perl.idea.refactoring.PerlRefactoringSupportProvider in project Perl5-IDEA by Camelcade.

the class PerlMemberInplaceRenameHandler method isAvailable.

@Override
protected boolean isAvailable(PsiElement element, Editor editor, PsiFile file) {
    PsiElement nameSuggestionContext = file.findElementAt(editor.getCaretModel().getOffset());
    if (nameSuggestionContext == null && editor.getCaretModel().getOffset() > 0) {
        nameSuggestionContext = file.findElementAt(editor.getCaretModel().getOffset() - 1);
    }
    if (element == null && LookupManager.getActiveLookup(editor) != null) {
        element = PsiTreeUtil.getParentOfType(nameSuggestionContext, PsiNamedElement.class);
    }
    final RefactoringSupportProvider supportProvider = element == null ? null : LanguageRefactoringSupport.INSTANCE.forLanguage(element.getLanguage());
    return editor.getSettings().isVariableInplaceRenameEnabled() && supportProvider instanceof PerlRefactoringSupportProvider && ((PerlRefactoringSupportProvider) supportProvider).isPerlInplaceRenameAvailable(element, nameSuggestionContext);
}
Also used : RefactoringSupportProvider(com.intellij.lang.refactoring.RefactoringSupportProvider) PerlRefactoringSupportProvider(com.perl5.lang.perl.idea.refactoring.PerlRefactoringSupportProvider) PsiNamedElement(com.intellij.psi.PsiNamedElement) PerlRefactoringSupportProvider(com.perl5.lang.perl.idea.refactoring.PerlRefactoringSupportProvider) PsiElement(com.intellij.psi.PsiElement)

Aggregations

RefactoringSupportProvider (com.intellij.lang.refactoring.RefactoringSupportProvider)1 PsiElement (com.intellij.psi.PsiElement)1 PsiNamedElement (com.intellij.psi.PsiNamedElement)1 PerlRefactoringSupportProvider (com.perl5.lang.perl.idea.refactoring.PerlRefactoringSupportProvider)1