@zzzen/pyright-internal 1.2.0-dev.20250420 → 1.2.0-dev.20250803

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/dist/analyzer/analyzerNodeInfo.js +1 -1
  2. package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
  3. package/dist/analyzer/binder.d.ts +2 -1
  4. package/dist/analyzer/binder.js +33 -18
  5. package/dist/analyzer/binder.js.map +1 -1
  6. package/dist/analyzer/checker.js +81 -44
  7. package/dist/analyzer/checker.js.map +1 -1
  8. package/dist/analyzer/codeFlowEngine.js +19 -7
  9. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  10. package/dist/analyzer/codeFlowTypes.d.ts +9 -8
  11. package/dist/analyzer/codeFlowTypes.js +9 -8
  12. package/dist/analyzer/codeFlowTypes.js.map +1 -1
  13. package/dist/analyzer/codeFlowUtils.js +4 -2
  14. package/dist/analyzer/codeFlowUtils.js.map +1 -1
  15. package/dist/analyzer/docStringUtils.js +3 -1
  16. package/dist/analyzer/docStringUtils.js.map +1 -1
  17. package/dist/analyzer/importStatementUtils.js +5 -3
  18. package/dist/analyzer/importStatementUtils.js.map +1 -1
  19. package/dist/analyzer/operations.js +1 -1
  20. package/dist/analyzer/operations.js.map +1 -1
  21. package/dist/analyzer/packageTypeVerifier.js +5 -3
  22. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  23. package/dist/analyzer/parameterUtils.js +10 -3
  24. package/dist/analyzer/parameterUtils.js.map +1 -1
  25. package/dist/analyzer/parseTreeUtils.d.ts +3 -4
  26. package/dist/analyzer/parseTreeUtils.js +19 -225
  27. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  28. package/dist/analyzer/patternMatching.js +4 -0
  29. package/dist/analyzer/patternMatching.js.map +1 -1
  30. package/dist/analyzer/program.d.ts +12 -2
  31. package/dist/analyzer/program.js +74 -58
  32. package/dist/analyzer/program.js.map +1 -1
  33. package/dist/analyzer/properties.js +3 -5
  34. package/dist/analyzer/properties.js.map +1 -1
  35. package/dist/analyzer/protocols.js +13 -3
  36. package/dist/analyzer/protocols.js.map +1 -1
  37. package/dist/analyzer/sentinel.d.ts +4 -0
  38. package/dist/analyzer/sentinel.js +51 -0
  39. package/dist/analyzer/sentinel.js.map +1 -0
  40. package/dist/analyzer/service.d.ts +2 -2
  41. package/dist/analyzer/service.js +7 -6
  42. package/dist/analyzer/service.js.map +1 -1
  43. package/dist/analyzer/sourceFile.d.ts +4 -0
  44. package/dist/analyzer/sourceFile.js +52 -12
  45. package/dist/analyzer/sourceFile.js.map +1 -1
  46. package/dist/analyzer/sourceFileInfo.d.ts +10 -1
  47. package/dist/analyzer/sourceFileInfo.js +28 -0
  48. package/dist/analyzer/sourceFileInfo.js.map +1 -1
  49. package/dist/analyzer/sourceFileInfoUtils.js +4 -4
  50. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
  51. package/dist/analyzer/sourceMapper.d.ts +1 -1
  52. package/dist/analyzer/sourceMapper.js +20 -20
  53. package/dist/analyzer/sourceMapper.js.map +1 -1
  54. package/dist/analyzer/symbol.d.ts +3 -0
  55. package/dist/analyzer/symbol.js +11 -0
  56. package/dist/analyzer/symbol.js.map +1 -1
  57. package/dist/analyzer/testWalker.js +2 -13
  58. package/dist/analyzer/testWalker.js.map +1 -1
  59. package/dist/analyzer/tracePrinter.js +1 -1
  60. package/dist/analyzer/tracePrinter.js.map +1 -1
  61. package/dist/analyzer/typeEvaluator.js +261 -137
  62. package/dist/analyzer/typeEvaluator.js.map +1 -1
  63. package/dist/analyzer/typeEvaluatorTypes.d.ts +8 -4
  64. package/dist/analyzer/typeEvaluatorTypes.js +15 -2
  65. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  66. package/dist/analyzer/typeGuards.js +47 -13
  67. package/dist/analyzer/typeGuards.js.map +1 -1
  68. package/dist/analyzer/typePrinter.js +10 -2
  69. package/dist/analyzer/typePrinter.js.map +1 -1
  70. package/dist/analyzer/typePrinterUtils.js +2 -2
  71. package/dist/analyzer/typePrinterUtils.js.map +1 -1
  72. package/dist/analyzer/typeUtils.d.ts +2 -0
  73. package/dist/analyzer/typeUtils.js +10 -0
  74. package/dist/analyzer/typeUtils.js.map +1 -1
  75. package/dist/analyzer/typedDicts.js +9 -5
  76. package/dist/analyzer/typedDicts.js.map +1 -1
  77. package/dist/analyzer/types.d.ts +9 -2
  78. package/dist/analyzer/types.js +39 -1
  79. package/dist/analyzer/types.js.map +1 -1
  80. package/dist/commands/dumpFileDebugInfoCommand.d.ts +96 -0
  81. package/dist/commands/dumpFileDebugInfoCommand.js +13 -2
  82. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  83. package/dist/common/cancellationUtils.d.ts +1 -1
  84. package/dist/common/cancellationUtils.js +2 -2
  85. package/dist/common/cancellationUtils.js.map +1 -1
  86. package/dist/common/charCodes.d.ts +1 -1
  87. package/dist/common/charCodes.js +1 -1
  88. package/dist/common/charCodes.js.map +1 -1
  89. package/dist/common/configOptions.d.ts +1 -0
  90. package/dist/common/configOptions.js +5 -0
  91. package/dist/common/configOptions.js.map +1 -1
  92. package/dist/common/core.d.ts +1 -3
  93. package/dist/common/core.js +3 -4
  94. package/dist/common/core.js.map +1 -1
  95. package/dist/common/diagnostic.d.ts +1 -1
  96. package/dist/common/diagnosticRules.d.ts +1 -0
  97. package/dist/common/diagnosticRules.js +1 -0
  98. package/dist/common/diagnosticRules.js.map +1 -1
  99. package/dist/common/docRange.d.ts +6 -0
  100. package/dist/common/docRange.js +10 -0
  101. package/dist/common/docRange.js.map +1 -0
  102. package/dist/common/envVarUtils.js +1 -6
  103. package/dist/common/envVarUtils.js.map +1 -1
  104. package/dist/common/extensibility.d.ts +11 -2
  105. package/dist/common/extensibility.js.map +1 -1
  106. package/dist/common/fileBasedCancellationUtils.d.ts +1 -0
  107. package/dist/common/fileBasedCancellationUtils.js +1 -0
  108. package/dist/common/fileBasedCancellationUtils.js.map +1 -1
  109. package/dist/common/logTracker.d.ts +5 -1
  110. package/dist/common/logTracker.js +43 -26
  111. package/dist/common/logTracker.js.map +1 -1
  112. package/dist/common/pathUtils.d.ts +1 -1
  113. package/dist/common/pathUtils.js +3 -2
  114. package/dist/common/pathUtils.js.map +1 -1
  115. package/dist/common/realFileSystem.d.ts +1 -1
  116. package/dist/common/realFileSystem.js +2 -1
  117. package/dist/common/realFileSystem.js.map +1 -1
  118. package/dist/common/stringUtils.d.ts +0 -1
  119. package/dist/common/stringUtils.js +0 -42
  120. package/dist/common/stringUtils.js.map +1 -1
  121. package/dist/common/textEditTracker.js +5 -3
  122. package/dist/common/textEditTracker.js.map +1 -1
  123. package/dist/common/textRange.d.ts +5 -11
  124. package/dist/common/textRange.js +31 -56
  125. package/dist/common/textRange.js.map +1 -1
  126. package/dist/common/textRangeCollection.js +3 -2
  127. package/dist/common/textRangeCollection.js.map +1 -1
  128. package/dist/common/uri/baseUri.js +2 -1
  129. package/dist/common/uri/baseUri.js.map +1 -1
  130. package/dist/common/uri/uri.d.ts +5 -2
  131. package/dist/common/uri/uri.js +21 -5
  132. package/dist/common/uri/uri.js.map +1 -1
  133. package/dist/common/uri/uriUtils.d.ts +2 -2
  134. package/dist/common/uri/uriUtils.js +4 -3
  135. package/dist/common/uri/uriUtils.js.map +1 -1
  136. package/dist/common/workspaceEditUtils.js +9 -9
  137. package/dist/common/workspaceEditUtils.js.map +1 -1
  138. package/dist/languageServerBase.d.ts +5 -3
  139. package/dist/languageServerBase.js +44 -37
  140. package/dist/languageServerBase.js.map +1 -1
  141. package/dist/languageService/analyzerServiceExecutor.d.ts +3 -0
  142. package/dist/languageService/analyzerServiceExecutor.js +1 -0
  143. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  144. package/dist/languageService/autoImporter.d.ts +2 -2
  145. package/dist/languageService/autoImporter.js +3 -3
  146. package/dist/languageService/autoImporter.js.map +1 -1
  147. package/dist/languageService/callHierarchyProvider.js +2 -3
  148. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  149. package/dist/languageService/completionProvider.js +16 -13
  150. package/dist/languageService/completionProvider.js.map +1 -1
  151. package/dist/languageService/definitionProvider.d.ts +2 -1
  152. package/dist/languageService/definitionProvider.js.map +1 -1
  153. package/dist/languageService/documentSymbolCollector.d.ts +4 -1
  154. package/dist/languageService/documentSymbolCollector.js +9 -7
  155. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  156. package/dist/languageService/hoverProvider.js +1 -9
  157. package/dist/languageService/hoverProvider.js.map +1 -1
  158. package/dist/languageService/importSorter.js +1 -0
  159. package/dist/languageService/importSorter.js.map +1 -1
  160. package/dist/languageService/navigationUtils.d.ts +1 -1
  161. package/dist/languageService/referencesProvider.d.ts +2 -1
  162. package/dist/languageService/referencesProvider.js +8 -7
  163. package/dist/languageService/referencesProvider.js.map +1 -1
  164. package/dist/languageService/renameProvider.js +4 -19
  165. package/dist/languageService/renameProvider.js.map +1 -1
  166. package/dist/languageService/tooltipUtils.d.ts +2 -0
  167. package/dist/languageService/tooltipUtils.js +2 -0
  168. package/dist/languageService/tooltipUtils.js.map +1 -1
  169. package/dist/languageService/workspaceSymbolProvider.js +1 -1
  170. package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
  171. package/dist/localization/localize.d.ts +12 -2
  172. package/dist/localization/localize.js +12 -2
  173. package/dist/localization/localize.js.map +1 -1
  174. package/dist/localization/package.nls.cs.json +23 -9
  175. package/dist/localization/package.nls.de.json +18 -4
  176. package/dist/localization/package.nls.en-us.json +36 -2
  177. package/dist/localization/package.nls.es.json +18 -4
  178. package/dist/localization/package.nls.fr.json +22 -8
  179. package/dist/localization/package.nls.it.json +23 -9
  180. package/dist/localization/package.nls.ja.json +18 -4
  181. package/dist/localization/package.nls.ko.json +23 -9
  182. package/dist/localization/package.nls.pl.json +18 -4
  183. package/dist/localization/package.nls.pt-br.json +18 -4
  184. package/dist/localization/package.nls.qps-ploc.json +17 -3
  185. package/dist/localization/package.nls.ru.json +18 -4
  186. package/dist/localization/package.nls.tr.json +23 -9
  187. package/dist/localization/package.nls.zh-cn.json +18 -4
  188. package/dist/localization/package.nls.zh-tw.json +18 -4
  189. package/dist/parser/characters.d.ts +1 -8
  190. package/dist/parser/characters.js +6 -3
  191. package/dist/parser/characters.js.map +1 -1
  192. package/dist/parser/parseNodeUtils.d.ts +12 -0
  193. package/dist/parser/parseNodeUtils.js +136 -0
  194. package/dist/parser/parseNodeUtils.js.map +1 -0
  195. package/dist/parser/parseNodes.d.ts +12 -2
  196. package/dist/parser/parseNodes.js +17 -2
  197. package/dist/parser/parseNodes.js.map +1 -1
  198. package/dist/parser/parser.d.ts +3 -2
  199. package/dist/parser/parser.js +54 -47
  200. package/dist/parser/parser.js.map +1 -1
  201. package/dist/parser/tokenizer.d.ts +3 -3
  202. package/dist/parser/tokenizer.js +58 -38
  203. package/dist/parser/tokenizer.js.map +1 -1
  204. package/dist/parser/tokenizerTypes.d.ts +4 -3
  205. package/dist/parser/tokenizerTypes.js +4 -3
  206. package/dist/parser/tokenizerTypes.js.map +1 -1
  207. package/dist/pyright.js +1 -1
  208. package/dist/pyright.js.map +1 -1
  209. package/dist/server.js +3 -3
  210. package/dist/server.js.map +1 -1
  211. package/dist/tests/checker.test.js +2 -2
  212. package/dist/tests/common.test.js +6 -6
  213. package/dist/tests/common.test.js.map +1 -1
  214. package/dist/tests/fourslash/completions.autoimport.unicode.fourslash.js +29 -0
  215. package/dist/tests/fourslash/completions.autoimport.unicode.fourslash.js.map +1 -0
  216. package/dist/tests/fourslash/completions.declNames.method.fourslash.js +8 -8
  217. package/dist/tests/harness/fourslash/testState.d.ts +3 -2
  218. package/dist/tests/harness/fourslash/testState.js +9 -3
  219. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  220. package/dist/tests/lsp/languageServer.js +1 -1
  221. package/dist/tests/lsp/languageServer.js.map +1 -1
  222. package/dist/tests/lsp/languageServerTestUtils.d.ts +1 -2
  223. package/dist/tests/lsp/languageServerTestUtils.js +2 -2
  224. package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
  225. package/dist/tests/positionUtils.test.js +1 -1
  226. package/dist/tests/service.test.js +4 -4
  227. package/dist/tests/service.test.js.map +1 -1
  228. package/dist/tests/sourceFile.test.js +19 -1
  229. package/dist/tests/sourceFile.test.js.map +1 -1
  230. package/dist/tests/stringUtils.test.js +0 -12
  231. package/dist/tests/stringUtils.test.js.map +1 -1
  232. package/dist/tests/testStateUtils.js +8 -3
  233. package/dist/tests/testStateUtils.js.map +1 -1
  234. package/dist/tests/tokenizer.test.js +5 -5
  235. package/dist/tests/tokenizer.test.js.map +1 -1
  236. package/dist/tests/typeEvaluator1.test.js +11 -13
  237. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  238. package/dist/tests/typeEvaluator2.test.js +15 -1
  239. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  240. package/dist/tests/typeEvaluator4.test.js +16 -1
  241. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  242. package/dist/tests/typeEvaluator5.test.js +9 -3
  243. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  244. package/dist/tests/typeEvaluator6.test.js +1 -1
  245. package/dist/tests/typeEvaluator7.test.js +9 -0
  246. package/dist/tests/typeEvaluator7.test.js.map +1 -1
  247. package/dist/tests/typeEvaluator8.test.js +4 -0
  248. package/dist/tests/typeEvaluator8.test.js.map +1 -1
  249. package/dist/tests/workspaceEditUtils.test.js +7 -9
  250. package/dist/tests/workspaceEditUtils.test.js.map +1 -1
  251. package/dist/types.d.ts +1 -1
  252. package/dist/workspaceFactory.d.ts +12 -1
  253. package/dist/workspaceFactory.js.map +1 -1
  254. package/package.json +2 -3
  255. package/dist/tests/fourslash/rename.args.fourslash.js +0 -72
  256. package/dist/tests/fourslash/rename.args.fourslash.js.map +0 -1
  257. /package/dist/tests/fourslash/{rename.args.fourslash.d.ts → completions.autoimport.unicode.fourslash.d.ts} +0 -0
