Collects an arbitrary number of patterns, and returns a (watch, exclude, NoCommonFilter) tuple.
()
| 94 | // Collects an arbitrary number of patterns, and returns a (watch, exclude, |
| 95 | // NoCommonFilter) tuple. |
| 96 | func (p *parser) collectPatterns() ([]string, []string, bool) { |
| 97 | noCommonFilter := false |
| 98 | watch := []string{} |
| 99 | exclude := []string{} |
| 100 | |
| 101 | vals := p.collect(itemBareString, itemQuotedString) |
| 102 | for _, v := range vals { |
| 103 | switch v.typ { |
| 104 | case itemBareString: |
| 105 | if v.val[0] == '!' { |
| 106 | exclude = append(exclude, v.val[1:]) |
| 107 | } else { |
| 108 | if v.val == "+noignore" { |
| 109 | noCommonFilter = true |
| 110 | } else { |
| 111 | watch = append(watch, v.val) |
| 112 | } |
| 113 | } |
| 114 | case itemQuotedString: |
| 115 | if v.val[0] == '!' { |
| 116 | exclude = append(exclude, unquote(v.val[1:])) |
| 117 | } else { |
| 118 | watch = append(watch, unquote(v.val)) |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | if len(watch) == 0 { |
| 123 | watch = nil |
| 124 | } |
| 125 | if len(exclude) == 0 { |
| 126 | exclude = nil |
| 127 | } |
| 128 | return watch, exclude, noCommonFilter |
| 129 | } |
| 130 | |
| 131 | // errorf formats the error and terminates processing. |
| 132 | func (p *parser) errorf(format string, args ...interface{}) { |
no test coverage detected