Search in sources :

Example 1 with GrMemberInfoStorage

use of org.jetbrains.plugins.groovy.refactoring.classMembers.GrMemberInfoStorage in project intellij-community by JetBrains.

the class GrPullUpHandler method invokeImpl.

private void invokeImpl(Project project, DataContext dataContext, GrTypeDefinition aClass, PsiElement aMember) {
    final Editor editor = dataContext != null ? CommonDataKeys.EDITOR.getData(dataContext) : null;
    if (aClass == null) {
        String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("is.not.supported.in.the.current.context", REFACTORING_NAME));
        CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.MEMBERS_PULL_UP);
        return;
    }
    ArrayList<PsiClass> bases = RefactoringHierarchyUtil.createBasesList(aClass, false, true);
    if (bases.isEmpty()) {
        final GrTypeDefinition containingClass = DefaultGroovyMethods.asType(aClass.getContainingClass(), GrTypeDefinition.class);
        if (containingClass != null) {
            invokeImpl(project, dataContext, containingClass, aClass);
            return;
        }
        String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("class.does.not.have.base.classes.interfaces.in.current.project", aClass.getQualifiedName()));
        CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.MEMBERS_PULL_UP);
        return;
    }
    mySubclass = aClass;
    GrMemberInfoStorage memberInfoStorage = new GrMemberInfoStorage((GrTypeDefinition) mySubclass, new MemberInfoBase.Filter<GrMember>() {

        @Override
        public boolean includeMember(GrMember element) {
            return true;
        }
    });
    List<GrMemberInfo> members = memberInfoStorage.getClassMemberInfos(mySubclass);
    PsiManager manager = mySubclass.getManager();
    for (GrMemberInfo member : members) {
        if (manager.areElementsEquivalent(member.getMember(), aMember)) {
            member.setChecked(true);
            break;
        }
    }
    final GrPullUpDialog dialog = new GrPullUpDialog(project, aClass, bases, memberInfoStorage, this);
    dialog.show();
}
Also used : GrMember(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember) GrMemberInfo(org.jetbrains.plugins.groovy.refactoring.classMembers.GrMemberInfo) MemberInfoBase(com.intellij.refactoring.classMembers.MemberInfoBase) GrTypeDefinition(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition) GrMemberInfoStorage(org.jetbrains.plugins.groovy.refactoring.classMembers.GrMemberInfoStorage) Editor(com.intellij.openapi.editor.Editor)

Aggregations

Editor (com.intellij.openapi.editor.Editor)1 MemberInfoBase (com.intellij.refactoring.classMembers.MemberInfoBase)1 GrTypeDefinition (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition)1 GrMember (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember)1 GrMemberInfo (org.jetbrains.plugins.groovy.refactoring.classMembers.GrMemberInfo)1 GrMemberInfoStorage (org.jetbrains.plugins.groovy.refactoring.classMembers.GrMemberInfoStorage)1