예제 #1
0
  @SuppressWarnings("unchecked")
  @Override
  public JS visit(WriterVisitor<JS> visitor, InstanceOfTree tree, GenerationContext<JS> context) {

    // build stjs.isInstanceOf(expr.constructor, type);
    // TODO do I need a check or parenthesis around !?

    TypeMirror type =
        context.getTrees().getTypeMirror(new TreePath(context.getCurrentPath(), tree.getType()));
    JS getConstructor =
        context
            .js()
            .property(visitor.scan(tree.getExpression(), context), JavascriptKeywords.CONSTRUCTOR);
    JS targetInst = context.js().property(context.js().name("stjs"), "isInstanceOf");
    JS typeName = context.js().name(context.getNames().getTypeName(context, type));
    return context.js().functionCall(targetInst, Arrays.asList(getConstructor, typeName));
  }
 @Override
 public FlowCondition visitInstanceOf(InstanceOfTree node, Void p) {
   return new FlowCondition(node.getExpression(), true);
 }