@zzzen/pyright-internal 1.2.0-dev.20230423 → 1.2.0-dev.20230507

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 (260) hide show
  1. package/dist/analyzer/analyzerFileInfo.d.ts +4 -1
  2. package/dist/analyzer/analyzerFileInfo.js.map +1 -1
  3. package/dist/analyzer/backgroundAnalysisProgram.d.ts +7 -4
  4. package/dist/analyzer/backgroundAnalysisProgram.js +22 -7
  5. package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
  6. package/dist/analyzer/binder.js +12 -7
  7. package/dist/analyzer/binder.js.map +1 -1
  8. package/dist/analyzer/checker.d.ts +1 -0
  9. package/dist/analyzer/checker.js +58 -7
  10. package/dist/analyzer/checker.js.map +1 -1
  11. package/dist/analyzer/constructors.d.ts +6 -0
  12. package/dist/analyzer/constructors.js +456 -0
  13. package/dist/analyzer/constructors.js.map +1 -0
  14. package/dist/analyzer/dataClasses.js +89 -2
  15. package/dist/analyzer/dataClasses.js.map +1 -1
  16. package/dist/analyzer/declarationUtils.d.ts +6 -1
  17. package/dist/analyzer/declarationUtils.js +10 -8
  18. package/dist/analyzer/declarationUtils.js.map +1 -1
  19. package/dist/analyzer/enums.js +54 -8
  20. package/dist/analyzer/enums.js.map +1 -1
  21. package/dist/analyzer/importResolver.d.ts +15 -15
  22. package/dist/analyzer/importResolver.js +477 -477
  23. package/dist/analyzer/importResolver.js.map +1 -1
  24. package/dist/analyzer/importStatementUtils.d.ts +2 -2
  25. package/dist/analyzer/importStatementUtils.js.map +1 -1
  26. package/dist/analyzer/namedTuples.d.ts +1 -1
  27. package/dist/analyzer/namedTuples.js +30 -42
  28. package/dist/analyzer/namedTuples.js.map +1 -1
  29. package/dist/analyzer/operations.d.ts +16 -0
  30. package/dist/analyzer/operations.js +749 -0
  31. package/dist/analyzer/operations.js.map +1 -0
  32. package/dist/analyzer/packageTypeReport.d.ts +2 -1
  33. package/dist/analyzer/packageTypeReport.js +2 -1
  34. package/dist/analyzer/packageTypeReport.js.map +1 -1
  35. package/dist/analyzer/packageTypeVerifier.d.ts +1 -1
  36. package/dist/analyzer/packageTypeVerifier.js +27 -13
  37. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  38. package/dist/analyzer/parseTreeUtils.d.ts +4 -2
  39. package/dist/analyzer/parseTreeUtils.js +32 -1
  40. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  41. package/dist/analyzer/patternMatching.js +16 -0
  42. package/dist/analyzer/patternMatching.js.map +1 -1
  43. package/dist/analyzer/program.d.ts +29 -53
  44. package/dist/analyzer/program.js +1050 -1649
  45. package/dist/analyzer/program.js.map +1 -1
  46. package/dist/analyzer/protocols.js +1 -1
  47. package/dist/analyzer/protocols.js.map +1 -1
  48. package/dist/analyzer/service.d.ts +14 -35
  49. package/dist/analyzer/service.js +92 -121
  50. package/dist/analyzer/service.js.map +1 -1
  51. package/dist/analyzer/sourceFile.d.ts +14 -49
  52. package/dist/analyzer/sourceFile.js +271 -291
  53. package/dist/analyzer/sourceFile.js.map +1 -1
  54. package/dist/analyzer/sourceFileInfoUtils.d.ts +2 -2
  55. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
  56. package/dist/analyzer/typeEvaluator.js +417 -1570
  57. package/dist/analyzer/typeEvaluator.js.map +1 -1
  58. package/dist/analyzer/typeEvaluatorTypes.d.ts +44 -9
  59. package/dist/analyzer/typeEvaluatorTypes.js +33 -1
  60. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  61. package/dist/analyzer/typeGuards.js +5 -9
  62. package/dist/analyzer/typeGuards.js.map +1 -1
  63. package/dist/analyzer/typeStubWriter.js.map +1 -1
  64. package/dist/analyzer/typeUtils.d.ts +3 -0
  65. package/dist/analyzer/typeUtils.js +66 -9
  66. package/dist/analyzer/typeUtils.js.map +1 -1
  67. package/dist/analyzer/typeVarContext.d.ts +5 -5
  68. package/dist/analyzer/typeVarContext.js +7 -0
  69. package/dist/analyzer/typeVarContext.js.map +1 -1
  70. package/dist/analyzer/typedDicts.js +2 -2
  71. package/dist/analyzer/typedDicts.js.map +1 -1
  72. package/dist/analyzer/types.d.ts +4 -2
  73. package/dist/analyzer/types.js +7 -0
  74. package/dist/analyzer/types.js.map +1 -1
  75. package/dist/backgroundAnalysisBase.d.ts +10 -11
  76. package/dist/backgroundAnalysisBase.js +87 -87
  77. package/dist/backgroundAnalysisBase.js.map +1 -1
  78. package/dist/commands/dumpFileDebugInfoCommand.js +8 -8
  79. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  80. package/dist/commands/quickActionCommand.js +4 -1
  81. package/dist/commands/quickActionCommand.js.map +1 -1
  82. package/dist/common/cancellationUtils.d.ts +1 -1
  83. package/dist/common/cancellationUtils.js +9 -9
  84. package/dist/common/cancellationUtils.js.map +1 -1
  85. package/dist/common/commandLineOptions.d.ts +1 -2
  86. package/dist/common/commandLineOptions.js.map +1 -1
  87. package/dist/common/configOptions.d.ts +2 -2
  88. package/dist/common/configOptions.js.map +1 -1
  89. package/dist/common/console.d.ts +5 -9
  90. package/dist/common/console.js +46 -33
  91. package/dist/common/console.js.map +1 -1
  92. package/dist/common/deferred.js +10 -10
  93. package/dist/common/deferred.js.map +1 -1
  94. package/dist/common/extensibility.d.ts +27 -5
  95. package/dist/common/extensibility.js +1 -1
  96. package/dist/common/extensibility.js.map +1 -1
  97. package/dist/common/fileBasedCancellationUtils.js +5 -5
  98. package/dist/common/fileBasedCancellationUtils.js.map +1 -1
  99. package/dist/common/fileSystem.d.ts +12 -10
  100. package/dist/common/fileSystem.js.map +1 -1
  101. package/dist/common/fullAccessHost.d.ts +3 -3
  102. package/dist/common/fullAccessHost.js +6 -6
  103. package/dist/common/fullAccessHost.js.map +1 -1
  104. package/dist/common/pathUtils.d.ts +13 -13
  105. package/dist/common/pathUtils.js.map +1 -1
  106. package/dist/common/realFileSystem.js +12 -7
  107. package/dist/common/realFileSystem.js.map +1 -1
  108. package/dist/common/uriParser.d.ts +2 -2
  109. package/dist/common/uriParser.js +3 -3
  110. package/dist/common/uriParser.js.map +1 -1
  111. package/dist/common/workspaceEditUtils.d.ts +5 -5
  112. package/dist/common/workspaceEditUtils.js +7 -4
  113. package/dist/common/workspaceEditUtils.js.map +1 -1
  114. package/dist/languageServerBase.d.ts +32 -31
  115. package/dist/languageServerBase.js +278 -345
  116. package/dist/languageServerBase.js.map +1 -1
  117. package/dist/languageService/analyzerServiceExecutor.js +0 -1
  118. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  119. package/dist/languageService/callHierarchyProvider.d.ts +16 -12
  120. package/dist/languageService/callHierarchyProvider.js +125 -41
  121. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  122. package/dist/languageService/completionProvider.d.ts +10 -13
  123. package/dist/languageService/completionProvider.js +21 -10
  124. package/dist/languageService/completionProvider.js.map +1 -1
  125. package/dist/languageService/definitionProvider.d.ts +23 -9
  126. package/dist/languageService/definitionProvider.js +116 -91
  127. package/dist/languageService/definitionProvider.js.map +1 -1
  128. package/dist/languageService/documentHighlightProvider.d.ts +8 -3
  129. package/dist/languageService/documentHighlightProvider.js +17 -6
  130. package/dist/languageService/documentHighlightProvider.js.map +1 -1
  131. package/dist/languageService/documentSymbolCollector.d.ts +6 -7
  132. package/dist/languageService/documentSymbolCollector.js +21 -11
  133. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  134. package/dist/languageService/documentSymbolProvider.js +5 -3
  135. package/dist/languageService/documentSymbolProvider.js.map +1 -1
  136. package/dist/languageService/hoverProvider.d.ts +4 -3
  137. package/dist/languageService/hoverProvider.js +30 -36
  138. package/dist/languageService/hoverProvider.js.map +1 -1
  139. package/dist/languageService/navigationUtils.d.ts +6 -0
  140. package/dist/languageService/navigationUtils.js +28 -0
  141. package/dist/languageService/navigationUtils.js.map +1 -0
  142. package/dist/languageService/quickActions.d.ts +2 -2
  143. package/dist/languageService/quickActions.js +12 -1
  144. package/dist/languageService/quickActions.js.map +1 -1
  145. package/dist/languageService/referencesProvider.d.ts +13 -12
  146. package/dist/languageService/referencesProvider.js +102 -16
  147. package/dist/languageService/referencesProvider.js.map +1 -1
  148. package/dist/languageService/renameProvider.d.ts +17 -0
  149. package/dist/languageService/renameProvider.js +143 -0
  150. package/dist/languageService/renameProvider.js.map +1 -0
  151. package/dist/languageService/signatureHelpProvider.d.ts +19 -23
  152. package/dist/languageService/signatureHelpProvider.js +111 -18
  153. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  154. package/dist/localization/localize.d.ts +17 -14
  155. package/dist/localization/localize.js +4 -6
  156. package/dist/localization/localize.js.map +1 -1
  157. package/dist/localization/package.nls.en-us.json +5 -6
  158. package/dist/parser/characterStream.d.ts +3 -3
  159. package/dist/parser/characterStream.js +12 -12
  160. package/dist/parser/characterStream.js.map +1 -1
  161. package/dist/parser/parser.d.ts +1 -1
  162. package/dist/parser/parser.js.map +1 -1
  163. package/dist/pyright.js +57 -54
  164. package/dist/pyright.js.map +1 -1
  165. package/dist/pyrightFileSystem.d.ts +1 -1
  166. package/dist/pyrightFileSystem.js +21 -21
  167. package/dist/pyrightFileSystem.js.map +1 -1
  168. package/dist/readonlyAugmentedFileSystem.d.ts +6 -6
  169. package/dist/readonlyAugmentedFileSystem.js +28 -28
  170. package/dist/readonlyAugmentedFileSystem.js.map +1 -1
  171. package/dist/server.js +6 -6
  172. package/dist/server.js.map +1 -1
  173. package/dist/tests/chainedSourceFiles.test.js +1 -1
  174. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  175. package/dist/tests/checker.test.js +1 -1
  176. package/dist/tests/documentSymbolCollector.test.js +3 -3
  177. package/dist/tests/documentSymbolCollector.test.js.map +1 -1
  178. package/dist/tests/fourslash/fourslash.d.ts +4 -4
  179. package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.js +1 -1
  180. package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.js.map +1 -1
  181. package/dist/tests/harness/fourslash/testLanguageService.d.ts +3 -3
  182. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  183. package/dist/tests/harness/fourslash/testState.d.ts +11 -11
  184. package/dist/tests/harness/fourslash/testState.js +123 -113
  185. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  186. package/dist/tests/harness/vfs/filesystem.d.ts +8 -8
  187. package/dist/tests/harness/vfs/filesystem.js +68 -68
  188. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  189. package/dist/tests/importStatementUtils.test.js +34 -0
  190. package/dist/tests/importStatementUtils.test.js.map +1 -1
  191. package/dist/tests/signatureHelp.test.js +5 -1
  192. package/dist/tests/signatureHelp.test.js.map +1 -1
  193. package/dist/tests/sourceFile.test.js +2 -2
  194. package/dist/tests/sourceFile.test.js.map +1 -1
  195. package/dist/tests/testStateUtils.d.ts +2 -2
  196. package/dist/tests/testStateUtils.js +39 -9
  197. package/dist/tests/testStateUtils.js.map +1 -1
  198. package/dist/tests/typeEvaluator1.test.js +8 -0
  199. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  200. package/dist/tests/typeEvaluator2.test.js +13 -1
  201. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  202. package/dist/tests/typeEvaluator3.test.js +2 -2
  203. package/dist/tests/typeEvaluator4.test.js +9 -1
  204. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  205. package/dist/tests/typeEvaluator5.test.js +4 -0
  206. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  207. package/dist/tests/workspaceEditUtils.test.js +84 -0
  208. package/dist/tests/workspaceEditUtils.test.js.map +1 -1
  209. package/package.json +4 -4
  210. package/dist/languageService/indentationUtils.d.ts +0 -16
  211. package/dist/languageService/indentationUtils.js +0 -727
  212. package/dist/languageService/indentationUtils.js.map +0 -1
  213. package/dist/languageService/insertionPointUtils.d.ts +0 -9
  214. package/dist/languageService/insertionPointUtils.js +0 -132
  215. package/dist/languageService/insertionPointUtils.js.map +0 -1
  216. package/dist/languageService/renameModuleProvider.d.ts +0 -65
  217. package/dist/languageService/renameModuleProvider.js +0 -939
  218. package/dist/languageService/renameModuleProvider.js.map +0 -1
  219. package/dist/tests/indentationUtils.ptvs.test.d.ts +0 -1
  220. package/dist/tests/indentationUtils.ptvs.test.js +0 -324
  221. package/dist/tests/indentationUtils.ptvs.test.js.map +0 -1
  222. package/dist/tests/indentationUtils.reindent.test.d.ts +0 -1
  223. package/dist/tests/indentationUtils.reindent.test.js +0 -372
  224. package/dist/tests/indentationUtils.reindent.test.js.map +0 -1
  225. package/dist/tests/indentationUtils.test.d.ts +0 -1
  226. package/dist/tests/indentationUtils.test.js +0 -502
  227. package/dist/tests/indentationUtils.test.js.map +0 -1
  228. package/dist/tests/insertionPointUtils.test.d.ts +0 -1
  229. package/dist/tests/insertionPointUtils.test.js +0 -154
  230. package/dist/tests/insertionPointUtils.test.js.map +0 -1
  231. package/dist/tests/moveSymbol.importAdder.test.d.ts +0 -1
  232. package/dist/tests/moveSymbol.importAdder.test.js +0 -298
  233. package/dist/tests/moveSymbol.importAdder.test.js.map +0 -1
  234. package/dist/tests/moveSymbol.insertion.test.d.ts +0 -1
  235. package/dist/tests/moveSymbol.insertion.test.js +0 -537
  236. package/dist/tests/moveSymbol.insertion.test.js.map +0 -1
  237. package/dist/tests/moveSymbol.misc.test.d.ts +0 -1
  238. package/dist/tests/moveSymbol.misc.test.js +0 -169
  239. package/dist/tests/moveSymbol.misc.test.js.map +0 -1
  240. package/dist/tests/moveSymbol.updateReference.test.d.ts +0 -1
  241. package/dist/tests/moveSymbol.updateReference.test.js +0 -1057
  242. package/dist/tests/moveSymbol.updateReference.test.js.map +0 -1
  243. package/dist/tests/renameModule.folder.test.d.ts +0 -1
  244. package/dist/tests/renameModule.folder.test.js +0 -229
  245. package/dist/tests/renameModule.folder.test.js.map +0 -1
  246. package/dist/tests/renameModule.fromImports.test.d.ts +0 -1
  247. package/dist/tests/renameModule.fromImports.test.js +0 -790
  248. package/dist/tests/renameModule.fromImports.test.js.map +0 -1
  249. package/dist/tests/renameModule.imports.test.d.ts +0 -1
  250. package/dist/tests/renameModule.imports.test.js +0 -380
  251. package/dist/tests/renameModule.imports.test.js.map +0 -1
  252. package/dist/tests/renameModule.misc.test.d.ts +0 -1
  253. package/dist/tests/renameModule.misc.test.js +0 -615
  254. package/dist/tests/renameModule.misc.test.js.map +0 -1
  255. package/dist/tests/renameModule.relativePath.test.d.ts +0 -1
  256. package/dist/tests/renameModule.relativePath.test.js +0 -231
  257. package/dist/tests/renameModule.relativePath.test.js.map +0 -1
  258. package/dist/tests/renameModuleTestUtils.d.ts +0 -4
  259. package/dist/tests/renameModuleTestUtils.js +0 -76
  260. package/dist/tests/renameModuleTestUtils.js.map +0 -1
