diff --git a/packages/pyright-scip/src/treeVisitor.ts b/packages/pyright-scip/src/treeVisitor.ts index 42fcd79e7..c757a9127 100644 --- a/packages/pyright-scip/src/treeVisitor.ts +++ b/packages/pyright-scip/src/treeVisitor.ts @@ -485,7 +485,7 @@ export class TreeVisitor extends ParseTreeWalker { const symbol = this.getScipSymbol(node); this.document.occurrences.push( new scip.Occurrence({ - symbol_roles: scip.SymbolRole.ReadAccess, + symbol_roles: scip.SymbolRole.Import | scip.SymbolRole.ReadAccess, symbol: symbol.value, range: parseNodeToRange(node.module, this.fileInfo!.lines).toLsif(), }) @@ -500,7 +500,8 @@ export class TreeVisitor extends ParseTreeWalker { } override visitImportFromAs(node: ImportFromAsNode): boolean { - this.pushNewOccurrence(node, this.getScipSymbol(node)); + const roles = scip.SymbolRole.Import | scip.SymbolRole.ReadAccess; + this.pushNewOccurrence(node, this.getScipSymbol(node), roles); return false; } @@ -510,19 +511,20 @@ export class TreeVisitor extends ParseTreeWalker { override visitImportAs(node: ImportAsNode): boolean { const moduleName = _formatModuleName(node.module); const importInfo = getImportInfo(node.module); + const roles = scip.SymbolRole.Import | scip.SymbolRole.ReadAccess; if ( importInfo && importInfo.resolvedPaths[0] && path.resolve(importInfo.resolvedPaths[0]).startsWith(this.cwd) ) { const symbol = Symbols.makeModuleInit(this.projectPackage, moduleName); - this.pushNewOccurrence(node.module, symbol); + this.pushNewOccurrence(node.module, symbol, roles); } else { const pythonPackage = this.moduleNameNodeToPythonPackage(node.module); if (pythonPackage) { const symbol = Symbols.makeModuleInit(pythonPackage, moduleName); - this.pushNewOccurrence(node.module, symbol); + this.pushNewOccurrence(node.module, symbol, roles); } else { // For python packages & modules that we cannot resolve, // we'll just make a local for the file and note that we could not resolve this module. @@ -534,7 +536,7 @@ export class TreeVisitor extends ParseTreeWalker { const symbol = this.getLocalForDeclaration(node, [ `(module): ${moduleName} [unable to resolve module]`, ]); - this.pushNewOccurrence(node.module, symbol); + this.pushNewOccurrence(node.module, symbol, roles); } } diff --git a/packages/pyright-scip/src/virtualenv/environment.ts b/packages/pyright-scip/src/virtualenv/environment.ts index 691f5ed48..5a2de4a71 100644 --- a/packages/pyright-scip/src/virtualenv/environment.ts +++ b/packages/pyright-scip/src/virtualenv/environment.ts @@ -34,9 +34,10 @@ function pipList(): PipInformation[] { function pipBulkShow(names: string[]): string[] { // TODO: This probably breaks with enough names. Should batch them into 512 or whatever the max for bash would be + const maxBuffer = 1024 * 1024 * 10; // 10MB return child_process - .execSync(`${getPipCommand()} show -f ${names.join(' ')}`) - .toString() + .spawnSync(getPipCommand(), ['show', '-f', `${names.join(' ')}`], { maxBuffer }) + .stdout.toString() .split('---'); }