@zzzen/pyright-internal 1.2.0-dev.20241215 → 1.2.0-dev.20241229
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/analysis.js +1 -1
- package/dist/analyzer/analysis.js.map +1 -1
- package/dist/analyzer/analyzerNodeInfo.js +17 -18
- package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.js +18 -35
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +38 -55
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +146 -185
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +24 -31
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +23 -24
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constraintTracker.js +1 -2
- package/dist/analyzer/constraintTracker.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +10 -12
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js +14 -19
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +27 -26
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/declarationUtils.js +8 -11
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.js +2 -3
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +6 -8
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/enums.js +12 -13
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/functionTransform.js +1 -2
- package/dist/analyzer/functionTransform.js.map +1 -1
- package/dist/analyzer/importResolver.js +18 -27
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importStatementUtils.js +4 -5
- package/dist/analyzer/importStatementUtils.js.map +1 -1
- package/dist/analyzer/namedTuples.js +6 -7
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +14 -17
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.js +35 -39
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parameterUtils.js +5 -7
- package/dist/analyzer/parameterUtils.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.js +8 -9
- package/dist/analyzer/parentDirectoryCache.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +30 -44
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/parseTreeWalker.js +2 -3
- package/dist/analyzer/parseTreeWalker.js.map +1 -1
- package/dist/analyzer/patternMatching.js +11 -20
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.js +29 -40
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +7 -8
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +21 -23
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +1 -1
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/scope.js +10 -10
- package/dist/analyzer/scope.js.map +1 -1
- package/dist/analyzer/service.js +32 -47
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.js +21 -26
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfo.js +2 -3
- package/dist/analyzer/sourceFileInfo.js.map +1 -1
- package/dist/analyzer/sourceFileInfoUtils.js +5 -5
- package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
- package/dist/analyzer/sourceMapper.js +19 -30
- package/dist/analyzer/sourceMapper.js.map +1 -1
- package/dist/analyzer/testWalker.js +1 -2
- package/dist/analyzer/testWalker.js.map +1 -1
- package/dist/analyzer/tracePrinter.js +7 -9
- package/dist/analyzer/tracePrinter.js.map +1 -1
- package/dist/analyzer/tuples.js +11 -13
- package/dist/analyzer/tuples.js.map +1 -1
- package/dist/analyzer/typeCacheUtils.js +5 -6
- package/dist/analyzer/typeCacheUtils.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.js +7 -11
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +628 -780
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -1
- package/dist/analyzer/typeEvaluatorWithTracker.js +2 -2
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
- package/dist/analyzer/typeGuards.js +26 -36
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +15 -24
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeStubWriter.js +1 -2
- package/dist/analyzer/typeStubWriter.js.map +1 -1
- package/dist/analyzer/typeUtils.js +65 -94
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeWalker.js +4 -8
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/typedDicts.js +39 -46
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.js +64 -103
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysis.js +2 -3
- package/dist/backgroundAnalysis.js.map +1 -1
- package/dist/backgroundAnalysisBase.js +9 -10
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.js +6 -7
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/commands/createTypeStub.js +1 -1
- package/dist/commands/createTypeStub.js.map +1 -1
- package/dist/commands/dumpFileDebugInfoCommand.js +3 -3
- package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
- package/dist/commands/quickActionCommand.js +1 -1
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/common/asyncInitialization.js +1 -1
- package/dist/common/chokidarFileWatcherProvider.js +2 -4
- package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
- package/dist/common/configOptions.js +9 -9
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/console.js +1 -2
- package/dist/common/console.js.map +1 -1
- package/dist/common/core.js +2 -2
- package/dist/common/core.js.map +1 -1
- package/dist/common/crypto.js +1 -1
- package/dist/common/crypto.js.map +1 -1
- package/dist/common/diagnostic.js +3 -5
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/envVarUtils.js +1 -1
- package/dist/common/envVarUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +1 -0
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileSystem.d.ts +1 -0
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/fullAccessHost.js +5 -5
- package/dist/common/fullAccessHost.js.map +1 -1
- package/dist/common/host.js +1 -1
- package/dist/common/host.js.map +1 -1
- package/dist/common/logTracker.js +1 -1
- package/dist/common/logTracker.js.map +1 -1
- package/dist/common/lspUtils.js +1 -2
- package/dist/common/lspUtils.js.map +1 -1
- package/dist/common/progressReporter.js +1 -2
- package/dist/common/progressReporter.js.map +1 -1
- package/dist/common/realFileSystem.js +2 -3
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.js +1 -1
- package/dist/common/serviceProvider.js.map +1 -1
- package/dist/common/textEditTracker.js +4 -6
- package/dist/common/textEditTracker.js.map +1 -1
- package/dist/common/tomlUtils.js +3 -1
- package/dist/common/tomlUtils.js.map +1 -1
- package/dist/common/uri/baseUri.js +1 -1
- package/dist/common/uri/baseUri.js.map +1 -1
- package/dist/common/uri/emptyUri.js +1 -1
- package/dist/common/uri/emptyUri.js.map +1 -1
- package/dist/common/uri/fileUri.js +2 -2
- package/dist/common/uri/fileUri.js.map +1 -1
- package/dist/common/uri/memoization.js +1 -1
- package/dist/common/uri/memoization.js.map +1 -1
- package/dist/common/uri/uri.js +2 -3
- package/dist/common/uri/uri.js.map +1 -1
- package/dist/common/uri/uriUtils.js +6 -8
- package/dist/common/uri/uriUtils.js.map +1 -1
- package/dist/common/uri/webUri.js +2 -2
- package/dist/common/uri/webUri.js.map +1 -1
- package/dist/common/workspaceEditUtils.js +10 -15
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.js +34 -42
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +8 -10
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/autoImporter.js +16 -19
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +6 -11
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +81 -106
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.js +3 -3
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.js +6 -9
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolCollector.js +32 -32
- package/dist/languageService/documentSymbolCollector.js.map +1 -1
- package/dist/languageService/dynamicFeature.js +1 -2
- package/dist/languageService/dynamicFeature.js.map +1 -1
- package/dist/languageService/hoverProvider.js +17 -23
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/referencesProvider.js +4 -9
- package/dist/languageService/referencesProvider.js.map +1 -1
- package/dist/languageService/renameProvider.js +2 -4
- package/dist/languageService/renameProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +11 -15
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.js +15 -17
- package/dist/languageService/tooltipUtils.js.map +1 -1
- package/dist/localization/localize.js +3 -3
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +6 -0
- package/dist/localization/package.nls.de.json +6 -0
- package/dist/localization/package.nls.en-us.json +8 -8
- package/dist/localization/package.nls.es.json +6 -0
- package/dist/localization/package.nls.fr.json +7 -1
- package/dist/localization/package.nls.it.json +6 -0
- package/dist/localization/package.nls.ja.json +6 -0
- package/dist/localization/package.nls.ko.json +6 -0
- package/dist/localization/package.nls.pl.json +6 -0
- package/dist/localization/package.nls.pt-br.json +6 -0
- package/dist/localization/package.nls.qps-ploc.json +6 -0
- package/dist/localization/package.nls.ru.json +6 -0
- package/dist/localization/package.nls.tr.json +6 -0
- package/dist/localization/package.nls.zh-cn.json +6 -0
- package/dist/localization/package.nls.zh-tw.json +6 -0
- package/dist/parser/parser.js +30 -38
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/tokenizer.js +8 -13
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/pprof/profiler.js +3 -3
- package/dist/pprof/profiler.js.map +1 -1
- package/dist/pyright.js +5 -7
- package/dist/pyright.js.map +1 -1
- package/dist/pyrightFileSystem.js +4 -5
- package/dist/pyrightFileSystem.js.map +1 -1
- package/dist/readonlyAugmentedFileSystem.js +3 -5
- package/dist/readonlyAugmentedFileSystem.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +3 -3
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/classDeclaration.test.js +7 -10
- package/dist/tests/classDeclaration.test.js.map +1 -1
- package/dist/tests/completions.test.js +3 -3
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +10 -17
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/diagnosticOverrides.test.js +4 -6
- package/dist/tests/diagnosticOverrides.test.js.map +1 -1
- package/dist/tests/envVarUtils.test.js +9 -12
- package/dist/tests/envVarUtils.test.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.js +45 -60
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +6 -7
- package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.js +3 -3
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/importResolver.test.js +6 -7
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/importStatementUtils.test.js +2 -2
- package/dist/tests/importStatementUtils.test.js.map +1 -1
- package/dist/tests/ipythonMode.test.js +11 -12
- package/dist/tests/ipythonMode.test.js.map +1 -1
- package/dist/tests/languageServer.test.js +1 -2
- package/dist/tests/languageServer.test.js.map +1 -1
- package/dist/tests/lsp/languageServer.js +10 -14
- package/dist/tests/lsp/languageServer.js.map +1 -1
- package/dist/tests/lsp/languageServerTestUtils.js +10 -14
- package/dist/tests/lsp/languageServerTestUtils.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +7 -7
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/parser.test.js +2 -2
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/service.test.js +2 -3
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +2 -3
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/sourceMapperUtils.test.js +3 -4
- package/dist/tests/sourceMapperUtils.test.js.map +1 -1
- package/dist/tests/testState.test.js +3 -6
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testStateUtils.js +3 -4
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js +2 -2
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +1 -1
- package/dist/tests/typeEvaluator4.test.js +4 -0
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typePrinter.test.js +1 -2
- package/dist/tests/typePrinter.test.js.map +1 -1
- package/dist/tests/workspaceEditUtils.test.js +3 -5
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/workspaceFactory.js +2 -3
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +1 -1
@@ -100,12 +100,13 @@ class TestState {
|
|
100
100
|
const vfsInfo = (0, testStateUtils_1.createVfsInfoFromFourSlashData)(projectRoot, testData);
|
101
101
|
this._vfsFiles = vfsInfo.files;
|
102
102
|
this.testFS =
|
103
|
-
testFS
|
103
|
+
testFS ??
|
104
|
+
(0, factory_1.createFromFileSystem)(host.HOST, vfsInfo.ignoreCase, { cwd: vfsInfo.projectRoot, files: vfsInfo.files, meta: testData.globalOptions }, mountPaths);
|
104
105
|
this.fs = new pyrightFileSystem_1.PyrightFileSystem(this.testFS);
|
105
106
|
this.console = new console_1.ConsoleWithLogLevel(new console_1.NullConsole(), 'test');
|
106
107
|
this.serviceProvider = (0, serviceProviderExtensions_1.createServiceProvider)(this.testFS, this.fs, this.console);
|
107
108
|
this._cancellationToken = new fourSlashTypes_1.TestCancellationToken();
|
108
|
-
this._hostSpecificFeatures = hostSpecificFeatures
|
109
|
+
this._hostSpecificFeatures = hostSpecificFeatures ?? new testLanguageService_1.TestFeatures();
|
109
110
|
this.files = vfsInfo.sourceFileNames;
|
110
111
|
this.rawConfigJson = vfsInfo.rawConfigJson;
|
111
112
|
const configOptions = this._convertGlobalOptionsToConfigOptions(vfsInfo.projectRoot, mountPaths);
|
@@ -151,15 +152,14 @@ class TestState {
|
|
151
152
|
return this.getFileContent(this.activeFile.fileName).length;
|
152
153
|
}
|
153
154
|
initializeFiles() {
|
154
|
-
var _a, _b;
|
155
155
|
if (this.files.length > 0) {
|
156
156
|
// Open the first file by default
|
157
157
|
this.openFile(this.files[0]);
|
158
158
|
}
|
159
159
|
for (const filePath of this.files) {
|
160
160
|
const file = this._vfsFiles[filePath];
|
161
|
-
if (
|
162
|
-
|
161
|
+
if (file.meta?.["ipythonmode" /* MetadataOptionNames.ipythonMode */]) {
|
162
|
+
this.program.getSourceFile(uri_1.Uri.file(filePath, this.serviceProvider))?.test_enableIPythonMode(true);
|
163
163
|
}
|
164
164
|
}
|
165
165
|
}
|
@@ -300,7 +300,7 @@ class TestState {
|
|
300
300
|
return result;
|
301
301
|
}
|
302
302
|
getFilteredRanges(predicate) {
|
303
|
-
return this.getRanges().filter((r) =>
|
303
|
+
return this.getRanges().filter((r) => predicate(r.marker, r.marker?.data, this.rangeText(r)));
|
304
304
|
}
|
305
305
|
getRangeByMarkerName(markerName) {
|
306
306
|
return (0, testStateUtils_1.getRangeByMarkerName)(this.testData, markerName);
|
@@ -486,7 +486,6 @@ class TestState {
|
|
486
486
|
}
|
487
487
|
}
|
488
488
|
async verifyCodeActions(verifyMode, map) {
|
489
|
-
var _a, _b;
|
490
489
|
// make sure we don't use cache built from other tests
|
491
490
|
this.workspace.service.invalidateAndForceReanalysis(backgroundAnalysisProgram_1.InvalidatedReason.Reanalyzed);
|
492
491
|
this.analyze();
|
@@ -540,7 +539,7 @@ class TestState {
|
|
540
539
|
const sourceFile = this.program.getSourceFile(uri);
|
541
540
|
const symbolsInTest2 = sourceFile
|
542
541
|
? ', symbols in test2.py: ' +
|
543
|
-
Array.from(
|
542
|
+
Array.from(sourceFile.getModuleSymbolTable()?.keys() ?? []).join(',')
|
544
543
|
: '';
|
545
544
|
this.raiseError(`doesn't contain expected result: ${(0, utils_1.stringify)(expected)}, actual: ${(0, utils_1.stringify)(codeActions)}, diagnostics: ${(0, utils_1.stringify)(diagnostics)}${symbolsInTest2}`);
|
546
545
|
}
|
@@ -558,7 +557,7 @@ class TestState {
|
|
558
557
|
}
|
559
558
|
}
|
560
559
|
}
|
561
|
-
return args
|
560
|
+
return args?.map((a) => {
|
562
561
|
if ((0, core_1.isString)(a)) {
|
563
562
|
// Might be a URI. For comparison purposes in a test, convert it into a
|
564
563
|
// file path.
|
@@ -572,10 +571,9 @@ class TestState {
|
|
572
571
|
}
|
573
572
|
}
|
574
573
|
async verifyCommand(command, files) {
|
575
|
-
var _a;
|
576
574
|
this.analyze();
|
577
575
|
// Convert command arguments to file Uri strings. That's the expected input for command arguments.
|
578
|
-
const convertedArgs =
|
576
|
+
const convertedArgs = command.arguments?.map((arg) => {
|
579
577
|
if (typeof arg === 'string' && (arg.endsWith('.py') || arg.endsWith('.pyi'))) {
|
580
578
|
return uri_1.Uri.file(arg, this.serviceProvider).toString();
|
581
579
|
}
|
@@ -604,7 +602,6 @@ class TestState {
|
|
604
602
|
return (0, workspaceEditTestUtils_1.verifyWorkspaceEdit)(expected, actual, marker);
|
605
603
|
}
|
606
604
|
async verifyInvokeCodeAction(map, verifyCodeActionCount) {
|
607
|
-
var _a;
|
608
605
|
this.analyze();
|
609
606
|
for (const range of this.getRanges()) {
|
610
607
|
const name = this.getMarkerName(range.marker);
|
@@ -625,7 +622,7 @@ class TestState {
|
|
625
622
|
for (const codeAction of matches) {
|
626
623
|
const results = await this._hostSpecificFeatures.execute(ls, {
|
627
624
|
command: codeAction.command.command,
|
628
|
-
arguments:
|
625
|
+
arguments: codeAction.command?.arguments || [],
|
629
626
|
}, vscode_languageserver_1.CancellationToken.None);
|
630
627
|
if (map[name].edits) {
|
631
628
|
const workspaceEdits = commandResult_1.CommandResult.is(results) ? results.edits : results;
|
@@ -770,7 +767,6 @@ class TestState {
|
|
770
767
|
}
|
771
768
|
}
|
772
769
|
verifySignature(docFormat, map) {
|
773
|
-
var _a, _b;
|
774
770
|
this.analyze();
|
775
771
|
for (const marker of this.getMarkers()) {
|
776
772
|
const fileName = marker.fileName;
|
@@ -813,14 +809,13 @@ class TestState {
|
|
813
809
|
});
|
814
810
|
assert_1.default.deepEqual(actual.signatures.map((sig) => sig.activeParameter), expected.activeParameters);
|
815
811
|
if (expected.callHasParameters !== undefined) {
|
816
|
-
const isActive = (sig) =>
|
817
|
-
const activeSignature =
|
812
|
+
const isActive = (sig) => !expected.callHasParameters && !sig.parameters?.length;
|
813
|
+
const activeSignature = expected.signatures?.findIndex(isActive) ?? undefined;
|
818
814
|
assert_1.default.equal(actual.activeSignature, activeSignature);
|
819
815
|
}
|
820
816
|
}
|
821
817
|
}
|
822
818
|
verifyFindAllReferences(map, createDocumentRange, convertToLocation) {
|
823
|
-
var _a;
|
824
819
|
this.analyze();
|
825
820
|
for (const name of this.getMarkerNames()) {
|
826
821
|
const marker = this.getMarkerByName(name);
|
@@ -830,22 +825,20 @@ class TestState {
|
|
830
825
|
}
|
831
826
|
let expected = map[name].references;
|
832
827
|
expected = expected.map((c) => {
|
833
|
-
var _a;
|
834
828
|
return {
|
835
829
|
...c,
|
836
|
-
uri:
|
830
|
+
uri: c.uri ?? uri_1.Uri.file(c.path, this.serviceProvider),
|
837
831
|
};
|
838
832
|
});
|
839
833
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
840
834
|
const actual = new referencesProvider_1.ReferencesProvider(this.program, vscode_languageserver_1.CancellationToken.None, createDocumentRange, convertToLocation).reportReferences(uri_1.Uri.file(fileName, this.serviceProvider), position, /* includeDeclaration */ true);
|
841
|
-
assert_1.default.strictEqual(
|
835
|
+
assert_1.default.strictEqual(actual?.length ?? 0, expected.length, `${name} has failed`);
|
842
836
|
for (const r of (0, navigationUtils_1.convertDocumentRangesToLocation)(this.program.fileSystem, expected, convertToLocation)) {
|
843
|
-
assert_1.default.equal(actual
|
837
|
+
assert_1.default.equal(actual?.filter((d) => this._deepEqual(d, r)).length, 1);
|
844
838
|
}
|
845
839
|
}
|
846
840
|
}
|
847
841
|
verifyShowCallHierarchyGetIncomingCalls(map) {
|
848
|
-
var _a, _b, _c;
|
849
842
|
this.analyze();
|
850
843
|
for (const marker of this.getMarkers()) {
|
851
844
|
const fileName = marker.fileName;
|
@@ -858,20 +851,19 @@ class TestState {
|
|
858
851
|
const expectedName = map[name].items.map((x) => x.name);
|
859
852
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
860
853
|
const actual = new callHierarchyProvider_1.CallHierarchyProvider(this.program, uri_1.Uri.file(fileName, this.serviceProvider), position, vscode_languageserver_1.CancellationToken.None).getIncomingCalls();
|
861
|
-
assert_1.default.strictEqual(
|
862
|
-
assert_1.default.strictEqual(
|
863
|
-
assert_1.default.strictEqual(
|
854
|
+
assert_1.default.strictEqual(actual?.length ?? 0, expectedFilePath.length, `${name} has failed`);
|
855
|
+
assert_1.default.strictEqual(actual?.length ?? 0, expectedRange.length, `${name} has failed`);
|
856
|
+
assert_1.default.strictEqual(actual?.length ?? 0, expectedName.length, `${name} has failed`);
|
864
857
|
if (actual) {
|
865
858
|
for (const a of actual) {
|
866
|
-
assert_1.default.strictEqual(expectedRange
|
867
|
-
assert_1.default.strictEqual(expectedName
|
868
|
-
assert_1.default.ok(
|
859
|
+
assert_1.default.strictEqual(expectedRange?.filter((e) => this._deepEqual(a.from.range, e)).length, 1);
|
860
|
+
assert_1.default.strictEqual(expectedName?.filter((e) => this._deepEqual(a.from.name, e)).length, 1);
|
861
|
+
assert_1.default.ok(expectedFilePath?.filter((e) => this._deepEqual(a.from.uri, uri_1.Uri.file(e, this.serviceProvider).toString())).length >= 1);
|
869
862
|
}
|
870
863
|
}
|
871
864
|
}
|
872
865
|
}
|
873
866
|
verifyShowCallHierarchyGetOutgoingCalls(map) {
|
874
|
-
var _a, _b, _c;
|
875
867
|
this.analyze();
|
876
868
|
for (const marker of this.getMarkers()) {
|
877
869
|
const fileName = marker.fileName;
|
@@ -884,20 +876,20 @@ class TestState {
|
|
884
876
|
const expectedName = map[name].items.map((x) => x.name);
|
885
877
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
886
878
|
const actual = new callHierarchyProvider_1.CallHierarchyProvider(this.program, uri_1.Uri.file(fileName, this.serviceProvider), position, vscode_languageserver_1.CancellationToken.None).getOutgoingCalls();
|
887
|
-
assert_1.default.strictEqual(
|
888
|
-
assert_1.default.strictEqual(
|
889
|
-
assert_1.default.strictEqual(
|
879
|
+
assert_1.default.strictEqual(actual?.length ?? 0, expectedFilePath.length, `${name} has failed`);
|
880
|
+
assert_1.default.strictEqual(actual?.length ?? 0, expectedRange.length, `${name} has failed`);
|
881
|
+
assert_1.default.strictEqual(actual?.length ?? 0, expectedName.length, `${name} has failed`);
|
890
882
|
if (actual) {
|
891
883
|
for (const a of actual) {
|
892
|
-
assert_1.default.strictEqual(expectedRange
|
893
|
-
assert_1.default.strictEqual(expectedName
|
894
|
-
assert_1.default.ok(
|
884
|
+
assert_1.default.strictEqual(expectedRange?.filter((e) => this._deepEqual(a.to.range, e)).length, 1);
|
885
|
+
assert_1.default.strictEqual(expectedName?.filter((e) => this._deepEqual(a.to.name, e)).length, 1);
|
886
|
+
assert_1.default.ok(expectedFilePath?.filter((e) => this._deepEqual(a.to.uri, uri_1.Uri.file(e, this.serviceProvider).toString())).length >= 1);
|
895
887
|
}
|
896
888
|
}
|
897
889
|
}
|
898
890
|
}
|
899
891
|
getDocumentHighlightKind(m) {
|
900
|
-
const kind =
|
892
|
+
const kind = m?.data ? m.data.kind : undefined;
|
901
893
|
switch (kind) {
|
902
894
|
case 'text':
|
903
895
|
return vscode_languageserver_1.DocumentHighlightKind.Text;
|
@@ -910,7 +902,6 @@ class TestState {
|
|
910
902
|
}
|
911
903
|
}
|
912
904
|
verifyHighlightReferences(map) {
|
913
|
-
var _a;
|
914
905
|
this.analyze();
|
915
906
|
for (const name of Object.keys(map)) {
|
916
907
|
const marker = this.getMarkerByName(name);
|
@@ -918,10 +909,10 @@ class TestState {
|
|
918
909
|
const expected = map[name].references;
|
919
910
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
920
911
|
const actual = new documentHighlightProvider_1.DocumentHighlightProvider(this.program, uri_1.Uri.file(fileName, this.serviceProvider), position, vscode_languageserver_1.CancellationToken.None).getDocumentHighlight();
|
921
|
-
assert_1.default.equal(
|
912
|
+
assert_1.default.equal(actual?.length ?? 0, expected.length);
|
922
913
|
for (const r of expected) {
|
923
|
-
const match = actual
|
924
|
-
assert_1.default.equal(match
|
914
|
+
const match = actual?.filter((h) => this._deepEqual(h.range, r.range));
|
915
|
+
assert_1.default.equal(match?.length, 1);
|
925
916
|
if (r.kind) {
|
926
917
|
assert_1.default.equal(match[0].kind, r.kind);
|
927
918
|
}
|
@@ -929,7 +920,7 @@ class TestState {
|
|
929
920
|
}
|
930
921
|
}
|
931
922
|
fixupDefinitionsToMatchExpected(actual) {
|
932
|
-
return actual
|
923
|
+
return actual?.map((a) => {
|
933
924
|
const { uri, ...restOfActual } = a;
|
934
925
|
return {
|
935
926
|
...restOfActual,
|
@@ -938,7 +929,6 @@ class TestState {
|
|
938
929
|
});
|
939
930
|
}
|
940
931
|
verifyFindDefinitions(map, filter = definitionProvider_1.DefinitionFilter.All) {
|
941
|
-
var _a;
|
942
932
|
this.analyze();
|
943
933
|
for (const marker of this.getMarkers()) {
|
944
934
|
const fileName = marker.fileName;
|
@@ -957,15 +947,14 @@ class TestState {
|
|
957
947
|
}
|
958
948
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
959
949
|
let actual = new definitionProvider_1.DefinitionProvider(this.program, uri, position, filter, vscode_languageserver_1.CancellationToken.None).getDefinitions();
|
960
|
-
assert_1.default.equal(
|
950
|
+
assert_1.default.equal(actual?.length ?? 0, expected.length, `No definitions found for marker "${name}"`);
|
961
951
|
actual = this.fixupDefinitionsToMatchExpected(actual);
|
962
952
|
for (const r of expected) {
|
963
|
-
assert_1.default.equal(actual
|
953
|
+
assert_1.default.equal(actual?.filter((d) => this._deepEqual(d, r)).length, 1, `No match found for ${JSON.stringify(r)} from marker ${name}`);
|
964
954
|
}
|
965
955
|
}
|
966
956
|
}
|
967
957
|
verifyFindTypeDefinitions(map) {
|
968
|
-
var _a;
|
969
958
|
this.analyze();
|
970
959
|
for (const marker of this.getMarkers()) {
|
971
960
|
const fileName = marker.fileName;
|
@@ -977,9 +966,9 @@ class TestState {
|
|
977
966
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
978
967
|
let actual = new definitionProvider_1.TypeDefinitionProvider(this.program, uri_1.Uri.file(fileName, this.serviceProvider), position, vscode_languageserver_1.CancellationToken.None).getDefinitions();
|
979
968
|
actual = this.fixupDefinitionsToMatchExpected(actual);
|
980
|
-
assert_1.default.strictEqual(
|
969
|
+
assert_1.default.strictEqual(actual?.length ?? 0, expected.length, name);
|
981
970
|
for (const r of expected) {
|
982
|
-
assert_1.default.strictEqual(actual
|
971
|
+
assert_1.default.strictEqual(actual?.filter((d) => this._deepEqual(d, r)).length, 1, name);
|
983
972
|
}
|
984
973
|
}
|
985
974
|
}
|
@@ -993,17 +982,16 @@ class TestState {
|
|
993
982
|
}
|
994
983
|
const expected = map[name];
|
995
984
|
expected.changes = expected.changes.map((c) => {
|
996
|
-
var _a;
|
997
985
|
return {
|
998
986
|
...c,
|
999
|
-
fileUri:
|
987
|
+
fileUri: c.fileUri ?? uri_1.Uri.file(c.filePath, this.serviceProvider),
|
1000
988
|
};
|
1001
989
|
});
|
1002
990
|
const position = this.convertOffsetToPosition(fileName, marker.position);
|
1003
991
|
const actual = new renameProvider_1.RenameProvider(this.program, isUntitled
|
1004
992
|
? uri_1.Uri.parse(`untitled:${fileName.replace(/\\/g, '/')}`, this.serviceProvider)
|
1005
993
|
: uri_1.Uri.file(fileName, this.serviceProvider), position, vscode_languageserver_1.CancellationToken.None).renameSymbol(expected.newName, /* isDefaultWorkspace */ false, isUntitled);
|
1006
|
-
(0, workspaceEditTestUtils_1.verifyWorkspaceEdit)((0, workspaceEditUtils_1.convertToWorkspaceEdit)(this.program.fileSystem, { edits: expected.changes, fileOperations: [] }), actual
|
994
|
+
(0, workspaceEditTestUtils_1.verifyWorkspaceEdit)((0, workspaceEditUtils_1.convertToWorkspaceEdit)(this.program.fileSystem, { edits: expected.changes, fileOperations: [] }), actual ?? { documentChanges: [] });
|
1007
995
|
}
|
1008
996
|
}
|
1009
997
|
verifyTypeVerifierResults(packageName, ignoreUnknownTypesFromImports, verboseOutput, expected) {
|
@@ -1129,7 +1117,6 @@ class TestState {
|
|
1129
1117
|
return this.getFileContent(fileName).slice(pos, end);
|
1130
1118
|
}
|
1131
1119
|
verifyCompletionItem(expected, actual) {
|
1132
|
-
var _a, _b, _c;
|
1133
1120
|
assert_1.default.strictEqual(actual.label, expected.label);
|
1134
1121
|
assert_1.default.strictEqual(actual.detail, expected.detail);
|
1135
1122
|
assert_1.default.strictEqual(actual.kind, expected.kind);
|
@@ -1137,10 +1124,10 @@ class TestState {
|
|
1137
1124
|
this._verifyEdit(actual.textEdit, expected.textEdit);
|
1138
1125
|
this._verifyEdits(actual.additionalTextEdits, expected.additionalTextEdits);
|
1139
1126
|
if (expected.detailDescription !== undefined) {
|
1140
|
-
assert_1.default.strictEqual(
|
1127
|
+
assert_1.default.strictEqual(actual.labelDetails?.description, expected.detailDescription);
|
1141
1128
|
}
|
1142
1129
|
if (expected.commitCharacters !== undefined) {
|
1143
|
-
expect(expected.commitCharacters.sort()).toEqual(
|
1130
|
+
expect(expected.commitCharacters.sort()).toEqual(actual.commitCharacters?.sort() ?? []);
|
1144
1131
|
}
|
1145
1132
|
}
|
1146
1133
|
_convertGlobalOptionsToConfigOptions(projectRoot, mountPaths) {
|
@@ -1176,12 +1163,11 @@ class TestState {
|
|
1176
1163
|
}
|
1177
1164
|
_getParserOutput(fileName) {
|
1178
1165
|
const file = this.program.getBoundSourceFile(uri_1.Uri.file(fileName, this.serviceProvider));
|
1179
|
-
return file
|
1166
|
+
return file?.getParseResults();
|
1180
1167
|
}
|
1181
1168
|
_getTextRangeCollection(fileName) {
|
1182
|
-
var _a;
|
1183
1169
|
if (this.files.includes(fileName)) {
|
1184
|
-
const tokenizerOutput =
|
1170
|
+
const tokenizerOutput = this._getParserOutput(fileName)?.tokenizerOutput;
|
1185
1171
|
if (tokenizerOutput) {
|
1186
1172
|
return tokenizerOutput.lines;
|
1187
1173
|
}
|
@@ -1201,12 +1187,11 @@ class TestState {
|
|
1201
1187
|
// blank for now
|
1202
1188
|
}
|
1203
1189
|
_editScriptAndUpdateMarkers(fileName, editStart, editEnd, newText) {
|
1204
|
-
var _a, _b;
|
1205
1190
|
let fileContent = this.getFileContent(fileName);
|
1206
1191
|
fileContent = fileContent.slice(0, editStart) + newText + fileContent.slice(editEnd);
|
1207
1192
|
const uri = uri_1.Uri.file(fileName, this.serviceProvider);
|
1208
1193
|
this.testFS.writeFileSync(uri, fileContent, 'utf8');
|
1209
|
-
const newVersion = (
|
1194
|
+
const newVersion = (this.program.getSourceFile(uri)?.getClientVersion() ?? -1) + 1;
|
1210
1195
|
this.program.setFileOpened(uri, newVersion, fileContent);
|
1211
1196
|
for (const marker of this.testData.markers) {
|
1212
1197
|
if (marker.fileName === fileName) {
|
@@ -1419,8 +1404,8 @@ class TestState {
|
|
1419
1404
|
}
|
1420
1405
|
}
|
1421
1406
|
_verifyEdits(actual, expected) {
|
1422
|
-
actual = actual
|
1423
|
-
expected = expected
|
1407
|
+
actual = actual ?? [];
|
1408
|
+
expected = expected ?? [];
|
1424
1409
|
let extra = expected.slice(0);
|
1425
1410
|
let left = actual.slice(0);
|
1426
1411
|
for (const item of actual) {
|