@@ -28,7 +28,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.parseFile = exports.SourceFile = exports.IPythonMode = void 0;
31
- const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
32
31
  const worker_threads_1 = require("worker_threads");
33
32
  const SymbolNameUtils = __importStar(require("../analyzer/symbolNameUtils"));
34
33
  const cancellationUtils_1 = require("../common/cancellationUtils");
@@ -48,12 +47,7 @@ const textRange_1 = require("../common/textRange");
48
47
  const textRangeCollection_1 = require("../common/textRangeCollection");
49
48
  const timing_1 = require("../common/timing");
50
49
  const completionProvider_1 = require("../languageService/completionProvider");
51
- const definitionProvider_1 = require("../languageService/definitionProvider");
52
- const documentHighlightProvider_1 = require("../languageService/documentHighlightProvider");
53
50
  const documentSymbolProvider_1 = require("../languageService/documentSymbolProvider");
54
- const quickActions_1 = require("../languageService/quickActions");
55
- const referencesProvider_1 = require("../languageService/referencesProvider");
56
- const signatureHelpProvider_1 = require("../languageService/signatureHelpProvider");
57
51
  const localize_1 = require("../localization/localize");
58
52
  const parseNodes_1 = require("../parser/parseNodes");
59
53
  const parser_1 = require("../parser/parser");
@@ -78,50 +72,58 @@ var IPythonMode;
78
72
  // Each cell is its own document.
79
73
  IPythonMode[IPythonMode["CellDocs"] = 1] = "CellDocs";
80
74
  })(IPythonMode = exports.IPythonMode || (exports.IPythonMode = {}));
