JvmAnnotationAttributeValue.getSourceElement is removed between 192.5728.98 -> 192.5728.98
已回答
Hello,
In the Apache Camel plug-in we have a feature that can look up a logical bean name reference between a camel route and a bean, this is done by searching for all classes annotated with the specific annotation and checking the value parameter match the logical bean name. Since the value can be a PsiReferenceExpressionImpl to a PSIField with the static name we use the JvmAnnotationAttributeValue.getSourceElement, but it is removed with 2019.2
@Repository(value = CompleteJavaSpringRepositoryBeanTestData.JAVA_REPOSITORY_TEST_BEAN)
public class CompleteJavaSpringRepositoryBeanTestData {
static public String JAVA_REPOSITORY_TEST_BEAN = "myRepositoryBean";
...
}
This is how we do it today :
final PsiAnnotation classAnnotation = psiClass.getAnnotation(annotation);
final JvmAnnotationAttribute attribute = classAnnotation.findAttribute("value");
if (attribute != null) {
final PsiElement sourceElement = attribute.getAttributeValue().getSourceElement();
if (sourceElement instanceof PsiReferenceExpressionImpl) {
final PsiField psiField = (PsiField) sourceElement.getReference().resolve();
Since the "JvmAnnotationAttributeValue.getSourceElement" is removed, I am looking for another way to achieve this.
Thanks,
Flemming
请先登录再写评论。
Hi, sorry for removal of these methods, this API is incomplete (experimental) and this particular method was incorrect.
Please use
Thanks, it works perfectly