public static boolean isIgnoredLanguageModuleClass(Class clazz) {
   return clazz.isString()
       || clazz.isInteger()
       || clazz.isFloat()
       || clazz.isCharacter()
       || clazz.isAnnotation();
 }
Esempio n. 2
0
  static void objectArgument(final Tree.ObjectArgument that, final GenerateJsVisitor gen) {
    final Class c = (Class) that.getDeclarationModel().getTypeDeclaration();

    gen.out("(function()");
    gen.beginBlock();
    gen.out("//ObjectArgument ", that.getIdentifier().getText());
    gen.location(that);
    gen.endLine();
    gen.out(GenerateJsVisitor.function, gen.getNames().name(c), "()");
    gen.beginBlock();
    gen.instantiateSelf(c);
    gen.referenceOuter(c);
    Tree.ExtendedType xt = that.getExtendedType();
    final Tree.ClassBody body = that.getClassBody();
    final Tree.SatisfiedTypes sts = that.getSatisfiedTypes();

    final List<Declaration> superDecs = new ArrayList<Declaration>(3);
    if (!gen.opts.isOptimize()) {
      new GenerateJsVisitor.SuperVisitor(superDecs).visit(that.getClassBody());
    }
    TypeGenerator.callSupertypes(
        sts == null ? null : TypeUtils.getTypes(sts.getTypes()),
        xt == null ? null : xt.getType(),
        c,
        that,
        superDecs,
        xt == null ? null : xt.getInvocationExpression(),
        xt == null ? null : c.getParameterList(),
        gen);

    body.visit(gen);
    gen.out("return ", gen.getNames().self(c), ";");
    gen.endBlock(false, true);
    // Add reference to metamodel
    gen.out(gen.getNames().name(c), ".$crtmm$=");
    TypeUtils.encodeForRuntime(that, c, gen);
    gen.endLine(true);

    TypeGenerator.typeInitialization(
        xt,
        sts,
        c,
        new GenerateJsVisitor.PrototypeInitCallback() {
          @Override
          public void addToPrototypeCallback() {
            gen.addToPrototype(that, c, body.getStatements());
          }
        },
        gen,
        null,
        null);
    gen.out("return ", gen.getNames().name(c), "(new ", gen.getNames().name(c), ".$$);");
    gen.endBlock();
    gen.out("())");
  }
 private static boolean isTestableClass(Class clazz) {
   if (clazz.isToplevel() && !clazz.isAbstract()) {
     List<MethodWithContainer> methods = getAllMethods(clazz);
     for (MethodWithContainer method : methods) {
       if (containsTestAnnotation(method.getMethod())) {
         return true;
       }
     }
   }
   return false;
 }
 @Override
 public void visit(Tree.DelegatedConstructor that) {
   super.visit(that);
   Tree.SimpleType type = that.getType();
   if (type != null) {
     delegatedConstructor = type.getDeclarationModel();
     if (delegatedConstructor instanceof Class) {
       // this case is not actually legal
       Class c = (Class) delegatedConstructor;
       delegatedConstructor = c.getDefaultConstructor();
     }
   }
 }