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


Java PushDownProcessor类代码示例

本文整理汇总了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");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PushDownTest.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");
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:PushDownTest.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");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:PushDownMultifileTest.java

示例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");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PushDownMultifileTest.java

示例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");
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:39,代码来源:PushDownMultifileTest.java

示例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");
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:PushDownMultifileTest.java


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