eachFunction()

in lib/generator.js [2098:2130]


  eachFunction(ast, level) {
    let comments = DSL.comment.getFrontComments(this.comments, ast.tokenRange[0]);
    this.visitComments(comments, level);
    this.visitAnnotation(ast.annotation, level, false);
    const functionName = _avoidKeywords(_name(ast.functionName));

    if(!ast.annotation || !ast.annotation.value) {
      this.emit('/**\n', level);
    }
    this.visitParamsType(ast.params, level);
    this.visitReturnType(ast, level);
    this.emit(' */', level);
    this.emit('\n');

    this.emit('', level);
    if (ast.isStatic) {
      this.emit('static ');
    }

    this.emit(`public function ${functionName}`);

    this.visitParams(ast.params, level);
    this.emit('\n');
    this.emit('{\n', level);
    if (ast.functionBody) {
      this.visitFunctionBody(ast.functionBody, level + 1);
    } else {
      this.used.push('use RuntimeException;');
      // interface mode
      this.emit('throw new RuntimeException(\'Un-implemented!\');\n', level + 1);
    }
    this.emit('}\n', level);
  }