コード例 #1
0
  @NotNull
  private Annotations addExtensionFunctionTypeAnnotation(@NotNull Annotations annotations) {
    if (annotations.findAnnotation(FQ_NAMES.extensionFunctionType) != null) return annotations;

    // TODO: preserve laziness of given annotations
    return new AnnotationsImpl(plus(annotations, listOf(createExtensionAnnotation())));
  }
コード例 #2
0
 public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
   if (Annotations.isNewRelicAnnotation(desc)) {
     this.log.info(
         MessageFormat.format(
             "[{0}] class has New Relic tag: {1}",
             new Object[] {this.context.getClassName(), desc}));
     this.context.addTag(desc);
   }
   return null;
 }
コード例 #3
0
  private static boolean containsAnnotation(
      DeclarationDescriptor descriptor, FqName annotationClassFqName) {
    DeclarationDescriptor original = descriptor.getOriginal();
    Annotations annotations = original.getAnnotations();

    if (annotations.findAnnotation(annotationClassFqName) != null) return true;

    AnnotationUseSiteTarget associatedUseSiteTarget =
        AnnotationUseSiteTarget.Companion.getAssociatedUseSiteTarget(descriptor);
    if (associatedUseSiteTarget != null) {
      if (Annotations.Companion.findUseSiteTargetedAnnotation(
              annotations, associatedUseSiteTarget, annotationClassFqName)
          != null) {
        return true;
      }
    }

    return false;
  }
コード例 #4
0
 static int getIntegralSize(Type type, Class typec, Annotations annotations) {
   if (type == int.class || type == Integer.class) {
     return 4;
   }
   if (type == long.class || type == Long.class) {
     if (annotations != null) {
       if (annotations.isAnnotationPresent(Ptr.class)) {
         return SizeT.SIZE;
       }
       if (annotations.isAnnotationPresent(org.bridj.ann.CLong.class)) {
         return CLong.SIZE;
       }
     }
     return 8;
   }
   if (type == CLong.class) {
     return CLong.SIZE;
   }
   if (type == SizeT.class) {
     return SizeT.SIZE;
   }
   if (type == TimeT.class) {
     return TimeT.SIZE;
   }
   if (type == byte.class || type == Byte.class) {
     return 1;
   }
   if (type == char.class
       || type == Character.class
       || type == short.class
       || type == Short.class) {
     return 2;
   }
   if (ValuedEnum.class.isAssignableFrom(typec)) {
     return 4;
   }
   if (Pointer.class.isAssignableFrom(typec)) {
     return SizeT.SIZE;
   }
   return -1;
 }
コード例 #5
0
ファイル: NamedType.java プロジェクト: alisheikh/msgcodec
 @Override
 public String toString() {
   StringBuilder str = new StringBuilder();
   if (!annotations.isEmpty()) {
     for (Entry<String, String> ann : annotations.entrySet()) {
       str.append(Annotations.toString(ann.getKey(), ann.getValue()));
       str.append('\n');
     }
   }
   str.append(name).append(" = ").append(type.toString()).append("\n");
   return str.toString();
 }
コード例 #6
0
  public static void main(String[] args) {
    try {
      String content = "Java How to Program Book Paul Deitel Harvey Deitel";
      Annotations annotations = new Annotations();
      annotations.add(new Annotation(0, content.length(), "content"));
      annotations.add(new Annotation(0, content.length(), "content1"));
      annotations.add(new Annotation(0, 19, "title"));
      annotations.add(new Annotation(0, 19, "title1"));
      annotations.add(new Annotation(17, 40, "overlap1"));
      annotations.add(new Annotation(38, 45, "overlap2"));
      annotations.add(new Annotation(37, 50, "author"));

      annotations.sort();

      for (Annotation s : annotations) {
        System.out.println(s.start + " " + s.end + "  " + s.annotation);
      }

    } catch (InvalidAnnotationException ex) {
      ex.printStackTrace();
    }

    System.out.println("Inserted");
  }
コード例 #7
0
 public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
   return annotations.isAnnotationPresent(annotationClass);
 }
コード例 #8
0
 public Annotation[] getDeclaredAnnotations() {
   return annotations.getDeclaredAnnotations();
 }
コード例 #9
0
 public Annotation[] getAnnotations() {
   return annotations.getAnnotations();
 }
コード例 #10
0
 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
   return annotations.getAnnotation(annotationClass);
 }
コード例 #11
0
ファイル: NamedType.java プロジェクト: alisheikh/msgcodec
 @Override
 public NamedType addAnnotations(Annotations annotations) {
   Map<String, String> newAnnotations = new HashMap<>(this.annotations);
   newAnnotations.putAll(annotations.map());
   return new NamedType(name, type, newAnnotations);
 }
コード例 #12
0
ファイル: NamedType.java プロジェクト: alisheikh/msgcodec
 @Override
 public NamedType replaceAnnotations(Annotations annotations) {
   return new NamedType(name, type, annotations.map());
 }
コード例 #13
0
 private boolean isValidAnnotation(final TypeElement annotation) {
   final String name = annotation.getQualifiedName().toString();
   return (name.equals(annotations.messageBundle().getName())
       || name.equals(annotations.messageLogger().getName()));
 }
コード例 #14
0
 /**
  * Creates a new element locator.
  *
  * @param driver The driver to use when finding the element
  * @param field The field on the Page Object that will hold the located value
  */
 public DefaultElementLocator(WebDriver driver, Field field) {
   this.driver = driver;
   Annotations annotations = new Annotations(field);
   cacheElement = annotations.isLookupCached();
   by = annotations.buildBy();
 }