Package japa.parser.ast.expr

Examples of japa.parser.ast.expr.FieldAccessExpr


        BlockStmt block = new BlockStmt();
        method.setBody(block);

        //add a statement do the method body
        NameExpr clazz = new NameExpr("System");
        FieldAccessExpr field = new FieldAccessExpr(clazz, "out");
        MethodCallExpr call = new MethodCallExpr(field, "println");
        ASTHelper.addArgument(call, new StringLiteralExpr("Hello World"));
        ASTHelper.addStmt(block, call);

        LOG.info(cu.toString());
View Full Code Here


        if (value instanceof EnumAttributeValue) {
            final EnumDetails castValue = ((EnumAttributeValue) value)
                    .getValue();
            // This isn't as elegant as it could be (ie loss of type
            // parameters), but it will do for now
            final FieldAccessExpr convertedValue = new FieldAccessExpr(
                    JavaParserUtils.getNameExpr(castValue.getType()
                            .getFullyQualifiedTypeName()), castValue.getField()
                            .getSymbolName());
            return new MemberValuePair(value.getName().getSymbolName(),
                    convertedValue);
View Full Code Here

            final String value = ((StringLiteralExpr) expression).getValue();
            return new StringAttributeValue(annotationName, value);
        }

        if (expression instanceof FieldAccessExpr) {
            final FieldAccessExpr field = (FieldAccessExpr) expression;
            final String fieldName = field.getField();

            // Determine the type
            final Expression scope = field.getScope();
            NameExpr nameToFind = null;
            if (scope instanceof FieldAccessExpr) {
                final FieldAccessExpr fScope = (FieldAccessExpr) scope;
                nameToFind = JavaParserUtils.getNameExpr(fScope.toString());
            }
            else if (scope instanceof NameExpr) {
                nameToFind = (NameExpr) scope;
            }
            else {
View Full Code Here

                        + simpleName;
                final JavaType javaType = new JavaType(fullyQualifiedName);
                final NameExpr nameToUse = importTypeIfRequired(targetType,
                        imports, javaType);
                if (!(nameToUse instanceof QualifiedNameExpr)) {
                    return new FieldAccessExpr(nameToUse, field);
                }
            }
        }
        else if (value instanceof ClassExpr) {
            final Type type = ((ClassExpr) value).getType();
View Full Code Here

        BlockStmt block = new BlockStmt();
        method.setBody(block);

        //add a statement do the method body
        NameExpr clazz = new NameExpr("System");
        FieldAccessExpr field = new FieldAccessExpr(clazz, "out");
        MethodCallExpr call = new MethodCallExpr(field, "println");
        ASTHelper.addArgument(call, new StringLiteralExpr("Hello World"));
        ASTHelper.addStmt(block, call);

        LOG.info(cu.toString());
View Full Code Here

        return Boolean.TRUE;
    }

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

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

        if (!objEquals(n1.getField(), n2.getField())) {
            return Boolean.FALSE;
        }

        if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) {
            return Boolean.FALSE;
        }

        return Boolean.TRUE;
    }
View Full Code Here

                        break;
                    default:
                        jj_la1[84] = jj_gen;
                        ;
                }
                ret = hasArgs ? new MethodCallExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, typeArgs, name, args) : new FieldAccessExpr(ret.getBeginLine(), ret.getBeginColumn(), token.endLine, token.endColumn, ret, null, name);
                break;
            case LPAREN:
                jj_consume_token(LPAREN);
                line = token.beginLine;
                column = token.beginColumn;
View Full Code Here

                                    break;
                                default:
                                    jj_la1[90] = jj_gen;
                                    ;
                            }
                            ret = hasArgs ? new MethodCallExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope, typeArgs, name, args) : new FieldAccessExpr(scope.getBeginLine(), scope.getBeginColumn(), token.endLine, token.endColumn, scope, typeArgs, name);
                        } else {
                            jj_consume_token(-1);
                            throw new ParseException();
                        }
                }
View Full Code Here

  public Node visit(FieldAccessExpr _n, Object _arg) {
    Expression scope = cloneNodes(_n.getScope(), _arg);
    List<Type> typeArgs = visit(_n.getTypeArgs(), _arg);
    Comment comment = cloneNodes(_n.getComment(), _arg);

    FieldAccessExpr r = new FieldAccessExpr(
        _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
        scope, typeArgs, _n.getField()
    );
    r.setComment(comment);
    return r;
  }
View Full Code Here

    return Boolean.TRUE;
  }

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

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

    if (!objEquals(n1.getField(), n2.getField())) {
      return Boolean.FALSE;
    }

    if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) {
      return Boolean.FALSE;
    }

    return Boolean.TRUE;
  }
View Full Code Here

TOP

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

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.