IDEA-133994 Cannot resolve the default value of a stubbed annotation if the resolution is an inner enum

This commit is contained in:
peter
2015-01-05 16:09:07 +01:00
parent 2a5be6d0ff
commit 6a91c7ebd4
2 changed files with 48 additions and 5 deletions
@@ -15,7 +15,6 @@
*/
package com.intellij.psi.impl.source;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
@@ -62,10 +61,7 @@ public class PsiAnnotationMethodImpl extends PsiMethodImpl implements PsiAnnotat
return value;
}
@NonNls final String annoText = "@interface _Dummy_ { " + getReturnType() + " " + getName() + "() default " + text + "; }";
final PsiFileFactory factory = PsiFileFactory.getInstance(getProject());
final PsiJavaFile file = (PsiJavaFile)factory.createFileFromText("a.java", JavaFileType.INSTANCE, annoText);
value = ((PsiAnnotationMethod)file.getClasses()[0].getMethods()[0]).getDefaultValue();
value = JavaPsiFacade.getElementFactory(getProject()).createAnnotationFromText("@Foo(" + text + ")", this).findAttributeValue(null);
myCachedDefaultValue = new SoftReference<PsiAnnotationMemberValue>(value);
return value;
}