mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
[java] More tests for preview; minor fixes
GitOrigin-RevId: 7f72c5f68ab821e728eb0d5152f0910f48035046
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7a1f179f41
commit
9c6aeba5b4
@@ -4,12 +4,15 @@ package com.intellij.codeInspection;
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.ExternalAnnotationsManager;
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo;
|
||||
import com.intellij.codeInspection.nullable.AnnotateOverriddenMethodParameterFix;
|
||||
import com.intellij.java.analysis.JavaAnalysisBundle;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -47,6 +50,18 @@ public class RemoveAnnotationQuickFix implements LocalQuickFix {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull IntentionPreviewInfo generatePreview(@NotNull Project project, @NotNull ProblemDescriptor previewDescriptor) {
|
||||
PsiJavaFile file = ObjectUtils.tryCast(previewDescriptor.getStartElement().getContainingFile(), PsiJavaFile.class);
|
||||
if (file == null) return IntentionPreviewInfo.DIFF;
|
||||
PsiAnnotation annotation = myAnnotation.getElement();
|
||||
if (annotation == null || annotation.getContainingFile() != file.getOriginalFile()) return IntentionPreviewInfo.EMPTY;
|
||||
PsiAnnotation copy = PsiTreeUtil.findSameElementInCopy(annotation, file);
|
||||
copy.delete();
|
||||
JavaCodeStyleManager.getInstance(project).removeRedundantImports(file);
|
||||
return IntentionPreviewInfo.DIFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
PsiAnnotation annotation = myAnnotation.getElement();
|
||||
|
||||
@@ -52,12 +52,6 @@ public final class AddMethodBodyFix implements IntentionActionWithFixAllOption {
|
||||
BaseIntentionAction.canModify(myMethod);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElement getElementToMakeWritable(@NotNull PsiFile file) {
|
||||
return myMethod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
PsiUtil.setModifierProperty(myMethod, PsiModifier.ABSTRACT, false);
|
||||
|
||||
@@ -17,7 +17,7 @@ public class AddRuntimeExceptionToThrowsAction implements IntentionAction {
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,14 +28,15 @@ public class AddRuntimeExceptionToThrowsAction implements IntentionAction {
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, Editor editor, PsiFile file) {
|
||||
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
|
||||
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
PsiClassType aClass = getRuntimeExceptionAtCaret(editor, file);
|
||||
PsiMethod method = PsiTreeUtil.getParentOfType(elementAtCaret(editor, file), PsiMethod.class);
|
||||
|
||||
AddExceptionToThrowsFix.addExceptionsToThrowsList(project, method, Collections.singleton(aClass));
|
||||
if (method != null) {
|
||||
if (method.isPhysical()) {
|
||||
AddExceptionToThrowsFix.addExceptionsToThrowsList(project, method, Collections.singleton(aClass));
|
||||
} else {
|
||||
AddExceptionToThrowsFix.processMethod(project, method, Collections.singleton(aClass));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,4 +36,15 @@ public class AnnotationMethodReturnTypeFix extends MethodReturnTypeFix {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateMethodType(@NotNull PsiMethod method, @NotNull PsiType type) {
|
||||
super.updateMethodType(method, type);
|
||||
if (!myFromDefaultValue && method instanceof PsiAnnotationMethod) {
|
||||
PsiAnnotationMemberValue value = ((PsiAnnotationMethod)method).getDefaultValue();
|
||||
if (value != null) {
|
||||
new CommentTracker().deleteAndRestoreComments(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,11 +455,8 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle
|
||||
PsiFile containingFile = method.getContainingFile();
|
||||
if (containingFile == file.getOriginalFile()) {
|
||||
PsiMethod methodCopy = PsiTreeUtil.findSameElementInCopy(method, file);
|
||||
PsiTypeElement typeElement = methodCopy.getReturnTypeElement();
|
||||
if (typeElement != null) {
|
||||
typeElement.replace(PsiElementFactory.getInstance(project).createTypeElement(type));
|
||||
return IntentionPreviewInfo.DIFF;
|
||||
}
|
||||
updateMethodType(methodCopy, type);
|
||||
return IntentionPreviewInfo.DIFF;
|
||||
}
|
||||
PsiModifierList modifiers = method.getModifierList();
|
||||
String modifiersText = StreamEx.of(PsiModifier.MODIFIERS).filter(modifiers::hasExplicitModifier).map(mod -> mod + " ").joining();
|
||||
@@ -474,4 +471,11 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle
|
||||
String newText = modifiersText + newTypeText + name + "(" + parameters + ")";
|
||||
return new IntentionPreviewInfo.CustomDiff(JavaFileType.INSTANCE, containingFile.getName(), origText, newText);
|
||||
}
|
||||
|
||||
protected void updateMethodType(@NotNull PsiMethod method, @NotNull PsiType type) {
|
||||
PsiTypeElement typeElement = method.getReturnTypeElement();
|
||||
if (typeElement != null) {
|
||||
typeElement.replace(PsiElementFactory.getInstance(method.getProject()).createTypeElement(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,12 +125,12 @@ public class AddSingleMemberStaticImportAction extends BaseElementAtCaretIntenti
|
||||
}
|
||||
|
||||
private static PsiImportStatementBase findExistingImport(PsiFile file, PsiClass aClass, String refName) {
|
||||
if (file instanceof PsiJavaFile) {
|
||||
if (file instanceof PsiJavaFile && aClass != null) {
|
||||
PsiImportList importList = ((PsiJavaFile)file).getImportList();
|
||||
if (importList != null) {
|
||||
for (PsiImportStaticStatement staticStatement : importList.getImportStaticStatements()) {
|
||||
if (staticStatement.isOnDemand()) {
|
||||
if (staticStatement.resolveTargetClass() == aClass) {
|
||||
if (aClass.isEquivalentTo(staticStatement.resolveTargetClass())) {
|
||||
return staticStatement;
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class AddSingleMemberStaticImportAction extends BaseElementAtCaretIntenti
|
||||
|
||||
final PsiImportStatementBase importStatement = importList.findSingleImportStatement(refName);
|
||||
if (importStatement instanceof PsiImportStaticStatement &&
|
||||
((PsiImportStaticStatement)importStatement).resolveTargetClass() == aClass) {
|
||||
aClass.isEquivalentTo(((PsiImportStaticStatement)importStatement).resolveTargetClass())) {
|
||||
return importStatement;
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,7 @@ public class AddSingleMemberStaticImportAction extends BaseElementAtCaretIntenti
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
if (!Comparing.equal(reference.resolve(), referent)) {
|
||||
if (referent == null ? reference.resolve() != null : !referent.isEquivalentTo(reference.resolve())) {
|
||||
reference = rebind(reference, resolvedClass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'type='" "true"
|
||||
// "Add 'type='" "true-preview"
|
||||
class T {
|
||||
@interface A {
|
||||
String[] type();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'name='" "true"
|
||||
// "Add 'name='" "true-preview"
|
||||
class T {
|
||||
@interface A {
|
||||
int size();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'type='" "true"
|
||||
// "Add 'type='" "true-preview"
|
||||
class T {
|
||||
@interface A {
|
||||
String name();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'type='" "true"
|
||||
// "Add 'type='" "true-preview"
|
||||
class T {
|
||||
@interface A {
|
||||
String[] type();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'name='" "true"
|
||||
// "Add 'name='" "true-preview"
|
||||
class T {
|
||||
@interface A {
|
||||
int size();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'type='" "true"
|
||||
// "Add 'type='" "true-preview"
|
||||
class T {
|
||||
@interface A {
|
||||
String name();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make annotation applicable to fields" "true"
|
||||
// "Make annotation applicable to fields" "true-preview"
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make annotation applicable to fields" "true"
|
||||
// "Make annotation applicable to fields" "true-preview"
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make annotation applicable to fields" "true"
|
||||
// "Make annotation applicable to fields" "true-preview"
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make annotation applicable to fields" "true"
|
||||
// "Make annotation applicable to fields" "true-preview"
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make annotation applicable to type uses" "true"
|
||||
// "Make annotation applicable to type uses" "true-preview"
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make annotation applicable to fields" "true"
|
||||
// "Make annotation applicable to fields" "true-preview"
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make annotation applicable to fields" "true"
|
||||
// "Make annotation applicable to fields" "true-preview"
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make annotation applicable to fields" "true"
|
||||
// "Make annotation applicable to fields" "true-preview"
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make annotation applicable to fields" "true"
|
||||
// "Make annotation applicable to fields" "true-preview"
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make annotation applicable to type uses" "true"
|
||||
// "Make annotation applicable to type uses" "true-preview"
|
||||
import java.util.List;
|
||||
|
||||
@interface Foo {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'obj instanceof String'" "true"
|
||||
// "Assert 'obj instanceof String'" "true-preview"
|
||||
class X {
|
||||
void test(Object obj) {
|
||||
if (obj instanceof Integer) System.out.println();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'myFoo != null'" "true"
|
||||
// "Assert 'myFoo != null'" "true-preview"
|
||||
class A{
|
||||
private final String myFoo = Math.random() > 0.5 ? "" : null;
|
||||
String myBar;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'container != null'" "true"
|
||||
// "Assert 'container != null'" "true-preview"
|
||||
class A{
|
||||
void test(){
|
||||
Integer container = null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'list != null'" "true"
|
||||
// "Assert 'list != null'" "true-preview"
|
||||
import java.util.List;
|
||||
|
||||
class A{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'container != null'" "true"
|
||||
// "Assert 'container != null'" "true-preview"
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class A{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'foo != null'" "true"
|
||||
// "Assert 'foo != null'" "true-preview"
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'obj instanceof String'" "true"
|
||||
// "Assert 'obj instanceof String'" "true-preview"
|
||||
class X {
|
||||
void test(Object obj) {
|
||||
if (obj instanceof Integer) System.out.println();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'myFoo != null'" "true"
|
||||
// "Assert 'myFoo != null'" "true-preview"
|
||||
class A{
|
||||
private final String myFoo = Math.random() > 0.5 ? "" : null;
|
||||
String myBar = myFoo.su<caret>bstring(0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'container != null'" "true"
|
||||
// "Assert 'container != null'" "true-preview"
|
||||
class A{
|
||||
void test(){
|
||||
Integer container = null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'list != null'" "true"
|
||||
// "Assert 'list != null'" "true-preview"
|
||||
import java.util.List;
|
||||
|
||||
class A{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'container != null'" "true"
|
||||
// "Assert 'container != null'" "true-preview"
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class A{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Assert 'foo != null'" "true"
|
||||
// "Assert 'foo != null'" "true-preview"
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class a {
|
||||
void g() throws Exception {
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class a {
|
||||
void g() throws Exception {
|
||||
}
|
||||
|
||||
// initializer
|
||||
// initializer
|
||||
{
|
||||
try {
|
||||
// comment before
|
||||
// comment before
|
||||
g();
|
||||
// comment after
|
||||
// comment after
|
||||
} catch (Exception e) {
|
||||
<caret><selection>throw new RuntimeException(e);</selection>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class MyException1 extends Exception {}
|
||||
class MyException2 extends Exception {}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
import java.io.IOException;
|
||||
|
||||
class Test {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class Test {
|
||||
static class E1 extends Exception { }
|
||||
static class E2 extends Exception { }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class Test {
|
||||
static class E1 extends Exception { }
|
||||
static class E2 extends Exception { }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class CatchExceptions {
|
||||
|
||||
void foo() throws java.io.IOException, java.io.FileNotFoundException {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class Foo {
|
||||
void test(String s) {
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class Foo {
|
||||
void test(String s) {
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
import java.io.IOException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Surround with try/catch" "true"
|
||||
// "Surround with try/catch" "true-preview"
|
||||
class Test {
|
||||
|
||||
interface I<E extends Exception> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class a {
|
||||
void g() throws Exception {
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class a {
|
||||
void g() throws Exception {
|
||||
}
|
||||
|
||||
// initializer
|
||||
// initializer
|
||||
{
|
||||
try {
|
||||
// comment before
|
||||
// comment before
|
||||
<caret>g();
|
||||
// comment after
|
||||
// comment after
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class MyException1 extends Exception {}
|
||||
class MyException2 extends Exception {}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
import java.io.IOException;
|
||||
|
||||
class Test {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class Test {
|
||||
static class E1 extends Exception { }
|
||||
static class E2 extends Exception { }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class Test {
|
||||
static class E1 extends Exception { }
|
||||
static class E2 extends Exception { }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class CatchExceptions {
|
||||
|
||||
void foo() throws java.io.IOException, java.io.FileNotFoundException {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class Foo {
|
||||
void test(String s) {
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
class Foo {
|
||||
void test(String s) {
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'catch' clause(s)" "true"
|
||||
// "Add 'catch' clause(s)" "true-preview"
|
||||
import java.io.IOException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Surround with try/catch" "true"
|
||||
// "Surround with try/catch" "true-preview"
|
||||
class Test {
|
||||
|
||||
interface I<E extends Exception> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add package-private no-args constructor to X" "true"
|
||||
// "Add package-private no-args constructor to X" "true-preview"
|
||||
class X {
|
||||
X(int... a) {}
|
||||
X(String... b) {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add private no-args constructor to X" "true"
|
||||
// "Add private no-args constructor to X" "true-preview"
|
||||
class Z {
|
||||
private class X {
|
||||
X(int... a) {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add public no-args constructor to X" "true"
|
||||
// "Add public no-args constructor to X" "true-preview"
|
||||
public class X {
|
||||
X(int... a) {}
|
||||
X(String... b) {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add protected no-args constructor to X" "true"
|
||||
// "Add protected no-args constructor to X" "true-preview"
|
||||
public abstract class X {
|
||||
protected X(int... a) {}
|
||||
public X(String... b) {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add package-private no-args constructor to X" "true"
|
||||
// "Add package-private no-args constructor to X" "true-preview"
|
||||
class X {
|
||||
X(int... a) {}
|
||||
X(String... b) {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add private no-args constructor to X" "true"
|
||||
// "Add private no-args constructor to X" "true-preview"
|
||||
class Z {
|
||||
private class X {
|
||||
X(int... a) {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add public no-args constructor to X" "true"
|
||||
// "Add public no-args constructor to X" "true-preview"
|
||||
public class X {
|
||||
X(int... a) {}
|
||||
X(String... b) {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add protected no-args constructor to X" "true"
|
||||
// "Add protected no-args constructor to X" "true-preview"
|
||||
public abstract class X {
|
||||
protected X(int... a) {}
|
||||
public X(String... b) {}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// "Insert '()'" "true"
|
||||
// "Insert '()'" "true-preview"
|
||||
|
||||
record A() {}
|
||||
@@ -1,3 +1,3 @@
|
||||
// "Insert '()'" "true"
|
||||
// "Insert '()'" "true-preview"
|
||||
|
||||
record <caret>A {}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace 'C' with more generic 'A'" "true"
|
||||
// "Replace 'C' with more generic 'A'" "true-preview"
|
||||
import java.io.Exception;
|
||||
|
||||
class A extends Exception {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add exception to existing catch clause" "true"
|
||||
// "Add exception to existing catch clause" "true-preview"
|
||||
import java.io.IOException;
|
||||
|
||||
class A extends Exception {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace 'C | D | B' with more generic 'A'" "true"
|
||||
// "Replace 'C | D | B' with more generic 'A'" "true-preview"
|
||||
import java.io.IOException;
|
||||
|
||||
class A extends Exception {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add exception to existing catch clause" "true"
|
||||
// "Add exception to existing catch clause" "true-preview"
|
||||
import java.io.IOException;
|
||||
|
||||
class X extends RuntimeException {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add exception to existing catch clause" "true"
|
||||
// "Add exception to existing catch clause" "true-preview"
|
||||
import java.io.IOException;
|
||||
|
||||
class X extends RuntimeException {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'IOException' to catch with 'IndexOutOfBoundsException'" "true"
|
||||
// "Add 'IOException' to catch with 'IndexOutOfBoundsException'" "true-preview"
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace 'C' with more generic 'A'" "true"
|
||||
// "Replace 'C' with more generic 'A'" "true-preview"
|
||||
import java.io.Exception;
|
||||
|
||||
class A extends Exception {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add exception to existing catch clause" "true"
|
||||
// "Add exception to existing catch clause" "true-preview"
|
||||
import java.io.IOException;
|
||||
|
||||
class A extends Exception {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace 'C | D | B' with more generic 'A'" "true"
|
||||
// "Replace 'C | D | B' with more generic 'A'" "true-preview"
|
||||
import java.io.IOException;
|
||||
|
||||
class A extends Exception {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add exception to existing catch clause" "true"
|
||||
// "Add exception to existing catch clause" "true-preview"
|
||||
import java.io.IOException;
|
||||
|
||||
class X extends RuntimeException {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add exception to existing catch clause" "true"
|
||||
// "Add exception to existing catch clause" "true-preview"
|
||||
import java.io.IOException;
|
||||
|
||||
class X extends RuntimeException {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'IOException' to catch with 'IndexOutOfBoundsException'" "true"
|
||||
// "Add 'IOException' to catch with 'IndexOutOfBoundsException'" "true-preview"
|
||||
import java.io.File;
|
||||
|
||||
class Test {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace 'FileNotFoundException' with more generic 'IOException'" "true"
|
||||
// "Replace 'FileNotFoundException' with more generic 'IOException'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace 'E1' with more generic 'E'" "true"
|
||||
// "Replace 'E1' with more generic 'E'" "true-preview"
|
||||
class C {
|
||||
static class E extends Exception { }
|
||||
static class E1 extends E { }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace 'FileNotFoundException' with more generic 'IOException'" "true"
|
||||
// "Replace 'FileNotFoundException' with more generic 'IOException'" "true-preview"
|
||||
import java.io.*;
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace 'E1' with more generic 'E'" "true"
|
||||
// "Replace 'E1' with more generic 'E'" "true-preview"
|
||||
class C {
|
||||
static class E extends Exception { }
|
||||
static class E1 extends E { }
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Add exception to existing catch clause" "true-preview"
|
||||
import java.io.IOException;
|
||||
|
||||
class X extends RuntimeException {}
|
||||
class Y extends RuntimeException {}
|
||||
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
try {
|
||||
throw new IOException();
|
||||
}
|
||||
catch (X | IOException x) {
|
||||
}
|
||||
}
|
||||
catch (Y y) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'finally' block" "true"
|
||||
// "Add 'finally' block" "true-preview"
|
||||
class Test {
|
||||
void foo() {
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add 'finally' block" "true"
|
||||
// "Add 'finally' block" "true-preview"
|
||||
class Test {
|
||||
void foo() {
|
||||
try {}<caret>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add method body" "true"
|
||||
// "Add method body" "true-preview"
|
||||
class a {
|
||||
void f() {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add method body" "true"
|
||||
// "Add method body" "true-preview"
|
||||
class a {
|
||||
String f() {
|
||||
<caret><selection>return null;</selection>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add method body" "true"
|
||||
// "Add method body" "true-preview"
|
||||
class a {
|
||||
a() {
|
||||
<caret><selection></selection>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add method body" "true"
|
||||
// "Add method body" "true-preview"
|
||||
class a {
|
||||
String f() {
|
||||
<caret><selection>return null;</selection>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add method body" "true"
|
||||
// "Add method body" "true-preview"
|
||||
interface a {
|
||||
default String f() {
|
||||
<selection>return null;</selection>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make 'a.f' not abstract" "true"
|
||||
// "Make 'a.f' not abstract" "true-preview"
|
||||
interface a {
|
||||
default String f() {
|
||||
return null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add method body" "true"
|
||||
// "Add method body" "true-preview"
|
||||
class a {
|
||||
<caret>void f();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add method body" "true"
|
||||
// "Add method body" "true-preview"
|
||||
class a {
|
||||
<caret>String f();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add method body" "true"
|
||||
// "Add method body" "true-preview"
|
||||
class a {
|
||||
<caret>a();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add method body" "true"
|
||||
// "Add method body" "true-preview"
|
||||
class a {
|
||||
<caret>abstract String f();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add method body" "true"
|
||||
// "Add method body" "true-preview"
|
||||
interface a {
|
||||
default <caret>String f();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Make 'a.f' not abstract" "true"
|
||||
// "Make 'a.f' not abstract" "true-preview"
|
||||
interface a {
|
||||
String f();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add missing annotation parameters - value3, value2, value1" "true"
|
||||
// "Add missing annotation parameters - value3, value2, value1" "true-preview"
|
||||
class Test {
|
||||
|
||||
@MyAnnotation(value3 = "", value2 = "", value1 = "")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add missing annotation parameters - value4, value1" "true"
|
||||
// "Add missing annotation parameters - value4, value1" "true-preview"
|
||||
class Test {
|
||||
|
||||
@MyAnnotation(value4 = {}, value3 = "", value2 = "", value1 = {})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Add missing annotation parameters - value4, value3, value2, value1" "true"
|
||||
// "Add missing annotation parameters - value4, value3, value2, value1" "true-preview"
|
||||
class Test {
|
||||
|
||||
@MyAnnotation(value = "xxx", value4 = "", value3 = "", value2 = "", value1 = "")
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user