當前位置: 首頁>>代碼示例>>Java>>正文


Java LiteralExpr類代碼示例

本文整理匯總了Java中com.github.javaparser.ast.expr.LiteralExpr的典型用法代碼示例。如果您正苦於以下問題:Java LiteralExpr類的具體用法?Java LiteralExpr怎麽用?Java LiteralExpr使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LiteralExpr類屬於com.github.javaparser.ast.expr包,在下文中一共展示了LiteralExpr類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: diffNode

import com.github.javaparser.ast.expr.LiteralExpr; //導入依賴的package包/類
private void diffNode(final Node a, final Node aParent,
                      final Node b, final Node bParent,
                      final Consumer<Quintet<Node, Node, Node, Node, DiffStatus>> diffCallback) {
    if (b == null) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISSING));
    } else if (a instanceof NameExpr && !Objects.equals(((NameExpr) a).getName(), ((NameExpr) b).getName())) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISMATCH));
    } else if (a instanceof FieldAccessExpr && !Objects.equals(((FieldAccessExpr) a).getFieldExpr(), ((FieldAccessExpr) b).getFieldExpr())) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISMATCH));
    } else if (a instanceof LiteralExpr && !Objects.equals(a, b)) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISMATCH));
    } else if (a instanceof AnnotationExpr && !Objects.equals(((AnnotationExpr) a).getName().getName(), ((AnnotationExpr) b).getName().getName())) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISMATCH));
    } else if (a instanceof Parameter && !Objects.equals(((Parameter) a).getType(), ((Parameter) b).getType())) {
        diffCallback.accept(Quintet.with(a, aParent, b, bParent, DiffStatus.MISMATCH));
    } else if (a instanceof MethodDeclaration) {
        final Iterator<Parameter> iSourceParameters = ((MethodDeclaration) b).getParameters().iterator();
        for (Parameter parameter : ((MethodDeclaration) a).getParameters()) {
            diffNode(parameter, a, iSourceParameters.hasNext() ? iSourceParameters.next() : null, b, diffCallback);
        }
        introspect(a, b, diffCallback);
    } else {
        introspect(a, b, diffCallback);
    }
}
 
開發者ID:hubrick,項目名稱:raml-maven-plugin,代碼行數:26,代碼來源:SpringWebValidatorMojo.java

示例2: extractType

import com.github.javaparser.ast.expr.LiteralExpr; //導入依賴的package包/類
protected IsType extractType(Expression val) {
  if (val instanceof LiteralExpr) {
    if (val instanceof IntegerLiteralExpr) {
      return new ImmutableType("", "int");
    } else if (val instanceof LongLiteralExpr) {
      return new ImmutableType("", "long");
    } else if (val instanceof DoubleLiteralExpr) {
      return new ImmutableType("", "double");
    } else if (val instanceof CharLiteralExpr) {
      return new ImmutableType("", "char");
    } else if (val instanceof BooleanLiteralExpr) {
      return new ImmutableType("", "boolean");
    } else if (val instanceof StringLiteralExpr) {
      return new ImmutableType("java.lang", "String");
    }
    // TODO: arrays, ui containers, annotated elements, constructors, etc...
  }
  return new ImmutableType("java.lang", "Object");
}
 
開發者ID:WeTheInternet,項目名稱:xapi,代碼行數:20,代碼來源:DataTypeOptions.java

示例3: parseExpression

import com.github.javaparser.ast.expr.LiteralExpr; //導入依賴的package包/類
/**
 *
 * @param expression
 *  a github javaparser Expression
 * @param attributes
 *      the list of attributes of the class,
 *      to potentially get a type from the name
 * @param lineNumber
 *      the starting line number of the parse method or constructor
 * @return
 *      an Expression structure
 */
