@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
@@ -37,7 +37,6 @@ const vscode_languageserver_1 = require("vscode-languageserver");
|
|
37
37
|
const parseTreeUtils_1 = require("../../../analyzer/parseTreeUtils");
|
38
38
|
const service_1 = require("../../../analyzer/service");
|
39
39
|
const commandResult_1 = require("../../../commands/commandResult");
|
40
|
-
const collectionUtils_1 = require("../../../common/collectionUtils");
|
41
40
|
const configOptions_1 = require("../../../common/configOptions");
|
42
41
|
const console_1 = require("../../../common/console");
|
43
42
|
const core_1 = require("../../../common/core");
|
@@ -45,8 +44,13 @@ const debug = __importStar(require("../../../common/debug"));
|
|
45
44
|
const pathUtils_1 = require("../../../common/pathUtils");
|
46
45
|
const positionUtils_1 = require("../../../common/positionUtils");
|
47
46
|
const textRange_1 = require("../../../common/textRange");
|
47
|
+
const callHierarchyProvider_1 = require("../../../languageService/callHierarchyProvider");
|
48
48
|
const definitionProvider_1 = require("../../../languageService/definitionProvider");
|
49
|
+
const documentHighlightProvider_1 = require("../../../languageService/documentHighlightProvider");
|
49
50
|
const hoverProvider_1 = require("../../../languageService/hoverProvider");
|
51
|
+
const navigationUtils_1 = require("../../../languageService/navigationUtils");
|
52
|
+
const referencesProvider_1 = require("../../../languageService/referencesProvider");
|
53
|
+
const signatureHelpProvider_1 = require("../../../languageService/signatureHelpProvider");
|
50
54
|
const tokenizer_1 = require("../../../parser/tokenizer");
|
51
55
|
const pyrightFileSystem_1 = require("../../../pyrightFileSystem");
|
52
56
|
const workspaceFactory_1 = require("../../../workspaceFactory");
|
@@ -60,6 +64,8 @@ const fourSlashTypes_1 = require("./fourSlashTypes");
|
|
60
64
|
const testLanguageService_1 = require("./testLanguageService");
|
61
65
|
const testStateUtils_1 = require("./testStateUtils");
|
62
66
|
const workspaceEditTestUtils_1 = require("./workspaceEditTestUtils");
|
67
|
+
const renameProvider_1 = require("../../../languageService/renameProvider");
|
68
|
+
const workspaceEditUtils_1 = require("../../../common/workspaceEditUtils");
|
63
69
|
const testAccessHost = new testAccessHost_1.TestAccessHost(vfs.MODULE_PATH, [factory_1.libFolder, factory_1.distlibFolder]);
|
64
70
|
class TestState {
|
65
71
|
constructor(projectRoot, testData, mountPaths, hostSpecificFeatures, testFS) {
|
@@ -259,12 +265,12 @@ class TestState {
|
|
259
265
|
if (this.testData.rangesByText) {
|
260
266
|
return this.testData.rangesByText;
|
261
267
|
}
|
262
|
-
const result = this.createMultiMap(this.getRanges(), (r) => this.
|
268
|
+
const result = this.createMultiMap(this.getRanges(), (r) => this.rangeText(r));
|
263
269
|
this.testData.rangesByText = result;
|
264
270
|
return result;
|
265
271
|
}
|
266
272
|
getFilteredRanges(predicate) {
|
267
|
-
return this.getRanges().filter((r) => { var _a; return predicate(r.marker, (_a = r.marker) === null || _a === void 0 ? void 0 : _a.data, this.
|
273
|
+
return this.getRanges().filter((r) => { var _a; return predicate(r.marker, (_a = r.marker) === null || _a === void 0 ? void 0 : _a.data, this.rangeText(r)); });
|
268
274
|
}
|
269
275
|
getRangeByMarkerName(markerName) {
|
270
276
|
const marker = this.getMarkerByName(markerName);
|
@@ -287,7 +293,7 @@ class TestState {
|
|
287
293
|
const fileToOpen = this._findFile(indexOrName);
|
288
294
|
fileToOpen.fileName = (0, pathUtils_1.normalizeSlashes)(fileToOpen.fileName);
|
289
295
|
this.activeFile = fileToOpen;
|
290
|
-
this.program.setFileOpened(this.activeFile.fileName, 1,
|
296
|
+
this.program.setFileOpened(this.activeFile.fileName, 1, fileToOpen.content);
|
291
297
|
}
|
292
298
|
openFiles(indexOrNames) {
|
293
299
|
for (const indexOrName of indexOrNames) {
|
@@ -450,7 +456,7 @@ class TestState {
|
|
450
456
|
return false;
|
451
457
|
}
|
452
458
|
}
|
453
|
-
async verifyCodeActions(
|
459
|
+
async verifyCodeActions(verifyMode, map) {
|
454
460
|
// make sure we don't use cache built from other tests
|
455
461
|
this.workspace.service.invalidateAndForceReanalysis();
|
456
462
|
this.analyze();
|
@@ -460,7 +466,7 @@ class TestState {
|
|
460
466
|
continue;
|
461
467
|
}
|
462
468
|
const codeActions = await this._getCodeActions(range);
|
463
|
-
if (
|
469
|
+
if (verifyMode === 'exact') {
|
464
470
|
if (codeActions.length !== map[name].codeActions.length) {
|
465
471
|
this.raiseError(`doesn't contain expected result: ${(0, utils_1.stringify)(map[name])}, actual: ${(0, utils_1.stringify)(codeActions)}`);
|
466
472
|
}
|
@@ -485,10 +491,13 @@ class TestState {
|
|
485
491
|
const actualEdit = a.edit;
|
486
492
|
return (a.title === expected.title &&
|
487
493
|
a.kind === expected.kind &&
|
488
|
-
this._deepEqual(actualCommand, expectedCommand) &&
|
489
|
-
this._deepEqual(actualEdit, expected.edit));
|
494
|
+
(expectedCommand ? this._deepEqual(actualCommand, expectedCommand) : true) &&
|
495
|
+
(expected.edit ? this._deepEqual(actualEdit, expected.edit) : true));
|
490
496
|
});
|
491
|
-
if (matches.length
|
497
|
+
if (verifyMode === 'excluded' && matches.length > 0) {
|
498
|
+
this.raiseError(`unexpected result: ${(0, utils_1.stringify)(map[name])}`);
|
499
|
+
}
|
500
|
+
else if (verifyMode !== 'excluded' && matches.length !== 1) {
|
492
501
|
this.raiseError(`doesn't contain expected result: ${(0, utils_1.stringify)(expected)}, actual: ${(0, utils_1.stringify)(codeActions)}`);
|
493
502
|
}
|
494
503
|
}
|
@@ -574,7 +583,7 @@ class TestState {
|
|
574
583
|
continue;
|
575
584
|
}
|
576
585
|
const rangePos = this.convertOffsetsToRange(range.fileName, range.pos, range.end);
|
577
|
-
const provider = new hoverProvider_1.HoverProvider(this.program, range.fileName, rangePos.start, kind,
|
586
|
+
const provider = new hoverProvider_1.HoverProvider(this.program, range.fileName, rangePos.start, kind, vscode_languageserver_1.CancellationToken.None);
|
578
587
|
const actual = provider.getHover();
|
579
588
|
// if expected is null then there should be nothing shown on hover
|
580
589
|
if (expected === null) {
|
@@ -617,7 +626,7 @@ class TestState {
|
|
617
626
|
}
|
618
627
|
}
|
619
628
|
verifyRangeIs(expectedText, includeWhiteSpace) {
|
620
|
-
this._verifyTextMatches(this.
|
629
|
+
this._verifyTextMatches(this.rangeText(this._getOnlyRange()), !!includeWhiteSpace, expectedText);
|
621
630
|
}
|
622
631
|
async verifyCompletion(verifyMode, docFormat, map, abbrMap) {
|
623
632
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
@@ -714,6 +723,7 @@ class TestState {
|
|
714
723
|
}
|
715
724
|
}
|
716
725
|
verifySignature(docFormat, map) {
|
726
|
+
var _a, _b;
|
717
727
|
this.analyze();
|
718
728
|
for (const marker of this.getMarkers()) {
|
719
729
|
const fileName = marker.fileName;
|
@@ -723,7 +733,10 @@ class TestState {
|
|
723
733
|
}
|
724
734
|
const expected = map[name];
|
725
735
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
726
|
-
const actual = this.program
|
736
|
+
const actual = new signatureHelpProvider_1.SignatureHelpProvider(this.program, fileName, position, docFormat,
|
737
|
+
/*hasSignatureLabelOffsetCapability*/ true,
|
738
|
+
/*hasActiveParameterCapability*/ true,
|
739
|
+
/*context*/ undefined, vscode_languageserver_1.CancellationToken.None).getSignatureHelp();
|
727
740
|
if (expected.noSig) {
|
728
741
|
assert_1.default.equal(actual, undefined);
|
729
742
|
continue;
|
@@ -738,7 +751,7 @@ class TestState {
|
|
738
751
|
assert_1.default.ok(sig.parameters);
|
739
752
|
const actualParameters = [];
|
740
753
|
sig.parameters.forEach((p) => {
|
741
|
-
actualParameters.push(sig.label.substring(p.
|
754
|
+
actualParameters.push((0, core_1.isString)(p.label) ? p.label : sig.label.substring(p.label[0], p.label[1]));
|
742
755
|
});
|
743
756
|
assert_1.default.deepEqual(actualParameters, expectedSig.parameters);
|
744
757
|
if (expectedSig.documentation === undefined) {
|
@@ -753,7 +766,9 @@ class TestState {
|
|
753
766
|
});
|
754
767
|
assert_1.default.deepEqual(actual.signatures.map((sig) => sig.activeParameter), expected.activeParameters);
|
755
768
|
if (expected.callHasParameters !== undefined) {
|
756
|
-
|
769
|
+
const isActive = (sig) => { var _a; return !expected.callHasParameters && !((_a = sig.parameters) === null || _a === void 0 ? void 0 : _a.length); };
|
770
|
+
const activeSignature = (_b = (_a = expected.signatures) === null || _a === void 0 ? void 0 : _a.findIndex(isActive)) !== null && _b !== void 0 ? _b : undefined;
|
771
|
+
assert_1.default.equal(actual.activeSignature, activeSignature);
|
757
772
|
}
|
758
773
|
}
|
759
774
|
}
|
@@ -768,10 +783,10 @@ class TestState {
|
|
768
783
|
}
|
769
784
|
const expected = map[name].references;
|
770
785
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
771
|
-
const actual =
|
772
|
-
|
786
|
+
const actual = new referencesProvider_1.ReferencesProvider(this.program, vscode_languageserver_1.CancellationToken.None).reportReferences(fileName, position,
|
787
|
+
/* includeDeclaration */ true);
|
773
788
|
assert_1.default.strictEqual((_a = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _a !== void 0 ? _a : 0, expected.length, `${name} has failed`);
|
774
|
-
for (const r of expected) {
|
789
|
+
for (const r of (0, navigationUtils_1.convertDocumentRangesToLocation)(this.program.fileSystem, expected)) {
|
775
790
|
assert_1.default.equal(actual === null || actual === void 0 ? void 0 : actual.filter((d) => this._deepEqual(d, r)).length, 1);
|
776
791
|
}
|
777
792
|
}
|
@@ -789,7 +804,7 @@ class TestState {
|
|
789
804
|
const expectedRange = map[name].items.map((x) => x.range);
|
790
805
|
const expectedName = map[name].items.map((x) => x.name);
|
791
806
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
792
|
-
const actual = this.program
|
807
|
+
const actual = new callHierarchyProvider_1.CallHierarchyProvider(this.program, fileName, position, vscode_languageserver_1.CancellationToken.None).getIncomingCalls();
|
793
808
|
assert_1.default.strictEqual((_a = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _a !== void 0 ? _a : 0, expectedFilePath.length, `${name} has failed`);
|
794
809
|
assert_1.default.strictEqual((_b = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _b !== void 0 ? _b : 0, expectedRange.length, `${name} has failed`);
|
795
810
|
assert_1.default.strictEqual((_c = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _c !== void 0 ? _c : 0, expectedName.length, `${name} has failed`);
|
@@ -797,7 +812,7 @@ class TestState {
|
|
797
812
|
for (const a of actual) {
|
798
813
|
assert_1.default.strictEqual(expectedRange === null || expectedRange === void 0 ? void 0 : expectedRange.filter((e) => this._deepEqual(a.from.range, e)).length, 1);
|
799
814
|
assert_1.default.strictEqual(expectedName === null || expectedName === void 0 ? void 0 : expectedName.filter((e) => this._deepEqual(a.from.name, e)).length, 1);
|
800
|
-
assert_1.default.ok((expectedFilePath === null || expectedFilePath === void 0 ? void 0 : expectedFilePath.filter((e) => this._deepEqual(a.from.uri, e)).length) >= 1);
|
815
|
+
assert_1.default.ok((expectedFilePath === null || expectedFilePath === void 0 ? void 0 : expectedFilePath.filter((e) => this._deepEqual(a.from.uri, (0, pathUtils_1.convertPathToUri)(this.program.fileSystem, e))).length) >= 1);
|
801
816
|
}
|
802
817
|
}
|
803
818
|
}
|
@@ -815,7 +830,7 @@ class TestState {
|
|
815
830
|
const expectedRange = map[name].items.map((x) => x.range);
|
816
831
|
const expectedName = map[name].items.map((x) => x.name);
|
817
832
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
818
|
-
const actual = this.program
|
833
|
+
const actual = new callHierarchyProvider_1.CallHierarchyProvider(this.program, fileName, position, vscode_languageserver_1.CancellationToken.None).getOutgoingCalls();
|
819
834
|
assert_1.default.strictEqual((_a = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _a !== void 0 ? _a : 0, expectedFilePath.length, `${name} has failed`);
|
820
835
|
assert_1.default.strictEqual((_b = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _b !== void 0 ? _b : 0, expectedRange.length, `${name} has failed`);
|
821
836
|
assert_1.default.strictEqual((_c = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _c !== void 0 ? _c : 0, expectedName.length, `${name} has failed`);
|
@@ -823,7 +838,7 @@ class TestState {
|
|
823
838
|
for (const a of actual) {
|
824
839
|
assert_1.default.strictEqual(expectedRange === null || expectedRange === void 0 ? void 0 : expectedRange.filter((e) => this._deepEqual(a.to.range, e)).length, 1);
|
825
840
|
assert_1.default.strictEqual(expectedName === null || expectedName === void 0 ? void 0 : expectedName.filter((e) => this._deepEqual(a.to.name, e)).length, 1);
|
826
|
-
assert_1.default.ok((expectedFilePath === null || expectedFilePath === void 0 ? void 0 : expectedFilePath.filter((e) => this._deepEqual(a.to.uri, e)).length) >= 1);
|
841
|
+
assert_1.default.ok((expectedFilePath === null || expectedFilePath === void 0 ? void 0 : expectedFilePath.filter((e) => this._deepEqual(a.to.uri, (0, pathUtils_1.convertPathToUri)(this.program.fileSystem, e))).length) >= 1);
|
827
842
|
}
|
828
843
|
}
|
829
844
|
}
|
@@ -849,7 +864,7 @@ class TestState {
|
|
849
864
|
const fileName = marker.fileName;
|
850
865
|
const expected = map[name].references;
|
851
866
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
852
|
-
const actual = this.program
|
867
|
+
const actual = new documentHighlightProvider_1.DocumentHighlightProvider(this.program, fileName, position, vscode_languageserver_1.CancellationToken.None).getDocumentHighlight();
|
853
868
|
assert_1.default.equal((_a = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _a !== void 0 ? _a : 0, expected.length);
|
854
869
|
for (const r of expected) {
|
855
870
|
const match = actual === null || actual === void 0 ? void 0 : actual.filter((h) => this._deepEqual(h.range, r.range));
|
@@ -874,11 +889,11 @@ class TestState {
|
|
874
889
|
if (!this.program.getSourceFileInfo(fileName)) {
|
875
890
|
const file = this.testData.files.find((v) => v.fileName === fileName);
|
876
891
|
if (file) {
|
877
|
-
this.program.setFileOpened(fileName, file.version,
|
892
|
+
this.program.setFileOpened(fileName, file.version, file.content);
|
878
893
|
}
|
879
894
|
}
|
880
895
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
881
|
-
const actual = this.program
|
896
|
+
const actual = new definitionProvider_1.DefinitionProvider(this.program, fileName, position, filter, vscode_languageserver_1.CancellationToken.None).getDefinitions();
|
882
897
|
assert_1.default.equal((_a = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _a !== void 0 ? _a : 0, expected.length, `No definitions found for marker "${name}"`);
|
883
898
|
for (const r of expected) {
|
884
899
|
assert_1.default.equal(actual === null || actual === void 0 ? void 0 : actual.filter((d) => this._deepEqual(d, r)).length, 1, `No match found for ${JSON.stringify(r)} from marker ${name}`);
|
@@ -896,7 +911,7 @@ class TestState {
|
|
896
911
|
}
|
897
912
|
const expected = map[name].definitions;
|
898
913
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
899
|
-
const actual = this.program
|
914
|
+
const actual = new definitionProvider_1.TypeDefinitionProvider(this.program, fileName, position, vscode_languageserver_1.CancellationToken.None).getDefinitions();
|
900
915
|
assert_1.default.strictEqual((_a = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _a !== void 0 ? _a : 0, expected.length, name);
|
901
916
|
for (const r of expected) {
|
902
917
|
assert_1.default.strictEqual(actual === null || actual === void 0 ? void 0 : actual.filter((d) => this._deepEqual(d, r)).length, 1, name);
|
@@ -904,7 +919,6 @@ class TestState {
|
|
904
919
|
}
|
905
920
|
}
|
906
921
|
verifyRename(map) {
|
907
|
-
var _a;
|
908
922
|
this.analyze();
|
909
923
|
for (const marker of this.getMarkers()) {
|
910
924
|
const fileName = marker.fileName;
|
@@ -914,13 +928,9 @@ class TestState {
|
|
914
928
|
}
|
915
929
|
const expected = map[name];
|
916
930
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
917
|
-
const actual = this.program
|
918
|
-
/* isDefaultWorkspace */ false
|
919
|
-
|
920
|
-
assert_1.default.equal((_a = actual === null || actual === void 0 ? void 0 : actual.edits.length) !== null && _a !== void 0 ? _a : 0, expected.changes.length);
|
921
|
-
for (const c of expected.changes) {
|
922
|
-
assert_1.default.equal(actual === null || actual === void 0 ? void 0 : actual.edits.filter((e) => this._deepEqual(e, c)).length, 1);
|
923
|
-
}
|
931
|
+
const actual = new renameProvider_1.RenameProvider(this.program, fileName, position, vscode_languageserver_1.CancellationToken.None).renameSymbol(expected.newName,
|
932
|
+
/* isDefaultWorkspace */ false);
|
933
|
+
(0, workspaceEditTestUtils_1.verifyWorkspaceEdit)((0, workspaceEditUtils_1.convertToWorkspaceEdit)(this.program.fileSystem, { edits: expected.changes, fileOperations: [] }), actual !== null && actual !== void 0 ? actual : { documentChanges: [] });
|
924
934
|
}
|
925
935
|
}
|
926
936
|
setCancelled(numberOfCalls) {
|
@@ -929,6 +939,86 @@ class TestState {
|
|
929
939
|
resetCancelled() {
|
930
940
|
this._cancellationToken.resetCancelled();
|
931
941
|
}
|
942
|
+
convertPositionToOffset(fileName, position) {
|
943
|
+
const lines = this._getTextRangeCollection(fileName);
|
944
|
+
return (0, positionUtils_1.convertPositionToOffset)(position, lines);
|
945
|
+
}
|
946
|
+
convertOffsetToPosition(fileName, offset) {
|
947
|
+
const lines = this._getTextRangeCollection(fileName);
|
948
|
+
return (0, positionUtils_1.convertOffsetToPosition)(offset, lines);
|
949
|
+
}
|
950
|
+
analyze() {
|
951
|
+
while (this.program.analyze()) {
|
952
|
+
// Continue to call analyze until it completes. Since we're not
|
953
|
+
// specifying a timeout, it should complete the first time.
|
954
|
+
}
|
955
|
+
}
|
956
|
+
getFileContent(fileName) {
|
957
|
+
const files = this.testData.files.filter((f) => (0, pathUtils_1.comparePaths)(f.fileName, fileName, this.testFS.ignoreCase) === 0 /* EqualTo */);
|
958
|
+
return files[0].content;
|
959
|
+
}
|
960
|
+
convertOffsetsToRange(fileName, startOffset, endOffset) {
|
961
|
+
const lines = this._getTextRangeCollection(fileName);
|
962
|
+
return {
|
963
|
+
start: (0, positionUtils_1.convertOffsetToPosition)(startOffset, lines),
|
964
|
+
end: (0, positionUtils_1.convertOffsetToPosition)(endOffset, lines),
|
965
|
+
};
|
966
|
+
}
|
967
|
+
raiseError(message) {
|
968
|
+
throw new Error(this._messageAtLastKnownMarker(message));
|
969
|
+
}
|
970
|
+
createMultiMap(values, getKey) {
|
971
|
+
const map = new Map();
|
972
|
+
map.add = multiMapAdd;
|
973
|
+
map.remove = multiMapRemove;
|
974
|
+
if (values && getKey) {
|
975
|
+
for (const value of values) {
|
976
|
+
map.add(getKey(value), value);
|
977
|
+
}
|
978
|
+
}
|
979
|
+
return map;
|
980
|
+
function multiMapAdd(key, value) {
|
981
|
+
let values = this.get(key);
|
982
|
+
if (values) {
|
983
|
+
values.push(value);
|
984
|
+
}
|
985
|
+
else {
|
986
|
+
this.set(key, (values = [value]));
|
987
|
+
}
|
988
|
+
return values;
|
989
|
+
}
|
990
|
+
function multiMapRemove(key, value) {
|
991
|
+
const values = this.get(key);
|
992
|
+
if (values) {
|
993
|
+
values.forEach((v, i, arr) => {
|
994
|
+
if (v === value) {
|
995
|
+
arr.splice(i, 1);
|
996
|
+
}
|
997
|
+
});
|
998
|
+
if (!values.length) {
|
999
|
+
this.delete(key);
|
1000
|
+
}
|
1001
|
+
}
|
1002
|
+
}
|
1003
|
+
}
|
1004
|
+
rangeText({ fileName, pos, end }) {
|
1005
|
+
return this.getFileContent(fileName).slice(pos, end);
|
1006
|
+
}
|
1007
|
+
verifyCompletionItem(expected, actual) {
|
1008
|
+
var _a, _b, _c;
|
1009
|
+
assert_1.default.strictEqual(actual.label, expected.label);
|
1010
|
+
assert_1.default.strictEqual(actual.detail, expected.detail);
|
1011
|
+
assert_1.default.strictEqual(actual.kind, expected.kind);
|
1012
|
+
assert_1.default.strictEqual(actual.insertText, expected.insertionText);
|
1013
|
+
this._verifyEdit(actual.textEdit, expected.textEdit);
|
1014
|
+
this._verifyEdits(actual.additionalTextEdits, expected.additionalTextEdits);
|
1015
|
+
if (expected.detailDescription !== undefined) {
|
1016
|
+
assert_1.default.strictEqual((_a = actual.labelDetails) === null || _a === void 0 ? void 0 : _a.description, expected.detailDescription);
|
1017
|
+
}
|
1018
|
+
if (expected.commitCharacters !== undefined) {
|
1019
|
+
expect(expected.commitCharacters.sort()).toEqual((_c = (_b = actual.commitCharacters) === null || _b === void 0 ? void 0 : _b.sort()) !== null && _c !== void 0 ? _c : []);
|
1020
|
+
}
|
1021
|
+
}
|
932
1022
|
_convertGlobalOptionsToConfigOptions(projectRoot, mountPaths) {
|
933
1023
|
const configOptions = new configOptions_1.ConfigOptions(projectRoot);
|
934
1024
|
// add more global options as we need them
|
@@ -960,25 +1050,6 @@ class TestState {
|
|
960
1050
|
}
|
961
1051
|
return configOptions;
|
962
1052
|
}
|
963
|
-
getFileContent(fileName) {
|
964
|
-
const files = this.testData.files.filter((f) => (0, pathUtils_1.comparePaths)(f.fileName, fileName, this.testFS.ignoreCase) === 0 /* EqualTo */);
|
965
|
-
return files[0].content;
|
966
|
-
}
|
967
|
-
convertPositionToOffset(fileName, position) {
|
968
|
-
const lines = this._getTextRangeCollection(fileName);
|
969
|
-
return (0, positionUtils_1.convertPositionToOffset)(position, lines);
|
970
|
-
}
|
971
|
-
convertOffsetToPosition(fileName, offset) {
|
972
|
-
const lines = this._getTextRangeCollection(fileName);
|
973
|
-
return (0, positionUtils_1.convertOffsetToPosition)(offset, lines);
|
974
|
-
}
|
975
|
-
convertOffsetsToRange(fileName, startOffset, endOffset) {
|
976
|
-
const lines = this._getTextRangeCollection(fileName);
|
977
|
-
return {
|
978
|
-
start: (0, positionUtils_1.convertOffsetToPosition)(startOffset, lines),
|
979
|
-
end: (0, positionUtils_1.convertOffsetToPosition)(endOffset, lines),
|
980
|
-
};
|
981
|
-
}
|
982
1053
|
_getParseResult(fileName) {
|
983
1054
|
const file = this.program.getBoundSourceFile(fileName);
|
984
1055
|
return file.getParseResults();
|
@@ -992,9 +1063,6 @@ class TestState {
|
|
992
1063
|
const tokenizer = new tokenizer_1.Tokenizer();
|
993
1064
|
return tokenizer.tokenize(fileContents).lines;
|
994
1065
|
}
|
995
|
-
raiseError(message) {
|
996
|
-
throw new Error(this._messageAtLastKnownMarker(message));
|
997
|
-
}
|
998
1066
|
_messageAtLastKnownMarker(message) {
|
999
1067
|
const locationDescription = this.lastKnownMarker
|
1000
1068
|
? this.lastKnownMarker
|
@@ -1022,43 +1090,6 @@ class TestState {
|
|
1022
1090
|
_removeWhitespace(text) {
|
1023
1091
|
return text.replace(/\s/g, '');
|
1024
1092
|
}
|
1025
|
-
createMultiMap(values, getKey) {
|
1026
|
-
const map = new Map();
|
1027
|
-
map.add = multiMapAdd;
|
1028
|
-
map.remove = multiMapRemove;
|
1029
|
-
if (values && getKey) {
|
1030
|
-
for (const value of values) {
|
1031
|
-
map.add(getKey(value), value);
|
1032
|
-
}
|
1033
|
-
}
|
1034
|
-
return map;
|
1035
|
-
function multiMapAdd(key, value) {
|
1036
|
-
let values = this.get(key);
|
1037
|
-
if (values) {
|
1038
|
-
values.push(value);
|
1039
|
-
}
|
1040
|
-
else {
|
1041
|
-
this.set(key, (values = [value]));
|
1042
|
-
}
|
1043
|
-
return values;
|
1044
|
-
}
|
1045
|
-
function multiMapRemove(key, value) {
|
1046
|
-
const values = this.get(key);
|
1047
|
-
if (values) {
|
1048
|
-
values.forEach((v, i, arr) => {
|
1049
|
-
if (v === value) {
|
1050
|
-
arr.splice(i, 1);
|
1051
|
-
}
|
1052
|
-
});
|
1053
|
-
if (!values.length) {
|
1054
|
-
this.delete(key);
|
1055
|
-
}
|
1056
|
-
}
|
1057
|
-
}
|
1058
|
-
}
|
1059
|
-
_rangeText({ fileName, pos, end }) {
|
1060
|
-
return this.getFileContent(fileName).slice(pos, end);
|
1061
|
-
}
|
1062
1093
|
_getOnlyRange() {
|
1063
1094
|
const ranges = this.getRanges();
|
1064
1095
|
if (ranges.length !== 1) {
|
@@ -1176,12 +1207,6 @@ class TestState {
|
|
1176
1207
|
// If inside the edit, return -1 to mark as invalid
|
1177
1208
|
return position <= editStart ? position : position < editEnd ? -1 : position + length - +(editEnd - editStart);
|
1178
1209
|
}
|
1179
|
-
analyze() {
|
1180
|
-
while (this.program.analyze()) {
|
1181
|
-
// Continue to call analyze until it completes. Since we're not
|
1182
|
-
// specifying a timeout, it should complete the first time.
|
1183
|
-
}
|
1184
|
-
}
|
1185
1210
|
_getDiagnosticsPerFile() {
|
1186
1211
|
const sourceFiles = this._files.map((f) => this.program.getSourceFile(f));
|
1187
1212
|
const results = sourceFiles.map((sourceFile, index) => {
|
@@ -1289,21 +1314,6 @@ class TestState {
|
|
1289
1314
|
this.raiseError(`doesn't contain expected result: ${(0, utils_1.stringify)(extra)}, actual: ${(0, utils_1.stringify)(left)}`);
|
1290
1315
|
}
|
1291
1316
|
}
|
1292
|
-
verifyCompletionItem(expected, actual) {
|
1293
|
-
var _a, _b, _c;
|
1294
|
-
assert_1.default.strictEqual(actual.label, expected.label);
|
1295
|
-
assert_1.default.strictEqual(actual.detail, expected.detail);
|
1296
|
-
assert_1.default.strictEqual(actual.kind, expected.kind);
|
1297
|
-
assert_1.default.strictEqual(actual.insertText, expected.insertionText);
|
1298
|
-
this._verifyEdit(actual.textEdit, expected.textEdit);
|
1299
|
-
this._verifyEdits(actual.additionalTextEdits, expected.additionalTextEdits);
|
1300
|
-
if (expected.detailDescription !== undefined) {
|
1301
|
-
assert_1.default.strictEqual((_a = actual.labelDetails) === null || _a === void 0 ? void 0 : _a.description, expected.detailDescription);
|
1302
|
-
}
|
1303
|
-
if (expected.commitCharacters !== undefined) {
|
1304
|
-
expect(expected.commitCharacters.sort()).toEqual((_c = (_b = actual.commitCharacters) === null || _b === void 0 ? void 0 : _b.sort()) !== null && _c !== void 0 ? _c : []);
|
1305
|
-
}
|
1306
|
-
}
|
1307
1317
|
}
|
1308
1318
|
exports.TestState = TestState;
|
1309
1319
|
function parseAndGetTestState(code, projectRoot = '/', anonymousFileName = 'unnamedFile.py', testFS) {
|