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

Function pythonOwnLines

src/resolution/name-matcher.ts:480–493  ·  view source on GitHub ↗

Line indexes that belong to `scope` itself (null: the module), not to a def or class nested in it.

(scope: Node | null, filePath: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

478
479/** Line indexes that belong to `scope` itself (null: the module), not to a def or class nested in it. */
480function pythonOwnLines(scope: Node | null, filePath: string, context: ResolutionContext): number[] {
481 const count = pythonMemberLines(filePath, context).length;
482 const from = scope ? scope.startLine : 1;
483 const to = scope ? Math.min(scope.endLine, count) : count;
484 const nested = new Uint8Array(to - from + 1);
485 for (const n of context.getNodesInFile(filePath)) {
486 if ((n.kind !== 'function' && n.kind !== 'method' && n.kind !== 'class') || n.id === scope?.id) continue;
487 if (n.startLine < from || n.endLine > to || (scope && n.startLine <= scope.startLine)) continue;
488 nested.fill(1, n.startLine - from, n.endLine - from + 1);
489 }
490 const own: number[] = [];
491 for (let l = from; l <= to; l++) if (!nested[l - from]) own.push(l - 1);
492 return own;
493}
494
495/** Split `a = b = value` at its top-level assignment operators; null when the line assigns nothing. */
496function pythonAssignment(line: string): { targets: string[]; value: string; augmented: boolean } | null {

Callers 3

pythonBindsLocallyFunction · 0.85
scanPythonGlobalBindingsFunction · 0.85
pythonDynamicGlobalWriteFunction · 0.85

Calls 4

pythonMemberLinesFunction · 0.85
fillMethod · 0.80
pushMethod · 0.80
getNodesInFileMethod · 0.65

Tested by

no test coverage detected