From b61c20a09d9d80186da6d36e0c0336660d25f0b5 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 2 Mar 2012 12:09:13 +0400 Subject: [PATCH] EA-34054 - assert: JUnitUtil.isTestMethodOrConfig --- .../src/com/intellij/execution/junit/JUnitUtil.java | 2 +- plugins/groovy/jetgroovy.iml | 1 + .../groovy/lang/GroovyHighlightingTest.groovy | 5 +++++ .../highlighting/GloballyUnusedInnerMethods.groovy | 12 ++++++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 plugins/groovy/testdata/highlighting/GloballyUnusedInnerMethods.groovy diff --git a/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java b/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java index 617eafad2459..6c38b54e9d93 100644 --- a/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java +++ b/java/execution/impl/src/com/intellij/execution/junit/JUnitUtil.java @@ -195,7 +195,7 @@ public class JUnitUtil { } public static boolean isTestMethodOrConfig(@NotNull PsiMethod psiMethod) { - if (getTestMethod(psiMethod, false) != null) { + if (isTestMethod(PsiLocation.fromPsiElement(psiMethod), false)) { final PsiClass containingClass = psiMethod.getContainingClass(); assert containingClass != null : psiMethod + "; " + psiMethod.getClass() + "; " + psiMethod.getParent(); if (containingClass.hasModifierProperty(PsiModifier.ABSTRACT)) { diff --git a/plugins/groovy/jetgroovy.iml b/plugins/groovy/jetgroovy.iml index fad3ca67ea89..9e76e222a152 100644 --- a/plugins/groovy/jetgroovy.iml +++ b/plugins/groovy/jetgroovy.iml @@ -32,6 +32,7 @@ + diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy index bad29401c92a..1f884636fffc 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy @@ -669,6 +669,11 @@ List list2 doTest(new GroovyUnusedDeclarationInspection(), new UnusedDeclarationInspection()) } + public void testGloballyUnusedInnerMethods() { + myFixture.addClass 'package junit.framework; public class TestCase {}' + doTest(new GroovyUnusedDeclarationInspection(), new UnusedDeclarationInspection()) + } + public void testAliasInParameterType() { myFixture.configureByText('a_.groovy', '''\ import java.awt.event.ActionListener diff --git a/plugins/groovy/testdata/highlighting/GloballyUnusedInnerMethods.groovy b/plugins/groovy/testdata/highlighting/GloballyUnusedInnerMethods.groovy new file mode 100644 index 000000000000..9aeda49b2624 --- /dev/null +++ b/plugins/groovy/testdata/highlighting/GloballyUnusedInnerMethods.groovy @@ -0,0 +1,12 @@ +import junit.framework.TestCase + +class Doo extends TestCase { + void testBar() { + void foo() { + + } + } + + void foo() {} +} +