当前位置: 首页>>代码示例>>Java>>正文


Java BinaryExpr类代码示例

本文整理汇总了Java中com.github.javaparser.ast.expr.BinaryExpr的典型用法代码示例。如果您正苦于以下问题:Java BinaryExpr类的具体用法?Java BinaryExpr怎么用?Java BinaryExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BinaryExpr类属于com.github.javaparser.ast.expr包,在下文中一共展示了BinaryExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Override public Boolean visit(final BinaryExpr n1, final Node arg) {
	final BinaryExpr n2 = (BinaryExpr) arg;

	if (n1.getOperator() != n2.getOperator()) {
		return false;
	}

	if (!nodeEquals(n1.getLeft(), n2.getLeft())) {
		return false;
	}

	if (!nodeEquals(n1.getRight(), n2.getRight())) {
		return false;
	}

	return true;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:18,代码来源:EqualsVisitor.java

示例2: apply

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Override
public boolean apply(CompilationUnit cu) {
	// first, get the list of nodes from the new cu
	List<Node> nodes = this.factory.appliesToNodes(cu);
	
	Node node = nodes.get(sourceNodeIndex);
	
	((BinaryExpr)node).setOperator(replacement);
	
	return true;
}
 
开发者ID:gintool,项目名称:gin,代码行数:12,代码来源:LogicalOperatorReplacement.java

示例3: getLeftmostExpression

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
private Expression getLeftmostExpression(Expression expression)
{
    if (expression instanceof BinaryExpr)
        return getLeftmostExpression(((BinaryExpr) expression).getLeft());

    return expression;
}
 
开发者ID:Axellience,项目名称:vue-gwt,代码行数:8,代码来源:TemplateParser.java

示例4: doMerge

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Override public BinaryExpr doMerge(BinaryExpr first, BinaryExpr second) {
  BinaryExpr be = new BinaryExpr();

  be.setOperator(first.getOperator());
  be.setLeft(mergeSingle(first.getLeft(),second.getLeft()));
  be.setRight(mergeSingle(first.getRight(),second.getRight()));

  return be;
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:10,代码来源:BinaryExprMerger.java

示例5: doIsEquals

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Override public boolean doIsEquals(BinaryExpr first, BinaryExpr second) {

    if(!isEqualsUseMerger(first.getLeft(),second.getLeft())) return false;
    if(!isEqualsUseMerger(first.getRight(),second.getRight())) return false;
    if(!first.getOperator().equals(second.getOperator())) return false;

    return true;
  }
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:9,代码来源:BinaryExprMerger.java

示例6: compileFunctionUsinStaticMethodFromJar

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Test
public void compileFunctionUsinStaticMethodFromJar() throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, IOException {
    Method invoke = compileFunction("use_jar_static_method", new Class[]{}, ImmutableList.of("src/test/resources/jars/javaparser-core-2.2.1.jar"));
    Expression expression = (Expression) invoke.invoke(null);
    assertEquals(true, expression instanceof BinaryExpr);
    BinaryExpr binaryExpr = (BinaryExpr)expression;
    assertEquals(BinaryExpr.Operator.plus, binaryExpr.getOperator());
}
 
开发者ID:ftomassetti,项目名称:turin-programming-language,代码行数:9,代码来源:CompilerJarReferenceTest.java

示例7: visit

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Override
public Node visit(BinaryExpr _n, Object _arg) {
	Expression left = cloneNodes(_n.getLeft(), _arg);
	Expression right = cloneNodes(_n.getRight(), _arg);
	Comment comment = cloneNodes(_n.getComment(), _arg);

	BinaryExpr r = new BinaryExpr(
			_n.getRange(),
			left, right, _n.getOperator()
	);
	r.setComment(comment);
	return r;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:14,代码来源:CloneVisitor.java

示例8: visit

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Override public Node visit(final BinaryExpr n, final A arg) {
	visitComment(n, arg);
	final Expression left = (Expression) n.getLeft().accept(this, arg);
	final Expression right = (Expression) n.getRight().accept(this, arg);
	if (left == null) {
		return right;
	}
	if (right == null) {
		return left;
	}
	n.setLeft(left);
	n.setRight(right);
	return n;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:15,代码来源:ModifierVisitorAdapter.java

示例9: appliesTo

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Override
public Collection<Class<? extends Node>> appliesTo() {
	return Collections.singleton(BinaryExpr.class);
}
 
开发者ID:gintool,项目名称:gin,代码行数:5,代码来源:LogicalOperatorReplacementFactory.java

示例10: visit

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Override
public void visit(BinaryExpr n, Script arg) {
}
 
开发者ID:Nosorog,项目名称:nosorog-core,代码行数:4,代码来源:NoOpVisitor.java

示例11: visit

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Override
public void visit(final BinaryExpr n, final Object arg) {
    printer.printLn("BinaryExpr");
    printJavaComment(n.getComment(), arg);
    n.getLeft().accept(this, arg);
    printer.print(" ");
    switch (n.getOperator()) {
        case or:
            printer.print("||");
            break;
        case and:
            printer.print("&&");
            break;
        case binOr:
            printer.print("|");
            break;
        case binAnd:
            printer.print("&");
            break;
        case xor:
            printer.print("^");
            break;
        case equals:
            printer.print("==");
            break;
        case notEquals:
            printer.print("!=");
            break;
        case less:
            printer.print("<");
            break;
        case greater:
            printer.print(">");
            break;
        case lessEquals:
            printer.print("<=");
            break;
        case greaterEquals:
            printer.print(">=");
            break;
        case lShift:
            printer.print("<<");
            break;
        case rSignedShift:
            printer.print(">>");
            break;
        case rUnsignedShift:
            printer.print(">>>");
            break;
        case plus:
            printer.print("+");
            break;
        case minus:
            printer.print("-");
            break;
        case times:
            printer.print("*");
            break;
        case divide:
            printer.print("/");
            break;
        case remainder:
            printer.print("%");
            break;
    }
    printer.print(" ");
    n.getRight().accept(this, arg);
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:69,代码来源:ASTDumpVisitor.java

示例12: visit

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Override
public JCTree visit(final BinaryExpr n, final Object arg) {
    //ARG0: int opcode
    Tag arg0;

    switch (n.getOperator()) {
        case or:
            arg0 = JCTree.Tag.OR;
            break;
        case and:
            arg0 = JCTree.Tag.AND;
            break;
        case binOr:
            arg0 = JCTree.Tag.BITOR;
            break;
        case binAnd:
            arg0 = JCTree.Tag.BITAND;
            break;
        case xor:
            arg0 = JCTree.Tag.BITXOR;
            break;
        case equals:
            arg0 = JCTree.Tag.EQ;
            break;
        case notEquals:
            arg0 = JCTree.Tag.NE;
            break;
        case less:
            arg0 = JCTree.Tag.LT;
            break;
        case greater:
            arg0 = JCTree.Tag.GT;
            break;
        case lessEquals:
            arg0 = JCTree.Tag.LE;
            break;
        case greaterEquals:
            arg0 = JCTree.Tag.GE;
            break;
        case lShift:
            arg0 = JCTree.Tag.SL;
            break;
        case rSignedShift:
            arg0 = JCTree.Tag.SR;
            break;
        case rUnsignedShift:
            arg0 = JCTree.Tag.USR;
            break;
        case plus:
            arg0 = JCTree.Tag.PLUS;
            break;
        case minus:
            arg0 = JCTree.Tag.MINUS;
            break;
        case times:
            arg0 = JCTree.Tag.MUL;
            break;
        case divide:
            arg0 = JCTree.Tag.DIV;
            break;
        case remainder:
            arg0 = JCTree.Tag.MOD;
            break;
        default:
            arg0 = JCTree.Tag.ERRONEOUS;
    }

    //ARG1: JCExpression lhs
    JCExpression arg1 = (JCExpression) n.getLeft().accept(this, arg);

    //ARG2: JCExpression rhs
    JCExpression arg2 = (JCExpression) n.getRight().accept(this, arg);

    return new AJCBinary(make.Binary(arg0, arg1, arg2), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:76,代码来源:JavaParser2JCTree.java

示例13: parseExpression

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的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

示例14: binaryOperator

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
/**
 *
 * @param operator
 *      a github javaparser binay operator
 * @return
 *      a string representation of the operator
 */
private String binaryOperator(BinaryExpr.Operator operator) {
    switch (operator) {
        case and:
            return "LAND";
        case binAnd:
            return "AND";
        case binOr:
            return "OR";
        case divide:
            return "QUO";
        case equals:
            return "EQ";
        case greater:
            return "GTR";
        case greaterEquals:
            return "GEQ";
        case less:
            return "LSS";
        case lessEquals:
            return "LEQ";
        case lShift:
            return "SHIFT_LEFT";
        case minus:
            return "SUB";
        case notEquals:
            return "NEQ";
        case or:
            return "LOR";
        case plus:
            return "ADD";
        case remainder:
            return "MOD";
        case rSignedShift:
            return "SHIFT_RIGHT";
        case rUnsignedShift:
            return "SHIFT_RIGHT";
        case times:
            return "MUL";
        default:
            return "XOR";
    }
}
 
开发者ID:DevMine,项目名称:parsers,代码行数:50,代码来源:Parser.java

示例15: visit

import com.github.javaparser.ast.expr.BinaryExpr; //导入依赖的package包/类
@Override public Node visit(final BinaryExpr n, final A arg) {
	n.setLeft((Expression) n.getLeft().accept(this, arg));
	n.setRight((Expression) n.getRight().accept(this, arg));
	return n;
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:6,代码来源:ModifierVisitorAdapter.java


注:本文中的com.github.javaparser.ast.expr.BinaryExpr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。