Esempio n. 1
0
 public <T extends lombok.ast.pg.IType<?, ?, ?, ?, ?, ?>> T memberType(final String typeName) {
   for (EclipseNode child : node().down()) {
     if (child.getKind() != Kind.TYPE) continue;
     if (child.getName().equals(typeName)) {
       return Cast.<T>uncheckedCast(EclipseType.typeOf(child, source));
     }
   }
   throw new IllegalArgumentException();
 }
  @Override
  public void handle(
      AnnotationValues<MVCAware> annotation, Annotation source, EclipseNode annotationNode) {
    EclipseType type = EclipseType.typeOf(annotationNode, source);
    if (type.isAnnotation() || type.isInterface()) {
      annotationNode.addError(canBeUsedOnClassAndEnumOnly(MVCAware.class));
      return;
    }

    EclipseUtil.addInterface(type.get(), MVCAwareConstants.MVC_HANDLER_TYPE, source);
    handler.addMVCSupport(type);
    type.editor().rebuild();
  }
Esempio n. 3
0
  @Override
  public void handle(
      final AnnotationValues<EnumId> annotation,
      final Annotation source,
      final EclipseNode annotationNode) {
    EclipseType type = EclipseType.typeOf(annotationNode, source);
    EclipseField field = EclipseField.fieldOf(annotationNode, source);
    if (field == null) {
      annotationNode.addError(canBeUsedOnFieldOnly(EnumId.class));
      return;
    }

    new EnumIdHandler<EclipseType, EclipseField>(type, field, annotationNode).handle();
  }
  @Override
  public void handle(
      AnnotationValues<CassandraAware> annotation, Annotation source, EclipseNode annotationNode) {
    EclipseType type = EclipseType.typeOf(annotationNode, source);
    if (type.isAnnotation() || type.isInterface()) {
      annotationNode.addError(canBeUsedOnClassAndEnumOnly(CassandraAware.class));
      return;
    }

    EclipseUtil.addInterface(
        type.get(), CassandraAwareConstants.CASSANDRA_CONTRIBUTION_HANDLER_TYPE, source);
    handler.addCassandraProviderField(type);
    handler.addCassandraProviderAccessors(type);
    handler.addCassandraContributionMethods(type);
    type.editor().rebuild();
  }
Esempio n. 5
0
 public static boolean onClassScope_buildFieldsAndMethods(final ClassScope scope) {
   TypeDeclaration decl = scope.referenceContext;
   final EclipseNode typeNode = getTypeNode(decl);
   if (typeNode != null) {
     final EclipseType type = EclipseType.typeOf(typeNode, decl);
     for (EclipseMethod method : type.methods()) {
       final Annotation ann = getAnnotation(Function.class, method.get().annotations);
       if (ann != null) {
         completeNode(typeNode);
         EclipseNode annotationNode = typeNode.getNodeFor(ann);
         try {
           new HandleFunction()
               .handle(createAnnotation(Function.class, annotationNode), ann, annotationNode);
         } catch (AnnotationValueDecodeFail fail) {
           fail.owner.setError(fail.getMessage(), fail.idx);
         }
       }
     }
   }
   return false;
 }
Esempio n. 6
0
 public <T extends IType<?, ?, ?, ?, ?, ?>> T surroundingType() {
   final EclipseNode parent = node().directUp();
   if (parent == null) return null;
   return Cast.<T>uncheckedCast(EclipseType.typeOf(parent, source));
 }