@zzzen/pyright-internal 1.2.0-dev.20230416 → 1.2.0-dev.20230430
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 +4 -4
- package/dist/analyzer/backgroundAnalysisProgram.js +10 -7
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +13 -10
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +6 -3
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +17 -0
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/commentUtils.d.ts +1 -1
- package/dist/analyzer/commentUtils.js +18 -3
- package/dist/analyzer/commentUtils.js.map +1 -1
- package/dist/analyzer/dataClasses.js +5 -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/docStringConversion.js +2 -3
- package/dist/analyzer/docStringConversion.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/namedTuples.d.ts +1 -1
- package/dist/analyzer/namedTuples.js +29 -41
- package/dist/analyzer/namedTuples.js.map +1 -1
- 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/patternMatching.d.ts +6 -2
- package/dist/analyzer/patternMatching.js +108 -2
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +34 -44
- package/dist/analyzer/program.js +1382 -1529
- 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 -27
- package/dist/analyzer/service.js +81 -114
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +7 -21
- package/dist/analyzer/sourceFile.js +58 -130
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.d.ts +7 -1
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +398 -334
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +6 -3
- package/dist/analyzer/typeEvaluatorTypes.js +0 -2
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.d.ts +2 -0
- package/dist/analyzer/typeGuards.js +175 -176
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +1 -0
- package/dist/analyzer/typeUtils.js +44 -17
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.js +10 -2
- 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 +33 -9
- 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 +2 -2
- 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.js +7 -4
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.d.ts +32 -30
- package/dist/languageServerBase.js +276 -337
- 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 +138 -41
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +119 -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 +2 -2
- package/dist/languageService/documentSymbolCollector.js +4 -3
- 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 +28 -28
- package/dist/languageService/hoverProvider.js +142 -120
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importAdder.d.ts +13 -2
- package/dist/languageService/importAdder.js +73 -26
- package/dist/languageService/importAdder.js.map +1 -1
- package/dist/languageService/indentationUtils.js +6 -1
- package/dist/languageService/indentationUtils.js.map +1 -1
- package/dist/languageService/insertionPointUtils.js +3 -3
- package/dist/languageService/insertionPointUtils.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 +8 -2
- package/dist/languageService/referencesProvider.js +81 -3
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameModuleProvider.d.ts +13 -13
- package/dist/languageService/renameModuleProvider.js +43 -43
- package/dist/languageService/renameModuleProvider.js.map +1 -1
- 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 +2 -0
- package/dist/localization/localize.js +2 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +2 -0
- 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 +2 -2
- package/dist/tests/completions.test.js +173 -0
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/docStringConversion.test.js +11 -1
- package/dist/tests/docStringConversion.test.js.map +1 -1
- package/dist/tests/fourslash/completions.override2.fourslash.js +15 -0
- package/dist/tests/fourslash/completions.override2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/fourslash.d.ts +11 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js +5 -6
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.js +1 -4
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js +10 -9
- package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js.map +1 -1
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction1.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction1.fourslash.js +54 -0
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction1.fourslash.js.map +1 -0
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction2.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction2.fourslash.js +46 -0
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction2.fourslash.js.map +1 -0
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.function.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.function.fourslash.js +39 -0
- package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.function.fourslash.js.map +1 -0
- 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 +14 -9
- package/dist/tests/harness/fourslash/testState.js +144 -102
- 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/importAdder.test.js +69 -1
- package/dist/tests/importAdder.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +34 -0
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/indentationUtils.ptvs.test.js +2 -2
- package/dist/tests/indentationUtils.ptvs.test.js.map +1 -1
- package/dist/tests/indentationUtils.test.js +18 -0
- package/dist/tests/indentationUtils.test.js.map +1 -1
- package/dist/tests/moveSymbol.updateReference.test.js +14 -0
- package/dist/tests/moveSymbol.updateReference.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 +1 -1
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/testStateUtils.js +1 -1
- 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 +12 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +7 -1
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +5 -1
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/package.json +1 -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");
|
@@ -259,12 +263,12 @@ class TestState {
|
|
259
263
|
if (this.testData.rangesByText) {
|
260
264
|
return this.testData.rangesByText;
|
261
265
|
}
|
262
|
-
const result = this.createMultiMap(this.getRanges(), (r) => this.
|
266
|
+
const result = this.createMultiMap(this.getRanges(), (r) => this.rangeText(r));
|
263
267
|
this.testData.rangesByText = result;
|
264
268
|
return result;
|
265
269
|
}
|
266
270
|
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.
|
271
|
+
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
272
|
}
|
269
273
|
getRangeByMarkerName(markerName) {
|
270
274
|
const marker = this.getMarkerByName(markerName);
|
@@ -287,7 +291,7 @@ class TestState {
|
|
287
291
|
const fileToOpen = this._findFile(indexOrName);
|
288
292
|
fileToOpen.fileName = (0, pathUtils_1.normalizeSlashes)(fileToOpen.fileName);
|
289
293
|
this.activeFile = fileToOpen;
|
290
|
-
this.program.setFileOpened(this.activeFile.fileName, 1,
|
294
|
+
this.program.setFileOpened(this.activeFile.fileName, 1, fileToOpen.content);
|
291
295
|
}
|
292
296
|
openFiles(indexOrNames) {
|
293
297
|
for (const indexOrName of indexOrNames) {
|
@@ -574,7 +578,8 @@ class TestState {
|
|
574
578
|
continue;
|
575
579
|
}
|
576
580
|
const rangePos = this.convertOffsetsToRange(range.fileName, range.pos, range.end);
|
577
|
-
const
|
581
|
+
const provider = new hoverProvider_1.HoverProvider(this.program, range.fileName, rangePos.start, kind, false, vscode_languageserver_1.CancellationToken.None);
|
582
|
+
const actual = provider.getHover();
|
578
583
|
// if expected is null then there should be nothing shown on hover
|
579
584
|
if (expected === null) {
|
580
585
|
assert_1.default.equal(actual, undefined);
|
@@ -616,7 +621,7 @@ class TestState {
|
|
616
621
|
}
|
617
622
|
}
|
618
623
|
verifyRangeIs(expectedText, includeWhiteSpace) {
|
619
|
-
this._verifyTextMatches(this.
|
624
|
+
this._verifyTextMatches(this.rangeText(this._getOnlyRange()), !!includeWhiteSpace, expectedText);
|
620
625
|
}
|
621
626
|
async verifyCompletion(verifyMode, docFormat, map, abbrMap) {
|
622
627
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
@@ -713,6 +718,7 @@ class TestState {
|
|
713
718
|
}
|
714
719
|
}
|
715
720
|
verifySignature(docFormat, map) {
|
721
|
+
var _a, _b;
|
716
722
|
this.analyze();
|
717
723
|
for (const marker of this.getMarkers()) {
|
718
724
|
const fileName = marker.fileName;
|
@@ -722,7 +728,10 @@ class TestState {
|
|
722
728
|
}
|
723
729
|
const expected = map[name];
|
724
730
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
725
|
-
const actual = this.program
|
731
|
+
const actual = new signatureHelpProvider_1.SignatureHelpProvider(this.program, fileName, position, docFormat,
|
732
|
+
/*hasSignatureLabelOffsetCapability*/ true,
|
733
|
+
/*hasActiveParameterCapability*/ true,
|
734
|
+
/*context*/ undefined, vscode_languageserver_1.CancellationToken.None).getSignatureHelp();
|
726
735
|
if (expected.noSig) {
|
727
736
|
assert_1.default.equal(actual, undefined);
|
728
737
|
continue;
|
@@ -737,7 +746,7 @@ class TestState {
|
|
737
746
|
assert_1.default.ok(sig.parameters);
|
738
747
|
const actualParameters = [];
|
739
748
|
sig.parameters.forEach((p) => {
|
740
|
-
actualParameters.push(sig.label.substring(p.
|
749
|
+
actualParameters.push((0, core_1.isString)(p.label) ? p.label : sig.label.substring(p.label[0], p.label[1]));
|
741
750
|
});
|
742
751
|
assert_1.default.deepEqual(actualParameters, expectedSig.parameters);
|
743
752
|
if (expectedSig.documentation === undefined) {
|
@@ -752,7 +761,9 @@ class TestState {
|
|
752
761
|
});
|
753
762
|
assert_1.default.deepEqual(actual.signatures.map((sig) => sig.activeParameter), expected.activeParameters);
|
754
763
|
if (expected.callHasParameters !== undefined) {
|
755
|
-
|
764
|
+
const isActive = (sig) => { var _a; return !expected.callHasParameters && !((_a = sig.parameters) === null || _a === void 0 ? void 0 : _a.length); };
|
765
|
+
const activeSignature = (_b = (_a = expected.signatures) === null || _a === void 0 ? void 0 : _a.findIndex(isActive)) !== null && _b !== void 0 ? _b : undefined;
|
766
|
+
assert_1.default.equal(actual.activeSignature, activeSignature);
|
756
767
|
}
|
757
768
|
}
|
758
769
|
}
|
@@ -767,16 +778,16 @@ class TestState {
|
|
767
778
|
}
|
768
779
|
const expected = map[name].references;
|
769
780
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
770
|
-
const actual =
|
771
|
-
|
781
|
+
const actual = new referencesProvider_1.ReferencesProvider(this.program, vscode_languageserver_1.CancellationToken.None).reportReferences(fileName, position,
|
782
|
+
/* includeDeclaration */ true);
|
772
783
|
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`);
|
773
|
-
for (const r of expected) {
|
784
|
+
for (const r of (0, navigationUtils_1.convertDocumentRangesToLocation)(this.program.fileSystem, expected)) {
|
774
785
|
assert_1.default.equal(actual === null || actual === void 0 ? void 0 : actual.filter((d) => this._deepEqual(d, r)).length, 1);
|
775
786
|
}
|
776
787
|
}
|
777
788
|
}
|
778
789
|
verifyShowCallHierarchyGetIncomingCalls(map) {
|
779
|
-
var _a;
|
790
|
+
var _a, _b, _c;
|
780
791
|
this.analyze();
|
781
792
|
for (const marker of this.getMarkers()) {
|
782
793
|
const fileName = marker.fileName;
|
@@ -784,14 +795,45 @@ class TestState {
|
|
784
795
|
if (!(name in map)) {
|
785
796
|
continue;
|
786
797
|
}
|
787
|
-
const
|
798
|
+
const expectedFilePath = map[name].items.map((x) => x.filePath);
|
799
|
+
const expectedRange = map[name].items.map((x) => x.range);
|
800
|
+
const expectedName = map[name].items.map((x) => x.name);
|
788
801
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
789
|
-
const actual = this.program
|
790
|
-
assert_1.default.strictEqual((_a = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _a !== void 0 ? _a : 0,
|
802
|
+
const actual = new callHierarchyProvider_1.CallHierarchyProvider(this.program, fileName, position, vscode_languageserver_1.CancellationToken.None).getIncomingCalls();
|
803
|
+
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`);
|
804
|
+
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`);
|
805
|
+
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`);
|
791
806
|
if (actual) {
|
792
807
|
for (const a of actual) {
|
793
|
-
assert_1.default.
|
794
|
-
assert_1.default.
|
808
|
+
assert_1.default.strictEqual(expectedRange === null || expectedRange === void 0 ? void 0 : expectedRange.filter((e) => this._deepEqual(a.from.range, e)).length, 1);
|
809
|
+
assert_1.default.strictEqual(expectedName === null || expectedName === void 0 ? void 0 : expectedName.filter((e) => this._deepEqual(a.from.name, e)).length, 1);
|
810
|
+
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);
|
811
|
+
}
|
812
|
+
}
|
813
|
+
}
|
814
|
+
}
|
815
|
+
verifyShowCallHierarchyGetOutgoingCalls(map) {
|
816
|
+
var _a, _b, _c;
|
817
|
+
this.analyze();
|
818
|
+
for (const marker of this.getMarkers()) {
|
819
|
+
const fileName = marker.fileName;
|
820
|
+
const name = this.getMarkerName(marker);
|
821
|
+
if (!(name in map)) {
|
822
|
+
continue;
|
823
|
+
}
|
824
|
+
const expectedFilePath = map[name].items.map((x) => x.filePath);
|
825
|
+
const expectedRange = map[name].items.map((x) => x.range);
|
826
|
+
const expectedName = map[name].items.map((x) => x.name);
|
827
|
+
const position = this.convertOffsetToPosition(fileName, marker.position);
|
828
|
+
const actual = new callHierarchyProvider_1.CallHierarchyProvider(this.program, fileName, position, vscode_languageserver_1.CancellationToken.None).getOutgoingCalls();
|
829
|
+
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`);
|
830
|
+
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`);
|
831
|
+
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`);
|
832
|
+
if (actual) {
|
833
|
+
for (const a of actual) {
|
834
|
+
assert_1.default.strictEqual(expectedRange === null || expectedRange === void 0 ? void 0 : expectedRange.filter((e) => this._deepEqual(a.to.range, e)).length, 1);
|
835
|
+
assert_1.default.strictEqual(expectedName === null || expectedName === void 0 ? void 0 : expectedName.filter((e) => this._deepEqual(a.to.name, e)).length, 1);
|
836
|
+
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);
|
795
837
|
}
|
796
838
|
}
|
797
839
|
}
|
@@ -817,7 +859,7 @@ class TestState {
|
|
817
859
|
const fileName = marker.fileName;
|
818
860
|
const expected = map[name].references;
|
819
861
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
820
|
-
const actual = this.program
|
862
|
+
const actual = new documentHighlightProvider_1.DocumentHighlightProvider(this.program, fileName, position, vscode_languageserver_1.CancellationToken.None).getDocumentHighlight();
|
821
863
|
assert_1.default.equal((_a = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _a !== void 0 ? _a : 0, expected.length);
|
822
864
|
for (const r of expected) {
|
823
865
|
const match = actual === null || actual === void 0 ? void 0 : actual.filter((h) => this._deepEqual(h.range, r.range));
|
@@ -842,11 +884,11 @@ class TestState {
|
|
842
884
|
if (!this.program.getSourceFileInfo(fileName)) {
|
843
885
|
const file = this.testData.files.find((v) => v.fileName === fileName);
|
844
886
|
if (file) {
|
845
|
-
this.program.setFileOpened(fileName, file.version,
|
887
|
+
this.program.setFileOpened(fileName, file.version, file.content);
|
846
888
|
}
|
847
889
|
}
|
848
890
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
849
|
-
const actual = this.program
|
891
|
+
const actual = new definitionProvider_1.DefinitionProvider(this.program, fileName, position, filter, vscode_languageserver_1.CancellationToken.None).getDefinitions();
|
850
892
|
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}"`);
|
851
893
|
for (const r of expected) {
|
852
894
|
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}`);
|
@@ -864,7 +906,7 @@ class TestState {
|
|
864
906
|
}
|
865
907
|
const expected = map[name].definitions;
|
866
908
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
867
|
-
const actual = this.program
|
909
|
+
const actual = new definitionProvider_1.TypeDefinitionProvider(this.program, fileName, position, vscode_languageserver_1.CancellationToken.None).getDefinitions();
|
868
910
|
assert_1.default.strictEqual((_a = actual === null || actual === void 0 ? void 0 : actual.length) !== null && _a !== void 0 ? _a : 0, expected.length, name);
|
869
911
|
for (const r of expected) {
|
870
912
|
assert_1.default.strictEqual(actual === null || actual === void 0 ? void 0 : actual.filter((d) => this._deepEqual(d, r)).length, 1, name);
|
@@ -897,6 +939,86 @@ class TestState {
|
|
897
939
|
resetCancelled() {
|
898
940
|
this._cancellationToken.resetCancelled();
|
899
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
|
+
}
|
900
1022
|
_convertGlobalOptionsToConfigOptions(projectRoot, mountPaths) {
|
901
1023
|
const configOptions = new configOptions_1.ConfigOptions(projectRoot);
|
902
1024
|
// add more global options as we need them
|
@@ -928,25 +1050,6 @@ class TestState {
|
|
928
1050
|
}
|
929
1051
|
return configOptions;
|
930
1052
|
}
|
931
|
-
getFileContent(fileName) {
|
932
|
-
const files = this.testData.files.filter((f) => (0, pathUtils_1.comparePaths)(f.fileName, fileName, this.testFS.ignoreCase) === 0 /* EqualTo */);
|
933
|
-
return files[0].content;
|
934
|
-
}
|
935
|
-
convertPositionToOffset(fileName, position) {
|
936
|
-
const lines = this._getTextRangeCollection(fileName);
|
937
|
-
return (0, positionUtils_1.convertPositionToOffset)(position, lines);
|
938
|
-
}
|
939
|
-
convertOffsetToPosition(fileName, offset) {
|
940
|
-
const lines = this._getTextRangeCollection(fileName);
|
941
|
-
return (0, positionUtils_1.convertOffsetToPosition)(offset, lines);
|
942
|
-
}
|
943
|
-
convertOffsetsToRange(fileName, startOffset, endOffset) {
|
944
|
-
const lines = this._getTextRangeCollection(fileName);
|
945
|
-
return {
|
946
|
-
start: (0, positionUtils_1.convertOffsetToPosition)(startOffset, lines),
|
947
|
-
end: (0, positionUtils_1.convertOffsetToPosition)(endOffset, lines),
|
948
|
-
};
|
949
|
-
}
|
950
1053
|
_getParseResult(fileName) {
|
951
1054
|
const file = this.program.getBoundSourceFile(fileName);
|
952
1055
|
return file.getParseResults();
|
@@ -960,9 +1063,6 @@ class TestState {
|
|
960
1063
|
const tokenizer = new tokenizer_1.Tokenizer();
|
961
1064
|
return tokenizer.tokenize(fileContents).lines;
|
962
1065
|
}
|
963
|
-
raiseError(message) {
|
964
|
-
throw new Error(this._messageAtLastKnownMarker(message));
|
965
|
-
}
|
966
1066
|
_messageAtLastKnownMarker(message) {
|
967
1067
|
const locationDescription = this.lastKnownMarker
|
968
1068
|
? this.lastKnownMarker
|
@@ -990,43 +1090,6 @@ class TestState {
|
|
990
1090
|
_removeWhitespace(text) {
|
991
1091
|
return text.replace(/\s/g, '');
|
992
1092
|
}
|
993
|
-
createMultiMap(values, getKey) {
|
994
|
-
const map = new Map();
|
995
|
-
map.add = multiMapAdd;
|
996
|
-
map.remove = multiMapRemove;
|
997
|
-
if (values && getKey) {
|
998
|
-
for (const value of values) {
|
999
|
-
map.add(getKey(value), value);
|
1000
|
-
}
|
1001
|
-
}
|
1002
|
-
return map;
|
1003
|
-
function multiMapAdd(key, value) {
|
1004
|
-
let values = this.get(key);
|
1005
|
-
if (values) {
|
1006
|
-
values.push(value);
|
1007
|
-
}
|
1008
|
-
else {
|
1009
|
-
this.set(key, (values = [value]));
|
1010
|
-
}
|
1011
|
-
return values;
|
1012
|
-
}
|
1013
|
-
function multiMapRemove(key, value) {
|
1014
|
-
const values = this.get(key);
|
1015
|
-
if (values) {
|
1016
|
-
values.forEach((v, i, arr) => {
|
1017
|
-
if (v === value) {
|
1018
|
-
arr.splice(i, 1);
|
1019
|
-
}
|
1020
|
-
});
|
1021
|
-
if (!values.length) {
|
1022
|
-
this.delete(key);
|
1023
|
-
}
|
1024
|
-
}
|
1025
|
-
}
|
1026
|
-
}
|
1027
|
-
_rangeText({ fileName, pos, end }) {
|
1028
|
-
return this.getFileContent(fileName).slice(pos, end);
|
1029
|
-
}
|
1030
1093
|
_getOnlyRange() {
|
1031
1094
|
const ranges = this.getRanges();
|
1032
1095
|
if (ranges.length !== 1) {
|
@@ -1144,12 +1207,6 @@ class TestState {
|
|
1144
1207
|
// If inside the edit, return -1 to mark as invalid
|
1145
1208
|
return position <= editStart ? position : position < editEnd ? -1 : position + length - +(editEnd - editStart);
|
1146
1209
|
}
|
1147
|
-
analyze() {
|
1148
|
-
while (this.program.analyze()) {
|
1149
|
-
// Continue to call analyze until it completes. Since we're not
|
1150
|
-
// specifying a timeout, it should complete the first time.
|
1151
|
-
}
|
1152
|
-
}
|
1153
1210
|
_getDiagnosticsPerFile() {
|
1154
1211
|
const sourceFiles = this._files.map((f) => this.program.getSourceFile(f));
|
1155
1212
|
const results = sourceFiles.map((sourceFile, index) => {
|
@@ -1257,21 +1314,6 @@ class TestState {
|
|
1257
1314
|
this.raiseError(`doesn't contain expected result: ${(0, utils_1.stringify)(extra)}, actual: ${(0, utils_1.stringify)(left)}`);
|
1258
1315
|
}
|
1259
1316
|
}
|
1260
|
-
verifyCompletionItem(expected, actual) {
|
1261
|
-
var _a, _b, _c;
|
1262
|
-
assert_1.default.strictEqual(actual.label, expected.label);
|
1263
|
-
assert_1.default.strictEqual(actual.detail, expected.detail);
|
1264
|
-
assert_1.default.strictEqual(actual.kind, expected.kind);
|
1265
|
-
assert_1.default.strictEqual(actual.insertText, expected.insertionText);
|
1266
|
-
this._verifyEdit(actual.textEdit, expected.textEdit);
|
1267
|
-
this._verifyEdits(actual.additionalTextEdits, expected.additionalTextEdits);
|
1268
|
-
if (expected.detailDescription !== undefined) {
|
1269
|
-
assert_1.default.strictEqual((_a = actual.labelDetails) === null || _a === void 0 ? void 0 : _a.description, expected.detailDescription);
|
1270
|
-
}
|
1271
|
-
if (expected.commitCharacters !== undefined) {
|
1272
|
-
expect(expected.commitCharacters.sort()).toEqual((_c = (_b = actual.commitCharacters) === null || _b === void 0 ? void 0 : _b.sort()) !== null && _c !== void 0 ? _c : []);
|
1273
|
-
}
|
1274
|
-
}
|
1275
1317
|
}
|
1276
1318
|
exports.TestState = TestState;
|
1277
1319
|
function parseAndGetTestState(code, projectRoot = '/', anonymousFileName = 'unnamedFile.py', testFS) {
|