mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: test conflict warnings on inheritors (IJ-CR-120227)
GitOrigin-RevId: 1d79b300e30699cd544055deea2124f97ea66218
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2625546a26
commit
9c6f41248b
@@ -0,0 +1,24 @@
|
||||
interface Probable {}
|
||||
interface Something<caret> extends Probable {
|
||||
void run();
|
||||
}
|
||||
class AX {
|
||||
void x() {
|
||||
Something s = () -> {};
|
||||
}
|
||||
}
|
||||
interface SomethingSub extends Something {}
|
||||
record SomethingElse() implements Something {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
enum SomethingEnum implements Something {
|
||||
;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
interface Probable {}
|
||||
abstract static class Something implements Probable {
|
||||
public abstract void run();
|
||||
}
|
||||
class AX {
|
||||
void x() {
|
||||
Something s = () -> {};
|
||||
}
|
||||
}
|
||||
interface SomethingSub extends Something {}
|
||||
record SomethingElse() implements Something {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
enum SomethingEnum extends Something {
|
||||
;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
+13
-3
@@ -8,7 +8,7 @@ import com.siyeh.IntentionPowerPackBundle;
|
||||
import com.siyeh.ipp.IPPTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ConvertInterfaceToClassTest extends IPPTestCase {
|
||||
public void testBasic() { doTest(); }
|
||||
@@ -20,17 +20,27 @@ public class ConvertInterfaceToClassTest extends IPPTestCase {
|
||||
|
||||
public void testFunctionalExpressions() {
|
||||
UiInterceptors.register(new ConflictInterceptor(
|
||||
List.of("() -> {...} in Test will not compile after converting interface <b><code>FunctionalExpressions</code></b> to a class")));
|
||||
Set.of("() -> {...} in Test will not compile after converting interface <b><code>FunctionalExpressions</code></b> to a class")));
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testExtendsConflict() {
|
||||
UiInterceptors.register(new ConflictInterceptor(
|
||||
List.of("class <b><code>AaaImpl</code></b> implementing interface <b><code>Aaa</code></b> already extends class " +
|
||||
Set.of("class <b><code>AaaImpl</code></b> implementing interface <b><code>Aaa</code></b> already extends class " +
|
||||
"<b><code>Bbb</code></b> and will not compile after converting interface <b><code>Aaa</code></b> to a class")));
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInheritorWarnings() {
|
||||
UiInterceptors.register(new ConflictInterceptor(
|
||||
Set.of(
|
||||
"() -> {...} in x() in InheritorWarnings.AX will not compile after converting interface <b><code>InheritorWarnings.Something</code></b> to a class",
|
||||
"enum <b><code>InheritorWarnings.SomethingEnum</code></b> implementing interface <b><code>InheritorWarnings.Something</code></b> will not compile after converting interface <b><code>InheritorWarnings.Something</code></b> to a class",
|
||||
"interface <b><code>InheritorWarnings.SomethingSub</code></b> implementing interface <b><code>InheritorWarnings.Something</code></b> will not compile after converting interface <b><code>InheritorWarnings.Something</code></b> to a class"
|
||||
)));
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFunctionalInterface() {
|
||||
assertIntentionNotAvailable();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// 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.refactoring.ui;
|
||||
|
||||
import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector;
|
||||
@@ -33,7 +32,7 @@ import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ConflictsDialog extends DialogWrapper implements ConflictsDialogBase {
|
||||
@@ -91,8 +90,8 @@ public class ConflictsDialog extends DialogWrapper implements ConflictsDialogBas
|
||||
init();
|
||||
}
|
||||
|
||||
public List<String> getConflictDescriptions() {
|
||||
return List.of(myConflictDescriptions);
|
||||
public Set<String> getConflictDescriptions() {
|
||||
return Set.of(myConflictDescriptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,7 @@ package com.intellij.ui;
|
||||
import com.intellij.refactoring.ui.ConflictsDialog;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -12,12 +12,12 @@ import static org.junit.Assert.assertEquals;
|
||||
* An interceptor that expects a conflict dialog. An interceptor assumes that "Continue" button will be pressed
|
||||
*/
|
||||
public class ConflictInterceptor extends UiInterceptors.UiInterceptor<ConflictsDialog> {
|
||||
private final List<String> myConflicts;
|
||||
private final Set<String> myConflicts;
|
||||
|
||||
/**
|
||||
* @param expectedConflicts list of expected conflicts
|
||||
*/
|
||||
public ConflictInterceptor(List<String> expectedConflicts) {
|
||||
public ConflictInterceptor(Set<String> expectedConflicts) {
|
||||
super(ConflictsDialog.class);
|
||||
myConflicts = expectedConflicts;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user