[surrounder] Surrounder.surroundElements: remove declared unchecked exception (unnecessary and rarely thrown anyway)

GitOrigin-RevId: c8122acc2c3ee0d2bf78c70efb5525c54020fe70
This commit is contained in:
Tagir Valeev
2024-06-19 16:00:49 +02:00
committed by intellij-monorepo-bot
parent 5b4e5db8b5
commit be91af43bb
11 changed files with 11 additions and 21 deletions

View File

@@ -28,7 +28,6 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiFileFactory;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.IncorrectOperationException;
import org.intellij.lang.regexp.RegExpFileType;
import org.intellij.lang.regexp.psi.RegExpAtom;
import org.intellij.lang.regexp.psi.RegExpPattern;
@@ -57,7 +56,7 @@ class GroupSurrounder implements Surrounder {
@Override
@Nullable
public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements) throws IncorrectOperationException {
public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements) {
assert elements.length == 1 || PsiTreeUtil.findCommonParent(elements) == elements[0].getParent();
final PsiElement e = elements[0];
final ASTNode node = e.getNode();

View File

@@ -35,7 +35,7 @@ public abstract class JavaExpressionSurrounder implements Surrounder {
@Override
public TextRange surroundElements(@NotNull Project project,
@NotNull Editor editor,
PsiElement @NotNull [] elements) throws IncorrectOperationException {
PsiElement @NotNull [] elements) {
if (elements.length != 1 || !(elements[0] instanceof PsiExpression)) {
throw new IllegalArgumentException(Arrays.toString(elements));
}

View File

@@ -9,7 +9,6 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -20,8 +19,7 @@ public abstract class JsonSurrounderBase implements Surrounder {
}
@Override
public @Nullable TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements)
throws IncorrectOperationException {
public @Nullable TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements) {
if (!isApplicable(elements)) {
return null;
}

View File

@@ -7,7 +7,6 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -49,7 +48,7 @@ public final class JsonWithObjectLiteralSurrounder extends JsonSurrounderBase {
@Override
public @Nullable TextRange surroundElements(@NotNull Project project,
@NotNull Editor editor,
PsiElement @NotNull [] elements) throws IncorrectOperationException {
PsiElement @NotNull [] elements) {
if (!isApplicable(elements)) {
return null;

View File

@@ -13,7 +13,6 @@ import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -40,8 +39,7 @@ public abstract class ModCommandSurrounder implements Surrounder {
public abstract @NotNull ModCommand surroundElements(@NotNull ActionContext context, @NotNull PsiElement @NotNull [] elements);
@Override
public final @Nullable TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements)
throws IncorrectOperationException {
public final @Nullable TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements) {
if (elements.length == 0) {
return null;
}

View File

@@ -9,7 +9,6 @@ import com.intellij.openapi.util.NlsActions;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.util.ArrayFactory;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -53,5 +52,5 @@ public interface Surrounder extends WriteActionAware {
@Nullable
TextRange surroundElements(@NotNull Project project,
@NotNull Editor editor,
PsiElement @NotNull [] elements) throws IncorrectOperationException;
PsiElement @NotNull [] elements);
}

View File

@@ -20,7 +20,6 @@ import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
@@ -32,7 +31,7 @@ public abstract class GroovyExpressionSurrounder implements Surrounder {
@Override
@Nullable
public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements) throws IncorrectOperationException {
public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements) {
if (elements.length != 1) return null;
PsiElement element = elements[0];

View File

@@ -54,7 +54,7 @@ public abstract class GroovyManyStatementsSurrounder implements Surrounder {
@Override
@Nullable
public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements) throws IncorrectOperationException {
public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements) {
if (elements.length == 0) return null;
PsiElement element1 = elements[0];

View File

@@ -50,7 +50,7 @@ class KotlinRuntimeTypeCastSurrounder : Surrounder {
return TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, type)
}
override fun surroundElements(project: Project, editor: Editor, elements: Array<out PsiElement?>): TextRange? {
override fun surroundElements(project: Project, editor: Editor, elements: Array<PsiElement>): TextRange? {
val expression = elements.singleOrNull() as? KtExpression ?: return null
val debuggerContext = DebuggerManagerEx.getInstanceEx(project).context
val debuggerSession = debuggerContext.debuggerSession

View File

@@ -26,8 +26,7 @@ public abstract class PyExpressionSurrounder implements Surrounder {
throws IncorrectOperationException;
@Override
public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements)
throws IncorrectOperationException {
public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements) {
return surroundExpression(project, editor, (PyExpression)elements[0]);
}
}

View File

@@ -23,8 +23,7 @@ public abstract class PyStatementSurrounder implements Surrounder {
throws IncorrectOperationException;
@Override
public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements)
throws IncorrectOperationException {
public TextRange surroundElements(@NotNull Project project, @NotNull Editor editor, PsiElement @NotNull [] elements) {
return surroundStatement(project, editor, elements);
}
}