emitFunctionInterface()

in lib/interface_generator.js [54:91]


  emitFunctionInterface(functions, level) {
    for (let i = 0; i < functions.length; i++) {
      if (_name(functions[i].functionName) === 'main') {
        continue;
      }
      if (this.ctx.closable && _name(functions[i].functionName) === 'close') {
        continue;
      }
      this.emitln();
      this.visitAnnotation(functions[i].annotation, level);
      if (_name(functions[i].functionName).endsWith('WithAsyncResponseHandler')) {
        this.emit(`<ReturnT> CompletableFuture<ReturnT>`);
      } else {
        this.emit(`${functions[i].isAsync ? 'CompletableFuture<' : ''}`, level);
        if (functions[i].isAsync && (functions[i].returnType.lexeme === 'void' || functions[i].returnType.name === 'void')) {
          this.emit(`Void`);
        } else {
          this.visitType(functions[i].returnType);
        }
        this.emit(`${functions[i].isAsync ? '>' : ''}`);
      }

      this.emit(` ${_name(functions[i].functionName)}`);
      if (_name(functions[i].functionName).endsWith('WithAsyncResponseHandler')) {
        const params = JSON.parse(JSON.stringify(functions[i].params));
        params.params.pop();
        this.emit('(');
        this.visitPureParams(params, level);
        this.emit(`, AsyncResponseHandler<`);
        this.visitType(functions[i].returnType);
        this.emit(`, ReturnT> responseHandler)`);
      } else {
        this.visitParams(functions[i].params, level);
      }

      this.emitln(';');
    }
  }