com.intellij.lang.refactoring.RefactoringSupportProvider Java Examples

The following examples show how to use com.intellij.lang.refactoring.RefactoringSupportProvider. 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: VariableInplaceRenameHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected boolean isAvailable(PsiElement element, Editor editor, PsiFile file) {
  final PsiElement nameSuggestionContext = file.findElementAt(editor.getCaretModel().getOffset());

  RefactoringSupportProvider supportProvider =
          element == null ? null : LanguageRefactoringSupport.INSTANCE.forLanguage(element.getLanguage());
  return supportProvider != null &&
         editor.getSettings().isVariableInplaceRenameEnabled() &&
         supportProvider.isInplaceRenameAvailable(element, nameSuggestionContext);
}
 
Example #2
Source File: MemberInplaceRenameHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #3
Source File: BasePlatformRefactoringAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
protected RefactoringActionHandler getHandler(@Nonnull Language language, PsiElement element) {
  List<RefactoringSupportProvider> providers = LanguageRefactoringSupport.INSTANCE.allForLanguage(language);
  if (providers.isEmpty()) return null;
  if (element == null) return getRefactoringHandler(providers.get(0));
  for (RefactoringSupportProvider provider : providers) {
    if (provider.isAvailable(element)) {
      return getRefactoringHandler(provider, element);
    }
  }
  return null;
}
 
Example #4
Source File: CSharpMemberInplaceRenameHandler.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
@RequiredReadAction
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) && element
			instanceof CSharpNamedElement;
}
 
Example #5
Source File: InlineAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider) {
  return new InlineRefactoringActionHandler();
}
 
Example #6
Source File: SafeDeleteProcessor.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static boolean validElement(@Nonnull 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);
}
 
Example #7
Source File: ExtractClassAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider) {
  return provider.getExtractClassHandler();
}
 
Example #8
Source File: BasePlatformRefactoringAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider, PsiElement element) {
  return getRefactoringHandler(provider);
}
 
Example #9
Source File: BasePlatformRefactoringAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
protected abstract RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider);
 
Example #10
Source File: BasePlatformRefactoringAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean isAvailableForLanguage(final Language language) {
  List<RefactoringSupportProvider> providers = LanguageRefactoringSupport.INSTANCE.allForLanguage(language);
  return ContainerUtil.find(providers, myCondition) != null;
}
 
Example #11
Source File: IntroduceVariableAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider) {
  return provider.getIntroduceVariableHandler();
}
 
Example #12
Source File: IntroduceFieldAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider) {
  return provider.getIntroduceFieldHandler();
}
 
Example #13
Source File: PullUpAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider) {
  return provider.getPullUpHandler();
}
 
Example #14
Source File: ExtractIncludeAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider, PsiElement element) {
  PsiFile file = element.getContainingFile();
  if (file == null) return null;
  return LanguageExtractInclude.INSTANCE.forLanguage(file.getViewProvider().getBaseLanguage());
}
 
Example #15
Source File: ExtractIncludeAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider) {
  return null;
}
 
Example #16
Source File: PushDownAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider) {
  return provider.getPushDownHandler();
}
 
Example #17
Source File: ExtractInterfaceAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider supportProvider) {
  return supportProvider.getExtractInterfaceHandler();
}
 
Example #18
Source File: ExtractModuleAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider supportProvider) {
  return supportProvider.getExtractModuleHandler();
}
 
Example #19
Source File: IntroduceConstantAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider) {
  return provider.getIntroduceConstantHandler();
}
 
Example #20
Source File: ExtractMethodAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider) {
  return provider.getExtractMethodHandler();
}
 
Example #21
Source File: IntroduceParameterAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider) {
  return provider.getIntroduceParameterHandler();
}
 
Example #22
Source File: ExtractSuperclassAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider supportProvider) {
  return supportProvider.getExtractSuperClassHandler();
}
 
Example #23
Source File: ChangeSignatureAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
protected RefactoringActionHandler getRefactoringHandler(@Nonnull RefactoringSupportProvider provider) {
  return provider.getChangeSignatureHandler();
}
 
Example #24
Source File: LanguageRefactoringSupport.java    From consulo with Apache License 2.0 4 votes vote down vote up
private LanguageRefactoringSupport() {
  super("com.intellij.lang.refactoringSupport", new RefactoringSupportProvider() {});
}