MCPcopy
hub / github.com/uber-go/nilaway / buildPkgInferenceMap

Method buildPkgInferenceMap

inference/engine.go:307–336  ·  view source on GitHub ↗
(triggers []annotation.FullTrigger)

Source from the content-addressed store, hash-verified

305}
306
307func (e *Engine) buildPkgInferenceMap(triggers []annotation.FullTrigger) {
308 // Map each site to all the triggers controlled by the site
309 controlledTgsBySite := map[primitiveSite]map[annotation.FullTrigger]bool{}
310 for _, trigger := range triggers {
311 if !trigger.Controlled() {
312 continue
313 }
314 // controller is an CallSiteParamAnnotationKey, which must be enclosed in a ArgPass
315 // consumer, which Kind() method returns Conditional which is not deep. Thus, we pass false
316 // here.
317 site := e.primitive.site(trigger.Controller, false)
318 ts, ok := controlledTgsBySite[site]
319 if !ok {
320 ts = map[annotation.FullTrigger]bool{}
321 controlledTgsBySite[site] = ts
322 }
323 ts[trigger] = true
324 }
325 e.controlledTriggersBySite = controlledTgsBySite
326
327 for _, trigger := range triggers {
328 // As the initial status, the controlled triggers are skipped and NilAway just pretends not
329 // to see them. Those controlled triggers will be activated and encoded into the inference
330 // map when the sites controlling them are assigned to proper values.
331 if trigger.Controlled() {
332 continue
333 }
334 e.buildFromSingleFullTrigger(trigger)
335 }
336}
337
338func (e *Engine) buildFromSingleFullTrigger(trigger annotation.FullTrigger) {
339 pKind, cKind := trigger.Producer.Annotation.Kind(), trigger.Consumer.Annotation.Kind()

Callers 1

ObservePackageMethod · 0.95

Calls 3

ControlledMethod · 0.80
siteMethod · 0.80

Tested by

no test coverage detected