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


Java PullUpHelper类代码示例

本文整理汇总了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());
}
 
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:19,代码来源:PullUpProcessor.java

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

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

示例5: createPullUpHelper

import com.intellij.refactoring.memberPullUp.PullUpHelper; //导入依赖的package包/类
@Override
public PullUpHelper createPullUpHelper(PullUpData data) {
  return new GrPullUpHelper(data);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:GrPullUpHelperFactory.java

示例6: checkedInterfacesContain

import com.intellij.refactoring.memberPullUp.PullUpHelper; //导入依赖的package包/类
public boolean checkedInterfacesContain(PsiMethod psiMethod) {
  return PullUpHelper.checkedInterfacesContain(myMemberInfos, psiMethod);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:ExtractSuperclassDialog.java

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

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


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