visitModels()

in lib/generator.js [599:621]


  visitModels(ast, filepath, level) {
    const models = ast.moduleBody.nodes.filter((item) => {
      return item.type === 'model';
    });
    for (let i = 0; i < models.length; i++) {
      const modelName = _upperFirst(models[i].modelName.lexeme);
      this.modelSpace = modelName;
      this.used.push('System');
      this.used.push('System.IO');
      this.used.push('System.Collections');
      this.used.push('System.Collections.Generic');
      // for [NameInMap]
      this.used.push('Darabonba');
      this.visitAnnotation(models[i].annotation, level + 1);
      let comments = DSL.comment.getFrontComments(this.comments, models[i].tokenRange[0]);
      this.visitComments(comments, level);
      this.eachModel(models[i], modelName, level + 1, ast.predefined);
      this.modelAfter();
      const modelDir = path.join(path.dirname(filepath), 'Models');
      const modelFilepath = path.join(modelDir, `${modelName}.cs`);
      this.save(modelFilepath);
    }
  }