@zzzen/pyright-internal 1.2.0-dev.20230827 → 1.2.0-dev.20230910

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/analyzer/binder.js +4 -1
  2. package/dist/analyzer/binder.js.map +1 -1
  3. package/dist/analyzer/checker.js +40 -14
  4. package/dist/analyzer/checker.js.map +1 -1
  5. package/dist/analyzer/codeFlowEngine.js +1 -2
  6. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  7. package/dist/analyzer/constraintSolver.js +5 -0
  8. package/dist/analyzer/constraintSolver.js.map +1 -1
  9. package/dist/analyzer/constructors.js +16 -7
  10. package/dist/analyzer/constructors.js.map +1 -1
  11. package/dist/analyzer/declarationUtils.js +2 -0
  12. package/dist/analyzer/declarationUtils.js.map +1 -1
  13. package/dist/analyzer/decorators.js +16 -1
  14. package/dist/analyzer/decorators.js.map +1 -1
  15. package/dist/analyzer/deprecatedSymbols.js +13 -2
  16. package/dist/analyzer/deprecatedSymbols.js.map +1 -1
  17. package/dist/analyzer/importResolver.d.ts +6 -4
  18. package/dist/analyzer/importResolver.js +20 -18
  19. package/dist/analyzer/importResolver.js.map +1 -1
  20. package/dist/analyzer/namedTuples.js +1 -1
  21. package/dist/analyzer/namedTuples.js.map +1 -1
  22. package/dist/analyzer/packageTypeVerifier.d.ts +3 -3
  23. package/dist/analyzer/packageTypeVerifier.js +8 -11
  24. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  25. package/dist/analyzer/parentDirectoryCache.js +1 -1
  26. package/dist/analyzer/parentDirectoryCache.js.map +1 -1
  27. package/dist/analyzer/program.d.ts +9 -22
  28. package/dist/analyzer/program.js +117 -105
  29. package/dist/analyzer/program.js.map +1 -1
  30. package/dist/analyzer/protocols.js +3 -1
  31. package/dist/analyzer/protocols.js.map +1 -1
  32. package/dist/analyzer/pythonPathUtils.js +10 -8
  33. package/dist/analyzer/pythonPathUtils.js.map +1 -1
  34. package/dist/analyzer/service.d.ts +6 -3
  35. package/dist/analyzer/service.js +40 -20
  36. package/dist/analyzer/service.js.map +1 -1
  37. package/dist/analyzer/sourceFile.d.ts +6 -4
  38. package/dist/analyzer/sourceFile.js +9 -16
  39. package/dist/analyzer/sourceFile.js.map +1 -1
  40. package/dist/analyzer/sourceFileInfo.d.ts +62 -0
  41. package/dist/analyzer/sourceFileInfo.js +145 -0
  42. package/dist/analyzer/sourceFileInfo.js.map +1 -0
  43. package/dist/analyzer/sourceMapper.d.ts +1 -1
  44. package/dist/analyzer/typeDocStringUtils.js +1 -1
  45. package/dist/analyzer/typeEvaluator.js +361 -262
  46. package/dist/analyzer/typeEvaluator.js.map +1 -1
  47. package/dist/analyzer/typeEvaluatorTypes.d.ts +10 -8
  48. package/dist/analyzer/typeEvaluatorTypes.js +11 -8
  49. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  50. package/dist/analyzer/typeGuards.js +116 -20
  51. package/dist/analyzer/typeGuards.js.map +1 -1
  52. package/dist/analyzer/typeUtils.d.ts +6 -4
  53. package/dist/analyzer/typeUtils.js +104 -63
  54. package/dist/analyzer/typeUtils.js.map +1 -1
  55. package/dist/analyzer/typeWalker.js +1 -1
  56. package/dist/analyzer/typeWalker.js.map +1 -1
  57. package/dist/analyzer/types.d.ts +1 -0
  58. package/dist/analyzer/types.js +8 -0
  59. package/dist/analyzer/types.js.map +1 -1
  60. package/dist/backgroundAnalysis.d.ts +1 -2
  61. package/dist/backgroundAnalysis.js +2 -2
  62. package/dist/backgroundAnalysis.js.map +1 -1
  63. package/dist/backgroundAnalysisBase.d.ts +1 -2
  64. package/dist/backgroundAnalysisBase.js +4 -4
  65. package/dist/backgroundAnalysisBase.js.map +1 -1
  66. package/dist/backgroundThreadBase.d.ts +1 -1
  67. package/dist/backgroundThreadBase.js +1 -0
  68. package/dist/backgroundThreadBase.js.map +1 -1
  69. package/dist/common/commandLineOptions.d.ts +1 -0
  70. package/dist/common/commandLineOptions.js.map +1 -1
  71. package/dist/common/configOptions.d.ts +4 -1
  72. package/dist/common/configOptions.js +18 -5
  73. package/dist/common/configOptions.js.map +1 -1
  74. package/dist/common/console.d.ts +3 -0
  75. package/dist/common/console.js +8 -1
  76. package/dist/common/console.js.map +1 -1
  77. package/dist/common/extensibility.d.ts +10 -1
  78. package/dist/common/extensibility.js.map +1 -1
  79. package/dist/common/fileSystem.d.ts +3 -0
  80. package/dist/common/fileSystem.js +8 -1
  81. package/dist/common/fileSystem.js.map +1 -1
  82. package/dist/common/pathUtils.d.ts +2 -15
  83. package/dist/common/pathUtils.js +9 -84
  84. package/dist/common/pathUtils.js.map +1 -1
  85. package/dist/common/realFileSystem.js +22 -13
  86. package/dist/common/realFileSystem.js.map +1 -1
  87. package/dist/common/serviceProvider.d.ts +1 -4
  88. package/dist/common/serviceProvider.js +4 -4
  89. package/dist/common/serviceProvider.js.map +1 -1
  90. package/dist/common/serviceProviderExtensions.d.ts +10 -4
  91. package/dist/common/serviceProviderExtensions.js +43 -1
  92. package/dist/common/serviceProviderExtensions.js.map +1 -1
  93. package/dist/languageServerBase.d.ts +9 -9
  94. package/dist/languageServerBase.js +5 -4
  95. package/dist/languageServerBase.js.map +1 -1
  96. package/dist/languageService/analyzerServiceExecutor.js +3 -2
  97. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  98. package/dist/languageService/completionProvider.d.ts +7 -5
  99. package/dist/languageService/completionProvider.js +190 -176
  100. package/dist/languageService/completionProvider.js.map +1 -1
  101. package/dist/languageService/completionProviderUtils.d.ts +1 -1
  102. package/dist/languageService/completionProviderUtils.js +1 -1
  103. package/dist/languageService/completionProviderUtils.js.map +1 -1
  104. package/dist/localization/localize.d.ts +14 -0
  105. package/dist/localization/localize.js +8 -0
  106. package/dist/localization/localize.js.map +1 -1
  107. package/dist/localization/package.nls.cs.json +26 -17
  108. package/dist/localization/package.nls.de.json +26 -17
  109. package/dist/localization/package.nls.en-us.json +9 -2
  110. package/dist/localization/package.nls.es.json +26 -17
  111. package/dist/localization/package.nls.fr.json +26 -17
  112. package/dist/localization/package.nls.it.json +26 -17
  113. package/dist/localization/package.nls.ja.json +26 -17
  114. package/dist/localization/package.nls.ko.json +26 -17
  115. package/dist/localization/package.nls.pl.json +26 -17
  116. package/dist/localization/package.nls.pt-br.json +26 -17
  117. package/dist/localization/package.nls.qps-ploc.json +14 -5
  118. package/dist/localization/package.nls.ru.json +26 -17
  119. package/dist/localization/package.nls.tr.json +26 -17
  120. package/dist/localization/package.nls.zh-cn.json +26 -17
  121. package/dist/localization/package.nls.zh-tw.json +26 -17
  122. package/dist/pyright.js +6 -4
  123. package/dist/pyright.js.map +1 -1
  124. package/dist/server.d.ts +2 -2
  125. package/dist/server.js +8 -10
  126. package/dist/server.js.map +1 -1
  127. package/dist/tests/chainedSourceFiles.test.js +4 -1
  128. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  129. package/dist/tests/checker.test.js +11 -11
  130. package/dist/tests/checker.test.js.map +1 -1
  131. package/dist/tests/completions.test.js +57 -0
  132. package/dist/tests/completions.test.js.map +1 -1
  133. package/dist/tests/config.test.js +28 -22
  134. package/dist/tests/config.test.js.map +1 -1
  135. package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js +5 -5
  136. package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js.map +1 -1
  137. package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js +11 -9
  138. package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js.map +1 -1
  139. package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js +14 -14
  140. package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
  141. package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js +12 -12
  142. package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js.map +1 -1
  143. package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js +9 -9
  144. package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js.map +1 -1
  145. package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js +3 -3
  146. package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js.map +1 -1
  147. package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js +3 -3
  148. package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
  149. package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js +4 -4
  150. package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js.map +1 -1
  151. package/dist/tests/fourslash/fourslash.d.ts +1 -0
  152. package/dist/tests/fourslash/missingModuleSource.fourslash.js +4 -1
  153. package/dist/tests/fourslash/missingModuleSource.fourslash.js.map +1 -1
  154. package/dist/tests/harness/fourslash/testLanguageService.js +4 -1
  155. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  156. package/dist/tests/harness/fourslash/testState.Consts.d.ts +1 -0
  157. package/dist/tests/harness/fourslash/testState.Consts.js +2 -0
  158. package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
  159. package/dist/tests/harness/fourslash/testState.d.ts +2 -0
  160. package/dist/tests/harness/fourslash/testState.js +9 -2
  161. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  162. package/dist/tests/harness/vfs/filesystem.js +10 -6
  163. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  164. package/dist/tests/importResolver.test.js +14 -9
  165. package/dist/tests/importResolver.test.js.map +1 -1
  166. package/dist/tests/localizer.test.js +1 -1
  167. package/dist/tests/localizer.test.js.map +1 -1
  168. package/dist/tests/pathUtils.test.js +13 -21
  169. package/dist/tests/pathUtils.test.js.map +1 -1
  170. package/dist/tests/service.test.js +55 -0
  171. package/dist/tests/service.test.js.map +1 -1
  172. package/dist/tests/sourceFile.test.js +4 -2
  173. package/dist/tests/sourceFile.test.js.map +1 -1
  174. package/dist/tests/testState.test.js +1 -1
  175. package/dist/tests/testState.test.js.map +1 -1
  176. package/dist/tests/testUtils.js +3 -5
  177. package/dist/tests/testUtils.js.map +1 -1
  178. package/dist/tests/typeEvaluator1.test.js +2 -2
  179. package/dist/tests/typeEvaluator2.test.js +5 -1
  180. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  181. package/dist/tests/typeEvaluator3.test.js +8 -4
  182. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  183. package/dist/tests/typeEvaluator4.test.js +4 -0
  184. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  185. package/dist/tests/typeEvaluator5.test.js +1 -1
  186. package/dist/tests/workspaceEditUtils.test.js +24 -20
  187. package/dist/tests/workspaceEditUtils.test.js.map +1 -1
  188. package/dist/workspaceFactory.d.ts +1 -0
  189. package/dist/workspaceFactory.js +7 -4
  190. package/dist/workspaceFactory.js.map +1 -1
  191. package/package.json +1 -1
