Package net.jangaroo.jooc.model

Examples of net.jangaroo.jooc.model.MethodModel


    FieldModel eventNameConstant = new FieldModel("NAME", "String", CompilerUtils.quote(event.name));
    eventNameConstant.setStatic(true);
    eventNameConstant.setAsdoc(MessageFormat.format("This constant defines the value of the <code>type</code> property of the event object\nfor a <code>{0}</code> event.\n   * @eventType {0}", event.name));
    extAsClass.addMember(eventNameConstant);

    MethodModel constructorModel = extAsClass.createConstructor();
    constructorModel.addParam(new ParamModel("arguments", "Array"));
    StringBuilder propertyAssignments = new StringBuilder();
    for (int i = 0; i < event.params.size(); i++) {
      Param param = event.params.get(i);

      // add assignment to constructor body:
      if (i > 0) {
        propertyAssignments.append("\n    ");
      }
      propertyAssignments.append(String.format("this['%s'] = arguments[%d];", convertName(param.name), i));

      // add getter method:
      MethodModel property = new MethodModel(MethodType.GET, convertName(param.name), convertType(param.type));
      property.setAsdoc(toAsDoc(param.doc));
      extAsClass.addMember(property);
    }

    constructorModel.setBody(propertyAssignments.toString());

View Full Code Here


  private static void addMethods(ClassModel classModel, List<Method> methods) {
    for (Method method : methods) {
      if (classModel.getMember(method.name) == null) {
        boolean isConstructor = method.name.equals("constructor");
        MethodModel methodModel = isConstructor
                ? new MethodModel(classModel.getName(), null)
                : new MethodModel(convertName(method.name), convertType(method.return_.type));
        methodModel.setAsdoc(toAsDoc(method.doc));
        methodModel.getReturnModel().setAsdoc(toAsDoc(method.return_.doc));
        setStatic(methodModel, method);
        for (Param param : method.params) {
          ParamModel paramModel = new ParamModel(convertName(param.name), convertType(param.type));
          paramModel.setAsdoc(toAsDoc(param.doc));
          setDefaultValue(paramModel, param);
          paramModel.setRest(param == method.params.get(method.params.size() - 1) && param.type.endsWith("..."));
          methodModel.addParam(paramModel);
        }
        classModel.addMember(methodModel);
      }
    }
  }
View Full Code Here

  @Override
  public void visitFunctionDeclaration(FunctionDeclaration functionDeclaration) throws IOException {
    boolean isTopLevelDeclaration = modelStack.peek() instanceof CompilationUnitModel;
    if (functionDeclaration.isPublicApi() || isTopLevelDeclaration) {
      MethodModel methodModel = new MethodModel();
      modelStack.push(methodModel);
      consumeRecordedAnnotations();
      if (isTopLevelDeclaration) {
        handleExcludeClassByDefault(methodModel);
      }
      recordAsdoc(functionDeclaration);
      recordAsdoc(functionDeclaration.getSymbol());
      consumeRecordedAsdoc();
      generateMemberModifiers(functionDeclaration);
      methodModel.setOverride(functionDeclaration.isOverride());
      methodModel.setFinal(functionDeclaration.isFinal());
      methodModel.setMethodType(functionDeclaration.isGetter() ? MethodType.GET
        : functionDeclaration.isSetter() ? MethodType.SET
        : null);
      functionDeclaration.getIde().visit(this);
      generateSignatureAsApiCode(functionDeclaration.getFun());
View Full Code Here

    field.setNamespace(NamespacedModel.PRIVATE);
    field.setAsdoc("A constant for foo bar.");
    field.setValue("'foo bar baz'");
    classModel.addMember(field);

    MethodModel method = new MethodModel();
    method.setName("doFoo");
    method.setAsdoc("Some method.");
    method.setBody("trace('foo');");
    ParamModel param = new ParamModel();
    param.setName("foo");
    param.setType("com.acme.sub.Bar");
    param.setValue("null");
    method.setParams(Collections.singletonList(param));
    method.setType("int");
    classModel.addMember(method);

    PropertyModel propertyModel = new PropertyModel();
    propertyModel.setName("baz");
    propertyModel.setType("String");
View Full Code Here

TOP

Related Classes of net.jangaroo.jooc.model.MethodModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.