addDeclaration()

in src/model/Group.js [53:72]


  addDeclaration(declaration) {
    const root = this.workflow();
    const existingInRoot = root && root.declarations[declaration.name];
    const ownExisting = this.ownDeclarations[declaration.name];
    if (!existingInRoot && !ownExisting) {
      if (declaration.step !== null) {
        declaration.step.removeDeclaration(declaration.name, root);
      }

      declaration.step = this;

      if (root) {
        root.declarations[declaration.name] = declaration;
      }
      this.ownDeclarations[declaration.name] = declaration;
    } else if (existingInRoot !== declaration && ownExisting !== declaration) {
      throw new Error(`Cannot add a declaration with the same name ${declaration.name}.`);
    }
    return declaration;
  }