Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yann Cébron
2013-01-28 10:26:50 +01:00
90 changed files with 237 additions and 129 deletions
@@ -18,11 +18,13 @@ package com.intellij.codeInsight.folding.impl.actions;
import com.intellij.codeInsight.CodeInsightActionHandler;
import com.intellij.codeInsight.actions.BaseCodeInsightAction;
import com.intellij.codeInsight.folding.impl.CollapseBlockHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
*/
public class CollapseBlockAction extends BaseCodeInsightAction {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new CollapseBlockHandler ();
@@ -22,15 +22,17 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiJavaFile;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.NotNull;
public class GenerateSuperMethodCallAction extends BaseCodeInsightAction {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new GenerateSuperMethodCallHandler();
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
if (!(file instanceof PsiJavaFile)) {
return false;
}
@@ -24,17 +24,18 @@ import com.intellij.psi.PsiNewExpression;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.anonymousToInner.AnonymousToInnerHandler;
import org.jetbrains.annotations.NotNull;
public class AnonymousToInnerAction extends BaseRefactoringAction {
public boolean isAvailableInEditorOnly() {
return true;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return false;
}
protected boolean isAvailableOnElementInEditorAndFile(final PsiElement element, final Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull final PsiElement element, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
final PsiElement targetElement = file.findElementAt(editor.getCaretModel().getOffset());
if (PsiTreeUtil.getParentOfType(targetElement, PsiAnonymousClass.class) != null) {
return true;
@@ -46,7 +47,7 @@ public class AnonymousToInnerAction extends BaseRefactoringAction {
return newExpression != null && newExpression.getAnonymousClass() != null;
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new AnonymousToInnerHandler();
}
}
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.psi.*;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.convertToInstanceMethod.ConvertToInstanceMethodHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author dsl
@@ -29,16 +30,16 @@ public class ConvertToInstanceMethodAction extends BaseRefactoringAction {
return false;
}
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return elements.length == 1 && elements[0] instanceof PsiMethod;
}
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, final Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
if (element instanceof PsiIdentifier) element = element.getParent();
return element instanceof PsiMethod && ((PsiMethod) element).hasModifierProperty(PsiModifier.STATIC);
}
protected RefactoringActionHandler getHandler(DataContext dataContext) {
protected RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new ConvertToInstanceMethodHandler();
}
}
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.encapsulateFields.EncapsulateFieldsHandler;
import org.jetbrains.annotations.NotNull;
public class EncapsulateFieldsAction extends BaseRefactoringAction {
public boolean isAvailableInEditorOnly() {
@@ -32,7 +33,7 @@ public class EncapsulateFieldsAction extends BaseRefactoringAction {
}
@Override
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
final PsiElement psiElement = file.findElementAt(editor.getCaretModel().getOffset());
final PsiClass containingClass = PsiTreeUtil.getParentOfType(psiElement, PsiClass.class, false);
if (containingClass != null) {
@@ -44,7 +45,7 @@ public class EncapsulateFieldsAction extends BaseRefactoringAction {
return false;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
if (elements.length == 1) {
return elements[0] instanceof PsiClass && elements[0].getLanguage().isKindOf(JavaLanguage.INSTANCE) || isAcceptedField(elements[0]);
}
@@ -59,7 +60,7 @@ public class EncapsulateFieldsAction extends BaseRefactoringAction {
return false;
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new EncapsulateFieldsHandler();
}
@@ -21,20 +21,21 @@ import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.inheritanceToDelegation.InheritanceToDelegationHandler;
import org.jetbrains.annotations.NotNull;
public class InheritanceToDelegationAction extends BaseRefactoringAction {
public boolean isAvailableInEditorOnly() {
return false;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return elements.length == 1 &&
elements[0] instanceof PsiClass &&
!((PsiClass)elements[0]).isInterface() &&
elements[0].getLanguage().isKindOf(JavaLanguage.INSTANCE);
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new InheritanceToDelegationHandler();
}
}
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiMethod;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.introduceparameterobject.IntroduceParameterObjectHandler;
import org.jetbrains.annotations.NotNull;
public class IntroduceParameterObjectAction extends BaseRefactoringAction {
@@ -28,11 +29,11 @@ public class IntroduceParameterObjectAction extends BaseRefactoringAction {
return false;
}
protected boolean isEnabledOnElements(final PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull final PsiElement[] elements) {
return elements.length == 1 && PsiTreeUtil.getParentOfType(elements[0], PsiMethod.class, false) != null;
}
protected RefactoringActionHandler getHandler(DataContext context) {
protected RefactoringActionHandler getHandler(@NotNull DataContext context) {
return new IntroduceParameterObjectHandler();
}
}
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.psi.*;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.invertBoolean.InvertBooleanHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -29,11 +30,11 @@ public class InvertBooleanAction extends BaseRefactoringAction {
return false;
}
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return elements.length == 1 && (elements[0] instanceof PsiMethod || elements[0] instanceof PsiVariable);
}
protected boolean isAvailableOnElementInEditorAndFile(final PsiElement element, final Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull final PsiElement element, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
if (element instanceof PsiVariable) {
return PsiType.BOOLEAN.equals(((PsiVariable) element).getType());
}
@@ -43,7 +44,7 @@ public class InvertBooleanAction extends BaseRefactoringAction {
return false;
}
protected RefactoringActionHandler getHandler(DataContext dataContext) {
protected RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new InvertBooleanHandler();
}
}
@@ -29,17 +29,18 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.psi.*;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.makeStatic.MakeStaticHandler;
import org.jetbrains.annotations.NotNull;
public class MakeStaticAction extends BaseRefactoringAction {
protected boolean isAvailableInEditorOnly() {
return false;
}
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return (elements.length == 1) && (elements[0] instanceof PsiMethod) && !((PsiMethod)elements[0]).isConstructor();
}
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, final Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
if (element instanceof PsiIdentifier) {
element = element.getParent();
}
@@ -47,7 +48,7 @@ public class MakeStaticAction extends BaseRefactoringAction {
MakeStaticHandler.validateTarget((PsiTypeParameterListOwner) element) == null;
}
protected RefactoringActionHandler getHandler(DataContext dataContext) {
protected RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new MakeStaticHandler();
}
}
@@ -19,6 +19,7 @@ import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.psi.PsiElement;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.util.duplicates.MethodDuplicatesHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author dsl
@@ -28,11 +29,11 @@ public class MethodDuplicatesAction extends BaseRefactoringAction {
return true;
}
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return false;
}
protected RefactoringActionHandler getHandler(DataContext dataContext) {
protected RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new MethodDuplicatesHandler();
}
}
@@ -23,15 +23,16 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.removemiddleman.RemoveMiddlemanHandler;
import org.jetbrains.annotations.NotNull;
public class RemoveMiddlemanAction extends BaseRefactoringAction{
protected RefactoringActionHandler getHandler(DataContext context) {
protected RefactoringActionHandler getHandler(@NotNull DataContext context) {
return new RemoveMiddlemanHandler();
}
@Override
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
return element instanceof PsiField;
}
@@ -39,7 +40,7 @@ public class RemoveMiddlemanAction extends BaseRefactoringAction{
return false;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return elements.length == 1 && PsiTreeUtil.getParentOfType(elements[0], PsiField.class, false) != null;
}
}
@@ -27,6 +27,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.replaceConstructorWithBuilder.ReplaceConstructorWithBuilderHandler;
import org.jetbrains.annotations.NotNull;
public class ReplaceConstructorWithBuilderAction extends BaseRefactoringAction{
protected boolean isAvailableInEditorOnly() {
@@ -34,18 +35,18 @@ public class ReplaceConstructorWithBuilderAction extends BaseRefactoringAction{
}
@Override
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
final int offset = editor.getCaretModel().getOffset();
final PsiElement elementAt = file.findElementAt(offset);
final PsiClass psiClass = ReplaceConstructorWithBuilderHandler.getParentNamedClass(elementAt);
return psiClass != null && psiClass.getConstructors().length > 0;
}
protected boolean isEnabledOnElements(final PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull final PsiElement[] elements) {
return false;
}
protected RefactoringActionHandler getHandler(final DataContext dataContext) {
protected RefactoringActionHandler getHandler(@NotNull final DataContext dataContext) {
return new ReplaceConstructorWithBuilderHandler();
}
}
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.replaceConstructorWithFactory.ReplaceConstructorWithFactoryHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author dsl
@@ -31,13 +32,13 @@ public class ReplaceConstructorWithFactoryAction extends BaseRefactoringAction {
return false;
}
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return elements.length == 1 &&
(elements[0] instanceof PsiMethod && ((PsiMethod)elements[0]).isConstructor() || elements[0] instanceof PsiClass)
&& elements[0].getLanguage().isKindOf(JavaLanguage.INSTANCE);
}
protected RefactoringActionHandler getHandler(DataContext dataContext) {
protected RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new ReplaceConstructorWithFactoryHandler();
}
}
@@ -24,17 +24,18 @@ import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.psi.PsiElement;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.extractMethodObject.ExtractMethodObjectHandler;
import org.jetbrains.annotations.NotNull;
public class ReplaceMethodWithMethodObjectAction extends BaseRefactoringAction{
protected boolean isAvailableInEditorOnly() {
return true;
}
protected boolean isEnabledOnElements(final PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull final PsiElement[] elements) {
return false;
}
protected RefactoringActionHandler getHandler(final DataContext dataContext) {
protected RefactoringActionHandler getHandler(@NotNull final DataContext dataContext) {
return new ExtractMethodObjectHandler();
}
}
@@ -23,21 +23,22 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiLocalVariable;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.tempWithQuery.TempWithQueryHandler;
import org.jetbrains.annotations.NotNull;
public class TempWithQueryAction extends BaseRefactoringAction{
public boolean isAvailableInEditorOnly() {
return true;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return false;
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new TempWithQueryHandler();
}
protected boolean isAvailableOnElementInEditorAndFile(final PsiElement element, final Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull final PsiElement element, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
return element instanceof PsiLocalVariable && ((PsiLocalVariable) element).getInitializer() != null;
}
}
@@ -21,17 +21,18 @@ import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.turnRefsToSuper.TurnRefsToSuperHandler;
import org.jetbrains.annotations.NotNull;
public class TurnRefsToSuperAction extends BaseRefactoringAction {
public boolean isAvailableInEditorOnly() {
return false;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return elements.length == 1 && elements[0] instanceof PsiClass && elements[0].getLanguage() == JavaLanguage.INSTANCE;
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new TurnRefsToSuperHandler();
}
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.typeCook.TypeCookHandler;
import org.jetbrains.annotations.NotNull;
public class TypeCookAction extends BaseRefactoringAction {
@@ -35,7 +36,7 @@ public class TypeCookAction extends BaseRefactoringAction {
return language.equals(JavaLanguage.INSTANCE);
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
if (project == null) {
@@ -59,7 +60,7 @@ public class TypeCookAction extends BaseRefactoringAction {
return true;
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return getHandler();
}
public RefactoringActionHandler getHandler() {
@@ -26,13 +26,14 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.actions.BaseRefactoringAction;
import com.intellij.refactoring.typeMigration.ChangeTypeSignatureHandler;
import org.jetbrains.annotations.NotNull;
public class ChangeTypeSignatureAction extends BaseRefactoringAction {
public boolean isAvailableInEditorOnly() {
return false;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
Project currProject = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
if (currProject == null) {
@@ -50,7 +51,7 @@ public class ChangeTypeSignatureAction extends BaseRefactoringAction {
return true;
}
protected boolean isAvailableOnElementInEditorAndFile(final PsiElement element, final Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull final PsiElement element, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
final int offset = TargetElementUtilBase.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
final PsiElement psiElement = file.findElementAt(offset);
final PsiReferenceParameterList referenceParameterList = PsiTreeUtil.getParentOfType(psiElement, PsiReferenceParameterList.class);
@@ -60,7 +61,7 @@ public class ChangeTypeSignatureAction extends BaseRefactoringAction {
return PsiTreeUtil.getParentOfType(psiElement, PsiTypeElement.class) != null;
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new ChangeTypeSignatureHandler();
}
}
@@ -21,10 +21,11 @@ import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.actions.BaseRefactoringAction;
import org.jetbrains.annotations.NotNull;
public class WrapReturnValueAction extends BaseRefactoringAction{
protected RefactoringActionHandler getHandler(DataContext context){
protected RefactoringActionHandler getHandler(@NotNull DataContext context){
return new WrapReturnValueHandler();
}
@@ -33,7 +34,7 @@ public class WrapReturnValueAction extends BaseRefactoringAction{
}
@Override
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
if (psiMethod != null && !(psiMethod instanceof PsiCompiledElement)) {
final PsiType returnType = psiMethod.getReturnType();
@@ -42,7 +43,7 @@ public class WrapReturnValueAction extends BaseRefactoringAction{
return false;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
if (elements.length != 1) {
return false;
}
@@ -17,6 +17,7 @@ package com.intellij.slicer;
import com.intellij.codeInsight.CodeInsightActionHandler;
import com.intellij.codeInsight.actions.CodeInsightAction;
import org.jetbrains.annotations.NotNull;
/**
* @author cdr
@@ -24,6 +25,7 @@ import com.intellij.codeInsight.actions.CodeInsightAction;
public class SliceBackwardAction extends CodeInsightAction{
private final SliceHandler myHandler = new SliceHandler(true);
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return myHandler;
@@ -17,6 +17,7 @@ package com.intellij.slicer;
import com.intellij.codeInsight.CodeInsightActionHandler;
import com.intellij.codeInsight.actions.CodeInsightAction;
import org.jetbrains.annotations.NotNull;
/**
* @author cdr
@@ -24,6 +25,7 @@ import com.intellij.codeInsight.actions.CodeInsightAction;
public class SliceForwardAction extends CodeInsightAction{
private final SliceHandler myHandler = new SliceForwardHandler();
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return myHandler;
@@ -72,7 +72,7 @@ public class BaseGenerateTestSupportMethodAction extends BaseGenerateAction {
}
@Override
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
if (file instanceof PsiCompiledElement) return false;
PsiDocumentManager.getInstance(project).commitAllDocuments();
@@ -22,6 +22,7 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class BaseGenerateAction extends CodeInsightAction {
@@ -31,6 +32,7 @@ public class BaseGenerateAction extends CodeInsightAction {
myHandler = handler;
}
@NotNull
@Override
protected final CodeInsightActionHandler getHandler() {
return myHandler;
@@ -46,7 +48,7 @@ public class BaseGenerateAction extends CodeInsightAction {
}
@Override
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
if (!(file instanceof PsiJavaFile)) return false;
if (file instanceof PsiCompiledElement) return false;
@@ -32,6 +32,7 @@ import org.jetbrains.annotations.NotNull;
* @author Dmitry Avdeev
*/
public abstract class CodeInsightAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
@@ -52,9 +53,11 @@ public abstract class CodeInsightAction extends AnAction {
final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
if (psiFile == null) return;
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
final CodeInsightActionHandler handler = getHandler();
final Runnable action = new Runnable() {
@Override
public void run() {
if (!ApplicationManager.getApplication().isUnitTestMode() && !editor.getContentComponent().isShowing()) return;
handler.invoke(project, editor, psiFile);
@@ -70,6 +73,7 @@ public abstract class CodeInsightAction extends AnAction {
}, getCommandName(), DocCommandGroupId.noneGroupId(editor.getDocument()));
}
@Override
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
DataContext dataContext = event.getDataContext();
@@ -90,14 +94,15 @@ public abstract class CodeInsightAction extends AnAction {
presentation.setEnabled(file != null && isValidForFile(project, editor, file));
}
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
return true;
}
@NotNull
protected abstract CodeInsightActionHandler getHandler();
protected String getCommandName() {
String text = getTemplatePresentation().getText();
return text != null ? text : "";
return text == null ? "" : text;
}
}
@@ -16,12 +16,14 @@
package com.intellij.codeInsight.actions;
import com.intellij.codeInsight.CodeInsightActionHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author Dmitry Avdeev
*/
public abstract class SimpleCodeInsightAction extends CodeInsightAction implements CodeInsightActionHandler {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return this;
@@ -37,13 +37,14 @@ public abstract class NextPrevParameterAction extends CodeInsightAction {
myNext = next;
}
@NotNull
@Override
public CodeInsightActionHandler getHandler() {
return new Handler();
}
@Override
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
return hasSutablePolicy(editor, file);
}
@@ -374,7 +374,7 @@ public final class Annotation implements Segment {
}
/**
* File level annoations are visualized differently than lesser range annotations by showing a title bar on top of the
* File level annotations are visualized differently than lesser range annotations by showing a title bar on top of the
* editor rather than applying text attributes to the text range.
* @return <code>true</code> if this particular annotation have been defined as file level.
*/
@@ -383,7 +383,7 @@ public final class Annotation implements Segment {
}
/**
* File level annoations are visualized differently than lesser range annotations by showing a title bar on top of the
* File level annotations are visualized differently than lesser range annotations by showing a title bar on top of the
* editor rather than applying text attributes to the text range.
* @param isFileLevelAnnotation <code>true</code> if this particular annotation should be visualized at file level.
*/
@@ -36,6 +36,7 @@ public class HippieBackwardCompletionAction extends BaseCodeInsightAction implem
super.actionPerformedImpl(project, editor);
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new HippieWordCompletionHandler(false);
@@ -36,6 +36,7 @@ public class HippieCompletionAction extends BaseCodeInsightAction implements Dum
super.actionPerformedImpl(project, editor);
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new HippieWordCompletionHandler(true);
@@ -23,19 +23,21 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.DumbAware;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class GotoNextErrorAction extends BaseCodeInsightAction implements DumbAware {
public GotoNextErrorAction() {
super(false);
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new GotoNextErrorHandler(true);
}
@Override
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
return DaemonCodeAnalyzer.getInstance(project).isHighlightingAvailable(file);
}
}
@@ -25,19 +25,21 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class GotoPreviousErrorAction extends BaseCodeInsightAction implements DumbAware {
public GotoPreviousErrorAction() {
super(false);
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new GotoNextErrorHandler(false);
}
@Override
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
return DaemonCodeAnalyzer.getInstance(project).isHighlightingAvailable(file);
}
}
@@ -41,13 +41,14 @@ public class ShowErrorDescriptionAction extends BaseCodeInsightAction implements
setEnabledInModalContext(true);
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new ShowErrorDescriptionHandler(shouldShowDescription ? width : 0);
}
@Override
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
return DaemonCodeAnalyzer.getInstance(project).isHighlightingAvailable(file) && isEnabledForFile(project, editor, file);
}
@@ -43,6 +43,7 @@ public class ShowQuickDocInfoAction extends BaseCodeInsightAction implements Hin
setInjectedContext(true);
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new CodeInsightActionHandler() {
@@ -41,13 +41,14 @@ public class EmacsStyleIndentAction extends BaseCodeInsightAction implements Dum
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.generation.actions.EmacsStyleIndentAction");
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new Handler();
}
@Override
protected boolean isValidForFile(final Project project, final Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
final PsiElement context = file.findElementAt(editor.getCaretModel().getOffset());
return context != null && LanguageFormatting.INSTANCE.forContext(context) != null;
}
@@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull;
*/
public class FillParagraphAction extends BaseCodeInsightAction {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new Handler();
@@ -45,7 +46,7 @@ public class FillParagraphAction extends BaseCodeInsightAction {
}
@Override
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
final ParagraphFillHandler handler =
LanguageFillParagraphExtension.INSTANCE.forLanguage(file.getLanguage());
return handler != null && handler.isAvailableForFile(file);
@@ -18,8 +18,10 @@ package com.intellij.codeInsight.folding.impl.actions;
import com.intellij.codeInsight.CodeInsightActionHandler;
import com.intellij.codeInsight.actions.BaseCodeInsightAction;
import com.intellij.codeInsight.folding.impl.CollapseExpandDocCommentsHandler;
import org.jetbrains.annotations.NotNull;
public class CollapseDocCommentsAction extends BaseCodeInsightAction{
@NotNull
@Override
protected CodeInsightActionHandler getHandler(){
return new CollapseExpandDocCommentsHandler(false);
@@ -20,11 +20,13 @@ import com.intellij.codeInsight.CodeInsightActionHandler;
import com.intellij.codeInsight.actions.BaseCodeInsightAction;
import com.intellij.codeInsight.folding.impl.CollapseSelectionHandler;
import com.intellij.openapi.project.DumbAware;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
*/
public class CollapseSelectionAction extends BaseCodeInsightAction implements DumbAware {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new CollapseSelectionHandler();
@@ -18,8 +18,10 @@ package com.intellij.codeInsight.folding.impl.actions;
import com.intellij.codeInsight.CodeInsightActionHandler;
import com.intellij.codeInsight.actions.BaseCodeInsightAction;
import com.intellij.codeInsight.folding.impl.CollapseExpandDocCommentsHandler;
import org.jetbrains.annotations.NotNull;
public class ExpandDocCommentsAction extends BaseCodeInsightAction{
@NotNull
@Override
protected CodeInsightActionHandler getHandler(){
return new CollapseExpandDocCommentsHandler(true);
@@ -26,8 +26,10 @@ import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class AutoIndentLinesAction extends BaseCodeInsightAction implements DumbAware {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new AutoIndentLinesHandler();
@@ -38,7 +40,7 @@ public class AutoIndentLinesAction extends BaseCodeInsightAction implements Dumb
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
final FileType fileType = file.getFileType();
return fileType instanceof LanguageFileType &&
LanguageFormatting.INSTANCE.forContext(((LanguageFileType)fileType).getLanguage(), file) != null;
@@ -27,19 +27,21 @@ import com.intellij.openapi.fileTypes.impl.AbstractFileType;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class CommentByBlockCommentAction extends BaseCodeInsightAction implements DumbAware {
public CommentByBlockCommentAction() {
setEnabledInModalContext(true);
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new CommentByBlockCommentHandler();
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
final FileType fileType = file.getFileType();
if (fileType instanceof AbstractFileType) {
return ((AbstractFileType)fileType).getCommenter() != null;
@@ -26,19 +26,21 @@ import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.lang.LanguageCommenters;
import org.jetbrains.annotations.NotNull;
public class CommentByLineCommentAction extends BaseCodeInsightAction implements DumbAware {
public CommentByLineCommentAction() {
setEnabledInModalContext(true);
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new CommentByLineCommentHandler();
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
final FileType fileType = file.getFileType();
if (fileType instanceof AbstractFileType) {
return ((AbstractFileType)fileType).getCommenter() != null;
@@ -27,16 +27,18 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilBase;
import org.jetbrains.annotations.NotNull;
public class DelegateMethodsAction extends BaseCodeInsightAction {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new DelegateMethodsHandler();
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
Language language = PsiUtilBase.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.DELEGATE_METHODS.forLanguage(language);
if (codeInsightActionHandler != null) {
@@ -27,15 +27,17 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilBase;
import org.jetbrains.annotations.NotNull;
public class ImplementMethodsAction extends BaseCodeInsightAction {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new ImplementMethodsHandler();
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
final Language language = PsiUtilBase.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.IMPLEMENT_METHOD.forLanguage(language);
return codeInsightActionHandler != null && codeInsightActionHandler.isValidFor(editor, file);
@@ -27,16 +27,18 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilBase;
import org.jetbrains.annotations.NotNull;
public class OverrideMethodsAction extends BaseCodeInsightAction {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new OverrideMethodsHandler();
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
Language language = PsiUtilBase.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
final LanguageCodeInsightActionHandler codeInsightActionHandler = CodeInsightActions.OVERRIDE_METHOD.forLanguage(language);
if (codeInsightActionHandler != null) {
@@ -26,19 +26,21 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilCore;
import org.jetbrains.annotations.NotNull;
public class SurroundWithAction extends BaseCodeInsightAction{
public SurroundWithAction() {
setEnabledInModalContext(true);
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler(){
return new SurroundWithHandler();
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
final Language language = file.getLanguage();
if (!LanguageSurrounders.INSTANCE.allForLanguage(language).isEmpty()) {
return true;
@@ -25,9 +25,11 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ShowContainerInfoAction extends BaseCodeInsightAction{
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new ShowContainerInfoHandler();
@@ -40,7 +42,7 @@ public class ShowContainerInfoAction extends BaseCodeInsightAction{
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
return LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(file) instanceof TreeBasedStructureViewBuilder;
}
}
@@ -25,19 +25,21 @@ import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilBase;
import org.jetbrains.annotations.NotNull;
public class ShowParameterInfoAction extends BaseCodeInsightAction implements DumbAware {
public ShowParameterInfoAction() {
setEnabledInModalContext(true);
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new ShowParameterInfoHandler();
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
final Language language = PsiUtilBase.getLanguageAtOffset(file, editor.getCaretModel().getOffset());
return ShowParameterInfoHandler.getHandlers(project, language, file.getViewProvider().getBaseLanguage()) != null;
}
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.CodeInsightActionHandler;
import com.intellij.codeInsight.actions.BaseCodeInsightAction;
import com.intellij.codeInsight.hint.HintManagerImpl;
import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author mike
@@ -34,6 +35,7 @@ public class ShowIntentionActionsAction extends BaseCodeInsightAction implements
return true;
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new ShowIntentionActionsHandler();
@@ -61,6 +61,7 @@ import java.util.Collections;
public class GotoDeclarationAction extends BaseCodeInsightAction implements CodeInsightActionHandler, DumbAware {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.navigation.actions.GotoDeclarationAction");
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
String s = "/java/lang/Object.class";
@@ -22,8 +22,10 @@ import com.intellij.codeInsight.navigation.GotoImplementationHandler;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAware;
import com.intellij.psi.search.searches.DefinitionsSearch;
import org.jetbrains.annotations.NotNull;
public class GotoImplementationAction extends BaseCodeInsightAction implements DumbAware {
@NotNull
@Override
protected CodeInsightActionHandler getHandler(){
return new GotoImplementationHandler();
@@ -33,6 +33,7 @@ public class GotoSuperAction extends BaseCodeInsightAction implements CodeInsigh
@NonNls public static final String FEATURE_ID = "navigation.goto.super";
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return this;
@@ -41,6 +41,7 @@ import java.util.Set;
public class GotoTypeDeclarationAction extends BaseCodeInsightAction implements CodeInsightActionHandler, DumbAware {
@NotNull
@Override
protected CodeInsightActionHandler getHandler(){
return this;
@@ -22,8 +22,10 @@ import com.intellij.codeInsight.navigation.MethodDownHandler;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class MethodDownAction extends BaseCodeInsightAction {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new MethodDownHandler();
@@ -35,7 +37,7 @@ public class MethodDownAction extends BaseCodeInsightAction {
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
return MethodUpAction.checkValidForFile(file);
}
}
@@ -26,8 +26,10 @@ import com.intellij.lang.LanguageStructureViewBuilder;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
public class MethodUpAction extends BaseCodeInsightAction {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new MethodUpHandler();
@@ -39,7 +41,7 @@ public class MethodUpAction extends BaseCodeInsightAction {
}
@Override
protected boolean isValidForFile(Project project, Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
return checkValidForFile(file);
}
@@ -20,8 +20,10 @@ package com.intellij.codeInsight.template.impl.actions;
import com.intellij.codeInsight.CodeInsightActionHandler;
import com.intellij.codeInsight.actions.BaseCodeInsightAction;
import com.intellij.codeInsight.template.impl.ListTemplatesHandler;
import org.jetbrains.annotations.NotNull;
public class ListTemplatesAction extends BaseCodeInsightAction{
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new ListTemplatesHandler();
@@ -19,11 +19,13 @@ package com.intellij.codeInsight.template.impl.actions;
import com.intellij.codeInsight.CodeInsightActionHandler;
import com.intellij.codeInsight.actions.BaseCodeInsightAction;
import com.intellij.codeInsight.template.impl.SurroundWithTemplateHandler;
import org.jetbrains.annotations.NotNull;
/**
* @author mike
*/
public class SurroundWithTemplateAction extends BaseCodeInsightAction {
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new SurroundWithTemplateHandler();
@@ -21,6 +21,7 @@ import com.intellij.codeInsight.actions.BaseCodeInsightAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
public class UnwrapAction extends BaseCodeInsightAction{
public UnwrapAction() {
@@ -28,13 +29,14 @@ public class UnwrapAction extends BaseCodeInsightAction{
setEnabledInModalContext(true);
}
@NotNull
@Override
protected CodeInsightActionHandler getHandler(){
return new UnwrapHandler();
}
@Override
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
return !LanguageUnwrappers.INSTANCE.allForLanguage(file.getLanguage()).isEmpty();
}
}
@@ -25,6 +25,7 @@ import com.intellij.psi.codeStyle.CodeStyleSchemes;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.impl.source.codeStyle.CodeStyleSchemeImpl;
import com.intellij.psi.impl.source.codeStyle.CodeStyleSchemesImpl;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -32,7 +33,7 @@ import java.util.Collection;
* @author max
*/
public class QuickChangeCodeStyleSchemeAction extends QuickSwitchSchemeAction {
protected void fillActions(Project project, DefaultActionGroup group, DataContext dataContext) {
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
final CodeStyleSettingsManager manager = CodeStyleSettingsManager.getInstance(project);
if (manager.PER_PROJECT_SETTINGS != null) {
//noinspection HardCodedStringLiteral
@@ -21,13 +21,14 @@ import com.intellij.ide.favoritesTreeView.FavoritesManager;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
/**
* User: anna
* Date: Feb 24, 2005
*/
public class AddToFavoritesPopupAction extends QuickSwitchSchemeAction {
protected void fillActions(Project project, DefaultActionGroup group, DataContext dataContext) {
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
group.removeAll();
final String[] availableFavoritesLists = FavoritesManager.getInstance(project).getAvailableFavoritesListNames();
for (String favoritesList : availableFavoritesLists) {
@@ -60,7 +60,7 @@ public abstract class BasePlatformRefactoringAction extends BaseRefactoringActio
}
@Override
protected final RefactoringActionHandler getHandler(DataContext dataContext) {
protected final RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
PsiElement element = null;
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
PsiFile file = LangDataKeys.PSI_FILE.getData(dataContext);
@@ -123,7 +123,7 @@ public abstract class BasePlatformRefactoringAction extends BaseRefactoringActio
}
@Override
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
return getHandler(context) != null;
}
@@ -133,7 +133,7 @@ public abstract class BasePlatformRefactoringAction extends BaseRefactoringActio
}
@Override
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
if (elements.length > 0) {
Language language = elements[0].getLanguage();
RefactoringActionHandler handler = getHandler(language, elements[0]);
@@ -57,19 +57,20 @@ public abstract class BaseRefactoringAction extends AnAction {
protected abstract boolean isAvailableInEditorOnly();
protected abstract boolean isEnabledOnElements(PsiElement[] elements);
protected abstract boolean isEnabledOnElements(@NotNull PsiElement[] elements);
protected boolean isAvailableOnElementInEditorAndFile(final PsiElement element, final Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
return true;
}
protected boolean hasAvailableHandler(DataContext dataContext) {
protected boolean hasAvailableHandler(@NotNull DataContext dataContext) {
return getHandler(dataContext) != null;
}
@Nullable
protected abstract RefactoringActionHandler getHandler(DataContext dataContext);
protected abstract RefactoringActionHandler getHandler(@NotNull DataContext dataContext);
@Override
public final void actionPerformed(AnActionEvent e) {
DataContext dataContext = e.getDataContext();
final Project project = e.getData(PlatformDataKeys.PROJECT);
@@ -129,6 +130,7 @@ public abstract class BaseRefactoringAction extends AnAction {
return false;
}
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
presentation.setVisible(true);
@@ -40,11 +40,11 @@ public class ChangeSignatureAction extends BaseRefactoringAction {
return false;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return elements.length == 1 && findTargetMember(elements[0]) != null;
}
protected boolean isAvailableOnElementInEditorAndFile(final PsiElement element, final Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull final PsiElement element, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
PsiElement targetMember = findTargetMember(file, editor);
if (targetMember == null) {
final ChangeSignatureHandler targetHandler = getChangeSignatureHandler(file.getLanguage());
@@ -88,7 +88,7 @@ public class ChangeSignatureAction extends BaseRefactoringAction {
}
@Override
protected boolean hasAvailableHandler(DataContext dataContext) {
protected boolean hasAvailableHandler(@NotNull DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project == null) return false;
final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
@@ -105,7 +105,7 @@ public class ChangeSignatureAction extends BaseRefactoringAction {
return targetMember != null && getChangeSignatureHandler(targetMember.getLanguage()) != null;
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
Language language = LangDataKeys.LANGUAGE.getData(dataContext);
if (language == null) {
PsiElement psiElement = LangDataKeys.PSI_ELEMENT.getData(dataContext);
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.lang.LanguageExtractInclude;
import org.jetbrains.annotations.NotNull;
/**
* @author ven
@@ -34,7 +35,7 @@ public class ExtractIncludeAction extends BaseRefactoringAction {
return true;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return false;
}
@@ -59,7 +60,7 @@ public class ExtractIncludeAction extends BaseRefactoringAction {
return LanguageExtractInclude.INSTANCE.forLanguage(baseLanguage) != null;
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
PsiFile file = LangDataKeys.PSI_FILE.getData(dataContext);
if (file == null) return null;
return LanguageExtractInclude.INSTANCE.forLanguage(file.getViewProvider().getBaseLanguage());
@@ -32,7 +32,7 @@ public class ExtractMethodAction extends BasePlatformRefactoringAction {
return true;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return false;
}
@@ -51,11 +51,11 @@ public class InlineAction extends BasePlatformRefactoringAction {
}
@Override
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
return hasInlineActionHandler(element, PsiUtilBase.getLanguageInEditor(editor, element.getProject()), editor);
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return elements.length == 1 && hasInlineActionHandler(elements [0], null, null);
}
@@ -37,7 +37,7 @@ public class IntroduceConstantAction extends BasePlatformRefactoringAction {
return true;
}
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return false;
}
}
@@ -37,7 +37,7 @@ public class IntroduceFieldAction extends BasePlatformRefactoringAction {
return true;
}
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return false;
}
}
@@ -36,7 +36,7 @@ public class IntroduceParameterAction extends BasePlatformRefactoringAction {
return true;
}
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return false;
}
@@ -32,7 +32,7 @@ public class IntroduceVariableAction extends BasePlatformRefactoringAction {
return true;
}
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return false;
}
@@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.psi.PsiElement;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.move.MoveHandler;
import org.jetbrains.annotations.NotNull;
public class MoveAction extends BaseRefactoringAction {
@@ -37,7 +38,7 @@ public class MoveAction extends BaseRefactoringAction {
return true;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return MoveHandler.canMove(elements, null);
}
@@ -45,7 +46,7 @@ public class MoveAction extends BaseRefactoringAction {
return MoveHandler.canMove(dataContext);
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new MoveHandler();
}
}
@@ -20,13 +20,14 @@ import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.ListPopup;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class RefactoringQuickListPopupAction extends QuickSwitchSchemeAction {
protected void fillActions(@Nullable final Project project,
final DefaultActionGroup group,
final DataContext dataContext) {
@NotNull final DefaultActionGroup group,
@NotNull final DataContext dataContext) {
if (project == null) {
return;
}
@@ -37,9 +38,10 @@ public class RefactoringQuickListPopupAction extends QuickSwitchSchemeAction {
}
private static void collectEnabledChildren(AnAction action,
DefaultActionGroup destinationGroup,
DataContext dataContext,
ActionManager actionManager, boolean popup) {
@NotNull DefaultActionGroup destinationGroup,
@NotNull DataContext dataContext,
@NotNull ActionManager actionManager,
boolean popup) {
if (action instanceof DefaultActionGroup) {
final AnAction[] children = ((DefaultActionGroup)action).getChildren(null);
for (AnAction child : children) {
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.SyntheticElement;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.rename.RenameHandlerRegistry;
import org.jetbrains.annotations.NotNull;
public class RenameElementAction extends BaseRefactoringAction {
@@ -36,19 +37,19 @@ public class RenameElementAction extends BaseRefactoringAction {
return false;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
if (elements.length != 1) return false;
PsiElement element = elements[0];
return element instanceof PsiNamedElement && !(element instanceof SyntheticElement);
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return RenameHandlerRegistry.getInstance().getRenameHandler(dataContext);
}
@Override
protected boolean hasAvailableHandler(DataContext dataContext) {
protected boolean hasAvailableHandler(@NotNull DataContext dataContext) {
return isEnabledOnDataContext(dataContext);
}
@@ -61,7 +62,7 @@ public class RenameElementAction extends BaseRefactoringAction {
}
@Override
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
return RenameHandlerRegistry.getInstance().hasAvailableHandler(context);
}
}
@@ -24,6 +24,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.safeDelete.SafeDeleteHandler;
import com.intellij.refactoring.safeDelete.SafeDeleteProcessor;
import org.jetbrains.annotations.NotNull;
public class SafeDeleteAction extends BaseRefactoringAction {
public SafeDeleteAction() {
@@ -38,18 +39,18 @@ public class SafeDeleteAction extends BaseRefactoringAction {
return true;
}
public boolean isEnabledOnElements(PsiElement[] elements) {
public boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
for (PsiElement element : elements) {
if (!SafeDeleteProcessor.validElement(element)) return false;
}
return true;
}
protected boolean isAvailableOnElementInEditorAndFile(final PsiElement element, final Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull final PsiElement element, @NotNull final Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
return SafeDeleteProcessor.validElement(element);
}
public RefactoringActionHandler getHandler(DataContext dataContext) {
public RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new SafeDeleteHandler();
}
@@ -27,8 +27,10 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilBase;
import org.jetbrains.annotations.NotNull;
public class GotoTestOrCodeAction extends BaseCodeInsightAction {
@NotNull
protected CodeInsightActionHandler getHandler(){
return new GotoTestOrCodeHandler();
}
@@ -46,6 +46,7 @@ public abstract class QuickSwitchSchemeAction extends AnAction implements DumbAw
myShowPopupWithNoActions = showPopupWithNoActions;
}
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(PlatformDataKeys.PROJECT);
DefaultActionGroup group = new DefaultActionGroup();
@@ -53,12 +54,12 @@ public abstract class QuickSwitchSchemeAction extends AnAction implements DumbAw
showPopup(e, group);
}
protected abstract void fillActions(Project project, DefaultActionGroup group, DataContext dataContext);
protected abstract void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext);
private void showPopup(AnActionEvent e, DefaultActionGroup group) {
if (!myShowPopupWithNoActions && group.getChildrenCount() == 0) return;
final ListPopup popup = JBPopupFactory.getInstance()
.createActionGroupPopup(QuickSwitchSchemeAction.this.getPopupTitle(e),
.createActionGroupPopup(getPopupTitle(e),
group,
e.getDataContext(), getAidMethod(),
true, myActionPlace);
@@ -78,6 +79,7 @@ public abstract class QuickSwitchSchemeAction extends AnAction implements DumbAw
return e.getPresentation().getText();
}
@Override
public void update(AnActionEvent e) {
super.update(e);
e.getPresentation().setEnabled(e.getData(PlatformDataKeys.PROJECT) != null && isEnabled());
@@ -25,6 +25,7 @@ import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.options.SharedScheme;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -32,7 +33,7 @@ import java.util.Collection;
* @author max
*/
public class QuickChangeColorSchemeAction extends QuickSwitchSchemeAction {
protected void fillActions(Project project, DefaultActionGroup group, DataContext dataContext) {
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
final EditorColorsScheme[] schemes = EditorColorsManager.getInstance().getAllSchemes();
EditorColorsScheme current = EditorColorsManager.getInstance().getGlobalScheme();
for (final EditorColorsScheme scheme : schemes) {
@@ -22,6 +22,7 @@ import com.intellij.openapi.keymap.ex.KeymapManagerEx;
import com.intellij.openapi.keymap.impl.KeymapImpl;
import com.intellij.openapi.options.SharedScheme;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
@@ -29,7 +30,7 @@ import java.util.Collection;
* @author max
*/
public class QuickChangeKeymapAction extends QuickSwitchSchemeAction {
protected void fillActions(Project project, DefaultActionGroup group, DataContext dataContext) {
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
final KeymapManagerEx manager = (KeymapManagerEx) KeymapManager.getInstance();
final Keymap current = manager.getActiveKeymap();
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -30,7 +31,7 @@ import javax.swing.*;
* @author max
*/
public class QuickChangeLookAndFeel extends QuickSwitchSchemeAction {
protected void fillActions(Project project, DefaultActionGroup group, DataContext dataContext) {
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
final LafManager manager = LafManager.getInstance();
final UIManager.LookAndFeelInfo[] lfs = manager.getInstalledLookAndFeels();
final UIManager.LookAndFeelInfo current = manager.getCurrentLookAndFeel();
@@ -19,12 +19,13 @@ import com.intellij.featureStatistics.FeatureUsageTracker;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.DumbAware;
import org.jetbrains.annotations.NotNull;
/**
* @author max
*/
public class QuickChangeSchemesAction extends QuickSwitchSchemeAction implements DumbAware {
protected void fillActions(Project project, DefaultActionGroup group, DataContext dataContext) {
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
final AnAction[] actions = getGroup().getChildren(null);
for (AnAction action : actions) {
group.add(action);
@@ -235,7 +235,7 @@ public class QuickListsManager implements ExportableApplicationComponent, NamedJ
getTemplatePresentation().setText(myQuickList.getDisplayName(), false);
}
protected void fillActions(Project project, DefaultActionGroup group, DataContext dataContext) {
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
ActionManager actionManager = ActionManagerEx.getInstance();
for (String actionId : myQuickList.getActionIds()) {
if (QuickList.SEPARATOR_ID.equals(actionId)) {
@@ -28,8 +28,8 @@ public class VcsQuickListPopupAction extends QuickSwitchSchemeAction implements
}
protected void fillActions(@Nullable final Project project,
final DefaultActionGroup group,
@Nullable final DataContext dataContext) {
@NotNull final DefaultActionGroup group,
@NotNull final DataContext dataContext) {
if (project == null) {
return;
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.refactoring.RefactoringActionHandler;
import com.intellij.refactoring.actions.BaseRefactoringAction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.GroovyFileType;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.refactoring.convertToJava.ConvertToJavaHandler;
@@ -32,7 +33,7 @@ import org.jetbrains.plugins.groovy.refactoring.convertToJava.ConvertToJavaHandl
public class ConvertToJavaAction extends BaseRefactoringAction {
@Override
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
return isEnabledOnElements(new PsiElement[]{element});
}
@@ -52,7 +53,7 @@ public class ConvertToJavaAction extends BaseRefactoringAction {
}
@Override
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
for (PsiElement element : elements) {
final PsiFile containingFile = element.getContainingFile();
@@ -63,7 +64,7 @@ public class ConvertToJavaAction extends BaseRefactoringAction {
}
@Override
protected RefactoringActionHandler getHandler(DataContext dataContext) {
protected RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new ConvertToJavaHandler();
}
}
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiCompiledElement;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.GroovyFileType;
/**
@@ -34,7 +35,7 @@ public abstract class GrBaseGenerateAction extends BaseGenerateAction {
super(handler);
}
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
if (file instanceof PsiCompiledElement) return false;
if (!GroovyFileType.GROOVY_FILE_TYPE.equals(file.getFileType())) return false;
@@ -26,7 +26,7 @@ public class MavenGenerateTemplateAction extends GenerateDomElementAction {
getTemplatePresentation().setIcon(ElementPresentationManager.getIconForClass(childElementClass));
}
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
return file instanceof XmlFile && MavenDomUtil.getMavenDomModel(file, MavenDomProjectModel.class) != null;
}
}
@@ -54,7 +54,7 @@ public class ExtractManagedDependenciesAction extends BaseRefactoringAction {
return true;
}
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return false;
}
@@ -63,7 +63,7 @@ public class ExtractManagedDependenciesAction extends BaseRefactoringAction {
return true;
}
protected RefactoringActionHandler getHandler(DataContext dataContext) {
protected RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new MyRefactoringActionHandler();
}
@@ -73,7 +73,7 @@ public class ExtractManagedDependenciesAction extends BaseRefactoringAction {
}
@Override
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
if (!super.isAvailableOnElementInEditorAndFile(element, editor, file, context)) return false;
return findDependencyAndParent(file, editor) != null;
}
@@ -54,7 +54,7 @@ public class IntroducePropertyAction extends BaseRefactoringAction {
return true;
}
protected boolean isEnabledOnElements(PsiElement[] elements) {
protected boolean isEnabledOnElements(@NotNull PsiElement[] elements) {
return false;
}
@@ -63,7 +63,7 @@ public class IntroducePropertyAction extends BaseRefactoringAction {
return true;
}
protected RefactoringActionHandler getHandler(DataContext dataContext) {
protected RefactoringActionHandler getHandler(@NotNull DataContext dataContext) {
return new MyRefactoringActionHandler();
}
@@ -76,7 +76,7 @@ public class IntroducePropertyAction extends BaseRefactoringAction {
}
@Override
protected boolean isAvailableOnElementInEditorAndFile(PsiElement element, Editor editor, PsiFile file, DataContext context) {
protected boolean isAvailableOnElementInEditorAndFile(@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) {
if (!super.isAvailableOnElementInEditorAndFile(element, editor, file, context)) return false;
return getSelectedElementAndTextRange(editor, file) != null;
}
@@ -49,7 +49,7 @@ public abstract class CreateDomElementAction<T extends DomElement> extends Simpl
protected abstract DomElement createElement(T context, Editor editor, PsiFile file, Project project);
@Override
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
return getContextElement(editor) != null;
}
@@ -50,6 +50,7 @@ public class GenerateDomElementAction extends CodeInsightAction {
this(generateProvider, null);
}
@NotNull
protected CodeInsightActionHandler getHandler() {
return new CodeInsightActionHandler() {
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
@@ -82,7 +83,7 @@ public class GenerateDomElementAction extends CodeInsightAction {
return true;
}
protected boolean isValidForFile(final Project project, final Editor editor, final PsiFile file) {
protected boolean isValidForFile(@NotNull final Project project, @NotNull final Editor editor, @NotNull final PsiFile file) {
final DomElement element = DomUtil.getContextElement(editor);
return element != null && myProvider.isAvailableForElement(element);
}
@@ -42,6 +42,7 @@ import org.jetbrains.annotations.Nullable;
*/
public class GenerateDTDAction extends BaseCodeInsightAction{
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.actions.GenerateDTDAction");
@NotNull
protected CodeInsightActionHandler getHandler(){
return new CodeInsightActionHandler(){
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
@@ -115,7 +116,7 @@ public class GenerateDTDAction extends BaseCodeInsightAction{
}
}
protected boolean isValidForFile(Project project, Editor editor, PsiFile file){
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file){
return file instanceof XmlFile;
}
}
@@ -300,7 +300,7 @@ public class GenerateXmlTagAction extends SimpleCodeInsightAction {
}
@Override
protected boolean isValidForFile(Project project, Editor editor, PsiFile file) {
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
if (!(file instanceof XmlFile)) return false;
XmlTag contextTag = getContextTag(editor, file);
return contextTag != null && contextTag.getDescriptor() != null;