MCPcopy
hub / github.com/tinylib/msgp / applyDirectives

Method applyDirectives

parse/getast.go:124–158  ·  view source on GitHub ↗

applyDirectives applies all of the directives that are known to the parser. additional method-specific directives remain in f.Directives

()

Source from the content-addressed store, hash-verified

122// are known to the parser. additional method-specific
123// directives remain in f.Directives
124func (fs *FileSet) applyDirectives() {
125 newdirs := make([]string, 0, len(fs.Directives))
126 for _, d := range fs.Directives {
127 chunks := strings.Split(d, " ")
128 if len(chunks) > 0 {
129 if fn, ok := directives[chunks[0]]; ok {
130 pushstate(chunks[0])
131 err := fn(chunks, fs)
132 if err != nil {
133 warnf("directive error: %s", err)
134 }
135 popstate()
136 } else {
137 newdirs = append(newdirs, d)
138 }
139 }
140 }
141 // Apply aliases last, so we don't overrule any manually specified replace directives.
142 for _, d := range fs.Aliased {
143 chunks := strings.Split(d, " ")
144 if len(chunks) > 0 {
145 if fn, ok := directives[chunks[0]]; ok {
146 pushstate(chunks[0])
147 err := fn(chunks, fs)
148 if err != nil {
149 warnf("directive error: %s", err)
150 }
151 popstate()
152 } else {
153 newdirs = append(newdirs, d)
154 }
155 }
156 }
157 fs.Directives = newdirs
158}
159
160// applyEarlyDirectives applies all early directives needed before process() is called.
161// additional directives remain in f.Directives for future processing

Callers 1

FileFunction · 0.95

Calls 3

pushstateFunction · 0.85
warnfFunction · 0.85
popstateFunction · 0.85

Tested by

no test coverage detected