@zzzen/pyright-internal 1.2.0-dev.20260816 → 1.2.0-dev.20260830
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.
- package/dist/analyzer/analyzerNodeInfo.d.ts +123 -24
- package/dist/analyzer/analyzerNodeInfo.js +429 -89
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +2 -1
- package/dist/analyzer/backgroundAnalysisProgram.js +4 -8
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.d.ts +6 -3
- package/dist/analyzer/binder.js +70 -69
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +4 -2
- package/dist/analyzer/checker.js +86 -59
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +2 -1
- package/dist/analyzer/codeFlowEngine.js +12 -10
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowUtils.d.ts +2 -1
- package/dist/analyzer/codeFlowUtils.js +2 -3
- package/dist/analyzer/codeFlowUtils.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +8 -0
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/dataClasses.d.ts +5 -4
- package/dist/analyzer/dataClasses.js +30 -59
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declarationUtils.d.ts +2 -1
- package/dist/analyzer/declarationUtils.js +2 -2
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.d.ts +5 -4
- package/dist/analyzer/decorators.js +20 -21
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/enums.d.ts +5 -4
- package/dist/analyzer/enums.js +11 -10
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +1 -1
- package/dist/analyzer/importResolver.js +5 -3
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.d.ts +3 -1
- package/dist/analyzer/importStatementUtils.js +14 -7
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.d.ts +2 -1
- package/dist/analyzer/namedTuples.js +3 -4
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.d.ts +3 -2
- package/dist/analyzer/operations.js +8 -8
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +2 -2
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +13 -11
- package/dist/analyzer/parseTreeUtils.js +62 -36
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.d.ts +7 -2
- package/dist/analyzer/parseTreeWalker.js +29 -175
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.d.ts +4 -3
- package/dist/analyzer/patternMatching.js +47 -43
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +12 -0
- package/dist/analyzer/program.js +238 -29
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.d.ts +4 -3
- package/dist/analyzer/properties.js +7 -8
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +14 -2
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/scopeUtils.d.ts +4 -3
- package/dist/analyzer/scopeUtils.js +8 -8
- package/dist/analyzer/scopeUtils.js.map +1 -1
- package/dist/analyzer/sentinel.d.ts +3 -2
- package/dist/analyzer/sentinel.js +4 -5
- package/dist/analyzer/sentinel.js.map +1 -1
- package/dist/analyzer/service.d.ts +5 -10
- package/dist/analyzer/service.js +36 -96
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceEnumerator.d.ts +5 -0
- package/dist/analyzer/sourceEnumerator.js +57 -3
- package/dist/analyzer/sourceEnumerator.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +12 -6
- package/dist/analyzer/sourceFile.js +74 -50
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.d.ts +1 -0
- package/dist/analyzer/sourceFileInfoUtils.js +8 -0
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.d.ts +4 -1
- package/dist/analyzer/sourceMapper.js +14 -8
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/testWalker.js +2 -1
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.d.ts +2 -1
- package/dist/analyzer/tracePrinter.js +2 -2
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/tuples.d.ts +3 -2
- package/dist/analyzer/tuples.js +5 -5
- package/dist/analyzer/tuples.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.d.ts +5 -7
- package/dist/analyzer/typeDocStringUtils.js +229 -132
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.d.ts +2 -0
- package/dist/analyzer/typeEvaluator.js +418 -229
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +2 -0
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.d.ts +3 -2
- package/dist/analyzer/typeGuards.js +159 -35
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeStubGeneration.d.ts +64 -0
- package/dist/analyzer/typeStubGeneration.js +226 -0
- package/dist/analyzer/typeStubGeneration.js.map +1 -0
- package/dist/analyzer/typeStubMessages.d.ts +4 -0
- package/dist/analyzer/typeStubMessages.js +25 -0
- package/dist/analyzer/typeStubMessages.js.map +1 -0
- package/dist/analyzer/typeStubOutput.d.ts +9 -0
- package/dist/analyzer/typeStubOutput.js +52 -0
- package/dist/analyzer/typeStubOutput.js.map +1 -0
- package/dist/analyzer/typeStubRenderer.d.ts +5 -0
- package/dist/analyzer/{typeStubWriter.js → typeStubRenderer.js} +20 -99
- package/dist/analyzer/typeStubRenderer.js.map +1 -0
- package/dist/analyzer/typeUtils.d.ts +1 -0
- package/dist/analyzer/typeUtils.js +115 -1
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.d.ts +4 -3
- package/dist/analyzer/typedDicts.js +15 -14
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +2 -0
- package/dist/analyzer/types.js +84 -58
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +5 -4
- package/dist/backgroundAnalysisBase.js +11 -19
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/commands/createTypeStub.d.ts +2 -6
- package/dist/commands/createTypeStub.js +14 -27
- package/dist/commands/createTypeStub.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/common/collectionUtils.js +15 -6
- package/dist/common/collectionUtils.js.map +1 -1
- package/dist/common/commandLineOptions.d.ts +1 -1
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/configOptions.d.ts +4 -1
- package/dist/common/configOptions.js +68 -12
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/envVarUtils.d.ts +1 -0
- package/dist/common/envVarUtils.js +41 -10
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +3 -1
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/extraPathGlob.d.ts +12 -0
- package/dist/common/extraPathGlob.js +315 -0
- package/dist/common/extraPathGlob.js.map +1 -0
- package/dist/common/host.d.ts +2 -0
- package/dist/common/host.js.map +1 -1
- package/dist/common/languageServerInterface.d.ts +2 -1
- package/dist/common/languageServerInterface.js.map +1 -1
- package/dist/common/pathConsts.d.ts +1 -0
- package/dist/common/pathConsts.js +11 -1
- package/dist/common/pathConsts.js.map +1 -1
- package/dist/common/processUtils.d.ts +4 -2
- package/dist/common/processUtils.js +3 -0
- package/dist/common/processUtils.js.map +1 -1
- package/dist/common/stringUtils.d.ts +6 -0
- package/dist/common/stringUtils.js +87 -5
- package/dist/common/stringUtils.js.map +1 -1
- package/dist/common/textEditTracker.d.ts +3 -1
- package/dist/common/textEditTracker.js +8 -6
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/textRangeCollection.d.ts +1 -0
- package/dist/common/textRangeCollection.js +32 -1
- package/dist/common/textRangeCollection.js.map +1 -1
- package/dist/common/uri/uriUtils.d.ts +3 -0
- package/dist/common/uri/uriUtils.js +65 -15
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/fileSystemMapping.d.ts +10 -0
- package/dist/fileSystemMapping.js +176 -0
- package/dist/fileSystemMapping.js.map +1 -0
- package/dist/languageServerBase.d.ts +1 -1
- package/dist/languageServerBase.js +2 -2
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.d.ts +1 -3
- package/dist/languageService/analyzerServiceExecutor.js +10 -29
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +1 -0
- package/dist/languageService/autoImporter.js +32 -5
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.d.ts +7 -0
- package/dist/languageService/callHierarchyProvider.js +97 -11
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +30 -8
- package/dist/languageService/completionProvider.js +298 -93
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/definitionProvider.js +7 -6
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.js +2 -1
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.d.ts +3 -1
- package/dist/languageService/documentSymbolCollector.js +78 -14
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.js +3 -2
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/fileWatcherDynamicFeature.js +28 -1
- package/dist/languageService/fileWatcherDynamicFeature.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +2 -1
- package/dist/languageService/hoverProvider.js +48 -16
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importSorter.d.ts +3 -1
- package/dist/languageService/importSorter.js +4 -2
- package/dist/languageService/importSorter.js.map +1 -1
- package/dist/languageService/importStatementCandidates.js +4 -2
- package/dist/languageService/importStatementCandidates.js.map +1 -1
- package/dist/languageService/quickActions.js +2 -1
- package/dist/languageService/quickActions.js.map +1 -1
- package/dist/languageService/referencesProvider.js +12 -5
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.d.ts +3 -0
- package/dist/languageService/signatureHelpProvider.js +56 -18
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.d.ts +2 -1
- package/dist/languageService/symbolIndexer.js +7 -7
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.d.ts +1 -1
- package/dist/languageService/tooltipUtils.js +103 -35
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.js +3 -2
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +6 -0
- package/dist/localization/localize.js +10 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +15 -0
- package/dist/localization/package.nls.de.json +15 -0
- package/dist/localization/package.nls.en-us.json +5 -0
- package/dist/localization/package.nls.es.json +15 -0
- package/dist/localization/package.nls.fr.json +15 -0
- package/dist/localization/package.nls.it.json +15 -0
- package/dist/localization/package.nls.ja.json +15 -0
- package/dist/localization/package.nls.ko.json +15 -0
- package/dist/localization/package.nls.pl.json +15 -0
- package/dist/localization/package.nls.pt-br.json +15 -0
- package/dist/localization/package.nls.qps-ploc.json +15 -0
- package/dist/localization/package.nls.ru.json +15 -0
- package/dist/localization/package.nls.tr.json +15 -0
- package/dist/localization/package.nls.zh-cn.json +16 -1
- package/dist/localization/package.nls.zh-tw.json +17 -2
- package/dist/parser/parseNodes.d.ts +85 -80
- package/dist/parser/parseNodes.js +182 -159
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parseTreeUtils.d.ts +3 -0
- package/dist/parser/parseTreeUtils.js +209 -0
- package/dist/parser/parseTreeUtils.js.map +1 -0
- package/dist/parser/parser.d.ts +16 -6
- package/dist/parser/parser.js +210 -144
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/stringAnnotationInfo.d.ts +16 -0
- package/dist/parser/stringAnnotationInfo.js +26 -0
- package/dist/parser/stringAnnotationInfo.js.map +1 -0
- package/dist/pyright.js +30 -17
- package/dist/pyright.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +2 -9
- package/dist/readonlyAugmentedFileSystem.js +17 -144
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/tests/analyzerNodeInfo.test.d.ts +1 -0
- package/dist/tests/analyzerNodeInfo.test.js +145 -0
- package/dist/tests/analyzerNodeInfo.test.js.map +1 -0
- package/dist/tests/collectionUtils.test.js +46 -0
- package/dist/tests/collectionUtils.test.js.map +1 -1
- package/dist/tests/completions.test.js +34 -0
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +131 -7
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/extraPathGlob.test.d.ts +1 -0
- package/dist/tests/extraPathGlob.test.js +434 -0
- package/dist/tests/extraPathGlob.test.js.map +1 -0
- package/dist/tests/fileSystemMapping.test.d.ts +1 -0
- package/dist/tests/fileSystemMapping.test.js +458 -0
- package/dist/tests/fileSystemMapping.test.js.map +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js +23 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js +14 -0
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js +7 -0
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.callSite.isinstanceNarrowing.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.callSite.isinstanceNarrowing.fourslash.js +41 -0
- package/dist/tests/fourslash/completions.callSite.isinstanceNarrowing.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js +2 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js +5 -0
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js +4 -0
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/findallreferences.protocolMemberVariable.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.protocolMemberVariable.fourslash.js +48 -0
- package/dist/tests/fourslash/findallreferences.protocolMemberVariable.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js +0 -1
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js +8 -2
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js +5 -2
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js.map +1 -1
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js +2 -2
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +1 -1
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/hoverProvider.test.js +38 -0
- package/dist/tests/hoverProvider.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +6 -3
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js +38 -0
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +88 -0
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/parser.test.js +60 -3
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/positionUtils.test.js +23 -0
- package/dist/tests/positionUtils.test.js.map +1 -1
- package/dist/tests/pyrightCli.test.d.ts +1 -0
- package/dist/tests/pyrightCli.test.js +205 -0
- package/dist/tests/pyrightCli.test.js.map +1 -0
- package/dist/tests/pyrightFileSystem.test.js +41 -0
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/service.test.js +183 -0
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/sourceEnumeratorSymlink.test.d.ts +1 -0
- package/dist/tests/sourceEnumeratorSymlink.test.js +203 -0
- package/dist/tests/sourceEnumeratorSymlink.test.js.map +1 -0
- package/dist/tests/stringUtils.test.js +84 -0
- package/dist/tests/stringUtils.test.js.map +1 -1
- package/dist/tests/symlinkAliasInvalidation.test.d.ts +1 -0
- package/dist/tests/symlinkAliasInvalidation.test.js +471 -0
- package/dist/tests/symlinkAliasInvalidation.test.js.map +1 -0
- package/dist/tests/testUtils.d.ts +2 -0
- package/dist/tests/testUtils.js +7 -1
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js +2 -2
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/textRangeCollection.test.d.ts +1 -0
- package/dist/tests/textRangeCollection.test.js +137 -0
- package/dist/tests/textRangeCollection.test.js.map +1 -0
- package/dist/tests/typeEquality.test.d.ts +1 -0
- package/dist/tests/typeEquality.test.js +95 -0
- package/dist/tests/typeEquality.test.js.map +1 -0
- package/dist/tests/typeEvaluator1.test.js +24 -3
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +4 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +8 -0
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +8 -0
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +1 -1
- package/dist/tests/typeEvaluator6.test.js +5 -1
- package/dist/tests/typeEvaluator6.test.js.map +1 -1
- package/dist/tests/typeEvaluator7.test.js +4 -0
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typeEvaluator8.test.js +4 -0
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/dist/tests/typeServer/typeCache.test.d.ts +1 -0
- package/dist/tests/typeServer/typeCache.test.js +69 -0
- package/dist/tests/typeServer/typeCache.test.js.map +1 -0
- package/dist/tests/typeServer/typeServer.virtualFileRedirect.test.js +18 -0
- package/dist/tests/typeServer/typeServer.virtualFileRedirect.test.js.map +1 -1
- package/dist/tests/typeStubGeneration.test.d.ts +1 -0
- package/dist/tests/typeStubGeneration.test.js +397 -0
- package/dist/tests/typeStubGeneration.test.js.map +1 -0
- package/dist/tests/typeStubOutput.test.d.ts +1 -0
- package/dist/tests/typeStubOutput.test.js +136 -0
- package/dist/tests/typeStubOutput.test.js.map +1 -0
- package/dist/tests/typeUtils.test.d.ts +1 -0
- package/dist/tests/typeUtils.test.js +133 -0
- package/dist/tests/typeUtils.test.js.map +1 -0
- package/dist/tests/uri.test.js +51 -0
- package/dist/tests/uri.test.js.map +1 -1
- package/dist/typeServer/notebookDocumentHandler.d.ts +9 -2
- package/dist/typeServer/notebookDocumentHandler.js +16 -6
- package/dist/typeServer/notebookDocumentHandler.js.map +1 -1
- package/dist/typeServer/programWrapper.d.ts +1 -0
- package/dist/typeServer/programWrapper.js +28 -15
- package/dist/typeServer/programWrapper.js.map +1 -1
- package/dist/typeServer/protocol/tspSupplemental.d.ts +1 -1
- package/dist/typeServer/protocol/tspSupplemental.js +2 -2
- package/dist/typeServer/server.d.ts +13 -2
- package/dist/typeServer/server.js +36 -23
- package/dist/typeServer/server.js.map +1 -1
- package/dist/typeServer/typeCache.d.ts +8 -4
- package/dist/typeServer/typeCache.js +33 -5
- package/dist/typeServer/typeCache.js.map +1 -1
- package/dist/typeServer/typeEvalUtils.d.ts +2 -1
- package/dist/typeServer/typeEvalUtils.js +7 -3
- package/dist/typeServer/typeEvalUtils.js.map +1 -1
- package/dist/typeServer/typeGuards.js +3 -4
- package/dist/typeServer/typeGuards.js.map +1 -1
- package/dist/typeServer/typeServerFileSystem.d.ts +10 -9
- package/dist/typeServer/typeServerFileSystem.js +16 -12
- package/dist/typeServer/typeServerFileSystem.js.map +1 -1
- package/package.json +7 -5
- package/dist/analyzer/parseTreeCleaner.d.ts +0 -8
- package/dist/analyzer/parseTreeCleaner.js +0 -65
- package/dist/analyzer/parseTreeCleaner.js.map +0 -1
- package/dist/analyzer/typeStubWriter.d.ts +0 -17
- package/dist/analyzer/typeStubWriter.js.map +0 -1
|
@@ -11,6 +11,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.SourceEnumerator = void 0;
|
|
12
12
|
const uriUtils_1 = require("../common/uri/uriUtils");
|
|
13
13
|
const envMarkers = [['bin', 'activate'], ['Scripts', 'activate'], ['pyvenv.cfg'], ['conda-meta']];
|
|
14
|
+
// Thresholds that define a "slow" enumeration. Kept at module scope so both the
|
|
15
|
+
// long-operation console warning and the `wasSlowEnumeration` getter derive
|
|
16
|
+
// "slow" from the same condition rather than from whether the warning was logged.
|
|
17
|
+
const longOperationLimitInMs = 10000;
|
|
18
|
+
const nFilesToSuggestSubfolder = 50;
|
|
19
|
+
// Configuration file names that mark a directory as a candidate "nearest
|
|
20
|
+
// configuration" root. These are collected during the normal source-file walk
|
|
21
|
+
// (see `getDiscoveredConfigFiles`) so Pylance can create virtual workspaces
|
|
22
|
+
// without performing a second traversal. Whether a `pyproject.toml` actually
|
|
23
|
+
// qualifies (i.e. has a `[tool.pyright]` section) is decided by the caller.
|
|
24
|
+
const pyrightConfigFileName = 'pyrightconfig.json';
|
|
25
|
+
const pyprojectTomlFileName = 'pyproject.toml';
|
|
14
26
|
class SourceEnumerator {
|
|
15
27
|
constructor(include, _excludes, _autoExcludeVenv, _fs, _console) {
|
|
16
28
|
this._excludes = _excludes;
|
|
@@ -29,12 +41,36 @@ class SourceEnumerator {
|
|
|
29
41
|
// potentially spanning multiple include roots, so Pylance can later filter
|
|
30
42
|
// workspace indexing against the full discovered set.
|
|
31
43
|
this._symlinkedDirectoryRoots = new Map();
|
|
44
|
+
// Candidate "nearest configuration" files (pyrightconfig.json / pyproject.toml)
|
|
45
|
+
// encountered during the walk, keyed by file uri. Surfaced to Pylance so it can
|
|
46
|
+
// create virtual workspaces without re-walking the tree. Directories that are
|
|
47
|
+
// auto-excluded (venvs) or excluded by config are never read, so configs under
|
|
48
|
+
// them are naturally skipped.
|
|
49
|
+
this._discoveredConfigFiles = new Map();
|
|
32
50
|
this._includesToExplore = include.slice(0).reverse();
|
|
51
|
+
// Resolve include roots to their real paths up front (an include root may
|
|
52
|
+
// itself be a symlink) so we can bound enumeration to directories that
|
|
53
|
+
// physically live under one of the workspace's include roots.
|
|
54
|
+
this._includeRoots = include.map((spec) => (0, uriUtils_1.tryRealpath)(_fs, spec.wildcardRoot) ?? spec.wildcardRoot);
|
|
33
55
|
this._console.log(`Searching for source files`);
|
|
34
56
|
}
|
|
57
|
+
get wasSlowEnumeration() {
|
|
58
|
+
// Derived from the elapsed-time / file-count threshold rather than from
|
|
59
|
+
// `_loggedLongOperationError` so "slow" stays independent of whether the
|
|
60
|
+
// console warning was logged. Sibling changes that alter the logging
|
|
61
|
+
// behavior (e.g. suppressing repeats) then can't silently disable this.
|
|
62
|
+
return this._isSlowEnumeration();
|
|
63
|
+
}
|
|
35
64
|
getSymlinkedDirectoryRoots() {
|
|
36
65
|
return Array.from(this._symlinkedDirectoryRoots.values());
|
|
37
66
|
}
|
|
67
|
+
// Returns the configuration files (pyrightconfig.json / pyproject.toml)
|
|
68
|
+
// discovered during enumeration. The caller decides which ones actually
|
|
69
|
+
// qualify as a configuration root (e.g. a pyproject.toml must contain a
|
|
70
|
+
// [tool.pyright] section).
|
|
71
|
+
getDiscoveredConfigFiles() {
|
|
72
|
+
return Array.from(this._discoveredConfigFiles.values());
|
|
73
|
+
}
|
|
38
74
|
// Enumerates as many files as possible within the specified
|
|
39
75
|
// time limit and returns all matching files.
|
|
40
76
|
enumerate(timeLimitInMs) {
|
|
@@ -52,11 +88,9 @@ class SourceEnumerator {
|
|
|
52
88
|
}
|
|
53
89
|
this._elapsedTimeInMs += Date.now() - startTime;
|
|
54
90
|
if (!this._loggedLongOperationError) {
|
|
55
|
-
const longOperationLimitInMs = 10000;
|
|
56
|
-
const nFilesToSuggestSubfolder = 50;
|
|
57
91
|
// If this is taking a long time, log an error to help the user
|
|
58
92
|
// diagnose and mitigate the problem.
|
|
59
|
-
if (this.
|
|
93
|
+
if (this._isSlowEnumeration()) {
|
|
60
94
|
this._console.error(`Enumeration of workspace source files is taking longer than ${longOperationLimitInMs * 0.001} seconds.\n` +
|
|
61
95
|
'This may be because:\n' +
|
|
62
96
|
'* You have opened your home directory or entire hard drive as a workspace\n' +
|
|
@@ -76,6 +110,9 @@ class SourceEnumerator {
|
|
|
76
110
|
isComplete: this._isComplete,
|
|
77
111
|
};
|
|
78
112
|
}
|
|
113
|
+
_isSlowEnumeration() {
|
|
114
|
+
return this._elapsedTimeInMs >= longOperationLimitInMs && this._numFilesVisited >= nFilesToSuggestSubfolder;
|
|
115
|
+
}
|
|
79
116
|
_recordSymlinkedDirectoryRoot(root) {
|
|
80
117
|
for (const existingRoot of this._symlinkedDirectoryRoots.values()) {
|
|
81
118
|
if (root.isChild(existingRoot)) {
|
|
@@ -117,6 +154,14 @@ class SourceEnumerator {
|
|
|
117
154
|
return;
|
|
118
155
|
}
|
|
119
156
|
this._seenDirs.add(realDirPath.key);
|
|
157
|
+
// A symlink that resolves outside every include root is not a recursive
|
|
158
|
+
// cycle (so `_seenDirs` won't catch it), but following it would pull in
|
|
159
|
+
// directories that don't belong to the workspace -- in the worst case a
|
|
160
|
+
// link to filesystem root "/" would enumerate the entire disk (issue #6006).
|
|
161
|
+
// Skip silently: external symlinks are legitimate and shouldn't be noisy.
|
|
162
|
+
if (this._includeRoots.length > 0 && !this._includeRoots.some((root) => realDirPath.startsWith(root))) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
120
165
|
if (this._autoExcludeVenv) {
|
|
121
166
|
if (envMarkers.some((f) => this._fs.existsSync(dir.uri.resolvePaths(...f)))) {
|
|
122
167
|
this._autoExcludeDirs.push(dir.uri);
|
|
@@ -133,6 +178,15 @@ class SourceEnumerator {
|
|
|
133
178
|
this._numFilesVisited++;
|
|
134
179
|
this._matches.set(file.key, file);
|
|
135
180
|
}
|
|
181
|
+
// Collect candidate configuration files. They are not `.py`/`.pyi`, so they
|
|
182
|
+
// never match include specs, but we still honor `exclude` specs: skip any
|
|
183
|
+
// config file explicitly excluded by the user (directory-level excludes and
|
|
184
|
+
// venv auto-exclusion already prevent us from reading excluded directories).
|
|
185
|
+
const fileName = file.fileName;
|
|
186
|
+
if ((fileName === pyrightConfigFileName || fileName === pyprojectTomlFileName) &&
|
|
187
|
+
!uriUtils_1.FileSpec.isInPath(file, this._excludes)) {
|
|
188
|
+
this._discoveredConfigFiles.set(file.key, file);
|
|
189
|
+
}
|
|
136
190
|
}
|
|
137
191
|
for (const subDir of directories.slice().reverse()) {
|
|
138
192
|
if (subDir.matchesRegex(dir.includeRegExp) || dir.hasDirectoryWildcard) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sourceEnumerator.js","sourceRoot":"","sources":["../../../../../src/analyzer/sourceEnumerator.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAKH,qDAAsH;AAQtH,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"sourceEnumerator.js","sourceRoot":"","sources":["../../../../../src/analyzer/sourceEnumerator.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAKH,qDAAsH;AAQtH,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AAElG,gFAAgF;AAChF,4EAA4E;AAC5E,kFAAkF;AAClF,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC,yEAAyE;AACzE,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AACnD,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAQ/C,MAAa,gBAAgB;IA0BzB,YACI,OAAmB,EACX,SAAqB,EACrB,gBAAyB,EACzB,GAAe,EACf,QAA0B;QAH1B,cAAS,GAAT,SAAS,CAAY;QACrB,qBAAgB,GAAhB,gBAAgB,CAAS;QACzB,QAAG,GAAH,GAAG,CAAY;QACf,aAAQ,GAAR,QAAQ,CAAkB;QA9B9B,qBAAgB,GAAG,CAAC,CAAC;QAErB,mBAAc,GAAmB,EAAE,CAAC;QACpC,aAAQ,GAAG,IAAI,GAAG,EAAe,CAAC;QAClC,qBAAgB,GAAU,EAAE,CAAC;QAC7B,gBAAW,GAAG,KAAK,CAAC;QACpB,qB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,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QACrC,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;YAClB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACjD,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,GAAG,UAAU,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/F,CAAC;IACL,CAAC;CACJ;AA3QD,4CA2QC"}
|
|
@@ -6,11 +6,14 @@ import { FileSystem } from '../common/fileSystem';
|
|
|
6
6
|
import { LogTracker } from '../common/logTracker';
|
|
7
7
|
import { ServiceProvider } from '../common/serviceProvider';
|
|
8
8
|
import '../common/serviceProviderExtensions';
|
|
9
|
+
import * as StringUtils from '../common/stringUtils';
|
|
9
10
|
import { TextRange } from '../common/textRange';
|
|
10
11
|
import { TextRangeCollection } from '../common/textRangeCollection';
|
|
11
12
|
import { Uri } from '../common/uri/uri';
|
|
12
|
-
import {
|
|
13
|
+
import { ModuleNode } from '../parser/parseNodes';
|
|
14
|
+
import { ParseFileResults, ParseOptions, ParserOutput } from '../parser/parser';
|
|
13
15
|
import { ImportLookup } from './analyzerFileInfo';
|
|
16
|
+
import * as AnalyzerNodeInfo from './analyzerNodeInfo';
|
|
14
17
|
import { CellChainIndexProvider } from './cellChainIndex';
|
|
15
18
|
import { CircularDependency } from './circularDependency';
|
|
16
19
|
import { ImportResolver } from './importResolver';
|
|
@@ -25,6 +28,8 @@ export declare enum IPythonMode {
|
|
|
25
28
|
}
|
|
26
29
|
export interface SourceFileEditMode {
|
|
27
30
|
readonly isEditMode: boolean;
|
|
31
|
+
readonly isClonedProgram?: boolean;
|
|
32
|
+
readonly analysisContextOwner?: object;
|
|
28
33
|
}
|
|
29
34
|
export declare class SourceFile {
|
|
30
35
|
readonly serviceProvider: ServiceProvider;
|
|
@@ -68,9 +73,9 @@ export declare class SourceFile {
|
|
|
68
73
|
getCheckTime(): number | undefined;
|
|
69
74
|
restore(): string | undefined;
|
|
70
75
|
didContentsChangeOnDisk(): boolean;
|
|
71
|
-
dropParseAndBindInfo():
|
|
76
|
+
dropParseAndBindInfo(): ModuleNode | undefined;
|
|
72
77
|
markDirty(): void;
|
|
73
|
-
markReanalysisRequired(forceRebinding: boolean): void;
|
|
78
|
+
markReanalysisRequired(forceRebinding: boolean, nodeInfoReader: AnalyzerNodeInfo.AnalyzerNodeInfoReader): void;
|
|
74
79
|
getFileContentsVersion(): number;
|
|
75
80
|
getClientVersion(): number | undefined;
|
|
76
81
|
getSemanticVersion(): number;
|
|
@@ -99,17 +104,18 @@ export declare class SourceFile {
|
|
|
99
104
|
isNoCircularDependencyConfirmed(): boolean;
|
|
100
105
|
setHitMaxImportDepth(maxImportDepth: number): void;
|
|
101
106
|
parse(configOptions: ConfigOptions, importResolver: ImportResolver, content?: string): boolean;
|
|
102
|
-
bind(configOptions: ConfigOptions, importLookup: ImportLookup, builtinsScope: Scope | undefined, futureImports: Set<string>, cellChainIndex: CellChainIndexProvider | undefined):
|
|
103
|
-
check(configOptions: ConfigOptions, importLookup: ImportLookup, importResolver: ImportResolver, evaluator: TypeEvaluator, dependentFiles
|
|
107
|
+
bind(configOptions: ConfigOptions, importLookup: ImportLookup, builtinsScope: Scope | undefined, futureImports: Set<string>, cellChainIndex: CellChainIndexProvider | undefined, nodeInfoContext: AnalyzerNodeInfo.AnalyzerNodeInfoContext): boolean;
|
|
108
|
+
check(configOptions: ConfigOptions, importLookup: ImportLookup, importResolver: ImportResolver, evaluator: TypeEvaluator, dependentFiles: ParserOutput[] | undefined, nodeInfoReader: AnalyzerNodeInfo.AnalyzerNodeInfoReader): void;
|
|
104
109
|
test_enableIPythonMode(enable: boolean): void;
|
|
105
110
|
protected createDiagnosticSink(): DiagnosticSink;
|
|
106
111
|
protected createTextRangeDiagnosticSink(lines: TextRangeCollection<TextRange>): TextRangeDiagnosticSink;
|
|
112
|
+
protected readFileContents(): string;
|
|
113
|
+
protected parseFileContents(fileContents: string, parseOptions: ParseOptions, diagSink: DiagnosticSink, contentHash: StringUtils.StringFingerprint): ParseFileResults;
|
|
107
114
|
private _makeFileId;
|
|
108
115
|
private _recomputeDiagnostics;
|
|
109
116
|
private _cachePreEditState;
|
|
110
117
|
private _addTaskListDiagnostics;
|
|
111
118
|
private _buildFileInfo;
|
|
112
|
-
private _cleanParseTreeIfRequired;
|
|
113
119
|
private _resolveImports;
|
|
114
120
|
private _getPathForLogging;
|
|
115
121
|
private _parseFile;
|
|
@@ -68,7 +68,6 @@ const AnalyzerNodeInfo = __importStar(require("./analyzerNodeInfo"));
|
|
|
68
68
|
const binder_1 = require("./binder");
|
|
69
69
|
const checker_1 = require("./checker");
|
|
70
70
|
const CommentUtils = __importStar(require("./commentUtils"));
|
|
71
|
-
const parseTreeCleaner_1 = require("./parseTreeCleaner");
|
|
72
71
|
const testWalker_1 = require("./testWalker");
|
|
73
72
|
// Limit the number of import cycles tracked per source file.
|
|
74
73
|
const _maxImportCyclesPerFile = 4;
|
|
@@ -98,14 +97,11 @@ class WriteableData {
|
|
|
98
97
|
// Number that is incremented every time semantic of the file
|
|
99
98
|
// might have changed.
|
|
100
99
|
this.semanticVersion = 0;
|
|
101
|
-
// Length and
|
|
100
|
+
// Length and fingerprint of the latest file contents supplied by disk or the client.
|
|
102
101
|
this.lastFileContentLength = undefined;
|
|
103
102
|
this.lastFileContentHash = undefined;
|
|
104
103
|
// Version of file contents that have been analyzed.
|
|
105
104
|
this.analyzedFileContentsVersion = -1;
|
|
106
|
-
// Do we need to walk the parse tree and clean
|
|
107
|
-
// the binder information hanging from it?
|
|
108
|
-
this.parseTreeNeedsCleaning = false;
|
|
109
105
|
// Reentrancy check for binding and checking.
|
|
110
106
|
this.isBindingInProgress = false;
|
|
111
107
|
this.isCheckingInProgress = false;
|
|
@@ -129,6 +125,7 @@ class WriteableData {
|
|
|
129
125
|
this.isBindingNeeded = true;
|
|
130
126
|
// Do we have valid diagnostic results from a checking pass?
|
|
131
127
|
this.isCheckingNeeded = true;
|
|
128
|
+
this.importInfo = [];
|
|
132
129
|
// True if the file appears to have been deleted.
|
|
133
130
|
this.isFileDeleted = false;
|
|
134
131
|
// Empty
|
|
@@ -143,12 +140,11 @@ class WriteableData {
|
|
|
143
140
|
isCheckingNeeded=${this.isCheckingNeeded},
|
|
144
141
|
isFileDeleted=${this.isFileDeleted},
|
|
145
142
|
hitMaxImportDepth=${this.hitMaxImportDepth},
|
|
146
|
-
parseTreeNeedsCleaning=${this.parseTreeNeedsCleaning},
|
|
147
143
|
fileContentsVersion=${this.fileContentsVersion},
|
|
148
144
|
analyzedFileContentsVersion=${this.analyzedFileContentsVersion},
|
|
149
145
|
clientDocumentVersion=${this.clientDocumentVersion},
|
|
150
146
|
lastFileContentLength=${this.lastFileContentLength},
|
|
151
|
-
lastFileContentHash=${this.lastFileContentHash},
|
|
147
|
+
lastFileContentHash=${JSON.stringify(this.lastFileContentHash)},
|
|
152
148
|
typeIgnoreAll=${this.typeIgnoreAll},
|
|
153
149
|
imports=${this.imports?.length},
|
|
154
150
|
builtinsImport=${this.builtinsImport?.importName},
|
|
@@ -307,7 +303,7 @@ class SourceFile {
|
|
|
307
303
|
if (this._writableData.lastFileContentLength === undefined) {
|
|
308
304
|
return true;
|
|
309
305
|
}
|
|
310
|
-
// Read in the latest file contents and see if the
|
|
306
|
+
// Read in the latest file contents and see if the fingerprint matches
|
|
311
307
|
// that of the previous contents.
|
|
312
308
|
try {
|
|
313
309
|
// Read the file's contents.
|
|
@@ -316,7 +312,9 @@ class SourceFile {
|
|
|
316
312
|
if (fileContents.length !== this._writableData.lastFileContentLength) {
|
|
317
313
|
return true;
|
|
318
314
|
}
|
|
319
|
-
|
|
315
|
+
const contentHash = StringUtils.getStringFingerprint(fileContents);
|
|
316
|
+
if (!this._writableData.lastFileContentHash ||
|
|
317
|
+
!StringUtils.areStringFingerprintsEqual(contentHash, this._writableData.lastFileContentHash)) {
|
|
320
318
|
return true;
|
|
321
319
|
}
|
|
322
320
|
}
|
|
@@ -337,16 +335,20 @@ class SourceFile {
|
|
|
337
335
|
// If we are actively binding or checking this file, we can't
|
|
338
336
|
// safely drop parse and binding info.
|
|
339
337
|
if (this._writableData.isBindingInProgress || this._writableData.isCheckingInProgress) {
|
|
340
|
-
return;
|
|
338
|
+
return undefined;
|
|
341
339
|
}
|
|
342
340
|
this._fireFileDirtyEvent();
|
|
341
|
+
const parseTree = this._writableData.parserOutput?.parseTree;
|
|
343
342
|
this._writableData.parserOutput = undefined;
|
|
344
343
|
this._writableData.tokenizerLines = undefined;
|
|
345
344
|
this._writableData.tokenizerOutput = undefined;
|
|
346
345
|
this._writableData.parsedFileContents = undefined;
|
|
346
|
+
this._writableData.parsedFileContentsHash = undefined;
|
|
347
347
|
this._writableData.moduleSymbolTable = undefined;
|
|
348
348
|
this._writableData.isBindingNeeded = true;
|
|
349
|
+
this._writableData.importInfo = [];
|
|
349
350
|
this._writableData.imports = [];
|
|
351
|
+
return parseTree;
|
|
350
352
|
}
|
|
351
353
|
markDirty() {
|
|
352
354
|
this._writableData.fileContentsVersion++;
|
|
@@ -358,7 +360,7 @@ class SourceFile {
|
|
|
358
360
|
this._writableData.lineCount = undefined;
|
|
359
361
|
this._fireFileDirtyEvent();
|
|
360
362
|
}
|
|
361
|
-
markReanalysisRequired(forceRebinding) {
|
|
363
|
+
markReanalysisRequired(forceRebinding, nodeInfoReader) {
|
|
362
364
|
// Keep the parse info, but reset the analysis to the beginning.
|
|
363
365
|
this._writableData.semanticVersion++;
|
|
364
366
|
this._writableData.isCheckingNeeded = true;
|
|
@@ -367,12 +369,12 @@ class SourceFile {
|
|
|
367
369
|
// we need to rebind because a dependent import may have changed.
|
|
368
370
|
if (this._writableData.parserOutput) {
|
|
369
371
|
if (this._writableData.parserOutput.containsWildcardImport ||
|
|
370
|
-
AnalyzerNodeInfo.getDunderAllInfo(this._writableData.parserOutput.parseTree) !==
|
|
372
|
+
AnalyzerNodeInfo.getDunderAllInfo(this._writableData.parserOutput.parseTree, nodeInfoReader) !==
|
|
373
|
+
undefined ||
|
|
371
374
|
forceRebinding) {
|
|
372
375
|
// We don't need to rebuild index data since wildcard
|
|
373
376
|
// won't affect user file indices. User file indices
|
|
374
377
|
// don't contain import alias info.
|
|
375
|
-
this._writableData.parseTreeNeedsCleaning = true;
|
|
376
378
|
this._writableData.isBindingNeeded = true;
|
|
377
379
|
this._writableData.moduleSymbolTable = undefined;
|
|
378
380
|
}
|
|
@@ -412,7 +414,7 @@ class SourceFile {
|
|
|
412
414
|
`which exceeds the maximum supported file size of ${exports.maxSourceFileSize}`);
|
|
413
415
|
throw new Error('File larger than max');
|
|
414
416
|
}
|
|
415
|
-
return this.
|
|
417
|
+
return this.readFileContents();
|
|
416
418
|
}
|
|
417
419
|
catch (error) {
|
|
418
420
|
return undefined;
|
|
@@ -431,10 +433,11 @@ class SourceFile {
|
|
|
431
433
|
else {
|
|
432
434
|
this._writableData.clientDocumentVersion = version;
|
|
433
435
|
this._writableData.clientDocumentContents = contents;
|
|
434
|
-
const contentsHash = StringUtils.
|
|
436
|
+
const contentsHash = StringUtils.getStringFingerprint(contents);
|
|
435
437
|
// Have the contents of the file changed?
|
|
436
438
|
if (contents.length !== this._writableData.lastFileContentLength ||
|
|
437
|
-
|
|
439
|
+
!this._writableData.lastFileContentHash ||
|
|
440
|
+
!StringUtils.areStringFingerprintsEqual(contentsHash, this._writableData.lastFileContentHash)) {
|
|
438
441
|
this.markDirty();
|
|
439
442
|
}
|
|
440
443
|
this._writableData.lastFileContentLength = contents.length;
|
|
@@ -473,7 +476,8 @@ class SourceFile {
|
|
|
473
476
|
// Otherwise re-tokenize the contents on demand.
|
|
474
477
|
const tokenizeContents = this._tokenizeContents.bind(this);
|
|
475
478
|
const parsedFileContents = this._writableData.parsedFileContents;
|
|
476
|
-
const contentHash = this._writableData.
|
|
479
|
+
const contentHash = this._writableData.parsedFileContentsHash ??
|
|
480
|
+
StringUtils.getStringFingerprint(this._writableData.parsedFileContents);
|
|
477
481
|
let tokenizerOutput = this._writableData.tokenizerOutput;
|
|
478
482
|
return {
|
|
479
483
|
contentHash,
|
|
@@ -531,6 +535,7 @@ class SourceFile {
|
|
|
531
535
|
}
|
|
532
536
|
const diagSink = this.createDiagnosticSink();
|
|
533
537
|
let fileContents = this.getOpenFileContents();
|
|
538
|
+
let contentHash = fileContents !== undefined ? this._writableData.lastFileContentHash : undefined;
|
|
534
539
|
if (fileContents === undefined) {
|
|
535
540
|
try {
|
|
536
541
|
const startTime = timing_1.timingStats.readFileTime.totalTime;
|
|
@@ -540,27 +545,31 @@ class SourceFile {
|
|
|
540
545
|
if (fileContents === undefined) {
|
|
541
546
|
throw new Error("Can't get file content");
|
|
542
547
|
}
|
|
543
|
-
// Remember the length and
|
|
548
|
+
// Remember the length and fingerprint for comparison purposes.
|
|
544
549
|
this._writableData.lastFileContentLength = fileContents.length;
|
|
545
|
-
|
|
550
|
+
contentHash = StringUtils.getStringFingerprint(fileContents);
|
|
551
|
+
this._writableData.lastFileContentHash = contentHash;
|
|
546
552
|
});
|
|
547
553
|
logState.add(`fs read ${timing_1.timingStats.readFileTime.totalTime - startTime}ms`);
|
|
548
554
|
}
|
|
549
555
|
catch (error) {
|
|
550
556
|
diagSink.addError(`Source file could not be read`, (0, textRange_1.getEmptyRange)());
|
|
551
557
|
fileContents = '';
|
|
558
|
+
contentHash = StringUtils.getStringFingerprint(fileContents);
|
|
552
559
|
if (!this.fileSystem.existsSync(this._uri)) {
|
|
553
560
|
this._writableData.isFileDeleted = true;
|
|
554
561
|
}
|
|
555
562
|
}
|
|
556
563
|
}
|
|
557
564
|
try {
|
|
565
|
+
contentHash ?? (contentHash = StringUtils.getStringFingerprint(fileContents));
|
|
558
566
|
// Parse the token stream, building the abstract syntax tree.
|
|
559
|
-
const parseFileResults = this._parseFile(configOptions, this._uri, fileContents, this._ipythonMode !== IPythonMode.None, diagSink);
|
|
567
|
+
const parseFileResults = this._parseFile(configOptions, this._uri, fileContents, this._ipythonMode !== IPythonMode.None, diagSink, contentHash);
|
|
560
568
|
(0, debug_1.assert)(parseFileResults !== undefined && parseFileResults.tokenizerOutput !== undefined);
|
|
561
569
|
this._writableData.parserOutput = parseFileResults.parserOutput;
|
|
562
570
|
this._writableData.tokenizerLines = parseFileResults.tokenizerOutput.lines;
|
|
563
571
|
this._writableData.parsedFileContents = fileContents;
|
|
572
|
+
this._writableData.parsedFileContentsHash = parseFileResults.contentHash;
|
|
564
573
|
this._writableData.typeIgnoreLines = parseFileResults.tokenizerOutput.typeIgnoreLines;
|
|
565
574
|
this._writableData.typeIgnoreAll = parseFileResults.tokenizerOutput.typeIgnoreAll;
|
|
566
575
|
this._writableData.pyrightIgnoreLines = parseFileResults.tokenizerOutput.pyrightIgnoreLines;
|
|
@@ -575,6 +584,7 @@ class SourceFile {
|
|
|
575
584
|
const importResult = this._resolveImports(importResolver, parseFileResults.parserOutput.importedModules, execEnvironment);
|
|
576
585
|
this._writableData.imports = importResult.imports;
|
|
577
586
|
this._writableData.builtinsImport = importResult.builtinsImportResult;
|
|
587
|
+
this._writableData.importInfo = importResult.importInfo;
|
|
578
588
|
this._writableData.parseDiagnostics = diagSink.fetchAndClear();
|
|
579
589
|
this._writableData.taskListDiagnostics = [];
|
|
580
590
|
this._addTaskListDiagnostics(configOptions.taskListTokens, parseFileResults, this._writableData.taskListDiagnostics);
|
|
@@ -599,9 +609,12 @@ class SourceFile {
|
|
|
599
609
|
}));
|
|
600
610
|
// Create dummy parse results.
|
|
601
611
|
this._writableData.parsedFileContents = '';
|
|
612
|
+
this._writableData.parsedFileContentsHash = StringUtils.getStringFingerprint('');
|
|
602
613
|
this._writableData.tokenizerLines = new textRangeCollection_1.TextRangeCollection([]);
|
|
614
|
+
const parseTree = parseNodes_1.ModuleNode.create({ start: 0, length: 0 });
|
|
603
615
|
this._writableData.parserOutput = {
|
|
604
|
-
parseTree
|
|
616
|
+
parseTree,
|
|
617
|
+
stringAnnotations: (0, parseNodes_1.getParserStringAnnotationInfo)(parseTree),
|
|
605
618
|
importedModules: [],
|
|
606
619
|
futureImports: new Set(),
|
|
607
620
|
containsWildcardImport: false,
|
|
@@ -622,6 +635,7 @@ class SourceFile {
|
|
|
622
635
|
};
|
|
623
636
|
this._writableData.imports = undefined;
|
|
624
637
|
this._writableData.builtinsImport = undefined;
|
|
638
|
+
this._writableData.importInfo = [];
|
|
625
639
|
const diagSink = this.createDiagnosticSink();
|
|
626
640
|
diagSink.addError(localize_1.LocMessage.internalParseError().format({
|
|
627
641
|
file: this.getUri().toUserVisibleString(),
|
|
@@ -635,38 +649,44 @@ class SourceFile {
|
|
|
635
649
|
this._writableData.analyzedFileContentsVersion = this._writableData.fileContentsVersion;
|
|
636
650
|
this._writableData.isBindingNeeded = true;
|
|
637
651
|
this._writableData.isCheckingNeeded = true;
|
|
638
|
-
this._writableData.parseTreeNeedsCleaning = false;
|
|
639
652
|
this._writableData.hitMaxImportDepth = undefined;
|
|
640
653
|
this._recomputeDiagnostics(configOptions);
|
|
641
654
|
return true;
|
|
642
655
|
});
|
|
643
656
|
}
|
|
644
|
-
bind(configOptions, importLookup, builtinsScope, futureImports, cellChainIndex) {
|
|
657
|
+
bind(configOptions, importLookup, builtinsScope, futureImports, cellChainIndex, nodeInfoContext) {
|
|
645
658
|
(0, debug_1.assert)(!this.isParseRequired(), 'Bind called before parsing');
|
|
646
659
|
(0, debug_1.assert)(this.isBindingRequired(), 'Bind called unnecessarily');
|
|
647
660
|
(0, debug_1.assert)(!this._writableData.isBindingInProgress, 'Bind called while binding in progress');
|
|
648
661
|
(0, debug_1.assert)(this._writableData.parserOutput !== undefined, 'Parse results not available');
|
|
649
662
|
return this._logTracker.log(`binding: ${this._getPathForLogging(this._uri)}`, () => {
|
|
663
|
+
let bound = false;
|
|
650
664
|
try {
|
|
651
665
|
// Perform name binding.
|
|
652
666
|
timing_1.timingStats.bindTime.timeOperation(() => {
|
|
653
|
-
this.
|
|
667
|
+
const parseTree = this._writableData.parserOutput.parseTree;
|
|
668
|
+
const bindingSession = nodeInfoContext.beginWrite(parseTree);
|
|
669
|
+
const nodeInfo = AnalyzerNodeInfo.createAnalyzerNodeInfoAccessor(bindingSession, bindingSession);
|
|
670
|
+
this._writableData.importInfo.forEach((record) => nodeInfo.setImportInfo(record.node, record.importResult));
|
|
654
671
|
const fileInfo = this._buildFileInfo(configOptions, importLookup, builtinsScope, futureImports);
|
|
655
|
-
|
|
656
|
-
const binder = new binder_1.Binder(fileInfo, configOptions.indexGenerationMode, cellChainIndex);
|
|
672
|
+
nodeInfo.setFileInfo(parseTree, fileInfo);
|
|
673
|
+
const binder = new binder_1.Binder(fileInfo, configOptions.indexGenerationMode, cellChainIndex, nodeInfo);
|
|
657
674
|
this._writableData.isBindingInProgress = true;
|
|
658
|
-
binder.bindModule(
|
|
675
|
+
binder.bindModule(parseTree);
|
|
676
|
+
const bindDiagnostics = fileInfo.diagnosticSink.fetchAndClear();
|
|
677
|
+
const moduleScope = nodeInfo.getScope(parseTree);
|
|
678
|
+
(0, debug_1.assert)(moduleScope !== undefined, 'Module scope not returned by binder');
|
|
679
|
+
nodeInfoContext.publish(bindingSession);
|
|
680
|
+
this._writableData.moduleSymbolTable = moduleScope.symbolTable;
|
|
681
|
+
this._writableData.bindDiagnostics = bindDiagnostics;
|
|
659
682
|
// If we're in "test mode" (used for unit testing), run an additional
|
|
660
683
|
// "test walker" over the parse tree to validate its internal consistency.
|
|
661
684
|
if (configOptions.internalTestMode) {
|
|
662
685
|
const testWalker = new testWalker_1.TestWalker();
|
|
663
686
|
testWalker.walk(this._writableData.parserOutput.parseTree);
|
|
664
687
|
}
|
|
665
|
-
this._writableData.bindDiagnostics = fileInfo.diagnosticSink.fetchAndClear();
|
|
666
|
-
const moduleScope = AnalyzerNodeInfo.getScope(this._writableData.parserOutput.parseTree);
|
|
667
|
-
(0, debug_1.assert)(moduleScope !== undefined, 'Module scope not returned by binder');
|
|
668
|
-
this._writableData.moduleSymbolTable = moduleScope.symbolTable;
|
|
669
688
|
});
|
|
689
|
+
bound = true;
|
|
670
690
|
}
|
|
671
691
|
catch (e) {
|
|
672
692
|
const message = (e.stack ? e.stack.toString() : undefined) ||
|
|
@@ -689,12 +709,13 @@ class SourceFile {
|
|
|
689
709
|
this._writableData.isBindingInProgress = false;
|
|
690
710
|
}
|
|
691
711
|
// Prepare for the next stage of the analysis.
|
|
692
|
-
this._writableData.isCheckingNeeded =
|
|
712
|
+
this._writableData.isCheckingNeeded = bound;
|
|
693
713
|
this._writableData.isBindingNeeded = false;
|
|
694
714
|
this._recomputeDiagnostics(configOptions);
|
|
715
|
+
return bound;
|
|
695
716
|
});
|
|
696
717
|
}
|
|
697
|
-
check(configOptions, importLookup, importResolver, evaluator, dependentFiles) {
|
|
718
|
+
check(configOptions, importLookup, importResolver, evaluator, dependentFiles, nodeInfoReader) {
|
|
698
719
|
(0, debug_1.assert)(!this.isParseRequired(), `Check called before parsing: state=${this._writableData.debugPrint()}`);
|
|
699
720
|
(0, debug_1.assert)(!this.isBindingRequired(), `Check called before binding: state=${this._writableData.debugPrint()}`);
|
|
700
721
|
(0, debug_1.assert)(!this._writableData.isBindingInProgress, 'Check called while binding in progress');
|
|
@@ -705,11 +726,12 @@ class SourceFile {
|
|
|
705
726
|
try {
|
|
706
727
|
timing_1.timingStats.typeCheckerTime.timeOperation(() => {
|
|
707
728
|
const checkDuration = new timing_1.Duration();
|
|
708
|
-
const
|
|
729
|
+
const nodeInfo = AnalyzerNodeInfo.createAnalyzerNodeInfoAccessor(nodeInfoReader);
|
|
730
|
+
const checker = new checker_1.Checker(importResolver, evaluator, this._writableData.parserOutput, dependentFiles, nodeInfo);
|
|
709
731
|
this._writableData.isCheckingInProgress = true;
|
|
710
732
|
checker.check();
|
|
711
733
|
this._writableData.isCheckingNeeded = false;
|
|
712
|
-
const fileInfo =
|
|
734
|
+
const fileInfo = nodeInfo.getFileInfo(this._writableData.parserOutput.parseTree);
|
|
713
735
|
this._writableData.checkerDiagnostics = fileInfo.diagnosticSink.fetchAndClear();
|
|
714
736
|
this._writableData.checkTime = checkDuration.getDurationInMilliseconds();
|
|
715
737
|
});
|
|
@@ -754,6 +776,12 @@ class SourceFile {
|
|
|
754
776
|
createTextRangeDiagnosticSink(lines) {
|
|
755
777
|
return new diagnosticSink_1.TextRangeDiagnosticSink(lines);
|
|
756
778
|
}
|
|
779
|
+
readFileContents() {
|
|
780
|
+
return this.fileSystem.readFileSync(this._uri, 'utf8');
|
|
781
|
+
}
|
|
782
|
+
parseFileContents(fileContents, parseOptions, diagSink, contentHash) {
|
|
783
|
+
return new parser_1.Parser().parseSourceFile(fileContents, parseOptions, diagSink, contentHash);
|
|
784
|
+
}
|
|
757
785
|
// Creates a short string that can be used to uniquely identify
|
|
758
786
|
// this file from all other files. It is used in the type evaluator
|
|
759
787
|
// to distinguish between types that are defined in different files
|
|
@@ -1072,17 +1100,9 @@ class SourceFile {
|
|
|
1072
1100
|
};
|
|
1073
1101
|
return fileInfo;
|
|
1074
1102
|
}
|
|
1075
|
-
_cleanParseTreeIfRequired() {
|
|
1076
|
-
if (this._writableData.parserOutput) {
|
|
1077
|
-
if (this._writableData.parseTreeNeedsCleaning) {
|
|
1078
|
-
const cleanerWalker = new parseTreeCleaner_1.ParseTreeCleanerWalker(this._writableData.parserOutput.parseTree);
|
|
1079
|
-
cleanerWalker.clean();
|
|
1080
|
-
this._writableData.parseTreeNeedsCleaning = false;
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
1103
|
_resolveImports(importResolver, moduleImports, execEnv) {
|
|
1085
1104
|
const imports = [];
|
|
1105
|
+
const importInfo = [];
|
|
1086
1106
|
const resolveAndAddIfNotSelf = (nameParts, skipMissingImport = false) => {
|
|
1087
1107
|
const importResult = importResolver.resolveImport(this._uri, execEnv, {
|
|
1088
1108
|
leadingDots: 0,
|
|
@@ -1121,7 +1141,7 @@ class SourceFile {
|
|
|
1121
1141
|
// name node in the parse tree so we can access it later
|
|
1122
1142
|
// (for hover and definition support).
|
|
1123
1143
|
if (moduleImport.nameParts.length === moduleImport.nameNode.d.nameParts.length) {
|
|
1124
|
-
|
|
1144
|
+
importInfo.push({ node: moduleImport.nameNode, importResult });
|
|
1125
1145
|
}
|
|
1126
1146
|
else {
|
|
1127
1147
|
// For implicit imports of higher-level modules within a multi-part
|
|
@@ -1130,18 +1150,22 @@ class SourceFile {
|
|
|
1130
1150
|
// case, store the import info on the name part node.
|
|
1131
1151
|
(0, debug_1.assert)(moduleImport.nameParts.length > 0);
|
|
1132
1152
|
(0, debug_1.assert)(moduleImport.nameParts.length - 1 < moduleImport.nameNode.d.nameParts.length);
|
|
1133
|
-
|
|
1153
|
+
importInfo.push({
|
|
1154
|
+
node: moduleImport.nameNode.d.nameParts[moduleImport.nameParts.length - 1],
|
|
1155
|
+
importResult,
|
|
1156
|
+
});
|
|
1134
1157
|
}
|
|
1135
1158
|
}
|
|
1136
1159
|
return {
|
|
1137
1160
|
imports,
|
|
1138
1161
|
builtinsImportResult,
|
|
1162
|
+
importInfo,
|
|
1139
1163
|
};
|
|
1140
1164
|
}
|
|
1141
1165
|
_getPathForLogging(fileUri) {
|
|
1142
1166
|
return (0, logTracker_1.getPathForLogging)(this.fileSystem, fileUri);
|
|
1143
1167
|
}
|
|
1144
|
-
_parseFile(configOptions, fileUri, fileContents, useNotebookMode, diagSink) {
|
|
1168
|
+
_parseFile(configOptions, fileUri, fileContents, useNotebookMode, diagSink, contentHash) {
|
|
1145
1169
|
// Use the configuration options to determine the environment zin which
|
|
1146
1170
|
// this source file will be executed.
|
|
1147
1171
|
const execEnvironment = configOptions.findExecEnvironment(fileUri);
|
|
@@ -1153,8 +1177,7 @@ class SourceFile {
|
|
|
1153
1177
|
parseOptions.pythonVersion = execEnvironment.pythonVersion;
|
|
1154
1178
|
parseOptions.skipFunctionAndClassBody = configOptions.indexGenerationMode ?? false;
|
|
1155
1179
|
// Parse the token stream, building the abstract syntax tree.
|
|
1156
|
-
|
|
1157
|
-
return parser.parseSourceFile(fileContents, parseOptions, diagSink);
|
|
1180
|
+
return this.parseFileContents(fileContents, parseOptions, diagSink, contentHash);
|
|
1158
1181
|
}
|
|
1159
1182
|
_tokenizeContents(fileContents, contentHash) {
|
|
1160
1183
|
const tokenizer = new tokenizer_1.Tokenizer();
|
|
@@ -1162,7 +1185,8 @@ class SourceFile {
|
|
|
1162
1185
|
// When the file is open, cache the tokenizer results.
|
|
1163
1186
|
// Because the tokenizer is lazy, ensure that the state remains unchanged before caching its output.
|
|
1164
1187
|
if (this._writableData.clientDocumentContents !== undefined &&
|
|
1165
|
-
this._writableData.lastFileContentHash
|
|
1188
|
+
this._writableData.lastFileContentHash &&
|
|
1189
|
+
StringUtils.areStringFingerprintsEqual(this._writableData.lastFileContentHash, contentHash)) {
|
|
1166
1190
|
this._writableData.tokenizerOutput = output;
|
|
1167
1191
|
// Replace the existing tokenizerLines with the newly-returned
|
|
1168
1192
|
// version. They should have the same contents, but we want to use
|