mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
Java: improve intention text
GitOrigin-RevId: 72e2cbc6c1927af08401835f7e9ee4814ac26dea
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5993d0cbef
commit
5dda5cdb12
@@ -27,8 +27,8 @@ add.method.text=Add Method ''{0}'' to Class ''{1}''
|
||||
add.new.array.family=Add missing new expression
|
||||
add.new.array.text=Add ''new {0}[]''
|
||||
add.return.statement.text=Add 'return' statement
|
||||
add.runtime.exception.to.throws.text=Add runtime exception(s) to method signature
|
||||
add.runtime.exception.to.throws.family=Add Runtime Exception to Method Signature
|
||||
add.runtime.exception.to.throws.text=Add ''{0}'' to method signature
|
||||
add.runtime.exception.to.throws.family=Add runtime exception to method signature
|
||||
add.typecast.family=Add type cast
|
||||
add.typecast.text=Cast to ''{0}''
|
||||
# {1} = one of fix.expression.role.xyz values
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.ExceptionUtil;
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -15,6 +14,8 @@ import java.util.Collections;
|
||||
|
||||
public class AddRuntimeExceptionToThrowsAction implements IntentionAction {
|
||||
|
||||
private String myThrowsClause;
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return true;
|
||||
@@ -23,7 +24,7 @@ public class AddRuntimeExceptionToThrowsAction implements IntentionAction {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return QuickFixBundle.message("add.runtime.exception.to.throws.text");
|
||||
return QuickFixBundle.message("add.runtime.exception.to.throws.text", myThrowsClause);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,9 +58,10 @@ public class AddRuntimeExceptionToThrowsAction implements IntentionAction {
|
||||
if (exception == null) return false;
|
||||
|
||||
PsiMethod method = PsiTreeUtil.getParentOfType(elementAtCaret(editor, file), PsiMethod.class, true, PsiLambdaExpression.class);
|
||||
if (method == null || !method.getThrowsList().isPhysical()) return false;
|
||||
if (method == null || !method.getThrowsList().isPhysical() || isMethodThrows(method, exception)) return false;
|
||||
|
||||
return !isMethodThrows(method, exception);
|
||||
myThrowsClause = "throws " + exception.getPresentableText();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static PsiClassType getRuntimeExceptionAtCaret(Editor editor, PsiFile file) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add runtime exception(s) to method signature" "true-preview"
|
||||
// "Add 'throws RuntimeException' to method signature" "true-preview"
|
||||
class a {
|
||||
int f() throws RuntimeException {
|
||||
throw new RuntimeException()<caret>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add runtime exception(s) to method signature" "true-preview"
|
||||
// "Add 'throws RuntimeException' to method signature" "true-preview"
|
||||
class a {
|
||||
int f() {
|
||||
throw new RuntimeException()<caret>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add runtime exception(s) to method signature" "false"
|
||||
// "Add 'throws RuntimeException' to method signature" "false"
|
||||
class a {
|
||||
int f() throws RuntimeException{
|
||||
throw new RuntimeException()<caret>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add runtime exception(s) to method signature" "false"
|
||||
// "Add 'throws RuntimeException' to method signature" "false"
|
||||
class a {
|
||||
int f() {
|
||||
Runnable r = () -> {
|
||||
|
||||
Reference in New Issue
Block a user