@zzzen/pyright-internal 1.1.254
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/aliasDeclarationUtils.d.ts +9 -0
- package/dist/analyzer/aliasDeclarationUtils.js +128 -0
- package/dist/analyzer/aliasDeclarationUtils.js.map +1 -0
- package/dist/analyzer/analysis.d.ts +18 -0
- package/dist/analyzer/analysis.js +81 -0
- package/dist/analyzer/analysis.js.map +1 -0
- package/dist/analyzer/analyzerFileInfo.d.ts +39 -0
- package/dist/analyzer/analyzerFileInfo.js +17 -0
- package/dist/analyzer/analyzerFileInfo.js.map +1 -0
- package/dist/analyzer/analyzerNodeInfo.d.ts +32 -0
- package/dist/analyzer/analyzerNodeInfo.js +138 -0
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -0
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +54 -0
- package/dist/analyzer/backgroundAnalysisProgram.js +222 -0
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -0
- package/dist/analyzer/binder.d.ts +149 -0
- package/dist/analyzer/binder.js +3195 -0
- package/dist/analyzer/binder.js.map +1 -0
- package/dist/analyzer/checker.d.ts +116 -0
- package/dist/analyzer/checker.js +3828 -0
- package/dist/analyzer/checker.js.map +1 -0
- package/dist/analyzer/circularDependency.d.ts +7 -0
- package/dist/analyzer/circularDependency.js +51 -0
- package/dist/analyzer/circularDependency.js.map +1 -0
- package/dist/analyzer/codeFlowEngine.d.ts +21 -0
- package/dist/analyzer/codeFlowEngine.js +1132 -0
- package/dist/analyzer/codeFlowEngine.js.map +1 -0
- package/dist/analyzer/codeFlowTypes.d.ts +82 -0
- package/dist/analyzer/codeFlowTypes.js +134 -0
- package/dist/analyzer/codeFlowTypes.js.map +1 -0
- package/dist/analyzer/codeFlowUtils.d.ts +2 -0
- package/dist/analyzer/codeFlowUtils.js +348 -0
- package/dist/analyzer/codeFlowUtils.js.map +1 -0
- package/dist/analyzer/commentUtils.d.ts +4 -0
- package/dist/analyzer/commentUtils.js +131 -0
- package/dist/analyzer/commentUtils.js.map +1 -0
- package/dist/analyzer/constraintSolver.d.ts +7 -0
- package/dist/analyzer/constraintSolver.js +605 -0
- package/dist/analyzer/constraintSolver.js.map +1 -0
- package/dist/analyzer/constructorTransform.d.ts +4 -0
- package/dist/analyzer/constructorTransform.js +219 -0
- package/dist/analyzer/constructorTransform.js.map +1 -0
- package/dist/analyzer/dataClasses.d.ts +9 -0
- package/dist/analyzer/dataClasses.js +762 -0
- package/dist/analyzer/dataClasses.js.map +1 -0
- package/dist/analyzer/declaration.d.ts +90 -0
- package/dist/analyzer/declaration.js +42 -0
- package/dist/analyzer/declaration.js.map +1 -0
- package/dist/analyzer/declarationUtils.d.ts +12 -0
- package/dist/analyzer/declarationUtils.js +212 -0
- package/dist/analyzer/declarationUtils.js.map +1 -0
- package/dist/analyzer/docStringConversion.d.ts +2 -0
- package/dist/analyzer/docStringConversion.js +699 -0
- package/dist/analyzer/docStringConversion.js.map +1 -0
- package/dist/analyzer/docStringUtils.d.ts +3 -0
- package/dist/analyzer/docStringUtils.js +103 -0
- package/dist/analyzer/docStringUtils.js.map +1 -0
- package/dist/analyzer/functionTransform.d.ts +4 -0
- package/dist/analyzer/functionTransform.js +96 -0
- package/dist/analyzer/functionTransform.js.map +1 -0
- package/dist/analyzer/importResolver.d.ts +97 -0
- package/dist/analyzer/importResolver.js +1617 -0
- package/dist/analyzer/importResolver.js.map +1 -0
- package/dist/analyzer/importResult.d.ts +33 -0
- package/dist/analyzer/importResult.js +11 -0
- package/dist/analyzer/importResult.js.map +1 -0
- package/dist/analyzer/importStatementUtils.d.ts +46 -0
- package/dist/analyzer/importStatementUtils.js +618 -0
- package/dist/analyzer/importStatementUtils.js.map +1 -0
- package/dist/analyzer/namedTuples.d.ts +5 -0
- package/dist/analyzer/namedTuples.js +342 -0
- package/dist/analyzer/namedTuples.js.map +1 -0
- package/dist/analyzer/packageTypeReport.d.ts +52 -0
- package/dist/analyzer/packageTypeReport.js +45 -0
- package/dist/analyzer/packageTypeReport.js.map +1 -0
- package/dist/analyzer/packageTypeVerifier.d.ts +37 -0
- package/dist/analyzer/packageTypeVerifier.js +908 -0
- package/dist/analyzer/packageTypeVerifier.js.map +1 -0
- package/dist/analyzer/parentDirectoryCache.d.ts +23 -0
- package/dist/analyzer/parentDirectoryCache.js +71 -0
- package/dist/analyzer/parentDirectoryCache.js.map +1 -0
- package/dist/analyzer/parseTreeCleaner.d.ts +8 -0
- package/dist/analyzer/parseTreeCleaner.js +51 -0
- package/dist/analyzer/parseTreeCleaner.js.map +1 -0
- package/dist/analyzer/parseTreeUtils.d.ts +98 -0
- package/dist/analyzer/parseTreeUtils.js +1753 -0
- package/dist/analyzer/parseTreeUtils.js.map +1 -0
- package/dist/analyzer/parseTreeWalker.d.ts +81 -0
- package/dist/analyzer/parseTreeWalker.js +437 -0
- package/dist/analyzer/parseTreeWalker.js.map +1 -0
- package/dist/analyzer/patternMatching.d.ts +6 -0
- package/dist/analyzer/patternMatching.js +866 -0
- package/dist/analyzer/patternMatching.js.map +1 -0
- package/dist/analyzer/program.d.ts +158 -0
- package/dist/analyzer/program.js +1902 -0
- package/dist/analyzer/program.js.map +1 -0
- package/dist/analyzer/properties.d.ts +10 -0
- package/dist/analyzer/properties.js +368 -0
- package/dist/analyzer/properties.js.map +1 -0
- package/dist/analyzer/protocols.d.ts +8 -0
- package/dist/analyzer/protocols.js +409 -0
- package/dist/analyzer/protocols.js.map +1 -0
- package/dist/analyzer/pyTypedUtils.d.ts +6 -0
- package/dist/analyzer/pyTypedUtils.js +42 -0
- package/dist/analyzer/pyTypedUtils.js.map +1 -0
- package/dist/analyzer/pythonPathUtils.d.ts +14 -0
- package/dist/analyzer/pythonPathUtils.js +173 -0
- package/dist/analyzer/pythonPathUtils.js.map +1 -0
- package/dist/analyzer/scope.d.ts +39 -0
- package/dist/analyzer/scope.js +110 -0
- package/dist/analyzer/scope.js.map +1 -0
- package/dist/analyzer/scopeUtils.d.ts +6 -0
- package/dist/analyzer/scopeUtils.js +72 -0
- package/dist/analyzer/scopeUtils.js.map +1 -0
- package/dist/analyzer/service.d.ts +144 -0
- package/dist/analyzer/service.js +1197 -0
- package/dist/analyzer/service.js.map +1 -0
- package/dist/analyzer/sourceFile.d.ts +123 -0
- package/dist/analyzer/sourceFile.js +908 -0
- package/dist/analyzer/sourceFile.js.map +1 -0
- package/dist/analyzer/sourceMapper.d.ts +47 -0
- package/dist/analyzer/sourceMapper.js +543 -0
- package/dist/analyzer/sourceMapper.js.map +1 -0
- package/dist/analyzer/staticExpressions.d.ts +4 -0
- package/dist/analyzer/staticExpressions.js +242 -0
- package/dist/analyzer/staticExpressions.js.map +1 -0
- package/dist/analyzer/symbol.d.ts +50 -0
- package/dist/analyzer/symbol.js +160 -0
- package/dist/analyzer/symbol.js.map +1 -0
- package/dist/analyzer/symbolNameUtils.d.ts +8 -0
- package/dist/analyzer/symbolNameUtils.js +53 -0
- package/dist/analyzer/symbolNameUtils.js.map +1 -0
- package/dist/analyzer/symbolUtils.d.ts +7 -0
- package/dist/analyzer/symbolUtils.js +46 -0
- package/dist/analyzer/symbolUtils.js.map +1 -0
- package/dist/analyzer/testWalker.d.ts +14 -0
- package/dist/analyzer/testWalker.js +92 -0
- package/dist/analyzer/testWalker.js.map +1 -0
- package/dist/analyzer/tracePrinter.d.ts +11 -0
- package/dist/analyzer/tracePrinter.js +222 -0
- package/dist/analyzer/tracePrinter.js.map +1 -0
- package/dist/analyzer/typeCache.d.ts +40 -0
- package/dist/analyzer/typeCache.js +134 -0
- package/dist/analyzer/typeCache.js.map +1 -0
- package/dist/analyzer/typeDocStringUtils.d.ts +12 -0
- package/dist/analyzer/typeDocStringUtils.js +293 -0
- package/dist/analyzer/typeDocStringUtils.js.map +1 -0
- package/dist/analyzer/typeEvaluator.d.ts +18 -0
- package/dist/analyzer/typeEvaluator.js +16598 -0
- package/dist/analyzer/typeEvaluator.js.map +1 -0
- package/dist/analyzer/typeEvaluatorTypes.d.ts +220 -0
- package/dist/analyzer/typeEvaluatorTypes.js +16 -0
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -0
- package/dist/analyzer/typeEvaluatorWithTracker.d.ts +6 -0
- package/dist/analyzer/typeEvaluatorWithTracker.js +121 -0
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -0
- package/dist/analyzer/typeGuards.d.ts +6 -0
- package/dist/analyzer/typeGuards.js +1293 -0
- package/dist/analyzer/typeGuards.js.map +1 -0
- package/dist/analyzer/typePrinter.d.ts +17 -0
- package/dist/analyzer/typePrinter.js +603 -0
- package/dist/analyzer/typePrinter.js.map +1 -0
- package/dist/analyzer/typeStubWriter.d.ts +48 -0
- package/dist/analyzer/typeStubWriter.js +605 -0
- package/dist/analyzer/typeStubWriter.js.map +1 -0
- package/dist/analyzer/typeUtils.d.ts +134 -0
- package/dist/analyzer/typeUtils.js +2380 -0
- package/dist/analyzer/typeUtils.js.map +1 -0
- package/dist/analyzer/typeVarContext.d.ts +50 -0
- package/dist/analyzer/typeVarContext.js +250 -0
- package/dist/analyzer/typeVarContext.js.map +1 -0
- package/dist/analyzer/typedDicts.d.ts +12 -0
- package/dist/analyzer/typedDicts.js +695 -0
- package/dist/analyzer/typedDicts.js.map +1 -0
- package/dist/analyzer/types.d.ts +484 -0
- package/dist/analyzer/types.js +1844 -0
- package/dist/analyzer/types.js.map +1 -0
- package/dist/backgroundAnalysis.d.ts +14 -0
- package/dist/backgroundAnalysis.js +42 -0
- package/dist/backgroundAnalysis.js.map +1 -0
- package/dist/backgroundAnalysisBase.d.ts +83 -0
- package/dist/backgroundAnalysisBase.js +429 -0
- package/dist/backgroundAnalysisBase.js.map +1 -0
- package/dist/backgroundThreadBase.d.ts +34 -0
- package/dist/backgroundThreadBase.js +134 -0
- package/dist/backgroundThreadBase.js.map +1 -0
- package/dist/commands/commandController.d.ts +13 -0
- package/dist/commands/commandController.js +48 -0
- package/dist/commands/commandController.js.map +1 -0
- package/dist/commands/commandResult.d.ts +9 -0
- package/dist/commands/commandResult.js +19 -0
- package/dist/commands/commandResult.js.map +1 -0
- package/dist/commands/commands.d.ts +7 -0
- package/dist/commands/commands.js +11 -0
- package/dist/commands/commands.js.map +1 -0
- package/dist/commands/createTypeStub.d.ts +8 -0
- package/dist/commands/createTypeStub.js +50 -0
- package/dist/commands/createTypeStub.js.map +1 -0
- package/dist/commands/quickActionCommand.d.ts +8 -0
- package/dist/commands/quickActionCommand.js +31 -0
- package/dist/commands/quickActionCommand.js.map +1 -0
- package/dist/commands/restartServer.d.ts +8 -0
- package/dist/commands/restartServer.js +20 -0
- package/dist/commands/restartServer.js.map +1 -0
- package/dist/common/cancellationUtils.d.ts +16 -0
- package/dist/common/cancellationUtils.js +60 -0
- package/dist/common/cancellationUtils.js.map +1 -0
- package/dist/common/chokidarFileWatcherProvider.d.ts +9 -0
- package/dist/common/chokidarFileWatcherProvider.js +88 -0
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -0
- package/dist/common/collectionUtils.d.ts +114 -0
- package/dist/common/collectionUtils.js +292 -0
- package/dist/common/collectionUtils.js.map +1 -0
- package/dist/common/commandLineOptions.d.ts +41 -0
- package/dist/common/commandLineOptions.js +46 -0
- package/dist/common/commandLineOptions.js.map +1 -0
- package/dist/common/configOptions.d.ts +144 -0
- package/dist/common/configOptions.js +908 -0
- package/dist/common/configOptions.js.map +1 -0
- package/dist/common/console.d.ts +61 -0
- package/dist/common/console.js +191 -0
- package/dist/common/console.js.map +1 -0
- package/dist/common/core.d.ts +67 -0
- package/dist/common/core.js +118 -0
- package/dist/common/core.js.map +1 -0
- package/dist/common/crypto.d.ts +1 -0
- package/dist/common/crypto.js +37 -0
- package/dist/common/crypto.js.map +1 -0
- package/dist/common/debug.d.ts +13 -0
- package/dist/common/debug.js +131 -0
- package/dist/common/debug.js.map +1 -0
- package/dist/common/deferred.d.ts +11 -0
- package/dist/common/deferred.js +62 -0
- package/dist/common/deferred.js.map +1 -0
- package/dist/common/diagnostic.d.ts +59 -0
- package/dist/common/diagnostic.js +134 -0
- package/dist/common/diagnostic.js.map +1 -0
- package/dist/common/diagnosticRules.d.ts +67 -0
- package/dist/common/diagnosticRules.js +83 -0
- package/dist/common/diagnosticRules.js.map +1 -0
- package/dist/common/diagnosticSink.d.ts +34 -0
- package/dist/common/diagnosticSink.js +110 -0
- package/dist/common/diagnosticSink.js.map +1 -0
- package/dist/common/editAction.d.ts +29 -0
- package/dist/common/editAction.js +11 -0
- package/dist/common/editAction.js.map +1 -0
- package/dist/common/extensibility.d.ts +11 -0
- package/dist/common/extensibility.js +10 -0
- package/dist/common/extensibility.js.map +1 -0
- package/dist/common/extensions.d.ts +3 -0
- package/dist/common/extensions.js +15 -0
- package/dist/common/extensions.js.map +1 -0
- package/dist/common/fileBasedCancellationUtils.d.ts +11 -0
- package/dist/common/fileBasedCancellationUtils.js +259 -0
- package/dist/common/fileBasedCancellationUtils.js.map +1 -0
- package/dist/common/fileSystem.d.ts +72 -0
- package/dist/common/fileSystem.js +69 -0
- package/dist/common/fileSystem.js.map +1 -0
- package/dist/common/fullAccessHost.d.ts +19 -0
- package/dist/common/fullAccessHost.js +193 -0
- package/dist/common/fullAccessHost.js.map +1 -0
- package/dist/common/host.d.ts +21 -0
- package/dist/common/host.js +30 -0
- package/dist/common/host.js.map +1 -0
- package/dist/common/logTracker.d.ts +15 -0
- package/dist/common/logTracker.js +129 -0
- package/dist/common/logTracker.js.map +1 -0
- package/dist/common/lspUtils.d.ts +3 -0
- package/dist/common/lspUtils.js +20 -0
- package/dist/common/lspUtils.js.map +1 -0
- package/dist/common/memUtils.d.ts +3 -0
- package/dist/common/memUtils.js +37 -0
- package/dist/common/memUtils.js.map +1 -0
- package/dist/common/pathConsts.d.ts +8 -0
- package/dist/common/pathConsts.js +19 -0
- package/dist/common/pathConsts.js.map +1 -0
- package/dist/common/pathUtils.d.ts +170 -0
- package/dist/common/pathUtils.js +762 -0
- package/dist/common/pathUtils.js.map +1 -0
- package/dist/common/positionUtils.d.ts +7 -0
- package/dist/common/positionUtils.js +71 -0
- package/dist/common/positionUtils.js.map +1 -0
- package/dist/common/progressReporter.d.ts +15 -0
- package/dist/common/progressReporter.js +44 -0
- package/dist/common/progressReporter.js.map +1 -0
- package/dist/common/pythonVersion.d.ts +20 -0
- package/dist/common/pythonVersion.js +71 -0
- package/dist/common/pythonVersion.js.map +1 -0
- package/dist/common/realFileSystem.d.ts +8 -0
- package/dist/common/realFileSystem.js +368 -0
- package/dist/common/realFileSystem.js.map +1 -0
- package/dist/common/stringUtils.d.ts +47 -0
- package/dist/common/stringUtils.js +160 -0
- package/dist/common/stringUtils.js.map +1 -0
- package/dist/common/textEditUtils.d.ts +3 -0
- package/dist/common/textEditUtils.js +29 -0
- package/dist/common/textEditUtils.js.map +1 -0
- package/dist/common/textRange.d.ts +47 -0
- package/dist/common/textRange.js +211 -0
- package/dist/common/textRange.js.map +1 -0
- package/dist/common/textRangeCollection.d.ts +13 -0
- package/dist/common/textRangeCollection.js +108 -0
- package/dist/common/textRangeCollection.js.map +1 -0
- package/dist/common/timing.d.ts +31 -0
- package/dist/common/timing.js +100 -0
- package/dist/common/timing.js.map +1 -0
- package/dist/common/uriParser.d.ts +12 -0
- package/dist/common/uriParser.js +25 -0
- package/dist/common/uriParser.js.map +1 -0
- package/dist/common/workspaceEditUtils.d.ts +7 -0
- package/dist/common/workspaceEditUtils.js +63 -0
- package/dist/common/workspaceEditUtils.js.map +1 -0
- package/dist/languageServerBase.d.ts +211 -0
- package/dist/languageServerBase.js +923 -0
- package/dist/languageServerBase.js.map +1 -0
- package/dist/languageService/analyzerServiceExecutor.d.ts +8 -0
- package/dist/languageService/analyzerServiceExecutor.js +97 -0
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -0
- package/dist/languageService/autoImporter.d.ts +84 -0
- package/dist/languageService/autoImporter.js +635 -0
- package/dist/languageService/autoImporter.js.map +1 -0
- package/dist/languageService/callHierarchyProvider.d.ts +12 -0
- package/dist/languageService/callHierarchyProvider.js +368 -0
- package/dist/languageService/callHierarchyProvider.js.map +1 -0
- package/dist/languageService/codeActionProvider.d.ts +6 -0
- package/dist/languageService/codeActionProvider.js +53 -0
- package/dist/languageService/codeActionProvider.js.map +1 -0
- package/dist/languageService/completionProvider.d.ts +147 -0
- package/dist/languageService/completionProvider.js +2220 -0
- package/dist/languageService/completionProvider.js.map +1 -0
- package/dist/languageService/definitionProvider.d.ts +17 -0
- package/dist/languageService/definitionProvider.js +206 -0
- package/dist/languageService/definitionProvider.js.map +1 -0
- package/dist/languageService/documentHighlightProvider.d.ts +7 -0
- package/dist/languageService/documentHighlightProvider.js +63 -0
- package/dist/languageService/documentHighlightProvider.js.map +1 -0
- package/dist/languageService/documentSymbolCollector.d.ts +37 -0
- package/dist/languageService/documentSymbolCollector.js +344 -0
- package/dist/languageService/documentSymbolCollector.js.map +1 -0
- package/dist/languageService/documentSymbolProvider.d.ts +37 -0
- package/dist/languageService/documentSymbolProvider.js +308 -0
- package/dist/languageService/documentSymbolProvider.js.map +1 -0
- package/dist/languageService/hoverProvider.d.ts +25 -0
- package/dist/languageService/hoverProvider.js +366 -0
- package/dist/languageService/hoverProvider.js.map +1 -0
- package/dist/languageService/importAdder.d.ts +24 -0
- package/dist/languageService/importAdder.js +296 -0
- package/dist/languageService/importAdder.js.map +1 -0
- package/dist/languageService/importSorter.d.ts +15 -0
- package/dist/languageService/importSorter.js +152 -0
- package/dist/languageService/importSorter.js.map +1 -0
- package/dist/languageService/indentationUtils.d.ts +4 -0
- package/dist/languageService/indentationUtils.js +597 -0
- package/dist/languageService/indentationUtils.js.map +1 -0
- package/dist/languageService/quickActions.d.ts +4 -0
- package/dist/languageService/quickActions.js +97 -0
- package/dist/languageService/quickActions.js.map +1 -0
- package/dist/languageService/referencesProvider.d.ts +36 -0
- package/dist/languageService/referencesProvider.js +236 -0
- package/dist/languageService/referencesProvider.js.map +1 -0
- package/dist/languageService/renameModuleProvider.d.ts +58 -0
- package/dist/languageService/renameModuleProvider.js +884 -0
- package/dist/languageService/renameModuleProvider.js.map +1 -0
- package/dist/languageService/signatureHelpProvider.d.ts +26 -0
- package/dist/languageService/signatureHelpProvider.js +180 -0
- package/dist/languageService/signatureHelpProvider.js.map +1 -0
- package/dist/languageService/tooltipUtils.d.ts +9 -0
- package/dist/languageService/tooltipUtils.js +129 -0
- package/dist/languageService/tooltipUtils.js.map +1 -0
- package/dist/localization/localize.d.ts +1324 -0
- package/dist/localization/localize.js +788 -0
- package/dist/localization/localize.js.map +1 -0
- package/dist/localization/package.nls.de.json +1 -0
- package/dist/localization/package.nls.en-us.json +636 -0
- package/dist/localization/package.nls.es.json +1 -0
- package/dist/localization/package.nls.fr.json +1 -0
- package/dist/localization/package.nls.ja.json +1 -0
- package/dist/localization/package.nls.ru.json +1 -0
- package/dist/localization/package.nls.zh-cn.json +1 -0
- package/dist/localization/package.nls.zh-tw.json +1 -0
- package/dist/nodeMain.d.ts +1 -0
- package/dist/nodeMain.js +21 -0
- package/dist/nodeMain.js.map +1 -0
- package/dist/nodeServer.d.ts +3 -0
- package/dist/nodeServer.js +31 -0
- package/dist/nodeServer.js.map +1 -0
- package/dist/parser/characterStream.d.ts +27 -0
- package/dist/parser/characterStream.js +120 -0
- package/dist/parser/characterStream.js.map +1 -0
- package/dist/parser/characters.d.ts +17 -0
- package/dist/parser/characters.js +240 -0
- package/dist/parser/characters.js.map +1 -0
- package/dist/parser/parseNodes.d.ts +750 -0
- package/dist/parser/parseNodes.js +1406 -0
- package/dist/parser/parseNodes.js.map +1 -0
- package/dist/parser/parser.d.ts +191 -0
- package/dist/parser/parser.js +3806 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/stringTokenUtils.d.ts +25 -0
- package/dist/parser/stringTokenUtils.js +455 -0
- package/dist/parser/stringTokenUtils.js.map +1 -0
- package/dist/parser/tokenizer.d.ts +71 -0
- package/dist/parser/tokenizer.js +1111 -0
- package/dist/parser/tokenizer.js.map +1 -0
- package/dist/parser/tokenizerTypes.d.ts +223 -0
- package/dist/parser/tokenizerTypes.js +164 -0
- package/dist/parser/tokenizerTypes.js.map +1 -0
- package/dist/parser/unicode.d.ts +23 -0
- package/dist/parser/unicode.js +2899 -0
- package/dist/parser/unicode.js.map +1 -0
- package/dist/pyright.d.ts +1 -0
- package/dist/pyright.js +645 -0
- package/dist/pyright.js.map +1 -0
- package/dist/pyrightFileSystem.d.ts +28 -0
- package/dist/pyrightFileSystem.js +196 -0
- package/dist/pyrightFileSystem.js.map +1 -0
- package/dist/readonlyAugmentedFileSystem.d.ts +40 -0
- package/dist/readonlyAugmentedFileSystem.js +155 -0
- package/dist/readonlyAugmentedFileSystem.js.map +1 -0
- package/dist/server.d.ts +21 -0
- package/dist/server.js +232 -0
- package/dist/server.js.map +1 -0
- package/dist/tests/chainedSourceFiles.test.d.ts +1 -0
- package/dist/tests/chainedSourceFiles.test.js +153 -0
- package/dist/tests/chainedSourceFiles.test.js.map +1 -0
- package/dist/tests/checker.test.d.ts +1 -0
- package/dist/tests/checker.test.js +346 -0
- package/dist/tests/checker.test.js.map +1 -0
- package/dist/tests/collectionUtils.test.d.ts +1 -0
- package/dist/tests/collectionUtils.test.js +153 -0
- package/dist/tests/collectionUtils.test.js.map +1 -0
- package/dist/tests/common.test.d.ts +1 -0
- package/dist/tests/common.test.js +125 -0
- package/dist/tests/common.test.js.map +1 -0
- package/dist/tests/config.test.d.ts +1 -0
- package/dist/tests/config.test.js +230 -0
- package/dist/tests/config.test.js.map +1 -0
- package/dist/tests/debug.test.d.ts +1 -0
- package/dist/tests/debug.test.js +102 -0
- package/dist/tests/debug.test.js.map +1 -0
- package/dist/tests/deferred.test.d.ts +1 -0
- package/dist/tests/deferred.test.js +65 -0
- package/dist/tests/deferred.test.js.map +1 -0
- package/dist/tests/diagnosticOverrides.test.d.ts +1 -0
- package/dist/tests/diagnosticOverrides.test.js +108 -0
- package/dist/tests/diagnosticOverrides.test.js.map +1 -0
- package/dist/tests/docStringConversion.test.d.ts +1 -0
- package/dist/tests/docStringConversion.test.js +695 -0
- package/dist/tests/docStringConversion.test.js.map +1 -0
- package/dist/tests/docStringUtils.test.d.ts +1 -0
- package/dist/tests/docStringUtils.test.js +70 -0
- package/dist/tests/docStringUtils.test.js.map +1 -0
- package/dist/tests/documentSymbolCollector.test.d.ts +1 -0
- package/dist/tests/documentSymbolCollector.test.js +635 -0
- package/dist/tests/documentSymbolCollector.test.js.map +1 -0
- package/dist/tests/filesystem.test.d.ts +1 -0
- package/dist/tests/filesystem.test.js +194 -0
- package/dist/tests/filesystem.test.js.map +1 -0
- package/dist/tests/fourSlashParser.test.d.ts +1 -0
- package/dist/tests/fourSlashParser.test.js +281 -0
- package/dist/tests/fourSlashParser.test.js.map +1 -0
- package/dist/tests/fourSlashRunner.test.d.ts +1 -0
- package/dist/tests/fourSlashRunner.test.js +52 -0
- package/dist/tests/fourSlashRunner.test.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.js +30 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.js +42 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.js +13 -0
- package/dist/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.disabled.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.disabled.fourslash.js +23 -0
- package/dist/tests/fourslash/completions.autoimport.disabled.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.js +35 -0
- package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.fourslash.js +27 -0
- package/dist/tests/fourslash/completions.autoimport.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.js +128 -0
- package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.js +27 -0
- package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js +43 -0
- package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.js +50 -0
- package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js +116 -0
- package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.builtinOverride.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.builtinOverride.fourslash.js +21 -0
- package/dist/tests/fourslash/completions.builtinOverride.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.js +54 -0
- package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js +245 -0
- package/dist/tests/fourslash/completions.call.typedDict.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js +162 -0
- package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js +132 -0
- package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.classVariable.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.classVariable.fourslash.js +37 -0
- package/dist/tests/fourslash/completions.classVariable.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.comment.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.comment.fourslash.js +27 -0
- package/dist/tests/fourslash/completions.comment.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.class.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.class.fourslash.js +30 -0
- package/dist/tests/fourslash/completions.declNames.class.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.exception.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.exception.fourslash.js +18 -0
- package/dist/tests/fourslash/completions.declNames.exception.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.for.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.for.fourslash.js +26 -0
- package/dist/tests/fourslash/completions.declNames.for.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.importAlias.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.importAlias.fourslash.js +15 -0
- package/dist/tests/fourslash/completions.declNames.importAlias.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.lambda.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.lambda.fourslash.js +36 -0
- package/dist/tests/fourslash/completions.declNames.lambda.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.method.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.method.fourslash.js +68 -0
- package/dist/tests/fourslash/completions.declNames.method.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.overload.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.overload.fourslash.js +147 -0
- package/dist/tests/fourslash/completions.declNames.overload.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.js +131 -0
- package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js +73 -0
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js +58 -0
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js +154 -0
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js +143 -0
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js +109 -0
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js +50 -0
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.enums.members.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.enums.members.fourslash.js +44 -0
- package/dist/tests/fourslash/completions.enums.members.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.excluded.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.excluded.fourslash.js +12 -0
- package/dist/tests/fourslash/completions.excluded.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.fourslash.js +51 -0
- package/dist/tests/fourslash/completions.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.fstring.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.fstring.fourslash.js +32 -0
- package/dist/tests/fourslash/completions.fstring.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js +96 -0
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.fuzzyMatching.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.fuzzyMatching.fourslash.js +30 -0
- package/dist/tests/fourslash/completions.fuzzyMatching.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.importDunderNames.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.importDunderNames.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.importDunderNames.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.importSubmodule.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.importSubmodule.fourslash.js +22 -0
- package/dist/tests/fourslash/completions.importSubmodule.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.importsDuplicates.fourslash.d.ts +0 -0
- package/dist/tests/fourslash/completions.importsDuplicates.fourslash.js +22 -0
- package/dist/tests/fourslash/completions.importsDuplicates.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inList.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inList.fourslash.js +32 -0
- package/dist/tests/fourslash/completions.inList.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.included.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.included.fourslash.js +12 -0
- package/dist/tests/fourslash/completions.included.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js +54 -0
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.js +26 -0
- package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.js +49 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.js +50 -0
- package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.js +101 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromStub.fourslash.js +105 -0
- package/dist/tests/fourslash/completions.inherited.property.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.js +67 -0
- package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js +75 -0
- package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js +66 -0
- package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.libStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.libStub.fourslash.js +66 -0
- package/dist/tests/fourslash/completions.libStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.literals.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.literals.fourslash.js +31 -0
- package/dist/tests/fourslash/completions.literals.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.localCode.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.localCode.fourslash.js +71 -0
- package/dist/tests/fourslash/completions.localCode.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.js +17 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.js +57 -0
- package/dist/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.js +27 -0
- package/dist/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.overloads.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.overloads.fourslash.js +37 -0
- package/dist/tests/fourslash/completions.overloads.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.default.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.default.fourslash.js +47 -0
- package/dist/tests/fourslash/completions.override.default.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.default.importStub.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.default.importStub.js +49 -0
- package/dist/tests/fourslash/completions.override.default.importStub.js.map +1 -0
- package/dist/tests/fourslash/completions.override.default.imported.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.default.imported.fourslash.js +60 -0
- package/dist/tests/fourslash/completions.override.default.imported.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.default.stub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.default.stub.fourslash.js +47 -0
- package/dist/tests/fourslash/completions.override.default.stub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.fourslash.js +47 -0
- package/dist/tests/fourslash/completions.override.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.property.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.property.fourslash.js +31 -0
- package/dist/tests/fourslash/completions.override.property.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.property.stub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.property.stub.fourslash.js +31 -0
- package/dist/tests/fourslash/completions.override.property.stub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.js +63 -0
- package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override.stub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override.stub.fourslash.js +47 -0
- package/dist/tests/fourslash/completions.override.stub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.override2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.override2.fourslash.js +66 -0
- package/dist/tests/fourslash/completions.override2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.parameters.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.parameters.fourslash.js +22 -0
- package/dist/tests/fourslash/completions.parameters.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.params.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.params.fourslash.js +23 -0
- package/dist/tests/fourslash/completions.params.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.parentFolder.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.parentFolder.fourslash.js +15 -0
- package/dist/tests/fourslash/completions.parentFolder.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.parentFolders.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.parentFolders.fourslash.js +68 -0
- package/dist/tests/fourslash/completions.parentFolders.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.plainText.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.plainText.fourslash.js +34 -0
- package/dist/tests/fourslash/completions.plainText.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.private.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.private.fourslash.js +61 -0
- package/dist/tests/fourslash/completions.private.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.property.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.property.fourslash.js +28 -0
- package/dist/tests/fourslash/completions.property.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.propertyDocStrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.propertyDocStrings.fourslash.js +64 -0
- package/dist/tests/fourslash/completions.propertyDocStrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.self.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.self.fourslash.js +43 -0
- package/dist/tests/fourslash/completions.self.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.js +71 -0
- package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js +78 -0
- package/dist/tests/fourslash/completions.stringLiteral.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.typeAlias.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.typeAlias.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.typeAlias.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.typeshed.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.typeshed.fourslash.js +9 -0
- package/dist/tests/fourslash/completions.typeshed.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.vardecls.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.vardecls.fourslash.js +33 -0
- package/dist/tests/fourslash/completions.vardecls.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.variableDocStrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js +68 -0
- package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.js +109 -0
- package/dist/tests/fourslash/completions.wildcardimports.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.with.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.with.fourslash.js +25 -0
- package/dist/tests/fourslash/completions.with.fourslash.js.map +1 -0
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.js +64 -0
- package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.js +24 -0
- package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.js +93 -0
- package/dist/tests/fourslash/findDefinitions.classes.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.js +23 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.js +19 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.js +23 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.js +20 -0
- package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.js +123 -0
- package/dist/tests/fourslash/findDefinitions.fields.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.js +79 -0
- package/dist/tests/fourslash/findDefinitions.functions.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.js +154 -0
- package/dist/tests/fourslash/findDefinitions.methods.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.modules.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.modules.fourslash.js +42 -0
- package/dist/tests/fourslash/findDefinitions.modules.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js +34 -0
- package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.overloads.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.overloads.fourslash.js +213 -0
- package/dist/tests/fourslash/findDefinitions.overloads.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.js +154 -0
- package/dist/tests/fourslash/findDefinitions.parameters.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.js +23 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.js +29 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.js +30 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.js +25 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.js +26 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.js +28 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.js +33 -0
- package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.js +26 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.js +25 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.js +25 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.js +20 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.js +20 -0
- package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.js +59 -0
- package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.js +59 -0
- package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.js +94 -0
- package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.js +79 -0
- package/dist/tests/fourslash/findDefinitions.variables.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.js +106 -0
- package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.js +24 -0
- package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.js +66 -0
- package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.js +26 -0
- package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.js +36 -0
- package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.fourslash.js +30 -0
- package/dist/tests/fourslash/findallreferences.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.importalias.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.importalias.fourslash.js +30 -0
- package/dist/tests/fourslash/findallreferences.importalias.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.js +46 -0
- package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.module.nested.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.module.nested.fourslash.js +60 -0
- package/dist/tests/fourslash/findallreferences.module.nested.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.js +54 -0
- package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.modules.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.modules.fourslash.js +41 -0
- package/dist/tests/fourslash/findallreferences.modules.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.js +83 -0
- package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.openFiles.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.openFiles.fourslash.js +32 -0
- package/dist/tests/fourslash/findallreferences.openFiles.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.parameter.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.parameter.fourslash.js +22 -0
- package/dist/tests/fourslash/findallreferences.parameter.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.js +29 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.js +33 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.js +36 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.js +44 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.js +31 -0
- package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.js.map +1 -0
- package/dist/tests/fourslash/findallreferences.variable.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/findallreferences.variable.fourslash.js +22 -0
- package/dist/tests/fourslash/findallreferences.variable.fourslash.js.map +1 -0
- package/dist/tests/fourslash/fourslash.d.ts +301 -0
- package/dist/tests/fourslash/fourslash.js +25 -0
- package/dist/tests/fourslash/fourslash.js.map +1 -0
- package/dist/tests/fourslash/highlightreferences.attributes.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/highlightreferences.attributes.fourslash.js +30 -0
- package/dist/tests/fourslash/highlightreferences.attributes.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js +63 -0
- package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.classNoInit.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.classNoInit.fourslash.js +14 -0
- package/dist/tests/fourslash/hover.classNoInit.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromScr.stringFormat.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromScr.stringFormat.fourslash.js +47 -0
- package/dist/tests/fourslash/hover.docFromScr.stringFormat.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js +77 -0
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js +22 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js +22 -0
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js +21 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js +20 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js +38 -0
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js +25 -0
- package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js +18 -0
- package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docstring.links.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docstring.links.fourslash.js +12 -0
- package/dist/tests/fourslash/hover.docstring.links.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docstring.overloads.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docstring.overloads.fourslash.js +38 -0
- package/dist/tests/fourslash/hover.docstring.overloads.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docstring.split.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js +24 -0
- package/dist/tests/fourslash/hover.docstring.split.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.fourslash.js +20 -0
- package/dist/tests/fourslash/hover.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.import.django.view.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.import.django.view.fourslash.js +23 -0
- package/dist/tests/fourslash/hover.import.django.view.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.import.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.import.fourslash.js +10 -0
- package/dist/tests/fourslash/hover.import.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js +61 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js +51 -0
- package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js +40 -0
- package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.js +43 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.js +44 -0
- package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.js +84 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromStub.fourslash.js +88 -0
- package/dist/tests/fourslash/hover.inherited.property.docFromStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.init.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.init.fourslash.js +38 -0
- package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js +49 -0
- package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js +39 -0
- package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.libStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.libStub.fourslash.js +39 -0
- package/dist/tests/fourslash/hover.libStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.optionalAliasParameter.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.optionalAliasParameter.fourslash.js +14 -0
- package/dist/tests/fourslash/hover.optionalAliasParameter.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.plainText.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.plainText.fourslash.js +20 -0
- package/dist/tests/fourslash/hover.plainText.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.typedDict.key.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.typedDict.key.fourslash.js +50 -0
- package/dist/tests/fourslash/hover.typedDict.key.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.variable.docString.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.variable.docString.fourslash.js +35 -0
- package/dist/tests/fourslash/hover.variable.docString.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.js +73 -0
- package/dist/tests/fourslash/hover.wildcardimports.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.publicSymbols.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.publicSymbols.fourslash.js +63 -0
- package/dist/tests/fourslash/import.publicSymbols.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.pytyped.dunderAll.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.pytyped.dunderAll.fourslash.js +72 -0
- package/dist/tests/fourslash/import.pytyped.dunderAll.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.js +61 -0
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js +35 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js +35 -0
- package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js.map +1 -0
- package/dist/tests/fourslash/import.wildcard.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/import.wildcard.fourslash.js +24 -0
- package/dist/tests/fourslash/import.wildcard.fourslash.js.map +1 -0
- package/dist/tests/fourslash/importnotresolved.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/importnotresolved.fourslash.js +13 -0
- package/dist/tests/fourslash/importnotresolved.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.js +18 -0
- package/dist/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingModuleSource.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/missingModuleSource.fourslash.js +13 -0
- package/dist/tests/fourslash/missingModuleSource.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.js +31 -0
- package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.command.multipart.fourslash.d.ts +7 -0
- package/dist/tests/fourslash/missingTypeStub.command.multipart.fourslash.js +44 -0
- package/dist/tests/fourslash/missingTypeStub.command.multipart.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlefile.fourslash.d.ts +7 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlefile.fourslash.js +35 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlefile.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlepart.fourslash.d.ts +7 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlepart.fourslash.js +35 -0
- package/dist/tests/fourslash/missingTypeStub.command.singlepart.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/missingTypeStub.fourslash.js +18 -0
- package/dist/tests/fourslash/missingTypeStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.js +34 -0
- package/dist/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.js.map +1 -0
- package/dist/tests/fourslash/noerrors.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/noerrors.fourslash.js +9 -0
- package/dist/tests/fourslash/noerrors.fourslash.js.map +1 -0
- package/dist/tests/fourslash/orderImports1.command.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/orderImports1.command.fourslash.js +17 -0
- package/dist/tests/fourslash/orderImports1.command.fourslash.js.map +1 -0
- package/dist/tests/fourslash/orderImports2.command.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/orderImports2.command.fourslash.js +21 -0
- package/dist/tests/fourslash/orderImports2.command.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.externallyHidden.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.externallyHidden.fourslash.js +23 -0
- package/dist/tests/fourslash/rename.externallyHidden.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.externallyHidden.params.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.externallyHidden.params.fourslash.js +23 -0
- package/dist/tests/fourslash/rename.externallyHidden.params.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.fourslash.js +26 -0
- package/dist/tests/fourslash/rename.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.library.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.library.fourslash.js +26 -0
- package/dist/tests/fourslash/rename.library.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.library.sourceAndStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.library.sourceAndStub.fourslash.js +29 -0
- package/dist/tests/fourslash/rename.library.sourceAndStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.multipleDecl.fourslash.d.ts +2 -0
- package/dist/tests/fourslash/rename.multipleDecl.fourslash.js +19 -0
- package/dist/tests/fourslash/rename.multipleDecl.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.sourceAndStub.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.sourceAndStub.fourslash.js +33 -0
- package/dist/tests/fourslash/rename.sourceAndStub.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.string.excluded.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.string.excluded.fourslash.js +39 -0
- package/dist/tests/fourslash/rename.string.excluded.fourslash.js.map +1 -0
- package/dist/tests/fourslash/rename.string.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/rename.string.fourslash.js +25 -0
- package/dist/tests/fourslash/rename.string.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js +62 -0
- package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.complicated.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.complicated.fourslash.js +97 -0
- package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.cornercases.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.cornercases.fourslash.js +22 -0
- package/dist/tests/fourslash/signature.cornercases.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.docstrings.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.docstrings.fourslash.js +42 -0
- package/dist/tests/fourslash/signature.docstrings.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js +49 -0
- package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.js +115 -0
- package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.overload.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.overload.fourslash.js +63 -0
- package/dist/tests/fourslash/signature.overload.fourslash.js.map +1 -0
- package/dist/tests/fourslash/signature.simple.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/signature.simple.fourslash.js +104 -0
- package/dist/tests/fourslash/signature.simple.fourslash.js.map +1 -0
- package/dist/tests/harness/fourslash/fourSlashParser.d.ts +10 -0
- package/dist/tests/harness/fourslash/fourSlashParser.js +347 -0
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -0
- package/dist/tests/harness/fourslash/fourSlashTypes.d.ts +81 -0
- package/dist/tests/harness/fourslash/fourSlashTypes.js +65 -0
- package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -0
- package/dist/tests/harness/fourslash/runner.d.ts +20 -0
- package/dist/tests/harness/fourslash/runner.js +93 -0
- package/dist/tests/harness/fourslash/runner.js.map +1 -0
- package/dist/tests/harness/fourslash/testLanguageService.d.ts +40 -0
- package/dist/tests/harness/fourslash/testLanguageService.js +120 -0
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -0
- package/dist/tests/harness/fourslash/testState.Consts.d.ts +11 -0
- package/dist/tests/harness/fourslash/testState.Consts.js +50 -0
- package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -0
- package/dist/tests/harness/fourslash/testState.d.ts +232 -0
- package/dist/tests/harness/fourslash/testState.js +1381 -0
- package/dist/tests/harness/fourslash/testState.js.map +1 -0
- package/dist/tests/harness/testAccessHost.d.ts +8 -0
- package/dist/tests/harness/testAccessHost.js +26 -0
- package/dist/tests/harness/testAccessHost.js.map +1 -0
- package/dist/tests/harness/testHost.d.ts +16 -0
- package/dist/tests/harness/testHost.js +161 -0
- package/dist/tests/harness/testHost.js.map +1 -0
- package/dist/tests/harness/utils.d.ts +74 -0
- package/dist/tests/harness/utils.js +328 -0
- package/dist/tests/harness/utils.js.map +1 -0
- package/dist/tests/harness/vfs/factory.d.ts +32 -0
- package/dist/tests/harness/vfs/factory.js +173 -0
- package/dist/tests/harness/vfs/factory.js.map +1 -0
- package/dist/tests/harness/vfs/filesystem.d.ts +430 -0
- package/dist/tests/harness/vfs/filesystem.js +1455 -0
- package/dist/tests/harness/vfs/filesystem.js.map +1 -0
- package/dist/tests/harness/vfs/pathValidation.d.ts +24 -0
- package/dist/tests/harness/vfs/pathValidation.js +123 -0
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -0
- package/dist/tests/importAdder.test.d.ts +1 -0
- package/dist/tests/importAdder.test.js +1192 -0
- package/dist/tests/importAdder.test.js.map +1 -0
- package/dist/tests/importResolver.test.d.ts +1 -0
- package/dist/tests/importResolver.test.js +450 -0
- package/dist/tests/importResolver.test.js.map +1 -0
- package/dist/tests/importStatementUtils.test.d.ts +1 -0
- package/dist/tests/importStatementUtils.test.js +371 -0
- package/dist/tests/importStatementUtils.test.js.map +1 -0
- package/dist/tests/indentationUtils.ptvs.test.d.ts +1 -0
- package/dist/tests/indentationUtils.ptvs.test.js +324 -0
- package/dist/tests/indentationUtils.ptvs.test.js.map +1 -0
- package/dist/tests/indentationUtils.reindent.test.d.ts +1 -0
- package/dist/tests/indentationUtils.reindent.test.js +332 -0
- package/dist/tests/indentationUtils.reindent.test.js.map +1 -0
- package/dist/tests/indentationUtils.test.d.ts +1 -0
- package/dist/tests/indentationUtils.test.js +375 -0
- package/dist/tests/indentationUtils.test.js.map +1 -0
- package/dist/tests/ipythonMode.test.d.ts +1 -0
- package/dist/tests/ipythonMode.test.js +303 -0
- package/dist/tests/ipythonMode.test.js.map +1 -0
- package/dist/tests/localizer.test.d.ts +1 -0
- package/dist/tests/localizer.test.js +64 -0
- package/dist/tests/localizer.test.js.map +1 -0
- package/dist/tests/parseTreeUtils.test.d.ts +1 -0
- package/dist/tests/parseTreeUtils.test.js +228 -0
- package/dist/tests/parseTreeUtils.test.js.map +1 -0
- package/dist/tests/parser.test.d.ts +1 -0
- package/dist/tests/parser.test.js +101 -0
- package/dist/tests/parser.test.js.map +1 -0
- package/dist/tests/pathUtils.test.d.ts +1 -0
- package/dist/tests/pathUtils.test.js +253 -0
- package/dist/tests/pathUtils.test.js.map +1 -0
- package/dist/tests/pyrightFileSystem.test.d.ts +1 -0
- package/dist/tests/pyrightFileSystem.test.js +152 -0
- package/dist/tests/pyrightFileSystem.test.js.map +1 -0
- package/dist/tests/renameModule.folder.test.d.ts +1 -0
- package/dist/tests/renameModule.folder.test.js +229 -0
- package/dist/tests/renameModule.folder.test.js.map +1 -0
- package/dist/tests/renameModule.fromImports.test.d.ts +1 -0
- package/dist/tests/renameModule.fromImports.test.js +790 -0
- package/dist/tests/renameModule.fromImports.test.js.map +1 -0
- package/dist/tests/renameModule.imports.test.d.ts +1 -0
- package/dist/tests/renameModule.imports.test.js +380 -0
- package/dist/tests/renameModule.imports.test.js.map +1 -0
- package/dist/tests/renameModule.misc.test.d.ts +1 -0
- package/dist/tests/renameModule.misc.test.js +615 -0
- package/dist/tests/renameModule.misc.test.js.map +1 -0
- package/dist/tests/renameModule.relativePath.test.d.ts +1 -0
- package/dist/tests/renameModule.relativePath.test.js +231 -0
- package/dist/tests/renameModule.relativePath.test.js.map +1 -0
- package/dist/tests/renameModuleTestUtils.d.ts +4 -0
- package/dist/tests/renameModuleTestUtils.js +148 -0
- package/dist/tests/renameModuleTestUtils.js.map +1 -0
- package/dist/tests/sourceFile.test.d.ts +1 -0
- package/dist/tests/sourceFile.test.js +25 -0
- package/dist/tests/sourceFile.test.js.map +1 -0
- package/dist/tests/stringUtils.test.d.ts +1 -0
- package/dist/tests/stringUtils.test.js +69 -0
- package/dist/tests/stringUtils.test.js.map +1 -0
- package/dist/tests/symbolNameUtils.test.d.ts +1 -0
- package/dist/tests/symbolNameUtils.test.js +83 -0
- package/dist/tests/symbolNameUtils.test.js.map +1 -0
- package/dist/tests/testState.test.d.ts +1 -0
- package/dist/tests/testState.test.js +521 -0
- package/dist/tests/testState.test.js.map +1 -0
- package/dist/tests/testUtils.d.ts +27 -0
- package/dist/tests/testUtils.js +213 -0
- package/dist/tests/testUtils.js.map +1 -0
- package/dist/tests/tokenizer.test.d.ts +1 -0
- package/dist/tests/tokenizer.test.js +1277 -0
- package/dist/tests/tokenizer.test.js.map +1 -0
- package/dist/tests/typeEvaluator1.test.d.ts +1 -0
- package/dist/tests/typeEvaluator1.test.js +1023 -0
- package/dist/tests/typeEvaluator1.test.js.map +1 -0
- package/dist/tests/typeEvaluator2.test.d.ts +1 -0
- package/dist/tests/typeEvaluator2.test.js +869 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -0
- package/dist/tests/typeEvaluator3.test.d.ts +1 -0
- package/dist/tests/typeEvaluator3.test.js +915 -0
- package/dist/tests/typeEvaluator3.test.js.map +1 -0
- package/dist/tests/typeEvaluator4.test.d.ts +1 -0
- package/dist/tests/typeEvaluator4.test.js +901 -0
- package/dist/tests/typeEvaluator4.test.js.map +1 -0
- package/dist/tests/updateSymbolReference.test.d.ts +1 -0
- package/dist/tests/updateSymbolReference.test.js +980 -0
- package/dist/tests/updateSymbolReference.test.js.map +1 -0
- package/dist/tests/zipfs.test.d.ts +1 -0
- package/dist/tests/zipfs.test.js +112 -0
- package/dist/tests/zipfs.test.js.map +1 -0
- package/dist/workspaceMap.d.ts +6 -0
- package/dist/workspaceMap.js +73 -0
- package/dist/workspaceMap.js.map +1 -0
- package/package.json +45 -0
@@ -0,0 +1,2220 @@
|
|
1
|
+
"use strict";
|
2
|
+
/*
|
3
|
+
* completionProvider.ts
|
4
|
+
* Copyright (c) Microsoft Corporation.
|
5
|
+
* Licensed under the MIT license.
|
6
|
+
* Author: Eric Traut
|
7
|
+
*
|
8
|
+
* Logic that maps a position within a Python program file into
|
9
|
+
* a list of zero or more text completions that apply in the context.
|
10
|
+
*/
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
12
|
+
if (k2 === undefined) k2 = k;
|
13
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
14
|
+
}) : (function(o, m, k, k2) {
|
15
|
+
if (k2 === undefined) k2 = k;
|
16
|
+
o[k2] = m[k];
|
17
|
+
}));
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
20
|
+
}) : function(o, v) {
|
21
|
+
o["default"] = v;
|
22
|
+
});
|
23
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
24
|
+
if (mod && mod.__esModule) return mod;
|
25
|
+
var result = {};
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
27
|
+
__setModuleDefault(result, mod);
|
28
|
+
return result;
|
29
|
+
};
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
31
|
+
exports.CompletionMap = exports.CompletionProvider = exports.dictionaryKeyDetail = exports.autoImportDetail = void 0;
|
32
|
+
const vscode_languageserver_1 = require("vscode-languageserver");
|
33
|
+
const AnalyzerNodeInfo = __importStar(require("../analyzer/analyzerNodeInfo"));
|
34
|
+
const declaration_1 = require("../analyzer/declaration");
|
35
|
+
const declarationUtils_1 = require("../analyzer/declarationUtils");
|
36
|
+
const docStringConversion_1 = require("../analyzer/docStringConversion");
|
37
|
+
const ParseTreeUtils = __importStar(require("../analyzer/parseTreeUtils"));
|
38
|
+
const parseTreeUtils_1 = require("../analyzer/parseTreeUtils");
|
39
|
+
const scopeUtils_1 = require("../analyzer/scopeUtils");
|
40
|
+
const sourceMapper_1 = require("../analyzer/sourceMapper");
|
41
|
+
const SymbolNameUtils = __importStar(require("../analyzer/symbolNameUtils"));
|
42
|
+
const symbolUtils_1 = require("../analyzer/symbolUtils");
|
43
|
+
const typedDicts_1 = require("../analyzer/typedDicts");
|
44
|
+
const typeDocStringUtils_1 = require("../analyzer/typeDocStringUtils");
|
45
|
+
const typePrinter_1 = require("../analyzer/typePrinter");
|
46
|
+
const types_1 = require("../analyzer/types");
|
47
|
+
const typeUtils_1 = require("../analyzer/typeUtils");
|
48
|
+
const cancellationUtils_1 = require("../common/cancellationUtils");
|
49
|
+
const collectionUtils_1 = require("../common/collectionUtils");
|
50
|
+
const debug = __importStar(require("../common/debug"));
|
51
|
+
const debug_1 = require("../common/debug");
|
52
|
+
const lspUtils_1 = require("../common/lspUtils");
|
53
|
+
const positionUtils_1 = require("../common/positionUtils");
|
54
|
+
const pythonVersion_1 = require("../common/pythonVersion");
|
55
|
+
const StringUtils = __importStar(require("../common/stringUtils"));
|
56
|
+
const textRange_1 = require("../common/textRange");
|
57
|
+
const textRange_2 = require("../common/textRange");
|
58
|
+
const timing_1 = require("../common/timing");
|
59
|
+
const parseNodes_1 = require("../parser/parseNodes");
|
60
|
+
const autoImporter_1 = require("./autoImporter");
|
61
|
+
const documentSymbolCollector_1 = require("./documentSymbolCollector");
|
62
|
+
const tooltipUtils_1 = require("./tooltipUtils");
|
63
|
+
var Keywords;
|
64
|
+
(function (Keywords) {
|
65
|
+
const base = [
|
66
|
+
// Expression keywords
|
67
|
+
'True',
|
68
|
+
'False',
|
69
|
+
'None',
|
70
|
+
'and',
|
71
|
+
'or',
|
72
|
+
'not',
|
73
|
+
'is',
|
74
|
+
'lambda',
|
75
|
+
'yield',
|
76
|
+
// Statement keywords
|
77
|
+
'assert',
|
78
|
+
'break',
|
79
|
+
'class',
|
80
|
+
'continue',
|
81
|
+
'def',
|
82
|
+
'del',
|
83
|
+
'elif',
|
84
|
+
'else',
|
85
|
+
'except',
|
86
|
+
'finally',
|
87
|
+
'for',
|
88
|
+
'from',
|
89
|
+
'global',
|
90
|
+
'if',
|
91
|
+
'import',
|
92
|
+
'in',
|
93
|
+
'nonlocal',
|
94
|
+
'pass',
|
95
|
+
'raise',
|
96
|
+
'return',
|
97
|
+
'try',
|
98
|
+
'while',
|
99
|
+
'with',
|
100
|
+
];
|
101
|
+
const python3_5 = [...base, 'async', 'await'];
|
102
|
+
const python3_10 = [...python3_5, 'case', 'match'];
|
103
|
+
function forVersion(version) {
|
104
|
+
if (version >= pythonVersion_1.PythonVersion.V3_10) {
|
105
|
+
return python3_10;
|
106
|
+
}
|
107
|
+
if (version >= pythonVersion_1.PythonVersion.V3_5) {
|
108
|
+
return python3_5;
|
109
|
+
}
|
110
|
+
return base;
|
111
|
+
}
|
112
|
+
Keywords.forVersion = forVersion;
|
113
|
+
})(Keywords || (Keywords = {}));
|
114
|
+
var SortCategory;
|
115
|
+
(function (SortCategory) {
|
116
|
+
// The order of the following is important. We use
|
117
|
+
// this to order the completion suggestions.
|
118
|
+
// A keyword that must be entered for the syntax to be correct.
|
119
|
+
SortCategory[SortCategory["LikelyKeyword"] = 0] = "LikelyKeyword";
|
120
|
+
// A module name recently used in an import statement.
|
121
|
+
SortCategory[SortCategory["RecentImportModuleName"] = 1] = "RecentImportModuleName";
|
122
|
+
// A module name used in an import statement.
|
123
|
+
SortCategory[SortCategory["ImportModuleName"] = 2] = "ImportModuleName";
|
124
|
+
// A literal string.
|
125
|
+
SortCategory[SortCategory["LiteralValue"] = 3] = "LiteralValue";
|
126
|
+
// A named parameter in a call expression.
|
127
|
+
SortCategory[SortCategory["NamedParameter"] = 4] = "NamedParameter";
|
128
|
+
// A keyword or symbol that was recently used for completion.
|
129
|
+
SortCategory[SortCategory["RecentKeywordOrSymbol"] = 5] = "RecentKeywordOrSymbol";
|
130
|
+
// An auto-import symbol that was recently used for completion.
|
131
|
+
SortCategory[SortCategory["RecentAutoImport"] = 6] = "RecentAutoImport";
|
132
|
+
// A keyword in the python syntax.
|
133
|
+
SortCategory[SortCategory["Keyword"] = 7] = "Keyword";
|
134
|
+
// An enum member.
|
135
|
+
SortCategory[SortCategory["EnumMember"] = 8] = "EnumMember";
|
136
|
+
// A normal symbol.
|
137
|
+
SortCategory[SortCategory["NormalSymbol"] = 9] = "NormalSymbol";
|
138
|
+
// A symbol that starts with _ or __ (used only when there is
|
139
|
+
// no matching filter).
|
140
|
+
SortCategory[SortCategory["PrivateSymbol"] = 10] = "PrivateSymbol";
|
141
|
+
// A symbol with a dunder name (e.g. __init__).
|
142
|
+
SortCategory[SortCategory["DunderSymbol"] = 11] = "DunderSymbol";
|
143
|
+
// An auto-import symbol.
|
144
|
+
SortCategory[SortCategory["AutoImport"] = 12] = "AutoImport";
|
145
|
+
})(SortCategory || (SortCategory = {}));
|
146
|
+
exports.autoImportDetail = 'Auto-import';
|
147
|
+
exports.dictionaryKeyDetail = 'Dictionary key';
|
148
|
+
// We'll use a somewhat-arbitrary cutoff value here to determine
|
149
|
+
// whether it's sufficiently similar.
|
150
|
+
const similarityLimit = 0.25;
|
151
|
+
// We'll remember this many completions in the MRU list.
|
152
|
+
const maxRecentCompletions = 128;
|
153
|
+
class CompletionProvider {
|
154
|
+
constructor(_workspacePath, _parseResults, _fileContents, _importResolver, _position, _filePath, _configOptions, _importLookup, _evaluator, _options, _sourceMapper, _autoImportMaps, _cancellationToken) {
|
155
|
+
this._workspacePath = _workspacePath;
|
156
|
+
this._parseResults = _parseResults;
|
157
|
+
this._fileContents = _fileContents;
|
158
|
+
this._importResolver = _importResolver;
|
159
|
+
this._position = _position;
|
160
|
+
this._filePath = _filePath;
|
161
|
+
this._configOptions = _configOptions;
|
162
|
+
this._importLookup = _importLookup;
|
163
|
+
this._evaluator = _evaluator;
|
164
|
+
this._options = _options;
|
165
|
+
this._sourceMapper = _sourceMapper;
|
166
|
+
this._autoImportMaps = _autoImportMaps;
|
167
|
+
this._cancellationToken = _cancellationToken;
|
168
|
+
// Indicate whether invocation is inside of string literal.
|
169
|
+
this._insideStringLiteral = undefined;
|
170
|
+
this._execEnv = this._configOptions.findExecEnvironment(this._filePath);
|
171
|
+
}
|
172
|
+
getCompletionsForPosition() {
|
173
|
+
var _a, _b;
|
174
|
+
const offset = (0, positionUtils_1.convertPositionToOffset)(this._position, this._parseResults.tokenizerOutput.lines);
|
175
|
+
if (offset === undefined) {
|
176
|
+
return undefined;
|
177
|
+
}
|
178
|
+
const token = ParseTreeUtils.getTokenOverlapping(this._parseResults.tokenizerOutput.tokens, offset);
|
179
|
+
if ((token === null || token === void 0 ? void 0 : token.type) === 5 /* String */) {
|
180
|
+
const stringToken = token;
|
181
|
+
this._insideStringLiteral = textRange_2.TextRange.contains(stringToken, offset)
|
182
|
+
? stringToken
|
183
|
+
: stringToken.flags & 65536 /* Unterminated */
|
184
|
+
? stringToken
|
185
|
+
: undefined;
|
186
|
+
}
|
187
|
+
let node = ParseTreeUtils.findNodeByOffset(this._parseResults.parseTree, offset);
|
188
|
+
// See if we can get to a "better" node by backing up a few columns.
|
189
|
+
// A "better" node is defined as one that's deeper than the current
|
190
|
+
// node.
|
191
|
+
const initialNode = node;
|
192
|
+
const initialDepth = node ? ParseTreeUtils.getNodeDepth(node) : 0;
|
193
|
+
if (!initialNode || initialNode.nodeType !== 38 /* Name */) {
|
194
|
+
let curOffset = offset;
|
195
|
+
let sawComma = false;
|
196
|
+
while (curOffset >= 0) {
|
197
|
+
curOffset--;
|
198
|
+
// Stop scanning backward if we hit certain stop characters.
|
199
|
+
const curChar = this._fileContents.substr(curOffset, 1);
|
200
|
+
if (curChar === '(' || curChar === '\n' || curChar === '}') {
|
201
|
+
break;
|
202
|
+
}
|
203
|
+
if (curChar === ',') {
|
204
|
+
sawComma = true;
|
205
|
+
}
|
206
|
+
const curNode = ParseTreeUtils.findNodeByOffset(this._parseResults.parseTree, curOffset);
|
207
|
+
if (curNode && curNode !== initialNode) {
|
208
|
+
if (ParseTreeUtils.getNodeDepth(curNode) > initialDepth) {
|
209
|
+
node = curNode;
|
210
|
+
// If we're at the end of a list with a hanging comma, handle the
|
211
|
+
// special case of "from x import y, ".
|
212
|
+
if (sawComma && ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 23 /* ImportFromAs */) {
|
213
|
+
node = node.parent;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
break;
|
217
|
+
}
|
218
|
+
}
|
219
|
+
}
|
220
|
+
if (node === undefined) {
|
221
|
+
return undefined;
|
222
|
+
}
|
223
|
+
// Get the text on that line prior to the insertion point.
|
224
|
+
const lineTextRange = this._parseResults.tokenizerOutput.lines.getItemAt(this._position.line);
|
225
|
+
const textOnLine = this._fileContents.substr(lineTextRange.start, lineTextRange.length);
|
226
|
+
const priorText = textOnLine.substr(0, this._position.character);
|
227
|
+
const postText = textOnLine.substr(this._position.character);
|
228
|
+
const priorWordIndex = priorText.search(/\w+$/);
|
229
|
+
const priorWord = priorWordIndex >= 0 ? priorText.substr(priorWordIndex) : '';
|
230
|
+
// Don't offer completions if we're within a comment.
|
231
|
+
if (this._isWithinComment(offset)) {
|
232
|
+
return undefined;
|
233
|
+
}
|
234
|
+
// See if the node is part of an error node. If so, that takes
|
235
|
+
// precedence.
|
236
|
+
let errorNode = node;
|
237
|
+
while (errorNode) {
|
238
|
+
if (errorNode.nodeType === 0 /* Error */) {
|
239
|
+
break;
|
240
|
+
}
|
241
|
+
errorNode = errorNode.parent;
|
242
|
+
}
|
243
|
+
// Determine the context based on the parse node's type and
|
244
|
+
// that of its ancestors.
|
245
|
+
let curNode = errorNode || node;
|
246
|
+
while (true) {
|
247
|
+
(0, cancellationUtils_1.throwIfCancellationRequested)(this._cancellationToken);
|
248
|
+
if (curNode.nodeType === 49 /* String */) {
|
249
|
+
return this._getLiteralCompletions(curNode, priorWord, priorText, postText);
|
250
|
+
}
|
251
|
+
if (curNode.nodeType === 48 /* StringList */ || curNode.nodeType === 27 /* FormatString */) {
|
252
|
+
return undefined;
|
253
|
+
}
|
254
|
+
if (curNode.nodeType === 37 /* ModuleName */) {
|
255
|
+
return this._getImportModuleCompletions(curNode);
|
256
|
+
}
|
257
|
+
if (curNode.nodeType === 0 /* Error */) {
|
258
|
+
return this._getExpressionErrorCompletions(curNode, priorWord, priorText, postText);
|
259
|
+
}
|
260
|
+
if (curNode.nodeType === 35 /* MemberAccess */) {
|
261
|
+
return this._getMemberAccessCompletions(curNode.leftExpression, priorWord);
|
262
|
+
}
|
263
|
+
if (curNode.nodeType === 15 /* Dictionary */) {
|
264
|
+
const completionMap = new CompletionMap();
|
265
|
+
if (this._addTypedDictKeys(curNode, /* stringNode */ undefined, priorText, postText, completionMap)) {
|
266
|
+
return { completionMap };
|
267
|
+
}
|
268
|
+
}
|
269
|
+
const dictionaryEntry = ParseTreeUtils.getFirstAncestorOrSelfOfKind(curNode, 17 /* DictionaryKeyEntry */);
|
270
|
+
if (dictionaryEntry) {
|
271
|
+
if (((_b = dictionaryEntry.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 15 /* Dictionary */) {
|
272
|
+
const dictionaryNode = dictionaryEntry.parent;
|
273
|
+
if (dictionaryNode.trailingCommaToken && dictionaryNode.trailingCommaToken.start < offset) {
|
274
|
+
const completionMap = new CompletionMap();
|
275
|
+
if (this._addTypedDictKeys(dictionaryNode,
|
276
|
+
/* stringNode */ undefined, priorText, postText, completionMap)) {
|
277
|
+
return { completionMap };
|
278
|
+
}
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}
|
282
|
+
if (curNode.nodeType === 38 /* Name */) {
|
283
|
+
// This condition is little different than others since it does its own
|
284
|
+
// tree walk up to find context and let outer tree walk up to proceed if it can't find
|
285
|
+
// one to show completion.
|
286
|
+
const result = this._tryGetNameCompletions(curNode, offset, priorWord, priorText, postText);
|
287
|
+
if (result || result === undefined) {
|
288
|
+
return result;
|
289
|
+
}
|
290
|
+
}
|
291
|
+
if (curNode.nodeType === 22 /* ImportFrom */) {
|
292
|
+
return this._getImportFromCompletions(curNode, priorWord);
|
293
|
+
}
|
294
|
+
if ((0, parseNodes_1.isExpressionNode)(curNode)) {
|
295
|
+
return this._getExpressionCompletions(curNode, priorWord, priorText, postText);
|
296
|
+
}
|
297
|
+
if (curNode.nodeType === 50 /* Suite */) {
|
298
|
+
if (curNode.parent &&
|
299
|
+
curNode.parent.nodeType === 25 /* Except */ &&
|
300
|
+
!curNode.parent.name &&
|
301
|
+
curNode.parent.typeExpression &&
|
302
|
+
textRange_2.TextRange.getEnd(curNode.parent.typeExpression) < offset &&
|
303
|
+
offset <= curNode.parent.exceptSuite.start) {
|
304
|
+
// except Exception as [<empty>]
|
305
|
+
return undefined;
|
306
|
+
}
|
307
|
+
if (curNode.parent &&
|
308
|
+
curNode.parent.nodeType === 10 /* Class */ &&
|
309
|
+
(!curNode.parent.name || !curNode.parent.name.value) &&
|
310
|
+
curNode.parent.arguments.length === 0 &&
|
311
|
+
offset <= curNode.parent.suite.start) {
|
312
|
+
// class [<empty>]
|
313
|
+
return undefined;
|
314
|
+
}
|
315
|
+
return this._getStatementCompletions(curNode, priorWord, priorText, postText);
|
316
|
+
}
|
317
|
+
if (curNode.nodeType === 36 /* Module */) {
|
318
|
+
return this._getStatementCompletions(curNode, priorWord, priorText, postText);
|
319
|
+
}
|
320
|
+
if (curNode.nodeType === 41 /* Parameter */ &&
|
321
|
+
curNode.length === 0 &&
|
322
|
+
curNode.parent &&
|
323
|
+
curNode.parent.nodeType === 30 /* Lambda */) {
|
324
|
+
// lambda [<empty>] or lambda x, [<empty>]
|
325
|
+
return undefined;
|
326
|
+
}
|
327
|
+
if (!curNode.parent) {
|
328
|
+
break;
|
329
|
+
}
|
330
|
+
curNode = curNode.parent;
|
331
|
+
}
|
332
|
+
return undefined;
|
333
|
+
}
|
334
|
+
// When the user selects a completion, this callback is invoked,
|
335
|
+
// allowing us to record what was selected. This allows us to
|
336
|
+
// build our MRU cache so we can better predict entries.
|
337
|
+
resolveCompletionItem(completionItem) {
|
338
|
+
(0, cancellationUtils_1.throwIfCancellationRequested)(this._cancellationToken);
|
339
|
+
const completionItemData = (0, lspUtils_1.fromLSPAny)(completionItem.data);
|
340
|
+
const label = completionItem.label;
|
341
|
+
let autoImportText = '';
|
342
|
+
if (completionItemData.autoImportText) {
|
343
|
+
autoImportText = completionItemData.autoImportText;
|
344
|
+
}
|
345
|
+
const curIndex = CompletionProvider._mostRecentCompletions.findIndex((item) => item.label === label && item.autoImportText === autoImportText);
|
346
|
+
if (curIndex > 0) {
|
347
|
+
// If there's an existing entry with the same name that's not at the
|
348
|
+
// beginning of the array, remove it.
|
349
|
+
CompletionProvider._mostRecentCompletions = CompletionProvider._mostRecentCompletions.splice(curIndex, 1);
|
350
|
+
}
|
351
|
+
if (curIndex !== 0) {
|
352
|
+
// Add to the start of the array.
|
353
|
+
CompletionProvider._mostRecentCompletions.unshift({ label, autoImportText });
|
354
|
+
}
|
355
|
+
if (CompletionProvider._mostRecentCompletions.length > maxRecentCompletions) {
|
356
|
+
// Prevent the MRU list from growing indefinitely.
|
357
|
+
CompletionProvider._mostRecentCompletions.pop();
|
358
|
+
}
|
359
|
+
if (completionItemData.symbolLabel) {
|
360
|
+
this._itemToResolve = completionItem;
|
361
|
+
if (!completionItemData.autoImportText) {
|
362
|
+
// Rerun the completion lookup. It will fill in additional information
|
363
|
+
// about the item to be resolved. We'll ignore the rest of the returned
|
364
|
+
// list. This is a bit wasteful, but all of that information should be
|
365
|
+
// cached, so it's not as bad as it might seem.
|
366
|
+
this.getCompletionsForPosition();
|
367
|
+
}
|
368
|
+
else if (!completionItem.additionalTextEdits) {
|
369
|
+
const completionMap = new CompletionMap();
|
370
|
+
const completionResults = { completionMap };
|
371
|
+
this._addAutoImportCompletions(completionItemData.symbolLabel,
|
372
|
+
/* similarityLimit */ 1,
|
373
|
+
/* lazyEdit */ false, completionResults);
|
374
|
+
}
|
375
|
+
}
|
376
|
+
}
|
377
|
+
// This method will return false if it wants
|
378
|
+
// caller to walk up the tree. it will return
|
379
|
+
// CompletionResults or undefined if it wants caller
|
380
|
+
// to return.
|
381
|
+
_tryGetNameCompletions(curNode, offset, priorWord, priorText, postText) {
|
382
|
+
var _a, _b, _c;
|
383
|
+
if (!curNode.parent) {
|
384
|
+
return false;
|
385
|
+
}
|
386
|
+
if (curNode.parent.nodeType === 21 /* ImportAs */ && curNode.parent.alias === curNode) {
|
387
|
+
// Are we within a "import Y as [Z]"?
|
388
|
+
return undefined;
|
389
|
+
}
|
390
|
+
if (curNode.parent.nodeType === 37 /* ModuleName */) {
|
391
|
+
// Are we within a "import Y as [<empty>]"?
|
392
|
+
if (curNode.parent.parent &&
|
393
|
+
curNode.parent.parent.nodeType === 21 /* ImportAs */ &&
|
394
|
+
!curNode.parent.parent.alias &&
|
395
|
+
textRange_2.TextRange.getEnd(curNode.parent.parent) < offset) {
|
396
|
+
return undefined;
|
397
|
+
}
|
398
|
+
// Are we within a "from X import Y as Z" statement and
|
399
|
+
// more specifically within the "Y"?
|
400
|
+
return this._getImportModuleCompletions(curNode.parent);
|
401
|
+
}
|
402
|
+
if (curNode.parent.nodeType === 23 /* ImportFromAs */) {
|
403
|
+
if (curNode.parent.alias === curNode) {
|
404
|
+
// Are we within a "from X import Y as [Z]"?
|
405
|
+
return undefined;
|
406
|
+
}
|
407
|
+
const parentNode = curNode.parent.parent;
|
408
|
+
if (parentNode && parentNode.nodeType === 22 /* ImportFrom */) {
|
409
|
+
// Are we within a "from X import Y as [<empty>]"?
|
410
|
+
if (!curNode.parent.alias && textRange_2.TextRange.getEnd(curNode.parent) < offset) {
|
411
|
+
return undefined;
|
412
|
+
}
|
413
|
+
if (curNode.parent.name === curNode) {
|
414
|
+
return this._getImportFromCompletions(parentNode, priorWord);
|
415
|
+
}
|
416
|
+
return this._getImportFromCompletions(parentNode, '');
|
417
|
+
}
|
418
|
+
return false;
|
419
|
+
}
|
420
|
+
if (curNode.parent.nodeType === 35 /* MemberAccess */ && curNode === curNode.parent.memberName) {
|
421
|
+
return this._getMemberAccessCompletions(curNode.parent.leftExpression, priorWord);
|
422
|
+
}
|
423
|
+
if (curNode.parent.nodeType === 25 /* Except */ && curNode === curNode.parent.name) {
|
424
|
+
return undefined;
|
425
|
+
}
|
426
|
+
if (curNode.parent.nodeType === 28 /* Function */ && curNode === curNode.parent.name) {
|
427
|
+
if ((_a = curNode.parent.decorators) === null || _a === void 0 ? void 0 : _a.some((d) => this._isOverload(d))) {
|
428
|
+
return this._getMethodOverloadsCompletions(priorWord, curNode);
|
429
|
+
}
|
430
|
+
return undefined;
|
431
|
+
}
|
432
|
+
if (curNode.parent.nodeType === 41 /* Parameter */ && curNode === curNode.parent.name) {
|
433
|
+
return undefined;
|
434
|
+
}
|
435
|
+
if (curNode.parent.nodeType === 10 /* Class */ && curNode === curNode.parent.name) {
|
436
|
+
return undefined;
|
437
|
+
}
|
438
|
+
if (curNode.parent.nodeType === 26 /* For */ &&
|
439
|
+
textRange_2.TextRange.contains(curNode.parent.targetExpression, curNode.start)) {
|
440
|
+
return undefined;
|
441
|
+
}
|
442
|
+
if (curNode.parent.nodeType === 33 /* ListComprehensionFor */ &&
|
443
|
+
textRange_2.TextRange.contains(curNode.parent.targetExpression, curNode.start)) {
|
444
|
+
return undefined;
|
445
|
+
}
|
446
|
+
// For assignments that implicitly declare variables, remove itself (var decl) from completion.
|
447
|
+
if (curNode.parent.nodeType === 3 /* Assignment */ ||
|
448
|
+
curNode.parent.nodeType === 4 /* AssignmentExpression */) {
|
449
|
+
const leftNode = curNode.parent.nodeType === 4 /* AssignmentExpression */
|
450
|
+
? curNode.parent.name
|
451
|
+
: curNode.parent.leftExpression;
|
452
|
+
if (leftNode !== curNode || priorWord.length === 0) {
|
453
|
+
return false;
|
454
|
+
}
|
455
|
+
const decls = this._evaluator.getDeclarationsForNameNode(curNode);
|
456
|
+
if ((decls === null || decls === void 0 ? void 0 : decls.length) !== 1 || !(0, declaration_1.isVariableDeclaration)(decls[0]) || decls[0].node !== curNode) {
|
457
|
+
return false;
|
458
|
+
}
|
459
|
+
const completionList = this._getExpressionCompletions(curNode, priorWord, priorText, postText);
|
460
|
+
if (completionList === null || completionList === void 0 ? void 0 : completionList.completionMap) {
|
461
|
+
completionList.completionMap.delete(curNode.value);
|
462
|
+
}
|
463
|
+
return completionList;
|
464
|
+
}
|
465
|
+
// Defining class variables.
|
466
|
+
// ex) class A:
|
467
|
+
// variable = 1
|
468
|
+
if (curNode.parent.nodeType === 47 /* StatementList */ &&
|
469
|
+
((_b = curNode.parent.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 50 /* Suite */ &&
|
470
|
+
((_c = curNode.parent.parent.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 10 /* Class */) {
|
471
|
+
const completionList = this._getClassVariableCompletions(priorWord, curNode);
|
472
|
+
if (completionList) {
|
473
|
+
return completionList;
|
474
|
+
}
|
475
|
+
}
|
476
|
+
return false;
|
477
|
+
}
|
478
|
+
_isWithinComment(offset) {
|
479
|
+
var _a, _b;
|
480
|
+
const token = getTokenAfter(offset, this._parseResults.tokenizerOutput.tokens);
|
481
|
+
if (!token) {
|
482
|
+
// If we're in the middle of a token, we're not in a comment.
|
483
|
+
return false;
|
484
|
+
}
|
485
|
+
return (_b = (_a = token.comments) === null || _a === void 0 ? void 0 : _a.some((c) => textRange_2.TextRange.overlaps(c, offset))) !== null && _b !== void 0 ? _b : false;
|
486
|
+
function getTokenAfter(offset, tokens) {
|
487
|
+
const tokenIndex = tokens.getItemAtPosition(offset);
|
488
|
+
if (tokenIndex < 0) {
|
489
|
+
return undefined;
|
490
|
+
}
|
491
|
+
let token = tokens.getItemAt(tokenIndex);
|
492
|
+
// If we're in the middle of a token, we can't be within a comment.
|
493
|
+
if (offset > token.start && offset < token.start + token.length) {
|
494
|
+
return undefined;
|
495
|
+
}
|
496
|
+
// Multiple zero length tokens can occupy same position.
|
497
|
+
// But comment is associated with the first one. loop
|
498
|
+
// backward to find the first token if position is same.
|
499
|
+
for (let i = tokenIndex - 1; i >= 0; i--) {
|
500
|
+
const prevToken = tokens.getItemAt(i);
|
501
|
+
if (token.start !== prevToken.start) {
|
502
|
+
break;
|
503
|
+
}
|
504
|
+
token = prevToken;
|
505
|
+
}
|
506
|
+
if (offset <= token.start) {
|
507
|
+
return token;
|
508
|
+
}
|
509
|
+
// If offset > token.start, tokenIndex + 1 < tokens.length
|
510
|
+
// should be always true.
|
511
|
+
debug.assert(tokenIndex + 1 < tokens.length);
|
512
|
+
return tokens.getItemAt(tokenIndex + 1);
|
513
|
+
}
|
514
|
+
}
|
515
|
+
_getExpressionErrorCompletions(node, priorWord, priorText, postText) {
|
516
|
+
var _a;
|
517
|
+
// Is the error due to a missing member access name? If so,
|
518
|
+
// we can evaluate the left side of the member access expression
|
519
|
+
// to determine its type and offer suggestions based on it.
|
520
|
+
switch (node.category) {
|
521
|
+
case 0 /* MissingIn */: {
|
522
|
+
return this._createSingleKeywordCompletion('in');
|
523
|
+
}
|
524
|
+
case 1 /* MissingElse */: {
|
525
|
+
return this._createSingleKeywordCompletion('else');
|
526
|
+
}
|
527
|
+
case 2 /* MissingExpression */:
|
528
|
+
case 4 /* MissingDecoratorCallName */: {
|
529
|
+
return this._getExpressionCompletions(node, priorWord, priorText, postText);
|
530
|
+
}
|
531
|
+
case 3 /* MissingIndexOrSlice */: {
|
532
|
+
let completionResults = this._getLiteralCompletions(node, priorWord, priorText, postText);
|
533
|
+
if (!completionResults || !completionResults.completionMap) {
|
534
|
+
completionResults = this._getExpressionCompletions(node, priorWord, priorText, postText);
|
535
|
+
}
|
536
|
+
return completionResults;
|
537
|
+
}
|
538
|
+
case 7 /* MissingMemberAccessName */: {
|
539
|
+
if (node.child && (0, parseNodes_1.isExpressionNode)(node.child)) {
|
540
|
+
return this._getMemberAccessCompletions(node.child, priorWord);
|
541
|
+
}
|
542
|
+
break;
|
543
|
+
}
|
544
|
+
case 10 /* MissingFunctionParameterList */: {
|
545
|
+
if (node.child && node.child.nodeType === 38 /* Name */) {
|
546
|
+
if ((_a = node.decorators) === null || _a === void 0 ? void 0 : _a.some((d) => this._isOverload(d))) {
|
547
|
+
return this._getMethodOverloadsCompletions(priorWord, node.child);
|
548
|
+
}
|
549
|
+
// Determine if the partial name is a method that's overriding
|
550
|
+
// a method in a base class.
|
551
|
+
return this._getMethodOverrideCompletions(priorWord, node.child, node.decorators);
|
552
|
+
}
|
553
|
+
break;
|
554
|
+
}
|
555
|
+
}
|
556
|
+
return undefined;
|
557
|
+
}
|
558
|
+
_isOverload(node) {
|
559
|
+
return this._checkDecorator(node, 'overload');
|
560
|
+
}
|
561
|
+
_checkDecorator(node, value) {
|
562
|
+
return node.expression.nodeType === 38 /* Name */ && node.expression.value === value;
|
563
|
+
}
|
564
|
+
_createSingleKeywordCompletion(keyword) {
|
565
|
+
const completionItem = vscode_languageserver_1.CompletionItem.create(keyword);
|
566
|
+
completionItem.kind = vscode_languageserver_1.CompletionItemKind.Keyword;
|
567
|
+
completionItem.sortText = this._makeSortText(SortCategory.LikelyKeyword, keyword);
|
568
|
+
const completionMap = new CompletionMap();
|
569
|
+
completionMap.set(completionItem);
|
570
|
+
return { completionMap };
|
571
|
+
}
|
572
|
+
_getClassVariableCompletions(priorWord, partialName) {
|
573
|
+
const enclosingClass = ParseTreeUtils.getEnclosingClass(partialName, false);
|
574
|
+
if (!enclosingClass) {
|
575
|
+
return undefined;
|
576
|
+
}
|
577
|
+
const classResults = this._evaluator.getTypeOfClass(enclosingClass);
|
578
|
+
if (!classResults) {
|
579
|
+
return undefined;
|
580
|
+
}
|
581
|
+
const symbolTable = new Map();
|
582
|
+
for (const mroClass of classResults.classType.details.mro) {
|
583
|
+
if ((0, types_1.isInstantiableClass)(mroClass)) {
|
584
|
+
(0, typeUtils_1.getMembersForClass)(mroClass, symbolTable, /* includeInstanceVars */ false);
|
585
|
+
}
|
586
|
+
}
|
587
|
+
const printFlags = (0, sourceMapper_1.isStubFile)(this._filePath)
|
588
|
+
? 1 /* ForwardDeclarations */ |
|
589
|
+
2 /* DoNotLimitStringLength */
|
590
|
+
: 2 /* DoNotLimitStringLength */;
|
591
|
+
const completionMap = new CompletionMap();
|
592
|
+
symbolTable.forEach((symbol, name) => {
|
593
|
+
if (SymbolNameUtils.isPrivateName(name) ||
|
594
|
+
symbol.isPrivateMember() ||
|
595
|
+
symbol.isExternallyHidden() ||
|
596
|
+
!StringUtils.isPatternInSymbol(partialName.value, name)) {
|
597
|
+
return;
|
598
|
+
}
|
599
|
+
const decls = symbol
|
600
|
+
.getDeclarations()
|
601
|
+
.filter((d) => (0, declaration_1.isVariableDeclaration)(d) && d.moduleName !== 'builtins');
|
602
|
+
// Skip any symbols invalid such as defined in the same class.
|
603
|
+
if (decls.length === 0 ||
|
604
|
+
decls.some((d) => d.node && ParseTreeUtils.getEnclosingClass(d.node, false) === enclosingClass)) {
|
605
|
+
return;
|
606
|
+
}
|
607
|
+
let edits;
|
608
|
+
const declWithTypeAnnotations = decls.filter((d) => d.typeAnnotationNode);
|
609
|
+
if (declWithTypeAnnotations.length > 0) {
|
610
|
+
const text = `${name}: ${ParseTreeUtils.printExpression(declWithTypeAnnotations[declWithTypeAnnotations.length - 1].typeAnnotationNode, printFlags)}`;
|
611
|
+
edits = {
|
612
|
+
textEdit: this._createReplaceEdits(priorWord, partialName, text),
|
613
|
+
};
|
614
|
+
}
|
615
|
+
this._addSymbol(name, symbol, partialName.value, completionMap, { edits });
|
616
|
+
});
|
617
|
+
return completionMap.size > 0 ? { completionMap } : undefined;
|
618
|
+
}
|
619
|
+
_getMethodOverloadsCompletions(priorWord, partialName) {
|
620
|
+
var _a;
|
621
|
+
const symbolTable = getSymbolTable(this._evaluator, partialName);
|
622
|
+
if (!symbolTable) {
|
623
|
+
return undefined;
|
624
|
+
}
|
625
|
+
const funcParensDisabled = ((_a = partialName.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 28 /* Function */ ? true : undefined;
|
626
|
+
const completionMap = new CompletionMap();
|
627
|
+
const enclosingFunc = ParseTreeUtils.getEnclosingFunction(partialName);
|
628
|
+
symbolTable.forEach((symbol, name) => {
|
629
|
+
const decl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(symbol);
|
630
|
+
if (!decl || decl.type !== 3 /* Function */) {
|
631
|
+
return;
|
632
|
+
}
|
633
|
+
if (!decl.node.decorators.some((d) => this._isOverload(d))) {
|
634
|
+
// Only consider ones that have overload decorator.
|
635
|
+
return;
|
636
|
+
}
|
637
|
+
const decls = symbol.getDeclarations();
|
638
|
+
if (decls.length === 1 && decls.some((d) => d.node === enclosingFunc)) {
|
639
|
+
// Don't show itself.
|
640
|
+
return;
|
641
|
+
}
|
642
|
+
if (StringUtils.isPatternInSymbol(partialName.value, name)) {
|
643
|
+
const textEdit = this._createReplaceEdits(priorWord, partialName, decl.node.name.value);
|
644
|
+
this._addSymbol(name, symbol, partialName.value, completionMap, {
|
645
|
+
funcParensDisabled,
|
646
|
+
edits: { textEdit },
|
647
|
+
});
|
648
|
+
}
|
649
|
+
});
|
650
|
+
return { completionMap };
|
651
|
+
function getSymbolTable(evaluator, partialName) {
|
652
|
+
const enclosingClass = ParseTreeUtils.getEnclosingClass(partialName, false);
|
653
|
+
if (enclosingClass) {
|
654
|
+
const classResults = evaluator.getTypeOfClass(enclosingClass);
|
655
|
+
if (!classResults) {
|
656
|
+
return undefined;
|
657
|
+
}
|
658
|
+
const symbolTable = new Map();
|
659
|
+
for (const mroClass of classResults.classType.details.mro) {
|
660
|
+
if ((0, types_1.isInstantiableClass)(mroClass)) {
|
661
|
+
(0, typeUtils_1.getMembersForClass)(mroClass, symbolTable, /* includeInstanceVars */ false);
|
662
|
+
}
|
663
|
+
}
|
664
|
+
return symbolTable;
|
665
|
+
}
|
666
|
+
// For function overload, we only care about top level functions
|
667
|
+
const moduleNode = ParseTreeUtils.getEnclosingModule(partialName);
|
668
|
+
if (moduleNode) {
|
669
|
+
const moduleScope = AnalyzerNodeInfo.getScope(moduleNode);
|
670
|
+
return moduleScope === null || moduleScope === void 0 ? void 0 : moduleScope.symbolTable;
|
671
|
+
}
|
672
|
+
return undefined;
|
673
|
+
}
|
674
|
+
}
|
675
|
+
_getMethodOverrideCompletions(priorWord, partialName, decorators) {
|
676
|
+
var _a, _b;
|
677
|
+
const enclosingClass = ParseTreeUtils.getEnclosingClass(partialName, /* stopAtFunction */ true);
|
678
|
+
if (!enclosingClass) {
|
679
|
+
return undefined;
|
680
|
+
}
|
681
|
+
const classResults = this._evaluator.getTypeOfClass(enclosingClass);
|
682
|
+
if (!classResults) {
|
683
|
+
return undefined;
|
684
|
+
}
|
685
|
+
const symbolTable = new Map();
|
686
|
+
for (let i = 1; i < classResults.classType.details.mro.length; i++) {
|
687
|
+
const mroClass = classResults.classType.details.mro[i];
|
688
|
+
if ((0, types_1.isInstantiableClass)(mroClass)) {
|
689
|
+
(0, typeUtils_1.getMembersForClass)(mroClass, symbolTable, /* includeInstanceVars */ false);
|
690
|
+
}
|
691
|
+
}
|
692
|
+
const staticmethod = (_a = decorators === null || decorators === void 0 ? void 0 : decorators.some((d) => this._checkDecorator(d, 'staticmethod'))) !== null && _a !== void 0 ? _a : false;
|
693
|
+
const classmethod = (_b = decorators === null || decorators === void 0 ? void 0 : decorators.some((d) => this._checkDecorator(d, 'classmethod'))) !== null && _b !== void 0 ? _b : false;
|
694
|
+
const completionMap = new CompletionMap();
|
695
|
+
symbolTable.forEach((symbol, name) => {
|
696
|
+
let decl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(symbol);
|
697
|
+
if (decl && decl.type === 3 /* Function */) {
|
698
|
+
if (StringUtils.isPatternInSymbol(partialName.value, name)) {
|
699
|
+
const declaredType = this._evaluator.getTypeForDeclaration(decl);
|
700
|
+
if (!declaredType) {
|
701
|
+
return;
|
702
|
+
}
|
703
|
+
let isProperty = (0, types_1.isClassInstance)(declaredType) && types_1.ClassType.isPropertyClass(declaredType);
|
704
|
+
if (SymbolNameUtils.isDunderName(name)) {
|
705
|
+
// Don't offer suggestions for built-in properties like "__class__", etc.
|
706
|
+
isProperty = false;
|
707
|
+
}
|
708
|
+
if (!(0, types_1.isFunction)(declaredType) && !isProperty) {
|
709
|
+
return;
|
710
|
+
}
|
711
|
+
if (isProperty) {
|
712
|
+
// For properties, we should override the "getter", which is typically
|
713
|
+
// the first declaration.
|
714
|
+
const typedDecls = symbol.getTypedDeclarations();
|
715
|
+
if (typedDecls.length > 0 && typedDecls[0].type === 3 /* Function */) {
|
716
|
+
decl = typedDecls[0];
|
717
|
+
}
|
718
|
+
}
|
719
|
+
const isDeclaredStaticMethod = (0, types_1.isFunction)(declaredType) && types_1.FunctionType.isStaticMethod(declaredType);
|
720
|
+
// Special-case the "__init__subclass__" method because it's an implicit
|
721
|
+
// classmethod that the type evaluator flags as a real classmethod.
|
722
|
+
const isDeclaredClassMethod = (0, types_1.isFunction)(declaredType) &&
|
723
|
+
types_1.FunctionType.isClassMethod(declaredType) &&
|
724
|
+
name !== '__init_subclass__';
|
725
|
+
if (staticmethod !== isDeclaredStaticMethod || classmethod !== isDeclaredClassMethod) {
|
726
|
+
return;
|
727
|
+
}
|
728
|
+
const methodSignature = this._printMethodSignature(classResults.classType, decl);
|
729
|
+
let text;
|
730
|
+
if ((0, sourceMapper_1.isStubFile)(this._filePath)) {
|
731
|
+
text = `${methodSignature}: ...`;
|
732
|
+
}
|
733
|
+
else {
|
734
|
+
const methodBody = this._printOverriddenMethodBody(classResults.classType, isDeclaredStaticMethod, isProperty, decl);
|
735
|
+
text = `${methodSignature}:\n${methodBody}`;
|
736
|
+
}
|
737
|
+
const textEdit = this._createReplaceEdits(priorWord, partialName, text);
|
738
|
+
this._addSymbol(name, symbol, partialName.value, completionMap, {
|
739
|
+
// method signature already contains ()
|
740
|
+
funcParensDisabled: true,
|
741
|
+
edits: {
|
742
|
+
format: this._options.snippet ? vscode_languageserver_1.InsertTextFormat.Snippet : undefined,
|
743
|
+
textEdit,
|
744
|
+
},
|
745
|
+
});
|
746
|
+
}
|
747
|
+
}
|
748
|
+
});
|
749
|
+
return { completionMap };
|
750
|
+
}
|
751
|
+
_createReplaceEdits(priorWord, node, text) {
|
752
|
+
const replaceOrInsertEndChar = (node === null || node === void 0 ? void 0 : node.nodeType) === 38 /* Name */
|
753
|
+
? this._position.character - priorWord.length + node.value.length
|
754
|
+
: this._position.character;
|
755
|
+
const range = {
|
756
|
+
start: { line: this._position.line, character: this._position.character - priorWord.length },
|
757
|
+
end: { line: this._position.line, character: replaceOrInsertEndChar },
|
758
|
+
};
|
759
|
+
return vscode_languageserver_1.TextEdit.replace(range, text);
|
760
|
+
}
|
761
|
+
_printMethodSignature(classType, decl) {
|
762
|
+
const node = decl.node;
|
763
|
+
let ellipsisForDefault;
|
764
|
+
if ((0, sourceMapper_1.isStubFile)(this._filePath)) {
|
765
|
+
// In stubs, always use "...".
|
766
|
+
ellipsisForDefault = true;
|
767
|
+
}
|
768
|
+
else if (classType.details.moduleName === decl.moduleName) {
|
769
|
+
// In the same file, always print the full default.
|
770
|
+
ellipsisForDefault = false;
|
771
|
+
}
|
772
|
+
const printFlags = (0, sourceMapper_1.isStubFile)(this._filePath)
|
773
|
+
? 1 /* ForwardDeclarations */ |
|
774
|
+
2 /* DoNotLimitStringLength */
|
775
|
+
: 2 /* DoNotLimitStringLength */;
|
776
|
+
const paramList = node.parameters
|
777
|
+
.map((param, index) => {
|
778
|
+
let paramString = '';
|
779
|
+
if (param.category === 1 /* VarArgList */) {
|
780
|
+
paramString += '*';
|
781
|
+
}
|
782
|
+
else if (param.category === 2 /* VarArgDictionary */) {
|
783
|
+
paramString += '**';
|
784
|
+
}
|
785
|
+
if (param.name) {
|
786
|
+
paramString += param.name.value;
|
787
|
+
}
|
788
|
+
// Currently, we don't automatically add import if the type used in the annotation is not imported
|
789
|
+
// in current file.
|
790
|
+
const paramTypeAnnotation = ParseTreeUtils.getTypeAnnotationForParameter(node, index);
|
791
|
+
if (paramTypeAnnotation) {
|
792
|
+
paramString += ': ' + ParseTreeUtils.printExpression(paramTypeAnnotation, printFlags);
|
793
|
+
}
|
794
|
+
if (param.defaultValue) {
|
795
|
+
paramString += paramTypeAnnotation ? ' = ' : '=';
|
796
|
+
const useEllipsis = ellipsisForDefault !== null && ellipsisForDefault !== void 0 ? ellipsisForDefault : !isSimpleDefault(param.defaultValue);
|
797
|
+
paramString += useEllipsis ? '...' : ParseTreeUtils.printExpression(param.defaultValue, printFlags);
|
798
|
+
}
|
799
|
+
if (!paramString && !param.name && param.category === 0 /* Simple */) {
|
800
|
+
return '/';
|
801
|
+
}
|
802
|
+
return paramString;
|
803
|
+
})
|
804
|
+
.join(', ');
|
805
|
+
let methodSignature = node.name.value + '(' + paramList + ')';
|
806
|
+
if (node.returnTypeAnnotation) {
|
807
|
+
methodSignature += ' -> ' + ParseTreeUtils.printExpression(node.returnTypeAnnotation, printFlags);
|
808
|
+
}
|
809
|
+
else if (node.functionAnnotationComment) {
|
810
|
+
methodSignature +=
|
811
|
+
' -> ' +
|
812
|
+
ParseTreeUtils.printExpression(node.functionAnnotationComment.returnTypeAnnotation, printFlags);
|
813
|
+
}
|
814
|
+
return methodSignature;
|
815
|
+
function isSimpleDefault(node) {
|
816
|
+
switch (node.nodeType) {
|
817
|
+
case 40 /* Number */:
|
818
|
+
case 11 /* Constant */:
|
819
|
+
return true;
|
820
|
+
case 49 /* String */:
|
821
|
+
return (node.token.flags & 64 /* Format */) === 0;
|
822
|
+
case 48 /* StringList */:
|
823
|
+
return node.strings.every(isSimpleDefault);
|
824
|
+
case 55 /* UnaryOperation */:
|
825
|
+
return isSimpleDefault(node.expression);
|
826
|
+
case 7 /* BinaryOperation */:
|
827
|
+
return isSimpleDefault(node.leftExpression) && isSimpleDefault(node.rightExpression);
|
828
|
+
default:
|
829
|
+
return false;
|
830
|
+
}
|
831
|
+
}
|
832
|
+
}
|
833
|
+
_printOverriddenMethodBody(classType, isStaticMethod, isProperty, decl) {
|
834
|
+
let sb = this._parseResults.tokenizerOutput.predominantTabSequence;
|
835
|
+
if (classType.details.baseClasses.length === 1 &&
|
836
|
+
(0, types_1.isClass)(classType.details.baseClasses[0]) &&
|
837
|
+
classType.details.baseClasses[0].details.fullName === 'builtins.object') {
|
838
|
+
sb += this._options.snippet ? '${0:pass}' : 'pass';
|
839
|
+
return sb;
|
840
|
+
}
|
841
|
+
if (decl.node.parameters.length === 0) {
|
842
|
+
sb += this._options.snippet ? '${0:pass}' : 'pass';
|
843
|
+
return sb;
|
844
|
+
}
|
845
|
+
const parameters = getParameters(isStaticMethod ? decl.node.parameters : decl.node.parameters.slice(1));
|
846
|
+
if (decl.node.name.value !== '__init__') {
|
847
|
+
sb += 'return ';
|
848
|
+
}
|
849
|
+
if (decl.node.isAsync) {
|
850
|
+
sb += 'await ';
|
851
|
+
}
|
852
|
+
if (isProperty) {
|
853
|
+
return sb + `super().${decl.node.name.value}`;
|
854
|
+
}
|
855
|
+
return sb + `super().${decl.node.name.value}(${parameters.map(convertToString).join(', ')})`;
|
856
|
+
function getParameters(parameters) {
|
857
|
+
const results = [];
|
858
|
+
let keywordOnly = false;
|
859
|
+
for (const parameter of parameters) {
|
860
|
+
if (parameter.name) {
|
861
|
+
results.push([parameter, keywordOnly]);
|
862
|
+
}
|
863
|
+
keywordOnly =
|
864
|
+
parameter.category === 1 /* VarArgList */ ||
|
865
|
+
parameter.category === 2 /* VarArgDictionary */;
|
866
|
+
}
|
867
|
+
return results;
|
868
|
+
}
|
869
|
+
function convertToString(parameter) {
|
870
|
+
var _a;
|
871
|
+
const name = (_a = parameter[0].name) === null || _a === void 0 ? void 0 : _a.value;
|
872
|
+
if (parameter[0].category === 1 /* VarArgList */) {
|
873
|
+
return `*${name}`;
|
874
|
+
}
|
875
|
+
if (parameter[0].category === 2 /* VarArgDictionary */) {
|
876
|
+
return `**${name}`;
|
877
|
+
}
|
878
|
+
return parameter[1] ? `${name}=${name}` : name;
|
879
|
+
}
|
880
|
+
}
|
881
|
+
_getMemberAccessCompletions(leftExprNode, priorWord) {
|
882
|
+
const symbolTable = new Map();
|
883
|
+
const completionMap = new CompletionMap();
|
884
|
+
let memberAccessInfo = {};
|
885
|
+
let leftType = this._evaluator.getType(leftExprNode);
|
886
|
+
if (leftType) {
|
887
|
+
leftType = this._evaluator.makeTopLevelTypeVarsConcrete(leftType);
|
888
|
+
(0, typeUtils_1.doForEachSubtype)(leftType, (subtype) => {
|
889
|
+
subtype = this._evaluator.makeTopLevelTypeVarsConcrete(subtype);
|
890
|
+
if ((0, types_1.isClass)(subtype)) {
|
891
|
+
// Handle LiteralString specially. Treat it like a 'str' for purposes
|
892
|
+
// of completion suggestions.
|
893
|
+
if (types_1.ClassType.isBuiltIn(subtype, 'LiteralString')) {
|
894
|
+
const strObject = this._evaluator.getBuiltInObject(leftExprNode, 'str');
|
895
|
+
if (strObject && (0, types_1.isClassInstance)(strObject)) {
|
896
|
+
subtype = strObject;
|
897
|
+
}
|
898
|
+
}
|
899
|
+
(0, typeUtils_1.getMembersForClass)(subtype, symbolTable, /* includeInstanceVars */ types_1.TypeBase.isInstance(subtype));
|
900
|
+
}
|
901
|
+
else if ((0, types_1.isModule)(subtype)) {
|
902
|
+
(0, typeUtils_1.getMembersForModule)(subtype, symbolTable);
|
903
|
+
}
|
904
|
+
else if ((0, types_1.isFunction)(subtype) || (0, types_1.isOverloadedFunction)(subtype)) {
|
905
|
+
const functionClass = this._evaluator.getBuiltInType(leftExprNode, 'function');
|
906
|
+
if (functionClass && (0, types_1.isInstantiableClass)(functionClass)) {
|
907
|
+
(0, typeUtils_1.getMembersForClass)(functionClass, symbolTable, /* includeInstanceVars */ true);
|
908
|
+
}
|
909
|
+
}
|
910
|
+
else if ((0, types_1.isNoneInstance)(subtype)) {
|
911
|
+
const objectClass = this._evaluator.getBuiltInType(leftExprNode, 'object');
|
912
|
+
if (objectClass && (0, types_1.isInstantiableClass)(objectClass)) {
|
913
|
+
(0, typeUtils_1.getMembersForClass)(objectClass, symbolTable, types_1.TypeBase.isInstance(subtype));
|
914
|
+
}
|
915
|
+
}
|
916
|
+
this._addSymbolsForSymbolTable(symbolTable, () => true, priorWord,
|
917
|
+
/* isInImport */ false, (0, types_1.isClass)(subtype) ? subtype : undefined, completionMap);
|
918
|
+
});
|
919
|
+
}
|
920
|
+
// If we don't know this type, look for a module we should stub.
|
921
|
+
if (!leftType || (0, types_1.isUnknown)(leftType) || (0, types_1.isUnbound)(leftType)) {
|
922
|
+
memberAccessInfo = this._getLastKnownModule(leftExprNode, leftType);
|
923
|
+
}
|
924
|
+
return { completionMap, memberAccessInfo };
|
925
|
+
}
|
926
|
+
_getLastKnownModule(leftExprNode, leftType) {
|
927
|
+
var _a;
|
928
|
+
let curNode = leftExprNode;
|
929
|
+
let curType = leftType;
|
930
|
+
let unknownMemberName = leftExprNode.nodeType === 35 /* MemberAccess */ ? leftExprNode === null || leftExprNode === void 0 ? void 0 : leftExprNode.memberName.value : undefined;
|
931
|
+
// Walk left of the expression scope till we find a known type. A.B.Unknown.<-- return B.
|
932
|
+
while (curNode) {
|
933
|
+
if (curNode.nodeType === 9 /* Call */ || curNode.nodeType === 35 /* MemberAccess */) {
|
934
|
+
// Move left
|
935
|
+
curNode = curNode.leftExpression;
|
936
|
+
// First time in the loop remember the name of the unknown type.
|
937
|
+
if (unknownMemberName === undefined) {
|
938
|
+
unknownMemberName =
|
939
|
+
curNode.nodeType === 35 /* MemberAccess */ ? (_a = curNode === null || curNode === void 0 ? void 0 : curNode.memberName.value) !== null && _a !== void 0 ? _a : '' : '';
|
940
|
+
}
|
941
|
+
}
|
942
|
+
else {
|
943
|
+
curNode = undefined;
|
944
|
+
}
|
945
|
+
if (curNode) {
|
946
|
+
curType = this._evaluator.getType(curNode);
|
947
|
+
// Breakout if we found a known type.
|
948
|
+
if (curType !== undefined && !(0, types_1.isUnknown)(curType) && !(0, types_1.isUnbound)(curType)) {
|
949
|
+
break;
|
950
|
+
}
|
951
|
+
}
|
952
|
+
}
|
953
|
+
const memberAccessInfo = {};
|
954
|
+
if (curType && !(0, types_1.isUnknown)(curType) && !(0, types_1.isUnbound)(curType) && curNode) {
|
955
|
+
const moduleNamesForType = (0, typeUtils_1.getDeclaringModulesForType)(curType);
|
956
|
+
// For union types we only care about non 'typing' modules.
|
957
|
+
memberAccessInfo.lastKnownModule = moduleNamesForType.find((n) => n !== 'typing');
|
958
|
+
if (curNode.nodeType === 35 /* MemberAccess */) {
|
959
|
+
memberAccessInfo.lastKnownMemberName = curNode.memberName.value;
|
960
|
+
}
|
961
|
+
else if (curNode.nodeType === 38 /* Name */ && (0, types_1.isInstantiableClass)(curType)) {
|
962
|
+
memberAccessInfo.lastKnownMemberName = curType.details.name;
|
963
|
+
}
|
964
|
+
else if (curNode.nodeType === 38 /* Name */ && (0, types_1.isClassInstance)(curType)) {
|
965
|
+
memberAccessInfo.lastKnownMemberName = curType.details.name;
|
966
|
+
}
|
967
|
+
memberAccessInfo.unknownMemberName = unknownMemberName;
|
968
|
+
}
|
969
|
+
return memberAccessInfo;
|
970
|
+
}
|
971
|
+
_getStatementCompletions(parseNode, priorWord, priorText, postText) {
|
972
|
+
// For now, use the same logic for expressions and statements.
|
973
|
+
return this._getExpressionCompletions(parseNode, priorWord, priorText, postText);
|
974
|
+
}
|
975
|
+
_getExpressionCompletions(parseNode, priorWord, priorText, postText) {
|
976
|
+
var _a, _b, _c, _d;
|
977
|
+
const isIndexArgument = this._isIndexArgument(parseNode);
|
978
|
+
// If the user typed a "." as part of a number, don't present
|
979
|
+
// any completion options.
|
980
|
+
if (!isIndexArgument && parseNode.nodeType === 40 /* Number */) {
|
981
|
+
return undefined;
|
982
|
+
}
|
983
|
+
// Are we within a "with Y as []"?
|
984
|
+
// Don't add any completion options.
|
985
|
+
if (((_a = parseNode.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 59 /* WithItem */ &&
|
986
|
+
parseNode.parent === ((_b = parseNode.parent.target) === null || _b === void 0 ? void 0 : _b.parent)) {
|
987
|
+
return undefined;
|
988
|
+
}
|
989
|
+
const completionMap = new CompletionMap();
|
990
|
+
const completionResults = { completionMap };
|
991
|
+
// Return empty completionList for Ellipsis
|
992
|
+
if (priorText.slice(-2) === '..') {
|
993
|
+
return completionResults;
|
994
|
+
}
|
995
|
+
// Add call argument completions.
|
996
|
+
this._addCallArgumentCompletions(parseNode, priorWord, priorText, postText,
|
997
|
+
/* atArgument */ false, completionMap);
|
998
|
+
// Add symbols that are in scope.
|
999
|
+
this._addSymbols(parseNode, priorWord, completionMap);
|
1000
|
+
// Add keywords.
|
1001
|
+
this._findMatchingKeywords(Keywords.forVersion(this._execEnv.pythonVersion), priorWord).map((keyword) => {
|
1002
|
+
if (completionMap.has(keyword)) {
|
1003
|
+
return;
|
1004
|
+
}
|
1005
|
+
const completionItem = vscode_languageserver_1.CompletionItem.create(keyword);
|
1006
|
+
completionItem.kind = vscode_languageserver_1.CompletionItemKind.Keyword;
|
1007
|
+
completionItem.sortText = this._makeSortText(SortCategory.Keyword, keyword);
|
1008
|
+
completionMap.set(completionItem);
|
1009
|
+
});
|
1010
|
+
// Add auto-import suggestions from other modules.
|
1011
|
+
// Ignore this check for privates, since they are not imported.
|
1012
|
+
if (!priorWord.startsWith('_') && !this._itemToResolve) {
|
1013
|
+
this._addAutoImportCompletions(priorWord, similarityLimit, this._options.lazyEdit, completionResults);
|
1014
|
+
}
|
1015
|
+
// Add literal values if appropriate.
|
1016
|
+
if (parseNode.nodeType === 0 /* Error */) {
|
1017
|
+
if (parseNode.category === 3 /* MissingIndexOrSlice */ &&
|
1018
|
+
((_c = parseNode.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 24 /* Index */) {
|
1019
|
+
this._tryAddTypedDictStringLiteral(parseNode.parent,
|
1020
|
+
/* priorText */ undefined,
|
1021
|
+
/* postText */ undefined, completionMap);
|
1022
|
+
}
|
1023
|
+
else if (parseNode.category === 2 /* MissingExpression */) {
|
1024
|
+
if (parseNode.parent && parseNode.parent.nodeType === 3 /* Assignment */) {
|
1025
|
+
const declaredTypeOfTarget = (_d = this._evaluator.getExpectedType(parseNode)) === null || _d === void 0 ? void 0 : _d.type;
|
1026
|
+
if (declaredTypeOfTarget) {
|
1027
|
+
this._addLiteralValuesForTargetType(declaredTypeOfTarget, priorText, priorWord, postText, completionMap);
|
1028
|
+
}
|
1029
|
+
}
|
1030
|
+
}
|
1031
|
+
}
|
1032
|
+
if (isIndexArgument) {
|
1033
|
+
// Completion for dict key (ex, dict_variable[<here>])
|
1034
|
+
const indexNode = parseNode.parent.parent;
|
1035
|
+
this._getIndexerKeys(indexNode, parseNode).forEach((key) => {
|
1036
|
+
if (completionMap.has(key)) {
|
1037
|
+
// Don't add key if it already exists in the completion.
|
1038
|
+
// ex) key = "dictKey"
|
1039
|
+
// dict[key] = 1
|
1040
|
+
// print(dict[<key will come from symbol table provider>]))
|
1041
|
+
return;
|
1042
|
+
}
|
1043
|
+
this._addNameToCompletions(key, vscode_languageserver_1.CompletionItemKind.Constant, priorWord, completionMap, {
|
1044
|
+
sortText: this._makeSortText(SortCategory.LiteralValue, key),
|
1045
|
+
itemDetail: exports.dictionaryKeyDetail,
|
1046
|
+
});
|
1047
|
+
});
|
1048
|
+
}
|
1049
|
+
return completionResults;
|
1050
|
+
}
|
1051
|
+
_isIndexArgument(node) {
|
1052
|
+
const currentNode = node.parent;
|
1053
|
+
return (currentNode &&
|
1054
|
+
currentNode.nodeType === 1 /* Argument */ &&
|
1055
|
+
currentNode.argumentCategory === 0 /* Simple */ &&
|
1056
|
+
currentNode.parent &&
|
1057
|
+
currentNode.parent.nodeType === 24 /* Index */ &&
|
1058
|
+
currentNode.parent.baseExpression &&
|
1059
|
+
currentNode.parent.baseExpression.nodeType === 38 /* Name */);
|
1060
|
+
}
|
1061
|
+
_addCallArgumentCompletions(parseNode, priorWord, priorText, postText, atArgument, completionMap) {
|
1062
|
+
// If we're within the argument list of a call, add parameter names.
|
1063
|
+
const offset = (0, positionUtils_1.convertPositionToOffset)(this._position, this._parseResults.tokenizerOutput.lines);
|
1064
|
+
const callInfo = (0, parseTreeUtils_1.getCallNodeAndActiveParameterIndex)(parseNode, offset, this._parseResults.tokenizerOutput.tokens);
|
1065
|
+
if (!callInfo) {
|
1066
|
+
return;
|
1067
|
+
}
|
1068
|
+
const signatureInfo = this._evaluator.getCallSignatureInfo(callInfo.callNode, callInfo.activeIndex, callInfo.activeOrFake);
|
1069
|
+
if (signatureInfo) {
|
1070
|
+
// Are we past the call expression and within the argument list?
|
1071
|
+
const callNameEnd = (0, positionUtils_1.convertOffsetToPosition)(signatureInfo.callNode.leftExpression.start + signatureInfo.callNode.leftExpression.length, this._parseResults.tokenizerOutput.lines);
|
1072
|
+
if ((0, textRange_1.comparePositions)(this._position, callNameEnd) > 0) {
|
1073
|
+
if (!atArgument) {
|
1074
|
+
this._addNamedParameters(signatureInfo, priorWord, completionMap);
|
1075
|
+
}
|
1076
|
+
// Add literals that apply to this parameter.
|
1077
|
+
this._addLiteralValuesForArgument(signatureInfo, priorText, priorWord, postText, completionMap);
|
1078
|
+
}
|
1079
|
+
}
|
1080
|
+
}
|
1081
|
+
_addLiteralValuesForArgument(signatureInfo, priorText, priorWord, postText, completionMap) {
|
1082
|
+
signatureInfo.signatures.forEach((signature) => {
|
1083
|
+
if (!signature.activeParam) {
|
1084
|
+
return undefined;
|
1085
|
+
}
|
1086
|
+
const type = signature.type;
|
1087
|
+
const paramIndex = type.details.parameters.indexOf(signature.activeParam);
|
1088
|
+
if (paramIndex < 0) {
|
1089
|
+
return undefined;
|
1090
|
+
}
|
1091
|
+
const paramType = type.details.parameters[paramIndex].type;
|
1092
|
+
this._addLiteralValuesForTargetType(paramType, priorText, priorWord, postText, completionMap);
|
1093
|
+
return undefined;
|
1094
|
+
});
|
1095
|
+
}
|
1096
|
+
_addLiteralValuesForTargetType(type, priorText, priorWord, postText, completionMap) {
|
1097
|
+
const quoteValue = this._getQuoteInfo(priorText);
|
1098
|
+
this._getSubTypesWithLiteralValues(type).forEach((v) => {
|
1099
|
+
if (types_1.ClassType.isBuiltIn(v, 'str')) {
|
1100
|
+
const value = (0, typePrinter_1.printLiteralValue)(v, quoteValue.quoteCharacter);
|
1101
|
+
if (quoteValue.stringValue === undefined) {
|
1102
|
+
this._addNameToCompletions(value, vscode_languageserver_1.CompletionItemKind.Constant, priorWord, completionMap, {
|
1103
|
+
sortText: this._makeSortText(SortCategory.LiteralValue, v.literalValue),
|
1104
|
+
});
|
1105
|
+
}
|
1106
|
+
else {
|
1107
|
+
this._addStringLiteralToCompletions(value.substr(1, value.length - 2), quoteValue.stringValue, postText, quoteValue.quoteCharacter, completionMap);
|
1108
|
+
}
|
1109
|
+
}
|
1110
|
+
});
|
1111
|
+
}
|
1112
|
+
_getDictExpressionStringKeys(parseNode, excludeIds) {
|
1113
|
+
const node = getDictionaryLikeNode(parseNode);
|
1114
|
+
if (!node) {
|
1115
|
+
return [];
|
1116
|
+
}
|
1117
|
+
return node.entries.flatMap((entry) => {
|
1118
|
+
if (entry.nodeType !== 17 /* DictionaryKeyEntry */ || (excludeIds === null || excludeIds === void 0 ? void 0 : excludeIds.has(entry.keyExpression.id))) {
|
1119
|
+
return [];
|
1120
|
+
}
|
1121
|
+
if (entry.keyExpression.nodeType === 48 /* StringList */) {
|
1122
|
+
return [entry.keyExpression.strings.map((s) => s.value).join('')];
|
1123
|
+
}
|
1124
|
+
return [];
|
1125
|
+
});
|
1126
|
+
function getDictionaryLikeNode(parseNode) {
|
1127
|
+
// this method assumes the given parseNode is either a child of a dictionary or a dictionary itself
|
1128
|
+
if (parseNode.nodeType === 15 /* Dictionary */) {
|
1129
|
+
return parseNode;
|
1130
|
+
}
|
1131
|
+
let curNode = parseNode;
|
1132
|
+
while (curNode && curNode.nodeType !== 15 /* Dictionary */ && curNode.nodeType !== 45 /* Set */) {
|
1133
|
+
curNode = curNode.parent;
|
1134
|
+
if (!curNode) {
|
1135
|
+
return;
|
1136
|
+
}
|
1137
|
+
}
|
1138
|
+
return curNode;
|
1139
|
+
}
|
1140
|
+
}
|
1141
|
+
_getSubTypesWithLiteralValues(type) {
|
1142
|
+
const values = [];
|
1143
|
+
(0, typeUtils_1.doForEachSubtype)(type, (subtype) => {
|
1144
|
+
if ((0, types_1.isClassInstance)(subtype) && (0, typeUtils_1.isLiteralType)(subtype)) {
|
1145
|
+
values.push(subtype);
|
1146
|
+
}
|
1147
|
+
});
|
1148
|
+
return values;
|
1149
|
+
}
|
1150
|
+
_getIndexerKeyType(baseType) {
|
1151
|
+
var _a;
|
1152
|
+
// Handle dict type
|
1153
|
+
if (types_1.ClassType.isBuiltIn(baseType, 'dict') || types_1.ClassType.isBuiltIn(baseType, 'Mapping')) {
|
1154
|
+
if (((_a = baseType.typeArguments) === null || _a === void 0 ? void 0 : _a.length) === 2) {
|
1155
|
+
return baseType.typeArguments[0];
|
1156
|
+
}
|
1157
|
+
}
|
1158
|
+
// Handle simple __getitem__
|
1159
|
+
const member = (0, typeUtils_1.lookUpObjectMember)(baseType, '__getitem__');
|
1160
|
+
if (member === null || member === void 0 ? void 0 : member.symbol.hasDeclarations()) {
|
1161
|
+
const declaration = member.symbol.getDeclarations()[0];
|
1162
|
+
if ((0, declaration_1.isFunctionDeclaration)(declaration) && declaration.isMethod) {
|
1163
|
+
const getItemType = this._evaluator.getTypeForDeclaration(declaration);
|
1164
|
+
if (getItemType && (0, types_1.isFunction)(getItemType) && getItemType.details.parameters.length === 2) {
|
1165
|
+
return getItemType.details.parameters[1].type;
|
1166
|
+
}
|
1167
|
+
}
|
1168
|
+
}
|
1169
|
+
return undefined;
|
1170
|
+
}
|
1171
|
+
_getIndexerKeys(indexNode, invocationNode) {
|
1172
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
1173
|
+
if (indexNode.baseExpression.nodeType !== 38 /* Name */) {
|
1174
|
+
// This completion only supports simple name case
|
1175
|
+
return [];
|
1176
|
+
}
|
1177
|
+
const baseType = this._evaluator.getType(indexNode.baseExpression);
|
1178
|
+
if (!baseType || !(0, types_1.isClassInstance)(baseType)) {
|
1179
|
+
return [];
|
1180
|
+
}
|
1181
|
+
// See whether indexer key is typed using Literal types. If it is, return those literal keys.
|
1182
|
+
const keyType = this._getIndexerKeyType(baseType);
|
1183
|
+
if (keyType) {
|
1184
|
+
const keys = [];
|
1185
|
+
this._getSubTypesWithLiteralValues(keyType).forEach((v) => {
|
1186
|
+
if (!types_1.ClassType.isBuiltIn(v, 'str') &&
|
1187
|
+
!types_1.ClassType.isBuiltIn(v, 'int') &&
|
1188
|
+
!types_1.ClassType.isBuiltIn(v, 'bool') &&
|
1189
|
+
!types_1.ClassType.isBuiltIn(v, 'bytes') &&
|
1190
|
+
!types_1.ClassType.isEnumClass(v)) {
|
1191
|
+
return;
|
1192
|
+
}
|
1193
|
+
keys.push((0, typePrinter_1.printLiteralValue)(v, this._parseResults.tokenizerOutput.predominantSingleQuoteCharacter));
|
1194
|
+
});
|
1195
|
+
if (keys.length > 0) {
|
1196
|
+
return keys;
|
1197
|
+
}
|
1198
|
+
}
|
1199
|
+
// Must be local variable/parameter
|
1200
|
+
const declarations = (_a = this._evaluator.getDeclarationsForNameNode(indexNode.baseExpression)) !== null && _a !== void 0 ? _a : [];
|
1201
|
+
const declaration = declarations.length > 0 ? declarations[0] : undefined;
|
1202
|
+
if (!declaration ||
|
1203
|
+
(declaration.type !== 1 /* Variable */ && declaration.type !== 2 /* Parameter */)) {
|
1204
|
+
return [];
|
1205
|
+
}
|
1206
|
+
if (declaration.path !== this._filePath) {
|
1207
|
+
return [];
|
1208
|
+
}
|
1209
|
+
let startingNode = indexNode.baseExpression;
|
1210
|
+
if (declaration.node) {
|
1211
|
+
const scopeRoot = ParseTreeUtils.getEvaluationScopeNode(declaration.node);
|
1212
|
+
// Find the lowest tree to search the symbol.
|
1213
|
+
if (((_b = ParseTreeUtils.getFileInfoFromNode(startingNode)) === null || _b === void 0 ? void 0 : _b.filePath) ===
|
1214
|
+
((_c = ParseTreeUtils.getFileInfoFromNode(scopeRoot)) === null || _c === void 0 ? void 0 : _c.filePath)) {
|
1215
|
+
startingNode = scopeRoot;
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
const results = documentSymbolCollector_1.DocumentSymbolCollector.collectFromNode(indexNode.baseExpression, this._evaluator, this._cancellationToken, startingNode);
|
1219
|
+
const keys = new Set();
|
1220
|
+
for (const result of results) {
|
1221
|
+
const node = ((_d = result.node.parent) === null || _d === void 0 ? void 0 : _d.nodeType) === 54 /* TypeAnnotation */ ? result.node.parent : result.node;
|
1222
|
+
if (((_e = node.parent) === null || _e === void 0 ? void 0 : _e.nodeType) === 3 /* Assignment */ ||
|
1223
|
+
((_f = node.parent) === null || _f === void 0 ? void 0 : _f.nodeType) === 4 /* AssignmentExpression */) {
|
1224
|
+
if (node.parent.rightExpression.nodeType === 15 /* Dictionary */) {
|
1225
|
+
const dictionary = node.parent.rightExpression;
|
1226
|
+
for (const entry of dictionary.entries.filter((e) => e.nodeType === 17 /* DictionaryKeyEntry */)) {
|
1227
|
+
const key = this._parseResults.text
|
1228
|
+
.substr(entry.keyExpression.start, entry.keyExpression.length)
|
1229
|
+
.trim();
|
1230
|
+
if (key.length > 0)
|
1231
|
+
keys.add(key);
|
1232
|
+
}
|
1233
|
+
}
|
1234
|
+
if (node.parent.rightExpression.nodeType === 9 /* Call */) {
|
1235
|
+
const call = node.parent.rightExpression;
|
1236
|
+
const type = this._evaluator.getType(call.leftExpression);
|
1237
|
+
if (!type || !(0, types_1.isInstantiableClass)(type) || !types_1.ClassType.isBuiltIn(type, 'dict')) {
|
1238
|
+
continue;
|
1239
|
+
}
|
1240
|
+
for (const arg of call.arguments) {
|
1241
|
+
const key = (_h = (_g = arg.name) === null || _g === void 0 ? void 0 : _g.value.trim()) !== null && _h !== void 0 ? _h : '';
|
1242
|
+
const quote = this._parseResults.tokenizerOutput.predominantSingleQuoteCharacter;
|
1243
|
+
if (key.length > 0) {
|
1244
|
+
keys.add(`${quote}${key}${quote}`);
|
1245
|
+
}
|
1246
|
+
}
|
1247
|
+
}
|
1248
|
+
}
|
1249
|
+
if (((_j = node.parent) === null || _j === void 0 ? void 0 : _j.nodeType) === 24 /* Index */ &&
|
1250
|
+
node.parent.items.length === 1 &&
|
1251
|
+
node.parent.items[0].valueExpression.nodeType !== 0 /* Error */ &&
|
1252
|
+
!textRange_2.TextRange.containsRange(node.parent, invocationNode)) {
|
1253
|
+
const indexArgument = node.parent.items[0];
|
1254
|
+
const key = this._parseResults.text
|
1255
|
+
.substr(indexArgument.valueExpression.start, indexArgument.valueExpression.length)
|
1256
|
+
.trim();
|
1257
|
+
if (key.length > 0)
|
1258
|
+
keys.add(key);
|
1259
|
+
}
|
1260
|
+
}
|
1261
|
+
return [...keys];
|
1262
|
+
}
|
1263
|
+
_getLiteralCompletions(parseNode, priorWord, priorText, postText) {
|
1264
|
+
var _a, _b, _c;
|
1265
|
+
let parentNode = parseNode.parent;
|
1266
|
+
if (!parentNode) {
|
1267
|
+
return undefined;
|
1268
|
+
}
|
1269
|
+
const completionMap = new CompletionMap();
|
1270
|
+
// See if the type evaluator can determine the expected type for this node.
|
1271
|
+
if ((0, parseNodes_1.isExpressionNode)(parentNode)) {
|
1272
|
+
const expectedTypeResult = this._evaluator.getExpectedType(parentNode);
|
1273
|
+
if (expectedTypeResult && (0, typeUtils_1.isLiteralTypeOrUnion)(expectedTypeResult.type)) {
|
1274
|
+
this._addLiteralValuesForTargetType(expectedTypeResult.type, priorText, priorWord, postText, completionMap);
|
1275
|
+
return { completionMap };
|
1276
|
+
}
|
1277
|
+
if (parseNode.nodeType === 49 /* String */ && ((_a = parseNode.parent) === null || _a === void 0 ? void 0 : _a.parent)) {
|
1278
|
+
const stringParent = parseNode.parent.parent;
|
1279
|
+
// If the dictionary is not yet filled in, it will appear as though it's
|
1280
|
+
// a set initially.
|
1281
|
+
let dictOrSet;
|
1282
|
+
if (stringParent.nodeType === 17 /* DictionaryKeyEntry */ &&
|
1283
|
+
stringParent.keyExpression === parseNode.parent &&
|
1284
|
+
((_b = stringParent.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 15 /* Dictionary */) {
|
1285
|
+
dictOrSet = stringParent.parent;
|
1286
|
+
}
|
1287
|
+
else if ((stringParent === null || stringParent === void 0 ? void 0 : stringParent.nodeType) === 45 /* Set */) {
|
1288
|
+
dictOrSet = stringParent;
|
1289
|
+
}
|
1290
|
+
if (dictOrSet) {
|
1291
|
+
if (this._addTypedDictKeys(dictOrSet, parseNode, priorText, postText, completionMap)) {
|
1292
|
+
return { completionMap };
|
1293
|
+
}
|
1294
|
+
}
|
1295
|
+
}
|
1296
|
+
}
|
1297
|
+
if (parentNode.nodeType !== 1 /* Argument */) {
|
1298
|
+
if (parentNode.nodeType !== 48 /* StringList */ || parentNode.strings.length > 1) {
|
1299
|
+
return undefined;
|
1300
|
+
}
|
1301
|
+
parentNode = parentNode.parent;
|
1302
|
+
if (!parentNode) {
|
1303
|
+
return undefined;
|
1304
|
+
}
|
1305
|
+
}
|
1306
|
+
if (parentNode.nodeType === 1 /* Argument */ && ((_c = parentNode.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 24 /* Index */) {
|
1307
|
+
const priorTextInString = parseNode.nodeType === 49 /* String */ ? priorText : '';
|
1308
|
+
if (!this._tryAddTypedDictStringLiteral(parentNode.parent, priorTextInString, postText, completionMap)) {
|
1309
|
+
const keys = this._getIndexerKeys(parentNode.parent, parseNode);
|
1310
|
+
const quoteValue = this._getQuoteInfo(priorTextInString);
|
1311
|
+
for (const key of keys) {
|
1312
|
+
const stringLiteral = /^["|'].*["|']$/.test(key);
|
1313
|
+
if (parseNode.nodeType === 49 /* String */ && !stringLiteral) {
|
1314
|
+
continue;
|
1315
|
+
}
|
1316
|
+
if (stringLiteral) {
|
1317
|
+
const keyWithoutQuote = key.substr(1, key.length - 2);
|
1318
|
+
this._addStringLiteralToCompletions(keyWithoutQuote, quoteValue.stringValue, postText, quoteValue.quoteCharacter, completionMap, exports.dictionaryKeyDetail);
|
1319
|
+
}
|
1320
|
+
else {
|
1321
|
+
this._addNameToCompletions(key, vscode_languageserver_1.CompletionItemKind.Constant, priorWord, completionMap, {
|
1322
|
+
sortText: this._makeSortText(SortCategory.LiteralValue, key),
|
1323
|
+
itemDetail: exports.dictionaryKeyDetail,
|
1324
|
+
});
|
1325
|
+
}
|
1326
|
+
}
|
1327
|
+
if (completionMap.size === 0) {
|
1328
|
+
return undefined;
|
1329
|
+
}
|
1330
|
+
}
|
1331
|
+
}
|
1332
|
+
else {
|
1333
|
+
debug.assert(parseNode.nodeType === 49 /* String */);
|
1334
|
+
const offset = (0, positionUtils_1.convertPositionToOffset)(this._position, this._parseResults.tokenizerOutput.lines);
|
1335
|
+
const atArgument = parentNode.start < offset && offset < textRange_2.TextRange.getEnd(parseNode);
|
1336
|
+
this._addCallArgumentCompletions(parseNode, priorWord, priorText, postText, atArgument, completionMap);
|
1337
|
+
}
|
1338
|
+
return { completionMap };
|
1339
|
+
}
|
1340
|
+
_addTypedDictKeys(dictionaryNode, stringNode, priorText, postText, completionMap) {
|
1341
|
+
var _a;
|
1342
|
+
const expectedTypeResult = this._evaluator.getExpectedType(dictionaryNode);
|
1343
|
+
if (!expectedTypeResult) {
|
1344
|
+
return false;
|
1345
|
+
}
|
1346
|
+
// If the expected type result is associated with a node above the
|
1347
|
+
// dictionaryNode in the parse tree, there are no typed dict keys to add.
|
1348
|
+
if (ParseTreeUtils.getNodeDepth(expectedTypeResult.node) < ParseTreeUtils.getNodeDepth(dictionaryNode)) {
|
1349
|
+
return false;
|
1350
|
+
}
|
1351
|
+
let typedDicts = [];
|
1352
|
+
(0, typeUtils_1.doForEachSubtype)(expectedTypeResult.type, (subtype) => {
|
1353
|
+
if ((0, types_1.isClassInstance)(subtype) && types_1.ClassType.isTypedDictClass(subtype)) {
|
1354
|
+
typedDicts.push(subtype);
|
1355
|
+
}
|
1356
|
+
});
|
1357
|
+
if (typedDicts.length === 0) {
|
1358
|
+
return false;
|
1359
|
+
}
|
1360
|
+
const keys = this._getDictExpressionStringKeys(dictionaryNode, stringNode ? new Set([(_a = stringNode.parent) === null || _a === void 0 ? void 0 : _a.id]) : undefined);
|
1361
|
+
typedDicts = this._tryNarrowTypedDicts(typedDicts, keys);
|
1362
|
+
const quoteValue = this._getQuoteInfo(priorText);
|
1363
|
+
const excludes = new Set(keys);
|
1364
|
+
typedDicts.forEach((typedDict) => {
|
1365
|
+
(0, typedDicts_1.getTypedDictMembersForClass)(this._evaluator, typedDict, /* allowNarrowed */ true).forEach((_, key) => {
|
1366
|
+
// Unions of TypedDicts may define the same key.
|
1367
|
+
if (excludes.has(key) || completionMap.has(key)) {
|
1368
|
+
return;
|
1369
|
+
}
|
1370
|
+
excludes.add(key);
|
1371
|
+
this._addStringLiteralToCompletions(key, quoteValue ? quoteValue.stringValue : undefined, postText, quoteValue
|
1372
|
+
? quoteValue.quoteCharacter
|
1373
|
+
: this._parseResults.tokenizerOutput.predominantSingleQuoteCharacter, completionMap);
|
1374
|
+
});
|
1375
|
+
});
|
1376
|
+
return true;
|
1377
|
+
}
|
1378
|
+
_tryNarrowTypedDicts(types, keys) {
|
1379
|
+
const newTypes = types.flatMap((type) => {
|
1380
|
+
const entries = (0, typedDicts_1.getTypedDictMembersForClass)(this._evaluator, type, /* allowNarrowed */ true);
|
1381
|
+
for (let index = 0; index < keys.length; index++) {
|
1382
|
+
if (!entries.has(keys[index])) {
|
1383
|
+
return [];
|
1384
|
+
}
|
1385
|
+
}
|
1386
|
+
return [type];
|
1387
|
+
});
|
1388
|
+
if (newTypes.length === 0) {
|
1389
|
+
// Couldn't narrow to any typed dicts. Just include all.
|
1390
|
+
return types;
|
1391
|
+
}
|
1392
|
+
return newTypes;
|
1393
|
+
}
|
1394
|
+
// Find out quotation and string prefix to use for string literals
|
1395
|
+
// completion under current context.
|
1396
|
+
_getQuoteInfo(priorText) {
|
1397
|
+
let stringValue = undefined;
|
1398
|
+
let quoteCharacter = this._parseResults.tokenizerOutput.predominantSingleQuoteCharacter;
|
1399
|
+
// If completion is not inside of the existing string literal
|
1400
|
+
// ex) typedDict[ |<= here
|
1401
|
+
// use default quotation char without any string prefix.
|
1402
|
+
if (!this._insideStringLiteral) {
|
1403
|
+
return { stringValue, quoteCharacter };
|
1404
|
+
}
|
1405
|
+
const singleQuote = "'";
|
1406
|
+
const doubleQuote = '"';
|
1407
|
+
// If completion is inside of string literal and has prior text
|
1408
|
+
// ex) typedDict["key |<= here
|
1409
|
+
// find quotation user has used (ex, ") and string prefix (ex, key)
|
1410
|
+
if (priorText !== undefined) {
|
1411
|
+
const lastSingleQuote = priorText.lastIndexOf(singleQuote);
|
1412
|
+
const lastDoubleQuote = priorText.lastIndexOf(doubleQuote);
|
1413
|
+
if (lastSingleQuote > lastDoubleQuote) {
|
1414
|
+
stringValue = priorText.substr(lastSingleQuote + 1);
|
1415
|
+
quoteCharacter = singleQuote;
|
1416
|
+
}
|
1417
|
+
else if (lastDoubleQuote > lastSingleQuote) {
|
1418
|
+
stringValue = priorText.substr(lastDoubleQuote + 1);
|
1419
|
+
quoteCharacter = doubleQuote;
|
1420
|
+
}
|
1421
|
+
}
|
1422
|
+
// If the string literal that completion is invoked in is f-string,
|
1423
|
+
// quotation must be the other one than one that is used for f-string.
|
1424
|
+
// ex) f"....{typedDict[|<= here ]}"
|
1425
|
+
// then quotation must be "'"
|
1426
|
+
//
|
1427
|
+
// for f-string, this code path will be only taken when completion is inside
|
1428
|
+
// of f-string segment.
|
1429
|
+
// ex) f"..{|<= here }"
|
1430
|
+
if (this._insideStringLiteral.flags & 64 /* Format */) {
|
1431
|
+
quoteCharacter = this._insideStringLiteral.flags & 1 /* SingleQuote */ ? doubleQuote : singleQuote;
|
1432
|
+
}
|
1433
|
+
return { stringValue, quoteCharacter };
|
1434
|
+
}
|
1435
|
+
_tryAddTypedDictStringLiteral(indexNode, priorText, postText, completionMap) {
|
1436
|
+
if (!indexNode) {
|
1437
|
+
return false;
|
1438
|
+
}
|
1439
|
+
const baseType = this._evaluator.getType(indexNode.baseExpression);
|
1440
|
+
if (!baseType) {
|
1441
|
+
return false;
|
1442
|
+
}
|
1443
|
+
let foundTypedDict = false;
|
1444
|
+
(0, typeUtils_1.doForEachSubtype)(baseType, (subtype) => {
|
1445
|
+
if (!(0, types_1.isClassInstance)(subtype)) {
|
1446
|
+
return;
|
1447
|
+
}
|
1448
|
+
if (!types_1.ClassType.isTypedDictClass(subtype)) {
|
1449
|
+
return;
|
1450
|
+
}
|
1451
|
+
const entries = (0, typedDicts_1.getTypedDictMembersForClass)(this._evaluator, subtype, /* allowNarrowed */ true);
|
1452
|
+
const quoteValue = this._getQuoteInfo(priorText);
|
1453
|
+
entries.forEach((_, key) => {
|
1454
|
+
this._addStringLiteralToCompletions(key, quoteValue.stringValue, postText, quoteValue.quoteCharacter, completionMap);
|
1455
|
+
});
|
1456
|
+
foundTypedDict = true;
|
1457
|
+
});
|
1458
|
+
return foundTypedDict;
|
1459
|
+
}
|
1460
|
+
_addStringLiteralToCompletions(value, priorString, postText, quoteCharacter, completionMap, detail) {
|
1461
|
+
if (StringUtils.isPatternInSymbol(priorString || '', value)) {
|
1462
|
+
const valueWithQuotes = `${quoteCharacter}${value}${quoteCharacter}`;
|
1463
|
+
if (completionMap.has(valueWithQuotes)) {
|
1464
|
+
return;
|
1465
|
+
}
|
1466
|
+
const completionItem = vscode_languageserver_1.CompletionItem.create(valueWithQuotes);
|
1467
|
+
completionItem.kind = vscode_languageserver_1.CompletionItemKind.Constant;
|
1468
|
+
completionItem.sortText = this._makeSortText(SortCategory.LiteralValue, valueWithQuotes);
|
1469
|
+
let rangeStartCol = this._position.character;
|
1470
|
+
if (priorString !== undefined) {
|
1471
|
+
rangeStartCol -= priorString.length + 1;
|
1472
|
+
}
|
1473
|
+
// If the text after the insertion point is the closing quote,
|
1474
|
+
// replace it.
|
1475
|
+
let rangeEndCol = this._position.character;
|
1476
|
+
if (postText !== undefined) {
|
1477
|
+
if (postText.startsWith(quoteCharacter)) {
|
1478
|
+
rangeEndCol++;
|
1479
|
+
}
|
1480
|
+
}
|
1481
|
+
const range = {
|
1482
|
+
start: { line: this._position.line, character: rangeStartCol },
|
1483
|
+
end: { line: this._position.line, character: rangeEndCol },
|
1484
|
+
};
|
1485
|
+
completionItem.textEdit = vscode_languageserver_1.TextEdit.replace(range, valueWithQuotes);
|
1486
|
+
completionItem.detail = detail;
|
1487
|
+
completionMap.set(completionItem);
|
1488
|
+
}
|
1489
|
+
}
|
1490
|
+
_addAutoImportCompletions(priorWord, similarityLimit, lazyEdit, completionResults) {
|
1491
|
+
var _a, _b, _c;
|
1492
|
+
if (!completionResults.completionMap ||
|
1493
|
+
!this._configOptions.autoImportCompletions ||
|
1494
|
+
!this._options.autoImport) {
|
1495
|
+
// If auto import on the server is turned off or this particular invocation
|
1496
|
+
// is turned off (ex, notebook), don't do any thing.
|
1497
|
+
return;
|
1498
|
+
}
|
1499
|
+
const moduleSymbolMap = this._autoImportMaps.getModuleSymbolsMap();
|
1500
|
+
const autoImporter = new autoImporter_1.AutoImporter(this._execEnv, this._importResolver, this._parseResults, this._position, completionResults.completionMap, moduleSymbolMap, { libraryMap: this._autoImportMaps.libraryMap, lazyEdit });
|
1501
|
+
const results = [];
|
1502
|
+
const info = (_a = this._autoImportMaps.nameMap) === null || _a === void 0 ? void 0 : _a.get(priorWord);
|
1503
|
+
if (info && priorWord.length > 1 && !completionResults.completionMap.has(priorWord)) {
|
1504
|
+
(0, collectionUtils_1.appendArray)(results, autoImporter.getAutoImportCandidatesForAbbr(priorWord, info, this._cancellationToken));
|
1505
|
+
}
|
1506
|
+
results.push(...autoImporter.getAutoImportCandidates(priorWord, similarityLimit,
|
1507
|
+
/* abbrFromUsers */ undefined, this._cancellationToken));
|
1508
|
+
const perfInfo = autoImporter.getPerfInfo();
|
1509
|
+
const additionDuration = new timing_1.Duration();
|
1510
|
+
for (const result of results) {
|
1511
|
+
if (result.symbol) {
|
1512
|
+
this._addSymbol(result.name, result.symbol, priorWord, completionResults.completionMap, {
|
1513
|
+
autoImportSource: result.source,
|
1514
|
+
autoImportAlias: result.alias,
|
1515
|
+
edits: {
|
1516
|
+
textEdit: this._createReplaceEdits(priorWord, /* node */ undefined, result.insertionText),
|
1517
|
+
additionalTextEdits: result.edits,
|
1518
|
+
},
|
1519
|
+
});
|
1520
|
+
}
|
1521
|
+
else {
|
1522
|
+
this._addNameToCompletions((_b = result.alias) !== null && _b !== void 0 ? _b : result.name, (_c = result.kind) !== null && _c !== void 0 ? _c : vscode_languageserver_1.CompletionItemKind.Module, priorWord, completionResults.completionMap, {
|
1523
|
+
autoImportText: this._getAutoImportText(result.name, result.source, result.alias),
|
1524
|
+
edits: {
|
1525
|
+
textEdit: this._createReplaceEdits(priorWord, /* node */ undefined, result.insertionText),
|
1526
|
+
additionalTextEdits: result.edits,
|
1527
|
+
},
|
1528
|
+
});
|
1529
|
+
}
|
1530
|
+
}
|
1531
|
+
completionResults.autoImportInfo = {
|
1532
|
+
indexUsed: perfInfo.indexUsed,
|
1533
|
+
totalTimeInMS: perfInfo.totalInMs,
|
1534
|
+
moduleTimeInMS: perfInfo.moduleTimeInMS,
|
1535
|
+
indexTimeInMS: perfInfo.indexTimeInMS,
|
1536
|
+
importAliasTimeInMS: perfInfo.importAliasTimeInMS,
|
1537
|
+
itemCount: results.length,
|
1538
|
+
symbolCount: perfInfo.symbolCount,
|
1539
|
+
indexCount: perfInfo.indexCount,
|
1540
|
+
importAliasCount: perfInfo.importAliasCount,
|
1541
|
+
additionTimeInMS: additionDuration.getDurationInMilliseconds(),
|
1542
|
+
};
|
1543
|
+
}
|
1544
|
+
_getImportFromCompletions(importFromNode, priorWord) {
|
1545
|
+
// Don't attempt to provide completions for "from X import *".
|
1546
|
+
if (importFromNode.isWildcardImport) {
|
1547
|
+
return undefined;
|
1548
|
+
}
|
1549
|
+
// Access the imported module information, which is hanging
|
1550
|
+
// off the ImportFromNode.
|
1551
|
+
const importInfo = AnalyzerNodeInfo.getImportInfo(importFromNode.module);
|
1552
|
+
if (!importInfo) {
|
1553
|
+
return undefined;
|
1554
|
+
}
|
1555
|
+
const completionMap = new CompletionMap();
|
1556
|
+
const resolvedPath = importInfo.resolvedPaths.length > 0 ? importInfo.resolvedPaths[importInfo.resolvedPaths.length - 1] : '';
|
1557
|
+
const lookupResults = this._importLookup(resolvedPath);
|
1558
|
+
if (lookupResults) {
|
1559
|
+
this._addSymbolsForSymbolTable(lookupResults.symbolTable, (symbol, name) => {
|
1560
|
+
// Don't suggest built in symbols or ones that have already been imported.
|
1561
|
+
return (symbol.getDeclarations().some((d) => !(0, declaration_1.isIntrinsicDeclaration)(d)) &&
|
1562
|
+
!importFromNode.imports.find((imp) => imp.name.value === name));
|
1563
|
+
}, priorWord,
|
1564
|
+
/* isInImport */ true,
|
1565
|
+
/* boundObject */ undefined, completionMap);
|
1566
|
+
}
|
1567
|
+
// Add the implicit imports.
|
1568
|
+
importInfo.implicitImports.forEach((implImport) => {
|
1569
|
+
if (!importFromNode.imports.find((imp) => imp.name.value === implImport.name)) {
|
1570
|
+
this._addNameToCompletions(implImport.name, vscode_languageserver_1.CompletionItemKind.Module, priorWord, completionMap);
|
1571
|
+
}
|
1572
|
+
});
|
1573
|
+
return { completionMap };
|
1574
|
+
}
|
1575
|
+
_findMatchingKeywords(keywordList, partialMatch) {
|
1576
|
+
return keywordList.filter((keyword) => {
|
1577
|
+
if (partialMatch) {
|
1578
|
+
return StringUtils.isPatternInSymbol(partialMatch, keyword);
|
1579
|
+
}
|
1580
|
+
else {
|
1581
|
+
return true;
|
1582
|
+
}
|
1583
|
+
});
|
1584
|
+
}
|
1585
|
+
_addNamedParameters(signatureInfo, priorWord, completionMap) {
|
1586
|
+
const argNameMap = new Map();
|
1587
|
+
signatureInfo.signatures.forEach((signature) => {
|
1588
|
+
this._addNamedParametersToMap(signature.type, argNameMap);
|
1589
|
+
});
|
1590
|
+
// Remove any named parameters that are already provided.
|
1591
|
+
signatureInfo.callNode.arguments.forEach((arg) => {
|
1592
|
+
if (arg.name) {
|
1593
|
+
argNameMap.delete(arg.name.value);
|
1594
|
+
}
|
1595
|
+
});
|
1596
|
+
// Add the remaining unique parameter names to the completion list.
|
1597
|
+
argNameMap.forEach((argName) => {
|
1598
|
+
if (StringUtils.isPatternInSymbol(priorWord, argName)) {
|
1599
|
+
const label = argName + '=';
|
1600
|
+
if (completionMap.has(label)) {
|
1601
|
+
return;
|
1602
|
+
}
|
1603
|
+
const completionItem = vscode_languageserver_1.CompletionItem.create(label);
|
1604
|
+
completionItem.kind = vscode_languageserver_1.CompletionItemKind.Variable;
|
1605
|
+
const completionItemData = {
|
1606
|
+
workspacePath: this._workspacePath,
|
1607
|
+
filePath: this._filePath,
|
1608
|
+
position: this._position,
|
1609
|
+
};
|
1610
|
+
completionItem.data = (0, lspUtils_1.toLSPAny)(completionItemData);
|
1611
|
+
completionItem.sortText = this._makeSortText(SortCategory.NamedParameter, argName);
|
1612
|
+
completionItem.filterText = argName;
|
1613
|
+
completionMap.set(completionItem);
|
1614
|
+
}
|
1615
|
+
});
|
1616
|
+
}
|
1617
|
+
_addNamedParametersToMap(type, paramMap) {
|
1618
|
+
type.details.parameters.forEach((param) => {
|
1619
|
+
if (param.name && !param.isNameSynthesized) {
|
1620
|
+
// Don't add private or protected names. These are assumed
|
1621
|
+
// not to be named parameters.
|
1622
|
+
if (!SymbolNameUtils.isPrivateOrProtectedName(param.name)) {
|
1623
|
+
paramMap.set(param.name, param.name);
|
1624
|
+
}
|
1625
|
+
}
|
1626
|
+
});
|
1627
|
+
}
|
1628
|
+
_addSymbols(node, priorWord, completionMap) {
|
1629
|
+
let curNode = node;
|
1630
|
+
while (curNode) {
|
1631
|
+
// Does this node have a scope associated with it?
|
1632
|
+
let scope = (0, scopeUtils_1.getScopeForNode)(curNode);
|
1633
|
+
if (scope) {
|
1634
|
+
while (scope) {
|
1635
|
+
this._addSymbolsForSymbolTable(scope.symbolTable, () => true, priorWord,
|
1636
|
+
/* isInImport */ false,
|
1637
|
+
/* boundObject */ undefined, completionMap);
|
1638
|
+
scope = scope.parent;
|
1639
|
+
}
|
1640
|
+
// If this is a class scope, add symbols from parent classes.
|
1641
|
+
if (curNode.nodeType === 10 /* Class */) {
|
1642
|
+
const classType = this._evaluator.getTypeOfClass(curNode);
|
1643
|
+
if (classType && (0, types_1.isInstantiableClass)(classType.classType)) {
|
1644
|
+
classType.classType.details.mro.forEach((baseClass, index) => {
|
1645
|
+
if ((0, types_1.isInstantiableClass)(baseClass)) {
|
1646
|
+
this._addSymbolsForSymbolTable(baseClass.details.fields, (symbol) => {
|
1647
|
+
if (!symbol.isClassMember()) {
|
1648
|
+
return false;
|
1649
|
+
}
|
1650
|
+
// Return only variables, not methods or classes.
|
1651
|
+
return symbol
|
1652
|
+
.getDeclarations()
|
1653
|
+
.some((decl) => decl.type === 1 /* Variable */);
|
1654
|
+
}, priorWord,
|
1655
|
+
/* isInImport */ false,
|
1656
|
+
/* boundObject */ undefined, completionMap);
|
1657
|
+
}
|
1658
|
+
});
|
1659
|
+
}
|
1660
|
+
}
|
1661
|
+
break;
|
1662
|
+
}
|
1663
|
+
curNode = curNode.parent;
|
1664
|
+
}
|
1665
|
+
}
|
1666
|
+
_addSymbolsForSymbolTable(symbolTable, includeSymbolCallback, priorWord, isInImport, boundObjectOrClass, completionMap) {
|
1667
|
+
symbolTable.forEach((symbol, name) => {
|
1668
|
+
// If there are no declarations or the symbol is not
|
1669
|
+
// exported from this scope, don't include it in the
|
1670
|
+
// suggestion list unless we are in the same file.
|
1671
|
+
const hidden = symbol.isExternallyHidden() &&
|
1672
|
+
!symbol.getDeclarations().some((d) => (0, declarationUtils_1.isDefinedInFile)(d, this._filePath));
|
1673
|
+
if (!hidden && includeSymbolCallback(symbol, name)) {
|
1674
|
+
// Don't add a symbol more than once. It may have already been
|
1675
|
+
// added from an inner scope's symbol table.
|
1676
|
+
if (!completionMap.has(name)) {
|
1677
|
+
this._addSymbol(name, symbol, priorWord, completionMap, {
|
1678
|
+
boundObjectOrClass,
|
1679
|
+
funcParensDisabled: isInImport,
|
1680
|
+
});
|
1681
|
+
}
|
1682
|
+
}
|
1683
|
+
});
|
1684
|
+
}
|
1685
|
+
_addSymbol(name, symbol, priorWord, completionMap, detail) {
|
1686
|
+
var _a, _b, _c;
|
1687
|
+
// If the symbol is a py.typed import that is not supposed to be re-exported,
|
1688
|
+
// don't offer it as a completion suggestion.
|
1689
|
+
if (symbol.isPrivatePyTypedImport()) {
|
1690
|
+
return;
|
1691
|
+
}
|
1692
|
+
let primaryDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(symbol);
|
1693
|
+
if (!primaryDecl) {
|
1694
|
+
const declarations = symbol.getDeclarations();
|
1695
|
+
if (declarations.length > 0) {
|
1696
|
+
primaryDecl = declarations[declarations.length - 1];
|
1697
|
+
}
|
1698
|
+
}
|
1699
|
+
if (primaryDecl) {
|
1700
|
+
let itemKind = vscode_languageserver_1.CompletionItemKind.Variable;
|
1701
|
+
primaryDecl = this._evaluator.resolveAliasDeclaration(primaryDecl, /* resolveLocalNames */ true);
|
1702
|
+
if (primaryDecl) {
|
1703
|
+
itemKind = this._convertDeclarationTypeToItemKind(primaryDecl);
|
1704
|
+
// Handle enum members specially. Enum members normally look like
|
1705
|
+
// variables, but the are declared using assignment expressions
|
1706
|
+
// within an enum class.
|
1707
|
+
if (primaryDecl.type === 1 /* Variable */ &&
|
1708
|
+
detail.boundObjectOrClass &&
|
1709
|
+
(0, types_1.isInstantiableClass)(detail.boundObjectOrClass) &&
|
1710
|
+
types_1.ClassType.isEnumClass(detail.boundObjectOrClass) &&
|
1711
|
+
((_a = primaryDecl.node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* Assignment */) {
|
1712
|
+
itemKind = vscode_languageserver_1.CompletionItemKind.EnumMember;
|
1713
|
+
}
|
1714
|
+
// Are we resolving a completion item? If so, see if this symbol
|
1715
|
+
// is the one that we're trying to match.
|
1716
|
+
if (this._itemToResolve) {
|
1717
|
+
const completionItemData = (0, lspUtils_1.fromLSPAny)(this._itemToResolve.data);
|
1718
|
+
if (completionItemData.symbolLabel === name && !completionItemData.autoImportText) {
|
1719
|
+
// This call can be expensive to perform on every completion item
|
1720
|
+
// that we return, so we do it lazily in the "resolve" callback.
|
1721
|
+
const type = this._evaluator.getEffectiveTypeOfSymbol(symbol);
|
1722
|
+
if (type) {
|
1723
|
+
let typeDetail;
|
1724
|
+
let documentation;
|
1725
|
+
switch (primaryDecl.type) {
|
1726
|
+
case 0 /* Intrinsic */:
|
1727
|
+
case 1 /* Variable */:
|
1728
|
+
case 2 /* Parameter */: {
|
1729
|
+
let expandTypeAlias = false;
|
1730
|
+
if (type && types_1.TypeBase.isInstantiable(type)) {
|
1731
|
+
const typeAliasInfo = (0, types_1.getTypeAliasInfo)(type);
|
1732
|
+
if (typeAliasInfo) {
|
1733
|
+
if (typeAliasInfo.name === name) {
|
1734
|
+
expandTypeAlias = true;
|
1735
|
+
}
|
1736
|
+
}
|
1737
|
+
}
|
1738
|
+
typeDetail = name + ': ' + this._evaluator.printType(type, expandTypeAlias);
|
1739
|
+
break;
|
1740
|
+
}
|
1741
|
+
case 3 /* Function */: {
|
1742
|
+
const functionType = detail.boundObjectOrClass && ((0, types_1.isFunction)(type) || (0, types_1.isOverloadedFunction)(type))
|
1743
|
+
? this._evaluator.bindFunctionToClassOrObject(detail.boundObjectOrClass, type)
|
1744
|
+
: type;
|
1745
|
+
if (functionType) {
|
1746
|
+
if ((0, typeUtils_1.isProperty)(functionType) &&
|
1747
|
+
detail.boundObjectOrClass &&
|
1748
|
+
(0, types_1.isClassInstance)(detail.boundObjectOrClass)) {
|
1749
|
+
const propertyType = this._evaluator.getGetterTypeFromProperty(functionType,
|
1750
|
+
/* inferTypeIfNeeded */ true) || types_1.UnknownType.create();
|
1751
|
+
typeDetail =
|
1752
|
+
name +
|
1753
|
+
': ' +
|
1754
|
+
this._evaluator.printType(propertyType, /* expandTypeAlias */ false) +
|
1755
|
+
' (property)';
|
1756
|
+
}
|
1757
|
+
else if ((0, types_1.isOverloadedFunction)(functionType)) {
|
1758
|
+
// 35 is completion tooltip's default width size
|
1759
|
+
typeDetail = (0, tooltipUtils_1.getOverloadedFunctionTooltip)(functionType, this._evaluator,
|
1760
|
+
/* columnThreshold */ 35);
|
1761
|
+
}
|
1762
|
+
else {
|
1763
|
+
typeDetail =
|
1764
|
+
name +
|
1765
|
+
': ' +
|
1766
|
+
this._evaluator.printType(functionType, /* expandTypeAlias */ false);
|
1767
|
+
}
|
1768
|
+
}
|
1769
|
+
break;
|
1770
|
+
}
|
1771
|
+
case 4 /* Class */:
|
1772
|
+
case 5 /* SpecialBuiltInClass */: {
|
1773
|
+
typeDetail = 'class ' + name + '()';
|
1774
|
+
break;
|
1775
|
+
}
|
1776
|
+
case 6 /* Alias */: {
|
1777
|
+
typeDetail = name;
|
1778
|
+
if (primaryDecl.path) {
|
1779
|
+
const lookupResults = this._importLookup(primaryDecl.path);
|
1780
|
+
if (lookupResults) {
|
1781
|
+
documentation = lookupResults.docString;
|
1782
|
+
}
|
1783
|
+
}
|
1784
|
+
break;
|
1785
|
+
}
|
1786
|
+
default: {
|
1787
|
+
typeDetail = name;
|
1788
|
+
break;
|
1789
|
+
}
|
1790
|
+
}
|
1791
|
+
if (primaryDecl.type === 1 /* Variable */ &&
|
1792
|
+
primaryDecl.typeAliasName &&
|
1793
|
+
primaryDecl.docString) {
|
1794
|
+
documentation = primaryDecl.docString;
|
1795
|
+
}
|
1796
|
+
else if ((0, types_1.isModule)(type)) {
|
1797
|
+
documentation = (0, typeDocStringUtils_1.getModuleDocString)(type, primaryDecl, this._sourceMapper);
|
1798
|
+
}
|
1799
|
+
else if ((0, types_1.isInstantiableClass)(type)) {
|
1800
|
+
documentation = (0, typeDocStringUtils_1.getClassDocString)(type, primaryDecl, this._sourceMapper);
|
1801
|
+
}
|
1802
|
+
else if ((0, types_1.isFunction)(type)) {
|
1803
|
+
const functionType = detail.boundObjectOrClass
|
1804
|
+
? this._evaluator.bindFunctionToClassOrObject(detail.boundObjectOrClass, type)
|
1805
|
+
: type;
|
1806
|
+
if (functionType && (0, types_1.isFunction)(functionType)) {
|
1807
|
+
documentation = (0, tooltipUtils_1.getFunctionDocStringFromType)(functionType, this._sourceMapper, this._evaluator);
|
1808
|
+
}
|
1809
|
+
}
|
1810
|
+
else if ((0, types_1.isOverloadedFunction)(type)) {
|
1811
|
+
const functionType = detail.boundObjectOrClass
|
1812
|
+
? this._evaluator.bindFunctionToClassOrObject(detail.boundObjectOrClass, type)
|
1813
|
+
: type;
|
1814
|
+
if (functionType && (0, types_1.isOverloadedFunction)(functionType)) {
|
1815
|
+
documentation = (0, tooltipUtils_1.getOverloadedFunctionDocStringsFromType)(functionType, this._sourceMapper, this._evaluator).find((doc) => doc);
|
1816
|
+
}
|
1817
|
+
}
|
1818
|
+
else if ((primaryDecl === null || primaryDecl === void 0 ? void 0 : primaryDecl.type) === 3 /* Function */) {
|
1819
|
+
// @property functions
|
1820
|
+
documentation = (0, typeDocStringUtils_1.getPropertyDocStringInherited)(primaryDecl, this._sourceMapper, this._evaluator);
|
1821
|
+
}
|
1822
|
+
else if ((primaryDecl === null || primaryDecl === void 0 ? void 0 : primaryDecl.type) === 1 /* Variable */) {
|
1823
|
+
const decl = ((_b = symbol
|
1824
|
+
.getDeclarations()
|
1825
|
+
.find((d) => d.type === 1 /* Variable */ && !!d.docString)) !== null && _b !== void 0 ? _b : primaryDecl);
|
1826
|
+
documentation = (0, typeDocStringUtils_1.getVariableDocString)(decl, this._sourceMapper);
|
1827
|
+
}
|
1828
|
+
if (this._options.format === vscode_languageserver_1.MarkupKind.Markdown) {
|
1829
|
+
let markdownString = '```python\n' + typeDetail + '\n```\n';
|
1830
|
+
if (documentation) {
|
1831
|
+
markdownString += '---\n';
|
1832
|
+
markdownString += (0, docStringConversion_1.convertDocStringToMarkdown)(documentation);
|
1833
|
+
}
|
1834
|
+
markdownString = markdownString.trimEnd();
|
1835
|
+
this._itemToResolve.documentation = {
|
1836
|
+
kind: vscode_languageserver_1.MarkupKind.Markdown,
|
1837
|
+
value: markdownString,
|
1838
|
+
};
|
1839
|
+
}
|
1840
|
+
else if (this._options.format === vscode_languageserver_1.MarkupKind.PlainText) {
|
1841
|
+
let plainTextString = typeDetail + '\n';
|
1842
|
+
if (documentation) {
|
1843
|
+
plainTextString += '\n';
|
1844
|
+
plainTextString += (0, docStringConversion_1.convertDocStringToPlainText)(documentation);
|
1845
|
+
}
|
1846
|
+
plainTextString = plainTextString.trimEnd();
|
1847
|
+
this._itemToResolve.documentation = {
|
1848
|
+
kind: vscode_languageserver_1.MarkupKind.PlainText,
|
1849
|
+
value: plainTextString,
|
1850
|
+
};
|
1851
|
+
}
|
1852
|
+
else {
|
1853
|
+
(0, debug_1.fail)(`Unsupported markup type: ${this._options.format}`);
|
1854
|
+
}
|
1855
|
+
}
|
1856
|
+
}
|
1857
|
+
}
|
1858
|
+
}
|
1859
|
+
const autoImportText = detail.autoImportSource
|
1860
|
+
? this._getAutoImportText(name, detail.autoImportSource, detail.autoImportAlias)
|
1861
|
+
: undefined;
|
1862
|
+
this._addNameToCompletions((_c = detail.autoImportAlias) !== null && _c !== void 0 ? _c : name, itemKind, priorWord, completionMap, {
|
1863
|
+
autoImportText,
|
1864
|
+
funcParensDisabled: detail.funcParensDisabled,
|
1865
|
+
edits: detail.edits,
|
1866
|
+
});
|
1867
|
+
}
|
1868
|
+
else {
|
1869
|
+
// Does the symbol have no declaration but instead has a synthesized type?
|
1870
|
+
const synthesizedType = symbol.getSynthesizedType();
|
1871
|
+
if (synthesizedType) {
|
1872
|
+
const itemKind = vscode_languageserver_1.CompletionItemKind.Variable;
|
1873
|
+
this._addNameToCompletions(name, itemKind, priorWord, completionMap, {
|
1874
|
+
funcParensDisabled: detail.funcParensDisabled,
|
1875
|
+
edits: detail.edits,
|
1876
|
+
});
|
1877
|
+
}
|
1878
|
+
}
|
1879
|
+
}
|
1880
|
+
_getAutoImportText(importName, importFrom, importAlias) {
|
1881
|
+
const autoImportText = (0, tooltipUtils_1.getAutoImportText)(importName, importFrom, importAlias);
|
1882
|
+
let importText = '';
|
1883
|
+
if (this._options.format === vscode_languageserver_1.MarkupKind.Markdown) {
|
1884
|
+
importText = `\`\`\`\n${autoImportText}\n\`\`\``;
|
1885
|
+
}
|
1886
|
+
else if (this._options.format === vscode_languageserver_1.MarkupKind.PlainText) {
|
1887
|
+
importText = autoImportText;
|
1888
|
+
}
|
1889
|
+
else {
|
1890
|
+
(0, debug_1.fail)(`Unsupported markup type: ${this._options.format}`);
|
1891
|
+
}
|
1892
|
+
return {
|
1893
|
+
source: importFrom !== null && importFrom !== void 0 ? importFrom : '',
|
1894
|
+
importText,
|
1895
|
+
};
|
1896
|
+
}
|
1897
|
+
_addNameToCompletions(name, itemKind, filter, completionMap, detail) {
|
1898
|
+
var _a, _b, _c, _d;
|
1899
|
+
// Auto importer already filtered out unnecessary ones. No need to do it again.
|
1900
|
+
const similarity = (detail === null || detail === void 0 ? void 0 : detail.autoImportText) ? true : StringUtils.isPatternInSymbol(filter, name);
|
1901
|
+
if (!similarity) {
|
1902
|
+
return;
|
1903
|
+
}
|
1904
|
+
if (completionMap.has(name, CompletionMap.matchKindAndImportText, itemKind, (_a = detail === null || detail === void 0 ? void 0 : detail.autoImportText) === null || _a === void 0 ? void 0 : _a.importText)) {
|
1905
|
+
return;
|
1906
|
+
}
|
1907
|
+
const completionItem = vscode_languageserver_1.CompletionItem.create(name);
|
1908
|
+
completionItem.kind = itemKind;
|
1909
|
+
const completionItemData = {
|
1910
|
+
workspacePath: this._workspacePath,
|
1911
|
+
filePath: this._filePath,
|
1912
|
+
position: this._position,
|
1913
|
+
};
|
1914
|
+
if (detail === null || detail === void 0 ? void 0 : detail.funcParensDisabled) {
|
1915
|
+
completionItemData.funcParensDisabled = true;
|
1916
|
+
}
|
1917
|
+
completionItem.data = (0, lspUtils_1.toLSPAny)(completionItemData);
|
1918
|
+
if ((detail === null || detail === void 0 ? void 0 : detail.sortText) || (detail === null || detail === void 0 ? void 0 : detail.itemDetail)) {
|
1919
|
+
completionItem.sortText = detail.sortText;
|
1920
|
+
completionItem.detail = detail.itemDetail;
|
1921
|
+
}
|
1922
|
+
else if (detail === null || detail === void 0 ? void 0 : detail.autoImportText) {
|
1923
|
+
// Force auto-import entries to the end.
|
1924
|
+
completionItem.sortText = this._makeSortText(SortCategory.AutoImport, name, detail.autoImportText.importText);
|
1925
|
+
completionItemData.autoImportText = detail.autoImportText.importText;
|
1926
|
+
completionItem.detail = exports.autoImportDetail;
|
1927
|
+
if (detail.autoImportText.source) {
|
1928
|
+
completionItem.labelDetails = { description: detail.autoImportText.source };
|
1929
|
+
}
|
1930
|
+
}
|
1931
|
+
else if (itemKind === vscode_languageserver_1.CompletionItemKind.EnumMember) {
|
1932
|
+
// Handle enum members separately so they are sorted above other symbols.
|
1933
|
+
completionItem.sortText = this._makeSortText(SortCategory.EnumMember, name);
|
1934
|
+
}
|
1935
|
+
else if (SymbolNameUtils.isDunderName(name)) {
|
1936
|
+
// Force dunder-named symbols to appear after all other symbols.
|
1937
|
+
completionItem.sortText = this._makeSortText(SortCategory.DunderSymbol, name);
|
1938
|
+
}
|
1939
|
+
else if (filter === '' && SymbolNameUtils.isPrivateOrProtectedName(name)) {
|
1940
|
+
// Distinguish between normal and private symbols only if there is
|
1941
|
+
// currently no filter text. Once we get a single character to filter
|
1942
|
+
// upon, we'll no longer differentiate.
|
1943
|
+
completionItem.sortText = this._makeSortText(SortCategory.PrivateSymbol, name);
|
1944
|
+
}
|
1945
|
+
else {
|
1946
|
+
completionItem.sortText = this._makeSortText(SortCategory.NormalSymbol, name);
|
1947
|
+
}
|
1948
|
+
completionItemData.symbolLabel = name;
|
1949
|
+
if (this._options.format === vscode_languageserver_1.MarkupKind.Markdown) {
|
1950
|
+
let markdownString = '';
|
1951
|
+
if (detail === null || detail === void 0 ? void 0 : detail.autoImportText) {
|
1952
|
+
markdownString += detail.autoImportText.importText;
|
1953
|
+
if (detail.typeDetail || detail.documentation) {
|
1954
|
+
// Micro perf optimization to not create new string from trimEnd.
|
1955
|
+
markdownString += '\n\n';
|
1956
|
+
}
|
1957
|
+
}
|
1958
|
+
if (detail === null || detail === void 0 ? void 0 : detail.typeDetail) {
|
1959
|
+
markdownString += '```python\n' + detail.typeDetail + '\n```\n';
|
1960
|
+
}
|
1961
|
+
if (detail === null || detail === void 0 ? void 0 : detail.documentation) {
|
1962
|
+
markdownString += '---\n';
|
1963
|
+
markdownString += (0, docStringConversion_1.convertDocStringToMarkdown)(detail.documentation);
|
1964
|
+
}
|
1965
|
+
markdownString = markdownString.trimEnd();
|
1966
|
+
if (markdownString) {
|
1967
|
+
completionItem.documentation = {
|
1968
|
+
kind: vscode_languageserver_1.MarkupKind.Markdown,
|
1969
|
+
value: markdownString,
|
1970
|
+
};
|
1971
|
+
}
|
1972
|
+
}
|
1973
|
+
else if (this._options.format === vscode_languageserver_1.MarkupKind.PlainText) {
|
1974
|
+
let plainTextString = '';
|
1975
|
+
if (detail === null || detail === void 0 ? void 0 : detail.autoImportText) {
|
1976
|
+
plainTextString += detail.autoImportText.importText;
|
1977
|
+
if (detail.typeDetail || detail.documentation) {
|
1978
|
+
// Micro perf optimization to not create new string from trimEnd.
|
1979
|
+
plainTextString += '\n\n';
|
1980
|
+
}
|
1981
|
+
}
|
1982
|
+
if (detail === null || detail === void 0 ? void 0 : detail.typeDetail) {
|
1983
|
+
plainTextString += detail.typeDetail + '\n';
|
1984
|
+
}
|
1985
|
+
if (detail === null || detail === void 0 ? void 0 : detail.documentation) {
|
1986
|
+
plainTextString += '\n' + (0, docStringConversion_1.convertDocStringToPlainText)(detail.documentation);
|
1987
|
+
}
|
1988
|
+
plainTextString = plainTextString.trimEnd();
|
1989
|
+
if (plainTextString) {
|
1990
|
+
completionItem.documentation = {
|
1991
|
+
kind: vscode_languageserver_1.MarkupKind.PlainText,
|
1992
|
+
value: plainTextString,
|
1993
|
+
};
|
1994
|
+
}
|
1995
|
+
}
|
1996
|
+
else {
|
1997
|
+
(0, debug_1.fail)(`Unsupported markup type: ${this._options.format}`);
|
1998
|
+
}
|
1999
|
+
if ((_b = detail === null || detail === void 0 ? void 0 : detail.edits) === null || _b === void 0 ? void 0 : _b.format) {
|
2000
|
+
completionItem.insertTextFormat = detail.edits.format;
|
2001
|
+
}
|
2002
|
+
if ((_c = detail === null || detail === void 0 ? void 0 : detail.edits) === null || _c === void 0 ? void 0 : _c.textEdit) {
|
2003
|
+
completionItem.textEdit = detail.edits.textEdit;
|
2004
|
+
}
|
2005
|
+
if ((_d = detail === null || detail === void 0 ? void 0 : detail.edits) === null || _d === void 0 ? void 0 : _d.additionalTextEdits) {
|
2006
|
+
completionItem.additionalTextEdits = detail.edits.additionalTextEdits.map((te) => {
|
2007
|
+
const textEdit = {
|
2008
|
+
range: {
|
2009
|
+
start: { line: te.range.start.line, character: te.range.start.character },
|
2010
|
+
end: { line: te.range.end.line, character: te.range.end.character },
|
2011
|
+
},
|
2012
|
+
newText: te.replacementText,
|
2013
|
+
};
|
2014
|
+
return textEdit;
|
2015
|
+
});
|
2016
|
+
if (this._itemToResolve) {
|
2017
|
+
const data = (0, lspUtils_1.fromLSPAny)(this._itemToResolve.data);
|
2018
|
+
if (data.autoImportText === completionItemData.autoImportText) {
|
2019
|
+
this._itemToResolve.additionalTextEdits = completionItem.additionalTextEdits;
|
2020
|
+
}
|
2021
|
+
}
|
2022
|
+
}
|
2023
|
+
completionMap.set(completionItem);
|
2024
|
+
}
|
2025
|
+
_getRecentListIndex(name, autoImportText) {
|
2026
|
+
return CompletionProvider._mostRecentCompletions.findIndex((item) => item.label === name && item.autoImportText === autoImportText);
|
2027
|
+
}
|
2028
|
+
_makeSortText(sortCategory, name, autoImportText = '') {
|
2029
|
+
const recentListIndex = this._getRecentListIndex(name, autoImportText);
|
2030
|
+
// If the label is in the recent list, modify the category
|
2031
|
+
// so it appears higher in our list.
|
2032
|
+
if (recentListIndex >= 0) {
|
2033
|
+
if (sortCategory === SortCategory.AutoImport) {
|
2034
|
+
sortCategory = SortCategory.RecentAutoImport;
|
2035
|
+
}
|
2036
|
+
else if (sortCategory === SortCategory.ImportModuleName) {
|
2037
|
+
sortCategory = SortCategory.RecentImportModuleName;
|
2038
|
+
}
|
2039
|
+
else if (sortCategory === SortCategory.Keyword ||
|
2040
|
+
sortCategory === SortCategory.NormalSymbol ||
|
2041
|
+
sortCategory === SortCategory.PrivateSymbol ||
|
2042
|
+
sortCategory === SortCategory.DunderSymbol) {
|
2043
|
+
sortCategory = SortCategory.RecentKeywordOrSymbol;
|
2044
|
+
}
|
2045
|
+
}
|
2046
|
+
// Generate a sort string of the format
|
2047
|
+
// XX.YYYY.name
|
2048
|
+
// where XX is the sort category
|
2049
|
+
// and YYYY is the index of the item in the MRU list
|
2050
|
+
return this._formatInteger(sortCategory, 2) + '.' + this._formatInteger(recentListIndex, 4) + '.' + name;
|
2051
|
+
}
|
2052
|
+
_formatInteger(val, digits) {
|
2053
|
+
const charCodeZero = '0'.charCodeAt(0);
|
2054
|
+
let result = '';
|
2055
|
+
for (let i = 0; i < digits; i++) {
|
2056
|
+
// Prepend the next digit.
|
2057
|
+
let digit = Math.floor(val % 10);
|
2058
|
+
if (digit < 0) {
|
2059
|
+
digit = 9;
|
2060
|
+
}
|
2061
|
+
result = String.fromCharCode(digit + charCodeZero) + result;
|
2062
|
+
val = Math.floor(val / 10);
|
2063
|
+
}
|
2064
|
+
return result;
|
2065
|
+
}
|
2066
|
+
_convertDeclarationTypeToItemKind(declaration) {
|
2067
|
+
const resolvedDeclaration = this._evaluator.resolveAliasDeclaration(declaration, /* resolveLocalNames */ true);
|
2068
|
+
if (!resolvedDeclaration) {
|
2069
|
+
return vscode_languageserver_1.CompletionItemKind.Variable;
|
2070
|
+
}
|
2071
|
+
switch (resolvedDeclaration.type) {
|
2072
|
+
case 0 /* Intrinsic */:
|
2073
|
+
return resolvedDeclaration.intrinsicType === 'class'
|
2074
|
+
? vscode_languageserver_1.CompletionItemKind.Class
|
2075
|
+
: vscode_languageserver_1.CompletionItemKind.Variable;
|
2076
|
+
case 2 /* Parameter */:
|
2077
|
+
return vscode_languageserver_1.CompletionItemKind.Variable;
|
2078
|
+
case 1 /* Variable */:
|
2079
|
+
return resolvedDeclaration.isConstant || resolvedDeclaration.isFinal
|
2080
|
+
? vscode_languageserver_1.CompletionItemKind.Constant
|
2081
|
+
: vscode_languageserver_1.CompletionItemKind.Variable;
|
2082
|
+
case 3 /* Function */: {
|
2083
|
+
if (this._isPossiblePropertyDeclaration(resolvedDeclaration)) {
|
2084
|
+
const functionType = this._evaluator.getTypeOfFunction(resolvedDeclaration.node);
|
2085
|
+
if (functionType && (0, typeUtils_1.isProperty)(functionType.decoratedType)) {
|
2086
|
+
return vscode_languageserver_1.CompletionItemKind.Property;
|
2087
|
+
}
|
2088
|
+
}
|
2089
|
+
return resolvedDeclaration.isMethod ? vscode_languageserver_1.CompletionItemKind.Method : vscode_languageserver_1.CompletionItemKind.Function;
|
2090
|
+
}
|
2091
|
+
case 4 /* Class */:
|
2092
|
+
case 5 /* SpecialBuiltInClass */:
|
2093
|
+
return vscode_languageserver_1.CompletionItemKind.Class;
|
2094
|
+
case 6 /* Alias */:
|
2095
|
+
return vscode_languageserver_1.CompletionItemKind.Module;
|
2096
|
+
}
|
2097
|
+
}
|
2098
|
+
_getImportModuleCompletions(node) {
|
2099
|
+
const moduleDescriptor = {
|
2100
|
+
leadingDots: node.leadingDots,
|
2101
|
+
hasTrailingDot: node.hasTrailingDot || false,
|
2102
|
+
nameParts: node.nameParts.map((part) => part.value),
|
2103
|
+
importedSymbols: [],
|
2104
|
+
};
|
2105
|
+
const completions = this._importResolver.getCompletionSuggestions(this._filePath, this._execEnv, moduleDescriptor);
|
2106
|
+
const completionMap = new CompletionMap();
|
2107
|
+
// If we're in the middle of a "from X import Y" statement, offer
|
2108
|
+
// the "import" keyword as a completion.
|
2109
|
+
if (!node.hasTrailingDot &&
|
2110
|
+
node.parent &&
|
2111
|
+
node.parent.nodeType === 22 /* ImportFrom */ &&
|
2112
|
+
node.parent.missingImportKeyword) {
|
2113
|
+
const keyword = 'import';
|
2114
|
+
const completionItem = vscode_languageserver_1.CompletionItem.create(keyword);
|
2115
|
+
completionItem.kind = vscode_languageserver_1.CompletionItemKind.Keyword;
|
2116
|
+
completionItem.sortText = this._makeSortText(SortCategory.Keyword, keyword);
|
2117
|
+
completionMap.set(completionItem);
|
2118
|
+
}
|
2119
|
+
completions.forEach((completionName) => {
|
2120
|
+
if (completionMap.has(completionName)) {
|
2121
|
+
return;
|
2122
|
+
}
|
2123
|
+
const completionItem = vscode_languageserver_1.CompletionItem.create(completionName);
|
2124
|
+
completionItem.kind = vscode_languageserver_1.CompletionItemKind.Module;
|
2125
|
+
completionItem.sortText = this._makeSortText(SortCategory.ImportModuleName, completionName);
|
2126
|
+
completionMap.set(completionItem);
|
2127
|
+
});
|
2128
|
+
return { completionMap };
|
2129
|
+
}
|
2130
|
+
_isPossiblePropertyDeclaration(decl) {
|
2131
|
+
// Do cheap check using only nodes that will cover 99.9% cases
|
2132
|
+
// before doing more expensive type evaluation.
|
2133
|
+
return decl.isMethod && decl.node.decorators.length > 0;
|
2134
|
+
}
|
2135
|
+
}
|
2136
|
+
exports.CompletionProvider = CompletionProvider;
|
2137
|
+
CompletionProvider._mostRecentCompletions = [];
|
2138
|
+
class CompletionMap {
|
2139
|
+
constructor() {
|
2140
|
+
this._completions = new Map();
|
2141
|
+
}
|
2142
|
+
get size() {
|
2143
|
+
return this._completions.size;
|
2144
|
+
}
|
2145
|
+
set(value) {
|
2146
|
+
const existing = this._completions.get(value.label);
|
2147
|
+
if (!existing) {
|
2148
|
+
this._completions.set(value.label, value);
|
2149
|
+
}
|
2150
|
+
else if (Array.isArray(existing)) {
|
2151
|
+
existing.push(value);
|
2152
|
+
}
|
2153
|
+
else {
|
2154
|
+
this._completions.set(value.label, [existing, value]);
|
2155
|
+
}
|
2156
|
+
}
|
2157
|
+
get(key) {
|
2158
|
+
return this._completions.get(key);
|
2159
|
+
}
|
2160
|
+
has(label, predicate, kind, autImportText) {
|
2161
|
+
const existing = this._completions.get(label);
|
2162
|
+
if (!existing) {
|
2163
|
+
return false;
|
2164
|
+
}
|
2165
|
+
if (predicate) {
|
2166
|
+
return predicate(existing, kind, autImportText);
|
2167
|
+
}
|
2168
|
+
return true;
|
2169
|
+
}
|
2170
|
+
clear() {
|
2171
|
+
this._completions.clear();
|
2172
|
+
}
|
2173
|
+
delete(key) {
|
2174
|
+
return this._completions.delete(key);
|
2175
|
+
}
|
2176
|
+
toArray() {
|
2177
|
+
var _a;
|
2178
|
+
const items = [];
|
2179
|
+
(_a = this._completions) === null || _a === void 0 ? void 0 : _a.forEach((value) => {
|
2180
|
+
if (Array.isArray(value)) {
|
2181
|
+
value.forEach((item) => {
|
2182
|
+
items.push(item);
|
2183
|
+
});
|
2184
|
+
}
|
2185
|
+
else {
|
2186
|
+
items.push(value);
|
2187
|
+
}
|
2188
|
+
});
|
2189
|
+
return items;
|
2190
|
+
}
|
2191
|
+
static matchKindAndImportText(completionItemOrItems, kind, autoImportText) {
|
2192
|
+
var _a;
|
2193
|
+
if (!Array.isArray(completionItemOrItems)) {
|
2194
|
+
return (completionItemOrItems.kind === kind &&
|
2195
|
+
((_a = _getCompletionData(completionItemOrItems)) === null || _a === void 0 ? void 0 : _a.autoImportText) === autoImportText);
|
2196
|
+
}
|
2197
|
+
else {
|
2198
|
+
return !!completionItemOrItems.find((c) => { var _a; return c.kind === kind && ((_a = _getCompletionData(c)) === null || _a === void 0 ? void 0 : _a.autoImportText) === autoImportText; });
|
2199
|
+
}
|
2200
|
+
}
|
2201
|
+
static labelOnlyIgnoringAutoImports(completionItemOrItems) {
|
2202
|
+
var _a;
|
2203
|
+
if (!Array.isArray(completionItemOrItems)) {
|
2204
|
+
if (!((_a = _getCompletionData(completionItemOrItems)) === null || _a === void 0 ? void 0 : _a.autoImportText)) {
|
2205
|
+
return true;
|
2206
|
+
}
|
2207
|
+
}
|
2208
|
+
else {
|
2209
|
+
if (completionItemOrItems.find((c) => { var _a; return !((_a = _getCompletionData(c)) === null || _a === void 0 ? void 0 : _a.autoImportText); })) {
|
2210
|
+
return true;
|
2211
|
+
}
|
2212
|
+
}
|
2213
|
+
return false;
|
2214
|
+
}
|
2215
|
+
}
|
2216
|
+
exports.CompletionMap = CompletionMap;
|
2217
|
+
function _getCompletionData(completionItem) {
|
2218
|
+
return (0, lspUtils_1.fromLSPAny)(completionItem.data);
|
2219
|
+
}
|
2220
|
+
//# sourceMappingURL=completionProvider.js.map
|