MCPcopy Create free account
hub / github.com/arktypeio/arktype / read

Method read

ark/aot/link.ts:1332–1358  ·  view source on GitHub ↗
(unit: Unit, reference: Reference)

Source from the content-addressed store, hash-verified

1330 }
1331
1332 private read(unit: Unit, reference: Reference): void {
1333 const binding = reference.binding
1334 if (!binding || binding.scope !== unit.module.scopes.root) return
1335 // a unit's own list of what it declares reads none of it, where a site's
1336 // names a validator the app reads, as one a link before this declared
1337 if (reference.id.parent?.type === "ExportSpecifier" && !unit.isSite) return
1338 const declared = this.declarationOf(unit, binding)
1339 if (!declared) return
1340 const [owner, declaration] = declared
1341 const reads = this.readsByBinding.get(declaration)
1342 if (reads) {
1343 reads.push({ unit, reference })
1344 return
1345 }
1346 this.readsByBinding.set(declaration, [{ unit, reference }])
1347 this.ownerByBinding.set(declaration, owner)
1348 // what a declaration reads is live once it is
1349 const { declaration: node } = declaration
1350 for (const inner of owner.module.scopes.references) {
1351 if (
1352 inner.id !== declaration.id &&
1353 node.start <= inner.id.start &&
1354 inner.id.end <= node.end
1355 )
1356 this.read(owner, inner)
1357 }
1358 }
1359
1360 private declarationOf(
1361 unit: Unit,

Callers 1

linkMethod · 0.95

Calls 4

declarationOfMethod · 0.95
getMethod · 0.65
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected