当前位置: 首页>>代码示例>>Java>>正文


Java ExtractInterfaceHandler类代码示例

本文整理汇总了Java中com.intellij.refactoring.extractInterface.ExtractInterfaceHandler的典型用法代码示例。如果您正苦于以下问题:Java ExtractInterfaceHandler类的具体用法?Java ExtractInterfaceHandler怎么用?Java ExtractInterfaceHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ExtractInterfaceHandler类属于com.intellij.refactoring.extractInterface包,在下文中一共展示了ExtractInterfaceHandler类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invoke

import com.intellij.refactoring.extractInterface.ExtractInterfaceHandler; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project,
                   @NotNull PsiFile file,
                   @Nullable("is null when called from inspection") Editor editor,
                   @NotNull PsiElement startElement,
                   @NotNull PsiElement endElement) {
  final PsiMethod method = (PsiMethod)startElement;
  if (!FileModificationService.getInstance().prepareFileForWrite(method.getContainingFile())) return;

  final PsiClass containingClass = method.getContainingClass();
  LOG.assertTrue(containingClass != null);

  PsiManager manager = containingClass.getManager();
  if (containingClass instanceof PsiAnonymousClass) {
    final PsiClassType baseClassType = ((PsiAnonymousClass)containingClass).getBaseClassType();
    final PsiClass baseClass = baseClassType.resolve();
    if (baseClass != null && manager.isInProject(baseClass)) {
      pullUp(method, containingClass, baseClass);
    }
  }
  else {
    final LinkedHashSet<PsiClass> classesToPullUp = new LinkedHashSet<PsiClass>();
    collectClassesToPullUp(manager, classesToPullUp, containingClass.getExtendsListTypes());
    collectClassesToPullUp(manager, classesToPullUp, containingClass.getImplementsListTypes());

    if (classesToPullUp.isEmpty()) {
      //check visibility
      new ExtractInterfaceHandler().invoke(project, new PsiElement[]{containingClass}, null);
    }
    else if (classesToPullUp.size() == 1) {
      pullUp(method, containingClass, classesToPullUp.iterator().next());
    }
    else if (editor != null) {
      NavigationUtil.getPsiElementPopup(classesToPullUp.toArray(new PsiClass[classesToPullUp.size()]), new PsiClassListCellRenderer(),
                                        "Choose super class",
                                        new PsiElementProcessor<PsiClass>() {
                                          @Override
                                          public boolean execute(@NotNull PsiClass aClass) {
                                            pullUp(method, containingClass, aClass);
                                            return false;
                                          }
                                        }, classesToPullUp.iterator().next()).showInBestPositionFor(editor);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:PullAsAbstractUpFix.java

示例2: getExtractInterfaceHandler

import com.intellij.refactoring.extractInterface.ExtractInterfaceHandler; //导入依赖的package包/类
@Override
public RefactoringActionHandler getExtractInterfaceHandler() {
  return new ExtractInterfaceHandler();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:JavaRefactoringSupportProvider.java

示例3: createExtractInterfaceHandler

import com.intellij.refactoring.extractInterface.ExtractInterfaceHandler; //导入依赖的package包/类
public RefactoringActionHandler createExtractInterfaceHandler() {
  return new ExtractInterfaceHandler();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:JavaRefactoringActionHandlerFactoryImpl.java

示例4: invoke

import com.intellij.refactoring.extractInterface.ExtractInterfaceHandler; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project,
                   @NotNull PsiFile file,
                   @Nullable("is null when called from inspection") Editor editor,
                   @NotNull PsiElement startElement,
                   @NotNull PsiElement endElement) {
  final PsiMethod method = (PsiMethod)startElement;
  if (!FileModificationService.getInstance().prepareFileForWrite(method.getContainingFile())) return;

  final PsiClass containingClass = method.getContainingClass();
  LOG.assertTrue(containingClass != null);

  PsiManager manager = containingClass.getManager();
  if (containingClass instanceof PsiAnonymousClass) {
    final PsiClassType baseClassType = ((PsiAnonymousClass)containingClass).getBaseClassType();
    final PsiClass baseClass = baseClassType.resolve();
    if (baseClass != null && manager.isInProject(baseClass)) {
      pullUp(method, containingClass, baseClass);
    }
  }
  else {
    final LinkedHashSet<PsiClass> classesToPullUp = new LinkedHashSet<PsiClass>();
    collectClassesToPullUp(manager, classesToPullUp, containingClass.getExtendsListTypes());
    collectClassesToPullUp(manager, classesToPullUp, containingClass.getImplementsListTypes());

    if (classesToPullUp.size() == 0) {
      //check visibility
      new ExtractInterfaceHandler().invoke(project, new PsiElement[]{containingClass}, null);
    }
    else if (classesToPullUp.size() == 1) {
      pullUp(method, containingClass, classesToPullUp.iterator().next());
    }
    else if (editor != null) {
      NavigationUtil.getPsiElementPopup(classesToPullUp.toArray(new PsiClass[classesToPullUp.size()]), new PsiClassListCellRenderer(),
                                        "Choose super class",
                                        new PsiElementProcessor<PsiClass>() {
                                          @Override
                                          public boolean execute(@NotNull PsiClass aClass) {
                                            pullUp(method, containingClass, aClass);
                                            return false;
                                          }
                                        }, classesToPullUp.iterator().next()).showInBestPositionFor(editor);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:46,代码来源:PullAsAbstractUpFix.java

示例5: getExtractInterfaceHandler

import com.intellij.refactoring.extractInterface.ExtractInterfaceHandler; //导入依赖的package包/类
@Override
public RefactoringActionHandler getExtractInterfaceHandler()
{
	return new ExtractInterfaceHandler();
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:6,代码来源:JavaRefactoringSupportProvider.java


注:本文中的com.intellij.refactoring.extractInterface.ExtractInterfaceHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。