@zzzen/pyright-internal 1.2.0-dev.20221009 → 1.2.0-dev.20221127

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 (338) hide show
  1. package/dist/analyzer/backgroundAnalysisProgram.d.ts +10 -10
  2. package/dist/analyzer/backgroundAnalysisProgram.js +21 -54
  3. package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
  4. package/dist/analyzer/binder.js +43 -32
  5. package/dist/analyzer/binder.js.map +1 -1
  6. package/dist/analyzer/cacheManager.d.ts +7 -7
  7. package/dist/analyzer/cacheManager.js +17 -15
  8. package/dist/analyzer/cacheManager.js.map +1 -1
  9. package/dist/analyzer/checker.d.ts +16 -3
  10. package/dist/analyzer/checker.js +295 -143
  11. package/dist/analyzer/checker.js.map +1 -1
  12. package/dist/analyzer/codeFlowEngine.d.ts +2 -2
  13. package/dist/analyzer/codeFlowEngine.js +85 -88
  14. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  15. package/dist/analyzer/codeFlowTypes.d.ts +1 -0
  16. package/dist/analyzer/codeFlowTypes.js +3 -1
  17. package/dist/analyzer/codeFlowTypes.js.map +1 -1
  18. package/dist/analyzer/constraintSolver.js +1 -1
  19. package/dist/analyzer/constraintSolver.js.map +1 -1
  20. package/dist/analyzer/dataClasses.d.ts +3 -3
  21. package/dist/analyzer/dataClasses.js +77 -57
  22. package/dist/analyzer/dataClasses.js.map +1 -1
  23. package/dist/analyzer/declaration.js.map +1 -1
  24. package/dist/analyzer/declarationUtils.d.ts +1 -1
  25. package/dist/analyzer/declarationUtils.js +6 -4
  26. package/dist/analyzer/declarationUtils.js.map +1 -1
  27. package/dist/analyzer/docStringConversion.js +4 -3
  28. package/dist/analyzer/docStringConversion.js.map +1 -1
  29. package/dist/analyzer/importResolver.d.ts +4 -0
  30. package/dist/analyzer/importResolver.js +53 -10
  31. package/dist/analyzer/importResolver.js.map +1 -1
  32. package/dist/analyzer/importResult.d.ts +1 -0
  33. package/dist/analyzer/namedTuples.js +1 -1
  34. package/dist/analyzer/namedTuples.js.map +1 -1
  35. package/dist/analyzer/packageTypeVerifier.d.ts +2 -1
  36. package/dist/analyzer/packageTypeVerifier.js +16 -10
  37. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  38. package/dist/analyzer/parseTreeUtils.d.ts +2 -1
  39. package/dist/analyzer/parseTreeUtils.js +38 -3
  40. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  41. package/dist/analyzer/parseTreeWalker.d.ts +86 -79
  42. package/dist/analyzer/parseTreeWalker.js +384 -201
  43. package/dist/analyzer/parseTreeWalker.js.map +1 -1
  44. package/dist/analyzer/program.d.ts +9 -9
  45. package/dist/analyzer/program.js +90 -86
  46. package/dist/analyzer/program.js.map +1 -1
  47. package/dist/analyzer/properties.js +10 -3
  48. package/dist/analyzer/properties.js.map +1 -1
  49. package/dist/analyzer/protocols.js +1 -1
  50. package/dist/analyzer/protocols.js.map +1 -1
  51. package/dist/analyzer/regions.d.ts +11 -0
  52. package/dist/analyzer/regions.js +57 -0
  53. package/dist/analyzer/regions.js.map +1 -0
  54. package/dist/analyzer/service.d.ts +11 -6
  55. package/dist/analyzer/service.js +69 -30
  56. package/dist/analyzer/service.js.map +1 -1
  57. package/dist/analyzer/sourceFile.d.ts +5 -2
  58. package/dist/analyzer/sourceFile.js +21 -8
  59. package/dist/analyzer/sourceFile.js.map +1 -1
  60. package/dist/analyzer/sourceFileInfoUtils.d.ts +1 -1
  61. package/dist/analyzer/sourceFileInfoUtils.js +1 -1
  62. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
  63. package/dist/analyzer/sourceMapper.d.ts +11 -3
  64. package/dist/analyzer/sourceMapper.js +61 -14
  65. package/dist/analyzer/sourceMapper.js.map +1 -1
  66. package/dist/analyzer/sourceMapperUtils.d.ts +10 -0
  67. package/dist/analyzer/sourceMapperUtils.js +57 -0
  68. package/dist/analyzer/sourceMapperUtils.js.map +1 -0
  69. package/dist/analyzer/staticExpressions.js +19 -9
  70. package/dist/analyzer/staticExpressions.js.map +1 -1
  71. package/dist/analyzer/symbolUtils.d.ts +1 -0
  72. package/dist/analyzer/symbolUtils.js +5 -1
  73. package/dist/analyzer/symbolUtils.js.map +1 -1
  74. package/dist/analyzer/typeEvaluator.js +654 -258
  75. package/dist/analyzer/typeEvaluator.js.map +1 -1
  76. package/dist/analyzer/typeEvaluatorTypes.d.ts +15 -4
  77. package/dist/analyzer/typeGuards.js +9 -0
  78. package/dist/analyzer/typeGuards.js.map +1 -1
  79. package/dist/analyzer/typePrinter.d.ts +3 -1
  80. package/dist/analyzer/typePrinter.js +135 -26
  81. package/dist/analyzer/typePrinter.js.map +1 -1
  82. package/dist/analyzer/typeStubWriter.js +5 -1
  83. package/dist/analyzer/typeStubWriter.js.map +1 -1
  84. package/dist/analyzer/typeUtils.d.ts +4 -2
  85. package/dist/analyzer/typeUtils.js +112 -25
  86. package/dist/analyzer/typeUtils.js.map +1 -1
  87. package/dist/analyzer/typedDicts.js +8 -6
  88. package/dist/analyzer/typedDicts.js.map +1 -1
  89. package/dist/analyzer/types.d.ts +8 -5
  90. package/dist/analyzer/types.js +49 -20
  91. package/dist/analyzer/types.js.map +1 -1
  92. package/dist/backgroundAnalysisBase.d.ts +6 -4
  93. package/dist/backgroundAnalysisBase.js +30 -8
  94. package/dist/backgroundAnalysisBase.js.map +1 -1
  95. package/dist/backgroundThreadBase.d.ts +2 -1
  96. package/dist/backgroundThreadBase.js +4 -0
  97. package/dist/backgroundThreadBase.js.map +1 -1
  98. package/dist/commands/createTypeStub.js +3 -1
  99. package/dist/commands/createTypeStub.js.map +1 -1
  100. package/dist/common/configOptions.d.ts +1 -0
  101. package/dist/common/configOptions.js +4 -0
  102. package/dist/common/configOptions.js.map +1 -1
  103. package/dist/common/core.d.ts +2 -0
  104. package/dist/common/core.js +24 -3
  105. package/dist/common/core.js.map +1 -1
  106. package/dist/common/diagnostic.d.ts +8 -0
  107. package/dist/common/diagnostic.js +5 -1
  108. package/dist/common/diagnostic.js.map +1 -1
  109. package/dist/common/diagnosticRules.d.ts +2 -1
  110. package/dist/common/diagnosticRules.js +1 -0
  111. package/dist/common/diagnosticRules.js.map +1 -1
  112. package/dist/common/fileSystem.d.ts +1 -0
  113. package/dist/common/fileSystem.js.map +1 -1
  114. package/dist/common/pathUtils.d.ts +1 -0
  115. package/dist/common/pathUtils.js +13 -3
  116. package/dist/common/pathUtils.js.map +1 -1
  117. package/dist/common/pythonVersion.d.ts +1 -1
  118. package/dist/common/pythonVersion.js +1 -1
  119. package/dist/common/realFileSystem.js +12 -3
  120. package/dist/common/realFileSystem.js.map +1 -1
  121. package/dist/common/workspaceEditUtils.d.ts +6 -1
  122. package/dist/common/workspaceEditUtils.js +72 -1
  123. package/dist/common/workspaceEditUtils.js.map +1 -1
  124. package/dist/languageServerBase.d.ts +9 -5
  125. package/dist/languageServerBase.js +35 -21
  126. package/dist/languageServerBase.js.map +1 -1
  127. package/dist/languageService/analyzerServiceExecutor.d.ts +6 -2
  128. package/dist/languageService/analyzerServiceExecutor.js +7 -4
  129. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  130. package/dist/languageService/autoImporter.js +2 -1
  131. package/dist/languageService/autoImporter.js.map +1 -1
  132. package/dist/languageService/codeActionProvider.js +30 -0
  133. package/dist/languageService/codeActionProvider.js.map +1 -1
  134. package/dist/languageService/completionProvider.d.ts +1 -0
  135. package/dist/languageService/completionProvider.js +66 -28
  136. package/dist/languageService/completionProvider.js.map +1 -1
  137. package/dist/languageService/definitionProvider.d.ts +2 -0
  138. package/dist/languageService/definitionProvider.js +3 -0
  139. package/dist/languageService/definitionProvider.js.map +1 -1
  140. package/dist/languageService/documentSymbolCollector.js +7 -3
  141. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  142. package/dist/languageService/documentSymbolProvider.js +1 -1
  143. package/dist/languageService/documentSymbolProvider.js.map +1 -1
  144. package/dist/languageService/hoverProvider.d.ts +1 -1
  145. package/dist/languageService/hoverProvider.js +73 -38
  146. package/dist/languageService/hoverProvider.js.map +1 -1
  147. package/dist/languageService/referencesProvider.js +2 -1
  148. package/dist/languageService/referencesProvider.js.map +1 -1
  149. package/dist/languageService/signatureHelpProvider.js +1 -2
  150. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  151. package/dist/languageService/tooltipUtils.js +30 -19
  152. package/dist/languageService/tooltipUtils.js.map +1 -1
  153. package/dist/localization/localize.d.ts +33 -4
  154. package/dist/localization/localize.js +22 -5
  155. package/dist/localization/localize.js.map +1 -1
  156. package/dist/localization/package.nls.en-us.json +20 -3
  157. package/dist/parser/parseNodes.d.ts +2 -1
  158. package/dist/parser/parseNodes.js +6 -1
  159. package/dist/parser/parseNodes.js.map +1 -1
  160. package/dist/parser/parser.js +19 -13
  161. package/dist/parser/parser.js.map +1 -1
  162. package/dist/parser/tokenizer.js +2 -1
  163. package/dist/parser/tokenizer.js.map +1 -1
  164. package/dist/pyright.js +4 -4
  165. package/dist/pyright.js.map +1 -1
  166. package/dist/pyrightFileSystem.d.ts +1 -0
  167. package/dist/pyrightFileSystem.js +3 -0
  168. package/dist/pyrightFileSystem.js.map +1 -1
  169. package/dist/readonlyAugmentedFileSystem.d.ts +1 -0
  170. package/dist/readonlyAugmentedFileSystem.js +3 -0
  171. package/dist/readonlyAugmentedFileSystem.js.map +1 -1
  172. package/dist/server.d.ts +1 -1
  173. package/dist/server.js +1 -1
  174. package/dist/server.js.map +1 -1
  175. package/dist/tests/checker.test.js +25 -2
  176. package/dist/tests/checker.test.js.map +1 -1
  177. package/dist/tests/config.test.js +11 -0
  178. package/dist/tests/config.test.js.map +1 -1
  179. package/dist/tests/diagnostics.test.d.ts +1 -0
  180. package/dist/tests/diagnostics.test.js +37 -0
  181. package/dist/tests/diagnostics.test.js.map +1 -0
  182. package/dist/tests/docStringConversion.test.js +25 -0
  183. package/dist/tests/docStringConversion.test.js.map +1 -1
  184. package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js +1 -1
  185. package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js.map +1 -1
  186. package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js +5 -5
  187. package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js.map +1 -1
  188. package/dist/tests/fourslash/completions.classVariable.fourslash.js +28 -6
  189. package/dist/tests/fourslash/completions.classVariable.fourslash.js.map +1 -1
  190. package/dist/tests/fourslash/{signature.paramspec.fourslash.d.ts → completions.dunderNew.Inheritance.fourslash.d.ts} +0 -0
  191. package/dist/tests/fourslash/completions.dunderNew.Inheritance.fourslash.js +29 -0
  192. package/dist/tests/fourslash/completions.dunderNew.Inheritance.fourslash.js.map +1 -0
  193. package/dist/tests/fourslash/completions.dunderNew.fourslash.d.ts +1 -0
  194. package/dist/tests/fourslash/completions.dunderNew.fourslash.js +20 -0
  195. package/dist/tests/fourslash/completions.dunderNew.fourslash.js.map +1 -0
  196. package/dist/tests/fourslash/completions.fourslash.js +2 -2
  197. package/dist/tests/fourslash/completions.fourslash.js.map +1 -1
  198. package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js +1 -1
  199. package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js.map +1 -1
  200. package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js +1 -1
  201. package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js.map +1 -1
  202. package/dist/tests/fourslash/completions.libStub.fourslash.js +1 -1
  203. package/dist/tests/fourslash/completions.libStub.fourslash.js.map +1 -1
  204. package/dist/tests/fourslash/completions.localCode.fourslash.js +2 -2
  205. package/dist/tests/fourslash/completions.localCode.fourslash.js.map +1 -1
  206. package/dist/tests/fourslash/completions.plainText.fourslash.js +2 -2
  207. package/dist/tests/fourslash/completions.plainText.fourslash.js.map +1 -1
  208. package/dist/tests/fourslash/completions.self.fourslash.js +2 -2
  209. package/dist/tests/fourslash/completions.self.fourslash.js.map +1 -1
  210. package/dist/tests/fourslash/completions.wildcardimports.fourslash.js +1 -1
  211. package/dist/tests/fourslash/completions.wildcardimports.fourslash.js.map +1 -1
  212. package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.js +8 -6
  213. package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.js.map +1 -1
  214. package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js +2 -2
  215. package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js.map +1 -1
  216. package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.d.ts +1 -0
  217. package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.js +32 -0
  218. package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.js.map +1 -0
  219. package/dist/tests/fourslash/fourslash.d.ts +2 -1
  220. package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js +2 -2
  221. package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js.map +1 -1
  222. package/dist/tests/fourslash/hover.docFromSrc.fourslash.js +4 -4
  223. package/dist/tests/fourslash/hover.docFromSrc.fourslash.js.map +1 -1
  224. package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js +1 -1
  225. package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js.map +1 -1
  226. package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js +1 -1
  227. package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js.map +1 -1
  228. package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js +1 -1
  229. package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js.map +1 -1
  230. package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js +1 -1
  231. package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js.map +1 -1
  232. package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js +1 -1
  233. package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js.map +1 -1
  234. package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js +2 -2
  235. package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js.map +1 -1
  236. package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js +1 -1
  237. package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js.map +1 -1
  238. package/dist/tests/fourslash/hover.docstring.alias.fourslash.d.ts +1 -0
  239. package/dist/tests/fourslash/hover.docstring.alias.fourslash.js +24 -0
  240. package/dist/tests/fourslash/hover.docstring.alias.fourslash.js.map +1 -0
  241. package/dist/tests/fourslash/hover.docstring.links.fourslash.js +1 -1
  242. package/dist/tests/fourslash/hover.docstring.links.fourslash.js.map +1 -1
  243. package/dist/tests/fourslash/hover.docstring.split.fourslash.js +3 -3
  244. package/dist/tests/fourslash/hover.docstring.split.fourslash.js.map +1 -1
  245. package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.d.ts +1 -0
  246. package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.js +13 -0
  247. package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.js.map +1 -0
  248. package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.d.ts +1 -0
  249. package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.js +15 -0
  250. package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.js.map +1 -0
  251. package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.d.ts +1 -0
  252. package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.js +21 -0
  253. package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.js.map +1 -0
  254. package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.d.ts +1 -0
  255. package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.js +17 -0
  256. package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.js.map +1 -0
  257. package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.d.ts +1 -0
  258. package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.js +15 -0
  259. package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.js.map +1 -0
  260. package/dist/tests/fourslash/hover.fourslash.js +1 -1
  261. package/dist/tests/fourslash/hover.fourslash.js.map +1 -1
  262. package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js +3 -3
  263. package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js.map +1 -1
  264. package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js +2 -2
  265. package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js.map +1 -1
  266. package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js +2 -2
  267. package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js.map +1 -1
  268. package/dist/tests/fourslash/hover.init.fourslash.js +1 -1
  269. package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
  270. package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js +1 -1
  271. package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js.map +1 -1
  272. package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js +1 -1
  273. package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js.map +1 -1
  274. package/dist/tests/fourslash/hover.libStub.fourslash.js +1 -1
  275. package/dist/tests/fourslash/hover.libStub.fourslash.js.map +1 -1
  276. package/dist/tests/fourslash/hover.plainText.fourslash.js +1 -1
  277. package/dist/tests/fourslash/hover.plainText.fourslash.js.map +1 -1
  278. package/dist/tests/fourslash/hover.wildcardimports.fourslash.js +1 -1
  279. package/dist/tests/fourslash/hover.wildcardimports.fourslash.js.map +1 -1
  280. package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js +1 -1
  281. package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js.map +1 -1
  282. package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js +1 -1
  283. package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js.map +1 -1
  284. package/dist/tests/fourslash/shadowedImports.fourslash.d.ts +1 -0
  285. package/dist/tests/fourslash/shadowedImports.fourslash.js +75 -0
  286. package/dist/tests/fourslash/shadowedImports.fourslash.js.map +1 -0
  287. package/dist/tests/fourslash/signature.dunderNew.fourslash.d.ts +1 -0
  288. package/dist/tests/fourslash/signature.dunderNew.fourslash.js +24 -0
  289. package/dist/tests/fourslash/signature.dunderNew.fourslash.js.map +1 -0
  290. package/dist/tests/harness/fourslash/runner.js +1 -0
  291. package/dist/tests/harness/fourslash/runner.js.map +1 -1
  292. package/dist/tests/harness/fourslash/testLanguageService.d.ts +3 -1
  293. package/dist/tests/harness/fourslash/testLanguageService.js +4 -2
  294. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  295. package/dist/tests/harness/fourslash/testState.d.ts +8 -7
  296. package/dist/tests/harness/fourslash/testState.js +80 -161
  297. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  298. package/dist/tests/harness/fourslash/workspaceEditTestUtils.d.ts +16 -0
  299. package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +159 -0
  300. package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -0
  301. package/dist/tests/harness/vfs/filesystem.d.ts +1 -0
  302. package/dist/tests/harness/vfs/filesystem.js +3 -0
  303. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  304. package/dist/tests/ipythonMode.test.js +39 -0
  305. package/dist/tests/ipythonMode.test.js.map +1 -1
  306. package/dist/tests/logger.test.js +3 -1
  307. package/dist/tests/logger.test.js.map +1 -1
  308. package/dist/tests/pathUtils.test.js +7 -0
  309. package/dist/tests/pathUtils.test.js.map +1 -1
  310. package/dist/tests/sourceFile.test.js +34 -1
  311. package/dist/tests/sourceFile.test.js.map +1 -1
  312. package/dist/tests/sourceMapperUtils.test.d.ts +1 -0
  313. package/dist/tests/sourceMapperUtils.test.js +138 -0
  314. package/dist/tests/sourceMapperUtils.test.js.map +1 -0
  315. package/dist/tests/tokenizer.test.js +6 -2
  316. package/dist/tests/tokenizer.test.js.map +1 -1
  317. package/dist/tests/typeEvaluator1.test.js +16 -6
  318. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  319. package/dist/tests/typeEvaluator2.test.js +19 -3
  320. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  321. package/dist/tests/typeEvaluator3.test.js +44 -10
  322. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  323. package/dist/tests/typeEvaluator4.test.js +11 -3
  324. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  325. package/dist/tests/typeEvaluator5.test.js +48 -0
  326. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  327. package/dist/tests/typePrinter.test.d.ts +1 -0
  328. package/dist/tests/typePrinter.test.js +148 -0
  329. package/dist/tests/typePrinter.test.js.map +1 -0
  330. package/dist/tests/workspaceEditUtils.test.d.ts +1 -0
  331. package/dist/tests/workspaceEditUtils.test.js +167 -0
  332. package/dist/tests/workspaceEditUtils.test.js.map +1 -0
  333. package/dist/workspaceMap.d.ts +2 -0
  334. package/dist/workspaceMap.js +45 -15
  335. package/dist/workspaceMap.js.map +1 -1
  336. package/package.json +3 -3
  337. package/dist/tests/fourslash/signature.paramspec.fourslash.js +0 -30
  338. package/dist/tests/fourslash/signature.paramspec.fourslash.js.map +0 -1
