Search in sources :

Example 1 with MockMoveMembersOptions

use of com.intellij.refactoring.move.moveMembers.MockMoveMembersOptions in project intellij-community by JetBrains.

the class MoveMembersTest method performAction.

private void performAction(String sourceClassName, String targetClassName, int[] memberIndices, final String visibility) throws Exception {
    PsiClass sourceClass = myJavaFacade.findClass(sourceClassName, ProjectScope.getProjectScope(myProject));
    assertNotNull("Class " + sourceClassName + " not found", sourceClass);
    PsiClass targetClass = myJavaFacade.findClass(targetClassName, ProjectScope.getProjectScope(myProject));
    assertNotNull("Class " + targetClassName + " not found", targetClass);
    PsiElement[] children = sourceClass.getChildren();
    ArrayList<PsiMember> members = new ArrayList<>();
    for (PsiElement child : children) {
        if (child instanceof PsiMember) {
            members.add(((PsiMember) child));
        }
    }
    LinkedHashSet<PsiMember> memberSet = new LinkedHashSet<>();
    for (int index : memberIndices) {
        PsiMember member = members.get(index);
        assertTrue(member.hasModifierProperty(PsiModifier.STATIC));
        memberSet.add(member);
    }
    MockMoveMembersOptions options = new MockMoveMembersOptions(targetClass.getQualifiedName(), memberSet);
    options.setMemberVisibility(visibility);
    new MoveMembersProcessor(myProject, null, options).run();
    FileDocumentManager.getInstance().saveAllDocuments();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PsiClass(com.intellij.psi.PsiClass) ArrayList(java.util.ArrayList) PsiElement(com.intellij.psi.PsiElement) MockMoveMembersOptions(com.intellij.refactoring.move.moveMembers.MockMoveMembersOptions) PsiMember(com.intellij.psi.PsiMember) MoveMembersProcessor(com.intellij.refactoring.move.moveMembers.MoveMembersProcessor)

Example 2 with MockMoveMembersOptions

use of com.intellij.refactoring.move.moveMembers.MockMoveMembersOptions in project intellij-community by JetBrains.

the class ConfigurationRefactoringsTest method moveMembers.

private void moveMembers(final PsiClass otherTest, final HashSet<PsiMember> members) {
    MockMoveMembersOptions options = new MockMoveMembersOptions(otherTest.getQualifiedName(), members);
    new MoveMembersProcessor(myProject, null, options).run();
}
Also used : MockMoveMembersOptions(com.intellij.refactoring.move.moveMembers.MockMoveMembersOptions) MoveMembersProcessor(com.intellij.refactoring.move.moveMembers.MoveMembersProcessor)

Aggregations

MockMoveMembersOptions (com.intellij.refactoring.move.moveMembers.MockMoveMembersOptions)2 MoveMembersProcessor (com.intellij.refactoring.move.moveMembers.MoveMembersProcessor)2 PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 PsiMember (com.intellij.psi.PsiMember)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1