visitModels()

in lib/generator.js [307:338]


  visitModels(ast, filepath, level) {
    const models = ast.moduleBody.nodes.filter((item) => {
      return item.type === 'model';
    });
    const modelDir = path.join(path.dirname(filepath), this.modelDir);
    for (let i = 0; i < models.length; i++) {
      const modelName = _modelName(models[i].modelName.lexeme);
      const modelFilepath = path.join(modelDir, `${modelName}.php`);
      const classNamespace = this.classNamespace.get(filepath);
      this.modelSpace = modelName;
      this.visitAnnotation(models[i].annotation, level);
      let comments = DSL.comment.getFrontComments(this.comments, models[i].tokenRange[0]);
      this.visitComments(comments, level);
      this.visitModel(models[i].modelBody, modelName, models[i].extendOn, level);
      this.save(modelFilepath);
      if (this.predefined) {
        Object.keys(this.predefined).filter((key) => {
          return key.startsWith(modelName + '.');
        }).map((key) => {
          this.modelSpace = this.getfullModelName(key, true);
          const realFullModelName = this.getfullModelName(key);
          const [ modelName ] = realFullModelName.split('\\').slice(-1);
          
          const realFullClassName = `${classNamespace}\\${this.modelDir}\\${realFullModelName}`;
          this.usedClass.set(modelName, realFullClassName);
          const subModelFilepath = path.join(modelDir, `${realFullModelName.split('\\').join(path.sep)}.php`);
          this.visitModel(this.predefined[key].modelBody, modelName, this.predefined[key].extendOn, level);
          this.save(subModelFilepath);
        });
      }
    }
  }