@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
@@ -1,12 +1,4 @@
1
1
  "use strict";
2
- /*
3
- * testState.ts
4
- * Copyright (c) Microsoft Corporation.
5
- * Licensed under the MIT license.
6
- *
7
- * TestState wraps currently test states and provides a way to query and manipulate
8
- * the test states.
9
- */
10
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
3
  if (k2 === undefined) k2 = k;
12
4
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -30,9 +22,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
31
23
  };
32
24
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.createVfsInfoFromFourSlashData = exports.getNodeAtMarker = exports.getNodeForRange = exports.parseAndGetTestState = exports.TestState = void 0;
25
+ exports.getMarkerNames = exports.getMarkerByName = exports.getMarkerName = exports.createVfsInfoFromFourSlashData = exports.getNodeAtMarker = exports.getNodeForRange = exports.parseAndGetTestState = exports.TestState = void 0;
26
+ /*
27
+ * testState.ts
28
+ * Copyright (c) Microsoft Corporation.
29
+ * Licensed under the MIT license.
30
+ *
31
+ * TestState wraps currently test states and provides a way to query and manipulate
32
+ * the test states.
33
+ */
34
34
  const assert_1 = __importDefault(require("assert"));
35
35
  const JSONC = __importStar(require("jsonc-parser"));
36
+ const path = __importStar(require("path"));
36
37
  const vscode_languageserver_1 = require("vscode-languageserver");
37
38
  const parseTreeUtils_1 = require("../../../analyzer/parseTreeUtils");
38
39
  const service_1 = require("../../../analyzer/service");
@@ -60,6 +61,7 @@ const vfs = __importStar(require("../vfs/filesystem"));
60
61
  const fourSlashParser_1 = require("./fourSlashParser");
61
62
  const fourSlashTypes_1 = require("./fourSlashTypes");
62
63
  const testLanguageService_1 = require("./testLanguageService");
64
+ const workspaceEditTestUtils_1 = require("./workspaceEditTestUtils");
63
65
  const testAccessHost = new testAccessHost_1.TestAccessHost(vfs.MODULE_PATH, [factory_1.libFolder, factory_1.distlibFolder]);
