abapmerge icon indicating copy to clipboard operation
abapmerge copied to clipboard

refactor finding leafs

Open larshp opened this issue 7 years ago • 1 comments

much of the code in the following 2 methods are identical

  public getDefinitions(): string {
    let g = new Graph<Class>();

    this.classes.forEach((c) => {
      g.addNode(c.getName(), c);
      c.getDependencies().forEach((d) => { g.addEdge(c.getName(), d); } );
    });

    let result = "";
    while (g.countNodes() > 0) {
      let leaf = g.popLeaf();
      result = result + leaf.getDefinition() + "\n";
    }

    return result;
  }

  public getExceptions(): string {
    let g = new Graph<Class>();

    this.exceptions.forEach((c) => {
      g.addNode(c.getName(), c);
      c.getDependencies().forEach((d) => { g.addEdge(c.getName(), d); } );
    });

    let result = "";
    while (g.countNodes() > 0) {
      let leaf = g.popLeaf();
      result = result + leaf.getDefinition() + "\n" + leaf.getImplementation() + "\n";
    }

    return result;
  }

larshp avatar Feb 13 '18 07:02 larshp

plus interfaces (in a bit)

larshp avatar Jun 11 '18 14:06 larshp