本文整理汇总了Java中com.intellij.refactoring.memberPushDown.PushDownProcessor类的典型用法代码示例。如果您正苦于以下问题:Java PushDownProcessor类的具体用法?Java PushDownProcessor怎么用?Java PushDownProcessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PushDownProcessor类属于com.intellij.refactoring.memberPushDown包,在下文中一共展示了PushDownProcessor类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTestImplements
import com.intellij.refactoring.memberPushDown.PushDownProcessor; //导入依赖的package包/类
private void doTestImplements(boolean toAbstract) {
configureByFile(BASE_PATH + getTestName(false) + ".java");
PsiClass currentClass = JavaPsiFacade.getInstance(getProject()).findClass("Test", GlobalSearchScope.projectScope(getProject()));
MemberInfoStorage memberInfoStorage = new MemberInfoStorage(currentClass, element -> true);
List<MemberInfo> members = memberInfoStorage.getClassMemberInfos(currentClass);
for (MemberInfo member : members) {
member.setChecked(true);
if (toAbstract) {
member.setToAbstract(toAbstract);
}
}
new PushDownProcessor(getProject(), members.toArray(new MemberInfo[members.size()]), currentClass,
new DocCommentPolicy(DocCommentPolicy.ASIS)) {
@Override
protected boolean showConflicts(@NotNull MultiMap<PsiElement, String> conflicts, UsageInfo[] usages) {
return true;
}
}.run();
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
}
示例2: doTestImplements
import com.intellij.refactoring.memberPushDown.PushDownProcessor; //导入依赖的package包/类
private void doTestImplements() {
configureByFile(BASE_PATH + getTestName(false) + ".java");
PsiClass currentClass = JavaPsiFacade.getInstance(getProject()).findClass("Test", GlobalSearchScope.projectScope(getProject()));
MemberInfoStorage memberInfoStorage = new MemberInfoStorage(currentClass, new MemberInfo.Filter<PsiMember>() {
@Override
public boolean includeMember(PsiMember element) {
return true;
}
});
List<MemberInfo> members = memberInfoStorage.getClassMemberInfos(currentClass);
for (MemberInfo member : members) {
member.setChecked(true);
}
new PushDownProcessor(getProject(), members.toArray(new MemberInfo[members.size()]), currentClass,
new DocCommentPolicy(DocCommentPolicy.ASIS)) {
@Override
protected boolean showConflicts(MultiMap<PsiElement, String> conflicts, UsageInfo[] usages) {
return true;
}
}.run();
checkResultByFile(BASE_PATH + getTestName(false) + "_after.java");
}
示例3: doTest
import com.intellij.refactoring.memberPushDown.PushDownProcessor; //导入依赖的package包/类
private void doTest(final boolean fail, final String sourceClassName, final String targetClassName) throws Exception {
try {
doTest((rootDir, rootAfter) -> {
final PsiClass srcClass = myJavaFacade.findClass(sourceClassName, GlobalSearchScope.allScope(myProject));
assertTrue("Source class not found", srcClass != null);
final PsiClass targetClass = myJavaFacade.findClass(targetClassName, 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;
new PushDownProcessor(getProject(), membersToMove, srcClass, new DocCommentPolicy(DocCommentPolicy.ASIS)).run();
//LocalFileSystem.getInstance().refresh(false);
//FileDocumentManager.getInstance().saveAllDocuments();
});
}
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
if (fail) {
return;
}
else {
throw e;
}
}
if (fail) {
fail("Conflict was not detected");
}
}
示例4: testUsagesInXml
import com.intellij.refactoring.memberPushDown.PushDownProcessor; //导入依赖的package包/类
public void testUsagesInXml() throws Exception {
try {
doTest((rootDir, rootAfter) -> {
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 PsiField[] fields = srcClass.getFields();
assertTrue("No methods found", fields.length > 0);
final MemberInfo[] membersToMove = new MemberInfo[1];
final MemberInfo memberInfo = new MemberInfo(fields[0]);
memberInfo.setChecked(true);
membersToMove[0] = memberInfo;
new PushDownProcessor(getProject(), membersToMove, srcClass, new DocCommentPolicy(DocCommentPolicy.ASIS)).run();
//LocalFileSystem.getInstance().refresh(false);
//FileDocumentManager.getInstance().saveAllDocuments();
});
}
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
assertEquals(e.getMessage(), "Class <b><code>b.B</code></b> is package local and will not be accessible from file <b><code>A.form</code></b>.");
return;
}
fail("Conflict was not detected");
}
示例5: doTest
import com.intellij.refactoring.memberPushDown.PushDownProcessor; //导入依赖的package包/类
private void doTest(final boolean fail, final String sourceClassName, final String targetClassName) throws Exception {
try {
doTest(new PerformAction() {
@Override
public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) throws Exception {
final PsiClass srcClass = myJavaFacade.findClass(sourceClassName, GlobalSearchScope.allScope(myProject));
assertTrue("Source class not found", srcClass != null);
final PsiClass targetClass = myJavaFacade.findClass(targetClassName, 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;
new PushDownProcessor(getProject(), membersToMove, srcClass, new DocCommentPolicy(DocCommentPolicy.ASIS)).run();
//LocalFileSystem.getInstance().refresh(false);
//FileDocumentManager.getInstance().saveAllDocuments();
}
});
}
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
if (fail) {
return;
}
else {
throw e;
}
}
if (fail) {
fail("Conflict was not detected");
}
}
示例6: testUsagesInXml
import com.intellij.refactoring.memberPushDown.PushDownProcessor; //导入依赖的package包/类
public void testUsagesInXml() throws Exception {
try {
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 PsiField[] fields = srcClass.getFields();
assertTrue("No methods found", fields.length > 0);
final MemberInfo[] membersToMove = new MemberInfo[1];
final MemberInfo memberInfo = new MemberInfo(fields[0]);
memberInfo.setChecked(true);
membersToMove[0] = memberInfo;
new PushDownProcessor(getProject(), membersToMove, srcClass, new DocCommentPolicy(DocCommentPolicy.ASIS)).run();
//LocalFileSystem.getInstance().refresh(false);
//FileDocumentManager.getInstance().saveAllDocuments();
}
});
}
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
assertEquals(e.getMessage(), "Class <b><code>b.B</code></b> is package local and will not be accessible from file <b><code>A.form</code></b>.");
return;
}
fail("Conflict was not detected");
}