64
66
  class TestState {
65
67
  constructor(projectRoot, testData, mountPaths, hostSpecificFeatures) {
@@ -84,7 +86,7 @@ class TestState {
84
86
  configOptions.initializeFromJson(this.rawConfigJson, 'basic', this.console, this.fs, testAccessHost);
85
87
  this._applyTestConfigOptions(configOptions);
86
88
  }
87
- const service = this._createAnalysisService(this.console, this._hostSpecificFeatures.importResolverFactory, configOptions);
89
+ const service = this._createAnalysisService(this.console, this._hostSpecificFeatures.importResolverFactory, this._hostSpecificFeatures.backgroundAnalysisProgramFactory, configOptions);
88
90
  this.workspace = {
89
91
  workspaceName: 'test workspace',
90
92
  rootPath: vfsInfo.projectRoot,
@@ -97,7 +99,6 @@ class TestState {
97
99
  disableWorkspaceSymbol: false,
98
100
  isInitialized: (0, deferred_1.createDeferred)(),
99
101
  searchPathsToWatch: [],
100
- owns: (f) => true,
101
102
  };
102
103
  const indexer = (0, core_1.toBoolean)(testData.globalOptions["indexer" /* indexer */]);
103
104
  const indexerWithoutStdLib = (0, core_1.toBoolean)(testData.globalOptions["indexerwithoutstdlib" /* indexerWithoutStdLib */]);
@@ -126,6 +127,9 @@ class TestState {
126
127
  get program() {
127
128
  return this.workspace.serviceInstance.test_program;
128
129
  }
130
+ dispose() {
131
+ this.workspace.serviceInstance.dispose();
132
+ }
129
133
  cwd() {
130
134
  return this.testFS.cwd();
131
135
  }
@@ -155,32 +159,17 @@ class TestState {
155
159
  return this.fs.getMappedFilePath(path);
156
160
  }
157
161
  getMarkerName(m) {
158
- let found;
159
- this.testData.markerPositions.forEach((marker, name) => {
160
- if (marker === m) {
161
- found = name;
162
- }
163
- });
164
- assert_1.default.ok(found);
165
- return found;
162
+ return getMarkerName(this.testData, m);
166
163
  }
167
164
  getMarkerByName(markerName) {
168
- const markerPos = this.testData.markerPositions.get(markerName);
169
- if (markerPos === undefined) {
170
- throw new Error(`Unknown marker "${markerName}" Available markers: ${this.getMarkerNames()
171
- .map((m) => '"' + m + '"')
172
- .join(', ')}`);
173
- }
174
- else {
175
- return markerPos;
176
- }
165
+ return getMarkerByName(this.testData, markerName);
177
166
  }
178
167
  getMarkers() {
179
168
  // Return a copy of the list
180
169
  return this.testData.markers.slice(0);
181
170
  }
182
171
  getMarkerNames() {
183
- return [...this.testData.markerPositions.keys()];
172
+ return getMarkerNames(this.testData);
184
173
  }
185
174
  getPositionRange(markerString) {
186
175
  const marker = this.getMarkerByName(markerString);
@@ -214,6 +203,9 @@ class TestState {
214
203
  getDirectoryPath(path) {
215
204
  return (0, pathUtils_1.getDirectoryPath)(path);
216
205
  }
206
+ getPathSep() {
207
+ return path.sep;
208
+ }
217
209
  goToPosition(positionOrLineAndColumn) {
218
210
  const pos = (0, core_1.isNumber)(positionOrLineAndColumn)
219
211
  ? positionOrLineAndColumn
@@ -377,7 +369,7 @@ class TestState {
377
369
  this._checkPostEditInvariants();
378
370
  }
379
371
  verifyDiagnostics(map) {
380
- this._analyze();
372
+ this.analyze();
381
373
  // organize things per file
382
374
  const resultPerFile = this._getDiagnosticsPerFile();
383
375
  const rangePerFile = this.createMultiMap(this.getRanges(), (r) => r.fileName);
@@ -412,8 +404,12 @@ class TestState {
412
404
  ? result.warnings
413
405
  : category === 'information'
414
406
  ? result.information
415
- : this.raiseError(`unexpected category ${category}`);
416
- if (expected.length !== actual.length) {
407
+ : category === 'unused'
408
+ ? result.unused
409
+ : category === 'none'
410
+ ? []
411
+ : this.raiseError(`unexpected category ${category}`);
412
+ if (expected.length !== actual.length && category !== 'none') {
417
413
  this.raiseError(`contains unexpected result - expected: ${(0, utils_1.stringify)(expected)}, actual: ${(0, utils_1.stringify)(actual)}`);
418
414
  }
419
415
  for (const range of expected) {
@@ -422,13 +418,19 @@ class TestState {
422
418
  const diagnosticSpan = textRange_1.TextRange.fromBounds((0, positionUtils_1.convertPositionToOffset)(d.range.start, lines), (0, positionUtils_1.convertPositionToOffset)(d.range.end, lines));
423
419
  return this._deepEqual(diagnosticSpan, rangeSpan);
424
420
  });
425
- if (matches.length === 0) {
421
+ // If the map is provided, it might say
422
+ // a marker should have none.
423
+ const name = map ? this.getMarkerName(range.marker) : '';
424
+ const message = map ? map[name].message : undefined;
425
+ const expectMatches = !!message;
426
+ if (expectMatches && matches.length === 0) {
426
427
  this.raiseError(`doesn't contain expected range: ${(0, utils_1.stringify)(range)}`);
427
428
  }
429
+ else if (!expectMatches && matches.length !== 0) {
430
+ this.raiseError(`${name} should not contain any matches`);
431
+ }
428
432
  // if map is provided, check message as well
429
- if (map) {
430
- const name = this.getMarkerName(range.marker);
431
- const message = map[name].message;
433
+ if (message) {
432
434
  if (matches.filter((d) => message === d.message).length !== 1) {
433
435
  this.raiseError(`message doesn't match: ${message} of ${name} - ${(0, utils_1.stringify)(range)}, actual: ${(0, utils_1.stringify)(matches)}`);
434
436
  }
@@ -451,7 +453,7 @@ class TestState {
451
453
  async verifyCodeActions(map, verifyCodeActionCount) {
452
454
  // make sure we don't use cache built from other tests
453
455
  this.workspace.serviceInstance.invalidateAndForceReanalysis();
454
- this._analyze();
456
+ this.analyze();
455
457
  for (const range of this.getRanges()) {
456
458
  const name = this.getMarkerName(range.marker);
457
459
  if (!map[name]) {
@@ -501,7 +503,7 @@ class TestState {
501
503
  }
502
504
  }
503
505
  async verifyCommand(command, files) {
504
- this._analyze();
506
+ this.analyze();
505
507
  const commandResult = await this._hostSpecificFeatures.execute(new testLanguageService_1.TestLanguageService(this.workspace, this.console, this.fs), { command: command.command, arguments: command.arguments || [] }, vscode_languageserver_1.CancellationToken.None);
506
508
  if (command.command === 'pyright.createtypestub') {
507
509
  await this._verifyFiles(files);
@@ -521,123 +523,11 @@ class TestState {
521
523
  return commandResult;
522
524
  }
523
525
  verifyWorkspaceEdit(expected, actual) {
524
- if (actual.changes) {
525
- this._verifyTextEditMap(expected.changes, actual.changes);
526
- }
527
- else {
528
- (0, assert_1.default)(!expected.changes);
529
- }
530
- if (actual.documentChanges) {
531
- this._verifyDocumentEdits(expected.documentChanges, actual.documentChanges);
532
- }
533
- else {
534
- (0, assert_1.default)(!expected.documentChanges);
535
- }
536
- if (actual.changeAnnotations) {
537
- this._verifyChangeAnnotations(expected.changeAnnotations, actual.changeAnnotations);
538
- }
539
- else {
540
- (0, assert_1.default)(!expected.changeAnnotations);
541
- }
542
- }
543
- _verifyChangeAnnotations(expected, actual) {
544
- assert_1.default.strictEqual(Object.entries(expected).length, Object.entries(actual).length);
545
- for (const key of Object.keys(expected)) {
546
- const expectedAnnotation = expected[key];
547
- const actualAnnotation = actual[key];
548
- // We need to improve it to test localized strings.
549
- assert_1.default.strictEqual(expectedAnnotation.label, actualAnnotation.label);
550
- assert_1.default.strictEqual(expectedAnnotation.description, actualAnnotation.description);
551
- assert_1.default.strictEqual(expectedAnnotation.needsConfirmation, actualAnnotation.needsConfirmation);
552
- }
553
- }
554
- _textDocumentAreSame(expected, actual) {
555
- return expected.version === actual.version && expected.uri === actual.uri;
556
- }
557
- _verifyDocumentEdits(expected, actual) {
558
- assert_1.default.strictEqual(expected.length, actual.length);
559
- for (const op of expected) {
560
- (0, assert_1.default)(actual.some((a) => {
561
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
562
- const expectedKind = vscode_languageserver_1.TextDocumentEdit.is(op) ? 'edit' : op.kind;
563
- const actualKind = vscode_languageserver_1.TextDocumentEdit.is(a) ? 'edit' : a.kind;
564
- if (expectedKind !== actualKind) {
565
- return false;
566
- }
567
- switch (expectedKind) {
568
- case 'edit': {
569
- const expectedEdit = op;
570
- const actualEdit = a;
571
- if (!this._textDocumentAreSame(expectedEdit.textDocument, actualEdit.textDocument)) {
572
- return false;
573
- }
574
- return this._textEditsAreSame(expectedEdit.edits, actualEdit.edits);
575
- }
576
- case 'create': {
577
- const expectedOp = op;
578
- const actualOp = a;
579
- return (expectedOp.kind === actualOp.kind &&
580
- expectedOp.annotationId === actualOp.annotationId &&
581
- expectedOp.uri === actualOp.uri &&
582
- ((_a = expectedOp.options) === null || _a === void 0 ? void 0 : _a.ignoreIfExists) === ((_b = actualOp.options) === null || _b === void 0 ? void 0 : _b.ignoreIfExists) &&
583
- ((_c = expectedOp.options) === null || _c === void 0 ? void 0 : _c.overwrite) === ((_d = actualOp.options) === null || _d === void 0 ? void 0 : _d.overwrite));
584
- }
585
- case 'rename': {
586
- const expectedOp = op;
587
- const actualOp = a;
588
- return (expectedOp.kind === actualOp.kind &&
589
- expectedOp.annotationId === actualOp.annotationId &&
590
- expectedOp.oldUri === actualOp.oldUri &&
591
- expectedOp.newUri === actualOp.newUri &&
592
- ((_e = expectedOp.options) === null || _e === void 0 ? void 0 : _e.ignoreIfExists) === ((_f = actualOp.options) === null || _f === void 0 ? void 0 : _f.ignoreIfExists) &&
593
- ((_g = expectedOp.options) === null || _g === void 0 ? void 0 : _g.overwrite) === ((_h = actualOp.options) === null || _h === void 0 ? void 0 : _h.overwrite));
594
- }
595
- case 'delete': {
596
- const expectedOp = op;
597
- const actualOp = a;
598
- return (expectedOp.annotationId === actualOp.annotationId &&
599
- expectedOp.kind === actualOp.kind &&
600
- expectedOp.uri === actualOp.uri &&
601
- ((_j = expectedOp.options) === null || _j === void 0 ? void 0 : _j.ignoreIfNotExists) === ((_k = actualOp.options) === null || _k === void 0 ? void 0 : _k.ignoreIfNotExists) &&
602
- ((_l = expectedOp.options) === null || _l === void 0 ? void 0 : _l.recursive) === ((_m = actualOp.options) === null || _m === void 0 ? void 0 : _m.recursive));
603
- }
604
- default:
605
- debug.assertNever(expectedKind);
606
- }
607
- }));
608
- }
609
- }
610
- _verifyTextEditMap(expected, actual) {
611
- assert_1.default.strictEqual(Object.entries(expected).length, Object.entries(actual).length);
612
- for (const key of Object.keys(expected)) {
613
- (0, assert_1.default)(this._textEditsAreSame(expected[key], actual[key]));
614
- }
615
- }
616
- _textEditsAreSame(expectedEdits, actualEdits) {
617
- if (expectedEdits.length !== actualEdits.length) {
618
- return false;
619
- }
620
- for (const edit of expectedEdits) {
621
- if (!actualEdits.some((a) => this._textEditAreSame(edit, a))) {
622
- return false;
623
- }
624
- }
625
- return true;
626
- }
627
- _textEditAreSame(expected, actual) {
628
- if (!(0, textRange_1.rangesAreEqual)(expected.range, actual.range)) {
629
- return false;
630
- }
631
- if (expected.newText !== actual.newText) {
632
- return false;
633
- }
634
- const expectedAnnotation = vscode_languageserver_1.AnnotatedTextEdit.is(expected) ? expected.annotationId : '';
635
- const actualAnnotation = vscode_languageserver_1.AnnotatedTextEdit.is(actual) ? actual.annotationId : '';
636
- return expectedAnnotation === actualAnnotation;
526
+ return (0, workspaceEditTestUtils_1.verifyWorkspaceEdit)(expected, actual);
637
527
  }
638
528
  async verifyInvokeCodeAction(map, verifyCodeActionCount) {
639
529
  var _a;
640
- this._analyze();
530
+ this.analyze();
641
531
  for (const range of this.getRanges()) {
642
532
  const name = this.getMarkerName(range.marker);
643
533
  if (!map[name]) {
@@ -730,7 +620,7 @@ class TestState {
730
620
  }
731
621
  async verifyCompletion(verifyMode, docFormat, map, abbrMap) {
732
622
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
733
- this._analyze();
623
+ this.analyze();
734
624
  for (const marker of this.getMarkers()) {
735
625
  const markerName = this.getMarkerName(marker);
736
626
  if (!map[markerName]) {
@@ -822,7 +712,7 @@ class TestState {
822
712
  }
823
713
  }
824
714
  verifySignature(docFormat, map) {
825
- this._analyze();
715
+ this.analyze();
826
716
  for (const marker of this.getMarkers()) {
827
717
  const fileName = marker.fileName;
828
718
  const name = this.getMarkerName(marker);
@@ -867,7 +757,7 @@ class TestState {
867
757
  }
868
758
  verifyFindAllReferences(map) {
869
759
  var _a;
870
- this._analyze();
760
+ this.analyze();
871
761
  for (const marker of this.getMarkers()) {
872
762
  const fileName = marker.fileName;
873
763
  const name = this.getMarkerName(marker);
@@ -899,7 +789,7 @@ class TestState {
899
789
  }
900
790
  verifyHighlightReferences(map) {
901
791
  var _a;
902
- this._analyze();
792
+ this.analyze();
903
793
  for (const name of Object.keys(map)) {
904
794
  const marker = this.getMarkerByName(name);
905
795
  const fileName = marker.fileName;
@@ -918,7 +808,7 @@ class TestState {
918
808
  }
919
809
  verifyFindDefinitions(map, filter = definitionProvider_1.DefinitionFilter.All) {
920
810
  var _a;
921
- this._analyze();
811
+ this.analyze();
922
812
  for (const marker of this.getMarkers()) {
923
813
  const fileName = marker.fileName;
924
814
  const name = this.getMarkerName(marker);
@@ -936,7 +826,7 @@ class TestState {
936
826
  }
937
827
  verifyFindTypeDefinitions(map) {
938
828
  var _a;
939
- this._analyze();
829
+ this.analyze();
940
830
  for (const marker of this.getMarkers()) {
941
831
  const fileName = marker.fileName;
942
832
  const name = this.getMarkerName(marker);
@@ -954,7 +844,7 @@ class TestState {
954
844
  }
955
845
  verifyRename(map) {
956
846
  var _a;
957
- this._analyze();
847
+ this.analyze();
958
848
  for (const marker of this.getMarkers()) {
959
849
  const fileName = marker.fileName;
960
850
  const name = this.getMarkerName(marker);
@@ -1219,7 +1109,7 @@ class TestState {
1219
1109
  // If inside the edit, return -1 to mark as invalid
1220
1110
  return position <= editStart ? position : position < editEnd ? -1 : position + length - +(editEnd - editStart);
1221
1111
  }
1222
- _analyze() {
1112
+ analyze() {
1223
1113
  while (this.program.analyze()) {
1224
1114
  // Continue to call analyze until it completes. Since we're not
1225
1115
  // specifying a timeout, it should complete the first time.
@@ -1237,6 +1127,7 @@ class TestState {
1237
1127
  errors: diagnostics.filter((diag) => diag.category === 0 /* Error */),
1238
1128
  warnings: diagnostics.filter((diag) => diag.category === 1 /* Warning */),
1239
1129
  information: diagnostics.filter((diag) => diag.category === 2 /* Information */),
1130
+ unused: diagnostics.filter((diag) => diag.category === 3 /* UnusedCode */),
1240
1131
  };
1241
1132
  return [filePath, value];
1242
1133
  }
@@ -1246,12 +1137,13 @@ class TestState {
1246
1137
  });
1247
1138
  return new Map(results);
1248
1139
  }
1249
- _createAnalysisService(nullConsole, importResolverFactory, configOptions) {
1140
+ _createAnalysisService(nullConsole, importResolverFactory, backgroundAnalysisProgramFactory, configOptions) {
1250
1141
  // we do not initiate automatic analysis or file watcher in test.
1251
1142
  const service = new service_1.AnalyzerService('test service', this.fs, {
1252
1143
  console: nullConsole,
1253
1144
  hostFactory: () => testAccessHost,
1254
1145
  importResolverFactory,
1146
+ backgroundAnalysisProgramFactory,
1255
1147
  configOptions,
1256
1148
  });
1257
1149
  // directly set files to track rather than using fileSpec from config
@@ -1408,6 +1300,33 @@ function createVfsInfoFromFourSlashData(projectRoot, testData) {
1408
1300
  return { files, sourceFileNames, projectRoot, ignoreCase, rawConfigJson };
1409
1301
  }
1410
1302
  exports.createVfsInfoFromFourSlashData = createVfsInfoFromFourSlashData;
1303
+ function getMarkerName(testData, markerToFind) {
1304
+ let found;
1305
+ testData.markerPositions.forEach((marker, name) => {
1306
+ if (marker === markerToFind) {
1307
+ found = name;
1308
+ }
1309
+ });
1310
+ assert_1.default.ok(found);
1311
+ return found;
1312
+ }
1313
+ exports.getMarkerName = getMarkerName;
1314
+ function getMarkerByName(testData, markerName) {
1315
+ const markerPos = testData.markerPositions.get(markerName);
1316
+ if (markerPos === undefined) {
1317
+ throw new Error(`Unknown marker "${markerName}" Available markers: ${getMarkerNames(testData)
1318
+ .map((m) => '"' + m + '"')
1319
+ .join(', ')}`);
1320
+ }
1321
+ else {
1322
+ return markerPos;
1323
+ }
1324
+ }
1325
+ exports.getMarkerByName = getMarkerByName;
1326
+ function getMarkerNames(testData) {
1327
+ return [...testData.markerPositions.keys()];
1328
+ }
1329
+ exports.getMarkerNames = getMarkerNames;
1411
1330
  function isConfig(file, ignoreCase) {
1412
1331
  const comparer = (0, stringUtils_1.getStringComparer)(ignoreCase);
1413
1332
  return service_1.configFileNames.some((f) => comparer((0, pathUtils_1.getBaseFileName)(file.fileName), f) === 0 /* EqualTo */);