@@ -68,7 +68,7 @@ exports.MaxWorkspaceIndexFileCount = 2000;
68
68
  // Opened - temporarily opened in the editor
69
69
  // Shadowed - implementation file that shadows a type stub file
70
70
  class Program {
71
- constructor(initialImportResolver, initialConfigOptions, console, _extension, logTracker, _disableChecker) {
71
+ constructor(initialImportResolver, initialConfigOptions, console, _extension, logTracker, _disableChecker, cacheManager) {
72
72
  this._extension = _extension;
73
73
  this._disableChecker = _disableChecker;
74
74
  this._sourceFileList = [];
@@ -78,7 +78,7 @@ class Program {
78
78
  var _a;
79
79
  let sourceFileInfo;
80
80
  if (typeof filePathOrModule === 'string') {
81
- sourceFileInfo = this._getSourceFileInfoFromPath(filePathOrModule);
81
+ sourceFileInfo = this.getSourceFileInfo(filePathOrModule);
82
82
  }
83
83
  else {
84
84
  // Resolve the import.
@@ -91,12 +91,12 @@ class Program {
91
91
  let resolvedPath = importResult.resolvedPaths[importResult.resolvedPaths.length - 1];
92
92
  if (resolvedPath) {
93
93
  // See if the source file already exists in the program.
94
- sourceFileInfo = this._getSourceFileInfoFromPath(resolvedPath);
94
+ sourceFileInfo = this.getSourceFileInfo(resolvedPath);
95
95
  if (!sourceFileInfo) {
96
96
  resolvedPath = (0, pathUtils_1.normalizePathCase)(this._fs, resolvedPath);
97
97
  // Start tracking the source file.
98
98
  this.addTrackedFile(resolvedPath);
99
- sourceFileInfo = this._getSourceFileInfoFromPath(resolvedPath);
99
+ sourceFileInfo = this.getSourceFileInfo(resolvedPath);
100
100
  }
101
101
  }
102
102
  }
@@ -131,11 +131,12 @@ class Program {
131
131
  this._logTracker = logTracker !== null && logTracker !== void 0 ? logTracker : new logTracker_1.LogTracker(console, 'FG');
132
132
  this._importResolver = initialImportResolver;
133
133
  this._configOptions = initialConfigOptions;
134
- cacheManager_1.CacheManager.registerCacheOwner(this);
134
+ this._cacheManager = cacheManager !== null && cacheManager !== void 0 ? cacheManager : new cacheManager_1.CacheManager();
135
+ this._cacheManager.registerCacheOwner(this);
135
136
  this._createNewEvaluator();
136
137
  }
137
138
  dispose() {
138
- cacheManager_1.CacheManager.unregisterCacheOwner(this);
139
+ this._cacheManager.unregisterCacheOwner(this);
139
140
  }
140
141
  get evaluator() {
141
142
  return this._evaluator;
@@ -192,7 +193,7 @@ class Program {
192
193
  });
193
194
  }
194
195
  addTrackedFile(filePath, isThirdPartyImport = false, isInPyTypedPackage = false) {
195
- let sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
196
+ let sourceFileInfo = this.getSourceFileInfo(filePath);
196
197
  const importName = this._getImportNameForFile(filePath);
197
198
  if (sourceFileInfo) {
198
199
  // The module name may have changed based on updates to the
@@ -220,7 +221,7 @@ class Program {
220
221
  }
221
222
  setFileOpened(filePath, version, contents, options) {
222
223
  var _a, _b;
223
- let sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
224
+ let sourceFileInfo = this.getSourceFileInfo(filePath);
224
225
  if (!sourceFileInfo) {
225
226
  const importName = this._getImportNameForFile(filePath);
226
227
  const sourceFile = new sourceFile_1.SourceFile(this._fs, filePath, importName,
@@ -230,7 +231,7 @@ class Program {
230
231
  sourceFileInfo = {
231
232
  sourceFile,
232
233
  isTracked: (_b = options === null || options === void 0 ? void 0 : options.isTracked) !== null && _b !== void 0 ? _b : false,
233
- chainedSourceFile: chainedFilePath ? this._getSourceFileInfoFromPath(chainedFilePath) : undefined,
234
+ chainedSourceFile: chainedFilePath ? this.getSourceFileInfo(chainedFilePath) : undefined,
234
235
  isOpenByClient: true,
235
236
  isTypeshedFile: false,
236
237
  isThirdPartyImport: false,
@@ -255,23 +256,22 @@ class Program {
255
256
  }
256
257
  getChainedFilePath(filePath) {
257
258
  var _a;
258
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
259
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
259
260
  return (_a = sourceFileInfo === null || sourceFileInfo === void 0 ? void 0 : sourceFileInfo.chainedSourceFile) === null || _a === void 0 ? void 0 : _a.sourceFile.getFilePath();
260
261
  }
261
262
  updateChainedFilePath(filePath, chainedFilePath) {
262
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
263
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
263
264
  if (sourceFileInfo) {
264
- sourceFileInfo.chainedSourceFile = chainedFilePath
265
- ? this._getSourceFileInfoFromPath(chainedFilePath)
266
- : undefined;
265
+ sourceFileInfo.chainedSourceFile = chainedFilePath ? this.getSourceFileInfo(chainedFilePath) : undefined;
267
266
  sourceFileInfo.sourceFile.markDirty();
268
267
  this._markFileDirtyRecursive(sourceFileInfo, new Set());
269
268
  }
270
269
  }
271
- setFileClosed(filePath) {
272
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
270
+ setFileClosed(filePath, isTracked) {
271
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
273
272
  if (sourceFileInfo) {
274
273
  sourceFileInfo.isOpenByClient = false;
274
+ sourceFileInfo.isTracked = isTracked !== null && isTracked !== void 0 ? isTracked : sourceFileInfo.isTracked;
275
275
  sourceFileInfo.sourceFile.setClientVersion(null, []);
276
276
  // There is no guarantee that content is saved before the file is closed.
277
277
  // We need to mark the file dirty so we can re-analyze next time.
@@ -284,9 +284,6 @@ class Program {
284
284
  }
285
285
  return this._removeUnneededFiles();
286
286
  }
287
- isFileOpen(filePath) {
288
- return this._getSourceFileInfoFromPath(filePath) !== undefined;
289
- }
290
287
  markAllFilesDirty(evenIfContentsAreSame, indexingNeeded = true) {
291
288
  const markDirtySet = new Set();
292
289
  this._sourceFileList.forEach((sourceFileInfo) => {
@@ -307,7 +304,7 @@ class Program {
307
304
  markFilesDirty(filePaths, evenIfContentsAreSame, indexingNeeded = true) {
308
305
  const markDirtySet = new Set();
309
306
  filePaths.forEach((filePath) => {
310
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
307
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
311
308
  if (sourceFileInfo) {
312
309
  const fileName = (0, pathUtils_1.getFileName)(filePath);
313
310
  // Handle builtins and __builtins__ specially. They are implicitly
@@ -368,19 +365,26 @@ class Program {
368
365
  return this._sourceFileList.some((i) => i.sourceFile.getFilePath().startsWith(normalized));
369
366
  }
370
367
  getSourceFile(filePath) {
371
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
368
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
372
369
  if (!sourceFileInfo) {
373
370
  return undefined;
374
371
  }
375
372
  return sourceFileInfo.sourceFile;
376
373
  }
377
374
  getBoundSourceFile(filePath) {
378
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
375
+ var _a;
376
+ return (_a = this.getBoundSourceFileInfo(filePath)) === null || _a === void 0 ? void 0 : _a.sourceFile;
377
+ }
378
+ getSourceFileInfo(filePath) {
379
+ return this._sourceFileMap.get((0, pathUtils_1.normalizePathCase)(this._fs, filePath));
380
+ }
381
+ getBoundSourceFileInfo(filePath) {
382
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
379
383
  if (!sourceFileInfo) {
380
384
  return undefined;
381
385
  }
382
386
  this._bindFile(sourceFileInfo);
383
- return this.getSourceFile(filePath);
387
+ return sourceFileInfo;
384
388
  }
385
389
  // Performs parsing and analysis of any source files in the program
386
390
  // that require it. If a limit time is specified, the operation
@@ -396,7 +400,7 @@ class Program {
396
400
  const effectiveMaxTime = maxTime ? maxTime.openFilesTimeInMs : Number.MAX_VALUE;
397
401
  // Check the open files.
398
402
  for (const sourceFileInfo of openFiles) {
399
- if (this._checkTypes(sourceFileInfo)) {
403
+ if (this._checkTypes(sourceFileInfo, token)) {
400
404
  if (elapsedTime.getDurationInMilliseconds() > effectiveMaxTime) {
401
405
  return true;
402
406
  }
@@ -416,7 +420,7 @@ class Program {
416
420
  if (!(0, sourceFileInfoUtils_1.isUserCode)(sourceFileInfo)) {
417
421
  continue;
418
422
  }
419
- if (this._checkTypes(sourceFileInfo)) {
423
+ if (this._checkTypes(sourceFileInfo, token)) {
420
424
  if (elapsedTime.getDurationInMilliseconds() > effectiveMaxTime) {
421
425
  return true;
422
426
  }
@@ -574,10 +578,10 @@ class Program {
574
578
  const evaluator = this._evaluator || this._createNewEvaluator();
575
579
  return evaluator.getEffectiveTypeOfSymbol(symbol);
576
580
  }
577
- printType(type, expandTypeAlias) {
581
+ printType(type, options) {
578
582
  this._handleMemoryHighUsage();
579
583
  const evaluator = this._evaluator || this._createNewEvaluator();
580
- return evaluator.printType(type, expandTypeAlias);
584
+ return evaluator.printType(type, options);
581
585
  }
582
586
  static _getPrintTypeFlags(configOptions) {
583
587
  let flags = 0 /* None */;
@@ -617,7 +621,7 @@ class Program {
617
621
  // We need to track the relationship so if the original type stub is removed from the
618
622
  // program, we can remove the corresponding shadowed file and any files it imports.
619
623
  _addShadowedFile(stubFile, shadowImplPath) {
620
- let shadowFileInfo = this._getSourceFileInfoFromPath(shadowImplPath);
624
+ let shadowFileInfo = this.getSourceFileInfo(shadowImplPath);
621
625
  if (!shadowFileInfo) {
622
626
  const importName = this._getImportNameForFile(shadowImplPath);
623
627
  const sourceFile = new sourceFile_1.SourceFile(this._fs, shadowImplPath, importName,
@@ -747,7 +751,7 @@ class Program {
747
751
  }
748
752
  return false;
749
753
  }
750
- _checkTypes(fileToCheck) {
754
+ _checkTypes(fileToCheck, token) {
751
755
  return this._logTracker.log(`analyzing: ${fileToCheck.sourceFile.getFilePath()}`, (logState) => {
752
756
  // If the file isn't needed because it was eliminated from the
753
757
  // transitive closure or deleted, skip the file rather than wasting
@@ -772,7 +776,8 @@ class Program {
772
776
  }
773
777
  }
774
778
  if (!this._disableChecker) {
775
- fileToCheck.sourceFile.check(this._importResolver, this._evaluator);
779
+ const execEnv = this._configOptions.findExecEnvironment(fileToCheck.sourceFile.getFilePath());
780
+ fileToCheck.sourceFile.check(this._importResolver, this._evaluator, execEnv, this._createSourceMapper(execEnv, token, fileToCheck), (p) => (0, sourceFileInfoUtils_1.isUserCode)(this.getSourceFileInfo(p)));
776
781
  }
777
782
  // For very large programs, we may need to discard the evaluator and
778
783
  // its cached types to avoid running out of heap space.
@@ -887,7 +892,7 @@ class Program {
887
892
  });
888
893
  circDep.normalizeOrder();
889
894
  const firstFilePath = circDep.getPaths()[0];
890
- const firstSourceFile = this._getSourceFileInfoFromPath(firstFilePath);
895
+ const firstSourceFile = this.getSourceFileInfo(firstFilePath);
891
896
  (0, debug_1.assert)(firstSourceFile !== undefined);
892
897
  firstSourceFile.sourceFile.addCircularDependency(circDep);
893
898
  }
@@ -906,7 +911,7 @@ class Program {
906
911
  }
907
912
  }
908
913
  getTextOnRange(filePath, range, token) {
909
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
914
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
910
915
  if (!sourceFileInfo) {
911
916
  return undefined;
912
917
  }
@@ -927,7 +932,7 @@ class Program {
927
932
  });
928
933
  }
929
934
  getAutoImports(filePath, range, similarityLimit, nameMap, options, token) {
930
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
935
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
931
936
  if (!sourceFileInfo) {
932
937
  return [];
933
938
  }
@@ -1017,36 +1022,38 @@ class Program {
1017
1022
  }
1018
1023
  getDefinitionsForPosition(filePath, position, filter, token) {
1019
1024
  return this._runEvaluatorWithCancellationToken(token, () => {
1020
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1025
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1021
1026
  if (!sourceFileInfo) {
1022
1027
  return undefined;
1023
1028
  }
1024
1029
  this._bindFile(sourceFileInfo);
1025
1030
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1026
- return sourceFileInfo.sourceFile.getDefinitionsForPosition(this._createSourceMapper(execEnv), position, filter, this._evaluator, token);
1031
+ return sourceFileInfo.sourceFile.getDefinitionsForPosition(this._createSourceMapper(execEnv, token, sourceFileInfo), position, filter, this._evaluator, token);
1027
1032
  });
1028
1033
  }
1029
1034
  getTypeDefinitionsForPosition(filePath, position, token) {
1030
1035
  return this._runEvaluatorWithCancellationToken(token, () => {
1031
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1036
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1032
1037
  if (!sourceFileInfo) {
1033
1038
  return undefined;
1034
1039
  }
1035
1040
  this._bindFile(sourceFileInfo);
1036
1041
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1037
- return sourceFileInfo.sourceFile.getTypeDefinitionsForPosition(this._createSourceMapper(execEnv, /* mapCompiled */ false, /* preferStubs */ true), position, this._evaluator, filePath, token);
1042
+ return sourceFileInfo.sourceFile.getTypeDefinitionsForPosition(this._createSourceMapper(execEnv, token, sourceFileInfo,
1043
+ /* mapCompiled */ false,
1044
+ /* preferStubs */ true), position, this._evaluator, filePath, token);
1038
1045
  });
1039
1046
  }
1040
1047
  reportReferencesForPosition(filePath, position, includeDeclaration, reporter, token) {
1041
1048
  this._runEvaluatorWithCancellationToken(token, () => {
1042
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1049
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1043
1050
  if (!sourceFileInfo) {
1044
1051
  return;
1045
1052
  }
1046
1053
  const invokedFromUserFile = (0, sourceFileInfoUtils_1.isUserCode)(sourceFileInfo);
1047
1054
  this._bindFile(sourceFileInfo);
1048
1055
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1049
- const referencesResult = sourceFileInfo.sourceFile.getDeclarationForPosition(this._createSourceMapper(execEnv), position, this._evaluator, reporter, token);
1056
+ const referencesResult = sourceFileInfo.sourceFile.getDeclarationForPosition(this._createSourceMapper(execEnv, token, sourceFileInfo), position, this._evaluator, reporter, token);
1050
1057
  if (!referencesResult) {
1051
1058
  return;
1052
1059
  }
@@ -1078,7 +1085,7 @@ class Program {
1078
1085
  // Already included.
1079
1086
  continue;
1080
1087
  }
1081
- const declFileInfo = this._getSourceFileInfoFromPath(decl.path);
1088
+ const declFileInfo = this.getSourceFileInfo(decl.path);
1082
1089
  if (!declFileInfo) {
1083
1090
  // The file the declaration belongs to doesn't belong to the program.
1084
1091
  continue;
@@ -1111,7 +1118,7 @@ class Program {
1111
1118
  this._handleMemoryHighUsage();
1112
1119
  return this._runEvaluatorWithCancellationToken(token, () => {
1113
1120
  var _a;
1114
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1121
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1115
1122
  if (!sourceFileInfo) {
1116
1123
  return undefined;
1117
1124
  }
@@ -1132,7 +1139,7 @@ class Program {
1132
1139
  }
1133
1140
  addSymbolsForDocument(filePath, symbolList, token) {
1134
1141
  return this._runEvaluatorWithCancellationToken(token, () => {
1135
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1142
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1136
1143
  if (sourceFileInfo) {
1137
1144
  if (!sourceFileInfo.sourceFile.getCachedIndexResults()) {
1138
1145
  // If we already have cached index for this file, no need to bind this file.
@@ -1170,40 +1177,40 @@ class Program {
1170
1177
  }
1171
1178
  getHoverForPosition(filePath, position, format, token) {
1172
1179
  return this._runEvaluatorWithCancellationToken(token, () => {
1173
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1180
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1174
1181
  if (!sourceFileInfo) {
1175
1182
  return undefined;
1176
1183
  }
1177
1184
  this._bindFile(sourceFileInfo);
1178
1185
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1179
- return sourceFileInfo.sourceFile.getHoverForPosition(this._createSourceMapper(execEnv, /* mapCompiled */ true), position, format, this._evaluator, token);
1186
+ return sourceFileInfo.sourceFile.getHoverForPosition(this._createSourceMapper(execEnv, token, sourceFileInfo, /* mapCompiled */ true), position, format, this._evaluator, token);
1180
1187
  });
1181
1188
  }
1182
1189
  getDocumentHighlight(filePath, position, token) {
1183
1190
  return this._runEvaluatorWithCancellationToken(token, () => {
1184
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1191
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1185
1192
  if (!sourceFileInfo) {
1186
1193
  return undefined;
1187
1194
  }
1188
1195
  this._bindFile(sourceFileInfo);
1189
1196
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1190
- return sourceFileInfo.sourceFile.getDocumentHighlight(this._createSourceMapper(execEnv), position, this._evaluator, token);
1197
+ return sourceFileInfo.sourceFile.getDocumentHighlight(this._createSourceMapper(execEnv, token, sourceFileInfo), position, this._evaluator, token);
1191
1198
  });
1192
1199
  }
1193
1200
  getSignatureHelpForPosition(filePath, position, format, token) {
1194
1201
  return this._runEvaluatorWithCancellationToken(token, () => {
1195
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1202
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1196
1203
  if (!sourceFileInfo) {
1197
1204
  return undefined;
1198
1205
  }
1199
1206
  this._bindFile(sourceFileInfo);
1200
1207
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1201
- return sourceFileInfo.sourceFile.getSignatureHelpForPosition(position, this._createSourceMapper(execEnv, /* mapCompiled */ true), this._evaluator, format, token);
1208
+ return sourceFileInfo.sourceFile.getSignatureHelpForPosition(position, this._createSourceMapper(execEnv, token, sourceFileInfo, /* mapCompiled */ true), this._evaluator, format, token);
1202
1209
  });
1203
1210
  }
1204
1211
  async getCompletionsForPosition(filePath, position, workspacePath, options, nameMap, libraryMap, token) {
1205
1212
  var _a;
1206
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1213
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1207
1214
  if (!sourceFileInfo) {
1208
1215
  return undefined;
1209
1216
  }
@@ -1212,7 +1219,7 @@ class Program {
1212
1219
  const result = this._runEvaluatorWithCancellationToken(token, () => {
1213
1220
  this._bindFile(sourceFileInfo);
1214
1221
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1215
- return sourceFileInfo.sourceFile.getCompletionsForPosition(position, workspacePath, this._configOptions, this._importResolver, this._lookUpImport, this._evaluator, options, this._createSourceMapper(execEnv, /* mapCompiled */ true), nameMap, libraryMap, () => this._buildModuleSymbolsMap(sourceFileInfo, !!libraryMap,
1222
+ return sourceFileInfo.sourceFile.getCompletionsForPosition(position, workspacePath, this._configOptions, this._importResolver, this._lookUpImport, this._evaluator, options, this._createSourceMapper(execEnv, token, sourceFileInfo, /* mapCompiled */ true), nameMap, libraryMap, () => this._buildModuleSymbolsMap(sourceFileInfo, !!libraryMap,
1216
1223
  /* includeIndexUserSymbols */ false, token), token);
1217
1224
  });
1218
1225
  ls.add(`found ${(_a = result === null || result === void 0 ? void 0 : result.completionMap.size) !== null && _a !== void 0 ? _a : 'null'} items`);
@@ -1238,20 +1245,20 @@ class Program {
1238
1245
  }
1239
1246
  resolveCompletionItem(filePath, completionItem, options, nameMap, libraryMap, token) {
1240
1247
  return this._runEvaluatorWithCancellationToken(token, () => {
1241
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1248
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1242
1249
  if (!sourceFileInfo) {
1243
1250
  return;
1244
1251
  }
1245
1252
  this._bindFile(sourceFileInfo);
1246
1253
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1247
- sourceFileInfo.sourceFile.resolveCompletionItem(this._configOptions, this._importResolver, this._lookUpImport, this._evaluator, options, this._createSourceMapper(execEnv, /* mapCompiled */ true), nameMap, libraryMap, () => this._buildModuleSymbolsMap(sourceFileInfo, !!libraryMap,
1254
+ sourceFileInfo.sourceFile.resolveCompletionItem(this._configOptions, this._importResolver, this._lookUpImport, this._evaluator, options, this._createSourceMapper(execEnv, token, sourceFileInfo, /* mapCompiled */ true), nameMap, libraryMap, () => this._buildModuleSymbolsMap(sourceFileInfo, !!libraryMap,
1248
1255
  /* includeIndexUserSymbols */ false, token), completionItem, token);
1249
1256
  });
1250
1257
  }
1251
1258
  renameModule(path, newPath, token) {
1252
1259
  return this._runEvaluatorWithCancellationToken(token, () => {
1253
1260
  if ((0, pathUtils_1.isFile)(this._fs, path)) {
1254
- const fileInfo = this._getSourceFileInfoFromPath(path);
1261
+ const fileInfo = this.getSourceFileInfo(path);
1255
1262
  if (!fileInfo) {
1256
1263
  return undefined;
1257
1264
  }
@@ -1266,7 +1273,7 @@ class Program {
1266
1273
  }
1267
1274
  moveSymbolAtPosition(filePath, newFilePath, position, token) {
1268
1275
  return this._runEvaluatorWithCancellationToken(token, () => {
1269
- const fileInfo = this._getSourceFileInfoFromPath(filePath);
1276
+ const fileInfo = this.getSourceFileInfo(filePath);
1270
1277
  if (!fileInfo) {
1271
1278
  return undefined;
1272
1279
  }
@@ -1289,7 +1296,7 @@ class Program {
1289
1296
  }
1290
1297
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1291
1298
  const declarations = documentSymbolCollector_1.DocumentSymbolCollector.getDeclarationsForNode(node, this._evaluator,
1292
- /* resolveLocalNames */ false, token, this._createSourceMapper(execEnv));
1299
+ /* resolveLocalNames */ false, token, this._createSourceMapper(execEnv, token, fileInfo));
1293
1300
  const renameModuleProvider = renameModuleProvider_1.RenameModuleProvider.createForSymbol(this._importResolver, this._configOptions, this._evaluator, filePath, newFilePath, declarations, token);
1294
1301
  if (!renameModuleProvider) {
1295
1302
  return undefined;
@@ -1300,7 +1307,7 @@ class Program {
1300
1307
  }
1301
1308
  canRenameSymbolAtPosition(filePath, position, isDefaultWorkspace, allowModuleRename, token) {
1302
1309
  return this._runEvaluatorWithCancellationToken(token, () => {
1303
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1310
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1304
1311
  if (!sourceFileInfo) {
1305
1312
  return undefined;
1306
1313
  }
@@ -1328,7 +1335,7 @@ class Program {
1328
1335
  renameSymbolAtPosition(filePath, position, newName, isDefaultWorkspace, allowModuleRename, token) {
1329
1336
  return this._runEvaluatorWithCancellationToken(token, () => {
1330
1337
  var _a;
1331
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1338
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1332
1339
  if (!sourceFileInfo) {
1333
1340
  return undefined;
1334
1341
  }
@@ -1413,13 +1420,13 @@ class Program {
1413
1420
  });
1414
1421
  }
1415
1422
  getCallForPosition(filePath, position, token) {
1416
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1423
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1417
1424
  if (!sourceFileInfo) {
1418
1425
  return undefined;
1419
1426
  }
1420
1427
  this._bindFile(sourceFileInfo);
1421
1428
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1422
- const referencesResult = sourceFileInfo.sourceFile.getDeclarationForPosition(this._createSourceMapper(execEnv), position, this._evaluator, undefined, token);
1429
+ const referencesResult = sourceFileInfo.sourceFile.getDeclarationForPosition(this._createSourceMapper(execEnv, token, sourceFileInfo), position, this._evaluator, undefined, token);
1423
1430
  if (!referencesResult || referencesResult.declarations.length === 0) {
1424
1431
  return undefined;
1425
1432
  }
@@ -1427,13 +1434,13 @@ class Program {
1427
1434
  return callHierarchyProvider_1.CallHierarchyProvider.getCallForDeclaration(referencesResult.symbolName, targetDecl, this._evaluator, token);
1428
1435
  }
1429
1436
  getIncomingCallsForPosition(filePath, position, token) {
1430
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1437
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1431
1438
  if (!sourceFileInfo) {
1432
1439
  return undefined;
1433
1440
  }
1434
1441
  this._bindFile(sourceFileInfo);
1435
1442
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1436
- const referencesResult = sourceFileInfo.sourceFile.getDeclarationForPosition(this._createSourceMapper(execEnv), position, this._evaluator, undefined, token);
1443
+ const referencesResult = sourceFileInfo.sourceFile.getDeclarationForPosition(this._createSourceMapper(execEnv, token, sourceFileInfo), position, this._evaluator, undefined, token);
1437
1444
  if (!referencesResult || referencesResult.declarations.length === 0) {
1438
1445
  return undefined;
1439
1446
  }
@@ -1454,13 +1461,13 @@ class Program {
1454
1461
  return items;
1455
1462
  }
1456
1463
  getOutgoingCallsForPosition(filePath, position, token) {
1457
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1464
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1458
1465
  if (!sourceFileInfo) {
1459
1466
  return undefined;
1460
1467
  }
1461
1468
  this._bindFile(sourceFileInfo);
1462
1469
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1463
- const referencesResult = sourceFileInfo.sourceFile.getDeclarationForPosition(this._createSourceMapper(execEnv), position, this._evaluator, undefined, token);
1470
+ const referencesResult = sourceFileInfo.sourceFile.getDeclarationForPosition(this._createSourceMapper(execEnv, token, sourceFileInfo), position, this._evaluator, undefined, token);
1464
1471
  if (!referencesResult || referencesResult.declarations.length === 0) {
1465
1472
  return undefined;
1466
1473
  }
@@ -1468,7 +1475,7 @@ class Program {
1468
1475
  return callHierarchyProvider_1.CallHierarchyProvider.getOutgoingCallsForDeclaration(targetDecl, sourceFileInfo.sourceFile.getParseResults(), this._evaluator, token);
1469
1476
  }
1470
1477
  performQuickAction(filePath, command, args, token) {
1471
- const sourceFileInfo = this._getSourceFileInfoFromPath(filePath);
1478
+ const sourceFileInfo = this.getSourceFileInfo(filePath);
1472
1479
  if (!sourceFileInfo) {
1473
1480
  return undefined;
1474
1481
  }
@@ -1491,8 +1498,8 @@ class Program {
1491
1498
  this._discardCachedParseResults();
1492
1499
  this._parsedFileCount = 0;
1493
1500
  }
1494
- test_createSourceMapper(execEnv) {
1495
- return this._createSourceMapper(execEnv, /* mapCompiled */ false);
1501
+ test_createSourceMapper(execEnv, from) {
1502
+ return this._createSourceMapper(execEnv, vscode_languageserver_1.CancellationToken.None, /*from*/ from, /* mapCompiled */ false);
1496
1503
  }
1497
1504
  _getRenameSymbolMode(sourceFileInfo, referencesResult, isDefaultWorkspace) {
1498
1505
  // We have 2 different cases
@@ -1508,10 +1515,10 @@ class Program {
1508
1515
  (userFile && !referencesResult.requiresGlobalSearch) ||
1509
1516
  (!userFile &&
1510
1517
  sourceFileInfo.isOpenByClient &&
1511
- referencesResult.declarations.every((d) => this._getSourceFileInfoFromPath(d.path) === sourceFileInfo))) {
1518
+ referencesResult.declarations.every((d) => this.getSourceFileInfo(d.path) === sourceFileInfo))) {
1512
1519
  return 'singleFileMode';
1513
1520
  }
1514
- if (referencesResult.declarations.every((d) => (0, sourceFileInfoUtils_1.isUserCode)(this._getSourceFileInfoFromPath(d.path)))) {
1521
+ if (referencesResult.declarations.every((d) => (0, sourceFileInfoUtils_1.isUserCode)(this.getSourceFileInfo(d.path)))) {
1515
1522
  return 'multiFileMode';
1516
1523
  }
1517
1524
  // Rename is not allowed.
@@ -1520,11 +1527,11 @@ class Program {
1520
1527
  }
1521
1528
  _supportRenameModule(declarations, isDefaultWorkspace) {
1522
1529
  // Rename module is not supported for standalone file and all decls must be on a user file.
1523
- return !isDefaultWorkspace && declarations.every((d) => (0, sourceFileInfoUtils_1.isUserCode)(this._getSourceFileInfoFromPath(d.path)));
1530
+ return !isDefaultWorkspace && declarations.every((d) => (0, sourceFileInfoUtils_1.isUserCode)(this.getSourceFileInfo(d.path)));
1524
1531
  }
1525
1532
  _getReferenceResult(sourceFileInfo, filePath, position, allowModuleRename, token) {
1526
1533
  const execEnv = this._configOptions.findExecEnvironment(filePath);
1527
- const referencesResult = sourceFileInfo.sourceFile.getDeclarationForPosition(this._createSourceMapper(execEnv), position, this._evaluator, undefined, token);
1534
+ const referencesResult = sourceFileInfo.sourceFile.getDeclarationForPosition(this._createSourceMapper(execEnv, token), position, this._evaluator, undefined, token);
1528
1535
  if (!referencesResult) {
1529
1536
  return undefined;
1530
1537
  }
@@ -1568,11 +1575,11 @@ class Program {
1568
1575
  }
1569
1576
  }
1570
1577
  _handleMemoryHighUsage() {
1571
- const cacheUsage = cacheManager_1.CacheManager.getCacheUsage();
1578
+ const cacheUsage = this._cacheManager.getCacheUsage();
1572
1579
  // If the total cache has exceeded 75%, determine whether we should empty
1573
1580
  // the cache.
1574
1581
  if (cacheUsage > 0.75) {
1575
- const usedHeapRatio = cacheManager_1.CacheManager.getUsedHeapRatio(this._configOptions.verboseOutput ? this._console : undefined);
1582
+ const usedHeapRatio = this._cacheManager.getUsedHeapRatio(this._configOptions.verboseOutput ? this._console : undefined);
1576
1583
  // The type cache uses a Map, which has an absolute limit of 2^24 entries
1577
1584
  // before it will fail. If we cross the 95% mark, we'll empty the cache.
1578
1585
  const absoluteMaxCacheEntryCount = (1 << 24) * 0.9;
@@ -1580,7 +1587,7 @@ class Program {
1580
1587
  // If we use more than 90% of the heap size limit, avoid a crash
1581
1588
  // by emptying the type cache.
1582
1589
  if (typeCacheEntryCount > absoluteMaxCacheEntryCount || usedHeapRatio > 0.9) {
1583
- cacheManager_1.CacheManager.emptyCache(this._console);
1590
+ this._cacheManager.emptyCache(this._console);
1584
1591
  }
1585
1592
  }
1586
1593
  }
@@ -1607,7 +1614,7 @@ class Program {
1607
1614
  // An unexpected exception occurred, potentially leaving the current evaluator
1608
1615
  // in an inconsistent state. Discard it and replace it with a fresh one. It is
1609
1616
  // Cancellation exceptions are known to handle this correctly.
1610
- if (!(e instanceof cancellationUtils_1.OperationCanceledException)) {
1617
+ if (!cancellationUtils_1.OperationCanceledException.is(e)) {
1611
1618
  this._createNewEvaluator();
1612
1619
  }
1613
1620
  throw e;
@@ -1713,15 +1720,15 @@ class Program {
1713
1720
  }
1714
1721
  return false;
1715
1722
  }
1716
- _createSourceMapper(execEnv, mapCompiled, preferStubs) {
1723
+ _createSourceMapper(execEnv, token, from, mapCompiled, preferStubs) {
1717
1724
  const sourceMapper = new sourceMapper_1.SourceMapper(this._importResolver, execEnv, this._evaluator, (stubFilePath, implFilePath) => {
1718
- const stubFileInfo = this._getSourceFileInfoFromPath(stubFilePath);
1725
+ const stubFileInfo = this.getSourceFileInfo(stubFilePath);
1719
1726
  if (!stubFileInfo) {
1720
1727
  return undefined;
1721
1728
  }
1722
1729
  this._addShadowedFile(stubFileInfo, implFilePath);
1723
1730
  return this.getBoundSourceFile(implFilePath);
1724
- }, (f) => this.getBoundSourceFile(f), mapCompiled !== null && mapCompiled !== void 0 ? mapCompiled : false, preferStubs !== null && preferStubs !== void 0 ? preferStubs : false);
1731
+ }, (f) => this.getBoundSourceFileInfo(f), (f) => this.getSourceFileInfo(f), mapCompiled !== null && mapCompiled !== void 0 ? mapCompiled : false, preferStubs !== null && preferStubs !== void 0 ? preferStubs : false, from, token);
1725
1732
  return sourceMapper;
1726
1733
  }
1727
1734
  _isImportAllowed(importer, importResult, isImportStubFile) {
@@ -1889,8 +1896,8 @@ class Program {
1889
1896
  // We found a new import to add. See if it's already part
1890
1897
  // of the program.
1891
1898
  let importedFileInfo;
1892
- if (this._getSourceFileInfoFromPath(importInfo.path)) {
1893
- importedFileInfo = this._getSourceFileInfoFromPath(importInfo.path);
1899
+ if (this.getSourceFileInfo(importInfo.path)) {
1900
+ importedFileInfo = this.getSourceFileInfo(importInfo.path);
1894
1901
  }
1895
1902
  else {
1896
1903
  const importName = this._getImportNameForFile(importInfo.path);
@@ -1919,8 +1926,8 @@ class Program {
1919
1926
  // specified by the source file.
1920
1927
  sourceFileInfo.imports = [];
1921
1928
  newImportPathMap.forEach((_, path) => {
1922
- if (this._getSourceFileInfoFromPath(path)) {
1923
- sourceFileInfo.imports.push(this._getSourceFileInfoFromPath(path));
1929
+ if (this.getSourceFileInfo(path)) {
1930
+ sourceFileInfo.imports.push(this.getSourceFileInfo(path));
1924
1931
  }
1925
1932
  });
1926
1933
  // Resolve the builtins import for the file. This needs to be
@@ -1929,7 +1936,7 @@ class Program {
1929
1936
  const builtinsImport = sourceFileInfo.sourceFile.getBuiltinsImport();
1930
1937
  if (builtinsImport && builtinsImport.isImportFound) {
1931
1938
  const resolvedBuiltinsPath = builtinsImport.resolvedPaths[builtinsImport.resolvedPaths.length - 1];
1932
- sourceFileInfo.builtinsImport = this._getSourceFileInfoFromPath(resolvedBuiltinsPath);
1939
+ sourceFileInfo.builtinsImport = this.getSourceFileInfo(resolvedBuiltinsPath);
1933
1940
  }
1934
1941
  // Resolve the ipython display import for the file. This needs to be
1935
1942
  // analyzed before the file can be analyzed.
@@ -1937,13 +1944,10 @@ class Program {
1937
1944
  const ipythonDisplayImport = sourceFileInfo.sourceFile.getIPythonDisplayImport();
1938
1945
  if (ipythonDisplayImport && ipythonDisplayImport.isImportFound) {
1939
1946
  const resolvedIPythonDisplayPath = ipythonDisplayImport.resolvedPaths[ipythonDisplayImport.resolvedPaths.length - 1];
1940
- sourceFileInfo.ipythonDisplayImport = this._getSourceFileInfoFromPath(resolvedIPythonDisplayPath);
1947
+ sourceFileInfo.ipythonDisplayImport = this.getSourceFileInfo(resolvedIPythonDisplayPath);
1941
1948
  }
1942
1949
  return filesAdded;
1943
1950
  }
1944
- _getSourceFileInfoFromPath(filePath) {
1945
- return this._sourceFileMap.get((0, pathUtils_1.normalizePathCase)(this._fs, filePath));
1946
- }
1947
1951
  _removeSourceFileFromListAndMap(filePath, indexToRemove) {
1948
1952
  this._sourceFileMap.delete((0, pathUtils_1.normalizePathCase)(this._fs, filePath));
1949
1953
  this._sourceFileList.splice(indexToRemove, 1);