mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-133994 Cannot resolve the default value of a stubbed annotation if the resolution is an inner enum
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi
|
||||
|
||||
import com.intellij.psi.impl.source.PsiFileImpl
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
|
||||
class JavaStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
public void "test resolve from annotation method defaule"() {
|
||||
def cls = myFixture.addClass("""
|
||||
public @interface BrokenAnnotation {
|
||||
|
||||
public enum Foo {
|
||||
DEFAULT,
|
||||
OTHER
|
||||
}
|
||||
|
||||
Foo value() default Foo.DEFAULT;
|
||||
}
|
||||
""")
|
||||
|
||||
def file = cls.containingFile as PsiFileImpl
|
||||
assert file.stub
|
||||
|
||||
def ref = (cls.methods[0] as PsiAnnotationMethod).defaultValue
|
||||
assert file.stub
|
||||
|
||||
assert ref instanceof PsiReferenceExpression
|
||||
assert ref.resolve() == cls.innerClasses[0].fields[0]
|
||||
assert file.stub
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user