Ejemplo n.º 1
0
  public static String getAttributeValue(
      PsiAnnotation annotation, String attributeName, DefaultPolicy policy) {
    final PsiAnnotationMemberValue value = getAnnotationMemberValue(annotation, attributeName);
    if (value != null) {
      if (value instanceof PsiClassObjectAccessExpression) {
        final PsiType type = ((PsiClassObjectAccessExpression) value).getType();
        if (type == null) {
          return null;
        }
        return type.getCanonicalText();
      } else {
        final String text = value.getText();
        return text.substring(1, text.length() - 1);
      }
    }

    if (policy == DefaultPolicy.OWNER_IDENTIFIER_NAME) {
      return PsiUtil.getName(getImmediateOwnerElement(annotation));
    } else {
      return null;
    }
  }