import { Traverser } from './traverser';
import { MatchVisitor, MatchParentVisitor, MatchChildrenVisitor } from './visitor';

export class TraverserBuilder {
  constructor() {
    this.setChildNodePath('nodes');
    this.setMatcher(node => {
      throw new Error('No matcher was specified')
    });
  }

  setChildNodePath(childNodePath) {
    this.childNodePath = childNodePath;

    return this;
  }

  setMatcher(matcher) {
    this.matcher = matcher;

    return this;
  }

  get() {
    let visitors = [
      new MatchVisitor(this.matcher),
      new MatchChildrenVisitor(),
      new MatchParentVisitor()
    ];

    return new Traverser(node => node[this.childNodePath] || [], visitors);
  }
}

@@ -19,17 +19,17 @@
  %7D from 
-'
+%22
 ./traver
@@ -35,293 +35,57 @@
 rser
-';%0Aimport %7B MatchVisitor, MatchParentVisitor, MatchChildrenVisitor %7D from './visitor';%0A%0Aexport class TraverserBuilder %7B%0A  constructor() %7B%0A    this.setChildNodePath('nodes');%0A    this.setMatcher(node =%3E %7B%0A      throw new Error('No matcher was specified')%0A    %7D);%0A  %7D%0A%0A  setChildNodePath
+%22;%0A%0Aexport class TraverserBuilder %7B%0A  constructor
 (chi
@@ -142,81 +142,93 @@
 th;%0A
-%0A
     
-return this;%0A  %7D%0A%0A  setMatcher(matcher) %7B%0A    this.matcher = matcher
+this.visitors = %5B%5D;%0A  %7D%0A%0A  addVisitors(visitor) %7B%0A    this.visitors.push(visitor)
 ;%0A%0A 
@@ -254,20 +254,36 @@
 %0A%0A  
-get(
+setVisitors(visitors
 ) %7B%0A    
 let 
@@ -282,12 +282,13 @@
     
-let 
+this.
 visi
@@ -298,120 +298,50 @@
 s = 
-%5B%0A      new MatchVisitor(this.matcher),%0A      new MatchChildrenVisitor(),%0A      new MatchParentVisitor()%0A    %5D;%0A
+visitors;%0A%0A    return this;%0A  %7D%0A%0A  get() %7B
 %0A   
@@ -402,16 +402,21 @@
  %7C%7C %5B%5D, 
+this.
 visitors

Simplify traverser builder