本文整理汇总了Java中com.intellij.refactoring.memberPullUp.PullUpHelper类的典型用法代码示例。如果您正苦于以下问题:Java PullUpHelper类的具体用法?Java PullUpHelper怎么用?Java PullUpHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PullUpHelper类属于com.intellij.refactoring.memberPullUp包,在下文中一共展示了PullUpHelper类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performRefactoring
import com.intellij.refactoring.memberPullUp.PullUpHelper; //导入依赖的package包/类
@Override
protected void performRefactoring(UsageInfo[] usages) {
moveMembersToBase();
moveFieldInitializations();
for (UsageInfo usage : usages) {
PsiElement element = usage.getElement();
if (element == null) continue;
PullUpHelper<MemberInfo> processor = getProcessor(element);
processor.updateUsage(element);
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
processMethodsDuplicates();
}
}, ModalityState.NON_MODAL, myProject.getDisposed());
}
示例2: pullUp
import com.intellij.refactoring.memberPullUp.PullUpHelper; //导入依赖的package包/类
private static void pullUp(PsiMethod method, PsiClass containingClass, PsiClass baseClass) {
if (!FileModificationService.getInstance().prepareFileForWrite(baseClass.getContainingFile())) return;
final MemberInfo memberInfo = new MemberInfo(method);
memberInfo.setChecked(true);
memberInfo.setToAbstract(true);
new PullUpHelper(containingClass, baseClass, new MemberInfo[]{memberInfo}, new DocCommentPolicy(DocCommentPolicy.ASIS)).run();
}
示例3: doTest
import com.intellij.refactoring.memberPullUp.PullUpHelper; //导入依赖的package包/类
private void doTest(final boolean checkMembersMovedCount, RefactoringTestUtil.MemberDescriptor... membersToFind) {
configureByFile(BASE_PATH + getTestName(false) + ".java");
PsiElement elementAt = getFile().findElementAt(getEditor().getCaretModel().getOffset());
final PsiClass sourceClass = PsiTreeUtil.getParentOfType(elementAt, PsiClass.class);
assertNotNull(sourceClass);
PsiClass targetClass = sourceClass.getSuperClass();
assertNotNull(targetClass);
if (!targetClass.isWritable()) {
final PsiClass[] interfaces = sourceClass.getInterfaces();
assertEquals(1, interfaces.length);
assertTrue(interfaces[0].isWritable());
targetClass = interfaces[0];
}
MemberInfo[] infos = RefactoringTestUtil.findMembers(sourceClass, membersToFind);
final int[] countMoved = {0};
final MoveMemberListener listener = new MoveMemberListener() {
@Override
public void memberMoved(PsiClass aClass, PsiMember member) {
assertEquals(sourceClass, aClass);
countMoved[0]++;
}
};
JavaRefactoringListenerManager.getInstance(getProject()).addMoveMembersListener(listener);
final PullUpHelper helper = new PullUpHelper(sourceClass, targetClass, infos, new DocCommentPolicy(DocCommentPolicy.ASIS));
helper.run();
UIUtil.dispatchAllInvocationEvents();
JavaRefactoringListenerManager.getInstance(getProject()).removeMoveMembersListener(listener);
if (checkMembersMovedCount) {
assertEquals(countMoved[0], membersToFind.length);
}
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
}
示例4: getProcessor
import com.intellij.refactoring.memberPullUp.PullUpHelper; //导入依赖的package包/类
private PullUpHelper<MemberInfo> getProcessor(Language language) {
PullUpHelper<MemberInfo> helper = myProcessors.get(language);
if (helper == null) {
//helper = PullUpHelper.INSTANCE.forLanguage(language).createPullUpHelper(this);
helper = new HaxePullUpHelper(this);
myProcessors.put(language, helper);
}
return helper;
}
示例5: createPullUpHelper
import com.intellij.refactoring.memberPullUp.PullUpHelper; //导入依赖的package包/类
@Override
public PullUpHelper createPullUpHelper(PullUpData data) {
return new GrPullUpHelper(data);
}
示例6: checkedInterfacesContain
import com.intellij.refactoring.memberPullUp.PullUpHelper; //导入依赖的package包/类
public boolean checkedInterfacesContain(PsiMethod psiMethod) {
return PullUpHelper.checkedInterfacesContain(myMemberInfos, psiMethod);
}
示例7: doTest
import com.intellij.refactoring.memberPullUp.PullUpHelper; //导入依赖的package包/类
private void doTest(final String... conflicts) throws Exception {
final MultiMap<PsiElement, String> conflictsMap = new MultiMap<PsiElement, String>();
doTest(new PerformAction() {
@Override
public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) throws Exception {
final PsiClass srcClass = myJavaFacade.findClass("a.A", GlobalSearchScope.allScope(myProject));
assertTrue("Source class not found", srcClass != null);
final PsiClass targetClass = myJavaFacade.findClass("b.B", GlobalSearchScope.allScope(myProject));
assertTrue("Target class not found", targetClass != null);
final PsiMethod[] methods = srcClass.getMethods();
assertTrue("No methods found", methods.length > 0);
final MemberInfo[] membersToMove = new MemberInfo[1];
final MemberInfo memberInfo = new MemberInfo(methods[0]);
memberInfo.setChecked(true);
membersToMove[0] = memberInfo;
final PsiDirectory targetDirectory = targetClass.getContainingFile().getContainingDirectory();
final PsiPackage targetPackage = targetDirectory != null ? JavaDirectoryService.getInstance().getPackage(targetDirectory) : null;
conflictsMap.putAllValues(
PullUpConflictsUtil.checkConflicts(membersToMove, srcClass, targetClass, targetPackage, targetDirectory, new InterfaceContainmentVerifier() {
@Override
public boolean checkedInterfacesContain(PsiMethod psiMethod) {
return PullUpHelper.checkedInterfacesContain(Arrays.asList(membersToMove), psiMethod);
}
}));
new PullUpHelper(srcClass, targetClass, membersToMove, new DocCommentPolicy(DocCommentPolicy.ASIS)).run();
}
});
if (conflicts.length != 0 && conflictsMap.isEmpty()) {
fail("Conflict was not detected");
}
final HashSet<String> values = new HashSet<String>(conflictsMap.values());
final HashSet<String> expected = new HashSet<String>(Arrays.asList(conflicts));
assertEquals(expected.size(), values.size());
for (String value : values) {
if (!expected.contains(value)) {
fail("Conflict: " + value + " is unexpectedly reported");
}
}
}
示例8: doTest
import com.intellij.refactoring.memberPullUp.PullUpHelper; //导入依赖的package包/类
private void doTest(@NonNls final String className,
@NonNls final String newClassName,
String[] conflicts,
String targetPackageName,
RefactoringTestUtil.MemberDescriptor... membersToFind) throws Exception {
String rootBefore = getRoot() + "/before";
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk14());
final VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
PsiClass psiClass = myJavaFacade.findClass(className, ProjectScope.getAllScope(myProject));
assertNotNull(psiClass);
final MemberInfo[] members = RefactoringTestUtil.findMembers(psiClass, membersToFind);
PsiDirectory targetDirectory;
if (targetPackageName == null) {
targetDirectory = psiClass.getContainingFile().getContainingDirectory();
} else {
final PsiPackage aPackage = myJavaFacade.findPackage(targetPackageName);
assertNotNull(aPackage);
targetDirectory = aPackage.getDirectories()[0];
}
ExtractSuperClassProcessor processor = new ExtractSuperClassProcessor(myProject,
targetDirectory,
newClassName,
psiClass, members,
false,
new DocCommentPolicy<PsiComment>(DocCommentPolicy.ASIS));
final PsiPackage targetPackage;
if (targetDirectory != null) {
targetPackage = JavaDirectoryService.getInstance().getPackage(targetDirectory);
}
else {
targetPackage = null;
}
final PsiClass superClass = psiClass.getExtendsListTypes().length > 0 ? psiClass.getSuperClass() : null;
final MultiMap<PsiElement, String> conflictsMap =
PullUpConflictsUtil.checkConflicts(members, psiClass, superClass, targetPackage, targetDirectory, new InterfaceContainmentVerifier() {
@Override
public boolean checkedInterfacesContain(PsiMethod psiMethod) {
return PullUpHelper.checkedInterfacesContain(Arrays.asList(members), psiMethod);
}
}, false);
if (conflicts != null) {
if (conflictsMap.isEmpty()) {
fail("Conflicts were not detected");
}
final HashSet<String> expectedConflicts = new HashSet<String>(Arrays.asList(conflicts));
final HashSet<String> actualConflicts = new HashSet<String>(conflictsMap.values());
assertEquals(expectedConflicts.size(), actualConflicts.size());
for (String actualConflict : actualConflicts) {
if (!expectedConflicts.contains(actualConflict)) {
fail("Unexpected conflict: " + actualConflict);
}
}
} else if (!conflictsMap.isEmpty()) {
fail("Unexpected conflicts!!!");
}
processor.run();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
FileDocumentManager.getInstance().saveAllDocuments();
String rootAfter = getRoot() + "/after";
VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
IdeaTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}