MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / unitDeclaration

Function unitDeclaration

src/resolution/pascal-scope.ts:2192–2202  ·  view source on GitHub ↗

* A unit's top-level declaration of a name (its enum values included), as * code in `fromFile` sees it: another unit's member that its parse lost (see * unitRoutineColumn) is not one, while in its own unit it is most likely the * member the code calls.

(filePath: string, lower: string, context: ResolutionContext, fromFile = filePath)

Source from the content-addressed store, hash-verified

2190 * member the code calls.
2191 */
2192function unitDeclaration(filePath: string, lower: string, context: ResolutionContext, fromFile = filePath): Node | undefined {
2193 // Another unit sees only the routines a unit's interface section declares.
2194 const otherUnit = fromFile !== filePath && !ownUnitFiles(fromFile, context).includes(filePath);
2195 const decls = pascalNamed(lower, context).filter((n) =>
2196 n.filePath === filePath && UNIT_KINDS.has(n.kind) && (n.kind === 'enum_member' || !n.qualifiedName.includes('::')) &&
2197 !(fromFile !== filePath && n.kind === 'function' && n.startColumn > unitRoutineColumn(filePath, context)) &&
2198 !(otherUnit && n.kind === 'function' && !exportedRoutine(n, context)));
2199 // A routine declared in the interface and defined in the implementation is
2200 // one name; of overloads, one called without arguments first.
2201 return decls.find((n) => !isRoutine(n)) ?? decls.find((n) => !needsArguments(n)) ?? decls[0];
2202}
2203
2204/**
2205 * Whether other units see a unit's routine: one its unit's interface section

Callers 5

declarationInScopeFunction · 0.85
memberAtPathFunction · 0.85
headOfFunction · 0.85
typeOfLinksFunction · 0.85
ownUnitDeclarationFunction · 0.85

Calls 7

ownUnitFilesFunction · 0.85
pascalNamedFunction · 0.85
unitRoutineColumnFunction · 0.85
exportedRoutineFunction · 0.85
isRoutineFunction · 0.85
needsArgumentsFunction · 0.85
hasMethod · 0.80

Tested by

no test coverage detected