MCPcopy
hub / github.com/google/mangle / updatedAtom

Method updatedAtom

packages/packages.go:137–157  ·  view source on GitHub ↗
(a ast.Atom, definedIdentifier map[ast.PredicateSym]bool, usedPackages stringset.Set)

Source from the content-addressed store, hash-verified

135}
136
137func (p *Package) updatedAtom(a ast.Atom, definedIdentifier map[ast.PredicateSym]bool, usedPackages stringset.Set) (ast.Atom, error) {
138 if _, ok := definedIdentifier[a.Predicate]; ok {
139 if p.Name == "" {
140 return a, nil
141 }
142 a.Predicate.Symbol = fmt.Sprintf("%s.%s", p.Name, a.Predicate.Symbol)
143 return a, nil
144 }
145 u := strings.LastIndex(a.Predicate.Symbol, ".")
146 // TODO: We handle this case in the transition stage. We can remove this later and return an error instead.
147 if u == -1 {
148 return a, nil
149 }
150
151 pkgName := a.Predicate.Symbol[:u]
152
153 if !usedPackages.Contains(pkgName) {
154 return ast.Atom{}, fmt.Errorf("in package %q, 'Use' declaration for %v not found", p.Name, a.Predicate)
155 }
156 return a, nil
157}
158
159// Clauses returns Clauses of the package with rewritten identifiers.
160func (p *Package) Clauses() ([]ast.Clause, error) {

Callers 1

ClausesMethod · 0.95

Calls 1

ContainsMethod · 0.65

Tested by

no test coverage detected