@zzzen/pyright-internal 1.2.0-dev.20231203 → 1.2.0-dev.20231217
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/analyzerFileInfo.d.ts +4 -3
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +15 -14
- package/dist/analyzer/backgroundAnalysisProgram.js +38 -38
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +67 -62
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +43 -33
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/circularDependency.d.ts +3 -2
- package/dist/analyzer/circularDependency.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +47 -47
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.d.ts +0 -1
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +3 -5
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/dataClasses.js +1 -1
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declaration.d.ts +5 -3
- package/dist/analyzer/declaration.js +3 -2
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/declarationUtils.d.ts +3 -2
- package/dist/analyzer/declarationUtils.js +14 -12
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.js +14 -43
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/enums.js +1 -1
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +29 -25
- package/dist/analyzer/importResolver.js +300 -301
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importResult.d.ts +5 -4
- package/dist/analyzer/importResult.js.map +1 -1
- package/dist/analyzer/importStatementUtils.d.ts +5 -4
- package/dist/analyzer/importStatementUtils.js +23 -22
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +3 -3
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/packageTypeReport.d.ts +7 -6
- package/dist/analyzer/packageTypeReport.js +4 -4
- package/dist/analyzer/packageTypeReport.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +68 -64
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.d.ts +7 -6
- package/dist/analyzer/parentDirectoryCache.js +9 -10
- package/dist/analyzer/parentDirectoryCache.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +1 -1
- package/dist/analyzer/parseTreeUtils.js +7 -4
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +102 -14
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +27 -26
- package/dist/analyzer/program.js +162 -156
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +6 -3
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/pyTypedUtils.d.ts +3 -2
- package/dist/analyzer/pyTypedUtils.js +4 -5
- package/dist/analyzer/pyTypedUtils.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.d.ts +7 -6
- package/dist/analyzer/pythonPathUtils.js +21 -23
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/service.d.ts +24 -23
- package/dist/analyzer/service.js +190 -184
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +4 -5
- package/dist/analyzer/sourceFile.js +68 -56
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js +3 -3
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.d.ts +11 -10
- package/dist/analyzer/sourceMapper.js +61 -63
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/sourceMapperUtils.d.ts +2 -1
- package/dist/analyzer/sourceMapperUtils.js +2 -2
- package/dist/analyzer/sourceMapperUtils.js.map +1 -1
- package/dist/analyzer/tracePrinter.d.ts +3 -2
- package/dist/analyzer/tracePrinter.js +21 -23
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.d.ts +2 -1
- package/dist/analyzer/typeDocStringUtils.js +14 -17
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +259 -152
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeGuards.d.ts +1 -0
- package/dist/analyzer/typeGuards.js +5 -4
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.d.ts +2 -0
- package/dist/analyzer/typePrinter.js +48 -8
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.d.ts +2 -1
- package/dist/analyzer/typeStubWriter.js +2 -2
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +5 -2
- package/dist/analyzer/typeUtils.js +37 -10
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +4 -4
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +10 -6
- package/dist/analyzer/types.js +7 -5
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysis.d.ts +1 -2
- package/dist/backgroundAnalysis.js +6 -4
- package/dist/backgroundAnalysis.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +22 -20
- package/dist/backgroundAnalysisBase.js +76 -55
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +1 -1
- package/dist/backgroundThreadBase.js +20 -11
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/createTypeStub.js +3 -2
- package/dist/commands/createTypeStub.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +21 -20
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/commands/quickActionCommand.js +5 -5
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/common/configOptions.d.ts +14 -13
- package/dist/common/configOptions.js +29 -27
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/diagnostic.d.ts +6 -5
- package/dist/common/diagnostic.js +2 -2
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/diagnosticSink.d.ts +2 -1
- package/dist/common/diagnosticSink.js.map +1 -1
- package/dist/common/editAction.d.ts +6 -5
- package/dist/common/editAction.js +2 -2
- package/dist/common/editAction.js.map +1 -1
- package/dist/common/envVarUtils.d.ts +2 -1
- package/dist/common/envVarUtils.js +20 -28
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +19 -19
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileSystem.d.ts +29 -28
- package/dist/common/fileWatcher.d.ts +2 -1
- package/dist/common/fileWatcher.js.map +1 -1
- package/dist/common/fullAccessHost.d.ts +8 -7
- package/dist/common/fullAccessHost.js +21 -16
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/host.d.ts +7 -6
- package/dist/common/host.js +1 -1
- package/dist/common/host.js.map +1 -1
- package/dist/common/logTracker.d.ts +2 -1
- package/dist/common/logTracker.js +4 -4
- package/dist/common/logTracker.js.map +1 -1
- package/dist/common/pathUtils.d.ts +1 -28
- package/dist/common/pathUtils.js +17 -366
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +7 -3
- package/dist/common/realFileSystem.js +78 -60
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProviderExtensions.d.ts +2 -1
- package/dist/common/serviceProviderExtensions.js +5 -2
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/common/textEditTracker.d.ts +2 -1
- package/dist/common/textEditTracker.js +28 -28
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/textRange.d.ts +2 -1
- package/dist/common/textRange.js.map +1 -1
- package/dist/common/uri/baseUri.d.ts +51 -0
- package/dist/common/uri/baseUri.js +194 -0
- package/dist/common/uri/baseUri.js.map +1 -0
- package/dist/common/uri/emptyUri.d.ts +32 -0
- package/dist/common/uri/emptyUri.js +98 -0
- package/dist/common/uri/emptyUri.js.map +1 -0
- package/dist/common/uri/fileUri.d.ts +36 -0
- package/dist/common/uri/fileUri.js +180 -0
- package/dist/common/uri/fileUri.js.map +1 -0
- package/dist/common/uri/memoization.d.ts +3 -0
- package/dist/common/uri/memoization.js +72 -0
- package/dist/common/uri/memoization.js.map +1 -0
- package/dist/common/uri/uri.d.ts +50 -0
- package/dist/common/uri/uri.js +104 -0
- package/dist/common/uri/uri.js.map +1 -0
- package/dist/common/uri/uriUtils.d.ts +39 -0
- package/dist/common/uri/uriUtils.js +362 -0
- package/dist/common/uri/uriUtils.js.map +1 -0
- package/dist/common/uri/webUri.d.ts +36 -0
- package/dist/common/uri/webUri.js +207 -0
- package/dist/common/uri/webUri.js.map +1 -0
- package/dist/common/workspaceEditUtils.d.ts +8 -8
- package/dist/common/workspaceEditUtils.js +35 -38
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +19 -22
- package/dist/languageServerBase.js +91 -95
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.d.ts +2 -1
- package/dist/languageService/analyzerServiceExecutor.js +14 -16
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +11 -9
- package/dist/languageService/autoImporter.js +45 -44
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.d.ts +3 -2
- package/dist/languageService/callHierarchyProvider.js +23 -35
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/codeActionProvider.d.ts +2 -1
- package/dist/languageService/codeActionProvider.js +8 -10
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +7 -6
- package/dist/languageService/completionProvider.js +32 -30
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.d.ts +2 -1
- package/dist/languageService/completionProviderUtils.js +1 -1
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.d.ts +4 -3
- package/dist/languageService/definitionProvider.js +26 -24
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.d.ts +3 -2
- package/dist/languageService/documentHighlightProvider.js +3 -3
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +8 -7
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.d.ts +5 -4
- package/dist/languageService/documentSymbolProvider.js +9 -11
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +4 -3
- package/dist/languageService/hoverProvider.js +6 -5
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/navigationUtils.d.ts +2 -1
- package/dist/languageService/navigationUtils.js +2 -3
- package/dist/languageService/navigationUtils.js.map +1 -1
- package/dist/languageService/quickActions.d.ts +2 -1
- package/dist/languageService/quickActions.js +3 -3
- package/dist/languageService/quickActions.js.map +1 -1
- package/dist/languageService/referencesProvider.d.ts +10 -9
- package/dist/languageService/referencesProvider.js +28 -28
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.d.ts +4 -3
- package/dist/languageService/renameProvider.js +17 -18
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.d.ts +3 -2
- package/dist/languageService/signatureHelpProvider.js +4 -4
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/symbolIndexer.d.ts +2 -1
- package/dist/languageService/symbolIndexer.js +11 -3
- package/dist/languageService/symbolIndexer.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +10 -4
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.d.ts +4 -3
- package/dist/languageService/workspaceSymbolProvider.js +10 -11
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +2 -0
- package/dist/localization/localize.js +2 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +3 -1
- package/dist/parser/parseNodes.d.ts +1 -0
- package/dist/parser/parseNodes.js +1 -0
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.js +18 -15
- package/dist/parser/parser.js.map +1 -1
- package/dist/pyright.js +16 -15
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +13 -13
- package/dist/pyrightFileSystem.js +38 -43
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +29 -28
- package/dist/readonlyAugmentedFileSystem.js +62 -65
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +21 -20
- package/dist/server.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +39 -30
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +31 -30
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/classDeclaration.test.d.ts +1 -0
- package/dist/tests/classDeclaration.test.js +166 -0
- package/dist/tests/classDeclaration.test.js.map +1 -0
- package/dist/tests/completions.test.js +7 -3
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +24 -22
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/documentSymbolCollector.test.js +3 -2
- package/dist/tests/documentSymbolCollector.test.js.map +1 -1
- package/dist/tests/filesystem.test.js +37 -35
- package/dist/tests/filesystem.test.js.map +1 -1
- package/dist/tests/fourSlashParser.test.js +4 -4
- package/dist/tests/fourSlashParser.test.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.js +27 -11
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/fourSlashParser.js +2 -2
- package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.d.ts +4 -5
- package/dist/tests/harness/fourslash/testLanguageService.js +9 -15
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +4 -4
- package/dist/tests/harness/fourslash/testState.js +91 -51
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +4 -0
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
- package/dist/tests/harness/testAccessHost.d.ts +3 -2
- package/dist/tests/harness/testAccessHost.js +2 -1
- package/dist/tests/harness/testAccessHost.js.map +1 -1
- package/dist/tests/harness/testHost.js +13 -11
- package/dist/tests/harness/testHost.js.map +1 -1
- package/dist/tests/harness/vfs/factory.d.ts +3 -2
- package/dist/tests/harness/vfs/factory.js +5 -4
- package/dist/tests/harness/vfs/factory.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +32 -31
- package/dist/tests/harness/vfs/filesystem.js +47 -49
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/harness/vfs/pathValidation.js +1 -10
- package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
- package/dist/tests/importResolver.test.js +106 -58
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +10 -9
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js +12 -11
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/logger.test.js +2 -1
- package/dist/tests/logger.test.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +2 -1
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/pathUtils.test.js +3 -138
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/pyrightFileSystem.test.js +38 -34
- package/dist/tests/pyrightFileSystem.test.js.map +1 -1
- package/dist/tests/service.test.js +37 -42
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/signatureHelp.test.js +3 -2
- package/dist/tests/signatureHelp.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +8 -7
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js +73 -35
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/testState.test.js +13 -9
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testStateUtils.d.ts +2 -5
- package/dist/tests/testStateUtils.js +27 -64
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/testUtils.d.ts +3 -5
- package/dist/tests/testUtils.js +15 -64
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js +4 -3
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +16 -15
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +22 -9
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +86 -63
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +29 -20
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +28 -27
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typePrinter.test.js +4 -3
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/tests/uri.test.d.ts +1 -0
- package/dist/tests/uri.test.js +695 -0
- package/dist/tests/uri.test.js.map +1 -0
- package/dist/tests/workspaceEditUtils.test.js +28 -28
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/tests/zipfs.test.js +11 -11
- package/dist/tests/zipfs.test.js.map +1 -1
- package/dist/workspaceFactory.d.ts +13 -14
- package/dist/workspaceFactory.js +54 -55
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +2 -2
- package/dist/common/uriParser.d.ts +0 -24
- package/dist/common/uriParser.js +0 -45
- package/dist/common/uriParser.js.map +0 -1
package/dist/analyzer/service.js
CHANGED
@@ -44,6 +44,8 @@ const pathConsts_1 = require("../common/pathConsts");
|
|
44
44
|
const pathUtils_1 = require("../common/pathUtils");
|
45
45
|
const serviceProviderExtensions_1 = require("../common/serviceProviderExtensions");
|
46
46
|
const timing_1 = require("../common/timing");
|
47
|
+
const uri_1 = require("../common/uri/uri");
|
48
|
+
const uriUtils_1 = require("../common/uri/uriUtils");
|
47
49
|
const backgroundAnalysisProgram_1 = require("./backgroundAnalysisProgram");
|
48
50
|
const importResolver_1 = require("./importResolver");
|
49
51
|
const pythonPathUtils_1 = require("./pythonPathUtils");
|
@@ -53,7 +55,7 @@ exports.pyprojectTomlName = 'pyproject.toml';
|
|
53
55
|
// How long since the last user activity should we wait until running
|
54
56
|
// the analyzer on any files that have not yet been analyzed?
|
55
57
|
const _userActivityBackoffTimeInMs = 250;
|
56
|
-
const _gitDirectory =
|
58
|
+
const _gitDirectory = '/.git/';
|
57
59
|
// Hold uniqueId for this service. It can be used to distinguish each service later.
|
58
60
|
let _nextServiceId = 1;
|
59
61
|
function getNextServiceId(name) {
|
@@ -69,7 +71,7 @@ class AnalyzerService {
|
|
69
71
|
this._disposed = false;
|
70
72
|
this._pendingLibraryChanges = { changesOnly: true };
|
71
73
|
this._instanceName = instanceName;
|
72
|
-
this.
|
74
|
+
this._executionRootUri = uri_1.Uri.empty();
|
73
75
|
this._options = options;
|
74
76
|
this._options.serviceId = (_a = this._options.serviceId) !== null && _a !== void 0 ? _a : getNextServiceId(instanceName);
|
75
77
|
this._options.console = options.console || new console_1.StandardConsole();
|
@@ -85,7 +87,8 @@ class AnalyzerService {
|
|
85
87
|
this._options.importResolverFactory = (_b = options.importResolverFactory) !== null && _b !== void 0 ? _b : AnalyzerService.createImportResolver;
|
86
88
|
this._options.cancellationProvider = (_c = options.cancellationProvider) !== null && _c !== void 0 ? _c : new cancellationUtils_1.DefaultCancellationProvider();
|
87
89
|
this._options.hostFactory = (_d = options.hostFactory) !== null && _d !== void 0 ? _d : (() => new host_1.NoAccessHost());
|
88
|
-
this._options.configOptions =
|
90
|
+
this._options.configOptions =
|
91
|
+
(_e = options.configOptions) !== null && _e !== void 0 ? _e : new configOptions_1.ConfigOptions(uri_1.Uri.file(process.cwd(), this._serviceProvider.fs().isCaseSensitive));
|
89
92
|
const importResolver = this._options.importResolverFactory(this._serviceProvider, this._options.configOptions, this._options.hostFactory());
|
90
93
|
this._backgroundAnalysisProgram =
|
91
94
|
this._options.backgroundAnalysisProgramFactory !== undefined
|
@@ -102,8 +105,8 @@ class AnalyzerService {
|
|
102
105
|
get cancellationProvider() {
|
103
106
|
return this._options.cancellationProvider;
|
104
107
|
}
|
105
|
-
get
|
106
|
-
return this.
|
108
|
+
get librarySearchUrisToWatch() {
|
109
|
+
return this._librarySearchUrisToWatch;
|
107
110
|
}
|
108
111
|
get backgroundAnalysisProgram() {
|
109
112
|
return this._backgroundAnalysisProgram;
|
@@ -131,7 +134,7 @@ class AnalyzerService {
|
|
131
134
|
for (const fileInfo of this.backgroundAnalysisProgram.program.getOpened()) {
|
132
135
|
const version = fileInfo.sourceFile.getClientVersion();
|
133
136
|
if (version !== undefined) {
|
134
|
-
service.setFileOpened(fileInfo.sourceFile.
|
137
|
+
service.setFileOpened(fileInfo.sourceFile.getUri(), version, fileInfo.sourceFile.getOpenFileContents(), fileInfo.sourceFile.getIPythonMode(), (_a = fileInfo.chainedSourceFile) === null || _a === void 0 ? void 0 : _a.sourceFile.getUri());
|
135
138
|
}
|
136
139
|
}
|
137
140
|
return service;
|
@@ -178,64 +181,62 @@ class AnalyzerService {
|
|
178
181
|
}
|
179
182
|
configOptions.ensureDefaultPythonPlatform(host, this._console);
|
180
183
|
this._backgroundAnalysisProgram.setConfigOptions(configOptions);
|
181
|
-
this.
|
184
|
+
this._executionRootUri = configOptions.projectRoot;
|
182
185
|
this._applyConfigOptions(host);
|
183
186
|
}
|
184
|
-
hasSourceFile(
|
185
|
-
return this.backgroundAnalysisProgram.hasSourceFile(
|
187
|
+
hasSourceFile(uri) {
|
188
|
+
return this.backgroundAnalysisProgram.hasSourceFile(uri);
|
186
189
|
}
|
187
|
-
isTracked(
|
188
|
-
return this._program.owns(
|
190
|
+
isTracked(uri) {
|
191
|
+
return this._program.owns(uri);
|
189
192
|
}
|
190
193
|
getUserFiles() {
|
191
|
-
return this._program.getUserFiles().map((i) => i.sourceFile.
|
194
|
+
return this._program.getUserFiles().map((i) => i.sourceFile.getUri());
|
192
195
|
}
|
193
196
|
getOpenFiles() {
|
194
|
-
return this._program.getOpened().map((i) => i.sourceFile.
|
197
|
+
return this._program.getOpened().map((i) => i.sourceFile.getUri());
|
195
198
|
}
|
196
|
-
setFileOpened(
|
199
|
+
setFileOpened(uri, version, contents, ipythonMode = sourceFile_1.IPythonMode.None, chainedFileUri) {
|
197
200
|
// Open the file. Notebook cells are always tracked as they aren't 3rd party library files.
|
198
201
|
// This is how it's worked in the past since each notebook used to have its own
|
199
202
|
// workspace and the workspace include setting marked all cells as tracked.
|
200
|
-
this._backgroundAnalysisProgram.setFileOpened(
|
201
|
-
isTracked: this.isTracked(
|
203
|
+
this._backgroundAnalysisProgram.setFileOpened(uri, version, contents, {
|
204
|
+
isTracked: this.isTracked(uri) || ipythonMode !== sourceFile_1.IPythonMode.None,
|
202
205
|
ipythonMode,
|
203
|
-
|
204
|
-
realFilePath,
|
206
|
+
chainedFileUri: chainedFileUri,
|
205
207
|
});
|
206
208
|
this._scheduleReanalysis(/* requireTrackedFileUpdate */ false);
|
207
209
|
}
|
208
|
-
|
209
|
-
return this._backgroundAnalysisProgram.
|
210
|
+
getChainedUri(uri) {
|
211
|
+
return this._backgroundAnalysisProgram.getChainedUri(uri);
|
210
212
|
}
|
211
|
-
|
212
|
-
this._backgroundAnalysisProgram.
|
213
|
+
updateChainedUri(uri, chainedFileUri) {
|
214
|
+
this._backgroundAnalysisProgram.updateChainedUri(uri, chainedFileUri);
|
213
215
|
this._scheduleReanalysis(/* requireTrackedFileUpdate */ false);
|
214
216
|
}
|
215
|
-
updateOpenFileContents(
|
216
|
-
this._backgroundAnalysisProgram.updateOpenFileContents(
|
217
|
-
isTracked: this.isTracked(
|
217
|
+
updateOpenFileContents(uri, version, contents, ipythonMode = sourceFile_1.IPythonMode.None) {
|
218
|
+
this._backgroundAnalysisProgram.updateOpenFileContents(uri, version, contents, {
|
219
|
+
isTracked: this.isTracked(uri),
|
218
220
|
ipythonMode,
|
219
|
-
|
220
|
-
realFilePath,
|
221
|
+
chainedFileUri: undefined,
|
221
222
|
});
|
222
223
|
this._scheduleReanalysis(/* requireTrackedFileUpdate */ false);
|
223
224
|
}
|
224
|
-
setFileClosed(
|
225
|
-
this._backgroundAnalysisProgram.setFileClosed(
|
225
|
+
setFileClosed(uri, isTracked) {
|
226
|
+
this._backgroundAnalysisProgram.setFileClosed(uri, isTracked);
|
226
227
|
this._scheduleReanalysis(/* requireTrackedFileUpdate */ false);
|
227
228
|
}
|
228
|
-
addInterimFile(
|
229
|
-
this._backgroundAnalysisProgram.addInterimFile(
|
229
|
+
addInterimFile(uri) {
|
230
|
+
this._backgroundAnalysisProgram.addInterimFile(uri);
|
230
231
|
}
|
231
|
-
getParseResult(
|
232
|
-
return this._program.getParseResults(
|
232
|
+
getParseResult(uri) {
|
233
|
+
return this._program.getParseResults(uri);
|
233
234
|
}
|
234
|
-
getSourceFile(
|
235
|
-
return this._program.getBoundSourceFile(
|
235
|
+
getSourceFile(uri) {
|
236
|
+
return this._program.getBoundSourceFile(uri);
|
236
237
|
}
|
237
|
-
getTextOnRange(
|
238
|
-
return this._program.getTextOnRange(
|
238
|
+
getTextOnRange(fileUri, range, token) {
|
239
|
+
return this._program.getTextOnRange(fileUri, range, token);
|
239
240
|
}
|
240
241
|
getEvaluator() {
|
241
242
|
return this._program.evaluator;
|
@@ -255,13 +256,13 @@ class AnalyzerService {
|
|
255
256
|
this._program.printDetailedAnalysisTimes();
|
256
257
|
}
|
257
258
|
printDependencies(verbose) {
|
258
|
-
this._program.printDependencies(this.
|
259
|
+
this._program.printDependencies(this._executionRootUri, verbose);
|
259
260
|
}
|
260
|
-
analyzeFile(
|
261
|
-
return this._backgroundAnalysisProgram.analyzeFile(
|
261
|
+
analyzeFile(fileUri, token) {
|
262
|
+
return this._backgroundAnalysisProgram.analyzeFile(fileUri, token);
|
262
263
|
}
|
263
|
-
getDiagnosticsForRange(
|
264
|
-
return this._backgroundAnalysisProgram.getDiagnosticsForRange(
|
264
|
+
getDiagnosticsForRange(fileUri, range, token) {
|
265
|
+
return this._backgroundAnalysisProgram.getDiagnosticsForRange(fileUri, range, token);
|
265
266
|
}
|
266
267
|
getConfigOptions() {
|
267
268
|
return this._configOptions;
|
@@ -283,21 +284,21 @@ class AnalyzerService {
|
|
283
284
|
test_getFileNamesFromFileSpecs() {
|
284
285
|
return this._getFileNamesFromFileSpecs();
|
285
286
|
}
|
286
|
-
test_shouldHandleSourceFileWatchChanges(
|
287
|
-
return this._shouldHandleSourceFileWatchChanges(
|
287
|
+
test_shouldHandleSourceFileWatchChanges(uri, isFile) {
|
288
|
+
return this._shouldHandleSourceFileWatchChanges(uri, isFile);
|
288
289
|
}
|
289
|
-
test_shouldHandleLibraryFileWatchChanges(
|
290
|
-
return this._shouldHandleLibraryFileWatchChanges(
|
290
|
+
test_shouldHandleLibraryFileWatchChanges(uri, libSearchUris) {
|
291
|
+
return this._shouldHandleLibraryFileWatchChanges(uri, libSearchUris);
|
291
292
|
}
|
292
293
|
writeTypeStub(token) {
|
293
294
|
var _a;
|
294
|
-
const
|
295
|
-
this._program.writeTypeStub((_a = this.
|
295
|
+
const typingsSubdirUri = this._getTypeStubFolder();
|
296
|
+
this._program.writeTypeStub((_a = this._typeStubTargetUri) !== null && _a !== void 0 ? _a : uri_1.Uri.empty(), this._typeStubTargetIsSingleFile, typingsSubdirUri, token);
|
296
297
|
}
|
297
298
|
writeTypeStubInBackground(token) {
|
298
299
|
var _a;
|
299
|
-
const
|
300
|
-
return this._backgroundAnalysisProgram.writeTypeStub((_a = this.
|
300
|
+
const typingsSubdirUri = this._getTypeStubFolder();
|
301
|
+
return this._backgroundAnalysisProgram.writeTypeStub((_a = this._typeStubTargetUri) !== null && _a !== void 0 ? _a : uri_1.Uri.empty(), this._typeStubTargetIsSingleFile, typingsSubdirUri, token);
|
301
302
|
}
|
302
303
|
invalidateAndForceReanalysis(reason) {
|
303
304
|
this._backgroundAnalysisProgram.invalidateAndForceReanalysis(reason);
|
@@ -350,32 +351,35 @@ class AnalyzerService {
|
|
350
351
|
// an optional config file, and default values.
|
351
352
|
_getConfigOptions(host, commandLineOptions) {
|
352
353
|
var _a, _b, _c;
|
353
|
-
let projectRoot =
|
354
|
+
let projectRoot = this.fs.realCasePath(uri_1.Uri.file(commandLineOptions.executionRoot, this.fs.isCaseSensitive, /* checkRelative */ true));
|
355
|
+
const executionRoot = this.fs.realCasePath(uri_1.Uri.file(commandLineOptions.executionRoot, this.fs.isCaseSensitive, /* checkRelative */ true));
|
354
356
|
let configFilePath;
|
355
357
|
let pyprojectFilePath;
|
356
358
|
if (commandLineOptions.configFilePath) {
|
357
359
|
// If the config file path was specified, determine whether it's
|
358
360
|
// a directory (in which case the default config file name is assumed)
|
359
361
|
// or a file.
|
360
|
-
configFilePath =
|
362
|
+
configFilePath = this.fs.realCasePath((0, pathUtils_1.isRootedDiskPath)(commandLineOptions.configFilePath)
|
363
|
+
? uri_1.Uri.file(commandLineOptions.configFilePath, this.fs.isCaseSensitive, /* checkRelative */ true)
|
364
|
+
: projectRoot.combinePaths(commandLineOptions.configFilePath));
|
361
365
|
if (!this.fs.existsSync(configFilePath)) {
|
362
|
-
this._console.info(`Configuration file not found at ${configFilePath}.`);
|
363
|
-
configFilePath =
|
366
|
+
this._console.info(`Configuration file not found at ${configFilePath.toUserVisibleString()}.`);
|
367
|
+
configFilePath = projectRoot;
|
364
368
|
}
|
365
369
|
else {
|
366
|
-
if (configFilePath.
|
367
|
-
projectRoot =
|
370
|
+
if (configFilePath.lastExtension.endsWith('.json')) {
|
371
|
+
projectRoot = configFilePath.getDirectory();
|
368
372
|
}
|
369
373
|
else {
|
370
374
|
projectRoot = configFilePath;
|
371
375
|
configFilePath = this._findConfigFile(configFilePath);
|
372
376
|
if (!configFilePath) {
|
373
|
-
this._console.info(`Configuration file not found at ${projectRoot}.`);
|
377
|
+
this._console.info(`Configuration file not found at ${projectRoot.toUserVisibleString()}.`);
|
374
378
|
}
|
375
379
|
}
|
376
380
|
}
|
377
381
|
}
|
378
|
-
else if (
|
382
|
+
else if (commandLineOptions.executionRoot) {
|
379
383
|
// In a project-based IDE like VS Code, we should assume that the
|
380
384
|
// project root directory contains the config file.
|
381
385
|
configFilePath = this._findConfigFile(projectRoot);
|
@@ -386,7 +390,7 @@ class AnalyzerService {
|
|
386
390
|
configFilePath = this._findConfigFileHereOrUp(projectRoot);
|
387
391
|
}
|
388
392
|
if (configFilePath) {
|
389
|
-
projectRoot =
|
393
|
+
projectRoot = configFilePath.getDirectory();
|
390
394
|
}
|
391
395
|
else {
|
392
396
|
this._console.log(`No configuration file found.`);
|
@@ -400,8 +404,8 @@ class AnalyzerService {
|
|
400
404
|
pyprojectFilePath = this._findPyprojectTomlFileHereOrUp(projectRoot);
|
401
405
|
}
|
402
406
|
if (pyprojectFilePath) {
|
403
|
-
projectRoot =
|
404
|
-
this._console.log(`pyproject.toml file found at ${projectRoot}.`);
|
407
|
+
projectRoot = pyprojectFilePath.getDirectory();
|
408
|
+
this._console.log(`pyproject.toml file found at ${projectRoot.toUserVisibleString()}.`);
|
405
409
|
}
|
406
410
|
else {
|
407
411
|
this._console.log(`No pyproject.toml file found.`);
|
@@ -411,7 +415,7 @@ class AnalyzerService {
|
|
411
415
|
const defaultExcludes = ['**/node_modules', '**/__pycache__', '**/.*'];
|
412
416
|
if (commandLineOptions.pythonPath) {
|
413
417
|
this._console.info(`Setting pythonPath for service "${this._instanceName}": ` + `"${commandLineOptions.pythonPath}"`);
|
414
|
-
|
418
|
+
configOptions.pythonPath = this.fs.realCasePath(uri_1.Uri.file(commandLineOptions.pythonPath, this.fs.isCaseSensitive, /* checkRelative */ true));
|
415
419
|
}
|
416
420
|
if (commandLineOptions.pythonEnvironmentName) {
|
417
421
|
this._console.info(`Setting environmentName for service "${this._instanceName}": ` +
|
@@ -425,17 +429,17 @@ class AnalyzerService {
|
|
425
429
|
configOptions.ensureDefaultExtraPaths(this.fs, (_a = commandLineOptions.autoSearchPaths) !== null && _a !== void 0 ? _a : false, commandLineOptions.extraPaths);
|
426
430
|
if (commandLineOptions.includeFileSpecs.length > 0) {
|
427
431
|
commandLineOptions.includeFileSpecs.forEach((fileSpec) => {
|
428
|
-
configOptions.include.push((0,
|
432
|
+
configOptions.include.push((0, uriUtils_1.getFileSpec)(projectRoot, fileSpec));
|
429
433
|
});
|
430
434
|
}
|
431
435
|
if (commandLineOptions.excludeFileSpecs.length > 0) {
|
432
436
|
commandLineOptions.excludeFileSpecs.forEach((fileSpec) => {
|
433
|
-
configOptions.exclude.push((0,
|
437
|
+
configOptions.exclude.push((0, uriUtils_1.getFileSpec)(projectRoot, fileSpec));
|
434
438
|
});
|
435
439
|
}
|
436
440
|
if (commandLineOptions.ignoreFileSpecs.length > 0) {
|
437
441
|
commandLineOptions.ignoreFileSpecs.forEach((fileSpec) => {
|
438
|
-
configOptions.ignore.push((0,
|
442
|
+
configOptions.ignore.push((0, uriUtils_1.getFileSpec)(projectRoot, fileSpec));
|
439
443
|
});
|
440
444
|
}
|
441
445
|
if (!configFilePath && commandLineOptions.executionRoot) {
|
@@ -443,40 +447,40 @@ class AnalyzerService {
|
|
443
447
|
// If no config file was found and there are no explicit include
|
444
448
|
// paths specified, assume the caller wants to include all source
|
445
449
|
// files under the execution root path.
|
446
|
-
configOptions.include.push((0,
|
450
|
+
configOptions.include.push((0, uriUtils_1.getFileSpec)(executionRoot, '.'));
|
447
451
|
}
|
448
452
|
if (commandLineOptions.excludeFileSpecs.length === 0) {
|
449
453
|
// Add a few common excludes to avoid long scan times.
|
450
454
|
defaultExcludes.forEach((exclude) => {
|
451
|
-
configOptions.exclude.push((0,
|
455
|
+
configOptions.exclude.push((0, uriUtils_1.getFileSpec)(executionRoot, exclude));
|
452
456
|
});
|
453
457
|
}
|
454
458
|
}
|
455
|
-
this.
|
459
|
+
this._configFileUri = configFilePath || pyprojectFilePath;
|
456
460
|
// If we found a config file, parse it to compute the effective options.
|
457
461
|
let configJsonObj;
|
458
462
|
if (configFilePath) {
|
459
|
-
this._console.info(`Loading configuration file at ${configFilePath}`);
|
463
|
+
this._console.info(`Loading configuration file at ${configFilePath.toUserVisibleString()}`);
|
460
464
|
configJsonObj = this._parseJsonConfigFile(configFilePath);
|
461
465
|
}
|
462
466
|
else if (pyprojectFilePath) {
|
463
|
-
this._console.info(`Loading pyproject.toml file at ${pyprojectFilePath}`);
|
467
|
+
this._console.info(`Loading pyproject.toml file at ${pyprojectFilePath.toUserVisibleString()}`);
|
464
468
|
configJsonObj = this._parsePyprojectTomlFile(pyprojectFilePath);
|
465
469
|
}
|
466
470
|
if (configJsonObj) {
|
467
471
|
configOptions.initializeFromJson(configJsonObj, this._typeCheckingMode, this.serviceProvider, host, commandLineOptions.diagnosticSeverityOverrides);
|
468
|
-
const configFileDir =
|
472
|
+
const configFileDir = this._configFileUri.getDirectory();
|
469
473
|
// If no include paths were provided, assume that all files within
|
470
474
|
// the project should be included.
|
471
475
|
if (configOptions.include.length === 0) {
|
472
|
-
this._console.info(`No include entries specified; assuming ${configFileDir}`);
|
473
|
-
configOptions.include.push((0,
|
476
|
+
this._console.info(`No include entries specified; assuming ${configFileDir.toUserVisibleString()}`);
|
477
|
+
configOptions.include.push((0, uriUtils_1.getFileSpec)(configFileDir, '.'));
|
474
478
|
}
|
475
479
|
// If there was no explicit set of excludes, add a few common ones to avoid long scan times.
|
476
480
|
if (configOptions.exclude.length === 0) {
|
477
481
|
defaultExcludes.forEach((exclude) => {
|
478
482
|
this._console.info(`Auto-excluding ${exclude}`);
|
479
|
-
configOptions.exclude.push((0,
|
483
|
+
configOptions.exclude.push((0, uriUtils_1.getFileSpec)(configFileDir, exclude));
|
480
484
|
});
|
481
485
|
if (configOptions.autoExcludeVenv === undefined) {
|
482
486
|
configOptions.autoExcludeVenv = true;
|
@@ -496,7 +500,7 @@ class AnalyzerService {
|
|
496
500
|
if (commandLineOptions.includeFileSpecsOverride) {
|
497
501
|
configOptions.include = [];
|
498
502
|
commandLineOptions.includeFileSpecsOverride.forEach((include) => {
|
499
|
-
configOptions.include.push((0,
|
503
|
+
configOptions.include.push((0, uriUtils_1.getFileSpec)(uri_1.Uri.file(include, this.fs.isCaseSensitive, /* checkRelative */ true), '.'));
|
500
504
|
});
|
501
505
|
}
|
502
506
|
const reportDuplicateSetting = (settingName, configValue) => {
|
@@ -512,18 +516,18 @@ class AnalyzerService {
|
|
512
516
|
// duplicates.
|
513
517
|
if (commandLineOptions.venvPath) {
|
514
518
|
if (!configOptions.venvPath) {
|
515
|
-
configOptions.venvPath = commandLineOptions.venvPath;
|
519
|
+
configOptions.venvPath = projectRoot.combinePaths(commandLineOptions.venvPath);
|
516
520
|
}
|
517
521
|
else {
|
518
|
-
reportDuplicateSetting('venvPath', configOptions.venvPath);
|
522
|
+
reportDuplicateSetting('venvPath', configOptions.venvPath.toUserVisibleString());
|
519
523
|
}
|
520
524
|
}
|
521
525
|
if (commandLineOptions.typeshedPath) {
|
522
526
|
if (!configOptions.typeshedPath) {
|
523
|
-
configOptions.typeshedPath =
|
527
|
+
configOptions.typeshedPath = projectRoot.combinePaths(commandLineOptions.typeshedPath);
|
524
528
|
}
|
525
529
|
else {
|
526
|
-
reportDuplicateSetting('typeshedPath', configOptions.typeshedPath);
|
530
|
+
reportDuplicateSetting('typeshedPath', configOptions.typeshedPath.toUserVisibleString());
|
527
531
|
}
|
528
532
|
}
|
529
533
|
// If the caller specified that "typeshedPath" is the root of the project,
|
@@ -536,7 +540,7 @@ class AnalyzerService {
|
|
536
540
|
this._console.info(`Excluding typeshed stdlib stubs according to VERSIONS file:`);
|
537
541
|
excludeList.forEach((exclude) => {
|
538
542
|
this._console.info(` ${exclude}`);
|
539
|
-
configOptions.exclude.push((0,
|
543
|
+
configOptions.exclude.push((0, uriUtils_1.getFileSpec)(executionRoot, exclude.getFilePath()));
|
540
544
|
});
|
541
545
|
}
|
542
546
|
configOptions.verboseOutput = (_b = commandLineOptions.verboseOutput) !== null && _b !== void 0 ? _b : configOptions.verboseOutput;
|
@@ -560,42 +564,42 @@ class AnalyzerService {
|
|
560
564
|
}
|
561
565
|
if (commandLineOptions.stubPath) {
|
562
566
|
if (!configOptions.stubPath) {
|
563
|
-
configOptions.stubPath =
|
567
|
+
configOptions.stubPath = this.fs.realCasePath(projectRoot.combinePaths(commandLineOptions.stubPath));
|
564
568
|
}
|
565
569
|
else {
|
566
|
-
reportDuplicateSetting('stubPath', configOptions.stubPath);
|
570
|
+
reportDuplicateSetting('stubPath', configOptions.stubPath.toUserVisibleString());
|
567
571
|
}
|
568
572
|
}
|
569
573
|
if (configOptions.stubPath) {
|
570
574
|
// If there was a stub path specified, validate it.
|
571
|
-
if (!this.fs.existsSync(configOptions.stubPath) || !(0,
|
575
|
+
if (!this.fs.existsSync(configOptions.stubPath) || !(0, uriUtils_1.isDirectory)(this.fs, configOptions.stubPath)) {
|
572
576
|
this._console.warn(`stubPath ${configOptions.stubPath} is not a valid directory.`);
|
573
577
|
}
|
574
578
|
}
|
575
579
|
else {
|
576
580
|
// If no stub path was specified, use a default path.
|
577
|
-
configOptions.stubPath =
|
581
|
+
configOptions.stubPath = configOptions.projectRoot.combinePaths(pathConsts_1.defaultStubsDirectory);
|
578
582
|
}
|
579
583
|
// Do some sanity checks on the specified settings and report missing
|
580
584
|
// or inconsistent information.
|
581
585
|
if (configOptions.venvPath) {
|
582
|
-
if (!this.fs.existsSync(configOptions.venvPath) || !(0,
|
583
|
-
this._console.error(`venvPath ${configOptions.venvPath} is not a valid directory.`);
|
586
|
+
if (!this.fs.existsSync(configOptions.venvPath) || !(0, uriUtils_1.isDirectory)(this.fs, configOptions.venvPath)) {
|
587
|
+
this._console.error(`venvPath ${configOptions.venvPath.toUserVisibleString()} is not a valid directory.`);
|
584
588
|
}
|
585
589
|
// venvPath without venv means it won't do anything while resolveImport.
|
586
590
|
// so first, try to set venv from existing configOption if it is null. if both are null,
|
587
591
|
// then, resolveImport won't consider venv
|
588
592
|
configOptions.venv = (_c = configOptions.venv) !== null && _c !== void 0 ? _c : this._configOptions.venv;
|
589
|
-
if (configOptions.venv) {
|
590
|
-
const fullVenvPath =
|
591
|
-
if (!this.fs.existsSync(fullVenvPath) || !(0,
|
592
|
-
this._console.error(`venv ${configOptions.venv} subdirectory not found in venv path ${configOptions.venvPath}.`);
|
593
|
+
if (configOptions.venv && configOptions.venvPath) {
|
594
|
+
const fullVenvPath = configOptions.venvPath.combinePaths(configOptions.venv);
|
595
|
+
if (!this.fs.existsSync(fullVenvPath) || !(0, uriUtils_1.isDirectory)(this.fs, fullVenvPath)) {
|
596
|
+
this._console.error(`venv ${configOptions.venv} subdirectory not found in venv path ${configOptions.venvPath.toUserVisibleString()}.`);
|
593
597
|
}
|
594
598
|
else {
|
595
599
|
const importFailureInfo = [];
|
596
600
|
if ((0, pythonPathUtils_1.findPythonSearchPaths)(this.fs, configOptions, host, importFailureInfo) === undefined) {
|
597
601
|
this._console.error(`site-packages directory cannot be located for venvPath ` +
|
598
|
-
`${configOptions.venvPath} and venv ${configOptions.venv}.`);
|
602
|
+
`${configOptions.venvPath.toUserVisibleString()} and venv ${configOptions.venv}.`);
|
599
603
|
if (configOptions.verboseOutput) {
|
600
604
|
importFailureInfo.forEach((diag) => {
|
601
605
|
this._console.error(` ${diag}`);
|
@@ -612,16 +616,16 @@ class AnalyzerService {
|
|
612
616
|
}
|
613
617
|
}
|
614
618
|
if (configOptions.typeshedPath) {
|
615
|
-
if (!this.fs.existsSync(configOptions.typeshedPath) || !(0,
|
616
|
-
this._console.error(`typeshedPath ${configOptions.typeshedPath} is not a valid directory.`);
|
619
|
+
if (!this.fs.existsSync(configOptions.typeshedPath) || !(0, uriUtils_1.isDirectory)(this.fs, configOptions.typeshedPath)) {
|
620
|
+
this._console.error(`typeshedPath ${configOptions.typeshedPath.toUserVisibleString()} is not a valid directory.`);
|
617
621
|
}
|
618
622
|
}
|
619
623
|
return configOptions;
|
620
624
|
}
|
621
625
|
_getTypeStubFolder() {
|
622
626
|
var _a;
|
623
|
-
const stubPath = (_a = this._configOptions.stubPath) !== null && _a !== void 0 ? _a :
|
624
|
-
if (!this.
|
627
|
+
const stubPath = (_a = this._configOptions.stubPath) !== null && _a !== void 0 ? _a : this.fs.realCasePath(this._configOptions.projectRoot.combinePaths(pathConsts_1.defaultStubsDirectory));
|
628
|
+
if (!this._typeStubTargetUri || !this._typeStubTargetImportName) {
|
625
629
|
const errMsg = `Import '${this._typeStubTargetImportName}'` + ` could not be resolved`;
|
626
630
|
this._console.error(errMsg);
|
627
631
|
throw new Error(errMsg);
|
@@ -641,45 +645,45 @@ class AnalyzerService {
|
|
641
645
|
}
|
642
646
|
}
|
643
647
|
catch (e) {
|
644
|
-
const errMsg = `Could not create typings directory '${stubPath}'`;
|
648
|
+
const errMsg = `Could not create typings directory '${stubPath.toUserVisibleString()}'`;
|
645
649
|
this._console.error(errMsg);
|
646
650
|
throw new Error(errMsg);
|
647
651
|
}
|
648
652
|
// Generate a typings subdirectory hierarchy.
|
649
|
-
const typingsSubdirPath =
|
650
|
-
const typingsSubdirHierarchy =
|
653
|
+
const typingsSubdirPath = stubPath.combinePaths(typeStubInputTargetParts[0]);
|
654
|
+
const typingsSubdirHierarchy = stubPath.combinePaths(...typeStubInputTargetParts);
|
651
655
|
try {
|
652
656
|
// Generate a new typings subdirectory if necessary.
|
653
657
|
if (!this.fs.existsSync(typingsSubdirHierarchy)) {
|
654
|
-
(0,
|
658
|
+
(0, uriUtils_1.makeDirectories)(this.fs, typingsSubdirHierarchy, stubPath);
|
655
659
|
}
|
656
660
|
}
|
657
661
|
catch (e) {
|
658
|
-
const errMsg = `Could not create typings subdirectory '${typingsSubdirHierarchy}'`;
|
662
|
+
const errMsg = `Could not create typings subdirectory '${typingsSubdirHierarchy.toUserVisibleString()}'`;
|
659
663
|
this._console.error(errMsg);
|
660
664
|
throw new Error(errMsg);
|
661
665
|
}
|
662
666
|
return typingsSubdirPath;
|
663
667
|
}
|
664
668
|
_findConfigFileHereOrUp(searchPath) {
|
665
|
-
return (0,
|
669
|
+
return (0, uriUtils_1.forEachAncestorDirectory)(searchPath, (ancestor) => this._findConfigFile(ancestor));
|
666
670
|
}
|
667
671
|
_findConfigFile(searchPath) {
|
668
672
|
for (const name of exports.configFileNames) {
|
669
|
-
const fileName =
|
673
|
+
const fileName = searchPath.combinePaths(name);
|
670
674
|
if (this.fs.existsSync(fileName)) {
|
671
|
-
return
|
675
|
+
return this.fs.realCasePath(fileName);
|
672
676
|
}
|
673
677
|
}
|
674
678
|
return undefined;
|
675
679
|
}
|
676
680
|
_findPyprojectTomlFileHereOrUp(searchPath) {
|
677
|
-
return (0,
|
681
|
+
return (0, uriUtils_1.forEachAncestorDirectory)(searchPath, (ancestor) => this._findPyprojectTomlFile(ancestor));
|
678
682
|
}
|
679
683
|
_findPyprojectTomlFile(searchPath) {
|
680
|
-
const fileName =
|
684
|
+
const fileName = searchPath.combinePaths(exports.pyprojectTomlName);
|
681
685
|
if (this.fs.existsSync(fileName)) {
|
682
|
-
return
|
686
|
+
return this.fs.realCasePath(fileName);
|
683
687
|
}
|
684
688
|
return undefined;
|
685
689
|
}
|
@@ -705,20 +709,20 @@ class AnalyzerService {
|
|
705
709
|
this._console.error(`Pyproject file parse attempt ${attemptCount} error: ${JSON.stringify(e)}`);
|
706
710
|
throw e;
|
707
711
|
}
|
708
|
-
this._console.info(`Pyproject file "${pyprojectPath}" has no "[tool.pyright]" section.`);
|
712
|
+
this._console.info(`Pyproject file "${pyprojectPath.toUserVisibleString()}" has no "[tool.pyright]" section.`);
|
709
713
|
return undefined;
|
710
714
|
});
|
711
715
|
}
|
712
|
-
_attemptParseFile(
|
716
|
+
_attemptParseFile(fileUri, parseCallback) {
|
713
717
|
let fileContents = '';
|
714
718
|
let parseAttemptCount = 0;
|
715
719
|
while (true) {
|
716
720
|
// Attempt to read the file contents.
|
717
721
|
try {
|
718
|
-
fileContents = this.fs.readFileSync(
|
722
|
+
fileContents = this.fs.readFileSync(fileUri, 'utf8');
|
719
723
|
}
|
720
724
|
catch {
|
721
|
-
this._console.error(`Config file "${
|
725
|
+
this._console.error(`Config file "${fileUri.toUserVisibleString()}" could not be read.`);
|
722
726
|
this._reportConfigParseError();
|
723
727
|
return undefined;
|
724
728
|
}
|
@@ -737,7 +741,7 @@ class AnalyzerService {
|
|
737
741
|
// may have been partially written when we read it, resulting in parse
|
738
742
|
// errors. We'll give it a little more time and try again.
|
739
743
|
if (parseAttemptCount++ >= 5) {
|
740
|
-
this._console.error(`Config file "${
|
744
|
+
this._console.error(`Config file "${fileUri.toUserVisibleString()}" could not be parsed. Verify that format is correct.`);
|
741
745
|
this._reportConfigParseError();
|
742
746
|
return undefined;
|
743
747
|
}
|
@@ -751,16 +755,16 @@ class AnalyzerService {
|
|
751
755
|
timing_1.timingStats.findFilesTime.timeOperation(() => {
|
752
756
|
const matchedFiles = this._matchFiles(this._configOptions.include, this._configOptions.exclude);
|
753
757
|
for (const file of matchedFiles) {
|
754
|
-
fileMap.set(file, file);
|
758
|
+
fileMap.set(file.key, file);
|
755
759
|
}
|
756
760
|
});
|
757
761
|
// And scan all matching open files. We need to do this since some of files are not backed by
|
758
762
|
// files in file system but only exist in memory (ex, virtual workspace)
|
759
763
|
this._backgroundAnalysisProgram.program
|
760
764
|
.getOpened()
|
761
|
-
.map((o) => o.sourceFile.
|
765
|
+
.map((o) => o.sourceFile.getUri())
|
762
766
|
.filter((f) => (0, configOptions_1.matchFileSpecs)(this._program.configOptions, f))
|
763
|
-
.forEach((f) => fileMap.set(f, f));
|
767
|
+
.forEach((f) => fileMap.set(f.key, f));
|
764
768
|
return Array.from(fileMap.values());
|
765
769
|
}
|
766
770
|
// If markFilesDirtyUnconditionally is true, we need to reparse
|
@@ -772,50 +776,50 @@ class AnalyzerService {
|
|
772
776
|
// Are we in type stub generation mode? If so, we need to search
|
773
777
|
// for a different set of files.
|
774
778
|
if (this._typeStubTargetImportName) {
|
775
|
-
const execEnv = this._configOptions.findExecEnvironment(this.
|
779
|
+
const execEnv = this._configOptions.findExecEnvironment(this._executionRootUri);
|
776
780
|
const moduleDescriptor = (0, importResolver_1.createImportedModuleDescriptor)(this._typeStubTargetImportName);
|
777
|
-
const importResult = this._backgroundAnalysisProgram.importResolver.resolveImport(
|
781
|
+
const importResult = this._backgroundAnalysisProgram.importResolver.resolveImport(uri_1.Uri.empty(), execEnv, moduleDescriptor);
|
778
782
|
if (importResult.isImportFound) {
|
779
783
|
const filesToImport = [];
|
780
784
|
// Determine the directory that contains the root package.
|
781
|
-
const finalResolvedPath = importResult.
|
782
|
-
const isFinalPathFile = (0,
|
783
|
-
const isFinalPathInitFile = isFinalPathFile && (
|
785
|
+
const finalResolvedPath = importResult.resolvedUris[importResult.resolvedUris.length - 1];
|
786
|
+
const isFinalPathFile = (0, uriUtils_1.isFile)(this.fs, finalResolvedPath);
|
787
|
+
const isFinalPathInitFile = isFinalPathFile && finalResolvedPath.stripAllExtensions().fileName === '__init__';
|
784
788
|
let rootPackagePath = finalResolvedPath;
|
785
789
|
if (isFinalPathFile) {
|
786
790
|
// If the module is a __init__.pyi? file, use its parent directory instead.
|
787
|
-
rootPackagePath =
|
791
|
+
rootPackagePath = rootPackagePath.getDirectory();
|
788
792
|
}
|
789
|
-
for (let i = importResult.
|
790
|
-
if (importResult.
|
791
|
-
rootPackagePath = importResult.
|
793
|
+
for (let i = importResult.resolvedUris.length - 2; i >= 0; i--) {
|
794
|
+
if (!importResult.resolvedUris[i].isEmpty()) {
|
795
|
+
rootPackagePath = importResult.resolvedUris[i];
|
792
796
|
}
|
793
797
|
else {
|
794
798
|
// If there was no file corresponding to this portion
|
795
799
|
// of the name path, assume that it's contained
|
796
800
|
// within its parent directory.
|
797
|
-
rootPackagePath =
|
801
|
+
rootPackagePath = rootPackagePath.getDirectory();
|
798
802
|
}
|
799
803
|
}
|
800
|
-
if ((0,
|
801
|
-
this.
|
804
|
+
if ((0, uriUtils_1.isDirectory)(this.fs, rootPackagePath)) {
|
805
|
+
this._typeStubTargetUri = rootPackagePath;
|
802
806
|
}
|
803
|
-
else if ((0,
|
807
|
+
else if ((0, uriUtils_1.isFile)(this.fs, rootPackagePath)) {
|
804
808
|
// This can occur if there is a "dir/__init__.py" at the same level as a
|
805
809
|
// module "dir/module.py" that is specifically targeted for stub generation.
|
806
|
-
this.
|
810
|
+
this._typeStubTargetUri = rootPackagePath.getDirectory();
|
807
811
|
}
|
808
812
|
if (!finalResolvedPath) {
|
809
813
|
this._typeStubTargetIsSingleFile = false;
|
810
814
|
}
|
811
815
|
else {
|
812
816
|
filesToImport.push(finalResolvedPath);
|
813
|
-
this._typeStubTargetIsSingleFile = importResult.
|
817
|
+
this._typeStubTargetIsSingleFile = importResult.resolvedUris.length === 1 && !isFinalPathInitFile;
|
814
818
|
}
|
815
819
|
// Add the implicit import paths.
|
816
820
|
importResult.filteredImplicitImports.forEach((implicitImport) => {
|
817
|
-
if (importResolver_1.ImportResolver.isSupportedImportSourceFile(implicitImport.
|
818
|
-
filesToImport.push(implicitImport.
|
821
|
+
if (importResolver_1.ImportResolver.isSupportedImportSourceFile(implicitImport.uri)) {
|
822
|
+
filesToImport.push(implicitImport.uri);
|
819
823
|
}
|
820
824
|
});
|
821
825
|
this._backgroundAnalysisProgram.setAllowedThirdPartyImports([this._typeStubTargetImportName]);
|
@@ -868,26 +872,24 @@ class AnalyzerService {
|
|
868
872
|
}
|
869
873
|
}
|
870
874
|
if (this._configOptions.autoExcludeVenv) {
|
871
|
-
if (envMarkers.some((f) => this.fs.existsSync(
|
875
|
+
if (envMarkers.some((f) => this.fs.existsSync(absolutePath.combinePaths(...f)))) {
|
872
876
|
// Save auto exclude paths in the configOptions once we found them.
|
873
|
-
if (!
|
874
|
-
exclude.push((0,
|
877
|
+
if (!uriUtils_1.FileSpec.isInPath(absolutePath, exclude)) {
|
878
|
+
exclude.push((0, uriUtils_1.getFileSpec)(this._configOptions.projectRoot, `${absolutePath}/**`));
|
875
879
|
}
|
876
|
-
this._console.info(`Auto-excluding ${absolutePath}`);
|
880
|
+
this._console.info(`Auto-excluding ${absolutePath.toUserVisibleString()}`);
|
877
881
|
return;
|
878
882
|
}
|
879
883
|
}
|
880
|
-
const { files, directories } = (0,
|
881
|
-
for (const
|
882
|
-
|
883
|
-
if (pathUtils_1.FileSpec.matchIncludeFileSpec(includeRegExp, exclude, filePath)) {
|
884
|
+
const { files, directories } = (0, uriUtils_1.getFileSystemEntries)(this.fs, absolutePath);
|
885
|
+
for (const filePath of files) {
|
886
|
+
if (uriUtils_1.FileSpec.matchIncludeFileSpec(includeRegExp, exclude, filePath)) {
|
884
887
|
results.push(filePath);
|
885
888
|
}
|
886
889
|
}
|
887
|
-
for (const
|
888
|
-
|
889
|
-
|
890
|
-
if (!pathUtils_1.FileSpec.isInPath(dirPath, exclude)) {
|
890
|
+
for (const dirPath of directories) {
|
891
|
+
if (dirPath.matchesRegex(includeRegExp) || hasDirectoryWildcard) {
|
892
|
+
if (!uriUtils_1.FileSpec.isInPath(dirPath, exclude)) {
|
891
893
|
visitDirectory(dirPath, includeRegExp, hasDirectoryWildcard);
|
892
894
|
}
|
893
895
|
}
|
@@ -895,27 +897,27 @@ class AnalyzerService {
|
|
895
897
|
};
|
896
898
|
const seenDirs = new Set();
|
897
899
|
const visitDirectory = (absolutePath, includeRegExp, hasDirectoryWildcard) => {
|
898
|
-
const realDirPath = (0,
|
900
|
+
const realDirPath = (0, uriUtils_1.tryRealpath)(this.fs, absolutePath);
|
899
901
|
if (!realDirPath) {
|
900
902
|
this._console.warn(`Skipping broken link "${absolutePath}"`);
|
901
903
|
return;
|
902
904
|
}
|
903
|
-
if (seenDirs.has(realDirPath)) {
|
905
|
+
if (seenDirs.has(realDirPath.key)) {
|
904
906
|
this._console.warn(`Skipping recursive symlink "${absolutePath}" -> "${realDirPath}"`);
|
905
907
|
return;
|
906
908
|
}
|
907
|
-
seenDirs.add(realDirPath);
|
909
|
+
seenDirs.add(realDirPath.key);
|
908
910
|
try {
|
909
911
|
visitDirectoryUnchecked(absolutePath, includeRegExp, hasDirectoryWildcard);
|
910
912
|
}
|
911
913
|
finally {
|
912
|
-
seenDirs.delete(realDirPath);
|
914
|
+
seenDirs.delete(realDirPath.key);
|
913
915
|
}
|
914
916
|
};
|
915
917
|
include.forEach((includeSpec) => {
|
916
|
-
if (!
|
918
|
+
if (!uriUtils_1.FileSpec.isInPath(includeSpec.wildcardRoot, exclude)) {
|
917
919
|
let foundFileSpec = false;
|
918
|
-
const stat = (0,
|
920
|
+
const stat = (0, uriUtils_1.tryStat)(this.fs, includeSpec.wildcardRoot);
|
919
921
|
if (stat === null || stat === void 0 ? void 0 : stat.isFile()) {
|
920
922
|
results.push(includeSpec.wildcardRoot);
|
921
923
|
foundFileSpec = true;
|
@@ -925,7 +927,7 @@ class AnalyzerService {
|
|
925
927
|
foundFileSpec = true;
|
926
928
|
}
|
927
929
|
if (!foundFileSpec) {
|
928
|
-
this._console.error(`File or directory "${includeSpec.wildcardRoot}" does not exist.`);
|
930
|
+
this._console.error(`File or directory "${includeSpec.wildcardRoot.toUserVisibleString()}" does not exist.`);
|
929
931
|
}
|
930
932
|
}
|
931
933
|
});
|
@@ -944,13 +946,13 @@ class AnalyzerService {
|
|
944
946
|
}
|
945
947
|
if (this._configOptions.include.length > 0) {
|
946
948
|
const fileList = this._configOptions.include.map((spec) => {
|
947
|
-
return
|
949
|
+
return spec.wildcardRoot;
|
948
950
|
});
|
949
951
|
try {
|
950
952
|
if (this._verboseOutput) {
|
951
953
|
this._console.info(`Adding fs watcher for directories:\n ${fileList.join('\n')}`);
|
952
954
|
}
|
953
|
-
const isIgnored = (0, fileWatcher_1.ignoredWatchEventFunction)(fileList);
|
955
|
+
const isIgnored = (0, fileWatcher_1.ignoredWatchEventFunction)(fileList.map((f) => f.getFilePath()));
|
954
956
|
this._sourceFileWatcher = this.fs.createFileSystemWatcher(fileList, (event, path) => {
|
955
957
|
if (!path) {
|
956
958
|
return;
|
@@ -965,21 +967,22 @@ class AnalyzerService {
|
|
965
967
|
if (path.endsWith('.tmp') || path.endsWith('.git') || path.includes(_gitDirectory)) {
|
966
968
|
return;
|
967
969
|
}
|
970
|
+
let uri = uri_1.Uri.file(path, this.fs.isCaseSensitive, /* checkRelative */ true);
|
968
971
|
// Make sure path is the true case.
|
969
|
-
|
970
|
-
const eventInfo = getEventInfo(this.fs, this._console, this._program, event,
|
972
|
+
uri = this.fs.realCasePath(uri);
|
973
|
+
const eventInfo = getEventInfo(this.fs, this._console, this._program, event, uri);
|
971
974
|
if (!eventInfo) {
|
972
975
|
// no-op event, return.
|
973
976
|
return;
|
974
977
|
}
|
975
|
-
if (!this._shouldHandleSourceFileWatchChanges(
|
978
|
+
if (!this._shouldHandleSourceFileWatchChanges(uri, eventInfo.isFile)) {
|
976
979
|
return;
|
977
980
|
}
|
978
981
|
// This is for performance optimization. If the change only pertains to the content of one file,
|
979
982
|
// then it can't affect the 'import resolution' result. All we need to do is reanalyze the related files
|
980
983
|
// (those that have a transitive dependency on this file).
|
981
984
|
if (eventInfo.isFile && eventInfo.event === 'change') {
|
982
|
-
this._backgroundAnalysisProgram.markFilesDirty([
|
985
|
+
this._backgroundAnalysisProgram.markFilesDirty([uri], /* evenIfContentsAreSame */ false);
|
983
986
|
this._scheduleReanalysis(/* requireTrackedFileUpdate */ false);
|
984
987
|
return;
|
985
988
|
}
|
@@ -995,13 +998,15 @@ class AnalyzerService {
|
|
995
998
|
});
|
996
999
|
}
|
997
1000
|
catch {
|
998
|
-
this._console.error(`Exception caught when installing fs watcher for:\n ${fileList
|
1001
|
+
this._console.error(`Exception caught when installing fs watcher for:\n ${fileList
|
1002
|
+
.map((f) => f.toUserVisibleString())
|
1003
|
+
.join('\n')}`);
|
999
1004
|
}
|
1000
1005
|
}
|
1001
1006
|
function getEventInfo(fs, console, program, event, path) {
|
1002
1007
|
// Due to the way we implemented file watcher, we will only get 2 events; 'add' and 'change'.
|
1003
1008
|
// Here, we will convert those 2 to 3 events. 'add', 'change' and 'unlink';
|
1004
|
-
const stats = (0,
|
1009
|
+
const stats = (0, uriUtils_1.tryStat)(fs, path);
|
1005
1010
|
if (event === 'add') {
|
1006
1011
|
if (!stats) {
|
1007
1012
|
// If we are told that the path is added, but if we can't access it, then consider it as already deleted.
|
@@ -1031,7 +1036,7 @@ class AnalyzerService {
|
|
1031
1036
|
}
|
1032
1037
|
_shouldHandleSourceFileWatchChanges(path, isFile) {
|
1033
1038
|
if (isFile) {
|
1034
|
-
if (!(0,
|
1039
|
+
if (!(0, uriUtils_1.hasPythonExtension)(path) || isTemporaryFile(path)) {
|
1035
1040
|
return false;
|
1036
1041
|
}
|
1037
1042
|
// Check whether the file change can affect semantics. If the file changed is not a user file or already a part of
|
@@ -1047,10 +1052,10 @@ class AnalyzerService {
|
|
1047
1052
|
// First, make sure the folder is included. By default, we exclude any folder whose name starts with '.'
|
1048
1053
|
return false;
|
1049
1054
|
}
|
1050
|
-
const parentPath =
|
1055
|
+
const parentPath = path.getDirectory();
|
1051
1056
|
const hasInit = parentPath.startsWith(this._configOptions.projectRoot) &&
|
1052
|
-
(this.fs.existsSync(
|
1053
|
-
this.fs.existsSync(
|
1057
|
+
(this.fs.existsSync(parentPath.combinePaths('__init__.py')) ||
|
1058
|
+
this.fs.existsSync(parentPath.combinePaths('__init__.pyi')));
|
1054
1059
|
// We don't have any file under the given path and its parent folder doesn't have __init__ then this folder change
|
1055
1060
|
// doesn't have any meaning to us.
|
1056
1061
|
if (!hasInit && !this._program.containsSourceFileIn(path)) {
|
@@ -1063,7 +1068,7 @@ class AnalyzerService {
|
|
1063
1068
|
// alongside the original file and name them "x.py.<temp-id>.py" where
|
1064
1069
|
// <temp-id> is a 32-character random string of hex digits. We don't
|
1065
1070
|
// want these events to trigger a full reanalysis.
|
1066
|
-
const fileName =
|
1071
|
+
const fileName = path.fileName;
|
1067
1072
|
const fileNameSplit = fileName.split('.');
|
1068
1073
|
if (fileNameSplit.length === 4) {
|
1069
1074
|
if (fileNameSplit[3] === fileNameSplit[1] && fileNameSplit[2].length === 32) {
|
@@ -1082,20 +1087,20 @@ class AnalyzerService {
|
|
1082
1087
|
_updateLibraryFileWatcher() {
|
1083
1088
|
this._removeLibraryFileWatcher();
|
1084
1089
|
if (!this._watchForLibraryChanges) {
|
1085
|
-
this.
|
1090
|
+
this._librarySearchUrisToWatch = undefined;
|
1086
1091
|
return;
|
1087
1092
|
}
|
1088
1093
|
// Watch the library paths for package install/uninstall.
|
1089
1094
|
const importFailureInfo = [];
|
1090
|
-
this.
|
1091
|
-
/* includeWatchPathsOnly */ true, this.
|
1092
|
-
const watchList = this.
|
1095
|
+
this._librarySearchUrisToWatch = (0, pythonPathUtils_1.findPythonSearchPaths)(this.fs, this._backgroundAnalysisProgram.configOptions, this._backgroundAnalysisProgram.host, importFailureInfo,
|
1096
|
+
/* includeWatchPathsOnly */ true, this._executionRootUri);
|
1097
|
+
const watchList = this._librarySearchUrisToWatch;
|
1093
1098
|
if (watchList && watchList.length > 0) {
|
1094
1099
|
try {
|
1095
1100
|
if (this._verboseOutput) {
|
1096
1101
|
this._console.info(`Adding fs watcher for library directories:\n ${watchList.join('\n')}`);
|
1097
1102
|
}
|
1098
|
-
const isIgnored = (0, fileWatcher_1.ignoredWatchEventFunction)(watchList);
|
1103
|
+
const isIgnored = (0, fileWatcher_1.ignoredWatchEventFunction)(watchList.map((f) => f.getFilePath()));
|
1099
1104
|
this._libraryFileWatcher = this.fs.createFileSystemWatcher(watchList, (event, path) => {
|
1100
1105
|
if (!path) {
|
1101
1106
|
return;
|
@@ -1106,16 +1111,19 @@ class AnalyzerService {
|
|
1106
1111
|
if (isIgnored(path)) {
|
1107
1112
|
return;
|
1108
1113
|
}
|
1109
|
-
|
1114
|
+
const uri = uri_1.Uri.file(path, this.fs.isCaseSensitive, /* checkRelative */ true);
|
1115
|
+
if (!this._shouldHandleLibraryFileWatchChanges(uri, watchList)) {
|
1110
1116
|
return;
|
1111
1117
|
}
|
1112
1118
|
// If file doesn't exist, it is delete.
|
1113
|
-
const isChange = event === 'change' && this.fs.existsSync(
|
1119
|
+
const isChange = event === 'change' && this.fs.existsSync(uri);
|
1114
1120
|
this._scheduleLibraryAnalysis(isChange);
|
1115
1121
|
});
|
1116
1122
|
}
|
1117
1123
|
catch {
|
1118
|
-
this._console.error(`Exception caught when installing fs watcher for:\n ${watchList
|
1124
|
+
this._console.error(`Exception caught when installing fs watcher for:\n ${watchList
|
1125
|
+
.map((w) => w.toUserVisibleString())
|
1126
|
+
.join('\n')}`);
|
1119
1127
|
}
|
1120
1128
|
}
|
1121
1129
|
}
|
@@ -1125,19 +1133,17 @@ class AnalyzerService {
|
|
1125
1133
|
}
|
1126
1134
|
// find the innermost matching search path
|
1127
1135
|
let matchingSearchPath;
|
1128
|
-
const tempFile = this.serviceProvider.tryGet(serviceProviderExtensions_1.ServiceKeys.tempFile);
|
1129
|
-
const ignoreCase = !(0, pathUtils_1.isFileSystemCaseSensitive)(this.fs, tempFile);
|
1130
1136
|
for (const libSearchPath of libSearchPaths) {
|
1131
|
-
if (
|
1132
|
-
(!matchingSearchPath || matchingSearchPath.
|
1137
|
+
if (path.isChild(libSearchPath) &&
|
1138
|
+
(!matchingSearchPath || matchingSearchPath.getPathLength() < libSearchPath.getPathLength())) {
|
1133
1139
|
matchingSearchPath = libSearchPath;
|
1134
1140
|
}
|
1135
1141
|
}
|
1136
1142
|
if (!matchingSearchPath) {
|
1137
1143
|
return true;
|
1138
1144
|
}
|
1139
|
-
const parentComponents =
|
1140
|
-
const childComponents =
|
1145
|
+
const parentComponents = matchingSearchPath.getPathComponents();
|
1146
|
+
const childComponents = path.getPathComponents();
|
1141
1147
|
for (let i = parentComponents.length; i < childComponents.length; i++) {
|
1142
1148
|
if (childComponents[i].startsWith('.')) {
|
1143
1149
|
return false;
|
@@ -1193,16 +1199,16 @@ class AnalyzerService {
|
|
1193
1199
|
if (!this._watchForConfigChanges) {
|
1194
1200
|
return;
|
1195
1201
|
}
|
1196
|
-
if (this.
|
1197
|
-
this._configFileWatcher = this.fs.createFileSystemWatcher([this.
|
1202
|
+
if (this._configFileUri) {
|
1203
|
+
this._configFileWatcher = this.fs.createFileSystemWatcher([this._configFileUri], (event) => {
|
1198
1204
|
if (this._verboseOutput) {
|
1199
1205
|
this._console.info(`Received fs event '${event}' for config file`);
|
1200
1206
|
}
|
1201
1207
|
this._scheduleReloadConfigFile();
|
1202
1208
|
});
|
1203
1209
|
}
|
1204
|
-
else if (this.
|
1205
|
-
this._configFileWatcher = this.fs.createFileSystemWatcher([this.
|
1210
|
+
else if (this._executionRootUri) {
|
1211
|
+
this._configFileWatcher = this.fs.createFileSystemWatcher([this._executionRootUri], (event, path) => {
|
1206
1212
|
if (!path) {
|
1207
1213
|
return;
|
1208
1214
|
}
|
@@ -1239,8 +1245,8 @@ class AnalyzerService {
|
|
1239
1245
|
}
|
1240
1246
|
_reloadConfigFile() {
|
1241
1247
|
this._updateConfigFileWatcher();
|
1242
|
-
if (this.
|
1243
|
-
this._console.info(`Reloading configuration file at ${this.
|
1248
|
+
if (this._configFileUri) {
|
1249
|
+
this._console.info(`Reloading configuration file at ${this._configFileUri.toUserVisibleString()}`);
|
1244
1250
|
const host = this._backgroundAnalysisProgram.host;
|
1245
1251
|
// We can't just reload config file when it is changed; we need to consider
|
1246
1252
|
// command line options as well to construct new config Options.
|
@@ -1261,7 +1267,7 @@ class AnalyzerService {
|
|
1261
1267
|
(0, console_1.log)(this._console, logLevel, `Search paths for ${execEnv.root || '<default>'}`);
|
1262
1268
|
const roots = importResolver.getImportRoots(execEnv, /* forLogging */ true);
|
1263
1269
|
roots.forEach((path) => {
|
1264
|
-
(0, console_1.log)(this._console, logLevel, ` ${path}`);
|
1270
|
+
(0, console_1.log)(this._console, logLevel, ` ${path.toUserVisibleString()}`);
|
1265
1271
|
});
|
1266
1272
|
}
|
1267
1273
|
}
|