Package japa.parser.ast.expr

Examples of japa.parser.ast.expr.MarkerAnnotationExpr


        // Create the AnnotationExpr; it varies depending on how many
        // member-value pairs we need to present
        AnnotationExpr annotationExpression = null;
        if (memberValuePairs.isEmpty()) {
            annotationExpression = new MarkerAnnotationExpr(nameToUse);
        }
        else if (memberValuePairs.size() == 1
                && (memberValuePairs.get(0).getName() == null || "value"
                        .equals(memberValuePairs.get(0).getName()))) {
            final Expression toUse = JavaParserUtils
                    .importExpressionIfRequired(
                            compilationUnitServices.getEnclosingTypeName(),
                            compilationUnitServices.getImports(),
                            memberValuePairs.get(0).getValue());
            annotationExpression = new SingleMemberAnnotationExpr(nameToUse,
                    toUse);
        }
        else {
            // We have a number of pairs being presented
            annotationExpression = new NormalAnnotationExpr(nameToUse,
                    new ArrayList<MemberValuePair>());
        }

        // Add our AnnotationExpr to the actual annotations that will eventually
        // be flushed through to the compilation unit
        annotations.add(annotationExpression);

        // Add member-value pairs to our AnnotationExpr
        if (!memberValuePairs.isEmpty()) {
            // Have to check here for cases where we need to change an existing
            // MarkerAnnotationExpr to a NormalAnnotationExpr or
            // SingleMemberAnnotationExpr
            if (annotationExpression instanceof MarkerAnnotationExpr) {
                final MarkerAnnotationExpr mae = (MarkerAnnotationExpr) annotationExpression;

                annotations.remove(mae);

                if (memberValuePairs.size() == 1
                        && (memberValuePairs.get(0).getName() == null || "value"
View Full Code Here


        if (value instanceof NestedAnnotationAttributeValue) {
            final NestedAnnotationAttributeValue castValue = (NestedAnnotationAttributeValue) value;
            AnnotationExpr annotationExpr;
            final AnnotationMetadata nestedAnnotation = castValue.getValue();
            if (castValue.getValue().getAttributeNames().size() == 0) {
                annotationExpr = new MarkerAnnotationExpr(
                        JavaParserUtils.getNameExpr(nestedAnnotation
                                .getAnnotationType()
                                .getFullyQualifiedTypeName()));
            }
            else if (castValue.getValue().getAttributeNames().size() == 1) {
View Full Code Here

     * @return the name (never null)
     */
    public static NameExpr getNameExpr(final AnnotationExpr annotationExpr) {
        Validate.notNull(annotationExpr, "Annotation expression required");
        if (annotationExpr instanceof MarkerAnnotationExpr) {
            final MarkerAnnotationExpr a = (MarkerAnnotationExpr) annotationExpr;
            final NameExpr nameToFind = a.getName();
            Validate.notNull(nameToFind,
                    "Unable to determine annotation name from '"
                            + annotationExpr + "'");
            return nameToFind;
        }
        else if (annotationExpr instanceof SingleMemberAnnotationExpr) {
            final SingleMemberAnnotationExpr a = (SingleMemberAnnotationExpr) annotationExpr;
            final NameExpr nameToFind = a.getName();
            Validate.notNull(nameToFind,
                    "Unable to determine annotation name from '"
                            + annotationExpr + "'");
            return nameToFind;
        }
        else if (annotationExpr instanceof NormalAnnotationExpr) {
            final NormalAnnotationExpr a = (NormalAnnotationExpr) annotationExpr;
            final NameExpr nameToFind = a.getName();
            Validate.notNull(nameToFind,
                    "Unable to determine annotation name from '"
                            + annotationExpr + "'");
            return nameToFind;
        }
View Full Code Here

        return Boolean.TRUE;
    }

    public Boolean visit(MarkerAnnotationExpr n1, Node arg) {
        MarkerAnnotationExpr n2 = (MarkerAnnotationExpr) arg;

        if (!nodeEquals(n1.getName(), n2.getName())) {
            return Boolean.FALSE;
        }

        return Boolean.TRUE;
    }
View Full Code Here

        line = token.beginLine;
        column = token.beginColumn;
        name = Name();
        {
            if (true) {
                return new MarkerAnnotationExpr(line, column, token.endLine, token.endColumn, name);
            }
        }
        throw new Error("Missing return statement in function");
    }
View Full Code Here

  @Override
  public Node visit(MarkerAnnotationExpr _n, Object _arg) {
    NameExpr name = cloneNodes(_n.getName(), _arg);
    Comment comment = cloneNodes(_n.getComment(), _arg);

    MarkerAnnotationExpr r = new MarkerAnnotationExpr(
        _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
        name
    );
    r.setComment(comment);
    return r;
  }
View Full Code Here

    return Boolean.TRUE;
  }

  @Override public Boolean visit(final MarkerAnnotationExpr n1, final Node arg) {
    final MarkerAnnotationExpr n2 = (MarkerAnnotationExpr) arg;

    if (!nodeEquals(n1.getName(), n2.getName())) {
      return Boolean.FALSE;
    }

    return Boolean.TRUE;
  }
View Full Code Here

TOP

Related Classes of japa.parser.ast.expr.MarkerAnnotationExpr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.