diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/ClashingTraitMethodsTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/ClashingTraitMethodsTest.java index 16cfe6775b11..a54c33e92d7e 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/ClashingTraitMethodsTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/ClashingTraitMethodsTest.java @@ -1,130 +1,132 @@ -// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package org.jetbrains.plugins.groovy.lang.highlighting +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package org.jetbrains.plugins.groovy.lang.highlighting; -import com.intellij.codeInspection.InspectionProfileEntry -import com.intellij.testFramework.LightProjectDescriptor -import org.jetbrains.plugins.groovy.GroovyProjectDescriptors -import org.jetbrains.plugins.groovy.codeInspection.confusing.ClashingTraitMethodsInspection +import com.intellij.codeInspection.InspectionProfileEntry; +import com.intellij.testFramework.LightProjectDescriptor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.GroovyProjectDescriptors; +import org.jetbrains.plugins.groovy.codeInspection.confusing.ClashingTraitMethodsInspection; /** * Created by Max Medvedev on 09/06/14 */ -class ClashingTraitMethodsTest extends GrHighlightingTestBase { +public class ClashingTraitMethodsTest extends GrHighlightingTestBase { + @Override + public InspectionProfileEntry[] getCustomInspections() { + return new ClashingTraitMethodsInspection[]{new ClashingTraitMethodsInspection()}; + } - final LightProjectDescriptor projectDescriptor = GroovyProjectDescriptors.GROOVY_3_0 + public void testClash() { + doTestHighlighting(""" + trait T1 { + def foo(){} + } + + trait T2 { + def foo(){} + } + + class A implements T1, T2 { + + } + """); + } + + public void testCustomImplementationNoClash() { + doTestHighlighting(""" + trait T1 { + def foo(){} + } + + trait T2 { + def foo(){} + } + + class A implements T1, T2 { + def foo() {} + } + """); + } + + public void testNoClash() { + doTestHighlighting(""" + trait T1 { + def foo(){} + } + + trait T2 { + abstract def foo() + } + + class A implements T1, T2 { + } + """); + } + + public void testNoClashWithInterface() { + doTestHighlighting(""" + trait T1 { + def foo(){} + } + + interface T2 { + def foo() + } + + class A implements T1, T2 { + } + """); + } + + public void testClashWithDefaultMethodInterfaces() { + doTestHighlighting(""" + interface T1 { + default foo(){} + } + + interface T2 { + default foo() {} + } + + class A implements T1, T2 { + } + """); + } + + public void testClashTraitWithDefaultMethodInterface() { + doTestHighlighting(""" + trait T1 { + def foo(){} + } + + interface T2 { + default foo() {} + } + + class A implements T1, T2 { + } + """); + } + + public void testNoClashInInheritor() { + doTestHighlighting(""" + trait T1 { + def foo(){} + } + + interface T2 { + def foo() + } + + class A implements T1, T2 { + } + + class B extends A{} + """); + } @Override - InspectionProfileEntry[] getCustomInspections() { - [new ClashingTraitMethodsInspection()] - } - - void testClash() { - doTestHighlighting(''' -trait T1 { - def foo(){} -} - -trait T2 { - def foo(){} -} - -class A implements T1, T2 { - -} -''') - } - - void testCustomImplementationNoClash() { - doTestHighlighting(''' -trait T1 { - def foo(){} -} - -trait T2 { - def foo(){} -} - -class A implements T1, T2 { - def foo() {} -} -''') - } - - void testNoClash() { - doTestHighlighting(''' -trait T1 { - def foo(){} -} - -trait T2 { - abstract def foo() -} - -class A implements T1, T2 { -} -''') - } - - void testNoClashWithInterface() { - doTestHighlighting(''' -trait T1 { - def foo(){} -} - -interface T2 { - def foo() -} - -class A implements T1, T2 { -} -''') - } - - void testClashWithDefaultMethodInterfaces() { - doTestHighlighting(''' -interface T1 { - default foo(){} -} - -interface T2 { - default foo() {} -} - -class A implements T1, T2 { -} -''') - } - - void testClashTraitWithDefaultMethodInterface() { - doTestHighlighting(''' -trait T1 { - def foo(){} -} - -interface T2 { - default foo() {} -} - -class A implements T1, T2 { -} -''') - } - - - void testNoClashInInheritor() { - doTestHighlighting(''' -trait T1 { - def foo(){} -} - -interface T2 { - def foo() -} - -class A implements T1, T2 { -} - -class B extends A{} -''') + public final @NotNull LightProjectDescriptor getProjectDescriptor() { + return GroovyProjectDescriptors.GROOVY_3_0; } }