@@ -28,7 +28,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
28
  return result;
29
29
  };
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.Program = void 0;
31
+ exports.Program = exports.ISourceFileFactory = void 0;
32
32
  const vscode_languageserver_1 = require("vscode-languageserver");
33
33
  const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
34
34
  const cancellationUtils_1 = require("../common/cancellationUtils");
@@ -54,7 +54,38 @@ const sourceMapper_1 = require("./sourceMapper");
54
54
  const tracePrinter_1 = require("./tracePrinter");
55
55
  const typeEvaluatorWithTracker_1 = require("./typeEvaluatorWithTracker");
56
56
  const typeStubWriter_1 = require("./typeStubWriter");
57
+ const sourceFileInfo_1 = require("./sourceFileInfo");
57
58
  const _maxImportDepth = 256;
59
+ var ISourceFileFactory;
60
+ (function (ISourceFileFactory) {
61
+ function is(obj) {
62
+ return obj.createSourceFile !== undefined;
63
+ }
64
+ ISourceFileFactory.is = is;
65
+ })(ISourceFileFactory = exports.ISourceFileFactory || (exports.ISourceFileFactory = {}));
66
+ // Track edit mode related information.
67
+ class EditModeTracker {
68
+ constructor() {
69
+ this._isEditMode = false;
70
+ this._mutatedFiles = [];
71
+ }
72
+ get isEditMode() {
73
+ return this._isEditMode;
74
+ }
75
+ addMutatedFiles(file) {
76
+ this._mutatedFiles.push(file);
77
+ }
78
+ enable() {
79
+ this._isEditMode = true;
80
+ this._mutatedFiles = [];
81
+ }
82
+ disable() {
83
+ this._isEditMode = false;
84
+ const files = this._mutatedFiles;
85
+ this._mutatedFiles = [];
86
+ return files;
87
+ }
88
+ }
58
89
  // Container for all of the files that are being analyzed. Files
