Exemplo n.º 1
0
  private void genMetaForPty(
      MethodDeclaration astNode, final JstType jstType, final Annotation anno) {

    CustomType cType = getCustomType(jstType);
    MethodKey mtdKey = MethodKey.genMethodKey(astNode);
    CustomMethod cMtd = cType.getCustomMethod(mtdKey);
    if (cMtd == null) {
      cMtd = new CustomMethod(mtdKey);
      cType.addCustomMethod(cMtd);
    }

    cMtd.setIsProperty(true);

    if (anno instanceof NormalAnnotation) {
      NormalAnnotation normalAnno = (NormalAnnotation) anno;
      List<?> annos = normalAnno.values();
      MemberValuePair pair = (MemberValuePair) annos.get(0);
      String name = getValue(pair.getValue(), astNode, jstType);
      if (name != null) {
        cMtd.setJstName(name);
        return;
      }
    }

    String mtdName = cMtd.getJstName();
    if (mtdName.startsWith("get")) {
      mtdName = mtdName.substring(3, 4).toLowerCase() + mtdName.substring(4, mtdName.length());
      cMtd.setJstName(mtdName);
    } else if (mtdName.startsWith("set")) {
      mtdName = mtdName.substring(3, 4).toLowerCase() + mtdName.substring(4, mtdName.length());
      cMtd.setJstName(mtdName);
    }
  }
 /*
  * @see ASTVisitor#visit(NormalAnnotation)
  * @since 3.0
  */
 public boolean visit(NormalAnnotation node) {
   this.fBuffer.append("@"); // $NON-NLS-1$
   node.getTypeName().accept(this);
   this.fBuffer.append("("); // $NON-NLS-1$
   for (Iterator it = node.values().iterator(); it.hasNext(); ) {
     MemberValuePair p = (MemberValuePair) it.next();
     p.accept(this);
     if (it.hasNext()) {
       this.fBuffer.append(","); // $NON-NLS-1$
     }
   }
   this.fBuffer.append(")"); // $NON-NLS-1$
   return false;
 }
  public boolean visit(NormalAnnotation annotation) {
    if (!isKnownAnnotation(annotation.getTypeName().getFullyQualifiedName())) {
      return false;
    }

    List values = annotation.values();

    if (null != values && !values.isEmpty()) {
      for (int i = 0; i < values.size(); i++) {
        MemberValuePair pair = (MemberValuePair) values.get(i);
        if ("parameters".equals(pair.getName().toString())) {
          Expression paramAttr = pair.getValue();
          if (paramAttr instanceof ArrayInitializer) {
            record((MethodDeclaration) annotation.getParent(), (ArrayInitializer) paramAttr);
          }
        }
      }
    }

    return false;
  }
  @Override
  public boolean visit(NormalAnnotation annotation) {
    String typeName = annotation.getTypeName().getFullyQualifiedName();
    if (!TEST_ANNOTATION.equals(typeName) && !TEST_ANNOTATION_FQN.equals(typeName)) {
      return false;
    }

    List values = annotation.values();

    if (null != values && !values.isEmpty()) {
      for (int i = 0; i < values.size(); i++) {
        MemberValuePair pair = (MemberValuePair) values.get(i);
        String name = pair.getName().toString();
        if (DEPENDS_ON_METHODS.equals(name)) {
          m_dependsOnMethods.addAll(extractValues(pair.getValue()));
        } else if (DEPENDS_ON_GROUPS.equals(name)) {
          m_dependsOnGroups.addAll(extractValues(pair.getValue()));
        }
      }
    }

    return false;
  }
Exemplo n.º 5
0
  private List<MemberValuePair> getAnnoMemberPairs(final Annotation anno) {

    if (!(anno instanceof NormalAnnotation)) {
      return Collections.emptyList();
    }

    NormalAnnotation nAnno = (NormalAnnotation) anno;
    MemberValuePair mvPair;
    String name;
    List<MemberValuePair> annoList = new ArrayList<MemberValuePair>();

    for (Object pair : nAnno.values()) {
      if (pair instanceof MemberValuePair) {
        mvPair = (MemberValuePair) pair;
        name = getName(mvPair);
        if (ANNO_NAME.equals(name) || ANNO_VALUE.equals(name)) {
          annoList.add(mvPair);
        }
      }
    }

    return annoList;
  }
Exemplo n.º 6
0
  @Override
  public boolean visit(NormalAnnotation node) {
    //
    // Test method?
    //
    if (isTestAnnotation(node.getTypeName().toString())) {
      ASTNode parent = node.getParent();
      if (parent instanceof MethodDeclaration) {
        addTestMethod((MethodDeclaration) parent, JDK15_ANNOTATION);
      } else if (parent instanceof TypeDeclaration) {
        m_typeIsTest = true;
        m_annotationType = JDK15_ANNOTATION;
      }

      List pairs = node.values();
      for (Iterator it = pairs.iterator(); it.hasNext(); ) {
        MemberValuePair mvp = (MemberValuePair) it.next();
        Name attribute = mvp.getName();
        String name = attribute.getFullyQualifiedName();
        if ("groups".equals(name)) {
          Expression value = mvp.getValue();
          // Array?
          if (value instanceof ArrayInitializer) {
            ArrayInitializer ai = (ArrayInitializer) value;
            List expressions = ai.expressions();
            for (Iterator it2 = expressions.iterator(); it2.hasNext(); ) {
              Expression e = (Expression) it2.next();
              addGroup(e.toString());
            }
          } else if (value instanceof SimpleName) {
            Object boundValue = value.resolveConstantExpressionValue();
            addGroup(boundValue.toString());
          } else if (value instanceof StringLiteral) {
            addGroup(value.toString());
          }
        }
      }
    } else if (isFactoryAnnotation(node.getTypeName().toString())) {
      if (node.getParent() instanceof MethodDeclaration) {
        m_annotationType = JDK15_ANNOTATION;
        addFactoryMethod((MethodDeclaration) node.getParent(), JDK15_ANNOTATION);
      }
    }

    return false;
  }
Exemplo n.º 7
0
 public boolean visit(NormalAnnotation node) {
   if (found(node, node) && this.resolveBinding)
     this.foundBinding = node.resolveAnnotationBinding();
   return true;
 }
 /* (non-Javadoc)
  * @see org.eclipse.jdt.internal.corext.dom.GenericVisitor#visit(org.eclipse.jdt.core.dom.MarkerAnnotation)
  */
 @Override
 public boolean visit(NormalAnnotation node) {
   typeRefFound(node.getTypeName());
   doVisitChildren(node.values());
   return false;
 }