visitExceptions()

in lib/generator.js [276:305]


  visitExceptions(ast, filepath, level) {
    const exs = ast.moduleBody.nodes.filter((item) => {
      return item.type === 'exception';
    });
    const exDir = path.join(path.dirname(filepath), this.exceptionDir);
    for (let i = 0; i < exs.length; i++) {
      const exceptionName = _modelName(exs[i].exceptionName.lexeme);
      const modelFilepath = path.join(exDir, `${exceptionName}Exception.php`);
      const classNamespace = this.classNamespace.get(filepath);
      this.modelSpace = exceptionName;
      this.visitException(exs[i].exceptionBody, exceptionName, ast.extendOn, level);
      this.save(modelFilepath);
      if (this.predefined) {
        Object.keys(this.predefined).filter((key) => {
          return key.startsWith(exceptionName + '.');
        }).map((key) => {
          const modelDir = path.join(path.dirname(filepath), this.modelDir);
          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);
        });
      }
    }
  }