本文整理汇总了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);
}
}
}
示例2: getExtractInterfaceHandler
import com.intellij.refactoring.extractInterface.ExtractInterfaceHandler; //导入依赖的package包/类
@Override
public RefactoringActionHandler getExtractInterfaceHandler() {
return new ExtractInterfaceHandler();
}
示例3: createExtractInterfaceHandler
import com.intellij.refactoring.extractInterface.ExtractInterfaceHandler; //导入依赖的package包/类
public RefactoringActionHandler createExtractInterfaceHandler() {
return new ExtractInterfaceHandler();
}
示例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);
}
}
}
示例5: getExtractInterfaceHandler
import com.intellij.refactoring.extractInterface.ExtractInterfaceHandler; //导入依赖的package包/类
@Override
public RefactoringActionHandler getExtractInterfaceHandler()
{
return new ExtractInterfaceHandler();
}