@@ -8,7 +8,7 @@ import { EditableProgram, ProgramView } from '../common/extensibility';
8
8
  import { LogTracker } from '../common/logTracker';
9
9
  import { ServiceProvider } from '../common/serviceProvider';
10
10
  import '../common/serviceProviderExtensions';
11
- import { Range } from '../common/textRange';
11
+ import { Range, TextRange } from '../common/textRange';
12
12
  import { Uri } from '../common/uri/uri';
13
13
  import { ParseFileResults, ParserOutput } from '../parser/parser';
14
14
  import { RequiringAnalysisCount } from './analysis';
@@ -16,7 +16,7 @@ import { ImportResolver } from './importResolver';
16
16
  import { IPythonMode, SourceFile } from './sourceFile';
17
17
  import { SourceFileInfo } from './sourceFileInfo';
18
18
  import { SourceMapper } from './sourceMapper';
19
- import { Symbol } from './symbol';
19
+ import { Symbol, SymbolTable } from './symbol';
20
20
  import { PrintTypeOptions, TypeEvaluator } from './typeEvaluatorTypes';
21
21
  import { Type } from './types';
22
22
  export interface MaxAnalysisTime {
@@ -24,10 +24,15 @@ export interface MaxAnalysisTime {
24
24
  noOpenFilesTimeInMs: number;
25
25
  }
26
26
  export type PreCheckCallback = (parserOutput: ParserOutput, evaluator: TypeEvaluator) => void;
27
+ export interface ChangedRange {
28
+ range: TextRange;
29
+ delta: number;
30
+ }
27
31
  export interface OpenFileOptions {
28
32
  isTracked: boolean;
29
33
  ipythonMode: IPythonMode;
30
34
  chainedFileUri: Uri | undefined;
35
+ changedRange?: ChangedRange;
31
36
  }
32
37
  export declare class Program {
33
38
  readonly serviceProvider: ServiceProvider;
@@ -43,6 +48,7 @@ export declare class Program {
43
48
  private _configOptions;
44
49
  private _importResolver;
45
50
  private _evaluator;
51
+ private _disposed;
46
52
  private _parsedFileCount;
47
53
  private _preCheckCallback;
48
54
  private _editModeTracker;
@@ -55,6 +61,7 @@ export declare class Program {
55
61
  get configOptions(): ConfigOptions;
56
62
  get importResolver(): ImportResolver;
57
63
  get fileSystem(): import("../common/fileSystem").FileSystem;
64
+ get isDisposed(): boolean;
58
65
  dispose(): void;
59
66
  enterEditMode(): void;
60
67
  exitEditMode(): FileEditAction[];
@@ -87,6 +94,7 @@ export declare class Program {
87
94
  getBoundSourceFile(uri: Uri): SourceFile | undefined;
88
95
  getSourceFileInfoList(): readonly SourceFileInfo[];
89
96
  getSourceFileInfo(uri: Uri): SourceFileInfo | undefined;
97
+ getModuleSymbolTable(fileUri: Uri): SymbolTable | undefined;
90
98
  getBoundSourceFileInfo(uri: Uri, content?: string, force?: boolean): SourceFileInfo | undefined;
91
99
  analyze(maxTime?: MaxAnalysisTime, token?: CancellationToken): boolean;
92
100
  analyzeFile(fileUri: Uri, token?: CancellationToken): boolean;
@@ -96,6 +104,7 @@ export declare class Program {
96
104
  getSourceMapper(fileUri: Uri, token: CancellationToken, mapCompiled?: boolean, preferStubs?: boolean): SourceMapper;
97
105
  getParserOutput(fileUri: Uri): ParserOutput | undefined;
98
106
  getParseResults(fileUri: Uri): ParseFileResults | undefined;
107
+ getParseDiagnostics(fileUri: Uri): Diagnostic[] | undefined;
99
108
  handleMemoryHighUsage(): void;
100
109
  printDetailedAnalysisTimes(): void;
101
110
  printDependencies(projectRootDir: Uri, verbose: boolean): void;
@@ -108,6 +117,7 @@ export declare class Program {
108
117
  clone(): Program;
109
118
  getCacheUsage(): number;
110
119
  emptyCache(): void;
120
+ bindShadowFile(stubFileUri: Uri, shadowFile: Uri): SourceFile | undefined;
111
121
  private _handleMemoryHighUsage;
112
122
  private _discardCachedParseResults;
113
123
  private _runEvaluatorWithCancellationToken;
@@ -97,6 +97,7 @@ class Program {
97
97
  this._disableChecker = _disableChecker;
98
98
  this._sourceFileList = [];
99
99
  this._sourceFileMap = new Map();
100
+ this._disposed = false;
100
101
  this._parsedFileCount = 0;
101
102
  this._editModeTracker = new EditModeTracker();
102
103
  this._lookUpImport = (fileUriOrModule, options) => {
@@ -198,8 +199,12 @@ class Program {
198
199
  get fileSystem() {
199
200
  return this._importResolver.fileSystem;
200
201
  }
202
+ get isDisposed() {
203
+ return this._disposed;
204
+ }
201
205
  dispose() {
202
206
  this._cacheManager.unregisterCacheOwner(this);
207
+ this._disposed = true;
203
208
  }
204
209
  enterEditMode() {
205
210
  this._editModeTracker.enable();
@@ -218,10 +223,10 @@ class Program {
218
223
  const newContents = fileInfo.restore();
219
224
  if (newContents) {
220
225
  // Create a text document so we can compute the edits.
221
- const textDocument = vscode_languageserver_textdocument_1.TextDocument.create(fileInfo.sourceFile.getUri().toString(), 'python', 1, fileInfo.sourceFile.getFileContent() || '');
226
+ const textDocument = vscode_languageserver_textdocument_1.TextDocument.create(fileInfo.uri.toString(), 'python', 1, fileInfo.contents || '');
222
227
  // Add an edit action to the list.
223
228
  edits.push({
224
- fileUri: fileInfo.sourceFile.getUri(),
229
+ fileUri: fileInfo.uri,
225
230
  range: {
226
231
  start: { line: 0, character: 0 },
227
232
  end: { line: textDocument.lineCount, character: 0 },
@@ -239,7 +244,7 @@ class Program {
239
244
  // We don't need to care about file diagnostics since in edit mode
240
245
  // checker won't run.
241
246
  v.sourceFile.prepareForClose();
242
- this._removeSourceFileFromListAndMap(v.sourceFile.getUri(), i);
247
+ this._removeSourceFileFromListAndMap(v.uri, i);
243
248
  }
244
249
  }
245
250
  }
@@ -273,7 +278,7 @@ class Program {
273
278
  // Files that are not in the tracked file list are
274
279
  // marked as no longer tracked.
275
280
  this._sourceFileList.forEach((oldFile) => {
276
- const fileUri = oldFile.sourceFile.getUri();
281
+ const fileUri = oldFile.uri;
277
282
  if (!newFileMap.has(fileUri.key)) {
278
283
  oldFile.isTracked = false;
279
284
  }
@@ -322,8 +327,7 @@ class Program {
322
327
  return sourceFileInfo.sourceFile;
323
328
  }
324
329
  const sourceFile = this._sourceFileFactory.createSourceFile(this.serviceProvider, fileUri, importName, isThirdPartyImport, isInPyTypedPackage, this._editModeTracker, this._console, this._logTracker);
325
- sourceFileInfo = new sourceFileInfo_1.SourceFileInfo(sourceFile,
326
- /* isTypeshedFile */ false, isThirdPartyImport, isInPyTypedPackage, this._editModeTracker, {
330
+ sourceFileInfo = new sourceFileInfo_1.SourceFileInfo(sourceFile, sourceFile.isTypingStubFile() || sourceFile.isTypeshedStubFile() || sourceFile.isBuiltInStubFile(), isThirdPartyImport, isInPyTypedPackage, this._editModeTracker, {
327
331
  isTracked: true,
328
332
  });
329
333
  this._addToSourceFileListAndMap(sourceFileInfo);
@@ -359,7 +363,7 @@ class Program {
359
363
  }
360
364
  getChainedUri(fileUri) {
361
365
  const sourceFileInfo = this.getSourceFileInfo(fileUri);
362
- return sourceFileInfo?.chainedSourceFile?.sourceFile.getUri();
366
+ return sourceFileInfo?.chainedSourceFile?.uri;
363
367
  }
364
368
  updateChainedUri(fileUri, chainedFileUri) {
365
369
  const sourceFileInfo = this.getSourceFileInfo(fileUri);
@@ -451,10 +455,10 @@ class Program {
451
455
  return this._sourceFileList.filter((s) => s.isOpenByClient);
452
456
  }
453
457
  getOwnedFiles() {
454
- return this._sourceFileList.filter((s) => (0, sourceFileInfoUtils_1.isUserCode)(s) && this.owns(s.sourceFile.getUri()));
458
+ return this._sourceFileList.filter((s) => (0, sourceFileInfoUtils_1.isUserCode)(s) && this.owns(s.uri));
455
459
  }
456
460
  getCheckingRequiredFiles() {
457
- return this._sourceFileList.filter((s) => s.isOpenByClient && this.owns(s.sourceFile.getUri()) && s.sourceFile.isCheckingRequired());
461
+ return this._sourceFileList.filter((s) => s.isOpenByClient && this.owns(s.uri) && s.sourceFile.isCheckingRequired());
458
462
  }
459
463
  getFilesToAnalyzeCount() {
460
464
  let filesToAnalyzeCount = 0;
@@ -485,7 +489,7 @@ class Program {
485
489
  }
486
490
  containsSourceFileIn(folder) {
487
491
  for (const normalizedSourceFilePath of this._sourceFileMap.values()) {
488
- if (normalizedSourceFilePath.sourceFile.getUri().startsWith(folder)) {
492
+ if (normalizedSourceFilePath.uri.startsWith(folder)) {
489
493
  return true;
490
494
  }
491
495
  }
@@ -519,6 +523,13 @@ class Program {
519
523
  }
520
524
  return undefined;
521
525
  }
526
+ getModuleSymbolTable(fileUri) {
527
+ const sourceFileInfo = this.getSourceFileInfo(fileUri);
528
+ if (sourceFileInfo) {
529
+ return sourceFileInfo.sourceFile.getModuleSymbolTable();
530
+ }
531
+ return undefined;
532
+ }
522
533
  getBoundSourceFileInfo(uri, content, force) {
523
534
  const sourceFileInfo = this.getSourceFileInfo(uri);
524
535
  if (!sourceFileInfo) {
@@ -619,6 +630,11 @@ class Program {
619
630
  /* content */ undefined,
620
631
  /* force */ true)?.sourceFile.getParseResults();
621
632
  }
633
+ getParseDiagnostics(fileUri) {
634
+ return this.getBoundSourceFileInfo(fileUri,
635
+ /* content */ undefined,
636
+ /* force */ true)?.sourceFile.getParseDiagnostics();
637
+ }
622
638
  handleMemoryHighUsage() {
623
639
  this._handleMemoryHighUsage();
624
640
  }
@@ -634,7 +650,7 @@ class Program {
634
650
  this._console.info('Analysis time by file');
635
651
  sortedFiles.forEach((sfInfo) => {
636
652
  const checkTimeInMs = sfInfo.sourceFile.getCheckTime();
637
- this._console.info(`${checkTimeInMs}ms: ${sfInfo.sourceFile.getUri()}`);
653
+ this._console.info(`${checkTimeInMs}ms: ${sfInfo.uri}`);
638
654
  });
639
655
  }
640
656
  // Prints import dependency information for each of the files in
@@ -644,12 +660,12 @@ class Program {
644
660
  const sortedFiles = this._sourceFileList
645
661
  .filter((s) => !s.isTypeshedFile)
646
662
  .sort((a, b) => {
647
- return fs.getOriginalUri(a.sourceFile.getUri()) < fs.getOriginalUri(b.sourceFile.getUri()) ? 1 : -1;
663
+ return fs.getOriginalUri(a.uri) < fs.getOriginalUri(b.uri) ? 1 : -1;
648
664
  });
649
665
  const zeroImportFiles = [];
650
666
  sortedFiles.forEach((sfInfo) => {
651
667
  this._console.info('');
652
- const fileUri = fs.getOriginalUri(sfInfo.sourceFile.getUri());
668
+ const fileUri = fs.getOriginalUri(sfInfo.uri);
653
669
  let fileString = fileUri.toString();
654
670
  const relPath = projectRootDir.getRelativePathComponents(fileUri);
655
671
  if (relPath) {
@@ -659,13 +675,13 @@ class Program {
659
675
  this._console.info(` Imports ${sfInfo.imports.length} ` + `file${sfInfo.imports.length === 1 ? '' : 's'}`);
660
676
  if (verbose) {
661
677
  sfInfo.imports.forEach((importInfo) => {
662
- this._console.info(` ${fs.getOriginalUri(importInfo.sourceFile.getUri())}`);
678
+ this._console.info(` ${fs.getOriginalUri(importInfo.uri)}`);
663
679
  });
664
680
  }
665
681
  this._console.info(` Imported by ${sfInfo.importedBy.length} ` + `file${sfInfo.importedBy.length === 1 ? '' : 's'}`);
666
682
  if (verbose) {
667
683
  sfInfo.importedBy.forEach((importInfo) => {
668
- this._console.info(` ${fs.getOriginalUri(importInfo.sourceFile.getUri())}`);
684
+ this._console.info(` ${fs.getOriginalUri(importInfo.uri)}`);
669
685
  });
670
686
  }
671
687
  if (sfInfo.importedBy.length === 0) {
@@ -683,7 +699,7 @@ class Program {
683
699
  writeTypeStub(targetImportPath, targetIsSingleFile, stubPath, token) {
684
700
  for (const sourceFileInfo of this._sourceFileList) {
685
701
  (0, cancellationUtils_1.throwIfCancellationRequested)(token);
686
- const fileUri = sourceFileInfo.sourceFile.getUri();
702
+ const fileUri = sourceFileInfo.uri;
687
703
  // Generate type stubs only for the files within the target path,
688
704
  // not any files that the target module happened to import.
689
705
  const relativePath = targetImportPath.getRelativePath(fileUri);
@@ -761,7 +777,7 @@ class Program {
761
777
  diag.category !== 5 /* DiagnosticCategory.Deprecated */);
762
778
  }
763
779
  fileDiagnostics.push({
764
- fileUri: sourceFileInfo.sourceFile.getUri(),
780
+ fileUri: sourceFileInfo.uri,
765
781
  version: sourceFileInfo.sourceFile.getClientVersion(),
766
782
  diagnostics,
767
783
  });
@@ -776,7 +792,7 @@ class Program {
776
792
  // This condition occurs when the user switches from workspace to
777
793
  // "open files only" mode. Clear all diagnostics for this file.
778
794
  fileDiagnostics.push({
779
- fileUri: sourceFileInfo.sourceFile.getUri(),
795
+ fileUri: sourceFileInfo.uri,
780
796
  version: sourceFileInfo.sourceFile.getClientVersion(),
781
797
  diagnostics: [],
782
798
  });
@@ -802,7 +818,7 @@ class Program {
802
818
  const program = new Program(this._importResolver, this._configOptions, this.serviceProvider, new logTracker_1.LogTracker(this._console, 'Cloned'), this._disableChecker);
803
819
  // Cloned program will use whatever user files the program currently has.
804
820
  const userFiles = this.getUserFiles();
805
- program.setTrackedFiles(userFiles.map((i) => i.sourceFile.getUri()));
821
+ program.setTrackedFiles(userFiles.map((i) => i.uri));
806
822
  program.markAllFilesDirty(/* evenIfContentsAreSame */ true);
807
823
  // Make sure we keep editor content (open file) which could be different than one in the file system.
808
824
  for (const fileInfo of this.getOpened()) {
@@ -810,9 +826,9 @@ class Program {
810
826
  if (version === undefined) {
811
827
  continue;
812
828
  }
813
- program.setFileOpened(fileInfo.sourceFile.getUri(), version, fileInfo.sourceFile.getOpenFileContents() ?? '', {
814
- chainedFileUri: fileInfo.chainedSourceFile?.sourceFile.getUri(),
815
- ipythonMode: fileInfo.sourceFile.getIPythonMode(),
829
+ program.setFileOpened(fileInfo.uri, version, fileInfo.sourceFile.getOpenFileContents() ?? '', {
830
+ chainedFileUri: fileInfo.chainedSourceFile?.uri,
831
+ ipythonMode: fileInfo.ipythonMode,
816
832
  isTracked: fileInfo.isTracked,
817
833
  });
818
834
  }
@@ -835,6 +851,20 @@ class Program {
835
851
  this._parsedFileCount = 0;
836
852
  this.serviceProvider.tryGet(serviceKeys_1.ServiceKeys.stateMutationListeners)?.forEach((l) => l.onClearCache?.());
837
853
  }
854
+ bindShadowFile(stubFileUri, shadowFile) {
855
+ let stubFileInfo = this.getSourceFileInfo(stubFileUri);
856
+ if (!stubFileInfo) {
857
+ // make sure uri exits before adding interimFile
858
+ if (!this.fileSystem.existsSync(stubFileUri)) {
859
+ return undefined;
860
+ }
861
+ // Special case for import statement like "import X.Y". The SourceFile
862
+ // for X might not be in memory since import `X.Y` only brings in Y.
863
+ stubFileInfo = this.addInterimFile(stubFileUri);
864
+ }
865
+ this._addShadowedFile(stubFileInfo, shadowFile);
866
+ return this.getBoundSourceFile(shadowFile);
867
+ }
838
868
  _handleMemoryHighUsage() {
839
869
  const cacheUsage = this._cacheManager.getCacheUsage();
840
870
  const usedHeapRatio = this._cacheManager.getUsedHeapRatio(this._configOptions.verboseOutput ? this._console : undefined);
@@ -898,13 +928,13 @@ class Program {
898
928
  // Clear only if there are any errors for this file.
899
929
  if (fileInfo.diagnosticsVersion !== undefined) {
900
930
  fileDiagnostics.push({
901
- fileUri: fileInfo.sourceFile.getUri(),
931
+ fileUri: fileInfo.uri,
902
932
  version: fileInfo.sourceFile.getClientVersion(),
903
933
  diagnostics: [],
904
934
  });
905
935
  }
906
936
  fileInfo.sourceFile.prepareForClose();
907
- this._removeSourceFileFromListAndMap(fileInfo.sourceFile.getUri(), i);
937
+ this._removeSourceFileFromListAndMap(fileInfo.uri, i);
908
938
  // Unlink any imports and remove them from the list if
909
939
  // they are no longer referenced.
910
940
  fileInfo.imports.forEach((importedFile) => {
@@ -922,13 +952,13 @@ class Program {
922
952
  // Clear if there are any errors for this import.
923
953
  if (importedFile.diagnosticsVersion !== undefined) {
924
954
  fileDiagnostics.push({
925
- fileUri: importedFile.sourceFile.getUri(),
955
+ fileUri: importedFile.uri,
926
956
  version: importedFile.sourceFile.getClientVersion(),
927
957
  diagnostics: [],
928
958
  });
929
959
  }
930
960
  importedFile.sourceFile.prepareForClose();
931
- this._removeSourceFileFromListAndMap(importedFile.sourceFile.getUri(), indexToRemove);
961
+ this._removeSourceFileFromListAndMap(importedFile.uri, indexToRemove);
932
962
  i--;
933
963
  }
934
964
  }
@@ -944,7 +974,7 @@ class Program {
944
974
  // out the errors for the now-closed file.
945
975
  if (!this._shouldCheckFile(fileInfo) && fileInfo.diagnosticsVersion !== undefined) {
946
976
  fileDiagnostics.push({
947
- fileUri: fileInfo.sourceFile.getUri(),
977
+ fileUri: fileInfo.uri,
948
978
  version: fileInfo.sourceFile.getClientVersion(),
949
979
  diagnostics: [],
950
980
  });
@@ -978,7 +1008,7 @@ class Program {
978
1008
  if (fileInfo.isTracked || fileInfo.isOpenByClient || fileInfo.shadows.length > 0) {
979
1009
  return true;
980
1010
  }
981
- const fileUri = fileInfo.sourceFile.getUri();
1011
+ const fileUri = fileInfo.uri;
982
1012
  // Avoid infinite recursion.
983
1013
  if (recursionSet.has(fileUri.key)) {
984
1014
  return false;
@@ -992,20 +1022,7 @@ class Program {
992
1022
  return false;
993
1023
  }
994
1024
  _createSourceMapper(execEnv, token, from, mapCompiled, preferStubs) {
995
- const sourceMapper = new sourceMapper_1.SourceMapper(this._importResolver, execEnv, this._evaluator, (stubFileUri, implFileUri) => {
996
- let stubFileInfo = this.getSourceFileInfo(stubFileUri);
997
- if (!stubFileInfo) {
998
- // make sure uri exits before adding interimFile
999
- if (!this.fileSystem.existsSync(stubFileUri)) {
1000
- return undefined;
1001
- }
1002
- // Special case for import statement like "import X.Y". The SourceFile
1003
- // for X might not be in memory since import `X.Y` only brings in Y.
1004
- stubFileInfo = this.addInterimFile(stubFileUri);
1005
- }
1006
- this._addShadowedFile(stubFileInfo, implFileUri);
1007
- return this.getBoundSourceFile(implFileUri);
1008
- }, (f) => {
1025
+ const sourceMapper = new sourceMapper_1.SourceMapper(this._importResolver, execEnv, this._evaluator, (stubFileUri, implFileUri) => this.bindShadowFile(stubFileUri, implFileUri), (f) => {
1009
1026
  let fileInfo = this.getBoundSourceFileInfo(f);
1010
1027
  if (!fileInfo) {
1011
1028
  // make sure uri exits before adding interimFile
@@ -1120,7 +1137,7 @@ class Program {
1120
1137
  sourceFileInfo.chainedSourceFile = undefined;
1121
1138
  }
1122
1139
  else {
1123
- const fileUri = sourceFileInfo.chainedSourceFile.sourceFile.getUri();
1140
+ const fileUri = sourceFileInfo.chainedSourceFile.uri;
1124
1141
  newImportPathMap.set(fileUri.key, {
1125
1142
  path: fileUri,
1126
1143
  isTypeshedFile: false,
@@ -1167,7 +1184,7 @@ class Program {
1167
1184
  if (!sourceFileInfo.sourceFile.isStubFile() && !importResult.isStdlibTypeshedFile) {
1168
1185
  if (options.verboseOutput) {
1169
1186
  this._console.info(`Could not resolve source for '${importResult.importName}' ` +
1170
- `in file '${sourceFileInfo.sourceFile.getUri().toUserVisibleString()}'`);
1187
+ `in file '${sourceFileInfo.uri.toUserVisibleString()}'`);
1171
1188
  if (importResult.nonStubImportResult.importFailureInfo) {
1172
1189
  importResult.nonStubImportResult.importFailureInfo.forEach((diag) => {
1173
1190
  this._console.info(` ${diag}`);
@@ -1179,7 +1196,7 @@ class Program {
1179
1196
  }
1180
1197
  else if (options.verboseOutput) {
1181
1198
  this._console.info(`Could not import '${importResult.importName}' ` +
1182
- `in file '${sourceFileInfo.sourceFile.getUri().toUserVisibleString()}'`);
1199
+ `in file '${sourceFileInfo.uri.toUserVisibleString()}'`);
1183
1200
  if (importResult.importFailureInfo) {
1184
1201
  importResult.importFailureInfo.forEach((diag) => {
1185
1202
  this._console.info(` ${diag}`);
@@ -1189,11 +1206,11 @@ class Program {
1189
1206
  });
1190
1207
  const updatedImportMap = new Map();
1191
1208
  sourceFileInfo.imports.forEach((importInfo) => {
1192
- const oldFilePath = importInfo.sourceFile.getUri();
1209
+ const oldFilePath = importInfo.uri;
1193
1210
  // A previous import was removed.
1194
1211
  if (!newImportPathMap.has(oldFilePath.key)) {
1195
1212
  importInfo.mutate((s) => {
1196
- s.importedBy = s.importedBy.filter((fi) => !fi.sourceFile.getUri().equals(sourceFileInfo.sourceFile.getUri()));
1213
+ s.importedBy = s.importedBy.filter((fi) => !fi.uri.equals(sourceFileInfo.uri));
1197
1214
  });
1198
1215
  }
1199
1216
  else {
@@ -1246,7 +1263,7 @@ class Program {
1246
1263
  this._sourceFileList.splice(indexToRemove, 1);
1247
1264
  }
1248
1265
  _addToSourceFileListAndMap(fileInfo) {
1249
- const fileUri = fileInfo.sourceFile.getUri();
1266
+ const fileUri = fileInfo.uri;
1250
1267
  // We should never add a file with the same path twice.
1251
1268
  (0, debug_1.assert)(!this._sourceFileMap.has(fileUri.key));
1252
1269
  // We should never have an empty URI for a source file.
@@ -1350,7 +1367,7 @@ class Program {
1350
1367
  const implicitSet = new Set();
1351
1368
  let nextImplicitImport = this._getImplicitImports(fileToAnalyze);
1352
1369
  while (nextImplicitImport) {
1353
- const implicitPath = nextImplicitImport.sourceFile.getUri();
1370
+ const implicitPath = nextImplicitImport.uri;
1354
1371
  if (implicitSet.has(implicitPath.key)) {
1355
1372
  // We've found a cycle. Break out of the loop.
1356
1373
  debug.fail(this.serviceProvider
@@ -1441,7 +1458,7 @@ class Program {
1441
1458
  return false;
1442
1459
  }
1443
1460
  _checkTypes(fileToCheck, token, chainedByList) {
1444
- return this._logTracker.log(`analyzing: ${fileToCheck.sourceFile.getUri()}`, (logState) => {
1461
+ return this._logTracker.log(`analyzing: ${fileToCheck.uri}`, (logState) => {
1445
1462
  // If the file isn't needed because it was eliminated from the
1446
1463
  // transitive closure or deleted, skip the file rather than wasting
1447
1464
  // time on it.
@@ -1475,7 +1492,7 @@ class Program {
1475
1492
  }
1476
1493
  }
1477
1494
  if (boundFile) {
1478
- const execEnv = this._configOptions.findExecEnvironment(fileToCheck.sourceFile.getUri());
1495
+ const execEnv = this._configOptions.findExecEnvironment(fileToCheck.uri);
1479
1496
  fileToCheck.sourceFile.check(this.configOptions, this._lookUpImport, this._importResolver, this._evaluator, this._createSourceMapper(execEnv, token, fileToCheck), dependentFiles);
1480
1497
  }
1481
1498
  }
@@ -1487,8 +1504,7 @@ class Program {
1487
1504
  // Don't detect import cycles when doing type stub generation. Some
1488
1505
  // third-party modules are pretty convoluted.
1489
1506
  // Or if the file is the notebook cell. notebook cell can't have cycles.
1490
- if (!this._allowedThirdPartyImports &&
1491
- fileToCheck.sourceFile.getIPythonMode() !== sourceFile_1.IPythonMode.CellDocs) {
1507
+ if (!this._allowedThirdPartyImports && fileToCheck.ipythonMode !== sourceFile_1.IPythonMode.CellDocs) {
1492
1508
  // We need to force all of the files to be parsed and build
1493
1509
  // a closure map for the files.
1494
1510
  const closureMap = new Map();
@@ -1512,7 +1528,7 @@ class Program {
1512
1528
  });
1513
1529
  }
1514
1530
  _checkDependentFiles(fileToCheck, chainedByList, token) {
1515
- if (fileToCheck.sourceFile.getIPythonMode() !== sourceFile_1.IPythonMode.CellDocs) {
1531
+ if (fileToCheck.ipythonMode !== sourceFile_1.IPythonMode.CellDocs) {
1516
1532
  return undefined;
1517
1533
  }
1518
1534
  // If we don't have chainedByList, it means none of them are checked yet.
@@ -1567,7 +1583,7 @@ class Program {
1567
1583
  _getImportsRecursive(file, closureMap, recursionCount) {
1568
1584
  // If the file is already in the closure map, we found a cyclical
1569
1585
  // dependency. Don't recur further.
1570
- const fileUri = file.sourceFile.getUri();
1586
+ const fileUri = file.uri;
1571
1587
  if (closureMap.has(fileUri.key)) {
1572
1588
  return;
1573
1589
  }
@@ -1601,7 +1617,7 @@ class Program {
1601
1617
  if (sourceFileInfo.sourceFile.isNoCircularDependencyConfirmed()) {
1602
1618
  return false;
1603
1619
  }
1604
- const fileUri = sourceFileInfo.sourceFile.getUri();
1620
+ const fileUri = sourceFileInfo.uri;
1605
1621
  filesVisited.set(fileUri.key, sourceFileInfo);
1606
1622
  let detectedCycle = false;
1607
1623
  if (dependencyMap.has(fileUri.key)) {
@@ -1645,7 +1661,7 @@ class Program {
1645
1661
  _logImportCycle(dependencyChain) {
1646
1662
  const circDep = new circularDependency_1.CircularDependency();
1647
1663
  dependencyChain.forEach((sourceFileInfo) => {
1648
- circDep.appendPath(sourceFileInfo.sourceFile.getUri());
1664
+ circDep.appendPath(sourceFileInfo.uri);
1649
1665
  });
1650
1666
  circDep.normalizeOrder();
1651
1667
  const firstFilePath = circDep.getPaths()[0];
@@ -1654,7 +1670,7 @@ class Program {
1654
1670
  firstSourceFile.sourceFile.addCircularDependency(this.configOptions, circDep);
1655
1671
  }
1656
1672
  _markFileDirtyRecursive(sourceFileInfo, markSet, forceRebinding = false) {
1657
- const fileUri = sourceFileInfo.sourceFile.getUri();
1673
+ const fileUri = sourceFileInfo.uri;
1658
1674
  // Don't mark it again if it's already been visited.
1659
1675
  if (markSet.has(fileUri.key)) {
1660
1676
  return;