@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.
- package/dist/analyzer/analyzerFileInfo.d.ts +4 -1
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +7 -4
- package/dist/analyzer/backgroundAnalysisProgram.js +22 -7
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +12 -7
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +1 -0
- package/dist/analyzer/checker.js +58 -7
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constructors.d.ts +6 -0
- package/dist/analyzer/constructors.js +456 -0
- package/dist/analyzer/constructors.js.map +1 -0
- package/dist/analyzer/dataClasses.js +89 -2
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declarationUtils.d.ts +6 -1
- package/dist/analyzer/declarationUtils.js +10 -8
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/enums.js +54 -8
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +15 -15
- package/dist/analyzer/importResolver.js +477 -477
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.d.ts +2 -2
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.d.ts +1 -1
- package/dist/analyzer/namedTuples.js +30 -42
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.d.ts +16 -0
- package/dist/analyzer/operations.js +749 -0
- package/dist/analyzer/operations.js.map +1 -0
- package/dist/analyzer/packageTypeReport.d.ts +2 -1
- package/dist/analyzer/packageTypeReport.js +2 -1
- package/dist/analyzer/packageTypeReport.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.d.ts +1 -1
- package/dist/analyzer/packageTypeVerifier.js +27 -13
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +4 -2
- package/dist/analyzer/parseTreeUtils.js +32 -1
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +16 -0
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +29 -53
- package/dist/analyzer/program.js +1050 -1649
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/protocols.js +1 -1
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/service.d.ts +14 -35
- package/dist/analyzer/service.js +92 -121
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +14 -49
- package/dist/analyzer/sourceFile.js +271 -291
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.d.ts +2 -2
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +417 -1570
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +44 -9
- package/dist/analyzer/typeEvaluatorTypes.js +33 -1
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +5 -9
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +3 -0
- package/dist/analyzer/typeUtils.js +66 -9
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeVarContext.d.ts +5 -5
- package/dist/analyzer/typeVarContext.js +7 -0
- package/dist/analyzer/typeVarContext.js.map +1 -1
- package/dist/analyzer/typedDicts.js +2 -2
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +4 -2
- package/dist/analyzer/types.js +7 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +10 -11
- package/dist/backgroundAnalysisBase.js +87 -87
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +8 -8
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/commands/quickActionCommand.js +4 -1
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/common/cancellationUtils.d.ts +1 -1
- package/dist/common/cancellationUtils.js +9 -9
- package/dist/common/cancellationUtils.js.map +1 -1
- package/dist/common/commandLineOptions.d.ts +1 -2
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/configOptions.d.ts +2 -2
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/console.d.ts +5 -9
- package/dist/common/console.js +46 -33
- package/dist/common/console.js.map +1 -1
- package/dist/common/deferred.js +10 -10
- package/dist/common/deferred.js.map +1 -1
- package/dist/common/extensibility.d.ts +27 -5
- package/dist/common/extensibility.js +1 -1
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileBasedCancellationUtils.js +5 -5
- package/dist/common/fileBasedCancellationUtils.js.map +1 -1
- package/dist/common/fileSystem.d.ts +12 -10
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/fullAccessHost.d.ts +3 -3
- package/dist/common/fullAccessHost.js +6 -6
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/pathUtils.d.ts +13 -13
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/realFileSystem.js +12 -7
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/uriParser.d.ts +2 -2
- package/dist/common/uriParser.js +3 -3
- package/dist/common/uriParser.js.map +1 -1
- package/dist/common/workspaceEditUtils.d.ts +5 -5
- package/dist/common/workspaceEditUtils.js +7 -4
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +32 -31
- package/dist/languageServerBase.js +278 -345
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +0 -1
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.d.ts +16 -12
- package/dist/languageService/callHierarchyProvider.js +125 -41
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +10 -13
- package/dist/languageService/completionProvider.js +21 -10
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/definitionProvider.d.ts +23 -9
- package/dist/languageService/definitionProvider.js +116 -91
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentHighlightProvider.d.ts +8 -3
- package/dist/languageService/documentHighlightProvider.js +17 -6
- package/dist/languageService/documentHighlightProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.d.ts +6 -7
- package/dist/languageService/documentSymbolCollector.js +21 -11
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.js +5 -3
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +4 -3
- package/dist/languageService/hoverProvider.js +30 -36
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/navigationUtils.d.ts +6 -0
- package/dist/languageService/navigationUtils.js +28 -0
- package/dist/languageService/navigationUtils.js.map +1 -0
- package/dist/languageService/quickActions.d.ts +2 -2
- package/dist/languageService/quickActions.js +12 -1
- package/dist/languageService/quickActions.js.map +1 -1
- package/dist/languageService/referencesProvider.d.ts +13 -12
- package/dist/languageService/referencesProvider.js +102 -16
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.d.ts +17 -0
- package/dist/languageService/renameProvider.js +143 -0
- package/dist/languageService/renameProvider.js.map +1 -0
- package/dist/languageService/signatureHelpProvider.d.ts +19 -23
- package/dist/languageService/signatureHelpProvider.js +111 -18
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +17 -14
- package/dist/localization/localize.js +4 -6
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +5 -6
- package/dist/parser/characterStream.d.ts +3 -3
- package/dist/parser/characterStream.js +12 -12
- package/dist/parser/characterStream.js.map +1 -1
- package/dist/parser/parser.d.ts +1 -1
- package/dist/parser/parser.js.map +1 -1
- package/dist/pyright.js +57 -54
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.d.ts +1 -1
- package/dist/pyrightFileSystem.js +21 -21
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.d.ts +6 -6
- package/dist/readonlyAugmentedFileSystem.js +28 -28
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +6 -6
- package/dist/server.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +1 -1
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +1 -1
- package/dist/tests/documentSymbolCollector.test.js +3 -3
- package/dist/tests/documentSymbolCollector.test.js.map +1 -1
- package/dist/tests/fourslash/fourslash.d.ts +4 -4
- package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.js +1 -1
- package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.d.ts +3 -3
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +11 -11
- package/dist/tests/harness/fourslash/testState.js +123 -113
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.d.ts +8 -8
- package/dist/tests/harness/vfs/filesystem.js +68 -68
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +34 -0
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/signatureHelp.test.js +5 -1
- package/dist/tests/signatureHelp.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +2 -2
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/testStateUtils.d.ts +2 -2
- package/dist/tests/testStateUtils.js +39 -9
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +8 -0
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +13 -1
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +2 -2
- package/dist/tests/typeEvaluator4.test.js +9 -1
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +4 -0
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/workspaceEditUtils.test.js +84 -0
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/package.json +4 -4
- package/dist/languageService/indentationUtils.d.ts +0 -16
- package/dist/languageService/indentationUtils.js +0 -727
- package/dist/languageService/indentationUtils.js.map +0 -1
- package/dist/languageService/insertionPointUtils.d.ts +0 -9
- package/dist/languageService/insertionPointUtils.js +0 -132
- package/dist/languageService/insertionPointUtils.js.map +0 -1
- package/dist/languageService/renameModuleProvider.d.ts +0 -65
- package/dist/languageService/renameModuleProvider.js +0 -939
- package/dist/languageService/renameModuleProvider.js.map +0 -1
- package/dist/tests/indentationUtils.ptvs.test.d.ts +0 -1
- package/dist/tests/indentationUtils.ptvs.test.js +0 -324
- package/dist/tests/indentationUtils.ptvs.test.js.map +0 -1
- package/dist/tests/indentationUtils.reindent.test.d.ts +0 -1
- package/dist/tests/indentationUtils.reindent.test.js +0 -372
- package/dist/tests/indentationUtils.reindent.test.js.map +0 -1
- package/dist/tests/indentationUtils.test.d.ts +0 -1
- package/dist/tests/indentationUtils.test.js +0 -502
- package/dist/tests/indentationUtils.test.js.map +0 -1
- package/dist/tests/insertionPointUtils.test.d.ts +0 -1
- package/dist/tests/insertionPointUtils.test.js +0 -154
- package/dist/tests/insertionPointUtils.test.js.map +0 -1
- package/dist/tests/moveSymbol.importAdder.test.d.ts +0 -1
- package/dist/tests/moveSymbol.importAdder.test.js +0 -298
- package/dist/tests/moveSymbol.importAdder.test.js.map +0 -1
- package/dist/tests/moveSymbol.insertion.test.d.ts +0 -1
- package/dist/tests/moveSymbol.insertion.test.js +0 -537
- package/dist/tests/moveSymbol.insertion.test.js.map +0 -1
- package/dist/tests/moveSymbol.misc.test.d.ts +0 -1
- package/dist/tests/moveSymbol.misc.test.js +0 -169
- package/dist/tests/moveSymbol.misc.test.js.map +0 -1
- package/dist/tests/moveSymbol.updateReference.test.d.ts +0 -1
- package/dist/tests/moveSymbol.updateReference.test.js +0 -1057
- package/dist/tests/moveSymbol.updateReference.test.js.map +0 -1
- package/dist/tests/renameModule.folder.test.d.ts +0 -1
- package/dist/tests/renameModule.folder.test.js +0 -229
- package/dist/tests/renameModule.folder.test.js.map +0 -1
- package/dist/tests/renameModule.fromImports.test.d.ts +0 -1
- package/dist/tests/renameModule.fromImports.test.js +0 -790
- package/dist/tests/renameModule.fromImports.test.js.map +0 -1
- package/dist/tests/renameModule.imports.test.d.ts +0 -1
- package/dist/tests/renameModule.imports.test.js +0 -380
- package/dist/tests/renameModule.imports.test.js.map +0 -1
- package/dist/tests/renameModule.misc.test.d.ts +0 -1
- package/dist/tests/renameModule.misc.test.js +0 -615
- package/dist/tests/renameModule.misc.test.js.map +0 -1
- package/dist/tests/renameModule.relativePath.test.d.ts +0 -1
- package/dist/tests/renameModule.relativePath.test.js +0 -231
- package/dist/tests/renameModule.relativePath.test.js.map +0 -1
- package/dist/tests/renameModuleTestUtils.d.ts +0 -4
- package/dist/tests/renameModuleTestUtils.js +0 -76
- 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
|
82
|
-
constructor(
|
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.
|
79
|
+
this.diagnosticVersion = 0;
|
88
80
|
// Generation count of the file contents. When the contents
|
89
81
|
// change, this is incremented.
|
90
|
-
this.
|
82
|
+
this.fileContentsVersion = 0;
|
91
83
|
// Length and hash of the file the last time it was read from disk.
|
92
|
-
this.
|
93
|
-
this.
|
84
|
+
this.lastFileContentLength = undefined;
|
85
|
+
this.lastFileContentHash = undefined;
|
94
86
|
// Version of file contents that have been analyzed.
|
95
|
-
this.
|
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.
|
90
|
+
this.parseTreeNeedsCleaning = false;
|
99
91
|
// Reentrancy check for binding.
|
100
|
-
this.
|
92
|
+
this.isBindingInProgress = false;
|
101
93
|
// Diagnostics generated during different phases of analysis.
|
102
|
-
this.
|
103
|
-
this.
|
104
|
-
this.
|
105
|
-
this.
|
106
|
-
this.
|
107
|
-
this.
|
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.
|
114
|
-
this.
|
101
|
+
this.circularDependencies = [];
|
102
|
+
this.noCircularDependencyConfirmed = false;
|
115
103
|
// Do we need to perform a binding step?
|
116
|
-
this.
|
104
|
+
this.isBindingNeeded = true;
|
117
105
|
// Do we have valid diagnostic results from a checking pass?
|
118
|
-
this.
|
106
|
+
this.isCheckingNeeded = true;
|
119
107
|
// Do we need to perform an indexing step?
|
120
|
-
this.
|
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.
|
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.
|
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.
|
194
|
-
...this.
|
195
|
-
...this.
|
196
|
-
...this.
|
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.
|
200
|
-
const pyrightIgnoreLinesClone = new Map(this.
|
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.
|
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.
|
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.
|
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.
|
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.
|
273
|
-
const rangeStart = this.
|
274
|
-
const rangeEnd = rangeStart + this.
|
275
|
-
const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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' &&
|
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.
|
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.
|
331
|
-
diagList.push(new diagnostic_1.Diagnostic(0 /* Error */, localize_1.Localizer.Diagnostic.importDepthExceeded().format({ depth: this.
|
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.
|
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.
|
364
|
+
return this._writableData.imports || [];
|
409
365
|
}
|
410
366
|
getBuiltinsImport() {
|
411
|
-
return this.
|
367
|
+
return this._writableData.builtinsImport;
|
412
368
|
}
|
413
369
|
getIPythonDisplayImport() {
|
414
|
-
return this.
|
370
|
+
return this._writableData.ipythonDisplayImport;
|
415
371
|
}
|
416
372
|
getModuleSymbolTable() {
|
417
|
-
return this.
|
373
|
+
return this._writableData.moduleSymbolTable;
|
418
374
|
}
|
419
375
|
getCheckTime() {
|
420
|
-
return this.
|
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.
|
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.
|
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.
|
410
|
+
if (fileContents.length !== this._writableData.lastFileContentLength) {
|
441
411
|
return true;
|
442
412
|
}
|
443
|
-
if (StringUtils.hashString(fileContents) !== this.
|
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.
|
457
|
-
this.
|
458
|
-
this.
|
426
|
+
this._writableData.parseResults = undefined;
|
427
|
+
this._writableData.moduleSymbolTable = undefined;
|
428
|
+
this._writableData.isBindingNeeded = true;
|
459
429
|
}
|
460
430
|
markDirty(indexingNeeded = true) {
|
461
|
-
this.
|
462
|
-
this.
|
463
|
-
this.
|
464
|
-
this.
|
465
|
-
this.
|
466
|
-
this.
|
467
|
-
this.
|
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.
|
474
|
-
this.
|
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.
|
478
|
-
if (this.
|
479
|
-
AnalyzerNodeInfo.getDunderAllInfo(this.
|
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.
|
485
|
-
this.
|
486
|
-
this.
|
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
|
-
|
492
|
-
return (_a = this._clientDocument) === null || _a === void 0 ? void 0 : _a.version;
|
461
|
+
return this._writableData.clientDocumentVersion;
|
493
462
|
}
|
494
463
|
getOpenFileContents() {
|
495
|
-
|
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.
|
491
|
+
this._writableData.clientDocumentVersion = undefined;
|
492
|
+
this._writableData.clientDocumentContents = undefined;
|
522
493
|
}
|
523
494
|
else {
|
524
|
-
|
525
|
-
|
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 (
|
499
|
+
if (contents.length !== this._writableData.lastFileContentLength ||
|
500
|
+
contentsHash !== this._writableData.lastFileContentHash) {
|
532
501
|
this.markDirty();
|
533
502
|
}
|
534
|
-
this.
|
535
|
-
this.
|
536
|
-
this.
|
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.
|
512
|
+
return this._writableData.isFileDeleted;
|
544
513
|
}
|
545
514
|
isParseRequired() {
|
546
|
-
return !this.
|
515
|
+
return (!this._writableData.parseResults ||
|
516
|
+
this._writableData.analyzedFileContentsVersion !== this._writableData.fileContentsVersion);
|
547
517
|
}
|
548
518
|
isBindingRequired() {
|
549
|
-
if (this.
|
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.
|
525
|
+
return this._writableData.isBindingNeeded;
|
556
526
|
}
|
557
527
|
isIndexingRequired() {
|
558
|
-
return this.
|
528
|
+
return this._writableData.indexingNeeded;
|
559
529
|
}
|
560
530
|
isCheckingRequired() {
|
561
|
-
return this.
|
531
|
+
return this._writableData.isCheckingNeeded;
|
562
532
|
}
|
563
533
|
getParseResults() {
|
564
534
|
if (!this.isParseRequired()) {
|
565
|
-
return this.
|
535
|
+
return this._writableData.parseResults;
|
566
536
|
}
|
567
537
|
return undefined;
|
568
538
|
}
|
569
539
|
getCachedIndexResults() {
|
570
|
-
return this.
|
540
|
+
return this._writableData.cachedIndexResults;
|
571
541
|
}
|
572
542
|
cacheIndexResults(indexResults) {
|
573
|
-
this.
|
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.
|
581
|
-
if (!this.
|
582
|
-
this.
|
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.
|
557
|
+
this._writableData.diagnosticVersion++;
|
588
558
|
}
|
589
559
|
}
|
590
560
|
setNoCircularDependencyConfirmed() {
|
591
|
-
this.
|
561
|
+
this._writableData.noCircularDependencyConfirmed = true;
|
592
562
|
}
|
593
563
|
isNoCircularDependencyConfirmed() {
|
594
|
-
return !this.isParseRequired() && this.
|
564
|
+
return !this.isParseRequired() && this._writableData.noCircularDependencyConfirmed;
|
595
565
|
}
|
596
566
|
setHitMaxImportDepth(maxImportDepth) {
|
597
|
-
this.
|
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.
|
622
|
-
this.
|
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.
|
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.
|
639
|
-
this.
|
640
|
-
this.
|
641
|
-
this.
|
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.
|
647
|
-
this.
|
648
|
-
this.
|
649
|
-
this.
|
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.
|
656
|
-
this.
|
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.
|
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.
|
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.
|
686
|
-
this.
|
687
|
-
this.
|
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.
|
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.
|
695
|
-
this.
|
696
|
-
this.
|
697
|
-
this.
|
698
|
-
this.
|
699
|
-
this.
|
700
|
-
this.
|
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.
|
678
|
+
if (!this._writableData.parseResults || !this.isIndexingRequired()) {
|
708
679
|
ls.suppress();
|
709
680
|
return undefined;
|
710
681
|
}
|
711
|
-
this.
|
712
|
-
const symbols = documentSymbolProvider_1.DocumentSymbolProvider.indexSymbols(AnalyzerNodeInfo.getFileInfo(this.
|
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.
|
692
|
+
if (!this._writableData.parseResults && !this._writableData.cachedIndexResults) {
|
750
693
|
return;
|
751
694
|
}
|
752
|
-
documentSymbolProvider_1.DocumentSymbolProvider.addHierarchicalSymbolsForDocument(this.
|
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.
|
701
|
+
if (!this._writableData.parseResults && !this._writableData.cachedIndexResults) {
|
757
702
|
return [];
|
758
703
|
}
|
759
|
-
return documentSymbolProvider_1.DocumentSymbolProvider.getSymbolsForDocument(this.
|
760
|
-
|
761
|
-
|
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
|
-
|
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.
|
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(
|
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(
|
726
|
+
resolveCompletionItem(program, importLookup, options, nameMap, libraryMap, moduleSymbolsCallback, completionItem, token) {
|
794
727
|
const fileContents = this.getOpenFileContents();
|
795
|
-
if (!this.
|
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.
|
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.
|
822
|
-
(0, debug_1.assert)(this.
|
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.
|
829
|
-
AnalyzerNodeInfo.setFileInfo(this.
|
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.
|
832
|
-
binder.bindModule(this.
|
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.
|
758
|
+
testWalker.walk(this._writableData.parseResults.parseTree);
|
838
759
|
}
|
839
|
-
this.
|
840
|
-
const moduleScope = AnalyzerNodeInfo.getScope(this.
|
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.
|
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.
|
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.
|
778
|
+
this._writableData.isBindingInProgress = false;
|
858
779
|
}
|
859
780
|
// Prepare for the next stage of the analysis.
|
860
|
-
this.
|
861
|
-
this.
|
862
|
-
this.
|
863
|
-
this.
|
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.
|
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.
|
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.
|
797
|
+
const checker = new checker_1.Checker(importResolver, evaluator, this._writableData.parseResults, sourceMapper, dependentFiles);
|
877
798
|
checker.check();
|
878
|
-
this.
|
879
|
-
const fileInfo = AnalyzerNodeInfo.getFileInfo(this.
|
880
|
-
this.
|
881
|
-
this.
|
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.
|
814
|
+
this._writableData.checkerDiagnostics = diagSink.fetchAndClear();
|
894
815
|
// Mark the file as complete so we don't get into an infinite loop.
|
895
|
-
this.
|
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.
|
904
|
-
this.
|
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.
|
913
|
-
const analysisDiagnostics = new diagnosticSink_1.TextRangeDiagnosticSink(this.
|
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.
|
923
|
-
typingSymbolAliases: this.
|
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.
|
939
|
-
if (this.
|
940
|
-
const cleanerWalker = new parseTreeCleaner_1.ParseTreeCleanerWalker(this.
|
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.
|
922
|
+
this._writableData.parseTreeNeedsCleaning = false;
|
943
923
|
}
|
944
924
|
}
|
945
925
|
}
|