@@ -302,6 +302,38 @@ func (n *node) compress() {
302
302
}
303
303
}
304
304
305
+ func printFPadding (padding int , format string , a ... interface {}) {
306
+ for i := 0 ; i < padding ; i ++ {
307
+ fmt .Print (" " )
308
+ }
309
+ fmt .Printf (format , a ... )
310
+ }
311
+
312
+ // Private function for now
313
+ func (n * node ) printDebug (level int ) {
314
+ level ++
315
+ // *splat branch
316
+ if n .SplatChild != nil {
317
+ printFPadding (level , "*splat\n " )
318
+ n .SplatChild .printDebug (level )
319
+ }
320
+ // :param branch
321
+ if n .ParamChild != nil {
322
+ printFPadding (level , ":param\n " )
323
+ n .ParamChild .printDebug (level )
324
+ }
325
+ // #param branch
326
+ if n .RelaxedChild != nil {
327
+ printFPadding (level , "#relaxed\n " )
328
+ n .RelaxedChild .printDebug (level )
329
+ }
330
+ // main branch
331
+ for key , node := range n .Children {
332
+ printFPadding (level , "\" %s\" \n " , key )
333
+ node .printDebug (level )
334
+ }
335
+ }
336
+
305
337
type Trie struct {
306
338
root * node
307
339
}
@@ -385,3 +417,10 @@ func (t *Trie) FindRoutesForPath(path string) []*Match {
385
417
func (t * Trie ) Compress () {
386
418
t .root .compress ()
387
419
}
420
+
421
+ // XXX Private function for now
422
+ func (t * Trie ) printDebug () {
423
+ fmt .Print ("<trie>\n " )
424
+ t .root .printDebug (0 )
425
+ fmt .Print ("</trie>\n " )
426
+ }
0 commit comments