<commit_before>import {Element, ComponentElement, Reporter, MakeJS, AttributeTypes, AttributePath, Project, Graph, Target, Task, Node} from '../index.priv';

const factory = (reporter: Reporter, name: string,
  definition: MakeJS.Environment, attrPath: AttributePath, parent: Element
) => {
  return new TaskElement(name, parent);
};
Project.elementFactories.registerSimple('task', factory);
Project.elementExportsFactories.registerSimple('task', factory);
export class TaskElement extends ComponentElement {
  static validate = Element.elementValidator('task', TaskElement);
  type: Task.Constructor<any, any> | undefined;

  constructor(name: string, parent: Element) {
    super('task', name, parent);
  }
}
Element.registerAttributes(TaskElement, [], {
  type: Task.providers.validate
});
export namespace TaskElement {
  const validateAsTask: AttributeTypes.Validator<Task, Graph> = {
    validate(reporter: Reporter, path: AttributePath, value: any, graph: Graph) : Task | undefined {
      let e = TaskElement.validate.validate(reporter, path, value);
      let cstor = e && e.type;
      let v = cstor && cstor.prototype.__validator;
      let attrs = v && v.validate(reporter, path, e, graph.target());
      let task = cstor && new cstor(e!.name, graph, attrs);
      return task;
    }
  };
  const validateArrayOfTask = AttributeTypes.listValidator(validateAsTask);
  const validateTaskOrArrayOfTask: AttributeTypes.Validator<Node, Graph> = {
    validate(reporter: Reporter, path: AttributePath, taskOrArray: any, graph: Graph) : Node | undefined {
      if (Array.isArray(taskOrArray)) {
        let g = new Graph({ type: "graph", name: "tasks" }, graph);
        validateArrayOfTask.validate(reporter, path, taskOrArray, g);
        return g;
      }
      else {
        return validateAsTask.validate(reporter, path, taskOrArray, graph);
      }<commit_msg>core: fix task.type can be injected by components<commit_after>import {Element, ComponentElement, Reporter, MakeJS, AttributeTypes, AttributePath, Project, Graph, Target, Task, Node} from '../index.priv';

const factory = (reporter: Reporter, name: string,
  definition: MakeJS.Environment, attrPath: AttributePath, parent: Element
) => {
  return new TaskElement(name, parent);
};
Project.elementFactories.registerSimple('task', factory);
Project.elementExportsFactories.registerSimple('task', factory);
export class TaskElement extends ComponentElement {
  static validate = Element.elementValidator('task', TaskElement);
  type: string | undefined;

  constructor(name: string, parent: Element) {
    super('task', name, parent);
  }

  __keyMeaning(attr) {
    return attr === "type" ? Element.KeyMeaning.Element : super.__keyMeaning(attr);
  }
}
export namespace TaskElement {
  const validateAsTask: AttributeTypes.Validator<Task, Graph> = {
    validate(reporter: Reporter, path: AttributePath, value: any, graph: Graph) : Task | undefined {
      let e = TaskElement.validate.validate(reporter, path, value);
      let cstor = e && e.type ? Task.providers.validate.validate(reporter, path, e.type) : undefined;
      let v = cstor && cstor.prototype.__validator;
      let attrs = v && v.validate(reporter, path, e, graph.target());
      let task = cstor && new cstor(e!.name, graph, attrs);
      return task;
    }
  };
  const validateArrayOfTask = AttributeTypes.listValidator(validateAsTask);
  const validateTaskOrArrayOfTask: AttributeTypes.Validator<Node, Graph> = {
    validate(reporter: Reporter, path: AttributePath, taskOrArray: any, graph: Graph) : Node | undefined {
      if (Array.isArray(taskOrArray)) {
        let g = new Graph({ type: "graph", name: "tasks" }, graph);
        validateArrayOfTask.validate(reporter, path, taskOrArray, g);
        return g;
      }
      else {
        return validateAsTask.validate(reporter, path, taskOrArray, graph);
      }
{'fraction_non_alphanumeric': 0.12315653298835705, 'fraction_numerical': 0.0, 'mean_word_length': 4.3769123783031985, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6533272', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1094, 'n_words': 299}