mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract getStringAttributeValue(PsiAnnotationMemberValue)
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -480,9 +478,9 @@ public class AnnotationUtil {
|
||||
@Nullable
|
||||
public static String getStringAttributeValue(@NotNull PsiAnnotation anno, @Nullable final String attributeName) {
|
||||
PsiAnnotationMemberValue attrValue = anno.findAttributeValue(attributeName);
|
||||
Object constValue = JavaPsiFacade.getInstance(anno.getProject()).getConstantEvaluationHelper().computeConstantExpression(attrValue);
|
||||
return constValue instanceof String ? (String)constValue : null;
|
||||
return attrValue == null ? null : getStringAttributeValue(attrValue);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Boolean getBooleanAttributeValue(@NotNull PsiAnnotation anno, @Nullable final String attributeName) {
|
||||
PsiAnnotationMemberValue attrValue = anno.findAttributeValue(attributeName);
|
||||
@@ -500,7 +498,13 @@ public class AnnotationUtil {
|
||||
@Nullable
|
||||
public static String getDeclaredStringAttributeValue(@NotNull PsiAnnotation anno, @Nullable final String attributeName) {
|
||||
PsiAnnotationMemberValue attrValue = anno.findDeclaredAttributeValue(attributeName);
|
||||
Object constValue = JavaPsiFacade.getInstance(anno.getProject()).getConstantEvaluationHelper().computeConstantExpression(attrValue);
|
||||
return attrValue == null ? null : getStringAttributeValue(attrValue);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getStringAttributeValue(@NotNull PsiAnnotationMemberValue attrValue) {
|
||||
PsiConstantEvaluationHelper evaluationHelper = JavaPsiFacade.getInstance(attrValue.getProject()).getConstantEvaluationHelper();
|
||||
Object constValue = evaluationHelper.computeConstantExpression(attrValue);
|
||||
return constValue instanceof String ? (String)constValue : null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user