Exemplo n.º 1
0
Arquivo: filter.go Projeto: xuy/srclib
// withEmptyImpliedValues returns the RefDefKey with empty field
// values for fields whose value in f.def matches the implied value.
//
// This is useful because in the index, the RefDefKey keys use the
// standard implicit values: a ref to a def in the same repo has an
// empty DefRepo, etc. But the ByRefDefFilter might have the def repo
// specified, since it was created at a higher level. Only set those
// values if they are not the same as the implicit ones (because the
// implicit ones should be blank).
func (f *byRefDefFilter) withEmptyImpliedValues() graph.RefDefKey {
	def := graph.RefDefKey{DefPath: f.ByDefPath()}
	if f.ByDefRepo() != f.impliedRepo {
		def.DefRepo = f.ByDefRepo()
	}
	if f.ByDefUnitType() != f.impliedUnit.Type {
		def.DefUnitType = f.ByDefUnitType()
	}
	if f.ByDefUnit() != f.impliedUnit.Name {
		def.DefUnit = f.ByDefUnit()
	}
	return def
}