get rid of additional scope checks for suppression intentions

This commit is contained in:
Sergey Ignatov
2015-09-25 11:42:54 +03:00
parent 458cd4c304
commit 6e58a5d643
2 changed files with 6 additions and 12 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -28,7 +28,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Iconable;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -66,8 +65,7 @@ public abstract class SuppressIntentionAction implements Iconable, IntentionActi
@Override
public final void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
if (!file.getManager().isInProject(file)) return;
final PsiElement element = getElement(editor, file);
PsiElement element = getElement(editor, file);
if (element != null) {
invoke(project, editor, element);
}
@@ -79,7 +77,7 @@ public abstract class SuppressIntentionAction implements Iconable, IntentionActi
* @param project the project in which the file is opened.
* @param editor the editor for the file.
* @param element the element under cursor.
* @throws com.intellij.util.IncorrectOperationException
* @throws IncorrectOperationException
*
*/
public abstract void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException;
@@ -87,10 +85,7 @@ public abstract class SuppressIntentionAction implements Iconable, IntentionActi
@Override
public final boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (file == null) return false;
final PsiManager manager = file.getManager();
if (manager == null) return false;
if (!manager.isInProject(file)) return false;
final PsiElement element = getElement(editor, file);
PsiElement element = getElement(editor, file);
return element != null && isAvailable(project, editor, element);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -25,7 +25,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Iconable;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiWhiteSpace;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
@@ -129,7 +128,7 @@ public abstract class AbstractBatchSuppressByNoInspectionCommentFix implements C
@Override
public boolean isAvailable(@NotNull final Project project, @NotNull final PsiElement context) {
return context.isValid() && PsiManager.getInstance(project).isInProject(context) && getContainer(context) != null;
return context.isValid() && getContainer(context) != null;
}
public void invoke(@NotNull final Project project, @NotNull final PsiElement element) throws IncorrectOperationException {