public Expr parseExpression(Expression expression, List<Attribute> attributes, int lineNumber) {
    if (expression instanceof AssignExpr) { // this.bar = "bar";
        AssignExpr assExpr = (AssignExpr) expression;
        return parseExpression(assExpr.getTarget(), attributes, lineNumber);
    } else if (expression instanceof MethodCallExpr) {
        MethodCallExpr mcEx = (MethodCallExpr) expression;
        return parseMethodCallExpression(mcEx, attributes, lineNumber);
    } else if (expression instanceof NameExpr) { // ident
        NameExpr nEx = (NameExpr) expression;
        Ident nameExpr = new Ident(nEx.getName());
        return nameExpr;
    } else if (expression instanceof LiteralExpr) { // basic lit
        return parseLiteralExpr((LiteralExpr) expression);
    } else if (expression instanceof FieldAccessExpr) {
        FieldAccessExpr fieldExpr = (FieldAccessExpr) expression;
        Ident ident = new Ident(ParserUtils.parseTarget(expression.toString()).get("name"));
        AttributeRef attrRef = new AttributeRef(ident);
        return attrRef;
    } else if (expression instanceof ObjectCreationExpr) {
        ObjectCreationExpr objConExpr = (ObjectCreationExpr) expression;
        return parseObjectCreationExpression(objConExpr, attributes, lineNumber);
    } else if (expression instanceof ArrayAccessExpr) {
        ArrayAccessExpr arryExpr = (ArrayAccessExpr) expression;
        return parseArrayAccessExpression(arryExpr);
    } else if (expression instanceof UnaryExpr) {
        UnaryExpr unExpr = (UnaryExpr) expression;
        return parseUnaryExpression(unExpr, attributes, lineNumber);
    } else if (expression instanceof ConditionalExpr) {
        ConditionalExpr condExpr = (ConditionalExpr) expression;
        return parseConditionalExpression(condExpr, attributes, lineNumber);
    } else if (expression instanceof CastExpr) {
        CastExpr castExpr = (CastExpr) expression;
        return parseExpression(castExpr.getExpr(), attributes, lineNumber);
    } else if (expression instanceof BinaryExpr) {
        BinaryExpr binEx = (BinaryExpr) expression;
        return parseBinaryExpression(binEx, attributes, lineNumber);
    } else if (expression instanceof EnclosedExpr) {
        EnclosedExpr enclosedExpr = (EnclosedExpr) expression;
        return parseExpression(enclosedExpr.getInner(), attributes, lineNumber);
    } else if (expression instanceof InstanceOfExpr) {
        InstanceOfExpr intExpr = (InstanceOfExpr) expression;
        return parseInstanceOfExpression(intExpr, attributes, lineNumber);
    } else if (expression instanceof ArrayCreationExpr) {
        ArrayCreationExpr arryCreaExpr = (ArrayCreationExpr) expression;
        return parseArrayCreationExpression(arryCreaExpr, attributes, lineNumber);
    } else if (expression instanceof ArrayInitializerExpr) {
        ArrayInitializerExpr arryInEx = (ArrayInitializerExpr) expression;
        return parseArrayInitializerExpression(arryInEx, attributes, lineNumber);
    } else if (expression instanceof ThisExpr) {
        return new Ident("this");
    } else if (expression instanceof SuperExpr) {
        return new Ident("super");
    } else if (expression instanceof ClassExpr) {
        return new Ident(expression.toString());
    } else if (expression instanceof VariableDeclarationExpr) { // int foo = 42;
        // should be parsed by parseVariableDeclarationExpression()
        Log.e(TAG, "Unreachable case :: expression : ".concat(expression.toString()));
        return null;
    } else {
        Log.e(TAG, "The type of expression '".concat(expression.getClass().toString()).concat("' is not managed by the parser"));
        return null;
    }
}
 
開發者ID:DevMine,項目名稱:parsers,代碼行數:76,代碼來源:Parser.java


注:本文中的com.github.javaparser.ast.expr.LiteralExpr類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。