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)
| 478 | |
| 479 | /** Line indexes that belong to `scope` itself (null: the module), not to a def or class nested in it. */ |
| 480 | function 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. */ |
| 496 | function pythonAssignment(line: string): { targets: string[]; value: string; augmented: boolean } | null { |
no test coverage detected