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


Java CastExpr类代码示例

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


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

示例1: processEventParameter

import com.github.javaparser.ast.expr.CastExpr; //导入依赖的package包/类
/**
 * Process the $event variable passed on v-on. This variable must have a valid cast in front.
 * @param expression The currently processed expression
 * @param nameExpr The variable we are processing
 * @param parameters The parameters this expression depends on
 */
private void processEventParameter(Expression expression, NameExpr nameExpr,
    List<VariableInfo> parameters)
{
    if (nameExpr.getParentNode().isPresent() && nameExpr
        .getParentNode()
        .get() instanceof CastExpr)
    {
        CastExpr castExpr = (CastExpr) nameExpr.getParentNode().get();
        parameters.add(new VariableInfo(castExpr.getType().toString(), "$event"));
    }
    else
    {
        throw new TemplateExpressionException(
            "\"$event\" should always be casted to it's intended type. Example: @click=\"doSomething((NativeEvent) $event)\".",
            expression.toString(),
            context);
    }
}
 
开发者ID:Axellience,项目名称:vue-gwt,代码行数:25,代码来源:TemplateParser.java

示例2: visit

import com.github.javaparser.ast.expr.CastExpr; //导入依赖的package包/类
@Override
public void visit(final CastExpr n, final Object arg) {
    printer.printLn("CastExpr");
    printJavaComment(n.getComment(), arg);
    printer.print("(");
    n.getType().accept(this, arg);
    printer.print(") ");
    n.getExpr().accept(this, arg);
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:10,代码来源:ASTDumpVisitor.java

示例3: visit

import com.github.javaparser.ast.expr.CastExpr; //导入依赖的package包/类
@Override
public JCTree visit(final CastExpr n, final Object arg) {
    ///ARG0: JCTree clazz
    JCTree arg0 = n.getType().accept(this, arg);

    ///ARG1: JCExpression expr
    JCExpression arg1 = (JCExpression) n.getExpr().accept(this, arg);

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

示例4: doMerge

import com.github.javaparser.ast.expr.CastExpr; //导入依赖的package包/类
@Override public CastExpr doMerge(CastExpr first, CastExpr second) {
  CastExpr ce = new CastExpr();
  ce.setType(mergeSingle(first.getType(),second.getType()));
  ce.setExpr(mergeSingle(first.getExpr(),second.getExpr()));

  return ce;
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:8,代码来源:CastExprMerger.java

示例5: visit

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

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

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

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

示例6: visit

import com.github.javaparser.ast.expr.CastExpr; //导入依赖的package包/类
@Override
public Node visit(CastExpr _n, Object _arg) {
	Type<?> type_ = cloneNodes(_n.getType(), _arg);
	Expression expr = cloneNodes(_n.getExpr(), _arg);
	Comment comment = cloneNodes(_n.getComment(), _arg);

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

示例7: visit

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

示例8: visit

import com.github.javaparser.ast.expr.CastExpr; //导入依赖的package包/类
@Override
public void visit(CastExpr n, Void arg) {
    super.visit(n, arg);
    
    if (isRefArray(n.getType(), "E")) {
        n.setType(atomicRefArrayType((ArrayType) n.getType()));
    }
}
 
开发者ID:JCTools,项目名称:JCTools,代码行数:9,代码来源:JavaParsingAtomicLinkedQueueGenerator.java

示例9: visit

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

示例10: parseExpression

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

示例11: visit

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

示例12: generateCopyExpression

import com.github.javaparser.ast.expr.CastExpr; //导入依赖的package包/类
private Expression generateCopyExpression(DefinedParamType type, String inputParmId, int
    inputIndex, String outputParamId, int outputIndex) {
  // GOAL: ((InputSocket<Mat>) inputs[0]).getValue().get().assignTo(((OutputSocket<Mat>)
  // outputs[0]).getValue().get());
  final ClassOrInterfaceType outputType = new ClassOrInterfaceType("OutputSocket");
  final ClassOrInterfaceType inputType = new ClassOrInterfaceType("InputSocket");
  outputType.setTypeArgs(Collections.singletonList(type.getType()));
  inputType.setTypeArgs(Collections.singletonList(type.getType()));

  final MethodCallExpr copyExpression = new MethodCallExpr(
      new MethodCallExpr(
          getOrSetValueExpression(
              new EnclosedExpr(
                  new CastExpr(
                      inputType,
                      arrayAccessExpr(inputParmId, inputIndex)
                  )
              ),
              null
          ),
          "get"
      ),
      "assignTo",
      Collections.singletonList(
          new MethodCallExpr(
              getOrSetValueExpression(
                  new EnclosedExpr(
                      new CastExpr(
                          outputType,
                          arrayAccessExpr(outputParamId, outputIndex)
                      )
                  ),
                  null
              ),
              "get"
          )
      )
  );
  copyExpression.setComment(new BlockComment(
      " Sets the value of the input Mat to the output because this operation does not have a " +
          "destination Mat. "
  ));
  return copyExpression;
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:45,代码来源:SocketHintDeclarationCollection.java

示例13: visit

import com.github.javaparser.ast.expr.CastExpr; //导入依赖的package包/类
@Override public void visit(final CastExpr n, final A arg) {
	visitComment(n.getComment(), arg);
	n.getType().accept(this, arg);
	n.getExpr().accept(this, arg);
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:6,代码来源:VoidVisitorAdapter.java

示例14: visit

import com.github.javaparser.ast.expr.CastExpr; //导入依赖的package包/类
@Override
public void visit(final CastExpr n, final Context ctx) {
  visitNode(n, ctx);
  super.visit(n, ctx);

}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:7,代码来源:LocalVariableCollector.java

示例15: visit

import com.github.javaparser.ast.expr.CastExpr; //导入依赖的package包/类
@Override
public void visit(CastExpr n, Void arg) {
    out.println("CastExpr: " + (extended ? n : ""));
    super.visit(n, arg);
}
 
开发者ID:JCTools,项目名称:JCTools,代码行数:6,代码来源:TraceVisitor.java


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