59
90
  // can fall into one or more of the following categories:
60
91
  // Tracked - specified by the config options
@@ -62,13 +93,13 @@ const _maxImportDepth = 256;
62
93
  // Opened - temporarily opened in the editor
63
94
  // Shadowed - implementation file that shadows a type stub file
64
95
  class Program {
65
- constructor(initialImportResolver, initialConfigOptions, _serviceProvider, logTracker, _disableChecker, cacheManager, id) {
66
- this._serviceProvider = _serviceProvider;
96
+ constructor(initialImportResolver, initialConfigOptions, serviceProvider, logTracker, _disableChecker, cacheManager, id) {
97
+ this.serviceProvider = serviceProvider;
67
98
  this._disableChecker = _disableChecker;
68
99
  this._sourceFileList = [];
69
100
  this._sourceFileMap = new Map();
70
101
  this._parsedFileCount = 0;
71
- this._isEditMode = false;
102
+ this._editModeTracker = new EditModeTracker();
72
103
  this._lookUpImport = (filePathOrModule, options) => {
73
104
  var _a;
74
105
  let sourceFileInfo;
@@ -83,12 +114,11 @@ class Program {
83
114
  importedSymbols: undefined,
84
115
  });
85
116
  if (importResult.isImportFound && !importResult.isNativeLib && importResult.resolvedPaths.length > 0) {
86
- let resolvedPath = importResult.resolvedPaths[importResult.resolvedPaths.length - 1];
117
+ const resolvedPath = importResult.resolvedPaths[importResult.resolvedPaths.length - 1];
87
118
  if (resolvedPath) {
88
119
  // See if the source file already exists in the program.
89
120
  sourceFileInfo = this.getSourceFileInfo(resolvedPath);
90
121
  if (!sourceFileInfo) {
91
- resolvedPath = (0, pathUtils_1.normalizePathCase)(this.fileSystem, resolvedPath);
92
122
  // Start tracking the source file.
93
123
  this.addTrackedFile(resolvedPath);
94
124
  sourceFileInfo = this.getSourceFileInfo(resolvedPath);
@@ -138,11 +168,11 @@ class Program {
138
168
  isInPyTypedPackage: fileInfo.isInPyTypedPackage,
139
169
  };
140
170
  };
141
- this._console = _serviceProvider.tryGet(serviceProviderExtensions_1.ServiceKeys.console) || new console_1.StandardConsole();
171
+ this._console = serviceProvider.tryGet(serviceProviderExtensions_1.ServiceKeys.console) || new console_1.StandardConsole();
142
172
  this._logTracker = logTracker !== null && logTracker !== void 0 ? logTracker : new logTracker_1.LogTracker(this._console, 'FG');
143
173
  this._importResolver = initialImportResolver;
144
174
  this._configOptions = initialConfigOptions;
145
- this._sourceFileFactory = _serviceProvider.sourceFileFactory();
175
+ this._sourceFileFactory = serviceProvider.sourceFileFactory();
146
176
  this._cacheManager = cacheManager !== null && cacheManager !== void 0 ? cacheManager : new cacheManager_1.CacheManager();
147
177
  this._cacheManager.registerCacheOwner(this);
148
178
  this._createNewEvaluator();
@@ -174,28 +204,26 @@ class Program {
174
204
  this._cacheManager.unregisterCacheOwner(this);
175
205
  }
176
206
  enterEditMode() {
177
- // Keep track of edit mode so we can apply it to new source files.
178
- this._isEditMode = true;
179
- // Tell all source files we're in edit mode.
180
- this._sourceFileList.forEach((sourceFile) => {
181
- sourceFile.sourceFile.enterEditMode();
182
- });
207
+ this._editModeTracker.enable();
183
208
  }
184
209
  exitEditMode() {
185
- // Tell all source files we're no longer in edit mode. Gather
186
- // up all of their edits.
210
+ // Stop applying edit mode to new source files.
211
+ const mutatedFiles = this._editModeTracker.disable();
212
+ const filesToDelete = new Set();
187
213
  const edits = [];
188
- this._sourceFileList.forEach((sourceFile) => {
189
- const newContents = sourceFile.sourceFile.exitEditMode();
214
+ // Tell all source files we're no longer in edit mode. Gather
215
+ // up all of their edits and find files that no longer needed.
216
+ mutatedFiles.forEach((fileInfo) => {
217
+ if (fileInfo.isCreatedInEditMode) {
218
+ filesToDelete.add(fileInfo);
219
+ }
220
+ const newContents = fileInfo.restore();
190
221
  if (newContents) {
191
- // This means this source file was modified. We need to recompute its imports after
192
- // we put it back to how it was.
193
- this._updateSourceFileImports(sourceFile, this.configOptions);
194
222
  // Create a text document so we can compute the edits.
195
- const textDocument = vscode_languageserver_textdocument_1.TextDocument.create(sourceFile.sourceFile.getFilePath(), 'python', 1, sourceFile.sourceFile.getFileContent() || '');
223
+ const textDocument = vscode_languageserver_textdocument_1.TextDocument.create(fileInfo.sourceFile.getFilePath(), 'python', 1, fileInfo.sourceFile.getFileContent() || '');
196
224
  // Add an edit action to the list.
197
225
  edits.push({
198
- filePath: sourceFile.sourceFile.getFilePath(),
226
+ filePath: fileInfo.sourceFile.getFilePath(),
199
227
  range: {
200
228
  start: { line: 0, character: 0 },
201
229
  end: { line: textDocument.lineCount, character: 0 },
@@ -204,8 +232,19 @@ class Program {
204
232
  });
205
233
  }
206
234
  });
207
- // Stop applying edit mode to new source files.
208
- this._isEditMode = false;
235
+ // Delete files added while in edit mode
236
+ if (filesToDelete.size > 0) {
237
+ // delete from the back to make sure index is valid.
238
+ for (let i = this._sourceFileList.length - 1; i >= 0; i--) {
239
+ const v = this._sourceFileList[i];
240
+ if (filesToDelete.has(v)) {
241
+ // We don't need to care about file diagnostics since in edit mode
242
+ // checker won't run.
243
+ v.sourceFile.prepareForClose();
244
+ this._removeSourceFileFromListAndMap(v.sourceFile.getFilePath(), i);
245
+ }
246
+ }
247
+ }
209
248
  return edits;
210
249
  }
211
250
  setConfigOptions(configOptions) {
@@ -227,12 +266,12 @@ class Program {
227
266
  // We need to determine which files to remove from the existing file list.
228
267
  const newFileMap = new Map();
229
268
  filePaths.forEach((path) => {
230
- newFileMap.set((0, pathUtils_1.normalizePathCase)(this.fileSystem, path), path);
269
+ newFileMap.set(path, path);
231
270
  });
232
271
  // Files that are not in the tracked file list are
233
272
  // marked as no longer tracked.
234
273
  this._sourceFileList.forEach((oldFile) => {
235
- const filePath = (0, pathUtils_1.normalizePathCase)(this.fileSystem, oldFile.sourceFile.getFilePath());
274
+ const filePath = oldFile.sourceFile.getFilePath();
236
275
  if (!newFileMap.has(filePath)) {
237
276
  oldFile.isTracked = false;
238
277
  }
@@ -279,20 +318,11 @@ class Program {
279
318
  sourceFileInfo.isTracked = true;
280
319
  return sourceFileInfo.sourceFile;
281
320
  }
282
- const sourceFile = this._sourceFileFactory.createSourceFile(this.fileSystem, filePath, importName, isThirdPartyImport, isInPyTypedPackage, this._isEditMode, this._console, this._logTracker);
283
- sourceFileInfo = {
284
- sourceFile,
321
+ const sourceFile = this._sourceFileFactory.createSourceFile(this.fileSystem, filePath, importName, isThirdPartyImport, isInPyTypedPackage, this._editModeTracker, this._console, this._logTracker);
322
+ sourceFileInfo = new sourceFileInfo_1.SourceFileInfo(sourceFile,
323
+ /* isTypeshedFile */ false, isThirdPartyImport, isInPyTypedPackage, this._editModeTracker, {
285
324
  isTracked: true,
286
- isOpenByClient: false,
287
- isTypeshedFile: false,
288
- isThirdPartyImport,
289
- isThirdPartyPyTypedPresent: isInPyTypedPackage,
290
- diagnosticsVersion: undefined,
291
- imports: [],
292
- importedBy: [],
293
- shadows: [],
294
- shadowedBy: [],
295
- };
325
+ });
296
326
  this._addToSourceFileListAndMap(sourceFileInfo);
297
327
  return sourceFile;
298
328
  }
@@ -303,22 +333,16 @@ class Program {
303
333
  const importName = this._getImportNameForFile(filePath);
304
334
  const sourceFile = this._sourceFileFactory.createSourceFile(this.fileSystem, filePath, importName,
305
335
  /* isThirdPartyImport */ false,
306
- /* isInPyTypedPackage */ false, this._isEditMode, this._console, this._logTracker, options === null || options === void 0 ? void 0 : options.realFilePath, (_a = options === null || options === void 0 ? void 0 : options.ipythonMode) !== null && _a !== void 0 ? _a : sourceFile_1.IPythonMode.None);
336
+ /* isInPyTypedPackage */ false, this._editModeTracker, this._console, this._logTracker, options === null || options === void 0 ? void 0 : options.realFilePath, (_a = options === null || options === void 0 ? void 0 : options.ipythonMode) !== null && _a !== void 0 ? _a : sourceFile_1.IPythonMode.None);
307
337
  const chainedFilePath = options === null || options === void 0 ? void 0 : options.chainedFilePath;
308
- sourceFileInfo = {
309
- sourceFile,
338
+ sourceFileInfo = new sourceFileInfo_1.SourceFileInfo(sourceFile,
339
+ /* isTypeshedFile */ false,
340
+ /* isThirdPartyImport */ false,
341
+ /* isThirdPartyPyTypedPresent */ false, this._editModeTracker, {
310
342
  isTracked: (_b = options === null || options === void 0 ? void 0 : options.isTracked) !== null && _b !== void 0 ? _b : false,
311
343
  chainedSourceFile: chainedFilePath ? this.getSourceFileInfo(chainedFilePath) : undefined,
312
344
  isOpenByClient: true,
313
- isTypeshedFile: false,
314
- isThirdPartyImport: false,
315
- isThirdPartyPyTypedPresent: false,
316
- diagnosticsVersion: undefined,
317
- imports: [],
318
- importedBy: [],
319
- shadows: [],
320
- shadowedBy: [],
321
- };
345
+ });
322
346
  this._addToSourceFileListAndMap(sourceFileInfo);
323
347
  }
324
348
  else {
@@ -447,9 +471,8 @@ class Program {
447
471
  return this._configOptions.functionSignatureDisplay;
448
472
  }
449
473
  containsSourceFileIn(folder) {
450
- const normalizedFolder = (0, pathUtils_1.normalizePathCase)(this.fileSystem, folder);
451
474
  for (const normalizedSourceFilePath of this._sourceFileMap.keys()) {
452
- if (normalizedSourceFilePath.startsWith(normalizedFolder)) {
475
+ if (normalizedSourceFilePath.startsWith(folder)) {
453
476
  return true;
454
477
  }
455
478
  }
@@ -479,7 +502,7 @@ class Program {
479
502
  return this._sourceFileList;
480
503
  }
481
504
  getSourceFileInfo(filePath) {
482
- return this._sourceFileMap.get((0, pathUtils_1.normalizePathCase)(this.fileSystem, filePath));
505
+ return this._sourceFileMap.get(filePath);
483
506
  }
484
507
  getBoundSourceFileInfo(filePath, content, force) {
485
508
  const sourceFileInfo = this.getSourceFileInfo(filePath);
@@ -552,7 +575,7 @@ class Program {
552
575
  // This will allow the callback to execute a type evaluator with an associated
553
576
  // cancellation token and provide a mutable program. Should already be in edit mode when called.
554
577
  runEditMode(callback, token) {
555
- if (this._isEditMode) {
578
+ if (this._editModeTracker.isEditMode) {
556
579
  return this._runEvaluatorWithCancellationToken(token, () => callback(this));
557
580
  }
558
581
  }
@@ -742,7 +765,7 @@ class Program {
742
765
  }
743
766
  clone() {
744
767
  var _a, _b;
745
- const program = new Program(this._importResolver, this._configOptions, this._serviceProvider, new logTracker_1.LogTracker(this._console, 'Cloned'));
768
+ const program = new Program(this._importResolver, this._configOptions, this.serviceProvider, new logTracker_1.LogTracker(this._console, 'Cloned'));
746
769
  // Cloned program will use whatever user files the program currently has.
747
770
  const userFiles = this.getUserFiles();
748
771
  program.setTrackedFiles(userFiles.map((i) => i.sourceFile.getFilePath()));
@@ -852,7 +875,7 @@ class Program {
852
875
  if (indexToRemove < 0) {
853
876
  return;
854
877
  }
855
- importedFile.importedBy.splice(indexToRemove, 1);
878
+ importedFile.mutate((s) => s.importedBy.splice(indexToRemove, 1));
856
879
  // See if we need to remove the imported file because it
857
880
  // is no longer needed. If its index is >= i, it will be
858
881
  // removed when we get to it.
@@ -875,9 +898,9 @@ class Program {
875
898
  });
876
899
  // Remove any shadowed files corresponding to this file.
877
900
  fileInfo.shadowedBy.forEach((shadowedFile) => {
878
- shadowedFile.shadows = shadowedFile.shadows.filter((f) => f !== fileInfo);
901
+ shadowedFile.mutate((s) => (s.shadows = s.shadows.filter((f) => f !== fileInfo)));
879
902
  });
880
- fileInfo.shadowedBy = [];
903
+ fileInfo.mutate((s) => (s.shadowedBy = []));
881
904
  }
882
905
  else {
883
906
  // If we're showing the user errors only for open files, clear
@@ -918,7 +941,7 @@ class Program {
918
941
  if (fileInfo.isTracked || fileInfo.isOpenByClient || fileInfo.shadows.length > 0) {
919
942
  return true;
920
943
  }
921
- const filePath = (0, pathUtils_1.normalizePathCase)(this.fileSystem, fileInfo.sourceFile.getFilePath());
944
+ const filePath = fileInfo.sourceFile.getFilePath();
922
945
  // Avoid infinite recursion.
923
946
  if (recursionSet.has(filePath)) {
924
947
  return false;
@@ -1050,7 +1073,7 @@ class Program {
1050
1073
  }
1051
1074
  else {
1052
1075
  const filePath = sourceFileInfo.chainedSourceFile.sourceFile.getFilePath();
1053
- newImportPathMap.set((0, pathUtils_1.normalizePathCase)(this.fileSystem, filePath), {
1076
+ newImportPathMap.set(filePath, {
1054
1077
  path: filePath,
1055
1078
  isTypeshedFile: false,
1056
1079
  isThirdPartyImport: false,
@@ -1065,7 +1088,7 @@ class Program {
1065
1088
  const filePath = importResult.resolvedPaths[importResult.resolvedPaths.length - 1];
1066
1089
  if (filePath) {
1067
1090
  const thirdPartyTypeInfo = getThirdPartyImportInfo(importResult);
1068
- newImportPathMap.set((0, pathUtils_1.normalizePathCase)(this.fileSystem, filePath), {
1091
+ newImportPathMap.set(filePath, {
1069
1092
  path: filePath,
1070
1093
  isTypeshedFile: !!importResult.isStdlibTypeshedFile || !!importResult.isThirdPartyTypeshedFile,
1071
1094
  isThirdPartyImport: thirdPartyTypeInfo.isThirdPartyImport,
@@ -1078,7 +1101,7 @@ class Program {
1078
1101
  if (this._isImportAllowed(sourceFileInfo, importResult, implicitImport.isStubFile)) {
1079
1102
  if (!implicitImport.isNativeLib) {
1080
1103
  const thirdPartyTypeInfo = getThirdPartyImportInfo(importResult);
1081
- newImportPathMap.set((0, pathUtils_1.normalizePathCase)(this.fileSystem, implicitImport.path), {
1104
+ newImportPathMap.set(implicitImport.path, {
1082
1105
  path: implicitImport.path,
1083
1106
  isTypeshedFile: !!importResult.isStdlibTypeshedFile || !!importResult.isThirdPartyTypeshedFile,
1084
1107
  isThirdPartyImport: thirdPartyTypeInfo.isThirdPartyImport,
@@ -1118,11 +1141,12 @@ class Program {
1118
1141
  });
1119
1142
  const updatedImportMap = new Map();
1120
1143
  sourceFileInfo.imports.forEach((importInfo) => {
1121
- const oldFilePath = (0, pathUtils_1.normalizePathCase)(this.fileSystem, importInfo.sourceFile.getFilePath());
1144
+ const oldFilePath = importInfo.sourceFile.getFilePath();
1122
1145
  // A previous import was removed.
1123
1146
  if (!newImportPathMap.has(oldFilePath)) {
1124
- importInfo.importedBy = importInfo.importedBy.filter((fi) => (0, pathUtils_1.normalizePathCase)(this.fileSystem, fi.sourceFile.getFilePath()) !==
1125
- (0, pathUtils_1.normalizePathCase)(this.fileSystem, sourceFileInfo.sourceFile.getFilePath()));
1147
+ importInfo.mutate((s) => {
1148
+ s.importedBy = s.importedBy.filter((fi) => fi.sourceFile.getFilePath() !== sourceFileInfo.sourceFile.getFilePath());
1149
+ });
1126
1150
  }
1127
1151
  else {
1128
1152
  updatedImportMap.set(oldFilePath, importInfo);
@@ -1136,33 +1160,21 @@ class Program {
1136
1160
  let importedFileInfo = this.getSourceFileInfo(importInfo.path);
1137
1161
  if (!importedFileInfo) {
1138
1162
  const importName = this._getImportNameForFile(importInfo.path);
1139
- const sourceFile = new sourceFile_1.SourceFile(this.fileSystem, importInfo.path, importName, importInfo.isThirdPartyImport, importInfo.isPyTypedPresent, this._isEditMode, this._console, this._logTracker);
1140
- importedFileInfo = {
1141
- sourceFile,
1142
- isTracked: false,
1143
- isOpenByClient: false,
1144
- isTypeshedFile: importInfo.isTypeshedFile,
1145
- isThirdPartyImport: importInfo.isThirdPartyImport,
1146
- isThirdPartyPyTypedPresent: importInfo.isPyTypedPresent,
1147
- diagnosticsVersion: undefined,
1148
- imports: [],
1149
- importedBy: [],
1150
- shadows: [],
1151
- shadowedBy: [],
1152
- };
1163
+ const sourceFile = new sourceFile_1.SourceFile(this.fileSystem, importInfo.path, importName, importInfo.isThirdPartyImport, importInfo.isPyTypedPresent, this._editModeTracker, this._console, this._logTracker);
1164
+ importedFileInfo = new sourceFileInfo_1.SourceFileInfo(sourceFile, importInfo.isTypeshedFile, importInfo.isThirdPartyImport, importInfo.isPyTypedPresent, this._editModeTracker);
1153
1165
  this._addToSourceFileListAndMap(importedFileInfo);
1154
1166
  filesAdded.push(importedFileInfo);
1155
1167
  }
1156
- importedFileInfo.importedBy.push(sourceFileInfo);
1168
+ importedFileInfo.mutate((s) => s.importedBy.push(sourceFileInfo));
1157
1169
  updatedImportMap.set(normalizedImportPath, importedFileInfo);
1158
1170
  }
1159
1171
  });
1160
1172
  // Update the imports list. It should now map the set of imports
1161
1173
  // specified by the source file.
1162
- sourceFileInfo.imports = [];
1174
+ sourceFileInfo.mutate((s) => (s.imports = []));
1163
1175
  newImportPathMap.forEach((_, path) => {
1164
1176
  if (this.getSourceFileInfo(path)) {
1165
- sourceFileInfo.imports.push(this.getSourceFileInfo(path));
1177
+ sourceFileInfo.mutate((s) => s.imports.push(this.getSourceFileInfo(path)));
1166
1178
  }
1167
1179
  });
1168
1180
  // Resolve the builtins import for the file. This needs to be
@@ -1184,11 +1196,11 @@ class Program {
1184
1196
  return filesAdded;
1185
1197
  }
1186
1198
  _removeSourceFileFromListAndMap(filePath, indexToRemove) {
1187
- this._sourceFileMap.delete((0, pathUtils_1.normalizePathCase)(this.fileSystem, filePath));
1199
+ this._sourceFileMap.delete(filePath);
1188
1200
  this._sourceFileList.splice(indexToRemove, 1);
1189
1201
  }
1190
1202
  _addToSourceFileListAndMap(fileInfo) {
1191
- const filePath = (0, pathUtils_1.normalizePathCase)(this.fileSystem, fileInfo.sourceFile.getFilePath());
1203
+ const filePath = fileInfo.sourceFile.getFilePath();
1192
1204
  // We should never add a file with the same path twice.
1193
1205
  (0, debug_1.assert)(!this._sourceFileMap.has(filePath));
1194
1206
  this._sourceFileList.push(fileInfo);
@@ -1234,10 +1246,10 @@ class Program {
1234
1246
  shadowFileInfo = this.addInterimFile(shadowImplPath);
1235
1247
  }
1236
1248
  if (!shadowFileInfo.shadows.includes(stubFile)) {
1237
- shadowFileInfo.shadows.push(stubFile);
1249
+ shadowFileInfo.mutate((s) => s.shadows.push(stubFile));
1238
1250
  }
1239
1251
  if (!stubFile.shadowedBy.includes(shadowFileInfo)) {
1240
- stubFile.shadowedBy.push(shadowFileInfo);
1252
+ stubFile.mutate((s) => s.shadowedBy.push(shadowFileInfo));
1241
1253
  }
1242
1254
  return shadowFileInfo.sourceFile;
1243
1255
  }
@@ -1245,20 +1257,11 @@ class Program {
1245
1257
  const importName = this._getImportNameForFile(filePath);
1246
1258
  const sourceFile = this._sourceFileFactory.createSourceFile(this.fileSystem, filePath, importName,
1247
1259
  /* isThirdPartyImport */ false,
1248
- /* isInPyTypedPackage */ false, this._isEditMode, this._console, this._logTracker);
1249
- const sourceFileInfo = {
1250
- sourceFile,
1251
- isTracked: false,
1252
- isOpenByClient: false,
1253
- isTypeshedFile: false,
1254
- isThirdPartyImport: false,
1255
- isThirdPartyPyTypedPresent: false,
1256
- diagnosticsVersion: undefined,
1257
- imports: [],
1258
- importedBy: [],
1259
- shadows: [],
1260
- shadowedBy: [],
1261
- };
1260
+ /* isInPyTypedPackage */ false, this._editModeTracker, this._console, this._logTracker);
1261
+ const sourceFileInfo = new sourceFileInfo_1.SourceFileInfo(sourceFile,
1262
+ /* isTypeshedFile */ false,
1263
+ /* isThirdPartyImport */ false,
1264
+ /* isThirdPartyPyTypedPresent */ false, this._editModeTracker);
1262
1265
  return sourceFileInfo;
1263
1266
  }
1264
1267
  _createNewEvaluator() {
@@ -1522,7 +1525,7 @@ class Program {
1522
1525
  _getImportsRecursive(file, closureMap, recursionCount) {
1523
1526
  // If the file is already in the closure map, we found a cyclical
1524
1527
  // dependency. Don't recur further.
1525
- const filePath = (0, pathUtils_1.normalizePathCase)(this.fileSystem, file.sourceFile.getFilePath());
1528
+ const filePath = file.sourceFile.getFilePath();
1526
1529
  if (closureMap.has(filePath)) {
1527
1530
  return;
1528
1531
  }
@@ -1556,7 +1559,7 @@ class Program {
1556
1559
  if (sourceFileInfo.sourceFile.isNoCircularDependencyConfirmed()) {
1557
1560
  return false;
1558
1561
  }
1559
- const filePath = (0, pathUtils_1.normalizePathCase)(this.fileSystem, sourceFileInfo.sourceFile.getFilePath());
1562
+ const filePath = sourceFileInfo.sourceFile.getFilePath();
1560
1563
  filesVisited.set(filePath, sourceFileInfo);
1561
1564
  let detectedCycle = false;
1562
1565
  if (dependencyMap.has(filePath)) {
@@ -1609,7 +1612,7 @@ class Program {
1609
1612
  firstSourceFile.sourceFile.addCircularDependency(this.configOptions, circDep);
1610
1613
  }
1611
1614
  _markFileDirtyRecursive(sourceFileInfo, markSet, forceRebinding = false) {
1612
- const filePath = (0, pathUtils_1.normalizePathCase)(this.fileSystem, sourceFileInfo.sourceFile.getFilePath());
1615
+ const filePath = sourceFileInfo.sourceFile.getFilePath();
1613
1616
  // Don't mark it again if it's already been visited.
1614
1617
  if (markSet.has(filePath)) {
1615
1618
  return;
@@ -1623,6 +1626,7 @@ class Program {
1623
1626
  this._markFileDirtyRecursive(dep, markSet, forceRebinding);
1624
1627
  });
1625
1628
  // Change in the current file could impact checker result of chainedSourceFile such as unused symbols.
1629
+ let reevaluationRequired = false;
1626
1630
  let chainedSourceFile = sourceFileInfo.chainedSourceFile;
1627
1631
  while (chainedSourceFile) {
1628
1632
  if (chainedSourceFile.sourceFile.isCheckingRequired()) {
@@ -1630,9 +1634,17 @@ class Program {
1630
1634
  // as well. Stop here.
1631
1635
  return;
1632
1636
  }
1637
+ reevaluationRequired = true;
1633
1638
  chainedSourceFile.sourceFile.markReanalysisRequired(/* forceRebinding */ false);
1634
1639
  chainedSourceFile = chainedSourceFile.chainedSourceFile;
1635
1640
  }
1641
+ // If the checker is going to run again, we have to recreate the type evaulator so
1642
+ // that it actually reevaluates all the nodes (instead of using the cache).
1643
+ // This is necessary because the original file change may not recreate the TypeEvaluator.
1644
+ // For example, it might be a file delete.
1645
+ if (reevaluationRequired) {
1646
+ this._createNewEvaluator();
1647
+ }
1636
1648
  }
1637
1649
  }
1638
1650
  exports.Program = Program;