@zzzen/pyright-internal 1.2.0-dev.20250413 → 1.2.0-dev.20250802
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 +0 -1
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/analyzerNodeInfo.js +1 -1
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/binder.d.ts +2 -1
- package/dist/analyzer/binder.js +45 -38
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +81 -44
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +19 -7
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/codeFlowTypes.d.ts +9 -8
- package/dist/analyzer/codeFlowTypes.js +9 -8
- package/dist/analyzer/codeFlowTypes.js.map +1 -1
- package/dist/analyzer/codeFlowUtils.js +4 -2
- package/dist/analyzer/codeFlowUtils.js.map +1 -1
- package/dist/analyzer/dataClasses.js +7 -2
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/docStringUtils.js +3 -1
- package/dist/analyzer/docStringUtils.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +0 -1
- package/dist/analyzer/importResolver.js +2 -25
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importResult.d.ts +0 -1
- package/dist/analyzer/importStatementUtils.js +5 -3
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +10 -0
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +1 -1
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +5 -3
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.js +10 -3
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +3 -4
- package/dist/analyzer/parseTreeUtils.js +19 -225
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +4 -0
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +12 -2
- package/dist/analyzer/program.js +78 -75
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/programTypes.d.ts +2 -2
- package/dist/analyzer/programTypes.js.map +1 -1
- package/dist/analyzer/properties.js +3 -5
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +13 -3
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/sentinel.d.ts +4 -0
- package/dist/analyzer/sentinel.js +51 -0
- package/dist/analyzer/sentinel.js.map +1 -0
- package/dist/analyzer/service.d.ts +2 -2
- package/dist/analyzer/service.js +7 -6
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +5 -2
- package/dist/analyzer/sourceFile.js +53 -15
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfo.d.ts +10 -1
- package/dist/analyzer/sourceFileInfo.js +28 -0
- package/dist/analyzer/sourceFileInfo.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js +4 -4
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.d.ts +1 -1
- package/dist/analyzer/sourceMapper.js +20 -20
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/symbol.d.ts +3 -0
- package/dist/analyzer/symbol.js +11 -0
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/testWalker.js +2 -13
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +1 -1
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +278 -147
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +8 -4
- package/dist/analyzer/typeEvaluatorTypes.js +15 -2
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +47 -13
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +10 -2
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typePrinterUtils.js +2 -2
- package/dist/analyzer/typePrinterUtils.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +2 -0
- package/dist/analyzer/typeUtils.js +14 -3
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +9 -5
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +9 -2
- package/dist/analyzer/types.js +39 -1
- package/dist/analyzer/types.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.d.ts +96 -0
- package/dist/commands/dumpFileDebugInfoCommand.js +13 -2
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/common/cancellationUtils.d.ts +1 -1
- package/dist/common/cancellationUtils.js +2 -2
- package/dist/common/cancellationUtils.js.map +1 -1
- package/dist/common/charCodes.d.ts +1 -1
- package/dist/common/charCodes.js +1 -1
- package/dist/common/charCodes.js.map +1 -1
- package/dist/common/configOptions.d.ts +1 -0
- package/dist/common/configOptions.js +5 -0
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/core.d.ts +1 -3
- package/dist/common/core.js +3 -4
- package/dist/common/core.js.map +1 -1
- package/dist/common/diagnostic.d.ts +1 -1
- package/dist/common/diagnosticRules.d.ts +1 -0
- package/dist/common/diagnosticRules.js +1 -0
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/common/docRange.d.ts +6 -0
- package/dist/common/docRange.js +10 -0
- package/dist/common/docRange.js.map +1 -0
- package/dist/common/envVarUtils.js +1 -6
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +11 -2
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileBasedCancellationUtils.d.ts +1 -0
- package/dist/common/fileBasedCancellationUtils.js +1 -0
- package/dist/common/fileBasedCancellationUtils.js.map +1 -1
- package/dist/common/logTracker.d.ts +5 -1
- package/dist/common/logTracker.js +43 -26
- package/dist/common/logTracker.js.map +1 -1
- package/dist/common/pathUtils.d.ts +1 -1
- package/dist/common/pathUtils.js +3 -2
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/realFileSystem.d.ts +1 -1
- package/dist/common/realFileSystem.js +2 -1
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProviderExtensions.js +2 -2
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/common/stringUtils.d.ts +0 -1
- package/dist/common/stringUtils.js +0 -42
- package/dist/common/stringUtils.js.map +1 -1
- package/dist/common/textEditTracker.js +5 -3
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/textRange.d.ts +5 -11
- package/dist/common/textRange.js +31 -56
- package/dist/common/textRange.js.map +1 -1
- package/dist/common/textRangeCollection.js +3 -2
- package/dist/common/textRangeCollection.js.map +1 -1
- package/dist/common/uri/baseUri.js +2 -1
- package/dist/common/uri/baseUri.js.map +1 -1
- package/dist/common/uri/uri.d.ts +5 -2
- package/dist/common/uri/uri.js +21 -5
- package/dist/common/uri/uri.js.map +1 -1
- package/dist/common/uri/uriUtils.d.ts +2 -2
- package/dist/common/uri/uriUtils.js +4 -3
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/common/workspaceEditUtils.js +9 -9
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +5 -3
- package/dist/languageServerBase.js +44 -37
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.d.ts +3 -0
- package/dist/languageService/analyzerServiceExecutor.js +1 -0
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.d.ts +2 -2
- package/dist/languageService/autoImporter.js +3 -3
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +2 -3
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +16 -13
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/definitionProvider.d.ts +2 -1
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.d.ts +4 -1
- package/dist/languageService/documentSymbolCollector.js +9 -7
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/hoverProvider.js +1 -9
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importSorter.js +1 -0
- package/dist/languageService/importSorter.js.map +1 -1
- package/dist/languageService/navigationUtils.d.ts +1 -1
- package/dist/languageService/referencesProvider.d.ts +2 -1
- package/dist/languageService/referencesProvider.js +8 -7
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.js +4 -19
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.d.ts +2 -0
- package/dist/languageService/tooltipUtils.js +2 -0
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/languageService/workspaceSymbolProvider.js +1 -1
- package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +16 -2
- package/dist/localization/localize.js +16 -2
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +23 -9
- package/dist/localization/package.nls.de.json +18 -4
- package/dist/localization/package.nls.en-us.json +53 -3
- package/dist/localization/package.nls.es.json +18 -4
- package/dist/localization/package.nls.fr.json +22 -8
- package/dist/localization/package.nls.it.json +23 -9
- package/dist/localization/package.nls.ja.json +18 -4
- package/dist/localization/package.nls.ko.json +23 -9
- package/dist/localization/package.nls.pl.json +18 -4
- package/dist/localization/package.nls.pt-br.json +18 -4
- package/dist/localization/package.nls.qps-ploc.json +17 -3
- package/dist/localization/package.nls.ru.json +18 -4
- package/dist/localization/package.nls.tr.json +23 -9
- package/dist/localization/package.nls.zh-cn.json +18 -4
- package/dist/localization/package.nls.zh-tw.json +18 -4
- package/dist/parser/characters.d.ts +1 -8
- package/dist/parser/characters.js +6 -3
- package/dist/parser/characters.js.map +1 -1
- package/dist/parser/parseNodeUtils.d.ts +12 -0
- package/dist/parser/parseNodeUtils.js +136 -0
- package/dist/parser/parseNodeUtils.js.map +1 -0
- package/dist/parser/parseNodes.d.ts +12 -2
- package/dist/parser/parseNodes.js +17 -2
- package/dist/parser/parseNodes.js.map +1 -1
- package/dist/parser/parser.d.ts +5 -2
- package/dist/parser/parser.js +83 -47
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/tokenizer.d.ts +3 -3
- package/dist/parser/tokenizer.js +58 -38
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/parser/tokenizerTypes.d.ts +4 -3
- package/dist/parser/tokenizerTypes.js +4 -3
- package/dist/parser/tokenizerTypes.js.map +1 -1
- package/dist/pyright.js +1 -1
- package/dist/pyright.js.map +1 -1
- package/dist/server.js +3 -3
- package/dist/server.js.map +1 -1
- package/dist/tests/checker.test.js +2 -2
- package/dist/tests/common.test.js +6 -6
- package/dist/tests/common.test.js.map +1 -1
- package/dist/tests/fourslash/completions.autoimport.unicode.fourslash.js +29 -0
- package/dist/tests/fourslash/completions.autoimport.unicode.fourslash.js.map +1 -0
- package/dist/tests/fourslash/completions.declNames.method.fourslash.js +8 -8
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.js +0 -18
- package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +3 -2
- package/dist/tests/harness/fourslash/testState.js +9 -3
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/lsp/languageServer.js +1 -1
- package/dist/tests/lsp/languageServer.js.map +1 -1
- package/dist/tests/lsp/languageServerTestUtils.d.ts +1 -2
- package/dist/tests/lsp/languageServerTestUtils.js +2 -2
- package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
- package/dist/tests/parser.test.js +17 -0
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/positionUtils.test.js +1 -1
- package/dist/tests/service.test.js +4 -4
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +21 -4
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/stringUtils.test.js +0 -12
- package/dist/tests/stringUtils.test.js.map +1 -1
- package/dist/tests/testStateUtils.js +8 -3
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/testUtils.js +1 -1
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/tokenizer.test.js +5 -5
- package/dist/tests/tokenizer.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +11 -13
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +15 -1
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +16 -1
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +10 -4
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/typeEvaluator6.test.js +1 -1
- package/dist/tests/typeEvaluator7.test.js +9 -0
- package/dist/tests/typeEvaluator7.test.js.map +1 -1
- package/dist/tests/typeEvaluator8.test.js +8 -0
- package/dist/tests/typeEvaluator8.test.js.map +1 -1
- package/dist/tests/workspaceEditUtils.test.js +7 -9
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/workspaceFactory.d.ts +12 -1
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +2 -3
- package/dist/tests/fourslash/rename.args.fourslash.js +0 -72
- package/dist/tests/fourslash/rename.args.fourslash.js.map +0 -1
- /package/dist/tests/fourslash/{rename.args.fourslash.d.ts → completions.autoimport.unicode.fourslash.d.ts} +0 -0
|
@@ -8,7 +8,7 @@ import { EditableProgram, ProgramView } from '../common/extensibility';
|
|
|
8
8
|
import { LogTracker } from '../common/logTracker';
|
|
9
9
|
import { ServiceProvider } from '../common/serviceProvider';
|
|
10
10
|
import '../common/serviceProviderExtensions';
|
|
11
|
-
import { Range } from '../common/textRange';
|
|
11
|
+
import { Range, TextRange } from '../common/textRange';
|
|
12
12
|
import { Uri } from '../common/uri/uri';
|
|
13
13
|
import { ParseFileResults, ParserOutput } from '../parser/parser';
|
|
14
14
|
import { RequiringAnalysisCount } from './analysis';
|
|
@@ -16,7 +16,7 @@ import { ImportResolver } from './importResolver';
|
|
|
16
16
|
import { IPythonMode, SourceFile } from './sourceFile';
|
|
17
17
|
import { SourceFileInfo } from './sourceFileInfo';
|
|
18
18
|
import { SourceMapper } from './sourceMapper';
|
|
19
|
-
import { Symbol } from './symbol';
|
|
19
|
+
import { Symbol, SymbolTable } from './symbol';
|
|
20
20
|
import { PrintTypeOptions, TypeEvaluator } from './typeEvaluatorTypes';
|
|
21
21
|
import { Type } from './types';
|
|
22
22
|
export interface MaxAnalysisTime {
|
|
@@ -24,10 +24,15 @@ export interface MaxAnalysisTime {
|
|
|
24
24
|
noOpenFilesTimeInMs: number;
|
|
25
25
|
}
|
|
26
26
|
export type PreCheckCallback = (parserOutput: ParserOutput, evaluator: TypeEvaluator) => void;
|
|
27
|
+
export interface ChangedRange {
|
|
28
|
+
range: TextRange;
|
|
29
|
+
delta: number;
|
|
30
|
+
}
|
|
27
31
|
export interface OpenFileOptions {
|
|
28
32
|
isTracked: boolean;
|
|
29
33
|
ipythonMode: IPythonMode;
|
|
30
34
|
chainedFileUri: Uri | undefined;
|
|
35
|
+
changedRange?: ChangedRange;
|
|
31
36
|
}
|
|
32
37
|
export declare class Program {
|
|
33
38
|
readonly serviceProvider: ServiceProvider;
|
|
@@ -43,6 +48,7 @@ export declare class Program {
|
|
|
43
48
|
private _configOptions;
|
|
44
49
|
private _importResolver;
|
|
45
50
|
private _evaluator;
|
|
51
|
+
private _disposed;
|
|
46
52
|
private _parsedFileCount;
|
|
47
53
|
private _preCheckCallback;
|
|
48
54
|
private _editModeTracker;
|
|
@@ -55,6 +61,7 @@ export declare class Program {
|
|
|
55
61
|
get configOptions(): ConfigOptions;
|
|
56
62
|
get importResolver(): ImportResolver;
|
|
57
63
|
get fileSystem(): import("../common/fileSystem").FileSystem;
|
|
64
|
+
get isDisposed(): boolean;
|
|
58
65
|
dispose(): void;
|
|
59
66
|
enterEditMode(): void;
|
|
60
67
|
exitEditMode(): FileEditAction[];
|
|
@@ -87,6 +94,7 @@ export declare class Program {
|
|
|
87
94
|
getBoundSourceFile(uri: Uri): SourceFile | undefined;
|
|
88
95
|
getSourceFileInfoList(): readonly SourceFileInfo[];
|
|
89
96
|
getSourceFileInfo(uri: Uri): SourceFileInfo | undefined;
|
|
97
|
+
getModuleSymbolTable(fileUri: Uri): SymbolTable | undefined;
|
|
90
98
|
getBoundSourceFileInfo(uri: Uri, content?: string, force?: boolean): SourceFileInfo | undefined;
|
|
91
99
|
analyze(maxTime?: MaxAnalysisTime, token?: CancellationToken): boolean;
|
|
92
100
|
analyzeFile(fileUri: Uri, token?: CancellationToken): boolean;
|
|
@@ -96,6 +104,7 @@ export declare class Program {
|
|
|
96
104
|
getSourceMapper(fileUri: Uri, token: CancellationToken, mapCompiled?: boolean, preferStubs?: boolean): SourceMapper;
|
|
97
105
|
getParserOutput(fileUri: Uri): ParserOutput | undefined;
|
|
98
106
|
getParseResults(fileUri: Uri): ParseFileResults | undefined;
|
|
107
|
+
getParseDiagnostics(fileUri: Uri): Diagnostic[] | undefined;
|
|
99
108
|
handleMemoryHighUsage(): void;
|
|
100
109
|
printDetailedAnalysisTimes(): void;
|
|
101
110
|
printDependencies(projectRootDir: Uri, verbose: boolean): void;
|
|
@@ -108,6 +117,7 @@ export declare class Program {
|
|
|
108
117
|
clone(): Program;
|
|
109
118
|
getCacheUsage(): number;
|
|
110
119
|
emptyCache(): void;
|
|
120
|
+
bindShadowFile(stubFileUri: Uri, shadowFile: Uri): SourceFile | undefined;
|
|
111
121
|
private _handleMemoryHighUsage;
|
|
112
122
|
private _discardCachedParseResults;
|
|
113
123
|
private _runEvaluatorWithCancellationToken;
|
package/dist/analyzer/program.js
CHANGED
|
@@ -97,6 +97,7 @@ class Program {
|
|
|
97
97
|
this._disableChecker = _disableChecker;
|
|
98
98
|
this._sourceFileList = [];
|
|
99
99
|
this._sourceFileMap = new Map();
|
|
100
|
+
this._disposed = false;
|
|
100
101
|
this._parsedFileCount = 0;
|
|
101
102
|
this._editModeTracker = new EditModeTracker();
|
|
102
103
|
this._lookUpImport = (fileUriOrModule, options) => {
|
|
@@ -198,8 +199,12 @@ class Program {
|
|
|
198
199
|
get fileSystem() {
|
|
199
200
|
return this._importResolver.fileSystem;
|
|
200
201
|
}
|
|
202
|
+
get isDisposed() {
|
|
203
|
+
return this._disposed;
|
|
204
|
+
}
|
|
201
205
|
dispose() {
|
|
202
206
|
this._cacheManager.unregisterCacheOwner(this);
|
|
207
|
+
this._disposed = true;
|
|
203
208
|
}
|
|
204
209
|
enterEditMode() {
|
|
205
210
|
this._editModeTracker.enable();
|
|
@@ -218,10 +223,10 @@ class Program {
|
|
|
218
223
|
const newContents = fileInfo.restore();
|
|
219
224
|
if (newContents) {
|
|
220
225
|
// Create a text document so we can compute the edits.
|
|
221
|
-
const textDocument = vscode_languageserver_textdocument_1.TextDocument.create(fileInfo.
|
|
226
|
+
const textDocument = vscode_languageserver_textdocument_1.TextDocument.create(fileInfo.uri.toString(), 'python', 1, fileInfo.contents || '');
|
|
222
227
|
// Add an edit action to the list.
|
|
223
228
|
edits.push({
|
|
224
|
-
fileUri: fileInfo.
|
|
229
|
+
fileUri: fileInfo.uri,
|
|
225
230
|
range: {
|
|
226
231
|
start: { line: 0, character: 0 },
|
|
227
232
|
end: { line: textDocument.lineCount, character: 0 },
|
|
@@ -239,7 +244,7 @@ class Program {
|
|
|
239
244
|
// We don't need to care about file diagnostics since in edit mode
|
|
240
245
|
// checker won't run.
|
|
241
246
|
v.sourceFile.prepareForClose();
|
|
242
|
-
this._removeSourceFileFromListAndMap(v.
|
|
247
|
+
this._removeSourceFileFromListAndMap(v.uri, i);
|
|
243
248
|
}
|
|
244
249
|
}
|
|
245
250
|
}
|
|
@@ -273,7 +278,7 @@ class Program {
|
|
|
273
278
|
// Files that are not in the tracked file list are
|
|
274
279
|
// marked as no longer tracked.
|
|
275
280
|
this._sourceFileList.forEach((oldFile) => {
|
|
276
|
-
const fileUri = oldFile.
|
|
281
|
+
const fileUri = oldFile.uri;
|
|
277
282
|
if (!newFileMap.has(fileUri.key)) {
|
|
278
283
|
oldFile.isTracked = false;
|
|
279
284
|
}
|
|
@@ -321,10 +326,8 @@ class Program {
|
|
|
321
326
|
sourceFileInfo.isTracked = true;
|
|
322
327
|
return sourceFileInfo.sourceFile;
|
|
323
328
|
}
|
|
324
|
-
const sourceFile = this._sourceFileFactory.createSourceFile(this.serviceProvider, fileUri, importName, isThirdPartyImport, isInPyTypedPackage,
|
|
325
|
-
|
|
326
|
-
sourceFileInfo = new sourceFileInfo_1.SourceFileInfo(sourceFile,
|
|
327
|
-
/* isTypeshedFile */ false, isThirdPartyImport, isInPyTypedPackage, this._editModeTracker, {
|
|
329
|
+
const sourceFile = this._sourceFileFactory.createSourceFile(this.serviceProvider, fileUri, importName, isThirdPartyImport, isInPyTypedPackage, this._editModeTracker, this._console, this._logTracker);
|
|
330
|
+
sourceFileInfo = new sourceFileInfo_1.SourceFileInfo(sourceFile, sourceFile.isTypingStubFile() || sourceFile.isTypeshedStubFile() || sourceFile.isBuiltInStubFile(), isThirdPartyImport, isInPyTypedPackage, this._editModeTracker, {
|
|
328
331
|
isTracked: true,
|
|
329
332
|
});
|
|
330
333
|
this._addToSourceFileListAndMap(sourceFileInfo);
|
|
@@ -335,7 +338,7 @@ class Program {
|
|
|
335
338
|
if (!sourceFileInfo) {
|
|
336
339
|
const moduleImportInfo = this._getModuleImportInfoForFile(fileUri);
|
|
337
340
|
const sourceFile = this._sourceFileFactory.createSourceFile(this.serviceProvider, fileUri, moduleImportInfo.moduleName,
|
|
338
|
-
/* isThirdPartyImport */ false, moduleImportInfo.isThirdPartyPyTypedPresent,
|
|
341
|
+
/* isThirdPartyImport */ false, moduleImportInfo.isThirdPartyPyTypedPresent, this._editModeTracker, this._console, this._logTracker, options?.ipythonMode ?? sourceFile_1.IPythonMode.None);
|
|
339
342
|
const chainedFilePath = options?.chainedFileUri;
|
|
340
343
|
sourceFileInfo = new sourceFileInfo_1.SourceFileInfo(sourceFile,
|
|
341
344
|
/* isTypeshedFile */ false,
|
|
@@ -360,7 +363,7 @@ class Program {
|
|
|
360
363
|
}
|
|
361
364
|
getChainedUri(fileUri) {
|
|
362
365
|
const sourceFileInfo = this.getSourceFileInfo(fileUri);
|
|
363
|
-
return sourceFileInfo?.chainedSourceFile?.
|
|
366
|
+
return sourceFileInfo?.chainedSourceFile?.uri;
|
|
364
367
|
}
|
|
365
368
|
updateChainedUri(fileUri, chainedFileUri) {
|
|
366
369
|
const sourceFileInfo = this.getSourceFileInfo(fileUri);
|
|
@@ -452,10 +455,10 @@ class Program {
|
|
|
452
455
|
return this._sourceFileList.filter((s) => s.isOpenByClient);
|
|
453
456
|
}
|
|
454
457
|
getOwnedFiles() {
|
|
455
|
-
return this._sourceFileList.filter((s) => (0, sourceFileInfoUtils_1.isUserCode)(s) && this.owns(s.
|
|
458
|
+
return this._sourceFileList.filter((s) => (0, sourceFileInfoUtils_1.isUserCode)(s) && this.owns(s.uri));
|
|
456
459
|
}
|
|
457
460
|
getCheckingRequiredFiles() {
|
|
458
|
-
return this._sourceFileList.filter((s) => s.isOpenByClient && this.owns(s.
|
|
461
|
+
return this._sourceFileList.filter((s) => s.isOpenByClient && this.owns(s.uri) && s.sourceFile.isCheckingRequired());
|
|
459
462
|
}
|
|
460
463
|
getFilesToAnalyzeCount() {
|
|
461
464
|
let filesToAnalyzeCount = 0;
|
|
@@ -486,7 +489,7 @@ class Program {
|
|
|
486
489
|
}
|
|
487
490
|
containsSourceFileIn(folder) {
|
|
488
491
|
for (const normalizedSourceFilePath of this._sourceFileMap.values()) {
|
|
489
|
-
if (normalizedSourceFilePath.
|
|
492
|
+
if (normalizedSourceFilePath.uri.startsWith(folder)) {
|
|
490
493
|
return true;
|
|
491
494
|
}
|
|
492
495
|
}
|
|
@@ -520,6 +523,13 @@ class Program {
|
|
|
520
523
|
}
|
|
521
524
|
return undefined;
|
|
522
525
|
}
|
|
526
|
+
getModuleSymbolTable(fileUri) {
|
|
527
|
+
const sourceFileInfo = this.getSourceFileInfo(fileUri);
|
|
528
|
+
if (sourceFileInfo) {
|
|
529
|
+
return sourceFileInfo.sourceFile.getModuleSymbolTable();
|
|
530
|
+
}
|
|
531
|
+
return undefined;
|
|
532
|
+
}
|
|
523
533
|
getBoundSourceFileInfo(uri, content, force) {
|
|
524
534
|
const sourceFileInfo = this.getSourceFileInfo(uri);
|
|
525
535
|
if (!sourceFileInfo) {
|
|
@@ -620,6 +630,11 @@ class Program {
|
|
|
620
630
|
/* content */ undefined,
|
|
621
631
|
/* force */ true)?.sourceFile.getParseResults();
|
|
622
632
|
}
|
|
633
|
+
getParseDiagnostics(fileUri) {
|
|
634
|
+
return this.getBoundSourceFileInfo(fileUri,
|
|
635
|
+
/* content */ undefined,
|
|
636
|
+
/* force */ true)?.sourceFile.getParseDiagnostics();
|
|
637
|
+
}
|
|
623
638
|
handleMemoryHighUsage() {
|
|
624
639
|
this._handleMemoryHighUsage();
|
|
625
640
|
}
|
|
@@ -635,7 +650,7 @@ class Program {
|
|
|
635
650
|
this._console.info('Analysis time by file');
|
|
636
651
|
sortedFiles.forEach((sfInfo) => {
|
|
637
652
|
const checkTimeInMs = sfInfo.sourceFile.getCheckTime();
|
|
638
|
-
this._console.info(`${checkTimeInMs}ms: ${sfInfo.
|
|
653
|
+
this._console.info(`${checkTimeInMs}ms: ${sfInfo.uri}`);
|
|
639
654
|
});
|
|
640
655
|
}
|
|
641
656
|
// Prints import dependency information for each of the files in
|
|
@@ -645,12 +660,12 @@ class Program {
|
|
|
645
660
|
const sortedFiles = this._sourceFileList
|
|
646
661
|
.filter((s) => !s.isTypeshedFile)
|
|
647
662
|
.sort((a, b) => {
|
|
648
|
-
return fs.getOriginalUri(a.
|
|
663
|
+
return fs.getOriginalUri(a.uri) < fs.getOriginalUri(b.uri) ? 1 : -1;
|
|
649
664
|
});
|
|
650
665
|
const zeroImportFiles = [];
|
|
651
666
|
sortedFiles.forEach((sfInfo) => {
|
|
652
667
|
this._console.info('');
|
|
653
|
-
const fileUri = fs.getOriginalUri(sfInfo.
|
|
668
|
+
const fileUri = fs.getOriginalUri(sfInfo.uri);
|
|
654
669
|
let fileString = fileUri.toString();
|
|
655
670
|
const relPath = projectRootDir.getRelativePathComponents(fileUri);
|
|
656
671
|
if (relPath) {
|
|
@@ -660,13 +675,13 @@ class Program {
|
|
|
660
675
|
this._console.info(` Imports ${sfInfo.imports.length} ` + `file${sfInfo.imports.length === 1 ? '' : 's'}`);
|
|
661
676
|
if (verbose) {
|
|
662
677
|
sfInfo.imports.forEach((importInfo) => {
|
|
663
|
-
this._console.info(` ${fs.getOriginalUri(importInfo.
|
|
678
|
+
this._console.info(` ${fs.getOriginalUri(importInfo.uri)}`);
|
|
664
679
|
});
|
|
665
680
|
}
|
|
666
681
|
this._console.info(` Imported by ${sfInfo.importedBy.length} ` + `file${sfInfo.importedBy.length === 1 ? '' : 's'}`);
|
|
667
682
|
if (verbose) {
|
|
668
683
|
sfInfo.importedBy.forEach((importInfo) => {
|
|
669
|
-
this._console.info(` ${fs.getOriginalUri(importInfo.
|
|
684
|
+
this._console.info(` ${fs.getOriginalUri(importInfo.uri)}`);
|
|
670
685
|
});
|
|
671
686
|
}
|
|
672
687
|
if (sfInfo.importedBy.length === 0) {
|
|
@@ -684,7 +699,7 @@ class Program {
|
|
|
684
699
|
writeTypeStub(targetImportPath, targetIsSingleFile, stubPath, token) {
|
|
685
700
|
for (const sourceFileInfo of this._sourceFileList) {
|
|
686
701
|
(0, cancellationUtils_1.throwIfCancellationRequested)(token);
|
|
687
|
-
const fileUri = sourceFileInfo.
|
|
702
|
+
const fileUri = sourceFileInfo.uri;
|
|
688
703
|
// Generate type stubs only for the files within the target path,
|
|
689
704
|
// not any files that the target module happened to import.
|
|
690
705
|
const relativePath = targetImportPath.getRelativePath(fileUri);
|
|
@@ -762,7 +777,7 @@ class Program {
|
|
|
762
777
|
diag.category !== 5 /* DiagnosticCategory.Deprecated */);
|
|
763
778
|
}
|
|
764
779
|
fileDiagnostics.push({
|
|
765
|
-
fileUri: sourceFileInfo.
|
|
780
|
+
fileUri: sourceFileInfo.uri,
|
|
766
781
|
version: sourceFileInfo.sourceFile.getClientVersion(),
|
|
767
782
|
diagnostics,
|
|
768
783
|
});
|
|
@@ -777,7 +792,7 @@ class Program {
|
|
|
777
792
|
// This condition occurs when the user switches from workspace to
|
|
778
793
|
// "open files only" mode. Clear all diagnostics for this file.
|
|
779
794
|
fileDiagnostics.push({
|
|
780
|
-
fileUri: sourceFileInfo.
|
|
795
|
+
fileUri: sourceFileInfo.uri,
|
|
781
796
|
version: sourceFileInfo.sourceFile.getClientVersion(),
|
|
782
797
|
diagnostics: [],
|
|
783
798
|
});
|
|
@@ -803,7 +818,7 @@ class Program {
|
|
|
803
818
|
const program = new Program(this._importResolver, this._configOptions, this.serviceProvider, new logTracker_1.LogTracker(this._console, 'Cloned'), this._disableChecker);
|
|
804
819
|
// Cloned program will use whatever user files the program currently has.
|
|
805
820
|
const userFiles = this.getUserFiles();
|
|
806
|
-
program.setTrackedFiles(userFiles.map((i) => i.
|
|
821
|
+
program.setTrackedFiles(userFiles.map((i) => i.uri));
|
|
807
822
|
program.markAllFilesDirty(/* evenIfContentsAreSame */ true);
|
|
808
823
|
// Make sure we keep editor content (open file) which could be different than one in the file system.
|
|
809
824
|
for (const fileInfo of this.getOpened()) {
|
|
@@ -811,9 +826,9 @@ class Program {
|
|
|
811
826
|
if (version === undefined) {
|
|
812
827
|
continue;
|
|
813
828
|
}
|
|
814
|
-
program.setFileOpened(fileInfo.
|
|
815
|
-
chainedFileUri: fileInfo.chainedSourceFile?.
|
|
816
|
-
ipythonMode: fileInfo.
|
|
829
|
+
program.setFileOpened(fileInfo.uri, version, fileInfo.sourceFile.getOpenFileContents() ?? '', {
|
|
830
|
+
chainedFileUri: fileInfo.chainedSourceFile?.uri,
|
|
831
|
+
ipythonMode: fileInfo.ipythonMode,
|
|
817
832
|
isTracked: fileInfo.isTracked,
|
|
818
833
|
});
|
|
819
834
|
}
|
|
@@ -836,6 +851,20 @@ class Program {
|
|
|
836
851
|
this._parsedFileCount = 0;
|
|
837
852
|
this.serviceProvider.tryGet(serviceKeys_1.ServiceKeys.stateMutationListeners)?.forEach((l) => l.onClearCache?.());
|
|
838
853
|
}
|
|
854
|
+
bindShadowFile(stubFileUri, shadowFile) {
|
|
855
|
+
let stubFileInfo = this.getSourceFileInfo(stubFileUri);
|
|
856
|
+
if (!stubFileInfo) {
|
|
857
|
+
// make sure uri exits before adding interimFile
|
|
858
|
+
if (!this.fileSystem.existsSync(stubFileUri)) {
|
|
859
|
+
return undefined;
|
|
860
|
+
}
|
|
861
|
+
// Special case for import statement like "import X.Y". The SourceFile
|
|
862
|
+
// for X might not be in memory since import `X.Y` only brings in Y.
|
|
863
|
+
stubFileInfo = this.addInterimFile(stubFileUri);
|
|
864
|
+
}
|
|
865
|
+
this._addShadowedFile(stubFileInfo, shadowFile);
|
|
866
|
+
return this.getBoundSourceFile(shadowFile);
|
|
867
|
+
}
|
|
839
868
|
_handleMemoryHighUsage() {
|
|
840
869
|
const cacheUsage = this._cacheManager.getCacheUsage();
|
|
841
870
|
const usedHeapRatio = this._cacheManager.getUsedHeapRatio(this._configOptions.verboseOutput ? this._console : undefined);
|
|
@@ -899,13 +928,13 @@ class Program {
|
|
|
899
928
|
// Clear only if there are any errors for this file.
|
|
900
929
|
if (fileInfo.diagnosticsVersion !== undefined) {
|
|
901
930
|
fileDiagnostics.push({
|
|
902
|
-
fileUri: fileInfo.
|
|
931
|
+
fileUri: fileInfo.uri,
|
|
903
932
|
version: fileInfo.sourceFile.getClientVersion(),
|
|
904
933
|
diagnostics: [],
|
|
905
934
|
});
|
|
906
935
|
}
|
|
907
936
|
fileInfo.sourceFile.prepareForClose();
|
|
908
|
-
this._removeSourceFileFromListAndMap(fileInfo.
|
|
937
|
+
this._removeSourceFileFromListAndMap(fileInfo.uri, i);
|
|
909
938
|
// Unlink any imports and remove them from the list if
|
|
910
939
|
// they are no longer referenced.
|
|
911
940
|
fileInfo.imports.forEach((importedFile) => {
|
|
@@ -923,13 +952,13 @@ class Program {
|
|
|
923
952
|
// Clear if there are any errors for this import.
|
|
924
953
|
if (importedFile.diagnosticsVersion !== undefined) {
|
|
925
954
|
fileDiagnostics.push({
|
|
926
|
-
fileUri: importedFile.
|
|
955
|
+
fileUri: importedFile.uri,
|
|
927
956
|
version: importedFile.sourceFile.getClientVersion(),
|
|
928
957
|
diagnostics: [],
|
|
929
958
|
});
|
|
930
959
|
}
|
|
931
960
|
importedFile.sourceFile.prepareForClose();
|
|
932
|
-
this._removeSourceFileFromListAndMap(importedFile.
|
|
961
|
+
this._removeSourceFileFromListAndMap(importedFile.uri, indexToRemove);
|
|
933
962
|
i--;
|
|
934
963
|
}
|
|
935
964
|
}
|
|
@@ -945,7 +974,7 @@ class Program {
|
|
|
945
974
|
// out the errors for the now-closed file.
|
|
946
975
|
if (!this._shouldCheckFile(fileInfo) && fileInfo.diagnosticsVersion !== undefined) {
|
|
947
976
|
fileDiagnostics.push({
|
|
948
|
-
fileUri: fileInfo.
|
|
977
|
+
fileUri: fileInfo.uri,
|
|
949
978
|
version: fileInfo.sourceFile.getClientVersion(),
|
|
950
979
|
diagnostics: [],
|
|
951
980
|
});
|
|
@@ -979,7 +1008,7 @@ class Program {
|
|
|
979
1008
|
if (fileInfo.isTracked || fileInfo.isOpenByClient || fileInfo.shadows.length > 0) {
|
|
980
1009
|
return true;
|
|
981
1010
|
}
|
|
982
|
-
const fileUri = fileInfo.
|
|
1011
|
+
const fileUri = fileInfo.uri;
|
|
983
1012
|
// Avoid infinite recursion.
|
|
984
1013
|
if (recursionSet.has(fileUri.key)) {
|
|
985
1014
|
return false;
|
|
@@ -993,20 +1022,7 @@ class Program {
|
|
|
993
1022
|
return false;
|
|
994
1023
|
}
|
|
995
1024
|
_createSourceMapper(execEnv, token, from, mapCompiled, preferStubs) {
|
|
996
|
-
const sourceMapper = new sourceMapper_1.SourceMapper(this._importResolver, execEnv, this._evaluator, (stubFileUri, implFileUri) => {
|
|
997
|
-
let stubFileInfo = this.getSourceFileInfo(stubFileUri);
|
|
998
|
-
if (!stubFileInfo) {
|
|
999
|
-
// make sure uri exits before adding interimFile
|
|
1000
|
-
if (!this.fileSystem.existsSync(stubFileUri)) {
|
|
1001
|
-
return undefined;
|
|
1002
|
-
}
|
|
1003
|
-
// Special case for import statement like "import X.Y". The SourceFile
|
|
1004
|
-
// for X might not be in memory since import `X.Y` only brings in Y.
|
|
1005
|
-
stubFileInfo = this.addInterimFile(stubFileUri);
|
|
1006
|
-
}
|
|
1007
|
-
this._addShadowedFile(stubFileInfo, implFileUri);
|
|
1008
|
-
return this.getBoundSourceFile(implFileUri);
|
|
1009
|
-
}, (f) => {
|
|
1025
|
+
const sourceMapper = new sourceMapper_1.SourceMapper(this._importResolver, execEnv, this._evaluator, (stubFileUri, implFileUri) => this.bindShadowFile(stubFileUri, implFileUri), (f) => {
|
|
1010
1026
|
let fileInfo = this.getBoundSourceFileInfo(f);
|
|
1011
1027
|
if (!fileInfo) {
|
|
1012
1028
|
// make sure uri exits before adding interimFile
|
|
@@ -1096,29 +1112,21 @@ class Program {
|
|
|
1096
1112
|
const getThirdPartyImportInfo = (importResult) => {
|
|
1097
1113
|
let isThirdPartyImport = false;
|
|
1098
1114
|
let isPyTypedPresent = false;
|
|
1099
|
-
let isModulePrivate = false;
|
|
1100
1115
|
if (importResult.importType === 1 /* ImportType.ThirdParty */) {
|
|
1101
1116
|
isThirdPartyImport = true;
|
|
1102
1117
|
if (importResult.pyTypedInfo) {
|
|
1103
1118
|
isPyTypedPresent = true;
|
|
1104
1119
|
}
|
|
1105
|
-
if (importResult.isModulePrivate) {
|
|
1106
|
-
isModulePrivate = true;
|
|
1107
|
-
}
|
|
1108
1120
|
}
|
|
1109
1121
|
else if (sourceFileInfo.isThirdPartyImport && importResult.importType === 2 /* ImportType.Local */) {
|
|
1110
1122
|
isThirdPartyImport = true;
|
|
1111
1123
|
if (sourceFileInfo.isThirdPartyPyTypedPresent) {
|
|
1112
1124
|
isPyTypedPresent = true;
|
|
1113
1125
|
}
|
|
1114
|
-
if (importResult.isModulePrivate) {
|
|
1115
|
-
isModulePrivate = true;
|
|
1116
|
-
}
|
|
1117
1126
|
}
|
|
1118
1127
|
return {
|
|
1119
1128
|
isThirdPartyImport,
|
|
1120
1129
|
isPyTypedPresent,
|
|
1121
|
-
isModulePrivate,
|
|
1122
1130
|
};
|
|
1123
1131
|
};
|
|
1124
1132
|
// Create a map of unique imports, since imports can appear more than once.
|
|
@@ -1129,13 +1137,12 @@ class Program {
|
|
|
1129
1137
|
sourceFileInfo.chainedSourceFile = undefined;
|
|
1130
1138
|
}
|
|
1131
1139
|
else {
|
|
1132
|
-
const fileUri = sourceFileInfo.chainedSourceFile.
|
|
1140
|
+
const fileUri = sourceFileInfo.chainedSourceFile.uri;
|
|
1133
1141
|
newImportPathMap.set(fileUri.key, {
|
|
1134
1142
|
path: fileUri,
|
|
1135
1143
|
isTypeshedFile: false,
|
|
1136
1144
|
isThirdPartyImport: false,
|
|
1137
1145
|
isPyTypedPresent: false,
|
|
1138
|
-
isModulePrivate: false,
|
|
1139
1146
|
});
|
|
1140
1147
|
}
|
|
1141
1148
|
}
|
|
@@ -1151,7 +1158,6 @@ class Program {
|
|
|
1151
1158
|
isTypeshedFile: !!importResult.isStdlibTypeshedFile || !!importResult.isThirdPartyTypeshedFile,
|
|
1152
1159
|
isThirdPartyImport: thirdPartyTypeInfo.isThirdPartyImport,
|
|
1153
1160
|
isPyTypedPresent: thirdPartyTypeInfo.isPyTypedPresent,
|
|
1154
|
-
isModulePrivate: thirdPartyTypeInfo.isModulePrivate,
|
|
1155
1161
|
});
|
|
1156
1162
|
}
|
|
1157
1163
|
}
|
|
@@ -1165,7 +1171,6 @@ class Program {
|
|
|
1165
1171
|
isTypeshedFile: !!importResult.isStdlibTypeshedFile || !!importResult.isThirdPartyTypeshedFile,
|
|
1166
1172
|
isThirdPartyImport: thirdPartyTypeInfo.isThirdPartyImport,
|
|
1167
1173
|
isPyTypedPresent: thirdPartyTypeInfo.isPyTypedPresent,
|
|
1168
|
-
isModulePrivate: thirdPartyTypeInfo.isModulePrivate,
|
|
1169
1174
|
});
|
|
1170
1175
|
}
|
|
1171
1176
|
}
|
|
@@ -1179,7 +1184,7 @@ class Program {
|
|
|
1179
1184
|
if (!sourceFileInfo.sourceFile.isStubFile() && !importResult.isStdlibTypeshedFile) {
|
|
1180
1185
|
if (options.verboseOutput) {
|
|
1181
1186
|
this._console.info(`Could not resolve source for '${importResult.importName}' ` +
|
|
1182
|
-
`in file '${sourceFileInfo.
|
|
1187
|
+
`in file '${sourceFileInfo.uri.toUserVisibleString()}'`);
|
|
1183
1188
|
if (importResult.nonStubImportResult.importFailureInfo) {
|
|
1184
1189
|
importResult.nonStubImportResult.importFailureInfo.forEach((diag) => {
|
|
1185
1190
|
this._console.info(` ${diag}`);
|
|
@@ -1191,7 +1196,7 @@ class Program {
|
|
|
1191
1196
|
}
|
|
1192
1197
|
else if (options.verboseOutput) {
|
|
1193
1198
|
this._console.info(`Could not import '${importResult.importName}' ` +
|
|
1194
|
-
`in file '${sourceFileInfo.
|
|
1199
|
+
`in file '${sourceFileInfo.uri.toUserVisibleString()}'`);
|
|
1195
1200
|
if (importResult.importFailureInfo) {
|
|
1196
1201
|
importResult.importFailureInfo.forEach((diag) => {
|
|
1197
1202
|
this._console.info(` ${diag}`);
|
|
@@ -1201,11 +1206,11 @@ class Program {
|
|
|
1201
1206
|
});
|
|
1202
1207
|
const updatedImportMap = new Map();
|
|
1203
1208
|
sourceFileInfo.imports.forEach((importInfo) => {
|
|
1204
|
-
const oldFilePath = importInfo.
|
|
1209
|
+
const oldFilePath = importInfo.uri;
|
|
1205
1210
|
// A previous import was removed.
|
|
1206
1211
|
if (!newImportPathMap.has(oldFilePath.key)) {
|
|
1207
1212
|
importInfo.mutate((s) => {
|
|
1208
|
-
s.importedBy = s.importedBy.filter((fi) => !fi.
|
|
1213
|
+
s.importedBy = s.importedBy.filter((fi) => !fi.uri.equals(sourceFileInfo.uri));
|
|
1209
1214
|
});
|
|
1210
1215
|
}
|
|
1211
1216
|
else {
|
|
@@ -1220,7 +1225,7 @@ class Program {
|
|
|
1220
1225
|
let importedFileInfo = this.getSourceFileInfo(importInfo.path);
|
|
1221
1226
|
if (!importedFileInfo) {
|
|
1222
1227
|
const moduleImportInfo = this._getModuleImportInfoForFile(importInfo.path);
|
|
1223
|
-
const sourceFile = this._sourceFileFactory.createSourceFile(this.serviceProvider, importInfo.path, moduleImportInfo.moduleName, importInfo.isThirdPartyImport, importInfo.isPyTypedPresent,
|
|
1228
|
+
const sourceFile = this._sourceFileFactory.createSourceFile(this.serviceProvider, importInfo.path, moduleImportInfo.moduleName, importInfo.isThirdPartyImport, importInfo.isPyTypedPresent, this._editModeTracker, this._console, this._logTracker);
|
|
1224
1229
|
importedFileInfo = new sourceFileInfo_1.SourceFileInfo(sourceFile, importInfo.isTypeshedFile, importInfo.isThirdPartyImport, importInfo.isPyTypedPresent, this._editModeTracker);
|
|
1225
1230
|
this._addToSourceFileListAndMap(importedFileInfo);
|
|
1226
1231
|
filesAdded.push(importedFileInfo);
|
|
@@ -1258,7 +1263,7 @@ class Program {
|
|
|
1258
1263
|
this._sourceFileList.splice(indexToRemove, 1);
|
|
1259
1264
|
}
|
|
1260
1265
|
_addToSourceFileListAndMap(fileInfo) {
|
|
1261
|
-
const fileUri = fileInfo.
|
|
1266
|
+
const fileUri = fileInfo.uri;
|
|
1262
1267
|
// We should never add a file with the same path twice.
|
|
1263
1268
|
(0, debug_1.assert)(!this._sourceFileMap.has(fileUri.key));
|
|
1264
1269
|
// We should never have an empty URI for a source file.
|
|
@@ -1299,8 +1304,7 @@ class Program {
|
|
|
1299
1304
|
const moduleImportInfo = this._getModuleImportInfoForFile(fileUri);
|
|
1300
1305
|
const sourceFile = this._sourceFileFactory.createSourceFile(this.serviceProvider, fileUri, moduleImportInfo.moduleName,
|
|
1301
1306
|
/* isThirdPartyImport */ false,
|
|
1302
|
-
/* isInPyTypedPackage */ false,
|
|
1303
|
-
/* isModulePrivate */ false, this._editModeTracker, this._console, this._logTracker);
|
|
1307
|
+
/* isInPyTypedPackage */ false, this._editModeTracker, this._console, this._logTracker);
|
|
1304
1308
|
const sourceFileInfo = new sourceFileInfo_1.SourceFileInfo(sourceFile,
|
|
1305
1309
|
/* isTypeshedFile */ false,
|
|
1306
1310
|
/* isThirdPartyImport */ false,
|
|
@@ -1363,7 +1367,7 @@ class Program {
|
|
|
1363
1367
|
const implicitSet = new Set();
|
|
1364
1368
|
let nextImplicitImport = this._getImplicitImports(fileToAnalyze);
|
|
1365
1369
|
while (nextImplicitImport) {
|
|
1366
|
-
const implicitPath = nextImplicitImport.
|
|
1370
|
+
const implicitPath = nextImplicitImport.uri;
|
|
1367
1371
|
if (implicitSet.has(implicitPath.key)) {
|
|
1368
1372
|
// We've found a cycle. Break out of the loop.
|
|
1369
1373
|
debug.fail(this.serviceProvider
|
|
@@ -1454,7 +1458,7 @@ class Program {
|
|
|
1454
1458
|
return false;
|
|
1455
1459
|
}
|
|
1456
1460
|
_checkTypes(fileToCheck, token, chainedByList) {
|
|
1457
|
-
return this._logTracker.log(`analyzing: ${fileToCheck.
|
|
1461
|
+
return this._logTracker.log(`analyzing: ${fileToCheck.uri}`, (logState) => {
|
|
1458
1462
|
// If the file isn't needed because it was eliminated from the
|
|
1459
1463
|
// transitive closure or deleted, skip the file rather than wasting
|
|
1460
1464
|
// time on it.
|
|
@@ -1488,7 +1492,7 @@ class Program {
|
|
|
1488
1492
|
}
|
|
1489
1493
|
}
|
|
1490
1494
|
if (boundFile) {
|
|
1491
|
-
const execEnv = this._configOptions.findExecEnvironment(fileToCheck.
|
|
1495
|
+
const execEnv = this._configOptions.findExecEnvironment(fileToCheck.uri);
|
|
1492
1496
|
fileToCheck.sourceFile.check(this.configOptions, this._lookUpImport, this._importResolver, this._evaluator, this._createSourceMapper(execEnv, token, fileToCheck), dependentFiles);
|
|
1493
1497
|
}
|
|
1494
1498
|
}
|
|
@@ -1500,8 +1504,7 @@ class Program {
|
|
|
1500
1504
|
// Don't detect import cycles when doing type stub generation. Some
|
|
1501
1505
|
// third-party modules are pretty convoluted.
|
|
1502
1506
|
// Or if the file is the notebook cell. notebook cell can't have cycles.
|
|
1503
|
-
if (!this._allowedThirdPartyImports &&
|
|
1504
|
-
fileToCheck.sourceFile.getIPythonMode() !== sourceFile_1.IPythonMode.CellDocs) {
|
|
1507
|
+
if (!this._allowedThirdPartyImports && fileToCheck.ipythonMode !== sourceFile_1.IPythonMode.CellDocs) {
|
|
1505
1508
|
// We need to force all of the files to be parsed and build
|
|
1506
1509
|
// a closure map for the files.
|
|
1507
1510
|
const closureMap = new Map();
|
|
@@ -1525,7 +1528,7 @@ class Program {
|
|
|
1525
1528
|
});
|
|
1526
1529
|
}
|
|
1527
1530
|
_checkDependentFiles(fileToCheck, chainedByList, token) {
|
|
1528
|
-
if (fileToCheck.
|
|
1531
|
+
if (fileToCheck.ipythonMode !== sourceFile_1.IPythonMode.CellDocs) {
|
|
1529
1532
|
return undefined;
|
|
1530
1533
|
}
|
|
1531
1534
|
// If we don't have chainedByList, it means none of them are checked yet.
|
|
@@ -1580,7 +1583,7 @@ class Program {
|
|
|
1580
1583
|
_getImportsRecursive(file, closureMap, recursionCount) {
|
|
1581
1584
|
// If the file is already in the closure map, we found a cyclical
|
|
1582
1585
|
// dependency. Don't recur further.
|
|
1583
|
-
const fileUri = file.
|
|
1586
|
+
const fileUri = file.uri;
|
|
1584
1587
|
if (closureMap.has(fileUri.key)) {
|
|
1585
1588
|
return;
|
|
1586
1589
|
}
|
|
@@ -1614,7 +1617,7 @@ class Program {
|
|
|
1614
1617
|
if (sourceFileInfo.sourceFile.isNoCircularDependencyConfirmed()) {
|
|
1615
1618
|
return false;
|
|
1616
1619
|
}
|
|
1617
|
-
const fileUri = sourceFileInfo.
|
|
1620
|
+
const fileUri = sourceFileInfo.uri;
|
|
1618
1621
|
filesVisited.set(fileUri.key, sourceFileInfo);
|
|
1619
1622
|
let detectedCycle = false;
|
|
1620
1623
|
if (dependencyMap.has(fileUri.key)) {
|
|
@@ -1658,7 +1661,7 @@ class Program {
|
|
|
1658
1661
|
_logImportCycle(dependencyChain) {
|
|
1659
1662
|
const circDep = new circularDependency_1.CircularDependency();
|
|
1660
1663
|
dependencyChain.forEach((sourceFileInfo) => {
|
|
1661
|
-
circDep.appendPath(sourceFileInfo.
|
|
1664
|
+
circDep.appendPath(sourceFileInfo.uri);
|
|
1662
1665
|
});
|
|
1663
1666
|
circDep.normalizeOrder();
|
|
1664
1667
|
const firstFilePath = circDep.getPaths()[0];
|
|
@@ -1667,7 +1670,7 @@ class Program {
|
|
|
1667
1670
|
firstSourceFile.sourceFile.addCircularDependency(this.configOptions, circDep);
|
|
1668
1671
|
}
|
|
1669
1672
|
_markFileDirtyRecursive(sourceFileInfo, markSet, forceRebinding = false) {
|
|
1670
|
-
const fileUri = sourceFileInfo.
|
|
1673
|
+
const fileUri = sourceFileInfo.uri;
|
|
1671
1674
|
// Don't mark it again if it's already been visited.
|
|
1672
1675
|
if (markSet.has(fileUri.key)) {
|
|
1673
1676
|
return;
|