mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (warnings, formatting)
This commit is contained in:
+3
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,10 +47,8 @@ public class ExtractInterfaceHandler implements RefactoringActionHandler, Elemen
|
||||
|
||||
public static final String REFACTORING_NAME = RefactoringBundle.message("extract.interface.title");
|
||||
|
||||
|
||||
private Project myProject;
|
||||
private PsiClass myClass;
|
||||
|
||||
private String myInterfaceName;
|
||||
private MemberInfo[] mySelectedMembers;
|
||||
private PsiDirectory myTargetDir;
|
||||
@@ -80,13 +78,13 @@ public class ExtractInterfaceHandler implements RefactoringActionHandler, Elemen
|
||||
myProject = project;
|
||||
myClass = (PsiClass)elements[0];
|
||||
|
||||
|
||||
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, myClass)) return;
|
||||
|
||||
final ExtractInterfaceDialog dialog = new ExtractInterfaceDialog(myProject, myClass);
|
||||
if (!dialog.showAndGet() || !dialog.isExtractSuperclass()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final MultiMap<PsiElement, String> conflicts = new MultiMap<>();
|
||||
ExtractSuperClassUtil.checkSuperAccessible(dialog.getTargetDirectory(), conflicts, myClass);
|
||||
if (!ExtractSuperClassUtil.showConflicts(dialog, conflicts, myProject)) return;
|
||||
@@ -104,7 +102,6 @@ public class ExtractInterfaceHandler implements RefactoringActionHandler, Elemen
|
||||
}), REFACTORING_NAME, null);
|
||||
}
|
||||
|
||||
|
||||
private void doRefactoring() throws IncorrectOperationException {
|
||||
LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());
|
||||
final PsiClass anInterface;
|
||||
@@ -149,4 +146,4 @@ public class ExtractInterfaceHandler implements RefactoringActionHandler, Elemen
|
||||
public boolean isEnabledOnElements(PsiElement[] elements) {
|
||||
return elements.length == 1 && elements[0] instanceof PsiClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-22
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.refactoring.extractSuperclass;
|
||||
|
||||
import com.intellij.history.LocalHistory;
|
||||
@@ -54,7 +53,6 @@ public class ExtractSuperclassHandler implements RefactoringActionHandler, Extra
|
||||
private PsiClass mySubclass;
|
||||
private Project myProject;
|
||||
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
|
||||
@@ -97,7 +95,6 @@ public class ExtractSuperclassHandler implements RefactoringActionHandler, Extra
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
List<MemberInfo> memberInfos = MemberInfo.extractClassMembers(mySubclass, new MemberInfo.Filter<PsiMember>() {
|
||||
@Override
|
||||
public boolean includeMember(PsiMember element) {
|
||||
@@ -110,8 +107,7 @@ public class ExtractSuperclassHandler implements RefactoringActionHandler, Extra
|
||||
memberInfo.getOverrides() != null));
|
||||
}
|
||||
|
||||
final ExtractSuperclassDialog dialog =
|
||||
new ExtractSuperclassDialog(project, mySubclass, memberInfos, this);
|
||||
final ExtractSuperclassDialog dialog = new ExtractSuperclassDialog(project, mySubclass, memberInfos, this);
|
||||
if (!dialog.showAndGet() || !dialog.isExtractSuperclass()) {
|
||||
return;
|
||||
}
|
||||
@@ -126,26 +122,22 @@ public class ExtractSuperclassHandler implements RefactoringActionHandler, Extra
|
||||
public boolean checkConflicts(final ExtractSuperclassDialog dialog) {
|
||||
final MemberInfo[] infos = ArrayUtil.toObjectArray(dialog.getSelectedMemberInfos(), MemberInfo.class);
|
||||
final PsiDirectory targetDirectory = dialog.getTargetDirectory();
|
||||
final PsiPackage targetPackage;
|
||||
if (targetDirectory != null) {
|
||||
targetPackage = JavaDirectoryService.getInstance().getPackage(targetDirectory);
|
||||
}
|
||||
else {
|
||||
targetPackage = null;
|
||||
}
|
||||
final PsiPackage targetPackage = targetDirectory != null ? JavaDirectoryService.getInstance().getPackage(targetDirectory) : null;
|
||||
final MultiMap<PsiElement,String> conflicts = new MultiMap<>();
|
||||
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ApplicationManager.getApplication().runReadAction(() -> {
|
||||
final PsiClass superClass =
|
||||
mySubclass.getExtendsListTypes().length > 0 || mySubclass instanceof PsiAnonymousClass ? mySubclass.getSuperClass() : null;
|
||||
conflicts.putAllValues(PullUpConflictsUtil.checkConflicts(infos, mySubclass, superClass, targetPackage, targetDirectory,
|
||||
dialog.getContainmentVerifier(), false));
|
||||
if (targetPackage != null) {
|
||||
conflicts.putAllValues(PullUpConflictsUtil.checkConflicts(
|
||||
infos, mySubclass, superClass, targetPackage, targetDirectory, dialog.getContainmentVerifier(), false));
|
||||
}
|
||||
}), RefactoringBundle.message("detecting.possible.conflicts"), true, myProject)) return false;
|
||||
ExtractSuperClassUtil.checkSuperAccessible(targetDirectory, conflicts, mySubclass);
|
||||
return ExtractSuperClassUtil.showConflicts(dialog, conflicts, myProject);
|
||||
}
|
||||
|
||||
// invoked inside Command and Atomic action
|
||||
private void doRefactoring(final Project project, final PsiClass subclass, final ExtractSuperclassDialog dialog) {
|
||||
private static void doRefactoring(final Project project, final PsiClass subclass, final ExtractSuperclassDialog dialog) {
|
||||
final String superclassName = dialog.getExtractedSuperName();
|
||||
final PsiDirectory targetDirectory = dialog.getTargetDirectory();
|
||||
final MemberInfo[] selectedMemberInfos = ArrayUtil.toObjectArray(dialog.getSelectedMemberInfos(), MemberInfo.class);
|
||||
@@ -153,10 +145,8 @@ public class ExtractSuperclassHandler implements RefactoringActionHandler, Extra
|
||||
LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName(subclass, superclassName));
|
||||
try {
|
||||
final PsiClass superclass;
|
||||
|
||||
try {
|
||||
superclass =
|
||||
ExtractSuperClassUtil.extractSuperClass(project, targetDirectory, superclassName, subclass, selectedMemberInfos, javaDocPolicy);
|
||||
superclass = ExtractSuperClassUtil.extractSuperClass(project, targetDirectory, superclassName, subclass, selectedMemberInfos, javaDocPolicy);
|
||||
}
|
||||
finally {
|
||||
a.finish();
|
||||
@@ -168,10 +158,9 @@ public class ExtractSuperclassHandler implements RefactoringActionHandler, Extra
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getCommandName(final PsiClass subclass, String newName) {
|
||||
private static String getCommandName(final PsiClass subclass, String newName) {
|
||||
return RefactoringBundle.message("extract.superclass.command.name", newName, DescriptiveNameUtil.getDescriptiveName(subclass));
|
||||
}
|
||||
|
||||
@@ -180,4 +169,4 @@ public class ExtractSuperclassHandler implements RefactoringActionHandler, Extra
|
||||
return elements.length == 1 && elements[0] instanceof PsiClass && !((PsiClass) elements[0]).isInterface()
|
||||
&&!((PsiClass)elements[0]).isEnum();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,6 @@ import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ExtractClassHandler implements ElementsHandler {
|
||||
|
||||
protected static String getHelpID() {
|
||||
return HelpID.ExtractClass;
|
||||
}
|
||||
@@ -125,4 +124,4 @@ public class ExtractClassHandler implements ElementsHandler {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,6 @@ package com.intellij.refactoring.inheritanceToDelegation;
|
||||
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.ScrollType;
|
||||
@@ -48,6 +47,7 @@ import java.util.*;
|
||||
|
||||
public class InheritanceToDelegationHandler implements RefactoringActionHandler {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.inheritanceToDelegation.InheritanceToDelegationHandler");
|
||||
|
||||
public static final String REFACTORING_NAME = RefactoringBundle.message("replace.inheritance.with.delegation.title");
|
||||
|
||||
private static final MemberInfo.Filter<PsiMember> MEMBER_INFO_FILTER = new MemberInfo.Filter<PsiMember>() {
|
||||
@@ -64,7 +64,7 @@ public class InheritanceToDelegationHandler implements RefactoringActionHandler
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
@@ -84,6 +84,7 @@ public class InheritanceToDelegationHandler implements RefactoringActionHandler
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
|
||||
if (elements.length != 1) return;
|
||||
|
||||
@@ -131,12 +132,9 @@ public class InheritanceToDelegationHandler implements RefactoringActionHandler
|
||||
|
||||
final MemberInfoStorage memberInfoStorage = new MemberInfoStorage(baseClass, MEMBER_INFO_FILTER);
|
||||
|
||||
ArrayList<MemberInfo> memberInfoList = new ArrayList<>(memberInfoStorage.getClassMemberInfos(deepestBase));
|
||||
List<MemberInfo> memberInfos = memberInfoStorage.getIntermediateMemberInfosList(deepestBase);
|
||||
for (final MemberInfo memberInfo : memberInfos) {
|
||||
memberInfoList.add(memberInfo);
|
||||
}
|
||||
|
||||
List<MemberInfo> memberInfoList = new ArrayList<>();
|
||||
memberInfoList.addAll(memberInfoStorage.getClassMemberInfos(deepestBase));
|
||||
memberInfoList.addAll(memberInfoStorage.getIntermediateMemberInfosList(deepestBase));
|
||||
return memberInfoList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,6 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class JavaPullUpHandler implements RefactoringActionHandler, PullUpDialog.Callback, ElementsHandler, ContextAwareActionHandler {
|
||||
@@ -110,8 +109,7 @@ public class JavaPullUpHandler implements RefactoringActionHandler, PullUpDialog
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<PsiClass> bases = RefactoringHierarchyUtil.createBasesList(aClass, false, true);
|
||||
|
||||
List<PsiClass> bases = RefactoringHierarchyUtil.createBasesList(aClass, false, true);
|
||||
if (bases.isEmpty()) {
|
||||
final PsiClass containingClass = aClass.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
|
||||
+12
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,13 +39,13 @@ import java.util.List;
|
||||
* Date: 06.06.2002
|
||||
*/
|
||||
public class TurnRefsToSuperDialog extends RefactoringDialog {
|
||||
@NotNull private final PsiClass mySubClass;
|
||||
private final List mySuperClasses;
|
||||
private final PsiClass mySubClass;
|
||||
private final List<PsiClass> mySuperClasses;
|
||||
|
||||
private JList mySuperClassesList;
|
||||
private JList<PsiClass> mySuperClassesList;
|
||||
private final JCheckBox myCbReplaceInstanceOf = new JCheckBox();
|
||||
|
||||
TurnRefsToSuperDialog(Project project, @NotNull PsiClass subClass, List superClasses) {
|
||||
TurnRefsToSuperDialog(Project project, @NotNull PsiClass subClass, List<PsiClass> superClasses) {
|
||||
super(project, true);
|
||||
|
||||
mySubClass = subClass;
|
||||
@@ -57,12 +57,7 @@ public class TurnRefsToSuperDialog extends RefactoringDialog {
|
||||
|
||||
@Nullable
|
||||
public PsiClass getSuperClass() {
|
||||
if(mySuperClassesList != null) {
|
||||
return (PsiClass) mySuperClassesList.getSelectedValue();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
return mySuperClassesList != null ? mySuperClassesList.getSelectedValue() : null;
|
||||
}
|
||||
|
||||
public boolean isUseInInstanceOf() {
|
||||
@@ -77,7 +72,7 @@ public class TurnRefsToSuperDialog extends RefactoringDialog {
|
||||
return mySuperClassesList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));
|
||||
@@ -85,7 +80,7 @@ public class TurnRefsToSuperDialog extends RefactoringDialog {
|
||||
final JLabel classListLabel = new JLabel();
|
||||
panel.add(classListLabel, BorderLayout.NORTH);
|
||||
|
||||
mySuperClassesList = new JBList(mySuperClasses.toArray());
|
||||
mySuperClassesList = new JBList<>(mySuperClasses.toArray());
|
||||
mySuperClassesList.setCellRenderer(new ClassCellRenderer(mySuperClassesList.getCellRenderer()));
|
||||
mySuperClassesList.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
classListLabel.setText(RefactoringBundle.message("turnRefsToSuper.change.usages.to", mySubClass.getQualifiedName()));
|
||||
@@ -106,10 +101,12 @@ public class TurnRefsToSuperDialog extends RefactoringDialog {
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDimensionServiceKey() {
|
||||
return "#com.intellij.refactoring.turnRefsToSuper.TurnRefsToSuperDialog";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doAction() {
|
||||
JavaRefactoringSettings.getInstance().TURN_REFS_TO_SUPER_PREVIEW_USAGES = isPreviewUsages();
|
||||
final PsiClass superClass = getSuperClass();
|
||||
@@ -118,7 +115,8 @@ public class TurnRefsToSuperDialog extends RefactoringDialog {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createNorthPanel() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.refactoring.turnRefsToSuper;
|
||||
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
@@ -32,12 +31,12 @@ import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.refactoring.util.RefactoringHierarchyUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TurnRefsToSuperHandler implements RefactoringActionHandler {
|
||||
public static final String REFACTORING_NAME = RefactoringBundle.message("use.interface.where.possible.title");
|
||||
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
|
||||
@@ -56,13 +55,12 @@ public class TurnRefsToSuperHandler implements RefactoringActionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
|
||||
if (elements.length != 1) return;
|
||||
|
||||
PsiClass subClass = (PsiClass) elements[0];
|
||||
|
||||
ArrayList basesList = RefactoringHierarchyUtil.createBasesList(subClass, true, true);
|
||||
|
||||
PsiClass subClass = (PsiClass)elements[0];
|
||||
List<PsiClass> basesList = RefactoringHierarchyUtil.createBasesList(subClass, true, true);
|
||||
if (basesList.isEmpty()) {
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("interface.does.not.have.base.interfaces", subClass.getQualifiedName()));
|
||||
Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
|
||||
@@ -72,5 +70,4 @@ public class TurnRefsToSuperHandler implements RefactoringActionHandler {
|
||||
|
||||
new TurnRefsToSuperDialog(project, subClass, basesList).show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+13
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.refactoring.actions;
|
||||
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
@@ -60,7 +59,10 @@ public abstract class BaseRefactoringAction extends AnAction {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
|
||||
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element,
|
||||
@NotNull Editor editor,
|
||||
@NotNull PsiFile file,
|
||||
@NotNull DataContext context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -83,14 +85,15 @@ public abstract class BaseRefactoringAction extends AnAction {
|
||||
protected abstract RefactoringActionHandler getHandler(@NotNull DataContext dataContext);
|
||||
|
||||
@Override
|
||||
public final void actionPerformed(AnActionEvent e) {
|
||||
public final void actionPerformed(@NotNull AnActionEvent e) {
|
||||
DataContext dataContext = e.getDataContext();
|
||||
final Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
Project project = e.getProject();
|
||||
if (project == null) return;
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
final Editor editor = e.getData(CommonDataKeys.EDITOR);
|
||||
final PsiElement[] elements = getPsiElementArray(dataContext);
|
||||
int eventCount = IdeEventQueue.getInstance().getEventCount();
|
||||
|
||||
RefactoringActionHandler handler;
|
||||
try {
|
||||
handler = getHandler(dataContext);
|
||||
@@ -99,8 +102,8 @@ public abstract class BaseRefactoringAction extends AnAction {
|
||||
return;
|
||||
}
|
||||
if (handler == null) {
|
||||
CommonRefactoringUtil.showErrorHint(project, editor, RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message(
|
||||
"error.wrong.caret.position.symbol.to.refactor")), RefactoringBundle.getCannotRefactorMessage(null), null);
|
||||
String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("error.wrong.caret.position.symbol.to.refactor"));
|
||||
CommonRefactoringUtil.showErrorHint(project, editor, message, RefactoringBundle.getCannotRefactorMessage(null), null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,7 +123,6 @@ public abstract class BaseRefactoringAction extends AnAction {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IdeEventQueue.getInstance().setEventCount(eventCount);
|
||||
if (editor != null) {
|
||||
final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
|
||||
@@ -187,7 +189,7 @@ public abstract class BaseRefactoringAction extends AnAction {
|
||||
|
||||
boolean isVisible = ContainerUtil.find(languages, myLanguageCondition) != null;
|
||||
if (isVisible) {
|
||||
boolean isEnabled = isAvailableOnElementInEditorAndFile(element, editor, file, dataContext);
|
||||
boolean isEnabled = file != null && isAvailableOnElementInEditorAndFile(element, editor, file, dataContext);
|
||||
if (!isEnabled) {
|
||||
disableAction(e);
|
||||
}
|
||||
@@ -231,7 +233,7 @@ public abstract class BaseRefactoringAction extends AnAction {
|
||||
return caret;
|
||||
}
|
||||
|
||||
private static void disableAction(final AnActionEvent e) {
|
||||
private static void disableAction(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -264,5 +266,4 @@ public abstract class BaseRefactoringAction extends AnAction {
|
||||
}
|
||||
return filtered == null ? psiElements : PsiUtilCore.toPsiElementArray(filtered);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,16 +15,11 @@
|
||||
*/
|
||||
package com.intellij.refactoring.actions;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageRefactoringSupport;
|
||||
import com.intellij.lang.refactoring.RefactoringSupportProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.lang.ElementsHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ExtractClassAction extends BasePlatformRefactoringAction {
|
||||
|
||||
@Override
|
||||
protected RefactoringActionHandler getRefactoringHandler(@NotNull RefactoringSupportProvider provider) {
|
||||
return provider.getExtractClassHandler();
|
||||
@@ -34,4 +29,4 @@ public class ExtractClassAction extends BasePlatformRefactoringAction {
|
||||
public boolean isAvailableInEditorOnly(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.refactoring.actions;
|
||||
|
||||
import com.intellij.lang.refactoring.RefactoringSupportProvider;
|
||||
@@ -22,7 +21,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ExtractInterfaceAction extends ExtractSuperActionBase {
|
||||
|
||||
public ExtractInterfaceAction() {
|
||||
setInjectedContext(true);
|
||||
}
|
||||
@@ -32,5 +30,4 @@ public class ExtractInterfaceAction extends ExtractSuperActionBase {
|
||||
protected RefactoringActionHandler getRefactoringHandler(@NotNull RefactoringSupportProvider supportProvider) {
|
||||
return supportProvider.getExtractInterfaceHandler();
|
||||
}
|
||||
|
||||
}
|
||||
+1
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.refactoring.actions;
|
||||
|
||||
import com.intellij.lang.refactoring.RefactoringSupportProvider;
|
||||
@@ -21,7 +20,6 @@ import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ExtractSuperclassAction extends ExtractSuperActionBase {
|
||||
|
||||
public ExtractSuperclassAction() {
|
||||
setInjectedContext(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user