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

Function unitDeclaration

src/resolution/pascal-scope.ts:798–805  ·  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

796 * member the code calls.
797 */
798function unitDeclaration(filePath: string, lower: string, context: ResolutionContext, fromFile = filePath): Node | undefined {
799 const decls = pascalNamed(lower, context).filter((n) =>
800 n.filePath === filePath && UNIT_KINDS.has(n.kind) && (n.kind === 'enum_member' || !n.qualifiedName.includes('::')) &&
801 !(fromFile !== filePath && n.kind === 'function' && n.startColumn > unitRoutineColumn(filePath, context)));
802 // A routine declared in the interface and defined in the implementation is
803 // one name; of overloads, one called without arguments first.
804 return decls.find((n) => !isRoutine(n)) ?? decls.find((n) => !needsArguments(n)) ?? decls[0];
805}
806
807/**
808 * How far a unit's own routines are indented at most. In a unit whose

Callers 4

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

Calls 5

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

Tested by

no test coverage detected