use of org.jetbrains.plugins.groovy.refactoring.classMembers.GrMemberInfo in project intellij-community by JetBrains.
the class GrPullUpDialog method doAction.
@Override
protected void doAction() {
if (!myCallback.checkConflicts(this))
return;
JavaRefactoringSettings.getInstance().PULL_UP_MEMBERS_JAVADOC = myJavaDocPanel.getPolicy();
final PsiClass superClass = getSuperClass();
String name = superClass.getQualifiedName();
if (name != null) {
StatisticsManager.getInstance().incUseCount(new StatisticsInfo(PULL_UP_STATISTICS_KEY + myClass.getQualifiedName(), name));
}
List<GrMemberInfo> infos = getSelectedMemberInfos();
//GrPullUpProcessor processor = new GrPullUpProcessor(myClass, superClass, infos.toArray(new GrMemberInfo[infos.size()]), new DocCommentPolicy(getJavaDocPolicy()));
//invokeRefactoring(processor);
close(OK_EXIT_CODE);
}
use of org.jetbrains.plugins.groovy.refactoring.classMembers.GrMemberInfo in project intellij-community by JetBrains.
the class GrPullUpHandler method checkConflicts.
@Override
public boolean checkConflicts(final GrPullUpDialog dialog) {
/* todo */
List<GrMemberInfo> _infos = dialog.getSelectedMemberInfos();
final GrMemberInfo[] infos = _infos.toArray(new GrMemberInfo[_infos.size()]);
final PsiClass superClass = dialog.getSuperClass();
if (!checkWritable(superClass, infos))
return false;
final MultiMap<PsiElement, String> conflicts = new MultiMap<>();
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ApplicationManager.getApplication().runReadAction(() -> {
final PsiDirectory targetDirectory = superClass.getContainingFile().getContainingDirectory();
final PsiPackage targetPackage = targetDirectory != null ? JavaDirectoryService.getInstance().getPackage(targetDirectory) : null;
conflicts.putAllValues(GrPullUpConflictsUtil.checkConflicts(infos, mySubclass, superClass, targetPackage, targetDirectory, dialog.getContainmentVerifier()));
}), RefactoringBundle.message("detecting.possible.conflicts"), true, myProject)) {
return false;
}
if (!conflicts.isEmpty()) {
ConflictsDialog conflictsDialog = new ConflictsDialog(myProject, conflicts);
conflictsDialog.show();
final boolean ok = conflictsDialog.isOK();
if (!ok && conflictsDialog.isShowConflicts())
dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
return ok;
}
return true;
}
use of org.jetbrains.plugins.groovy.refactoring.classMembers.GrMemberInfo in project intellij-community by JetBrains.
the class GrPullUpDialog method addCustomElementsToCentralPanel.
@Override
protected void addCustomElementsToCentralPanel(JPanel panel) {
myJavaDocPanel = new DocCommentPanel(RefactoringBundle.message("javadoc.for.abstracts"));
myJavaDocPanel.setPolicy(JavaRefactoringSettings.getInstance().PULL_UP_MEMBERS_JAVADOC);
boolean hasJavadoc = false;
for (GrMemberInfo info : myMemberInfos) {
final PsiMember member = info.getMember();
if (myMemberInfoModel.isAbstractEnabled(info) && member instanceof PsiDocCommentOwner && ((PsiDocCommentOwner) member).getDocComment() != null) {
hasJavadoc = true;
break;
}
}
UIUtil.setEnabled(myJavaDocPanel, hasJavadoc, true);
panel.add(myJavaDocPanel, BorderLayout.EAST);
}
use of org.jetbrains.plugins.groovy.refactoring.classMembers.GrMemberInfo 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();
}
Aggregations