From da3c033ab412799c4514a4146b17f95601797992 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Mon, 21 Jan 2013 13:57:59 +0400 Subject: [PATCH] IDEA-99196 Groovy: valueOf for Groovy enums with sinlge String arg --- .../resources/standardDsls/defaultMethods.gdsl | 4 ++++ .../groovy/lang/resolve/ResolveMethodTest.groovy | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/plugins/groovy/resources/standardDsls/defaultMethods.gdsl b/plugins/groovy/resources/standardDsls/defaultMethods.gdsl index 60e521aac122..8464717f2a01 100644 --- a/plugins/groovy/resources/standardDsls/defaultMethods.gdsl +++ b/plugins/groovy/resources/standardDsls/defaultMethods.gdsl @@ -86,3 +86,7 @@ contributor(ctype: 'groovy.lang.MetaClass') { property name: 'static' } +contributor(ctype: 'java.lang.Enum') { + method(type: psiClass.qualName, name: 'valueOf', params: [name: 'java.lang.String'], isStatic: true) +} + diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy index c81bf1663c46..677f72da379d 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy @@ -1494,4 +1494,18 @@ def 'a\\'bc'(){} "a'bc"() ''', GrMethod) } + + void testValueOf() { + final valueof = resolveByText('''\ +enum MyEnum { + FOO, BAR +} + + +MyEnum myEnum +myEnum = MyEnum.valueOf('FOO') +''', PsiMethod) + + assertEquals(valueof.parameterList.parametersCount, 1) + } }