MCPcopy Create free account
hub / github.com/docopt/docopt.go / fixIdentities

Method fixIdentities

docopt.go:857–884  ·  view source on GitHub ↗
(uniq patternList)

Source from the content-addressed store, hash-verified

855}
856
857func (p *pattern) fixIdentities(uniq patternList) error {
858 // Make pattern-tree tips point to same object if they are equal.
859 if p.t&patternBranch == 0 {
860 return nil
861 }
862 if uniq == nil {
863 pFlat, err := p.flat(patternDefault)
864 if err != nil {
865 return err
866 }
867 uniq = pFlat.unique()
868 }
869 for i, child := range p.children {
870 if child.t&patternBranch == 0 {
871 ind, err := uniq.index(child)
872 if err != nil {
873 return err
874 }
875 p.children[i] = uniq[ind]
876 } else {
877 err := child.fixIdentities(uniq)
878 if err != nil {
879 return err
880 }
881 }
882 }
883 return nil
884}
885
886func (p *pattern) fixRepeatingArguments() {
887 // Fix elements that should accumulate/increment values.

Callers 3

fixMethod · 0.95

Calls 3

flatMethod · 0.95
uniqueMethod · 0.80
indexMethod · 0.80

Tested by 2