public static boolean validElement(@NotNull PsiElement element) {
   if (element instanceof PsiFile) return true;
   if (!element.isPhysical()) return false;
   final RefactoringSupportProvider provider =
       LanguageRefactoringSupport.INSTANCE.forLanguage(element.getLanguage());
   return provider.isSafeDeleteAvailable(element);
 }
Ejemplo n.º 2
0
 @Override
 public boolean doInplaceRenameFor(PsiElement element, PsiElement context) {
   if (!element.isWritable() || element.getContainingFile() == null) return false;
   final RefactoringSupportProvider realProvider =
       ContextProvider.getContextProvider(element).getRefactoringSupportProvider();
   return realProvider != null && realProvider.doInplaceRenameFor(element, context);
 }
Ejemplo n.º 3
0
 @Override
 public boolean isSafeDeleteAvailable(PsiElement element) {
   if (!element.isWritable() || element.getContainingFile() == null) return false;
   final RefactoringSupportProvider realProvider =
       ContextProvider.getContextProvider(element).getRefactoringSupportProvider();
   return realProvider != null && realProvider.isSafeDeleteAvailable(element);
 }
 @Override
 protected boolean isAvailable(PsiElement element, Editor editor, PsiFile file) {
   final PsiElement nameSuggestionContext = file.findElementAt(editor.getCaretModel().getOffset());
   if (element == null && LookupManager.getActiveLookup(editor) != null) {
     element = PsiTreeUtil.getParentOfType(nameSuggestionContext, PsiNamedElement.class);
   }
   final RefactoringSupportProvider supportProvider =
       element != null
           ? LanguageRefactoringSupport.INSTANCE.forLanguage(element.getLanguage())
           : null;
   return editor.getSettings().isVariableInplaceRenameEnabled()
       && supportProvider != null
       && supportProvider.isMemberInplaceRenameAvailable(element, nameSuggestionContext);
 }