IDEA-99194 Groovy: valueOf of Groovy enum should be available in Java code

This commit is contained in:
Max Medvedev
2014-03-18 17:21:54 +04:00
parent 7476283ebf
commit 4d206946e8
2 changed files with 11 additions and 8 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,8 +63,3 @@ contributor(ctype:"groovy.lang.GString") {
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)
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -133,7 +133,7 @@ public class GrEnumTypeDefinitionImpl extends GrTypeDefinitionImpl implements Gr
return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiMethod[]>() {
@Override
public Result<PsiMethod[]> compute() {
PsiMethod[] defMethods = new PsiMethod[3];
PsiMethod[] defMethods = new PsiMethod[4];
final PsiManagerEx manager = getManager();
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(getProject());
defMethods[0] = new LightMethodBuilder(manager, GROOVY_LANGUAGE, "values")
@@ -151,6 +151,14 @@ public class GrEnumTypeDefinitionImpl extends GrTypeDefinitionImpl implements Gr
.setMethodReturnType(factory.createType(GrEnumTypeDefinitionImpl.this))
.setContainingClass(GrEnumTypeDefinitionImpl.this)
.addModifier(PsiModifier.PUBLIC);
defMethods[3] = new LightMethodBuilder(manager, GROOVY_LANGUAGE, "valueOf")
.setMethodReturnType(factory.createType(GrEnumTypeDefinitionImpl.this))
.setContainingClass(GrEnumTypeDefinitionImpl.this)
.addParameter("name", CommonClassNames.JAVA_LANG_STRING)
.addModifier(PsiModifier.PUBLIC)
.addModifier(PsiModifier.STATIC);
return Result.create(defMethods, GrEnumTypeDefinitionImpl.this);
}
});