81
- class SourceFile {
82
- constructor(fs, filePath, moduleName, isThirdPartyImport, isThirdPartyPyTypedPresent, console, logTracker, realFilePath, ipythonMode = IPythonMode.None) {
83
- // True if the file appears to have been deleted.
84
- this._isFileDeleted = false;
75
+ class WriteableData {
76
+ constructor() {
85
77
  // Number that is incremented every time the diagnostics
86
78
  // are updated.
87
- this._diagnosticVersion = 0;
79
+ this.diagnosticVersion = 0;
88
80
  // Generation count of the file contents. When the contents
89
81
  // change, this is incremented.
90
- this._fileContentsVersion = 0;
82
+ this.fileContentsVersion = 0;
91
83
  // Length and hash of the file the last time it was read from disk.
92
- this._lastFileContentLength = undefined;
93
- this._lastFileContentHash = undefined;
84
+ this.lastFileContentLength = undefined;
85
+ this.lastFileContentHash = undefined;
94
86
  // Version of file contents that have been analyzed.
95
- this._analyzedFileContentsVersion = -1;
87
+ this.analyzedFileContentsVersion = -1;
96
88
  // Do we need to walk the parse tree and clean
97
89
  // the binder information hanging from it?
98
- this._parseTreeNeedsCleaning = false;
90
+ this.parseTreeNeedsCleaning = false;
99
91
  // Reentrancy check for binding.
100
- this._isBindingInProgress = false;
92
+ this.isBindingInProgress = false;
101
93
  // Diagnostics generated during different phases of analysis.
102
- this._parseDiagnostics = [];
103
- this._commentDiagnostics = [];
104
- this._bindDiagnostics = [];
105
- this._checkerDiagnostics = [];
106
- this._typeIgnoreLines = new Map();
107
- this._pyrightIgnoreLines = new Map();
108
- // Settings that control which diagnostics should be output. The rules
109
- // are initialized to the basic set. They should be updated after the
110
- // the file is parsed.
111
- this._diagnosticRuleSet = (0, configOptions_1.getBasicDiagnosticRuleSet)();
94
+ this.parseDiagnostics = [];
95
+ this.commentDiagnostics = [];
96
+ this.bindDiagnostics = [];
97
+ this.checkerDiagnostics = [];
98
+ this.typeIgnoreLines = new Map();
99
+ this.pyrightIgnoreLines = new Map();
112
100
  // Circular dependencies that have been reported in this file.
113
- this._circularDependencies = [];
114
- this._noCircularDependencyConfirmed = false;
101
+ this.circularDependencies = [];
102
+ this.noCircularDependencyConfirmed = false;
115
103
  // Do we need to perform a binding step?
116
- this._isBindingNeeded = true;
104
+ this.isBindingNeeded = true;
117
105
  // Do we have valid diagnostic results from a checking pass?
118
- this._isCheckingNeeded = true;
106
+ this.isCheckingNeeded = true;
119
107
  // Do we need to perform an indexing step?
120
- this._indexingNeeded = true;
108
+ this.indexingNeeded = true;
109
+ // True if the file appears to have been deleted.
110
+ this.isFileDeleted = false;
111
+ }
112
+ }
113
+ class SourceFile {
114
+ constructor(fs, filePath, moduleName, isThirdPartyImport, isThirdPartyPyTypedPresent, editMode, console, logTracker, realFilePath, ipythonMode = IPythonMode.None) {
115
+ // Data that changes when the source file changes.
116
+ this._writableData = new WriteableData();
117
+ // Settings that control which diagnostics should be output. The rules
118
+ // are initialized to the basic set. They should be updated after the
119
+ // the file is parsed.
120
+ this._diagnosticRuleSet = (0, configOptions_1.getBasicDiagnosticRuleSet)();
121
121
  // Indicate whether this file is for ipython or not.
122
122
  this._ipythonMode = IPythonMode.None;
123
+ this._isEditMode = false;
123
124
  this.fileSystem = fs;
124
125
  this._console = console || new console_1.StandardConsole();
126
+ this._isEditMode = editMode;
125
127
  this._filePath = filePath;
126
128
  this._realFilePath = realFilePath !== null && realFilePath !== void 0 ? realFilePath : filePath;
127
129
  this._moduleName = moduleName;
@@ -168,7 +170,7 @@ class SourceFile {
168
170
  this._moduleName = name;
169
171
  }
170
172
  getDiagnosticVersion() {
171
- return this._diagnosticVersion;
173
+ return this._writableData.diagnosticVersion;
172
174
  }
173
175
  isStubFile() {
174
176
  return this._isStubFile;
@@ -180,7 +182,7 @@ class SourceFile {
180
182
  // If the prevVersion is specified, the method returns undefined if
181
183
  // the diagnostics haven't changed.
182
184
  getDiagnostics(options, prevDiagnosticVersion) {
183
- if (this._diagnosticVersion === prevDiagnosticVersion) {
185
+ if (this._writableData.diagnosticVersion === prevDiagnosticVersion) {
184
186
  return undefined;
185
187
  }
186
188
  let includeWarningsAndErrors = true;
@@ -190,23 +192,23 @@ class SourceFile {
190
192
  includeWarningsAndErrors = false;
191
193
  }
192
194
  let diagList = [
193
- ...this._parseDiagnostics,
194
- ...this._commentDiagnostics,
195
- ...this._bindDiagnostics,
196
- ...this._checkerDiagnostics,
195
+ ...this._writableData.parseDiagnostics,
196
+ ...this._writableData.commentDiagnostics,
197
+ ...this._writableData.bindDiagnostics,
198
+ ...this._writableData.checkerDiagnostics,
197
199
  ];
198
200
  const prefilteredDiagList = diagList;
199
- const typeIgnoreLinesClone = new Map(this._typeIgnoreLines);
200
- const pyrightIgnoreLinesClone = new Map(this._pyrightIgnoreLines);
201
+ const typeIgnoreLinesClone = new Map(this._writableData.typeIgnoreLines);
202
+ const pyrightIgnoreLinesClone = new Map(this._writableData.pyrightIgnoreLines);
201
203
  // Filter the diagnostics based on "type: ignore" lines.
202
204
  if (this._diagnosticRuleSet.enableTypeIgnoreComments) {
203
- if (this._typeIgnoreLines.size > 0) {
205
+ if (this._writableData.typeIgnoreLines.size > 0) {
204
206
  diagList = diagList.filter((d) => {
205
207
  if (d.category !== 3 /* UnusedCode */ &&
206
208
  d.category !== 4 /* UnreachableCode */ &&
207
209
  d.category !== 5 /* Deprecated */) {
208
210
  for (let line = d.range.start.line; line <= d.range.end.line; line++) {
209
- if (this._typeIgnoreLines.has(line)) {
211
+ if (this._writableData.typeIgnoreLines.has(line)) {
210
212
  typeIgnoreLinesClone.delete(line);
211
213
  return false;
212
214
  }
@@ -217,11 +219,11 @@ class SourceFile {
217
219
  }
218
220
  }
219
221
  // Filter the diagnostics based on "pyright: ignore" lines.
220
- if (this._pyrightIgnoreLines.size > 0) {
222
+ if (this._writableData.pyrightIgnoreLines.size > 0) {
221
223
  diagList = diagList.filter((d) => {
222
224
  if (d.category !== 4 /* UnreachableCode */ && d.category !== 5 /* Deprecated */) {
223
225
  for (let line = d.range.start.line; line <= d.range.end.line; line++) {
224
- const pyrightIgnoreComment = this._pyrightIgnoreLines.get(line);
226
+ const pyrightIgnoreComment = this._writableData.pyrightIgnoreLines.get(line);
225
227
  if (pyrightIgnoreComment) {
226
228
  if (!pyrightIgnoreComment.rulesList) {
227
229
  pyrightIgnoreLinesClone.delete(line);
@@ -269,20 +271,20 @@ class SourceFile {
269
271
  diag.range.start.line <= range.start.line &&
270
272
  diag.range.end.line >= range.end.line);
271
273
  };
272
- if (prefilteredErrorList.length === 0 && this._typeIgnoreAll !== undefined) {
273
- const rangeStart = this._typeIgnoreAll.range.start;
274
- const rangeEnd = rangeStart + this._typeIgnoreAll.range.length;
275
- const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._parseResults.tokenizerOutput.lines);
274
+ if (prefilteredErrorList.length === 0 && this._writableData.typeIgnoreAll !== undefined) {
275
+ const rangeStart = this._writableData.typeIgnoreAll.range.start;
276
+ const rangeEnd = rangeStart + this._writableData.typeIgnoreAll.range.length;
277
+ const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
276
278
  if (!isUnreachableCodeRange(range) && this._diagnosticRuleSet.enableTypeIgnoreComments) {
277
279
  unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryTypeIgnore(), range));
278
280
  }
279
281
  }
280
282
  typeIgnoreLinesClone.forEach((ignoreComment) => {
281
283
  var _a;
282
- if ((_a = this._parseResults) === null || _a === void 0 ? void 0 : _a.tokenizerOutput.lines) {
284
+ if ((_a = this._writableData.parseResults) === null || _a === void 0 ? void 0 : _a.tokenizerOutput.lines) {
283
285
  const rangeStart = ignoreComment.range.start;
284
286
  const rangeEnd = rangeStart + ignoreComment.range.length;
285
- const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._parseResults.tokenizerOutput.lines);
287
+ const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
286
288
  if (!isUnreachableCodeRange(range) && this._diagnosticRuleSet.enableTypeIgnoreComments) {
287
289
  unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryTypeIgnore(), range));
288
290
  }
@@ -290,11 +292,11 @@ class SourceFile {
290
292
  });
291
293
  pyrightIgnoreLinesClone.forEach((ignoreComment) => {
292
294
  var _a;
293
- if ((_a = this._parseResults) === null || _a === void 0 ? void 0 : _a.tokenizerOutput.lines) {
295
+ if ((_a = this._writableData.parseResults) === null || _a === void 0 ? void 0 : _a.tokenizerOutput.lines) {
294
296
  if (!ignoreComment.rulesList) {
295
297
  const rangeStart = ignoreComment.range.start;
296
298
  const rangeEnd = rangeStart + ignoreComment.range.length;
297
- const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._parseResults.tokenizerOutput.lines);
299
+ const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
298
300
  if (!isUnreachableCodeRange(range)) {
299
301
  unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryPyrightIgnore(), range));
300
302
  }
@@ -303,7 +305,7 @@ class SourceFile {
303
305
  ignoreComment.rulesList.forEach((unusedRule) => {
304
306
  const rangeStart = unusedRule.range.start;
305
307
  const rangeEnd = rangeStart + unusedRule.range.length;
306
- const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._parseResults.tokenizerOutput.lines);
308
+ const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
307
309
  if (!isUnreachableCodeRange(range)) {
308
310
  unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryPyrightIgnoreRule().format({
309
311
  name: unusedRule.text,
@@ -314,9 +316,10 @@ class SourceFile {
314
316
  }
315
317
  });
316
318
  }
317
- if (this._diagnosticRuleSet.reportImportCycles !== 'none' && this._circularDependencies.length > 0) {
319
+ if (this._diagnosticRuleSet.reportImportCycles !== 'none' &&
320
+ this._writableData.circularDependencies.length > 0) {
318
321
  const category = (0, diagnostic_1.convertLevelToCategory)(this._diagnosticRuleSet.reportImportCycles);
319
- this._circularDependencies.forEach((cirDep) => {
322
+ this._writableData.circularDependencies.forEach((cirDep) => {
320
323
  const diag = new diagnostic_1.Diagnostic(category, localize_1.Localizer.Diagnostic.importCycleDetected() +
321
324
  '\n' +
322
325
  cirDep
@@ -327,8 +330,8 @@ class SourceFile {
327
330
  diagList.push(diag);
328
331
  });
329
332
  }
330
- if (this._hitMaxImportDepth !== undefined) {
331
- diagList.push(new diagnostic_1.Diagnostic(0 /* Error */, localize_1.Localizer.Diagnostic.importDepthExceeded().format({ depth: this._hitMaxImportDepth }), (0, textRange_1.getEmptyRange)()));
333
+ if (this._writableData.hitMaxImportDepth !== undefined) {
334
+ diagList.push(new diagnostic_1.Diagnostic(0 /* Error */, localize_1.Localizer.Diagnostic.importDepthExceeded().format({ depth: this._writableData.hitMaxImportDepth }), (0, textRange_1.getEmptyRange)()));
332
335
  }
333
336
  // add diagnostics for comments that match the task list tokens
334
337
  this._addTaskListDiagnostics(options.taskListTokens, diagList);
@@ -339,7 +342,7 @@ class SourceFile {
339
342
  // If there is a "type: ignore" comment at the top of the file, clear
340
343
  // the diagnostic list of all error, warning, and information diagnostics.
341
344
  if (this._diagnosticRuleSet.enableTypeIgnoreComments) {
342
- if (this._typeIgnoreAll !== undefined) {
345
+ if (this._writableData.typeIgnoreAll !== undefined) {
343
346
  diagList = diagList.filter((diag) => diag.category !== 0 /* Error */ &&
344
347
  diag.category !== 1 /* Warning */ &&
345
348
  diag.category !== 2 /* Information */);
@@ -357,67 +360,34 @@ class SourceFile {
357
360
  }
358
361
  return diagList;
359
362
  }
360
- // Get all task list diagnostics for the current file and add them
361
- // to the specified diagnostic list
362
- _addTaskListDiagnostics(taskListTokens, diagList) {
363
- var _a, _b;
364
- // input validation
365
- if (!taskListTokens || taskListTokens.length === 0 || !diagList) {
366
- return;
367
- }
368
- // if we have no tokens, we're done
369
- if (!((_b = (_a = this._parseResults) === null || _a === void 0 ? void 0 : _a.tokenizerOutput) === null || _b === void 0 ? void 0 : _b.tokens)) {
370
- return;
371
- }
372
- const tokenizerOutput = this._parseResults.tokenizerOutput;
373
- for (let i = 0; i < tokenizerOutput.tokens.count; i++) {
374
- const token = tokenizerOutput.tokens.getItemAt(i);
375
- // if there are no comments, skip this token
376
- if (!token.comments || token.comments.length === 0) {
377
- continue;
378
- }
379
- for (const comment of token.comments) {
380
- for (const token of taskListTokens) {
381
- // Check if the comment matches the task list token.
382
- // The comment must start with zero or more whitespace characters,
383
- // followed by the taskListToken (case insensitive),
384
- // followed by (0+ whitespace + EOL) OR (1+ NON-alphanumeric characters)
385
- const regexStr = '^[\\s]*' + token.text + '([\\s]*$|[\\W]+)';
386
- const regex = RegExp(regexStr, 'i'); // case insensitive
387
- // if the comment doesn't match, skip it
388
- if (!regex.test(comment.value)) {
389
- continue;
390
- }
391
- // Calculate the range for the diagnostic
392
- // This allows navigation to the comment via double clicking the item in the task list pane
393
- let rangeStart = comment.start;
394
- // The comment technically starts right after the comment identifier (#), but we want the caret right
395
- // before the task list token (since there might be whitespace before it)
396
- const indexOfToken = comment.value.toLowerCase().indexOf(token.text.toLowerCase());
397
- rangeStart += indexOfToken;
398
- const rangeEnd = textRange_1.TextRange.getEnd(comment);
399
- const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, tokenizerOutput.lines);
400
- // Add the diagnostic to the list to send to VS,
401
- // and trim whitespace from the comment so it's easier to read in the task list
402
- diagList.push(new diagnostic_1.Diagnostic(6 /* TaskItem */, comment.value.trim(), range, token.priority));
403
- }
404
- }
405
- }
406
- }
407
363
  getImports() {
408
- return this._imports || [];
364
+ return this._writableData.imports || [];
409
365
  }
410
366
  getBuiltinsImport() {
411
- return this._builtinsImport;
367
+ return this._writableData.builtinsImport;
412
368
  }
413
369
  getIPythonDisplayImport() {
414
- return this._ipythonDisplayImport;
370
+ return this._writableData.ipythonDisplayImport;
415
371
  }
416
372
  getModuleSymbolTable() {
417
- return this._moduleSymbolTable;
373
+ return this._writableData.moduleSymbolTable;
418
374
  }
419
375
  getCheckTime() {
420
- return this._checkTime;
376
+ return this._writableData.checkTime;
377
+ }
378
+ enterEditMode() {
379
+ this._isEditMode = true;
380
+ }
381
+ exitEditMode() {
382
+ this._isEditMode = false;
383
+ // If we had an edit, return our text.
384
+ if (this._preEditData) {
385
+ const text = this._writableData.clientDocumentContents;
386
+ this._writableData = this._preEditData;
387
+ this._preEditData = undefined;
388
+ return text;
389
+ }
390
+ return undefined;
421
391
  }
422
392
  // Indicates whether the contents of the file have changed since
423
393
  // the last analysis was performed.
@@ -425,11 +395,11 @@ class SourceFile {
425
395
  // If this is an open file any content changes will be
426
396
  // provided through the editor. We can assume contents
427
397
  // didn't change without us knowing about them.
428
- if (this._clientDocument) {
398
+ if (this._writableData.clientDocumentContents) {
429
399
  return false;
430
400
  }
431
401
  // If the file was never read previously, no need to check for a change.
432
- if (this._lastFileContentLength === undefined) {
402
+ if (this._writableData.lastFileContentLength === undefined) {
433
403
  return false;
434
404
  }
435
405
  // Read in the latest file contents and see if the hash matches
@@ -437,10 +407,10 @@ class SourceFile {
437
407
  try {
438
408
  // Read the file's contents.
439
409
  const fileContents = this.fileSystem.readFileSync(this._filePath, 'utf8');
440
- if (fileContents.length !== this._lastFileContentLength) {
410
+ if (fileContents.length !== this._writableData.lastFileContentLength) {
441
411
  return true;
442
412
  }
443
- if (StringUtils.hashString(fileContents) !== this._lastFileContentHash) {
413
+ if (StringUtils.hashString(fileContents) !== this._writableData.lastFileContentHash) {
444
414
  return true;
445
415
  }
446
416
  }
@@ -453,47 +423,45 @@ class SourceFile {
453
423
  // in cases where memory is low. When info is needed, the file
454
424
  // will be re-parsed and rebound.
455
425
  dropParseAndBindInfo() {
456
- this._parseResults = undefined;
457
- this._moduleSymbolTable = undefined;
458
- this._isBindingNeeded = true;
426
+ this._writableData.parseResults = undefined;
427
+ this._writableData.moduleSymbolTable = undefined;
428
+ this._writableData.isBindingNeeded = true;
459
429
  }
460
430
  markDirty(indexingNeeded = true) {
461
- this._fileContentsVersion++;
462
- this._noCircularDependencyConfirmed = false;
463
- this._isCheckingNeeded = true;
464
- this._isBindingNeeded = true;
465
- this._indexingNeeded = indexingNeeded;
466
- this._moduleSymbolTable = undefined;
467
- this._cachedIndexResults = undefined;
431
+ this._writableData.fileContentsVersion++;
432
+ this._writableData.noCircularDependencyConfirmed = false;
433
+ this._writableData.isCheckingNeeded = true;
434
+ this._writableData.isBindingNeeded = true;
435
+ this._writableData.indexingNeeded = indexingNeeded;
436
+ this._writableData.moduleSymbolTable = undefined;
437
+ this._writableData.cachedIndexResults = undefined;
468
438
  const filePath = this.getFilePath();
469
439
  extensibility_1.Extensions.getProgramExtensions(filePath).forEach((e) => (e.fileDirty ? e.fileDirty(filePath) : null));
470
440
  }
471
441
  markReanalysisRequired(forceRebinding) {
472
442
  // Keep the parse info, but reset the analysis to the beginning.
473
- this._isCheckingNeeded = true;
474
- this._noCircularDependencyConfirmed = false;
443
+ this._writableData.isCheckingNeeded = true;
444
+ this._writableData.noCircularDependencyConfirmed = false;
475
445
  // If the file contains a wildcard import or __all__ symbols,
476
446
  // we need to rebind because a dependent import may have changed.
477
- if (this._parseResults) {
478
- if (this._parseResults.containsWildcardImport ||
479
- AnalyzerNodeInfo.getDunderAllInfo(this._parseResults.parseTree) !== undefined ||
447
+ if (this._writableData.parseResults) {
448
+ if (this._writableData.parseResults.containsWildcardImport ||
449
+ AnalyzerNodeInfo.getDunderAllInfo(this._writableData.parseResults.parseTree) !== undefined ||
480
450
  forceRebinding) {
481
451
  // We don't need to rebuild index data since wildcard
482
452
  // won't affect user file indices. User file indices
483
453
  // don't contain import alias info.
484
- this._parseTreeNeedsCleaning = true;
485
- this._isBindingNeeded = true;
486
- this._moduleSymbolTable = undefined;
454
+ this._writableData.parseTreeNeedsCleaning = true;
455
+ this._writableData.isBindingNeeded = true;
456
+ this._writableData.moduleSymbolTable = undefined;
487
457
  }
488
458
  }
489
459
  }
490
460
  getClientVersion() {
491
- var _a;
492
- return (_a = this._clientDocument) === null || _a === void 0 ? void 0 : _a.version;
461
+ return this._writableData.clientDocumentVersion;
493
462
  }
494
463
  getOpenFileContents() {
495
- var _a;
496
- return (_a = this._clientDocument) === null || _a === void 0 ? void 0 : _a.getText();
464
+ return this._writableData.clientDocumentContents;
497
465
  }
498
466
  getFileContent() {
499
467
  // Get current buffer content if the file is opened.
@@ -517,84 +485,86 @@ class SourceFile {
517
485
  }
518
486
  }
519
487
  setClientVersion(version, contents) {
488
+ // Save pre edit state if in edit mode.
489
+ this._cachePreEditState();
520
490
  if (version === null) {
521
- this._clientDocument = undefined;
491
+ this._writableData.clientDocumentVersion = undefined;
492
+ this._writableData.clientDocumentContents = undefined;
522
493
  }
523
494
  else {
524
- if (!this._clientDocument) {
525
- this._clientDocument = vscode_languageserver_textdocument_1.TextDocument.create(this._filePath, 'python', version, '');
526
- }
527
- this._clientDocument = vscode_languageserver_textdocument_1.TextDocument.update(this._clientDocument, contents, version);
528
- const fileContents = this._clientDocument.getText();
529
- const contentsHash = StringUtils.hashString(fileContents);
495
+ this._writableData.clientDocumentVersion = version;
496
+ this._writableData.clientDocumentContents = contents;
497
+ const contentsHash = StringUtils.hashString(contents);
530
498
  // Have the contents of the file changed?
531
- if (fileContents.length !== this._lastFileContentLength || contentsHash !== this._lastFileContentHash) {
499
+ if (contents.length !== this._writableData.lastFileContentLength ||
500
+ contentsHash !== this._writableData.lastFileContentHash) {
532
501
  this.markDirty();
533
502
  }
534
- this._lastFileContentLength = fileContents.length;
535
- this._lastFileContentHash = contentsHash;
536
- this._isFileDeleted = false;
503
+ this._writableData.lastFileContentLength = contents.length;
504
+ this._writableData.lastFileContentHash = contentsHash;
505
+ this._writableData.isFileDeleted = false;
537
506
  }
538
507
  }
539
508
  prepareForClose() {
540
509
  // Nothing to do currently.
541
510
  }
542
511
  isFileDeleted() {
543
- return this._isFileDeleted;
512
+ return this._writableData.isFileDeleted;
544
513
  }
545
514
  isParseRequired() {
546
- return !this._parseResults || this._analyzedFileContentsVersion !== this._fileContentsVersion;
515
+ return (!this._writableData.parseResults ||
516
+ this._writableData.analyzedFileContentsVersion !== this._writableData.fileContentsVersion);
547
517
  }
548
518
  isBindingRequired() {
549
- if (this._isBindingInProgress) {
519
+ if (this._writableData.isBindingInProgress) {
550
520
  return false;
551
521
  }
552
522
  if (this.isParseRequired()) {
553
523
  return true;
554
524
  }
555
- return this._isBindingNeeded;
525
+ return this._writableData.isBindingNeeded;
556
526
  }
557
527
  isIndexingRequired() {
558
- return this._indexingNeeded;
528
+ return this._writableData.indexingNeeded;
559
529
  }
560
530
  isCheckingRequired() {
561
- return this._isCheckingNeeded;
531
+ return this._writableData.isCheckingNeeded;
562
532
  }
563
533
  getParseResults() {
564
534
  if (!this.isParseRequired()) {
565
- return this._parseResults;
535
+ return this._writableData.parseResults;
566
536
  }
567
537
  return undefined;
568
538
  }
569
539
  getCachedIndexResults() {
570
- return this._cachedIndexResults;
540
+ return this._writableData.cachedIndexResults;
571
541
  }
572
542
  cacheIndexResults(indexResults) {
573
- this._cachedIndexResults = indexResults;
543
+ this._writableData.cachedIndexResults = indexResults;
574
544
  }
575
545
  // Adds a new circular dependency for this file but only if
576
546
  // it hasn't already been added.
577
547
  addCircularDependency(circDependency) {
578
548
  let updatedDependencyList = false;
579
549
  // Some topologies can result in a massive number of cycles. We'll cut it off.
580
- if (this._circularDependencies.length < _maxImportCyclesPerFile) {
581
- if (!this._circularDependencies.some((dep) => dep.isEqual(circDependency))) {
582
- this._circularDependencies.push(circDependency);
550
+ if (this._writableData.circularDependencies.length < _maxImportCyclesPerFile) {
551
+ if (!this._writableData.circularDependencies.some((dep) => dep.isEqual(circDependency))) {
552
+ this._writableData.circularDependencies.push(circDependency);
583
553
  updatedDependencyList = true;
584
554
  }
585
555
  }
586
556
  if (updatedDependencyList) {
587
- this._diagnosticVersion++;
557
+ this._writableData.diagnosticVersion++;
588
558
  }
589
559
  }
590
560
  setNoCircularDependencyConfirmed() {
591
- this._noCircularDependencyConfirmed = true;
561
+ this._writableData.noCircularDependencyConfirmed = true;
592
562
  }
593
563
  isNoCircularDependencyConfirmed() {
594
- return !this.isParseRequired() && this._noCircularDependencyConfirmed;
564
+ return !this.isParseRequired() && this._writableData.noCircularDependencyConfirmed;
595
565
  }
596
566
  setHitMaxImportDepth(maxImportDepth) {
597
- this._hitMaxImportDepth = maxImportDepth;
567
+ this._writableData.hitMaxImportDepth = maxImportDepth;
598
568
  }
599
569
  // Parse the file and update the state. Callers should wait for completion
600
570
  // (or at least cancel) prior to calling again. It returns true if a parse
@@ -618,8 +588,8 @@ class SourceFile {
618
588
  throw new Error("Can't get file content");
619
589
  }
620
590
  // Remember the length and hash for comparison purposes.
621
- this._lastFileContentLength = fileContents.length;
622
- this._lastFileContentHash = StringUtils.hashString(fileContents);
591
+ this._writableData.lastFileContentLength = fileContents.length;
592
+ this._writableData.lastFileContentHash = StringUtils.hashString(fileContents);
623
593
  });
624
594
  logState.add(`fs read ${timing_1.timingStats.readFileTime.totalTime - startTime}ms`);
625
595
  }
@@ -627,7 +597,7 @@ class SourceFile {
627
597
  diagSink.addError(`Source file could not be read`, (0, textRange_1.getEmptyRange)());
628
598
  fileContents = '';
629
599
  if (!this.fileSystem.existsSync(this._realFilePath)) {
630
- this._isFileDeleted = true;
600
+ this._writableData.isFileDeleted = true;
631
601
  }
632
602
  }
633
603
  }
@@ -635,27 +605,28 @@ class SourceFile {
635
605
  // Parse the token stream, building the abstract syntax tree.
636
606
  const parseResults = parseFile(configOptions, this._filePath, fileContents, this._ipythonMode, diagSink);
637
607
  (0, debug_1.assert)(parseResults !== undefined && parseResults.tokenizerOutput !== undefined);
638
- this._parseResults = parseResults;
639
- this._typeIgnoreLines = this._parseResults.tokenizerOutput.typeIgnoreLines;
640
- this._typeIgnoreAll = this._parseResults.tokenizerOutput.typeIgnoreAll;
641
- this._pyrightIgnoreLines = this._parseResults.tokenizerOutput.pyrightIgnoreLines;
608
+ this._writableData.parseResults = parseResults;
609
+ this._writableData.typeIgnoreLines = this._writableData.parseResults.tokenizerOutput.typeIgnoreLines;
610
+ this._writableData.typeIgnoreAll = this._writableData.parseResults.tokenizerOutput.typeIgnoreAll;
611
+ this._writableData.pyrightIgnoreLines =
612
+ this._writableData.parseResults.tokenizerOutput.pyrightIgnoreLines;
642
613
  // Resolve imports.
643
614
  const execEnvironment = configOptions.findExecEnvironment(this._filePath);
644
615
  timing_1.timingStats.resolveImportsTime.timeOperation(() => {
645
616
  const importResult = this._resolveImports(importResolver, parseResults.importedModules, execEnvironment);
646
- this._imports = importResult.imports;
647
- this._builtinsImport = importResult.builtinsImportResult;
648
- this._ipythonDisplayImport = importResult.ipythonDisplayImportResult;
649
- this._parseDiagnostics = diagSink.fetchAndClear();
617
+ this._writableData.imports = importResult.imports;
618
+ this._writableData.builtinsImport = importResult.builtinsImportResult;
619
+ this._writableData.ipythonDisplayImport = importResult.ipythonDisplayImportResult;
620
+ this._writableData.parseDiagnostics = diagSink.fetchAndClear();
650
621
  });
651
622
  // Is this file in a "strict" path?
652
623
  const useStrict = configOptions.strict.find((strictFileSpec) => strictFileSpec.regExp.test(this._realFilePath)) !==
653
624
  undefined;
654
625
  const commentDiags = [];
655
- this._diagnosticRuleSet = CommentUtils.getFileLevelDirectives(this._parseResults.tokenizerOutput.tokens, this._parseResults.tokenizerOutput.lines, configOptions.diagnosticRuleSet, useStrict, commentDiags);
656
- this._commentDiagnostics = [];
626
+ this._diagnosticRuleSet = CommentUtils.getFileLevelDirectives(this._writableData.parseResults.tokenizerOutput.tokens, this._writableData.parseResults.tokenizerOutput.lines, configOptions.diagnosticRuleSet, useStrict, commentDiags);
627
+ this._writableData.commentDiagnostics = [];
657
628
  commentDiags.forEach((commentDiag) => {
658
- this._commentDiagnostics.push(new diagnostic_1.Diagnostic(0 /* Error */, commentDiag.message, (0, positionUtils_1.convertTextRangeToRange)(commentDiag.range, this._parseResults.tokenizerOutput.lines)));
629
+ this._writableData.commentDiagnostics.push(new diagnostic_1.Diagnostic(0 /* Error */, commentDiag.message, (0, positionUtils_1.convertTextRangeToRange)(commentDiag.range, this._writableData.parseResults.tokenizerOutput.lines)));
659
630
  });
660
631
  }
661
632
  catch (e) {
@@ -664,7 +635,7 @@ class SourceFile {
664
635
  JSON.stringify(e);
665
636
  this._console.error(localize_1.Localizer.Diagnostic.internalParseError().format({ file: this.getFilePath(), message }));
666
637
  // Create dummy parse results.
667
- this._parseResults = {
638
+ this._writableData.parseResults = {
668
639
  text: '',
669
640
  parseTree: parseNodes_1.ModuleNode.create({ start: 0, length: 0 }),
670
641
  importedModules: [],
@@ -682,99 +653,61 @@ class SourceFile {
682
653
  containsWildcardImport: false,
683
654
  typingSymbolAliases: new Map(),
684
655
  };
685
- this._imports = undefined;
686
- this._builtinsImport = undefined;
687
- this._ipythonDisplayImport = undefined;
656
+ this._writableData.imports = undefined;
657
+ this._writableData.builtinsImport = undefined;
658
+ this._writableData.ipythonDisplayImport = undefined;
688
659
  const diagSink = new diagnosticSink_1.DiagnosticSink();
689
660
  diagSink.addError(localize_1.Localizer.Diagnostic.internalParseError().format({ file: this.getFilePath(), message }), (0, textRange_1.getEmptyRange)());
690
- this._parseDiagnostics = diagSink.fetchAndClear();
661
+ this._writableData.parseDiagnostics = diagSink.fetchAndClear();
691
662
  // Do not rethrow the exception, swallow it here. Callers are not
692
663
  // prepared to handle an exception.
693
664
  }
694
- this._analyzedFileContentsVersion = this._fileContentsVersion;
695
- this._indexingNeeded = true;
696
- this._isBindingNeeded = true;
697
- this._isCheckingNeeded = true;
698
- this._parseTreeNeedsCleaning = false;
699
- this._hitMaxImportDepth = undefined;
700
- this._diagnosticVersion++;
665
+ this._writableData.analyzedFileContentsVersion = this._writableData.fileContentsVersion;
666
+ this._writableData.indexingNeeded = true;
667
+ this._writableData.isBindingNeeded = true;
668
+ this._writableData.isCheckingNeeded = true;
669
+ this._writableData.parseTreeNeedsCleaning = false;
670
+ this._writableData.hitMaxImportDepth = undefined;
671
+ this._writableData.diagnosticVersion++;
701
672
  return true;
702
673
  });
703
674
  }
704
675
  index(options, token) {
705
676
  return this._logTracker.log(`indexing: ${this._getPathForLogging(this._filePath)}`, (ls) => {
706
677
  // If we have no completed analysis job, there's nothing to do.
707
- if (!this._parseResults || !this.isIndexingRequired()) {
678
+ if (!this._writableData.parseResults || !this.isIndexingRequired()) {
708
679
  ls.suppress();
709
680
  return undefined;
710
681
  }
711
- this._indexingNeeded = false;
712
- const symbols = documentSymbolProvider_1.DocumentSymbolProvider.indexSymbols(AnalyzerNodeInfo.getFileInfo(this._parseResults.parseTree), this._parseResults, options, token);
682
+ this._writableData.indexingNeeded = false;
683
+ const symbols = documentSymbolProvider_1.DocumentSymbolProvider.indexSymbols(AnalyzerNodeInfo.getFileInfo(this._writableData.parseResults.parseTree), this._writableData.parseResults, options, token);
713
684
  ls.add(`found ${symbols.length}`);
714
685
  const name = (0, pathUtils_1.stripFileExtension)((0, pathUtils_1.getFileName)(this._filePath));
715
686
  const privateOrProtected = SymbolNameUtils.isPrivateOrProtectedName(name);
716
687
  return { privateOrProtected, symbols };
717
688
  });
718
689
  }
719
- getDefinitionsForPosition(sourceMapper, position, filter, evaluator, token) {
720
- // If we have no completed analysis job, there's nothing to do.
721
- if (!this._parseResults) {
722
- return undefined;
723
- }
724
- return definitionProvider_1.DefinitionProvider.getDefinitionsForPosition(sourceMapper, this._parseResults, position, filter, evaluator, token);
725
- }
726
- getTypeDefinitionsForPosition(sourceMapper, position, evaluator, filePath, token) {
727
- // If we have no completed analysis job, there's nothing to do.
728
- if (!this._parseResults) {
729
- return undefined;
730
- }
731
- return definitionProvider_1.DefinitionProvider.getTypeDefinitionsForPosition(sourceMapper, this._parseResults, position, evaluator, filePath, token);
732
- }
733
- getDeclarationForPosition(sourceMapper, position, evaluator, reporter, useCase, token, implicitlyImportedBy) {
734
- // If we have no completed analysis job, there's nothing to do.
735
- if (!this._parseResults) {
736
- return undefined;
737
- }
738
- return referencesProvider_1.ReferencesProvider.getDeclarationForPosition(sourceMapper, this._parseResults, this._filePath, position, evaluator, reporter, useCase, token, implicitlyImportedBy);
739
- }
740
- addReferences(referencesResult, includeDeclaration, evaluator, token) {
741
- // If we have no completed analysis job, there's nothing to do.
742
- if (!this._parseResults) {
743
- return;
744
- }
745
- referencesProvider_1.ReferencesProvider.addReferences(this._parseResults, this._filePath, referencesResult, includeDeclaration, evaluator, token);
746
- }
747
690
  addHierarchicalSymbolsForDocument(symbolList, token) {
748
691
  // If we have no completed analysis job, there's nothing to do.
749
- if (!this._parseResults && !this._cachedIndexResults) {
692
+ if (!this._writableData.parseResults && !this._writableData.cachedIndexResults) {
750
693
  return;
751
694
  }
752
- documentSymbolProvider_1.DocumentSymbolProvider.addHierarchicalSymbolsForDocument(this._parseResults ? AnalyzerNodeInfo.getFileInfo(this._parseResults.parseTree) : undefined, this.getCachedIndexResults(), this._parseResults, symbolList, token);
695
+ documentSymbolProvider_1.DocumentSymbolProvider.addHierarchicalSymbolsForDocument(this._writableData.parseResults
696
+ ? AnalyzerNodeInfo.getFileInfo(this._writableData.parseResults.parseTree)
697
+ : undefined, this.getCachedIndexResults(), this._writableData.parseResults, symbolList, token);
753
698
  }
754
699
  getSymbolsForDocument(query, token) {
755
700
  // If we have no completed analysis job, there's nothing to do.
756
- if (!this._parseResults && !this._cachedIndexResults) {
701
+ if (!this._writableData.parseResults && !this._writableData.cachedIndexResults) {
757
702
  return [];
758
703
  }
759
- return documentSymbolProvider_1.DocumentSymbolProvider.getSymbolsForDocument(this._parseResults ? AnalyzerNodeInfo.getFileInfo(this._parseResults.parseTree) : undefined, this.getCachedIndexResults(), this._parseResults, this._filePath, query, token);
760
- }
761
- getDocumentHighlight(sourceMapper, position, evaluator, token) {
762
- // If this file hasn't been bound, no hover info is available.
763
- if (this._isBindingNeeded || !this._parseResults) {
764
- return undefined;
765
- }
766
- return documentHighlightProvider_1.DocumentHighlightProvider.getDocumentHighlight(this._parseResults, position, evaluator, token);
704
+ return documentSymbolProvider_1.DocumentSymbolProvider.getSymbolsForDocument(this._writableData.parseResults
705
+ ? AnalyzerNodeInfo.getFileInfo(this._writableData.parseResults.parseTree)
706
+ : undefined, this.getCachedIndexResults(), this._writableData.parseResults, this._filePath, query, token);
767
707
  }
768
- getSignatureHelpForPosition(position, sourceMapper, evaluator, format, token) {
708
+ getCompletionsForPosition(program, position, workspacePath, importLookup, options, nameMap, libraryMap, moduleSymbolsCallback, token) {
769
709
  // If we have no completed analysis job, there's nothing to do.
770
- if (!this._parseResults) {
771
- return undefined;
772
- }
773
- return signatureHelpProvider_1.SignatureHelpProvider.getSignatureHelpForPosition(this._parseResults, position, sourceMapper, evaluator, format, token);
774
- }
775
- getCompletionsForPosition(position, workspacePath, configOptions, importResolver, importLookup, evaluator, options, sourceMapper, nameMap, libraryMap, moduleSymbolsCallback, token) {
776
- // If we have no completed analysis job, there's nothing to do.
777
- if (!this._parseResults) {
710
+ if (!this._writableData.parseResults) {
778
711
  return undefined;
779
712
  }
780
713
  // This command should be called only for open files, in which
@@ -783,63 +716,51 @@ class SourceFile {
783
716
  if (fileContents === undefined) {
784
717
  return undefined;
785
718
  }
786
- const completionProvider = new completionProvider_1.CompletionProvider(workspacePath, this._parseResults, fileContents, importResolver, position, this._filePath, configOptions, importLookup, evaluator, options, sourceMapper, {
719
+ const completionProvider = new completionProvider_1.CompletionProvider(program, workspacePath, this._filePath, position, importLookup, options, {
787
720
  nameMap,
788
721
  libraryMap,
789
722
  getModuleSymbolsMap: moduleSymbolsCallback,
790
723
  }, token);
791
724
  return completionProvider.getCompletionsForPosition();
792
725
  }
793
- resolveCompletionItem(configOptions, importResolver, importLookup, evaluator, options, sourceMapper, nameMap, libraryMap, moduleSymbolsCallback, completionItem, token) {
726
+ resolveCompletionItem(program, importLookup, options, nameMap, libraryMap, moduleSymbolsCallback, completionItem, token) {
794
727
  const fileContents = this.getOpenFileContents();
795
- if (!this._parseResults || fileContents === undefined) {
728
+ if (!this._writableData.parseResults || fileContents === undefined) {
796
729
  return;
797
730
  }
798
731
  const completionData = (0, lspUtils_1.fromLSPAny)(completionItem.data);
799
- const completionProvider = new completionProvider_1.CompletionProvider(completionData.workspacePath, this._parseResults, fileContents, importResolver, completionData.position, this._filePath, configOptions, importLookup, evaluator, options, sourceMapper, {
732
+ const completionProvider = new completionProvider_1.CompletionProvider(program, completionData.workspacePath, this._filePath, completionData.position, importLookup, options, {
800
733
  nameMap,
801
734
  libraryMap,
802
735
  getModuleSymbolsMap: moduleSymbolsCallback,
803
736
  }, token);
804
737
  completionProvider.resolveCompletionItem(completionItem);
805
738
  }
806
- performQuickAction(command, args, token) {
807
- // If we have no completed analysis job, there's nothing to do.
808
- if (!this._parseResults) {
809
- return undefined;
810
- }
811
- // This command should be called only for open files, in which
812
- // case we should have the file contents already loaded.
813
- if (this.getClientVersion() === undefined) {
814
- return undefined;
815
- }
816
- return (0, quickActions_1.performQuickAction)(command, args, this._parseResults, token);
817
- }
818
739
  bind(configOptions, importLookup, builtinsScope, futureImports) {
819
740
  (0, debug_1.assert)(!this.isParseRequired(), 'Bind called before parsing');
820
741
  (0, debug_1.assert)(this.isBindingRequired(), 'Bind called unnecessarily');
821
- (0, debug_1.assert)(!this._isBindingInProgress, 'Bind called while binding in progress');
822
- (0, debug_1.assert)(this._parseResults !== undefined, 'Parse results not available');
742
+ (0, debug_1.assert)(!this._writableData.isBindingInProgress, 'Bind called while binding in progress');
743
+ (0, debug_1.assert)(this._writableData.parseResults !== undefined, 'Parse results not available');
823
744
  return this._logTracker.log(`binding: ${this._getPathForLogging(this._filePath)}`, () => {
824
745
  try {
825
746
  // Perform name binding.
826
747
  timing_1.timingStats.bindTime.timeOperation(() => {
827
748
  this._cleanParseTreeIfRequired();
828
- const fileInfo = this._buildFileInfo(configOptions, this._parseResults.text, importLookup, builtinsScope, futureImports);
829
- AnalyzerNodeInfo.setFileInfo(this._parseResults.parseTree, fileInfo);
749
+ const fileInfo = this._buildFileInfo(configOptions, this._writableData.parseResults.text, importLookup, builtinsScope, futureImports);
750
+ AnalyzerNodeInfo.setFileInfo(this._writableData.parseResults.parseTree, fileInfo);
830
751
  const binder = new binder_1.Binder(fileInfo, configOptions.indexGenerationMode);
831
- this._isBindingInProgress = true;
832
- binder.bindModule(this._parseResults.parseTree);
752
+ this._writableData.isBindingInProgress = true;
753
+ binder.bindModule(this._writableData.parseResults.parseTree);
833
754
  // If we're in "test mode" (used for unit testing), run an additional
834
755
  // "test walker" over the parse tree to validate its internal consistency.
835
756
  if (configOptions.internalTestMode) {
836
757
  const testWalker = new testWalker_1.TestWalker();
837
- testWalker.walk(this._parseResults.parseTree);
758
+ testWalker.walk(this._writableData.parseResults.parseTree);
838
759
  }
839
- this._bindDiagnostics = fileInfo.diagnosticSink.fetchAndClear();
840
- const moduleScope = AnalyzerNodeInfo.getScope(this._parseResults.parseTree);
760
+ this._writableData.bindDiagnostics = fileInfo.diagnosticSink.fetchAndClear();
761
+ const moduleScope = AnalyzerNodeInfo.getScope(this._writableData.parseResults.parseTree);
841
762
  (0, debug_1.assert)(moduleScope !== undefined, 'Module scope not returned by binder');
842
- this._moduleSymbolTable = moduleScope.symbolTable;
763
+ this._writableData.moduleSymbolTable = moduleScope.symbolTable;
843
764
  });
844
765
  }
845
766
  catch (e) {
@@ -849,36 +770,36 @@ class SourceFile {
849
770
  this._console.error(localize_1.Localizer.Diagnostic.internalBindError().format({ file: this.getFilePath(), message }));
850
771
  const diagSink = new diagnosticSink_1.DiagnosticSink();
851
772
  diagSink.addError(localize_1.Localizer.Diagnostic.internalBindError().format({ file: this.getFilePath(), message }), (0, textRange_1.getEmptyRange)());
852
- this._bindDiagnostics = diagSink.fetchAndClear();
773
+ this._writableData.bindDiagnostics = diagSink.fetchAndClear();
853
774
  // Do not rethrow the exception, swallow it here. Callers are not
854
775
  // prepared to handle an exception.
855
776
  }
856
777
  finally {
857
- this._isBindingInProgress = false;
778
+ this._writableData.isBindingInProgress = false;
858
779
  }
859
780
  // Prepare for the next stage of the analysis.
860
- this._diagnosticVersion++;
861
- this._isCheckingNeeded = true;
862
- this._indexingNeeded = true;
863
- this._isBindingNeeded = false;
781
+ this._writableData.diagnosticVersion++;
782
+ this._writableData.isCheckingNeeded = true;
783
+ this._writableData.indexingNeeded = true;
784
+ this._writableData.isBindingNeeded = false;
864
785
  });
865
786
  }
866
787
  check(importResolver, evaluator, sourceMapper, dependentFiles) {
867
788
  (0, debug_1.assert)(!this.isParseRequired(), 'Check called before parsing');
868
789
  (0, debug_1.assert)(!this.isBindingRequired(), 'Check called before binding');
869
- (0, debug_1.assert)(!this._isBindingInProgress, 'Check called while binding in progress');
790
+ (0, debug_1.assert)(!this._writableData.isBindingInProgress, 'Check called while binding in progress');
870
791
  (0, debug_1.assert)(this.isCheckingRequired(), 'Check called unnecessarily');
871
- (0, debug_1.assert)(this._parseResults !== undefined, 'Parse results not available');
792
+ (0, debug_1.assert)(this._writableData.parseResults !== undefined, 'Parse results not available');
872
793
  return this._logTracker.log(`checking: ${this._getPathForLogging(this._filePath)}`, () => {
873
794
  try {
874
795
  timing_1.timingStats.typeCheckerTime.timeOperation(() => {
875
796
  const checkDuration = new timing_1.Duration();
876
- const checker = new checker_1.Checker(importResolver, evaluator, this._parseResults, sourceMapper, dependentFiles);
797
+ const checker = new checker_1.Checker(importResolver, evaluator, this._writableData.parseResults, sourceMapper, dependentFiles);
877
798
  checker.check();
878
- this._isCheckingNeeded = false;
879
- const fileInfo = AnalyzerNodeInfo.getFileInfo(this._parseResults.parseTree);
880
- this._checkerDiagnostics = fileInfo.diagnosticSink.fetchAndClear();
881
- this._checkTime = checkDuration.getDurationInMilliseconds();
799
+ this._writableData.isCheckingNeeded = false;
800
+ const fileInfo = AnalyzerNodeInfo.getFileInfo(this._writableData.parseResults.parseTree);
801
+ this._writableData.checkerDiagnostics = fileInfo.diagnosticSink.fetchAndClear();
802
+ this._writableData.checkTime = checkDuration.getDurationInMilliseconds();
882
803
  });
883
804
  }
884
805
  catch (e) {
@@ -890,9 +811,9 @@ class SourceFile {
890
811
  this._console.error(localize_1.Localizer.Diagnostic.internalTypeCheckingError().format({ file: this.getFilePath(), message }));
891
812
  const diagSink = new diagnosticSink_1.DiagnosticSink();
892
813
  diagSink.addError(localize_1.Localizer.Diagnostic.internalTypeCheckingError().format({ file: this.getFilePath(), message }), (0, textRange_1.getEmptyRange)());
893
- this._checkerDiagnostics = diagSink.fetchAndClear();
814
+ this._writableData.checkerDiagnostics = diagSink.fetchAndClear();
894
815
  // Mark the file as complete so we don't get into an infinite loop.
895
- this._isCheckingNeeded = false;
816
+ this._writableData.isCheckingNeeded = false;
896
817
  }
897
818
  throw e;
898
819
  }
@@ -900,17 +821,76 @@ class SourceFile {
900
821
  // Clear any circular dependencies associated with this file.
901
822
  // These will be detected by the program module and associated
902
823
  // with the source file right before it is finalized.
903
- this._circularDependencies = [];
904
- this._diagnosticVersion++;
824
+ this._writableData.circularDependencies = [];
825
+ this._writableData.diagnosticVersion++;
905
826
  }
906
827
  });
907
828
  }
908
829
  test_enableIPythonMode(enable) {
909
830
  this._ipythonMode = enable ? IPythonMode.CellDocs : IPythonMode.None;
910
831
  }
832
+ _cachePreEditState() {
833
+ // If there's no document yet, this change doesn't count as a write yet.
834
+ if (this._writableData.clientDocumentContents !== undefined) {
835
+ // If this is our first write, then make a copy of the writable data.
836
+ if (this._isEditMode && !this._preEditData) {
837
+ // Copy over the writable data.
838
+ this._preEditData = this._writableData;
839
+ // Recreate all the writable data from scratch.
840
+ this._writableData = new WriteableData();
841
+ }
842
+ }
843
+ }
844
+ // Get all task list diagnostics for the current file and add them
845
+ // to the specified diagnostic list
846
+ _addTaskListDiagnostics(taskListTokens, diagList) {
847
+ var _a, _b;
848
+ // input validation
849
+ if (!taskListTokens || taskListTokens.length === 0 || !diagList) {
850
+ return;
851
+ }
852
+ // if we have no tokens, we're done
853
+ if (!((_b = (_a = this._writableData.parseResults) === null || _a === void 0 ? void 0 : _a.tokenizerOutput) === null || _b === void 0 ? void 0 : _b.tokens)) {
854
+ return;
855
+ }
856
+ const tokenizerOutput = this._writableData.parseResults.tokenizerOutput;
857
+ for (let i = 0; i < tokenizerOutput.tokens.count; i++) {
858
+ const token = tokenizerOutput.tokens.getItemAt(i);
859
+ // if there are no comments, skip this token
860
+ if (!token.comments || token.comments.length === 0) {
861
+ continue;
862
+ }
863
+ for (const comment of token.comments) {
864
+ for (const token of taskListTokens) {
865
+ // Check if the comment matches the task list token.
866
+ // The comment must start with zero or more whitespace characters,
867
+ // followed by the taskListToken (case insensitive),
868
+ // followed by (0+ whitespace + EOL) OR (1+ NON-alphanumeric characters)
869
+ const regexStr = '^[\\s]*' + token.text + '([\\s]*$|[\\W]+)';
870
+ const regex = RegExp(regexStr, 'i'); // case insensitive
871
+ // if the comment doesn't match, skip it
872
+ if (!regex.test(comment.value)) {
873
+ continue;
874
+ }
875
+ // Calculate the range for the diagnostic
876
+ // This allows navigation to the comment via double clicking the item in the task list pane
877
+ let rangeStart = comment.start;
878
+ // The comment technically starts right after the comment identifier (#), but we want the caret right
879
+ // before the task list token (since there might be whitespace before it)
880
+ const indexOfToken = comment.value.toLowerCase().indexOf(token.text.toLowerCase());
881
+ rangeStart += indexOfToken;
882
+ const rangeEnd = textRange_1.TextRange.getEnd(comment);
883
+ const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, tokenizerOutput.lines);
884
+ // Add the diagnostic to the list to send to VS,
885
+ // and trim whitespace from the comment so it's easier to read in the task list
886
+ diagList.push(new diagnostic_1.Diagnostic(6 /* TaskItem */, comment.value.trim(), range, token.priority));
887
+ }
888
+ }
889
+ }
890
+ }
911
891
  _buildFileInfo(configOptions, fileContents, importLookup, builtinsScope, futureImports) {
912
- (0, debug_1.assert)(this._parseResults !== undefined, 'Parse results not available');
913
- const analysisDiagnostics = new diagnosticSink_1.TextRangeDiagnosticSink(this._parseResults.tokenizerOutput.lines);
892
+ (0, debug_1.assert)(this._writableData.parseResults !== undefined, 'Parse results not available');
893
+ const analysisDiagnostics = new diagnosticSink_1.TextRangeDiagnosticSink(this._writableData.parseResults.tokenizerOutput.lines);
914
894
  const fileInfo = {
915
895
  importLookup,
916
896
  futureImports,
@@ -919,8 +899,8 @@ class SourceFile {
919
899
  executionEnvironment: configOptions.findExecEnvironment(this._filePath),
920
900
  diagnosticRuleSet: this._diagnosticRuleSet,
921
901
  fileContents,
922
- lines: this._parseResults.tokenizerOutput.lines,
923
- typingSymbolAliases: this._parseResults.typingSymbolAliases,
902
+ lines: this._writableData.parseResults.tokenizerOutput.lines,
903
+ typingSymbolAliases: this._writableData.parseResults.typingSymbolAliases,
924
904
  definedConstants: configOptions.defineConstant,
925
905
  filePath: this._filePath,
926
906
  moduleName: this._moduleName,
@@ -935,11 +915,11 @@ class SourceFile {
935
915
  return fileInfo;
936
916
  }
937
917
  _cleanParseTreeIfRequired() {
938
- if (this._parseResults) {
939
- if (this._parseTreeNeedsCleaning) {
940
- const cleanerWalker = new parseTreeCleaner_1.ParseTreeCleanerWalker(this._parseResults.parseTree);
918
+ if (this._writableData.parseResults) {
919
+ if (this._writableData.parseTreeNeedsCleaning) {
920
+ const cleanerWalker = new parseTreeCleaner_1.ParseTreeCleanerWalker(this._writableData.parseResults.parseTree);
941
921
  cleanerWalker.clean();
942
- this._parseTreeNeedsCleaning = false;
922
+ this._writableData.parseTreeNeedsCleaning = false;
943
923
  }
944
924
  }
945
925
  }