コード例 #1
0
 public InlineSuperClassRefactoringProcessor(
     Project project, PsiClass superClass, final PsiClass... targetClasses) {
   super(project);
   mySuperClass = superClass;
   myTargetClasses = targetClasses;
   MemberInfoStorage memberInfoStorage =
       new MemberInfoStorage(
           mySuperClass,
           new MemberInfo.Filter<PsiMember>() {
             public boolean includeMember(PsiMember element) {
               return true;
             }
           });
   final List<MemberInfo> members = memberInfoStorage.getClassMemberInfos(mySuperClass);
   for (MemberInfo member : members) {
     member.setChecked(true);
   }
   myMemberInfos = members.toArray(new MemberInfo[members.size()]);
 }
コード例 #2
0
  public void invoke(
      @NotNull final Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
    if (elements.length != 1) return;

    PsiElement element = elements[0];
    PsiClass aClass;
    PsiElement aMember = null;

    if (element instanceof PsiClass) {
      aClass = (PsiClass) element;
    } else if (element instanceof PsiMethod) {
      aClass = ((PsiMethod) element).getContainingClass();
      aMember = element;
    } else if (element instanceof PsiField) {
      aClass = ((PsiField) element).getContainingClass();
      aMember = element;
    } else return;

    if (!CommonRefactoringUtil.checkReadOnlyStatus(project, aClass)) return;
    MemberInfoStorage memberInfoStorage =
        new MemberInfoStorage(
            aClass,
            new MemberInfo.Filter<PsiMember>() {
              public boolean includeMember(PsiMember element) {
                return !(element instanceof PsiEnumConstant);
              }
            });
    List<MemberInfo> members = memberInfoStorage.getClassMemberInfos(aClass);
    PsiManager manager = aClass.getManager();

    for (MemberInfoBase<PsiMember> member : members) {
      if (manager.areElementsEquivalent(member.getMember(), aMember)) {
        member.setChecked(true);
        break;
      }
    }
    PushDownDialog dialog =
        new PushDownDialog(project, members.toArray(new MemberInfo[members.size()]), aClass);
    dialog.show();
  }